You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-flatpickr

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-flatpickr - npm Package Compare versions

Comparing version

to
4.0.3

build/react-flatpickr.cjs

67

build/react-flatpickr.js

@@ -1,1 +0,66 @@

"use strict";var h=Object.create?function(r,e,n,a){a===void 0&&(a=n);var t=Object.getOwnPropertyDescriptor(e,n);(!t||("get"in t?!e.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(r,a,t)}:function(r,e,n,a){a===void 0&&(a=n),r[a]=e[n]},M=Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e},w=function(){var r=function(e){return r=Object.getOwnPropertyNames||function(n){var a=[];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(a[a.length]=t);return a},r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var a=r(e),t=0;t<a.length;t++)a[t]!=="default"&&h(n,e,a[t]);return M(n,e),n}}(),E=function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0});const o=w(require("react")),P=E(require("flatpickr")),m=["onCreate","onDestroy"],j=["onChange","onOpen","onClose","onMonthChange","onYearChange","onReady","onValueUpdate","onDayCreate"],p=(r,e)=>(j.forEach(n=>{if(e[n]){r[n]&&!Array.isArray(r[n])?r[n]=[r[n]]:r[n]||(r[n]=[]);const a=Array.isArray(e[n])?e[n]:[e[n]];r[n].push(a)}}),r),A=r=>{const e=(0,o.useMemo)(()=>Object.assign({},r),[r]),{defaultValue:n,className:a,options:t={},value:c,children:C,render:O,onCreate:v,onDestroy:y,onChange:D}=e,d=(0,o.useRef)(null),u=(0,o.useRef)(null);(0,o.useEffect)(()=>{const i=()=>{let f=Object.assign({onClose:()=>{var l;!((l=d.current)===null||l===void 0)&&l.blur&&d.current.blur()}},t);f&&(f=p(f,e),u.current=(0,P.default)(d.current,f),c!==void 0&&u.current.setDate(c,!1),v&&v(u.current))},g=()=>{y&&y(u.current),u.current&&u.current.destroy(),u.current=null};return i(),()=>{g()}},[t,c,v,y,e]),(0,o.useEffect)(()=>{var i;if(u.current){const g=p(t,e),f=Object.getOwnPropertyNames(g);for(let l=f.length-1;l>=0;l--){const _=f[l];let s=g[_];(s==null?void 0:s.toString())!==((i=u.current.config[_])===null||i===void 0?void 0:i.toString())&&(j.includes(_)&&!Array.isArray(s)&&(s=[s]),u.current.set(_,s))}c!==void 0&&c!==u.current.input.value&&u.current.setDate(c,!1)}},[t,c,e]);const b=i=>{d.current=i};return j.forEach(i=>{delete e[i]}),m.forEach(i=>{delete e[i]}),O?O(Object.assign(Object.assign({},e),{defaultValue:n,value:c}),b):t.wrap?o.default.createElement("div",Object.assign({},e,{ref:b}),C):o.default.createElement("input",{value:c==null?void 0:c.toString(),onChange:D,className:a,defaultValue:n,ref:b})};exports.default=A;
import { jsx as D } from "react/jsx-runtime";
import { useMemo as A, useRef as b, useEffect as E, useCallback as F } from "react";
import R from "flatpickr";
const H = ["onCreate", "onDestroy"], C = [
"onChange",
"onOpen",
"onClose",
"onMonthChange",
"onYearChange",
"onReady",
"onValueUpdate",
"onDayCreate"
], N = (e, c) => (C.forEach((r) => {
const s = c[r], o = e[r];
if (s) {
o && !Array.isArray(o) ? 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);
}
}), C.forEach((r) => {
delete c[r];
}), H.forEach((r) => {
delete c[r];
}), e), I = (e) => {
const c = A(() => ({ ...e }), [e]), { defaultValue: r, className: s, options: o = {}, value: n, children: k, render: m, onChange: v } = c, l = A(() => N(o, c), [o, c]), i = b(null), t = b(null);
E(() => {
var h;
const g = () => {
l.onClose = l.onClose || (() => {
var f;
(f = i.current) != null && f.blur && i.current.blur();
}), t.current = R(i.current, l), 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 = null;
};
if (g(), t.current) {
const f = Object.getOwnPropertyNames(l);
for (let d = f.length - 1; d >= 0; d--) {
const u = f[d];
let a = l[u];
(a == null ? void 0 : a.toString()) !== ((h = t.current.config[u]) == null ? void 0 : h.toString()) && (C.includes(u) && !Array.isArray(a) && (a = [a]), t.current.set(u, a));
}
n !== void 0 && n !== t.current.input.value && t.current.setDate(n, !1);
}
return () => {
x();
};
}, [l, o, c, n, e]);
const y = F((g) => {
i.current = g;
}, []);
return m ? m({ ...c, defaultValue: r, value: n }, y) : o.wrap ? /* @__PURE__ */ D("div", { ...c, ref: y, children: k }) : /* @__PURE__ */ D(
"input",
{
value: n == null ? void 0 : n.toString(),
onChange: v,
className: s,
defaultValue: r,
ref: y
}
);
};
export {
I as default
};
//# sourceMappingURL=react-flatpickr.js.map

23

package.json
{
"name": "react-flatpickr",
"version": "4.0.2",
"version": "4.0.3",
"description": "flatpickr for React",
"main": "build/react-flatpickr",
"module": "build/react-flatpickr.mjs",
"exports": {
".": {
"import": "./build/react-flatpickr.mjs",
"require": "./build/react-flatpickr.js"
"import": {
"types": "./build/react-flatpickr.d.ts",
"default": "./build/react-flatpickr.mjs"
},
"require": {
"types": "./build/react-flatpickr.d.ts",
"default": "./build/react-flatpickr.js"
}
}
},
"type": "module",
"types": "./build/react-flatpickr.d.ts",
"main": "./build/react-flatpickr.js",
"module": "./build/react-flatpickr.mjs",
"scripts": {
"lint": "eslint lib example test --quiet --fix",
"format": "prettier --config .prettierrc 'lib/*.{ts,tsx}' 'test/*.{ts,tsx}' --write",
"format": "prettier --config .prettierrc 'lib/*.{ts,tsx}' 'example/*' 'test/*.{ts,tsx}' --write",
"build": "tsc -b && vite build",

@@ -68,3 +76,4 @@ "test": "jest --config=jest.config.ts --env=jsdom",

"typescript-eslint": "^8.29.1",
"vite": "^6.2.3"
"vite": "^6.2.3",
"vite-plugin-dts": "^4.5.3"
},

@@ -71,0 +80,0 @@ "peerDependencies": {