react-flatpickr
Advanced tools
Comparing version 3.10.12 to 3.10.13
@@ -97,7 +97,3 @@ "use strict"; | ||
hooks.forEach(function (hook) { | ||
if (_this.props[hook]) { | ||
options[hook] = _this.props[hook]; | ||
} | ||
}); | ||
options = mergeHooks(options, _this.props); | ||
_this.flatpickr = (0, _flatpickr["default"])(_this.node, options); | ||
@@ -138,11 +134,7 @@ | ||
value: function componentDidUpdate(prevProps) { | ||
var _this2 = this; | ||
var options = this.props.options; | ||
var prevOptions = prevProps.options; | ||
hooks.forEach(function (hook) { | ||
mergeHooks(options, _this2.props, hook); // Add prev ones too so we can compare against them later | ||
options = mergeHooks(options, this.props); // Add prev ones too so we can compare against them later | ||
mergeHooks(prevOptions, prevProps, hook); | ||
}); | ||
prevOptions = mergeHooks(prevOptions, prevProps); | ||
var optionsKeys = Object.getOwnPropertyNames(options); | ||
@@ -238,19 +230,20 @@ | ||
function mergeHooks(inputOptions, props, hook) { | ||
function mergeHooks(inputOptions, props) { | ||
var options = _objectSpread({}, inputOptions); | ||
if (props.hasOwnProperty(hook)) { | ||
var _options$hook; | ||
hooks.forEach(function (hook) { | ||
if (props.hasOwnProperty(hook)) { | ||
var _options$hook; | ||
if (options[hook] && !Array.isArray(options[hook])) { | ||
options[hook] = [options[hook]]; | ||
} else if (!options[hook]) { | ||
options[hook] = []; | ||
} | ||
if (options[hook] && !Array.isArray(options[hook])) { | ||
options[hook] = [options[hook]]; | ||
} else if (!options[hook]) { | ||
options[hook] = []; | ||
} | ||
var propHook = Array.isArray(props[hook]) ? props[hook] : [props[hook]]; | ||
var propHook = Array.isArray(props[hook]) ? props[hook] : [props[hook]]; | ||
(_options$hook = options[hook]).push.apply(_options$hook, _toConsumableArray(propHook)); | ||
} | ||
(_options$hook = options[hook]).push.apply(_options$hook, _toConsumableArray(propHook)); | ||
} | ||
}); | ||
return options; | ||
@@ -257,0 +250,0 @@ } |
@@ -57,11 +57,9 @@ import React, { Component } from 'react' | ||
componentDidUpdate(prevProps) { | ||
const { options } = this.props | ||
const prevOptions = prevProps.options | ||
let { options } = this.props | ||
let prevOptions = prevProps.options | ||
hooks.forEach(hook => { | ||
mergeHooks(options, this.props, hook) | ||
options = mergeHooks(options, this.props) | ||
// Add prev ones too so we can compare against them later | ||
mergeHooks(prevOptions, prevProps, hook) | ||
}) | ||
// Add prev ones too so we can compare against them later | ||
prevOptions = mergeHooks(prevOptions, prevProps) | ||
@@ -109,3 +107,3 @@ const optionsKeys = Object.getOwnPropertyNames(options) | ||
createFlatpickrInstance = () => { | ||
const options = { | ||
let options = { | ||
onClose: () => { | ||
@@ -118,7 +116,3 @@ this.node.blur && this.node.blur() | ||
// Add prop hooks to options | ||
hooks.forEach(hook => { | ||
if (this.props[hook]) { | ||
options[hook] = this.props[hook] | ||
} | ||
}) | ||
options = mergeHooks(options, this.props) | ||
@@ -176,17 +170,20 @@ this.flatpickr = flatpickr(this.node, options) | ||
function mergeHooks(inputOptions, props, hook) { | ||
function mergeHooks(inputOptions, props) { | ||
const options = {...inputOptions} | ||
if (props.hasOwnProperty(hook)) { | ||
if (options[hook] && !Array.isArray(options[hook])) { | ||
options[hook] = [options[hook]] | ||
} else if (!options[hook]) { | ||
options[hook] = [] | ||
hooks.forEach(hook => { | ||
if (props.hasOwnProperty(hook)) { | ||
if (options[hook] && !Array.isArray(options[hook])) { | ||
options[hook] = [options[hook]] | ||
} else if (!options[hook]) { | ||
options[hook] = [] | ||
} | ||
const propHook = Array.isArray(props[hook]) | ||
? props[hook] | ||
: [props[hook]] | ||
options[hook].push(...propHook) | ||
} | ||
}) | ||
const propHook = Array.isArray(props[hook]) | ||
? props[hook] | ||
: [props[hook]] | ||
options[hook].push(...propHook) | ||
} | ||
return options | ||
@@ -193,0 +190,0 @@ } |
{ | ||
"name": "react-flatpickr", | ||
"version": "3.10.12", | ||
"version": "3.10.13", | ||
"description": "flatpickr for React", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27454
352