@starasia/date 1.0.1 → 1.0.3
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.
- package/dist/date.es.js +602 -1255
- package/dist/date.umd.js +8 -51
- package/package.json +1 -1
package/dist/date.umd.js
CHANGED
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var me;function Qe(){if(me)return G;me=1;var t=R,n=Symbol.for("react.element"),l=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,u=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function b(j,f,a){var E,w={},_=null,M=null;a!==void 0&&(_=""+a),f.key!==void 0&&(_=""+f.key),f.ref!==void 0&&(M=f.ref);for(E in f)o.call(f,E)&&!m.hasOwnProperty(E)&&(w[E]=f[E]);if(j&&j.defaultProps)for(E in f=j.defaultProps,f)w[E]===void 0&&(w[E]=f[E]);return{$$typeof:n,type:j,key:_,ref:M,props:w,_owner:u.current}}return G.Fragment=l,G.jsx=b,G.jsxs=b,G}var K={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var be;function qe(){return be||(be=1,process.env.NODE_ENV!=="production"&&function(){var t=R,n=Symbol.for("react.element"),l=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),b=Symbol.for("react.provider"),j=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),M=Symbol.for("react.offscreen"),v=Symbol.iterator,c="@@iterator";function p(e){if(e===null||typeof e!="object")return null;var r=v&&e[v]||e[c];return typeof r=="function"?r:null}var d=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){{for(var r=arguments.length,s=new Array(r>1?r-1:0),y=1;y<r;y++)s[y-1]=arguments[y];h("error",e,s)}}function h(e,r,s){{var y=d.ReactDebugCurrentFrame,T=y.getStackAddendum();T!==""&&(r+="%s",s=s.concat([T]));var D=s.map(function(S){return String(S)});D.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,D)}}var x=!1,P=!1,O=!1,C=!1,I=!1,_e;_e=Symbol.for("react.module.reference");function pr(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===m||I||e===u||e===a||e===E||C||e===M||x||P||O||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===w||e.$$typeof===b||e.$$typeof===j||e.$$typeof===f||e.$$typeof===_e||e.getModuleId!==void 0))}function gr(e,r,s){var y=e.displayName;if(y)return y;var T=r.displayName||r.name||"";return T!==""?s+"("+T+")":s}function Te(e){return e.displayName||"Context"}function W(e){if(e==null)return null;if(typeof e.tag=="number"&&g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case l:return"Portal";case m:return"Profiler";case u:return"StrictMode";case a:return"Suspense";case E:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case j:var r=e;return Te(r)+".Consumer";case b:var s=e;return Te(s._context)+".Provider";case f:return gr(e,e.render,"ForwardRef");case w:var y=e.displayName||null;return y!==null?y:W(e.type)||"Memo";case _:{var T=e,D=T._payload,S=T._init;try{return W(S(D))}catch{return null}}}return null}var B=Object.assign,X=0,De,Me,Fe,Ye,Oe,Pe,Ne;function Ie(){}Ie.__reactDisabledLog=!0;function vr(){{if(X===0){De=console.log,Me=console.info,Fe=console.warn,Ye=console.error,Oe=console.group,Pe=console.groupCollapsed,Ne=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ie,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}X++}}function yr(){{if(X--,X===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},e,{value:De}),info:B({},e,{value:Me}),warn:B({},e,{value:Fe}),error:B({},e,{value:Ye}),group:B({},e,{value:Oe}),groupCollapsed:B({},e,{value:Pe}),groupEnd:B({},e,{value:Ne})})}X<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=d.ReactCurrentDispatcher,ue;function ae(e,r,s){{if(ue===void 0)try{throw Error()}catch(T){var y=T.stack.trim().match(/\n( *(at )?)/);ue=y&&y[1]||""}return`
|
|
18
|
-
`+ue+e}}var de=!1,ne;{var mr=typeof WeakMap=="function"?WeakMap:Map;ne=new mr}function Le(e,r){if(!e||de)return"";{var s=ne.get(e);if(s!==void 0)return s}var y;de=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var D;D=ce.current,ce.current=null,vr();try{if(r){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(L){y=L}Reflect.construct(e,[],S)}else{try{S.call()}catch(L){y=L}e.call(S.prototype)}}else{try{throw Error()}catch(L){y=L}e()}}catch(L){if(L&&y&&typeof L.stack=="string"){for(var k=L.stack.split(`
|
|
19
|
-
`),N=y.stack.split(`
|
|
20
|
-
`),F=k.length-1,Y=N.length-1;F>=1&&Y>=0&&k[F]!==N[Y];)Y--;for(;F>=1&&Y>=0;F--,Y--)if(k[F]!==N[Y]){if(F!==1||Y!==1)do if(F--,Y--,Y<0||k[F]!==N[Y]){var A=`
|
|
21
|
-
`+k[F].replace(" at new "," at ");return e.displayName&&A.includes("<anonymous>")&&(A=A.replace("<anonymous>",e.displayName)),typeof e=="function"&&ne.set(e,A),A}while(F>=1&&Y>=0);break}}}finally{de=!1,ce.current=D,yr(),Error.prepareStackTrace=T}var H=e?e.displayName||e.name:"",U=H?ae(H):"";return typeof e=="function"&&ne.set(e,U),U}function br(e,r,s){return Le(e,!1)}function wr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function te(e,r,s){if(e==null)return"";if(typeof e=="function")return Le(e,wr(e));if(typeof e=="string")return ae(e);switch(e){case a:return ae("Suspense");case E:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return br(e.render);case w:return te(e.type,r,s);case _:{var y=e,T=y._payload,D=y._init;try{return te(D(T),r,s)}catch{}}}return""}var Z=Object.prototype.hasOwnProperty,Ae={},We=d.ReactDebugCurrentFrame;function se(e){if(e){var r=e._owner,s=te(e.type,e._source,r?r.type:null);We.setExtraStackFrame(s)}else We.setExtraStackFrame(null)}function xr(e,r,s,y,T){{var D=Function.call.bind(Z);for(var S in e)if(D(e,S)){var k=void 0;try{if(typeof e[S]!="function"){var N=Error((y||"React class")+": "+s+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}k=e[S](r,S,y,s,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(F){k=F}k&&!(k instanceof Error)&&(se(T),g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",y||"React class",s,S,typeof k),se(null)),k instanceof Error&&!(k.message in Ae)&&(Ae[k.message]=!0,se(T),g("Failed %s type: %s",s,k.message),se(null))}}}var Er=Array.isArray;function fe(e){return Er(e)}function jr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,s=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s}}function Cr(e){try{return Ve(e),!1}catch{return!0}}function Ve(e){return""+e}function $e(e){if(Cr(e))return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jr(e)),Ve(e)}var Q=d.ReactCurrentOwner,kr={key:!0,ref:!0,__self:!0,__source:!0},Be,Ue,he;he={};function Rr(e){if(Z.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Sr(e){if(Z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function _r(e,r){if(typeof e.ref=="string"&&Q.current&&r&&Q.current.stateNode!==r){var s=W(Q.current.type);he[s]||(g('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',W(Q.current.type),e.ref),he[s]=!0)}}function Tr(e,r){{var s=function(){Be||(Be=!0,g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}}function Dr(e,r){{var s=function(){Ue||(Ue=!0,g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};s.isReactWarning=!0,Object.defineProperty(e,"ref",{get:s,configurable:!0})}}var Mr=function(e,r,s,y,T,D,S){var k={$$typeof:n,type:e,key:r,ref:s,props:S,_owner:D};return k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(k,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function Fr(e,r,s,y,T){{var D,S={},k=null,N=null;s!==void 0&&($e(s),k=""+s),Sr(r)&&($e(r.key),k=""+r.key),Rr(r)&&(N=r.ref,_r(r,T));for(D in r)Z.call(r,D)&&!kr.hasOwnProperty(D)&&(S[D]=r[D]);if(e&&e.defaultProps){var F=e.defaultProps;for(D in F)S[D]===void 0&&(S[D]=F[D])}if(k||N){var Y=typeof e=="function"?e.displayName||e.name||"Unknown":e;k&&Tr(S,Y),N&&Dr(S,Y)}return Mr(e,k,N,T,y,Q.current,S)}}var pe=d.ReactCurrentOwner,ze=d.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,s=te(e.type,e._source,r?r.type:null);ze.setExtraStackFrame(s)}else ze.setExtraStackFrame(null)}var ge;ge=!1;function ve(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function Je(){{if(pe.current){var e=W(pe.current.type);if(e)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function Yr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),s=e.lineNumber;return`
|
|
24
|
-
|
|
25
|
-
Check your code at `+r+":"+s+"."}return""}}var He={};function Or(e){{var r=Je();if(!r){var s=typeof e=="string"?e:e.displayName||e.name;s&&(r=`
|
|
26
|
-
|
|
27
|
-
Check the top-level render call using <`+s+">.")}return r}}function Ge(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=Or(r);if(He[s])return;He[s]=!0;var y="";e&&e._owner&&e._owner!==pe.current&&(y=" It was passed a child from "+W(e._owner.type)+"."),J(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,y),J(null)}}function Ke(e,r){{if(typeof e!="object")return;if(fe(e))for(var s=0;s<e.length;s++){var y=e[s];ve(y)&&Ge(y,r)}else if(ve(e))e._store&&(e._store.validated=!0);else if(e){var T=p(e);if(typeof T=="function"&&T!==e.entries)for(var D=T.call(e),S;!(S=D.next()).done;)ve(S.value)&&Ge(S.value,r)}}}function Pr(e){{var r=e.type;if(r==null||typeof r=="string")return;var s;if(typeof r=="function")s=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===f||r.$$typeof===w))s=r.propTypes;else return;if(s){var y=W(r);xr(s,e.props,"prop",y,e)}else if(r.PropTypes!==void 0&&!ge){ge=!0;var T=W(r);g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nr(e){{for(var r=Object.keys(e.props),s=0;s<r.length;s++){var y=r[s];if(y!=="children"&&y!=="key"){J(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",y),J(null);break}}e.ref!==null&&(J(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}var Xe={};function Ze(e,r,s,y,T,D){{var S=pr(e);if(!S){var k="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N=Yr(T);N?k+=N:k+=Je();var F;e===null?F="null":fe(e)?F="array":e!==void 0&&e.$$typeof===n?(F="<"+(W(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):F=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,k)}var Y=Fr(e,r,s,T,D);if(Y==null)return Y;if(S){var A=r.children;if(A!==void 0)if(y)if(fe(A)){for(var H=0;H<A.length;H++)Ke(A[H],e);Object.freeze&&Object.freeze(A)}else g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ke(A,e)}if(Z.call(r,"key")){var U=W(e),L=Object.keys(r).filter(function($r){return $r!=="key"}),ye=L.length>0?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}";if(!Xe[U+ye]){var Vr=L.length>0?"{"+L.join(": ..., ")+": ...}":"{}";g(`A props object containing a "key" prop is being spread into JSX:
|
|
28
|
-
let props = %s;
|
|
29
|
-
<%s {...props} />
|
|
30
|
-
React keys must be passed directly to JSX without using spread:
|
|
31
|
-
let props = %s;
|
|
32
|
-
<%s key={someKey} {...props} />`,ye,U,Vr,U),Xe[U+ye]=!0}}return e===o?Nr(Y):Pr(Y),Y}}function Ir(e,r,s){return Ze(e,r,s,!0)}function Lr(e,r,s){return Ze(e,r,s,!1)}var Ar=Lr,Wr=Ir;K.Fragment=o,K.jsx=Ar,K.jsxs=Wr}()),K}process.env.NODE_ENV==="production"?ie.exports=Qe():ie.exports=qe();var i=ie.exports;const q=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
|
|
1
|
+
(function(Y,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],r):(Y=typeof globalThis<"u"?globalThis:Y||self,r(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,r,m){"use strict";const N=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
|
|
33
2
|
|
|
34
3
|
* {
|
|
35
4
|
margin: 0;
|
|
@@ -77,23 +46,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
77
46
|
#f9fafb
|
|
78
47
|
);
|
|
79
48
|
|
|
80
|
-
/*
|
|
81
|
-
--starasia-ui-date-color-primary-blue: var(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
);
|
|
85
|
-
--starasia-ui-date-color-secondary-blue: var(
|
|
86
|
-
--starasia-ui-color-blue-500,
|
|
87
|
-
#3b82f6
|
|
88
|
-
);
|
|
89
|
-
--starasia-ui-date-color-tertiary-blue: var(
|
|
90
|
-
--starasia-ui-color-blue-300,
|
|
91
|
-
#93c5fd
|
|
92
|
-
);
|
|
93
|
-
--starasia-ui-date-color-quaternary-blue: var(
|
|
94
|
-
--starasia-ui-color-blue-50,
|
|
95
|
-
#eff6ff
|
|
96
|
-
);
|
|
49
|
+
/* brand */
|
|
50
|
+
--starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default);
|
|
51
|
+
--starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default);
|
|
52
|
+
--starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
|
|
53
|
+
--starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
97
54
|
|
|
98
55
|
/* spacing */
|
|
99
56
|
--starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
|
|
@@ -285,7 +242,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
285
242
|
|
|
286
243
|
.starasia-calendar-input-container:has(input:focus) {
|
|
287
244
|
border-color: var(--starasia-ui-date-color-primary-blue);
|
|
288
|
-
box-shadow: 0px 0px 0px 2px rgba(
|
|
245
|
+
box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary), 0.2);
|
|
289
246
|
}
|
|
290
247
|
.starasia-calendar-input-container:has(input:disabled) {
|
|
291
248
|
/* border-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
@@ -362,4 +319,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
362
319
|
.starasia-calendar-input-container-warning {
|
|
363
320
|
border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
|
|
364
321
|
}
|
|
365
|
-
`,we=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],$=["January","February","March","April","May","June","July","August","September","October","November","December"],er=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function xe(t){const[n,l]=R.useState(t),o=R.useRef(null),u=m=>{o.current&&!o.current.contains(m.target)&&l(!1)};return R.useEffect(()=>(document.addEventListener("click",u,!0),()=>{document.removeEventListener("click",u,!0)}),[]),{ref:o,isComponentVisible:n,setIsComponentVisible:l}}const Ee="starasia-calendar-input-styles";(t=>{if(!document.getElementById(Ee)){const n=document.createElement("style");n.id=Ee,n.textContent=t,document.head.appendChild(n)}})(q);const ee=t=>{if(t==="sm")return 16;if(t==="md")return 16;if(t==="lg")return 20},rr=t=>{const{size:n="md",status:l="default",variant:o="outline",...u}=t,m=R.useRef(null),b=()=>{m.current&&u.onClick&&(m.current.focus(),u.onClick(""))};return i.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${o} starasia-calendar-input-container-${l} ${n} `,onClick:b,children:[i.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:ee(n),height:ee(n),viewBox:"0 0 20 20",fill:"none",children:i.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),i.jsx("div",{className:"starasia-calendar-input-preview-container",children:i.jsx("input",{className:"starasia-calendar-input",...u,disabled:l==="disable"?!0:u.disabled,value:u.value,ref:m})}),i.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:ee(n),height:ee(n),viewBox:"0 0 20 20",fill:"none",children:i.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},ar=({date:t,setDate:n,dateRange:l,setDateRange:o,onChange:u,minDate:m,maxDate:b,input:j})=>{var v,c,p;let f=new Date(t.getFullYear(),t.getMonth(),1),a=f.getDay(),E=[];const w=t.getMonth();for(let d=0;d<42;d++){d===0&&a===0?f.setDate(f.getDate()-7):d===0?f.setDate(f.getDate()+(d-a)):f.setDate(f.getDate()+1);let g={currentMonth:f.getMonth()===w,date:new Date(f),month:f.getMonth(),number:f.getDate(),selected:f.toDateString()===((v=l.from)==null?void 0:v.toDateString())||f.toDateString()===(((c=l.to)==null?void 0:c.toDateString())||((p=l.from)==null?void 0:p.toDateString())),year:f.getFullYear(),isDisabled:m&&f<m||b&&f>b};E.push(g)}const _=d=>{n(d)},M=d=>{var h;let g={...l};if(g.from&&g.to)g={from:d,to:null};else{const x=((h=g.from)==null?void 0:h.getTime())||0;d.getTime()>x?g={from:g.from,to:d}:g={from:d,to:g.from}}o(g),u(g)};return i.jsxs("div",{className:"starasia-calendar-days-preivew",children:[i.jsx("div",{className:"starasia-calendar-days-name-preivew",children:we.map((d,g)=>i.jsx("p",{children:d},g))}),i.jsx("div",{className:"starasia-calendar-days-number-preivew",children:E.map((d,g)=>{var P;const h=d.date.getTime()>l.from.getTime()&&d.date.getTime()<(((P=l.to)==null?void 0:P.getTime())||l.from.getTime()),x=d.isDisabled;return i.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:h?"rgba(100, 181, 246, 0.1)":"",pointerEvents:x?"none":void 0,cursor:x?"not-allowed":"pointer",color:x?"#ccc":h?"#b0b0b0":"",...j?{}:{width:"100%"}},onClick:()=>{x||(_(d.date),M(d.date))},children:d.number},g)})})]})},nr=({date:t,setDate:n,filter:l,setViews:o,dateRange:u,setDateRange:m,onChange:b,minDate:j,maxDate:f,input:a})=>{const E=u.from.getFullYear(),w=t.getFullYear(),_=v=>{l?(M(v),n(v)):(o("days"),n(v))},M=v=>{var p;let c={...u};if(c.from&&c.to)c={from:v,to:null};else{const d=((p=c.from)==null?void 0:p.getTime())||0;v.getTime()>d?c={from:c.from,to:v}:c={from:v,to:c.from}}m(c),b(c)};return i.jsx("div",{className:"starasia-calendar-months-preview",children:$.map((v,c)=>{var g,h,x;const p=new Date(w,c).getTime()>u.from.getTime()&&new Date(w,c).getTime()<(((g=u.to)==null?void 0:g.getTime())||u.from.getTime()),d=j&&new Date(w,c)<j||f&&new Date(w,c)>f;return i.jsx("p",{className:E===w&&(c===((h=u.from)==null?void 0:h.getMonth())||c===((x=u.to)==null?void 0:x.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:p?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":p?"#b0b0b0":"",...a?{}:{width:"100%"}},onClick:()=>{d||_(new Date(w,c))},children:v.slice(0,3)},c)})})},oe=t=>{const n=Math.floor(t/10)*10,l=n+10;return{start:n,end:l}},tr=({date:t,filter:n,setViews:l,setDate:o,dateRange:u,setDateRange:m,onChange:b,minDate:j,maxDate:f,input:a})=>{var g;let E=[];const w=t.getFullYear(),{start:_,end:M}=oe(w),v=u.from.getFullYear(),c=(g=u.to)==null?void 0:g.getFullYear();for(let h=_;h<M;h++){const x=new Date(h,0),P=(!j||x>=j)&&(!f||x<=f),O=h===v||h===c,C=x>u.from&&x<u.to;E.push({year:h,active:O&&P,highlight:C&&P,disabled:!P})}const p=h=>{n?(d(h),o(h)):(o(h),l("months"))},d=h=>{var P;let x={...u};if(x.from&&x.to)x={from:h,to:null};else{const O=((P=x.from)==null?void 0:P.getTime())||0;h.getTime()>O?x={from:x.from,to:h}:x={from:h,to:x.from}}m(x),b(x)};return i.jsx("div",{className:"starasia-calendar-years-preview",children:E.map((h,x)=>i.jsx("p",{className:`${h.active?"starasia-calendar-months-active":""} ${h.highlight?"starasia-calendar-months-highlight":""} ${h.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{h.disabled||p(new Date(h.year,0))},style:{backgroundColor:h.highlight?"rgba(100, 181, 246, 0.1)":"",color:h.highlight?"#b0b0b0":h.active?"":h.disabled?"#ccc":"",cursor:h.disabled?"not-allowed":"pointer",pointerEvents:h.disbled?"none":"all",...a?{}:{width:"100%"}},children:h.year},x))})},je=({...t})=>i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...t,children:i.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ce=({...t})=>i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...t,children:i.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),sr=({setViews:t,views:n,filter:l,date:o,setDate:u})=>{const m=()=>{l||t(a=>a==="days"?"months":a==="months"?"years":"days")},b=()=>{if(n==="years"){u(a=>new Date(a.getFullYear()+10,0));return}if(n==="months"){u(a=>new Date(a.getFullYear()+1,a.getMonth()));return}u(a=>new Date(a.getFullYear(),a.getMonth()+1))},j=()=>{if(n==="years"){u(a=>new Date(a.getFullYear()-10,0));return}if(n==="months"){u(a=>new Date(a.getFullYear()-1,a.getMonth()));return}u(a=>new Date(a.getMonth()===0?a.getFullYear()-1:a.getFullYear(),a.getMonth()===0?11:a.getMonth()-1))},f=()=>{if(n==="days")return`${$[o.getMonth()]} ${o.getFullYear()}`;if(n==="months")return`${o.getFullYear()}`;if(n==="years")return`${oe(o.getFullYear()).start} ~ ${oe(o.getFullYear()).end}`};return i.jsxs("div",{className:"starasia-calendar-header",children:[i.jsx(je,{onClick:()=>j()}),i.jsx("div",{style:{cursor:"pointer"},onClick:m,children:f()}),i.jsx(Ce,{onClick:()=>b()})]})};function z(t){const n=new Date(t),l=n.getFullYear(),o=n.getMonth();return`${n.getDate().toString().padStart(2,"0")} ${er[o]} ${l}`}const ke="starasia-calendar-styles";(t=>{if(!document.getElementById(ke)){const n=document.createElement("style");n.id=ke,n.textContent=t,document.head.appendChild(n)}})(q);const ir=R.forwardRef(({value:t,onChange:n,filter:l,input:o=!0,disabled:u,minDate:m,maxDate:b,placeholder:j,size:f,status:a},E)=>{const{ref:w,isComponentVisible:_,setIsComponentVisible:M}=xe(!1),v=R.useRef(null),[c,p]=R.useState("days"),[d,g]=R.useState(new Date),[h,x]=R.useState({from:(t==null?void 0:t.from)||new Date,to:(t==null?void 0:t.to)||new Date});R.useEffect(()=>{t?(g(t.from),x(t)):(g(new Date),x({from:new Date,to:new Date}))},[t]),R.useEffect(()=>{l&&p(l)},[l]),R.useEffect(()=>{l||p("days")},[_]),R.useEffect(()=>{o||M(!0)},[o]);const P=()=>{var C,I;if(!t)return"";if(l){if(c==="days")return`${z(h.from)} ~ ${z(h.to||h.from)||"-"}`;if(c==="months")return`${$[h.from.getMonth()]} ~ ${h.to?$[h.to.getMonth()]:"-"}`;if(c==="years")return`${(C=h.from)==null?void 0:C.getFullYear()} ~ ${((I=h.to)==null?void 0:I.getFullYear())||"-"}`}else return`${z(h.from)} ~ ${z(h.to||h.from)||"-"}`},O=()=>{if(v.current&&w.current&&o){const C=w.current.getBoundingClientRect(),I=v.current.getBoundingClientRect();window.innerWidth<C.left+I.width?v.current.style.left=`${C.left-I.width+C.width}px`:v.current.style.left=`${C.left}px`,C.top+I.height>window.innerHeight?v.current.style.top=`${C.y-(C.height+I.height-28)}px`:v.current.style.top=`${C.y+C.height}px`}};return R.useEffect(()=>{v.current&&w.current&&o&&O()},[v,w,_]),R.useEffect(()=>{const C=E==null?void 0:E.current;return C&&C.addEventListener("scroll",O),window.addEventListener("scroll",O),()=>{C&&C.removeEventListener("scroll",O),window.removeEventListener("scroll",O)}},[]),i.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?w:null,children:[o?i.jsx(rr,{value:P(),inputMode:"none",onClick:()=>{M(!0)},onChange:()=>{},disabled:u,placeholder:j,size:f,status:a}):null,_?i.jsxs("div",{className:`starasia-calendar ${o?"":"starasia-calendar-no-input"}`,ref:v,children:[i.jsx(sr,{setViews:p,views:c,filter:l,date:d,setDate:g}),i.jsx("div",{className:"starasia-calendar-body",children:c==="days"?i.jsx(ar,{date:d,setDate:g,setIsComponentVisible:M,dateRange:h,setDateRange:x,input:o,onChange:n,minDate:m,maxDate:b}):c==="months"?i.jsx(nr,{date:d,setDate:g,filter:l,setViews:p,dateRange:h,setDateRange:x,setIsComponentVisible:M,input:o,onChange:n,minDate:m,maxDate:b}):i.jsx(tr,{date:d,setDate:g,filter:l,setViews:p,dateRange:h,setDateRange:x,setIsComponentVisible:M,input:o,onChange:n,minDate:m,maxDate:b})})]}):null]})}),Re="starasia-calendar-input-styles";(t=>{if(!document.getElementById(Re)){const n=document.createElement("style");n.id=Re,n.textContent=t,document.head.appendChild(n)}})(q);const re=t=>{if(t==="sm")return 16;if(t==="md")return 16;if(t==="lg")return 20},or=t=>{const{size:n="md",status:l="default",variant:o="outline",...u}=t,m=R.useRef(null),b=()=>{m.current&&u.onClick&&(m.current.focus(),u.onClick(""))};return i.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${o} starasia-calendar-input-container-${l} ${n} `,onClick:b,children:[i.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:re(n),height:re(n),viewBox:"0 0 20 20",fill:"none",children:i.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),i.jsx("div",{className:"starasia-calendar-input-preview-container",children:i.jsx("input",{className:"starasia-calendar-input",...u,disabled:l==="disable"?!0:u.disabled,value:u.value,ref:m})}),i.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:re(n),height:re(n),viewBox:"0 0 20 20",fill:"none",children:i.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},lr=({date:t,setDate:n,previewDate:l,setPreviewDate:o,setIsComponentVisible:u,minDate:m,maxDate:b,input:j,onChange:f})=>{let a=new Date(l.getFullYear(),l.getMonth(),1),E=a.getDay(),w=[];const _=t.toDateString(),M=l.getMonth();for(let c=0;c<42;c++){c===0&&E===0?a.setDate(a.getDate()-7):c===0?a.setDate(a.getDate()+(c-E)):a.setDate(a.getDate()+1);let p={currentMonth:a.getMonth()===M,date:new Date(a),month:a.getMonth(),number:a.getDate(),selected:a.toDateString()===_,year:a.getFullYear(),isDisabled:m&&a<m||b&&a>b};w.push(p)}const v=c=>{(!m||c>=m)&&(!b||c<=b)&&(n(c),f(c),o(c),j&&u(!1))};return i.jsxs("div",{className:"starasia-calendar-days-preivew",children:[i.jsx("div",{className:"starasia-calendar-days-name-preivew",children:we.map((c,p)=>i.jsx("p",{children:c},p))}),i.jsx("div",{className:"starasia-calendar-days-number-preivew",children:w.map((c,p)=>{const d=c.isDisabled;return i.jsx("p",{className:`${c.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${c.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...j?{}:{width:"100%"}},onClick:()=>{d||v(c.date)},children:c.number},p)})})]})},cr=({date:t,setDate:n,filter:l,setViews:o,onChange:u,previewDate:m,setPreviewDate:b,minDate:j,maxDate:f,input:a})=>{const E=t.getMonth(),w=t.getFullYear(),_=m.getFullYear(),M=v=>{(!j||v>=j)&&(!f||v<=f)&&(l?(u(v),n(v),b(v)):(o("days"),b(v)))};return i.jsx("div",{className:"starasia-calendar-months-preview",children:$.map((v,c)=>{const p=j&&new Date(_,c,1)<j||f&&new Date(_,c+1,0)>f;return i.jsx("p",{className:c===E&&_===w?"starasia-calendar-months-active":"",style:{color:p?"#ccc":void 0,pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",...a?{}:{width:"100%"}},onClick:()=>{p||M(new Date(_,c))},children:v.slice(0,3)},c)})})},le=t=>{const n=Math.floor(t/10)*10,l=n+10;return{start:n,end:l}},ur=({date:t,filter:n,setViews:l,setDate:o,onChange:u,previewDate:m,setPreviewDate:b,minDate:j,maxDate:f,input:a})=>{let E=[];const w=m.getFullYear(),{start:_,end:M}=le(w),v=t.getFullYear();for(let p=_;p<M;p++){let d=j&&new Date(p,0,1)<j||f&&new Date(p,11,31)>f;E.push({year:p,active:p===v,isDisabled:d})}const c=p=>{(!j||p>=j)&&(!f||p<=f)&&(n?(u(p),o(p),b(p)):(l("months"),b(p)))};return i.jsx("div",{className:"starasia-calendar-years-preview",children:E.map((p,d)=>i.jsx("p",{className:p.active?"starasia-calendar-months-active":"",style:{color:p.isDisabled?"#ccc":void 0,pointerEvents:p.isDisabled?"none":void 0,cursor:p.isDisabled?"not-allowed":"pointer",...a?{}:{width:"100%"}},onClick:()=>{p.isDisabled||c(new Date(p.year,0))},children:p.year},d))})},dr=({setViews:t,views:n,filter:l,previewDate:o,setPreviewDate:u})=>{const m=()=>{l||t(a=>a==="days"?"months":a==="months"?"years":"days")},b=()=>{if(n==="years"){u(a=>new Date(a.getFullYear()+10,0));return}if(n==="months"){u(a=>new Date(a.getFullYear()+1,a.getMonth()));return}u(a=>new Date(a.getFullYear(),a.getMonth()+1))},j=()=>{if(n==="years"){u(a=>new Date(a.getFullYear()-10,0));return}if(n==="months"){u(a=>new Date(a.getFullYear()-1,a.getMonth()));return}u(a=>new Date(a.getMonth()===0?a.getFullYear()-1:a.getFullYear(),a.getMonth()===0?11:a.getMonth()-1))},f=()=>{if(n==="days")return`${$[o.getMonth()]} ${o.getFullYear()}`;if(n==="months")return`${o.getFullYear()}`;if(n==="years")return`${le(o.getFullYear()).start} ~ ${le(o.getFullYear()).end}`};return i.jsxs("div",{className:"starasia-calendar-header",children:[i.jsx(je,{onClick:()=>j()}),i.jsx("div",{style:{cursor:"pointer"},onClick:m,children:f()}),i.jsx(Ce,{onClick:()=>b()})]})},Se="starasia-calendar-styles";(t=>{if(!document.getElementById(Se)){const n=document.createElement("style");n.id=Se,n.textContent=t,document.head.appendChild(n)}})(q);const fr=R.forwardRef(({value:t,onChange:n,filter:l,input:o=!0,disabled:u,minDate:m,maxDate:b,placeholder:j,size:f,status:a},E)=>{const{ref:w,isComponentVisible:_,setIsComponentVisible:M}=xe(!1),v=R.useRef(null),[c,p]=R.useState("days"),[d,g]=R.useState(new Date),[h,x]=R.useState(new Date);R.useEffect(()=>{t?(g(t),x(t)):(g(new Date),x(new Date))},[t]),R.useEffect(()=>{l&&p(l)},[l]),R.useEffect(()=>{l||p("days")},[_]),R.useEffect(()=>{o||M(!0)},[o]);const P=()=>t?l==="days"?z(d):l==="months"?`${$[d.getMonth()]} ${d.getFullYear()}`:l==="years"?d.getFullYear():z(d):"",O=()=>{if(v.current&&w.current&&o){const C=w.current.getBoundingClientRect(),I=v.current.getBoundingClientRect();window.innerWidth<C.left+I.width?v.current.style.left=`${C.left-I.width+C.width}px`:v.current.style.left=`${C.left}px`,C.top+I.height>window.innerHeight?v.current.style.top=`${C.y-(C.height+I.height-28)}px`:v.current.style.top=`${C.y+C.height}px`}};return R.useEffect(()=>{v.current&&w.current&&o&&O()},[v,w,_]),R.useEffect(()=>{const C=E==null?void 0:E.current;return C&&C.addEventListener("scroll",O),window.addEventListener("scroll",O),()=>{C&&C.removeEventListener("scroll",O),window.removeEventListener("scroll",O)}},[]),i.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?w:null,children:[o?i.jsx(or,{value:P(),onClick:()=>M(!0),onChange:()=>{},placeholder:j,disabled:u,size:f,status:a,inputMode:"none"}):null,_?i.jsxs("div",{className:`starasia-calendar ${o?"":"starasia-calendar-no-input"}`,ref:v,children:[i.jsx(dr,{setViews:p,views:c,filter:l,previewDate:h,setPreviewDate:x,isComponentVisible:_}),i.jsx("div",{className:"starasia-calendar-body",children:c==="days"?i.jsx(lr,{date:d,setDate:g,previewDate:h,setPreviewDate:x,setIsComponentVisible:M,input:o,minDate:m,maxDate:b,onChange:n}):c==="months"?i.jsx(cr,{date:d,setDate:g,previewDate:h,setPreviewDate:x,filter:l,setViews:p,onChange:n,minDate:m,maxDate:b,input:o}):i.jsx(ur,{date:d,setDate:g,previewDate:h,setPreviewDate:x,filter:l,setViews:p,onChange:n,minDate:m,maxDate:b,input:o})})]}):null]})}),hr=R.forwardRef(({value:t,onChange:n,filter:l,input:o=!0,rangedDate:u,disabled:m,minDate:b,maxDate:j,placeholder:f,size:a,status:E},w)=>i.jsx(i.Fragment,{children:u?i.jsx(ir,{onChange:n,value:t,input:o,filter:l,disabled:m,ref:w,minDate:b,maxDate:j,placeholder:f,size:a,status:E}):i.jsx(fr,{onChange:n,value:t,input:o,filter:l,disabled:m,ref:w,minDate:b,maxDate:j,placeholder:f,size:a,status:E})}));V.StarasiaDate=hr,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
|
322
|
+
`,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(n){const[a,s]=m.useState(n),i=m.useRef(null),o=g=>{i.current&&!i.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:i,isComponentVisible:a,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(n=>{if(!document.getElementById(V)){const a=document.createElement("style");a.id=V,a.textContent=n,document.head.appendChild(a)}})(N);const S=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},J=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},P=({date:n,setDate:a,dateRange:s,setDateRange:i,onChange:o,minDate:g,maxDate:f,input:w})=>{var u,t,c;let h=new Date(n.getFullYear(),n.getMonth(),1),e=h.getDay(),k=[];const v=n.getMonth();for(let d=0;d<42;d++){d===0&&e===0?h.setDate(h.getDate()-7):d===0?h.setDate(h.getDate()+(d-e)):h.setDate(h.getDate()+1);let y={currentMonth:h.getMonth()===v,date:new Date(h),month:h.getMonth(),number:h.getDate(),selected:h.toDateString()===((u=s.from)==null?void 0:u.toDateString())||h.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:h.getFullYear(),isDisabled:g&&h<g||f&&h>f};k.push(y)}const M=d=>{a(d)},x=d=>{var l;let y={...s};if(y.from&&y.to)y={from:d,to:null};else{const p=((l=y.from)==null?void 0:l.getTime())||0;d.getTime()>p?y={from:y.from,to:d}:y={from:d,to:y.from}}i(y),o(y)};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((d,y)=>r.jsx("p",{children:d},y))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:k.map((d,y)=>{var D;const l=d.date.getTime()>s.from.getTime()&&d.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),p=d.isDisabled;return r.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:l?"rgba(100, 181, 246, 0.1)":"",pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",color:p?"#ccc":l?"#b0b0b0":"",...w?{}:{width:"100%"}},onClick:()=>{p||(M(d.date),x(d.date))},children:d.number},y)})})]})},G=({date:n,setDate:a,filter:s,setViews:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{const k=o.from.getFullYear(),v=n.getFullYear(),M=u=>{s?(x(u),a(u)):(i("days"),a(u))},x=u=>{var c;let t={...o};if(t.from&&t.to)t={from:u,to:null};else{const d=((c=t.from)==null?void 0:c.getTime())||0;u.getTime()>d?t={from:t.from,to:u}:t={from:u,to:t.from}}g(t),f(t)};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{var y,l,p;const c=new Date(v,t).getTime()>o.from.getTime()&&new Date(v,t).getTime()<(((y=o.to)==null?void 0:y.getTime())||o.from.getTime()),d=w&&new Date(v,t)<w||h&&new Date(v,t)>h;return r.jsx("p",{className:k===v&&(t===((l=o.from)==null?void 0:l.getMonth())||t===((p=o.to)==null?void 0:p.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:c?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":c?"#b0b0b0":"",...e?{}:{width:"100%"}},onClick:()=>{d||M(new Date(v,t))},children:u.slice(0,3)},t)})})},T=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},U=({date:n,filter:a,setViews:s,setDate:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{var y;let k=[];const v=n.getFullYear(),{start:M,end:x}=T(v),u=o.from.getFullYear(),t=(y=o.to)==null?void 0:y.getFullYear();for(let l=M;l<x;l++){const p=new Date(l,0),D=(!w||p>=w)&&(!h||p<=h),C=l===u||l===t,b=p>o.from&&p<o.to;k.push({year:l,active:C&&D,highlight:b&&D,disabled:!D})}const c=l=>{a?(d(l),i(l)):(i(l),s("months"))},d=l=>{var D;let p={...o};if(p.from&&p.to)p={from:l,to:null};else{const C=((D=p.from)==null?void 0:D.getTime())||0;l.getTime()>C?p={from:p.from,to:l}:p={from:l,to:p.from}}g(p),f(p)};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((l,p)=>r.jsx("p",{className:`${l.active?"starasia-calendar-months-active":""} ${l.highlight?"starasia-calendar-months-highlight":""} ${l.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{l.disabled||c(new Date(l.year,0))},style:{backgroundColor:l.highlight?"rgba(100, 181, 246, 0.1)":"",color:l.highlight?"#b0b0b0":l.active?"":l.disabled?"#ccc":"",cursor:l.disabled?"not-allowed":"pointer",pointerEvents:l.disbled?"none":"all",...e?{}:{width:"100%"}},children:l.year},p))})},W=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),z=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:n,views:a,filter:s,date:i,setDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${T(i.getFullYear()).start} ~ ${T(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})};function E(n){const a=new Date(n),s=a.getFullYear(),i=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${q[i]} ${s}`}const O="starasia-calendar-styles";(n=>{if(!document.getElementById(O)){const a=document.createElement("style");a.id=O,a.textContent=n,document.head.appendChild(a)}})(N);const Q=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState({from:(n==null?void 0:n.from)||new Date,to:(n==null?void 0:n.to)||new Date});m.useEffect(()=>{n?(y(n.from),p(n)):(y(new Date),p({from:new Date,to:new Date}))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>{var b,$;if(!n)return"";if(s){if(t==="days")return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`;if(t==="months")return`${F[l.from.getMonth()]} ~ ${l.to?F[l.to.getMonth()]:"-"}`;if(t==="years")return`${(b=l.from)==null?void 0:b.getFullYear()} ~ ${(($=l.to)==null?void 0:$.getFullYear())||"-"}`}else return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`},C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(J,{value:D(),inputMode:"none",onClick:()=>{x(!0)},onChange:()=>{},disabled:o,placeholder:w,size:h,status:e}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(K,{setViews:c,views:t,filter:s,date:d,setDate:y}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(P,{date:d,setDate:y,setIsComponentVisible:x,dateRange:l,setDateRange:p,input:i,onChange:a,minDate:g,maxDate:f}):t==="months"?r.jsx(G,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f}):r.jsx(U,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f})})]}):null]})}),H="starasia-calendar-input-styles";(n=>{if(!document.getElementById(H)){const a=document.createElement("style");a.id=H,a.textContent=n,document.head.appendChild(a)}})(N);const L=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},X=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:n,setDate:a,previewDate:s,setPreviewDate:i,setIsComponentVisible:o,minDate:g,maxDate:f,input:w,onChange:h})=>{let e=new Date(s.getFullYear(),s.getMonth(),1),k=e.getDay(),v=[];const M=n.toDateString(),x=s.getMonth();for(let t=0;t<42;t++){t===0&&k===0?e.setDate(e.getDate()-7):t===0?e.setDate(e.getDate()+(t-k)):e.setDate(e.getDate()+1);let c={currentMonth:e.getMonth()===x,date:new Date(e),month:e.getMonth(),number:e.getDate(),selected:e.toDateString()===M,year:e.getFullYear(),isDisabled:g&&e<g||f&&e>f};v.push(c)}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(a(t),h(t),i(t),w&&o(!1))};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,c)=>r.jsx("p",{children:t},c))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:v.map((t,c)=>{const d=t.isDisabled;return r.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{d||u(t.date)},children:t.number},c)})})]})},_=({date:n,setDate:a,filter:s,setViews:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{const k=n.getMonth(),v=n.getFullYear(),M=g.getFullYear(),x=u=>{(!w||u>=w)&&(!h||u<=h)&&(s?(o(u),a(u),f(u)):(i("days"),f(u)))};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{const c=w&&new Date(M,t,1)<w||h&&new Date(M,t+1,0)>h;return r.jsx("p",{className:t===k&&M===v?"starasia-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c||x(new Date(M,t))},children:u.slice(0,3)},t)})})},I=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},R=({date:n,filter:a,setViews:s,setDate:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{let k=[];const v=g.getFullYear(),{start:M,end:x}=I(v),u=n.getFullYear();for(let c=M;c<x;c++){let d=w&&new Date(c,0,1)<w||h&&new Date(c,11,31)>h;k.push({year:c,active:c===u,isDisabled:d})}const t=c=>{(!w||c>=w)&&(!h||c<=h)&&(a?(o(c),i(c),f(c)):(s("months"),f(c)))};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((c,d)=>r.jsx("p",{className:c.active?"starasia-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},d))})},aa=({setViews:n,views:a,filter:s,previewDate:i,setPreviewDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${I(i.getFullYear()).start} ~ ${I(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})},A="starasia-calendar-styles";(n=>{if(!document.getElementById(A)){const a=document.createElement("style");a.id=A,a.textContent=n,document.head.appendChild(a)}})(N);const ea=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState(new Date);m.useEffect(()=>{n?(y(n),p(n)):(y(new Date),p(new Date))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>n?s==="days"?E(d):s==="months"?`${F[d.getMonth()]} ${d.getFullYear()}`:s==="years"?d.getFullYear():E(d):"",C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(X,{value:D(),onClick:()=>x(!0),onChange:()=>{},placeholder:w,disabled:o,size:h,status:e,inputMode:"none"}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(aa,{setViews:c,views:t,filter:s,previewDate:l,setPreviewDate:p,isComponentVisible:M}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(Z,{date:d,setDate:y,previewDate:l,setPreviewDate:p,setIsComponentVisible:x,input:i,minDate:g,maxDate:f,onChange:a}):t==="months"?r.jsx(_,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i}):r.jsx(R,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i})})]}):null]})}),ra=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,rangedDate:o,disabled:g,minDate:f,maxDate:w,placeholder:h,size:e,status:k},v)=>r.jsx(r.Fragment,{children:o?r.jsx(Q,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k}):r.jsx(ea,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k})}));Y.StarasiaDate=ra,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|