stimulus-flatpickr
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,2 +0,2 @@ | ||
var t,e=require("stimulus"),i=(t=require("flatpickr"))&&"object"==typeof t&&"default"in t?t.default:t,a=function(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()},n=["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],o=["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],r=["defaultHour","defaultMinute","hourIncrement","minuteIncrement"],s=["disable","enable"],c=["maxDate","minDate"],l=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"],u=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){this.initializeBooleans(),this.initializeStrings(),this.initializeNumbers(),this.initializeArrays(),this.initializeDates(),this.initializeEvents(),this.fp=i(this.element,Object.assign({},this.config))},e.prototype.initialize=function(){this.config={}},e.prototype.initializeEvents=function(){var t=this;l.forEach(function(e){var i,a="on"+((i=e).charAt(0).toUpperCase()+i.slice(1));t.config[a]=t[e]})},e.prototype.initializeBooleans=function(){var t=this;n.forEach(function(e){var i=a(e);t.data.has(i)&&(t.config[e]="true"===t.data.get(i))})},e.prototype.initializeStrings=function(){var t=this;o.forEach(function(e){var i=a(e);t.data.has(i)&&(t.config[e]=t.data.get(i))})},e.prototype.initializeNumbers=function(){var t=this;r.forEach(function(e){var i=a(e);t.data.has(i)&&(t.config[e]=parseInt(t.data.get(i)))})},e.prototype.initializeArrays=function(){var t=this;s.forEach(function(e){var i=a(e);t.data.has(i)&&(t.config[e]=JSON.parse(t.data.get(i)))})},e.prototype.initializeDates=function(){var t=this;c.forEach(function(e){var i=a(e);t.data.has(i)&&(t.config[e]=t.data.get(i))})},e}(e.Controller);module.exports=u; | ||
var t,e=require("stimulus"),n=(t=require("flatpickr"))&&"object"==typeof t&&"default"in t?t.default:t,a={string:["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],boolean:["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],date:["maxDate","minDate"],array:["disable","enable"],number:["defaultHour","defaultMinute","hourIncrement","minuteIncrement"]},o=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"],r=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.initialize=function(){this.config={}},e.prototype.connect=function(){this.initializeOptions(),this.initializeEvents(),this.fp=n(this.element,Object.assign({},this.config))},e.prototype.disconnect=function(){this.fp.destroy()},e.prototype.initializeEvents=function(){var t=this;o.forEach(function(e){var n,a="on"+((n=e).charAt(0).toUpperCase()+n.slice(1));t.config[a]=t[e]})},e.prototype.initializeOptions=function(){var t=this;Object.keys(a).forEach(function(e){a[e].forEach(function(n){var a=n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase();t.data.has(a)&&(t.config[n]=t[e](a))})})},e.prototype.string=function(t){return this.data.get(t)},e.prototype.date=function(t){return this.data.get(t)},e.prototype.boolean=function(t){return"true"===this.data.get(t)},e.prototype.array=function(t){return JSON.parse(this.data.get(t))},e.prototype.number=function(t){return parseInt(this.data.get(t))},e}(e.Controller);module.exports=r; | ||
//# sourceMappingURL=stimulus-flatpickr.js.map |
@@ -1,2 +0,2 @@ | ||
import{Controller as t}from"stimulus";import i from"flatpickr";var a=function(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()},e=["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],n=["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],o=["defaultHour","defaultMinute","hourIncrement","minuteIncrement"],r=["disable","enable"],s=["maxDate","minDate"],c=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"];export default function(t){function l(){t.apply(this,arguments)}return t&&(l.__proto__=t),(l.prototype=Object.create(t&&t.prototype)).constructor=l,l.prototype.connect=function(){this.initializeBooleans(),this.initializeStrings(),this.initializeNumbers(),this.initializeArrays(),this.initializeDates(),this.initializeEvents(),this.fp=i(this.element,Object.assign({},this.config))},l.prototype.initialize=function(){this.config={}},l.prototype.initializeEvents=function(){var t=this;c.forEach(function(i){var a,e="on"+((a=i).charAt(0).toUpperCase()+a.slice(1));t.config[e]=t[i]})},l.prototype.initializeBooleans=function(){var t=this;e.forEach(function(i){var e=a(i);t.data.has(e)&&(t.config[i]="true"===t.data.get(e))})},l.prototype.initializeStrings=function(){var t=this;n.forEach(function(i){var e=a(i);t.data.has(e)&&(t.config[i]=t.data.get(e))})},l.prototype.initializeNumbers=function(){var t=this;o.forEach(function(i){var e=a(i);t.data.has(e)&&(t.config[i]=parseInt(t.data.get(e)))})},l.prototype.initializeArrays=function(){var t=this;r.forEach(function(i){var e=a(i);t.data.has(e)&&(t.config[i]=JSON.parse(t.data.get(e)))})},l.prototype.initializeDates=function(){var t=this;s.forEach(function(i){var e=a(i);t.data.has(e)&&(t.config[i]=t.data.get(e))})},l}(t); | ||
import{Controller as t}from"stimulus";import e from"flatpickr";var n={string:["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],boolean:["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],date:["maxDate","minDate"],array:["disable","enable"],number:["defaultHour","defaultMinute","hourIncrement","minuteIncrement"]},a=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"];export default function(t){function o(){t.apply(this,arguments)}return t&&(o.__proto__=t),(o.prototype=Object.create(t&&t.prototype)).constructor=o,o.prototype.initialize=function(){this.config={}},o.prototype.connect=function(){this.initializeOptions(),this.initializeEvents(),this.fp=e(this.element,Object.assign({},this.config))},o.prototype.disconnect=function(){this.fp.destroy()},o.prototype.initializeEvents=function(){var t=this;a.forEach(function(e){var n,a="on"+((n=e).charAt(0).toUpperCase()+n.slice(1));t.config[a]=t[e]})},o.prototype.initializeOptions=function(){var t=this;Object.keys(n).forEach(function(e){n[e].forEach(function(n){var a=n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase();t.data.has(a)&&(t.config[n]=t[e](a))})})},o.prototype.string=function(t){return this.data.get(t)},o.prototype.date=function(t){return this.data.get(t)},o.prototype.boolean=function(t){return"true"===this.data.get(t)},o.prototype.array=function(t){return JSON.parse(this.data.get(t))},o.prototype.number=function(t){return parseInt(this.data.get(t))},o}(t); | ||
//# sourceMappingURL=stimulus-flatpickr.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("stimulus"),require("flatpickr")):"function"==typeof define&&define.amd?define(["stimulus","flatpickr"],e):t.stimulusFlatpickr=e(t.stimulus,t.flatpickr)}(this,function(t,e){e=e&&e.hasOwnProperty("default")?e.default:e;var i=function(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase()},a=["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],n=["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],o=["defaultHour","defaultMinute","hourIncrement","minuteIncrement"],r=["disable","enable"],s=["maxDate","minDate"],c=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"];return function(t){function u(){t.apply(this,arguments)}return t&&(u.__proto__=t),(u.prototype=Object.create(t&&t.prototype)).constructor=u,u.prototype.connect=function(){this.initializeBooleans(),this.initializeStrings(),this.initializeNumbers(),this.initializeArrays(),this.initializeDates(),this.initializeEvents(),this.fp=e(this.element,Object.assign({},this.config))},u.prototype.initialize=function(){this.config={}},u.prototype.initializeEvents=function(){var t=this;c.forEach(function(e){var i,a="on"+((i=e).charAt(0).toUpperCase()+i.slice(1));t.config[a]=t[e]})},u.prototype.initializeBooleans=function(){var t=this;a.forEach(function(e){var a=i(e);t.data.has(a)&&(t.config[e]="true"===t.data.get(a))})},u.prototype.initializeStrings=function(){var t=this;n.forEach(function(e){var a=i(e);t.data.has(a)&&(t.config[e]=t.data.get(a))})},u.prototype.initializeNumbers=function(){var t=this;o.forEach(function(e){var a=i(e);t.data.has(a)&&(t.config[e]=parseInt(t.data.get(a)))})},u.prototype.initializeArrays=function(){var t=this;r.forEach(function(e){var a=i(e);t.data.has(a)&&(t.config[e]=JSON.parse(t.data.get(a)))})},u.prototype.initializeDates=function(){var t=this;s.forEach(function(e){var a=i(e);t.data.has(a)&&(t.config[e]=t.data.get(a))})},u}(t.Controller)}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("stimulus"),require("flatpickr")):"function"==typeof define&&define.amd?define(["stimulus","flatpickr"],e):t.stimulusFlatpickr=e(t.stimulus,t.flatpickr)}(this,function(t,e){e=e&&e.hasOwnProperty("default")?e.default:e;var n={string:["altFormat","altInputClass","ariaDateFormat","dateFormat","defaultDate","mode","nextArrow","prevArrow"],boolean:["altInput","allowInput","clickOpens","disableMobile","enableTime","enableSeconds","inline","noCalendar","shorthandCurrentMonth","static","time_24hr","weekNumbers","wrap"],date:["maxDate","minDate"],array:["disable","enable"],number:["defaultHour","defaultMinute","hourIncrement","minuteIncrement"]},o=["change","open","close","monthChange","yearChange","ready","valueUpdate","dayCreate"];return function(t){function i(){t.apply(this,arguments)}return t&&(i.__proto__=t),(i.prototype=Object.create(t&&t.prototype)).constructor=i,i.prototype.initialize=function(){this.config={}},i.prototype.connect=function(){this.initializeOptions(),this.initializeEvents(),this.fp=e(this.element,Object.assign({},this.config))},i.prototype.disconnect=function(){this.fp.destroy()},i.prototype.initializeEvents=function(){var t=this;o.forEach(function(e){var n,o="on"+((n=e).charAt(0).toUpperCase()+n.slice(1));t.config[o]=t[e]})},i.prototype.initializeOptions=function(){var t=this;Object.keys(n).forEach(function(e){n[e].forEach(function(n){var o=n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase();t.data.has(o)&&(t.config[n]=t[e](o))})})},i.prototype.string=function(t){return this.data.get(t)},i.prototype.date=function(t){return this.data.get(t)},i.prototype.boolean=function(t){return"true"===this.data.get(t)},i.prototype.array=function(t){return JSON.parse(this.data.get(t))},i.prototype.number=function(t){return parseInt(this.data.get(t))},i}(t.Controller)}); | ||
//# sourceMappingURL=stimulus-flatpickr.umd.js.map |
{ | ||
"name": "stimulus-flatpickr", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A Stimulus Wrapper for Flatpickr library", | ||
@@ -5,0 +5,0 @@ "main": "dist/stimulus-flatpickr.js", |
@@ -1,2 +0,2 @@ | ||
export const booleanOptions = [ | ||
const booleanOptions = [ | ||
"altInput", | ||
@@ -17,3 +17,3 @@ "allowInput", | ||
export const stringOptions = [ | ||
const stringOptions = [ | ||
"altFormat", | ||
@@ -29,3 +29,3 @@ "altInputClass", | ||
export const numberOptions = [ | ||
const numberOptions = [ | ||
"defaultHour", | ||
@@ -37,5 +37,12 @@ "defaultMinute", | ||
export const arrayOptions = ["disable", "enable"]; | ||
const arrayOptions = ["disable", "enable"]; | ||
export const dateOptions = ["maxDate", "minDate"]; | ||
const dateOptions = ["maxDate", "minDate"]; | ||
export const options = { | ||
string: stringOptions, | ||
boolean: booleanOptions, | ||
date: dateOptions, | ||
array: arrayOptions, | ||
number: numberOptions | ||
}; |
import { Controller } from "stimulus"; | ||
import flatpickr from "flatpickr"; | ||
import { kebabCase, capitalize } from "./utils"; | ||
import { | ||
booleanOptions, | ||
stringOptions, | ||
numberOptions, | ||
arrayOptions, | ||
dateOptions | ||
} from "./config_options"; | ||
import { options } from "./config_options"; | ||
import { events } from "./events"; | ||
class Flatpickr extends Controller { | ||
initialize() { | ||
this.config = {}; | ||
} | ||
connect() { | ||
this.initializeBooleans(); | ||
this.initializeStrings(); | ||
this.initializeNumbers(); | ||
this.initializeArrays(); | ||
this.initializeDates(); | ||
this.initializeOptions(); | ||
this.initializeEvents(); | ||
@@ -28,4 +21,4 @@ | ||
initialize() { | ||
this.config = {}; | ||
disconnect() { | ||
this.fp.destroy(); | ||
} | ||
@@ -40,48 +33,35 @@ | ||
initializeBooleans() { | ||
booleanOptions.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = this.data.get(optionKebab) === "true"; | ||
} | ||
initializeOptions() { | ||
Object.keys(options).forEach(optionType => { | ||
const optionsCamelCase = options[optionType]; | ||
optionsCamelCase.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = this[optionType](optionKebab); | ||
} | ||
}); | ||
}); | ||
} | ||
initializeStrings() { | ||
stringOptions.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = this.data.get(optionKebab); | ||
} | ||
}); | ||
string(option) { | ||
return this.data.get(option); | ||
} | ||
initializeNumbers() { | ||
numberOptions.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = parseInt(this.data.get(optionKebab)); | ||
} | ||
}); | ||
date(option) { | ||
return this.data.get(option); | ||
} | ||
initializeArrays() { | ||
arrayOptions.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = JSON.parse(this.data.get(optionKebab)); | ||
} | ||
}); | ||
boolean(option) { | ||
return this.data.get(option) === "true"; | ||
} | ||
initializeDates() { | ||
dateOptions.forEach(option => { | ||
const optionKebab = kebabCase(option); | ||
if (this.data.has(optionKebab)) { | ||
this.config[option] = this.data.get(optionKebab); | ||
} | ||
}); | ||
array(option) { | ||
return JSON.parse(this.data.get(option)); | ||
} | ||
number(option) { | ||
return parseInt(this.data.get(option)); | ||
} | ||
} | ||
export default Flatpickr; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
145801
136