@sonygrg/nepali-datepicker 1.0.19 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>
|
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require("react"),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),x=e(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=y():t.exports=b()}))();function S({onSelectDate:e,selectDate:n}){let[s,c]=(0,r.useState)(()=>n?.year??2083),[l,u]=(0,r.useState)(()=>n?.month??1);(0,r.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c(n.year),u(n.month)},0);return()=>clearTimeout(e)},[n]);let d=Object.keys(i).map(Number),p=i[String(s)]?.[a[l-1]]??30,m=f(s,l),g=()=>{l===1?(u(12),c(e=>e-1)):u(e=>e-1)},_=()=>{l===12?(u(1),c(e=>e+1)):u(e=>e+1)},v=s===2e3&&l===1,y=s===2090&&l===12,b=[...Array(m).fill(null),...Array.from({length:p},(e,t)=>t+1)];return(0,x.jsxs)(t.Card,{sx:{p:`
|
|
6
|
+
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require("react"),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),x=e(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=y():t.exports=b()}))();function S({onSelectDate:e,selectDate:n}){let[s,c]=(0,r.useState)(()=>n?.year??2083),[l,u]=(0,r.useState)(()=>n?.month??1);(0,r.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{c(n.year),u(n.month)},0);return()=>clearTimeout(e)},[n]);let d=Object.keys(i).map(Number),p=i[String(s)]?.[a[l-1]]??30,m=f(s,l),g=()=>{l===1?(u(12),c(e=>e-1)):u(e=>e-1)},_=()=>{l===12?(u(1),c(e=>e+1)):u(e=>e+1)},v=s===2e3&&l===1,y=s===2090&&l===12,b=[...Array(m).fill(null),...Array.from({length:p},(e,t)=>t+1)];return(0,x.jsxs)(t.Card,{sx:{p:`10px`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,x.jsxs)(t.Box,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,mb:`8px`},children:[(0,x.jsx)(t.IconButton,{onClick:g,disabled:v,children:`‹`}),(0,x.jsx)(t.Select,{value:s,onChange:e=>{c(Number(e.target.value))},size:`small`,MenuProps:{slotProps:{paper:{sx:{maxHeight:250}}}},sx:{minWidth:90},children:d.map(e=>(0,x.jsx)(t.MenuItem,{value:e,children:h(e)},e))}),(0,x.jsx)(t.Select,{value:l,onChange:e=>u(Number(e.target.value)),MenuProps:{slotProps:{paper:{sx:{maxHeight:250}}}},sx:{minWidth:90},size:`small`,children:o.month.long.map((e,n)=>(0,x.jsx)(t.MenuItem,{value:n+1,children:e},e))}),(0,x.jsx)(t.IconButton,{onClick:_,disabled:y,children:`›`})]}),(0,x.jsxs)(t.Box,{sx:{display:`grid`,gridTemplateColumns:`repeat(7, 1fr)`,textAlign:`center`,gap:2},children:[o.day.short.map(e=>(0,x.jsx)(t.Box,{children:(0,x.jsx)(t.Typography,{variant:`caption`,sx:{fontSize:`14px`},children:e})},e)),b.map((r,i)=>{let a=n&&n.day===r&&n.month===l&&n.year===s;return(0,x.jsx)(t.Box,{children:r&&(0,x.jsx)(t.Box,{onClick:()=>{r!==null&&e({year:s,month:l,day:r})},sx:{cursor:`pointer`,bgcolor:a?`primary.main`:`transparent`,color:a?`#fff`:`text.primary`,borderRadius:`50%`,height:`32px`,width:`32px`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:h(r)})},i)})]})]})}function C(e,t=`-`){let n=_(e).split(t);if(n.length!==3||n[0].length!==4)return null;let r=parseInt(n[0],10),o=parseInt(n[1],10),s=parseInt(n[2],10);if(isNaN(r)||isNaN(o)||isNaN(s))return null;let c=i[String(r)]?.[a[o-1]];return!c||o<1||o>12||s<1||s>c?null:{year:r,month:o,day:s}}function w({value:e,onChange:i,format:a=`YYYY/MM/DD`}){let[o,s]=(0,r.useState)(null),[c,l]=(0,r.useState)(``),[u,d]=(0,r.useState)(null),f=[`-`,`/`],p=a.includes(`-`)?`-`:`/`,m=e===void 0?u:e,h=m?C(m,p):null,y=(0,r.useRef)(null),b=(0,r.useRef)(null),w=(0,r.useRef)(null),T=e=>{let t=e?g(e,a):null;d(t),i?.(t)},E=()=>{let e=C(c,p);e?T(e):c&&T(null),l(``)};return(0,r.useLayoutEffect)(()=>{b.current&&w.current!==null&&b.current.setSelectionRange(w.current,w.current)},[c]),(0,x.jsx)(`div`,{children:(0,x.jsxs)(t.Box,{sx:{m:`0px`},children:[(0,x.jsx)(t.Box,{ref:y,children:(0,x.jsx)(t.TextField,{label:m?``:`मिति छान्नुहोस् `,size:`small`,sx:{" .MuiInputBase-input":{height:`20px`}},value:c?v(c):m||``,placeholder:a,onChange:e=>{let t=e.target,n=t.selectionStart??0,r=_(t.value);r=r.split(``).map(e=>f.includes(e)?p:e).filter(e=>e>=`0`&&e<=`9`||e===p).join(``);let i=r.length;(r.length===4&&!r.includes(p)||r.length===7&&r.split(p).length===2)&&(r+=p),r.length>i&&n===i&&(n+=1),w.current=n,l(r.slice(0,10))},onFocus:()=>{if(h&&!c){let e=h.year;l(`${e}${p}${String(h.month).padStart(2,`0`)}${p}${String(h.day).padStart(2,`0`)}`)}},onBlur:E,onKeyDown:e=>{e.key===`Enter`&&E()},slotProps:{input:{inputRef:b,sx:{pl:`8px`,fontSize:`18px`},endAdornment:(0,x.jsx)(t.InputAdornment,{position:`end`,children:(0,x.jsx)(t.IconButton,{onClick:()=>s(y.current),children:(0,x.jsx)(n.CalendarIcon,{})})})}}})}),(0,x.jsx)(t.Popover,{open:!!o,anchorEl:o,onClose:()=>s(null),anchorOrigin:{vertical:`bottom`,horizontal:`left`},children:(0,x.jsx)(S,{selectDate:h,onSelectDate:e=>{T(e),l(``),s(null)}})})]})})}exports.InputCalendar=w,exports.formatBSDateNepali=g;
|
|
@@ -1617,7 +1617,7 @@ function F({ onSelectDate: r, selectDate: a }) {
|
|
|
1617
1617
|
}, S = s === 2e3 && u === 1, C = s === 2090 && u === 12, T = [...Array(y).fill(null), ...Array.from({ length: h }, (e, t) => t + 1)];
|
|
1618
1618
|
return /* @__PURE__ */ (0, P.jsxs)(t, {
|
|
1619
1619
|
sx: {
|
|
1620
|
-
p: "
|
|
1620
|
+
p: "10px",
|
|
1621
1621
|
display: "flex",
|
|
1622
1622
|
flexDirection: "column",
|
|
1623
1623
|
gap: "10px"
|
|
@@ -1720,44 +1720,44 @@ function I(e, t = "-") {
|
|
|
1720
1720
|
}
|
|
1721
1721
|
//#endregion
|
|
1722
1722
|
//#region src/components/InputCalendar.tsx
|
|
1723
|
-
function L({ value: t, onChange: i, format: o = "YYYY
|
|
1724
|
-
let [c, u] = m(null), [d, h] = m(""), [g, _] = m(null), v = o.includes("-") ? "-" : "/",
|
|
1723
|
+
function L({ value: t, onChange: i, format: o = "YYYY/MM/DD" }) {
|
|
1724
|
+
let [c, u] = m(null), [d, h] = m(""), [g, _] = m(null), v = ["-", "/"], y = o.includes("-") ? "-" : "/", b = t === void 0 ? g : t, x = b ? I(b, y) : null, S = p(null), C = p(null), w = p(null), T = (e) => {
|
|
1725
1725
|
let t = e ? O(e, o) : null;
|
|
1726
1726
|
_(t), i?.(t);
|
|
1727
|
-
},
|
|
1728
|
-
let e = I(d,
|
|
1729
|
-
e ?
|
|
1730
|
-
}
|
|
1727
|
+
}, E = () => {
|
|
1728
|
+
let e = I(d, y);
|
|
1729
|
+
e ? T(e) : d && T(null), h("");
|
|
1730
|
+
};
|
|
1731
1731
|
return f(() => {
|
|
1732
|
-
|
|
1732
|
+
C.current && w.current !== null && C.current.setSelectionRange(w.current, w.current);
|
|
1733
1733
|
}, [d]), /* @__PURE__ */ (0, P.jsx)("div", { children: /* @__PURE__ */ (0, P.jsxs)(e, {
|
|
1734
1734
|
sx: { m: "0px" },
|
|
1735
1735
|
children: [/* @__PURE__ */ (0, P.jsx)(e, {
|
|
1736
|
-
ref:
|
|
1736
|
+
ref: S,
|
|
1737
1737
|
children: /* @__PURE__ */ (0, P.jsx)(s, {
|
|
1738
|
-
label:
|
|
1738
|
+
label: b ? "" : "मिति छान्नुहोस् ",
|
|
1739
1739
|
size: "small",
|
|
1740
1740
|
sx: { " .MuiInputBase-input": { height: "20px" } },
|
|
1741
|
-
value: d ? A(d) :
|
|
1741
|
+
value: d ? A(d) : b || "",
|
|
1742
1742
|
placeholder: o,
|
|
1743
1743
|
onChange: (e) => {
|
|
1744
1744
|
let t = e.target, n = t.selectionStart ?? 0, r = k(t.value);
|
|
1745
|
-
r = r.split("").map((e) =>
|
|
1745
|
+
r = r.split("").map((e) => v.includes(e) ? y : e).filter((e) => e >= "0" && e <= "9" || e === y).join("");
|
|
1746
1746
|
let i = r.length;
|
|
1747
|
-
(r.length === 4 && !r.includes(
|
|
1747
|
+
(r.length === 4 && !r.includes(y) || r.length === 7 && r.split(y).length === 2) && (r += y), r.length > i && n === i && (n += 1), w.current = n, h(r.slice(0, 10));
|
|
1748
1748
|
},
|
|
1749
1749
|
onFocus: () => {
|
|
1750
|
-
if (
|
|
1751
|
-
let e =
|
|
1752
|
-
h(`${e}${
|
|
1750
|
+
if (x && !d) {
|
|
1751
|
+
let e = x.year;
|
|
1752
|
+
h(`${e}${y}${String(x.month).padStart(2, "0")}${y}${String(x.day).padStart(2, "0")}`);
|
|
1753
1753
|
}
|
|
1754
1754
|
},
|
|
1755
|
-
onBlur:
|
|
1755
|
+
onBlur: E,
|
|
1756
1756
|
onKeyDown: (e) => {
|
|
1757
|
-
e.key === "Enter" &&
|
|
1757
|
+
e.key === "Enter" && E();
|
|
1758
1758
|
},
|
|
1759
1759
|
slotProps: { input: {
|
|
1760
|
-
inputRef:
|
|
1760
|
+
inputRef: C,
|
|
1761
1761
|
sx: {
|
|
1762
1762
|
pl: "8px",
|
|
1763
1763
|
fontSize: "18px"
|
|
@@ -1765,7 +1765,7 @@ function L({ value: t, onChange: i, format: o = "YYYY-MM-DD" }) {
|
|
|
1765
1765
|
endAdornment: /* @__PURE__ */ (0, P.jsx)(r, {
|
|
1766
1766
|
position: "end",
|
|
1767
1767
|
children: /* @__PURE__ */ (0, P.jsx)(n, {
|
|
1768
|
-
onClick: () => u(
|
|
1768
|
+
onClick: () => u(S.current),
|
|
1769
1769
|
children: /* @__PURE__ */ (0, P.jsx)(l, {})
|
|
1770
1770
|
})
|
|
1771
1771
|
})
|
|
@@ -1780,9 +1780,9 @@ function L({ value: t, onChange: i, format: o = "YYYY-MM-DD" }) {
|
|
|
1780
1780
|
horizontal: "left"
|
|
1781
1781
|
},
|
|
1782
1782
|
children: /* @__PURE__ */ (0, P.jsx)(F, {
|
|
1783
|
-
selectDate:
|
|
1783
|
+
selectDate: x,
|
|
1784
1784
|
onSelectDate: (e) => {
|
|
1785
|
-
|
|
1785
|
+
T(e), h(""), u(null);
|
|
1786
1786
|
}
|
|
1787
1787
|
})
|
|
1788
1788
|
})]
|