Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ muqube:autoform-nouislider

`meteor add muqube:autoform-nouislider`

There are two ways to import the package: dynamic and static.
The default way is dynamic, where you import a function, containing a dynamic import.
This prevents this package from being added to the initial client bundle and allows
you to import it only at that point when it's really required.

```js
import loadAfNoUiSlider from 'meteor/muqube:autoform-nouislider'

// This is only an example of how to reactively track
// if the extension has been loaded.
// You can, of course, track it anyway you want!
Template.myTemplate.onCreated(async function () {
const instance = this
instance.state = new ReactiveDict()
await loadAfNoUiSlider.default()
instance.state.set('afNoUiSliderLoaded', true)
})
```

If you really need this package being added to the initial bundle, thus being present at
startup time, then you should use the static import:

```javascript
import 'meteor/muqube:autoform-nouislider/static'
```

## Configuration
Adds the `noUiSlider` type to [autoform](https://github.com/aldeed/meteor-autoform). It uses `min`, `max`, and `step` attributes like a normal slider, so it can be a drop in replacement, but options passed as `noUiSliderOptions` are passed directly to [nouislider](http://refreshless.com/nouislider/) for advanced control.

Expand Down
2 changes: 1 addition & 1 deletion autoform-nouislider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global AutoForm, Template */

import noUiSlider from 'nouislider'
import 'nouislider/distribute/nouislider.css'
import './autoform-nouislider.css'
import './autoform-nouislider.html'

AutoForm.addInputType('noUiSlider', {
Expand Down
8 changes: 8 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This is the main entry point for dynamically loading this extension.
* Use it to defer the loading to the point when it's really needed.
* @return {Promise<{}>}
*/
export default function () {
return import('./static')
}
8 changes: 2 additions & 6 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Package.describe({
name: 'muqube:autoform-nouislider',
summary: 'Dual value slider for autoform.',
version: '0.5.2',
version: '0.6.0',
git: 'https://github.com/muqube/meteor-autoform-nouislider'
})

Expand All @@ -17,9 +17,5 @@ Package.onUse(function (api) {
api.use('[email protected]')
api.use('[email protected]')
api.use('aldeed:[email protected] || 5.0.0 || 6.0.0 || 7.0.0')
api.addFiles([
'autoform-nouislider.html',
'autoform-nouislider.js',
'autoform-nouislider.css'
], 'client')
api.mainModule('main.js', 'client')
})
1 change: 1 addition & 0 deletions static.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './autoform-nouislider'