@starasia/date 1.0.0
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/README.md +83 -0
- package/dist/date.es.js +1943 -0
- package/dist/date.umd.js +365 -0
- package/dist/index.d.ts +2 -0
- package/dist/interfaces.d.ts +116 -0
- package/package.json +37 -0
package/dist/date.umd.js
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
(function(V,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],R):(V=typeof globalThis<"u"?globalThis:V||self,R(V.Date={},V.React))})(this,function(V,R){"use strict";var ie={exports:{}},G={};/**
|
|
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");
|
|
33
|
+
|
|
34
|
+
* {
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
font-family: "Poppins", sans-serif;
|
|
38
|
+
font-style: normal;
|
|
39
|
+
/* box-sizing: border-box; */
|
|
40
|
+
}
|
|
41
|
+
:root {
|
|
42
|
+
/* border radius */
|
|
43
|
+
--starasia-ui-date-border-radius: var(--starasia-ui-radii-md, 8px);
|
|
44
|
+
--starasia-ui-date-border-radius-sm: var(--starasia-ui-radii-md, 8px);
|
|
45
|
+
--starasia-ui-date-border-radius-md: var(--starasia-ui-radii-md, 8px);
|
|
46
|
+
--starasia-ui-date-border-radius-lg: var(--starasia-ui-radii-lg, 12px);
|
|
47
|
+
|
|
48
|
+
/* color */
|
|
49
|
+
--starasia-ui-date-color-black-secondary: var(
|
|
50
|
+
--starasia-ui-color-gray-50,
|
|
51
|
+
#f9fafb
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
/* box shadow */
|
|
55
|
+
--starasia-ui-date-box-shadow: var(
|
|
56
|
+
--starasia-ui-shadow-md,
|
|
57
|
+
0 4px 6px -1px rgb(0 0 0 / 0.1),
|
|
58
|
+
0 2px 4px -2px rgb(0 0 0 / 0.1)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
/* color */
|
|
62
|
+
/* gray / black */
|
|
63
|
+
--starasia-ui-date-color-primary-black: var(
|
|
64
|
+
--starasia-ui-color-gray-700,
|
|
65
|
+
#374151
|
|
66
|
+
);
|
|
67
|
+
--starasia-ui-date-color-secondary-black: var(
|
|
68
|
+
--starasia-ui-color-gray-500,
|
|
69
|
+
#6b7280
|
|
70
|
+
);
|
|
71
|
+
--starasia-ui-date-color-tertiary-black: var(
|
|
72
|
+
--starasia-ui-color-gray-300,
|
|
73
|
+
#d1d5db
|
|
74
|
+
);
|
|
75
|
+
--starasia-ui-date-color-quaternary-black: var(
|
|
76
|
+
--starasia-ui-color-gray-50,
|
|
77
|
+
#f9fafb
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
/* gray / blue */
|
|
81
|
+
--starasia-ui-date-color-primary-blue: var(
|
|
82
|
+
--starasia-ui-color-blue-500,
|
|
83
|
+
#3b82f6
|
|
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
|
+
);
|
|
97
|
+
|
|
98
|
+
/* spacing */
|
|
99
|
+
--starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
|
|
100
|
+
--starasia-ui-date-spacing-sm: var(--starasia-ui-spacing-sm, 8px);
|
|
101
|
+
--starasia-ui-date-spacing-ms: var(--starasia-ui-spacing-3, 12px);
|
|
102
|
+
--starasia-ui-date-spacing-md: var(--starasia-ui-spacing-md, 16);
|
|
103
|
+
--starasia-ui-date-spacing-lg: var(--starasia-ui-spacing-lg, 24px);
|
|
104
|
+
|
|
105
|
+
/* height */
|
|
106
|
+
--starasia-ui-date-input-height: var(--starasia-ui-h-10, 40px);
|
|
107
|
+
--starasia-ui-date-height-sm: var(--starasia-ui-h-8, 32px);
|
|
108
|
+
--starasia-ui-date-height-md: 38px;
|
|
109
|
+
--starasia-ui-date-height-lg: var(--starasia-ui-h-12, 48px);
|
|
110
|
+
|
|
111
|
+
/* color */
|
|
112
|
+
--starasia-ui-input-color-tertiary-gray: var(
|
|
113
|
+
--starasia-ui-color-gray-300,
|
|
114
|
+
#d1d5db
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
--starasia-ui-date-placholder-color: var(
|
|
118
|
+
--starasia-ui-color-gray-200,
|
|
119
|
+
#c9cecc
|
|
120
|
+
);
|
|
121
|
+
--starasia-ui-date-placholder-fontWeight: var(
|
|
122
|
+
--starasia-ui-fontWeights-normal,
|
|
123
|
+
300
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
--starasia-ui-input-color-secondary-red: var(
|
|
127
|
+
--starasia-ui-color-red-500,
|
|
128
|
+
#ef4444
|
|
129
|
+
);
|
|
130
|
+
--starasia-ui-input-color-secondary-yellow: var(
|
|
131
|
+
--starasia-ui-color-yellow-500,
|
|
132
|
+
#eab308
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
.starasia-calendar-wrapper {
|
|
136
|
+
position: relative;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.starasia-calendar {
|
|
140
|
+
border-radius: var(--starasia-ui-date-border-radius);
|
|
141
|
+
border: var(--starasia-ui-border, 1px) solid
|
|
142
|
+
var(--starasia-ui-date-color-black-secondary);
|
|
143
|
+
background: var(--starasia-ui-date-color-black-secondary);
|
|
144
|
+
box-shadow: var(--starasia-ui-date-box-shadow);
|
|
145
|
+
padding: var(--starasia-ui-date-spacing-lg) var(--starasia-ui-date-spacing-md);
|
|
146
|
+
width: max-content;
|
|
147
|
+
display: flex;
|
|
148
|
+
gap: var(--starasia-ui-date-spacing-ms);
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
position: fixed;
|
|
151
|
+
z-index: 999;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.starasia-calendar.starasia-calendar-no-input {
|
|
155
|
+
position: relative !important;
|
|
156
|
+
margin-top: 0px;
|
|
157
|
+
|
|
158
|
+
/* bellow is for input no input */
|
|
159
|
+
width: 100%;
|
|
160
|
+
box-shadow: unset;
|
|
161
|
+
border: none;
|
|
162
|
+
background-color: white;
|
|
163
|
+
/* background-color: white; */
|
|
164
|
+
height: 100%;
|
|
165
|
+
border-radius: 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.starasia-calendar-header {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: row;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: space-between;
|
|
173
|
+
gap: var(--starasia-ui-date-spacing-xs);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.starasia-calendar-days-name-preivew {
|
|
177
|
+
display: flex;
|
|
178
|
+
gap: var(--starasia-ui-date-spacing-sm);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.starasia-calendar-days-name-preivew p {
|
|
182
|
+
color: var(--starasia-ui-date-color-secondary-black);
|
|
183
|
+
font-size: var(--starasia-ui-fontSizes-md, 14px);
|
|
184
|
+
flex: 1;
|
|
185
|
+
display: grid;
|
|
186
|
+
place-content: center;
|
|
187
|
+
}
|
|
188
|
+
.starasia-calendar-days-number-preivew {
|
|
189
|
+
display: grid;
|
|
190
|
+
grid-template-columns: repeat(7, 1fr);
|
|
191
|
+
gap: var(--starasia-ui-date-spacing-sm);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.starasia-calendar-days-number-preivew p {
|
|
195
|
+
font-size: var(--starasia-ui-fontSizes-md, 14px);
|
|
196
|
+
text-align: center;
|
|
197
|
+
width: 35px;
|
|
198
|
+
height: 32px;
|
|
199
|
+
flex: 1;
|
|
200
|
+
display: grid;
|
|
201
|
+
place-content: center;
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
font-weight: 500;
|
|
204
|
+
border-radius: var(--starasia-ui-date-border-radius);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.starasia-calendar-days {
|
|
208
|
+
color: var(--starasia-ui-date-color-tertiary-black);
|
|
209
|
+
}
|
|
210
|
+
.starasia-calendar-days-current {
|
|
211
|
+
color: var(--starasia-ui-date-color-primary-black);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.starasia-calendar-days-number-preivew p:hover {
|
|
215
|
+
background: var(--starasia-ui-date-color-quaternary-blue);
|
|
216
|
+
color: var(--starasia-ui-date-color-tertiary-blue);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.starasia-calendar-days-active {
|
|
220
|
+
background: var(--starasia-ui-date-color-tertiary-blue);
|
|
221
|
+
color: var(--starasia-ui-date-color-primary-blue);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* MONTH STYLING */
|
|
225
|
+
.starasia-calendar-months-preview {
|
|
226
|
+
display: grid;
|
|
227
|
+
grid-template-columns: repeat(3, 1fr);
|
|
228
|
+
row-gap: var(--starasia-ui-date-spacing-xs);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.starasia-calendar-months-preview p {
|
|
232
|
+
width: 98px;
|
|
233
|
+
height: 48px;
|
|
234
|
+
display: grid;
|
|
235
|
+
place-content: center;
|
|
236
|
+
cursor: pointer;
|
|
237
|
+
border-radius: var(--starasia-ui-date-border-radius);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.starasia-calendar-months-preview p:hover {
|
|
241
|
+
background: var(--starasia-ui-date-color-quaternary-blue);
|
|
242
|
+
color: var(--starasia-ui-date-color-tertiary-blue);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.starasia-calendar-months-active {
|
|
246
|
+
background: var(--starasia-ui-date-color-tertiary-blue);
|
|
247
|
+
color: var(--starasia-ui-date-color-primary-blue);
|
|
248
|
+
}
|
|
249
|
+
/* Year STYLING */
|
|
250
|
+
.starasia-calendar-years-preview {
|
|
251
|
+
display: grid;
|
|
252
|
+
grid-template-columns: repeat(3, 1fr);
|
|
253
|
+
row-gap: var(--starasia-ui-date-spacing-xs);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.starasia-calendar-years-preview p {
|
|
257
|
+
width: 98px;
|
|
258
|
+
height: 48px;
|
|
259
|
+
display: grid;
|
|
260
|
+
place-content: center;
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
border-radius: var(--starasia-ui-date-border-radius);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.starasia-calendar-years-preview p:hover {
|
|
266
|
+
background: var(--starasia-ui-date-color-quaternary-blue);
|
|
267
|
+
color: var(--starasia-ui-date-color-tertiary-blue);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.starasia-calendar-years-active {
|
|
271
|
+
background: var(--starasia-ui-date-color-tertiary-blue);
|
|
272
|
+
color: var(--starasia-ui-date-color-primary-blue);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* INPUT */
|
|
276
|
+
|
|
277
|
+
.starasia-calendar-input-container {
|
|
278
|
+
box-sizing: border-box;
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
display: flex;
|
|
281
|
+
align-items: center;
|
|
282
|
+
gap: var(--starasia-ui-date-spacing-sm);
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.starasia-calendar-input-container:has(input:focus) {
|
|
287
|
+
border-color: var(--starasia-ui-date-color-primary-blue);
|
|
288
|
+
box-shadow: 0px 0px 0px 2px rgba(100, 181, 246, 0.2);
|
|
289
|
+
}
|
|
290
|
+
.starasia-calendar-input-container:has(input:disabled) {
|
|
291
|
+
/* border-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
292
|
+
/* background-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
293
|
+
border-color: rgba(120, 134, 127, 0.2);
|
|
294
|
+
background-color: rgba(120, 134, 127, 0.1);
|
|
295
|
+
pointer-events: none;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.starasia-calendar-input-outline {
|
|
299
|
+
border-color: rgba(120, 134, 127, 0.2);
|
|
300
|
+
/* border-color: var(--starasia-ui-date-color-tertiary-black); */
|
|
301
|
+
background-color: transparent;
|
|
302
|
+
border-width: var(--starasia-ui-border, 1px);
|
|
303
|
+
border-style: solid;
|
|
304
|
+
/* height: var(--starasia-ui-date-input-height); */
|
|
305
|
+
/* border-radius: var(--starasia-ui-date-border-radius); */
|
|
306
|
+
/* padding-inline: var(--starasia-ui-date-spacing-ms); */
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.starasia-calendar-input-container.sm {
|
|
310
|
+
height: var(--starasia-ui-date-height-sm);
|
|
311
|
+
border-radius: var(--starasia-ui-date-border-radius-sm);
|
|
312
|
+
font-size: var(--starasia-ui-fontSizes-sm, 12px);
|
|
313
|
+
padding-inline: var(--starasia-ui-date-spacing-sm);
|
|
314
|
+
}
|
|
315
|
+
.starasia-calendar-input-container.md {
|
|
316
|
+
height: var(--starasia-ui-date-height-md);
|
|
317
|
+
border-radius: var(--starasia-ui-date-border-radius-md);
|
|
318
|
+
font-size: var(--starasia-ui-fontSizes-md, 14px);
|
|
319
|
+
padding-inline: var(--starasia-ui-date-spacing-ms);
|
|
320
|
+
}
|
|
321
|
+
.starasia-calendar-input-container.lg {
|
|
322
|
+
height: var(--starasia-ui-date-height-lg);
|
|
323
|
+
border-radius: var(--starasia-ui-date-border-radius-lg);
|
|
324
|
+
font-size: var(--starasia-ui-fontSizes-lg, 16px);
|
|
325
|
+
padding-inline: var(--starasia-ui-date-spacing-ms);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.starasia-calendar-input-preview-container {
|
|
329
|
+
width: 100%;
|
|
330
|
+
position: relative;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.starasia-calendar-input {
|
|
334
|
+
width: 100%;
|
|
335
|
+
box-sizing: border-box;
|
|
336
|
+
height: 100%;
|
|
337
|
+
border: none;
|
|
338
|
+
outline: none;
|
|
339
|
+
font-size: inherit;
|
|
340
|
+
font-weight: 500;
|
|
341
|
+
background: transparent;
|
|
342
|
+
cursor: pointer;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.starasia-calendar-input::placeholder {
|
|
346
|
+
color: var(--starasia-ui-date-placholder-color);
|
|
347
|
+
font-weight: var(--starasia-ui-date-placholder-fontWeight);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* INPUT ICON */
|
|
351
|
+
.starasia-calendar-input-container-icon-left {
|
|
352
|
+
display: flex;
|
|
353
|
+
}
|
|
354
|
+
.starasia-calendar-input-container-icon-right {
|
|
355
|
+
display: flex;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.starasia-calendar-input-container-error {
|
|
359
|
+
border-color: var(--starasia-ui-input-color-secondary-red) !important;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.starasia-calendar-input-container-warning {
|
|
363
|
+
border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
|
|
364
|
+
}
|
|
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"})});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface IDateProps {
|
|
2
|
+
value?: Date | IDateRange;
|
|
3
|
+
onChange: (props: any) => void;
|
|
4
|
+
filter?: "days" | "months" | "years";
|
|
5
|
+
input?: boolean;
|
|
6
|
+
rangedDate?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
minDate?: Date;
|
|
9
|
+
maxDate?: Date;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
status?: "error" | "warning";
|
|
13
|
+
}
|
|
14
|
+
export interface IDateRange {
|
|
15
|
+
from: Date | null;
|
|
16
|
+
to: Date | null;
|
|
17
|
+
}
|
|
18
|
+
export interface IInputDateProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
19
|
+
size?: "sm" | "md" | "lg";
|
|
20
|
+
status?: "error" | "warning" | "disable" | "default";
|
|
21
|
+
variant?: "outline" | "filled" | "flushed";
|
|
22
|
+
}
|
|
23
|
+
export interface IHeaderDateProps {
|
|
24
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
25
|
+
views: "days" | "months" | "years";
|
|
26
|
+
filter?: "days" | "months" | "years";
|
|
27
|
+
date: Date;
|
|
28
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
29
|
+
prevDate: Date;
|
|
30
|
+
isComponentVisible: boolean;
|
|
31
|
+
dateRange: IDateRange;
|
|
32
|
+
rangedDate?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface IRenderDays {
|
|
35
|
+
date: Date;
|
|
36
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
37
|
+
prevDate: Date;
|
|
38
|
+
setPrevDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
39
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
40
|
+
dateRange: IDateRange;
|
|
41
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
42
|
+
rangedDate?: boolean;
|
|
43
|
+
input?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface IRenderMonths {
|
|
46
|
+
date: Date;
|
|
47
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
48
|
+
prevDate: Date;
|
|
49
|
+
setPrevDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
50
|
+
filter?: "days" | "months" | "years";
|
|
51
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
52
|
+
dateRange: IDateRange;
|
|
53
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
54
|
+
rangedDate?: boolean;
|
|
55
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
56
|
+
input?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface IRenderYears {
|
|
59
|
+
date: Date;
|
|
60
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
61
|
+
prevDate: Date;
|
|
62
|
+
setPrevDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
63
|
+
filter?: "days" | "months" | "years";
|
|
64
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
65
|
+
dateRange: IDateRange;
|
|
66
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
67
|
+
rangedDate?: boolean;
|
|
68
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
69
|
+
input?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface IHeaderDateRangeProps {
|
|
72
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
73
|
+
views: "days" | "months" | "years";
|
|
74
|
+
filter?: "days" | "months" | "years";
|
|
75
|
+
date: Date;
|
|
76
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
77
|
+
}
|
|
78
|
+
export interface IRenderDateRangeDays {
|
|
79
|
+
date: Date;
|
|
80
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
81
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
82
|
+
dateRange: IDateRange;
|
|
83
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
84
|
+
rangedDate?: boolean;
|
|
85
|
+
input?: boolean;
|
|
86
|
+
minDate?: Date;
|
|
87
|
+
maxDate?: Date;
|
|
88
|
+
onChange: (props: any) => void;
|
|
89
|
+
}
|
|
90
|
+
export interface IRenderDateRangeMonths {
|
|
91
|
+
date: Date;
|
|
92
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
93
|
+
filter?: "days" | "months" | "years";
|
|
94
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
95
|
+
dateRange: IDateRange;
|
|
96
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
97
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
98
|
+
input?: boolean;
|
|
99
|
+
onChange: (props: any) => void;
|
|
100
|
+
minDate?: Date;
|
|
101
|
+
maxDate?: Date;
|
|
102
|
+
}
|
|
103
|
+
export interface IRenderDateRangeYears {
|
|
104
|
+
date: Date;
|
|
105
|
+
setDate: React.Dispatch<React.SetStateAction<Date>>;
|
|
106
|
+
filter?: "days" | "months" | "years";
|
|
107
|
+
setViews: React.Dispatch<React.SetStateAction<"days" | "months" | "years">>;
|
|
108
|
+
dateRange: IDateRange;
|
|
109
|
+
setDateRange: React.Dispatch<React.SetStateAction<IDateRange>>;
|
|
110
|
+
rangedDate?: boolean;
|
|
111
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
112
|
+
input?: boolean;
|
|
113
|
+
onChange: (props: any) => void;
|
|
114
|
+
minDate?: Date;
|
|
115
|
+
maxDate?: Date;
|
|
116
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@starasia/date",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "date component for starasia UI",
|
|
5
|
+
"author": "Prawito Hudoro",
|
|
6
|
+
"main": "dist/date.umd.js",
|
|
7
|
+
"module": "dist/date.es.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/*.js",
|
|
11
|
+
"dist/*.d.ts",
|
|
12
|
+
"dist/*.map",
|
|
13
|
+
"dist/*.css"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "vite --config vite.config.ts --port 3000",
|
|
17
|
+
"build": "vite build --config vite.config.ts"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.11.16",
|
|
27
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
28
|
+
"tsconfig-paths": "^4.2.0",
|
|
29
|
+
"typescript": "^5.3.3",
|
|
30
|
+
"vite": "^5.0.12",
|
|
31
|
+
"vite-plugin-dts": "^3.7.2",
|
|
32
|
+
"react": "^18.2.0",
|
|
33
|
+
"react-dom": "^18.2.0",
|
|
34
|
+
"@types/react": "^18.2.55",
|
|
35
|
+
"@types/react-dom": "^18.2.19"
|
|
36
|
+
}
|
|
37
|
+
}
|