@theengineerguy/chronos-picker 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/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/components/Calendar.d.ts +15 -0
- package/dist/components/Calendar.d.ts.map +1 -0
- package/dist/components/DateTimePicker.d.ts +5 -0
- package/dist/components/DateTimePicker.d.ts.map +1 -0
- package/dist/components/TimePicker.d.ts +12 -0
- package/dist/components/TimePicker.d.ts.map +1 -0
- package/dist/components/TimezoneSelector.d.ts +9 -0
- package/dist/components/TimezoneSelector.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1113 -0
- package/dist/index.js +30 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/calendar.d.ts +16 -0
- package/dist/utils/calendar.d.ts.map +1 -0
- package/dist/utils/timezone.d.ts +27 -0
- package/dist/utils/timezone.d.ts.map +1 -0
- package/package.json +59 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
(function(I,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react"),require("luxon")):typeof define=="function"&&define.amd?define(["exports","react","luxon"],p):(I=typeof globalThis<"u"?globalThis:I||self,p(I.ChronosPicker={},I.React,I.luxon))})(this,function(I,p,U){"use strict";var ue={exports:{}},H={};/**
|
|
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 xe;function Be(){if(xe)return H;xe=1;var o=p,l=Symbol.for("react.element"),d=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,b=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function m(k,y,D){var E,w={},C=null,S=null;D!==void 0&&(C=""+D),y.key!==void 0&&(C=""+y.key),y.ref!==void 0&&(S=y.ref);for(E in y)c.call(y,E)&&!_.hasOwnProperty(E)&&(w[E]=y[E]);if(k&&k.defaultProps)for(E in y=k.defaultProps,y)w[E]===void 0&&(w[E]=y[E]);return{$$typeof:l,type:k,key:C,ref:S,props:w,_owner:b.current}}return H.Fragment=d,H.jsx=m,H.jsxs=m,H}var $={};/**
|
|
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 je;function Ke(){return je||(je=1,process.env.NODE_ENV!=="production"&&function(){var o=p,l=Symbol.for("react.element"),d=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),k=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),S=Symbol.for("react.offscreen"),P=Symbol.iterator,F="@@iterator";function g(e){if(e===null||typeof e!="object")return null;var r=P&&e[P]||e[F];return typeof r=="function"?r:null}var i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function n(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),s=1;s<r;s++)t[s-1]=arguments[s];M("error",e,t)}}function M(e,r,t){{var s=i.ReactDebugCurrentFrame,h=s.getStackAddendum();h!==""&&(r+="%s",t=t.concat([h]));var v=t.map(function(f){return String(f)});v.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,v)}}var O=!1,V=!1,K=!1,re=!1,de=!1,te;te=Symbol.for("react.module.reference");function he(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===_||de||e===b||e===D||e===E||re||e===S||O||V||K||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===w||e.$$typeof===m||e.$$typeof===k||e.$$typeof===y||e.$$typeof===te||e.getModuleId!==void 0))}function ne(e,r,t){var s=e.displayName;if(s)return s;var h=r.displayName||r.name||"";return h!==""?t+"("+h+")":t}function ae(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&n("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 c:return"Fragment";case d:return"Portal";case _:return"Profiler";case b:return"StrictMode";case D:return"Suspense";case E:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case k:var r=e;return ae(r)+".Consumer";case m:var t=e;return ae(t._context)+".Provider";case y:return ne(e,e.render,"ForwardRef");case w:var s=e.displayName||null;return s!==null?s:Y(e.type)||"Memo";case C:{var h=e,v=h._payload,f=h._init;try{return Y(f(v))}catch{return null}}}return null}var z=Object.assign,J=0,x,T,L,B,oe,Re,ke;function Oe(){}Oe.__reactDisabledLog=!0;function qe(){{if(J===0){x=console.log,T=console.info,L=console.warn,B=console.error,oe=console.group,Re=console.groupCollapsed,ke=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Oe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function er(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},e,{value:x}),info:z({},e,{value:T}),warn:z({},e,{value:L}),error:z({},e,{value:B}),group:z({},e,{value:oe}),groupCollapsed:z({},e,{value:Re}),groupEnd:z({},e,{value:ke})})}J<0&&n("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var me=i.ReactCurrentDispatcher,ve;function se(e,r,t){{if(ve===void 0)try{throw Error()}catch(h){var s=h.stack.trim().match(/\n( *(at )?)/);ve=s&&s[1]||""}return`
|
|
18
|
+
`+ve+e}}var pe=!1,ie;{var rr=typeof WeakMap=="function"?WeakMap:Map;ie=new rr}function we(e,r){if(!e||pe)return"";{var t=ie.get(e);if(t!==void 0)return t}var s;pe=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var v;v=me.current,me.current=null,qe();try{if(r){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(A){s=A}Reflect.construct(e,[],f)}else{try{f.call()}catch(A){s=A}e.call(f.prototype)}}else{try{throw Error()}catch(A){s=A}e()}}catch(A){if(A&&s&&typeof A.stack=="string"){for(var u=A.stack.split(`
|
|
19
|
+
`),N=s.stack.split(`
|
|
20
|
+
`),j=u.length-1,R=N.length-1;j>=1&&R>=0&&u[j]!==N[R];)R--;for(;j>=1&&R>=0;j--,R--)if(u[j]!==N[R]){if(j!==1||R!==1)do if(j--,R--,R<0||u[j]!==N[R]){var W=`
|
|
21
|
+
`+u[j].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),typeof e=="function"&&ie.set(e,W),W}while(j>=1&&R>=0);break}}}finally{pe=!1,me.current=v,er(),Error.prepareStackTrace=h}var X=e?e.displayName||e.name:"",Z=X?se(X):"";return typeof e=="function"&&ie.set(e,Z),Z}function tr(e,r,t){return we(e,!1)}function nr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function le(e,r,t){if(e==null)return"";if(typeof e=="function")return we(e,nr(e));if(typeof e=="string")return se(e);switch(e){case D:return se("Suspense");case E:return se("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return tr(e.render);case w:return le(e.type,r,t);case C:{var s=e,h=s._payload,v=s._init;try{return le(v(h),r,t)}catch{}}}return""}var q=Object.prototype.hasOwnProperty,Ce={},Pe=i.ReactDebugCurrentFrame;function ce(e){if(e){var r=e._owner,t=le(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(t)}else Pe.setExtraStackFrame(null)}function ar(e,r,t,s,h){{var v=Function.call.bind(q);for(var f in e)if(v(e,f)){var u=void 0;try{if(typeof e[f]!="function"){var N=Error((s||"React class")+": "+t+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw N.name="Invariant Violation",N}u=e[f](r,f,s,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(j){u=j}u&&!(u instanceof Error)&&(ce(h),n("%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).",s||"React class",t,f,typeof u),ce(null)),u instanceof Error&&!(u.message in Ce)&&(Ce[u.message]=!0,ce(h),n("Failed %s type: %s",t,u.message),ce(null))}}}var or=Array.isArray;function be(e){return or(e)}function sr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function ir(e){try{return Me(e),!1}catch{return!0}}function Me(e){return""+e}function De(e){if(ir(e))return n("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",sr(e)),Me(e)}var Ne=i.ReactCurrentOwner,lr={key:!0,ref:!0,__self:!0,__source:!0},Ae,Ie;function cr(e){if(q.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ur(e){if(q.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function fr(e,r){typeof e.ref=="string"&&Ne.current}function dr(e,r){{var t=function(){Ae||(Ae=!0,n("%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))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function hr(e,r){{var t=function(){Ie||(Ie=!0,n("%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))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var mr=function(e,r,t,s,h,v,f){var u={$$typeof:l,type:e,key:r,ref:t,props:f,_owner:v};return u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u};function vr(e,r,t,s,h){{var v,f={},u=null,N=null;t!==void 0&&(De(t),u=""+t),ur(r)&&(De(r.key),u=""+r.key),cr(r)&&(N=r.ref,fr(r,h));for(v in r)q.call(r,v)&&!lr.hasOwnProperty(v)&&(f[v]=r[v]);if(e&&e.defaultProps){var j=e.defaultProps;for(v in j)f[v]===void 0&&(f[v]=j[v])}if(u||N){var R=typeof e=="function"?e.displayName||e.name||"Unknown":e;u&&dr(f,R),N&&hr(f,R)}return mr(e,u,N,h,s,Ne.current,f)}}var ye=i.ReactCurrentOwner,Fe=i.ReactDebugCurrentFrame;function G(e){if(e){var r=e._owner,t=le(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(t)}else Fe.setExtraStackFrame(null)}var ge;ge=!1;function Te(e){return typeof e=="object"&&e!==null&&e.$$typeof===l}function We(){{if(ye.current){var e=Y(ye.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function pr(e){return""}var Ye={};function br(e){{var r=We();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
24
|
+
|
|
25
|
+
Check the top-level render call using <`+t+">.")}return r}}function Le(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=br(r);if(Ye[t])return;Ye[t]=!0;var s="";e&&e._owner&&e._owner!==ye.current&&(s=" It was passed a child from "+Y(e._owner.type)+"."),G(e),n('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,s),G(null)}}function Ue(e,r){{if(typeof e!="object")return;if(be(e))for(var t=0;t<e.length;t++){var s=e[t];Te(s)&&Le(s,r)}else if(Te(e))e._store&&(e._store.validated=!0);else if(e){var h=g(e);if(typeof h=="function"&&h!==e.entries)for(var v=h.call(e),f;!(f=v.next()).done;)Te(f.value)&&Le(f.value,r)}}}function yr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===y||r.$$typeof===w))t=r.propTypes;else return;if(t){var s=Y(r);ar(t,e.props,"prop",s,e)}else if(r.PropTypes!==void 0&&!ge){ge=!0;var h=Y(r);n("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",h||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&n("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function gr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var s=r[t];if(s!=="children"&&s!=="key"){G(e),n("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),G(null);break}}e.ref!==null&&(G(e),n("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var ze={};function Ve(e,r,t,s,h,v){{var f=he(e);if(!f){var u="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(u+=" 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=pr();N?u+=N:u+=We();var j;e===null?j="null":be(e)?j="array":e!==void 0&&e.$$typeof===l?(j="<"+(Y(e.type)||"Unknown")+" />",u=" Did you accidentally export a JSX literal instead of a component?"):j=typeof e,n("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,u)}var R=vr(e,r,t,h,v);if(R==null)return R;if(f){var W=r.children;if(W!==void 0)if(s)if(be(W)){for(var X=0;X<W.length;X++)Ue(W[X],e);Object.freeze&&Object.freeze(W)}else n("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 Ue(W,e)}if(q.call(r,"key")){var Z=Y(e),A=Object.keys(r).filter(function(Sr){return Sr!=="key"}),Ee=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";if(!ze[Z+Ee]){var _r=A.length>0?"{"+A.join(": ..., ")+": ...}":"{}";n(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
+
let props = %s;
|
|
27
|
+
<%s {...props} />
|
|
28
|
+
React keys must be passed directly to JSX without using spread:
|
|
29
|
+
let props = %s;
|
|
30
|
+
<%s key={someKey} {...props} />`,Ee,Z,_r,Z),ze[Z+Ee]=!0}}return e===c?gr(R):yr(R),R}}function Tr(e,r,t){return Ve(e,r,t,!0)}function Er(e,r,t){return Ve(e,r,t,!1)}var xr=Er,jr=Tr;$.Fragment=c,$.jsx=xr,$.jsxs=jr}()),$}process.env.NODE_ENV==="production"?ue.exports=Be():ue.exports=Ke();var a=ue.exports;const _e="Asia/Kolkata",fe=[{value:"Asia/Kolkata",label:"India (IST)"},{value:"America/New_York",label:"Eastern Time (ET)"},{value:"America/Chicago",label:"Central Time (CT)"},{value:"America/Denver",label:"Mountain Time (MT)"},{value:"America/Los_Angeles",label:"Pacific Time (PT)"},{value:"Europe/London",label:"London (GMT/BST)"},{value:"Europe/Paris",label:"Central Europe (CET)"},{value:"Asia/Dubai",label:"Dubai (GST)"},{value:"Asia/Singapore",label:"Singapore (SGT)"},{value:"Asia/Tokyo",label:"Tokyo (JST)"},{value:"Australia/Sydney",label:"Sydney (AEDT)"},{value:"UTC",label:"UTC"}];function Q(o,l){return U.DateTime.isDateTime(o)?o.setZone(l):typeof o=="string"?U.DateTime.fromISO(o,{zone:l}):U.DateTime.fromJSDate(o,{zone:l})}function ee(o){return U.DateTime.now().setZone(o)}function Se(o){const d=U.DateTime.now().setZone(o).offset,c=Math.floor(Math.abs(d)/60),b=Math.abs(d)%60;return`UTC${d>=0?"+":"-"}${c}${b>0?`:${b.toString().padStart(2,"0")}`:""}`}function Je(o,l,d,c,b,_){const m=U.DateTime.fromObject({year:o,month:l,day:1},{zone:d}),k=m.startOf("week"),D=m.endOf("month").endOf("week"),E=U.DateTime.now().setZone(d).startOf("day"),w=[];let C=[],S=k;for(;S<=D;){const P=S.month===l,F=S.hasSame(E,"day"),g=c?S.hasSame(c,"day"):!1;let i=!1;b&&S<b.startOf("day")&&(i=!0),_&&S>_.endOf("day")&&(i=!0),C.push({date:S,isCurrentMonth:P,isToday:F,isSelected:g,isDisabled:i}),C.length===7&&(w.push(C),C=[]),S=S.plus({days:1})}return w}function Ze(){const o=U.DateTime.now().startOf("week"),l=[];for(let d=0;d<7;d++){const c=o.plus({days:d});l.push(c.toFormat("ccc"))}return l}function Ge(){const o=[];for(let l=1;l<=12;l++){const d=U.DateTime.fromObject({month:l});o.push(d.toFormat("MMMM"))}return o}const Xe=({viewDate:o,selectedDate:l,onDateSelect:d,onViewDateChange:c,timezone:b,minDate:_,maxDate:m})=>{const k=p.useMemo(()=>Je(o.year,o.month,b,l??void 0,_,m),[o,l,b,_,m]),y=p.useMemo(()=>Ze(),[]),D=p.useMemo(()=>Ge(),[]),E=()=>{c(o.minus({months:1}))},w=()=>{c(o.plus({months:1}))},C=n=>{const M=parseInt(n.target.value,10);c(o.set({month:M}))},S=n=>{const M=parseInt(n.target.value,10);c(o.set({year:M}))},P=(n,M)=>{M||d(n)},F=(n,M,O)=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),P(M,O))},g=o.year,i=Array.from({length:21},(n,M)=>g-10+M);return a.jsxs("div",{className:"chronos-calendar",role:"region","aria-label":"Calendar",children:[a.jsxs("div",{className:"chronos-calendar-header",children:[a.jsx("button",{type:"button",className:"chronos-nav-button",onClick:E,"aria-label":"Previous month",children:"‹"}),a.jsxs("div",{className:"chronos-month-year-selectors",children:[a.jsx("select",{className:"chronos-month-select",value:o.month,onChange:C,"aria-label":"Select month",children:D.map((n,M)=>a.jsx("option",{value:M+1,children:n},M))}),a.jsx("select",{className:"chronos-year-select",value:o.year,onChange:S,"aria-label":"Select year",children:i.map(n=>a.jsx("option",{value:n,children:n},n))})]}),a.jsx("button",{type:"button",className:"chronos-nav-button",onClick:w,"aria-label":"Next month",children:"›"})]}),a.jsxs("div",{className:"chronos-calendar-grid",children:[a.jsx("div",{className:"chronos-weekday-row",children:y.map(n=>a.jsx("div",{className:"chronos-weekday",children:n},n))}),k.map((n,M)=>a.jsx("div",{className:"chronos-week-row",children:n.map((O,V)=>a.jsx("button",{type:"button",className:`chronos-day ${O.isSelected?"selected":""} ${O.isToday?"today":""} ${O.isCurrentMonth?"":"other-month"} ${O.isDisabled?"disabled":""}`,onClick:()=>P(O.date,O.isDisabled),onKeyDown:K=>F(K,O.date,O.isDisabled),disabled:O.isDisabled,"aria-label":O.date.toFormat("MMMM d, yyyy"),"aria-selected":O.isSelected,"aria-current":O.isToday?"date":void 0,children:O.date.day},V))},M))]})]})},He=({value:o,onChange:l,use24Hour:d})=>{const[c,b]=p.useState((o==null?void 0:o.hour)??12),[_,m]=p.useState((o==null?void 0:o.minute)??0),[k,y]=p.useState(o&&o.hour>=12?"PM":"AM");p.useEffect(()=>{o&&(b(o.hour),m(o.minute),y(o.hour>=12?"PM":"AM"))},[o]);const D=i=>{b(i);let n=i;d||(k==="PM"&&i!==12?n=i+12:k==="AM"&&i===12&&(n=0)),l(n,_)},E=i=>{m(i),l(c,i)},w=()=>{const i=k==="AM"?"PM":"AM";y(i);let n=c;i==="PM"&&c!==12?n=c+12:i==="AM"&&c===12?n=0:i==="AM"&&c>12&&(n=c-12),l(n,_)},C=d?c:c%12||12,S=d?23:12,P=d?0:1,F=Array.from({length:S-P+1},(i,n)=>P+n),g=Array.from({length:60},(i,n)=>n);return a.jsxs("div",{className:"chronos-time-picker",role:"group","aria-label":"Time picker",children:[a.jsxs("div",{className:"chronos-time-header",children:[a.jsxs("svg",{className:"chronos-clock-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"12 6 12 12 16 14"})]}),a.jsx("span",{children:"Time"})]}),a.jsxs("div",{className:"chronos-time-controls",children:[a.jsxs("div",{className:"chronos-time-input-group",children:[a.jsx("label",{htmlFor:"chronos-hour-select",className:"chronos-time-label",children:"Hour"}),a.jsx("select",{id:"chronos-hour-select",className:"chronos-time-select",value:C,onChange:i=>D(parseInt(i.target.value,10)),"aria-label":"Select hour",children:F.map(i=>a.jsx("option",{value:i,children:i.toString().padStart(2,"0")},i))})]}),a.jsx("span",{className:"chronos-time-separator",children:":"}),a.jsxs("div",{className:"chronos-time-input-group",children:[a.jsx("label",{htmlFor:"chronos-minute-select",className:"chronos-time-label",children:"Minute"}),a.jsx("select",{id:"chronos-minute-select",className:"chronos-time-select",value:_,onChange:i=>E(parseInt(i.target.value,10)),"aria-label":"Select minute",children:g.map(i=>a.jsx("option",{value:i,children:i.toString().padStart(2,"0")},i))})]}),!d&&a.jsx("button",{type:"button",className:"chronos-period-toggle",onClick:w,"aria-label":`Switch to ${k==="AM"?"PM":"AM"}`,children:k})]})]})},$e=({value:o,onChange:l})=>{const[d,c]=p.useState(!1),b=fe.find(m=>m.value===o)||{label:o},_=m=>{l(m),c(!1)};return a.jsxs("div",{className:"chronos-timezone-selector",children:[a.jsxs("div",{className:"chronos-timezone-header",children:[a.jsxs("svg",{className:"chronos-globe-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),a.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),a.jsx("span",{children:"Timezone"})]}),a.jsxs("button",{type:"button",className:"chronos-timezone-button",onClick:()=>c(!d),"aria-expanded":d,"aria-label":"Select timezone",children:[a.jsx("span",{className:"chronos-timezone-label",children:b.label}),a.jsx("span",{className:"chronos-timezone-offset",children:Se(o)}),a.jsx("svg",{className:`chronos-chevron ${d?"expanded":""}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),d&&a.jsx("div",{className:"chronos-timezone-list",role:"listbox",children:fe.map(m=>a.jsxs("button",{type:"button",className:`chronos-timezone-option ${m.value===o?"selected":""}`,onClick:()=>_(m.value),role:"option","aria-selected":m.value===o,children:[a.jsx("span",{className:"chronos-timezone-option-label",children:m.label}),a.jsx("span",{className:"chronos-timezone-option-offset",children:Se(m.value)})]},m.value))})]})},Qe=({value:o,onChange:l,timezone:d=_e,dateFormat:c="DD",timeFormat:b="HH:mm",minDate:_,maxDate:m,placeholder:k="Select date and time",disabled:y=!1,showTime:D=!0,use24Hour:E=!0,className:w="",ariaLabel:C="Date and time picker",showTimezoneSelector:S=!1})=>{const[P,F]=p.useState(!1),[g,i]=p.useState(()=>o?Q(o,d):null),[n,M]=p.useState(d),[O,V]=p.useState(()=>g||ee(d)),K=p.useRef(null),re=p.useRef(null);p.useEffect(()=>{o&&i(Q(o,n))},[o,n]),p.useEffect(()=>{const x=T=>{K.current&&!K.current.contains(T.target)&&F(!1)};if(P)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[P]),p.useEffect(()=>{const x=T=>{var L;T.key==="Escape"&&P&&(F(!1),(L=re.current)==null||L.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[P]);const de=p.useCallback(x=>{let T=x;if(g&&(T=x.set({hour:g.hour,minute:g.minute,second:g.second})),i(T),V(T),D||F(!1),l){const L={iso:T.toISO()||"",formatted:T.toFormat(`${c} ${b}`),timestamp:T.toMillis(),dateTime:T};l(L)}},[g,D,l,c,b]),te=p.useCallback((x,T)=>{const B=(g||ee(n)).set({hour:x,minute:T,second:0});if(i(B),l){const oe={iso:B.toISO()||"",formatted:B.toFormat(`${c} ${b}`),timestamp:B.toMillis(),dateTime:B};l(oe)}},[g,n,l,c,b]),he=p.useCallback(x=>{if(M(x),g){const T=g.setZone(x);if(i(T),V(T),l){const L={iso:T.toISO()||"",formatted:T.toFormat(`${c} ${b}`),timestamp:T.toMillis(),dateTime:T};l(L)}}else V(ee(x))},[g,l,c,b]),ne=()=>{y||F(!P)},ae=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),ne())},Y=g?g.toFormat(`${c} ${D?b:""}`):"",z=_?Q(_,n):void 0,J=m?Q(m,n):void 0;return a.jsxs("div",{ref:K,className:`chronos-picker ${w}`,"data-disabled":y,children:[a.jsxs("div",{className:"chronos-input-wrapper",onClick:ne,children:[a.jsx("input",{ref:re,type:"text",className:"chronos-input",value:Y,placeholder:k,readOnly:!0,disabled:y,onKeyDown:ae,"aria-label":C,"aria-expanded":P,"aria-haspopup":"dialog",role:"combobox"}),a.jsxs("svg",{className:"chronos-calendar-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]})]}),P&&a.jsxs("div",{className:"chronos-dropdown",role:"dialog","aria-label":"Date and time picker dialog",children:[a.jsx(Xe,{viewDate:O,selectedDate:g,onDateSelect:de,onViewDateChange:V,timezone:n,minDate:z,maxDate:J}),D&&a.jsx(He,{value:g,onChange:te,use24Hour:E,timezone:n}),S&&a.jsx($e,{value:n,onChange:he})]})]})};I.COMMON_TIMEZONES=fe,I.DEFAULT_TIMEZONE=_e,I.DateTimePicker=Qe,I.convertToTimezone=Q,I.nowInTimezone=ee,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.chronos-picker{position:relative;display:inline-block;width:100%;max-width:320px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;color:#1a1a1a}.chronos-picker[data-disabled=true]{opacity:.6;cursor:not-allowed}.chronos-input-wrapper{position:relative;display:flex;align-items:center;cursor:pointer}.chronos-input{width:100%;padding:10px 40px 10px 14px;border:1.5px solid #d1d5db;border-radius:8px;font-size:14px;color:#1a1a1a;background-color:#fff;transition:all .2s ease;cursor:pointer;outline:none}.chronos-input:hover:not(:disabled){border-color:#9ca3af}.chronos-input:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.chronos-input:disabled{background-color:#f3f4f6;cursor:not-allowed}.chronos-input::placeholder{color:#9ca3af}.chronos-calendar-icon{position:absolute;right:12px;width:20px;height:20px;color:#6b7280;pointer-events:none;transition:color .2s ease}.chronos-input:hover:not(:disabled)~.chronos-calendar-icon,.chronos-input:focus~.chronos-calendar-icon{color:#3b82f6}.chronos-dropdown{position:absolute;top:calc(100% + 8px);left:0;z-index:1000;min-width:320px;background:#fff;border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 10px 40px #0000001f;overflow:hidden;animation:chronos-dropdown-appear .2s ease}@keyframes chronos-dropdown-appear{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.chronos-calendar{padding:16px}.chronos-calendar-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;gap:8px}.chronos-nav-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;border-radius:6px;background:transparent;color:#4b5563;font-size:20px;font-weight:600;cursor:pointer;transition:all .15s ease}.chronos-nav-button:hover{background:#f3f4f6;color:#1a1a1a}.chronos-nav-button:active{transform:scale(.95)}.chronos-month-year-selectors{display:flex;gap:8px;flex:1;justify-content:center}.chronos-month-select,.chronos-year-select{padding:6px 10px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;font-weight:500;color:#1a1a1a;background-color:#fff;cursor:pointer;transition:all .15s ease;outline:none}.chronos-month-select:hover,.chronos-year-select:hover{border-color:#9ca3af}.chronos-month-select:focus,.chronos-year-select:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.chronos-calendar-grid{display:flex;flex-direction:column;gap:4px}.chronos-weekday-row,.chronos-week-row{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}.chronos-weekday{display:flex;align-items:center;justify-content:center;height:32px;font-size:12px;font-weight:600;color:#6b7280;text-transform:uppercase}.chronos-day{display:flex;align-items:center;justify-content:center;height:36px;border:none;border-radius:6px;font-size:14px;font-weight:500;color:#1a1a1a;background:transparent;cursor:pointer;transition:all .15s ease;position:relative}.chronos-day:hover:not(.disabled){background:#f3f4f6;transform:scale(1.05)}.chronos-day.other-month{color:#9ca3af}.chronos-day.today{color:#3b82f6;font-weight:600}.chronos-day.today:after{content:"";position:absolute;bottom:4px;left:50%;transform:translate(-50%);width:4px;height:4px;border-radius:50%;background:#3b82f6}.chronos-day.selected{background:#3b82f6;color:#fff;font-weight:600}.chronos-day.selected:hover{background:#2563eb}.chronos-day.disabled{color:#d1d5db;cursor:not-allowed;opacity:.5}.chronos-day.disabled:hover{background:transparent;transform:none}.chronos-day:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.chronos-time-picker{padding:16px;border-top:1px solid #e5e7eb}.chronos-time-header{display:flex;align-items:center;gap:8px;margin-bottom:12px;font-weight:600;color:#4b5563}.chronos-clock-icon{width:18px;height:18px;color:#6b7280}.chronos-time-controls{display:flex;align-items:flex-end;justify-content:center;gap:8px}.chronos-time-input-group{display:flex;flex-direction:column;gap:4px}.chronos-time-label{font-size:11px;font-weight:500;color:#6b7280;text-transform:uppercase;letter-spacing:.5px}.chronos-time-select{width:70px;padding:8px 10px;border:1.5px solid #d1d5db;border-radius:6px;font-size:16px;font-weight:600;color:#1a1a1a;background-color:#fff;cursor:pointer;transition:all .15s ease;outline:none;text-align:center}.chronos-time-select:hover{border-color:#9ca3af}.chronos-time-select:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.chronos-time-separator{font-size:24px;font-weight:700;color:#1a1a1a;line-height:1;margin-bottom:8px}.chronos-period-toggle{padding:8px 16px;border:1.5px solid #d1d5db;border-radius:6px;font-size:14px;font-weight:600;color:#1a1a1a;background-color:#fff;cursor:pointer;transition:all .15s ease;outline:none}.chronos-period-toggle:hover{border-color:#3b82f6;background-color:#eff6ff;color:#3b82f6}.chronos-period-toggle:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.chronos-period-toggle:active{transform:scale(.95)}.chronos-timezone-selector{padding:16px;border-top:1px solid #e5e7eb}.chronos-timezone-header{display:flex;align-items:center;gap:8px;margin-bottom:12px;font-weight:600;color:#4b5563}.chronos-globe-icon{width:18px;height:18px;color:#6b7280}.chronos-timezone-button{display:flex;align-items:center;justify-content:space-between;width:100%;padding:10px 12px;border:1.5px solid #d1d5db;border-radius:8px;background-color:#fff;cursor:pointer;transition:all .15s ease;outline:none}.chronos-timezone-button:hover{border-color:#9ca3af}.chronos-timezone-button:focus{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.chronos-timezone-label{font-weight:500;color:#1a1a1a;flex:1;text-align:left}.chronos-timezone-offset{font-size:12px;color:#6b7280;margin-right:8px}.chronos-chevron{width:16px;height:16px;color:#6b7280;transition:transform .2s ease}.chronos-chevron.expanded{transform:rotate(180deg)}.chronos-timezone-list{margin-top:8px;max-height:240px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:8px;background:#fff;animation:chronos-timezone-list-appear .2s ease}@keyframes chronos-timezone-list-appear{0%{opacity:0;max-height:0}to{opacity:1;max-height:240px}}.chronos-timezone-option{display:flex;align-items:center;justify-content:space-between;width:100%;padding:10px 12px;border:none;border-bottom:1px solid #f3f4f6;background:transparent;text-align:left;cursor:pointer;transition:background .15s ease;outline:none}.chronos-timezone-option:last-child{border-bottom:none}.chronos-timezone-option:hover{background:#f9fafb}.chronos-timezone-option.selected{background:#eff6ff}.chronos-timezone-option:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.chronos-timezone-option-label{font-weight:500;color:#1a1a1a}.chronos-timezone-option.selected .chronos-timezone-option-label{color:#3b82f6;font-weight:600}.chronos-timezone-option-offset{font-size:12px;color:#6b7280}@media (max-width: 480px){.chronos-dropdown{min-width:calc(100vw - 32px);max-width:calc(100vw - 32px)}.chronos-picker{max-width:100%}}.chronos-timezone-list::-webkit-scrollbar{width:6px}.chronos-timezone-list::-webkit-scrollbar-track{background:#f3f4f6}.chronos-timezone-list::-webkit-scrollbar-thumb{background:#d1d5db;border-radius:3px}.chronos-timezone-list::-webkit-scrollbar-thumb:hover{background:#9ca3af}@media (prefers-color-scheme: dark){.chronos-picker{color:#f3f4f6}.chronos-input{background-color:#1f2937;border-color:#374151;color:#f3f4f6}.chronos-input:hover:not(:disabled){border-color:#4b5563}.chronos-input:disabled{background-color:#111827}.chronos-dropdown{background:#1f2937;border-color:#374151}.chronos-day,.chronos-time-select,.chronos-timezone-button{color:#f3f4f6;background-color:#1f2937;border-color:#374151}.chronos-day:hover:not(.disabled){background:#374151}.chronos-day.selected{background:#3b82f6;color:#fff}}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
|
|
3
|
+
export interface DateTimeValue {
|
|
4
|
+
/** ISO 8601 string representation */
|
|
5
|
+
iso: string;
|
|
6
|
+
/** Formatted local string */
|
|
7
|
+
formatted: string;
|
|
8
|
+
/** Unix timestamp in milliseconds */
|
|
9
|
+
timestamp: number;
|
|
10
|
+
/** Luxon DateTime object */
|
|
11
|
+
dateTime: DateTime;
|
|
12
|
+
}
|
|
13
|
+
export interface DateTimePickerProps {
|
|
14
|
+
/** Selected date and time value */
|
|
15
|
+
value?: Date | string | DateTime;
|
|
16
|
+
/** Callback when date/time changes */
|
|
17
|
+
onChange?: (value: DateTimeValue) => void;
|
|
18
|
+
/** IANA timezone identifier (e.g., "Asia/Kolkata", "America/New_York") */
|
|
19
|
+
timezone?: string;
|
|
20
|
+
/** Custom date format for display (Luxon format tokens) */
|
|
21
|
+
dateFormat?: string;
|
|
22
|
+
/** Custom time format for display (Luxon format tokens) */
|
|
23
|
+
timeFormat?: string;
|
|
24
|
+
/** Minimum selectable date */
|
|
25
|
+
minDate?: Date | string;
|
|
26
|
+
/** Maximum selectable date */
|
|
27
|
+
maxDate?: Date | string;
|
|
28
|
+
/** Placeholder text */
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/** Disabled state */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Show time picker */
|
|
33
|
+
showTime?: boolean;
|
|
34
|
+
/** 12-hour or 24-hour format */
|
|
35
|
+
use24Hour?: boolean;
|
|
36
|
+
/** Custom CSS class */
|
|
37
|
+
className?: string;
|
|
38
|
+
/** ARIA label */
|
|
39
|
+
ariaLabel?: string;
|
|
40
|
+
/** Show timezone selector */
|
|
41
|
+
showTimezoneSelector?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface CalendarDate {
|
|
44
|
+
date: DateTime;
|
|
45
|
+
isCurrentMonth: boolean;
|
|
46
|
+
isToday: boolean;
|
|
47
|
+
isSelected: boolean;
|
|
48
|
+
isDisabled: boolean;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEjC,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAE1C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
import { CalendarDate } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generate calendar grid for a given month
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateCalendarMonth(year: number, month: number, timezone: string, selectedDate?: DateTime, minDate?: DateTime, maxDate?: DateTime): CalendarDate[][];
|
|
8
|
+
/**
|
|
9
|
+
* Get weekday names
|
|
10
|
+
*/
|
|
11
|
+
export declare function getWeekdayNames(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Get month names
|
|
14
|
+
*/
|
|
15
|
+
export declare function getMonthNames(): string[];
|
|
16
|
+
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../src/utils/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,QAAQ,EACvB,OAAO,CAAC,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,QAAQ,GACjB,YAAY,EAAE,EAAE,CAgDlB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAU1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,EAAE,CASxC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
|
|
3
|
+
export declare const DEFAULT_TIMEZONE = "Asia/Kolkata";
|
|
4
|
+
/**
|
|
5
|
+
* Common timezone options for quick selection
|
|
6
|
+
*/
|
|
7
|
+
export declare const COMMON_TIMEZONES: {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
}[];
|
|
11
|
+
/**
|
|
12
|
+
* Convert a date to a specific timezone
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertToTimezone(date: Date | string | DateTime, timezone: string): DateTime;
|
|
15
|
+
/**
|
|
16
|
+
* Get the current date/time in a specific timezone
|
|
17
|
+
*/
|
|
18
|
+
export declare function nowInTimezone(timezone: string): DateTime;
|
|
19
|
+
/**
|
|
20
|
+
* Format timezone offset for display (e.g., "UTC+5:30")
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatTimezoneOffset(timezone: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Validate if a timezone is valid
|
|
25
|
+
*/
|
|
26
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
27
|
+
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;GAa5B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAU5F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAExD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOzD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theengineerguy/chronos-picker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A modern, accessible date & time picker with comprehensive timezone support",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"build": "tsc && vite build",
|
|
14
|
+
"lint": "eslint src --ext ts,tsx",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"datepicker",
|
|
20
|
+
"timepicker",
|
|
21
|
+
"datetime",
|
|
22
|
+
"timezone",
|
|
23
|
+
"react",
|
|
24
|
+
"component",
|
|
25
|
+
"accessible",
|
|
26
|
+
"a11y"
|
|
27
|
+
],
|
|
28
|
+
"author": "Debmalya Biswas <viperbale.db.@gmail.com>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/AnTIdoTe003/chronos-picker#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/AnTIdoTe003/chronos-picker/issues"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": "^18.0.0",
|
|
36
|
+
"react-dom": "^18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"luxon": "^3.4.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/luxon": "^3.4.2",
|
|
43
|
+
"@types/react": "^18.2.48",
|
|
44
|
+
"@types/react-dom": "^18.2.18",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
47
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
50
|
+
"typescript": "^5.3.3",
|
|
51
|
+
"vite": "^5.0.11",
|
|
52
|
+
"vite-plugin-dts": "^3.7.1",
|
|
53
|
+
"vitest": "^1.2.1"
|
|
54
|
+
},
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/AnTIdoTe003/chronos-picker"
|
|
58
|
+
}
|
|
59
|
+
}
|