Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cibernox/ember-power-select-with-fallback
Ember Power Select that fallbacks to a native select when certain criteria are met
https://github.com/cibernox/ember-power-select-with-fallback
Last synced: 2 months ago
JSON representation
Ember Power Select that fallbacks to a native select when certain criteria are met
- Host: GitHub
- URL: https://github.com/cibernox/ember-power-select-with-fallback
- Owner: cibernox
- License: mit
- Created: 2016-02-08T18:31:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-13T09:43:09.000Z (about 6 years ago)
- Last Synced: 2024-10-18T07:58:40.774Z (3 months ago)
- Language: JavaScript
- Homepage: https://ember-power-select-with-fallback.pagefrontapp.com/
- Size: 32.2 KB
- Stars: 10
- Watchers: 5
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ember-power-select-with-fallback
This is a addon on top Ember Power Select that based on some criteria decides if renders the rich `{{#power-select}}`
component or fallbacks to a simpler ``.This is particularly useful if you want to use native selects on iOS/Android devices, when
screen readers are detected, or any other criteria you decide.Take into account that since this components will try to fallback to a simple select, many features
availables in Ember Power Select won't work with the fallback.The component during development will try to warn you when you use some feature that cannot be safely
translated to a regular select. **TODO: Not done :trollface: ****Disclaimer:** This component is the fruit of 1h of work. I'm sure it can be greatly improved. PR welcomed.
## DEMO
[https://ember-power-select-with-fallback.pagefrontapp.com/](https://ember-power-select-with-fallback.pagefrontapp.com/)
## Installation
* `ember install ember-power-select-with-fallback`
## Usage
If your options are just strings, this component is a drop in replacement of ember-power-select.
```hbs
{{#power-select-with-fallback options=options selected=selected onchange=(action (mut selected)) as |opt|}}
{{opt}}
{{/power-select-with-fallback}}
```If your options are objects, you will need to pass a `labelPath` property to hint the component what
field should display when it fallback to the native component.```hbs
{{#power-select-with-fallback options=users selected=user onchange=(action (mut user)) labelPath="fullName" as |opt|}}
{{opt.fullName}}
{{/power-select-with-fallback}}
```If you by default you will see that non of the previous examples is displayed as a native select. Why?
Because fallback to native is an opt-in behaviour.You can either pass `mustFallback=` to customize this behaviour:
```hbs
{{#power-select-with-fallback mustFallback=true options=options selected=selected onchange=(action (mut selected)) as |opt|}}
{{opt}}
{{/power-select-with-fallback}}
```or, more likely, specify a fallback strategy, with `fallback-when=`.
There is 4 fallback strategies included in the component:* `ios`: Fallbacks only in ios devices.
* `android`: Fallbacks only in android devices.
* `windows-phone`: Fallbacks only in windows phones.
* `mobile`: Fallbacks in any of the previous cases.```hbs
{{#power-select-with-fallback fallback-when="mobile" options=options selected=selected onchange=(action (mut selected)) as |opt|}}
{{opt}}
{{/power-select-with-fallback}}
```## Known limitations
* All the options must be available upfront. You cannot populate options using the `search` action.
* Accepts nested groups up to 1 level deep.## Upcoming features
* Implement some developer warnings that make very clear to the users that they're using some functionality
that cannot be translated.* Support passing a promise that resolves to a collection as `options`. The component should be disabled
until that promise resolves.* Fallback multiple select too.