wimui 0.47.8 → 0.47.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/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +2 -1
- package/dist/components/feedback/Snackbar/snackbar.module.cjs +1 -1
- package/dist/components/feedback/Snackbar/snackbar.module.js +7 -7
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +67 -65
- package/dist/components/form/Combobox/combobox.module.cjs +1 -1
- package/dist/components/form/Combobox/combobox.module.js +1 -1
- package/dist/components/form/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/form/DatePicker/DatePicker.js +45 -43
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.js +22 -20
- package/dist/components/form/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/form/TreeSelect/TreeSelect.js +54 -53
- package/dist/i18n/generated/keys.d.ts +1 -1
- package/dist/i18n/generated/resources.cjs +1 -1
- package/dist/i18n/generated/resources.js +3 -0
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/locales/en/components.json +3 -0
- package/dist/locales/ja/components.json +3 -0
- package/dist/locales/pt/components.json +3 -0
- package/dist/styles.css +2 -2
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +3 -3
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/check.cjs"),r=require("../../../icon/chevron-down.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("./model-selector.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e),u=(e,t=`$`)=>`${t}${e}`,d=o.default.forwardRef(({models:e,value:d,defaultValue:f,onChange:p,size:m=`md`,disabled:h=!1,fullWidth:g=!1,showPricing:_=!0,showContext:v=!0,labels:y,className:b,...x},S)=>{let{placeholder:C=`Select a model`,contextLabel:w=`Context`,inputLabel:T=`In`,outputLabel:E=`Out`,perTokensLabel:D=`/1M`,triggerAriaLabel:O=`Select a model`}=y??{},k=d!==void 0,[A,j]=(0,o.useState)(f),M=k?d:A,N=e.find(e=>e.id===M),[P,F]=(0,o.useState)(!1),[I,L]=(0,o.useState)(-1),R=(0,o.useRef)(null),z=(0,o.useRef)(null),B=(0,o.useId)(),V=`${B}-listbox`,H=(0,o.useCallback)(e=>{R.current=e,typeof S==`function`?S(e):S&&(S.current=e)},[S]);(0,o.useEffect)(()=>{if(!P)return;let e=e=>{R.current&&!R.current.contains(e.target)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[P]);let U=e=>{e.disabled||(k||j(e.id),p?.(e.id,e),F(!1))},W=t=>{if(!h){if(t.key===`ArrowDown`||t.key===`Enter`||t.key===` `){if(t.preventDefault(),!P){F(!0);let t=e.findIndex(e=>e.id===M);L(t>=0?t:0)}}else t.key===`Escape`&&F(!1)}},G=t=>{L(n=>{let r=n;for(let n=0;n<e.length&&(r=(r+t+e.length)%e.length,e[r]?.disabled);n++);return r})},K=t=>{if(t.key===`ArrowDown`)t.preventDefault(),G(1);else if(t.key===`ArrowUp`)t.preventDefault(),G(-1);else if(t.key===`Enter`||t.key===` `){t.preventDefault();let n=e[I];n&&U(n)}else t.key===`Escape`&&(t.preventDefault(),F(!1),R.current?.querySelector(`button`)?.focus())};(0,o.useEffect)(()=>{P&&I>=0&&(z.current?.querySelectorAll(`[role="option"]`)?.[I])?.scrollIntoView({block:`nearest`})},[I,P]);let q=e=>{let t=[];if(v&&e.contextLength&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[w,` `,l(e.contextLength)]},`ctx`)),_&&e.pricing){let{input:n,output:r,currency:i}=e.pricing;n!==void 0&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[T,` `,u(n,i),D]},`in`)),r!==void 0&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[E,` `,u(r,i),D]},`out`))}return t.length===0?null:(0,c.jsx)(`span`,{className:a.default.metaRow,children:t})};return(0,c.jsxs)(`div`,{ref:H,className:(0,s.default)(`wim-model-selector`,a.default.root,a.default[m],g&&a.default.fullWidth,h&&a.default.disabled,b),...x,children:[(0,c.jsxs)(`button`,{type:`button`,className:a.default.trigger,"aria-haspopup":`listbox`,"aria-expanded":P,"aria-controls":P?V:void 0,"aria-label":O,disabled:h,onClick:()=>{if(h)return;F(e=>!e);let t=e.findIndex(e=>e.id===M);L(t>=0?t:0)},onKeyDown:W,children:[(0,c.jsx)(`span`,{className:a.default.triggerLabel,children:N?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{className:a.default.triggerName,children:N.name}),N.badge&&(0,c.jsx)(`span`,{className:a.default.badge,children:N.badge})]}):(0,c.jsx)(`span`,{className:a.default.placeholder,children:C})}),(0,c.jsx)(i.Icon,{component:r.default,size:`sm`,className:(0,s.default)(a.default.chevron,P&&a.default.chevronOpen)})]}),(0,c.jsx)(t.Transition,{show:P,preset:`scale`,unmount:!0,className:a.default.dropdownWrapper,children:(0,c.jsx)(`ul`,{ref:z,id:V,role:`listbox`,tabIndex
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/check.cjs"),r=require("../../../icon/chevron-down.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("./model-selector.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=e=>e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}M`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}K`:String(e),u=(e,t=`$`)=>`${t}${e}`,d=o.default.forwardRef(({models:e,value:d,defaultValue:f,onChange:p,size:m=`md`,disabled:h=!1,fullWidth:g=!1,showPricing:_=!0,showContext:v=!0,labels:y,className:b,...x},S)=>{let{placeholder:C=`Select a model`,contextLabel:w=`Context`,inputLabel:T=`In`,outputLabel:E=`Out`,perTokensLabel:D=`/1M`,triggerAriaLabel:O=`Select a model`}=y??{},k=d!==void 0,[A,j]=(0,o.useState)(f),M=k?d:A,N=e.find(e=>e.id===M),[P,F]=(0,o.useState)(!1),[I,L]=(0,o.useState)(-1),R=(0,o.useRef)(null),z=(0,o.useRef)(null),B=(0,o.useId)(),V=`${B}-listbox`,H=(0,o.useCallback)(e=>{R.current=e,typeof S==`function`?S(e):S&&(S.current=e)},[S]);(0,o.useEffect)(()=>{if(!P)return;let e=e=>{R.current&&!R.current.contains(e.target)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[P]);let U=e=>{e.disabled||(k||j(e.id),p?.(e.id,e),F(!1))},W=t=>{if(!h){if(t.key===`ArrowDown`||t.key===`Enter`||t.key===` `){if(t.preventDefault(),!P){F(!0);let t=e.findIndex(e=>e.id===M);L(t>=0?t:0)}}else t.key===`Escape`&&F(!1)}},G=t=>{L(n=>{let r=n;for(let n=0;n<e.length&&(r=(r+t+e.length)%e.length,e[r]?.disabled);n++);return r})},K=t=>{if(t.key===`ArrowDown`)t.preventDefault(),G(1);else if(t.key===`ArrowUp`)t.preventDefault(),G(-1);else if(t.key===`Enter`||t.key===` `){t.preventDefault();let n=e[I];n&&U(n)}else t.key===`Escape`&&(t.preventDefault(),F(!1),R.current?.querySelector(`button`)?.focus())};(0,o.useEffect)(()=>{P&&I>=0&&(z.current?.querySelectorAll(`[role="option"]`)?.[I])?.scrollIntoView({block:`nearest`})},[I,P]);let q=e=>{let t=[];if(v&&e.contextLength&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[w,` `,l(e.contextLength)]},`ctx`)),_&&e.pricing){let{input:n,output:r,currency:i}=e.pricing;n!==void 0&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[T,` `,u(n,i),D]},`in`)),r!==void 0&&t.push((0,c.jsxs)(`span`,{className:a.default.meta,children:[E,` `,u(r,i),D]},`out`))}return t.length===0?null:(0,c.jsx)(`span`,{className:a.default.metaRow,children:t})};return(0,c.jsxs)(`div`,{ref:H,className:(0,s.default)(`wim-model-selector`,a.default.root,a.default[m],g&&a.default.fullWidth,h&&a.default.disabled,b),...x,children:[(0,c.jsxs)(`button`,{type:`button`,className:a.default.trigger,"aria-haspopup":`listbox`,"aria-expanded":P,"aria-controls":P?V:void 0,"aria-label":O,disabled:h,onClick:()=>{if(h)return;F(e=>!e);let t=e.findIndex(e=>e.id===M);L(t>=0?t:0)},onKeyDown:W,children:[(0,c.jsx)(`span`,{className:a.default.triggerLabel,children:N?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{className:a.default.triggerName,children:N.name}),N.badge&&(0,c.jsx)(`span`,{className:a.default.badge,children:N.badge})]}):(0,c.jsx)(`span`,{className:a.default.placeholder,children:C})}),(0,c.jsx)(i.Icon,{component:r.default,size:`sm`,className:(0,s.default)(a.default.chevron,P&&a.default.chevronOpen)})]}),(0,c.jsx)(t.Transition,{show:P,preset:`scale`,unmount:!0,className:a.default.dropdownWrapper,children:(0,c.jsx)(`ul`,{ref:z,id:V,role:`listbox`,"aria-label":O,tabIndex:0,className:a.default.dropdown,onKeyDown:K,"aria-activedescendant":I>=0?`${B}-opt-${I}`:void 0,children:e.map((e,t)=>{let r=e.id===M;return(0,c.jsxs)(`li`,{id:`${B}-opt-${t}`,role:`option`,"aria-selected":r,"aria-disabled":e.disabled||void 0,className:(0,s.default)(a.default.option,t===I&&a.default.active,e.disabled&&a.default.optionDisabled),onMouseEnter:()=>L(t),onClick:()=>U(e),children:[(0,c.jsx)(`span`,{className:a.default.check,"aria-hidden":`true`,children:r&&(0,c.jsx)(i.Icon,{component:n.default,size:`sm`})}),(0,c.jsxs)(`span`,{className:a.default.optionBody,children:[(0,c.jsxs)(`span`,{className:a.default.optionHeader,children:[(0,c.jsx)(`span`,{className:a.default.optionName,children:e.name}),e.badge&&(0,c.jsx)(`span`,{className:a.default.badge,children:e.badge})]}),e.description&&(0,c.jsx)(`span`,{className:a.default.description,children:e.description}),q(e)]})]},e.id)})})})]})});d.displayName=`ModelSelector`,exports.ModelSelector=d;
|
|
@@ -128,7 +128,8 @@ var h = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
128
128
|
ref: G,
|
|
129
129
|
id: q,
|
|
130
130
|
role: "listbox",
|
|
131
|
-
|
|
131
|
+
"aria-label": P,
|
|
132
|
+
tabIndex: 0,
|
|
132
133
|
className: i.dropdown,
|
|
133
134
|
onKeyDown: Q,
|
|
134
135
|
"aria-activedescendant": H >= 0 ? `${K}-opt-${H}` : void 0,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_wrapper_1n28t_3`,t=`_root_1n28t_41`,n=`_hasCloseButton_1n28t_64`,r=`_visible_1n28t_79`,i=`_content_1n28t_83`,a=`_icon_1n28t_89`,o=`_message_1n28t_97`,s=`_actions_1n28t_102`,c=`_actionButton_1n28t_108`,l=`_closeButton_1n28t_112`,u=`_success_1n28t_140`,d=`_danger_1n28t_144`,f=`_warning_1n28t_148`,p=`_info_1n28t_153`,m={wrapper:e,"top-left":`_top-left_1n28t_11`,"top-center":`_top-center_1n28t_16`,"top-right":`_top-right_1n28t_21`,"bottom-left":`_bottom-left_1n28t_26`,"bottom-center":`_bottom-center_1n28t_31`,"bottom-right":`_bottom-right_1n28t_36`,root:t,hasCloseButton:n,visible:r,content:i,icon:a,message:o,actions:s,actionButton:c,closeButton:l,success:u,danger:d,warning:f,info:p};exports.actionButton=c,exports.actions=s,exports.closeButton=l,exports.content=i,exports.danger=d,exports.default=m,exports.hasCloseButton=n,exports.icon=a,exports.info=p,exports.message=o,exports.root=t,exports.success=u,exports.visible=r,exports.warning=f,exports.wrapper=e;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/feedback/Snackbar/snackbar.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_wrapper_1n28t_3", t = "_root_1n28t_41", n = "_hasCloseButton_1n28t_64", r = "_visible_1n28t_79", i = "_content_1n28t_83", a = "_icon_1n28t_89", o = "_message_1n28t_97", s = "_actions_1n28t_102", c = "_actionButton_1n28t_108", l = "_closeButton_1n28t_112", u = "_success_1n28t_140", d = "_danger_1n28t_144", f = "_warning_1n28t_148", p = "_info_1n28t_153", m = {
|
|
4
4
|
wrapper: e,
|
|
5
|
-
"top-left": "_top-
|
|
6
|
-
"top-center": "_top-
|
|
7
|
-
"top-right": "_top-
|
|
8
|
-
"bottom-left": "_bottom-
|
|
9
|
-
"bottom-center": "_bottom-
|
|
10
|
-
"bottom-right": "_bottom-
|
|
5
|
+
"top-left": "_top-left_1n28t_11",
|
|
6
|
+
"top-center": "_top-center_1n28t_16",
|
|
7
|
+
"top-right": "_top-right_1n28t_21",
|
|
8
|
+
"bottom-left": "_bottom-left_1n28t_26",
|
|
9
|
+
"bottom-center": "_bottom-center_1n28t_31",
|
|
10
|
+
"bottom-right": "_bottom-right_1n28t_36",
|
|
11
11
|
root: t,
|
|
12
12
|
hasCloseButton: n,
|
|
13
13
|
visible: r,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/chevron-right.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("./cascader.module.cjs"),s=require("../FieldTemplate/FieldTemplate.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");function d(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}var f=({options:e=[],value:f,onChange:p,placeholder:m,label:h,error:g,required:_,layout:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/chevron-right.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../_internal/BaseListItem/BaseListItem.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("./cascader.module.cjs"),s=require("../FieldTemplate/FieldTemplate.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");function d(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}var f=({options:e=[],value:f,onChange:p,placeholder:m,label:h,error:g,required:_,layout:ee,className:v,disabled:y=!1,defaultValue:te,id:ne,expandTrigger:b=`click`,separator:x=` / `,allowClear:S=!1,"aria-label":C,width:w,fullWidth:re=!1,...T})=>{let E=(0,c.useId)(),D=ne||`wim-cascader-${E}`,O=h?`${D}-label`:void 0,k=g?`${D}-error`:void 0,A=`${D}-trigger`,j=`${D}-popup`,[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(te||[]),[I,L]=(0,c.useState)([]),[R,z]=(0,c.useState)(-1),[B,V]=(0,c.useState)([]),[ie,H]=(0,c.useState)(!1),U=(0,c.useRef)(null),W=(0,c.useRef)(null),G=f!==void 0,K=G?f:P;(0,c.useEffect)(()=>{let e=e=>{U.current&&!U.current.contains(e.target)&&N(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,c.useEffect)(()=>{if(M&&R>=0){let e=B[R],t=`${D}-menu-${R}-option-${e}`,n=U.current?.querySelector(`#${t}`);n&&n.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[R,B,M,D]);let q=()=>{if(!y){let e=!M;N(e),e?(L(K||[]),z(0),V([0])):z(-1)}},J=()=>{if(!K||K.length===0)return null;let t=[],n=e;for(let e of K){let r=n.find(t=>t.value===e);if(r)t.push(r.label),n=r.children||[];else break}return t.length===0?null:t.map((e,n)=>(0,u.jsxs)(c.default.Fragment,{children:[e,n<t.length-1&&(0,u.jsx)(`span`,{children:x})]},n))},Y=(t,n)=>{if(t.disabled)return;let r=[...I.slice(0,n),t.value];if(L(r),!t.children||t.children.length===0){if(G||F(r),p){let t=[],n=e;for(let e of r){let r=n.find(t=>t.value===e);r&&(t.push(r),n=r.children||[])}p(r,t)}N(!1),W.current?.focus()}},ae=e=>{e?.stopPropagation(),!y&&(G||F([]),p&&p([],[]))},oe=(e,t)=>{b===`hover`&&!e.disabled&&L([...I.slice(0,t),e.value])},se=t=>{if(H(!0),y)return;if(!M){(t.key===`Enter`||t.key===` `||t.key===`ArrowDown`||t.key===`ArrowDown`&&t.altKey)&&(t.preventDefault(),q());return}let n=[e],r=e;for(let e=0;e<I.length;e++){let t=I[e],i=r.find(e=>e.value===t);if(i&&i.children&&i.children.length>0)n.push(i.children),r=i.children;else break}let i=n[R]||[],a=B[R]||0;switch(t.key){case`ArrowDown`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=Math.min(a+1,i.length-1),t});break;case`ArrowUp`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=Math.max(a-1,0),t});break;case`ArrowRight`:{t.preventDefault();let e=i[a];e&&e.children&&e.children.length>0&&(L([...I.slice(0,R),e.value]),z(R+1),V(e=>[...e.slice(0,R+1),0]));break}case`ArrowLeft`:t.preventDefault(),R>0&&(z(R-1),V(e=>e.slice(0,R)));break;case`Enter`:case` `:{t.preventDefault();let e=i[a];e&&Y(e,R);break}case`Escape`:t.preventDefault(),N(!1),z(-1),W.current?.focus();break;case`Home`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=0,t});break;case`End`:t.preventDefault(),V(e=>{let t=[...e];return t[R]=i.length-1,t});break;case`Tab`:M&&(N(!1),z(-1))}},X=[e],Z=e;for(let e=0;e<I.length;e++){let t=I[e],n=Z.find(e=>e.value===t);if(n&&n.children&&n.children.length>0)X.push(n.children),Z=n.children;else break}let Q=J(),$=()=>{if(!K||K.length===0)return``;let t=[],n=e;for(let e of K){let r=n.find(t=>t.value===e);if(r)t.push(d(r.label)),n=r.children||[];else break}return t.join(x)};return(0,u.jsx)(s.FieldTemplate,{label:h,error:g,required:_,layout:ee,labelId:O,errorId:k,className:(0,l.default)(`wim-cascader`,v),children:(0,u.jsxs)(`div`,{className:o.default.root,ref:U,onMouseMove:()=>H(!1),"data-keyboard-nav":ie,...T,children:[(0,u.jsx)(a.InputBase,{disabled:y,allowClear:S,hasValue:!!Q,onClear:ae,intent:g?`danger`:`default`,width:w,fullWidth:re,rightIcons:[{name:`ChevronDownIcon`,rotated:M}],className:(0,l.default)(M&&o.default.open),children:(0,u.jsx)(`div`,{id:A,ref:W,className:(0,l.default)(o.default.trigger,y&&o.default.disabled),onClick:q,onKeyDown:se,tabIndex:y?-1:0,role:`combobox`,"aria-expanded":M,"aria-controls":M?j:void 0,"aria-haspopup":`listbox`,"aria-disabled":y,"aria-labelledby":O,"aria-label":O?void 0:C||$()||d(m),"aria-describedby":k,"aria-required":_,"aria-invalid":!!g,"aria-activedescendant":M&&R>=0?`${D}-menu-${R}-option-${B[R]}`:void 0,children:(0,u.jsx)(`div`,{className:(0,l.default)(o.default.value,!Q&&o.default.placeholder),children:Q||m})})}),(0,u.jsx)(t.Transition,{show:M&&!y,preset:`fade`,id:j,className:o.default.dropdown,children:X.map((e,t)=>(0,u.jsx)(`div`,{className:o.default.menu,role:`listbox`,"aria-labelledby":O,"aria-label":O?void 0:C||$()||d(m),children:e.map((e,a)=>{let s=I[t]===e.value,c=R===t&&B[t]===a,d=K[t]===e.value,f=e.children&&e.children.length>0;return(0,u.jsx)(i.BaseListItem,{className:(0,l.default)(o.default.menuItem,d&&o.default.selected),active:c||s,disabled:e.disabled,onClick:n=>{n.stopPropagation(),Y(e,t)},onMouseEnter:()=>{oe(e,t),z(t),V(e=>[...e.slice(0,t),a])},rightSection:f?(0,u.jsx)(r.Icon,{component:n.default,size:`sm`}):void 0,role:`option`,id:`${D}-menu-${t}-option-${a}`,"aria-selected":d,tabIndex:-1,children:e.label},e.value)})},t))})]})})};f.displayName=`Cascader`,exports.Cascader=f;
|
|
@@ -13,31 +13,31 @@ import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
|
13
13
|
function h(e) {
|
|
14
14
|
return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
|
|
15
15
|
}
|
|
16
|
-
var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, error: x, required: S, layout:
|
|
17
|
-
let
|
|
16
|
+
var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, error: x, required: S, layout: C, className: ee, disabled: w = !1, defaultValue: te, id: ne, expandTrigger: re = "click", separator: T = " / ", allowClear: ie = !1, "aria-label": E, width: ae, fullWidth: oe = !1, ...se }) => {
|
|
17
|
+
let D = l(), O = ne || `wim-cascader-${D}`, k = b ? `${O}-label` : void 0, A = x ? `${O}-error` : void 0, j = `${O}-trigger`, M = `${O}-popup`, [N, P] = d(!1), [F, I] = d(te || []), [L, R] = d([]), [z, B] = d(-1), [V, H] = d([]), [ce, U] = d(!1), W = u(null), G = u(null), K = _ !== void 0, q = K ? _ : F;
|
|
18
18
|
c(() => {
|
|
19
19
|
let e = (e) => {
|
|
20
20
|
W.current && !W.current.contains(e.target) && P(!1);
|
|
21
21
|
};
|
|
22
22
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
23
23
|
}, []), c(() => {
|
|
24
|
-
if (N &&
|
|
25
|
-
let e =
|
|
24
|
+
if (N && z >= 0) {
|
|
25
|
+
let e = V[z], t = `${O}-menu-${z}-option-${e}`, n = W.current?.querySelector(`#${t}`);
|
|
26
26
|
n && n.scrollIntoView({
|
|
27
27
|
block: "nearest",
|
|
28
28
|
behavior: "smooth"
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}, [
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
z,
|
|
33
|
+
V,
|
|
34
34
|
N,
|
|
35
|
-
|
|
35
|
+
O
|
|
36
36
|
]);
|
|
37
37
|
let J = () => {
|
|
38
|
-
if (!
|
|
38
|
+
if (!w) {
|
|
39
39
|
let e = !N;
|
|
40
|
-
P(e), e ? (
|
|
40
|
+
P(e), e ? (R(q || []), B(0), H([0])) : B(-1);
|
|
41
41
|
}
|
|
42
42
|
}, le = () => {
|
|
43
43
|
if (!q || q.length === 0) return null;
|
|
@@ -47,12 +47,12 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
47
47
|
if (r) e.push(r.label), t = r.children || [];
|
|
48
48
|
else break;
|
|
49
49
|
}
|
|
50
|
-
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ m(s.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ p("span", { children:
|
|
50
|
+
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ m(s.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ p("span", { children: T })] }, n));
|
|
51
51
|
}, Y = (e, t) => {
|
|
52
52
|
if (e.disabled) return;
|
|
53
|
-
let n = [...
|
|
54
|
-
if (
|
|
55
|
-
if (K ||
|
|
53
|
+
let n = [...L.slice(0, t), e.value];
|
|
54
|
+
if (R(n), !e.children || e.children.length === 0) {
|
|
55
|
+
if (K || I(n), v) {
|
|
56
56
|
let e = [], t = g;
|
|
57
57
|
for (let r of n) {
|
|
58
58
|
let n = t.find((e) => e.value === r);
|
|
@@ -63,75 +63,75 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
63
63
|
P(!1), G.current?.focus();
|
|
64
64
|
}
|
|
65
65
|
}, ue = (e) => {
|
|
66
|
-
e?.stopPropagation(), !
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
if (U(!0),
|
|
66
|
+
e?.stopPropagation(), !w && (K || I([]), v && v([], []));
|
|
67
|
+
}, de = (e, t) => {
|
|
68
|
+
re === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
|
|
69
|
+
}, fe = (e) => {
|
|
70
|
+
if (U(!0), w) return;
|
|
71
71
|
if (!N) {
|
|
72
72
|
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(), J());
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
let t = [g], n = g;
|
|
76
|
-
for (let e = 0; e <
|
|
77
|
-
let r =
|
|
76
|
+
for (let e = 0; e < L.length; e++) {
|
|
77
|
+
let r = L[e], i = n.find((e) => e.value === r);
|
|
78
78
|
if (i && i.children && i.children.length > 0) t.push(i.children), n = i.children;
|
|
79
79
|
else break;
|
|
80
80
|
}
|
|
81
|
-
let r = t[
|
|
81
|
+
let r = t[z] || [], i = V[z] || 0;
|
|
82
82
|
switch (e.key) {
|
|
83
83
|
case "ArrowDown":
|
|
84
|
-
e.preventDefault(),
|
|
84
|
+
e.preventDefault(), H((e) => {
|
|
85
85
|
let t = [...e];
|
|
86
|
-
return t[
|
|
86
|
+
return t[z] = Math.min(i + 1, r.length - 1), t;
|
|
87
87
|
});
|
|
88
88
|
break;
|
|
89
89
|
case "ArrowUp":
|
|
90
|
-
e.preventDefault(),
|
|
90
|
+
e.preventDefault(), H((e) => {
|
|
91
91
|
let t = [...e];
|
|
92
|
-
return t[
|
|
92
|
+
return t[z] = Math.max(i - 1, 0), t;
|
|
93
93
|
});
|
|
94
94
|
break;
|
|
95
95
|
case "ArrowRight": {
|
|
96
96
|
e.preventDefault();
|
|
97
97
|
let t = r[i];
|
|
98
|
-
t && t.children && t.children.length > 0 && (
|
|
98
|
+
t && t.children && t.children.length > 0 && (R([...L.slice(0, z), t.value]), B(z + 1), H((e) => [...e.slice(0, z + 1), 0]));
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
101
|
case "ArrowLeft":
|
|
102
|
-
e.preventDefault(),
|
|
102
|
+
e.preventDefault(), z > 0 && (B(z - 1), H((e) => e.slice(0, z)));
|
|
103
103
|
break;
|
|
104
104
|
case "Enter":
|
|
105
105
|
case " ": {
|
|
106
106
|
e.preventDefault();
|
|
107
107
|
let t = r[i];
|
|
108
|
-
t && Y(t,
|
|
108
|
+
t && Y(t, z);
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
case "Escape":
|
|
112
|
-
e.preventDefault(), P(!1),
|
|
112
|
+
e.preventDefault(), P(!1), B(-1), G.current?.focus();
|
|
113
113
|
break;
|
|
114
114
|
case "Home":
|
|
115
|
-
e.preventDefault(),
|
|
115
|
+
e.preventDefault(), H((e) => {
|
|
116
116
|
let t = [...e];
|
|
117
|
-
return t[
|
|
117
|
+
return t[z] = 0, t;
|
|
118
118
|
});
|
|
119
119
|
break;
|
|
120
120
|
case "End":
|
|
121
|
-
e.preventDefault(),
|
|
121
|
+
e.preventDefault(), H((e) => {
|
|
122
122
|
let t = [...e];
|
|
123
|
-
return t[
|
|
123
|
+
return t[z] = r.length - 1, t;
|
|
124
124
|
});
|
|
125
125
|
break;
|
|
126
|
-
case "Tab": N && (P(!1),
|
|
126
|
+
case "Tab": N && (P(!1), B(-1));
|
|
127
127
|
}
|
|
128
|
-
},
|
|
129
|
-
for (let e = 0; e <
|
|
130
|
-
let t =
|
|
131
|
-
if (n && n.children && n.children.length > 0)
|
|
128
|
+
}, X = [g], Z = g;
|
|
129
|
+
for (let e = 0; e < L.length; e++) {
|
|
130
|
+
let t = L[e], n = Z.find((e) => e.value === t);
|
|
131
|
+
if (n && n.children && n.children.length > 0) X.push(n.children), Z = n.children;
|
|
132
132
|
else break;
|
|
133
133
|
}
|
|
134
|
-
let
|
|
134
|
+
let Q = le(), $ = () => {
|
|
135
135
|
if (!q || q.length === 0) return "";
|
|
136
136
|
let e = [], t = g;
|
|
137
137
|
for (let n of q) {
|
|
@@ -139,26 +139,26 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
139
139
|
if (r) e.push(h(r.label)), t = r.children || [];
|
|
140
140
|
else break;
|
|
141
141
|
}
|
|
142
|
-
return e.join(
|
|
142
|
+
return e.join(T);
|
|
143
143
|
};
|
|
144
144
|
return /* @__PURE__ */ p(o, {
|
|
145
145
|
label: b,
|
|
146
146
|
error: x,
|
|
147
147
|
required: S,
|
|
148
|
-
layout:
|
|
149
|
-
labelId:
|
|
150
|
-
errorId:
|
|
151
|
-
className: f("wim-cascader",
|
|
148
|
+
layout: C,
|
|
149
|
+
labelId: k,
|
|
150
|
+
errorId: A,
|
|
151
|
+
className: f("wim-cascader", ee),
|
|
152
152
|
children: /* @__PURE__ */ m("div", {
|
|
153
153
|
className: a.root,
|
|
154
154
|
ref: W,
|
|
155
155
|
onMouseMove: () => U(!1),
|
|
156
|
-
"data-keyboard-nav":
|
|
157
|
-
...
|
|
156
|
+
"data-keyboard-nav": ce,
|
|
157
|
+
...se,
|
|
158
158
|
children: [/* @__PURE__ */ p(i, {
|
|
159
|
-
disabled:
|
|
160
|
-
allowClear:
|
|
161
|
-
hasValue:
|
|
159
|
+
disabled: w,
|
|
160
|
+
allowClear: ie,
|
|
161
|
+
hasValue: !!Q,
|
|
162
162
|
onClear: ue,
|
|
163
163
|
intent: x ? "danger" : "default",
|
|
164
164
|
width: ae,
|
|
@@ -169,38 +169,40 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
169
169
|
}],
|
|
170
170
|
className: f(N && a.open),
|
|
171
171
|
children: /* @__PURE__ */ p("div", {
|
|
172
|
-
id:
|
|
172
|
+
id: j,
|
|
173
173
|
ref: G,
|
|
174
|
-
className: f(a.trigger,
|
|
174
|
+
className: f(a.trigger, w && a.disabled),
|
|
175
175
|
onClick: J,
|
|
176
|
-
onKeyDown:
|
|
177
|
-
tabIndex:
|
|
176
|
+
onKeyDown: fe,
|
|
177
|
+
tabIndex: w ? -1 : 0,
|
|
178
178
|
role: "combobox",
|
|
179
179
|
"aria-expanded": N,
|
|
180
180
|
"aria-controls": N ? M : void 0,
|
|
181
181
|
"aria-haspopup": "listbox",
|
|
182
|
-
"aria-disabled":
|
|
183
|
-
"aria-labelledby":
|
|
184
|
-
"aria-label":
|
|
185
|
-
"aria-describedby":
|
|
182
|
+
"aria-disabled": w,
|
|
183
|
+
"aria-labelledby": k,
|
|
184
|
+
"aria-label": k ? void 0 : E || $() || h(y),
|
|
185
|
+
"aria-describedby": A,
|
|
186
186
|
"aria-required": S,
|
|
187
187
|
"aria-invalid": !!x,
|
|
188
|
-
"aria-activedescendant": N &&
|
|
188
|
+
"aria-activedescendant": N && z >= 0 ? `${O}-menu-${z}-option-${V[z]}` : void 0,
|
|
189
189
|
children: /* @__PURE__ */ p("div", {
|
|
190
|
-
className: f(a.value,
|
|
191
|
-
children:
|
|
190
|
+
className: f(a.value, !Q && a.placeholder),
|
|
191
|
+
children: Q || y
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
194
|
}), /* @__PURE__ */ p(e, {
|
|
195
|
-
show: N && !
|
|
195
|
+
show: N && !w,
|
|
196
196
|
preset: "fade",
|
|
197
197
|
id: M,
|
|
198
198
|
className: a.dropdown,
|
|
199
|
-
children:
|
|
199
|
+
children: X.map((e, i) => /* @__PURE__ */ p("div", {
|
|
200
200
|
className: a.menu,
|
|
201
201
|
role: "listbox",
|
|
202
|
+
"aria-labelledby": k,
|
|
203
|
+
"aria-label": k ? void 0 : E || $() || h(y),
|
|
202
204
|
children: e.map((e, o) => {
|
|
203
|
-
let s =
|
|
205
|
+
let s = L[i] === e.value, c = z === i && V[i] === o, l = q[i] === e.value, u = e.children && e.children.length > 0;
|
|
204
206
|
return /* @__PURE__ */ p(r, {
|
|
205
207
|
className: f(a.menuItem, l && a.selected),
|
|
206
208
|
active: c || s,
|
|
@@ -209,14 +211,14 @@ var g = ({ options: g = [], value: _, onChange: v, placeholder: y, label: b, err
|
|
|
209
211
|
t.stopPropagation(), Y(e, i);
|
|
210
212
|
},
|
|
211
213
|
onMouseEnter: () => {
|
|
212
|
-
|
|
214
|
+
de(e, i), B(i), H((e) => [...e.slice(0, i), o]);
|
|
213
215
|
},
|
|
214
216
|
rightSection: u ? /* @__PURE__ */ p(n, {
|
|
215
217
|
component: t,
|
|
216
218
|
size: "sm"
|
|
217
219
|
}) : void 0,
|
|
218
220
|
role: "option",
|
|
219
|
-
id: `${
|
|
221
|
+
id: `${O}-menu-${i}-option-${o}`,
|
|
220
222
|
"aria-selected": l,
|
|
221
223
|
tabIndex: -1,
|
|
222
224
|
children: e.label
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_106uf_3`,t=`_fullWidth_106uf_8`,n=`_input_106uf_11`,r=`_dropdown_106uf_32`,i=`_list_106uf_37`,a=`_option_106uf_60`,o=`_selected_106uf_64`,s=`_empty_106uf_69`,c={root:e,fullWidth:t,input:n,dropdown:r,list:i,option:a,selected:o,empty:s};exports.default=c,exports.dropdown=r,exports.empty=s,exports.fullWidth=t,exports.input=n,exports.list=i,exports.option=a,exports.root=e,exports.selected=o;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/Combobox/combobox.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_106uf_3", t = "_fullWidth_106uf_8", n = "_input_106uf_11", r = "_dropdown_106uf_32", i = "_list_106uf_37", a = "_option_106uf_60", o = "_selected_106uf_64", s = "_empty_106uf_69", c = {
|
|
4
4
|
root: e,
|
|
5
5
|
fullWidth: t,
|
|
6
6
|
input: n,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../layout/Transition/Transition.cjs"),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../overlay/FocusTrap/FocusTrap.cjs"),a=require("../InputBase/InputBase.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("../Input/input.module.cjs"),c=require("../../data-display/Calendar/Calendar.cjs"),l=require("../../_internal/mergeRefs.cjs"),u=require("./date-picker.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=(0,d.forwardRef)(({intent:e=`default`,variant:m=`outline`,fullWidth:h=!1,className:g,disabled:_,value:v,defaultValue:y,onChange:b,format:x=`YYYY-MM-DD`,clearable:S=!0,placeholder:C,minDate:ee,maxDate:te,disabledDates:ne,label:w,error:T,required:E,layout:D,id:re,labels:O,width:k,asChild:A=!1,children:j,...M},N)=>{let[P,F]=(0,d.useState)(!1),[I,L]=(0,d.useState)(y||null),R=(0,d.useRef)(null),z=(0,d.useRef)(null),B=l.mergeRefs(R,N),{t:V}=n.useWimTranslation(`components`),H=(0,d.useId)(),U=re||`wim-datepicker-${H}`,W=`${U}-dropdown`,G=w?`${U}-label`:void 0,K=T?`${U}-error`:void 0,q=v!==void 0,J=q?v:I,Y=C??O?.placeholder,X=_,Z=T?`danger`:e;(0,d.useEffect)(()=>{let e=e=>{R.current&&!R.current.contains(e.target)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,d.useEffect)(()=>{let e=e=>{e.key===`Escape`&&P&&(F(!1),z.current?.focus())};return P&&document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[P]);let Q=e=>{if(!e)return``;let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,`0`),r=String(e.getDate()).padStart(2,`0`);return x.replace(`YYYY`,String(t)).replace(`MM`,n).replace(`DD`,r)},ie=e=>{q||L(e),b?.(e),F(!1),z.current?.focus()},ae=e=>{e?.stopPropagation(),X||(q||L(null),b?.(null))},$=()=>{X||F(!P)};return(0,d.useEffect)(()=>{if(P){let e=setTimeout(()=>{let e=R.current?.querySelector(`[data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus`);e?e.focus():R.current?.querySelector(`[data-calendar-day]:not([data-other-month]):not(:disabled)`)?.focus()},50);return()=>clearTimeout(e)}},[P]),(0,p.jsx)(o.FieldTemplate,{label:w,error:T,required:E,layout:D,labelId:G,htmlFor:U,errorId:K,className:g,children:(0,p.jsxs)(A?t.Root:`div`,{ref:B,className:(0,f.default)(`wim-date-picker`,u.default.root,h&&u.default.fullWidth),children:[(0,p.jsxs)(t.Slottable,{children:[(0,p.jsx)(a.InputBase,{intent:Z,variant:m,width:k,fullWidth:h,disabled:X,allowClear:S,hasValue:!!J,onClear:ae,rightIcons:[{name:`ChevronDownIcon`,rotated:P,onClick:$}],children:(0,p.jsx)(`input`,{id:U,ref:z,type:`text`,readOnly:!0,role:`combobox`,className:(0,f.default)(s.default.root,u.default.input),value:Q(J),placeholder:Y,disabled:X,onClick:$,onKeyDown:e=>{X||(e.key===`Escape`?(F(!1),z.current?.focus()):(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`&&(e.altKey||!P))&&(e.preventDefault(),F(!P)))},"aria-haspopup":`dialog`,"aria-expanded":P,"aria-controls":P?W:void 0,"aria-invalid":Z===`danger`,"aria-describedby":K,"aria-labelledby":G,"aria-required":E,...M})}),(0,p.jsx)(r.Transition,{show:P&&!_,preset:`fade`,id:W,className:u.default.dropdown,children:(0,p.jsx)(i.FocusTrap,{active:P,initialFocus:!1,children:(0,p.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":G,"aria-label":G?void 0:M[`aria-label`]??V(`datepicker.dialog`),children:(0,p.jsx)(c.Calendar,{value:J??void 0,onChange:ie})})})})]}),j]})})});m.displayName=`DatePicker`,exports.DatePicker=m,exports.default=m;
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
3
|
+
import { useWimTranslation as n } from "../../../i18n/useWimTranslation.js";
|
|
4
|
+
import { Transition as r } from "../../layout/Transition/Transition.js";
|
|
5
|
+
import { FocusTrap as ee } from "../../overlay/FocusTrap/FocusTrap.js";
|
|
6
|
+
import { InputBase as te } from "../InputBase/InputBase.js";
|
|
7
|
+
import { FieldTemplate as ne } from "../FieldTemplate/FieldTemplate.js";
|
|
8
|
+
import i from "../Input/input.module.js";
|
|
9
|
+
import { Calendar as a } from "../../data-display/Calendar/Calendar.js";
|
|
10
|
+
import { mergeRefs as o } from "../../_internal/mergeRefs.js";
|
|
11
|
+
import s from "./date-picker.module.js";
|
|
12
|
+
import { forwardRef as c, useEffect as l, useId as u, useRef as d, useState as f } from "react";
|
|
12
13
|
import p from "classnames";
|
|
13
14
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
14
15
|
//#region src/components/form/DatePicker/DatePicker.tsx
|
|
15
|
-
var g =
|
|
16
|
-
let [I, L] = f(!1), [R, z] = f(x || null), B = d(null), V = d(null), H =
|
|
17
|
-
|
|
16
|
+
var g = c(({ intent: c = "default", variant: g = "outline", fullWidth: _ = !1, className: v, disabled: y, value: b, defaultValue: x, onChange: S, format: C = "YYYY-MM-DD", clearable: w = !0, placeholder: T, minDate: re, maxDate: ie, disabledDates: ae, label: E, error: D, required: O, layout: oe, id: k, labels: A, width: j, asChild: M = !1, children: N, ...P }, F) => {
|
|
17
|
+
let [I, L] = f(!1), [R, z] = f(x || null), B = d(null), V = d(null), H = o(B, F), { t: U } = n("components"), W = u(), G = k || `wim-datepicker-${W}`, K = `${G}-dropdown`, q = E ? `${G}-label` : void 0, J = D ? `${G}-error` : void 0, Y = b !== void 0, X = Y ? b : R, se = T ?? A?.placeholder, Z = y, Q = D ? "danger" : c;
|
|
18
|
+
l(() => {
|
|
18
19
|
let e = (e) => {
|
|
19
20
|
B.current && !B.current.contains(e.target) && L(!1);
|
|
20
21
|
};
|
|
21
22
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
22
|
-
}, []),
|
|
23
|
+
}, []), l(() => {
|
|
23
24
|
let e = (e) => {
|
|
24
25
|
e.key === "Escape" && I && (L(!1), V.current?.focus());
|
|
25
26
|
};
|
|
26
27
|
return I && document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
27
28
|
}, [I]);
|
|
28
|
-
let
|
|
29
|
+
let ce = (e) => {
|
|
29
30
|
if (!e) return "";
|
|
30
31
|
let t = e.getFullYear(), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
|
|
31
32
|
return C.replace("YYYY", String(t)).replace("MM", n).replace("DD", r);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
e?.stopPropagation(), Z || (
|
|
33
|
+
}, le = (e) => {
|
|
34
|
+
Y || z(e), S?.(e), L(!1), V.current?.focus();
|
|
35
|
+
}, ue = (e) => {
|
|
36
|
+
e?.stopPropagation(), Z || (Y || z(null), S?.(null));
|
|
36
37
|
}, $ = () => {
|
|
37
38
|
Z || L(!I);
|
|
38
39
|
};
|
|
39
|
-
return
|
|
40
|
+
return l(() => {
|
|
40
41
|
if (I) {
|
|
41
42
|
let e = setTimeout(() => {
|
|
42
43
|
let e = B.current?.querySelector("[data-calendar-day][data-selected]:not(:disabled), [data-calendar-day]:focus");
|
|
@@ -44,41 +45,41 @@ var g = l(({ intent: l = "default", variant: g = "outline", fullWidth: _ = !1, c
|
|
|
44
45
|
}, 50);
|
|
45
46
|
return () => clearTimeout(e);
|
|
46
47
|
}
|
|
47
|
-
}, [I]), /* @__PURE__ */ m(
|
|
48
|
+
}, [I]), /* @__PURE__ */ m(ne, {
|
|
48
49
|
label: E,
|
|
49
50
|
error: D,
|
|
50
51
|
required: O,
|
|
51
|
-
layout:
|
|
52
|
-
labelId:
|
|
53
|
-
htmlFor:
|
|
54
|
-
errorId:
|
|
52
|
+
layout: oe,
|
|
53
|
+
labelId: q,
|
|
54
|
+
htmlFor: G,
|
|
55
|
+
errorId: J,
|
|
55
56
|
className: v,
|
|
56
57
|
children: /* @__PURE__ */ h(M ? e : "div", {
|
|
57
58
|
ref: H,
|
|
58
|
-
className: p("wim-date-picker",
|
|
59
|
-
children: [/* @__PURE__ */ h(t, { children: [/* @__PURE__ */ m(
|
|
59
|
+
className: p("wim-date-picker", s.root, _ && s.fullWidth),
|
|
60
|
+
children: [/* @__PURE__ */ h(t, { children: [/* @__PURE__ */ m(te, {
|
|
60
61
|
intent: Q,
|
|
61
62
|
variant: g,
|
|
62
63
|
width: j,
|
|
63
64
|
fullWidth: _,
|
|
64
65
|
disabled: Z,
|
|
65
66
|
allowClear: w,
|
|
66
|
-
hasValue: !!
|
|
67
|
-
onClear:
|
|
67
|
+
hasValue: !!X,
|
|
68
|
+
onClear: ue,
|
|
68
69
|
rightIcons: [{
|
|
69
70
|
name: "ChevronDownIcon",
|
|
70
71
|
rotated: I,
|
|
71
72
|
onClick: $
|
|
72
73
|
}],
|
|
73
74
|
children: /* @__PURE__ */ m("input", {
|
|
74
|
-
id:
|
|
75
|
+
id: G,
|
|
75
76
|
ref: V,
|
|
76
77
|
type: "text",
|
|
77
78
|
readOnly: !0,
|
|
78
79
|
role: "combobox",
|
|
79
|
-
className: p(
|
|
80
|
-
value:
|
|
81
|
-
placeholder:
|
|
80
|
+
className: p(i.root, s.input),
|
|
81
|
+
value: ce(X),
|
|
82
|
+
placeholder: se,
|
|
82
83
|
disabled: Z,
|
|
83
84
|
onClick: $,
|
|
84
85
|
onKeyDown: (e) => {
|
|
@@ -86,28 +87,29 @@ var g = l(({ intent: l = "default", variant: g = "outline", fullWidth: _ = !1, c
|
|
|
86
87
|
},
|
|
87
88
|
"aria-haspopup": "dialog",
|
|
88
89
|
"aria-expanded": I,
|
|
89
|
-
"aria-controls": I ?
|
|
90
|
+
"aria-controls": I ? K : void 0,
|
|
90
91
|
"aria-invalid": Q === "danger",
|
|
91
|
-
"aria-describedby":
|
|
92
|
-
"aria-labelledby":
|
|
92
|
+
"aria-describedby": J,
|
|
93
|
+
"aria-labelledby": q,
|
|
93
94
|
"aria-required": O,
|
|
94
95
|
...P
|
|
95
96
|
})
|
|
96
|
-
}), /* @__PURE__ */ m(
|
|
97
|
+
}), /* @__PURE__ */ m(r, {
|
|
97
98
|
show: I && !y,
|
|
98
99
|
preset: "fade",
|
|
99
|
-
id:
|
|
100
|
-
className:
|
|
101
|
-
children: /* @__PURE__ */ m(
|
|
100
|
+
id: K,
|
|
101
|
+
className: s.dropdown,
|
|
102
|
+
children: /* @__PURE__ */ m(ee, {
|
|
102
103
|
active: I,
|
|
103
104
|
initialFocus: !1,
|
|
104
105
|
children: /* @__PURE__ */ m("div", {
|
|
105
106
|
role: "dialog",
|
|
106
107
|
"aria-modal": "true",
|
|
107
|
-
"aria-labelledby":
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
"aria-labelledby": q,
|
|
109
|
+
"aria-label": q ? void 0 : P["aria-label"] ?? U("datepicker.dialog"),
|
|
110
|
+
children: /* @__PURE__ */ m(a, {
|
|
111
|
+
value: X ?? void 0,
|
|
112
|
+
onChange: le
|
|
111
113
|
})
|
|
112
114
|
})
|
|
113
115
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/chevron-down.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("./phone-input.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=[{code:`US`,name:`United States`,dialCode:`1`,flag:`🇺🇸`},{code:`JP`,name:`Japan`,dialCode:`81`,flag:`🇯🇵`},{code:`GB`,name:`United Kingdom`,dialCode:`44`,flag:`🇬🇧`},{code:`AU`,name:`Australia`,dialCode:`61`,flag:`🇦🇺`},{code:`DE`,name:`Germany`,dialCode:`49`,flag:`🇩🇪`},{code:`FR`,name:`France`,dialCode:`33`,flag:`🇫🇷`},{code:`CN`,name:`China`,dialCode:`86`,flag:`🇨🇳`},{code:`KR`,name:`South Korea`,dialCode:`82`,flag:`🇰🇷`},{code:`IN`,name:`India`,dialCode:`91`,flag:`🇮🇳`},{code:`BR`,name:`Brazil`,dialCode:`55`,flag:`🇧🇷`}],u=(0,o.forwardRef)(({value:e=``,onChange:u,countryCode:d=`US`,onCountryChange:f,placeholder:p=`000-0000-0000`,disabled:m=!1,error:h,required:g=!1,label:_,layout:v=`vertical`,className:y,fullWidth:b=!1,...x},S)=>{let C=`wim-phone-input-${(0,o.useId)()}`,w=_?`${C}-label`:void 0,T=h?`${C}-error`:void 0,[
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../layout/Transition/Transition.cjs"),n=require("../../../icon/chevron-down.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("./phone-input.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=[{code:`US`,name:`United States`,dialCode:`1`,flag:`🇺🇸`},{code:`JP`,name:`Japan`,dialCode:`81`,flag:`🇯🇵`},{code:`GB`,name:`United Kingdom`,dialCode:`44`,flag:`🇬🇧`},{code:`AU`,name:`Australia`,dialCode:`61`,flag:`🇦🇺`},{code:`DE`,name:`Germany`,dialCode:`49`,flag:`🇩🇪`},{code:`FR`,name:`France`,dialCode:`33`,flag:`🇫🇷`},{code:`CN`,name:`China`,dialCode:`86`,flag:`🇨🇳`},{code:`KR`,name:`South Korea`,dialCode:`82`,flag:`🇰🇷`},{code:`IN`,name:`India`,dialCode:`91`,flag:`🇮🇳`},{code:`BR`,name:`Brazil`,dialCode:`55`,flag:`🇧🇷`}],u=(0,o.forwardRef)(({value:e=``,onChange:u,countryCode:d=`US`,onCountryChange:f,placeholder:p=`000-0000-0000`,disabled:m=!1,error:h,required:g=!1,label:_,layout:v=`vertical`,className:y,fullWidth:b=!1,...x},S)=>{let C=`wim-phone-input-${(0,o.useId)()}`,w=_?`${C}-label`:void 0,T=_?void 0:`Select country`,E=h?`${C}-error`:void 0,[D,O]=(0,o.useState)(!1),k=(0,o.useRef)(null);(0,o.useEffect)(()=>{let e=e=>{k.current&&!k.current.contains(e.target)&&O(!1)};return D&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[D]);let A=l.find(e=>e.code===d)??l[0],j=e=>{u?.(e.target.value)};return(0,c.jsx)(i.FieldTemplate,{label:_,labelId:w,htmlFor:C,required:g,error:h,errorId:E,layout:v,className:y,children:(0,c.jsxs)(`div`,{ref:k,className:(0,s.default)(`wim-phone-input`,a.default.root,b&&a.default.fullWidth,m&&a.default.disabled,h&&a.default.danger),"data-testid":`phone-input-root`,...x,children:[(0,c.jsxs)(`div`,{className:a.default.countryWrapper,children:[(0,c.jsxs)(`button`,{type:`button`,className:a.default.countryTrigger,onClick:()=>!m&&O(!D),disabled:m,"aria-haspopup":`listbox`,"aria-expanded":D,"aria-labelledby":w,"aria-label":T,children:[(0,c.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`1.2em`},children:A.flag}),(0,c.jsxs)(`span`,{children:[`+`,A.dialCode]}),(0,c.jsx)(r.Icon,{component:n.default,size:`sm`,className:(0,s.default)(a.default.chevron,D&&a.default.chevronOpen)})]}),(0,c.jsx)(t.Transition,{show:D,preset:`fade`,className:a.default.dropdown,children:(0,c.jsx)(`ul`,{className:a.default.countryList,role:`listbox`,"aria-labelledby":_?w:void 0,"aria-label":T,children:l.map(e=>(0,c.jsxs)(`li`,{className:(0,s.default)(a.default.countryOption,A.code===e.code&&a.default.selected),onClick:()=>{f?.(e.code),O(!1)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f?.(e.code),O(!1))},tabIndex:0,role:`option`,"aria-selected":A.code===e.code,children:[(0,c.jsx)(`span`,{"aria-hidden":`true`,children:e.flag}),(0,c.jsx)(`span`,{className:a.default.countryName,children:e.name}),(0,c.jsxs)(`span`,{className:a.default.countryCode,children:[`+`,e.dialCode]})]},e.code))})})]}),(0,c.jsx)(`div`,{className:a.default.divider,"aria-hidden":`true`}),(0,c.jsx)(`input`,{id:C,ref:S,type:`tel`,value:e,onChange:j,placeholder:p,disabled:m,className:a.default.number,"aria-invalid":!!h,"aria-describedby":E})]})})});u.displayName=`PhoneInput`,exports.PHONE_COUNTRIES=l,exports.PhoneInput=u;
|