wimui 0.54.0 → 0.56.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/data-display/Kanban/Kanban.cjs +1 -1
- package/dist/components/data-display/Kanban/Kanban.js +1 -1
- package/dist/components/form/CheckboxGroup/CheckboxGroup.cjs +1 -1
- package/dist/components/form/CheckboxGroup/CheckboxGroup.js +2 -2
- package/dist/components/form/CounterTextarea/CounterTextarea.cjs +1 -1
- package/dist/components/form/CounterTextarea/CounterTextarea.js +2 -2
- package/dist/components/form/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/form/ImageCropper/ImageCropper.d.ts +36 -4
- package/dist/components/form/ImageCropper/ImageCropper.js +151 -103
- package/dist/components/form/ImageCropper/cropImage.cjs +2 -0
- package/dist/components/form/ImageCropper/cropImage.d.ts +58 -0
- package/dist/components/form/ImageCropper/cropImage.js +36 -0
- package/dist/components/form/ImageCropper/image-cropper.module.cjs +1 -1
- package/dist/components/form/ImageCropper/image-cropper.module.js +1 -1
- package/dist/components/form/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/components/form/RadioGroup/RadioGroup.js +2 -2
- package/dist/components/form/SwitchGroup/SwitchGroup.cjs +1 -1
- package/dist/components/form/SwitchGroup/SwitchGroup.js +2 -2
- package/dist/components/form/TagInput/TagInput.cjs +1 -1
- package/dist/components/form/TagInput/TagInput.js +37 -36
- package/dist/components/form/ToggleGroup/ToggleGroup.cjs +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/components/form/ToggleGroup/ToggleGroup.js +46 -46
- package/dist/components/navigation/Anchor/Anchor.cjs +1 -1
- package/dist/components/navigation/Anchor/Anchor.js +54 -45
- package/dist/components/overlay/Dialog/Dialog.cjs +1 -1
- package/dist/components/overlay/Dialog/Dialog.js +2 -2
- package/dist/components/overlay/Drawer/Drawer.cjs +1 -1
- package/dist/components/overlay/Drawer/Drawer.js +3 -3
- package/dist/i18n/generated/form.cjs +1 -1
- package/dist/i18n/generated/form.d.ts +1 -1
- package/dist/i18n/generated/form.js +6 -0
- package/dist/llms-full.txt +17 -3
- package/dist/llms.txt +1 -1
- package/dist/locales/en/form.json +2 -0
- package/dist/locales/ja/form.json +2 -0
- package/dist/locales/pt/form.json +2 -0
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../FieldTemplate/FieldTemplate.cjs"),r=require("../Switch/Switch.cjs"),i=require("./switch-group.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)(({options:e,value:c,defaultValue:l=[],onChange:u,direction:d=`vertical`,name:f,className:p,label:m,error:h,required:g,disabled:_,asChild:v=!1,children:y,...b},x)=>{let S=c!==void 0,[C,w]=(0,a.useState)(l),T=`wim-switch-group-${(0,a.useId)()}`,E=`${T}-label`,D=h?`${T}-error`:void 0,O=S?c:C,k=(e,t)=>{let n;n=t?[...O||[],e]:(O||[]).filter(t=>t!==e),S||w(n),u&&u(n)};return(0,s.jsx)(n.FieldTemplate,{label:m,error:h,required:g,labelId:E,errorId:D,className:p,children:(0,s.jsxs)(v?t.Root:`div`,{...b,ref:x,className:(0,o.default)(`wim-switch-group`,i.default.root,d===`horizontal`&&i.default.horizontal),role:`group`,"aria-labelledby":m?E:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../FieldTemplate/FieldTemplate.cjs"),r=require("../Switch/Switch.cjs"),i=require("./switch-group.module.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("classnames");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=(0,a.forwardRef)(({options:e,value:c,defaultValue:l=[],onChange:u,direction:d=`vertical`,name:f,className:p,label:m,error:h,required:g,disabled:_,asChild:v=!1,children:y,...b},x)=>{let S=c!==void 0,[C,w]=(0,a.useState)(l),T=`wim-switch-group-${(0,a.useId)()}`,E=`${T}-label`,D=h?`${T}-error`:void 0,O=S?c:C,k=(e,t)=>{let n;n=t?[...O||[],e]:(O||[]).filter(t=>t!==e),S||w(n),u&&u(n)};return(0,s.jsx)(n.FieldTemplate,{label:m,error:h,required:g,labelId:E,errorId:D,className:p,children:(0,s.jsxs)(v?t.Root:`div`,{...b,ref:x,className:(0,o.default)(`wim-switch-group`,i.default.root,d===`horizontal`&&i.default.horizontal),role:`group`,"aria-labelledby":m?E:b[`aria-labelledby`],"aria-describedby":[b[`aria-describedby`],D].filter(Boolean).join(` `)||void 0,children:[(0,s.jsx)(t.Slottable,{children:e.map(e=>(0,s.jsx)(r.Switch,{value:e.value,checked:(O||[]).includes(e.value),disabled:_||e.disabled,error:!!h,name:f,onChange:t=>k(e.value,t.target.checked),children:e.label},e.value))}),y]})})});c.displayName=`SwitchGroup`,exports.SwitchGroup=c,exports.default=c;
|
|
@@ -24,8 +24,8 @@ var d = a(({ options: a, value: d, defaultValue: f = [], onChange: p, direction:
|
|
|
24
24
|
ref: w,
|
|
25
25
|
className: c("wim-switch-group", i.root, m === "horizontal" && i.horizontal),
|
|
26
26
|
role: "group",
|
|
27
|
-
"aria-labelledby": _ ? k :
|
|
28
|
-
"aria-describedby": A,
|
|
27
|
+
"aria-labelledby": _ ? k : C["aria-labelledby"],
|
|
28
|
+
"aria-describedby": [C["aria-describedby"], A].filter(Boolean).join(" ") || void 0,
|
|
29
29
|
children: [/* @__PURE__ */ l(t, { children: a.map((e) => /* @__PURE__ */ l(r, {
|
|
30
30
|
value: e.value,
|
|
31
31
|
checked: (j || []).includes(e.value),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../InputBase/InputBase.cjs"),r=require("../../../i18n/generated/form.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../data-display/Tag/Tag.cjs"),o=require("./tag-input.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=s.default.forwardRef(({value:e,defaultValue:u=[],onChange:d,placeholder:f,disabled:p=!1,intent:m=`default`,variant:h=`outline`,fullWidth:g=!1,width:_,label:v,error:y,required:b,layout:x,allowDelete:S=!0,maxTags:C,className:w,...
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../InputBase/InputBase.cjs"),r=require("../../../i18n/generated/form.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../data-display/Tag/Tag.cjs"),o=require("./tag-input.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=s.default.forwardRef(({value:e,defaultValue:u=[],onChange:d,placeholder:f,disabled:p=!1,intent:m=`default`,variant:h=`outline`,fullWidth:g=!1,width:_,label:v,error:y,required:b,layout:x,allowDelete:S=!0,maxTags:C,className:w,id:T,"aria-label":E,"aria-labelledby":D,"aria-describedby":O,...k},A)=>{let[j,M]=(0,s.useState)(u),[N,P]=(0,s.useState)(``),F=(0,s.useRef)(null),I=e!==void 0,L=I?e:j,R=f,z=e=>{P(e.target.value)},B=e=>{let t=e.trim();if(!t)return;if(L.includes(t)){P(``);return}if(C&&L.length>=C)return;let n=[...L,t];I||M(n),d?.(n),P(``)},V=e=>{if(p||!S)return;let t=L.filter(t=>t!==e);I||M(t),d?.(t)},H=e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),B(N)):e.key===`Backspace`&&N===``&&L.length>0&&V(L[L.length-1])},U=()=>{F.current?.focus()},{t:W}=t.useWimTranslation(r.formNs),G=(0,s.useId)(),K=T||`wim-tag-input-${G}`,q=y?`${K}-error`:void 0,J=v?`${K}-label`:void 0,Y=y?`danger`:m;return(0,l.jsx)(i.FieldTemplate,{...k,ref:A,label:v,error:y,required:b,layout:x,labelId:J,htmlFor:K,errorId:q,className:(0,c.default)(`wim-tag-input`,w),children:(0,l.jsx)(n.InputBase,{intent:Y,variant:h,fullWidth:g,width:_,disabled:p,className:o.default.inputBase,styles:{inner:o.default.inputBaseInner},children:(0,l.jsx)(`div`,{className:(0,c.default)(o.default.container,{[o.default.disabled]:p}),onClick:U,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&U()},role:`presentation`,children:(0,l.jsxs)(`div`,{className:o.default.tagList,children:[L.map(e=>(0,l.jsx)(a.Tag,{variant:`solid`,intent:`neutral`,size:`sm`,disabled:p,onDelete:S&&!p?()=>V(e):void 0,className:o.default.tag,children:e},e)),(0,l.jsx)(`input`,{id:K,ref:F,type:`text`,value:N,onChange:z,onKeyDown:H,disabled:p,placeholder:L.length===0?R:``,className:o.default.input,"aria-invalid":Y===`danger`,"aria-describedby":[O,q].filter(Boolean).join(` `)||void 0,"aria-labelledby":v?J:D,"aria-label":v||D?void 0:E??W(`tag_input.input_label`),"aria-required":b})]})})})})});u.displayName=`TagInput`,exports.TagInput=u;
|
|
@@ -9,40 +9,41 @@ import o, { useId as s, useRef as c, useState as l } from "react";
|
|
|
9
9
|
import u from "classnames";
|
|
10
10
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/TagInput/TagInput.tsx
|
|
12
|
-
var p = o.forwardRef(({ value: o, defaultValue: p = [], onChange: m, placeholder: h, disabled: g = !1, intent: _ = "default", variant: v = "outline", fullWidth: y = !1, width: b, label: x, error: S, required: C, layout: w, allowDelete: T = !0, maxTags: E, className: D,
|
|
13
|
-
let [
|
|
14
|
-
|
|
15
|
-
},
|
|
12
|
+
var p = o.forwardRef(({ value: o, defaultValue: p = [], onChange: m, placeholder: h, disabled: g = !1, intent: _ = "default", variant: v = "outline", fullWidth: y = !1, width: b, label: x, error: S, required: C, layout: w, allowDelete: T = !0, maxTags: E, className: D, id: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, ...M }, N) => {
|
|
13
|
+
let [P, F] = l(p), [I, L] = l(""), R = c(null), z = o !== void 0, B = z ? o : P, V = h, H = (e) => {
|
|
14
|
+
L(e.target.value);
|
|
15
|
+
}, U = (e) => {
|
|
16
16
|
let t = e.trim();
|
|
17
17
|
if (!t) return;
|
|
18
|
-
if (
|
|
19
|
-
|
|
18
|
+
if (B.includes(t)) {
|
|
19
|
+
L("");
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
if (E &&
|
|
23
|
-
let n = [...
|
|
24
|
-
|
|
25
|
-
},
|
|
22
|
+
if (E && B.length >= E) return;
|
|
23
|
+
let n = [...B, t];
|
|
24
|
+
z || F(n), m?.(n), L("");
|
|
25
|
+
}, W = (e) => {
|
|
26
26
|
if (g || !T) return;
|
|
27
|
-
let t =
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
e.key === "Enter" || e.key === "," ? (e.preventDefault(),
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
}, { t:
|
|
27
|
+
let t = B.filter((t) => t !== e);
|
|
28
|
+
z || F(t), m?.(t);
|
|
29
|
+
}, G = (e) => {
|
|
30
|
+
e.key === "Enter" || e.key === "," ? (e.preventDefault(), U(I)) : e.key === "Backspace" && I === "" && B.length > 0 && W(B[B.length - 1]);
|
|
31
|
+
}, K = () => {
|
|
32
|
+
R.current?.focus();
|
|
33
|
+
}, { t: q } = e(n), J = s(), Y = O || `wim-tag-input-${J}`, X = S ? `${Y}-error` : void 0, Z = x ? `${Y}-label` : void 0, Q = S ? "danger" : _;
|
|
34
34
|
return /* @__PURE__ */ d(r, {
|
|
35
|
-
|
|
35
|
+
...M,
|
|
36
|
+
ref: N,
|
|
36
37
|
label: x,
|
|
37
38
|
error: S,
|
|
38
39
|
required: C,
|
|
39
40
|
layout: w,
|
|
40
|
-
labelId:
|
|
41
|
-
htmlFor:
|
|
42
|
-
errorId:
|
|
41
|
+
labelId: Z,
|
|
42
|
+
htmlFor: Y,
|
|
43
|
+
errorId: X,
|
|
43
44
|
className: u("wim-tag-input", D),
|
|
44
45
|
children: /* @__PURE__ */ d(t, {
|
|
45
|
-
intent:
|
|
46
|
+
intent: Q,
|
|
46
47
|
variant: v,
|
|
47
48
|
fullWidth: y,
|
|
48
49
|
width: b,
|
|
@@ -51,35 +52,35 @@ var p = o.forwardRef(({ value: o, defaultValue: p = [], onChange: m, placeholder
|
|
|
51
52
|
styles: { inner: a.inputBaseInner },
|
|
52
53
|
children: /* @__PURE__ */ d("div", {
|
|
53
54
|
className: u(a.container, { [a.disabled]: g }),
|
|
54
|
-
onClick:
|
|
55
|
+
onClick: K,
|
|
55
56
|
onKeyDown: (e) => {
|
|
56
|
-
(e.key === "Enter" || e.key === " ") &&
|
|
57
|
+
(e.key === "Enter" || e.key === " ") && K();
|
|
57
58
|
},
|
|
58
59
|
role: "presentation",
|
|
59
60
|
children: /* @__PURE__ */ f("div", {
|
|
60
61
|
className: a.tagList,
|
|
61
|
-
children: [
|
|
62
|
+
children: [B.map((e) => /* @__PURE__ */ d(i, {
|
|
62
63
|
variant: "solid",
|
|
63
64
|
intent: "neutral",
|
|
64
65
|
size: "sm",
|
|
65
66
|
disabled: g,
|
|
66
|
-
onDelete: T && !g ? () =>
|
|
67
|
+
onDelete: T && !g ? () => W(e) : void 0,
|
|
67
68
|
className: a.tag,
|
|
68
69
|
children: e
|
|
69
70
|
}, e)), /* @__PURE__ */ d("input", {
|
|
70
|
-
id:
|
|
71
|
-
ref:
|
|
71
|
+
id: Y,
|
|
72
|
+
ref: R,
|
|
72
73
|
type: "text",
|
|
73
|
-
value:
|
|
74
|
-
onChange:
|
|
75
|
-
onKeyDown:
|
|
74
|
+
value: I,
|
|
75
|
+
onChange: H,
|
|
76
|
+
onKeyDown: G,
|
|
76
77
|
disabled: g,
|
|
77
|
-
placeholder:
|
|
78
|
+
placeholder: B.length === 0 ? V : "",
|
|
78
79
|
className: a.input,
|
|
79
|
-
"aria-invalid":
|
|
80
|
-
"aria-describedby":
|
|
81
|
-
"aria-labelledby": x ?
|
|
82
|
-
"aria-label": x ? void 0 :
|
|
80
|
+
"aria-invalid": Q === "danger",
|
|
81
|
+
"aria-describedby": [j, X].filter(Boolean).join(" ") || void 0,
|
|
82
|
+
"aria-labelledby": x ? Z : A,
|
|
83
|
+
"aria-label": x || A ? void 0 : k ?? q("tag_input.input_label"),
|
|
83
84
|
"aria-required": C
|
|
84
85
|
})]
|
|
85
86
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./toggle-group.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(0,s.forwardRef)(({options:e,value:u,defaultValue:d,onChange:f,selectionMode:p=`single`,size:m=`md`,fullWidth:h=!1,className:g,"aria-label":_,"aria-labelledby":v,disabled:
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../../hooks/useMergedRef.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../FieldTemplate/FieldTemplate.cjs"),a=require("../../_internal/useIndicator.cjs"),o=require("./toggle-group.module.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("classnames");c=e.__toESM(c,1);let l=require("react/jsx-runtime");var u=(0,s.forwardRef)(({options:e,value:u,defaultValue:d,onChange:f,selectionMode:p=`single`,size:m=`md`,fullWidth:h=!1,className:g,"aria-label":_,"aria-labelledby":v,"aria-describedby":y,disabled:b=!1,label:x,error:S,required:C,layout:w=`vertical`,id:T,asChild:E=!1,children:D},O)=>{let k=s.default.useId(),A=T||`wim-toggle-group-${k}`,j=`${A}-label`,M=`${A}-error`,N=u!==void 0,[P,F]=(0,s.useState)(d??(p===`multiple`?[]:``)),I=N?u:P,{containerRef:L,sliderStyle:R,isReady:z}=a.useIndicator({activeSelector:`.${o.default.active}`,dependence:e.length}),B=(0,s.useRef)([]),V=e.findIndex(e=>!e.disabled),[H,U]=(0,s.useState)(()=>{if(p===`single`){let t=N?u:d;if(typeof t==`string`){let n=e.findIndex(e=>!e.disabled&&e.value===t);if(n>=0)return n}}return V>=0?V:0});(0,s.useEffect)(()=>{if(p===`single`&&N&&typeof u==`string`){let t=e.findIndex(e=>!e.disabled&&e.value===u);t>=0&&U(t)}},[u,p,N,e]);let W=e=>{let t;if(p===`multiple`){let n=Array.isArray(I)?I:[];t=n.includes(e)?n.filter(t=>t!==e):[...n,e]}else t=I===e?``:e;N||F(t),f?.(t)},G=e=>p===`multiple`?(Array.isArray(I)?I:[]).includes(e):I===e,K=(t,n)=>{for(let r=1;r<=e.length;r++){let i=(t+n*r+e.length)%e.length;if(!e[i].disabled)return i}return t},q=(t,n)=>{let r=null;if(n.key===`ArrowRight`||n.key===`ArrowDown`)n.preventDefault(),r=K(t,1);else if(n.key===`ArrowLeft`||n.key===`ArrowUp`)n.preventDefault(),r=K(t,-1);else if(n.key===`Home`)n.preventDefault(),r=V>=0?V:null;else if(n.key===`End`){n.preventDefault();for(let t=e.length-1;t>=0;t--)if(!e[t].disabled){r=t;break}}r!==null&&r!==t&&(U(r),B.current[r]?.focus(),p===`single`&&W(e[r].value))},J=p===`single`?`radiogroup`:`toolbar`,Y=`${A}-item-0`;return(0,l.jsx)(i.FieldTemplate,{label:x,error:S,required:C,layout:w,labelId:j,htmlFor:Y,errorId:M,className:g,children:(0,l.jsxs)(E?t.Root:`div`,{ref:n.useMergedRef(L,O),id:A,className:(0,c.default)(`wim-toggle-group`,o.default.root,o.default[m],o.default[p],h&&o.default.fullWidth,z&&o.default.ready,S&&o.default.danger),role:J,"aria-label":_,"aria-labelledby":x?j:v,"aria-orientation":`horizontal`,"aria-invalid":S?!0:void 0,"aria-describedby":[y,S?M:void 0].filter(Boolean).join(` `)||void 0,children:[(0,l.jsx)(`div`,{className:(0,c.default)(o.default.slider,o.default[p],z&&o.default.ready),style:R,"aria-hidden":`true`}),e.map((e,t)=>{let n=`${A}-item-${t}`;return(0,l.jsxs)(`button`,{id:n,ref:e=>{B.current[t]=e},type:`button`,className:(0,c.default)(o.default.item,o.default[p],G(e.value)&&o.default.active,!e.label&&e.iconName&&o.default.iconOnly),onClick:()=>{U(t),W(e.value)},onKeyDown:e=>q(t,e),disabled:b||e.disabled,role:p===`single`?`radio`:`button`,"aria-checked":p===`single`?G(e.value):void 0,"aria-pressed":p===`multiple`?G(e.value):void 0,"aria-label":e.label||e.value,tabIndex:!e.disabled&&t===H?0:-1,children:[e.iconName&&(0,l.jsx)(r.Icon,{name:e.iconName,size:m,className:o.default.icon}),e.label&&(0,l.jsx)(`span`,{children:e.label})]},e.value)}),(0,l.jsx)(t.Slottable,{children:D})]})})});u.displayName=`ToggleGroup`,exports.ToggleGroup=u;
|
|
@@ -46,6 +46,8 @@ type ToggleGroupProps = {
|
|
|
46
46
|
"aria-label"?: string;
|
|
47
47
|
/** ID of the element that labels the group */
|
|
48
48
|
"aria-labelledby"?: string;
|
|
49
|
+
/** ID of the element that describes the group, such as help text */
|
|
50
|
+
"aria-describedby"?: string;
|
|
49
51
|
};
|
|
50
52
|
/**
|
|
51
53
|
* ToggleGroup component allows users to select one or multiple options from a set of buttons.
|
|
@@ -9,49 +9,49 @@ import s, { forwardRef as c, useEffect as l, useRef as u, useState as d } from "
|
|
|
9
9
|
import f from "classnames";
|
|
10
10
|
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/form/ToggleGroup/ToggleGroup.tsx
|
|
12
|
-
var h = c(({ options: c, value: h, defaultValue: g, onChange: _, selectionMode: v = "single", size: y = "md", fullWidth: b = !1, className: x, "aria-label": S, "aria-labelledby": C,
|
|
13
|
-
let
|
|
12
|
+
var h = c(({ options: c, value: h, defaultValue: g, onChange: _, selectionMode: v = "single", size: y = "md", fullWidth: b = !1, className: x, "aria-label": S, "aria-labelledby": C, "aria-describedby": w, disabled: T = !1, label: E, error: D, required: O, layout: k = "vertical", id: A, asChild: j = !1, children: M }, N) => {
|
|
13
|
+
let P = s.useId(), F = A || `wim-toggle-group-${P}`, I = `${F}-label`, L = `${F}-error`, R = h !== void 0, [z, B] = d(g ?? (v === "multiple" ? [] : "")), V = R ? h : z, { containerRef: H, sliderStyle: U, isReady: W } = a({
|
|
14
14
|
activeSelector: `.${o.active}`,
|
|
15
15
|
dependence: c.length
|
|
16
|
-
}),
|
|
16
|
+
}), G = u([]), K = c.findIndex((e) => !e.disabled), [q, J] = d(() => {
|
|
17
17
|
if (v === "single") {
|
|
18
|
-
let e =
|
|
18
|
+
let e = R ? h : g;
|
|
19
19
|
if (typeof e == "string") {
|
|
20
20
|
let t = c.findIndex((t) => !t.disabled && t.value === e);
|
|
21
21
|
if (t >= 0) return t;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return K >= 0 ? K : 0;
|
|
25
25
|
});
|
|
26
26
|
l(() => {
|
|
27
|
-
if (v === "single" &&
|
|
27
|
+
if (v === "single" && R && typeof h == "string") {
|
|
28
28
|
let e = c.findIndex((e) => !e.disabled && e.value === h);
|
|
29
|
-
e >= 0 &&
|
|
29
|
+
e >= 0 && J(e);
|
|
30
30
|
}
|
|
31
31
|
}, [
|
|
32
32
|
h,
|
|
33
33
|
v,
|
|
34
|
-
|
|
34
|
+
R,
|
|
35
35
|
c
|
|
36
36
|
]);
|
|
37
|
-
let
|
|
37
|
+
let Y = (e) => {
|
|
38
38
|
let t;
|
|
39
39
|
if (v === "multiple") {
|
|
40
|
-
let n = Array.isArray(
|
|
40
|
+
let n = Array.isArray(V) ? V : [];
|
|
41
41
|
t = n.includes(e) ? n.filter((t) => t !== e) : [...n, e];
|
|
42
|
-
} else t =
|
|
43
|
-
|
|
44
|
-
},
|
|
42
|
+
} else t = V === e ? "" : e;
|
|
43
|
+
R || B(t), _?.(t);
|
|
44
|
+
}, X = (e) => v === "multiple" ? (Array.isArray(V) ? V : []).includes(e) : V === e, Z = (e, t) => {
|
|
45
45
|
for (let n = 1; n <= c.length; n++) {
|
|
46
46
|
let r = (e + t * n + c.length) % c.length;
|
|
47
47
|
if (!c[r].disabled) return r;
|
|
48
48
|
}
|
|
49
49
|
return e;
|
|
50
|
-
},
|
|
50
|
+
}, Q = (e, t) => {
|
|
51
51
|
let n = null;
|
|
52
|
-
if (t.key === "ArrowRight" || t.key === "ArrowDown") t.preventDefault(), n =
|
|
53
|
-
else if (t.key === "ArrowLeft" || t.key === "ArrowUp") t.preventDefault(), n =
|
|
54
|
-
else if (t.key === "Home") t.preventDefault(), n =
|
|
52
|
+
if (t.key === "ArrowRight" || t.key === "ArrowDown") t.preventDefault(), n = Z(e, 1);
|
|
53
|
+
else if (t.key === "ArrowLeft" || t.key === "ArrowUp") t.preventDefault(), n = Z(e, -1);
|
|
54
|
+
else if (t.key === "Home") t.preventDefault(), n = K >= 0 ? K : null;
|
|
55
55
|
else if (t.key === "End") {
|
|
56
56
|
t.preventDefault();
|
|
57
57
|
for (let e = c.length - 1; e >= 0; e--) if (!c[e].disabled) {
|
|
@@ -59,52 +59,52 @@ var h = c(({ options: c, value: h, defaultValue: g, onChange: _, selectionMode:
|
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
n !== null && n !== e && (
|
|
63
|
-
},
|
|
62
|
+
n !== null && n !== e && (J(n), G.current[n]?.focus(), v === "single" && Y(c[n].value));
|
|
63
|
+
}, $ = v === "single" ? "radiogroup" : "toolbar", ee = `${F}-item-0`;
|
|
64
64
|
return /* @__PURE__ */ p(i, {
|
|
65
|
-
label:
|
|
66
|
-
error:
|
|
67
|
-
required:
|
|
68
|
-
layout:
|
|
69
|
-
labelId:
|
|
70
|
-
htmlFor:
|
|
71
|
-
errorId:
|
|
65
|
+
label: E,
|
|
66
|
+
error: D,
|
|
67
|
+
required: O,
|
|
68
|
+
layout: k,
|
|
69
|
+
labelId: I,
|
|
70
|
+
htmlFor: ee,
|
|
71
|
+
errorId: L,
|
|
72
72
|
className: x,
|
|
73
|
-
children: /* @__PURE__ */ m(
|
|
74
|
-
ref: n(
|
|
75
|
-
id:
|
|
76
|
-
className: f("wim-toggle-group", o.root, o[y], o[v], b && o.fullWidth,
|
|
77
|
-
role:
|
|
73
|
+
children: /* @__PURE__ */ m(j ? e : "div", {
|
|
74
|
+
ref: n(H, N),
|
|
75
|
+
id: F,
|
|
76
|
+
className: f("wim-toggle-group", o.root, o[y], o[v], b && o.fullWidth, W && o.ready, D && o.danger),
|
|
77
|
+
role: $,
|
|
78
78
|
"aria-label": S,
|
|
79
|
-
"aria-labelledby":
|
|
79
|
+
"aria-labelledby": E ? I : C,
|
|
80
80
|
"aria-orientation": "horizontal",
|
|
81
|
-
"aria-invalid":
|
|
82
|
-
"aria-describedby":
|
|
81
|
+
"aria-invalid": D ? !0 : void 0,
|
|
82
|
+
"aria-describedby": [w, D ? L : void 0].filter(Boolean).join(" ") || void 0,
|
|
83
83
|
children: [
|
|
84
84
|
/* @__PURE__ */ p("div", {
|
|
85
|
-
className: f(o.slider, o[v],
|
|
86
|
-
style:
|
|
85
|
+
className: f(o.slider, o[v], W && o.ready),
|
|
86
|
+
style: U,
|
|
87
87
|
"aria-hidden": "true"
|
|
88
88
|
}),
|
|
89
89
|
c.map((e, t) => {
|
|
90
|
-
let n = `${
|
|
90
|
+
let n = `${F}-item-${t}`;
|
|
91
91
|
return /* @__PURE__ */ m("button", {
|
|
92
92
|
id: n,
|
|
93
93
|
ref: (e) => {
|
|
94
|
-
|
|
94
|
+
G.current[t] = e;
|
|
95
95
|
},
|
|
96
96
|
type: "button",
|
|
97
|
-
className: f(o.item, o[v],
|
|
97
|
+
className: f(o.item, o[v], X(e.value) && o.active, !e.label && e.iconName && o.iconOnly),
|
|
98
98
|
onClick: () => {
|
|
99
|
-
|
|
99
|
+
J(t), Y(e.value);
|
|
100
100
|
},
|
|
101
|
-
onKeyDown: (e) =>
|
|
102
|
-
disabled:
|
|
101
|
+
onKeyDown: (e) => Q(t, e),
|
|
102
|
+
disabled: T || e.disabled,
|
|
103
103
|
role: v === "single" ? "radio" : "button",
|
|
104
|
-
"aria-checked": v === "single" ?
|
|
105
|
-
"aria-pressed": v === "multiple" ?
|
|
104
|
+
"aria-checked": v === "single" ? X(e.value) : void 0,
|
|
105
|
+
"aria-pressed": v === "multiple" ? X(e.value) : void 0,
|
|
106
106
|
"aria-label": e.label || e.value,
|
|
107
|
-
tabIndex: !e.disabled && t ===
|
|
107
|
+
tabIndex: !e.disabled && t === q ? 0 : -1,
|
|
108
108
|
children: [e.iconName && /* @__PURE__ */ p(r, {
|
|
109
109
|
name: e.iconName,
|
|
110
110
|
size: y,
|
|
@@ -112,7 +112,7 @@ var h = c(({ options: c, value: h, defaultValue: g, onChange: _, selectionMode:
|
|
|
112
112
|
}), e.label && /* @__PURE__ */ p("span", { children: e.label })]
|
|
113
113
|
}, e.value);
|
|
114
114
|
}),
|
|
115
|
-
/* @__PURE__ */ p(t, { children:
|
|
115
|
+
/* @__PURE__ */ p(t, { children: M })
|
|
116
116
|
]
|
|
117
117
|
})
|
|
118
118
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l})=>{let[u,d]=(0,n.useState)(``),[f,p]=(0,n.useState)({}),m=(0,n.useRef)(null),h=(e,t)=>{e.preventDefault();let n=t.replace(`#`,``),r=document.getElementById(n);r&&(window.scrollTo({top:r.offsetTop-o,behavior:`smooth`}),d(t))};(0,n.useLayoutEffect)(()=>{let t=()=>{let t=(e,n)=>{let r=[];return e.forEach(e=>{r.push({href:e.href,parentHref:n}),e.children&&(r=r.concat(t(e.children,n||e.href)))}),r},n=t(e),r=``,i=window.scrollY||document.documentElement.scrollTop,c=document.documentElement.scrollHeight,l=document.documentElement.clientHeight;if(i>0&&Math.ceil(i+l)>=c&&n.length>0){let e=n[n.length-1];r=s===`horizontal`&&e.parentHref?e.parentHref:e.href}else for(let e of n){let t=e.href.replace(`#`,``),n=document.getElementById(t);if(n){if(n.getBoundingClientRect().top<=o+a)r=s===`horizontal`&&e.parentHref?e.parentHref:e.href;else break}}r&&r!==u&&d(r)};return window.addEventListener(`scroll`,t),t(),()=>window.removeEventListener(`scroll`,t)},[e,o,a,u,s])
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./anchor.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({items:e=[],bounds:a=5,offset:o=0,direction:s=`vertical`,className:c,style:l})=>{let[u,d]=(0,n.useState)(``),[f,p]=(0,n.useState)({}),m=(0,n.useRef)(null),h=(e,t)=>{e.preventDefault();let n=t.replace(`#`,``),r=document.getElementById(n);r&&(window.scrollTo({top:r.offsetTop-o,behavior:`smooth`}),d(t))};(0,n.useLayoutEffect)(()=>{let t=()=>{let t=(e,n)=>{let r=[];return e.forEach(e=>{r.push({href:e.href,parentHref:n}),e.children&&(r=r.concat(t(e.children,n||e.href)))}),r},n=t(e),r=``,i=window.scrollY||document.documentElement.scrollTop,c=document.documentElement.scrollHeight,l=document.documentElement.clientHeight;if(i>0&&Math.ceil(i+l)>=c&&n.length>0){let e=n[n.length-1];r=s===`horizontal`&&e.parentHref?e.parentHref:e.href}else for(let e of n){let t=e.href.replace(`#`,``),n=document.getElementById(t);if(n){if(n.getBoundingClientRect().top<=o+a)r=s===`horizontal`&&e.parentHref?e.parentHref:e.href;else break}}r&&r!==u&&d(r)};return window.addEventListener(`scroll`,t),t(),()=>window.removeEventListener(`scroll`,t)},[e,o,a,u,s]);let g=(0,n.useCallback)(()=>{if(!u||!m.current)return;let e=m.current.querySelector(`a[href="${u}"]`);if(e){let n=m.current.getBoundingClientRect();if(s===`vertical`){let t=e.getBoundingClientRect();p({top:t.top-n.top,height:t.height,opacity:1})}else{let r=m.current.querySelector(`.${t.default.list}`);if(r){let t=e.getBoundingClientRect(),i=r.getBoundingClientRect(),a=t.left-i.left+r.scrollLeft,o=a-i.width/2+t.width/2,s=r.scrollWidth-i.width,c=Math.max(0,Math.min(o,s)),l=a-c+(i.left-n.left);p({left:l,width:t.width,opacity:1}),r.scrollTo({left:c,behavior:`smooth`})}else{let t=e.getBoundingClientRect();p({left:t.left-m.current.getBoundingClientRect().left,width:t.width,opacity:1})}}}else p({opacity:0})},[u,s]);(0,n.useLayoutEffect)(()=>{g()},[g]),(0,n.useEffect)(()=>{let e=m.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>g());return t.observe(e),e.querySelectorAll(`a`).forEach(e=>t.observe(e)),()=>t.disconnect()},[g,e]);let _=e=>(0,i.jsx)(`ul`,{className:(0,r.default)(t.default.list,t.default[s]),children:e.map(e=>(0,i.jsxs)(`li`,{className:(0,r.default)(t.default.item,u===e.href&&t.default.active),children:[(0,i.jsx)(`a`,{href:e.href,className:t.default.link,"aria-current":u===e.href?`location`:void 0,onClick:t=>h(t,e.href),title:typeof e.title==`string`?e.title:void 0,children:e.title}),e.children&&s===`vertical`&&_(e.children)]},e.key))});return(0,i.jsxs)(`div`,{className:(0,r.default)(`wim-anchor`,t.default.root,t.default[s],c),style:l,ref:m,children:[(0,i.jsx)(`div`,{className:t.default.ink,children:(0,i.jsx)(`span`,{className:t.default.inkBall,style:f})}),_(e)]})};exports.Anchor=a,exports.default=a;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import e from "./anchor.module.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { jsx as
|
|
3
|
+
import { useCallback as t, useEffect as n, useLayoutEffect as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import o from "classnames";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/navigation/Anchor/Anchor.tsx
|
|
7
|
-
var
|
|
8
|
-
let [
|
|
7
|
+
var l = ({ items: l = [], bounds: u = 5, offset: d = 0, direction: f = "vertical", className: p, style: m }) => {
|
|
8
|
+
let [h, g] = a(""), [_, v] = a({}), y = i(null), b = (e, t) => {
|
|
9
9
|
e.preventDefault();
|
|
10
10
|
let n = t.replace("#", ""), r = document.getElementById(n);
|
|
11
11
|
r && (window.scrollTo({
|
|
12
|
-
top: r.offsetTop -
|
|
12
|
+
top: r.offsetTop - d,
|
|
13
13
|
behavior: "smooth"
|
|
14
|
-
}),
|
|
14
|
+
}), g(t));
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
r(() => {
|
|
17
17
|
let e = () => {
|
|
18
18
|
let e = (t, n) => {
|
|
19
19
|
let r = [];
|
|
@@ -23,43 +23,44 @@ var s = ({ items: s = [], bounds: c = 5, offset: l = 0, direction: u = "vertical
|
|
|
23
23
|
parentHref: n
|
|
24
24
|
}), t.children && (r = r.concat(e(t.children, n || t.href)));
|
|
25
25
|
}), r;
|
|
26
|
-
}, t = e(
|
|
26
|
+
}, t = e(l), n = "", r = window.scrollY || document.documentElement.scrollTop, i = document.documentElement.scrollHeight, a = document.documentElement.clientHeight;
|
|
27
27
|
if (r > 0 && Math.ceil(r + a) >= i && t.length > 0) {
|
|
28
28
|
let e = t[t.length - 1];
|
|
29
|
-
n =
|
|
29
|
+
n = f === "horizontal" && e.parentHref ? e.parentHref : e.href;
|
|
30
30
|
} else for (let e of t) {
|
|
31
31
|
let t = e.href.replace("#", ""), r = document.getElementById(t);
|
|
32
32
|
if (r) {
|
|
33
|
-
if (r.getBoundingClientRect().top <=
|
|
33
|
+
if (r.getBoundingClientRect().top <= d + u) n = f === "horizontal" && e.parentHref ? e.parentHref : e.href;
|
|
34
34
|
else break;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
n && n !==
|
|
37
|
+
n && n !== h && g(n);
|
|
38
38
|
};
|
|
39
39
|
return window.addEventListener("scroll", e), e(), () => window.removeEventListener("scroll", e);
|
|
40
40
|
}, [
|
|
41
|
-
s,
|
|
42
41
|
l,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
d,
|
|
43
|
+
u,
|
|
44
|
+
h,
|
|
45
|
+
f
|
|
46
|
+
]);
|
|
47
|
+
let x = t(() => {
|
|
48
|
+
if (!h || !y.current) return;
|
|
49
|
+
let t = y.current.querySelector(`a[href="${h}"]`);
|
|
49
50
|
if (t) {
|
|
50
|
-
let n =
|
|
51
|
-
if (
|
|
51
|
+
let n = y.current.getBoundingClientRect();
|
|
52
|
+
if (f === "vertical") {
|
|
52
53
|
let e = t.getBoundingClientRect();
|
|
53
|
-
|
|
54
|
+
v({
|
|
54
55
|
top: e.top - n.top,
|
|
55
56
|
height: e.height,
|
|
56
57
|
opacity: 1
|
|
57
58
|
});
|
|
58
59
|
} else {
|
|
59
|
-
let r =
|
|
60
|
+
let r = y.current.querySelector(`.${e.list}`);
|
|
60
61
|
if (r) {
|
|
61
62
|
let e = t.getBoundingClientRect(), i = r.getBoundingClientRect(), a = e.left - i.left + r.scrollLeft, o = a - i.width / 2 + e.width / 2, s = r.scrollWidth - i.width, c = Math.max(0, Math.min(o, s)), l = a - c + (i.left - n.left);
|
|
62
|
-
|
|
63
|
+
v({
|
|
63
64
|
left: l,
|
|
64
65
|
width: e.width,
|
|
65
66
|
opacity: 1
|
|
@@ -69,41 +70,49 @@ var s = ({ items: s = [], bounds: c = 5, offset: l = 0, direction: u = "vertical
|
|
|
69
70
|
});
|
|
70
71
|
} else {
|
|
71
72
|
let e = t.getBoundingClientRect();
|
|
72
|
-
|
|
73
|
-
left: e.left -
|
|
73
|
+
v({
|
|
74
|
+
left: e.left - y.current.getBoundingClientRect().left,
|
|
74
75
|
width: e.width,
|
|
75
76
|
opacity: 1
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
} else
|
|
80
|
-
}, [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
} else v({ opacity: 0 });
|
|
81
|
+
}, [h, f]);
|
|
82
|
+
r(() => {
|
|
83
|
+
x();
|
|
84
|
+
}, [x]), n(() => {
|
|
85
|
+
let e = y.current;
|
|
86
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
87
|
+
let t = new ResizeObserver(() => x());
|
|
88
|
+
return t.observe(e), e.querySelectorAll("a").forEach((e) => t.observe(e)), () => t.disconnect();
|
|
89
|
+
}, [x, l]);
|
|
90
|
+
let S = (t) => /* @__PURE__ */ s("ul", {
|
|
91
|
+
className: o(e.list, e[f]),
|
|
92
|
+
children: t.map((t) => /* @__PURE__ */ c("li", {
|
|
93
|
+
className: o(e.item, h === t.href && e.active),
|
|
94
|
+
children: [/* @__PURE__ */ s("a", {
|
|
86
95
|
href: t.href,
|
|
87
96
|
className: e.link,
|
|
88
|
-
"aria-current":
|
|
89
|
-
onClick: (e) =>
|
|
97
|
+
"aria-current": h === t.href ? "location" : void 0,
|
|
98
|
+
onClick: (e) => b(e, t.href),
|
|
90
99
|
title: typeof t.title == "string" ? t.title : void 0,
|
|
91
100
|
children: t.title
|
|
92
|
-
}), t.children &&
|
|
101
|
+
}), t.children && f === "vertical" && S(t.children)]
|
|
93
102
|
}, t.key))
|
|
94
103
|
});
|
|
95
|
-
return /* @__PURE__ */
|
|
96
|
-
className:
|
|
97
|
-
style:
|
|
98
|
-
ref:
|
|
99
|
-
children: [/* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ c("div", {
|
|
105
|
+
className: o("wim-anchor", e.root, e[f], p),
|
|
106
|
+
style: m,
|
|
107
|
+
ref: y,
|
|
108
|
+
children: [/* @__PURE__ */ s("div", {
|
|
100
109
|
className: e.ink,
|
|
101
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ s("span", {
|
|
102
111
|
className: e.inkBall,
|
|
103
|
-
style:
|
|
112
|
+
style: _
|
|
104
113
|
})
|
|
105
|
-
}),
|
|
114
|
+
}), S(l)]
|
|
106
115
|
});
|
|
107
116
|
};
|
|
108
117
|
//#endregion
|
|
109
|
-
export {
|
|
118
|
+
export { l as Anchor, l as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/OverlayBase.cjs"),r=require("./dialog.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.createContext)(void 0),c=()=>{let e=(0,i.useContext)(s);if(!e)throw Error(`Dialog sub-components must be used within Dialog`);return e},l=({children:e,open:t,onOpenChange:n,defaultOpen:r=!1,role:a=`dialog`,closeOnOverlayClick:c=a!==`alertdialog`})=>{let[l,u]=(0,i.useState)(r),d=t!==void 0,f=d?t:l,p=e=>{d||u(e),n?.(e)},m=`wim-dialog-${(0,i.useId)()}`,h=`${m}-title`,g=`${m}-description`;return(0,o.jsx)(s.Provider,{value:{titleId:h,descriptionId:g,open:f,onOpenChange:p,closeOnOverlayClick:c,role:a},children:e})};l.displayName=`Dialog`;var u=({children:e,className:n,onClick:r,asChild:i=!1,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(i?t.Root:`button`,{type:`button`,className:n,onClick:e=>{r?.(e),s(!0)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})};u.displayName=`Dialog.Trigger`;var d=({children:e,className:n,onClick:r,asChild:i=!1,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(i?t.Root:`button`,{type:`button`,className:n,onClick:e=>{r?.(e),s(!1)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})};d.displayName=`Dialog.Close`;var f=({children:e,className:i,asChild:s=!1,open:l,onOpenChange:u,role:d,...f})=>{let{open:p,onOpenChange:m,titleId:h,descriptionId:g,closeOnOverlayClick:_,role:v}=c(),y=l===void 0?p:l,b=u===void 0?m:u,x=s?t.Root:`div`;return(0,o.jsx)(n.OverlayBase,{...f,open:y,onOpenChange:b,closeOnOverlayClick:_,overlayClassName:r.default.overlay,role:d??v,"aria-labelledby":h,"aria-describedby":g,children:(0,o.jsx)(x,{className:(0,a.default)(`wim-dialog`,r.default.content,i),children:(0,o.jsx)(t.Slottable,{children:e})})})};f.displayName=`Dialog.Content`;var p=({children:e,className:t,...n})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.header,t),"data-testid":`dialog-header`,...n,children:e});p.displayName=`Dialog.Header`;var m=({children:e,className:t,layout:n,...i})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.footer,t),"data-layout":n,"data-testid":`dialog-footer`,...i,children:e});m.displayName=`Dialog.Footer`;var h=({children:e,className:t,...n})=>{let{titleId:i}=c();return(0,o.jsx)(`h2`,{id:i,className:(0,a.default)(r.default.title,t),"data-testid":`dialog-title`,...n,children:e})};h.displayName=`Dialog.Title`;var g=({children:e,className:t,...n})=>{let{descriptionId:i}=c();return(0,o.jsx)(`p`,{id:i,className:(0,a.default)(r.default.description,t),"data-testid":`dialog-description`,...n,children:e})};g.displayName=`Dialog.Description`;var _=e=>(0,o.jsx)(l,{...e});_.displayName=`Dialog`,_.Trigger=u,_.Content=f,_.Close=d,_.Header=p,_.Footer=m,_.Title=h,_.Description=g,exports.Dialog=_,exports.default=_,exports.DialogClose=d,exports.DialogContent=f,exports.DialogDescription=g,exports.DialogFooter=m,exports.DialogHeader=p,exports.DialogTitle=h,exports.DialogTrigger=u,exports.useDialog=c;
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/OverlayBase.cjs"),r=require("./dialog.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.createContext)(void 0),c=()=>{let e=(0,i.useContext)(s);if(!e)throw Error(`Dialog sub-components must be used within Dialog`);return e},l=({children:e,open:t,onOpenChange:n,defaultOpen:r=!1,role:a=`dialog`,closeOnOverlayClick:c=a!==`alertdialog`})=>{let[l,u]=(0,i.useState)(r),d=t!==void 0,f=d?t:l,p=e=>{d||u(e),n?.(e)},m=`wim-dialog-${(0,i.useId)()}`,h=`${m}-title`,g=`${m}-description`;return(0,o.jsx)(s.Provider,{value:{titleId:h,descriptionId:g,open:f,onOpenChange:p,closeOnOverlayClick:c,role:a},children:e})};l.displayName=`Dialog`;var u=({children:e,className:n,onClick:r,asChild:i=!1,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(i?t.Root:`button`,{type:`button`,className:n,onClick:e=>{r?.(e),s(!0)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})};u.displayName=`Dialog.Trigger`;var d=({children:e,className:n,onClick:r,asChild:i=!1,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(i?t.Root:`button`,{type:`button`,className:n,onClick:e=>{r?.(e),s(!1)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})};d.displayName=`Dialog.Close`;var f=({children:e,className:i,asChild:s=!1,open:l,onOpenChange:u,role:d,...f})=>{let{open:p,onOpenChange:m,titleId:h,descriptionId:g,closeOnOverlayClick:_,role:v}=c(),y=l===void 0?p:l,b=u===void 0?m:u,x=s?t.Root:`div`;return(0,o.jsx)(n.OverlayBase,{...f,open:y,onOpenChange:b,closeOnOverlayClick:_,overlayClassName:r.default.overlay,role:d??v,"aria-labelledby":f[`aria-labelledby`]??h,"aria-describedby":[f[`aria-describedby`],g].filter(Boolean).join(` `),children:(0,o.jsx)(x,{className:(0,a.default)(`wim-dialog`,r.default.content,i),children:(0,o.jsx)(t.Slottable,{children:e})})})};f.displayName=`Dialog.Content`;var p=({children:e,className:t,...n})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.header,t),"data-testid":`dialog-header`,...n,children:e});p.displayName=`Dialog.Header`;var m=({children:e,className:t,layout:n,...i})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.footer,t),"data-layout":n,"data-testid":`dialog-footer`,...i,children:e});m.displayName=`Dialog.Footer`;var h=({children:e,className:t,...n})=>{let{titleId:i}=c();return(0,o.jsx)(`h2`,{id:i,className:(0,a.default)(r.default.title,t),"data-testid":`dialog-title`,...n,children:e})};h.displayName=`Dialog.Title`;var g=({children:e,className:t,...n})=>{let{descriptionId:i}=c();return(0,o.jsx)(`p`,{id:i,className:(0,a.default)(r.default.description,t),"data-testid":`dialog-description`,...n,children:e})};g.displayName=`Dialog.Description`;var _=e=>(0,o.jsx)(l,{...e});_.displayName=`Dialog`,_.Trigger=u,_.Content=f,_.Close=d,_.Header=p,_.Footer=m,_.Title=h,_.Description=g,exports.Dialog=_,exports.default=_,exports.DialogClose=d,exports.DialogContent=f,exports.DialogDescription=g,exports.DialogFooter=m,exports.DialogHeader=p,exports.DialogTitle=h,exports.DialogTrigger=u,exports.useDialog=c;
|
|
@@ -62,8 +62,8 @@ var h = ({ children: i, className: a, asChild: o = !1, open: s, onOpenChange: u,
|
|
|
62
62
|
closeOnOverlayClick: v,
|
|
63
63
|
overlayClassName: r.overlay,
|
|
64
64
|
role: f ?? y,
|
|
65
|
-
"aria-labelledby": g,
|
|
66
|
-
"aria-describedby": _,
|
|
65
|
+
"aria-labelledby": p["aria-labelledby"] ?? g,
|
|
66
|
+
"aria-describedby": [p["aria-describedby"], _].filter(Boolean).join(" "),
|
|
67
67
|
children: /* @__PURE__ */ l(S, {
|
|
68
68
|
className: c("wim-dialog", r.content, a),
|
|
69
69
|
children: /* @__PURE__ */ l(t, { children: i })
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/OverlayBase.cjs"),r=require("./drawer.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.createContext)(void 0),c=()=>{let e=(0,i.useContext)(s);if(!e)throw Error(`useDrawer must be used within a Drawer provider`);return e},l=({children:e,open:t,onOpenChange:n,defaultOpen:r=!1,side:a=`right`,slideIn:c=!0,slideOut:l=!0})=>{let[u,d]=(0,i.useState)(r),f=t!==void 0,p=f?t:u,m=e=>{f||d(e),n?.(e)},h=`wim-drawer-${(0,i.useId)()}`,g=`${h}-title`,_=`${h}-description`;return(0,o.jsx)(s.Provider,{value:{titleId:g,descriptionId:_,open:p,onOpenChange:m,side:a,slideIn:c,slideOut:l},children:e})},u=({children:e,className:n,onClick:r,asChild:i,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(t.Root,{type:`button`,className:n,onClick:e=>{r?.(e),s(!0)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})},d=({children:e,className:n,onClick:r,asChild:i,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(t.Root,{type:`button`,className:n,onClick:e=>{r?.(e),s(!1)},"data-testid":`drawer-close`,...a,children:(0,o.jsx)(t.Slottable,{children:e})})},f=({children:e,className:i,asChild:s=!1,open:l,onOpenChange:u,side:d,slideIn:f,slideOut:p,showOverlay:m=!0,...h})=>{let{open:g,onOpenChange:_,titleId:v,descriptionId:y,side:b,slideIn:x,slideOut:S}=c(),C=l===void 0?g:l,w=u===void 0?_:u,T=d??b,E=f??x,D=p??S,O=s?t.Root:`div`;return(0,o.jsx)(n.OverlayBase,{...h,open:C,onOpenChange:w,overlayClassName:(0,a.default)(r.default.overlay,!m&&r.default.hideOverlay),contentClassName:(0,a.default)(`wim-drawer`,r.default.content,r.default[T],i),transitionProps:{preset:`slide-${T}`,enterPreset:E?void 0:`none`,leavePreset:D?void 0:`none`},role
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/@radix-ui/react-slot/dist/index.cjs"),n=require("../../_internal/OverlayBase.cjs"),r=require("./drawer.module.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("classnames");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=(0,i.createContext)(void 0),c=()=>{let e=(0,i.useContext)(s);if(!e)throw Error(`useDrawer must be used within a Drawer provider`);return e},l=({children:e,open:t,onOpenChange:n,defaultOpen:r=!1,side:a=`right`,slideIn:c=!0,slideOut:l=!0})=>{let[u,d]=(0,i.useState)(r),f=t!==void 0,p=f?t:u,m=e=>{f||d(e),n?.(e)},h=`wim-drawer-${(0,i.useId)()}`,g=`${h}-title`,_=`${h}-description`;return(0,o.jsx)(s.Provider,{value:{titleId:g,descriptionId:_,open:p,onOpenChange:m,side:a,slideIn:c,slideOut:l},children:e})},u=({children:e,className:n,onClick:r,asChild:i,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(t.Root,{type:`button`,className:n,onClick:e=>{r?.(e),s(!0)},...a,children:(0,o.jsx)(t.Slottable,{children:e})})},d=({children:e,className:n,onClick:r,asChild:i,...a})=>{let{onOpenChange:s}=c();return(0,o.jsx)(t.Root,{type:`button`,className:n,onClick:e=>{r?.(e),s(!1)},"data-testid":`drawer-close`,...a,children:(0,o.jsx)(t.Slottable,{children:e})})},f=({children:e,className:i,asChild:s=!1,open:l,onOpenChange:u,side:d,slideIn:f,slideOut:p,showOverlay:m=!0,...h})=>{let{open:g,onOpenChange:_,titleId:v,descriptionId:y,side:b,slideIn:x,slideOut:S}=c(),C=l===void 0?g:l,w=u===void 0?_:u,T=d??b,E=f??x,D=p??S,O=s?t.Root:`div`;return(0,o.jsx)(n.OverlayBase,{...h,open:C,onOpenChange:w,overlayClassName:(0,a.default)(r.default.overlay,!m&&r.default.hideOverlay),contentClassName:(0,a.default)(`wim-drawer`,r.default.content,r.default[T],i),transitionProps:{preset:`slide-${T}`,enterPreset:E?void 0:`none`,leavePreset:D?void 0:`none`},role:h.role??`dialog`,"aria-labelledby":h[`aria-labelledby`]??v,"aria-describedby":[h[`aria-describedby`],y].filter(Boolean).join(` `),"data-side":T,children:(0,o.jsx)(O,{"data-testid":`drawer-content`,"data-side":T,children:(0,o.jsx)(`div`,{children:(0,o.jsx)(t.Slottable,{children:e})})})})},p=({children:e,className:t,...n})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.header,t),"data-testid":`drawer-header`,...n,children:e}),m=({children:e,className:t,...n})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.body,t),"data-testid":`drawer-body`,...n,children:e}),h=({children:e,className:t,...n})=>(0,o.jsx)(`div`,{className:(0,a.default)(r.default.footer,t),"data-testid":`drawer-footer`,...n,children:e}),g=({children:e,className:t,...n})=>{let{titleId:i}=c();return(0,o.jsx)(`h2`,{id:i,className:(0,a.default)(r.default.title,t),"data-testid":`drawer-title`,...n,children:e})},_=({children:e,className:t,...n})=>{let{descriptionId:i}=c();return(0,o.jsx)(`p`,{id:i,className:(0,a.default)(r.default.description,t),"data-testid":`drawer-description`,...n,children:e})},v=e=>(0,o.jsx)(l,{...e});v.displayName=`Drawer`,v.Trigger=u,v.Content=f,v.Header=p,v.Footer=h,v.Title=g,v.Description=_,v.Close=d,exports.Drawer=v,exports.default=v,exports.DrawerBody=m,exports.DrawerClose=d,exports.DrawerContent=f,exports.DrawerDescription=_,exports.DrawerFooter=h,exports.DrawerHeader=p,exports.DrawerTitle=g,exports.DrawerTrigger=u,exports.useDrawer=c;
|
|
@@ -62,9 +62,9 @@ var u = i(void 0), d = () => {
|
|
|
62
62
|
enterPreset: D ? void 0 : "none",
|
|
63
63
|
leavePreset: O ? void 0 : "none"
|
|
64
64
|
},
|
|
65
|
-
role: "dialog",
|
|
66
|
-
"aria-labelledby": y,
|
|
67
|
-
"aria-describedby": b,
|
|
65
|
+
role: g.role ?? "dialog",
|
|
66
|
+
"aria-labelledby": g["aria-labelledby"] ?? y,
|
|
67
|
+
"aria-describedby": [g["aria-describedby"], b].filter(Boolean).join(" "),
|
|
68
68
|
"data-side": E,
|
|
69
69
|
children: /* @__PURE__ */ l(k, {
|
|
70
70
|
"data-testid": "drawer-content",
|