Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
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 4,239 weekly downloads. As such, ember-power-select-with-create popularity was classified as 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.