zaman-backoffice 1.0.3 → 1.1.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/dist/components/CalendarItem/CalendarItem.styled.d.ts +10 -0
- package/dist/components/CalendarItem/CalendarItem.types.d.ts +7 -0
- package/dist/components/CalendarItem/index.d.ts +1 -0
- package/dist/components/CalendarWrapper/CalendarWrapper.styled.d.ts +5 -0
- package/dist/components/CalendarWrapper/index.d.ts +1 -0
- package/dist/components/FloatingElement/FloatingElement.d.ts +4 -0
- package/dist/components/FloatingElement/FloatingElement.styled.d.ts +4 -0
- package/dist/components/FloatingElement/FloatingElement.types.d.ts +7 -0
- package/dist/components/FloatingElement/index.d.ts +1 -0
- package/dist/components/Header/Header.d.ts +4 -0
- package/dist/components/Header/Header.styled.d.ts +12 -0
- package/dist/components/Header/Header.types.d.ts +6 -0
- package/dist/components/Header/index.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +2 -0
- package/dist/components/IconButton/IconButton.styled.d.ts +4 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/Icons/ChevronLeft/index.d.ts +3 -0
- package/dist/components/Icons/ChevronRight/index.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts +4 -0
- package/dist/components/Modal/Modal.styled.d.ts +4 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/Modal/types.d.ts +6 -0
- package/dist/components/MonthPicker/Month.styled.d.ts +4 -0
- package/dist/components/MonthPicker/MonthPicker.d.ts +4 -0
- package/dist/components/MonthPicker/MonthPicker.types.d.ts +4 -0
- package/dist/components/MonthPicker/index.d.ts +1 -0
- package/dist/components/RenderCalendar/RenderCalendar.d.ts +4 -0
- package/dist/components/RenderCalendar/RenderCalendar.types.d.ts +9 -0
- package/dist/components/RenderCalendar/index.d.ts +1 -0
- package/dist/components/YearPicker/YearPicker.d.ts +4 -0
- package/dist/components/YearPicker/YearPicker.styled.d.ts +4 -0
- package/dist/components/YearPicker/YearPicker.types.d.ts +4 -0
- package/dist/components/YearPicker/index.d.ts +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/hooks/useCalendarHandlers.d.ts +20 -0
- package/dist/hooks/useClickOutside.d.ts +3 -0
- package/dist/hooks/useSlideCalendar.d.ts +13 -0
- package/dist/hooks/useTimePicker.d.ts +19 -0
- package/dist/index.cjs.js +303 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +303 -0
- package/dist/packages/Calendar/Calendar.d.ts +4 -0
- package/dist/packages/Calendar/Calendar.styled.d.ts +20 -0
- package/dist/packages/Calendar/Calendar.types.d.ts +21 -0
- package/dist/packages/Calendar/index.d.ts +2 -0
- package/dist/packages/CalendarProvider/CalendarProvider.d.ts +4 -0
- package/dist/packages/CalendarProvider/CalendarProvider.types.d.ts +5 -0
- package/dist/packages/CalendarProvider/index.d.ts +2 -0
- package/dist/packages/DatePicker/DatePicker.d.ts +4 -0
- package/dist/packages/DatePicker/DatePicker.types.d.ts +15 -0
- package/dist/packages/DatePicker/index.d.ts +2 -0
- package/dist/packages/TimePicker/TimePicker.d.ts +4 -0
- package/dist/packages/TimePicker/TimePicker.styled.d.ts +37 -0
- package/dist/packages/TimePicker/TimePicker.types.d.ts +14 -0
- package/dist/packages/TimePicker/components/Numbers/Numbers.d.ts +4 -0
- package/dist/packages/TimePicker/components/Numbers/Numbers.styled.d.ts +9 -0
- package/dist/packages/TimePicker/components/Numbers/Numbers.types.d.ts +13 -0
- package/dist/packages/TimePicker/components/Numbers/index.d.ts +1 -0
- package/dist/packages/TimePicker/index.d.ts +2 -0
- package/dist/style/animation.d.ts +12 -0
- package/dist/style/classNames.d.ts +7 -0
- package/dist/style/colorPallete.d.ts +1 -0
- package/dist/style/colors.d.ts +5 -0
- package/dist/style/hexToHSL.d.ts +6 -0
- package/dist/style/radius.d.ts +7 -0
- package/dist/types.d.ts +41 -0
- package/dist/utils/dateHelper/dateHelper.d.ts +15 -0
- package/dist/utils/dateHelper/index.d.ts +1 -0
- package/dist/utils/dateTimeFormat/dateTimeFormat.d.ts +13 -0
- package/dist/utils/dateTimeFormat/index.d.ts +1 -0
- package/dist/utils/format/format.d.ts +4 -0
- package/dist/utils/format/format.types.d.ts +10 -0
- package/dist/utils/format/index.d.ts +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/locale.d.ts +6 -0
- package/dist/utils/locales/en.d.ts +3 -0
- package/dist/utils/locales/fa.d.ts +3 -0
- package/dist/utils/locales/index.d.ts +3 -0
- package/dist/utils/locales/locales.types.d.ts +12 -0
- package/dist/utils/month/index.d.ts +1 -0
- package/dist/utils/month/month.d.ts +5 -0
- package/dist/utils/month/month.types.d.ts +10 -0
- package/dist/utils/timePicker.d.ts +36 -0
- package/package.json +5 -5
package/dist/index.js
ADDED
@@ -0,0 +1,303 @@
|
|
1
|
+
import e,{useRef as t,useEffect as n,useMemo as r,useState as o,forwardRef as a,useImperativeHandle as i}from"react";import{createPortal as s}from"react-dom";import l from"@emotion/styled";import{keyframes as c,ThemeProvider as u}from"@emotion/react";var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,y=/^0o[0-7]+$/i,g=parseInt,v="object"==typeof d&&d&&d.Object===Object&&d,b="object"==typeof self&&self&&self.Object===Object&&self,x=v||b||Function("return this")(),$=Object.prototype.toString,w=Math.max,M=Math.min,k=function(){return x.Date.now()};function D(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function E(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==$.call(e)}(e))return NaN;if(D(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=D(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(h,"");var n=p.test(e);return n||y.test(e)?g(e.slice(2),n?2:8):f.test(e)?NaN:+e}var Y=m((function(e,t,n){var r,o,a,i,s,l,c=0,u=!1,d=!1,m=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=r,a=o;return r=o=void 0,c=t,i=e.apply(a,n)}function f(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=a}function p(){var e=k();if(f(e))return y(e);s=setTimeout(p,function(e){var n=t-(e-l);return d?M(n,a-(e-c)):n}(e))}function y(e){return s=void 0,m&&r?h(e):(r=o=void 0,i)}function g(){var e=k(),n=f(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(p,t),u?h(e):i}(l);if(d)return s=setTimeout(p,t),h(l)}return void 0===s&&(s=setTimeout(p,t)),i}return t=E(t)||0,D(n)&&(u=!!n.leading,a=(d="maxWait"in n)?w(E(n.maxWait)||0,t):a,m="trailing"in n?!!n.trailing:m),g.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},g.flush=function(){return void 0===s?i:y(k())},g}));const _=320,C="cubic-bezier(0.4, 0, 0.2, 1)",S="#0D59F2",T=c`
|
2
|
+
from {
|
3
|
+
visibility: hidden;
|
4
|
+
opacity: 0;
|
5
|
+
transform: translateY(-4px);
|
6
|
+
}
|
7
|
+
to {
|
8
|
+
visibility: visible;
|
9
|
+
opacity: 1;
|
10
|
+
transform: translateY(0px);
|
11
|
+
}
|
12
|
+
`,O=c`
|
13
|
+
from {
|
14
|
+
opacity: 0;
|
15
|
+
}
|
16
|
+
to {
|
17
|
+
opacity: 1;
|
18
|
+
}
|
19
|
+
`,L=l.div`
|
20
|
+
position: absolute;
|
21
|
+
animation: ${T} 0.3s ${C} alternate;
|
22
|
+
`,N=r=>{const{children:o,destinationRef:a,position:i}=r,l=t(null),c=()=>{var e;let t=0;if(null!=a&&null!==l){const n=l.current;if(null===n)return;const{top:r,bottom:o,right:s,left:c,width:u}=null===(e=null==a?void 0:a.current)||void 0===e?void 0:e.getBoundingClientRect(),{height:d,width:m}=null==n?void 0:n.getBoundingClientRect();t=window.innerHeight-o>d?o+window.scrollY:r+window.scrollY-d-8,n.style.top=`${t+4}px`;({right:()=>{n.style.right=`${Math.abs(document.body.clientWidth-s)+16}px`},left:()=>{n.style.left=`${c}px`},center:()=>{const e=m>u?0:Math.abs(m-u)/2+16;n.style.right=`${Math.abs(document.body.clientWidth-s)+e}px`}})[i]()}};return n((()=>(c(),window.addEventListener("resize",Y(c,500)),()=>{window.removeEventListener("resize",c)})),[a]),e.createElement(e.Fragment,null,s(e.createElement(L,{ref:l},o),document.body))},H=l.div`
|
23
|
+
position: fixed;
|
24
|
+
display: flex;
|
25
|
+
justify-content: center;
|
26
|
+
align-items: center;
|
27
|
+
top: 0;
|
28
|
+
right: 0;
|
29
|
+
width: 100%;
|
30
|
+
height: 100%;
|
31
|
+
z-index: 10;
|
32
|
+
|
33
|
+
.rdp__overlay {
|
34
|
+
position: absolute;
|
35
|
+
top: 0;
|
36
|
+
right: 0;
|
37
|
+
width: 100%;
|
38
|
+
height: 100%;
|
39
|
+
z-index: -10;
|
40
|
+
background-color: rgba(86, 86, 86, 0.4);
|
41
|
+
}
|
42
|
+
`,I=t=>{const{open:n,toggleOpen:r,children:o}=t;return!1===n?null:e.createElement(e.Fragment,null,s(e.createElement(H,{className:"rdp__modal"},o,e.createElement("div",{"data-testid":"overlay",className:"rdp__overlay",onClick:r})),document.body))},j=t=>{const{position:n="right"}=t;if(!t.showCalendar)return null;const{matches:r}=window.matchMedia("(min-width: 640px)");return r?e.createElement(N,{destinationRef:t.destinationRef,position:n},t.children):e.createElement(I,{toggleOpen:t.toggleOpen,open:t.showCalendar},t.children)},B={thin:{wrapper:0,calendarItem:0},x1:{wrapper:8,calendarItem:4},x2:{wrapper:16,calendarItem:8},x3:{wrapper:24,calendarItem:16},x4:{wrapper:24,calendarItem:20}},F=l.div`
|
43
|
+
overflow: hidden;
|
44
|
+
position: relative;
|
45
|
+
width: ${_}px;
|
46
|
+
height: ${372}px;
|
47
|
+
border: 1px solid ${e=>e.theme.colors.gray[40]};
|
48
|
+
background-color: #fff;
|
49
|
+
border-radius: ${e=>B[e.theme.round].wrapper}px;
|
50
|
+
`,A=l.div`
|
51
|
+
display: flex;
|
52
|
+
position: absolute;
|
53
|
+
overflow: hidden;
|
54
|
+
right: ${e=>"rtl"===e.theme.direction?"8px":"unset"};
|
55
|
+
left: ${e=>"rtl"!==e.theme.direction?"8px":"unset"};
|
56
|
+
`,W=l.div`
|
57
|
+
will-change: transform;
|
58
|
+
display: flex;
|
59
|
+
flex-direction: column;
|
60
|
+
width: ${_}px;
|
61
|
+
gap: 4px;
|
62
|
+
`,z=l.div`
|
63
|
+
display: flex;
|
64
|
+
gap: 4px;
|
65
|
+
`,P=l.div`
|
66
|
+
display: flex;
|
67
|
+
justify-content: center;
|
68
|
+
align-items: center;
|
69
|
+
margin-top: 12px;
|
70
|
+
margin-bottom: 8px;
|
71
|
+
height: 24px;
|
72
|
+
gap: 4px;
|
73
|
+
`,R=l.button`
|
74
|
+
cursor: pointer;
|
75
|
+
outline: none;
|
76
|
+
border: none;
|
77
|
+
display: flex;
|
78
|
+
justify-content: center;
|
79
|
+
align-items: center;
|
80
|
+
width: 40px;
|
81
|
+
height: 40px;
|
82
|
+
transition: background-color 0.2s ease-in;
|
83
|
+
color: ${e=>e.theme.colors.primary[50]};
|
84
|
+
background-color: transparent;
|
85
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
86
|
+
|
87
|
+
&:hover,
|
88
|
+
&:focus {
|
89
|
+
background-color: ${e=>e.theme.colors.primary[90]};
|
90
|
+
}
|
91
|
+
`,V={localeDefault:"en",setLocale(e){null!=e&&(this.localeDefault=e)},get locale(){return this.localeDefault}},X=()=>{if(""!==document.dir)return"rtl"===document.dir;const{body:e}=document;return"rtl"===getComputedStyle(e).direction},U=e=>{if("test"===process.env.NODE_ENV)return e;const{locale:t}=V;return Number(e).toLocaleString(t,{useGrouping:!1})},J=()=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-chevron-right",style:{transform:X()?"unset":"rotate(180deg)"}},e.createElement("polyline",{points:"9 18 15 12 9 6"})),Z=()=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-chevron-left",style:{transform:X()?"unset":"rotate(180deg)"}},e.createElement("polyline",{points:"15 18 9 12 15 6"})),q=l.div`
|
92
|
+
display: flex;
|
93
|
+
justify-content: space-between;
|
94
|
+
align-items: center;
|
95
|
+
height: 56px;
|
96
|
+
padding-right: 8px;
|
97
|
+
padding-left: 8px;
|
98
|
+
background-color: ${e=>e.theme.colors.primary[95]};
|
99
|
+
border-bottom: 2px solid ${e=>e.theme.colors.primary[85]};
|
100
|
+
`,G=l.button`
|
101
|
+
will-change: auto;
|
102
|
+
min-width: 100px;
|
103
|
+
outline: none;
|
104
|
+
border: 0;
|
105
|
+
font-family: inherit;
|
106
|
+
background-color: transparent;
|
107
|
+
cursor: pointer;
|
108
|
+
color: ${e=>e.theme.colors.primary[50]};
|
109
|
+
padding: 8px 16px;
|
110
|
+
font-weight: 500;
|
111
|
+
transition: background-color 0.2s ease-in;
|
112
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
113
|
+
|
114
|
+
&:hover,
|
115
|
+
&:focus {
|
116
|
+
background-color: ${e=>e.theme.colors.primary[90]};
|
117
|
+
}
|
118
|
+
`,Q=l.div`
|
119
|
+
display: flex;
|
120
|
+
justify-content: center;
|
121
|
+
align-items: center;
|
122
|
+
font-size: 14px;
|
123
|
+
width: 40px;
|
124
|
+
color: #8c8c8c;
|
125
|
+
`,K=t=>e.createElement(q,{className:"zm-Header"},e.createElement(R,{"aria-label":"Previous month",onClick:t.onPrevClick,className:"zm-IconPrevButton",tabIndex:0},e.createElement(J,null)),e.createElement(G,{className:"zm-MonthYearButton",role:"presentation",onClick:t.onClickOnTitle,"aria-label":"calendar view is open, switch to year and month view",tabIndex:0},t.monthName),e.createElement(R,{"aria-label":"Next month",onClick:t.onNextClick,className:"zm-IconNextButton",tabIndex:0},e.createElement(Z,null)));var ee={exports:{}};ee.exports=function(){var e=1e3,t=6e4,n=36e5,r="millisecond",o="second",a="minute",i="hour",s="day",l="week",c="month",u="quarter",d="year",m="date",h="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},g=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},v={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),o=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(o,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),o=t.clone().add(r,c),a=n-o<0,i=t.clone().add(r+(a?-1:1),c);return+(-(r+(n-o)/(a?o-i:i-o))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:d,w:l,d:s,D:m,h:i,m:a,s:o,ms:r,Q:u}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",x={};x[b]=y;var $="$isDayjsObject",w=function(e){return e instanceof E||!(!e||!e[$])},M=function e(t,n,r){var o;if(!t)return b;if("string"==typeof t){var a=t.toLowerCase();x[a]&&(o=a),n&&(x[a]=n,o=a);var i=t.split("-");if(!o&&i.length>1)return e(i[0])}else{var s=t.name;x[s]=t,o=s}return!r&&o&&(b=o),o||!r&&b},k=function(e,t){if(w(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new E(n)},D=v;D.l=M,D.i=w,D.w=function(e,t){return k(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function y(e){this.$L=M(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[$]=!0}var g=y.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(D.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(f);if(r){var o=r[2]-1||0,a=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],o,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return D},g.isValid=function(){return!(this.$d.toString()===h)},g.isSame=function(e,t){var n=k(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return k(e)<this.startOf(t)},g.isBefore=function(e,t){return this.endOf(t)<k(e)},g.$g=function(e,t,n){return D.u(e)?this[t]:this.set(n,e)},g.unix=function(){return Math.floor(this.valueOf()/1e3)},g.valueOf=function(){return this.$d.getTime()},g.startOf=function(e,t){var n=this,r=!!D.u(t)||t,u=D.p(e),h=function(e,t){var o=D.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?o:o.endOf(s)},f=function(e,t){return D.w(n.toDate()[e].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},p=this.$W,y=this.$M,g=this.$D,v="set"+(this.$u?"UTC":"");switch(u){case d:return r?h(1,0):h(31,11);case c:return r?h(1,y):h(0,y+1);case l:var b=this.$locale().weekStart||0,x=(p<b?p+7:p)-b;return h(r?g-x:g+(6-x),y);case s:case m:return f(v+"Hours",0);case i:return f(v+"Minutes",1);case a:return f(v+"Seconds",2);case o:return f(v+"Milliseconds",3);default:return this.clone()}},g.endOf=function(e){return this.startOf(e,!1)},g.$set=function(e,t){var n,l=D.p(e),u="set"+(this.$u?"UTC":""),h=(n={},n[s]=u+"Date",n[m]=u+"Date",n[c]=u+"Month",n[d]=u+"FullYear",n[i]=u+"Hours",n[a]=u+"Minutes",n[o]=u+"Seconds",n[r]=u+"Milliseconds",n)[l],f=l===s?this.$D+(t-this.$W):t;if(l===c||l===d){var p=this.clone().set(m,1);p.$d[h](f),p.init(),this.$d=p.set(m,Math.min(this.$D,p.daysInMonth())).$d}else h&&this.$d[h](f);return this.init(),this},g.set=function(e,t){return this.clone().$set(e,t)},g.get=function(e){return this[D.p(e)]()},g.add=function(r,u){var m,h=this;r=Number(r);var f=D.p(u),p=function(e){var t=k(h);return D.w(t.date(t.date()+Math.round(e*r)),h)};if(f===c)return this.set(c,this.$M+r);if(f===d)return this.set(d,this.$y+r);if(f===s)return p(1);if(f===l)return p(7);var y=(m={},m[a]=t,m[i]=n,m[o]=e,m)[f]||1,g=this.$d.getTime()+r*y;return D.w(g,this)},g.subtract=function(e,t){return this.add(-1*e,t)},g.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||h;var r=e||"YYYY-MM-DDTHH:mm:ssZ",o=D.z(this),a=this.$H,i=this.$m,s=this.$M,l=n.weekdays,c=n.months,u=n.meridiem,d=function(e,n,o,a){return e&&(e[n]||e(t,r))||o[n].slice(0,a)},m=function(e){return D.s(a%12||12,e,"0")},f=u||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(p,(function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return D.s(t.$y,4,"0");case"M":return s+1;case"MM":return D.s(s+1,2,"0");case"MMM":return d(n.monthsShort,s,c,3);case"MMMM":return d(c,s);case"D":return t.$D;case"DD":return D.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return d(n.weekdaysMin,t.$W,l,2);case"ddd":return d(n.weekdaysShort,t.$W,l,3);case"dddd":return l[t.$W];case"H":return String(a);case"HH":return D.s(a,2,"0");case"h":return m(1);case"hh":return m(2);case"a":return f(a,i,!0);case"A":return f(a,i,!1);case"m":return String(i);case"mm":return D.s(i,2,"0");case"s":return String(t.$s);case"ss":return D.s(t.$s,2,"0");case"SSS":return D.s(t.$ms,3,"0");case"Z":return o}return null}(e)||o.replace(":","")}))},g.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},g.diff=function(r,m,h){var f,p=this,y=D.p(m),g=k(r),v=(g.utcOffset()-this.utcOffset())*t,b=this-g,x=function(){return D.m(p,g)};switch(y){case d:f=x()/12;break;case c:f=x();break;case u:f=x()/3;break;case l:f=(b-v)/6048e5;break;case s:f=(b-v)/864e5;break;case i:f=b/n;break;case a:f=b/t;break;case o:f=b/e;break;default:f=b}return h?f:D.a(f)},g.daysInMonth=function(){return this.endOf(c).$D},g.$locale=function(){return x[this.$L]},g.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=M(e,t,!0);return r&&(n.$L=r),n},g.clone=function(){return D.w(this.$d,this)},g.toDate=function(){return new Date(this.valueOf())},g.toJSON=function(){return this.isValid()?this.toISOString():null},g.toISOString=function(){return this.$d.toISOString()},g.toString=function(){return this.$d.toUTCString()},y}(),Y=E.prototype;return k.prototype=Y,[["$ms",r],["$s",o],["$m",a],["$H",i],["$W",s],["$M",c],["$y",d],["$D",m]].forEach((function(e){Y[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),k.extend=function(e,t){return e.$i||(e(t,E,k),e.$i=!0),k},k.locale=M,k.isDayjs=w,k.unix=function(e){return k(1e3*e)},k.en=x[b],k.Ls=x,k.p={},k}();var te=ee.exports,ne=m(te);!function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),r={name:"fa",weekdays:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),weekdaysShort:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(e){return e},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};n.default.locale(r,null,!0)}(te);var re={exports:{}};re.exports=function(e,t){t.prototype.weekday=function(e){var t=this.$locale().weekStart||0,n=this.$W,r=(n<t?n+7:n)-t;return this.$utils().u(e)?r:this.subtract(r,"day").add(e,"day")}};var oe,ae=m(re.exports),ie={exports:{}},se=m(ie.exports=(oe={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},function(e,t,n){var r=t.prototype,o=r.format;n.en.formats=oe,r.format=function(e){void 0===e&&(e="YYYY-MM-DDTHH:mm:ssZ");var t=this.$locale().formats,n=function(e,t){return e.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(e,n,r){var o=r&&r.toUpperCase();return n||t[r]||oe[r]||t[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))}(e,void 0===t?{}:t);return o.call(this,n)}}));const le=(e,t,n)=>{const{locale:r}=V,o=Object.assign(Object.assign({},t),null!=n&&{numberingSystem:n});return new Date(e).toLocaleString(r,o)},ce=e=>parseInt(le(e,{day:"numeric"},"latn"),10),ue=(e,t)=>le(e,{day:"numeric"},t),de=(e,t)=>le(e,{year:"numeric"},t),me=(e,t)=>le(e,{month:"2-digit"},t);var he={exports:{}};he.exports=function(e,t,n){t.prototype.isBetween=function(e,t,r,o){var a=n(e),i=n(t),s="("===(o=o||"()")[0],l=")"===o[1];return(s?this.isAfter(a,r):!this.isBefore(a,r))&&(l?this.isBefore(i,r):!this.isAfter(i,r))||(s?this.isBefore(a,r):!this.isAfter(a,r))&&(l?this.isAfter(i,r):!this.isBefore(i,r))}};var fe=m(he.exports);ne.extend(fe);const pe=(e,t)=>me(e)===me(t),ye=(e,t)=>void 0!==e&&ne(e).isSame(t,"day"),ge=(e,t,n)=>null!==t&&null!==n&&ne(e).isBetween(ne(t),ne(n)),ve={MMMM:(e,t)=>le(e,{month:"short"},t),MM:me,M:me,YYYY:de,YY:(e,t)=>le(e,{year:"2-digit"},t),DD:ue,D:ue},be=/\/|\s|-/,xe=(e,t,n)=>{try{(e=>{const t=e.trimStart().trimEnd().split(be);if(""===e||""===e.trim())throw new Error("format is empty");t.forEach((e=>{if(!(e in ve))throw new Error(`format is not valid, format passed is: ${e}`)}))})(t);const r=t.trimStart().trimEnd().split(be),o=t.match(be),a=null!==o?o[0]:"";return r.map((t=>ve[t](e,n))).join(a)}catch(e){console.error(e)}return""};ne.extend(ae),ne.extend(se);const $e=e=>{const{locale:t}=V;ne.locale(t);const n=void 0===e?new Date:ne(e).toDate(),r=ce(new Date(n)),o=ne(new Date(n)).subtract(r-1,"days"),a=o.weekday(),i=ne(o).subtract(a,"days"),s=o.add(15,"days"),l=[];let c=ne(i.format());for(let e=0;e<=5;e++){const e=[];for(let t=0;t<7;t++){const t=new Date(c.format());e.push({date:t,disabled:!pe(o.toDate(),t)}),c=c.add(1,"day")}l.push(e)}return{id:Date.now(),monthName:xe(new Date(n),"MMMM YYYY"),middleOfMonth:s.toDate(),weeks:l}},we=()=>X()?_:-320,Me=l.div`
|
126
|
+
color: inherit;
|
127
|
+
`,ke=l.button`
|
128
|
+
position: relative;
|
129
|
+
outline: none;
|
130
|
+
background-color: transparent;
|
131
|
+
display: flex;
|
132
|
+
font-family: inherit;
|
133
|
+
align-items: center;
|
134
|
+
justify-content: center;
|
135
|
+
width: ${e=>e.width}px;
|
136
|
+
height: ${e=>e.height}px;
|
137
|
+
border: 1px solid transparent;
|
138
|
+
user-select: none;
|
139
|
+
color: ${e=>e.theme.colors.gray[600]};
|
140
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
141
|
+
|
142
|
+
// pseudos
|
143
|
+
&:hover,
|
144
|
+
&:focus {
|
145
|
+
border-color: ${e=>e.theme.colors.gray[50]};
|
146
|
+
}
|
147
|
+
&:active {
|
148
|
+
background-color: ${e=>e.theme.colors.primary[40]};
|
149
|
+
border-color: transparent;
|
150
|
+
color: ${e=>e.theme.colors.gray[0]};
|
151
|
+
}
|
152
|
+
// days picker
|
153
|
+
&[data-selected='true'] {
|
154
|
+
background-color: ${e=>e.theme.colors.primary[50]};
|
155
|
+
border-color: transparent;
|
156
|
+
color: ${e=>e.theme.colors.gray[0]};
|
157
|
+
}
|
158
|
+
&[data-disabled='true'] {
|
159
|
+
border-color: transparent;
|
160
|
+
}
|
161
|
+
&[data-disabled='true'] .cl-text {
|
162
|
+
opacity: 0.5;
|
163
|
+
}
|
164
|
+
&:not([data-range='true']) {
|
165
|
+
transition: all 0.1s linear;
|
166
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
167
|
+
}
|
168
|
+
&:not([data-selected='true'])&[data-weekend='true'] {
|
169
|
+
color: #ff4d4d;
|
170
|
+
}
|
171
|
+
&:not([data-disabled='true']) {
|
172
|
+
cursor: pointer;
|
173
|
+
}
|
174
|
+
// range picker
|
175
|
+
&[data-in-range='true'] {
|
176
|
+
background-color: ${e=>e.theme.colors.primary[90]};
|
177
|
+
border-color: transparent;
|
178
|
+
}
|
179
|
+
&[data-start-range='true'] {
|
180
|
+
background-color: ${e=>e.theme.colors.primary[40]};
|
181
|
+
color: ${e=>e.theme.colors.gray[0]};
|
182
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
183
|
+
border-color: transparent;
|
184
|
+
}
|
185
|
+
&[data-end-range='true'] {
|
186
|
+
background-color: ${e=>e.theme.colors.primary[40]};
|
187
|
+
color: ${e=>e.theme.colors.gray[0]};
|
188
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
189
|
+
border-color: transparent;
|
190
|
+
}
|
191
|
+
&[data-in-range='true']:before,
|
192
|
+
&[data-end-range='true']:before {
|
193
|
+
content: ' ';
|
194
|
+
display: block;
|
195
|
+
position: absolute;
|
196
|
+
width: 40px;
|
197
|
+
height: 40px;
|
198
|
+
top: -1px;
|
199
|
+
left: ${e=>"rtl"===e.theme.direction?"20px":"unset"};
|
200
|
+
right: ${e=>"rtl"===e.theme.direction?"unset":"20px"};
|
201
|
+
background-color: ${e=>e.theme.colors.primary[90]};
|
202
|
+
z-index: -1;
|
203
|
+
}
|
204
|
+
&[data-in-range='true']:nth-of-type(1):before,
|
205
|
+
&[data-start-range='true']:before {
|
206
|
+
display: none;
|
207
|
+
}
|
208
|
+
`;ke.defaultProps={width:40,height:40};const De={fa:{shortWeekDays:[{key:0,name:"ش"},{key:1,name:"ی"},{key:2,name:"د"},{key:3,name:"س"},{key:4,name:"چ"},{key:5,name:"پ"},{key:6,name:"ج"}],months:[{key:1,name:"فروردین"},{key:2,name:"اردیبهشت"},{key:3,name:"خرداد"},{key:4,name:"تیر"},{key:5,name:"مرداد"},{key:6,name:"شهریور"},{key:7,name:"مهر"},{key:8,name:"آبان"},{key:9,name:"آذر"},{key:10,name:"دی"},{key:11,name:"بهمن"},{key:12,name:"اسفند"}],format:"YYYY/MM/DD",am:"ق.ظ",pm:"ب.ظ"},en:{shortWeekDays:[{key:0,name:"S"},{key:1,name:"M"},{key:2,name:"T"},{key:3,name:"W"},{key:4,name:"T"},{key:5,name:"F"},{key:6,name:"S"}],months:[{key:1,name:"January"},{key:2,name:"February"},{key:3,name:"March"},{key:4,name:"April"},{key:5,name:"May"},{key:6,name:"June"},{key:7,name:"July"},{key:8,name:"August"},{key:9,name:"September"},{key:10,name:"October"},{key:11,name:"November"},{key:12,name:"December"}],format:"MM-DD-YY",am:"AM",pm:"PM"}},Ee=l.div`
|
209
|
+
display: flex;
|
210
|
+
justify-content: center;
|
211
|
+
align-items: center;
|
212
|
+
flex-wrap: wrap;
|
213
|
+
gap: 4px;
|
214
|
+
height: ${_}px;
|
215
|
+
`,Ye=t=>{const{locale:n}=V,r=xe(t.value,"MM","latn");return e.createElement(Ee,null,De[n].months.map((n=>e.createElement(ke,{key:n.key,className:"zm-MonthPickerButton",width:90,height:48,"data-selected":n.key===parseInt(r,10),onClick:()=>t.onMonthSelect(n.key),"aria-current":"date",type:"button",tabIndex:0},n.name))))},_e=l.div`
|
216
|
+
display: grid;
|
217
|
+
grid-template-columns: repeat(3, 92px);
|
218
|
+
grid-template-rows: auto;
|
219
|
+
justify-content: center;
|
220
|
+
gap: 4px;
|
221
|
+
max-height: ${_}px;
|
222
|
+
overflow: auto;
|
223
|
+
padding-top: 8px;
|
224
|
+
padding-bottom: 8px;
|
225
|
+
`,Ce=t=>{const n=parseInt(xe(t.value,"YYYY","latn"),10),o=r((()=>((e,t=80,n=50)=>{const r=parseInt(de(e,"latn"),10),o=r+n,a=[];for(let e=r-t;e<=o;e++)a.push(e);return a})(t.value)),[]),a=e.useCallback((e=>{if(null===e)return;const t=e.querySelector("button[data-selected=true]");if(null!=t){const{height:n,top:r}=e.getBoundingClientRect(),{top:o}=t.getBoundingClientRect();e.scrollTop=Math.abs(r-o)-n/2}}),[]);return e.createElement(_e,{ref:a},o.map((r=>e.createElement(ke,{className:"zm-YearPickerButton",key:r,width:90,height:48,"data-selected":n===r,"aria-selected":n===r,"aria-current":"date",type:"button",tabIndex:0,onClick:()=>t.onYearSelect(r)},U(r)))))},Se=e=>!0===e.range,Te=e=>{const[t,r]=o(!1),[a,i]=o(void 0!==e.from?new Date(e.from):void 0);console.log(e.controlledRangeValue);const[s,l]=o(void 0!==e.to?new Date(e.to):void 0),c=(t,n)=>{"function"==typeof e.onChange&&Se(e)&&null!=t&&null!=n&&e.onChange({from:t,to:n})};return n((()=>{null!=e.controlledRangeValue&&(i(e.controlledRangeValue[0]),l(e.controlledRangeValue[1]))}),[e.controlledRangeValue]),{handlers:Object.assign({onClick:n=>!0===e.range?(e=>{const{value:n}=e.currentTarget.dataset;t||(void 0!==n&&(i(new Date(n)),l(null)),r(!0)),t&&null===s&&(void 0!==n&&(l(new Date(n)),c(a,new Date(n))),r(!1)),t&&void 0!==s&&(c(a,s),r(!1))})(n):(t=>{const{value:n,disabled:r}=t.currentTarget.dataset;if(void 0!==n&&"true"!==r)return Se(e)||"function"!=typeof e.onChange||e.onChange({value:new Date(n)}),n})(n)},!0===e.range&&{onMouseMove:e=>{const{value:n}=e.currentTarget.dataset;t&&void 0!==n&&ne(n).isAfter(ne(a))&&l(new Date(n))}}),from:a,to:s}},Oe=a(((a,s)=>{const{locale:l}=V,{defaultValue:c,weekends:u,controlledValue:d,range:m=!1}=a,h=void 0===c?new Date:c,[f,p]=o("days"),[y,g]=o(void 0!==c?new Date(c):void 0),v=r((()=>$e(y)),[y]),[b,x]=o([v]),$=t([]),w=(({daysElementRefs:e,days:n,setDays:r})=>{const o=t(!1),a=n[0].middleOfMonth,i=t=>requestAnimationFrame((()=>{o.current=!0;const[n,a]=e.current;n.style.transform=`translateX(${we()}px)`,a.style.transform=`translateX(${we()}px)`,requestAnimationFrame((()=>{a.style.transition=`transform 250ms ${C}`,a.style.transform="translateX(0px)",n.style.transition=`transform 250ms ${C}`,n.style.transform="translateX(0px)",setTimeout((()=>{r((e=>e.filter((e=>e.id===t.id)))),n.style.transition=null,n.style.transform=null,o.current=!1}),300)}))})),s=t=>{requestAnimationFrame((()=>{o.current=!0;const[n,a]=e.current;n.style.transition=`transform 250ms ${C}`,n.style.transform=`translateX(${we()}px)`,a.style.transition=`transform 250ms ${C}`,a.style.transform=`translateX(${we()}px)`,setTimeout((()=>{r((e=>e.filter((e=>e.id===t.id)))),a.style.transition=null,a.style.transform=null,o.current=!1}),300)}))};return{slideToTheNextMonth:()=>{if(o.current)return;const e=ne(a).add(1,"month"),t=$e(e.toDate());r([...n,t]),s(t)},slideToPrevMonth:()=>{if(o.current)return;const e=ne(a).subtract(1,"month"),t=$e(e.toDate());r([t,...n]),i(t)},slideToCurrentMonth:()=>{if(o.current)return;const e=ce(new Date);console.log(e);const t=ne(new Date).subtract(e-1,"days").add(15,"days");console.log("middle of the month",t.toDate());const l=$e(t.toDate());r([...n,l]),ne(a).isAfter(t)&&(console.log("we re animating right "),i(l)),ne(a.getMonth()).isBefore(t.get("month"))&&(console.log("we re animating left"),s(l))}}})({daysElementRefs:$,days:b,setDays:x}),{from:M,to:k,handlers:D}=Te(a);i(s,(()=>({todayTransitionHandler:()=>w.slideToCurrentMonth()})));return n((()=>{d!==y&&void 0!==d&&g(d)}),[d]),e.createElement(F,{ref:s,className:null!==a.className?a.className:""},e.createElement(K,{monthName:b[0].monthName,onNextClick:()=>{if("days"===f)return w.slideToTheNextMonth()},onPrevClick:()=>{if("days"===f)return w.slideToPrevMonth()},onClickOnTitle:()=>{p("month"!==f&&"year"!==f?"year":"days")}}),"year"===f?e.createElement(Ce,{value:h,onYearSelect:e=>{const t=((e,t)=>{const n=t-parseInt(de(e,"latn"),10);return n>0?ne(e).add(n,"years").toDate():ne(e).subtract(Math.abs(n),"years").toDate()})(h,e);x([$e(t)]),p("month")}}):null,"month"===f?e.createElement(Ye,{value:h,onMonthSelect:e=>{const t=((e,t)=>{const n=t-parseInt(me(e,"latn"),10);return n>0?ne(e).add(n,"months").toDate():ne(e).subtract(Math.abs(n),"months").toDate()})(b[0].middleOfMonth,e);x([$e(t)]),p("days")}}):null,"days"===f?e.createElement(e.Fragment,null,e.createElement(P,null,De[l].shortWeekDays.map((t=>e.createElement(Q,{key:t.key},t.name)))),e.createElement(A,null,b.map(((t,n)=>e.createElement(W,{key:t.id,className:"item",ref:e=>{$.current[n]=e},role:"rowgroup"},t.weeks.map(((t,n)=>e.createElement(z,{key:n,role:"row","aria-rowindex":n+1},t.map(((t,n)=>e.createElement(ke,Object.assign({key:t.date.getTime(),className:"zm-DaysButton","data-value":t.date,"data-disabled":t.disabled,"data-range":a.range,"data-selected":!m&&ye(y,t.date),"data-start-range":null!=M&&ye(M,t.date),"data-in-range":ge(t.date,M,k),"data-end-range":null!=k&&ye(k,t.date),"data-weekend":null==u?void 0:u.some((e=>e===n)),type:"button",role:"gridcell","aria-colindex":n+1,tabIndex:0,"aria-selected":!m&&ye(h,t.date)},D),e.createElement(Me,{className:"cl-text"},xe(t.date,"DD"))))))))))))):null)}));function Le(e,t){n((()=>{function n({target:n}){null==e.current||e.current.contains(n)||t()}return document.addEventListener("mousedown",n),()=>{document.removeEventListener("mousedown",n)}}),[e,t])}Oe.displayName="Calendar";const Ne=(e,t,n)=>`hsl(${e}deg ${t}% ${n}%)`,He=e=>{const{h:t,s:n,l:r}=function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(null==t)throw new Error("Could not parse Hex Color");const n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,o=parseInt(t[3],16)/255,a=Math.max(n,r,o),i=Math.min(n,r,o);let s=(a+i)/2,l=s,c=s;if(a===i)return{h:0,s:0,l:c};const u=a-i;switch(l=c>.5?u/(2-a-i):u/(a+i),a){case n:s=(r-o)/u+(r<o?6:0);break;case r:s=(o-n)/u+2;break;case o:s=(n-r)/u+4}return s/=6,l*=100,l=Math.round(l),c*=100,c=Math.round(c),s=Math.round(360*s),{h:s,s:l,l:c}}(e),o={};return o[40]=Ne(t,n,r-10),o[50]=Ne(t,n,r),o[85]=Ne(t,n,85),o[90]=Ne(t,n,90),o[95]=Ne(t,n,95),o},Ie={0:"#FFFFFF",20:"#F5F5F5",30:"#EBEBEB",40:"#DEDEDE",50:"#BFBFBF",60:"#B0B0B0",70:"#575757",80:"#666666",600:"#2E2E2E"},je=t=>{const{accentColor:n=S,locale:o,round:a="thin",direction:i="rtl"}=t;r((()=>V.setLocale(o)),[o]);const s={colors:{primary:r((()=>He(n)),[]),gray:Ie},round:a,direction:i};return e.createElement(u,{theme:s},t.children)},Be=a=>{const{defaultValue:i,locale:s="fa",weekends:l=[],direction:c="rtl",accentColor:u,controlledValue:d}=a;r((()=>V.setLocale(s)),[s]);const m=t(null),h=t(null),[f,p]=o(void 0!==i?new Date(i):void 0),[y,g]=o(!0===a.range&&void 0!==a.from?new Date(a.from):void 0),[v,b]=o(!0===a.range&&void 0!==a.to?new Date(a.to):void 0),[x,$]=o(!1);n((()=>{d&&d!==f&&p(d)}),[d]),Le(h,(()=>$(!1)));const w=()=>{$(!x)},M=r((()=>{var e;const t=null!==(e=null==a?void 0:a.customShowDateFormat)&&void 0!==e?e:De[s].format;return void 0===a.range&&void 0!==f?xe(f,t):(console.log("from >>",y),void 0!==y&&void 0!==v?`\n ${xe(y,t)}\n -\n ${xe(v,t)}\n `:"")}),[f,y,v]);return e.createElement(je,{accentColor:u,round:a.round,direction:c},e.createElement("input",Object.assign({ref:m},null==a?void 0:a.inputAttributes,{onClick:w,type:"text",value:M,className:null!==a.inputClass?a.inputClass:"",readOnly:!0})),e.createElement(j,{toggleOpen:w,showCalendar:x,destinationRef:m,position:a.position},e.createElement(Oe,{defaultValue:f,ref:h,className:a.className,weekends:l,onChange:e=>{if(!0===a.range&&"function"==typeof a.onChange){const t="from"in e?e.from:new Date,n="to"in e?e.to:new Date;g(t),b(n),a.onChange({from:t,to:n})}else if((!1===a.range||void 0===a.range)&&"function"==typeof a.onChange){const t="value"in e?e.value:new Date;p(t),a.onChange({value:t})}},range:a.range,from:!0===a.range?a.from:void 0,to:!0===a.range?a.to:void 0})))},Fe=l.div`
|
226
|
+
width: 260px;
|
227
|
+
height: 260px;
|
228
|
+
position: relative;
|
229
|
+
z-index: 1;
|
230
|
+
border-radius: 50%;
|
231
|
+
background-color: ${e=>e.theme.colors.primary[95]};
|
232
|
+
`,Ae=l("div")`
|
233
|
+
left: 50%;
|
234
|
+
width: 1.5px;
|
235
|
+
bottom: 50%;
|
236
|
+
height: ${e=>e.isInsideHour?"26%":"40%"};
|
237
|
+
position: absolute;
|
238
|
+
background-color: ${e=>e.theme.colors.primary[85]};
|
239
|
+
transform-origin: center bottom 0;
|
240
|
+
transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
241
|
+
pointer-events: none;
|
242
|
+
${e=>e.isSelectingHour?`transform: rotateZ(${e.value/12*360}deg); `:`transform: rotateZ(${e.value/60*360}deg); `}
|
243
|
+
`,We=l("div")`
|
244
|
+
top: -22px;
|
245
|
+
right: -16px;
|
246
|
+
border: 16px solid ${e=>e.theme.colors.primary[85]};
|
247
|
+
position: absolute;
|
248
|
+
box-sizing: content-box;
|
249
|
+
border-radius: 100%;
|
250
|
+
background-color: ${e=>e.theme.colors.primary[85]};
|
251
|
+
pointer-events: none;
|
252
|
+
`,ze=l.div`
|
253
|
+
position: absolute;
|
254
|
+
top: 16px;
|
255
|
+
left: 16px;
|
256
|
+
display: flex;
|
257
|
+
align-items: center;
|
258
|
+
gap: 8px;
|
259
|
+
`,Pe=l.div`
|
260
|
+
padding: 4px 8px;
|
261
|
+
border-radius: ${e=>B[e.theme.round].calendarItem}px;
|
262
|
+
background-color: ${e=>e.theme.colors.gray[20]};
|
263
|
+
`,Re=l.div`
|
264
|
+
display: flex;
|
265
|
+
gap: 4px;
|
266
|
+
`,Ve=l.div`
|
267
|
+
cursor: pointer;
|
268
|
+
font-size: 12px;
|
269
|
+
padding: 4px;
|
270
|
+
border-radius: 4px;
|
271
|
+
|
272
|
+
&.cl_selected {
|
273
|
+
background-color: ${e=>e.theme.colors.gray[20]};
|
274
|
+
}
|
275
|
+
`;const Xe=130,Ue=130,Je=(e,t=30)=>{const{offsetX:n,offsetY:r}=(e=>{const t=e,n=e;let{offsetX:r,offsetY:o}=t.nativeEvent;if(void 0===r){const e=n.currentTarget.getBoundingClientRect();0!==n.changedTouches.length?(r=n.changedTouches[0].clientX-e.left,o=n.changedTouches[0].clientY-e.top):(r=t.clientX-e.left,o=t.clientY-e.top)}return{offsetX:r,offsetY:o}})(e),o=n-Xe,a=r-Ue,i=Math.PI-Math.atan2(o,a),s=Math.sqrt(Math.pow(o,2)+Math.pow(a,2));const l=((e,t,n)=>{const r=Math.floor(e*(1/n));return 6===n?r:Math.round(t)>85?0===r?-12:r:0===r?12:r})(57.29577951308232*i,s,t);return{value:l,delta:s}},Ze=[12,1,2,3,4,5,6,7,8,9,10,11],qe=[0,13,14,15,16,17,18,19,20,21,22,23],Ge=[0,5,10,15,20,25,30,35,40,45,50,55],Qe=l("div")`
|
276
|
+
animation: ${O} 0.7s linear alternate;
|
277
|
+
`,Ke=l.span`
|
278
|
+
left: calc(50% - 16px);
|
279
|
+
top: ${e=>e.top};
|
280
|
+
width: 32px;
|
281
|
+
height: 32px;
|
282
|
+
display: inline-flex;
|
283
|
+
position: absolute;
|
284
|
+
align-items: center;
|
285
|
+
border-radius: 32px;
|
286
|
+
justify-content: center;
|
287
|
+
user-select: none;
|
288
|
+
pointer-events: none;
|
289
|
+
color: black;
|
290
|
+
transform: ${e=>`translate(${function(e,t=130,n=20){const r=t-n;return Math.round(r*Math.sin(.5235987755982988*e))}(e.idx,e.clockHalfWidth,e.numbersPadd)}px,\n ${function(e,t=130,n=17){const r=t-n;return-Math.round(r*Math.cos(.5235987755982988*e))+t-n}(e.idx,e.clockHalfWidth,e.numbersPadd)}px)`};
|
291
|
+
`;Ke.defaultProps={clockHalfWidth:130,numbersPadd:24,top:"2%"};const et=t=>{const{insideHour:n,hourSelecting:r,clockTime:o}=t;return r?12===o?e.createElement(e.Fragment,null,Ze.map(((t,r)=>e.createElement(Ke,{key:t,idx:r,style:{opacity:n?.3:1}},U(t))))):e.createElement(e.Fragment,null,Ze.map(((t,r)=>e.createElement(Ke,{key:t,idx:r,top:"15%",clockHalfWidth:85,numbersPadd:10,style:{opacity:n?1:.3}},U(t)))),qe.map(((t,r)=>e.createElement(Ke,{key:t,idx:r,style:{opacity:n?.3:1}},U(t))))):e.createElement(Qe,null,Ge.map(((t,n)=>e.createElement(Ke,{key:t,idx:n},U(t)))))},tt=l.div`
|
292
|
+
overflow: hidden;
|
293
|
+
position: relative;
|
294
|
+
display: flex;
|
295
|
+
flex-direction: column;
|
296
|
+
justify-content: center;
|
297
|
+
align-items: center;
|
298
|
+
width: ${_}px;
|
299
|
+
min-height: ${372}px;
|
300
|
+
border: 1px solid ${e=>e.theme.colors.gray[40]};
|
301
|
+
background-color: #fff;
|
302
|
+
border-radius: ${e=>B[e.theme.round].wrapper}px;
|
303
|
+
`,nt=n=>{const{defaultValue:a,onChange:i,round:s="x2",locale:l="fa",clockTime:c=24}=n;r((()=>V.setLocale(l)),[l]);const u=t(null),d=t(null),[m,h]=o(!1),[f,p]=o("am");Le(d,(()=>h(!1)));const y=()=>{h(!m)},{hour:g,minute:v,isInsideHour:b,selectingHour:x,handleMouseMove:$,handleMouseUp:w,handleSelecting:M}=(({defaultValue:e,clockTime:t,timeConvention:n,onChange:r})=>{const a=void 0!==e?ne(e):ne().startOf("date"),[i,s]=o(!1),[l,c]=o(!1),[u,d]=o(!1),m=24===t?"HH":"h",[h,f]=o(parseInt(a.format(m),10)),[p,y]=o(parseInt(a.format("mm"),10)),g=e=>{const{value:t}=Je(e,6);y(t)},v=e=>{const{value:n,delta:r}=Je(e);24!==t?f(n):Math.round(r)<85?(f(n),d(!0)):(f(n+12),d(!1))};return{hour:h,minute:p,isInsideHour:u,selectingHour:l,handleMouseMove:e=>{if(e.preventDefault(),i)return l?v(e):g(e)},handleMouseUp:()=>{if(l)return"function"==typeof r&&r(Object.assign({hour:h,minute:p},12===t&&{timeConvention:n})),s(!1),c(!1),void d(!1);s(!1),c(!0)},handleSelecting:e=>(s(!0),l?v(e):g(e))}})({defaultValue:a,clockTime:c,timeConvention:f,onChange:i}),k=r((()=>`${g}:${v}`),[g,v]);return e.createElement(je,{accentColor:n.accentColor,round:s},e.createElement("input",Object.assign({ref:u},null==n?void 0:n.inputAttributes,{onClick:y,type:"text",value:k,className:null!==n.inputClass?n.inputClass:"",readOnly:!0})),e.createElement(j,{toggleOpen:y,showCalendar:m,destinationRef:u},e.createElement(tt,{ref:d},e.createElement(ze,null,12===c?e.createElement(Re,null,e.createElement(Ve,{className:"am"===f?"cl_selected":"",onClick:()=>p("am")},De[l].am),e.createElement(Ve,{className:"pm"===f?"cl_selected":"",onClick:()=>p("pm")},De[l].pm)):null,e.createElement(Pe,null,U(g),":",U(v))),e.createElement(Fe,{onMouseMove:$,onMouseUp:w,onMouseDown:M,onTouchMove:M,onTouchEnd:w},e.createElement(Ae,{value:x?g:v,hour:g,minute:v,isSelectingHour:x,isInsideHour:b},e.createElement(We,{isSelectingHour:x})),e.createElement(et,{insideHour:b,hourSelecting:x,clockTime:c})))))};export{Oe as Calendar,je as CalendarProvider,Be as DatePicker,nt as TimePicker};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
export declare const Wrapper: import("@emotion/styled").StyledComponent<{
|
2
|
+
theme?: import("@emotion/react").Theme;
|
3
|
+
as?: React.ElementType;
|
4
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
5
|
+
export declare const WrapperDays: import("@emotion/styled").StyledComponent<{
|
6
|
+
theme?: import("@emotion/react").Theme;
|
7
|
+
as?: React.ElementType;
|
8
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
9
|
+
export declare const SlideDays: import("@emotion/styled").StyledComponent<{
|
10
|
+
theme?: import("@emotion/react").Theme;
|
11
|
+
as?: React.ElementType;
|
12
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
13
|
+
export declare const Days: import("@emotion/styled").StyledComponent<{
|
14
|
+
theme?: import("@emotion/react").Theme;
|
15
|
+
as?: React.ElementType;
|
16
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
17
|
+
export declare const SubHeader: import("@emotion/styled").StyledComponent<{
|
18
|
+
theme?: import("@emotion/react").Theme;
|
19
|
+
as?: React.ElementType;
|
20
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { DaysRange, DatePickerValue, onRangeDatePickerChangePayload, onDatePickerChangePayload } from '../../types';
|
2
|
+
export interface CalendarBaseProps {
|
3
|
+
defaultValue?: Date;
|
4
|
+
weekends?: DaysRange[];
|
5
|
+
className?: string;
|
6
|
+
controlledValue?: Date;
|
7
|
+
}
|
8
|
+
export interface CalendarRangeProps {
|
9
|
+
range: true;
|
10
|
+
from?: DatePickerValue;
|
11
|
+
to?: DatePickerValue;
|
12
|
+
rangeValue?: Date[];
|
13
|
+
onChange?: (args: onRangeDatePickerChangePayload) => void;
|
14
|
+
controlledRangeValue?: [Date, Date];
|
15
|
+
}
|
16
|
+
export interface CalendarDefaultProps {
|
17
|
+
range?: false | undefined;
|
18
|
+
onChange?: (args: onDatePickerChangePayload) => void;
|
19
|
+
}
|
20
|
+
export type OnChangePayload = onRangeDatePickerChangePayload | onDatePickerChangePayload;
|
21
|
+
export type CalendarProps = CalendarBaseProps & (CalendarRangeProps | CalendarDefaultProps);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
2
|
+
import type { BaseProps, DatePickerValue, DaysRange, Positions } from '../../types';
|
3
|
+
import type { CalendarDefaultProps, CalendarRangeProps } from '../Calendar/Calendar.types';
|
4
|
+
export interface DatePickerBaseProps extends BaseProps {
|
5
|
+
defaultValue?: DatePickerValue;
|
6
|
+
weekends?: DaysRange[];
|
7
|
+
show?: boolean;
|
8
|
+
inputClass?: string;
|
9
|
+
className?: string;
|
10
|
+
inputAttributes?: InputHTMLAttributes<HTMLInputElement>;
|
11
|
+
position?: Positions;
|
12
|
+
customShowDateFormat?: string;
|
13
|
+
controlledValue?: DatePickerValue;
|
14
|
+
}
|
15
|
+
export type DatePickerProps = DatePickerBaseProps & (CalendarRangeProps | CalendarDefaultProps);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
export declare const Clock: import("@emotion/styled").StyledComponent<{
|
2
|
+
theme?: import("@emotion/react").Theme;
|
3
|
+
as?: React.ElementType;
|
4
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
5
|
+
export interface IStyledHandProps {
|
6
|
+
hour: number;
|
7
|
+
minute: number;
|
8
|
+
value: number;
|
9
|
+
isInsideHour: boolean;
|
10
|
+
isSelectingHour: boolean;
|
11
|
+
}
|
12
|
+
export declare const Hand: import("@emotion/styled").StyledComponent<{
|
13
|
+
theme?: import("@emotion/react").Theme;
|
14
|
+
as?: React.ElementType;
|
15
|
+
} & IStyledHandProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
16
|
+
export declare const HandCircle: import("@emotion/styled").StyledComponent<{
|
17
|
+
theme?: import("@emotion/react").Theme;
|
18
|
+
as?: React.ElementType;
|
19
|
+
} & {
|
20
|
+
isSelectingHour: boolean;
|
21
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
22
|
+
export declare const TimeWrapper: import("@emotion/styled").StyledComponent<{
|
23
|
+
theme?: import("@emotion/react").Theme;
|
24
|
+
as?: React.ElementType;
|
25
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
26
|
+
export declare const Time: import("@emotion/styled").StyledComponent<{
|
27
|
+
theme?: import("@emotion/react").Theme;
|
28
|
+
as?: React.ElementType;
|
29
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
30
|
+
export declare const ClockTimeWrapper: import("@emotion/styled").StyledComponent<{
|
31
|
+
theme?: import("@emotion/react").Theme;
|
32
|
+
as?: React.ElementType;
|
33
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
34
|
+
export declare const ClockTime: import("@emotion/styled").StyledComponent<{
|
35
|
+
theme?: import("@emotion/react").Theme;
|
36
|
+
as?: React.ElementType;
|
37
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
2
|
+
import type { BaseProps, DatePickerValue } from '../../types';
|
3
|
+
export interface onChangePayload {
|
4
|
+
hour: number;
|
5
|
+
minute: number;
|
6
|
+
timeConvention?: 'am' | 'pm';
|
7
|
+
}
|
8
|
+
export interface TimePickerProps extends BaseProps {
|
9
|
+
defaultValue?: DatePickerValue;
|
10
|
+
clockTime?: 12 | 24;
|
11
|
+
onChange?: (payload: onChangePayload) => void;
|
12
|
+
inputClass?: string;
|
13
|
+
inputAttributes?: InputHTMLAttributes<HTMLInputElement>;
|
14
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { NumbersItemProps } from './Numbers.types';
|
2
|
+
export declare const MinuteWithAnimation: import("@emotion/styled").StyledComponent<{
|
3
|
+
theme?: import("@emotion/react").Theme;
|
4
|
+
as?: React.ElementType;
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
6
|
+
export declare const NumbersItem: import("@emotion/styled").StyledComponent<{
|
7
|
+
theme?: import("@emotion/react").Theme;
|
8
|
+
as?: React.ElementType;
|
9
|
+
} & NumbersItemProps, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export interface NumbersProps {
|
2
|
+
insideHour: boolean;
|
3
|
+
hourSelecting: boolean;
|
4
|
+
clockTime: 12 | 24;
|
5
|
+
}
|
6
|
+
export interface NumbersItemProps {
|
7
|
+
idx: number;
|
8
|
+
clockHalfWidth?: number;
|
9
|
+
numbersPadd?: number;
|
10
|
+
top?: string;
|
11
|
+
insideHour?: boolean;
|
12
|
+
isSelectedNumber?: boolean;
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Numbers';
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export declare const MonthYearButton = "zm-MonthYearButton";
|
2
|
+
export declare const IconNextButton = "zm-IconNextButton";
|
3
|
+
export declare const IconPrevButton = "zm-IconPrevButton";
|
4
|
+
export declare const HeaderClass = "zm-Header";
|
5
|
+
export declare const DaysButton = "zm-DaysButton";
|
6
|
+
export declare const MonthPickerButton = "zm-MonthPickerButton";
|
7
|
+
export declare const YearPickerButton = "zm-YearPickerButton";
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const makeColorPallet: (accentColor: string) => Record<number, string>;
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
import '@emotion/react';
|
2
|
+
import type { Radius } from './style/radius';
|
3
|
+
export type DatePickerValue = number | Date | string;
|
4
|
+
export type Locales = 'fa' | 'en';
|
5
|
+
export type Directions = 'rtl' | 'ltr';
|
6
|
+
export type DaysRange = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
7
|
+
export type Pickers = 'days' | 'year' | 'month';
|
8
|
+
export type Positions = 'right' | 'left' | 'center';
|
9
|
+
export interface BaseProps {
|
10
|
+
round?: Radius;
|
11
|
+
accentColor?: string;
|
12
|
+
locale?: Locales;
|
13
|
+
direction?: Directions;
|
14
|
+
}
|
15
|
+
export interface onDatePickerChangePayload {
|
16
|
+
value: Date;
|
17
|
+
}
|
18
|
+
export interface onRangeDatePickerChangePayload {
|
19
|
+
from: Date;
|
20
|
+
to: Date;
|
21
|
+
}
|
22
|
+
interface MyProps1 {
|
23
|
+
range: true;
|
24
|
+
myMethod: (arg: onRangeDatePickerChangePayload) => void;
|
25
|
+
}
|
26
|
+
interface MyProps2 {
|
27
|
+
range: false;
|
28
|
+
myMethod: (arg: onDatePickerChangePayload) => void;
|
29
|
+
}
|
30
|
+
export type CalendarTypeProps = MyProps1 | MyProps2;
|
31
|
+
declare module '@emotion/react' {
|
32
|
+
interface Theme {
|
33
|
+
colors: {
|
34
|
+
gray: Record<number, string>;
|
35
|
+
primary: Record<number, string>;
|
36
|
+
};
|
37
|
+
round: Radius;
|
38
|
+
direction: Directions;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
export {};
|