zaravand-ui 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Dialog/Dialog.cjs +1 -1
- package/dist/components/Dialog/Dialog.js +1 -1
- package/dist/components/Input/Input.formatting.cjs +1 -1
- package/dist/components/Input/Input.formatting.js +35 -17
- package/dist/components/Input/Input.interface.d.cts +5 -1
- package/dist/components/Input/Input.interface.d.ts +5 -1
- package/dist/components/OtpInput/OtpInput.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.d.cts +10 -0
- package/dist/components/OtpInput/OtpInput.d.ts +10 -0
- package/dist/components/OtpInput/OtpInput.interface.d.cts +49 -0
- package/dist/components/OtpInput/OtpInput.interface.d.ts +49 -0
- package/dist/components/OtpInput/OtpInput.js +150 -0
- package/dist/components/OtpInput/OtpInput.variant.cjs +1 -0
- package/dist/components/OtpInput/OtpInput.variant.d.cts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.d.ts +6 -0
- package/dist/components/OtpInput/OtpInput.variant.js +15 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.d.cts +4 -1
- package/dist/components/Select/Select.d.ts +4 -1
- package/dist/components/Select/Select.interface.d.cts +15 -1
- package/dist/components/Select/Select.interface.d.ts +15 -1
- package/dist/components/Select/Select.js +697 -566
- package/dist/components/Table/Table.cjs +1 -1
- package/dist/components/Table/Table.constants.cjs +1 -1
- package/dist/components/Table/Table.constants.d.cts +1 -0
- package/dist/components/Table/Table.constants.d.ts +1 -0
- package/dist/components/Table/Table.constants.js +2 -2
- package/dist/components/Table/Table.interface.d.cts +39 -0
- package/dist/components/Table/Table.interface.d.ts +39 -0
- package/dist/components/Table/Table.js +522 -421
- package/dist/components/Table/Table.utils.cjs +1 -1
- package/dist/components/Table/Table.utils.d.cts +10 -1
- package/dist/components/Table/Table.utils.d.ts +10 -1
- package/dist/components/Table/Table.utils.js +23 -1
- package/dist/components/Table/Table.variant.cjs +1 -1
- package/dist/components/Table/Table.variant.d.cts +5 -0
- package/dist/components/Table/Table.variant.d.ts +5 -0
- package/dist/components/Table/Table.variant.js +17 -11
- package/dist/components/Table/TableActiveFilters.cjs +1 -0
- package/dist/components/Table/TableActiveFilters.d.cts +12 -0
- package/dist/components/Table/TableActiveFilters.d.ts +12 -0
- package/dist/components/Table/TableActiveFilters.js +55 -0
- package/dist/components/Table/TableColumnFilter.cjs +1 -0
- package/dist/components/Table/TableColumnFilter.d.cts +20 -0
- package/dist/components/Table/TableColumnFilter.d.ts +20 -0
- package/dist/components/Table/TableColumnFilter.js +100 -0
- package/dist/components/Table/TableEmptyState.cjs +1 -1
- package/dist/components/Table/TableEmptyState.d.cts +1 -1
- package/dist/components/Table/TableEmptyState.d.ts +1 -1
- package/dist/components/Table/TableEmptyState.js +16 -7
- package/dist/components/Table/TableFilterRegistry.cjs +1 -0
- package/dist/components/Table/TableFilterRegistry.d.cts +13 -0
- package/dist/components/Table/TableFilterRegistry.d.ts +13 -0
- package/dist/components/Table/TableFilterRegistry.js +5 -0
- package/dist/components/Table/TableSkeletonRows.cjs +1 -1
- package/dist/components/Table/TableSkeletonRows.js +7 -7
- package/dist/components/Table/TableSortToggle.cjs +1 -1
- package/dist/components/Table/TableSortToggle.js +8 -8
- package/dist/components/Table/hooks/useTableFilter.cjs +1 -0
- package/dist/components/Table/hooks/useTableFilter.d.cts +18 -0
- package/dist/components/Table/hooks/useTableFilter.d.ts +18 -0
- package/dist/components/Table/hooks/useTableFilter.js +49 -0
- package/dist/components/Uploader/Uploader.variant.cjs +1 -1
- package/dist/components/Uploader/Uploader.variant.d.cts +1 -1
- package/dist/components/Uploader/Uploader.variant.d.ts +1 -1
- package/dist/components/Uploader/Uploader.variant.js +1 -1
- package/dist/components/VerticalTabs/VerticalTabs.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.cts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.d.ts +4 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.cts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.interface.d.ts +41 -0
- package/dist/components/VerticalTabs/VerticalTabs.js +196 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.cjs +1 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.cts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.d.ts +19 -0
- package/dist/components/VerticalTabs/VerticalTabs.variant.js +48 -0
- package/dist/components/shared/responsiveScale.cjs +1 -1
- package/dist/components/shared/responsiveScale.d.cts +3 -1
- package/dist/components/shared/responsiveScale.d.ts +3 -1
- package/dist/components/shared/responsiveScale.js +2 -2
- package/dist/config/messages.cjs +1 -1
- package/dist/config/messages.d.cts +8 -0
- package/dist/config/messages.d.ts +8 -0
- package/dist/config/messages.js +12 -2
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +19 -16
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../lib/utils.cjs`),r=require(`../shared/overlay.cjs`),i=require(`../shared/overlay.utils.cjs`),a=require(`./DialogDragHandle.cjs`),o=require(`./Dialog.variant.cjs`);let s=require(`react`);s=e.__toESM(s,1);let c=require(`react/jsx-runtime`),l=require(`lucide-react`),u=require(`@radix-ui/react-dialog`);u=e.__toESM(u,1);var d=`zui:absolute zui:mobile:start-3 zui:desktop:end-3 zui:mobile:top-1.5 zui:desktop:top-3 zui:inline-flex zui:mobile:size-10 zui:desktop:size-8 zui:items-center zui:justify-center zui:rounded-
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../lib/utils.cjs`),r=require(`../shared/overlay.cjs`),i=require(`../shared/overlay.utils.cjs`),a=require(`./DialogDragHandle.cjs`),o=require(`./Dialog.variant.cjs`);let s=require(`react`);s=e.__toESM(s,1);let c=require(`react/jsx-runtime`),l=require(`lucide-react`),u=require(`@radix-ui/react-dialog`);u=e.__toESM(u,1);var d=`zui:absolute zui:mobile:start-3 zui:desktop:end-3 zui:mobile:top-1.5 zui:desktop:top-3 zui:inline-flex zui:cursor-pointer zui:mobile:size-10 zui:desktop:size-8 zui:items-center zui:justify-center zui:rounded-full zui:text-[var(--zui-color-text)] zui:opacity-70 zui:transition-[background-color,opacity] zui:hover:bg-[var(--zui-color-muted-surface)] zui:hover:opacity-100 zui:focus-visible:opacity-100 zui:focus-visible:outline-none zui:focus-visible:ring-2 zui:focus-visible:ring-[var(--zui-theme-action-secondary)]`,f=s.forwardRef(function({open:e,defaultOpen:f,onOpenChange:p,modal:m=!0,dir:h,title:g,description:_,content:v,child:y,children:b,trigger:x,triggerLabel:S,triggerAriaLabel:C,closeLabel:w,closeAriaLabel:T,showCloseButton:E=!0,showCloseIcon:D,closeIcon:O=!1,triggerClassName:k,onOpenAutoFocus:A,className:j,overlayClassName:M},N){let P=s.useRef(null),{messages:F,dir:I}=t.useZuiConfig(),L=h??I,R=S??F.dialog.trigger,z=w??F.common.close,B=v??y??b,V=D??O,H=i.resolveAriaLabel(T,z,F.common.close);return(0,c.jsxs)(u.Root,{open:e,defaultOpen:f,onOpenChange:p,modal:m,children:[(0,c.jsx)(r.OverlayTrigger,{"data-slot":`dialog-trigger`,trigger:x,label:R,ariaLabel:i.resolveAriaLabel(C,R,F.dialog.trigger),className:k}),(0,c.jsx)(u.Portal,{"data-slot":`dialog-portal`,children:(0,c.jsx)(u.Overlay,{"data-slot":`dialog-overlay`,className:n.cn(o.dialogOverlayVariants(),M),children:(0,c.jsxs)(u.Content,{ref:N,"data-slot":`dialog-content`,dir:L,onOpenAutoFocus:A,className:n.cn(`zui:relative`,o.dialogContentVariants(),j),children:[(0,c.jsx)(u.Close,{ref:P,hidden:!0,tabIndex:-1}),(0,c.jsx)(a.default,{onDismiss:()=>P.current?.click()}),V?(0,c.jsx)(u.Close,{"data-slot":`dialog-close`,asChild:!0,children:(0,c.jsx)(`button`,{type:`button`,"aria-label":H,className:d,children:(0,c.jsx)(l.XIcon,{className:`zui:mobile:size-5 zui:desktop:size-4`,"aria-hidden":`true`})})}):null,(0,c.jsx)(r.OverlayHeader,{slotPrefix:`dialog`,title:g,description:_,fallbackTitle:typeof R==`string`?R:F.dialog.fallbackTitle,className:o.dialogHeaderVariants(),titleClassName:o.dialogTitleVariants(),descriptionClassName:o.dialogDescriptionVariants()}),B==null?null:(0,c.jsx)(`div`,{"data-slot":`dialog-body`,className:`zui:text-sm zui:text-[var(--zui-theme-text-primary)]`,children:B}),E?(0,c.jsx)(`div`,{"data-slot":`dialog-footer`,className:o.dialogFooterVariants(),children:(0,c.jsx)(u.Close,{"data-slot":`dialog-close`,asChild:!0,children:(0,c.jsx)(`button`,{type:`button`,"aria-label":H,className:i.overlayFooterCloseButtonClassName,children:z})})}):null]})})})]})});exports.default=f;
|
|
@@ -10,7 +10,7 @@ import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
|
10
10
|
import { XIcon as g } from "lucide-react";
|
|
11
11
|
import * as _ from "@radix-ui/react-dialog";
|
|
12
12
|
//#region src/components/Dialog/Dialog.tsx
|
|
13
|
-
var v = "zui:absolute zui:mobile:start-3 zui:desktop:end-3 zui:mobile:top-1.5 zui:desktop:top-3 zui:inline-flex zui:mobile:size-10 zui:desktop:size-8 zui:items-center zui:justify-center zui:rounded-
|
|
13
|
+
var v = "zui:absolute zui:mobile:start-3 zui:desktop:end-3 zui:mobile:top-1.5 zui:desktop:top-3 zui:inline-flex zui:cursor-pointer zui:mobile:size-10 zui:desktop:size-8 zui:items-center zui:justify-center zui:rounded-full zui:text-[var(--zui-color-text)] zui:opacity-70 zui:transition-[background-color,opacity] zui:hover:bg-[var(--zui-color-muted-surface)] zui:hover:opacity-100 zui:focus-visible:opacity-100 zui:focus-visible:outline-none zui:focus-visible:ring-2 zui:focus-visible:ring-[var(--zui-theme-action-secondary)]", y = p.forwardRef(function({ open: y, defaultOpen: b, onOpenChange: x, modal: S = !0, dir: C, title: w, description: T, content: E, child: D, children: O, trigger: k, triggerLabel: A, triggerAriaLabel: j, closeLabel: M, closeAriaLabel: N, showCloseButton: P = !0, showCloseIcon: F, closeIcon: I = !1, triggerClassName: L, onOpenAutoFocus: R, className: z, overlayClassName: B }, V) {
|
|
14
14
|
let H = p.useRef(null), { messages: U, dir: W } = e(), G = C ?? W, K = A ?? U.dialog.trigger, q = M ?? U.common.close, J = E ?? D ?? O, Y = F ?? I, X = a(N, q, U.common.close);
|
|
15
15
|
return /* @__PURE__ */ h(_.Root, {
|
|
16
16
|
open: y,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),t=require(`../../services/convertToPersianDigits/convertToPersianDigits.cjs`);var n=11;function r(t){return e.convertToEnglishDigits({value:t})}function i(e){return r(e).replace(/\D/g,``)}function a(e){return e.replace(/^0+(?=\d)/,``)}function o(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function s(e){let t=a(e);if(t===``)return t;let n=Number(t);return Number.isNaN(n)?t:n>100?`100`:String(n)}function c(e){let t=!1,n=``;for(let i of r(e).replace(/٫/g,`.`))/\d/.test(i)?n+=i:i===`.`&&!t&&(n+=i,t=!0);return n}function l(e){return e===``?``:(e[0]===`0`?e:`0${e}`).slice(0,n)}function u(e,t){let n=[],r=0;for(let i of t)n.push(e.slice(r,r+i)),r+=i;return n.filter(Boolean).join(`-`)}function d(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)/[0-9]/.test(e[r])&&(n+=1);return n}function f(e,t){let n=0,r=!1;for(let i=0;i<t&&i<e.length;i+=1){let t=e[i];/\d/.test(t)?n+=1:t===`.`&&!r&&(n+=1,r=!0)}return n}function p(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r+=1)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function m(e){return(t,n)=>{let i=r(t),a=e(i);return{value:a,caret:Math.min(d(i,n),a.length)}}}function h(e){return(t,n)=>{let i=r(t),a=d(i,n),o=i.replace(/\D/g,``),s=l(o),c=+(o!==``&&o[0]!==`0`),f=u(s,e);return{value:f,caret:p(f,Math.min(a+c,s.length))}}}var g={normalize:e=>e,isFormatted:!1,isCentered:!1},
|
|
1
|
+
const e=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),t=require(`../../services/convertToPersianDigits/convertToPersianDigits.cjs`);var n=11;function r(t){return e.convertToEnglishDigits({value:t})}function i(e){return r(e).replace(/\D/g,``)}function a(e){return e.replace(/^0+(?=\d)/,``)}function o(e){return e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)}function s(e){let t=a(e);if(t===``)return t;let n=Number(t);return Number.isNaN(n)?t:n>100?`100`:String(n)}function c(e){let t=!1,n=``;for(let i of r(e).replace(/٫/g,`.`))/\d/.test(i)?n+=i:i===`.`&&!t&&(n+=i,t=!0);return n}function l(e){return e===``?``:(e[0]===`0`?e:`0${e}`).slice(0,n)}function u(e,t){let n=[],r=0;for(let i of t)n.push(e.slice(r,r+i)),r+=i;return n.filter(Boolean).join(`-`)}function d(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)/[0-9]/.test(e[r])&&(n+=1);return n}function f(e,t){let n=0,r=!1;for(let i=0;i<t&&i<e.length;i+=1){let t=e[i];/\d/.test(t)?n+=1:t===`.`&&!r&&(n+=1,r=!0)}return n}function p(e,t){if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r+=1)if(/[0-9]/.test(e[r])&&(n+=1,n===t))return r+1;return e.length}function m(e){return(t,n)=>{let i=r(t),a=e(i);return{value:a,caret:Math.min(d(i,n),a.length)}}}function h(e){return(t,n)=>{let i=r(t),a=d(i,n),o=i.replace(/\D/g,``),s=l(o),c=+(o!==``&&o[0]!==`0`),f=u(s,e);return{value:f,caret:p(f,Math.min(a+c,s.length))}}}var g=/[\p{L}\p{M}\u200c ]/u;function _(e){return v(e,e.length).value}function v(e,t){let n=``,r=0,i=0;for(let a of e)g.test(a)&&!(a===` `&&n===``)&&(n+=a,i<t&&(r+=a.length)),i+=a.length;return{value:n,caret:r}}var y={normalize:e=>e,isFormatted:!1,isCentered:!1},b={text:y,search:y,username:{...y,isCentered:!0},name:{normalize:_,format:v,isFormatted:!1,isCentered:!1},password:{...y,isCentered:!0},number:{normalize:i,format:m(i),inputMode:`numeric`,isFormatted:!0,isCentered:!0},year:{normalize:e=>i(e).slice(0,4),format:m(e=>i(e).slice(0,4)),inputMode:`numeric`,maxLength:4,isFormatted:!0,isCentered:!0},money:{normalize:e=>o(a(i(e))),format:(e,t)=>{let n=r(e),i=d(n,t),s=n.replace(/\D/g,``),c=a(s),l=Math.min(s.length-c.length,i),u=o(c);return{value:u,caret:p(u,i-l)}},inputMode:`numeric`,isFormatted:!0,isCentered:!0},percent:{normalize:e=>s(i(e)),format:m(e=>s(i(e))),displayPrefix:`%`,inputMode:`numeric`,isFormatted:!0,isCentered:!0},decimal:{normalize:c,format:(e,t)=>{let n=r(e).replace(/٫/g,`.`),i=c(n);return{value:i,caret:Math.min(f(n,t),i.length)}},inputMode:`decimal`,isFormatted:!0,isCentered:!0},phone:{normalize:e=>u(l(i(e)),[4,3,4]),format:h([4,3,4]),inputMode:`numeric`,maxLength:13,isFormatted:!0,isCentered:!0},landline:{normalize:e=>u(l(i(e)),[3,4,4]),format:h([3,4,4]),inputMode:`numeric`,maxLength:13,isFormatted:!0,isCentered:!0}};function x(e){return b[e]??y}function S(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function C(e,t){return x(t).normalize(S(e))}function w(e,n,r){let i=x(n).displayPrefix,a=i&&e!==``?`${i}${e}`:e;return r?t.convertToPersianDigits({value:a}):a}function T(e,n,i,a,o){let s=x(e);if(!s.format){let e=i===null?null:[i,a??i];return{asciiValue:r(n),asciiSelection:e,displayValue:o?t.convertToPersianDigits({value:r(n)}):null,displaySelection:o?e:null}}let{value:c,caret:l}=s.format(n,i??r(n).length),u=l+(s.displayPrefix&&c!==``?s.displayPrefix.length:0);return{asciiValue:c,asciiSelection:[l,l],displayValue:o?w(c,e,!0):null,displaySelection:o?[u,u]:null}}exports.applyInputChange=T,exports.resolveAsciiValue=C,exports.resolveDisplayValue=w,exports.resolveInputTypeStrategy=x;
|
|
@@ -70,19 +70,37 @@ function h(e) {
|
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
var g = {
|
|
73
|
+
var g = /[\p{L}\p{M}\u200c ]/u;
|
|
74
|
+
function _(e) {
|
|
75
|
+
return v(e, e.length).value;
|
|
76
|
+
}
|
|
77
|
+
function v(e, t) {
|
|
78
|
+
let n = "", r = 0, i = 0;
|
|
79
|
+
for (let a of e) g.test(a) && !(a === " " && n === "") && (n += a, i < t && (r += a.length)), i += a.length;
|
|
80
|
+
return {
|
|
81
|
+
value: n,
|
|
82
|
+
caret: r
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
var y = {
|
|
74
86
|
normalize: (e) => e,
|
|
75
87
|
isFormatted: !1,
|
|
76
88
|
isCentered: !1
|
|
77
|
-
},
|
|
78
|
-
text:
|
|
79
|
-
search:
|
|
89
|
+
}, b = {
|
|
90
|
+
text: y,
|
|
91
|
+
search: y,
|
|
80
92
|
username: {
|
|
81
|
-
...
|
|
93
|
+
...y,
|
|
82
94
|
isCentered: !0
|
|
83
95
|
},
|
|
96
|
+
name: {
|
|
97
|
+
normalize: _,
|
|
98
|
+
format: v,
|
|
99
|
+
isFormatted: !1,
|
|
100
|
+
isCentered: !1
|
|
101
|
+
},
|
|
84
102
|
password: {
|
|
85
|
-
...
|
|
103
|
+
...y,
|
|
86
104
|
isCentered: !0
|
|
87
105
|
},
|
|
88
106
|
number: {
|
|
@@ -167,21 +185,21 @@ var g = {
|
|
|
167
185
|
isCentered: !0
|
|
168
186
|
}
|
|
169
187
|
};
|
|
170
|
-
function
|
|
171
|
-
return
|
|
188
|
+
function x(e) {
|
|
189
|
+
return b[e] ?? y;
|
|
172
190
|
}
|
|
173
|
-
function
|
|
191
|
+
function S(e) {
|
|
174
192
|
return e == null ? "" : Array.isArray(e) ? e.join(", ") : String(e);
|
|
175
193
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
194
|
+
function C(e, t) {
|
|
195
|
+
return x(t).normalize(S(e));
|
|
178
196
|
}
|
|
179
|
-
function
|
|
180
|
-
let i =
|
|
197
|
+
function w(e, n, r) {
|
|
198
|
+
let i = x(n).displayPrefix, a = i && e !== "" ? `${i}${e}` : e;
|
|
181
199
|
return r ? t({ value: a }) : a;
|
|
182
200
|
}
|
|
183
|
-
function
|
|
184
|
-
let s =
|
|
201
|
+
function T(e, n, i, a, o) {
|
|
202
|
+
let s = x(e);
|
|
185
203
|
if (!s.format) {
|
|
186
204
|
let e = i === null ? null : [i, a ?? i];
|
|
187
205
|
return {
|
|
@@ -195,9 +213,9 @@ function S(e, n, i, a, o) {
|
|
|
195
213
|
return {
|
|
196
214
|
asciiValue: c,
|
|
197
215
|
asciiSelection: [l, l],
|
|
198
|
-
displayValue: o ?
|
|
216
|
+
displayValue: o ? w(c, e, !0) : null,
|
|
199
217
|
displaySelection: o ? [u, u] : null
|
|
200
218
|
};
|
|
201
219
|
}
|
|
202
220
|
//#endregion
|
|
203
|
-
export {
|
|
221
|
+
export { T as applyInputChange, C as resolveAsciiValue, w as resolveDisplayValue, x as resolveInputTypeStrategy };
|
|
@@ -4,7 +4,11 @@ import { inputVariants } from "./Input.variant.cjs";
|
|
|
4
4
|
/** Native `<input>` attributes that are passed straight through to the input element. */
|
|
5
5
|
type InputNativeProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "title" | "value" | "defaultValue" | "children" | "dangerouslySetInnerHTML">;
|
|
6
6
|
export interface InputProps extends InputNativeProps, VariantProps<typeof inputVariants> {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Formats what is typed. `name` keeps only letters of any script, combining marks, spaces and
|
|
9
|
+
* the Persian half-space (digits and symbols are dropped).
|
|
10
|
+
*/
|
|
11
|
+
type?: "number" | "password" | "text" | "search" | "money" | "username" | "name" | "percent" | "decimal" | "year" | "phone" | "landline";
|
|
8
12
|
/** Label rendered above the input (not the native `title` tooltip). */
|
|
9
13
|
title?: string;
|
|
10
14
|
required?: boolean;
|
|
@@ -4,7 +4,11 @@ import { inputVariants } from "./Input.variant.js";
|
|
|
4
4
|
/** Native `<input>` attributes that are passed straight through to the input element. */
|
|
5
5
|
type InputNativeProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "title" | "value" | "defaultValue" | "children" | "dangerouslySetInnerHTML">;
|
|
6
6
|
export interface InputProps extends InputNativeProps, VariantProps<typeof inputVariants> {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Formats what is typed. `name` keeps only letters of any script, combining marks, spaces and
|
|
9
|
+
* the Persian half-space (digits and symbols are dropped).
|
|
10
|
+
*/
|
|
11
|
+
type?: "number" | "password" | "text" | "search" | "money" | "username" | "name" | "percent" | "decimal" | "year" | "phone" | "landline";
|
|
8
12
|
/** Label rendered above the input (not the native `title` tooltip). */
|
|
9
13
|
title?: string;
|
|
10
14
|
required?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),r=require(`../../services/localizeDigits/localizeDigits.cjs`),i=require(`../../lib/utils.cjs`),a=require(`../shared/FieldLabel.cjs`),o=require(`../shared/useInvalidState.cjs`),s=require(`../shared/useControllableState.cjs`),c=require(`../shared/RequiredValidationInput.cjs`),l=require(`./OtpInput.variant.cjs`);let u=require(`react`);u=e.__toESM(u,1);let d=require(`react/jsx-runtime`);var f=6;function p(e,t,r){let i=n.convertToEnglishDigits({value:e});return(t===`number`?i.replace(/\D/g,``):i.replace(/[^A-Za-z0-9]/g,``)).slice(0,r)}var m=u.forwardRef(function({length:e=f,type:n=`number`,value:m,defaultValue:h,onChange:g,onComplete:_,title:v,required:y=!1,showRequiredMessage:b=!1,mask:x=!1,disabled:S=!1,readOnly:C=!1,invalid:w=!1,autoFocus:T=!1,groupSize:E,name:D,form:O,id:k,"aria-label":ee,onInvalid:A,wrapperClassName:j,className:M,inputClassName:N},P){let{messages:F,digits:I,dir:L}=t.useZuiConfig(),R=Math.max(1,Math.floor(e)),z=u.useId(),B=k??z,V=`${B}-label`,H=u.useRef([]),{isInvalid:U,setIsInvalid:W,handleInvalid:G}=o.useInvalidState(A),[K,q]=s.useControllableState({value:m===void 0?void 0:p(m,n,R),defaultValue:()=>p(h??``,n,R),onChange:g}),J=u.useRef(K);J.current=K;let Y=u.useCallback(e=>{let t=H.current[Math.min(Math.max(e,0),R-1)];t?.focus(),t?.select()},[R]);u.useEffect(()=>{T&&!S&&!C&&Y(K.length)},[]);let X=(e,t)=>{W(!1),e!==K&&(J.current=e,q(e),e.length===R&&_?.(e)),Y(t)},Z=(e,t)=>{if(S||C)return;let r=t.target.value,i=K[e]??``;if(r===``){X(K.slice(0,e)+K.slice(e+1),e);return}let a=p(i!==``&&r.length>1&&r.replace(i,``)||r,n,R-e);a!==``&&X((K.slice(0,e)+a+K.slice(e+a.length)).slice(0,R),e+a.length)},Q=(e,t)=>{switch(t.key){case`Backspace`:!C&&!S&&(K[e]??``)===``&&e>0&&(t.preventDefault(),X(K.slice(0,e-1)+K.slice(e),e-1));break;case`Delete`:!C&&!S&&(t.preventDefault(),X(K.slice(0,e)+K.slice(e+1),e));break;case`ArrowLeft`:t.preventDefault(),Y(e-1);break;case`ArrowRight`:t.preventDefault(),Y(Math.min(e+1,K.length));break;case`Home`:t.preventDefault(),Y(0);break;case`End`:t.preventDefault(),Y(K.length);break;default:break}},te=(e,t)=>{if(e>J.current.length){Y(J.current.length);return}t.target.select()},ne=w||U,re=r.localizeDigits(String(R),I),$=[];for(let e=0;e<R;e+=1){let t=K[e]??``,a=r.localizeDigits(String(e+1),I);$.push((0,d.jsxs)(`div`,{"data-slot":`otp-input-cell`,className:l.otpInputCellVariants(),children:[(0,d.jsx)(`input`,{ref:t=>{H.current[e]=t},id:e===0?B:`${B}-${e+1}`,"data-slot":`otp-input-box`,type:x?`password`:`text`,inputMode:n===`number`?`numeric`:`text`,autoComplete:e===0?`one-time-code`:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":F.otp.digitLabel(a,re),"aria-invalid":ne||void 0,"data-has-value":t!==``,disabled:S,readOnly:C,value:r.localizeDigits(t,I),onChange:t=>Z(e,t),onKeyDown:t=>Q(e,t),onFocus:t=>te(e,t),className:i.cn(l.otpInputBoxVariants(),N)}),t===``?null:(0,d.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`otp-input-digit`,className:l.otpInputDigitVariants(),children:x?`•`:r.localizeDigits(t,I)},t)]},e)),E&&E>0&&(e+1)%E===0&&e+1<R&&$.push((0,d.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`otp-input-separator`,className:l.otpInputSeparatorVariants()},`separator-${e}`))}return(0,d.jsxs)(`div`,{ref:P,"data-slot":`otp-input`,dir:L,className:i.cn(`zui:relative zui:w-full zui:space-y-1.5 zui:text-start`,j),children:[(0,d.jsx)(a.FieldLabel,{id:V,title:v,required:y,showRequiredMessage:b}),(0,d.jsx)(`div`,{role:`group`,"aria-label":v?void 0:ee,"aria-labelledby":v?V:void 0,dir:`ltr`,className:i.cn(l.otpInputRowVariants(),M),children:$}),D?(0,d.jsx)(`input`,{type:`hidden`,name:D,form:O,value:K,disabled:S}):null,y?(0,d.jsx)(c.default,{"data-slot":`otp-input-required`,hasValue:K.length===R,disabled:S,form:O,onInvalid:G}):null]})});exports.default=m;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { OtpInputProps } from "./OtpInput.interface.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A one-time code (SMS / e-mail verification) typed into one box per character. The code is one
|
|
5
|
+
* contiguous string: typing fills the next box, Backspace removes the previous character, and a
|
|
6
|
+
* paste or an autofilled code is spread over the boxes. The boxes always read left to right, like
|
|
7
|
+
* the digits of the code.
|
|
8
|
+
*/
|
|
9
|
+
declare const OtpInput: React.ForwardRefExoticComponent<OtpInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default OtpInput;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { OtpInputProps } from "./OtpInput.interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* A one-time code (SMS / e-mail verification) typed into one box per character. The code is one
|
|
5
|
+
* contiguous string: typing fills the next box, Backspace removes the previous character, and a
|
|
6
|
+
* paste or an autofilled code is spread over the boxes. The boxes always read left to right, like
|
|
7
|
+
* the digits of the code.
|
|
8
|
+
*/
|
|
9
|
+
declare const OtpInput: React.ForwardRefExoticComponent<OtpInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export default OtpInput;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export interface OtpInputProps {
|
|
3
|
+
/** Number of boxes. @default 6 */
|
|
4
|
+
length?: number;
|
|
5
|
+
/**
|
|
6
|
+
* What the boxes accept: `number` takes digits only (Persian and Arabic digits are converted),
|
|
7
|
+
* `text` takes letters and digits.
|
|
8
|
+
* @default "number"
|
|
9
|
+
*/
|
|
10
|
+
type?: "number" | "text";
|
|
11
|
+
/** The code typed so far, as ASCII. Without it the component keeps the code itself. */
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
/** Called on every edit with the code typed so far (fewer characters than `length` until full). */
|
|
15
|
+
onChange?: (value: string) => void;
|
|
16
|
+
/** Called once, with the whole code, when the last box gets filled. */
|
|
17
|
+
onComplete?: (value: string) => void;
|
|
18
|
+
/** Label rendered above the boxes. */
|
|
19
|
+
title?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* When true and `required` is true, shows a "این فیلد اجباری است" hint next to the required star.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
showRequiredMessage?: boolean;
|
|
26
|
+
/** Shows the characters as dots, like a password. */
|
|
27
|
+
mask?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
/** Marks the boxes as wrong (for example after the server rejected the code). */
|
|
31
|
+
invalid?: boolean;
|
|
32
|
+
/** Focuses the first empty box when the component mounts. */
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
/** Draws a small dash after every `groupSize` boxes (for example 3 for `123-456`). */
|
|
35
|
+
groupSize?: number;
|
|
36
|
+
/** Name of the hidden field that carries the whole code in a native `<form>`. */
|
|
37
|
+
name?: string;
|
|
38
|
+
form?: string;
|
|
39
|
+
id?: string;
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
/** Called when a native `<form>` rejects an incomplete `required` code. */
|
|
42
|
+
onInvalid?: React.FormEventHandler<HTMLInputElement>;
|
|
43
|
+
/** Applied to the outer field wrapper (label + boxes). */
|
|
44
|
+
wrapperClassName?: string;
|
|
45
|
+
/** Applied to the row of boxes. */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** Applied to every box. */
|
|
48
|
+
inputClassName?: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export interface OtpInputProps {
|
|
3
|
+
/** Number of boxes. @default 6 */
|
|
4
|
+
length?: number;
|
|
5
|
+
/**
|
|
6
|
+
* What the boxes accept: `number` takes digits only (Persian and Arabic digits are converted),
|
|
7
|
+
* `text` takes letters and digits.
|
|
8
|
+
* @default "number"
|
|
9
|
+
*/
|
|
10
|
+
type?: "number" | "text";
|
|
11
|
+
/** The code typed so far, as ASCII. Without it the component keeps the code itself. */
|
|
12
|
+
value?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
/** Called on every edit with the code typed so far (fewer characters than `length` until full). */
|
|
15
|
+
onChange?: (value: string) => void;
|
|
16
|
+
/** Called once, with the whole code, when the last box gets filled. */
|
|
17
|
+
onComplete?: (value: string) => void;
|
|
18
|
+
/** Label rendered above the boxes. */
|
|
19
|
+
title?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* When true and `required` is true, shows a "این فیلد اجباری است" hint next to the required star.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
showRequiredMessage?: boolean;
|
|
26
|
+
/** Shows the characters as dots, like a password. */
|
|
27
|
+
mask?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
/** Marks the boxes as wrong (for example after the server rejected the code). */
|
|
31
|
+
invalid?: boolean;
|
|
32
|
+
/** Focuses the first empty box when the component mounts. */
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
/** Draws a small dash after every `groupSize` boxes (for example 3 for `123-456`). */
|
|
35
|
+
groupSize?: number;
|
|
36
|
+
/** Name of the hidden field that carries the whole code in a native `<form>`. */
|
|
37
|
+
name?: string;
|
|
38
|
+
form?: string;
|
|
39
|
+
id?: string;
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
/** Called when a native `<form>` rejects an incomplete `required` code. */
|
|
42
|
+
onInvalid?: React.FormEventHandler<HTMLInputElement>;
|
|
43
|
+
/** Applied to the outer field wrapper (label + boxes). */
|
|
44
|
+
wrapperClassName?: string;
|
|
45
|
+
/** Applied to the row of boxes. */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** Applied to every box. */
|
|
48
|
+
inputClassName?: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useZuiConfig as e } from "../../config/useZuiConfig.js";
|
|
3
|
+
import { convertToEnglishDigits as t } from "../../services/convertToEnglishDigits/convertToEnglishDigits.js";
|
|
4
|
+
import { localizeDigits as n } from "../../services/localizeDigits/localizeDigits.js";
|
|
5
|
+
import { cn as r } from "../../lib/utils.js";
|
|
6
|
+
import { FieldLabel as i } from "../shared/FieldLabel.js";
|
|
7
|
+
import { useInvalidState as a } from "../shared/useInvalidState.js";
|
|
8
|
+
import { useControllableState as o } from "../shared/useControllableState.js";
|
|
9
|
+
import s from "../shared/RequiredValidationInput.js";
|
|
10
|
+
import { otpInputBoxVariants as c, otpInputCellVariants as l, otpInputDigitVariants as u, otpInputRowVariants as ee, otpInputSeparatorVariants as d } from "./OtpInput.variant.js";
|
|
11
|
+
import * as f from "react";
|
|
12
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/OtpInput/OtpInput.tsx
|
|
14
|
+
var h = 6;
|
|
15
|
+
function g(e, n, r) {
|
|
16
|
+
let i = t({ value: e });
|
|
17
|
+
return (n === "number" ? i.replace(/\D/g, "") : i.replace(/[^A-Za-z0-9]/g, "")).slice(0, r);
|
|
18
|
+
}
|
|
19
|
+
var _ = f.forwardRef(function({ length: t = h, type: _ = "number", value: v, defaultValue: y, onChange: b, onComplete: x, title: S, required: C = !1, showRequiredMessage: te = !1, mask: w = !1, disabled: T = !1, readOnly: E = !1, invalid: ne = !1, autoFocus: re = !1, groupSize: D, name: O, form: k, id: A, "aria-label": j, onInvalid: M, wrapperClassName: N, className: P, inputClassName: F }, I) {
|
|
20
|
+
let { messages: L, digits: R, dir: z } = e(), B = Math.max(1, Math.floor(t)), V = f.useId(), H = A ?? V, U = `${H}-label`, W = f.useRef([]), { isInvalid: G, setIsInvalid: K, handleInvalid: q } = a(M), [J, Y] = o({
|
|
21
|
+
value: v === void 0 ? void 0 : g(v, _, B),
|
|
22
|
+
defaultValue: () => g(y ?? "", _, B),
|
|
23
|
+
onChange: b
|
|
24
|
+
}), X = f.useRef(J);
|
|
25
|
+
X.current = J;
|
|
26
|
+
let Z = f.useCallback((e) => {
|
|
27
|
+
let t = W.current[Math.min(Math.max(e, 0), B - 1)];
|
|
28
|
+
t?.focus(), t?.select();
|
|
29
|
+
}, [B]);
|
|
30
|
+
f.useEffect(() => {
|
|
31
|
+
re && !T && !E && Z(J.length);
|
|
32
|
+
}, []);
|
|
33
|
+
let Q = (e, t) => {
|
|
34
|
+
K(!1), e !== J && (X.current = e, Y(e), e.length === B && x?.(e)), Z(t);
|
|
35
|
+
}, ie = (e, t) => {
|
|
36
|
+
if (T || E) return;
|
|
37
|
+
let n = t.target.value, r = J[e] ?? "";
|
|
38
|
+
if (n === "") {
|
|
39
|
+
Q(J.slice(0, e) + J.slice(e + 1), e);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let i = g(r !== "" && n.length > 1 && n.replace(r, "") || n, _, B - e);
|
|
43
|
+
i !== "" && Q((J.slice(0, e) + i + J.slice(e + i.length)).slice(0, B), e + i.length);
|
|
44
|
+
}, ae = (e, t) => {
|
|
45
|
+
switch (t.key) {
|
|
46
|
+
case "Backspace":
|
|
47
|
+
!E && !T && (J[e] ?? "") === "" && e > 0 && (t.preventDefault(), Q(J.slice(0, e - 1) + J.slice(e), e - 1));
|
|
48
|
+
break;
|
|
49
|
+
case "Delete":
|
|
50
|
+
!E && !T && (t.preventDefault(), Q(J.slice(0, e) + J.slice(e + 1), e));
|
|
51
|
+
break;
|
|
52
|
+
case "ArrowLeft":
|
|
53
|
+
t.preventDefault(), Z(e - 1);
|
|
54
|
+
break;
|
|
55
|
+
case "ArrowRight":
|
|
56
|
+
t.preventDefault(), Z(Math.min(e + 1, J.length));
|
|
57
|
+
break;
|
|
58
|
+
case "Home":
|
|
59
|
+
t.preventDefault(), Z(0);
|
|
60
|
+
break;
|
|
61
|
+
case "End":
|
|
62
|
+
t.preventDefault(), Z(J.length);
|
|
63
|
+
break;
|
|
64
|
+
default: break;
|
|
65
|
+
}
|
|
66
|
+
}, oe = (e, t) => {
|
|
67
|
+
if (e > X.current.length) {
|
|
68
|
+
Z(X.current.length);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
t.target.select();
|
|
72
|
+
}, se = ne || G, ce = n(String(B), R), $ = [];
|
|
73
|
+
for (let e = 0; e < B; e += 1) {
|
|
74
|
+
let t = J[e] ?? "", i = n(String(e + 1), R);
|
|
75
|
+
$.push(/* @__PURE__ */ m("div", {
|
|
76
|
+
"data-slot": "otp-input-cell",
|
|
77
|
+
className: l(),
|
|
78
|
+
children: [/* @__PURE__ */ p("input", {
|
|
79
|
+
ref: (t) => {
|
|
80
|
+
W.current[e] = t;
|
|
81
|
+
},
|
|
82
|
+
id: e === 0 ? H : `${H}-${e + 1}`,
|
|
83
|
+
"data-slot": "otp-input-box",
|
|
84
|
+
type: w ? "password" : "text",
|
|
85
|
+
inputMode: _ === "number" ? "numeric" : "text",
|
|
86
|
+
autoComplete: e === 0 ? "one-time-code" : "off",
|
|
87
|
+
autoCapitalize: "off",
|
|
88
|
+
autoCorrect: "off",
|
|
89
|
+
spellCheck: !1,
|
|
90
|
+
"aria-label": L.otp.digitLabel(i, ce),
|
|
91
|
+
"aria-invalid": se || void 0,
|
|
92
|
+
"data-has-value": t !== "",
|
|
93
|
+
disabled: T,
|
|
94
|
+
readOnly: E,
|
|
95
|
+
value: n(t, R),
|
|
96
|
+
onChange: (t) => ie(e, t),
|
|
97
|
+
onKeyDown: (t) => ae(e, t),
|
|
98
|
+
onFocus: (t) => oe(e, t),
|
|
99
|
+
className: r(c(), F)
|
|
100
|
+
}), t === "" ? null : /* @__PURE__ */ p("span", {
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
"data-slot": "otp-input-digit",
|
|
103
|
+
className: u(),
|
|
104
|
+
children: w ? "•" : n(t, R)
|
|
105
|
+
}, t)]
|
|
106
|
+
}, e)), D && D > 0 && (e + 1) % D === 0 && e + 1 < B && $.push(/* @__PURE__ */ p("span", {
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
"data-slot": "otp-input-separator",
|
|
109
|
+
className: d()
|
|
110
|
+
}, `separator-${e}`));
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */ m("div", {
|
|
113
|
+
ref: I,
|
|
114
|
+
"data-slot": "otp-input",
|
|
115
|
+
dir: z,
|
|
116
|
+
className: r("zui:relative zui:w-full zui:space-y-1.5 zui:text-start", N),
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ p(i, {
|
|
119
|
+
id: U,
|
|
120
|
+
title: S,
|
|
121
|
+
required: C,
|
|
122
|
+
showRequiredMessage: te
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ p("div", {
|
|
125
|
+
role: "group",
|
|
126
|
+
"aria-label": S ? void 0 : j,
|
|
127
|
+
"aria-labelledby": S ? U : void 0,
|
|
128
|
+
dir: "ltr",
|
|
129
|
+
className: r(ee(), P),
|
|
130
|
+
children: $
|
|
131
|
+
}),
|
|
132
|
+
O ? /* @__PURE__ */ p("input", {
|
|
133
|
+
type: "hidden",
|
|
134
|
+
name: O,
|
|
135
|
+
form: k,
|
|
136
|
+
value: J,
|
|
137
|
+
disabled: T
|
|
138
|
+
}) : null,
|
|
139
|
+
C ? /* @__PURE__ */ p(s, {
|
|
140
|
+
"data-slot": "otp-input-required",
|
|
141
|
+
hasValue: J.length === B,
|
|
142
|
+
disabled: T,
|
|
143
|
+
form: k,
|
|
144
|
+
onInvalid: q
|
|
145
|
+
}) : null
|
|
146
|
+
]
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
//#endregion
|
|
150
|
+
export { _ as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../shared/responsiveScale.cjs`),t=require(`../shared/fieldStyles.cjs`);let n=require(`class-variance-authority`);var r=(0,n.cva)(`zui:relative ${e.CONTROL_HEIGHT_LG} zui:min-w-0 zui:max-w-[calc(var(--zui-scale,10px)*5.76)] zui:flex-1`),i=(0,n.cva)([`zui:size-full zui-radius-xs zui:border zui:border-[var(--zui-color-border)] zui:bg-transparent zui:p-0 zui:text-center zui:text-lg zui:mobile:text-[max(var(--zui-text-lg),16px)] zui:font-medium zui:text-transparent zui:caret-[var(--zui-color-text)] zui:outline-none`,`zui:selection:bg-transparent zui:selection:text-transparent`,`zui:mobile:rounded-none! zui:mobile:border-x-0 zui:mobile:border-t-0 zui:mobile:border-b-2 zui:mobile:focus:shadow-none! zui:mobile:focus-visible:shadow-none! zui:mobile:aria-invalid:focus:shadow-none! zui:mobile:aria-invalid:focus-visible:shadow-none!`,`zui:data-[has-value=true]:border-[var(--zui-theme-action-primary)]`,`zui:[&:not(:focus):not(:focus-visible):not([aria-invalid=true]):not([data-has-value=true])]:border-[var(--zui-color-border)]`,`zui:disabled:pointer-events-none zui:disabled:cursor-not-allowed zui:disabled:bg-[var(--zui-color-muted-surface)] zui:disabled:opacity-50`,t.fieldInteractionClassName].join(` `)),a=(0,n.cva)(`zui:pointer-events-none zui:absolute zui:inset-0 zui:flex zui:items-center zui:justify-center zui:text-lg zui:mobile:text-[max(var(--zui-text-lg),16px)] zui:font-medium zui:text-[var(--zui-color-text)] zui:animate-[zui-otp-digit-in_520ms_cubic-bezier(0.22,0.9,0.3,1)]`),o=(0,n.cva)(`zui:flex zui:w-full zui:items-center zui:justify-center zui:gap-2`),s=(0,n.cva)(`zui:h-px zui:w-2 zui:shrink-0 zui:bg-[var(--zui-theme-text-muted)]`);exports.otpInputBoxVariants=i,exports.otpInputCellVariants=r,exports.otpInputDigitVariants=a,exports.otpInputRowVariants=o,exports.otpInputSeparatorVariants=s;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const otpInputCellVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
declare const otpInputBoxVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
declare const otpInputDigitVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
declare const otpInputRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
declare const otpInputSeparatorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
6
|
+
export { otpInputBoxVariants, otpInputCellVariants, otpInputDigitVariants, otpInputRowVariants, otpInputSeparatorVariants, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const otpInputCellVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
|
+
declare const otpInputBoxVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
|
+
declare const otpInputDigitVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
4
|
+
declare const otpInputRowVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
5
|
+
declare const otpInputSeparatorVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
6
|
+
export { otpInputBoxVariants, otpInputCellVariants, otpInputDigitVariants, otpInputRowVariants, otpInputSeparatorVariants, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CONTROL_HEIGHT_LG as e } from "../shared/responsiveScale.js";
|
|
2
|
+
import { fieldInteractionClassName as t } from "../shared/fieldStyles.js";
|
|
3
|
+
import { cva as n } from "class-variance-authority";
|
|
4
|
+
//#region src/components/OtpInput/OtpInput.variant.ts
|
|
5
|
+
var r = n(`zui:relative ${e} zui:min-w-0 zui:max-w-[calc(var(--zui-scale,10px)*5.76)] zui:flex-1`), i = n([
|
|
6
|
+
"zui:size-full zui-radius-xs zui:border zui:border-[var(--zui-color-border)] zui:bg-transparent zui:p-0 zui:text-center zui:text-lg zui:mobile:text-[max(var(--zui-text-lg),16px)] zui:font-medium zui:text-transparent zui:caret-[var(--zui-color-text)] zui:outline-none",
|
|
7
|
+
"zui:selection:bg-transparent zui:selection:text-transparent",
|
|
8
|
+
"zui:mobile:rounded-none! zui:mobile:border-x-0 zui:mobile:border-t-0 zui:mobile:border-b-2 zui:mobile:focus:shadow-none! zui:mobile:focus-visible:shadow-none! zui:mobile:aria-invalid:focus:shadow-none! zui:mobile:aria-invalid:focus-visible:shadow-none!",
|
|
9
|
+
"zui:data-[has-value=true]:border-[var(--zui-theme-action-primary)]",
|
|
10
|
+
"zui:[&:not(:focus):not(:focus-visible):not([aria-invalid=true]):not([data-has-value=true])]:border-[var(--zui-color-border)]",
|
|
11
|
+
"zui:disabled:pointer-events-none zui:disabled:cursor-not-allowed zui:disabled:bg-[var(--zui-color-muted-surface)] zui:disabled:opacity-50",
|
|
12
|
+
t
|
|
13
|
+
].join(" ")), a = n("zui:pointer-events-none zui:absolute zui:inset-0 zui:flex zui:items-center zui:justify-center zui:text-lg zui:mobile:text-[max(var(--zui-text-lg),16px)] zui:font-medium zui:text-[var(--zui-color-text)] zui:animate-[zui-otp-digit-in_520ms_cubic-bezier(0.22,0.9,0.3,1)]"), o = n("zui:flex zui:w-full zui:items-center zui:justify-center zui:gap-2"), s = n("zui:h-px zui:w-2 zui:shrink-0 zui:bg-[var(--zui-theme-text-muted)]");
|
|
14
|
+
//#endregion
|
|
15
|
+
export { i as otpInputBoxVariants, r as otpInputCellVariants, a as otpInputDigitVariants, o as otpInputRowVariants, s as otpInputSeparatorVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),r=require(`../../services/localizeDigits/localizeDigits.cjs`),i=require(`../../lib/utils.cjs`),a=require(`../Button/Button.cjs`),o=require(`../Dialog/Dialog.cjs`),s=require(`../shared/FieldClearButton.cjs`),c=require(`../shared/FieldLabel.cjs`),l=require(`../shared/useInvalidState.cjs`),u=require(`../Input/Input.cjs`),d=require(`../shared/IconActionButton.cjs`),f=require(`../shared/useControllableState.cjs`),p=require(`../shared/viewport.cjs`),ee=require(`../shared/useIsomorphicLayoutEffect.cjs`),m=require(`../shared/RequiredValidationInput.cjs`),h=require(`../Skeleton/Skeleton.cjs`),g=require(`../Tabs/Tabs.cjs`),_=require(`./Select.variant.cjs`);let v=require(`react`);v=e.__toESM(v,1);let y=require(`react/jsx-runtime`),b=require(`lucide-react`),x=require(`@radix-ui/react-popover`);x=e.__toESM(x,1);var te=`__zui-ungrouped__`,ne=40,re=24,ie=.3,ae=1,S=20,oe=350,se=48,C=3,ce=`zui:size-[calc(var(--zui-scale,10px)*1.92)]`,le=v.createContext(null);function ue(e,t){return`${e}-option-${t}`}function de(e){return typeof e==`string`&&e.length>0}function w(e){if(!Array.isArray(e))return[];let t=new Set;return e.forEach(e=>{typeof e==`string`&&e.trim().length>0&&t.add(e.trim())}),Array.from(t)}function T(e,t){return`${t??``}\u0000${e}`}function fe(e){if(!Array.isArray(e))return[];let t=[],n=new Set;return e.forEach(e=>{if(!e||typeof e!=`object`)return;let r=e,i=typeof r.value==`string`?r.value.trim():``,a=typeof r.group==`string`&&r.group.trim().length>0?r.group.trim():void 0,o=T(i,a);if(i.length===0||n.has(o))return;let s=typeof r.label==`string`&&r.label.trim().length>0?r.label.trim():i;n.add(o),t.push({value:i,label:s,disabled:r.disabled===!0,group:a})}),t}function pe(e,t){if(t.length===0)return e;let n=new Map;return e.forEach(e=>{n.set(T(e.value,e.group),e)}),t.forEach(e=>{n.set(T(e.value,e.group),e)}),Array.from(n.values())}function E(e){let t=[],n=new Map;return e.forEach(e=>{if(e.group===void 0){t.push(e);return}let r=n.get(e.group);if(r){r.push(e);return}let i=[e];n.set(e.group,i),t.push(i)}),t.flat()}function D(e,t){return n.convertToEnglishDigits({value:(e.length>0?e:t).toLocaleLowerCase()})}function me(e){return{value:e.value,label:e.label,searchText:D(e.label.trim(),e.value),disabled:e.disabled===!0,group:e.group}}function he(e){if(typeof e!=`number`||!Number.isFinite(e))return S;let t=Math.floor(e);return t>0?t:S}function ge(e,t,n,r){return typeof e.hasMore==`boolean`?e.hasMore:typeof e.totalItems==`number`&&Number.isFinite(e.totalItems)?t<Math.max(0,Math.floor(e.totalItems)):typeof e.nextPage==`number`?Number.isFinite(e.nextPage)&&e.nextPage>0:n>=r}function O(e,t){return typeof e.nextPage==`number`&&Number.isFinite(e.nextPage)&&e.nextPage>t?Math.floor(e.nextPage):t+1}function _e(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:t}function ve(){return(0,y.jsx)(`div`,{"data-slot":`select-loading`,className:`zui:space-y-1 zui:px-2 zui:py-2`,children:Array.from({length:C},(e,t)=>(0,y.jsx)(h.default,{className:i.cn(`zui:h-5 zui:max-w-full`,t===0?`zui:w-[88%]`:t===1?`zui:w-[72%]`:`zui:w-[80%]`)},`select-loading-${t}`))})}function k(e,t){return typeof e==`string`?r.localizeDigits(e,t):typeof e==`number`?r.localizeDigits(String(e),t):Array.isArray(e)?e.map((e,n)=>(0,y.jsx)(v.Fragment,{children:k(e,t)},n)):v.isValidElement(e)?!(`children`in e.props)||e.props.children===void 0?e:v.cloneElement(e,void 0,k(e.props.children,t)):e}function A(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(A).join(` `):v.isValidElement(e)?A(e.props.children):``}function j(e){return null}function M(e){return null}function N(e){return null}function P(){return null}function ye(e){let t=[],n=new Set,r=!1,i=(e,a)=>{v.Children.forEach(e,e=>{if(v.isValidElement(e)){if(e.type===P){r=t.length>0;return}if(e.type===j){let i=e.props,o=typeof i.value==`string`?i.value.trim():``,s=T(o,a);if(o.length===0||n.has(s))return;n.add(s),t.push({value:o,label:i.children,searchText:D(A(i.children).trim(),o),disabled:i.disabled===!0,group:a,separatorBefore:r,className:i.className}),r=!1;return}if(e.type===M){let t=e.props.children,n;v.Children.forEach(t,e=>{if(v.isValidElement(e)&&e.type===N){let t=A(e.props.children).trim();n=t.length>0?t:void 0}}),i(t,n??a);return}`children`in e.props&&i(e.props.children,a)}})};return i(e),t}function F(e){let{messages:n,dir:r}=t.useZuiConfig(),{type:a=`single`,title:o,required:s=!1,showRequiredMessage:u=!1,placeholder:d,options:ee,remoteOptions:h,isSearch:g=!1,disabled:_=!1,disable:b=!1,onInvalid:te,onOpenChange:ne,open:re,defaultOpen:ie,id:ae,name:S,form:oe,children:se,selectAllLabel:C,selectedCountLabel:ce,multiValueSubmitFormat:ue=`separate`,onValueChange:T,onChange:pe}=e,E=v.useCallback(e=>{T?.(e),pe?.(e)},[pe,T]),D=v.useId(),me=ae??D,he=`${me}-listbox`,ge=_||b,O=a===`multi`,_e=v.useRef(null),ve=v.useRef(null),k=v.useRef(null),A=v.useCallback(e=>{k.current?.(e)},[]),j=v.useCallback(e=>{k.current=e},[]),[M,N]=v.useState(``),[P,F]=v.useState(-1),{isInvalid:be,setIsInvalid:z,handleInvalid:B}=l.useInvalidState(te),[V,xe,Se]=f.useControllableState({value:!O&&typeof e.value==`string`?e.value:void 0,defaultValue:!O&&typeof e.defaultValue==`string`?e.defaultValue:void 0}),Ce=O&&Array.isArray(e.value)?e.value:void 0,[H,we]=f.useControllableState({value:v.useMemo(()=>Ce?w(Ce):void 0,[Ce]),defaultValue:()=>w(e.defaultValue)}),[U,W]=f.useControllableState({value:re,defaultValue:!!ie,onChange:ne}),[Te,Ee]=v.useState(null),De=v.useCallback(e=>{Ee(e?p.isMobileViewport():null),W(e)},[W]),Oe=U&&(Te??p.isMobileViewport()),ke=v.useMemo(()=>fe(ee),[ee]),G=v.useMemo(()=>ye(se),[se]),Ae=g?M:``,K=O?H.length>0:de(V),je=be&&!K,[q,J]=v.useState(()=>({isOpen:U,values:w(e.defaultValue)}));if(q.isOpen!==U){let e=O?H:de(V)?[V]:[];J({isOpen:U,values:U?e:q.values}),F(-1),U||N(``)}let Me=v.useMemo(()=>!O||H.length===0?``:typeof ce==`function`?ce(H.length):n.select.selectedCount(String(H.length)),[O,n,H.length,ce]),Y=v.useCallback(e=>{N(e),F(-1)},[]),Ne=v.useCallback(e=>{xe(e),z(!1),E(e)},[E,z,xe]),Pe=v.useCallback(()=>{O||(xe(Se?``:void 0),E(``))},[E,O,Se,xe]),Fe=v.useCallback(e=>{let t=w(e);we(t),z(!1),E(t)},[E,z,we]),Ie=v.Children.toArray(se),Le=Ie.some(e=>v.isValidElement(e)&&e.type===R),X=h?.enabled!==!1&&h,Z=!Le&&(ke.length>0||X)?[...Ie,(0,y.jsx)(R,{},`select-generated-content`)]:se,Re=v.Children.toArray(Z).some(e=>v.isValidElement(e)&&e.type===I),ze=v.Children.map(Z,e=>{if(!v.isValidElement(e))return e;if(e.type===I){let t=e.props;return v.cloneElement(e,{id:t.id??me,disabled:t.disabled??ge,className:i.cn(`zui:text-start`,t.className)})}if(e.type===R){let t=e.props;return v.cloneElement(e,{className:i.cn(`zui:text-start`,t.className)})}return e}),Be=v.useMemo(()=>({listboxId:he,isSearch:g,searchTerm:Ae,setSearchTerm:Y,hasValue:K,isInvalid:je,selectType:a,isOpen:U,setOpen:De,isModal:Oe,modalLabel:o??d,isDisabled:ge,activeIndex:P,setActiveIndex:F,singleSelectedValue:V,setSingleSelectedValue:Ne,clearSingleSelection:Pe,multiSelectedValues:H,pinnedSelectedValues:q.values,setMultiSelectedValues:Fe,multiSelectAllLabel:C??n.select.selectAll,multiSelectedCountText:Me,options:ke,childOptions:G,remoteOptions:h,contentRef:ve,fieldRootRef:_e,onListKeyDown:A,registerListKeyDown:j}),[P,G,Pe,Fe,Ne,K,ge,g,Oe,je,he,n,d,o,Me,ke,A,q.values,j,h,H,U,V,Ae,C,a,De,Y]);return(0,y.jsxs)(`div`,{ref:_e,"data-slot":`select-field`,dir:r,className:`zui:relative zui:w-full zui:space-y-1.5 zui:text-start`,children:[(0,y.jsx)(c.FieldLabel,{title:o,htmlFor:me,required:s,showRequiredMessage:u}),(0,y.jsxs)(le.Provider,{value:Be,children:[(0,y.jsx)(x.Root,{open:U&&!Oe,onOpenChange:De,children:(0,y.jsx)(x.Anchor,{asChild:!0,children:(0,y.jsxs)(`div`,{"data-slot":`select`,dir:r,className:`zui:relative`,children:[Re?ze:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(I,{id:me,children:(0,y.jsx)(L,{placeholder:d})}),ze]}),S?O&&ue===`separate`?H.map(e=>(0,y.jsx)(`input`,{type:`hidden`,name:S,form:oe,value:e},e)):(0,y.jsx)(`input`,{type:`hidden`,name:S,form:oe,value:O?H.join(`,`):V??``}):null]})})}),s?(0,y.jsx)(m.default,{hasValue:K,form:oe,disabled:ge,onInvalid:B}):null]})]})}var I=v.forwardRef(function({className:e,children:n,onClick:r,onKeyDown:a,disabled:o,...c},l){let u=v.useContext(le),{messages:d,dir:f}=t.useZuiConfig(),p=u?.hasValue??!1,ee=u?.isInvalid??!1,m=u?.isOpen??!1,h=u?.selectType===`multi`,g=o||(u?.isDisabled??!1),x=u?.activeIndex??-1,te=!h&&p&&!g&&!!u;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{ref:l,type:`button`,"data-slot":`select-trigger`,"data-has-value":p,"data-state":m?`open`:`closed`,dir:f,"aria-expanded":m,"aria-haspopup":`listbox`,"aria-controls":m&&u?u.listboxId:void 0,"aria-activedescendant":m&&u&&x>=0?ue(u.listboxId,x):void 0,"aria-invalid":ee||void 0,disabled:g,className:i.cn(_.selectTriggerVariants({className:e}),`zui:text-start`),onClick:e=>{r?.(e),!(e.defaultPrevented||g||!u)&&u.setOpen(!m)},onKeyDown:e=>{a?.(e),e.defaultPrevented||u?.onListKeyDown(e)},...c,children:[n,te?(0,y.jsx)(s.FieldClearButtonSlot,{}):null,(0,y.jsx)(b.ChevronDown,{className:i.cn(s.CLEAR_ICON_CLASS,`zui:shrink-0 zui:text-[var(--zui-color-text)] zui:transition-transform zui:duration-200`,m?`zui:rotate-180`:`zui:rotate-0`)})]}),te?(0,y.jsx)(s.FieldClearButton,{"data-slot":`select-clear-button`,label:d.select.clearSelection,onClear:()=>u?.clearSingleSelection()}):null]})});function L({className:e,placeholder:n,children:r,...a}){let o=v.useContext(le),{digits:s}=t.useZuiConfig();if(o?.selectType===`multi`){let t=r??(o.hasValue?o.multiSelectedCountText:n);return(0,y.jsx)(`span`,{"data-slot":`select-value`,"data-placeholder":o.hasValue?void 0:!0,className:i.cn(`zui:block zui:max-w-full zui:truncate zui:text-start zui:text-[var(--zui-color-text)]`,!o.hasValue&&`zui:text-[var(--zui-theme-text-muted)] zui:mobile:text-sm`,e),...a,children:k(t,s)})}let c=o?.options.find(e=>e.value===o.singleSelectedValue)??o?.childOptions.find(e=>e.value===o.singleSelectedValue);return c?(0,y.jsx)(`span`,{"data-slot":`select-value`,className:i.cn(`zui:block zui:min-w-0 zui:flex-1 zui:truncate zui:text-start zui:text-[var(--zui-color-text)]`,e),...a,children:k(r??c.label,s)}):(0,y.jsx)(`span`,{"data-slot":`select-value`,"data-placeholder":``,className:i.cn(`zui:block zui:min-w-0 zui:flex-1 zui:truncate zui:text-start zui:text-[var(--zui-theme-text-muted)] zui:mobile:text-sm`,e),...a,children:n})}var R=v.forwardRef(function({className:e,children:r},s){let c=v.useContext(le),{messages:l,digits:f,dir:p}=t.useZuiConfig(),m=c?.selectType===`multi`,h=c?.isSearch??!1,S=c?.searchTerm??``,C=c?.isOpen??!1,w=c?.activeIndex??-1,D=c?.listboxId??``,A=v.useRef(null),j=v.useRef(null),M=v.useRef(null),N=c?.singleSelectedValue,P=c?.multiSelectedValues,F=c?.pinnedSelectedValues,I=c?.options,L=v.useMemo(()=>m?P??[]:de(N)?[N]:[],[m,P,N]),R=v.useMemo(()=>F??[],[F]),be=v.useMemo(()=>I??[],[I]),z=c?.remoteOptions,B=typeof z?.loadOptions==`function`&&z.enabled!==!1,V=he(z?.pageSize),xe=z?.cacheKey,Se=z?.loadOptions,Ce=v.useRef(Se);ee.useIsomorphicLayoutEffect(()=>{Ce.current=Se});let H=v.useRef(null),we=v.useRef(null),U=v.useRef([]),W=v.useRef(0),Te=v.useRef(!1),[Ee,De]=v.useState([]),[Oe,ke]=v.useState(``),G=B?Oe:``,[Ae,K]=v.useState(ae),[je,q]=v.useState(!0),[J,Me]=v.useState(!1),[Y,Ne]=v.useState(null),Pe=v.useMemo(()=>new Set(L),[L]),Fe=v.useMemo(()=>new Set(R),[R]),Ie=v.useCallback(async(e,t,n)=>{let r=Ce.current;if(!B||!r||t===`append`&&Te.current)return;let i=W.current+1;W.current=i,Te.current=!0,t===`replace`&&(U.current=[],De([]),K(ae),q(!0)),Me(!0),Ne(null);try{let a=await r({page:e,pageSize:V,search:n});if(i!==W.current)return;let o=fe(a.options),s=t===`append`?pe(U.current,o):o;U.current=s,De(s),K(O(a,e)),q(ge(a,s.length,o.length,V))}catch(e){i===W.current&&(Ne(_e(e,l.select.loadError)),q(!1))}finally{i===W.current&&(Te.current=!1,Me(!1))}},[B,l.select.loadError,V]);v.useEffect(()=>{if(!B)return;let e=window.setTimeout(()=>{ke(S.trim())},oe);return()=>window.clearTimeout(e)},[B,S]),v.useEffect(()=>{!B||!C||Ie(ae,`replace`,G)},[C,B,Ie,xe,G]);let Le=v.useMemo(()=>B?pe(G.length===0?be:[],Ee):be,[be,B,Ee,G.length]),X=v.useMemo(()=>Le.length>0||B?E(Le).map(me):ye(r),[r,Le,B]),Z=B&&C&&je&&!J&&Y===null,Re=v.useCallback(()=>{Z&&Ie(Ae,`append`,G)},[Z,Ie,Ae,G]),ze=v.useCallback(e=>{if(!Z)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<=se&&Re()},[Z,Re]);v.useEffect(()=>{if(!Z||typeof window>`u`||!(`IntersectionObserver`in window))return;let e=we.current,t=H.current;if(!e||!t)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Re()},{root:t});return n.observe(e),()=>n.disconnect()},[Z,Re]);let Be=v.useMemo(()=>{if(!h||B)return X;let e=S.trim().toLocaleLowerCase();return e.length===0?X:X.filter(t=>t.searchText.includes(e))},[X,B,h,S]),Q=v.useMemo(()=>{if(Be.some(e=>e.group!==void 0))return Be;let e=[],t=[];return Be.forEach(n=>{Fe.has(n.value)?e.push(n):t.push(n)}),[...e,...t]},[Be,Fe]),Ve=v.useMemo(()=>Array.from(new Set(X.filter(e=>!e.disabled).map(e=>e.value))),[X]),He=Ve.length>0&&Ve.every(e=>Pe.has(e)),Ue=c?.isModal??!1,[We,Ge]=v.useState({isOpen:!1,group:null,enterFrom:null});We.isOpen!==Ue&&Ge({isOpen:Ue,group:null,enterFrom:null});let Ke=v.useRef(null),qe=v.useRef(null),Je=v.useRef(!1);v.useEffect(()=>{if(!h||!C||Ue)return;let e=requestAnimationFrame(()=>{A.current?.focus(),A.current?.select()});return()=>cancelAnimationFrame(e)},[C,Ue,h]),v.useEffect(()=>{j.current?.scrollIntoView({block:`nearest`})},[w]);let Ye=v.useCallback(e=>{c?.setSearchTerm(n.convertToEnglishDigits({value:e.target.value}))},[c]),Xe=v.useCallback(e=>{if(c){if(m){let t=new Set(L);t.has(e)?t.delete(e):t.add(e),c.setMultiSelectedValues(Array.from(t));return}c.setSingleSelectedValue(e),c.setOpen(!1)}},[m,c,L]),Ze=v.useCallback((e,t,n)=>{e.preventDefault(),!n&&(M.current=t,Xe(t))},[Xe]),Qe=v.useCallback((e,t)=>{if(!t){if(M.current===e){M.current=null;return}Xe(e)}},[Xe]),$e=v.useCallback(()=>{m&&c&&c.setMultiSelectedValues(He?[]:Ve)},[He,m,c,Ve]),et=c?.isDisabled??!1,tt=e=>{if(!C||!c)return;let t=c.fieldRootRef.current?.querySelector(`[data-slot="select-trigger"]`),n=e=>{let t=Q[e];return!!t&&!t.disabled&&!et},r=(e,t)=>{let r=Q.length;for(let i=1;i<=r;i+=1){let a=((e+t*i)%r+r)%r;if(n(a))return a}return-1};if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),e.stopPropagation(),Q.length===0)return;let t=r(w>=0?w:e.key===`ArrowDown`?-1:0,e.key===`ArrowDown`?1:-1);t>=0&&c.setActiveIndex(t);return}if(e.key===`Enter`&&n(w)){e.preventDefault(),e.stopPropagation(),Xe(Q[w].value),m||t?.focus();return}e.key===`Tab`&&(e.target===A.current&&t?.focus(),c.setOpen(!1))},nt=c?.registerListKeyDown;if(ee.useIsomorphicLayoutEffect(()=>{nt?.(tt)}),!c)return null;let rt=Q.length>0,it=c.isDisabled||L.length===0,at=c.isDisabled||Ve.length===0||He,ot=Q.some(e=>e.group!==void 0),st=e=>e.group??te,ct=ot?Array.from(new Set(Q.map(st))):[],lt=Q.find(e=>Pe.has(e.value)),ut=We.group??(lt?st(lt):void 0),$=ut!==void 0&&ct.includes(ut)?ut:ct[0],dt=(e,t)=>{Ge({isOpen:Ue,group:e,enterFrom:t}),window.requestAnimationFrame(()=>{let e=Ke.current,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.left+r.width/2-(n.left+n.width/2);typeof e.scrollTo==`function`?e.scrollTo({left:e.scrollLeft+i,behavior:`smooth`}):e.scrollLeft+=i})},ft=e=>{Je.current=!1,qe.current={x:e.clientX,y:e.clientY,time:e.timeStamp}},pt=e=>{let t=qe.current;if(qe.current=null,!t||$===void 0)return;let n=e.clientX-t.x,r=e.clientY-t.y,i=Math.abs(n),a=i/Math.max(e.timeStamp-t.time,1);if(!(i>=ne||i>=re&&a>=ie)||i<Math.abs(r))return;Je.current=!0;let o=p===`rtl`?n>0:n<0,s=ct[ct.indexOf($)+(o?1:-1)];s!==void 0&&dt(s,n>0?`left`:`right`)},mt=e=>{Je.current&&(Je.current=!1,e.preventDefault(),e.stopPropagation())},ht=Q.map((e,t)=>{if(ot&&st(e)!==$)return null;let n=Pe.has(e.value),r=c.isDisabled||e.disabled,a=!ot&&e.group!==void 0&&e.group!==Q[t-1]?.group,o=!ot&&e.separatorBefore===!0&&t>0;return(0,y.jsxs)(v.Fragment,{children:[o?(0,y.jsx)(`div`,{role:`separator`,"data-slot":`select-separator`,className:`zui:my-1 zui:h-px zui:bg-[var(--zui-color-border)]`}):null,a?(0,y.jsx)(`div`,{role:`presentation`,"data-slot":`select-group-label`,className:`zui:px-1 zui:pt-2 zui:text-start zui:text-[max(calc(var(--zui-scale,10px)*1.26),13px)] zui:font-semibold zui:text-[var(--zui-theme-text-muted)]`,children:k(e.group,f)}):null,(0,y.jsxs)(`button`,{type:`button`,id:ue(D,t),"data-slot":`select-item`,role:`option`,"aria-selected":n,"aria-disabled":r||void 0,disabled:r,tabIndex:-1,dir:p,className:i.cn(_.selectModalOptionClassName,n&&`zui:border-[var(--zui-theme-status-success)] zui:bg-[color-mix(in_srgb,var(--zui-theme-status-success)_8%,var(--zui-color-surface))]`,e.className),onClick:()=>Qe(e.value,r),children:[(0,y.jsx)(`span`,{className:`zui:min-w-0 zui:flex-1 zui:break-words zui:text-start`,children:k(e.label,f)}),(0,y.jsx)(`span`,{"aria-hidden":`true`,className:`zui:flex zui:shrink-0 zui:items-center`,children:n?(0,y.jsx)(`span`,{className:`zui:flex zui:size-7 zui:items-center zui:justify-center zui:rounded-full zui:bg-[var(--zui-theme-status-success)] zui:text-[var(--zui-color-on-solid)]`,children:(0,y.jsx)(b.Check,{className:`zui:size-4`,strokeWidth:3})}):null})]})]},T(e.value,e.group))}),gt=(0,y.jsxs)(`div`,{ref:H,"data-slot":`select-viewport`,onScroll:ze,className:`zui:-mx-1 zui:min-h-0 zui:flex-1 zui:touch-pan-y zui:overflow-x-hidden zui:overflow-y-auto zui:overscroll-contain zui:px-1 zui:py-1`,children:[(0,y.jsx)(`div`,{id:D,role:`listbox`,"aria-multiselectable":m||void 0,"data-slot":`select-listbox`,className:`zui:flex zui:flex-col zui:gap-2.5`,children:ht}),!rt&&!J?(0,y.jsx)(`p`,{"data-slot":`select-empty`,className:`zui:px-2 zui:py-4 zui:text-center zui:text-[max(calc(var(--zui-scale,10px)*1.44),15px)] zui:text-[var(--zui-theme-text-muted)]`,children:l.select.noResults}):null,J?(0,y.jsx)(ve,{}):null,Y?(0,y.jsx)(`p`,{"data-slot":`select-error`,className:`zui:px-2 zui:py-2 zui:text-sm zui:text-[var(--zui-theme-status-danger)]`,children:Y}):null,Z?(0,y.jsx)(`div`,{ref:we,"data-slot":`select-infinite-scroll-sentinel`,"aria-hidden":`true`,className:`zui:h-px zui:w-full`}):null]}),_t=(0,y.jsxs)(`div`,{"data-slot":`select-modal-body`,className:`zui:flex zui:min-h-0 zui:flex-1 zui:flex-col zui:gap-4`,children:[h?(0,y.jsxs)(`div`,{"data-slot":`select-search`,className:`zui:flex zui:items-center zui:gap-2`,children:[(0,y.jsx)(`div`,{className:`zui:min-w-0 zui:flex-1`,children:(0,y.jsx)(u.default,{ref:A,type:`search`,dir:p,role:`combobox`,"aria-expanded":C,"aria-controls":D,"aria-autocomplete":`list`,"aria-label":l.common.searchPlaceholder,value:S,placeholder:l.common.searchPlaceholder,onChange:Ye,onKeyDown:e=>{e.stopPropagation(),tt(e)}})}),(0,y.jsx)(d.IconActionButton,{label:l.select.clearAll,icon:(0,y.jsx)(b.X,{className:`zui:size-5`,"aria-hidden":`true`}),className:_.selectModalActionButtonClassName,disabled:it,onClick:()=>m?c.setMultiSelectedValues([]):c.clearSingleSelection()}),m?(0,y.jsx)(d.IconActionButton,{label:c.multiSelectAllLabel,icon:(0,y.jsx)(b.CheckCheck,{className:`zui:size-5`,"aria-hidden":`true`}),className:_.selectModalActionButtonClassName,disabled:at,onClick:$e}):null]}):null,ot&&$!==void 0?(0,y.jsxs)(g.default,{value:$,onValueChange:e=>dt(e,null),dir:p,className:`zui:min-h-0 zui:flex-1`,children:[(0,y.jsx)(`div`,{ref:Ke,"data-slot":`select-group-tabs`,className:`zui:-mx-1 zui:overflow-x-auto zui:px-1 zui:[scrollbar-width:none] zui:[&::-webkit-scrollbar]:hidden`,children:(0,y.jsx)(g.TabsList,{"aria-label":l.select.ungrouped,className:`zui:w-max zui:min-w-full`,children:ct.map(e=>(0,y.jsx)(g.TabsTrigger,{value:e,className:`zui:flex-none`,children:e===te?l.select.ungrouped:k(e,f)},e))})}),(0,y.jsx)(`div`,{"data-slot":`select-group-swipe-area`,className:`zui:flex zui:min-h-0 zui:flex-1 zui:touch-pan-y zui:flex-col`,onPointerDown:ft,onPointerUp:pt,onPointerCancel:()=>{qe.current=null},onClickCapture:mt,children:(0,y.jsx)(g.TabsContent,{value:$,className:i.cn(`zui:mt-0 zui:flex zui:min-h-0 zui:flex-1 zui:flex-col`,We.enterFrom===`left`&&`zui:slide-in-from-left-8 zui:data-[state=active]:slide-in-from-bottom-0`,We.enterFrom===`right`&&`zui:slide-in-from-right-8 zui:data-[state=active]:slide-in-from-bottom-0`),children:gt},$)})]}):gt,(0,y.jsx)(a.default,{label:l.common.close,fullWidth:!0,onClick:()=>c.setOpen(!1)})]});return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(x.Portal,{children:(0,y.jsx)(x.Content,{ref:i.mergeRefs(s,c.contentRef),"data-slot":`select-content`,dir:p,side:`bottom`,align:`start`,sideOffset:6,collisionPadding:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{c.fieldRootRef.current?.contains(e.target)&&e.preventDefault()},className:i.cn(_.selectContentVariants(),e),children:(0,y.jsxs)(`div`,{ref:H,"data-slot":`select-viewport`,className:i.cn(_.selectViewportVariants({hasSearch:h}),`zui:max-h-72 zui:overflow-y-auto`),onScroll:ze,children:[h?(0,y.jsx)(`div`,{"data-slot":`select-search`,className:_.selectSearchBarClassName,children:(0,y.jsxs)(`div`,{dir:p,className:`zui:flex zui:items-center zui:gap-1`,children:[(0,y.jsx)(`div`,{className:`zui:min-w-0 zui:flex-1`,children:(0,y.jsx)(u.default,{ref:A,type:`search`,dir:p,role:`combobox`,"aria-expanded":C,"aria-controls":D,"aria-autocomplete":`list`,"aria-activedescendant":w>=0?ue(D,w):void 0,"aria-label":l.common.searchPlaceholder,value:S,placeholder:l.common.searchPlaceholder,onChange:Ye,onKeyDown:e=>{e.stopPropagation(),tt(e)},onPointerDown:e=>e.stopPropagation()})}),(0,y.jsx)(d.IconActionButton,{label:l.select.clearAll,icon:(0,y.jsx)(b.X,{className:`zui:size-4 zui:text-[var(--zui-color-text)]`,"aria-hidden":`true`}),className:_.selectActionButtonClassName,disabled:it,onPointerDown:e=>e.stopPropagation(),onClick:()=>m?c.setMultiSelectedValues([]):c.clearSingleSelection()}),m?(0,y.jsx)(d.IconActionButton,{label:c.multiSelectAllLabel,icon:(0,y.jsx)(b.CheckCheck,{className:i.cn(ce,`zui:text-[var(--zui-color-text)]`),"aria-hidden":`true`}),className:_.selectActionButtonClassName,disabled:at,onPointerDown:e=>e.stopPropagation(),onClick:$e}):null]})}):null,(0,y.jsx)(`div`,{id:D,role:`listbox`,"aria-multiselectable":m||void 0,"data-slot":`select-listbox`,children:Q.map((e,t)=>{let n=Pe.has(e.value),r=c.isDisabled||e.disabled,a=e.group!==void 0&&e.group!==Q[t-1]?.group,o=e.separatorBefore===!0&&t>0;return(0,y.jsxs)(v.Fragment,{children:[o?(0,y.jsx)(`div`,{role:`separator`,"data-slot":`select-separator`,className:_.selectSeparatorVariants()}):null,a?(0,y.jsx)(`div`,{role:`presentation`,"data-slot":`select-group-label`,className:i.cn(_.selectLabelVariants(),t>0&&`zui:pt-4`),children:k(e.group,f)}):null,(0,y.jsxs)(`button`,{type:`button`,id:ue(D,t),"data-slot":`select-item`,role:`option`,"aria-selected":n,"aria-disabled":r||void 0,"data-active":t===w||void 0,ref:t===w?j:void 0,tabIndex:-1,onMouseMove:()=>{!r&&t!==w&&c.setActiveIndex(t)},dir:p,className:i.cn(_.selectOptionVariants(),e.group!==void 0&&`zui:ms-2 zui:w-[calc(100%-var(--zui-spacing)*2)] zui:border-s zui:border-s-[var(--zui-color-border)]`,h&&`zui:scroll-mt-16`,t===Q.length-1&&`zui:border-b-0`,e.className),disabled:r,onPointerDown:t=>Ze(t,e.value,r),onClick:()=>Qe(e.value,r),children:[(0,y.jsx)(`span`,{className:`zui:line-clamp-2 zui:min-w-0 zui:flex-1 zui:break-words zui:text-start`,children:k(e.label,f)}),(0,y.jsx)(`span`,{"aria-hidden":`true`,className:`zui:flex zui:shrink-0 zui:items-center zui:justify-center zui:text-[var(--zui-theme-action-primary)]`,children:(0,y.jsx)(b.Check,{className:i.cn(ce,!n&&`zui:opacity-0`)})})]})]},T(e.value,e.group))})}),!rt&&!J?(0,y.jsx)(`p`,{"data-slot":`select-empty`,className:`zui:px-2 zui:py-2 zui:text-xs zui:text-[var(--zui-color-text)]`,children:l.select.noResults}):null,J?(0,y.jsx)(ve,{}):null,Y?(0,y.jsx)(`p`,{"data-slot":`select-error`,className:`zui:px-2 zui:py-2 zui:text-xs zui:text-[var(--zui-theme-status-danger)]`,children:Y}):null,Z?(0,y.jsx)(`div`,{ref:we,"data-slot":`select-infinite-scroll-sentinel`,"aria-hidden":`true`,className:`zui:h-px zui:w-full`}):null]})})}),(0,y.jsx)(o.default,{trigger:null,open:c.isModal,onOpenChange:e=>c.setOpen(e),dir:p,triggerLabel:c.modalLabel,showCloseButton:!1,onOpenAutoFocus:e=>e.preventDefault(),className:`zui:mobile:h-[75dvh] zui:mobile:touch-pan-y zui:mobile:overflow-x-hidden zui:mobile:overscroll-contain zui:mobile:px-3 zui:mobile:[&>[data-slot=dialog-body]]:flex zui:mobile:[&>[data-slot=dialog-body]]:min-h-0 zui:mobile:[&>[data-slot=dialog-body]]:flex-1 zui:mobile:[&>[data-slot=dialog-body]]:flex-col`,content:_t})]})});exports.SelectContent=R,exports.SelectGroup=M,exports.SelectItem=j,exports.SelectLabel=N,exports.SelectSeparator=P,exports.SelectTrigger=I,exports.SelectValue=L,exports.default=F;
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../config/useZuiConfig.cjs`),n=require(`../../services/convertToEnglishDigits/convertToEnglishDigits.cjs`),r=require(`../../services/localizeDigits/localizeDigits.cjs`),i=require(`../../lib/utils.cjs`),a=require(`../Button/Button.cjs`),o=require(`../Dialog/Dialog.cjs`),s=require(`../Tooltip/Tooltip.cjs`),c=require(`../shared/FieldClearButton.cjs`),l=require(`../shared/FieldLabel.cjs`),u=require(`../shared/useInvalidState.cjs`),d=require(`../Input/Input.cjs`),f=require(`../shared/IconActionButton.cjs`),p=require(`../shared/useControllableState.cjs`),m=require(`../shared/viewport.cjs`),h=require(`../shared/useIsomorphicLayoutEffect.cjs`),g=require(`../shared/RequiredValidationInput.cjs`),_=require(`../Skeleton/Skeleton.cjs`),v=require(`../Tabs/Tabs.cjs`),y=require(`./Select.variant.cjs`);let b=require(`react`);b=e.__toESM(b,1);let x=require(`react/jsx-runtime`),S=require(`lucide-react`),C=require(`@radix-ui/react-popover`);C=e.__toESM(C,1);let ee=require(`@tanstack/react-virtual`);var te=`__zui-ungrouped__`,ne=40,re=24,ie=.3,ae=1,w=20,oe=350,se=48,T=3,ce=`zui:size-[calc(var(--zui-scale,10px)*1.92)]`,le=100,ue=36,E=8,de=b.createContext(null);function fe(e,t){return`${e}-option-${t}`}function pe(e){return typeof e==`string`&&e.length>0}function D(e){if(!Array.isArray(e))return[];let t=new Set;return e.forEach(e=>{typeof e==`string`&&e.trim().length>0&&t.add(e.trim())}),Array.from(t)}function O(e,t){return`${t??``}\u0000${e}`}function me(e){if(!Array.isArray(e))return[];let t=[],n=new Set;return e.forEach(e=>{if(!e||typeof e!=`object`)return;let r=e,i=typeof r.value==`string`?r.value.trim():``,a=typeof r.group==`string`&&r.group.trim().length>0?r.group.trim():void 0,o=O(i,a);if(i.length===0||n.has(o))return;let s=typeof r.label==`string`&&r.label.trim().length>0?r.label.trim():i;n.add(o),t.push({value:i,label:s,disabled:r.disabled===!0,group:a})}),t}function he(e,t){if(t.length===0)return e;let n=new Map;return e.forEach(e=>{n.set(O(e.value,e.group),e)}),t.forEach(e=>{n.set(O(e.value,e.group),e)}),Array.from(n.values())}function ge(e){let t=[],n=new Map;return e.forEach(e=>{if(e.group===void 0){t.push(e);return}let r=n.get(e.group);if(r){r.push(e);return}let i=[e];n.set(e.group,i),t.push(i)}),t.flat()}function k(e,t){return n.convertToEnglishDigits({value:(e.length>0?e:t).toLocaleLowerCase()})}function _e(e){return{value:e.value,label:e.label,searchText:k(e.label.trim(),e.value),disabled:e.disabled===!0,group:e.group}}function ve(e){if(typeof e!=`number`||!Number.isFinite(e))return w;let t=Math.floor(e);return t>0?t:w}function ye(e,t,n,r){return typeof e.hasMore==`boolean`?e.hasMore:typeof e.totalItems==`number`&&Number.isFinite(e.totalItems)?t<Math.max(0,Math.floor(e.totalItems)):typeof e.nextPage==`number`?Number.isFinite(e.nextPage)&&e.nextPage>0:n>=r}function be(e,t){return typeof e.nextPage==`number`&&Number.isFinite(e.nextPage)&&e.nextPage>t?Math.floor(e.nextPage):t+1}function xe(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:t}function Se(){return(0,x.jsx)(`div`,{"data-slot":`select-loading`,className:`zui:space-y-1 zui:px-2 zui:py-2`,children:Array.from({length:T},(e,t)=>(0,x.jsx)(_.default,{className:i.cn(`zui:h-5 zui:max-w-full`,t===0?`zui:w-[88%]`:t===1?`zui:w-[72%]`:`zui:w-[80%]`)},`select-loading-${t}`))})}function A(e,t){return typeof e==`string`?r.localizeDigits(e,t):typeof e==`number`?r.localizeDigits(String(e),t):Array.isArray(e)?e.map((e,n)=>(0,x.jsx)(b.Fragment,{children:A(e,t)},n)):b.isValidElement(e)?!(`children`in e.props)||e.props.children===void 0?e:b.cloneElement(e,void 0,A(e.props.children,t)):e}function j(e){return typeof e==`string`||typeof e==`number`?String(e):Array.isArray(e)?e.map(j).join(` `):b.isValidElement(e)?j(e.props.children):``}function M(e){return null}function N(e){return null}function P(e){return null}function Ce(){return null}function we(e){let t=[],n=new Set,r=!1,i=(e,a)=>{b.Children.forEach(e,e=>{if(b.isValidElement(e)){if(e.type===Ce){r=t.length>0;return}if(e.type===M){let i=e.props,o=typeof i.value==`string`?i.value.trim():``,s=O(o,a);if(o.length===0||n.has(s))return;n.add(s),t.push({value:o,label:i.children,searchText:k(j(i.children).trim(),o),disabled:i.disabled===!0,group:a,separatorBefore:r,className:i.className}),r=!1;return}if(e.type===N){let t=e.props.children,n;b.Children.forEach(t,e=>{if(b.isValidElement(e)&&e.type===P){let t=j(e.props.children).trim();n=t.length>0?t:void 0}}),i(t,n??a);return}`children`in e.props&&i(e.props.children,a)}})};return i(e),t}function F(e){let{messages:n,dir:r}=t.useZuiConfig(),{type:a=`single`,title:o,required:s=!1,showRequiredMessage:c=!1,placeholder:d,options:f,remoteOptions:h,isSearch:_=!1,searchActions:v=!0,disabled:y=!1,disable:S=!1,onInvalid:ee,onOpenChange:te,open:ne,defaultOpen:re,id:ie,name:ae,form:w,children:oe,selectAllLabel:se,selectedCountLabel:T,multiValueSubmitFormat:ce=`separate`,onValueChange:le,onChange:ue}=e,E=b.useCallback(e=>{le?.(e),ue?.(e)},[ue,le]),fe=b.useId(),O=ie??fe,he=`${O}-listbox`,ge=y||S,k=a===`multi`,_e=b.useRef(null),ve=b.useRef(null),ye=b.useRef(null),be=b.useCallback(e=>{ye.current?.(e)},[]),xe=b.useCallback(e=>{ye.current=e},[]),[Se,A]=b.useState(``),[j,M]=b.useState(-1),{isInvalid:N,setIsInvalid:P,handleInvalid:Ce}=u.useInvalidState(ee),[F,Ee,Oe]=p.useControllableState({value:!k&&typeof e.value==`string`?e.value:void 0,defaultValue:!k&&typeof e.defaultValue==`string`?e.defaultValue:void 0}),L=k&&Array.isArray(e.value)?e.value:void 0,[R,ke]=p.useControllableState({value:b.useMemo(()=>L?D(L):void 0,[L]),defaultValue:()=>D(e.defaultValue)}),[z,Ae]=p.useControllableState({value:ne,defaultValue:!!re,onChange:te}),[je,Me]=b.useState(null),B=b.useCallback(e=>{Me(e?m.isMobileViewport():null),Ae(e)},[Ae]),V=z&&(je??m.isMobileViewport()),H=b.useMemo(()=>me(f),[f]),Ne=b.useMemo(()=>we(oe),[oe]),Pe=_?Se:``,U=k?R.length>0:pe(F),Fe=N&&!U,[Ie,W]=b.useState(()=>({isOpen:z,values:D(e.defaultValue)}));if(Ie.isOpen!==z){let e=k?R:pe(F)?[F]:[];W({isOpen:z,values:z?e:Ie.values}),M(-1),z||A(``)}let Le=b.useMemo(()=>!k||R.length===0?``:typeof T==`function`?T(R.length):n.select.selectedCount(String(R.length)),[k,n,R.length,T]),Re=b.useCallback(e=>{A(e),M(-1)},[]),ze=b.useCallback(e=>{Ee(e),P(!1),E(e)},[E,P,Ee]),Be=b.useCallback(()=>{k||(Ee(Oe?``:void 0),E(``))},[E,k,Oe,Ee]),G=b.useCallback(e=>{let t=D(e);ke(t),P(!1),E(t)},[E,P,ke]),Ve=b.Children.toArray(oe),He=Ve.some(e=>b.isValidElement(e)&&e.type===De),Ue=h?.enabled!==!1&&h,We=!He&&(H.length>0||Ue)?[...Ve,(0,x.jsx)(De,{},`select-generated-content`)]:oe,Ge=b.Children.toArray(We).some(e=>b.isValidElement(e)&&e.type===Te),Ke=b.Children.map(We,e=>{if(!b.isValidElement(e))return e;if(e.type===Te){let t=e.props;return b.cloneElement(e,{id:t.id??O,disabled:t.disabled??ge,className:i.cn(`zui:text-start`,t.className)})}if(e.type===De){let t=e.props;return b.cloneElement(e,{className:i.cn(`zui:text-start`,t.className)})}return e}),qe=b.useMemo(()=>({listboxId:he,isSearch:_,showSearchActions:v,searchTerm:Pe,setSearchTerm:Re,hasValue:U,isInvalid:Fe,selectType:a,isOpen:z,setOpen:B,isModal:V,modalLabel:o??d,isDisabled:ge,activeIndex:j,setActiveIndex:M,singleSelectedValue:F,setSingleSelectedValue:ze,clearSingleSelection:Be,multiSelectedValues:R,pinnedSelectedValues:Ie.values,setMultiSelectedValues:G,multiSelectAllLabel:se??n.select.selectAll,multiSelectedCountText:Le,options:H,childOptions:Ne,remoteOptions:h,contentRef:ve,fieldRootRef:_e,onListKeyDown:be,registerListKeyDown:xe}),[j,Ne,Be,G,ze,U,ge,_,v,V,Fe,he,n,d,o,Le,H,be,Ie.values,xe,h,R,z,F,Pe,se,a,B,Re]);return(0,x.jsxs)(`div`,{ref:_e,"data-slot":`select-field`,dir:r,className:`zui:relative zui:w-full zui:space-y-1.5 zui:text-start`,children:[(0,x.jsx)(l.FieldLabel,{title:o,htmlFor:O,required:s,showRequiredMessage:c}),(0,x.jsxs)(de.Provider,{value:qe,children:[(0,x.jsx)(C.Root,{open:z&&!V,onOpenChange:B,children:(0,x.jsx)(C.Anchor,{asChild:!0,children:(0,x.jsxs)(`div`,{"data-slot":`select`,dir:r,className:`zui:relative`,children:[Ge?Ke:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Te,{id:O,children:(0,x.jsx)(I,{placeholder:d})}),Ke]}),ae?k&&ce===`separate`?R.map(e=>(0,x.jsx)(`input`,{type:`hidden`,name:ae,form:w,value:e},e)):(0,x.jsx)(`input`,{type:`hidden`,name:ae,form:w,value:k?R.join(`,`):F??``}):null]})})}),s?(0,x.jsx)(g.default,{hasValue:U,form:w,disabled:ge,onInvalid:Ce}):null]})]})}var Te=b.forwardRef(function({className:e,children:n,onClick:r,onKeyDown:a,disabled:o,unstyled:l=!1,tooltip:u,...d},f){let p=b.useContext(de),{messages:m,dir:h}=t.useZuiConfig(),g=p?.hasValue??!1,_=p?.isInvalid??!1,v=p?.isOpen??!1,C=p?.selectType===`multi`,ee=o||(p?.isDisabled??!1),te=p?.activeIndex??-1,ne=!l&&!C&&g&&!ee&&!!p,re=(0,x.jsxs)(`button`,{ref:f,type:`button`,"data-slot":`select-trigger`,"data-has-value":g,"data-state":v?`open`:`closed`,dir:h,"aria-expanded":v,"aria-haspopup":`listbox`,"aria-controls":v&&p?p.listboxId:void 0,"aria-activedescendant":v&&p&&te>=0?fe(p.listboxId,te):void 0,"aria-invalid":_||void 0,disabled:ee,className:l?e:i.cn(y.selectTriggerVariants({className:e}),`zui:text-start`),onClick:e=>{r?.(e),!(e.defaultPrevented||ee||!p)&&p.setOpen(!v)},onKeyDown:e=>{a?.(e),e.defaultPrevented||p?.onListKeyDown(e)},...d,children:[n,ne?(0,x.jsx)(c.FieldClearButtonSlot,{}):null,l?null:(0,x.jsx)(S.ChevronDown,{className:i.cn(c.CLEAR_ICON_CLASS,`zui:shrink-0 zui:text-[var(--zui-color-text)] zui:transition-transform zui:duration-200`,v?`zui:rotate-180`:`zui:rotate-0`)})]});return(0,x.jsxs)(x.Fragment,{children:[u?(0,x.jsx)(s.default,{text:u,position:`top`,trigger:re}):re,ne?(0,x.jsx)(c.FieldClearButton,{"data-slot":`select-clear-button`,label:m.select.clearSelection,onClear:()=>p?.clearSingleSelection()}):null]})});function I({className:e,placeholder:n,children:r,...a}){let o=b.useContext(de),{digits:s}=t.useZuiConfig();if(o?.selectType===`multi`){let t=r??(o.hasValue?o.multiSelectedCountText:n);return(0,x.jsx)(`span`,{"data-slot":`select-value`,"data-placeholder":o.hasValue?void 0:!0,className:i.cn(`zui:block zui:max-w-full zui:truncate zui:text-start zui:text-[var(--zui-color-text)]`,!o.hasValue&&`zui:text-[var(--zui-theme-text-muted)] zui:mobile:text-sm`,e),...a,children:A(t,s)})}let c=o?.options.find(e=>e.value===o.singleSelectedValue)??o?.childOptions.find(e=>e.value===o.singleSelectedValue);return c?(0,x.jsx)(`span`,{"data-slot":`select-value`,className:i.cn(`zui:block zui:min-w-0 zui:flex-1 zui:truncate zui:text-start zui:text-[var(--zui-color-text)]`,e),...a,children:A(r??c.label,s)}):(0,x.jsx)(`span`,{"data-slot":`select-value`,"data-placeholder":``,className:i.cn(`zui:block zui:min-w-0 zui:flex-1 zui:truncate zui:text-start zui:text-[var(--zui-theme-text-muted)] zui:mobile:text-sm`,e),...a,children:n})}var Ee=b.memo(function({option:e,index:t,listboxId:n,dir:r,digits:a,isActive:o,isSelected:s,isDisabled:c,isLast:l,isSearchEnabled:u,showSeparator:d,showGroupHeading:f,listSize:p,activeOptionRef:m,onActivateIndex:h,onOptionPointerDown:g,onOptionClick:_}){return(0,x.jsxs)(x.Fragment,{children:[d?(0,x.jsx)(`div`,{role:`separator`,"data-slot":`select-separator`,className:y.selectSeparatorVariants()}):null,f?(0,x.jsx)(`div`,{role:`presentation`,"data-slot":`select-group-label`,className:i.cn(y.selectLabelVariants(),t>0&&`zui:pt-4`),children:A(e.group,a)}):null,(0,x.jsxs)(`button`,{type:`button`,id:fe(n,t),"data-slot":`select-item`,role:`option`,"aria-selected":s,"aria-disabled":c||void 0,"aria-setsize":p,"aria-posinset":p===void 0?void 0:t+1,"data-active":o||void 0,ref:o?m:void 0,tabIndex:-1,onMouseMove:()=>{!c&&!o&&h(t)},dir:r,className:i.cn(y.selectOptionVariants(),e.group!==void 0&&`zui:ms-2 zui:w-[calc(100%-var(--zui-spacing)*2)] zui:border-s zui:border-s-[var(--zui-color-border)]`,u&&`zui:scroll-mt-16`,l&&`zui:border-b-0`,e.className),disabled:c,onPointerDown:t=>g(t,e.value,c),onClick:()=>_(e.value,c),children:[(0,x.jsx)(`span`,{className:`zui:line-clamp-2 zui:min-w-0 zui:flex-1 zui:break-words zui:text-start`,children:A(e.label,a)}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`zui:flex zui:shrink-0 zui:items-center zui:justify-center zui:text-[var(--zui-theme-action-primary)]`,children:(0,x.jsx)(S.Check,{className:i.cn(ce,!s&&`zui:opacity-0`)})})]})]})}),De=b.forwardRef(function({className:e,children:r},s){let c=b.useContext(de),{messages:l,digits:u,dir:p}=t.useZuiConfig(),m=c?.selectType===`multi`,g=c?.isSearch??!1,_=c?.showSearchActions??!0,w=c?.searchTerm??``,T=c?.isOpen??!1,D=c?.activeIndex??-1,k=c?.listboxId??``,j=b.useRef(null),M=b.useRef(null),N=b.useRef(null),P=c?.singleSelectedValue,Ce=c?.multiSelectedValues,F=c?.pinnedSelectedValues,Te=c?.options,I=b.useMemo(()=>m?Ce??[]:pe(P)?[P]:[],[m,Ce,P]),De=b.useMemo(()=>F??[],[F]),Oe=b.useMemo(()=>Te??[],[Te]),L=c?.remoteOptions,R=typeof L?.loadOptions==`function`&&L.enabled!==!1,ke=ve(L?.pageSize),z=L?.cacheKey,Ae=L?.loadOptions,je=b.useRef(Ae);h.useIsomorphicLayoutEffect(()=>{je.current=Ae});let Me=b.useRef(null),B=b.useRef(null),V=b.useRef([]),H=b.useRef(0),Ne=b.useRef(!1),[Pe,U]=b.useState([]),[Fe,Ie]=b.useState(``),W=R?Fe:``,[Le,Re]=b.useState(ae),[ze,Be]=b.useState(!0),[G,Ve]=b.useState(!1),[He,Ue]=b.useState(null),We=b.useMemo(()=>new Set(I),[I]),Ge=b.useMemo(()=>new Set(De),[De]),Ke=b.useCallback(async(e,t,n)=>{let r=je.current;if(!R||!r||t===`append`&&Ne.current)return;let i=H.current+1;H.current=i,Ne.current=!0,t===`replace`&&(V.current=[],U([]),Re(ae),Be(!0)),Ve(!0),Ue(null);try{let a=await r({page:e,pageSize:ke,search:n});if(i!==H.current)return;let o=me(a.options),s=t===`append`?he(V.current,o):o;V.current=s,U(s),Re(be(a,e)),Be(ye(a,s.length,o.length,ke))}catch(e){i===H.current&&(Ue(xe(e,l.select.loadError)),Be(!1))}finally{i===H.current&&(Ne.current=!1,Ve(!1))}},[R,l.select.loadError,ke]);b.useEffect(()=>{if(!R)return;let e=window.setTimeout(()=>{Ie(w.trim())},oe);return()=>window.clearTimeout(e)},[R,w]),b.useEffect(()=>{!R||!T||Ke(ae,`replace`,W)},[T,R,Ke,z,W]);let qe=b.useMemo(()=>R?he(W.length===0?Oe:[],Pe):Oe,[Oe,R,Pe,W.length]),Je=b.useMemo(()=>qe.length>0||R?ge(qe).map(_e):we(r),[r,qe,R]),K=R&&T&&ze&&!G&&He===null,Ye=b.useCallback(()=>{K&&Ke(Le,`append`,W)},[K,Ke,Le,W]),Xe=b.useCallback(e=>{if(!K)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<=se&&Ye()},[K,Ye]);b.useEffect(()=>{if(!K||typeof window>`u`||!(`IntersectionObserver`in window))return;let e=B.current,t=Me.current;if(!e||!t)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&Ye()},{root:t});return n.observe(e),()=>n.disconnect()},[K,Ye]);let Ze=b.useDeferredValue(w),Qe=b.useMemo(()=>{if(!g||R)return Je;let e=Ze.trim().toLocaleLowerCase();return e.length===0?Je:Je.filter(t=>t.searchText.includes(e))},[Je,Ze,R,g]),q=b.useMemo(()=>{if(Qe.some(e=>e.group!==void 0))return Qe;let e=[],t=[];return Qe.forEach(n=>{Ge.has(n.value)?e.push(n):t.push(n)}),[...e,...t]},[Qe,Ge]),$e=b.useMemo(()=>Array.from(new Set(Je.filter(e=>!e.disabled).map(e=>e.value))),[Je]),et=$e.length>0&&$e.every(e=>We.has(e)),J=c?.isModal??!1,[tt,nt]=b.useState({isOpen:!1,group:null,enterFrom:null});tt.isOpen!==J&&nt({isOpen:J,group:null,enterFrom:null});let rt=b.useRef(null),it=b.useRef(null),at=b.useRef(!1);b.useEffect(()=>{if(!g||!T||J)return;let e=requestAnimationFrame(()=>{j.current?.focus(),j.current?.select()});return()=>cancelAnimationFrame(e)},[T,J,g]);let Y=q.some(e=>e.group!==void 0),ot=e=>e.group??te,st=Y?Array.from(new Set(q.map(ot))):[],ct=q.find(e=>We.has(e.value)),lt=tt.group??(ct?ot(ct):void 0),X=lt!==void 0&&st.includes(lt)?lt:st[0],[Z,ut]=b.useState(null),[dt,ft]=b.useState(0),[pt,mt]=b.useState(0),ht=b.useRef(null),gt=b.useRef(!1),_t=b.useMemo(()=>{if(!J||!Y)return null;let e=[];return q.forEach((t,n)=>{(t.group??te)===X&&e.push(n)}),e},[X,Y,J,q]),vt=_t?.length??q.length,Q=vt>le,yt=e=>_t?.[e]??e,bt=b.useCallback(e=>{Me.current=e,ut(e)},[]);h.useIsomorphicLayoutEffect(()=>{let e=ht.current;!Q||!Z||!e||(ft(e.getBoundingClientRect().top-Z.getBoundingClientRect().top+Z.scrollTop),mt(Z.querySelector(`[data-slot="select-search"]`)?.offsetHeight??0))},[g,Q,Z]);let $=(0,ee.useVirtualizer)({count:Q?vt:0,getScrollElement:()=>Z,estimateSize:()=>ue,overscan:E,scrollMargin:dt,scrollPaddingStart:pt,useFlushSync:!1,getItemKey:e=>{let t=q[yt(e)];return t?O(t.value,t.group):e}});h.useIsomorphicLayoutEffect(()=>{!Q||!Z||(Z.scrollTop=0,$.scrollToOffset(0))},[Ze,$,Q,Z]),b.useEffect(()=>{if(gt.current){gt.current=!1;return}if(Q){D>=0&&!J&&$.scrollToIndex(D,{align:`auto`});return}M.current?.scrollIntoView({block:`nearest`})},[D,J,$,Q]);let xt=b.useCallback(e=>{c?.setSearchTerm(n.convertToEnglishDigits({value:e.target.value}))},[c]),St=b.useCallback(e=>{if(c){if(m){let t=new Set(I);t.has(e)?t.delete(e):t.add(e),c.setMultiSelectedValues(Array.from(t));return}c.setSingleSelectedValue(e),c.setOpen(!1)}},[m,c,I]),Ct=b.useCallback((e,t,n)=>{e.preventDefault(),!n&&(N.current=t,St(t))},[St]),wt=b.useCallback((e,t)=>{if(!t){if(N.current===e){N.current=null;return}St(e)}},[St]),Tt=b.useRef({activateIndex:()=>void 0,pointerDown:Ct,click:wt}),Et=c?.setActiveIndex;h.useIsomorphicLayoutEffect(()=>{Tt.current={activateIndex:e=>{gt.current=!0,Et?.(e)},pointerDown:Ct,click:wt}});let Dt=b.useCallback(e=>Tt.current.activateIndex(e),[]),Ot=b.useCallback((e,t,n)=>Tt.current.pointerDown(e,t,n),[]),kt=b.useCallback((e,t)=>Tt.current.click(e,t),[]),At=b.useCallback(()=>{m&&c&&c.setMultiSelectedValues(et?[]:$e)},[et,m,c,$e]),jt=c?.isDisabled??!1,Mt=e=>{if(!T||!c)return;let t=c.fieldRootRef.current?.querySelector(`[data-slot="select-trigger"]`),n=e=>{let t=q[e];return!!t&&!t.disabled&&!jt},r=(e,t)=>{let r=q.length;for(let i=1;i<=r;i+=1){let a=((e+t*i)%r+r)%r;if(n(a))return a}return-1};if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),e.stopPropagation(),q.length===0)return;let t=r(D>=0?D:e.key===`ArrowDown`?-1:0,e.key===`ArrowDown`?1:-1);t>=0&&c.setActiveIndex(t);return}if(e.key===`Enter`&&n(D)){e.preventDefault(),e.stopPropagation(),St(q[D].value),m||t?.focus();return}e.key===`Tab`&&(e.target===j.current&&t?.focus(),c.setOpen(!1))},Nt=c?.registerListKeyDown;if(h.useIsomorphicLayoutEffect(()=>{Nt?.(Mt)}),!c)return null;let Pt=q.length>0,Ft=c.isDisabled||I.length===0,It=c.isDisabled||$e.length===0||et,Lt=(e,t)=>{nt({isOpen:J,group:e,enterFrom:t}),window.requestAnimationFrame(()=>{let e=rt.current,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.left+r.width/2-(n.left+n.width/2);typeof e.scrollTo==`function`?e.scrollTo({left:e.scrollLeft+i,behavior:`smooth`}):e.scrollLeft+=i})},Rt=e=>{at.current=!1,it.current={x:e.clientX,y:e.clientY,time:e.timeStamp}},zt=e=>{let t=it.current;if(it.current=null,!t||X===void 0)return;let n=e.clientX-t.x,r=e.clientY-t.y,i=Math.abs(n),a=i/Math.max(e.timeStamp-t.time,1);if(!(i>=ne||i>=re&&a>=ie)||i<Math.abs(r))return;at.current=!0;let o=p===`rtl`?n>0:n<0,s=st[st.indexOf(X)+(o?1:-1)];s!==void 0&&Lt(s,n>0?`left`:`right`)},Bt=e=>{at.current&&(at.current=!1,e.preventDefault(),e.stopPropagation())},Vt=(e,t,n)=>(0,x.jsx)(Ee,{option:e,index:t,listboxId:k,dir:p,digits:u,isActive:t===D,isSelected:We.has(e.value),isDisabled:c.isDisabled||e.disabled,isLast:t===q.length-1,isSearchEnabled:g,showSeparator:e.separatorBefore===!0&&t>0,showGroupHeading:e.group!==void 0&&e.group!==q[t-1]?.group,listSize:n,activeOptionRef:M,onActivateIndex:Dt,onOptionPointerDown:Ot,onOptionClick:kt}),Ht=(e,t,n,r)=>{let a=We.has(e.value),o=c.isDisabled||e.disabled,s=!Y&&e.group!==void 0&&e.group!==q[t-1]?.group;return(0,x.jsxs)(x.Fragment,{children:[!Y&&e.separatorBefore===!0&&t>0?(0,x.jsx)(`div`,{role:`separator`,"data-slot":`select-separator`,className:`zui:my-1 zui:h-px zui:bg-[var(--zui-color-border)]`}):null,s?(0,x.jsx)(`div`,{role:`presentation`,"data-slot":`select-group-label`,className:`zui:px-1 zui:pt-2 zui:text-start zui:text-[max(calc(var(--zui-scale,10px)*1.26),13px)] zui:font-semibold zui:text-[var(--zui-theme-text-muted)]`,children:A(e.group,u)}):null,(0,x.jsxs)(`button`,{type:`button`,id:fe(k,t),"data-slot":`select-item`,role:`option`,"aria-selected":a,"aria-disabled":o||void 0,"aria-setsize":n,"aria-posinset":r,disabled:o,tabIndex:-1,dir:p,className:i.cn(y.selectModalOptionClassName,a&&`zui:border-[var(--zui-theme-status-success)] zui:bg-[color-mix(in_srgb,var(--zui-theme-status-success)_8%,var(--zui-color-surface))]`,e.className),onClick:()=>wt(e.value,o),children:[(0,x.jsx)(`span`,{className:`zui:min-w-0 zui:flex-1 zui:break-words zui:text-start`,children:A(e.label,u)}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`zui:flex zui:shrink-0 zui:items-center`,children:a?(0,x.jsx)(`span`,{className:`zui:flex zui:size-7 zui:items-center zui:justify-center zui:rounded-full zui:bg-[var(--zui-theme-status-success)] zui:text-[var(--zui-color-on-solid)]`,children:(0,x.jsx)(S.Check,{className:`zui:size-4`,strokeWidth:3})}):null})]})]})},Ut=J&&!Q?q.map((e,t)=>Y&&ot(e)!==X?null:(0,x.jsx)(b.Fragment,{children:Ht(e,t)},O(e.value,e.group))):null,Wt=(0,x.jsxs)(`div`,{ref:bt,"data-slot":`select-viewport`,onScroll:Xe,className:`zui:-mx-1 zui:min-h-0 zui:flex-1 zui:touch-pan-y zui:overflow-x-hidden zui:overflow-y-auto zui:overscroll-contain zui:px-1 zui:py-1`,children:[(0,x.jsx)(`div`,{ref:ht,id:k,role:`listbox`,"aria-multiselectable":m||void 0,"data-slot":`select-listbox`,className:Q?void 0:`zui:flex zui:flex-col zui:gap-2.5`,style:Q?{position:`relative`,height:$.getTotalSize()}:void 0,children:Q?$.getVirtualItems().map(e=>{let t=yt(e.index),n=q[t];return n?(0,x.jsx)(`div`,{ref:$.measureElement,"data-index":e.index,role:`presentation`,className:`zui:pb-2.5`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start-dt}px)`},children:Ht(n,t,vt,e.index+1)},e.key):null}):Ut}),!Pt&&!G?(0,x.jsx)(`p`,{"data-slot":`select-empty`,className:`zui:px-2 zui:py-4 zui:text-center zui:text-[max(calc(var(--zui-scale,10px)*1.44),15px)] zui:text-[var(--zui-theme-text-muted)]`,children:l.select.noResults}):null,G?(0,x.jsx)(Se,{}):null,He?(0,x.jsx)(`p`,{"data-slot":`select-error`,className:`zui:px-2 zui:py-2 zui:text-sm zui:text-[var(--zui-theme-status-danger)]`,children:He}):null,K?(0,x.jsx)(`div`,{ref:B,"data-slot":`select-infinite-scroll-sentinel`,"aria-hidden":`true`,className:`zui:h-px zui:w-full`}):null]}),Gt=(0,x.jsxs)(`div`,{"data-slot":`select-modal-body`,className:`zui:flex zui:min-h-0 zui:flex-1 zui:flex-col zui:gap-4`,children:[g?(0,x.jsxs)(`div`,{"data-slot":`select-search`,className:`zui:flex zui:items-center zui:gap-2`,children:[(0,x.jsx)(`div`,{className:`zui:min-w-0 zui:flex-1`,children:(0,x.jsx)(d.default,{ref:j,type:`search`,dir:p,role:`combobox`,"aria-expanded":T,"aria-controls":k,"aria-autocomplete":`list`,"aria-label":l.common.searchPlaceholder,value:w,placeholder:l.common.searchPlaceholder,onChange:xt,onKeyDown:e=>{e.stopPropagation(),Mt(e)}})}),_?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(f.IconActionButton,{label:l.select.clearAll,icon:(0,x.jsx)(S.X,{className:`zui:size-5`,"aria-hidden":`true`}),className:y.selectModalActionButtonClassName,disabled:Ft,onClick:()=>m?c.setMultiSelectedValues([]):c.clearSingleSelection()}),m?(0,x.jsx)(f.IconActionButton,{label:c.multiSelectAllLabel,icon:(0,x.jsx)(S.CheckCheck,{className:`zui:size-5`,"aria-hidden":`true`}),className:y.selectModalActionButtonClassName,disabled:It,onClick:At}):null]}):null]}):null,Y&&X!==void 0?(0,x.jsxs)(v.default,{value:X,onValueChange:e=>Lt(e,null),dir:p,className:`zui:min-h-0 zui:flex-1`,children:[(0,x.jsx)(`div`,{ref:rt,"data-slot":`select-group-tabs`,className:`zui:-mx-1 zui:overflow-x-auto zui:px-1 zui:[scrollbar-width:none] zui:[&::-webkit-scrollbar]:hidden`,children:(0,x.jsx)(v.TabsList,{"aria-label":l.select.ungrouped,className:`zui:w-max zui:min-w-full`,children:st.map(e=>(0,x.jsx)(v.TabsTrigger,{value:e,className:`zui:flex-none`,children:e===te?l.select.ungrouped:A(e,u)},e))})}),(0,x.jsx)(`div`,{"data-slot":`select-group-swipe-area`,className:`zui:flex zui:min-h-0 zui:flex-1 zui:touch-pan-y zui:flex-col`,onPointerDown:Rt,onPointerUp:zt,onPointerCancel:()=>{it.current=null},onClickCapture:Bt,children:(0,x.jsx)(v.TabsContent,{value:X,className:i.cn(`zui:mt-0 zui:flex zui:min-h-0 zui:flex-1 zui:flex-col`,tt.enterFrom===`left`&&`zui:slide-in-from-left-8 zui:data-[state=active]:slide-in-from-bottom-0`,tt.enterFrom===`right`&&`zui:slide-in-from-right-8 zui:data-[state=active]:slide-in-from-bottom-0`),children:Wt},X)})]}):Wt,(0,x.jsx)(a.default,{label:l.common.close,fullWidth:!0,onClick:()=>c.setOpen(!1)})]});return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(C.Portal,{children:(0,x.jsx)(C.Content,{ref:i.mergeRefs(s,c.contentRef),"data-slot":`select-content`,dir:p,side:`bottom`,align:`start`,sideOffset:6,collisionPadding:8,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{c.fieldRootRef.current?.contains(e.target)&&e.preventDefault()},className:i.cn(y.selectContentVariants(),e),children:(0,x.jsxs)(`div`,{ref:bt,"data-slot":`select-viewport`,className:i.cn(y.selectViewportVariants({hasSearch:g}),`zui:max-h-72 zui:overflow-y-auto`),onScroll:Xe,children:[g?(0,x.jsx)(`div`,{"data-slot":`select-search`,className:y.selectSearchBarClassName,children:(0,x.jsxs)(`div`,{dir:p,className:`zui:flex zui:items-center zui:gap-1`,children:[(0,x.jsx)(`div`,{className:`zui:min-w-0 zui:flex-1`,children:(0,x.jsx)(d.default,{ref:j,type:`search`,dir:p,role:`combobox`,"aria-expanded":T,"aria-controls":k,"aria-autocomplete":`list`,"aria-activedescendant":D>=0?fe(k,D):void 0,"aria-label":l.common.searchPlaceholder,value:w,placeholder:l.common.searchPlaceholder,onChange:xt,onKeyDown:e=>{e.stopPropagation(),Mt(e)},onPointerDown:e=>e.stopPropagation()})}),_?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(f.IconActionButton,{label:l.select.clearAll,icon:(0,x.jsx)(S.X,{className:`zui:size-4 zui:text-[var(--zui-color-text)]`,"aria-hidden":`true`}),className:y.selectActionButtonClassName,disabled:Ft,onPointerDown:e=>e.stopPropagation(),onClick:()=>m?c.setMultiSelectedValues([]):c.clearSingleSelection()}),m?(0,x.jsx)(f.IconActionButton,{label:c.multiSelectAllLabel,icon:(0,x.jsx)(S.CheckCheck,{className:i.cn(ce,`zui:text-[var(--zui-color-text)]`),"aria-hidden":`true`}),className:y.selectActionButtonClassName,disabled:It,onPointerDown:e=>e.stopPropagation(),onClick:At}):null]}):null]})}):null,(0,x.jsx)(`div`,{ref:ht,id:k,role:`listbox`,"aria-multiselectable":m||void 0,"data-slot":`select-listbox`,style:Q?{position:`relative`,height:$.getTotalSize()}:void 0,children:Q?$.getVirtualItems().map(e=>{let t=q[e.index];return t?(0,x.jsx)(`div`,{ref:$.measureElement,"data-index":e.index,role:`presentation`,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start-dt}px)`},children:Vt(t,e.index,q.length)},e.key):null}):q.map((e,t)=>(0,x.jsx)(b.Fragment,{children:Vt(e,t)},O(e.value,e.group)))}),!Pt&&!G?(0,x.jsx)(`p`,{"data-slot":`select-empty`,className:`zui:px-2 zui:py-2 zui:text-xs zui:text-[var(--zui-color-text)]`,children:l.select.noResults}):null,G?(0,x.jsx)(Se,{}):null,He?(0,x.jsx)(`p`,{"data-slot":`select-error`,className:`zui:px-2 zui:py-2 zui:text-xs zui:text-[var(--zui-theme-status-danger)]`,children:He}):null,K?(0,x.jsx)(`div`,{ref:B,"data-slot":`select-infinite-scroll-sentinel`,"aria-hidden":`true`,className:`zui:h-px zui:w-full`}):null]})})}),(0,x.jsx)(o.default,{trigger:null,open:c.isModal,onOpenChange:e=>c.setOpen(e),dir:p,triggerLabel:c.modalLabel,showCloseButton:!1,onOpenAutoFocus:e=>e.preventDefault(),className:`zui:mobile:h-[75dvh] zui:mobile:touch-pan-y zui:mobile:overflow-x-hidden zui:mobile:overscroll-contain zui:mobile:px-3 zui:mobile:[&>[data-slot=dialog-body]]:flex zui:mobile:[&>[data-slot=dialog-body]]:min-h-0 zui:mobile:[&>[data-slot=dialog-body]]:flex-1 zui:mobile:[&>[data-slot=dialog-body]]:flex-col`,content:Gt})]})});exports.SelectContent=De,exports.SelectGroup=N,exports.SelectItem=M,exports.SelectLabel=P,exports.SelectSeparator=Ce,exports.SelectTrigger=Te,exports.SelectValue=I,exports.default=F;
|