@ada-cx/lovelace 1.8.1 → 1.9.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/Survey/SurveyLabelProps.d.ts +8 -0
- package/dist/components/Survey/SurveyRating/SurveyRating.d.ts +4 -5
- package/dist/components/Survey/SurveyRating/SurveyRating.js +10 -9
- package/dist/components/Survey/SurveyRating/SurveyRating.js.map +1 -1
- package/dist/components/Survey/SurveySelect/SurveySelect.d.ts +4 -5
- package/dist/components/Survey/SurveySelect/SurveySelect.js +8 -7
- package/dist/components/Survey/SurveySelect/SurveySelect.js.map +1 -1
- package/dist/components/Survey/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
2
2
|
import type { Key } from "react-aria-components";
|
|
3
|
+
import type { SurveyLabelProps } from "../SurveyLabelProps.js";
|
|
3
4
|
export interface SurveyRatingOption {
|
|
4
5
|
/** Numeric value shown on the chip (e.g. 1–5, 1–10). Rendered unless `icon` is set. */
|
|
5
6
|
value: number;
|
|
@@ -12,11 +13,9 @@ export interface SurveyRatingOption {
|
|
|
12
13
|
/** Accessible name for the option. Overrides the numeric value / icon; icon options fall back to `label`. */
|
|
13
14
|
"aria-label"?: string;
|
|
14
15
|
}
|
|
15
|
-
export
|
|
16
|
+
export type SurveyRatingProps = SurveyLabelProps & {
|
|
16
17
|
/** Ordered rating options, lowest value first. */
|
|
17
18
|
options: SurveyRatingOption[];
|
|
18
|
-
/** Accessible name for the rating group. */
|
|
19
|
-
"aria-label": string;
|
|
20
19
|
/** Show the first and last options' labels as scale endpoints. */
|
|
21
20
|
showLabels?: boolean;
|
|
22
21
|
isDisabled?: boolean;
|
|
@@ -29,11 +28,11 @@ export interface SurveyRatingProps {
|
|
|
29
28
|
className?: string;
|
|
30
29
|
style?: CSSProperties;
|
|
31
30
|
ref?: Ref<HTMLDivElement>;
|
|
32
|
-
}
|
|
31
|
+
};
|
|
33
32
|
/**
|
|
34
33
|
* Single-select rating scale for post-conversation surveys. Renders each option as a
|
|
35
34
|
* square {@link Chip}; a numeric `value` or an `icon` (emoji, thumbs) per option supports
|
|
36
35
|
* arbitrary scales. Exactly one option is selectable at a time, and tapping the selected
|
|
37
36
|
* option deselects it (React Aria toggle semantics).
|
|
38
37
|
*/
|
|
39
|
-
export declare function SurveyRating({ options, showLabels, isDisabled, selectedKey, defaultSelectedKey, onChange, className, style, ref, "aria-label": ariaLabel, }: SurveyRatingProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function SurveyRating({ options, showLabels, isDisabled, selectedKey, defaultSelectedKey, onChange, className, style, ref, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: SurveyRatingProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,11 +11,11 @@ var s = (e, t) => e.key ?? t, c = 7, l = 48, u = 8, d = (e) => {
|
|
|
11
11
|
let t = d(e);
|
|
12
12
|
return t * l + (t - 1) * u;
|
|
13
13
|
};
|
|
14
|
-
function p({ options: c, showLabels: l = !1, isDisabled: u, selectedKey: d, defaultSelectedKey: p, onChange: m, className: h, style: g, ref: _, "aria-label": v }) {
|
|
15
|
-
let
|
|
14
|
+
function p({ options: c, showLabels: l = !1, isDisabled: u, selectedKey: d, defaultSelectedKey: p, onChange: m, className: h, style: g, ref: _, "aria-label": v, "aria-labelledby": y }) {
|
|
15
|
+
let b = c[0]?.label, x = c[c.length - 1]?.label, S = (e) => {
|
|
16
16
|
let t = e.size ? [...e][0] : null, n = t == null ? null : c.find((e, n) => s(e, n) === t) ?? null;
|
|
17
17
|
m?.(t, n);
|
|
18
|
-
},
|
|
18
|
+
}, C = (e) => e == null ? [] : [e], w = d !== void 0;
|
|
19
19
|
return /* @__PURE__ */ a("div", {
|
|
20
20
|
ref: _,
|
|
21
21
|
className: e(n, h),
|
|
@@ -23,12 +23,13 @@ function p({ options: c, showLabels: l = !1, isDisabled: u, selectedKey: d, defa
|
|
|
23
23
|
children: [/* @__PURE__ */ i(o, {
|
|
24
24
|
selectionMode: "single",
|
|
25
25
|
isDisabled: u,
|
|
26
|
-
"aria-label": v,
|
|
26
|
+
"aria-label": y ? void 0 : v,
|
|
27
|
+
"aria-labelledby": y,
|
|
27
28
|
className: r,
|
|
28
29
|
style: { maxWidth: f(c.length) },
|
|
29
|
-
onSelectionChange:
|
|
30
|
-
selectedKeys:
|
|
31
|
-
defaultSelectedKeys:
|
|
30
|
+
onSelectionChange: S,
|
|
31
|
+
selectedKeys: w ? C(d) : void 0,
|
|
32
|
+
defaultSelectedKeys: w ? void 0 : C(p),
|
|
32
33
|
children: c.map((e, n) => {
|
|
33
34
|
let r = e.icon != null;
|
|
34
35
|
return /* @__PURE__ */ i(t, {
|
|
@@ -39,9 +40,9 @@ function p({ options: c, showLabels: l = !1, isDisabled: u, selectedKey: d, defa
|
|
|
39
40
|
children: e.icon ?? e.value
|
|
40
41
|
}, s(e, n));
|
|
41
42
|
})
|
|
42
|
-
}), l && (
|
|
43
|
+
}), l && (b != null || x != null) && /* @__PURE__ */ a("div", {
|
|
43
44
|
className: "jzxfg72",
|
|
44
|
-
children: [/* @__PURE__ */ i("span", { children:
|
|
45
|
+
children: [/* @__PURE__ */ i("span", { children: b }), /* @__PURE__ */ i("span", { children: x })]
|
|
45
46
|
})]
|
|
46
47
|
});
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveyRating.js","names":[],"sources":["../../../../src/components/Survey/SurveyRating/SurveyRating.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../../utils/cx.js\";\nimport { Chip } from \"../../Chip/index.js\";\nimport {\n\tsurveyRatingLabels,\n\tsurveyRatingRoot,\n\tsurveyRatingScale,\n} from \"./SurveyRating.css.js\";\n\nexport interface SurveyRatingOption {\n\t/** Numeric value shown on the chip (e.g. 1–5, 1–10). Rendered unless `icon` is set. */\n\tvalue: number;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n\t/** Endpoint label to render as selected option. */\n\tlabel?: string;\n\t/** Renders an icon chip (emoji, thumbs) instead of the numeric value. */\n\ticon?: ReactNode;\n\t/** Accessible name for the option. Overrides the numeric value / icon; icon options fall back to `label`. */\n\t\"aria-label\"?: string;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"SurveyRating.js","names":[],"sources":["../../../../src/components/Survey/SurveyRating/SurveyRating.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../../utils/cx.js\";\nimport { Chip } from \"../../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyLabelProps.js\";\nimport {\n\tsurveyRatingLabels,\n\tsurveyRatingRoot,\n\tsurveyRatingScale,\n} from \"./SurveyRating.css.js\";\n\nexport interface SurveyRatingOption {\n\t/** Numeric value shown on the chip (e.g. 1–5, 1–10). Rendered unless `icon` is set. */\n\tvalue: number;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n\t/** Endpoint label to render as selected option. */\n\tlabel?: string;\n\t/** Renders an icon chip (emoji, thumbs) instead of the numeric value. */\n\ticon?: ReactNode;\n\t/** Accessible name for the option. Overrides the numeric value / icon; icon options fall back to `label`. */\n\t\"aria-label\"?: string;\n}\n\nexport type SurveyRatingProps = SurveyLabelProps & {\n\t/** Ordered rating options, lowest value first. */\n\toptions: SurveyRatingOption[];\n\t/** Show the first and last options' labels as scale endpoints. */\n\tshowLabels?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option key (controlled). `null` means nothing selected. */\n\tselectedKey?: Key | null;\n\t/** Initially-selected option key (uncontrolled). */\n\tdefaultSelectedKey?: Key | null;\n\t/** Fires with the newly-selected key and option, or `null` when deselected. */\n\tonChange?: (key: Key | null, option: SurveyRatingOption | null) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveyRatingOption, index: number) =>\n\toption.key ?? index;\n\n/** Most chips allowed on one row before the scale wraps to a balanced grid. */\nconst MAX_PER_ROW = 7;\n\n/** Chip footprint at `size=\"lg\"` — mirrors Chip.css.ts's fixed 48px square + gap-8. */\nconst CHIP_SIZE_LG = 48;\nconst CHIP_GAP = 8;\n\n/** Column count that splits `count` options into evenly-sized rows (11 → 6, 10 → 5, 7 → 7). */\nconst balancedColumns = (count: number) => {\n\tconst rows = Math.max(1, Math.ceil(count / MAX_PER_ROW));\n\treturn Math.max(1, Math.ceil(count / rows));\n};\n\n/**\n * Width that wraps the scale at the balanced column count. A cap rather than a fixed\n * track count, so a container narrower than this wraps further instead of overflowing\n * (the 0-10 scale is 328px wide — wider than the 320px BubbleOverlay cap).\n */\nconst balancedMaxWidth = (count: number) => {\n\tconst cols = balancedColumns(count);\n\treturn cols * CHIP_SIZE_LG + (cols - 1) * CHIP_GAP;\n};\n\n/**\n * Single-select rating scale for post-conversation surveys. Renders each option as a\n * square {@link Chip}; a numeric `value` or an `icon` (emoji, thumbs) per option supports\n * arbitrary scales. Exactly one option is selectable at a time, and tapping the selected\n * option deselects it (React Aria toggle semantics).\n */\nexport function SurveyRating({\n\toptions,\n\tshowLabels = false,\n\tisDisabled,\n\tselectedKey,\n\tdefaultSelectedKey,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveyRatingProps) {\n\tconst lowLabel = options[0]?.label;\n\tconst highLabel = options[options.length - 1]?.label;\n\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst key = keys.size ? [...keys][0] : null;\n\t\tconst option =\n\t\t\tkey == null\n\t\t\t\t? null\n\t\t\t\t: (options.find((o, i) => keyFor(o, i) === key) ?? null);\n\t\tonChange?.(key, option);\n\t};\n\n\t// Translate the single-key facade into RAC's Set-based controlled/uncontrolled props:\n\t// a defined `selectedKey` (including `null`) is controlled; otherwise it's uncontrolled.\n\tconst toKeys = (key: Key | null | undefined) => (key == null ? [] : [key]);\n\tconst isControlled = selectedKey !== undefined;\n\n\treturn (\n\t\t<div ref={ref} className={cx(surveyRatingRoot, className)} style={style}>\n\t\t\t<ToggleButtonGroup\n\t\t\t\tselectionMode=\"single\"\n\t\t\t\tisDisabled={isDisabled}\n\t\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\t\tclassName={surveyRatingScale}\n\t\t\t\tstyle={{ maxWidth: balancedMaxWidth(options.length) }}\n\t\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\t\tselectedKeys={isControlled ? toKeys(selectedKey) : undefined}\n\t\t\t\tdefaultSelectedKeys={\n\t\t\t\t\tisControlled ? undefined : toKeys(defaultSelectedKey)\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{options.map((option, index) => {\n\t\t\t\t\tconst isIcon = option.icon != null;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Chip\n\t\t\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\t\t\tvariant={isIcon ? \"icon\" : \"number\"}\n\t\t\t\t\t\t\tsize=\"lg\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\toption[\"aria-label\"] ?? (isIcon ? option.label : undefined)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{option.icon ?? option.value}\n\t\t\t\t\t\t</Chip>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</ToggleButtonGroup>\n\t\t\t{showLabels && (lowLabel != null || highLabel != null) && (\n\t\t\t\t<div className={surveyRatingLabels}>\n\t\t\t\t\t<span>{lowLabel}</span>\n\t\t\t\t\t<span>{highLabel}</span>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AA0CA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO,GAGT,IAAc,GAGd,IAAe,IACf,IAAW,GAGX,KAAmB,MAAkB;CAC1C,IAAM,IAAO,KAAK,IAAI,GAAG,KAAK,KAAK,IAAQ,EAAY,CAAC;AACxD,QAAO,KAAK,IAAI,GAAG,KAAK,KAAK,IAAQ,EAAK,CAAC;GAQtC,KAAoB,MAAkB;CAC3C,IAAM,IAAO,EAAgB,EAAM;AACnC,QAAO,IAAO,KAAgB,IAAO,KAAK;;AAS3C,SAAgB,EAAa,EAC5B,YACA,gBAAa,IACb,eACA,gBACA,uBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,IAAW,EAAQ,IAAI,OACvB,IAAY,EAAQ,EAAQ,SAAS,IAAI,OAEzC,KAAyB,MAAmB;EACjD,IAAM,IAAM,EAAK,OAAO,CAAC,GAAG,EAAK,CAAC,KAAK,MACjC,IACL,KAAO,OACJ,OACC,EAAQ,MAAM,GAAG,MAAM,EAAO,GAAG,EAAE,KAAK,EAAI,IAAI;AACrD,MAAW,GAAK,EAAO;IAKlB,KAAU,MAAiC,KAAO,OAAO,EAAE,GAAG,CAAC,EAAI,EACnE,IAAe,MAAgB,KAAA;AAErC,QACC,kBAAC,OAAD;EAAU;EAAK,WAAW,EAAG,GAAkB,EAAU;EAAS;YAAlE,CACC,kBAAC,GAAD;GACC,eAAc;GACF;GACZ,cAAY,IAAiB,KAAA,IAAY;GACzC,mBAAiB;GACjB,WAAW;GACX,OAAO,EAAE,UAAU,EAAiB,EAAQ,OAAO,EAAE;GACrD,mBAAmB;GACnB,cAAc,IAAe,EAAO,EAAY,GAAG,KAAA;GACnD,qBACC,IAAe,KAAA,IAAY,EAAO,EAAmB;aAGrD,EAAQ,KAAK,GAAQ,MAAU;IAC/B,IAAM,IAAS,EAAO,QAAQ;AAC9B,WACC,kBAAC,GAAD;KAEC,IAAI,EAAO,GAAQ,EAAM;KACzB,SAAS,IAAS,SAAS;KAC3B,MAAK;KACL,cACC,EAAO,kBAAkB,IAAS,EAAO,QAAQ,KAAA;eAGjD,EAAO,QAAQ,EAAO;KACjB,EATD,EAAO,GAAQ,EAAM,CASpB;KAEP;GACiB,CAAA,EACnB,MAAe,KAAY,QAAQ,KAAa,SAChD,kBAAC,OAAD;GAAK,WAAA;aAAL,CACC,kBAAC,QAAD,EAAA,UAAO,GAAgB,CAAA,EACvB,kBAAC,QAAD,EAAA,UAAO,GAAiB,CAAA,CACnB;KAEF"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { CSSProperties, Ref } from "react";
|
|
2
2
|
import type { Key } from "react-aria-components";
|
|
3
|
+
import type { SurveyLabelProps } from "../SurveyLabelProps.js";
|
|
3
4
|
export interface SurveySelectOption {
|
|
4
5
|
/** Chip label text. */
|
|
5
6
|
label: string;
|
|
6
7
|
/** Stable identity used for selection. Defaults to the option's array index. */
|
|
7
8
|
key?: Key;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
+
export type SurveySelectProps = SurveyLabelProps & {
|
|
10
11
|
/** Selectable options, rendered in order. */
|
|
11
12
|
options: SurveySelectOption[];
|
|
12
|
-
/** Accessible name for the group. */
|
|
13
|
-
"aria-label": string;
|
|
14
13
|
/**
|
|
15
14
|
* `multiple` (default) allows any number of selected chips; `single` allows at
|
|
16
15
|
* most one (e.g. a Yes/No question) and renders as a radiogroup.
|
|
@@ -31,10 +30,10 @@ export interface SurveySelectProps {
|
|
|
31
30
|
className?: string;
|
|
32
31
|
style?: CSSProperties;
|
|
33
32
|
ref?: Ref<HTMLDivElement>;
|
|
34
|
-
}
|
|
33
|
+
};
|
|
35
34
|
/**
|
|
36
35
|
* Multi-select chip group for surveys — the labelled-pill counterpart to the single-select
|
|
37
36
|
* {@link SurveyRating}. Any number of options can be selected at once; selection state
|
|
38
37
|
* renders the accent fill on each {@link Chip}.
|
|
39
38
|
*/
|
|
40
|
-
export declare function SurveySelect({ options, selectionMode, disallowEmptySelection, isDisabled, selectedKeys, defaultSelectedKeys, onChange, className, style, ref, "aria-label": ariaLabel, }: SurveySelectProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function SurveySelect({ options, selectionMode, disallowEmptySelection, isDisabled, selectedKeys, defaultSelectedKeys, onChange, className, style, ref, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: SurveySelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,25 +5,26 @@ import { jsx as r } from "react/jsx-runtime";
|
|
|
5
5
|
import { ToggleButtonGroup as i } from "react-aria-components";
|
|
6
6
|
//#region src/components/Survey/SurveySelect/SurveySelect.tsx
|
|
7
7
|
var a = (e, t) => e.key ?? t;
|
|
8
|
-
function o({ options: o, selectionMode: s = "multiple", disallowEmptySelection: c, isDisabled: l, selectedKeys: u, defaultSelectedKeys: d, onChange: f, className: p, style: m, ref: h, "aria-label": g }) {
|
|
9
|
-
let
|
|
8
|
+
function o({ options: o, selectionMode: s = "multiple", disallowEmptySelection: c, isDisabled: l, selectedKeys: u, defaultSelectedKeys: d, onChange: f, className: p, style: m, ref: h, "aria-label": g, "aria-labelledby": _ }) {
|
|
9
|
+
let v = (e) => {
|
|
10
10
|
let t = o.map((e, t) => ({
|
|
11
11
|
option: e,
|
|
12
12
|
key: a(e, t)
|
|
13
13
|
})).filter(({ key: t }) => e.has(t));
|
|
14
14
|
f?.(t.map((e) => e.key), t.map((e) => e.option));
|
|
15
|
-
},
|
|
15
|
+
}, y = u !== void 0;
|
|
16
16
|
return /* @__PURE__ */ r(i, {
|
|
17
17
|
ref: h,
|
|
18
18
|
selectionMode: s,
|
|
19
19
|
disallowEmptySelection: c,
|
|
20
20
|
isDisabled: l,
|
|
21
|
-
"aria-label": g,
|
|
21
|
+
"aria-label": _ ? void 0 : g,
|
|
22
|
+
"aria-labelledby": _,
|
|
22
23
|
className: e(n, p),
|
|
23
24
|
style: m,
|
|
24
|
-
onSelectionChange:
|
|
25
|
-
selectedKeys:
|
|
26
|
-
defaultSelectedKeys:
|
|
25
|
+
onSelectionChange: v,
|
|
26
|
+
selectedKeys: y ? u : void 0,
|
|
27
|
+
defaultSelectedKeys: y ? void 0 : d ?? [],
|
|
27
28
|
children: o.map((e, n) => /* @__PURE__ */ r(t, {
|
|
28
29
|
id: a(e, n),
|
|
29
30
|
variant: "text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../../src/components/Survey/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../../utils/cx.js\";\nimport { Chip } from \"../../Chip/index.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../../src/components/Survey/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../../utils/cx.js\";\nimport { Chip } from \"../../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyLabelProps.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport type SurveySelectProps = SurveyLabelProps & {\n\t/** Selectable options, rendered in order. */\n\toptions: SurveySelectOption[];\n\t/**\n\t * `multiple` (default) allows any number of selected chips; `single` allows at\n\t * most one (e.g. a Yes/No question) and renders as a radiogroup.\n\t */\n\tselectionMode?: \"single\" | \"multiple\";\n\t/**\n\t * When `true`, a selected option can't be toggled back off — restores radio\n\t * semantics for a required single-select (e.g. a Yes/No question).\n\t */\n\tdisallowEmptySelection?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option keys (controlled). */\n\tselectedKeys?: Key[];\n\t/** Initially-selected option keys (uncontrolled). */\n\tdefaultSelectedKeys?: Key[];\n\t/** Fires with the full set of selected keys and their options, in option order. */\n\tonChange?: (keys: Key[], options: SurveySelectOption[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveySelectOption, index: number) =>\n\toption.key ?? index;\n\n/**\n * Multi-select chip group for surveys — the labelled-pill counterpart to the single-select\n * {@link SurveyRating}. Any number of options can be selected at once; selection state\n * renders the accent fill on each {@link Chip}.\n */\nexport function SurveySelect({\n\toptions,\n\tselectionMode = \"multiple\",\n\tdisallowEmptySelection,\n\tisDisabled,\n\tselectedKeys,\n\tdefaultSelectedKeys,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveySelectProps) {\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst selected = options\n\t\t\t.map((option, index) => ({ option, key: keyFor(option, index) }))\n\t\t\t.filter(({ key }) => keys.has(key));\n\t\tonChange?.(\n\t\t\tselected.map((s) => s.key),\n\t\t\tselected.map((s) => s.option),\n\t\t);\n\t};\n\n\tconst isControlled = selectedKeys !== undefined;\n\n\treturn (\n\t\t<ToggleButtonGroup\n\t\t\tref={ref}\n\t\t\tselectionMode={selectionMode}\n\t\t\tdisallowEmptySelection={disallowEmptySelection}\n\t\t\tisDisabled={isDisabled}\n\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tclassName={cx(surveySelectRoot, className)}\n\t\t\tstyle={style}\n\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\tselectedKeys={isControlled ? selectedKeys : undefined}\n\t\t\tdefaultSelectedKeys={\n\t\t\t\tisControlled ? undefined : (defaultSelectedKeys ?? [])\n\t\t\t}\n\t\t>\n\t\t\t{options.map((option, index) => (\n\t\t\t\t<Chip\n\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\tvariant=\"text\"\n\t\t\t\t\tsize=\"md\"\n\t\t\t\t>\n\t\t\t\t\t{option.label}\n\t\t\t\t</Chip>\n\t\t\t))}\n\t\t</ToggleButtonGroup>\n\t);\n}\n"],"mappings":";;;;;;AAwCA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO;AAOf,SAAgB,EAAa,EAC5B,YACA,mBAAgB,YAChB,2BACA,eACA,iBACA,wBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,KAAyB,MAAmB;EACjD,IAAM,IAAW,EACf,KAAK,GAAQ,OAAW;GAAE;GAAQ,KAAK,EAAO,GAAQ,EAAM;GAAE,EAAE,CAChE,QAAQ,EAAE,aAAU,EAAK,IAAI,EAAI,CAAC;AACpC,MACC,EAAS,KAAK,MAAM,EAAE,IAAI,EAC1B,EAAS,KAAK,MAAM,EAAE,OAAO,CAC7B;IAGI,IAAe,MAAiB,KAAA;AAEtC,QACC,kBAAC,GAAD;EACM;EACU;EACS;EACZ;EACZ,cAAY,IAAiB,KAAA,IAAY;EACzC,mBAAiB;EACjB,WAAW,EAAG,GAAkB,EAAU;EACnC;EACP,mBAAmB;EACnB,cAAc,IAAe,IAAe,KAAA;EAC5C,qBACC,IAAe,KAAA,IAAa,KAAuB,EAAE;YAGrD,EAAQ,KAAK,GAAQ,MACrB,kBAAC,GAAD;GAEC,IAAI,EAAO,GAAQ,EAAM;GACzB,SAAQ;GACR,MAAK;aAEJ,EAAO;GACF,EAND,EAAO,GAAQ,EAAM,CAMpB,CACN;EACiB,CAAA"}
|
package/package.json
CHANGED