Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins support? #24

Open
khalilgharbaoui opened this issue Nov 1, 2018 · 1 comment
Open

Plugins support? #24

khalilgharbaoui opened this issue Nov 1, 2018 · 1 comment

Comments

@khalilgharbaoui
Copy link

khalilgharbaoui commented Nov 1, 2018

How can we add support for these plugins?

https://flatpickr.js.org/plugins/#rangeplugin-beta

https://github.com/flatpickr/flatpickr/tree/master/src/plugins

I kind of solved it by importing for example the rangePlugin from flatpicker plugins folder:

 import rangePlugin from 'flatpickr/dist/plugins/rangePlugin.js'

And i used it in the config:

connect(){
  this.config = {
      mode: 'range', 
      plugins: [new rangePlugin({ input: "#secondRangeInput"})]
    }
  super.connect()
}

and then in the view i did:

<%= text_field_tag :starts_at, nil,
      placeholder: 'select',
      data: {
       // ...
        controller: 'flatpickr',
        flatpickr_mode: 'range',
       // ...
      } %>
<%= text_field_tag :ends_at, nil, id: 'secondRangeInput' %>

It works but i feel this should be part of the stimulus-flatpicker's api without having to import stuff.

Thanks,

Khalil Gharbaoui

@adrienpoly
Copy link
Owner

adrienpoly commented Nov 1, 2018

Hello

I haven’t documented this yet but what you ended up doing is how I would do it.
I am afraid that importing all plugins into the stimulus-flatpickr wrapper would increase the size with lots of unnecessary stuff.
Tree shaking would probably work for this but not everyone is using bundlers with tree shaking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants