Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
ember-power-select-with-create
Advanced tools
Ember Power Select addon that allows creation of items.
Simple variation of ember-power-select that allows you to create a new entry based on the search text.
ember install ember-power-select-with-create
Please also refer to Ember Power Select documentation for it's compatibility notes.
<PowerSelectWithCreate
@options={{countries}}
@selected={{selectedCountry}}
@onChange={{action (mut selectedCountry)}}
@onCreate={{action "createCountry"}}
as |country|
>
{{country.name}}
</PowerSelectWithCreate>
If you want to be able to select multiple options, use the <PowerSelectMultipleWithCreate>
component instead. It has the same API as the normal <PowerSelectWithCreate>
.
For more options please refer to the Ember Power Select docs.
You can provide a callback showCreateWhen
, which will be called whenever the user types into the search field.
If you return true
, the create option will be shown. If you return false
, it won't be shown.
<PowerSelectWithCreate
@options={{countries}}
@searchField="name"
@selected={{selectedCountry}}
@onCreate={{action "createCountry"}}
@showCreateWhen={{action "hideCreateOptionOnSameName"}}
as |country|
>
{{country.name}}
</PowerSelectWithCreate>
import Component from '@ember/component';
import { action } from '@ember/object';
export default class MyComponent extends Component {
@action
hideCreateOptionOnSameName(term) {
let existingOption = this.countries.find(({ name }) => name === term);
return !existingOption;
}
}
You can provide showCreatePosition
property to control the position(bottom|top) of create option. It should be either "top"
or "bottom"
. It defaults to "top"
.
<PowerSelectWithCreate
@options={{countries}}
@searchField="name"
@selected={{selectedCountry}}
@onCreate={{action "createCountry"}}
@showCreatePosition="bottom"
@showCreateWhen={{action "hideCreateOptionOnSameName"}}
as |country|
>
{{country.name}}
</PowerSelectWithCreate>
Add "{{option}}"...
You can provide the buildSuggestion
action to control the label of the create option. Default - Add "{{option}}"...
<PowerSelectWithCreate
@options={{countries}}
@searchField="name"
@selected={{selectedCountry}}
@onCreate={{action "createCountry"}}
@buildSuggestion={{action "customSuggestion"}}
>
{{country.name}}
</PowerSelectWithCreate>
import Component from '@ember/component';
import { action } from '@ember/object';
export default class MyComponent extends Component {
@action
customSuggestion(term) {
return `Create ${term}`;
}
}
Beyond building the suggestion label, you can pass the suggestedOptionComponent
property, which should be a component, not a string to be embroider compatible.
This component will receive the suggestedOption itself as option
and the current term
as term
.
<PowerSelectWithCreate
@options={{countries}}
@searchField="name"
@selected={{selectedCountry}}
@onCreate={{action "createCountry"}}
@suggestedOptionComponent={{component (ensure-safe-component "suggested-option")}}
>
{{country.name}}
</PowerSelectWithCreate>
<!-- <SuggestedOption @option={{option}} @term={{term}} /> -->
<span class="is-suggested">
Add "{{term}}"...
</span>
<!-- </SuggestedOption> -->
FAQs
Ember Power Select addon that allows creation of items.
The npm package ember-power-select-with-create receives a total of 0 weekly downloads. As such, ember-power-select-with-create popularity was classified as not popular.
We found that ember-power-select-with-create demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.