wimui 0.50.0 → 0.50.2
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 +28 -16
- package/dist/components/data-display/Carousel/Carousel.cjs +1 -1
- package/dist/components/data-display/Carousel/Carousel.js +94 -95
- package/dist/components/form/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/form/PhoneInput/PhoneInput.d.ts +2 -2
- package/dist/components/form/PhoneInput/PhoneInput.js +116 -120
- package/dist/components/form/QueryBuilder/QueryBuilder.cjs +1 -1
- package/dist/components/form/QueryBuilder/QueryBuilder.d.ts +1 -28
- package/dist/components/form/QueryBuilder/QueryBuilder.js +1 -28
- package/dist/i18n/generated/keys.d.ts +1 -1
- package/dist/i18n/generated/resources.cjs +1 -1
- package/dist/i18n/generated/resources.js +120 -9
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/locales/en/components.json +24 -1
- package/dist/locales/en/form.json +13 -1
- package/dist/locales/ja/components.json +24 -1
- package/dist/locales/ja/form.json +13 -1
- package/dist/locales/pt/components.json +24 -1
- package/dist/locales/pt/form.json +13 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +6 -5
|
@@ -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,n)=>{let r=t;for(let t=0;t<e.length;t++){if(!e[r]?.disabled)return r;r=(r+n+e.length)%e.length}return-1},G=t=>{let n=e.findIndex(e=>e.id===M);L(t??(n>=0?n:W(0,1))),F(!0)},K=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})},q=t=>{if(!h)switch(t.key){case`ArrowDown`:case`ArrowUp`:t.preventDefault(),P?K(t.key===`ArrowDown`?1:-1):G();break;case`Home`:case`End`:t.preventDefault(),t.key===`Home`?P?L(W(0,1)):G(W(0,1)):P?L(W(e.length-1,-1)):G(W(e.length-1,-1));break;case`Enter`:case` `:if(t.preventDefault(),!P)G();else{let t=e[I];t&&U(t)}break;case`Escape`:P&&(t.preventDefault(),F(!1));break;case`Tab`:F(!1)}};(0,o.useEffect)(()=>{P&&I>=0&&(z.current?.querySelectorAll(`[role="option"]`)?.[I])?.scrollIntoView({block:`nearest`})},[I,P]);let J=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.
|
|
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,n)=>{let r=t;for(let t=0;t<e.length;t++){if(!e[r]?.disabled)return r;r=(r+n+e.length)%e.length}return-1},G=t=>{let n=e.findIndex(e=>e.id===M);L(t??(n>=0?n:W(0,1))),F(!0)},K=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})},q=t=>{if(!h)switch(t.key){case`ArrowDown`:case`ArrowUp`:t.preventDefault(),P?K(t.key===`ArrowDown`?1:-1):G();break;case`Home`:case`End`:t.preventDefault(),t.key===`Home`?P?L(W(0,1)):G(W(0,1)):P?L(W(e.length-1,-1)):G(W(e.length-1,-1));break;case`Enter`:case` `:if(t.preventDefault(),!P)G();else{let t=e[I];t&&U(t)}break;case`Escape`:P&&(t.preventDefault(),F(!1));break;case`Tab`:F(!1)}};(0,o.useEffect)(()=>{P&&I>=0&&(z.current?.querySelectorAll(`[role="option"]`)?.[I])?.scrollIntoView({block:`nearest`})},[I,P]);let J=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`))}if(t.length===0)return null;let n=t.flatMap((e,t)=>t===0?[e]:[` `,e]);return(0,c.jsx)(`span`,{className:a.default.metaRow,children:n})};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`,role:`combobox`,className:a.default.trigger,"aria-haspopup":`listbox`,"aria-expanded":P,"aria-controls":P?V:void 0,"aria-activedescendant":P&&I>=0?`${B}-opt-${I}`:void 0,"aria-label":O,disabled:h,onClick:()=>{h||(P?F(!1):G())},onKeyDown:q,onKeyUp:e=>{e.key===` `&&e.preventDefault()},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:-1,className:a.default.dropdown,onMouseDown:e=>e.preventDefault(),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}),` `,J(e)]})]},e.id)})})})]})});d.displayName=`ModelSelector`,exports.ModelSelector=d;
|
|
@@ -93,9 +93,11 @@ var h = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
93
93
|
]
|
|
94
94
|
}, "out"));
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
if (t.length === 0) return null;
|
|
97
|
+
let n = t.flatMap((e, t) => t === 0 ? [e] : [" ", e]);
|
|
98
|
+
return /* @__PURE__ */ p("span", {
|
|
97
99
|
className: i.metaRow,
|
|
98
|
-
children:
|
|
100
|
+
children: n
|
|
99
101
|
});
|
|
100
102
|
};
|
|
101
103
|
return /* @__PURE__ */ m("div", {
|
|
@@ -121,13 +123,17 @@ var h = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
121
123
|
},
|
|
122
124
|
children: [/* @__PURE__ */ p("span", {
|
|
123
125
|
className: i.triggerLabel,
|
|
124
|
-
children: z ? /* @__PURE__ */ m(f, { children: [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
children: z ? /* @__PURE__ */ m(f, { children: [
|
|
127
|
+
/* @__PURE__ */ p("span", {
|
|
128
|
+
className: i.triggerName,
|
|
129
|
+
children: z.name
|
|
130
|
+
}),
|
|
131
|
+
" ",
|
|
132
|
+
z.badge && /* @__PURE__ */ p("span", {
|
|
133
|
+
className: i.badge,
|
|
134
|
+
children: z.badge
|
|
135
|
+
})
|
|
136
|
+
] }) : /* @__PURE__ */ p("span", {
|
|
131
137
|
className: i.placeholder,
|
|
132
138
|
children: k
|
|
133
139
|
})
|
|
@@ -171,18 +177,24 @@ var h = (e) => e >= 1e6 ? `${(e / 1e6).toFixed(e % 1e6 == 0 ? 0 : 1)}M` : e >= 1
|
|
|
171
177
|
children: [
|
|
172
178
|
/* @__PURE__ */ m("span", {
|
|
173
179
|
className: i.optionHeader,
|
|
174
|
-
children: [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ p("span", {
|
|
182
|
+
className: i.optionName,
|
|
183
|
+
children: e.name
|
|
184
|
+
}),
|
|
185
|
+
" ",
|
|
186
|
+
e.badge && /* @__PURE__ */ p("span", {
|
|
187
|
+
className: i.badge,
|
|
188
|
+
children: e.badge
|
|
189
|
+
})
|
|
190
|
+
]
|
|
181
191
|
}),
|
|
192
|
+
" ",
|
|
182
193
|
e.description && /* @__PURE__ */ p("span", {
|
|
183
194
|
className: i.description,
|
|
184
195
|
children: e.description
|
|
185
196
|
}),
|
|
197
|
+
" ",
|
|
186
198
|
ee(e)
|
|
187
199
|
]
|
|
188
200
|
})]
|
|
@@ -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("../../../icon/chevron-left.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("../../../icon/chevron-left.cjs"),i=require("../../../icon/chevron-right.cjs"),a=require("../../media/Icon/Icon.cjs"),o=require("./carousel.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(e,t)=>typeof e==`number`?e:e?t>=1280&&e.xl?e.xl:t>=1024&&e.lg?e.lg:t>=768&&e.md?e.md:t>=640&&e.sm?e.sm:e.base||1:1,d=(0,s.forwardRef)(({children:e,autoPlay:d=!1,interval:f=5e3,showIndicators:p=!0,showControls:m=!0,controlsPlacement:h=`overlay`,loop:g=!0,slidesToShow:_=1,aspectRatio:v,objectFit:y=`cover`,labels:b,className:x,asChild:S,...C},w)=>{let T=S?t.Root:`div`,{t:E}=n.useWimTranslation(`components`),D={slideLabel:e=>E(`carousel.slide`,{number:e}),prevSlide:E(`carousel.prev_slide`),nextSlide:E(`carousel.next_slide`),goToSlide:e=>E(`carousel.go_to_slide`,{number:e}),...b},O=(0,s.useMemo)(()=>s.default.Children.toArray(e),[e]),k=O.length,[A,j]=(0,s.useState)(typeof window<`u`?window.innerWidth:0),[M,N]=(0,s.useState)(g?k:0),[P,F]=(0,s.useState)(!1),[I,L]=(0,s.useState)(!1),R=u(_,A),z=(0,s.useRef)(null),B=(0,s.useRef)(null),V=(0,s.useRef)(null),H=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=()=>j(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let U=(0,s.useMemo)(()=>!g||k===0?O:[...O,...O,...O],[O,g,k]),W=(0,s.useCallback)(()=>{if(!P){if(!g){N(e=>Math.min(e+1,k-R));return}F(!0),N(e=>e+1)}},[P,g,k,R]),G=(0,s.useCallback)(()=>{if(!P){if(!g){N(e=>Math.max(e-1,0));return}F(!0),N(e=>e-1)}},[P,g]),K=e=>{P||(g?(F(!0),N(e+k)):N(e))},q=()=>{g&&(F(!1),M>=k*2?N(M-k):M<k&&N(M+k))};(0,s.useEffect)(()=>(d&&!I&&k>R&&(z.current=window.setInterval(W,f)),()=>{z.current&&window.clearInterval(z.current)}),[d,f,W,k,R,I]);let J=e=>{e.key===`ArrowLeft`?G():e.key===`ArrowRight`&&W()},Y=e=>{V.current=e.targetTouches[0].clientX},X=e=>{H.current=e.targetTouches[0].clientX},Z=()=>{if(!V.current||!H.current)return;let e=V.current-H.current;e>50?W():e<-50&&G(),V.current=null,H.current=null};if(k===0)return null;let Q=100/R,$=-M*Q;return(0,l.jsxs)(T,{ref:w,className:(0,c.default)(`wim-carousel`,o.default.root,h===`outside`&&o.default.controlsOutside,x),onMouseEnter:()=>L(!0),onMouseLeave:()=>L(!1),onFocus:()=>L(!0),onBlur:()=>L(!1),onKeyDown:J,tabIndex:0,role:`region`,"aria-roledescription":`carousel`,...C,children:[(0,l.jsx)(`div`,{className:o.default.viewport,children:(0,l.jsx)(`div`,{ref:B,className:(0,c.default)(o.default.track,P&&o.default.transition),style:{transform:`translateX(${$}%)`},onTransitionEnd:q,onTouchStart:Y,onTouchMove:X,onTouchEnd:Z,children:U.map((e,t)=>(0,l.jsx)(`div`,{className:(0,c.default)(o.default.item,v&&o.default.hasAspectRatio),style:{flex:`0 0 ${Q}%`,width:`${Q}%`,...v?{aspectRatio:v,"--wim-carousel-object-fit":y}:{}},role:`group`,"aria-roledescription":`slide`,"aria-label":D.slideLabel(t%k+1),children:e},t))})}),m&&k>R&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`button`,{className:(0,c.default)(o.default.control,o.default.prev),onClick:G,"aria-label":D.prevSlide,disabled:!g&&M===0,tabIndex:-1,children:(0,l.jsx)(a.Icon,{component:r.default,size:`md`})}),(0,l.jsx)(`button`,{className:(0,c.default)(o.default.control,o.default.next),onClick:W,"aria-label":D.nextSlide,disabled:!g&&M>=k-R,tabIndex:-1,children:(0,l.jsx)(a.Icon,{component:i.default,size:`md`})})]}),p&&k>1&&(0,l.jsx)(`div`,{className:o.default.indicators,children:O.map((e,t)=>{let n=g?M%k===t:M===t;return(0,l.jsx)(`button`,{className:(0,c.default)(o.default.indicator,n&&o.default.active),onClick:()=>K(t),"aria-label":D.goToSlide(t+1),"aria-current":n?`true`:`false`},t)})})]})});d.displayName=`Carousel`,exports.Carousel=d;
|
|
@@ -1,109 +1,108 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
|
-
import t from "../../../
|
|
4
|
-
import n from "../../../icon/chevron-
|
|
5
|
-
import
|
|
6
|
-
import i from "
|
|
7
|
-
import a
|
|
3
|
+
import { useWimTranslation as t } from "../../../i18n/useWimTranslation.js";
|
|
4
|
+
import n from "../../../icon/chevron-left.js";
|
|
5
|
+
import r from "../../../icon/chevron-right.js";
|
|
6
|
+
import { Icon as i } from "../../media/Icon/Icon.js";
|
|
7
|
+
import a from "./carousel.module.js";
|
|
8
|
+
import ee, { forwardRef as o, useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
8
9
|
import f from "classnames";
|
|
9
|
-
import { Fragment as
|
|
10
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
11
|
//#region src/components/data-display/Carousel/Carousel.tsx
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let j = O ? e : "div", M = {
|
|
18
|
-
...h,
|
|
12
|
+
var g = (e, t) => typeof e == "number" ? e : e ? t >= 1280 && e.xl ? e.xl : t >= 1024 && e.lg ? e.lg : t >= 768 && e.md ? e.md : t >= 640 && e.sm ? e.sm : e.base || 1 : 1, _ = o(({ children: o, autoPlay: _ = !1, interval: v = 5e3, showIndicators: y = !0, showControls: b = !0, controlsPlacement: x = "overlay", loop: S = !0, slidesToShow: C = 1, aspectRatio: w, objectFit: T = "cover", labels: E, className: D, asChild: O, ...k }, A) => {
|
|
13
|
+
let j = O ? e : "div", { t: M } = t("components"), N = {
|
|
14
|
+
slideLabel: (e) => M("carousel.slide", { number: e }),
|
|
15
|
+
prevSlide: M("carousel.prev_slide"),
|
|
16
|
+
nextSlide: M("carousel.next_slide"),
|
|
17
|
+
goToSlide: (e) => M("carousel.go_to_slide", { number: e }),
|
|
19
18
|
...E
|
|
20
|
-
},
|
|
19
|
+
}, P = l(() => ee.Children.toArray(o), [o]), F = P.length, [I, L] = d(typeof window < "u" ? window.innerWidth : 0), [R, z] = d(S ? F : 0), [B, V] = d(!1), [H, U] = d(!1), W = g(C, I), G = u(null), K = u(null), q = u(null), J = u(null);
|
|
21
20
|
c(() => {
|
|
22
|
-
let e = () =>
|
|
21
|
+
let e = () => L(window.innerWidth);
|
|
23
22
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
24
23
|
}, []);
|
|
25
|
-
let
|
|
26
|
-
...
|
|
27
|
-
...
|
|
28
|
-
...
|
|
24
|
+
let Y = l(() => !S || F === 0 ? P : [
|
|
25
|
+
...P,
|
|
26
|
+
...P,
|
|
27
|
+
...P
|
|
29
28
|
], [
|
|
30
|
-
|
|
29
|
+
P,
|
|
31
30
|
S,
|
|
32
|
-
|
|
33
|
-
]),
|
|
34
|
-
if (!
|
|
31
|
+
F
|
|
32
|
+
]), X = s(() => {
|
|
33
|
+
if (!B) {
|
|
35
34
|
if (!S) {
|
|
36
|
-
|
|
35
|
+
z((e) => Math.min(e + 1, F - W));
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
V(!0), z((e) => e + 1);
|
|
40
39
|
}
|
|
41
40
|
}, [
|
|
42
|
-
|
|
41
|
+
B,
|
|
43
42
|
S,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
]),
|
|
47
|
-
if (!
|
|
43
|
+
F,
|
|
44
|
+
W
|
|
45
|
+
]), Z = s(() => {
|
|
46
|
+
if (!B) {
|
|
48
47
|
if (!S) {
|
|
49
|
-
|
|
48
|
+
z((e) => Math.max(e - 1, 0));
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
|
-
|
|
51
|
+
V(!0), z((e) => e - 1);
|
|
53
52
|
}
|
|
54
|
-
}, [
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
S && (
|
|
53
|
+
}, [B, S]), Q = (e) => {
|
|
54
|
+
B || (S ? (V(!0), z(e + F)) : z(e));
|
|
55
|
+
}, te = () => {
|
|
56
|
+
S && (V(!1), R >= F * 2 ? z(R - F) : R < F && z(R + F));
|
|
58
57
|
};
|
|
59
|
-
c(() => (_ && !
|
|
60
|
-
|
|
58
|
+
c(() => (_ && !H && F > W && (G.current = window.setInterval(X, v)), () => {
|
|
59
|
+
G.current && window.clearInterval(G.current);
|
|
61
60
|
}), [
|
|
62
61
|
_,
|
|
63
62
|
v,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
X,
|
|
64
|
+
F,
|
|
65
|
+
W,
|
|
66
|
+
H
|
|
68
67
|
]);
|
|
69
|
-
let
|
|
70
|
-
e.key === "ArrowLeft" ?
|
|
71
|
-
}, ne = (e) => {
|
|
72
|
-
K.current = e.targetTouches[0].clientX;
|
|
68
|
+
let ne = (e) => {
|
|
69
|
+
e.key === "ArrowLeft" ? Z() : e.key === "ArrowRight" && X();
|
|
73
70
|
}, re = (e) => {
|
|
74
71
|
q.current = e.targetTouches[0].clientX;
|
|
75
|
-
}, ie = () => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
}, ie = (e) => {
|
|
73
|
+
J.current = e.targetTouches[0].clientX;
|
|
74
|
+
}, ae = () => {
|
|
75
|
+
if (!q.current || !J.current) return;
|
|
76
|
+
let e = q.current - J.current;
|
|
77
|
+
e > 50 ? X() : e < -50 && Z(), q.current = null, J.current = null;
|
|
79
78
|
};
|
|
80
|
-
if (
|
|
81
|
-
let $ = 100 /
|
|
82
|
-
return /* @__PURE__ */
|
|
79
|
+
if (F === 0) return null;
|
|
80
|
+
let $ = 100 / W, oe = -R * $;
|
|
81
|
+
return /* @__PURE__ */ h(j, {
|
|
83
82
|
ref: A,
|
|
84
|
-
className: f("wim-carousel",
|
|
85
|
-
onMouseEnter: () =>
|
|
86
|
-
onMouseLeave: () =>
|
|
87
|
-
onFocus: () =>
|
|
88
|
-
onBlur: () =>
|
|
89
|
-
onKeyDown:
|
|
83
|
+
className: f("wim-carousel", a.root, x === "outside" && a.controlsOutside, D),
|
|
84
|
+
onMouseEnter: () => U(!0),
|
|
85
|
+
onMouseLeave: () => U(!1),
|
|
86
|
+
onFocus: () => U(!0),
|
|
87
|
+
onBlur: () => U(!1),
|
|
88
|
+
onKeyDown: ne,
|
|
90
89
|
tabIndex: 0,
|
|
91
90
|
role: "region",
|
|
92
91
|
"aria-roledescription": "carousel",
|
|
93
92
|
...k,
|
|
94
93
|
children: [
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
className:
|
|
97
|
-
children: /* @__PURE__ */
|
|
98
|
-
ref:
|
|
99
|
-
className: f(
|
|
100
|
-
style: { transform: `translateX(${
|
|
101
|
-
onTransitionEnd:
|
|
102
|
-
onTouchStart:
|
|
103
|
-
onTouchMove:
|
|
104
|
-
onTouchEnd:
|
|
105
|
-
children:
|
|
106
|
-
className: f(
|
|
94
|
+
/* @__PURE__ */ m("div", {
|
|
95
|
+
className: a.viewport,
|
|
96
|
+
children: /* @__PURE__ */ m("div", {
|
|
97
|
+
ref: K,
|
|
98
|
+
className: f(a.track, B && a.transition),
|
|
99
|
+
style: { transform: `translateX(${oe}%)` },
|
|
100
|
+
onTransitionEnd: te,
|
|
101
|
+
onTouchStart: re,
|
|
102
|
+
onTouchMove: ie,
|
|
103
|
+
onTouchEnd: ae,
|
|
104
|
+
children: Y.map((e, t) => /* @__PURE__ */ m("div", {
|
|
105
|
+
className: f(a.item, w && a.hasAspectRatio),
|
|
107
106
|
style: {
|
|
108
107
|
flex: `0 0 ${$}%`,
|
|
109
108
|
width: `${$}%`,
|
|
@@ -114,40 +113,40 @@ var h = {
|
|
|
114
113
|
},
|
|
115
114
|
role: "group",
|
|
116
115
|
"aria-roledescription": "slide",
|
|
117
|
-
"aria-label":
|
|
116
|
+
"aria-label": N.slideLabel(t % F + 1),
|
|
118
117
|
children: e
|
|
119
118
|
}, t))
|
|
120
119
|
})
|
|
121
120
|
}),
|
|
122
|
-
b &&
|
|
123
|
-
className: f(
|
|
124
|
-
onClick:
|
|
125
|
-
"aria-label":
|
|
126
|
-
disabled: !S &&
|
|
121
|
+
b && F > W && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("button", {
|
|
122
|
+
className: f(a.control, a.prev),
|
|
123
|
+
onClick: Z,
|
|
124
|
+
"aria-label": N.prevSlide,
|
|
125
|
+
disabled: !S && R === 0,
|
|
127
126
|
tabIndex: -1,
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
-
component:
|
|
127
|
+
children: /* @__PURE__ */ m(i, {
|
|
128
|
+
component: n,
|
|
130
129
|
size: "md"
|
|
131
130
|
})
|
|
132
|
-
}), /* @__PURE__ */
|
|
133
|
-
className: f(
|
|
134
|
-
onClick:
|
|
135
|
-
"aria-label":
|
|
136
|
-
disabled: !S &&
|
|
131
|
+
}), /* @__PURE__ */ m("button", {
|
|
132
|
+
className: f(a.control, a.next),
|
|
133
|
+
onClick: X,
|
|
134
|
+
"aria-label": N.nextSlide,
|
|
135
|
+
disabled: !S && R >= F - W,
|
|
137
136
|
tabIndex: -1,
|
|
138
|
-
children: /* @__PURE__ */
|
|
139
|
-
component:
|
|
137
|
+
children: /* @__PURE__ */ m(i, {
|
|
138
|
+
component: r,
|
|
140
139
|
size: "md"
|
|
141
140
|
})
|
|
142
141
|
})] }),
|
|
143
|
-
y &&
|
|
144
|
-
className:
|
|
145
|
-
children:
|
|
146
|
-
let n = S ?
|
|
147
|
-
return /* @__PURE__ */
|
|
148
|
-
className: f(
|
|
149
|
-
onClick: () =>
|
|
150
|
-
"aria-label":
|
|
142
|
+
y && F > 1 && /* @__PURE__ */ m("div", {
|
|
143
|
+
className: a.indicators,
|
|
144
|
+
children: P.map((e, t) => {
|
|
145
|
+
let n = S ? R % F === t : R === t;
|
|
146
|
+
return /* @__PURE__ */ m("button", {
|
|
147
|
+
className: f(a.indicator, n && a.active),
|
|
148
|
+
onClick: () => Q(t),
|
|
149
|
+
"aria-label": N.goToSlide(t + 1),
|
|
151
150
|
"aria-current": n ? "true" : "false"
|
|
152
151
|
}, t);
|
|
153
152
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/generated/resources.cjs"),n=require("../../../i18n/useWimTranslation.cjs"),r=require("../../layout/Transition/Transition.cjs"),i=require("../../../icon/chevron-down.cjs"),a=require("../../media/Icon/Icon.cjs"),o=require("../FieldTemplate/FieldTemplate.cjs"),s=require("./phone-input.module.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");var d=[{code:`US`,dialCode:`1`,flag:`🇺🇸`},{code:`JP`,dialCode:`81`,flag:`🇯🇵`},{code:`GB`,dialCode:`44`,flag:`🇬🇧`},{code:`AU`,dialCode:`61`,flag:`🇦🇺`},{code:`DE`,dialCode:`49`,flag:`🇩🇪`},{code:`FR`,dialCode:`33`,flag:`🇫🇷`},{code:`CN`,dialCode:`86`,flag:`🇨🇳`},{code:`KR`,dialCode:`82`,flag:`🇰🇷`},{code:`IN`,dialCode:`91`,flag:`🇮🇳`},{code:`BR`,dialCode:`55`,flag:`🇧🇷`}],f=(0,c.forwardRef)(({value:e=``,onChange:f,countryCode:p=`US`,onCountryChange:m,placeholder:h=`000-0000-0000`,disabled:g=!1,error:_,required:v=!1,label:y,layout:b=`vertical`,className:x,fullWidth:S=!1,...C},w)=>{let T=`wim-phone-input-${(0,c.useId)()}`,E=y?`${T}-label`:void 0,{t:D}=n.useWimTranslation(`form`),O=D(`phone.select_country`),k=`${T}-countries`,A=e=>`${T}-country-${e}`,j=_?`${T}-error`:void 0,[M,N]=(0,c.useState)(!1),[P,F]=(0,c.useState)(-1),I=(0,c.useRef)(null),L=(0,c.useRef)(null),R=(0,c.useRef)({text:``,timer:null});(0,c.useEffect)(()=>{let e=e=>{I.current&&!I.current.contains(e.target)&&N(!1)};return M&&document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[M]);let z=d.find(e=>e.code===p)??d[0],B=e=>{f?.(e.target.value)},V=d.length-1,H=e=>{let t=d.findIndex(e=>e.code===z.code);F(e??Math.max(t,0)),N(!0)},U=e=>{let t=d[e];t&&(m?.(t.code),N(!1))},W=e=>D(`phone.countries.${e.code}`),G=e=>(t.wimResources.en?.form)?.phone?.countries?.[e.code]??``,K=(e,t)=>{let n=e.toLowerCase().replace(/^\+/,``);if(n===``)return-1;let r=/^[0-9]+$/.test(n),i=!r&&n.length>1&&n.split(``).every(e=>e===n[0]),a=i?n[0]:n,o=i||n.length===1?t+1:t,s=r?[e=>e.dialCode]:[e=>W(e).toLowerCase(),e=>G(e).toLowerCase(),e=>e.code.toLowerCase()];for(let e of s)for(let t=0;t<d.length;t++){let n=(Math.max(o,0)+t)%d.length;if(e(d[n]).startsWith(a))return n}return-1},q=e=>{let t=R.current;t.timer&&clearTimeout(t.timer),t.text+=e,t.timer=setTimeout(()=>{t.text=``,t.timer=null},500);let n=K(t.text,M?P:-1);n<0||(M?F(n):H(n))},J=e=>{if(!g)switch(e.key){case`ArrowDown`:case`ArrowUp`:if(e.preventDefault(),!M)H();else{let t=e.key===`ArrowDown`?1:-1;F(e=>(e+t+d.length)%d.length)}break;case`Home`:case`End`:e.preventDefault(),M?F(e.key===`Home`?0:V):H(e.key===`Home`?0:V);break;case`Enter`:case` `:e.preventDefault(),e.key===` `&&R.current.text!==``?q(` `):M?U(P):H();break;case`Escape`:M&&(e.preventDefault(),N(!1));break;case`Tab`:N(!1);break;default:e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),q(e.key))}};return(0,c.useEffect)(()=>{let e=R.current;return()=>{e.timer&&clearTimeout(e.timer)}},[]),(0,c.useEffect)(()=>{M&&P>=0&&(L.current?.querySelectorAll(`[role="option"]`)?.[P])?.scrollIntoView?.({block:`nearest`})},[P,M]),(0,u.jsx)(o.FieldTemplate,{label:y,labelId:E,htmlFor:T,required:v,error:_,errorId:j,layout:b,className:x,children:(0,u.jsxs)(`div`,{ref:I,className:(0,l.default)(`wim-phone-input`,s.default.root,S&&s.default.fullWidth,g&&s.default.disabled,_&&s.default.danger),"data-testid":`phone-input-root`,...C,children:[(0,u.jsxs)(`div`,{className:s.default.countryWrapper,children:[(0,u.jsxs)(`button`,{type:`button`,role:`combobox`,className:s.default.countryTrigger,onClick:()=>{g||(M?N(!1):H())},onKeyDown:J,onKeyUp:e=>{e.key===` `&&e.preventDefault()},disabled:g,"aria-haspopup":`listbox`,"aria-expanded":M,"aria-controls":M?k:void 0,"aria-activedescendant":M&&P>=0?A(P):void 0,"aria-label":O,children:[(0,u.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`1.2em`},children:z.flag}),(0,u.jsxs)(`span`,{children:[`+`,z.dialCode]}),(0,u.jsx)(a.Icon,{component:i.default,size:`sm`,className:(0,l.default)(s.default.chevron,M&&s.default.chevronOpen)})]}),(0,u.jsx)(r.Transition,{show:M,preset:`fade`,className:s.default.dropdown,children:(0,u.jsx)(`ul`,{ref:L,id:k,className:s.default.countryList,role:`listbox`,"aria-label":O,tabIndex:-1,onMouseDown:e=>e.preventDefault(),children:d.map((e,t)=>(0,u.jsxs)(`li`,{id:A(t),className:(0,l.default)(s.default.countryOption,t===P&&s.default.active,z.code===e.code&&s.default.selected),onMouseEnter:()=>F(t),onClick:()=>U(t),role:`option`,"aria-selected":z.code===e.code,children:[(0,u.jsx)(`span`,{"aria-hidden":`true`,children:e.flag}),(0,u.jsx)(`span`,{className:s.default.countryName,children:W(e)}),` `,(0,u.jsxs)(`span`,{className:s.default.countryCode,children:[`+`,e.dialCode]})]},e.code))})})]}),(0,u.jsx)(`div`,{className:s.default.divider,"aria-hidden":`true`}),(0,u.jsx)(`input`,{id:T,ref:w,type:`tel`,value:e,onChange:B,placeholder:h,disabled:g,className:s.default.number,"aria-invalid":!!_,"aria-describedby":j})]})})});f.displayName=`PhoneInput`,exports.PHONE_COUNTRIES=d,exports.PhoneInput=f;
|