@planningcenter/tapestry 3.1.0-rc.14 → 3.1.0-rc.16
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/select/Select.d.ts +2 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/select/Select.js +7 -3
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/select/SelectOptions.d.ts.map +1 -1
- package/dist/components/select/SelectOptions.js +2 -1
- package/dist/components/select/SelectOptions.js.map +1 -1
- package/dist/components/select/SelectPopover.d.ts +1 -0
- package/dist/components/select/SelectPopover.d.ts.map +1 -1
- package/dist/components/select/SelectPopover.js +9 -7
- package/dist/components/select/SelectPopover.js.map +1 -1
- package/dist/reactRender.css +780 -779
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +780 -779
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +1 -0
- package/dist/unstable.css.map +1 -1
- package/dist/utilities/selectUtils.d.ts +1 -0
- package/dist/utilities/selectUtils.d.ts.map +1 -1
- package/dist/utilities/selectUtils.js +10 -1
- package/dist/utilities/selectUtils.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@ import "./index.css";
|
|
|
2
2
|
import React, { type SelectHTMLAttributes } from "react";
|
|
3
3
|
export type SelectSize = "lg" | "md";
|
|
4
4
|
export interface SelectOptionWithTextLabel {
|
|
5
|
+
[key: `data-${string}`]: boolean | number | string | undefined;
|
|
5
6
|
/** Whether this option is non-interactive. */
|
|
6
7
|
disabled?: boolean;
|
|
7
8
|
divider?: never;
|
|
@@ -11,6 +12,7 @@ export interface SelectOptionWithTextLabel {
|
|
|
11
12
|
value: string;
|
|
12
13
|
}
|
|
13
14
|
export interface SelectOptionWithNodeLabel {
|
|
15
|
+
[key: `data-${string}`]: boolean | number | string | undefined;
|
|
14
16
|
/** Whether this option is non-interactive. */
|
|
15
17
|
disabled?: boolean;
|
|
16
18
|
divider?: never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,EAAc,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAKpB,OAAO,KAAK,EAAE,EAAc,KAAK,oBAAoB,EAAU,MAAM,OAAO,CAAA;AAS5E,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAA;AAEpC,MAAM,WAAW,yBAAyB;IACxC,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC9D,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC9D,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,KAAK,CAAA;IACf,uCAAuC;IACvC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,OAAO,EAAE,IAAI,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,SAAS,CAAC,EAAE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d;AAED,MAAM,MAAM,WAAW,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,qBAAqB,GACrB,sBAAsB,CAAA;AAE1B,KAAK,sBAAsB,GAAG,IAAI,CAChC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,CACxC,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,GAC3D,WAAW,GAAG;IACZ,OAAO,CAAC,EAAE,KAAK,CAAA;CAChB,CAAA;AAEH,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,GAC5D,WAAW,GAAG;IACZ,OAAO,EAAE,IAAI,CAAA;CACd,CAAA;AAEH,MAAM,MAAM,kBAAkB,GAC1B,wBAAwB,GACxB,yBAAyB,CAAA;AAkB7B,eAAO,MAAM,MAAM,8FAwGlB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Icon from '../../utilities/Icon.js';
|
|
2
2
|
import { useId } from '../../utilities/useId.js';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import React__default, { forwardRef } from 'react';
|
|
4
|
+
import React__default, { forwardRef, useRef } from 'react';
|
|
5
5
|
import { SelectNative } from './SelectNative.js';
|
|
6
6
|
import { SelectPopover } from './SelectPopover.js';
|
|
7
7
|
|
|
@@ -17,6 +17,7 @@ function normalizeSelectValue(value) {
|
|
|
17
17
|
// ---------------------------------------------------------------------------
|
|
18
18
|
const Select = forwardRef(function Select(props, ref) {
|
|
19
19
|
const { "aria-label": userAriaLabel, "aria-labelledby": userAriaLabelledBy, className, complex, defaultValue, description, hideLabel, id, invalid, label, onChange, options, placeholder, required, size, value, ...restProps } = props;
|
|
20
|
+
const triggerRef = useRef(null);
|
|
20
21
|
const stableId = useId();
|
|
21
22
|
const controlId = id || `tds-select-${stableId}`;
|
|
22
23
|
const labelId = `${controlId}-label`;
|
|
@@ -47,11 +48,14 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
47
48
|
required,
|
|
48
49
|
value: normalizedValue,
|
|
49
50
|
};
|
|
51
|
+
const handleComplexLabelClick = () => triggerRef.current?.focus();
|
|
50
52
|
const SelectComponent = complex ? SelectPopover : SelectNative;
|
|
51
53
|
return (React__default.createElement("div", { className: computedClassName },
|
|
52
54
|
showLabel &&
|
|
53
|
-
(complex ? (
|
|
54
|
-
|
|
55
|
+
(complex ? (
|
|
56
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- mirrors native label click-to-focus; keyboard users interact with the combobox directly
|
|
57
|
+
React__default.createElement("div", { className: "tds-select-label", id: labelId, onClick: handleComplexLabelClick }, label)) : (React__default.createElement("label", { htmlFor: controlId, id: labelId }, label))),
|
|
58
|
+
React__default.createElement(SelectComponent, { ...sharedControlProps, ref: ref, id: controlId, onChange: onChange, ...(complex && { triggerRef }) }),
|
|
55
59
|
description && descriptionId && (React__default.createElement("p", { className: "tds-select-description", id: descriptionId },
|
|
56
60
|
React__default.createElement(Icon, { "aria-hidden": true, className: "tds-select-description-invalid-icon", symbol: "general#exclamation-triangle" }),
|
|
57
61
|
description))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, type SelectHTMLAttributes } from \"react\"\n\nimport { SelectNative } from \"./SelectNative\"\nimport { SelectPopover } from \"./SelectPopover\"\n\n// ---------------------------------------------------------------------------\n// Shared types\n// ---------------------------------------------------------------------------\n\nexport type SelectSize = \"lg\" | \"md\"\n\nexport interface SelectOptionWithTextLabel {\n /** Whether this option is non-interactive. */\n disabled?: boolean\n divider?: never\n /** Displayed as the option content and used for type-ahead matching. */\n label: string\n textValue?: never\n value: string\n}\n\nexport interface SelectOptionWithNodeLabel {\n /** Whether this option is non-interactive. */\n disabled?: boolean\n divider?: never\n /** Displayed as the option content. */\n label: React.ReactNode\n /** Plain-text representation required for type-ahead matching. */\n textValue: string\n value: string\n}\n\nexport interface SelectOptionDivider {\n disabled?: never\n divider: true\n label?: never\n textValue?: never\n value?: never\n}\n\nexport type SelectOption =\n | SelectOptionDivider\n | SelectOptionWithNodeLabel\n | SelectOptionWithTextLabel\n\nexport interface SelectOptionsGroup {\n /** Whether all options in this group are non-interactive. */\n disabled?: boolean\n /** Visible heading displayed above the group's options. */\n label: string\n /** The selectable options within this group. */\n options: SelectOption[]\n}\n\nexport type SelectItem = SelectOption | SelectOptionsGroup\n\n// ---------------------------------------------------------------------------\n// Select component props\n// ---------------------------------------------------------------------------\n\ninterface SelectBaseProps {\n /** Render as popover listbox (SelectPopover) instead of native <select>. */\n complex?: boolean\n /** Helper text below the select. Red when invalid. */\n description?: string\n /** Triggers invalid state (red border, red description). */\n invalid?: boolean\n /** A flat or mixed array of options and option groups. */\n options: SelectItem[]\n /** Placeholder text for the empty state. */\n placeholder: string\n /** Visual size of the select. */\n size?: SelectSize\n}\n\ninterface SelectWithVisibleLabel extends SelectBaseProps {\n /** If true, label is visually hidden and applied as aria-label instead. */\n hideLabel?: false\n /** Label text displayed above the select. */\n label: string\n}\n\ninterface SelectWithHiddenLabel extends SelectBaseProps {\n /** If true, label is visually hidden and applied as aria-label instead. */\n hideLabel: true\n /** Label text used as aria-label when visually hidden. */\n label: string\n}\n\ninterface SelectWithAriaLabel extends SelectBaseProps {\n \"aria-label\": string\n hideLabel?: never\n label?: never\n}\n\ninterface SelectWithAriaLabelledBy extends SelectBaseProps {\n \"aria-labelledby\": string\n hideLabel?: never\n label?: never\n}\n\nexport type SelectProps =\n | SelectWithAriaLabel\n | SelectWithAriaLabelledBy\n | SelectWithHiddenLabel\n | SelectWithVisibleLabel\n\ntype BaseSelectElementProps = Omit<\n SelectHTMLAttributes<HTMLSelectElement>,\n keyof SelectProps | \"multiple\" | \"size\"\n>\n\nexport type NativeSelectElementProps = BaseSelectElementProps &\n SelectProps & {\n complex?: false\n }\n\nexport type ComplexSelectElementProps = BaseSelectElementProps &\n SelectProps & {\n complex: true\n }\n\nexport type SelectElementProps =\n | NativeSelectElementProps\n | ComplexSelectElementProps\n\nfunction normalizeSelectValue(\n value:\n | NativeSelectElementProps[\"defaultValue\"]\n | NativeSelectElementProps[\"value\"]\n | ComplexSelectElementProps[\"defaultValue\"]\n | ComplexSelectElementProps[\"value\"]\n) {\n if (value === undefined || value === null) return undefined\n if (Array.isArray(value)) return value[0]\n return String(value)\n}\n\n// ---------------------------------------------------------------------------\n// Select (public)\n// ---------------------------------------------------------------------------\n\nexport const Select = forwardRef<HTMLSelectElement, SelectElementProps>(\n function Select(props: SelectElementProps, ref) {\n const {\n \"aria-label\": userAriaLabel,\n \"aria-labelledby\": userAriaLabelledBy,\n className,\n complex,\n defaultValue,\n description,\n hideLabel,\n id,\n invalid,\n label,\n onChange,\n options,\n placeholder,\n required,\n size,\n value,\n ...restProps\n } = props\n\n const stableId = useId()\n const controlId = id || `tds-select-${stableId}`\n const labelId = `${controlId}-label`\n const descriptionId = description ? `${controlId}-description` : undefined\n const computedClassName = classNames(\n \"tds-select\",\n {\n \"tds-select--invalid\": invalid,\n \"tds-select--lg\": size === \"lg\",\n \"tds-select--required\": required,\n },\n className\n )\n\n const normalizedDefaultValue = normalizeSelectValue(defaultValue)\n const normalizedValue = normalizeSelectValue(value)\n\n const computedDefaultValue =\n normalizedDefaultValue === undefined && normalizedValue === undefined\n ? \"\"\n : normalizedDefaultValue\n const showLabel = !!label && !hideLabel\n const computedAriaLabel = userAriaLabel ?? (hideLabel ? label : undefined)\n const computedAriaLabelledBy =\n userAriaLabelledBy ??\n (computedAriaLabel || !showLabel ? undefined : labelId)\n\n const sharedControlProps = {\n ...restProps,\n \"aria-describedby\": descriptionId,\n \"aria-label\": computedAriaLabel,\n \"aria-labelledby\": computedAriaLabelledBy,\n defaultValue: computedDefaultValue,\n invalid,\n options,\n placeholder,\n required,\n value: normalizedValue,\n }\n\n const SelectComponent = complex ? SelectPopover : SelectNative\n\n return (\n <div className={computedClassName}>\n {showLabel &&\n (complex ? (\n <div className=\"tds-select-label\" id={labelId}>\n {label}\n </div>\n ) : (\n <label htmlFor={controlId} id={labelId}>\n {label}\n </label>\n ))}\n <SelectComponent\n {...sharedControlProps}\n ref={ref}\n id={controlId}\n onChange={onChange}\n />\n {description && descriptionId && (\n <p className=\"tds-select-description\" id={descriptionId}>\n <Icon\n aria-hidden\n className=\"tds-select-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </p>\n )}\n </div>\n )\n }\n)\n\nSelect.displayName = \"Select\"\n"],"names":["React"],"mappings":";;;;;;;AAmIA,SAAS,oBAAoB,CAC3B,KAIsC,EAAA;AAEtC,IAAA,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,SAAS;AAC3D,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC;AACzC,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB;AAEA;AACA;AACA;AAEO,MAAM,MAAM,GAAG,UAAU,CAC9B,SAAS,MAAM,CAAC,KAAyB,EAAE,GAAG,EAAA;AAC5C,IAAA,MAAM,EACJ,YAAY,EAAE,aAAa,EAC3B,iBAAiB,EAAE,kBAAkB,EACrC,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,SAAS,EACT,EAAE,EACF,OAAO,EACP,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,GAAG,SAAS,EACb,GAAG,KAAK;AAET,IAAA,MAAM,QAAQ,GAAG,KAAK,EAAE;AACxB,IAAA,MAAM,SAAS,GAAG,EAAE,IAAI,CAAA,WAAA,EAAc,QAAQ,EAAE;AAChD,IAAA,MAAM,OAAO,GAAG,CAAA,EAAG,SAAS,QAAQ;AACpC,IA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,EAAC,EAAE,EAAE,OAAO,IAC1C,KAAK,CACF,KAENA,cAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAA,EACnC,KAAK,CACA,CACT,CAAC;AACJ,QAAAA,cAAA,CAAA,aAAA,CAAC,eAAe,EAAA,EAAA,GACV,kBAAkB,EACtB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,EACb,QAAQ,EAAE,QAAQ,EAAA,CAClB;QACD,WAAW,IAAI,aAAa,KAC3BA,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,wBAAwB,EAAC,EAAE,EAAE,aAAa,EAAA;YACrDA,cAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,qCAAqC,EAC/C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,WAAW,CACV,CACL,CACG;AAEV,CAAC;AAGH,MAAM,CAAC,WAAW,GAAG,QAAQ;;;;"}
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport { useId } from \"@utilities/useId\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, type SelectHTMLAttributes, useRef } from \"react\"\n\nimport { SelectNative } from \"./SelectNative\"\nimport { SelectPopover } from \"./SelectPopover\"\n\n// ---------------------------------------------------------------------------\n// Shared types\n// ---------------------------------------------------------------------------\n\nexport type SelectSize = \"lg\" | \"md\"\n\nexport interface SelectOptionWithTextLabel {\n [key: `data-${string}`]: boolean | number | string | undefined\n /** Whether this option is non-interactive. */\n disabled?: boolean\n divider?: never\n /** Displayed as the option content and used for type-ahead matching. */\n label: string\n textValue?: never\n value: string\n}\n\nexport interface SelectOptionWithNodeLabel {\n [key: `data-${string}`]: boolean | number | string | undefined\n /** Whether this option is non-interactive. */\n disabled?: boolean\n divider?: never\n /** Displayed as the option content. */\n label: React.ReactNode\n /** Plain-text representation required for type-ahead matching. */\n textValue: string\n value: string\n}\n\nexport interface SelectOptionDivider {\n disabled?: never\n divider: true\n label?: never\n textValue?: never\n value?: never\n}\n\nexport type SelectOption =\n | SelectOptionDivider\n | SelectOptionWithNodeLabel\n | SelectOptionWithTextLabel\n\nexport interface SelectOptionsGroup {\n /** Whether all options in this group are non-interactive. */\n disabled?: boolean\n /** Visible heading displayed above the group's options. */\n label: string\n /** The selectable options within this group. */\n options: SelectOption[]\n}\n\nexport type SelectItem = SelectOption | SelectOptionsGroup\n\n// ---------------------------------------------------------------------------\n// Select component props\n// ---------------------------------------------------------------------------\n\ninterface SelectBaseProps {\n /** Render as popover listbox (SelectPopover) instead of native <select>. */\n complex?: boolean\n /** Helper text below the select. Red when invalid. */\n description?: string\n /** Triggers invalid state (red border, red description). */\n invalid?: boolean\n /** A flat or mixed array of options and option groups. */\n options: SelectItem[]\n /** Placeholder text for the empty state. */\n placeholder: string\n /** Visual size of the select. */\n size?: SelectSize\n}\n\ninterface SelectWithVisibleLabel extends SelectBaseProps {\n /** If true, label is visually hidden and applied as aria-label instead. */\n hideLabel?: false\n /** Label text displayed above the select. */\n label: string\n}\n\ninterface SelectWithHiddenLabel extends SelectBaseProps {\n /** If true, label is visually hidden and applied as aria-label instead. */\n hideLabel: true\n /** Label text used as aria-label when visually hidden. */\n label: string\n}\n\ninterface SelectWithAriaLabel extends SelectBaseProps {\n \"aria-label\": string\n hideLabel?: never\n label?: never\n}\n\ninterface SelectWithAriaLabelledBy extends SelectBaseProps {\n \"aria-labelledby\": string\n hideLabel?: never\n label?: never\n}\n\nexport type SelectProps =\n | SelectWithAriaLabel\n | SelectWithAriaLabelledBy\n | SelectWithHiddenLabel\n | SelectWithVisibleLabel\n\ntype BaseSelectElementProps = Omit<\n SelectHTMLAttributes<HTMLSelectElement>,\n keyof SelectProps | \"multiple\" | \"size\"\n>\n\nexport type NativeSelectElementProps = BaseSelectElementProps &\n SelectProps & {\n complex?: false\n }\n\nexport type ComplexSelectElementProps = BaseSelectElementProps &\n SelectProps & {\n complex: true\n }\n\nexport type SelectElementProps =\n | NativeSelectElementProps\n | ComplexSelectElementProps\n\nfunction normalizeSelectValue(\n value:\n | NativeSelectElementProps[\"defaultValue\"]\n | NativeSelectElementProps[\"value\"]\n | ComplexSelectElementProps[\"defaultValue\"]\n | ComplexSelectElementProps[\"value\"]\n) {\n if (value === undefined || value === null) return undefined\n if (Array.isArray(value)) return value[0]\n return String(value)\n}\n\n// ---------------------------------------------------------------------------\n// Select (public)\n// ---------------------------------------------------------------------------\n\nexport const Select = forwardRef<HTMLSelectElement, SelectElementProps>(\n function Select(props: SelectElementProps, ref) {\n const {\n \"aria-label\": userAriaLabel,\n \"aria-labelledby\": userAriaLabelledBy,\n className,\n complex,\n defaultValue,\n description,\n hideLabel,\n id,\n invalid,\n label,\n onChange,\n options,\n placeholder,\n required,\n size,\n value,\n ...restProps\n } = props\n\n const triggerRef = useRef<HTMLButtonElement>(null)\n const stableId = useId()\n const controlId = id || `tds-select-${stableId}`\n const labelId = `${controlId}-label`\n const descriptionId = description ? `${controlId}-description` : undefined\n const computedClassName = classNames(\n \"tds-select\",\n {\n \"tds-select--invalid\": invalid,\n \"tds-select--lg\": size === \"lg\",\n \"tds-select--required\": required,\n },\n className\n )\n\n const normalizedDefaultValue = normalizeSelectValue(defaultValue)\n const normalizedValue = normalizeSelectValue(value)\n\n const computedDefaultValue =\n normalizedDefaultValue === undefined && normalizedValue === undefined\n ? \"\"\n : normalizedDefaultValue\n const showLabel = !!label && !hideLabel\n const computedAriaLabel = userAriaLabel ?? (hideLabel ? label : undefined)\n const computedAriaLabelledBy =\n userAriaLabelledBy ??\n (computedAriaLabel || !showLabel ? undefined : labelId)\n\n const sharedControlProps = {\n ...restProps,\n \"aria-describedby\": descriptionId,\n \"aria-label\": computedAriaLabel,\n \"aria-labelledby\": computedAriaLabelledBy,\n defaultValue: computedDefaultValue,\n invalid,\n options,\n placeholder,\n required,\n value: normalizedValue,\n }\n\n const handleComplexLabelClick = () => triggerRef.current?.focus()\n\n const SelectComponent = complex ? SelectPopover : SelectNative\n\n return (\n <div className={computedClassName}>\n {showLabel &&\n (complex ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- mirrors native label click-to-focus; keyboard users interact with the combobox directly\n <div\n className=\"tds-select-label\"\n id={labelId}\n onClick={handleComplexLabelClick}\n >\n {label}\n </div>\n ) : (\n <label htmlFor={controlId} id={labelId}>\n {label}\n </label>\n ))}\n <SelectComponent\n {...sharedControlProps}\n ref={ref}\n id={controlId}\n onChange={onChange}\n {...(complex && { triggerRef })}\n />\n {description && descriptionId && (\n <p className=\"tds-select-description\" id={descriptionId}>\n <Icon\n aria-hidden\n className=\"tds-select-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n />\n {description}\n </p>\n )}\n </div>\n )\n }\n)\n\nSelect.displayName = \"Select\"\n"],"names":["React"],"mappings":";;;;;;;AAqIA,SAAS,oBAAoB,CAC3B,KAIsC,EAAA;AAEtC,IAAA,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;AAAE,QAAA,OAAO,SAAS;AAC3D,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC;AACzC,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB;AAEA;AACA;AACA;AAEO,MAAM,MAAM,GAAG,UAAU,CAC9B,SAAS,MAAM,CAAC,KAAyB,EAAE,GAAG,EAAA;AAC5C,IAAA,MAAM,EACJ,YAAY,EAAE,aAAa,EAC3B,iBAAiB,EAAE,kBAAkB,EACrC,SAAS,EACT,OAAO,EACP,YAAY,EACZ,WAAW,EACX,SAAS,EACT,EAAE,EACF,OAAO,EACP,KAAK,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,GAAG,SAAS,E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eAAe;KACvB;IAED,MAAM,uBAAuB,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE;IAEjE,MAAM,eAAe,GAAG,OAAO,GAAG,aAAa,GAAG,YAAY;AAE9D,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,iBAAiB,EAAA;QAC9B,SAAS;aACP,OAAO;;AAEN,YAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAC,kBAAkB,EAC5B,EAAE,EAAE,OAAO,EACX,OAAO,EAAE,uBAAuB,EAAA,EAE/B,KAAK,CACF,KAENA,cAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAA,EACnC,KAAK,CACA,CACT,CAAC;QACJA,cAAA,CAAA,aAAA,CAAC,eAAe,OACV,kBAAkB,EACtB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,EACb,QAAQ,EAAE,QAAQ,EAAA,IACb,OAAO,IAAI,EAAE,UAAU,EAAE,CAAC,EAAA,CAC/B;QACD,WAAW,IAAI,aAAa,KAC3BA,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,wBAAwB,EAAC,EAAE,EAAE,aAAa,EAAA;YACrDA,cAAA,CAAA,aAAA,CAAC,IAAI,yBAEH,SAAS,EAAC,qCAAqC,EAC/C,MAAM,EAAC,8BAA8B,EAAA,CACrC;AACD,YAAA,WAAW,CACV,CACL,CACG;AAEV,CAAC;AAGH,MAAM,CAAC,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOptions.d.ts","sourceRoot":"","sources":["../../../src/components/select/SelectOptions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectOptions.d.ts","sourceRoot":"","sources":["../../../src/components/select/SelectOptions.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,UAAU,CAAA;AAMjB,UAAU,kBAAkB;IAC1B,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AA2BD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,kBAA0B,GAC3B,EAAE,kBAAkB,GAAG,KAAK,CAAC,SAAS,CA8BtC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getDataAttributes } from '../../utilities/selectUtils.js';
|
|
1
2
|
import React__default from 'react';
|
|
2
3
|
|
|
3
4
|
function isGroup(item) {
|
|
@@ -9,7 +10,7 @@ function getOptionLabel(option) {
|
|
|
9
10
|
return option.textValue ?? option.value ?? "";
|
|
10
11
|
}
|
|
11
12
|
function Option({ option }) {
|
|
12
|
-
return (React__default.createElement("option", { disabled: option.disabled, value: option.value }, getOptionLabel(option)));
|
|
13
|
+
return (React__default.createElement("option", { ...getDataAttributes(option), disabled: option.disabled, value: option.value }, getOptionLabel(option)));
|
|
13
14
|
}
|
|
14
15
|
function SelectOptions({ items, supportsBaseSelect = false, }) {
|
|
15
16
|
return items.map((item, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOptions.js","sources":["../../../src/components/select/SelectOptions.tsx"],"sourcesContent":["import React from \"react\"\n\nimport type {\n SelectItem,\n SelectOptionsGroup,\n SelectOptionWithNodeLabel,\n SelectOptionWithTextLabel,\n} from \"./Select\"\n\ninterface OptionProps {\n option: SelectOptionWithNodeLabel | SelectOptionWithTextLabel\n}\n\ninterface SelectOptionsProps {\n items: SelectItem[]\n supportsBaseSelect?: boolean\n}\n\nfunction isGroup(item: SelectItem): item is SelectOptionsGroup {\n return \"options\" in item\n}\n\nfunction getOptionLabel(option: {\n label: React.ReactNode\n textValue?: string\n value?: string\n}): string {\n if (typeof option.label === \"string\") return option.label\n return option.textValue ?? option.value ?? \"\"\n}\n\nfunction Option({ option }: OptionProps) {\n return (\n <option
|
|
1
|
+
{"version":3,"file":"SelectOptions.js","sources":["../../../src/components/select/SelectOptions.tsx"],"sourcesContent":["import { getDataAttributes } from \"@utilities/selectUtils\"\nimport React from \"react\"\n\nimport type {\n SelectItem,\n SelectOptionsGroup,\n SelectOptionWithNodeLabel,\n SelectOptionWithTextLabel,\n} from \"./Select\"\n\ninterface OptionProps {\n option: SelectOptionWithNodeLabel | SelectOptionWithTextLabel\n}\n\ninterface SelectOptionsProps {\n items: SelectItem[]\n supportsBaseSelect?: boolean\n}\n\nfunction isGroup(item: SelectItem): item is SelectOptionsGroup {\n return \"options\" in item\n}\n\nfunction getOptionLabel(option: {\n label: React.ReactNode\n textValue?: string\n value?: string\n}): string {\n if (typeof option.label === \"string\") return option.label\n return option.textValue ?? option.value ?? \"\"\n}\n\nfunction Option({ option }: OptionProps) {\n return (\n <option\n {...getDataAttributes(option)}\n disabled={option.disabled}\n value={option.value}\n >\n {getOptionLabel(option)}\n </option>\n )\n}\n\nexport function SelectOptions({\n items,\n supportsBaseSelect = false,\n}: SelectOptionsProps): React.ReactNode {\n return items.map((item, index) => {\n if (isGroup(item)) {\n return (\n <optgroup\n key={`${item.label}-${index}`}\n disabled={item.disabled}\n label={item.label}\n >\n {supportsBaseSelect && (\n <legend>\n <span>{item.label}</span>\n </legend>\n )}\n {item.options.map((opt, optIndex) => {\n if (opt.divider) {\n return <hr key={`divider-${optIndex}`} />\n }\n return <Option key={opt.value ?? `opt-${optIndex}`} option={opt} />\n })}\n </optgroup>\n )\n }\n\n if (item.divider) {\n return <hr key={`divider-${index}`} />\n }\n\n return <Option key={item.value ?? `opt-${index}`} option={item} />\n })\n}\n"],"names":["React"],"mappings":";;;AAmBA,SAAS,OAAO,CAAC,IAAgB,EAAA;IAC/B,OAAO,SAAS,IAAI,IAAI;AAC1B;AAEA,SAAS,cAAc,CAAC,MAIvB,EAAA;AACC,IAAA,IAAI,OAAO,MAAM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AAE,MAAM,EAAE,GAAG,GAAI;gBACrE,CAAC,CAAC,CACO;QAEf;AAEA,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AAChB,YAAA,OAAOA,qCAAI,GAAG,EAAE,WAAW,KAAK,CAAA,CAAE,GAAI;QACxC;AAEA,QAAA,OAAOA,6BAAC,MAAM,EAAA,EAAC,GAAG,EAAE,IAAI,CAAC,KAAK,IAAI,CAAA,IAAA,EAAO,KAAK,CAAA,CAAE,EAAE,MAAM,EAAE,IAAI,GAAI;AACpE,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -12,6 +12,7 @@ export interface SelectPopoverProps {
|
|
|
12
12
|
options: SelectItem[];
|
|
13
13
|
placeholder: string;
|
|
14
14
|
required?: boolean;
|
|
15
|
+
triggerRef?: React.RefObject<HTMLButtonElement>;
|
|
15
16
|
value?: string;
|
|
16
17
|
}
|
|
17
18
|
export type SelectPopoverElementProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, keyof SelectPopoverProps | "multiple"> & SelectPopoverProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPopover.d.ts","sourceRoot":"","sources":["../../../src/components/select/SelectPopover.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectPopover.d.ts","sourceRoot":"","sources":["../../../src/components/select/SelectPopover.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAEZ,KAAK,oBAAoB,EAM1B,MAAM,OAAO,CAAA;AAEd,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,UAAU,CAAA;AAQxD,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0DAA0D;IAC1D,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAA;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,kBAAkB,GAAG,UAAU,CACtC,GACC,kBAAkB,CAAA;AAqDpB,eAAO,MAAM,aAAa,2LA2ZzB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getComboboxActionFromKey, ComboboxAction, getUpdatedIndex } from '../../utilities/keyboardUtils.js';
|
|
2
|
-
import { normalizeOptions, getSelectableOptionsFromSegments, getIndexByLetter } from '../../utilities/selectUtils.js';
|
|
2
|
+
import { normalizeOptions, getSelectableOptionsFromSegments, getIndexByLetter, getDataAttributes } from '../../utilities/selectUtils.js';
|
|
3
3
|
import { useId } from '../../utilities/useId.js';
|
|
4
4
|
import React__default, { forwardRef, useState, useMemo, useRef, useCallback, useEffect } from 'react';
|
|
5
5
|
import { SelectOptions } from './SelectOptions.js';
|
|
@@ -19,7 +19,7 @@ function renderListSegments(segments, baseId, renderItem) {
|
|
|
19
19
|
return (React__default.createElement("ul", { key: `options-${segmentIndex}`, role: "presentation" }, segment.options.map((opt, i) => renderItem(opt, startIndex + i))));
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
const SelectPopover = forwardRef(({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, defaultValue, disabled, id, invalid, onBlur, onChange, onClick, onFocus, options, placeholder, required, value, ...props }, ref) => {
|
|
22
|
+
const SelectPopover = forwardRef(({ "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, defaultValue, disabled, id, invalid, onBlur, onChange, onClick, onFocus, options, placeholder, required, triggerRef, value, ...props }, ref) => {
|
|
23
23
|
const stableId = useId();
|
|
24
24
|
const baseId = id || `tds-select-popover-${stableId}`;
|
|
25
25
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -38,7 +38,8 @@ const SelectPopover = forwardRef(({ "aria-describedby": ariaDescribedBy, "aria-l
|
|
|
38
38
|
? `${baseId}-option-${activeOption.value}`
|
|
39
39
|
: undefined;
|
|
40
40
|
const popoverRef = useRef(null);
|
|
41
|
-
const
|
|
41
|
+
const internalTriggerRef = useRef(null);
|
|
42
|
+
const resolvedTriggerRef = triggerRef ?? internalTriggerRef;
|
|
42
43
|
const hiddenSelectRef = useRef(null);
|
|
43
44
|
const pendingChangeValueRef = useRef(null);
|
|
44
45
|
const searchStringRef = useRef("");
|
|
@@ -87,7 +88,7 @@ const SelectPopover = forwardRef(({ "aria-describedby": ariaDescribedBy, "aria-l
|
|
|
87
88
|
useEffect(() => () => {
|
|
88
89
|
clearTimeout(searchTimeoutRef.current);
|
|
89
90
|
}, []);
|
|
90
|
-
const openPopover = () => popoverRef.current?.showPopover({ source:
|
|
91
|
+
const openPopover = () => popoverRef.current?.showPopover({ source: resolvedTriggerRef.current });
|
|
91
92
|
const closePopover = () => popoverRef.current?.hidePopover();
|
|
92
93
|
const commitSelection = useCallback((nextValue) => {
|
|
93
94
|
if (nextValue === selectedValue) {
|
|
@@ -215,17 +216,18 @@ const SelectPopover = forwardRef(({ "aria-describedby": ariaDescribedBy, "aria-l
|
|
|
215
216
|
const handleButtonFocus = useCallback((event) => {
|
|
216
217
|
forwardEventToSelect(event, onFocus);
|
|
217
218
|
}, [forwardEventToSelect, onFocus]);
|
|
218
|
-
const renderListOption = (
|
|
219
|
+
const renderListOption = (option, index) => {
|
|
220
|
+
const { disabled, divider, label, value } = option;
|
|
219
221
|
if (divider)
|
|
220
222
|
return React__default.createElement("li", { key: index, role: "separator" });
|
|
221
223
|
return (
|
|
222
224
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard events are handled on the combobox button
|
|
223
|
-
React__default.createElement("li", { key: value, "aria-disabled": disabled || undefined, "aria-selected": value === selectedValue, className: value === activeOption?.value
|
|
225
|
+
React__default.createElement("li", { key: value, ...getDataAttributes(option), "aria-disabled": disabled || undefined, "aria-selected": value === selectedValue, className: value === activeOption?.value
|
|
224
226
|
? "tds-select-option--active"
|
|
225
227
|
: undefined, id: `${baseId}-option-${value}`, onClick: disabled ? undefined : () => commitSelection(value), role: "option" }, label));
|
|
226
228
|
};
|
|
227
229
|
return (React__default.createElement(React__default.Fragment, null,
|
|
228
|
-
React__default.createElement("button", { ref:
|
|
230
|
+
React__default.createElement("button", { ref: resolvedTriggerRef, popovertarget: baseId, "aria-activedescendant": activeOptionId, "aria-controls": baseId, "aria-describedby": ariaDescribedBy, "aria-disabled": disabled ? "true" : undefined, "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-invalid": invalid ? "true" : undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-required": required ? "true" : undefined, disabled: disabled, onBlur: handleButtonBlur, onClick: handleButtonClick, onFocus: handleButtonFocus, onKeyDown: handleKeyDown, role: "combobox", type: "button" }, selectedOption ? selectedOption.label : placeholder),
|
|
229
231
|
React__default.createElement("div", { ref: popoverRef, popover: "", id: baseId, role: "listbox", "aria-describedby": ariaDescribedBy, "aria-invalid": invalid ? "true" : undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-required": required ? "true" : undefined }, renderListSegments(segments, baseId, renderListOption)),
|
|
230
232
|
React__default.createElement("select", { ...props, ref: setHiddenSelectRef, "aria-hidden": true, className: "tds-select-hidden-select", disabled: disabled, id: `${baseId}-control`, onChange: handleHiddenSelectChange, required: required, tabIndex: -1, value: selectedValue ?? "" },
|
|
231
233
|
React__default.createElement("option", { value: "" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPopover.js","sources":["../../../src/components/select/SelectPopover.tsx"],"sourcesContent":["import {\n ComboboxAction,\n getComboboxActionFromKey,\n getUpdatedIndex,\n} from \"@utilities/keyboardUtils\"\nimport {\n getIndexByLetter,\n getSelectableOptionsFromSegments,\n normalizeOptions,\n type Segment,\n} from \"@utilities/selectUtils\"\nimport { useId } from \"@utilities/useId\"\nimport React, {\n forwardRef,\n type SelectHTMLAttributes,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\n\nimport type { SelectItem, SelectOption } from \"./Select\"\nimport { SelectOptions } from \"./SelectOptions\"\n\ninterface ToggleEvent extends Event {\n newState: \"closed\" | \"open\"\n oldState: \"closed\" | \"open\"\n}\n\nexport interface SelectPopoverProps {\n \"aria-describedby\"?: string\n \"aria-label\"?: string\n \"aria-labelledby\"?: string\n defaultValue?: string\n disabled?: boolean\n id?: string\n invalid?: boolean\n /** A flat or mixed array of options and option groups. */\n options: SelectItem[]\n placeholder: string\n required?: boolean\n value?: string\n}\n\nexport type SelectPopoverElementProps = Omit<\n SelectHTMLAttributes<HTMLSelectElement>,\n keyof SelectPopoverProps | \"multiple\"\n> &\n SelectPopoverProps\n\nconst Group = ({\n children,\n disabled,\n id,\n label,\n}: {\n children: React.ReactNode\n disabled?: boolean\n id: string\n label: string\n}) => (\n <ul aria-disabled={disabled || undefined} aria-labelledby={id} role=\"group\">\n <li id={id} role=\"presentation\">\n <span>{label}</span>\n </li>\n {children}\n </ul>\n)\n\nfunction renderListSegments(\n segments: Segment[],\n baseId: string,\n renderItem: (option: SelectOption, index: number) => React.ReactNode\n) {\n let flatIndex = 0\n\n return segments.map((segment, segmentIndex) => {\n const startIndex = flatIndex\n flatIndex += segment.options.length\n\n if (segment.type === \"group\") {\n return (\n <Group\n key={`${segment.label}-${segmentIndex}`}\n disabled={segment.disabled}\n id={`${baseId}-group-${segmentIndex}`}\n label={segment.label}\n >\n {segment.options.map((opt, i) => renderItem(opt, startIndex + i))}\n </Group>\n )\n }\n\n return (\n <ul key={`options-${segmentIndex}`} role=\"presentation\">\n {segment.options.map((opt, i) => renderItem(opt, startIndex + i))}\n </ul>\n )\n })\n}\n\nexport const SelectPopover = forwardRef<\n HTMLSelectElement,\n SelectPopoverElementProps\n>(\n (\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n defaultValue,\n disabled,\n id,\n invalid,\n onBlur,\n onChange,\n onClick,\n onFocus,\n options,\n placeholder,\n required,\n value,\n ...props\n }: SelectPopoverElementProps,\n ref\n ) => {\n const stableId = useId()\n const baseId = id || `tds-select-popover-${stableId}`\n\n const [isOpen, setIsOpen] = useState(false)\n const [uncontrolledValue, setUncontrolledValue] = useState<string | null>(\n defaultValue ?? null\n )\n const [activeIndex, setActiveIndex] = useState(-1)\n\n const isControlled = value !== undefined\n const selectedValue = isControlled ? (value ?? null) : uncontrolledValue\n\n const { allOptions, segments } = useMemo(() => {\n const segments = normalizeOptions(options)\n const allOptions = getSelectableOptionsFromSegments(segments)\n return { allOptions, segments }\n }, [options])\n\n const selectedOption = allOptions.find((opt) => opt.value === selectedValue)\n\n const activeOption = activeIndex >= 0 ? allOptions[activeIndex] : undefined\n const activeOptionId = activeOption\n ? `${baseId}-option-${activeOption.value}`\n : undefined\n\n const popoverRef = useRef<HTMLDivElement>(null)\n const triggerButtonRef = useRef<HTMLButtonElement | null>(null)\n const hiddenSelectRef = useRef<HTMLSelectElement | null>(null)\n const pendingChangeValueRef = useRef<string | null>(null)\n const searchStringRef = useRef(\"\")\n const searchTimeoutRef = useRef<ReturnType<typeof setTimeout>>()\n\n const setHiddenSelectRef = useCallback(\n (element: HTMLSelectElement | null) => {\n hiddenSelectRef.current = element\n if (typeof ref === \"function\") {\n ref(element)\n } else if (ref) {\n ref.current = element\n }\n },\n [ref]\n )\n\n useEffect(() => {\n const popoverEl = popoverRef.current\n if (!popoverEl) return\n\n const handleToggle = (e: Event) => {\n const newIsOpen = (e as ToggleEvent).newState === \"open\"\n setIsOpen(newIsOpen)\n\n if (newIsOpen) {\n const index = allOptions.findIndex(\n (opt) => opt.value === selectedValue && !opt.disabled\n )\n if (index >= 0) {\n setActiveIndex(index)\n } else {\n // Find first non-disabled option\n const firstEnabledIndexOrFirstIndex = Math.max(\n allOptions.findIndex((opt) => !opt.disabled),\n 0\n )\n setActiveIndex(firstEnabledIndexOrFirstIndex)\n }\n } else {\n setActiveIndex(-1)\n }\n }\n\n popoverEl.addEventListener(\"toggle\", handleToggle)\n return () => popoverEl.removeEventListener(\"toggle\", handleToggle)\n }, [allOptions, selectedValue])\n\n useEffect(() => {\n if (activeOptionId) {\n document\n .getElementById(activeOptionId)\n ?.scrollIntoView({ block: \"nearest\" })\n }\n }, [activeOptionId])\n\n useEffect(\n () => () => {\n clearTimeout(searchTimeoutRef.current)\n },\n []\n )\n\n const openPopover = () =>\n popoverRef.current?.showPopover({ source: triggerButtonRef.current! })\n\n const closePopover = () => popoverRef.current?.hidePopover()\n\n const commitSelection = useCallback(\n (nextValue: string) => {\n if (nextValue === selectedValue) {\n closePopover()\n return\n }\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n const hiddenEl = hiddenSelectRef.current\n if (hiddenEl) {\n pendingChangeValueRef.current = nextValue\n hiddenEl.value = nextValue\n hiddenEl.dispatchEvent(new Event(\"change\", { bubbles: true }))\n if (isControlled) {\n hiddenEl.value = value ?? \"\"\n }\n }\n\n closePopover()\n },\n [isControlled, selectedValue, value]\n )\n\n const selectActiveOption = useCallback(() => {\n if (activeOption && !activeOption.disabled) {\n commitSelection(activeOption.value!)\n return true\n }\n return false\n }, [activeOption, commitSelection])\n\n const commitActiveOptionOrClose = useCallback(() => {\n if (!selectActiveOption()) {\n closePopover()\n }\n }, [selectActiveOption])\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n\n // Tab must not be prevented — allow native focus movement\n if (e.key === \"Tab\" && isOpen) {\n commitActiveOptionOrClose()\n return\n }\n\n const action = getComboboxActionFromKey(e, isOpen)\n if (!action) return\n\n e.preventDefault()\n\n switch (action) {\n case ComboboxAction.OpenPopup:\n openPopover()\n break\n case ComboboxAction.CommitAndClose:\n commitActiveOptionOrClose()\n break\n case ComboboxAction.MoveFirst:\n case ComboboxAction.MoveLast:\n if (!isOpen) openPopover()\n setActiveIndex(getUpdatedIndex(activeIndex, action, allOptions))\n break\n case ComboboxAction.MoveNext:\n case ComboboxAction.MovePrevious:\n setActiveIndex(getUpdatedIndex(activeIndex, action, allOptions))\n break\n case ComboboxAction.TypeCharacter: {\n if (!isOpen) openPopover()\n\n clearTimeout(searchTimeoutRef.current)\n searchStringRef.current += e.key\n searchTimeoutRef.current = setTimeout(() => {\n searchStringRef.current = \"\"\n }, 500)\n\n const searchIndex = getIndexByLetter(\n allOptions,\n searchStringRef.current,\n activeIndex\n )\n if (searchIndex >= 0) {\n setActiveIndex(searchIndex)\n }\n break\n }\n case ComboboxAction.ClosePopup:\n closePopover()\n break\n }\n }\n\n const createStableEventTarget = (\n target: HTMLSelectElement,\n valueSnapshot: string\n ) => {\n const proxy = Object.create(target)\n Object.defineProperties(proxy, {\n disabled: {\n configurable: true,\n enumerable: true,\n value: target.disabled,\n },\n form: { configurable: true, enumerable: true, value: target.form },\n name: { configurable: true, enumerable: true, value: target.name },\n type: { configurable: true, enumerable: true, value: target.type },\n value: { configurable: true, enumerable: true, value: valueSnapshot },\n })\n return proxy as HTMLSelectElement\n }\n\n const withSelectTarget = useCallback(\n <\n SourceEvent extends React.SyntheticEvent,\n TargetEvent extends React.SyntheticEvent<HTMLSelectElement>,\n >(\n event: SourceEvent,\n target: HTMLSelectElement,\n currentTarget: HTMLSelectElement = target\n ) => {\n return Object.defineProperties(Object.create(event), {\n currentTarget: { value: currentTarget },\n target: { value: target },\n }) as TargetEvent\n },\n []\n )\n\n const handleHiddenSelectChange = useCallback(\n (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!onChange) return\n\n const valueSnapshot =\n pendingChangeValueRef.current ?? event.currentTarget.value\n pendingChangeValueRef.current = null\n\n const stableEvent = withSelectTarget<\n React.ChangeEvent<HTMLSelectElement>,\n React.ChangeEvent<HTMLSelectElement>\n >(\n event,\n createStableEventTarget(\n event.target as HTMLSelectElement,\n valueSnapshot\n ),\n createStableEventTarget(event.currentTarget, valueSnapshot)\n )\n\n onChange(stableEvent)\n },\n [onChange, withSelectTarget]\n )\n\n const forwardEventToSelect = useCallback(\n <\n ButtonEvent extends React.SyntheticEvent<HTMLButtonElement>,\n SelectEvent extends React.SyntheticEvent<HTMLSelectElement>,\n >(\n event: ButtonEvent,\n handler?: (event: SelectEvent) => void\n ) => {\n if (!handler) return\n\n const hiddenEl = hiddenSelectRef.current\n if (!hiddenEl) return\n\n const stableEvent = withSelectTarget<ButtonEvent, SelectEvent>(\n event,\n hiddenEl\n )\n\n handler(stableEvent)\n },\n [withSelectTarget]\n )\n\n const handleButtonBlur = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.FocusEvent<HTMLButtonElement>,\n React.FocusEvent<HTMLSelectElement>\n >(event, onBlur)\n },\n [forwardEventToSelect, onBlur]\n )\n\n const handleButtonClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.MouseEvent<HTMLButtonElement>,\n React.MouseEvent<HTMLSelectElement>\n >(event, onClick)\n },\n [forwardEventToSelect, onClick]\n )\n\n const handleButtonFocus = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.FocusEvent<HTMLButtonElement>,\n React.FocusEvent<HTMLSelectElement>\n >(event, onFocus)\n },\n [forwardEventToSelect, onFocus]\n )\n\n const renderListOption = (\n { disabled, divider, label, value }: SelectOption,\n index: number\n ) => {\n if (divider) return <li key={index} role=\"separator\" />\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard events are handled on the combobox button\n <li\n key={value}\n aria-disabled={disabled || undefined}\n aria-selected={value === selectedValue}\n className={\n value === activeOption?.value\n ? \"tds-select-option--active\"\n : undefined\n }\n id={`${baseId}-option-${value}`}\n onClick={disabled ? undefined : () => commitSelection(value!)}\n role=\"option\"\n >\n {label}\n </li>\n )\n }\n\n return (\n <>\n <button\n ref={triggerButtonRef}\n popovertarget={baseId}\n aria-activedescendant={activeOptionId}\n aria-controls={baseId}\n aria-describedby={ariaDescribedBy}\n aria-disabled={disabled ? \"true\" : undefined}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n aria-invalid={invalid ? \"true\" : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-required={required ? \"true\" : undefined}\n disabled={disabled}\n onBlur={handleButtonBlur}\n onClick={handleButtonClick}\n onFocus={handleButtonFocus}\n onKeyDown={handleKeyDown}\n role=\"combobox\"\n type=\"button\"\n >\n {selectedOption ? selectedOption.label : placeholder}\n </button>\n <div\n ref={popoverRef}\n popover=\"\"\n id={baseId}\n role=\"listbox\"\n aria-describedby={ariaDescribedBy}\n aria-invalid={invalid ? \"true\" : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-required={required ? \"true\" : undefined}\n >\n {renderListSegments(segments, baseId, renderListOption)}\n </div>\n <select\n {...props}\n ref={setHiddenSelectRef}\n aria-hidden\n className=\"tds-select-hidden-select\"\n disabled={disabled}\n id={`${baseId}-control`}\n onChange={handleHiddenSelectChange}\n required={required}\n tabIndex={-1}\n value={selectedValue ?? \"\"}\n >\n <option value=\"\" />\n <SelectOptions items={options} />\n </select>\n </>\n )\n }\n)\n\nSelectPopover.displayName = \"SelectPopover\"\n"],"names":["React"],"mappings":";;;;;;AAmDA,MAAM,KAAK,GAAG,CAAC,EACb,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,KAAK,GAMN,MACCA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,eAAA,EAAmB,QAAQ,IAAI,SAAS,EA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AAW,CAC7C;QACTA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,GAAG,EAAE,UAAU,EACf,OAAO,EAAC,EAAE,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAC,SAAS,EAAA,kBAAA,EACI,eAAe,EAAA,cAAA,EACnB,OAAO,GAAG,MAAM,GAAG,SAAS,EAAA,YAAA,EAC9B,SAAS,EAAA,iBAAA,EACJ,cAAc,mBAChB,QAAQ,GAAG,MAAM,GAAG,SAAS,EAAA,EAE3C,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,CAAC,CACnD;AACN,QAAAA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,GACM,KAAK,EACT,GAAG,EAAE,kBAAkB,uBAEvB,SAAS,EAAC,0BAA0B,EACpC,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,CAAA,EAAG,MAAM,CAAA,QAAA,CAAU,EACvB,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,EAAE,EACZ,KAAK,EAAE,aAAa,IAAI,EAAE,EAAA;YAE1BA,cAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAQ,KAAK,EAAC,EAAE,EAAA,CAAG;YACnBA,cAAA,CAAA,aAAA,CAAC,aAAa,IAAC,KAAK,EAAE,OAAO,EAAA,CAAI,CAC1B,CACR;AAEP,CAAC;AAGH,aAAa,CAAC,WAAW,GAAG,eAAe;;;;"}
|
|
1
|
+
{"version":3,"file":"SelectPopover.js","sources":["../../../src/components/select/SelectPopover.tsx"],"sourcesContent":["import {\n ComboboxAction,\n getComboboxActionFromKey,\n getUpdatedIndex,\n} from \"@utilities/keyboardUtils\"\nimport {\n getDataAttributes,\n getIndexByLetter,\n getSelectableOptionsFromSegments,\n normalizeOptions,\n type Segment,\n} from \"@utilities/selectUtils\"\nimport { useId } from \"@utilities/useId\"\nimport React, {\n forwardRef,\n type SelectHTMLAttributes,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\n\nimport type { SelectItem, SelectOption } from \"./Select\"\nimport { SelectOptions } from \"./SelectOptions\"\n\ninterface ToggleEvent extends Event {\n newState: \"closed\" | \"open\"\n oldState: \"closed\" | \"open\"\n}\n\nexport interface SelectPopoverProps {\n \"aria-describedby\"?: string\n \"aria-label\"?: string\n \"aria-labelledby\"?: string\n defaultValue?: string\n disabled?: boolean\n id?: string\n invalid?: boolean\n /** A flat or mixed array of options and option groups. */\n options: SelectItem[]\n placeholder: string\n required?: boolean\n triggerRef?: React.RefObject<HTMLButtonElement>\n value?: string\n}\n\nexport type SelectPopoverElementProps = Omit<\n SelectHTMLAttributes<HTMLSelectElement>,\n keyof SelectPopoverProps | \"multiple\"\n> &\n SelectPopoverProps\n\nconst Group = ({\n children,\n disabled,\n id,\n label,\n}: {\n children: React.ReactNode\n disabled?: boolean\n id: string\n label: string\n}) => (\n <ul aria-disabled={disabled || undefined} aria-labelledby={id} role=\"group\">\n <li id={id} role=\"presentation\">\n <span>{label}</span>\n </li>\n {children}\n </ul>\n)\n\nfunction renderListSegments(\n segments: Segment[],\n baseId: string,\n renderItem: (option: SelectOption, index: number) => React.ReactNode\n) {\n let flatIndex = 0\n\n return segments.map((segment, segmentIndex) => {\n const startIndex = flatIndex\n flatIndex += segment.options.length\n\n if (segment.type === \"group\") {\n return (\n <Group\n key={`${segment.label}-${segmentIndex}`}\n disabled={segment.disabled}\n id={`${baseId}-group-${segmentIndex}`}\n label={segment.label}\n >\n {segment.options.map((opt, i) => renderItem(opt, startIndex + i))}\n </Group>\n )\n }\n\n return (\n <ul key={`options-${segmentIndex}`} role=\"presentation\">\n {segment.options.map((opt, i) => renderItem(opt, startIndex + i))}\n </ul>\n )\n })\n}\n\nexport const SelectPopover = forwardRef<\n HTMLSelectElement,\n SelectPopoverElementProps\n>(\n (\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n defaultValue,\n disabled,\n id,\n invalid,\n onBlur,\n onChange,\n onClick,\n onFocus,\n options,\n placeholder,\n required,\n triggerRef,\n value,\n ...props\n }: SelectPopoverElementProps,\n ref\n ) => {\n const stableId = useId()\n const baseId = id || `tds-select-popover-${stableId}`\n\n const [isOpen, setIsOpen] = useState(false)\n const [uncontrolledValue, setUncontrolledValue] = useState<string | null>(\n defaultValue ?? null\n )\n const [activeIndex, setActiveIndex] = useState(-1)\n\n const isControlled = value !== undefined\n const selectedValue = isControlled ? (value ?? null) : uncontrolledValue\n\n const { allOptions, segments } = useMemo(() => {\n const segments = normalizeOptions(options)\n const allOptions = getSelectableOptionsFromSegments(segments)\n return { allOptions, segments }\n }, [options])\n\n const selectedOption = allOptions.find((opt) => opt.value === selectedValue)\n\n const activeOption = activeIndex >= 0 ? allOptions[activeIndex] : undefined\n const activeOptionId = activeOption\n ? `${baseId}-option-${activeOption.value}`\n : undefined\n\n const popoverRef = useRef<HTMLDivElement>(null)\n const internalTriggerRef = useRef<HTMLButtonElement | null>(null)\n const resolvedTriggerRef = triggerRef ?? internalTriggerRef\n const hiddenSelectRef = useRef<HTMLSelectElement | null>(null)\n const pendingChangeValueRef = useRef<string | null>(null)\n const searchStringRef = useRef(\"\")\n const searchTimeoutRef = useRef<ReturnType<typeof setTimeout>>()\n\n const setHiddenSelectRef = useCallback(\n (element: HTMLSelectElement | null) => {\n hiddenSelectRef.current = element\n if (typeof ref === \"function\") {\n ref(element)\n } else if (ref) {\n ref.current = element\n }\n },\n [ref]\n )\n\n useEffect(() => {\n const popoverEl = popoverRef.current\n if (!popoverEl) return\n\n const handleToggle = (e: Event) => {\n const newIsOpen = (e as ToggleEvent).newState === \"open\"\n setIsOpen(newIsOpen)\n\n if (newIsOpen) {\n const index = allOptions.findIndex(\n (opt) => opt.value === selectedValue && !opt.disabled\n )\n if (index >= 0) {\n setActiveIndex(index)\n } else {\n // Find first non-disabled option\n const firstEnabledIndexOrFirstIndex = Math.max(\n allOptions.findIndex((opt) => !opt.disabled),\n 0\n )\n setActiveIndex(firstEnabledIndexOrFirstIndex)\n }\n } else {\n setActiveIndex(-1)\n }\n }\n\n popoverEl.addEventListener(\"toggle\", handleToggle)\n return () => popoverEl.removeEventListener(\"toggle\", handleToggle)\n }, [allOptions, selectedValue])\n\n useEffect(() => {\n if (activeOptionId) {\n document\n .getElementById(activeOptionId)\n ?.scrollIntoView({ block: \"nearest\" })\n }\n }, [activeOptionId])\n\n useEffect(\n () => () => {\n clearTimeout(searchTimeoutRef.current)\n },\n []\n )\n\n const openPopover = () =>\n popoverRef.current?.showPopover({ source: resolvedTriggerRef.current! })\n\n const closePopover = () => popoverRef.current?.hidePopover()\n\n const commitSelection = useCallback(\n (nextValue: string) => {\n if (nextValue === selectedValue) {\n closePopover()\n return\n }\n\n if (!isControlled) {\n setUncontrolledValue(nextValue)\n }\n\n const hiddenEl = hiddenSelectRef.current\n if (hiddenEl) {\n pendingChangeValueRef.current = nextValue\n hiddenEl.value = nextValue\n hiddenEl.dispatchEvent(new Event(\"change\", { bubbles: true }))\n if (isControlled) {\n hiddenEl.value = value ?? \"\"\n }\n }\n\n closePopover()\n },\n [isControlled, selectedValue, value]\n )\n\n const selectActiveOption = useCallback(() => {\n if (activeOption && !activeOption.disabled) {\n commitSelection(activeOption.value!)\n return true\n }\n return false\n }, [activeOption, commitSelection])\n\n const commitActiveOptionOrClose = useCallback(() => {\n if (!selectActiveOption()) {\n closePopover()\n }\n }, [selectActiveOption])\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n\n // Tab must not be prevented — allow native focus movement\n if (e.key === \"Tab\" && isOpen) {\n commitActiveOptionOrClose()\n return\n }\n\n const action = getComboboxActionFromKey(e, isOpen)\n if (!action) return\n\n e.preventDefault()\n\n switch (action) {\n case ComboboxAction.OpenPopup:\n openPopover()\n break\n case ComboboxAction.CommitAndClose:\n commitActiveOptionOrClose()\n break\n case ComboboxAction.MoveFirst:\n case ComboboxAction.MoveLast:\n if (!isOpen) openPopover()\n setActiveIndex(getUpdatedIndex(activeIndex, action, allOptions))\n break\n case ComboboxAction.MoveNext:\n case ComboboxAction.MovePrevious:\n setActiveIndex(getUpdatedIndex(activeIndex, action, allOptions))\n break\n case ComboboxAction.TypeCharacter: {\n if (!isOpen) openPopover()\n\n clearTimeout(searchTimeoutRef.current)\n searchStringRef.current += e.key\n searchTimeoutRef.current = setTimeout(() => {\n searchStringRef.current = \"\"\n }, 500)\n\n const searchIndex = getIndexByLetter(\n allOptions,\n searchStringRef.current,\n activeIndex\n )\n if (searchIndex >= 0) {\n setActiveIndex(searchIndex)\n }\n break\n }\n case ComboboxAction.ClosePopup:\n closePopover()\n break\n }\n }\n\n const createStableEventTarget = (\n target: HTMLSelectElement,\n valueSnapshot: string\n ) => {\n const proxy = Object.create(target)\n Object.defineProperties(proxy, {\n disabled: {\n configurable: true,\n enumerable: true,\n value: target.disabled,\n },\n form: { configurable: true, enumerable: true, value: target.form },\n name: { configurable: true, enumerable: true, value: target.name },\n type: { configurable: true, enumerable: true, value: target.type },\n value: { configurable: true, enumerable: true, value: valueSnapshot },\n })\n return proxy as HTMLSelectElement\n }\n\n const withSelectTarget = useCallback(\n <\n SourceEvent extends React.SyntheticEvent,\n TargetEvent extends React.SyntheticEvent<HTMLSelectElement>,\n >(\n event: SourceEvent,\n target: HTMLSelectElement,\n currentTarget: HTMLSelectElement = target\n ) => {\n return Object.defineProperties(Object.create(event), {\n currentTarget: { value: currentTarget },\n target: { value: target },\n }) as TargetEvent\n },\n []\n )\n\n const handleHiddenSelectChange = useCallback(\n (event: React.ChangeEvent<HTMLSelectElement>) => {\n if (!onChange) return\n\n const valueSnapshot =\n pendingChangeValueRef.current ?? event.currentTarget.value\n pendingChangeValueRef.current = null\n\n const stableEvent = withSelectTarget<\n React.ChangeEvent<HTMLSelectElement>,\n React.ChangeEvent<HTMLSelectElement>\n >(\n event,\n createStableEventTarget(\n event.target as HTMLSelectElement,\n valueSnapshot\n ),\n createStableEventTarget(event.currentTarget, valueSnapshot)\n )\n\n onChange(stableEvent)\n },\n [onChange, withSelectTarget]\n )\n\n const forwardEventToSelect = useCallback(\n <\n ButtonEvent extends React.SyntheticEvent<HTMLButtonElement>,\n SelectEvent extends React.SyntheticEvent<HTMLSelectElement>,\n >(\n event: ButtonEvent,\n handler?: (event: SelectEvent) => void\n ) => {\n if (!handler) return\n\n const hiddenEl = hiddenSelectRef.current\n if (!hiddenEl) return\n\n const stableEvent = withSelectTarget<ButtonEvent, SelectEvent>(\n event,\n hiddenEl\n )\n\n handler(stableEvent)\n },\n [withSelectTarget]\n )\n\n const handleButtonBlur = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.FocusEvent<HTMLButtonElement>,\n React.FocusEvent<HTMLSelectElement>\n >(event, onBlur)\n },\n [forwardEventToSelect, onBlur]\n )\n\n const handleButtonClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.MouseEvent<HTMLButtonElement>,\n React.MouseEvent<HTMLSelectElement>\n >(event, onClick)\n },\n [forwardEventToSelect, onClick]\n )\n\n const handleButtonFocus = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n forwardEventToSelect<\n React.FocusEvent<HTMLButtonElement>,\n React.FocusEvent<HTMLSelectElement>\n >(event, onFocus)\n },\n [forwardEventToSelect, onFocus]\n )\n\n const renderListOption = (option: SelectOption, index: number) => {\n const { disabled, divider, label, value } = option\n if (divider) return <li key={index} role=\"separator\" />\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard events are handled on the combobox button\n <li\n key={value}\n {...getDataAttributes(option)}\n aria-disabled={disabled || undefined}\n aria-selected={value === selectedValue}\n className={\n value === activeOption?.value\n ? \"tds-select-option--active\"\n : undefined\n }\n id={`${baseId}-option-${value}`}\n onClick={disabled ? undefined : () => commitSelection(value!)}\n role=\"option\"\n >\n {label}\n </li>\n )\n }\n\n return (\n <>\n <button\n ref={resolvedTriggerRef}\n popovertarget={baseId}\n aria-activedescendant={activeOptionId}\n aria-controls={baseId}\n aria-describedby={ariaDescribedBy}\n aria-disabled={disabled ? \"true\" : undefined}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n aria-invalid={invalid ? \"true\" : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-required={required ? \"true\" : undefined}\n disabled={disabled}\n onBlur={handleButtonBlur}\n onClick={handleButtonClick}\n onFocus={handleButtonFocus}\n onKeyDown={handleKeyDown}\n role=\"combobox\"\n type=\"button\"\n >\n {selectedOption ? selectedOption.label : placeholder}\n </button>\n <div\n ref={popoverRef}\n popover=\"\"\n id={baseId}\n role=\"listbox\"\n aria-describedby={ariaDescribedBy}\n aria-invalid={invalid ? \"true\" : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-required={required ? \"true\" : undefined}\n >\n {renderListSegments(segments, baseId, renderListOption)}\n </div>\n <select\n {...props}\n ref={setHiddenSelectRef}\n aria-hidden\n className=\"tds-select-hidden-select\"\n disabled={disabled}\n id={`${baseId}-control`}\n onChange={handleHiddenSelectChange}\n required={required}\n tabIndex={-1}\n value={selectedValue ?? \"\"}\n >\n <option value=\"\" />\n <SelectOptions items={options} />\n </select>\n </>\n )\n }\n)\n\nSelectPopover.displayName = \"SelectPopover\"\n"],"names":["React"],"mappings":";;;;;;AAqDA,MAAM,KAAK,GAAG,CAAC,EACb,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,KAAK,GAMN,MACCA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,eAAA,EAAmB,QAAQ,IAAI,SAAS,EAAA,iBAAA,EAAmB,EAAE,EAAE,IAAI,EAAC,OAAO,EAAA;AACzE,IAAAA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAC,cAAc,EAAA;QAC7BA,cAAA,CAAA,aAAA,CAAA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