meticulous-ui 3.7.8 → 3.7.10
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/cjs/components/Button/Button.cjs +6 -6
- package/cjs/components/Carousel/Carousel.cjs +15 -15
- package/cjs/components/DatePicker/DatePicker.cjs +48 -48
- package/cjs/components/Dropdown/Dropdown.cjs +29 -29
- package/cjs/components/Input/Checkbox/Checkbox.cjs +8 -8
- package/cjs/components/Input/FileUploader/FileUploader.cjs +8 -8
- package/cjs/components/Input/Input/Input.cjs +1 -1
- package/cjs/components/Input/Radio/Radio.cjs +10 -10
- package/cjs/components/Input/RadioGroup/RadioGroup.cjs +4 -4
- package/cjs/components/Input/Textarea/Textarea.cjs +4 -4
- package/cjs/components/Loader/Loader.cjs +5 -5
- package/cjs/components/Modal/Modal.cjs +6 -6
- package/cjs/components/OtpInput/OtpInput.cjs +2 -2
- package/cjs/components/PageLoader/PageLoader.cjs +4 -4
- package/cjs/components/Pagination/Pagination.cjs +21 -21
- package/cjs/components/Ripple/Ripple.cjs +1 -1
- package/cjs/components/Selectbox/Selectbox.cjs +24 -24
- package/cjs/components/Spinner/Spinner.cjs +7 -7
- package/cjs/components/Toast/Toast.cjs +24 -24
- package/cjs/components/VideoPlayer/useSpacebarToggle.cjs +1 -1
- package/cjs/hooks/useCopyToClipboard.cjs +1 -1
- package/cjs/hooks/useEventListener.cjs +1 -1
- package/cjs/hooks/useLocalStorage.cjs +1 -1
- package/cjs/hooks/useSessionStorage.cjs +1 -1
- package/cjs/reactUtils/withErrorBoundary.cjs +1 -1
- package/cjs/reactUtils/withSuspense.cjs +1 -1
- package/cjs/utils/auditLog.cjs +1 -1
- package/cjs/utils/captureException.cjs +1 -1
- package/cjs/utils/copyToClipboard.cjs +1 -1
- package/cjs/utils/createPubSub.cjs +1 -1
- package/cjs/utils/decodeJWT.cjs +1 -1
- package/cjs/utils/detectOutsideClick.cjs +1 -1
- package/cjs/utils/featureGate.cjs +1 -1
- package/cjs/utils/focusElement.cjs +1 -1
- package/cjs/utils/getLocalStorage.cjs +1 -1
- package/cjs/utils/getSessionStorage.cjs +1 -1
- package/cjs/utils/getVariant.cjs +1 -1
- package/cjs/utils/groupBy.cjs +1 -1
- package/cjs/utils/handleKeyboardNavigation.cjs +1 -1
- package/cjs/utils/hasPermission.cjs +1 -1
- package/cjs/utils/isAuthenticated.cjs +1 -1
- package/cjs/utils/isFeatureEnabled.cjs +1 -1
- package/cjs/utils/isURL.cjs +1 -1
- package/cjs/utils/logInfo.cjs +1 -1
- package/cjs/utils/logWarn.cjs +1 -1
- package/cjs/utils/measureElement.cjs +1 -1
- package/cjs/utils/measurePerformance.cjs +1 -1
- package/cjs/utils/permissionGuard.cjs +1 -1
- package/cjs/utils/requestIdleTask.cjs +1 -1
- package/cjs/utils/safeJSONParse.cjs +1 -1
- package/cjs/utils/safeJSONStringify.cjs +1 -1
- package/cjs/utils/setLocalStorage.cjs +1 -1
- package/cjs/utils/setSessionStorage.cjs +1 -1
- package/cjs/utils/smoothScroll.cjs +1 -1
- package/cjs/utils/toggleFullscreen.cjs +1 -1
- package/cjs/utils/trackEvent.cjs +1 -1
- package/cjs/utils/trackPageView.cjs +1 -1
- package/cjs/utils/trapFocus.cjs +1 -1
- package/components/Button/Button.js +50 -49
- package/components/Carousel/Carousel.js +104 -103
- package/components/DatePicker/DatePicker.js +184 -180
- package/components/Dropdown/Dropdown.js +118 -116
- package/components/Input/Checkbox/Checkbox.js +92 -88
- package/components/Input/FileUploader/FileUploader.js +50 -48
- package/components/Input/Input/Input.js +4 -1
- package/components/Input/Radio/Radio.js +37 -36
- package/components/Input/RadioGroup/RadioGroup.js +26 -23
- package/components/Input/Textarea/Textarea.js +13 -10
- package/components/Loader/Loader.js +22 -16
- package/components/Modal/Modal.js +62 -60
- package/components/OtpInput/OtpInput.js +61 -60
- package/components/PageLoader/PageLoader.js +37 -33
- package/components/Pagination/Pagination.js +89 -87
- package/components/Ripple/Ripple.js +1 -1
- package/components/Selectbox/Selectbox.js +77 -75
- package/components/Spinner/Spinner.js +28 -27
- package/components/Toast/Toast.js +69 -68
- package/components/VideoPlayer/useSpacebarToggle.js +15 -14
- package/hooks/useCopyToClipboard.js +3 -3
- package/hooks/useEventListener.js +8 -8
- package/hooks/useLocalStorage.js +5 -5
- package/hooks/useSessionStorage.js +5 -5
- package/package.json +1 -1
- package/reactUtils/withErrorBoundary.js +7 -6
- package/reactUtils/withSuspense.js +7 -6
- package/utils/auditLog.js +7 -6
- package/utils/captureException.js +1 -1
- package/utils/copyToClipboard.js +4 -3
- package/utils/createPubSub.js +11 -7
- package/utils/decodeJWT.js +4 -4
- package/utils/detectOutsideClick.js +7 -6
- package/utils/featureGate.js +1 -1
- package/utils/focusElement.js +5 -3
- package/utils/getLocalStorage.js +1 -1
- package/utils/getSessionStorage.js +1 -1
- package/utils/getVariant.js +5 -4
- package/utils/groupBy.js +5 -4
- package/utils/handleKeyboardNavigation.js +13 -13
- package/utils/hasPermission.js +8 -7
- package/utils/isAuthenticated.js +5 -5
- package/utils/isFeatureEnabled.js +5 -4
- package/utils/isURL.js +5 -5
- package/utils/logInfo.js +5 -4
- package/utils/logWarn.js +5 -4
- package/utils/measureElement.js +5 -4
- package/utils/measurePerformance.js +8 -7
- package/utils/permissionGuard.js +1 -1
- package/utils/requestIdleTask.js +1 -1
- package/utils/safeJSONParse.js +3 -3
- package/utils/safeJSONStringify.js +3 -3
- package/utils/setLocalStorage.js +3 -3
- package/utils/setSessionStorage.js +3 -3
- package/utils/smoothScroll.js +8 -7
- package/utils/toggleFullscreen.js +2 -1
- package/utils/trackEvent.js +5 -4
- package/utils/trackPageView.js +6 -5
- package/utils/trapFocus.js +10 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),M=require("react"),D=require("../Spinner/Spinner.cjs"),P=require("../../colors/colorMap.cjs"),w=require("../../colors/blue.cjs"),R=require("../Ripple/Ripple.cjs"),S=require("../../colors/white.cjs"),v=require("../../colors/grey.cjs"),y=require("./constants.cjs"),z=require("prop-types"),l=require("styled-components"),x=e=>e&&e.__esModule?e:{default:e},o=x(z),d=x(l),B=d.default.button`
|
|
2
2
|
height: ${({$height:e})=>e}rem;
|
|
3
3
|
width: ${({$width:e})=>e}rem;
|
|
4
4
|
border-radius: 0.96rem;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
padding: 0.96rem 0.64rem;
|
|
7
7
|
position: relative;
|
|
8
8
|
overflow: hidden;
|
|
9
|
-
background-color: ${({$selectedColor:e,disabled:t})=>t?
|
|
9
|
+
background-color: ${({$selectedColor:e,disabled:t})=>t?v.default.m500:e};
|
|
10
10
|
cursor: ${({disabled:e,$isLoading:t})=>e?"not-allowed":t?"auto":"pointer"};
|
|
11
11
|
|
|
12
12
|
${({$isLoading:e})=>e&&l.css`
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
&:focus-visible {
|
|
27
27
|
outline: none;
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,E=d.default.div`
|
|
30
30
|
font-size: ${({$font:e})=>e}rem;
|
|
31
31
|
font-weight: 500;
|
|
32
32
|
max-width: 100%;
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
color: ${({$textColor:e})=>e};
|
|
35
35
|
opacity: ${({$isLoading:e})=>e?0:1};
|
|
36
36
|
transition: opacity 0.3s ease;
|
|
37
|
-
`,
|
|
37
|
+
`,K=d.default.div`
|
|
38
38
|
height: ${({$height:e})=>e}rem;
|
|
39
39
|
width: ${({$width:e})=>e}rem;
|
|
40
40
|
display: inline-block;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
transform: translateY(-2px);
|
|
54
54
|
}
|
|
55
55
|
`};
|
|
56
|
-
`,
|
|
56
|
+
`,O=d.default.div`
|
|
57
57
|
position: absolute;
|
|
58
58
|
inset: 0;
|
|
59
59
|
display: flex;
|
|
@@ -62,4 +62,4 @@
|
|
|
62
62
|
opacity: ${({$isLoading:e})=>e?1:0};
|
|
63
63
|
transition: opacity 0.3s ease;
|
|
64
64
|
pointer-events: none;
|
|
65
|
-
`,
|
|
65
|
+
`,W=({theme:e,children:t})=>r.jsx(R.default,{rippleColor:e.m100,children:t}),C=e=>{var g;const{children:t,theme:n=w.blue,size:q=y.MEDIUM,width:c,leftIcon:U,rightIcon:Y,isLoading:i,textColor:u,onKeyDown:a,...j}=e||{},f=M.useRef(0),_=s=>{if(s.key==="Enter"||s.key===" "){const $=Date.now();if($-f.current<500){s.preventDefault(),s.stopPropagation();return}f.current=$}a==null||a(s)},{m400:T,m500:k,m600:I}=(g=P.default[n])!=null?g:w.blue,{height:h,width:p,font:L}=y.SIZE[q]||{},m=["white","yellow"].includes(n)?v.default.m600:S.default,b=r.jsxs(B,{type:"button",...j,onKeyDown:_,$hoverColor:k,$activeColor:I,$selectedColor:T,$height:h,$width:c||p,disabled:e.disabled,$isLoading:i,children:[r.jsx(O,{$isLoading:i,children:r.jsx(D.default,{size:"small",color:u||m})}),r.jsx(E,{$isLoading:i,$textColor:u||m,$font:L,children:t})]});return r.jsx(K,{$height:h,$width:c||p,disabled:e.disabled,$isLoading:i,children:i?b:r.jsx(W,{theme:n,children:b})})};C.propTypes={children:o.default.node,theme:o.default.string,size:o.default.string,width:o.default.oneOfType([o.default.string,o.default.number]),leftIcon:o.default.elementType,rightIcon:o.default.elementType,isLoading:o.default.bool,textColor:o.default.string,disabled:o.default.bool};exports.default=C;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),s=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),s=require("react"),fe=require("../Icons/ChevronLeft.cjs"),he=require("../Icons/ChevronRight.cjs"),Y=require("styled-components"),pe=t=>t&&t.__esModule?t:{default:t},o=pe(Y),xe=o.default.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
width: 100%;
|
|
7
7
|
gap: 12px;
|
|
8
8
|
outline: none;
|
|
9
|
-
`,
|
|
9
|
+
`,be=o.default.div`
|
|
10
10
|
position: relative;
|
|
11
11
|
width: 100%;
|
|
12
|
-
`,
|
|
12
|
+
`,ge=o.default.div`
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
width: 100%;
|
|
15
15
|
outline: none;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
&:active {
|
|
19
19
|
cursor: ${({$draggable:t})=>t?"grabbing":"default"};
|
|
20
20
|
}
|
|
21
|
-
`,
|
|
21
|
+
`,ve=o.default.div`
|
|
22
22
|
display: flex;
|
|
23
23
|
width: 100%;
|
|
24
24
|
transform: translateX(${({$translateX:t})=>t}%);
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
min-width: 0;
|
|
34
34
|
box-sizing: border-box;
|
|
35
35
|
}
|
|
36
|
-
`,
|
|
36
|
+
`,N=o.default.button`
|
|
37
37
|
position: absolute;
|
|
38
|
-
top: ${({$arrowTop:t})=>t
|
|
38
|
+
top: ${({$arrowTop:t})=>t!=null?t:"50%"};
|
|
39
39
|
transform: translateY(-50%);
|
|
40
40
|
z-index: 1;
|
|
41
41
|
display: flex;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
opacity 0.3s;
|
|
54
54
|
padding: 0;
|
|
55
55
|
|
|
56
|
-
${({$direction:t,$overlay:
|
|
56
|
+
${({$direction:t,$overlay:l})=>t==="prev"?`left: ${l?"12px":"-16px"};`:`right: ${l?"12px":"-16px"};`}
|
|
57
57
|
|
|
58
58
|
&:hover:not(:disabled) {
|
|
59
59
|
background: #f5f5f5;
|
|
@@ -74,15 +74,15 @@
|
|
|
74
74
|
border-color: #bdbdbd;
|
|
75
75
|
`}
|
|
76
76
|
|
|
77
|
-
${({$overlay:t,$visible:
|
|
77
|
+
${({$overlay:t,$visible:l})=>t&&!l&&`
|
|
78
78
|
opacity: 0;
|
|
79
79
|
pointer-events: none;
|
|
80
80
|
`}
|
|
81
|
-
`,
|
|
81
|
+
`,me=o.default.div`
|
|
82
82
|
display: flex;
|
|
83
83
|
gap: 6px;
|
|
84
84
|
align-items: center;
|
|
85
|
-
`,
|
|
85
|
+
`,we=o.default.button`
|
|
86
86
|
width: ${({$active:t})=>t?"20px":"8px"};
|
|
87
87
|
height: 8px;
|
|
88
88
|
border-radius: 4px;
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
transition:
|
|
94
94
|
width 0.2s ease,
|
|
95
95
|
background 0.2s ease;
|
|
96
|
-
|
|
96
|
+
`,$e=Y.keyframes`
|
|
97
97
|
from { width: 0%; }
|
|
98
98
|
to { width: 100%; }
|
|
99
|
-
`,
|
|
99
|
+
`,je=o.default.div`
|
|
100
100
|
width: 100%;
|
|
101
101
|
height: 3px;
|
|
102
102
|
background: #e0e0e0;
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
inset: 0;
|
|
111
111
|
width: 0%;
|
|
112
112
|
background: #333;
|
|
113
|
-
animation: ${
|
|
113
|
+
animation: ${$e} ${({$duration:t})=>t}s linear forwards;
|
|
114
114
|
animation-play-state: ${({$paused:t})=>t?"paused":"running"};
|
|
115
115
|
|
|
116
116
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
width: 100%;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
`,ke=o.default.button`
|
|
122
122
|
position: absolute;
|
|
123
123
|
bottom: 8px;
|
|
124
124
|
right: 8px;
|
|
@@ -145,4 +145,4 @@
|
|
|
145
145
|
outline: 2px solid #fff;
|
|
146
146
|
outline-offset: 2px;
|
|
147
147
|
}
|
|
148
|
-
`,
|
|
148
|
+
`,E=50,D=2e3,ye=()=>n.jsxs("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"1",width:"3",height:"10",rx:"1"}),n.jsx("rect",{x:"7",y:"1",width:"3",height:"10",rx:"1"})]}),Me=()=>n.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M2 1.5l9 4.5-9 4.5V1.5z"})}),Ee=({data:t,renderCarousel:l,visibleSlides:R=1,hasArrow:L=!0,overlayArrows:u=!1,arrowTop:m,areDotsHidden:A=!1,autoSlide:w=!1,autoSlideSec:T=3,loop:h=!1,dragToSlide:$=!1,liveDrag:j=!1,liveDragMobile:I=!0,showProgress:G=!1,defaultIndex:J=0,onSlideChange:X,...Q})=>{var U,K;const[i,k]=s.useState(J),[O,p]=s.useState(!0),[P,S]=s.useState(!1),[x,b]=s.useState(!1),[Z,g]=s.useState(0),[q,v]=s.useState(!1),[_,z]=s.useState(!1),d=s.useRef(null),c=s.useRef(null),f=s.useRef(null),B=s.useRef(null);s.useEffect(()=>{const e=window.matchMedia("(max-width: 1024px)");z(e.matches);const r=de=>z(de.matches);return e.addEventListener("change",r),()=>e.removeEventListener("change",r)},[]);const a=t.length-R,y=()=>k(e=>h&&e===0?a:Math.max(e-1,0)),M=()=>k(e=>h&&e>=a?0:Math.min(e+1,a));s.useEffect(()=>{X==null||X(i)},[i]);const V=()=>{u&&(clearTimeout(f.current),p(!0),f.current=setTimeout(()=>p(!1),D))},ee=()=>{b(!0),u&&(clearTimeout(f.current),p(!0))},te=()=>{b(!1),u&&(f.current=setTimeout(()=>p(!1),D))};s.useEffect(()=>{if(u)return f.current=setTimeout(()=>p(!1),D),()=>clearTimeout(f.current)},[u]),s.useEffect(()=>{if(!w||x)return;const e=setInterval(()=>{k(r=>r>=a?0:r+1)},T*1e3);return()=>clearInterval(e)},[w,T,x,a]);const W=e=>h?e:i===0&&e>0||i===a&&e<0?e*.3:e,ne=e=>{d.current=e.touches[0].clientX,I&&_&&v(!0),V()},re=e=>{!I||!_||d.current===null||g(W(e.touches[0].clientX-d.current))},se=e=>{if(I&&_&&(v(!1),g(0)),d.current===null)return;const r=d.current-e.changedTouches[0].clientX;r>E?M():r<-E&&y(),d.current=null},ie=e=>{$&&(c.current=e.clientX,j&&v(!0))},oe=e=>{!$||!j||c.current===null||g(W(e.clientX-c.current))},ae=e=>{if(!$||c.current===null)return;j&&(v(!1),g(0));const r=c.current-e.clientX;r>E?M():r<-E&&y(),c.current=null},ue=e=>{e.key==="ArrowLeft"?(e.preventDefault(),y()):e.key==="ArrowRight"&&(e.preventDefault(),M())},F=(K=(U=B.current)==null?void 0:U.clientWidth)!=null?K:0,ce=F>0?Z/F*100:0,le=-(i*(100/R))+ce,H=m!==void 0?typeof m=="number"?`${m}px`:m:void 0,C=a+1;return n.jsxs(xe,{onClick:V,onMouseEnter:ee,onMouseLeave:te,onMouseMove:oe,onMouseUp:ae,onKeyDown:ue,role:"region","aria-label":"Carousel",...Q,children:[n.jsxs(be,{onTouchStart:ne,onTouchMove:re,onTouchEnd:se,children:[L&&n.jsx(N,{onClick:y,disabled:!h&&i===0,"aria-label":"Previous slide",$direction:"prev",$overlay:u,$visible:O,$arrowTop:H,$viewportFocused:P,children:n.jsx(fe.default,{size:20,"aria-hidden":"true"})}),n.jsx(ge,{ref:B,tabIndex:0,"aria-label":"Carousel slides. Use arrow keys to navigate.",$draggable:$,onFocus:()=>{S(!0),b(!0)},onBlur:()=>{S(!1),b(!1)},onMouseDown:ie,onMouseLeave:e=>{e.buttons!==1&&(j&&q&&(v(!1),g(0)),c.current=null)},children:n.jsx(ve,{$translateX:le,$visibleSlides:R,$dragging:q,children:t.map(l)})}),L&&n.jsx(N,{onClick:M,disabled:!h&&i===a,"aria-label":"Next slide",$direction:"next",$overlay:u,$visible:O,$arrowTop:H,$viewportFocused:P,children:n.jsx(he.default,{size:20,"aria-hidden":"true"})}),w&&n.jsx(ke,{onClick:()=>b(e=>!e),"aria-label":x?"Play slideshow":"Pause slideshow",children:x?n.jsx(Me,{}):n.jsx(ye,{})})]}),n.jsxs("div",{"aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"},children:["Slide ",i+1," of ",C]}),w&&G&&n.jsx(je,{$duration:T,$paused:x},i),!A&&n.jsx(me,{children:Array.from({length:C}).map((e,r)=>n.jsx(we,{$active:r===i,onClick:()=>k(r),"aria-label":`Slide ${r+1} of ${C}`,"aria-current":r===i?"true":void 0},r))})]})};exports.default=Ee;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),f=require("react"),Me=require("prop-types"),Re=require("../../colors/colorMap.cjs"),Ne=require("../../colors/blue.cjs"),s=require("./constants.cjs"),g=require("./utils.cjs"),B=require("styled-components"),le=t=>t&&t.__esModule?t:{default:t},b=le(Me),i=le(B),we=B.keyframes`
|
|
2
2
|
from { opacity: 0; transform: translateY(6px); }
|
|
3
3
|
to { opacity: 1; transform: translateY(0); }
|
|
4
|
-
`,
|
|
4
|
+
`,Oe=i.default.div`
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
background: #ffffff;
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
padding: 20px;
|
|
13
13
|
width: 320px;
|
|
14
14
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
15
|
-
animation: ${
|
|
15
|
+
animation: ${we} 0.22s ease;
|
|
16
16
|
user-select: none;
|
|
17
|
-
`,
|
|
17
|
+
`,Le=i.default.div`
|
|
18
18
|
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
20
|
gap: 8px;
|
|
21
21
|
margin-bottom: 16px;
|
|
22
|
-
`,
|
|
22
|
+
`,C=i.default.div`
|
|
23
23
|
flex: 1;
|
|
24
|
-
background: ${({$active:
|
|
25
|
-
color: ${({$active:
|
|
24
|
+
background: ${({$active:t,$primary:r})=>t?r:"#f1f3f4"};
|
|
25
|
+
color: ${({$active:t})=>t?"#fff":"#5f6368"};
|
|
26
26
|
border-radius: 12px;
|
|
27
27
|
padding: 10px 14px;
|
|
28
28
|
font-size: 13px;
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
opacity: 0.7;
|
|
41
41
|
margin-bottom: 2px;
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,Ge=i.default.div`
|
|
44
44
|
color: #bdc1c6;
|
|
45
45
|
font-size: 16px;
|
|
46
46
|
flex-shrink: 0;
|
|
47
|
-
`,
|
|
47
|
+
`,_e=i.default.div`
|
|
48
48
|
display: flex;
|
|
49
49
|
background: #f1f3f4;
|
|
50
50
|
border-radius: 10px;
|
|
51
51
|
padding: 3px;
|
|
52
52
|
margin-bottom: 16px;
|
|
53
|
-
`,
|
|
53
|
+
`,te=i.default.button`
|
|
54
54
|
flex: 1;
|
|
55
55
|
border: none;
|
|
56
|
-
background: ${({$active:
|
|
57
|
-
color: ${({$active:
|
|
56
|
+
background: ${({$active:t})=>t?"#fff":"transparent"};
|
|
57
|
+
color: ${({$active:t,$primary:r})=>t?r:"#5f6368"};
|
|
58
58
|
border-radius: 8px;
|
|
59
59
|
padding: 6px 0;
|
|
60
60
|
font-size: 12px;
|
|
@@ -63,18 +63,18 @@
|
|
|
63
63
|
transition:
|
|
64
64
|
background 0.15s,
|
|
65
65
|
color 0.15s;
|
|
66
|
-
box-shadow: ${({$active:
|
|
66
|
+
box-shadow: ${({$active:t})=>t?"0 1px 4px rgba(0,0,0,0.1)":"none"};
|
|
67
67
|
|
|
68
68
|
&:focus-visible {
|
|
69
|
-
outline: 2px solid ${({$primary:
|
|
69
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
70
70
|
outline-offset: 2px;
|
|
71
71
|
}
|
|
72
|
-
`,
|
|
72
|
+
`,Te=i.default.div`
|
|
73
73
|
display: flex;
|
|
74
74
|
align-items: center;
|
|
75
75
|
justify-content: space-between;
|
|
76
76
|
margin-bottom: 12px;
|
|
77
|
-
`,
|
|
77
|
+
`,ne=i.default.button`
|
|
78
78
|
background: none;
|
|
79
79
|
border: none;
|
|
80
80
|
cursor: pointer;
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
|
|
92
92
|
&:hover {
|
|
93
93
|
background: #f1f3f4;
|
|
94
|
-
color: ${({$primary:
|
|
94
|
+
color: ${({$primary:t})=>t};
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
&:focus-visible {
|
|
98
|
-
outline: 2px solid ${({$primary:
|
|
98
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
99
99
|
}
|
|
100
|
-
`,
|
|
100
|
+
`,re=i.default.button`
|
|
101
101
|
background: none;
|
|
102
102
|
border: none;
|
|
103
103
|
cursor: pointer;
|
|
@@ -113,13 +113,13 @@
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
&:focus-visible {
|
|
116
|
-
outline: 2px solid ${({$primary:
|
|
116
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
117
117
|
}
|
|
118
|
-
`,
|
|
118
|
+
`,Ye=i.default.div`
|
|
119
119
|
display: grid;
|
|
120
120
|
grid-template-columns: repeat(7, 1fr);
|
|
121
121
|
gap: 0;
|
|
122
|
-
`,
|
|
122
|
+
`,Ie=i.default.div`
|
|
123
123
|
text-align: center;
|
|
124
124
|
font-size: 11px;
|
|
125
125
|
font-weight: 600;
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
padding: 4px 0 8px;
|
|
128
128
|
text-transform: uppercase;
|
|
129
129
|
letter-spacing: 0.4px;
|
|
130
|
-
`,
|
|
130
|
+
`,Pe=i.default.div`
|
|
131
131
|
position: relative;
|
|
132
132
|
display: flex;
|
|
133
133
|
align-items: center;
|
|
@@ -138,11 +138,11 @@
|
|
|
138
138
|
content: '';
|
|
139
139
|
position: absolute;
|
|
140
140
|
inset: 4px 0;
|
|
141
|
-
background: ${({$inRange:
|
|
142
|
-
border-radius: ${({$rangeStart:
|
|
141
|
+
background: ${({$inRange:t,$primaryLight:r})=>t?r:"transparent"};
|
|
142
|
+
border-radius: ${({$rangeStart:t,$rangeEnd:r})=>t?"50% 0 0 50%":r?"0 50% 50% 0":"0"};
|
|
143
143
|
pointer-events: none;
|
|
144
144
|
}
|
|
145
|
-
`,
|
|
145
|
+
`,ze=i.default.button`
|
|
146
146
|
position: relative;
|
|
147
147
|
z-index: 1;
|
|
148
148
|
width: 32px;
|
|
@@ -154,36 +154,36 @@
|
|
|
154
154
|
justify-content: center;
|
|
155
155
|
font-size: 13px;
|
|
156
156
|
font-weight: 500;
|
|
157
|
-
cursor: ${({$empty:
|
|
158
|
-
background: ${({$selected:
|
|
159
|
-
color: ${({$selected:
|
|
160
|
-
outline: ${({$today:
|
|
157
|
+
cursor: ${({$empty:t,disabled:r})=>t||r?"default":"pointer"};
|
|
158
|
+
background: ${({$selected:t,$hovered:r,$primary:a,$primaryLight:u})=>t?a:r?u:"transparent"};
|
|
159
|
+
color: ${({$selected:t,$today:r,disabled:a,$primary:u})=>t?"#fff":a?"#dadce0":r?u:"#202124"};
|
|
160
|
+
outline: ${({$today:t,$selected:r,$primary:a})=>t&&!r?`2px solid ${a}`:"none"};
|
|
161
161
|
outline-offset: -2px;
|
|
162
162
|
transition:
|
|
163
163
|
background 0.12s,
|
|
164
164
|
color 0.12s;
|
|
165
|
-
pointer-events: ${({$empty:
|
|
165
|
+
pointer-events: ${({$empty:t,disabled:r})=>t||r?"none":"auto"};
|
|
166
166
|
|
|
167
|
-
${({$empty:
|
|
167
|
+
${({$empty:t})=>t&&B.css`
|
|
168
168
|
visibility: hidden;
|
|
169
169
|
`}
|
|
170
170
|
|
|
171
171
|
&:hover {
|
|
172
|
-
background: ${({$selected:
|
|
172
|
+
background: ${({$selected:t,$primary:r,$primaryDark:a,$primaryLight:u})=>t?a:u};
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
&:focus-visible {
|
|
176
|
-
outline: 2px solid ${({$primary:
|
|
176
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
177
177
|
}
|
|
178
|
-
`,
|
|
178
|
+
`,He=i.default.div`
|
|
179
179
|
display: grid;
|
|
180
180
|
grid-template-columns: repeat(3, 1fr);
|
|
181
181
|
gap: 6px;
|
|
182
182
|
padding: 4px 0;
|
|
183
|
-
`,
|
|
183
|
+
`,oe=i.default.button`
|
|
184
184
|
border: none;
|
|
185
|
-
background: ${({$active:
|
|
186
|
-
color: ${({$active:
|
|
185
|
+
background: ${({$active:t,$primary:r})=>t?r:"transparent"};
|
|
186
|
+
color: ${({$active:t})=>t?"#fff":"#202124"};
|
|
187
187
|
border-radius: 10px;
|
|
188
188
|
padding: 8px 4px;
|
|
189
189
|
font-size: 13px;
|
|
@@ -194,13 +194,13 @@
|
|
|
194
194
|
color 0.13s;
|
|
195
195
|
|
|
196
196
|
&:hover {
|
|
197
|
-
background: ${({$active:
|
|
197
|
+
background: ${({$active:t,$primaryDark:r})=>t?r:"#f1f3f4"};
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
&:focus-visible {
|
|
201
|
-
outline: 2px solid ${({$primary:
|
|
201
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
202
202
|
}
|
|
203
|
-
`,
|
|
203
|
+
`,qe=i.default.div`
|
|
204
204
|
display: grid;
|
|
205
205
|
grid-template-columns: repeat(3, 1fr);
|
|
206
206
|
gap: 6px;
|
|
@@ -208,17 +208,17 @@
|
|
|
208
208
|
overflow-y: auto;
|
|
209
209
|
padding: 4px 0;
|
|
210
210
|
scrollbar-width: thin;
|
|
211
|
-
`,
|
|
211
|
+
`,Ce=i.default.div`
|
|
212
212
|
display: flex;
|
|
213
213
|
justify-content: flex-end;
|
|
214
214
|
gap: 8px;
|
|
215
215
|
margin-top: 16px;
|
|
216
216
|
padding-top: 12px;
|
|
217
217
|
border-top: 1px solid #f1f3f4;
|
|
218
|
-
`,
|
|
218
|
+
`,se=i.default.button`
|
|
219
219
|
border: none;
|
|
220
|
-
background: ${({$isPrimary:
|
|
221
|
-
color: ${({$isPrimary:
|
|
220
|
+
background: ${({$isPrimary:t,$primary:r})=>t?r:"transparent"};
|
|
221
|
+
color: ${({$isPrimary:t,$primary:r})=>t?"#fff":r};
|
|
222
222
|
border-radius: 8px;
|
|
223
223
|
padding: 7px 16px;
|
|
224
224
|
font-size: 13px;
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
opacity 0.14s;
|
|
230
230
|
|
|
231
231
|
&:hover {
|
|
232
|
-
background: ${({$isPrimary:
|
|
232
|
+
background: ${({$isPrimary:t,$primaryDark:r,$primaryLight:a})=>t?r:a};
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
&:disabled {
|
|
@@ -238,6 +238,6 @@
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
&:focus-visible {
|
|
241
|
-
outline: 2px solid ${({$primary:
|
|
241
|
+
outline: 2px solid ${({$primary:t})=>t};
|
|
242
242
|
}
|
|
243
|
-
`,
|
|
243
|
+
`,Be=()=>n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"15 18 9 12 15 6"})}),Fe=()=>n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polyline",{points:"9 18 15 12 9 6"})}),d={CALENDAR:"calendar",MONTH:"month",YEAR:"year"},We=new Date,ie=1924,Ue=We.getFullYear()+20,Je=Array.from({length:Ue-ie+1},(t,r)=>ie+r),ae=({theme:t="blue",mode:r=s.MODE.SINGLE,value:a,rangeValue:u,onChange:l,minDate:w,maxDate:O,showModeToggle:ce=!0,showFooter:L=!0,...de})=>{var Q,X;const G=f.useMemo(()=>{var e;return(e=Re.default[t])!=null?e:Ne.blue},[t]),p=G.m500,_=G.m700,$=G.m100,T={$primary:p,$primaryDark:_,$primaryLight:$},F=new Date,[c,ue]=f.useState(r),[Y,I]=f.useState(F.getFullYear()),[k,v]=f.useState(F.getMonth()),[y,j]=f.useState(d.CALENDAR),[D,P]=f.useState(a!=null?a:null),[o,z]=f.useState((Q=u==null?void 0:u[0])!=null?Q:null),[m,S]=f.useState((X=u==null?void 0:u[1])!=null?X:null),[A,M]=f.useState(null),[R,N]=f.useState(!1),pe=g.buildCalendarGrid(Y,k),W=f.useCallback(e=>!!(!e||w&&e<w||O&&e>O),[w,O]),fe=()=>{k===0?(v(11),I(e=>e-1)):v(e=>e-1)},xe=()=>{k===11?(v(0),I(e=>e+1)):v(e=>e+1)},ge=e=>{if(!(!e||W(e))){if(c===s.MODE.SINGLE){P(e),L||l==null||l(e);return}!R||!o?(z(e),S(null),N(!0)):(S(e),N(!1),L||l==null||l([e<=o?e:o,e<=o?o:e]))}},H=e=>{ue(e),P(null),z(null),S(null),N(!1),M(null)};f.useEffect(()=>{H(r)},[r]);const be=()=>{if(c===s.MODE.SINGLE)l==null||l(D);else if(o&&m){const[e,E]=o<=m?[o,m]:[m,o];l==null||l([e,E])}},he=()=>{P(null),z(null),S(null),N(!1),M(null),l==null||l(c===s.MODE.SINGLE?null:[null,null])},x=R&&A?A:m,U=e=>c===s.MODE.RANGE&&g.isRangeStart(e,o,x),J=e=>c===s.MODE.RANGE&&g.isRangeEnd(e,o,x),me=e=>c===s.MODE.RANGE&&g.isInRange(e,o,x),ye=e=>c===s.MODE.SINGLE?g.isSameDay(e,D):U(e)||J(e),K=c===s.MODE.SINGLE?g.formatDate(D):g.formatDate(o?o<=(x!=null?x:o)?o:x:null),Ee=c===s.MODE.RANGE?g.formatDate(x?x>=o?x:o:null):null,ke=c===s.MODE.SINGLE?!D:!o||!m,ve=()=>n.jsx(He,{children:s.MONTHS.map((e,E)=>n.jsx(oe,{$active:E===k,...T,onClick:()=>{v(E),j(d.CALENDAR)},children:e.slice(0,3)},e))}),De=()=>n.jsx(qe,{children:Je.map(e=>n.jsx(oe,{$active:e===Y,...T,onClick:()=>{I(e),j(d.CALENDAR)},children:e},e))}),$e=()=>n.jsxs(Ye,{children:[s.DAYS_SHORT.map(e=>n.jsx(Ie,{children:e},e)),pe.map((e,E)=>{const h=!e,Z=W(e),q=!h&&ye(e),je=!h&&g.isToday(e),V=!h&&U(e),ee=!h&&J(e),Se=!h&&me(e),Ae=!h&&A&&g.isSameDay(e,A);return n.jsx(Pe,{$inRange:Se||V||ee,$rangeStart:V,$rangeEnd:ee,$primaryLight:$,children:n.jsx(ze,{$empty:h,$selected:q,$today:je,$hovered:Ae&&!q,disabled:Z,...T,onClick:()=>ge(e),onMouseEnter:()=>!h&&M(e),onMouseLeave:()=>M(null),"aria-label":e?e.toDateString():void 0,"aria-pressed":q,tabIndex:h||Z?-1:0,children:e==null?void 0:e.getDate()})},E)})]});return n.jsxs(Oe,{...de,children:[n.jsx(Le,{children:c===s.MODE.RANGE?n.jsxs(n.Fragment,{children:[n.jsxs(C,{$active:R||!o&&!m,$primary:p,children:[n.jsx("span",{children:"From"}),K]}),n.jsx(Ge,{children:"→"}),n.jsxs(C,{$active:!R&&!!m,$primary:p,children:[n.jsx("span",{children:"To"}),Ee]})]}):n.jsxs(C,{$active:!!D,$primary:p,style:{flex:"none",width:"100%"},children:[n.jsx("span",{children:"Selected"}),K]})}),ce&&n.jsxs(_e,{children:[n.jsx(te,{$active:c===s.MODE.SINGLE,$primary:p,onClick:()=>H(s.MODE.SINGLE),children:"Single"}),n.jsx(te,{$active:c===s.MODE.RANGE,$primary:p,onClick:()=>H(s.MODE.RANGE),children:"Range"})]}),n.jsxs(Te,{children:[n.jsx(ne,{$primary:p,onClick:fe,"aria-label":"Previous month",children:n.jsx(Be,{})}),n.jsxs("div",{style:{display:"flex",gap:4},children:[n.jsx(re,{$primary:p,onClick:()=>j(y===d.MONTH?d.CALENDAR:d.MONTH),children:s.MONTHS[k]}),n.jsx(re,{$primary:p,onClick:()=>j(y===d.YEAR?d.CALENDAR:d.YEAR),children:Y})]}),n.jsx(ne,{$primary:p,onClick:xe,"aria-label":"Next month",children:n.jsx(Fe,{})})]}),y===d.CALENDAR&&$e(),y===d.MONTH&&ve(),y===d.YEAR&&De(),L&&y===d.CALENDAR&&n.jsxs(Ce,{children:[n.jsx(se,{$primary:p,$primaryDark:_,$primaryLight:$,onClick:he,children:"Clear"}),n.jsx(se,{$isPrimary:!0,$primary:p,$primaryDark:_,$primaryLight:$,disabled:ke,onClick:be,children:"Apply"})]})]})};ae.propTypes={theme:b.default.string,mode:b.default.oneOf(["single","range"]),value:b.default.instanceOf(Date),rangeValue:b.default.arrayOf(b.default.instanceOf(Date)),onChange:b.default.func,minDate:b.default.instanceOf(Date),maxDate:b.default.instanceOf(Date),showModeToggle:b.default.bool,showFooter:b.default.bool};exports.default=ae;
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),o=require("react"),fe=require("prop-types"),p=require("../../colors/grey.cjs"),pe=require("../MenuItem/MenuItem.cjs"),me=require("../../colors/colorMap.cjs"),he=require("../../colors/blue.cjs"),H=require("../Spinner/Spinner.cjs"),h=require("styled-components"),be=require("../Typography/P/P.cjs"),ge=require("../Icons/ChevronDown.cjs"),xe=require("../Icons/Search.cjs"),we=require("./constants.cjs"),K=require("../../colors/white.cjs"),U=t=>t&&t.__esModule?t:{default:t},n=U(fe),c=U(h),ve=h.keyframes`
|
|
2
2
|
from {
|
|
3
3
|
transform: rotate(0deg);
|
|
4
4
|
}
|
|
5
5
|
to {
|
|
6
6
|
transform: rotate(180deg);
|
|
7
7
|
}
|
|
8
|
-
`,
|
|
8
|
+
`,ye=h.keyframes`
|
|
9
9
|
from {
|
|
10
10
|
transform: rotate(180deg);
|
|
11
11
|
}
|
|
12
12
|
to {
|
|
13
13
|
transform: rotate(0deg);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
`,$e=c.default.div`
|
|
16
16
|
max-width: ${({$width:t})=>t};
|
|
17
17
|
position: relative;
|
|
18
18
|
outline: none;
|
|
19
19
|
|
|
20
|
-
${({$isLoading:t})=>t&&
|
|
20
|
+
${({$isLoading:t})=>t&&h.css`
|
|
21
21
|
pointer-events: none;
|
|
22
22
|
opacity: 0.8;
|
|
23
23
|
`}
|
|
24
24
|
|
|
25
|
-
${({$isDisabled:t})=>t&&
|
|
25
|
+
${({$isDisabled:t})=>t&&h.css`
|
|
26
26
|
pointer-events: none;
|
|
27
27
|
opacity: 0.7;
|
|
28
28
|
`}
|
|
29
|
-
`,
|
|
29
|
+
`,Se=c.default.div`
|
|
30
30
|
height: 3.2rem;
|
|
31
31
|
width: ${({$width:t})=>t};
|
|
32
32
|
border-radius: 0.96rem;
|
|
33
|
-
border: ${({$isOpen:t,$isFocused:
|
|
33
|
+
border: ${({$isOpen:t,$isFocused:b,$border:l})=>t||b?`2px solid ${l}`:`1px solid ${we.DEFAULT_BORDER}`};
|
|
34
34
|
padding: 0.64rem 0.96rem 0.64rem;
|
|
35
35
|
display: flex;
|
|
36
36
|
align-items: center;
|
|
37
37
|
justify-content: space-between;
|
|
38
38
|
cursor: pointer;
|
|
39
|
-
|
|
39
|
+
`,ke=c.default(be.default)`
|
|
40
40
|
overflow: hidden;
|
|
41
41
|
white-space: nowrap;
|
|
42
42
|
text-overflow: ellipsis;
|
|
43
43
|
max-width: calc(${({$width:t})=>t} - 3.2rem);
|
|
44
44
|
pointer-events: none;
|
|
45
|
-
`,
|
|
46
|
-
animation: ${({$isOpen:t})=>t?
|
|
45
|
+
`,Ee=c.default(ge.default)`
|
|
46
|
+
animation: ${({$isOpen:t})=>t?ve:ye} 0.15s linear;
|
|
47
47
|
transform: rotate(${({$isOpen:t})=>t?180:0}deg);
|
|
48
|
-
`,
|
|
49
|
-
border: 1px solid ${
|
|
48
|
+
`,Ie=c.default.div`
|
|
49
|
+
border: 1px solid ${p.default.m700};
|
|
50
50
|
width: calc(${({$width:t})=>t} + 1.6rem);
|
|
51
51
|
/* Remove overflow: auto from here */
|
|
52
52
|
display: flex;
|
|
53
53
|
flex-direction: column;
|
|
54
54
|
position: absolute;
|
|
55
55
|
z-index: 1000;
|
|
56
|
-
background-color: ${
|
|
56
|
+
background-color: ${K.default};
|
|
57
57
|
left: 0.24rem;
|
|
58
58
|
max-height: 0;
|
|
59
59
|
transition: max-height 0.15s ease-out;
|
|
60
60
|
opacity: 0;
|
|
61
61
|
overflow: hidden; /* Keep this hidden so the collapse works */
|
|
62
62
|
|
|
63
|
-
${({$isOpen:t})=>t&&
|
|
64
|
-
max-height: ${({$height:
|
|
63
|
+
${({$isOpen:t})=>t&&h.css`
|
|
64
|
+
max-height: ${({$height:b})=>b};
|
|
65
65
|
opacity: 1;
|
|
66
66
|
`};
|
|
67
67
|
|
|
68
|
-
${({$top:t})=>t?
|
|
68
|
+
${({$top:t})=>t?h.css`
|
|
69
69
|
bottom: 100%;
|
|
70
70
|
flex-direction: column-reverse; /* Search at bottom if menu opens upward */
|
|
71
71
|
border-top-right-radius: 0.96rem;
|
|
72
72
|
border-top-left-radius: 0.96rem;
|
|
73
73
|
margin-bottom: 0.16rem;
|
|
74
|
-
`:
|
|
74
|
+
`:h.css`
|
|
75
75
|
top: 100%;
|
|
76
76
|
border-bottom-right-radius: 0.96rem;
|
|
77
77
|
border-bottom-left-radius: 0.96rem;
|
|
78
78
|
margin-top: 0.16rem;
|
|
79
79
|
`}
|
|
80
|
-
`,
|
|
80
|
+
`,Ce=c.default.div`
|
|
81
81
|
overflow-y: auto;
|
|
82
82
|
flex: 1;
|
|
83
|
-
`,
|
|
83
|
+
`,je=c.default.div`
|
|
84
84
|
position: absolute;
|
|
85
85
|
top: 1.28rem;
|
|
86
86
|
right: 1.92rem;
|
|
87
|
-
`,
|
|
87
|
+
`,Oe=c.default.div`
|
|
88
88
|
position: relative;
|
|
89
89
|
display: flex;
|
|
90
90
|
align-items: center;
|
|
91
|
-
border-bottom: 1px solid ${
|
|
92
|
-
background: ${
|
|
91
|
+
border-bottom: 1px solid ${p.default.m300};
|
|
92
|
+
background: ${K.default};
|
|
93
93
|
|
|
94
94
|
&:focus-within {
|
|
95
|
-
border-bottom-color: ${
|
|
95
|
+
border-bottom-color: ${p.default.m500};
|
|
96
96
|
}
|
|
97
|
-
`,
|
|
97
|
+
`,qe=c.default.input`
|
|
98
98
|
width: 100%;
|
|
99
99
|
box-sizing: border-box;
|
|
100
100
|
border: none;
|
|
101
101
|
/* Add left padding to make room for the icon */
|
|
102
102
|
padding: 0.8rem 1.2rem 0.8rem 0;
|
|
103
103
|
font-size: 1.92rem;
|
|
104
|
-
color: ${
|
|
104
|
+
color: ${p.default.m700};
|
|
105
105
|
background: transparent;
|
|
106
106
|
outline: none;
|
|
107
107
|
|
|
108
108
|
&::placeholder {
|
|
109
|
-
color: ${
|
|
109
|
+
color: ${p.default.m400};
|
|
110
110
|
}
|
|
111
|
-
`,
|
|
111
|
+
`,Re=c.default(xe.default)`
|
|
112
112
|
margin: 0 1.28rem;
|
|
113
|
-
`,
|
|
113
|
+
`,De=c.default.div`
|
|
114
114
|
display: flex;
|
|
115
115
|
justify-content: center;
|
|
116
116
|
align-items: center;
|
|
117
117
|
padding: 1.6rem 0;
|
|
118
118
|
min-height: 1.6rem;
|
|
119
119
|
width: 100%;
|
|
120
|
-
`,
|
|
120
|
+
`,Fe=t=>{if(typeof t!="string")return t;if(t.endsWith("px"))return parseFloat(t);if(t.endsWith("rem")){const b=parseFloat(t),l=parseFloat(getComputedStyle(document.documentElement).fontSize);return b*l}return parseFloat(t)},V=({options:t,onChange:b,value:l,width:y="32rem",menuHeight:O="32rem",placeholder:Q,theme:N="blue",isLoading:$,isDisabled:S,loaderColor:R,searchable:k=!1,onLoadMore:d,hasMore:E=!1,isLoadingMore:g=!1,searchPh:D="Search...",...G})=>{var B,T;const[s,x]=o.useState(!1),[J,F]=o.useState(!1),[X,Y]=o.useState("bottom"),[I,z]=o.useState(""),[u,w]=o.useState(-1),j=o.useId(),v=o.useRef(null),C=o.useRef(null),q=o.useRef(null),_=o.useRef(null),Z=o.useRef(!0),M=()=>!$&&!S&&x(e=>!e),P=e=>{e!==l&&(b(e),x(!1))},f=o.useMemo(()=>{if(!k||!I.trim())return t;const e=I.toLowerCase();return t.filter(({label:r})=>r.toLowerCase().includes(e))},[t,I,k]);o.useEffect(()=>{if(s){const e=f.findIndex(r=>r.value===l);if(e!==-1&&!f[e].disabled)w(e);else{const r=f.findIndex(a=>!a.disabled);w(r)}}else z(""),w(-1)},[s,I,f,l]),o.useEffect(()=>{if(s&&u!==-1&&C.current){const e=C.current.children[u];e&&e.scrollIntoView({block:"nearest",behavior:"auto"})}},[u,s]),o.useEffect(()=>{s&&k&&q.current&&q.current.focus()},[s,k]),o.useEffect(()=>{s||(Z.current=!0)},[s]),o.useEffect(()=>{const e=r=>{v.current&&!v.current.contains(r.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),o.useLayoutEffect(()=>{if(s&&C.current&&v.current){const e=v.current.getBoundingClientRect(),r=window.innerHeight,a=Fe(O),m=r-e.bottom;Y(m<a+8&&e.top>m?"top":"bottom")}},[s,O]);const L=e=>{let r=e+1;for(;r<f.length;){if(!f[r].disabled)return r;r++}return e},ee=e=>{let r=e-1;for(;r>=0;){if(!f[r].disabled)return r;r--}return e},te=e=>{if(!($||S)){if(!s){(e.key===" "||e.key==="Enter"||e.key==="ArrowDown"||e.key==="ArrowUp")&&(e.preventDefault(),x(!0));return}switch(e.key){case"ArrowDown":e.preventDefault();const r=L(u);r===u&&E&&!g&&(d==null||d()),w(r);break;case"ArrowUp":e.preventDefault(),w(m=>ee(m));break;case"Enter":e.preventDefault();const a=f[u];a&&!a.disabled&&P(a.value);break;case"Escape":x(!1);break}}},A=o.useCallback(()=>{E&&!g&&d&&d()},[E,g,d]);o.useEffect(()=>{const e=_.current;if(!e||!d||!E)return;const r=new IntersectionObserver(([a])=>{a.isIntersecting&&!g&&A()},{root:C.current,threshold:.1,rootMargin:"20px"});return r.observe(e),()=>r.disconnect()},[A,d,E,g]);const{m50:re,m100:oe,m200:ne,m500:se}=(B=me.default[N])!=null?B:he.blue,ie=(e,r)=>()=>!e&&w(r),W=e=>`${j}-opt-${e}`,ae=({value:e,label:r,disabled:a},m)=>o.createElement(pe.default,{value:e,label:r,isDisabled:a,onSelect:P,onMouseEnter:ie(a,m),isSelected:e===l,isHighlighted:m===u,key:e,id:W(m),width:y,selectedColor:ne,hoverColor:re,activeColor:oe}),le=e=>()=>{F(e)},ce=e=>{var r;F(!1),(r=v.current)!=null&&r.contains(e.relatedTarget)||x(!1)},de=e=>{z(e.target.value)},ue=e=>{e.stopPropagation()};return i.jsxs($e,{ref:v,$width:y,...G,tabIndex:S||$?-1:0,onKeyDown:te,$isLoading:$,$isDisabled:S,role:"combobox","aria-expanded":s,"aria-haspopup":"listbox","aria-controls":j,"aria-disabled":S||void 0,"aria-activedescendant":u!==-1?W(u):void 0,onFocus:le(!0),onBlur:ce,children:[i.jsxs(Se,{$width:y,onClick:M,$isOpen:s,$border:se,$isFocused:J&&!s,children:[i.jsx(ke,{$width:y,color:l?p.default.m700:p.default.m500,size:"1.92rem",children:l?(T=t.find(({value:e})=>l===e))==null?void 0:T.label:Q}),i.jsx(Ee,{color:p.default.m500,size:22,$isOpen:s,"aria-hidden":!0})]}),i.jsxs(Ie,{$isOpen:s,$width:y,$height:O,$top:X==="top",children:[k&&i.jsxs(Oe,{onClick:ue,children:[i.jsx(Re,{size:20,color:p.default.m600,"aria-hidden":!0}),i.jsx(qe,{ref:q,value:I,onChange:de,placeholder:D,"aria-label":D,"aria-controls":j,"aria-autocomplete":"list","aria-expanded":s,role:"combobox",tabIndex:s?0:-1})]}),i.jsxs(Ce,{ref:C,role:"listbox",id:j,tabIndex:-1,children:[f.map(ae),d&&i.jsx(De,{ref:_,children:g&&i.jsx(H.default,{size:"small",color:R})})]})]}),$&&i.jsx(je,{children:i.jsx(H.default,{size:"small",color:R})})]})};V.propTypes={options:n.default.arrayOf(n.default.shape({value:n.default.any,label:n.default.string,disabled:n.default.bool})),value:n.default.any,onChange:n.default.func,width:n.default.string,menuHeight:n.default.string,placeholder:n.default.string,theme:n.default.string,isLoading:n.default.bool,isDisabled:n.default.bool,loaderColor:n.default.string,searchable:n.default.bool,searchPh:n.default.string,onLoadMore:n.default.func,hasMore:n.default.bool,isLoadingMore:n.default.bool};exports.default=V;
|