wimui 0.66.0 → 0.68.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/_internal/ChoiceLabel.cjs +2 -0
- package/dist/components/_internal/ChoiceLabel.d.ts +31 -0
- package/dist/components/_internal/ChoiceLabel.js +22 -0
- package/dist/components/_internal/InlineDisclosure.cjs +2 -0
- package/dist/components/_internal/InlineDisclosure.d.ts +22 -0
- package/dist/components/_internal/InlineDisclosure.js +47 -0
- package/dist/components/_internal/choice-label.module.cjs +2 -0
- package/dist/components/_internal/choice-label.module.js +11 -0
- package/dist/components/_internal/inline-disclosure.module.cjs +2 -0
- package/dist/components/_internal/inline-disclosure.module.js +9 -0
- package/dist/components/_internal/rovingIndex.cjs +2 -0
- package/dist/components/_internal/rovingIndex.d.ts +38 -0
- package/dist/components/_internal/rovingIndex.js +16 -0
- package/dist/components/data-display/AvatarGroup/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup/AvatarGroup.d.ts +10 -3
- package/dist/components/data-display/AvatarGroup/AvatarGroup.js +55 -27
- package/dist/components/data-display/AvatarGroup/avatar-group.module.cjs +1 -1
- package/dist/components/data-display/AvatarGroup/avatar-group.module.js +8 -6
- package/dist/components/data-display/Card/Card.cjs +1 -1
- package/dist/components/data-display/Card/Card.d.ts +21 -0
- package/dist/components/data-display/Card/Card.js +7 -3
- package/dist/components/data-display/Card/card.module.cjs +1 -1
- package/dist/components/data-display/Card/card.module.js +17 -16
- package/dist/components/form/CheckboxGroup/CheckboxGroup.cjs +1 -1
- package/dist/components/form/CheckboxGroup/CheckboxGroup.d.ts +9 -0
- package/dist/components/form/CheckboxGroup/CheckboxGroup.js +42 -30
- package/dist/components/form/CheckboxGroup/checkbox-group.module.cjs +1 -1
- package/dist/components/form/CheckboxGroup/checkbox-group.module.js +4 -3
- package/dist/components/form/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/components/form/RadioGroup/RadioGroup.d.ts +9 -0
- package/dist/components/form/RadioGroup/RadioGroup.js +46 -34
- package/dist/components/form/RadioGroup/radio-group.module.cjs +1 -1
- package/dist/components/form/RadioGroup/radio-group.module.js +4 -3
- package/dist/components/form/SegmentedControl/SegmentedControl.cjs +1 -1
- package/dist/components/form/SegmentedControl/SegmentedControl.js +56 -68
- package/dist/components/form/ToggleGroup/ToggleGroup.cjs +1 -1
- package/dist/components/form/ToggleGroup/ToggleGroup.js +80 -88
- package/dist/components/layout/OverflowList/OverflowList.cjs +2 -0
- package/dist/components/layout/OverflowList/OverflowList.d.ts +81 -0
- package/dist/components/layout/OverflowList/OverflowList.js +85 -0
- package/dist/components/layout/OverflowList/getVisibleCount.cjs +2 -0
- package/dist/components/layout/OverflowList/getVisibleCount.d.ts +30 -0
- package/dist/components/layout/OverflowList/getVisibleCount.js +26 -0
- package/dist/components/layout/OverflowList/overflow-list.module.cjs +2 -0
- package/dist/components/layout/OverflowList/overflow-list.module.js +10 -0
- package/dist/components/layout/Toolbar/Toolbar.cjs +1 -1
- package/dist/components/layout/Toolbar/Toolbar.js +52 -51
- package/dist/components/navigation/Breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb/Breadcrumb.d.ts +12 -0
- package/dist/components/navigation/Breadcrumb/Breadcrumb.js +88 -53
- package/dist/components/navigation/Stepper/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper/Stepper.js +51 -53
- package/dist/components/navigation/TabNavigation/TabNavigation.cjs +1 -1
- package/dist/components/navigation/TabNavigation/TabNavigation.js +47 -49
- package/dist/components/navigation/Tabs/Tabs.cjs +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +80 -73
- package/dist/data-display.cjs +1 -1
- package/dist/data-display.js +40 -40
- package/dist/i18n/generated/components.d.ts +1 -1
- package/dist/i18n/generated/data-display.cjs +1 -1
- package/dist/i18n/generated/data-display.d.ts +1 -1
- package/dist/i18n/generated/data-display.js +12 -3
- package/dist/i18n/generated/keys.d.ts +2 -1
- package/dist/i18n/generated/navigation.cjs +2 -0
- package/dist/i18n/generated/navigation.d.ts +3 -0
- package/dist/i18n/generated/navigation.js +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +175 -174
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.ts +1 -0
- package/dist/layout.js +2 -1
- package/dist/llms-full.txt +45 -3
- package/dist/llms.txt +2 -1
- package/dist/locales/en/components.json +2 -1
- package/dist/locales/en/data-display.json +3 -0
- package/dist/locales/ja/components.json +2 -1
- package/dist/locales/ja/data-display.json +3 -0
- package/dist/locales/pt/components.json +2 -1
- package/dist/locales/pt/data-display.json +3 -0
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +30 -30
|
@@ -3,41 +3,53 @@ import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react
|
|
|
3
3
|
import { FieldTemplate as n } from "../FieldTemplate/FieldTemplate.js";
|
|
4
4
|
import { Checkbox as r } from "../Checkbox/Checkbox.js";
|
|
5
5
|
import i from "./checkbox-group.module.js";
|
|
6
|
-
import {
|
|
7
|
-
import c from "
|
|
8
|
-
import
|
|
6
|
+
import { ChoiceLabel as a, choiceLabelClasses as o } from "../../_internal/ChoiceLabel.js";
|
|
7
|
+
import { forwardRef as s, useId as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/form/CheckboxGroup/CheckboxGroup.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
11
|
+
var p = s(({ options: s, value: p, defaultValue: m = [], onChange: h, direction: g = "vertical", variant: _ = "default", name: v, className: y, label: b, error: x, required: S, disabled: C, asChild: w = !1, children: T, ...E }, D) => {
|
|
12
|
+
let O = p !== void 0, [k, A] = l(m), j = `wim-checkbox-group-${c()}`, M = `${j}-label`, N = x ? `${j}-error` : void 0, P = O ? p : k, F = (e, t) => {
|
|
12
13
|
let n;
|
|
13
|
-
n = t ? [...
|
|
14
|
+
n = t ? [...P, e] : P.filter((t) => t !== e), O || A(n), h && h(n);
|
|
14
15
|
};
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
label:
|
|
17
|
-
error:
|
|
18
|
-
required:
|
|
19
|
-
labelId:
|
|
20
|
-
errorId:
|
|
21
|
-
className:
|
|
22
|
-
children: /* @__PURE__ */
|
|
23
|
-
...
|
|
24
|
-
ref:
|
|
25
|
-
className:
|
|
16
|
+
return /* @__PURE__ */ d(n, {
|
|
17
|
+
label: b,
|
|
18
|
+
error: x,
|
|
19
|
+
required: S,
|
|
20
|
+
labelId: M,
|
|
21
|
+
errorId: N,
|
|
22
|
+
className: y,
|
|
23
|
+
children: /* @__PURE__ */ f(w ? e : "div", {
|
|
24
|
+
...E,
|
|
25
|
+
ref: D,
|
|
26
|
+
className: u("wim-checkbox-group", i.root, g === "horizontal" && i.horizontal, _ === "card" && i.cards),
|
|
26
27
|
role: "group",
|
|
27
|
-
"aria-labelledby":
|
|
28
|
-
"aria-describedby": [
|
|
29
|
-
children: [
|
|
30
|
-
value: e.value
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
"aria-labelledby": b ? M : E["aria-labelledby"],
|
|
29
|
+
"aria-describedby": [E["aria-describedby"], N].filter(Boolean).join(" ") || void 0,
|
|
30
|
+
children: [s.map((e) => {
|
|
31
|
+
let t = e.description ? `${j}-${e.value}-description` : void 0, n = e.description ? `${j}-${e.value}-label` : void 0;
|
|
32
|
+
return /* @__PURE__ */ d(r, {
|
|
33
|
+
value: e.value,
|
|
34
|
+
checked: P.includes(e.value),
|
|
35
|
+
disabled: C || e.disabled,
|
|
36
|
+
error: !!x,
|
|
37
|
+
name: v,
|
|
38
|
+
onChange: (t) => F(e.value, t.target.checked),
|
|
39
|
+
"aria-describedby": t,
|
|
40
|
+
"aria-labelledby": n,
|
|
41
|
+
className: u(_ === "card" && o.card, e.description && o.top),
|
|
42
|
+
children: /* @__PURE__ */ d(a, {
|
|
43
|
+
label: e.label,
|
|
44
|
+
description: e.description,
|
|
45
|
+
descriptionId: t,
|
|
46
|
+
labelId: n
|
|
47
|
+
})
|
|
48
|
+
}, e.value);
|
|
49
|
+
}), /* @__PURE__ */ d(t, { children: T })]
|
|
38
50
|
})
|
|
39
51
|
});
|
|
40
52
|
});
|
|
41
|
-
|
|
53
|
+
p.displayName = "CheckboxGroup";
|
|
42
54
|
//#endregion
|
|
43
|
-
export {
|
|
55
|
+
export { p as CheckboxGroup, p as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1pbiw_3`,t=`_horizontal_1pbiw_8`,n=`_cards_1pbiw_15`,r={root:e,horizontal:t,cards:n};exports.cards=n,exports.default=r,exports.horizontal=t,exports.root=e;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/CheckboxGroup/checkbox-group.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1pbiw_3", t = "_horizontal_1pbiw_8", n = "_cards_1pbiw_15", r = {
|
|
4
4
|
root: e,
|
|
5
|
-
horizontal: t
|
|
5
|
+
horizontal: t,
|
|
6
|
+
cards: n
|
|
6
7
|
};
|
|
7
8
|
//#endregion
|
|
8
|
-
export { n as default, t as horizontal, e as root };
|
|
9
|
+
export { n as cards, r as default, t as horizontal, e as root };
|
|
@@ -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("../Radio/Radio.cjs"),
|
|
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("../../_internal/ChoiceLabel.cjs"),i=require("../Radio/Radio.cjs"),a=require("./radio-group.module.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("classnames");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=(0,o.forwardRef)(({options:e,value:l,defaultValue:u,onChange:d,direction:f=`vertical`,variant:p=`default`,name:m,className:h,label:g,error:_,required:v,disabled:y,asChild:b=!1,children:x,...S},C)=>{let w=l!==void 0,[T,E]=(0,o.useState)(u),D=`wim-radio-group-${(0,o.useId)()}`,O=`${D}-label`,k=_?`${D}-error`:void 0,A=w?l:T,j=e=>{w||E(e),d&&d(e)};return(0,c.jsx)(n.FieldTemplate,{label:g,error:_,required:v,labelId:O,errorId:k,className:h,children:(0,c.jsxs)(b?t.Root:`div`,{...S,ref:C,className:(0,s.default)(`wim-radio-group`,a.default.root,f===`horizontal`&&a.default.horizontal,p===`card`&&a.default.cards),role:`radiogroup`,"aria-labelledby":g?O:S[`aria-labelledby`],"aria-describedby":[S[`aria-describedby`],k].filter(Boolean).join(` `)||void 0,"aria-required":v,"aria-invalid":!!_,children:[e.map(e=>{let t=e.description?`${D}-${e.value}-description`:void 0,n=e.description?`${D}-${e.value}-label`:void 0;return(0,c.jsx)(i.Radio,{value:e.value,checked:A===e.value,disabled:y||e.disabled,error:!!_,name:m,onChange:()=>j(e.value),"aria-describedby":t,"aria-labelledby":n,className:(0,s.default)(p===`card`&&r.choiceLabelClasses.card,e.description&&r.choiceLabelClasses.top),children:(0,c.jsx)(r.ChoiceLabel,{label:e.label,description:e.description,descriptionId:t,labelId:n})},e.value)}),(0,c.jsx)(t.Slottable,{children:x})]})})});l.displayName=`RadioGroup`,exports.RadioGroup=l,exports.default=l;
|
|
@@ -3,6 +3,8 @@ type Option = {
|
|
|
3
3
|
label: string;
|
|
4
4
|
value: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
/** A second line that explains the option (shown under the label, and linked with `aria-describedby`) */
|
|
7
|
+
description?: string;
|
|
6
8
|
};
|
|
7
9
|
export interface RadioGroupProps extends Omit<React.ComponentPropsWithoutRef<"div">, "onChange" | "defaultValue"> {
|
|
8
10
|
/** List of radio options */
|
|
@@ -15,6 +17,13 @@ export interface RadioGroupProps extends Omit<React.ComponentPropsWithoutRef<"di
|
|
|
15
17
|
onChange?: (value: string) => void;
|
|
16
18
|
/** Layout direction of the radio buttons */
|
|
17
19
|
direction?: "vertical" | "horizontal";
|
|
20
|
+
/**
|
|
21
|
+
* `card` draws each option as a bordered card that is selectable as a whole
|
|
22
|
+
* (the card is the option's `<label>`). Keys and group semantics stay those
|
|
23
|
+
* of a radio group. Use with `description` when the options need explaining.
|
|
24
|
+
* @default "default"
|
|
25
|
+
*/
|
|
26
|
+
variant?: "default" | "card";
|
|
18
27
|
/** Name attribute shared by the radio inputs */
|
|
19
28
|
name?: string;
|
|
20
29
|
/** Whether to render as a child element. */
|
|
@@ -1,44 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { FieldTemplate as n } from "../FieldTemplate/FieldTemplate.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import c from "
|
|
8
|
-
import
|
|
4
|
+
import { ChoiceLabel as r, choiceLabelClasses as i } from "../../_internal/ChoiceLabel.js";
|
|
5
|
+
import { Radio as a } from "../Radio/Radio.js";
|
|
6
|
+
import o from "./radio-group.module.js";
|
|
7
|
+
import { forwardRef as s, useId as c, useState as l } from "react";
|
|
8
|
+
import u from "classnames";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/form/RadioGroup/RadioGroup.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
11
|
+
var p = s(({ options: s, value: p, defaultValue: m, onChange: h, direction: g = "vertical", variant: _ = "default", name: v, className: y, label: b, error: x, required: S, disabled: C, asChild: w = !1, children: T, ...E }, D) => {
|
|
12
|
+
let O = p !== void 0, [k, A] = l(m), j = `wim-radio-group-${c()}`, M = `${j}-label`, N = x ? `${j}-error` : void 0, P = O ? p : k, F = (e) => {
|
|
13
|
+
O || A(e), h && h(e);
|
|
13
14
|
};
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
label:
|
|
16
|
-
error:
|
|
17
|
-
required:
|
|
18
|
-
labelId:
|
|
19
|
-
errorId:
|
|
20
|
-
className:
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
-
...
|
|
23
|
-
ref:
|
|
24
|
-
className:
|
|
15
|
+
return /* @__PURE__ */ d(n, {
|
|
16
|
+
label: b,
|
|
17
|
+
error: x,
|
|
18
|
+
required: S,
|
|
19
|
+
labelId: M,
|
|
20
|
+
errorId: N,
|
|
21
|
+
className: y,
|
|
22
|
+
children: /* @__PURE__ */ f(w ? e : "div", {
|
|
23
|
+
...E,
|
|
24
|
+
ref: D,
|
|
25
|
+
className: u("wim-radio-group", o.root, g === "horizontal" && o.horizontal, _ === "card" && o.cards),
|
|
25
26
|
role: "radiogroup",
|
|
26
|
-
"aria-labelledby":
|
|
27
|
-
"aria-describedby": [
|
|
28
|
-
"aria-required":
|
|
29
|
-
"aria-invalid": !!
|
|
30
|
-
children: [
|
|
31
|
-
value: e.value
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
"aria-labelledby": b ? M : E["aria-labelledby"],
|
|
28
|
+
"aria-describedby": [E["aria-describedby"], N].filter(Boolean).join(" ") || void 0,
|
|
29
|
+
"aria-required": S,
|
|
30
|
+
"aria-invalid": !!x,
|
|
31
|
+
children: [s.map((e) => {
|
|
32
|
+
let t = e.description ? `${j}-${e.value}-description` : void 0, n = e.description ? `${j}-${e.value}-label` : void 0;
|
|
33
|
+
return /* @__PURE__ */ d(a, {
|
|
34
|
+
value: e.value,
|
|
35
|
+
checked: P === e.value,
|
|
36
|
+
disabled: C || e.disabled,
|
|
37
|
+
error: !!x,
|
|
38
|
+
name: v,
|
|
39
|
+
onChange: () => F(e.value),
|
|
40
|
+
"aria-describedby": t,
|
|
41
|
+
"aria-labelledby": n,
|
|
42
|
+
className: u(_ === "card" && i.card, e.description && i.top),
|
|
43
|
+
children: /* @__PURE__ */ d(r, {
|
|
44
|
+
label: e.label,
|
|
45
|
+
description: e.description,
|
|
46
|
+
descriptionId: t,
|
|
47
|
+
labelId: n
|
|
48
|
+
})
|
|
49
|
+
}, e.value);
|
|
50
|
+
}), /* @__PURE__ */ d(t, { children: T })]
|
|
39
51
|
})
|
|
40
52
|
});
|
|
41
53
|
});
|
|
42
|
-
|
|
54
|
+
p.displayName = "RadioGroup";
|
|
43
55
|
//#endregion
|
|
44
|
-
export {
|
|
56
|
+
export { p as RadioGroup, p as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=`
|
|
2
|
+
var e=`_root_1pbiw_3`,t=`_horizontal_1pbiw_8`,n=`_cards_1pbiw_15`,r={root:e,horizontal:t,cards:n};exports.cards=n,exports.default=r,exports.horizontal=t,exports.root=e;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
//#region src/components/form/RadioGroup/radio-group.module.scss
|
|
3
|
-
var e = "
|
|
3
|
+
var e = "_root_1pbiw_3", t = "_horizontal_1pbiw_8", n = "_cards_1pbiw_15", r = {
|
|
4
4
|
root: e,
|
|
5
|
-
horizontal: t
|
|
5
|
+
horizontal: t,
|
|
6
|
+
cards: n
|
|
6
7
|
};
|
|
7
8
|
//#endregion
|
|
8
|
-
export { n as default, t as horizontal, e as root };
|
|
9
|
+
export { n as cards, r as default, t as horizontal, e as root };
|
|
@@ -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"),
|
|
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("../../_internal/rovingIndex.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../_internal/useIndicator.cjs"),s=require("./segmented-control.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=(0,c.forwardRef)(({options:e,value:d,onChange:f,size:p=`md`,fullWidth:m=!1,className:h,label:g,error:_,required:v,layout:y=`vertical`,disabled:b=!1,asChild:x=!1,children:S,id:C,styles:w,"aria-label":T,"aria-labelledby":E,"aria-describedby":D},O)=>{let k=(0,c.useRef)([]),A=(0,c.useId)(),j=C||`wim-segmented-${A}`,M=`${j}-label`,N=`${j}-error`,{containerRef:P,sliderStyle:F,isReady:I}=o.useIndicator({activeSelector:`.${s.default.active}`,dependence:e.length}),L=e.findIndex(e=>e.value===d),R=(t,n)=>{let r=i.getRovingIndex({key:t.key,current:n,count:e.length});r!==null&&(t.preventDefault(),f(e[r].value),k.current[r]?.focus())},z=`${j}-item-0`;return(0,u.jsx)(a.FieldTemplate,{label:g,error:_,required:v,layout:y,labelId:M,htmlFor:z,errorId:N,className:h,children:(0,u.jsxs)(x?t.Root:`div`,{ref:n.useMergedRef(P,O),id:j,className:(0,l.default)(`wim-segmented-control`,s.default.root,s.default[p],m&&s.default.fullWidth,I&&s.default.ready,_&&s.default.danger,w?.root),role:`radiogroup`,"aria-labelledby":g?M:E,"aria-label":g||E?void 0:T,"aria-required":v,"aria-invalid":_?!0:void 0,"aria-describedby":[D,_?N:void 0].filter(Boolean).join(` `)||void 0,children:[(0,u.jsx)(`div`,{className:(0,l.default)(s.default.slider,w?.slider),style:F,"aria-hidden":`true`}),e.map((e,t)=>{let n=e.value===d,i=n||L===-1&&t===0,a=`${j}-item-${t}`;return(0,u.jsxs)(`button`,{id:a,ref:e=>{k.current[t]=e},type:`button`,className:(0,l.default)(s.default.item,n&&s.default.active,!e.label&&e.iconName&&s.default.iconOnly,w?.item),onClick:()=>f(e.value),onKeyDown:e=>R(e,t),onFocus:()=>{},onBlur:()=>{},role:`radio`,"aria-checked":n,tabIndex:i?0:-1,"aria-label":e.label?void 0:e.value,disabled:b,children:[e.iconName&&(0,u.jsx)(r.Icon,{name:e.iconName,size:p,className:s.default.icon}),e.label&&(0,u.jsx)(`span`,{className:(0,l.default)(s.default.label,w?.label),children:e.label})]},e.value)}),(0,u.jsx)(t.Slottable,{children:S})]})})});d.displayName=`SegmentedControl`,exports.SegmentedControl=d;
|
|
@@ -2,96 +2,84 @@
|
|
|
2
2
|
import { Root as e, Slottable as t } from "../../../node_modules/@radix-ui/react-slot/dist/index.js";
|
|
3
3
|
import { useMergedRef as n } from "../../../hooks/useMergedRef.js";
|
|
4
4
|
import { Icon as r } from "../../media/Icon/Icon.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import o from "
|
|
8
|
-
import
|
|
9
|
-
import u from "
|
|
10
|
-
import
|
|
5
|
+
import { getRovingIndex as i } from "../../_internal/rovingIndex.js";
|
|
6
|
+
import { FieldTemplate as a } from "../FieldTemplate/FieldTemplate.js";
|
|
7
|
+
import { useIndicator as o } from "../../_internal/useIndicator.js";
|
|
8
|
+
import s from "./segmented-control.module.js";
|
|
9
|
+
import { forwardRef as c, useId as l, useRef as u } from "react";
|
|
10
|
+
import d from "classnames";
|
|
11
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/form/SegmentedControl/SegmentedControl.tsx
|
|
12
|
-
var
|
|
13
|
-
let
|
|
14
|
-
activeSelector: `.${
|
|
15
|
-
dependence:
|
|
16
|
-
}),
|
|
17
|
-
let n
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return /* @__PURE__ */ d(i, {
|
|
38
|
-
label: v,
|
|
39
|
-
error: y,
|
|
40
|
-
required: b,
|
|
41
|
-
layout: x,
|
|
42
|
-
labelId: P,
|
|
43
|
-
htmlFor: V,
|
|
44
|
-
errorId: F,
|
|
45
|
-
className: _,
|
|
46
|
-
children: /* @__PURE__ */ f(C ? e : "div", {
|
|
47
|
-
ref: n(I, A),
|
|
48
|
-
id: N,
|
|
49
|
-
className: u("wim-segmented-control", o.root, o[h], g && o.fullWidth, R && o.ready, y && o.danger, E?.root),
|
|
13
|
+
var m = c(({ options: c, value: m, onChange: h, size: g = "md", fullWidth: _ = !1, className: v, label: y, error: b, required: x, layout: S = "vertical", disabled: C = !1, asChild: w = !1, children: T, id: E, styles: D, "aria-label": O, "aria-labelledby": k, "aria-describedby": A }, j) => {
|
|
14
|
+
let M = u([]), N = l(), P = E || `wim-segmented-${N}`, F = `${P}-label`, I = `${P}-error`, { containerRef: L, sliderStyle: R, isReady: z } = o({
|
|
15
|
+
activeSelector: `.${s.active}`,
|
|
16
|
+
dependence: c.length
|
|
17
|
+
}), B = c.findIndex((e) => e.value === m), V = (e, t) => {
|
|
18
|
+
let n = i({
|
|
19
|
+
key: e.key,
|
|
20
|
+
current: t,
|
|
21
|
+
count: c.length
|
|
22
|
+
});
|
|
23
|
+
n !== null && (e.preventDefault(), h(c[n].value), M.current[n]?.focus());
|
|
24
|
+
}, H = `${P}-item-0`;
|
|
25
|
+
return /* @__PURE__ */ f(a, {
|
|
26
|
+
label: y,
|
|
27
|
+
error: b,
|
|
28
|
+
required: x,
|
|
29
|
+
layout: S,
|
|
30
|
+
labelId: F,
|
|
31
|
+
htmlFor: H,
|
|
32
|
+
errorId: I,
|
|
33
|
+
className: v,
|
|
34
|
+
children: /* @__PURE__ */ p(w ? e : "div", {
|
|
35
|
+
ref: n(L, j),
|
|
36
|
+
id: P,
|
|
37
|
+
className: d("wim-segmented-control", s.root, s[g], _ && s.fullWidth, z && s.ready, b && s.danger, D?.root),
|
|
50
38
|
role: "radiogroup",
|
|
51
|
-
"aria-labelledby":
|
|
52
|
-
"aria-label":
|
|
53
|
-
"aria-required":
|
|
54
|
-
"aria-invalid":
|
|
55
|
-
"aria-describedby": [
|
|
39
|
+
"aria-labelledby": y ? F : k,
|
|
40
|
+
"aria-label": y || k ? void 0 : O,
|
|
41
|
+
"aria-required": x,
|
|
42
|
+
"aria-invalid": b ? !0 : void 0,
|
|
43
|
+
"aria-describedby": [A, b ? I : void 0].filter(Boolean).join(" ") || void 0,
|
|
56
44
|
children: [
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
className:
|
|
59
|
-
style:
|
|
45
|
+
/* @__PURE__ */ f("div", {
|
|
46
|
+
className: d(s.slider, D?.slider),
|
|
47
|
+
style: R,
|
|
60
48
|
"aria-hidden": "true"
|
|
61
49
|
}),
|
|
62
|
-
|
|
63
|
-
let n = e.value ===
|
|
64
|
-
return /* @__PURE__ */
|
|
50
|
+
c.map((e, t) => {
|
|
51
|
+
let n = e.value === m, i = n || B === -1 && t === 0, a = `${P}-item-${t}`;
|
|
52
|
+
return /* @__PURE__ */ p("button", {
|
|
65
53
|
id: a,
|
|
66
54
|
ref: (e) => {
|
|
67
|
-
|
|
55
|
+
M.current[t] = e;
|
|
68
56
|
},
|
|
69
57
|
type: "button",
|
|
70
|
-
className:
|
|
71
|
-
onClick: () =>
|
|
72
|
-
onKeyDown: (e) =>
|
|
58
|
+
className: d(s.item, n && s.active, !e.label && e.iconName && s.iconOnly, D?.item),
|
|
59
|
+
onClick: () => h(e.value),
|
|
60
|
+
onKeyDown: (e) => V(e, t),
|
|
73
61
|
onFocus: () => {},
|
|
74
62
|
onBlur: () => {},
|
|
75
63
|
role: "radio",
|
|
76
64
|
"aria-checked": n,
|
|
77
65
|
tabIndex: i ? 0 : -1,
|
|
78
66
|
"aria-label": e.label ? void 0 : e.value,
|
|
79
|
-
disabled:
|
|
80
|
-
children: [e.iconName && /* @__PURE__ */
|
|
67
|
+
disabled: C,
|
|
68
|
+
children: [e.iconName && /* @__PURE__ */ f(r, {
|
|
81
69
|
name: e.iconName,
|
|
82
|
-
size:
|
|
83
|
-
className:
|
|
84
|
-
}), e.label && /* @__PURE__ */
|
|
85
|
-
className:
|
|
70
|
+
size: g,
|
|
71
|
+
className: s.icon
|
|
72
|
+
}), e.label && /* @__PURE__ */ f("span", {
|
|
73
|
+
className: d(s.label, D?.label),
|
|
86
74
|
children: e.label
|
|
87
75
|
})]
|
|
88
76
|
}, e.value);
|
|
89
77
|
}),
|
|
90
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ f(t, { children: T })
|
|
91
79
|
]
|
|
92
80
|
})
|
|
93
81
|
});
|
|
94
82
|
});
|
|
95
|
-
|
|
83
|
+
m.displayName = "SegmentedControl";
|
|
96
84
|
//#endregion
|
|
97
|
-
export {
|
|
85
|
+
export { m as SegmentedControl };
|
|
@@ -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"),
|
|
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("../../_internal/rovingIndex.cjs"),a=require("../FieldTemplate/FieldTemplate.cjs"),o=require("../../_internal/useIndicator.cjs"),s=require("./toggle-group.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=(0,c.forwardRef)(({options:e,value:d,defaultValue:f,onChange:p,selectionMode:m=`single`,size:h=`md`,fullWidth:g=!1,className:_,"aria-label":v,"aria-labelledby":y,"aria-describedby":b,disabled:x=!1,label:S,error:C,required:w,layout:T=`vertical`,id:E,asChild:D=!1,children:O},k)=>{let A=c.default.useId(),j=E||`wim-toggle-group-${A}`,M=`${j}-label`,N=`${j}-error`,P=d!==void 0,[F,I]=(0,c.useState)(f??(m===`multiple`?[]:``)),L=P?d:F,{containerRef:R,sliderStyle:z,isReady:B}=o.useIndicator({activeSelector:`.${s.default.active}`,dependence:e.length}),V=(0,c.useRef)([]),H=e.findIndex(e=>!e.disabled),[U,W]=(0,c.useState)(()=>{if(m===`single`){let t=P?d:f;if(typeof t==`string`){let n=e.findIndex(e=>!e.disabled&&e.value===t);if(n>=0)return n}}return H>=0?H:0});(0,c.useEffect)(()=>{if(m===`single`&&P&&typeof d==`string`){let t=e.findIndex(e=>!e.disabled&&e.value===d);t>=0&&W(t)}},[d,m,P,e]);let G=e=>{let t;if(m===`multiple`){let n=Array.isArray(L)?L:[];t=n.includes(e)?n.filter(t=>t!==e):[...n,e]}else t=L===e?``:e;P||I(t),p?.(t)},K=e=>m===`multiple`?(Array.isArray(L)?L:[]).includes(e):L===e,q=(t,n)=>{if(!i.isRovingKey(n.key))return;n.preventDefault();let r=i.getRovingIndex({key:n.key,current:t,count:e.length,isDisabled:t=>!!e[t].disabled});r!==null&&r!==t&&(W(r),V.current[r]?.focus(),m===`single`&&G(e[r].value))},J=m===`single`?`radiogroup`:`toolbar`,Y=`${j}-item-0`;return(0,u.jsx)(a.FieldTemplate,{label:S,error:C,required:w,layout:T,labelId:M,htmlFor:Y,errorId:N,className:_,children:(0,u.jsxs)(D?t.Root:`div`,{ref:n.useMergedRef(R,k),id:j,className:(0,l.default)(`wim-toggle-group`,s.default.root,s.default[h],s.default[m],g&&s.default.fullWidth,B&&s.default.ready,C&&s.default.danger),role:J,"aria-label":v,"aria-labelledby":S?M:y,"aria-orientation":`horizontal`,"aria-invalid":C?!0:void 0,"aria-describedby":[b,C?N:void 0].filter(Boolean).join(` `)||void 0,children:[(0,u.jsx)(`div`,{className:(0,l.default)(s.default.slider,s.default[m],B&&s.default.ready),style:z,"aria-hidden":`true`}),e.map((e,t)=>{let n=`${j}-item-${t}`;return(0,u.jsxs)(`button`,{id:n,ref:e=>{V.current[t]=e},type:`button`,className:(0,l.default)(s.default.item,s.default[m],K(e.value)&&s.default.active,!e.label&&e.iconName&&s.default.iconOnly),onClick:()=>{W(t),G(e.value)},onKeyDown:e=>q(t,e),disabled:x||e.disabled,role:m===`single`?`radio`:`button`,"aria-checked":m===`single`?K(e.value):void 0,"aria-pressed":m===`multiple`?K(e.value):void 0,"aria-label":e.label?void 0:e.value,tabIndex:!e.disabled&&t===U?0:-1,children:[e.iconName&&(0,u.jsx)(r.Icon,{name:e.iconName,size:h,className:s.default.icon}),e.label&&(0,u.jsx)(`span`,{children:e.label})]},e.value)}),(0,u.jsx)(t.Slottable,{children:O})]})})});d.displayName=`ToggleGroup`,exports.ToggleGroup=d;
|