react-flatpickr
Advanced tools
Comparing version
import { jsx as k } from "react/jsx-runtime"; | ||
import { useMemo as v, useRef as D, useImperativeHandle as x, useEffect as E, useCallback as F } from "react"; | ||
import H from "flatpickr"; | ||
import { useMemo as v, useRef as D, useImperativeHandle as E, useEffect as F, useCallback as H } from "react"; | ||
import A from "flatpickr"; | ||
const N = ["onCreate", "onDestroy"], m = [ | ||
@@ -14,7 +14,7 @@ "onChange", | ||
], R = (e, c) => (m.forEach((r) => { | ||
const s = c[r], o = e[r]; | ||
const s = c[r], a = e[r]; | ||
if (s) { | ||
o && !Array.isArray(o) ? e[r] = [e[r]] : e[r] || (e[r] = []); | ||
const t = Array.isArray(s) ? s : [s]; | ||
e[r].length === 0 ? e[r] = t : e[r].push(...t); | ||
a && !Array.isArray(a) ? e[r] = [e[r]] : e[r] || (e[r] = []); | ||
const n = Array.isArray(s) ? s : [s]; | ||
e[r].length === 0 ? e[r] = n : e[r].push(...n); | ||
} | ||
@@ -26,38 +26,39 @@ }), m.forEach((r) => { | ||
}), e), w = (e) => { | ||
const c = v(() => ({ ...e }), [e]), { defaultValue: r, className: s, options: o = {}, value: t, children: A, render: C } = c, f = v(() => R(o, c), [o, c]), l = D(null), n = D(void 0); | ||
x( | ||
const c = v(() => ({ ...e }), [e]), { defaultValue: r, className: s, options: a = {}, value: n, children: b, render: C } = c, f = v(() => R(a, c), [a, c]), u = D(null), t = D(void 0); | ||
E( | ||
e.ref, | ||
() => ({ | ||
get flatpickr() { | ||
return n.current; | ||
return t.current; | ||
} | ||
}), | ||
[] | ||
), E(() => { | ||
), F(() => { | ||
var h; | ||
const d = () => { | ||
const g = () => { | ||
var l; | ||
f.onClose = f.onClose || (() => { | ||
var i; | ||
(i = l.current) != null && i.blur && l.current.blur(); | ||
}), n.current = H(l.current, f), n.current && t !== void 0 && n.current.setDate(t, !1), e.onCreate && e.onCreate(n.current); | ||
}, b = () => { | ||
e.onDestroy && e.onDestroy(n.current), n.current && n.current.destroy(), n.current = void 0; | ||
(i = u.current) != null && i.blur && u.current.blur(); | ||
}), t.current = (((l = A) == null ? void 0 : l.default) || A)(u.current, f), t.current && n !== void 0 && t.current.setDate(n, !1), e.onCreate && e.onCreate(t.current); | ||
}, x = () => { | ||
e.onDestroy && e.onDestroy(t.current), t.current && t.current.destroy(), t.current = void 0; | ||
}; | ||
if (d(), n.current) { | ||
const i = Object.getOwnPropertyNames(f); | ||
for (let g = i.length - 1; g >= 0; g--) { | ||
const u = i[g]; | ||
let a = f[u]; | ||
(a == null ? void 0 : a.toString()) !== ((h = n.current.config[u]) == null ? void 0 : h.toString()) && (m.includes(u) && !Array.isArray(a) && (a = [a]), n.current.set(u, a)); | ||
if (g(), t.current) { | ||
const l = Object.getOwnPropertyNames(f); | ||
for (let i = l.length - 1; i >= 0; i--) { | ||
const d = l[i]; | ||
let o = f[d]; | ||
(o == null ? void 0 : o.toString()) !== ((h = t.current.config[d]) == null ? void 0 : h.toString()) && (m.includes(d) && !Array.isArray(o) && (o = [o]), t.current.set(d, o)); | ||
} | ||
t !== void 0 && t !== n.current.input.value && n.current.setDate(t, !1); | ||
n !== void 0 && n !== t.current.input.value && t.current.setDate(n, !1); | ||
} | ||
return () => { | ||
b(); | ||
x(); | ||
}; | ||
}, [f, o, c, t, e]); | ||
const y = F((d) => { | ||
l.current = d; | ||
}, [f, a, c, n, e]); | ||
const y = H((g) => { | ||
u.current = g; | ||
}, []); | ||
return C ? C({ ...c, defaultValue: r, value: t }, y) : o.wrap ? /* @__PURE__ */ k("div", { className: "flatpickr", ref: y, children: A }) : /* @__PURE__ */ k("input", { value: t == null ? void 0 : t.toString(), className: s, defaultValue: r, ref: y }); | ||
return C ? C({ ...c, defaultValue: r, value: n }, y) : a.wrap ? /* @__PURE__ */ k("div", { className: "flatpickr", ref: y, children: b }) : /* @__PURE__ */ k("input", { value: n == null ? void 0 : n.toString(), className: s, defaultValue: r, ref: y }); | ||
}; | ||
@@ -64,0 +65,0 @@ export { |
{ | ||
"name": "react-flatpickr", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"description": "flatpickr for React", | ||
@@ -5,0 +5,0 @@ "exports": { |
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
29643
1.64%109
0.93%