@jimka/typescript-ui 0.6.0 → 0.7.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/lib/{AbstractInput-sRNPzWel.js → AbstractInput-W2PLJV5_.js} +2 -2
- package/dist/lib/{AbstractInput-sRNPzWel.js.map → AbstractInput-W2PLJV5_.js.map} +1 -1
- package/dist/lib/{Anchor-CwRhdP2J.js → Anchor-iZhsvMlT.js} +2 -2
- package/dist/lib/{Anchor-CwRhdP2J.js.map → Anchor-iZhsvMlT.js.map} +1 -1
- package/dist/lib/AnimatedDropdown-D0RhVgv3.js +2 -0
- package/dist/lib/AnimatedDropdown-D0RhVgv3.js.map +1 -0
- package/dist/lib/Border-6GsTNV-2.js +2 -0
- package/dist/lib/Border-6GsTNV-2.js.map +1 -0
- package/dist/lib/Button-CnFAiQuV.js +2 -0
- package/dist/lib/Button-CnFAiQuV.js.map +1 -0
- package/dist/lib/{Card-QYo27r5b.js → Card-C20k2YHU.js} +2 -2
- package/dist/lib/{Card-QYo27r5b.js.map → Card-C20k2YHU.js.map} +1 -1
- package/dist/lib/Checkbox-CM1z8keM.js +2 -0
- package/dist/lib/Checkbox-CM1z8keM.js.map +1 -0
- package/dist/lib/{CheckboxMenuRow-CesLhSnp.js → CheckboxMenuRow-C1h4LPHR.js} +2 -2
- package/dist/lib/{CheckboxMenuRow-CesLhSnp.js.map → CheckboxMenuRow-C1h4LPHR.js.map} +1 -1
- package/dist/lib/{CodeEditor-N1FQodcF.js → CodeEditor-CTL2WjF8.js} +2 -2
- package/dist/lib/{CodeEditor-N1FQodcF.js.map → CodeEditor-CTL2WjF8.js.map} +1 -1
- package/dist/lib/ComboBox-PZ5YPL0X.js +2 -0
- package/dist/lib/ComboBox-PZ5YPL0X.js.map +1 -0
- package/dist/lib/Component-D99-15Zt.js +2 -0
- package/dist/lib/Component-D99-15Zt.js.map +1 -0
- package/dist/lib/Container-FWRjgF6T.js +2 -0
- package/dist/lib/{Container-abY5Ww3W.js.map → Container-FWRjgF6T.js.map} +1 -1
- package/dist/lib/DOM-Cjh7_7TF.js +2 -0
- package/dist/lib/DOM-Cjh7_7TF.js.map +1 -0
- package/dist/lib/Dialog-DN78RaVH.js +2 -0
- package/dist/lib/Dialog-DN78RaVH.js.map +1 -0
- package/dist/lib/{FieldDecorator-BlYMfZ9L.js → FieldDecorator-DyPX8CFh.js} +2 -2
- package/dist/lib/{FieldDecorator-BlYMfZ9L.js.map → FieldDecorator-DyPX8CFh.js.map} +1 -1
- package/dist/lib/{Fit-BhlB-HAo.js → Fit-CaPMj7Up.js} +2 -2
- package/dist/lib/{Fit-BhlB-HAo.js.map → Fit-CaPMj7Up.js.map} +1 -1
- package/dist/lib/{FloatingPanel-DkJXsZ2D.js → FloatingPanel-Dsy_vJxi.js} +2 -2
- package/dist/lib/{FloatingPanel-DkJXsZ2D.js.map → FloatingPanel-Dsy_vJxi.js.map} +1 -1
- package/dist/lib/Glyph-DiEpD3gy.js +2 -0
- package/dist/lib/Glyph-DiEpD3gy.js.map +1 -0
- package/dist/lib/{Grid-Daiz7F5d.js → Grid-ft_UUpj8.js} +2 -2
- package/dist/lib/{Grid-Daiz7F5d.js.map → Grid-ft_UUpj8.js.map} +1 -1
- package/dist/lib/{GridConstraints-C58LuTqM.js → GridConstraints-CvZ0Nzaw.js} +2 -2
- package/dist/lib/{GridConstraints-C58LuTqM.js.map → GridConstraints-CvZ0Nzaw.js.map} +1 -1
- package/dist/lib/{Header-Dql3Zxc6.js → Header-Osm3IjDw.js} +2 -2
- package/dist/lib/{Header-Dql3Zxc6.js.map → Header-Osm3IjDw.js.map} +1 -1
- package/dist/lib/{IconText-PUjhTLlp.js → IconText-BBaYJ2Fx.js} +2 -2
- package/dist/lib/{IconText-PUjhTLlp.js.map → IconText-BBaYJ2Fx.js.map} +1 -1
- package/dist/lib/{LayoutSerialization-CMxunLfV.js → LayoutSerialization-BC64__O7.js} +2 -2
- package/dist/lib/{LayoutSerialization-CMxunLfV.js.map → LayoutSerialization-BC64__O7.js.map} +1 -1
- package/dist/lib/List-CQbZK_pT.js +2 -0
- package/dist/lib/List-CQbZK_pT.js.map +1 -0
- package/dist/lib/{Menu-Q0bpXXze.js → Menu-CwHluLGT.js} +2 -2
- package/dist/lib/{Menu-Q0bpXXze.js.map → Menu-CwHluLGT.js.map} +1 -1
- package/dist/lib/{MenuButton-DCXi0tsP.js → MenuButton-BqCT-1yv.js} +2 -2
- package/dist/lib/{MenuButton-DCXi0tsP.js.map → MenuButton-BqCT-1yv.js.map} +1 -1
- package/dist/lib/{OverlayFade-3pof2AJH.js → OverlayFade-CuEXgimf.js} +2 -2
- package/dist/lib/{OverlayFade-3pof2AJH.js.map → OverlayFade-CuEXgimf.js.map} +1 -1
- package/dist/lib/{Panel-Cy1pdlWO.js → Panel-CtViePqY.js} +2 -2
- package/dist/lib/{Panel-Cy1pdlWO.js.map → Panel-CtViePqY.js.map} +1 -1
- package/dist/lib/{Position-BwtxouxK.js → Position-BIEU1Eze.js} +2 -2
- package/dist/lib/Position-BIEU1Eze.js.map +1 -0
- package/dist/lib/{ProgressSpinner-DK8xEQ9y.js → ProgressSpinner-BuBvC1FY.js} +2 -2
- package/dist/lib/{ProgressSpinner-DK8xEQ9y.js.map → ProgressSpinner-BuBvC1FY.js.map} +1 -1
- package/dist/lib/RadioButton-Df5J-H6m.js +2 -0
- package/dist/lib/RadioButton-Df5J-H6m.js.map +1 -0
- package/dist/lib/RadioMenuRow-Cfv0x6Qj.js +2 -0
- package/dist/lib/RadioMenuRow-Cfv0x6Qj.js.map +1 -0
- package/dist/lib/{RovingTabIndex-pHEv5oLD.js → RovingTabIndex--w28AnXc.js} +2 -2
- package/dist/lib/{RovingTabIndex-pHEv5oLD.js.map → RovingTabIndex--w28AnXc.js.map} +1 -1
- package/dist/lib/Scrollbar-DcnueNJd.js +2 -0
- package/dist/lib/Scrollbar-DcnueNJd.js.map +1 -0
- package/dist/lib/SelectableText-DZNxjKXR.js +2 -0
- package/dist/lib/SelectableText-DZNxjKXR.js.map +1 -0
- package/dist/lib/{Slider-CTbwR6HR.js → Slider-DNfd8Lxz.js} +2 -2
- package/dist/lib/{Slider-CTbwR6HR.js.map → Slider-DNfd8Lxz.js.map} +1 -1
- package/dist/lib/{Spacer-srdN2d2b.js → Spacer-BznfGbwG.js} +2 -2
- package/dist/lib/{Spacer-srdN2d2b.js.map → Spacer-BznfGbwG.js.map} +1 -1
- package/dist/lib/TabButton-CAACsMov.js +2 -0
- package/dist/lib/TabButton-CAACsMov.js.map +1 -0
- package/dist/lib/{TabCloseButton-CY7BGitY.js → TabCloseButton-CCiqsX3y.js} +2 -2
- package/dist/lib/{TabCloseButton-CY7BGitY.js.map → TabCloseButton-CCiqsX3y.js.map} +1 -1
- package/dist/lib/Text-O-FWa5Cy.js +2 -0
- package/dist/lib/Text-O-FWa5Cy.js.map +1 -0
- package/dist/lib/{Tooltip-CUOJOqQi.js → Tooltip-CyICVu15.js} +2 -2
- package/dist/lib/Tooltip-CyICVu15.js.map +1 -0
- package/dist/lib/{Tree-C64JNPWJ.js → Tree-CSEguhlk.js} +2 -2
- package/dist/lib/{Tree-C64JNPWJ.js.map → Tree-CSEguhlk.js.map} +1 -1
- package/dist/lib/{VBox-DfJPWXqc.js → VBox-DVe4UXwX.js} +2 -2
- package/dist/lib/{VBox-DfJPWXqc.js.map → VBox-DVe4UXwX.js.map} +1 -1
- package/dist/lib/{VirtualScroller-DTIn19o1.js → VirtualScroller-ggPTCQb0.js} +2 -2
- package/dist/lib/{VirtualScroller-DTIn19o1.js.map → VirtualScroller-ggPTCQb0.js.map} +1 -1
- package/dist/lib/component/button.es.js +1 -1
- package/dist/lib/component/chart.es.js +1 -1
- package/dist/lib/component/chart.es.js.map +1 -1
- package/dist/lib/component/container.es.js +1 -1
- package/dist/lib/component/diagram.es.js +1 -1
- package/dist/lib/component/display.es.js +1 -1
- package/dist/lib/component/display.es.js.map +1 -1
- package/dist/lib/component/editor.es.js +2 -2
- package/dist/lib/component/editor.es.js.map +1 -1
- package/dist/lib/component/input.es.js +1 -1
- package/dist/lib/component/input.es.js.map +1 -1
- package/dist/lib/component/list.es.js +1 -1
- package/dist/lib/component/menubar.es.js +1 -1
- package/dist/lib/component/table.es.js +6 -6
- package/dist/lib/component/table.es.js.map +1 -1
- package/dist/lib/component/tree.es.js +1 -1
- package/dist/lib/core.es.js +1 -1
- package/dist/lib/core.es.js.map +1 -1
- package/dist/lib/glyphs/solid/index.es.js +1 -1
- package/dist/lib/layout.es.js +1 -1
- package/dist/lib/overlay.es.js +1 -1
- package/dist/lib/overlay.es.js.map +1 -1
- package/dist/lib/primitive.es.js +1 -1
- package/dist/lib/router.es.js +1 -1
- package/dist/lib/{selectionsEqual-gMG7gCVI.js → selectionsEqual-C7MrKMQr.js} +2 -2
- package/dist/lib/{selectionsEqual-gMG7gCVI.js.map → selectionsEqual-C7MrKMQr.js.map} +1 -1
- package/dist/lib/types/component/button/Button.d.ts +9 -0
- package/dist/lib/types/component/button/TabButton.d.ts +5 -0
- package/dist/lib/types/component/button/ToggleButton.d.ts +3 -0
- package/dist/lib/types/component/chart/AbstractChart.d.ts +2 -0
- package/dist/lib/types/component/display/Markdown.d.ts +2 -1
- package/dist/lib/types/component/input/AbstractCalendarDropdown.d.ts +2 -0
- package/dist/lib/types/component/input/AbstractPickerField.d.ts +2 -0
- package/dist/lib/types/component/input/AutoCompleteDropdown.d.ts +2 -0
- package/dist/lib/types/component/input/ComboBox.d.ts +3 -1
- package/dist/lib/types/component/input/Link.d.ts +2 -0
- package/dist/lib/types/component/input/PasswordField.d.ts +2 -0
- package/dist/lib/types/component/input/PickerInput.d.ts +2 -0
- package/dist/lib/types/component/input/SelectableText.d.ts +11 -0
- package/dist/lib/types/component/input/SpinButton.d.ts +2 -0
- package/dist/lib/types/component/input/Text.d.ts +16 -2
- package/dist/lib/types/component/input/TextArea.d.ts +2 -0
- package/dist/lib/types/component/input/TextField.d.ts +2 -0
- package/dist/lib/types/component/input/TextInput.d.ts +2 -0
- package/dist/lib/types/component/input/TimePickerDropdown.d.ts +3 -1
- package/dist/lib/types/component/input/UsernameField.d.ts +2 -0
- package/dist/lib/types/component/input/index.d.ts +2 -0
- package/dist/lib/types/component/list/AbstractSelectableList.d.ts +4 -2
- package/dist/lib/types/component/table/Body.d.ts +40 -14
- package/dist/lib/types/component/table/Header.d.ts +1 -1
- package/dist/lib/types/component/table/Row.d.ts +20 -2
- package/dist/lib/types/component/table/Table.d.ts +2 -0
- package/dist/lib/types/component/table/TableExporter.d.ts +3 -0
- package/dist/lib/types/component/table/TablePanel.d.ts +1 -0
- package/dist/lib/types/component/table/TreeTablePanel.d.ts +1 -0
- package/dist/lib/types/component/table/cell/Cell.d.ts +7 -2
- package/dist/lib/types/component/table/cell/Default.d.ts +1 -1
- package/dist/lib/types/component/table/cell/Header.d.ts +3 -0
- package/dist/lib/types/component/table/cell/ResizeHandle.d.ts +1 -1
- package/dist/lib/types/component/table/cell/renderer/CellRenderer.d.ts +2 -2
- package/dist/lib/types/component/table/cell/renderer/String.d.ts +3 -1
- package/dist/lib/types/component/table/index.d.ts +1 -1
- package/dist/lib/types/core/AnimatedDropdown.d.ts +2 -0
- package/dist/lib/types/core/ClassStyleRules.d.ts +46 -3
- package/dist/lib/types/core/Component.d.ts +30 -2
- package/dist/lib/types/core/DOM.d.ts +5 -1
- package/dist/lib/types/core/LayerManager.d.ts +1 -0
- package/dist/lib/types/core/StyleTarget.d.ts +2 -0
- package/dist/lib/types/core/Theme.d.ts +1 -0
- package/dist/lib/types/core/Util.d.ts +4 -0
- package/dist/lib/types/core/index.d.ts +1 -1
- package/dist/lib/types/layout/Table.d.ts +2 -0
- package/dist/lib/types/overlay/AbstractWindow.d.ts +3 -0
- package/dist/lib/types/overlay/PopupPanel.d.ts +2 -0
- package/dist/lib/validation.es.js +1 -1
- package/package.json +1 -1
- package/dist/lib/AnimatedDropdown-H3Rh-YMZ.js +0 -2
- package/dist/lib/AnimatedDropdown-H3Rh-YMZ.js.map +0 -1
- package/dist/lib/Border-0DJFDiij.js +0 -2
- package/dist/lib/Border-0DJFDiij.js.map +0 -1
- package/dist/lib/Button-MpMIYBYJ.js +0 -2
- package/dist/lib/Button-MpMIYBYJ.js.map +0 -1
- package/dist/lib/Checkbox-D0JYK-wc.js +0 -2
- package/dist/lib/Checkbox-D0JYK-wc.js.map +0 -1
- package/dist/lib/ComboBox-Dx8Tk9yg.js +0 -2
- package/dist/lib/ComboBox-Dx8Tk9yg.js.map +0 -1
- package/dist/lib/Component-B0ShfPVi.js +0 -2
- package/dist/lib/Component-B0ShfPVi.js.map +0 -1
- package/dist/lib/Container-abY5Ww3W.js +0 -2
- package/dist/lib/DOM-C-Edb3tA.js +0 -2
- package/dist/lib/DOM-C-Edb3tA.js.map +0 -1
- package/dist/lib/Dialog-cbA9V17e.js +0 -2
- package/dist/lib/Dialog-cbA9V17e.js.map +0 -1
- package/dist/lib/Glyph-_VeBacS2.js +0 -2
- package/dist/lib/Glyph-_VeBacS2.js.map +0 -1
- package/dist/lib/List-nx8220Fi.js +0 -2
- package/dist/lib/List-nx8220Fi.js.map +0 -1
- package/dist/lib/Position-BwtxouxK.js.map +0 -1
- package/dist/lib/RadioButton-BEwpqg1k.js +0 -2
- package/dist/lib/RadioButton-BEwpqg1k.js.map +0 -1
- package/dist/lib/RadioMenuRow-DP5qPyFR.js +0 -2
- package/dist/lib/RadioMenuRow-DP5qPyFR.js.map +0 -1
- package/dist/lib/Scrollbar-t8fFrUVQ.js +0 -2
- package/dist/lib/Scrollbar-t8fFrUVQ.js.map +0 -1
- package/dist/lib/TabButton-DLoMQzky.js +0 -2
- package/dist/lib/TabButton-DLoMQzky.js.map +0 -1
- package/dist/lib/Text-CMKnK9uB.js +0 -2
- package/dist/lib/Text-CMKnK9uB.js.map +0 -1
- package/dist/lib/Tooltip-CUOJOqQi.js.map +0 -1
- package/dist/lib/types/component/table/CellGeometry.d.ts +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"List-nx8220Fi.js","names":[],"sources":["../../src/typescript/lib/component/list/ListItemRenderer.ts","../../src/typescript/lib/component/list/renderer/Label.ts","../../src/typescript/lib/component/list/AbstractSelectableList.ts","../../src/typescript/lib/component/list/List.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component } from \"~/core/Component.js\";\nimport { ListItemRenderContext } from \"~/component/list/ListItemRenderContext.js\";\n\n/**\n * Abstract base class for list item renderers.\n *\n * @remarks\n * A `ListItemRenderer` owns the content of a single list row — the label, and\n * optionally an icon or other affordance. The owning\n * [`List`](/api/component/list/classes/List) /\n * [`MultiSelectList`](/api/component/list/classes/MultiSelectList) holds a\n * renderer factory; each pooled row calls that factory once at construction and\n * rebinds via {@link update} when the row is remapped to a different item. The\n * collapsed [`ComboBox`](/api/component/input/classes/ComboBox) control hosts\n * one renderer built from the same factory, so the selected entry renders on\n * the closed control exactly as it does in the open dropdown.\n *\n * Selection / focus / hover chrome is applied by the list on the row element\n * directly and never reaches the renderer.\n *\n * Subclasses implement {@link update} and {@link layoutChildren}. See\n * [`LabelListItemRenderer`](/api/component/list/classes/LabelListItemRenderer)\n * for the canonical default. {@link getContentWidth} is optional: it is read\n * only by a list running with `horizontalScrolling` on, and the base\n * implementation already reports \"no intrinsic width\".\n *\n * Not wrapped with `callable()` — abstract classes are never instantiated.\n *\n * @category Components\n */\nexport abstract class ListItemRenderer extends Component {\n\n constructor() {\n super();\n }\n\n /**\n * Rebinds this renderer to new item data.\n *\n * @param context - The bound-item state for this render pass.\n *\n * @remarks Called every time the owning row (or collapsed control) is\n * mapped to a different item.\n */\n abstract update(context: ListItemRenderContext): void;\n\n /**\n * Returns the natural width of the currently bound content — the width at\n * which it renders without clipping.\n *\n * Read only by a list running with\n * [`horizontalScrolling`](/api/component/list/classes/List#sethorizontalscrolling)\n * on, which sizes every row to the widest value across the bound items so\n * over-long content scrolls into view instead of ellipsising. A list with\n * horizontal scrolling off — the default — never calls this, so a renderer\n * that measures lazily pays nothing for it.\n *\n * The base implementation returns 0, meaning \"no intrinsic width\": rows\n * stay at the viewport width and never extend the horizontal scroll extent.\n * That keeps a custom renderer written against the previous contract\n * working unchanged; override it to opt that renderer into horizontal\n * scrolling.\n *\n * @returns The bound content's natural width in pixels, or 0 when unknown.\n */\n getContentWidth(): number {\n return 0;\n }\n\n /**\n * Positions this renderer's internal children inside its content box.\n *\n * @param width - The horizontal extent of the renderer in pixels.\n * @param height - The vertical extent of the renderer in pixels.\n *\n * @remarks Called by the owning row after the renderer's own size has been\n * set via `setX` / `setY` / `setWidth` / `setHeight`.\n *\n * The `width` and `height` arguments are this renderer's **outer** box, so\n * an implementation must not place children against them directly: take the\n * rectangle from [`getContentBounds()`](/api/core/classes/Component), which\n * subtracts any border and padding the renderer carries, and fall back to\n * the arguments only when it returns `null` (no element yet). A child's\n * containing block is already this renderer's padding box, so one placed\n * at `(0, 0)` sized to `width` / `height` starts inside the border and\n * overruns the opposite edge by its width, where the `overflow: hidden`\n * every component carries clips it.\n */\n abstract layoutChildren(width: number, height: number): void;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { Text } from \"~/component/input/Text.js\";\nimport { ListItemRenderer } from \"~/component/list/ListItemRenderer.js\";\nimport { ListItemRenderContext } from \"~/component/list/ListItemRenderContext.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * The default [`ListItemRenderer`](/api/component/list/classes/ListItemRenderer) —\n * a single [`Text`](/api/component/input/classes/Text) child carrying the\n * item's label.\n *\n * @remarks\n * Used as the implicit factory by [`List`](/api/component/list/classes/List) /\n * [`MultiSelectList`](/api/component/list/classes/MultiSelectList) and the\n * collapsed [`ComboBox`](/api/component/input/classes/ComboBox) control when no\n * custom renderer is set. The label keeps `Text`'s default `truncate: true`, so\n * a label wider than its row clips with an ellipsis — reproducing the row\n * chrome the list carried before renderers existed. The label is sized to fill\n * the row in {@link layoutChildren} rather than to its natural width: the row\n * is never narrower than {@link getContentWidth}, so filling it lets the\n * selection wash span the whole row without clipping the text.\n *\n * @example\n * ```typescript\n * list.setRendererFactory(() => new LabelListItemRenderer());\n * ```\n *\n * @category Components\n */\nclass LabelListItemRenderer extends ListItemRenderer {\n\n private _label: Text;\n /**\n * Whether `_label`'s cached natural width matches the bound text. The label\n * runs with `autoMeasure(false)`, so the measure is driven from\n * {@link getContentWidth} rather than {@link update} — a list with\n * horizontal scrolling off never asks, and so never pays for it.\n */\n private _measured: boolean = false;\n\n /**\n * Constructs a label renderer with an empty text node. The label is\n * populated on the first {@link update} call.\n */\n constructor() {\n super();\n this.clearInsets();\n\n this._label = new Text();\n this._label.clearInsets();\n this._label.setAutoMeasure(false);\n }\n\n /**\n * Returns the underlying label component so consumers can tweak font /\n * colour properties at construction time.\n *\n * @returns The internal [`Text`](/api/component/input/classes/Text) instance.\n */\n getLabel(): Text {\n return this._label;\n }\n\n /**\n * Updates the rendered label text.\n *\n * @param context - The bound-item state for this render pass.\n */\n update(context: ListItemRenderContext): void {\n this._label.setText(context.item.label);\n this._measured = false;\n }\n\n /**\n * Returns the natural width of the bound label, measuring it on first ask\n * after each {@link update}.\n *\n * @returns The label's natural width in pixels.\n */\n getContentWidth(): number {\n if (!this._measured) {\n this._label.measure();\n this._measured = true;\n }\n\n return this._label.getPreferredSize()?.width ?? 0;\n }\n\n /**\n * Sizes the label to fill the renderer's allocated box and centres its\n * line-box vertically by matching `line-height` to the row height.\n *\n * The label goes inside this renderer's content box, so a border or padding\n * on the renderer shrinks it rather than being painted over.\n *\n * @param width - The horizontal extent of the row in pixels. Used only\n * while the renderer has no element yet and the content box is\n * unavailable.\n * @param height - The vertical extent of the row in pixels, used under the\n * same condition as `width`.\n */\n layoutChildren(width: number, height: number): void {\n const box = this.getContentBounds() ?? { x: 0, y: 0, width, height };\n\n this._label.setAutoCommitStyle(false);\n this._label.setX(box.x);\n this._label.setY(box.y);\n this._label.setWidth(box.width);\n this._label.setHeight(box.height);\n this._label.setLineHeight(box.height);\n this._label.setAutoCommitStyle(true);\n }\n\n /**\n * Appends the label sub-component element to the renderer's DOM element.\n *\n * @param element - Optional element passed by the rendering pipeline; falls\n * back to getElement().\n *\n * @returns This renderer, for method chaining.\n */\n protected init(element?: Handle): this {\n super.init(element);\n\n const el = element || this.getElement();\n if (!el) {\n return this;\n }\n\n DOM.sink.appendChild(el, this._label.getElement(true)!);\n\n return this;\n }\n}\n\nconst LabelListItemRendererCallable = callable(LabelListItemRenderer);\ntype LabelListItemRendererCallable = LabelListItemRenderer;\nexport {\n LabelListItemRenderer as _LabelListItemRenderer,\n LabelListItemRendererCallable as LabelListItemRenderer,\n};\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { AbstractInput, AbstractInputOptions } from \"~/component/input/AbstractInput.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { Panel } from \"~/core/Panel.js\";\nimport { StyleRule } from \"~/core/StyleTarget.js\";\nimport { Event } from \"~/core/Event.js\";\nimport { ListenerBag } from \"~/core/ListenerBag.js\";\nimport { Tooltip } from \"~/overlay/Tooltip.js\";\nimport { Type } from \"~/core/Type.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { Fit } from \"~/layout/Fit.js\";\nimport { _VBox } from \"~/layout/VBox.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { AbstractStore } from \"~/data/AbstractStore.js\";\nimport { ModelRecord } from \"~/data/ModelRecord.js\";\nimport { ListItemRenderer } from \"~/component/list/ListItemRenderer.js\";\nimport { LabelListItemRenderer } from \"~/component/list/renderer/Label.js\";\nimport { COMPONENT_CLASS } from \"~/core/ClassStyleRules.js\";\nimport { Text } from \"~/component/input/Text.js\";\n\n/**\n * One entry in a [`List`](/api/component/list/classes/List) /\n * [`MultiSelectList`](/api/component/list/classes/MultiSelectList) item\n * array. Plain data — the row pool is the view layer.\n *\n * @category Components\n */\nexport interface SelectableListItem {\n /** Binding identifier — what `getValue` / `setValue` round-trip. */\n key: string;\n /** Display text rendered in the row. */\n label: string;\n /**\n * Optional registry glyph name, read by\n * [`GlyphListItemRenderer`](/api/component/list/classes/GlyphListItemRenderer)\n * to paint an icon beside the label. Ignored by the default label\n * renderer. Array-supplied items carry it directly; store-bound items\n * resolve it from the record field named by the list's `glyphField`.\n */\n glyph?: string;\n /**\n * Optional hover-tooltip text for the row, shown after the standard hover\n * delay via [`Tooltip`](/api/overlay/classes/Tooltip). Lets a host surface\n * the full value behind a truncated label without reaching into the row DOM.\n * Array-supplied items carry it directly; store-bound items resolve it from\n * the record field named by the list's `tooltipField`.\n */\n tooltip?: string;\n}\n\n/**\n * Accepted form for a single item passed to a custom list's `setItems` /\n * `addItem`: either a plain string (which becomes both the item's key and its\n * label, so a selection is written and read back as the string itself) or a\n * pre-formed {@link SelectableListItem} with an explicit caller-supplied key.\n *\n * @category Components\n */\nexport type SelectableListItemSpec = String | SelectableListItem;\n\n/**\n * Pixel height of one rendered row. Matches `SelectableListRow`'s cached\n * `preferredSize(0, 22)` and the `lineHeight: 22px` declaration in the\n * shared `.SelectableListRow` class rule. Keep these three values in lockstep\n * if the row chrome changes — keyboard `PageUp`/`PageDown` derives its\n * page size from this constant divided into the visible viewport height.\n */\nconst ROW_HEIGHT_PX = 22;\n\n/**\n * Horizontal padding on each side of a row, between the row edge and its\n * renderer. Read by {@link SelectableListRow.publishContentWidth} to convert a\n * renderer's content width into the row's own natural width, so keep it in step\n * with the row's `setPadding` call.\n */\nconst ROW_PADDING_X_PX = 8;\n\n/**\n * Maximum time (in milliseconds) between successive printable-character\n * keypresses before the type-ahead search buffer resets. Picked to match\n * the native `<select>` type-ahead window the custom list replaces — a\n * burst of letters within this window builds a single search prefix; a\n * pause longer than this starts a fresh search.\n */\nconst TYPE_AHEAD_TIMEOUT_MS = 700;\n\n/**\n * Construction-time options for {@link AbstractSelectableList}.\n *\n * @category Components\n */\nexport interface AbstractSelectableListOptions extends AbstractInputOptions {\n items?: String | Array<String>;\n store?: AbstractStore;\n displayField?: string;\n valueField?: string;\n /**\n * Record field whose value becomes each store-bound item's `glyph`, read\n * by [`GlyphListItemRenderer`](/api/component/list/classes/GlyphListItemRenderer).\n * Array-supplied items carry their glyph on the item instead.\n */\n glyphField?: string;\n /**\n * Record field whose value becomes each store-bound item's `tooltip` (the\n * hover text). Array-supplied items carry their tooltip on the item instead.\n */\n tooltipField?: string;\n /**\n * Zero-argument factory producing the renderer for each row. Defaults to a\n * label renderer reproducing the plain-text rows. Supply\n * `() => new GlyphListItemRenderer()` to paint each item's `glyph` beside\n * its label.\n */\n rendererFactory?: () => ListItemRenderer;\n /**\n * Construction-time listener bag — the declarative form of `on()`. Adds the\n * list's `action` shorthand to the inherited `change` / `binding`.\n */\n listeners?: {\n action?: () => void;\n change?: (value: any) => void;\n binding?: () => void;\n };\n /**\n * Muted placeholder text shown inside the scroll area when the list is\n * empty. Opt-in: with neither `emptyText` nor `emptyComponent` set, an empty\n * list has no placeholder child.\n */\n emptyText?: string;\n /**\n * Factory for a custom empty-state placeholder, shown inside the scroll area\n * when the list is empty. Takes precedence over `emptyText`. The returned\n * component should report an unbounded max (the `Component` default) so the\n * empty list still fills its region and drag-resizes.\n */\n emptyComponent?: () => Component;\n /**\n * Construction-time shortcut for\n * [`setHorizontalScrolling`](/api/component/list/classes/List#sethorizontalscrolling).\n * Defaults to `false` — a label wider than the row ellipsises.\n */\n horizontalScrolling?: boolean;\n}\n\n/**\n * Shared visual defaults for every {@link AbstractSelectableList} subclass.\n * Layered into the defaults bag passed to `super` from the abstract\n * constructor so {@link List} and {@link MultiSelectList} share row\n * chrome without duplicating the bag at every leaf.\n */\nconst _defaultAbstractSelectableListOptions: Partial<AbstractSelectableListOptions> = {\n tag: \"div\",\n backgroundColor: \"var(--ts-ui-list-bg, rgb(255, 255, 255))\",\n foregroundColor: \"var(--ts-ui-text-color, black)\",\n border: \"1px solid var(--ts-ui-list-border, rgb(200, 200, 200))\",\n borderRadius: \"var(--ts-ui-border-radius, 4px)\",\n preferredSize: { width: 200, height: 200 },\n maxSize: { width: Number.MAX_SAFE_INTEGER, height: Number.MAX_SAFE_INTEGER },\n};\n\n/**\n * Static styling registered once at module init. The container surface\n * carries the focus ring (matched against the framework auto-added\n * `.List` / `.MultiSelectList` classes that `Component.init()` derives\n * from `constructor.name`); `.SelectableListRow` carries the row chrome\n * (single-line text with ellipsis truncation); the row's theme-controlled\n * separator is a real border set through `setBorder` in the row constructor,\n * not a class rule, so the framework's box math can see it. The\n * `.selected` / `.focused` modifier classes layer the\n * selection wash and keyboard-focus outline on top.\n *\n * The `:focus` ring is attached via a compound selector covering both\n * concrete subclass names rather than the abstract base — TypeScript\n * `class.constructor.name` is the leaf class, so the framework adds\n * `\"List\"` / `\"MultiSelectList\"` (not `\"AbstractSelectableList\"`) to the\n * surface's classList. Keep this list in sync if a new concrete\n * subclass extends `AbstractSelectableList`.\n */\n(() => {\n new StyleRule({\n scope: \"selector\",\n name: \".List, .MultiSelectList\",\n styles: {\n userSelect: \"none\",\n outline: \"none\",\n },\n });\n\n // Pseudo-element overlay rather than a plain `outline:` rule so an\n // ancestor with `overflow: hidden` (the framework's Component default)\n // can't clip the focus indicator. `z-index: 1` lifts the ring above the\n // absolutely-positioned rows.\n new StyleRule({\n scope: \"selector\",\n name: \".List:focus::after, .MultiSelectList:focus::after\",\n styles: {\n content: \"''\",\n position: \"absolute\",\n inset: \"0\",\n border: \"2px solid var(--ts-ui-indicator-focus, rgb(30, 100, 200))\",\n borderRadius: \"inherit\",\n boxSizing: \"border-box\",\n pointerEvents: \"none\",\n zIndex: \"1\",\n },\n });\n\n // `lineHeight: 22px` centers the single line of label text vertically\n // without `display: flex` — matches `ROW_HEIGHT_PX` and the row's\n // cached `preferredSize(0, 22)`. The whiteSpace/overflow/textOverflow\n // trio truncates long labels with an ellipsis when the row is narrower\n // than the label text.\n new StyleRule({\n scope: \"class\",\n name: \"SelectableListRow\",\n styles: {\n lineHeight: \"22px\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n cursor: \"pointer\",\n },\n });\n\n new StyleRule({\n scope: \"selector\",\n name: \".SelectableListRow:hover\",\n styles: {\n backgroundColor: \"var(--ts-ui-list-row-hover-bg, rgba(30, 100, 200, 0.08))\",\n },\n });\n\n new StyleRule({\n scope: \"selector\",\n name: \".SelectableListRow.selected\",\n styles: {\n backgroundColor: \"var(--ts-ui-list-row-selected-bg, rgba(30, 100, 200, 0.18))\",\n color: \"var(--ts-ui-list-row-selected-color, inherit)\",\n },\n });\n\n // The keyboard-focused row is part of the *selection* indicator family\n // (a light per-row mark, distinct from the heavier focus border around\n // the focusable list root itself). Uses the dashed `indicator.selection`\n // shorthand so future themes can re-skin every \"selection mark\" in one\n // place. Rows have no positioned descendants, so the outline draws on\n // top of the row's text without any covering issue.\n new StyleRule({\n scope: \"selector\",\n name: \".SelectableListRow.focused\",\n styles: {\n outline: \"var(--ts-ui-indicator-selection, 1px dashed rgb(120, 170, 240))\",\n },\n });\n})();\n\n/**\n * A single row inside an {@link AbstractSelectableList}. Holds the static\n * row styling via the `.SelectableListRow` / `.SelectableListRow:hover` /\n * `.SelectableListRow.selected` / `.SelectableListRow.focused` class rules —\n * except the bottom separator, which is a real border set in the constructor so\n * it is measurable — and exposes typed setters for the label, the pool index,\n * the selected flag, and the focused flag.\n *\n * Internal — not re-exported from the per-subpath barrel; the public\n * surface lives on `List` / `MultiSelectList`.\n */\nclass SelectableListRow extends Component {\n // Cached so setter calls made before the element renders survive to\n // be applied at render time.\n private _selected: boolean = false;\n private _focused: boolean = false;\n /** Zero-based index in the row pool; forwarded to the handlers on a gesture. */\n private _index: number;\n /** Owner-supplied gesture handlers, each invoked with this row's `_index`. */\n private readonly _handlers: RowHandlers;\n /** Whether a tooltip is currently attached, so `updateItem` can detach it. */\n private _tooltipAttached: boolean = false;\n /**\n * The renderer owning this row's content (label, optional glyph). Built\n * from the owning list's factory, appended straight into the row DOM in\n * {@link init}, and positioned from {@link doLayout}. Rendered\n * `pointer-events: none` so a click on the label falls through to the\n * row element, whose exact-target `click` listener drives selection.\n */\n private _renderer: ListItemRenderer;\n\n /**\n * @param handlers - Owner-supplied gesture callbacks (click, contextmenu,\n * dblclick), each invoked with the row's index and the raw mouse event.\n * @param index - Initial pool index.\n * @param rendererFactory - Zero-argument factory producing this row's\n * content renderer.\n */\n constructor(handlers: RowHandlers, index: number, rendererFactory: () => ListItemRenderer) {\n super({ tag: \"div\" });\n\n this._handlers = handlers;\n this._index = index;\n this._renderer = rendererFactory();\n this._renderer.setPointerEvents(\"none\");\n\n this.getAria().setRole(\"option\");\n this.setPreferredSize({ width: 0, height: ROW_HEIGHT_PX });\n // Do NOT cap the row's max height. A finite per-row height max makes the\n // list's VBox sum to a finite content max (VBox.aggregateMaxSize), which\n // shrink-wraps the whole list to its content and breaks stretch/scroll\n // and the accordion's resizable drag. The row is already pinned to\n // ROW_HEIGHT_PX by its preferredSize above; leave its max unbounded (the\n // Component default).\n this.setPadding(new Insets(0, ROW_PADDING_X_PX, 0, ROW_PADDING_X_PX));\n // Declared through the typed setter rather than the shared class rule so\n // getBorderSize() sees the 1px the separator takes out of the row's\n // content box; a class-rule border is invisible to the framework's box\n // math, and the renderer would be sized a pixel too tall and clipped.\n this.setBorder({ borderBottom: \"1px solid var(--ts-ui-list-row-separator, transparent)\" });\n // Component's framework default writes `cursor: default` as an\n // inline style, which would beat the `.SelectableListRow` class rule\n // — set the inline cursor explicitly so rows show the hand\n // cursor on hover.\n this.setCursor(\"pointer\");\n\n Event.addListener(this, \"pointerdown\", { prevent: true, handler: this.onPointerDown });\n Event.addListener(this, \"click\", this.onClick);\n Event.addListener(this, \"contextmenu\", this.onContextMenu);\n Event.addListener(this, \"dblclick\", this.onDblClick);\n }\n\n /**\n * Rebinds this row's renderer to a new item, replacing the plain-text\n * label write the pool sync used before renderers existed.\n *\n * @param item - The item to display.\n * @param index - The item's zero-based index.\n *\n * @returns This row, for method chaining.\n */\n updateItem(item: SelectableListItem, index: number): this {\n this._renderer.update({ item, index });\n this.applyTooltip(item.tooltip);\n\n return this;\n }\n\n /**\n * Attaches (or detaches) the row's hover tooltip to match the item. Called\n * from {@link updateItem} so a pooled row reused for a different item tracks\n * the new item's `tooltip` — attaching when set, detaching when cleared.\n *\n * @param text - The item's tooltip text, or `undefined` for no tooltip.\n */\n private applyTooltip(text: string | undefined): void {\n if (text) {\n // Tooltip.attach replaces any prior attachment, so re-attaching with\n // new text on pool reuse is safe. The renderer is pointer-events:none,\n // so hover events target the row element and the component-level\n // attach matches (no need to reach the label child).\n Tooltip.attach(this, text);\n this._tooltipAttached = true;\n } else if (this._tooltipAttached) {\n Tooltip.detach(this);\n this._tooltipAttached = false;\n }\n }\n\n /**\n * Returns the row's natural width — its renderer's content width plus the\n * row's own horizontal padding — i.e. the width at which the bound item\n * renders without clipping.\n *\n * Read by {@link ListRowColumn.computeTotalMinSize}, and only while the\n * owning list scrolls horizontally, so a list with the setting off never\n * calls this and never makes its renderers measure.\n *\n * Deliberately *not* published as the row's `minSize`: a minimum is a\n * constraint that propagates outward (`VBox.getMinSize` → the inner\n * `Panel` → the list's `Fit` → `Component.clampWidth`), so a wide row would\n * inflate the whole `List` element inside its host rather than scroll\n * within it. The natural width is an input to the column's own overflow\n * inflation only.\n *\n * @returns The row's natural width in pixels.\n */\n getNaturalWidth(): number {\n return this._renderer.getContentWidth() + ROW_PADDING_X_PX * 2;\n }\n\n /**\n * Swaps in a new content renderer, removing the old renderer's element\n * and appending the new one. Used when the owning list's renderer factory\n * changes. The new renderer is left blank until the next\n * {@link updateItem}.\n *\n * @param renderer - The replacement renderer.\n *\n * @returns This row, for method chaining.\n */\n setRenderer(renderer: ListItemRenderer): this {\n const el = this.getElement();\n\n if (el) {\n const oldEl = this._renderer.getElement();\n if (oldEl && DOM.source.getParentNode(oldEl) === el) {\n DOM.sink.removeChild(el, oldEl);\n }\n }\n\n this._renderer = renderer;\n this._renderer.setPointerEvents(\"none\");\n\n if (el) {\n DOM.sink.appendChild(el, this._renderer.getElement(true)!);\n }\n\n return this;\n }\n\n /**\n * Updates the index this row reports through its click callback. Used\n * when the row pool is reconciled against a new item list and an\n * existing row is reused at a new position.\n *\n * @param index - The new zero-based row index.\n *\n * @returns This row, for method chaining.\n */\n setIndex(index: number): this {\n this._index = index;\n\n return this;\n }\n\n /**\n * Returns the row's current pool index.\n *\n * @returns The zero-based index.\n */\n getIndex(): number {\n return this._index;\n }\n\n /**\n * Toggles the `.selected` class and `aria-selected` to reflect\n * membership in the owning list's selection set.\n *\n * @param value - `true` when this row is currently selected.\n *\n * @returns This row, for method chaining.\n */\n setSelected(value: boolean): this {\n this._selected = value;\n this.getAria().setSelected(value);\n this.applyRowClass();\n\n return this;\n }\n\n /**\n * Returns the cached selected state.\n *\n * @returns `true` when this row is currently selected.\n */\n isSelected(): boolean {\n return this._selected;\n }\n\n /**\n * Toggles the `.focused` class to reflect the keyboard-focus position\n * inside the owning list.\n *\n * @param value - `true` when this row currently holds the keyboard\n * focus position.\n *\n * @returns This row, for method chaining.\n */\n setFocused(value: boolean): this {\n this._focused = value;\n this.applyRowClass();\n\n return this;\n }\n\n /**\n * Returns the cached focused state.\n *\n * @returns `true` when this row holds the keyboard-focus position.\n */\n isFocused(): boolean {\n return this._focused;\n }\n\n /**\n * Renders the row's `<div>` with its current class set. The label content\n * lives in the renderer child, appended by {@link init}.\n *\n * @returns The created element handle.\n */\n protected render(): Handle {\n const element = super.render();\n this.applyRowClass();\n\n return element;\n }\n\n /**\n * Appends the renderer's element to the row DOM. The renderer's own\n * children (label, optional glyph) are appended by the renderer's `init`.\n *\n * @param element - Optional element passed by the rendering pipeline;\n * falls back to getElement().\n *\n * @returns This row, for method chaining.\n */\n protected init(element?: Handle): this {\n super.init(element);\n\n const el = element || this.getElement();\n if (el) {\n DOM.sink.appendChild(el, this._renderer.getElement(true)!);\n }\n\n return this;\n }\n\n /**\n * Positions the renderer to fill the row's content box, then lets it lay\n * out its own children. Only writes setters (no geometry reads), so it is\n * safe under the `commitBounds` auto-commit path that drives it.\n *\n * @returns This row, for method chaining.\n */\n doLayout(): this {\n super.doLayout();\n\n const box = this.getContentBounds();\n if (!box) {\n return this;\n }\n\n this._renderer.setAutoCommitStyle(false);\n this._renderer.setX(box.x);\n this._renderer.setY(box.y);\n this._renderer.setWidth(box.width);\n this._renderer.setHeight(box.height);\n this._renderer.setAutoCommitStyle(true);\n\n this._renderer.layoutChildren(box.width, box.height);\n\n return this;\n }\n\n /**\n * Computes the row's class list from the cached selected/focused\n * state. Writes via `setElementAttribute(\"class\", …)` so the framework\n * defer-write seam owns the DOM write.\n *\n * The write replaces the whole `class` attribute, so it must re-state the\n * framework `COMPONENT_CLASS` that `Component.init` adds — otherwise a\n * post-init rewrite (a selection change) drops it, and with it the\n * `:where(.ts-ui-component)` rule that supplies `position: absolute`,\n * collapsing every row to `top: auto` so they stack on top of each other.\n */\n private applyRowClass(): void {\n const classes = [COMPONENT_CLASS, \"SelectableListRow\"];\n\n if (this._selected) {\n classes.push(\"selected\");\n }\n\n if (this._focused) {\n classes.push(\"focused\");\n }\n\n this.setElementAttribute(\"class\", classes.join(\" \"));\n }\n\n /**\n * Suppresses focus loss when the row is pointed at. Without this,\n * clicking a row while the list root has focus would blur the list,\n * and the keyboard model would lose its focus position before the\n * click handler runs. The same pattern guards the AutoComplete row\n * pool against blurring the host input on click.\n *\n * @param e - The pointerdown event.\n */\n private onPointerDown(_e: PointerEvent): void {\n }\n\n /**\n * Forwards the row's index and the raw mouse event to the owner-supplied\n * click callback.\n *\n * @param e - The click event.\n */\n private onClick(e: MouseEvent): void {\n this._handlers.onClick(this._index, e);\n }\n\n /**\n * Forwards the row's index and the raw mouse event to the owner-supplied\n * context-menu callback.\n *\n * @param e - The contextmenu event.\n */\n private onContextMenu(e: MouseEvent): void {\n this._handlers.onContextMenu(this._index, e);\n }\n\n /**\n * Forwards the row's index and the raw mouse event to the owner-supplied\n * double-click callback.\n *\n * @param e - The dblclick event.\n */\n private onDblClick(e: MouseEvent): void {\n this._handlers.onDblClick(this._index, e);\n }\n}\n\n/**\n * The row stack inside a list's scroll panel: a `VBox` that additionally knows\n * how wide its rows want to be.\n *\n * Exists for one reason — the framework's cross-axis overflow inflation reads\n * the children's *minimum* width (`LayoutManager.inflateForOverflow` →\n * {@link computeTotalMinSize}), but a row's natural width must not become a\n * minimum. A minimum propagates outward — `VBox.getMinSize` → the scroll\n * `Panel` → the list's `Fit` → `Component.clampWidth` — and would inflate the\n * `List` element itself inside its host, so a long label would widen the whole\n * rail instead of scrolling inside it.\n *\n * Overriding `computeTotalMinSize` alone separates the two: the inflation\n * target picks up the widest row's natural width, while `getMinSize` (untouched\n * from `VBox`) keeps reporting the rows' real minimum of zero. So the column\n * lays out wide and scrolls, and nothing outside the scroll panel ever learns\n * of the content's width.\n *\n * Inert unless the host has opted into horizontal overflow — `inflateForOverflow`\n * ignores an axis the host does not scroll, so with `horizontalScrolling` off\n * this behaves exactly as a plain `VBox` and never measures a renderer.\n */\nclass ListRowColumn extends _VBox {\n\n /**\n * Widens the inflation target to the widest row's natural width, so a list\n * scrolling horizontally lays its rows out at full content width.\n *\n * @returns The children's combined min size, with the width raised to the\n * widest row's natural width.\n */\n protected computeTotalMinSize(): Size {\n const total = super.computeTotalMinSize();\n const container = this.getContainer();\n\n // Only the X-overflow path consumes the width, and the scan below makes\n // every row measure its renderer — so skip it whenever the host isn't\n // scrolling X. Not merely an optimisation: a list has always scrolled Y,\n // so `inflateForOverflow` calls this on every layout of every list, and\n // an ungated scan would put a per-row text measure into all of them.\n if (!container || !this.isOverflowingX()) {\n return total;\n }\n\n let natural = 0;\n\n for (const component of container.getLaidOutComponents()) {\n // The empty-state placeholder shares the column with the rows and has\n // no natural width to contribute — it tracks the viewport instead.\n if (component instanceof SelectableListRow) {\n natural = Math.max(natural, component.getNaturalWidth());\n }\n }\n\n return { width: Math.max(total.width, natural), height: total.height };\n }\n}\n\n/**\n * Owner-supplied gesture callbacks for a {@link SelectableListRow}, each invoked\n * with the row's current pool index and the originating mouse event. The row\n * owns no selection or event-dispatch logic itself — it forwards to the list.\n */\ninterface RowHandlers {\n /** Invoked on a left-click of the row. */\n onClick: (index: number, event: MouseEvent) => void;\n /** Invoked on a right-click of the row (before the list suppresses the native menu). */\n onContextMenu: (index: number, event: MouseEvent) => void;\n /** Invoked on a double-click of the row. */\n onDblClick: (index: number, event: MouseEvent) => void;\n}\n\n/**\n * Abstract base for the framework's custom selectable list controls.\n *\n * Owns the item array, the store binding, the row pool (one\n * {@link SelectableListRow} per visible item), the selection set, the\n * keyboard model (ArrowUp/Down, Home/End, PageUp/Down, Enter/Space,\n * type-ahead), and the ARIA listbox wiring. Concrete subclasses\n * ({@link List}, {@link MultiSelectList}) supply the\n * {@link AbstractSelectableList.reduceSelection} reducer that translates a\n * click or keyboard gesture into a new selection set, and the\n * {@link AbstractSelectableList.setValue} / `getValue` round-trip used by\n * [`Bindable`](/api/core/interfaces/Bindable).\n *\n * Not wrapped with `callable()` — abstract classes are never instantiated;\n * the wrapping rule applies only to concrete component subclasses.\n *\n * @category Components\n */\nabstract class AbstractSelectableList<\n TValue,\n TOptions extends AbstractSelectableListOptions = AbstractSelectableListOptions\n>\n extends AbstractInput<TValue, TOptions>\n{\n protected _items: Array<SelectableListItem> = [];\n protected _rowPool: Array<SelectableListRow> = [];\n protected _selectedSet: Set<number> = new Set();\n protected _anchorIndex: number | null = null;\n protected _focusedIndex: number = -1;\n /** Lower-cased type-ahead buffer; cleared on Escape or timeout. */\n protected _typeAheadBuf: string = \"\";\n /** Timestamp (ms) of the last printable keypress; used to time out the buffer. */\n protected _typeAheadAt: number = 0;\n /**\n * When true, {@link handleRowClick} pulls DOM focus to the list root\n * after the gesture commits so subsequent keystrokes route through\n * `handleKeyDown`. Hosts that own their own focus surface and forward\n * keystrokes (e.g. the ComboBox dropdown, which calls\n * {@link handleKey} from the ComboBox's own `keydown`) set this to\n * `false` so the embedded list never steals focus from the wrapping\n * input.\n */\n protected _focusOnRowClick: boolean = true;\n /**\n * When true (default), keyboard navigation\n * (ArrowUp/Down/Home/End/PageUp/Down) commits the focused row as the\n * selection — the \"selection follows focus\" pattern most listbox\n * controls use. Hosts that want a navigable highlight without\n * committing the row as the selected value (the WAI-ARIA\n * combobox-with-list-autocomplete pattern, exercised by\n * [`AutoCompleteField`](/api/component/input/classes/AutoCompleteField))\n * call `setSelectFollowsFocus(false)` so ArrowUp/Down moves only the\n * focus highlight; Enter / Space / click still commit.\n */\n protected _selectFollowsFocus: boolean = true;\n /**\n * Whether over-long rows scroll horizontally instead of ellipsising.\n * Written only by {@link setHorizontalScrolling}, dispatched from the\n * constructor body once `_innerPanel` exists, so the field-initializer\n * default survives the `super()` cascade without a `declare`.\n */\n private _horizontalScrolling: boolean = false;\n protected _innerPanel: Panel;\n /** Cached empty-state placeholder, built lazily on first need; null until then. */\n private _emptyPlaceholder: Component | null = null;\n /** Whether `_emptyPlaceholder` is currently a child of `_innerPanel`. */\n private _placeholderAttached: boolean = false;\n private _storeRefresh: (() => void) | null = null;\n /**\n * Factory producing each row's content renderer. Defaults to a label\n * renderer reproducing the plain-text rows. Written only by\n * {@link setRendererFactory}, dispatched from the constructor body, so the\n * field-initializer default survives the `super()` cascade without a\n * `declare`.\n */\n private _rendererFactory: () => ListItemRenderer = () => new LabelListItemRenderer();\n /**\n * Listeners for the row-gesture events that carry a row index payload\n * (`contextmenu`, `dblclick`) — kept off the DOM `Event` bus, which fires\n * bare DOM events without the index. `change` / `action` stay on the DOM\n * bus via {@link on}. Mirrors [`Tree`](/api/component/tree/classes/Tree)'s\n * `contextmenu` / `dblclick` wiring.\n */\n private _rowListeners: ListenerBag<\"contextmenu\" | \"dblclick\"> = new ListenerBag();\n\n /**\n * @param options - Caller-supplied options bag.\n * @param subclassDefaults - Per-subclass default bag layered over this\n * class's defaults; subclasses forward their `_defaultXxxOptions`\n * constant here.\n */\n constructor(options?: TOptions, subclassDefaults?: Partial<TOptions>) {\n // `Fit` makes the inner panel fill the list root; the Component\n // default `Absolute` would size every child to its preferredSize\n // (none here) and collapse the inner panel to 0×0. Layered into\n // the defaults bag so concrete subclass defaults and user options\n // can still override, alongside the shared list chrome.\n super(\n options,\n {\n ..._defaultAbstractSelectableListOptions,\n layoutManager: new Fit(),\n ...(subclassDefaults ?? {}),\n } as Partial<TOptions>,\n );\n\n // Element-level chrome: the list root carries the `listbox` role\n // and is focusable. The framework auto-adds the leaf-class name\n // (`\"List\"` / `\"MultiSelectList\"`) to the surface's classList in\n // `Component.init()`; the shared `.List, .MultiSelectList`\n // style rule registered at module init picks both up without an\n // extra opt-in.\n this.getAria().setRole(\"listbox\");\n this.getAria().setTabIndex(0);\n\n // Inner panel is the scrollable row stack. `autoScroll: \"y\"` opts\n // it into the framework's native-overflow path; `VBox` lays the\n // rows out vertically full-width with no gap.\n this._innerPanel = new Panel({\n layoutManager: new ListRowColumn({ spacing: 0, stretching: true }),\n autoScroll: \"y\",\n insets: new Insets(0, 0, 0, 0),\n });\n this.addComponent(this._innerPanel);\n\n // Default floor, but let a caller-supplied minSize option win. The\n // super() cascade writes `_options.minSize` only when the caller passed\n // one (the class default {0,0} lives in the defaults bag, not `_options`),\n // so its presence means \"caller set it\". maxSize stays unbounded.\n if (this._options.minSize === undefined) {\n // 100×100 keeps a short empty/placeholder list a usable size.\n this.setMinSize({ width: 100, height: 100 });\n }\n\n Event.addListener(this, \"keydown\", this.handleKeyDown);\n\n // Late-built state: `rendererFactory` / `store` / `items` / `enabled` /\n // `readOnly` were written pure to `_options` by the super-time cascade.\n // Dispatch them now that `_innerPanel` and `_rowPool` exist. The\n // factory is dispatched first so the row pool is built (by `setStore` /\n // `setItems` below) with the caller's renderer on first paint.\n if (this._options.rendererFactory !== undefined) {\n this.setRendererFactory(this._options.rendererFactory);\n }\n\n if (this._options.horizontalScrolling !== undefined) {\n this.setHorizontalScrolling(this._options.horizontalScrolling);\n }\n\n if (this._options.store !== undefined && this._options.displayField !== undefined) {\n this.setStore(this._options.store, this._options.displayField, this._options.valueField, this._options.glyphField, this._options.tooltipField);\n }\n\n if (this._options.items !== undefined) {\n this.setItems(this._options.items);\n }\n\n if (this._options.enabled !== undefined) {\n this.applyEnabled(this._options.enabled);\n }\n\n if (this._options.readOnly !== undefined) {\n this.applyReadOnly(this._options.readOnly);\n }\n\n // Dispatch the empty-state options last, after items/store — a list built\n // *with* items must show no placeholder. Needed because an empty list\n // configured with only `emptyText`/`emptyComponent` never calls syncRows\n // during construction.\n if (this._options.emptyText !== undefined || this._options.emptyComponent !== undefined) {\n this.syncEmptyPlaceholder();\n }\n }\n\n /**\n * Reflects the enabled flag on the ARIA tree, the tabindex, and the\n * cursor. Disabling the list parks the focus index at -1 so a\n * subsequent enable starts fresh, mirroring the native `<select>`\n * the framework replaces. Concrete subclasses can still override\n * for additional behaviour.\n *\n * @param value - The new enabled state.\n */\n protected applyEnabled(value: boolean): void {\n this.getAria().setDisabled(!value);\n this.getAria().setTabIndex(value ? 0 : -1);\n this.setCursor(value ? \"default\" : \"not-allowed\");\n\n if (!value) {\n this._focusedIndex = -1;\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n }\n }\n\n /**\n * Reflects the read-only flag on the ARIA tree. Read-only lists\n * stay focusable and announce their state; the click / keyboard\n * reducers are gated separately in {@link handleRowClick} /\n * {@link handleKeyDown}.\n *\n * @param value - The new read-only state.\n */\n protected applyReadOnly(value: boolean): void {\n this.getAria().setReadOnly(value);\n }\n\n /**\n * Applies an {@link AbstractSelectableListOptions} bag. Item / store\n * fields are written pure into `_options` here and dispatched from the\n * constructor body — the row pool and inner panel only exist after\n * `super()` returns.\n *\n * @param options - The options bag carrying the values to apply.\n *\n * @returns This component, for method chaining.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n if (options.items !== undefined) this._options.items = options.items;\n if (options.store !== undefined) this._options.store = options.store;\n if (options.displayField !== undefined) this._options.displayField = options.displayField;\n if (options.valueField !== undefined) this._options.valueField = options.valueField;\n if (options.glyphField !== undefined) this._options.glyphField = options.glyphField;\n if (options.tooltipField !== undefined) this._options.tooltipField = options.tooltipField;\n if (options.rendererFactory !== undefined) this._options.rendererFactory = options.rendererFactory;\n if (options.emptyText !== undefined) this._options.emptyText = options.emptyText;\n if (options.emptyComponent !== undefined) this._options.emptyComponent = options.emptyComponent;\n\n if (options.horizontalScrolling !== undefined) this._options.horizontalScrolling = options.horizontalScrolling;\n\n return this;\n }\n\n /**\n * Sets whether a row wider than the viewport scrolls horizontally instead of\n * ellipsising.\n *\n * Off by default, which is the behaviour every list has always had: rows track\n * the viewport width and a label too long for its row clips with an ellipsis.\n * That is the right default for a narrow rail, and for the dropdown surfaces\n * (`ComboBox`, `AutoCompleteField`) where a horizontal bar under a popup reads\n * as a glitch. Turn it on for a list whose labels carry meaning past the\n * truncation point — a file path, a query — and whose host is too narrow to\n * show them.\n *\n * When on, every row is sized to the widest bound row's natural width (see\n * {@link ListItemRenderer.getContentWidth}) or the viewport, whichever is\n * larger, and the scroll area raises a horizontal scrollbar once the content\n * exceeds it. Rows stay full-width relative to each other, so the selection\n * wash still spans the whole row when scrolled. A custom renderer that does\n * not override `getContentWidth` reports no intrinsic width, so its rows stay\n * at the viewport width and nothing scrolls.\n *\n * @param value - True to scroll over-long rows horizontally.\n *\n * @returns This component, for method chaining.\n */\n setHorizontalScrolling(value: boolean): this {\n if (this._horizontalScrolling === value) {\n return this;\n }\n\n this._horizontalScrolling = value;\n\n // `\"auto\"` adds the X axis to the Y the list has always scrolled. That\n // alone drives everything: it is what lets `ListRowColumn` inflate past\n // the viewport, and what raises the bar once the rows do.\n this._innerPanel.setAutoScroll(value ? \"auto\" : \"y\");\n this.scheduleLayout();\n\n return this;\n }\n\n /**\n * Returns whether over-long rows scroll horizontally rather than ellipsising.\n *\n * @returns True when horizontal scrolling is on.\n */\n isHorizontalScrolling(): boolean {\n return this._horizontalScrolling;\n }\n\n /**\n * Sets the muted placeholder text shown inside the scroll area when the list\n * is empty. Pass `null` to clear it. Takes effect immediately: an already\n * empty list shows (or drops) the placeholder on the next layout.\n *\n * @param text - The placeholder text, or `null` to remove it.\n *\n * @returns This component, for method chaining.\n */\n setEmptyText(text: string | null): this {\n this._options.emptyText = text ?? undefined;\n this.resetEmptyPlaceholder();\n this.syncEmptyPlaceholder();\n\n return this;\n }\n\n /**\n * Returns the configured empty-state placeholder text.\n *\n * @returns The placeholder text, or `null` if none is set.\n */\n getEmptyText(): string | null {\n return this._options.emptyText ?? null;\n }\n\n /**\n * Sets a factory for a custom empty-state placeholder, shown inside the\n * scroll area when the list is empty. Takes precedence over\n * {@link setEmptyText}. Pass `null` to clear it. The returned component\n * should report an unbounded max so the empty list still fills its region.\n *\n * @param factory - The placeholder factory, or `null` to remove it.\n *\n * @returns This component, for method chaining.\n */\n setEmptyComponent(factory: (() => Component) | null): this {\n this._options.emptyComponent = factory ?? undefined;\n this.resetEmptyPlaceholder();\n this.syncEmptyPlaceholder();\n\n return this;\n }\n\n /**\n * Returns the configured empty-state placeholder factory.\n *\n * @returns The placeholder factory, or `null` if none is set.\n */\n getEmptyComponent(): (() => Component) | null {\n return this._options.emptyComponent ?? null;\n }\n\n /**\n * Adds or removes the empty-state placeholder against the current item\n * count. Attaches the placeholder (building it lazily on first need) to\n * `_innerPanel` when an empty-state is configured and the list is empty;\n * detaches it otherwise. A no-op when no empty-state is configured — an\n * opted-out empty list keeps no placeholder child.\n *\n * Called at the tail of {@link syncRows}, from the empty-state setters, and\n * once at construction for a list built empty with an empty-state option.\n */\n protected syncEmptyPlaceholder(): void {\n const configured = this._options.emptyComponent !== undefined || this._options.emptyText !== undefined;\n const wants = configured && this._items.length === 0;\n\n if (wants) {\n if (!this._emptyPlaceholder) {\n this._emptyPlaceholder = this.buildEmptyPlaceholder();\n }\n\n if (!this._placeholderAttached) {\n // weight: 1 makes the single child absorb all leftover main-axis\n // (height) space so the placeholder fills the scroll area; the\n // inner VBox's stretching:true fills the width.\n this._innerPanel.addComponent(this._emptyPlaceholder, { weight: 1 });\n this._placeholderAttached = true;\n }\n } else if (this._placeholderAttached && this._emptyPlaceholder) {\n this._innerPanel.removeComponent(this._emptyPlaceholder);\n this._placeholderAttached = false;\n }\n }\n\n /**\n * Builds the empty-state placeholder: the `emptyComponent` factory's output\n * if set, otherwise a muted, horizontally-centered single-line `Text` from\n * `emptyText` using the list-scoped disabled token.\n *\n * @returns The placeholder component.\n */\n private buildEmptyPlaceholder(): Component {\n const factory = this._options.emptyComponent;\n if (factory) {\n return factory();\n }\n\n const text = new Text(this._options.emptyText ?? \"\", { textAlign: \"center\" });\n text.setForegroundColor(\"var(--ts-ui-list-row-disabled-color, rgb(170, 170, 170))\");\n\n return text;\n }\n\n /**\n * Detaches the cached placeholder (if attached) and drops it, so the next\n * {@link syncEmptyPlaceholder} rebuilds it from the current options. Used by\n * the empty-state setters when the configuration changes.\n */\n private resetEmptyPlaceholder(): void {\n if (this._placeholderAttached && this._emptyPlaceholder) {\n this._innerPanel.removeComponent(this._emptyPlaceholder);\n this._placeholderAttached = false;\n }\n\n this._emptyPlaceholder = null;\n }\n\n /**\n * Returns `null` so a multi-line list surface is treated as a\n * replaced/graphical element by horizontal layouts — matches the\n * behaviour the prior native `<select>`-backed `List` preserved.\n *\n * @returns Always `null`.\n */\n getBaseline(): number | null {\n return null;\n }\n\n /**\n * Returns a shallow copy of the current item array.\n *\n * @returns The items in display order.\n */\n getItems(): Array<SelectableListItem> {\n return this._items.slice();\n }\n\n /**\n * Replaces all items with the given specs. Each entry is either a plain\n * string — keyed by the string itself (`{ key: label }`), so `getValue` /\n * `setValue` round-trip the visible text for the common \"list of names\"\n * case — or a pre-formed {@link SelectableListItem} whose explicit key is kept\n * verbatim. Selection and focus are reset; the row pool is reconciled\n * against the new length.\n *\n * @param items - A single spec or an array of specs. Each spec is a string\n * (keyed by its own value) or a `{ key, label }` object (explicit key).\n *\n * @remarks The caller owns key uniqueness — repeated strings, or an explicit\n * key colliding with a string value, produce duplicate keys, and\n * `getValue` / `setValue` resolve to the first row whose `key` matches, so\n * a duplicate key is merely addressed by its lowest matching row.\n *\n * @returns This component, for method chaining.\n */\n setItems(items: SelectableListItemSpec | Array<SelectableListItemSpec>): this {\n if (!Type.isArray(items)) {\n items = [items as SelectableListItemSpec];\n }\n\n const list = items as Array<SelectableListItemSpec>;\n const built: Array<SelectableListItem> = [];\n\n for (const entry of list) {\n built.push(\n typeof entry === \"string\"\n ? { key: entry, label: entry }\n : { key: (entry as SelectableListItem).key, label: (entry as SelectableListItem).label, glyph: (entry as SelectableListItem).glyph, tooltip: (entry as SelectableListItem).tooltip },\n );\n }\n\n return this.setItemsArray(built);\n }\n\n /**\n * Replaces all items with the given pre-formed `{key, label}` pairs.\n * Mirrors {@link setItems} but skips the key-from-label step so a host\n * that already owns typed items (e.g. the [`ComboBox`](/api/component/input/classes/ComboBox)\n * dropdown pushing a `SelectableListItem` array) can hand them over\n * without the keys being overwritten by their labels. Selection and focus are reset; the row pool\n * is reconciled against the new length.\n *\n * Protected on the abstract base so each concrete subclass decides\n * whether to widen it into the public surface — {@link List} does;\n * `MultiSelectList` does not (the multi-select consumers haven't\n * needed the typed-array entry point so far).\n *\n * @param items - The pre-formed item pairs, in display order.\n *\n * @returns This component, for method chaining.\n */\n protected setItemsArray(items: Array<SelectableListItem>): this {\n this._items = items.slice();\n\n this._selectedSet.clear();\n this._anchorIndex = null;\n this._focusedIndex = -1;\n\n this.pauseLayout();\n this.syncRows();\n this.resumeLayout();\n this.updateActiveDescendant();\n\n return this;\n }\n\n /**\n * Appends a new item to the end of the list. A plain string is keyed by the\n * string itself (`{ key: label }`), so `getValue` / `setValue` round-trip the\n * visible text; a pre-formed {@link SelectableListItem} keeps its explicit key\n * verbatim.\n *\n * @param item - A string (keyed by its own value) or a `{ key, label }`\n * object (explicit key).\n *\n * @remarks The caller owns key uniqueness — appending a string equal to an\n * earlier string or explicit key produces a duplicate key, and `getValue` /\n * `setValue` resolve to the first matching row.\n *\n * @returns This component, for method chaining.\n */\n addItem(item: SelectableListItemSpec): this {\n this._items.push(\n typeof item === \"string\"\n ? { key: item, label: item }\n : { key: (item as SelectableListItem).key, label: (item as SelectableListItem).label, glyph: (item as SelectableListItem).glyph, tooltip: (item as SelectableListItem).tooltip },\n );\n\n this.pauseLayout();\n this.syncRows();\n this.resumeLayout();\n\n return this;\n }\n\n /**\n * Binds this list to a store. Records are pulled via `displayField` /\n * `valueField` whenever the store fires `load` / `add` / `remove` /\n * `datachange` / `sync`. Re-binding to a new store de-registers the\n * previous handlers first.\n *\n * @param store - The store to bind to.\n * @param displayField - The record field whose value becomes the row label.\n * @param valueField - Optional. The record field used as the row key;\n * defaults to the record's primary key when omitted.\n * @param glyphField - Optional. The record field whose value becomes each\n * item's `glyph` (read by the glyph renderer); omitted leaves items\n * glyph-less.\n * @param tooltipField - Optional. The record field whose value becomes each\n * item's hover `tooltip`; omitted leaves items tooltip-less.\n *\n * @returns This component, for method chaining.\n */\n setStore(store: AbstractStore, displayField: string, valueField?: string, glyphField?: string, tooltipField?: string): this {\n const oldStore = this._options.store;\n\n if (this._storeRefresh && oldStore) {\n (['load', 'add', 'remove', 'datachange', 'sync'] as const)\n .forEach(e => oldStore.off(e, this._storeRefresh!));\n }\n\n this._options.store = store;\n this._options.displayField = displayField;\n this._options.valueField = valueField;\n this._options.glyphField = glyphField;\n this._options.tooltipField = tooltipField;\n\n const refresh = (): void => this.refreshFromStore();\n this._storeRefresh = refresh;\n\n store.on('load', refresh);\n store.on('add', refresh);\n store.on('remove', refresh);\n store.on('datachange', refresh);\n store.on('sync', refresh);\n\n this.refreshFromStore();\n\n return this;\n }\n\n /**\n * Returns the currently bound store, or `null` when none is set.\n *\n * @returns The bound store, or `null`.\n */\n getStore(): AbstractStore | null {\n return this._options.store ?? null;\n }\n\n /**\n * Replaces the renderer factory. Every existing pool row swaps to a fresh\n * renderer from the new factory and the pool is re-synced so each renderer\n * rebinds to its item before the next layout. New rows built afterwards use\n * the new factory too.\n *\n * @param factory - Zero-argument factory producing a renderer per row.\n *\n * @returns This component, for method chaining.\n */\n setRendererFactory(factory: () => ListItemRenderer): this {\n this._rendererFactory = factory;\n\n for (const row of this._rowPool) {\n row.setRenderer(factory());\n }\n\n this.pauseLayout();\n this.syncRows();\n this.resumeLayout();\n\n return this;\n }\n\n /**\n * Returns the renderer factory currently in use.\n *\n * @returns The zero-argument renderer factory.\n */\n getRendererFactory(): () => ListItemRenderer {\n return this._rendererFactory;\n }\n\n /**\n * Returns the store record corresponding to the most recent\n * single-selection anchor — matches the prior `<select>`-backed\n * behaviour where `getSelectedRecord()` returned the active option's\n * record. For {@link MultiSelectList} consumers wanting the full set\n * of selected records, use [`getSelectedRecords`](/api/component/list/classes/MultiSelectList#getselectedrecords).\n *\n * @returns The selected [`ModelRecord`](/api/data/classes/ModelRecord), or `undefined` when no\n * store is bound or nothing is selected.\n */\n getSelectedRecord(): ModelRecord | undefined {\n const store = this._options.store;\n\n if (!store) {\n return undefined;\n }\n\n const idx = this.getSelectedIndex();\n\n if (idx < 0) {\n return undefined;\n }\n\n return store.getRecords()[idx];\n }\n\n /**\n * Returns the index of the most recent single-selection anchor, or\n * `-1` when nothing is selected.\n *\n * @returns The anchor index.\n */\n getSelectedIndex(): number {\n if (this._anchorIndex !== null && this._selectedSet.has(this._anchorIndex)) {\n return this._anchorIndex;\n }\n\n if (this._selectedSet.size === 0) {\n return -1;\n }\n\n // Fallback when the anchor is gone (e.g. after a programmatic\n // setValues that bypassed the click reducer): return the lowest\n // selected index so the contract stays single-valued.\n return Math.min(...this._selectedSet);\n }\n\n /**\n * Sets the single-selection anchor. The selection set becomes\n * exactly `{idx}` (or empty for `idx < 0`); `_focusedIndex` follows.\n * Optionally fires the `change` event so binding listeners run.\n *\n * @param idx - The zero-based index to select, or a negative value\n * to clear the selection.\n * @param fireEvent - When `true` (default), fires the `change` event\n * after updating; pass `false` for programmatic writes.\n *\n * @returns This component, for method chaining.\n */\n setSelectedIndex(idx: number, fireEvent: boolean = true): this {\n this._selectedSet.clear();\n\n if (idx >= 0 && idx < this._items.length) {\n this._selectedSet.add(idx);\n this._anchorIndex = idx;\n this._focusedIndex = idx;\n } else {\n this._anchorIndex = null;\n this._focusedIndex = -1;\n }\n\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n\n if (fireEvent) {\n this.fireChange();\n }\n\n return this;\n }\n\n /**\n * Registers a listener for one of this list's events. `\"action\"` is a\n * typed semantic shorthand over {@link Event.addListener} for the DOM\n * change event — fired only on user-driven (click / keyboard) selection\n * changes, never on programmatic `setValue` / `setValues`, matching the\n * prior native `<select>`-backed semantics. `\"change\"` and `\"binding\"`\n * are the inherited {@link AbstractInput} listener-bag events.\n *\n * `\"contextmenu\"` fires when a row is right-clicked, with the row index and\n * the raw {@link MouseEvent} (the native menu is suppressed); `\"dblclick\"`\n * fires on a row double-click with the same payload. Both carry the row\n * index directly, so hosts need not walk the row DOM to resolve it.\n *\n * @param event - The event name.\n * @param listener - The callback to invoke when the event fires.\n *\n * @returns This component, for method chaining.\n */\n on(event: \"action\", listener: Event.Listener): this;\n on(event: \"change\", listener: (value: TValue) => void): this;\n on(event: \"binding\", listener: () => void): this;\n on(event: \"contextmenu\", listener: (index: number, event: MouseEvent) => void): this;\n on(event: \"dblclick\", listener: (index: number, event: MouseEvent) => void): this;\n on(event: \"action\" | \"change\" | \"binding\" | \"contextmenu\" | \"dblclick\", listener: Function): this {\n if (event === \"action\") {\n Event.addListener(this, \"change\", listener as Event.Listener);\n\n return this;\n }\n\n if (event === \"contextmenu\" || event === \"dblclick\") {\n this._rowListeners.add(event, listener);\n\n return this;\n }\n\n return super.on(event as \"change\", listener as (value: TValue) => void);\n }\n\n /**\n * Removes a previously registered listener. The exact callback\n * reference must match the one passed to {@link on}.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The callback to remove.\n *\n * @returns This component, for method chaining.\n */\n off(event: \"action\" | \"change\" | \"binding\" | \"contextmenu\" | \"dblclick\", listener: Function): this {\n if (event === \"action\") {\n Event.removeListener(this, \"change\", listener as Event.Listener);\n\n return this;\n }\n\n if (event === \"contextmenu\" || event === \"dblclick\") {\n this._rowListeners.remove(event, listener);\n\n return this;\n }\n\n return super.off(event as \"change\" | \"binding\", listener);\n }\n\n /**\n * Subclass hook: translate a click or keyboard gesture at `idx` into\n * a new selection set. The modifier-key flags are normalised so the\n * same reducer runs for mouse and keyboard origins.\n *\n * @param idx - The row index targeted by the gesture.\n * @param ev - Normalised modifier flags. `ctrl` covers both Ctrl and\n * Cmd (macOS).\n */\n protected abstract reduceSelection(idx: number, ev: { ctrl: boolean, shift: boolean }): void;\n\n /**\n * Subclass hook used by user-driven gestures: encode the current\n * selection set into the subclass's `TValue` shape and fire change /\n * binding listeners. Called from the click and keyboard reducers\n * after {@link reduceSelection} mutates the selection set.\n */\n protected abstract notifyUserChange(): void;\n\n /**\n * Rebuilds `_items` from the bound store's current records. Preserves\n * the previously-selected key when possible — if the key still maps\n * to an item, the selection survives; otherwise the selection is\n * cleared and the focus collapses to row 0 (matching the native\n * `<select>` refresh behaviour the prior `List` inherited).\n */\n protected refreshFromStore(): void {\n const store = this._options.store;\n const displayField = this._options.displayField;\n const valueField = this._options.valueField;\n const glyphField = this._options.glyphField;\n const tooltipField = this._options.tooltipField;\n\n if (!store || !displayField) {\n return;\n }\n\n // Remember the active selection key so we can re-locate it in\n // the new item set; survives partial reorderings / additions.\n const previousAnchorKey = this._anchorIndex !== null && this._items[this._anchorIndex]\n ? this._items[this._anchorIndex].key\n : null;\n\n this._items = [];\n this._selectedSet.clear();\n this._anchorIndex = null;\n\n const records = store.getRecords();\n let restoredAnchor = -1;\n\n for (let i = 0; i < records.length; i++) {\n const record = records[i];\n const label = String(record.get(displayField));\n const key = valueField\n ? String(record.get(valueField))\n : String(record.getId());\n const glyph = glyphField ? String(record.get(glyphField)) : undefined;\n const tooltip = tooltipField ? String(record.get(tooltipField)) : undefined;\n\n this._items.push({ key, label, glyph, tooltip });\n\n if (previousAnchorKey !== null && key === previousAnchorKey) {\n restoredAnchor = i;\n }\n }\n\n if (restoredAnchor >= 0) {\n this._selectedSet.add(restoredAnchor);\n this._anchorIndex = restoredAnchor;\n this._focusedIndex = restoredAnchor;\n } else {\n this._focusedIndex = this._items.length > 0 ? 0 : -1;\n }\n\n this.pauseLayout();\n this.syncRows();\n this.resumeLayout();\n this.updateActiveDescendant();\n }\n\n /**\n * Reconciles the row pool with `_items`. Overlapping rows have their\n * label, index, selected, and focused state updated; surplus items\n * spawn new rows; surplus rows are removed.\n */\n protected syncRows(): void {\n const newLen = this._items.length;\n const oldLen = this._rowPool.length;\n const overlap = Math.min(newLen, oldLen);\n\n for (let i = 0; i < overlap; i++) {\n const row = this._rowPool[i];\n row.updateItem(this._items[i], i);\n row.setIndex(i);\n row.setSelected(this._selectedSet.has(i));\n row.setFocused(i === this._focusedIndex);\n }\n\n if (newLen > oldLen) {\n for (let i = oldLen; i < newLen; i++) {\n const row = new SelectableListRow(\n {\n onClick: (idx, e) => this.handleRowClick(idx, e),\n onContextMenu: (idx, e) => this.handleRowContextMenu(idx, e),\n onDblClick: (idx, e) => this.handleRowDblClick(idx, e),\n },\n i,\n this._rendererFactory,\n );\n row.updateItem(this._items[i], i);\n row.setSelected(this._selectedSet.has(i));\n row.setFocused(i === this._focusedIndex);\n this._innerPanel.addComponent(row);\n this._rowPool.push(row);\n }\n } else if (newLen < oldLen) {\n for (let i = newLen; i < oldLen; i++) {\n // Drop the row's tooltip attachment (a static id-keyed map) before\n // discarding the row, so a shrinking pool doesn't leak entries.\n Tooltip.detach(this._rowPool[i]);\n this._innerPanel.removeComponent(this._rowPool[i]);\n }\n this._rowPool.splice(newLen);\n }\n\n // Toggle the empty-state placeholder against the new item count. Runs\n // after the row reconciliation, so on a 0→N transition the rows are in\n // place before the placeholder is dropped (and on N→0, dropped rows are\n // gone before the placeholder attaches). syncRows runs inside a paused\n // layout, so the transient coexistence never renders.\n this.syncEmptyPlaceholder();\n }\n\n /**\n * Pushes the cached selection / focus state into every pool row.\n * Called after a selection mutation (click / keyboard reducer or\n * programmatic write) so the visible chrome catches up without a\n * full `syncRows` reconciliation.\n */\n protected refreshRowVisualState(): void {\n for (let i = 0; i < this._rowPool.length; i++) {\n const row = this._rowPool[i];\n row.setSelected(this._selectedSet.has(i));\n row.setFocused(i === this._focusedIndex);\n }\n }\n\n /**\n * Mirrors `_focusedIndex` onto `aria-activedescendant` so assistive\n * tech tracks the keyboard-focus row. Clears the attribute when no\n * row holds focus. Points at the row's framework-generated id — the\n * Event system already keys listeners off that id, so rewriting the\n * DOM id to a synthetic value (e.g. `ListRow-N`) would break row\n * click / pointerdown delivery.\n */\n protected updateActiveDescendant(): void {\n if (this._focusedIndex < 0 || this._focusedIndex >= this._rowPool.length) {\n this.getAria().setActiveDescendant(\"\");\n\n return;\n }\n\n this.getAria().setActiveDescendant(this._rowPool[this._focusedIndex].getId());\n }\n\n /**\n * Fires the `change` event so `on(\"change\", fn)` subscribers and\n * `notifyChange`-fed bindings run. Subclasses route their own\n * `notifyUserChange` through this after the reducer commits.\n */\n protected fireChange(): void {\n const element = this.getElement();\n\n if (element) {\n Event.fireEvent(this, \"change\");\n }\n\n this.notifyChange(this.getValue());\n }\n\n /**\n * Handles a click on a pool row: dispatches the gesture through the\n * subclass's {@link reduceSelection}, syncs the visible chrome, and\n * fires user-change notifications. The list root takes focus on\n * click (rows are not focusable) so subsequent keyboard navigation\n * starts from the clicked row.\n *\n * @param idx - The row index that was clicked.\n * @param e - The original mouse event — modifier-key flags drive the\n * reducer's multi-select branch.\n */\n protected handleRowClick(idx: number, e: MouseEvent): void {\n if (!this.isEnabled() || this.isReadOnly()) {\n return;\n }\n\n if (idx < 0 || idx >= this._items.length) {\n return;\n }\n\n this.reduceSelection(idx, { ctrl: e.ctrlKey || e.metaKey, shift: e.shiftKey });\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n\n if (this._focusOnRowClick) {\n // Pull DOM focus back to the list root so subsequent keystrokes\n // route through `handleKeyDown` — rows themselves are not\n // focusable, only the listbox surface is. Suppressed when the\n // list is hosted by a focus-managing parent (e.g. the\n // ComboBox dropdown) so a programmatic focus shift can't\n // tear down a wrapping cell editor's input.\n this.focus();\n }\n\n this.notifyUserChange();\n }\n\n /**\n * Handles a right-click on a pool row: suppresses the browser's native\n * context menu and fires the `\"contextmenu\"` event with the row index and\n * the raw event. Deliberately does not change the selection — a host that\n * wants the right-clicked row highlighted calls {@link setSelectedIndex}\n * from its listener (mirrors [`Tree`](/api/component/tree/classes/Tree)'s\n * contextmenu contract). Out-of-range indices are ignored.\n *\n * @param idx - The row index that was right-clicked.\n * @param e - The original contextmenu event.\n */\n protected handleRowContextMenu(idx: number, e: MouseEvent): void {\n if (idx < 0 || idx >= this._items.length) {\n return;\n }\n\n e.preventDefault();\n this._rowListeners.fire(\"contextmenu\", idx, e);\n }\n\n /**\n * Handles a double-click on a pool row: fires the `\"dblclick\"` event with\n * the row index and the raw event. The first click of the pair already ran\n * through {@link handleRowClick} and set the selection, so this only layers\n * an activation signal on top. Out-of-range indices are ignored.\n *\n * @param idx - The row index that was double-clicked.\n * @param e - The original dblclick event.\n */\n protected handleRowDblClick(idx: number, e: MouseEvent): void {\n if (idx < 0 || idx >= this._items.length) {\n return;\n }\n\n this._rowListeners.fire(\"dblclick\", idx, e);\n }\n\n /**\n * Toggles whether a row-click gesture pulls DOM focus to the list\n * root after the commit. Hosts that own their own focus surface\n * (the ComboBox dropdown is the canonical example) call\n * `setFocusOnRowClick(false)` so the embedded list never steals\n * focus from a wrapping input or cell editor.\n *\n * @param value - `false` to suppress the focus call.\n *\n * @returns This component, for method chaining.\n */\n setFocusOnRowClick(value: boolean): this {\n this._focusOnRowClick = value;\n\n return this;\n }\n\n /**\n * Toggles whether keyboard navigation (ArrowUp/Down/Home/End/PageUp/Down)\n * commits the focused row as the selection. When `false`, the focus\n * highlight moves but the selection set is untouched and the `change`\n * event does not fire. Enter / Space / click still commit. The\n * [`AutoCompleteField`](/api/component/input/classes/AutoCompleteField)\n * dropdown sets this to `false` so ArrowUp/Down previews a row\n * without writing it into the host TextField.\n *\n * @param value - `false` to disable the selection-follows-focus\n * coupling on keyboard navigation.\n *\n * @returns This component, for method chaining.\n */\n setSelectFollowsFocus(value: boolean): this {\n this._selectFollowsFocus = value;\n\n return this;\n }\n\n /**\n * Returns the current keyboard-focus index, or `-1` when no row\n * holds focus.\n *\n * @returns The zero-based focus index, or `-1`.\n */\n getFocusedIndex(): number {\n return this._focusedIndex;\n }\n\n /**\n * Returns the framework-generated DOM element id of the keyboard-focus\n * row, suitable for writing into a host input's `aria-activedescendant`.\n * Returns `null` when no row holds focus or the focused row hasn't\n * been instantiated in the pool yet (rows materialise lazily as the\n * pool reconciles against the item array).\n *\n * @returns The focused row's element id, or `null`.\n */\n getFocusedRowId(): string | null {\n if (this._focusedIndex < 0 || this._focusedIndex >= this._rowPool.length) {\n return null;\n }\n\n return this._rowPool[this._focusedIndex].getId();\n }\n\n /**\n * Public entry point used by hosts that keep DOM focus on their own\n * surface while embedding this list (e.g. the [`ComboBox`](/api/component/input/classes/ComboBox)\n * dropdown forwarding keystrokes from the ComboBox surface).\n * Returns `true` when the list consumed the key — the caller\n * should then `e.preventDefault()` and stop further processing.\n * Escape is intentionally NOT consumed here so the host can use\n * it to close the wrapping overlay; the list-focused entry point\n * (the protected `handleKeyDown` registered as the list's own\n * `keydown` listener) still handles Escape inline.\n *\n * @param e - The keyboard event captured by the host.\n *\n * @returns `true` when the list consumed the key.\n */\n handleKey(e: KeyboardEvent): boolean {\n if (!this.isEnabled() || this.isReadOnly()) {\n return false;\n }\n\n if (this._items.length === 0) {\n return false;\n }\n\n if (e.key === \"Escape\") {\n return false;\n }\n\n const ctrl = e.ctrlKey || e.metaKey;\n\n if (this.handleNavigationKey(e, ctrl)) {\n return true;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n this.commitFocusedRow(ctrl, e.shiftKey);\n\n return true;\n }\n\n if (!ctrl && !e.altKey && e.key.length === 1) {\n this.handleTypeAhead(e.key);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Handles keydown on the list root: ArrowUp/Down/Home/End move the\n * focus index, PageUp/Down move by visible-row count, Enter/Space\n * commits the focused row, Ctrl+A in subclasses extends to select\n * all (handled in {@link MultiSelectList}), Escape clears the\n * type-ahead buffer, and printable characters feed the type-ahead\n * search.\n *\n * @param e - The keyboard event.\n */\n protected handleKeyDown(e: KeyboardEvent): Event.ListenerResult {\n if (!this.isEnabled() || this.isReadOnly()) {\n return;\n }\n\n if (this._items.length === 0) {\n return;\n }\n\n const ctrl = e.ctrlKey || e.metaKey;\n\n if (e.key === \"Escape\") {\n this._typeAheadBuf = \"\";\n\n return;\n }\n\n if (this.handleNavigationKey(e, ctrl)) {\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n this.commitFocusedRow(ctrl, e.shiftKey);\n\n return { prevent: true };\n }\n\n // Printable single-character key — feed the type-ahead buffer.\n // `key.length === 1` filters out named keys (`\"Tab\"`, `\"Shift\"`,\n // `\"ArrowDown\"`, …) without an explicit allow-list.\n if (!ctrl && !e.altKey && e.key.length === 1) {\n this.handleTypeAhead(e.key);\n }\n }\n\n /**\n * Subset of `handleKeyDown` that processes the arrow / Home / End /\n * Page-* navigation keys. Returns `true` when a key was handled so\n * the caller can skip the remaining branches.\n *\n * @param e - The keyboard event.\n * @param ctrl - Pre-computed Ctrl-or-Cmd flag.\n *\n * @returns `true` when the key was handled.\n */\n protected handleNavigationKey(e: KeyboardEvent, ctrl: boolean): boolean {\n const navigable = new Set([\n \"ArrowDown\", \"ArrowUp\", \"Home\", \"End\", \"PageDown\", \"PageUp\",\n ]);\n\n if (!navigable.has(e.key)) {\n return false;\n }\n\n e.preventDefault();\n\n const viewportH = this.getHeight() || ROW_HEIGHT_PX;\n const pageSize = Math.max(1, Math.floor(viewportH / ROW_HEIGHT_PX));\n const curr = this._focusedIndex < 0 ? 0 : this._focusedIndex;\n let next: number;\n\n if (e.key === \"ArrowDown\") {\n next = Math.min(curr + 1, this._items.length - 1);\n } else if (e.key === \"ArrowUp\") {\n next = Math.max(curr - 1, 0);\n } else if (e.key === \"PageDown\") {\n next = Math.min(curr + pageSize, this._items.length - 1);\n } else if (e.key === \"PageUp\") {\n next = Math.max(curr - pageSize, 0);\n } else if (e.key === \"Home\") {\n next = 0;\n } else {\n next = this._items.length - 1;\n }\n\n this.moveFocus(next, ctrl, e.shiftKey);\n\n return true;\n }\n\n /**\n * Moves the keyboard focus to `idx`. By default the move also runs\n * the subclass's {@link reduceSelection} so single-select lists track\n * the focus highlight; pass `ctrl: true` to move the focus without\n * touching the selection (the standard \"browse without committing\"\n * gesture). `shift: true` forwards the range-extend hint to the\n * reducer. When the list-wide {@link setSelectFollowsFocus} flag is\n * `false`, the commit branch is suppressed entirely — the focus\n * highlight moves but the selection set is untouched and\n * `notifyUserChange` does not fire.\n *\n * @param idx - The new focus index.\n * @param ctrl - When `true`, skip the selection update.\n * @param shift - When `true`, ask the reducer to extend the\n * selection from `_anchorIndex` to `idx`.\n */\n protected moveFocus(idx: number, ctrl: boolean, shift: boolean): void {\n this._focusedIndex = idx;\n\n const commit = !ctrl && this._selectFollowsFocus;\n\n if (commit) {\n this.reduceSelection(idx, { ctrl: false, shift });\n }\n\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n this.scrollIndexIntoView(idx);\n\n if (commit) {\n this.notifyUserChange();\n }\n }\n\n /**\n * Commits the focused row through {@link reduceSelection}. Mirrors\n * the gesture of clicking that row with the same modifier keys.\n *\n * @param ctrl - Ctrl-or-Cmd modifier flag at the time of the keypress.\n * @param shift - Shift modifier flag at the time of the keypress.\n */\n protected commitFocusedRow(ctrl: boolean, shift: boolean): void {\n if (this._focusedIndex < 0) {\n return;\n }\n\n this.reduceSelection(this._focusedIndex, { ctrl, shift });\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n this.notifyUserChange();\n }\n\n /**\n * Appends `ch` to the type-ahead buffer (after timing out the\n * previous buffer when more than {@link TYPE_AHEAD_TIMEOUT_MS}\n * elapsed since the last key) and jumps the focus to the first item\n * whose lower-cased label starts with the buffer.\n *\n * @param ch - The character key pressed.\n */\n protected handleTypeAhead(ch: string): void {\n const now = Date.now();\n\n if (now - this._typeAheadAt > TYPE_AHEAD_TIMEOUT_MS) {\n this._typeAheadBuf = \"\";\n }\n\n this._typeAheadBuf += ch.toLowerCase();\n this._typeAheadAt = now;\n\n const buf = this._typeAheadBuf;\n const idx = this._items.findIndex(item => item.label.toLowerCase().startsWith(buf));\n\n if (idx < 0) {\n return;\n }\n\n // Type-ahead moves only the focus highlight; selection is\n // unaffected (same behaviour as the native `<select>` it\n // replaces — typing a letter previews the row without\n // committing).\n this._focusedIndex = idx;\n this.refreshRowVisualState();\n this.updateActiveDescendant();\n this.scrollIndexIntoView(idx);\n }\n\n /**\n * Scrolls the inner panel so the row at `idx` is fully visible, with\n * no movement when it already is. Reads / writes the panel's native\n * `scrollTop` directly — the framework's typed scroll setter only\n * lives on the `VirtualScroller`-backed components (`Table.Body`,\n * `Tree`); the `Panel`-with-`autoScroll: \"y\"` surface relies on\n * native browser overflow and exposes no setter.\n *\n * @param idx - The row index to scroll into view.\n */\n protected scrollIndexIntoView(idx: number): void {\n if (idx < 0 || idx >= this._items.length) {\n return;\n }\n\n const panelEl = this._innerPanel.getElement();\n\n if (!panelEl) {\n return;\n }\n\n const metrics = DOM.source.getScrollMetrics(panelEl);\n const top = idx * ROW_HEIGHT_PX;\n const bottom = top + ROW_HEIGHT_PX;\n const scrollTop = metrics.scrollTop;\n const visibleBottom = scrollTop + metrics.clientHeight;\n\n if (top < scrollTop) {\n DOM.sink.apply(panelEl, { scrollTop: top });\n } else if (bottom > visibleBottom) {\n DOM.sink.apply(panelEl, { scrollTop: bottom - metrics.clientHeight });\n }\n }\n}\n\nexport { AbstractSelectableList, SelectableListRow };\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { AbstractSelectableList, AbstractSelectableListOptions, SelectableListItem } from \"~/component/list/AbstractSelectableList.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link List}.\n *\n * @category Components\n */\nexport interface ListOptions extends AbstractSelectableListOptions {\n selectedIndex?: number;\n value?: string;\n selectedItem?: string;\n}\n\n/**\n * A scrollable single-selection list box.\n *\n * Rendered as a `<div role=\"listbox\">` populated with `<div role=\"option\">`\n * rows. Implements [`Bindable<string>`](/api/core/interfaces/Bindable) so it can be plugged into a\n * [`Binding`](/api/core/classes/Binding) directly. Keyboard model mirrors the WAI-ARIA listbox\n * pattern: ArrowUp/Down moves and selects, Home/End jump to the\n * extremes, PageUp/Down jump by viewport-row count, Enter / Space\n * commits the focused row, and printable characters drive a 700ms\n * type-ahead search.\n *\n * @category Components\n */\nclass List extends AbstractSelectableList<string, ListOptions> {\n\n /**\n * @param options - Optional. Construction-time options applied to\n * the list.\n */\n constructor(options?: ListOptions) {\n super(options);\n\n // Late-built state: `selectedIndex` / `value` / `selectedItem`\n // were written pure to `_options` by the super-time cascade.\n // Dispatch them now that the row pool and selection set exist\n // (`super()` already populated `_items` from `items` / `store`,\n // and applied `enabled` / `readOnly`).\n if (this._options.selectedIndex !== undefined) {\n this.setSelectedIndex(this._options.selectedIndex, false);\n }\n\n if (this._options.value !== undefined) {\n this.setValue(this._options.value);\n }\n\n if (this._options.selectedItem !== undefined) {\n this.setValue(this._options.selectedItem);\n }\n }\n\n /**\n * Applies a {@link ListOptions} bag. Single-select state fields are\n * written pure into `_options` here and dispatched from the constructor\n * body after the row pool is built.\n *\n * @param options - The options bag carrying the values to apply.\n *\n * @returns This component, for method chaining.\n */\n protected applyOptions(options: ListOptions): this {\n super.applyOptions(options);\n\n if (options.selectedIndex !== undefined) this._options.selectedIndex = options.selectedIndex;\n if (options.value !== undefined) this._options.value = options.value;\n if (options.selectedItem !== undefined) this._options.selectedItem = options.selectedItem;\n\n return this;\n }\n\n /**\n * Pushes pre-formed {@link SelectableListItem} pairs into the list,\n * bypassing the auto-keying that {@link setItems} applies to a\n * label-only array. Intended for hosts that already own typed\n * `{key, label}` data (e.g. the [`ComboBox`](/api/component/input/classes/ComboBox)\n * dropdown forwarding its item array). Selection and focus are\n * reset; the row pool is reconciled against the new length.\n *\n * @param items - The pre-formed item pairs, in display order.\n *\n * @returns This component, for method chaining.\n */\n setItemsArray(items: Array<SelectableListItem>): this {\n return super.setItemsArray(items);\n }\n\n /**\n * Selects the row whose `key` matches `value`. No-op when the value\n * doesn't appear in the current item set — same behaviour the prior\n * native `<select>` had when assigned an unknown `value`.\n *\n * @param value - The row key to select.\n *\n * @returns This component, for method chaining.\n */\n setValue(value: string): this {\n const idx = this._items.findIndex(item => item.key === value);\n\n this.setSelectedIndex(idx, false);\n\n return this;\n }\n\n /**\n * Returns the key of the currently selected row.\n *\n * @returns The selected row's key, or an empty string when nothing\n * is selected.\n */\n getValue(): string {\n const idx = this.getSelectedIndex();\n\n if (idx < 0 || idx >= this._items.length) {\n return \"\";\n }\n\n return this._items[idx].key;\n }\n\n /**\n * Reduces a click / keyboard gesture into the single-select shape:\n * the modifier keys are ignored, the selection becomes exactly\n * `{idx}`, and the anchor / focus collapse to the clicked row.\n *\n * @param idx - The row index the gesture targeted.\n * @param _ev - Ignored; single-select doesn't branch on modifier keys.\n */\n protected reduceSelection(idx: number, _ev: { ctrl: boolean, shift: boolean }): void {\n this._selectedSet.clear();\n this._selectedSet.add(idx);\n this._anchorIndex = idx;\n this._focusedIndex = idx;\n }\n\n /**\n * User-driven selection commit. Mirrors the prior native `<select>`\n * `change` event semantics — fired from the click / keyboard\n * reducers, not from programmatic `setValue` / `setSelectedIndex(idx,\n * false)`.\n */\n protected notifyUserChange(): void {\n this.fireChange();\n }\n\n}\n\nconst ListCallable = callable(List);\ntype ListCallable = List;\nexport {\n List as _List,\n ListCallable as List,\n};\n"],"mappings":"ocAgCA,IAAsB,iBAAtB,cAA+C,CAAU,CAErD,aAAc,CACV,MAAM,CACV,CA+BA,iBAA0B,CACtB,MAAO,EACX,CAsBJ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B,EACrB,KAAK,cAAgB,CACzB,CAQA,kBAAmC,CAC/B,KAAK,WAAW,CACpB,CAEJ,EAEM,EAAe,EAAS,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Position-BwtxouxK.js","names":[],"sources":["../../src/typescript/lib/core/Util.ts","../../src/typescript/lib/core/BaseObject.ts","../../src/typescript/lib/primitive/Size.ts","../../src/typescript/lib/primitive/Border.ts","../../src/typescript/lib/primitive/Insets.ts","../../src/typescript/lib/primitive/Position.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Size } from \"~/primitive/Size.js\";\nimport type { Insets } from \"~/primitive/Insets.js\";\nimport { DOM } from \"~/core/DOM.js\";\n\n/**\n * Font options for off-screen text measurement.\n * All properties default to the active theme variables when omitted.\n */\nexport interface TextMeasureOptions {\n fontFamily?: string;\n fontSize? : string;\n fontWeight?: string;\n fontStyle? : string;\n fontVariant?: string;\n fontStretch?: string;\n lineHeight?: string\n /**\n * When set, the probe wraps at this pixel width (using `pre-wrap`) instead of\n * measuring on a single `nowrap` line. The returned `height` then reflects the\n * wrapped, multi-line box. Omit to measure the natural single-line size.\n */\n maxWidth?: number;\n}\n\n/**\n * Result of an off-screen text measurement that also reports the typographic baseline.\n *\n * @remarks `baseline` is the offset from the top of the measured box to the font baseline,\n * in pixels — analogous to CSS `vertical-align: baseline` on an inline-block element.\n */\nexport interface TextMetrics {\n width: number;\n height: number;\n baseline: number;\n}\n\n/**\n * General-purpose utility functions for DOM interaction and browser environment queries.\n *\n * @category Util\n */\nexport namespace Util {\n\n // Cached text-metric results, invalidated together on theme change via\n // `invalidateTextMetricsCache`. `-1` is the \"not yet measured\" sentinel\n // (a real padding / font size / baseline / offset is always >= 0).\n let linePaddingCache: number = -1;\n let rootFontSizeCache: number = -1;\n let textBaselineCache: number = -1;\n let opticalOffsetCache: number = -1;\n\n // Generation counter bumped by `invalidateTextMetricsCache`, so a caller\n // (e.g. `Text.needsMeasure`) can tell whether its last measurement\n // predates the active theme without holding its own subscription.\n let metricsGeneration = 0;\n\n // Resolved bound-font-size results, keyed by `cssVar + \"|\" + cssRule`, so\n // every `Text` bound to the same CSS var/rule pair shares one resolution\n // per theme change instead of each instance re-probing the cascade.\n const boundFontSizeCache = new Map<string, number | null>();\n\n /**\n * Measures the rendered size of a text string using an off-screen probe `<span>`.\n *\n * @param text - The string to measure.\n * @param options - Font properties to apply. Defaults to the active theme variables.\n * @returns The measured `{width, height}` in pixels, ceiled to whole pixels.\n */\n export function measureTextSize(text: string, options: TextMeasureOptions = {}): Size {\n const metrics = DOM.source.measureText(text, options);\n\n return { width: metrics.width, height: metrics.height };\n }\n\n /**\n * Returns the rendered pixel width of a text string.\n *\n * @param text - The string to measure.\n * @param options - Font properties to apply. Defaults to the active theme variables.\n * @returns The measured width in pixels, ceiled to a whole pixel.\n */\n export function measureTextWidth(text: string, options?: TextMeasureOptions): number {\n return measureTextSize(text, options).width;\n }\n\n /**\n * Measures many strings under one font in a single document reflow,\n * instead of one reflow per string.\n *\n * @param texts - The strings to measure.\n * @param options - Font properties to apply. Defaults to the active theme variables.\n * @returns One width per input, in input order.\n */\n export function measureTextWidths(texts: string[], options?: TextMeasureOptions): number[] {\n return DOM.source.measureTextWidths(texts, options);\n }\n\n /**\n * Returns the active theme's leading (`--ts-ui-line-padding`) in pixels.\n *\n * @returns The integer-pixel value of `--ts-ui-line-padding`, or `4` as a\n * fallback when the variable is missing or unparseable.\n */\n function linePaddingPx(): number {\n if (linePaddingCache >= 0) {\n return linePaddingCache;\n }\n\n const raw = DOM.source.getThemeVar(\"--ts-ui-line-padding\");\n const parsed = parseFloat(raw);\n\n // 2 mirrors the `--ts-ui-line-padding` default shipped by every theme\n // (see ModernTheme/DarkTheme/ClassicTheme `font.linePadding: '2px'`);\n // it only applies when the var is absent (e.g. pre-theme-apply probe).\n linePaddingCache = isNaN(parsed) ? 2 : parsed;\n\n return linePaddingCache;\n }\n\n /**\n * Returns the document root font size (`--ts-ui-font-size`) in pixels, the\n * default font size for a control that doesn't override it.\n *\n * @returns The integer-pixel root font size, or `14` as a fallback.\n */\n function rootFontSizePx(): number {\n if (rootFontSizeCache >= 0) {\n return rootFontSizeCache;\n }\n\n const raw = DOM.source.getThemeVar(\"--ts-ui-font-size\");\n const parsed = parseFloat(raw);\n\n rootFontSizeCache = isNaN(parsed) ? 14 : parsed;\n\n return rootFontSizeCache;\n }\n\n /**\n * Returns a vertical text metric in integer pixels: a control's font size,\n * plus the theme leading (`--ts-ui-line-padding`) by default.\n *\n * @param options - Measurement options.\n * @param options.fontSizePx - The control's font size in pixels. Omit to use\n * the document root font size (`--ts-ui-font-size`), which is what the\n * native `<input>`-backed controls render at.\n * @param options.linePadding - Controls the leading added to the font size:\n * `true` (the default) adds the theme `--ts-ui-line-padding`, giving the\n * full rendered line box (matching the `calc(1em + …)` line-height controls\n * render at); `false` adds nothing, returning the bare font size to size a\n * box from its font without leading; a number adds that exact pixel padding.\n * @returns `round(fontSize + leading)`, where leading is the theme padding,\n * `0`, or the given number.\n *\n * @remarks With the default leading the line box scales with font size, so\n * 12px and 14px text get proportionate line boxes from the one token. Text\n * components, table rows, and the baseline computation use the default so\n * their measurement matches the rendered line box; the native input box\n * heights pass `false` so the box hugs the font size plus their own chrome.\n * The padding and root font size are cached; call\n * {@link invalidateTextMetricsCache} after a theme change to force a\n * re-read.\n */\n export function lineHeightPx(options: { fontSizePx?: number, linePadding?: boolean | number } = {}): number {\n let fs = options.fontSizePx ?? rootFontSizePx();\n\n const linePadding = options.linePadding ?? true;\n\n if (linePadding === true) {\n fs += linePaddingPx();\n } else if (typeof linePadding === \"number\") {\n fs += linePadding;\n }\n\n return Math.round(fs);\n }\n\n /**\n * Returns the content-relative text baseline for the unified line-height\n * model: the offset from the top of the `lineHeightPx()` line box to the\n * font baseline.\n *\n * @returns The baseline offset in pixels, rounded to the nearest integer.\n *\n * @remarks Computed from the canvas 2D `measureText` font metrics rather\n * than a DOM probe, so it is deterministic and UA-independent. A CSS line\n * box centres the font's ascent+descent within `line-height`; this\n * reproduces that centring with the known px line box —\n * `round(lineGap / 2 + ascent)` where `lineGap = lineHeightPx - (ascent +\n * descent)` — so the measured baseline matches where the browser paints the\n * glyph in both a native `<input>` and a `Text`/`Label`. `fontBoundingBox*`\n * (font-intrinsic, string-independent) is used in preference to\n * `actualBoundingBox*` (glyph-ink specific) so the baseline does not shift\n * per measured string; `\"X\"` is passed only to satisfy `measureText`. The\n * result is cached; call {@link invalidateTextMetricsCache} after a theme\n * change to force re-measurement.\n */\n export function measureTextBaseline(): number {\n if (textBaselineCache >= 0) {\n return textBaselineCache;\n }\n\n const m = DOM.source.measureFontMetrics();\n const gap = lineHeightPx() - (m.ascent + m.descent);\n\n textBaselineCache = Math.round(gap / 2 + m.ascent);\n\n return textBaselineCache;\n }\n\n /**\n * Returns the pixel height of a single-line input box: the theme line-box\n * height ({@link lineHeightPx}) plus the component's own vertical chrome\n * (insets + optional padding + border).\n *\n * @param insets - The component's layout insets (top/bottom read).\n * @param padding - The component's CSS padding, or `null` when it has none.\n * @param border - The component's border widths (top/bottom read).\n * @returns The single-line box height in pixels.\n *\n * @remarks Factors out the `chrome = insets + padding + border; h =\n * lineHeightPx() + chrome` idiom shared by every single-line native-input\n * box height (`TextField` / `PasswordField` / `ComboBox` / the picker fields\n * / `NumberSpinner`). Only the vertical (top/bottom) edges contribute; the\n * horizontal edges are the caller's width concern. `NumberSpinner` uniquely\n * passes its *inner input's* padding rather than its own.\n */\n export function singleLineBoxHeight(\n insets: Insets,\n padding: Insets | null,\n border: { top: number; bottom: number },\n ): number {\n const chrome = insets.getTop() + insets.getBottom()\n + (padding ? padding.getTop() + padding.getBottom() : 0)\n + border.top + border.bottom;\n\n return lineHeightPx() + chrome;\n }\n\n /**\n * Returns the downward pixel offset that moves a single line of text from\n * its line-box (geometric) centre to its optical (cap-height) centre.\n *\n * @returns The downward offset in pixels (`>= 0`), rounded to the nearest\n * integer.\n *\n * @remarks A label's visible glyphs occupy cap-top→baseline; the descender\n * band below the baseline is empty ink, so the ink's visual centre sits\n * above the font box's geometric centre and a geometrically-centred label\n * reads as too high. This returns roughly half the unused descender space —\n * `round(boxMid - inkMid)` where `boxMid = (ascent - descent) / 2` and\n * `inkMid = capTop / 2` with `capTop = actualBoundingBoxAscent` (the cap-top\n * ink of `\"X\"`) — so a consumer ([`Button`](/api/component/button/classes/Button))\n * can nudge single-line text down onto its true optical centre. Derived\n * from the same cached canvas\n * metrics as {@link measureTextBaseline}; cached and invalidated together\n * via {@link invalidateTextMetricsCache}.\n */\n export function opticalCenterOffset(): number {\n if (opticalOffsetCache >= 0) {\n return opticalOffsetCache;\n }\n\n const m = DOM.source.measureFontMetrics();\n const boxMid = (m.ascent - m.descent) / 2;\n const inkMid = m.capTop / 2;\n\n opticalOffsetCache = Math.max(0, Math.round(boxMid - inkMid));\n\n return opticalOffsetCache;\n }\n\n /**\n * Returns the generation counter for the cached text metrics, bumped once\n * every time {@link invalidateTextMetricsCache} runs.\n *\n * @returns The current generation number.\n *\n * @remarks Lets a caller that measured against a past generation (stashed\n * from a prior read of this function) tell, cheaply and without holding\n * its own theme subscription, whether a re-measure is due — the pattern\n * `Text` uses instead of subscribing to `ThemeManager` per instance.\n */\n export function textMetricsGeneration(): number {\n return metricsGeneration;\n }\n\n /**\n * Resolves a CSS custom property bound to a control's font size to a\n * pixel number, caching the result per `cssVar`/`cssRule` pair so every\n * control bound to the same token shares one resolution per theme change.\n *\n * @param cssVar - The CSS custom property name (e.g. `\"--ts-ui-font-size\"`).\n * @param cssRule - The CSS value the control's `font-size` rule is set to\n * (e.g. `\"var(--ts-ui-font-size, 14px)\"`), used as the fallback probe\n * when `cssVar`'s raw value isn't a bare, parseable pixel number (a\n * `calc(...)`-valued relative token). Pass `null` when the control has\n * no rule text of its own; the probe then falls back to `var(${cssVar})`.\n * @returns The resolved pixel size.\n *\n * @remarks Mirrors the theme-var-then-probe strategy every other cached\n * metric in this namespace uses: a simple var parses straight off its raw\n * string; a `calc(...)`-valued token falls back to\n * {@link DOMSource.resolveFontSizePx}, a cascade-evaluating probe. Cleared\n * together with the rest of the text metrics by\n * {@link invalidateTextMetricsCache}.\n */\n export function boundFontSizePx(cssVar: string, cssRule: string | null): number | null {\n const key = cssVar + \"|\" + (cssRule ?? \"\");\n const cached = boundFontSizeCache.get(key);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const raw = parseFloat(DOM.source.getThemeVar(cssVar));\n const resolved = isNaN(raw)\n ? DOM.source.resolveFontSizePx(cssRule ?? `var(${cssVar})`)\n : raw;\n\n boundFontSizeCache.set(key, resolved);\n\n return resolved;\n }\n\n /**\n * Discards every cached text metric (line box, baseline, optical offset,\n * bound font sizes) so the next read re-measures against the active theme\n * font.\n *\n * @remarks Call this whenever the active theme's font size, family, or\n * line-height changes, since the cached values reflect the font in use at\n * the time of the first measurement and would otherwise mis-align controls\n * against each other after a theme swap.\n */\n export function invalidateTextMetricsCache(): void {\n linePaddingCache = -1;\n rootFontSizeCache = -1;\n textBaselineCache = -1;\n opticalOffsetCache = -1;\n boundFontSizeCache.clear();\n metricsGeneration++;\n }\n\n /**\n * Generates a UUID string, ensuring the first character is never a digit.\n *\n * @returns A UUID v4 string with a guaranteed non-numeric first character.\n *\n * @remarks If the standard UUID generation produces a leading digit, it is replaced\n * with the letter \"a\" so the result is safe to use as a DOM id or CSS identifier.\n */\n export function generateUUID() {\n let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n let r = Math.random() * 16 | 0,\n v = c == 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n\n let first = parseInt(uuid[0]);\n if (Util.isInteger(first)) {\n uuid = \"a\" + uuid.substring(1, uuid.length);\n }\n\n return uuid;\n }\n\n /**\n * Returns true if value is an integer.\n *\n * @param value - The value to test.\n *\n * @returns `true` if `value` is an integer, `false` otherwise.\n */\n export function isInteger(value: Object) {\n return Number.isInteger(value);\n }\n\n /**\n * Clamps a number into an inclusive `[min, max]` range.\n *\n * @param value - The number to clamp.\n * @param min - The lower bound.\n * @param max - The upper bound.\n *\n * @returns `value` when it lies within the range, otherwise the nearer bound.\n *\n * @remarks Assumes `min <= max` (the framework's `min <= preferred <= max`\n * size invariant). When `min > max` the maximum wins (`clamp(v, 10, 0) === 0`)\n * — the low-first `Math.min(Math.max(...))` tie-break; callers must not rely\n * on it. `NaN` propagates (a `NaN` input returns `NaN`), matching the inlined\n * `Math.min`/`Math.max` expressions this replaces.\n */\n export function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n }\n\n /**\n * Converts a hyphen-separated identifier (e.g. `\"border-top-width\"`) to its\n * camelCase equivalent (`\"borderTopWidth\"`). Useful for translating\n * CSS-style kebab-case property names into the camelCase form expected by\n * `CSSStyleDeclaration` bracket-indexed assignment.\n *\n * @param value - The kebab-case input string.\n * @returns The camelCase equivalent.\n */\n export function kebabToCamel(value: string): string {\n return value.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n }\n\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Util } from \"~/core/Util.js\"\n\n/**\n * Base class for all library objects.\n * Automatically assigns a unique identifier on construction.\n *\n * @category Core\n */\nexport class BaseObject {\n\n private _id: string;\n\n constructor() {\n this._id = Util.generateUUID();\n }\n\n /**\n * Returns the unique identifier for this object.\n *\n * @returns The UUID string assigned at construction time.\n */\n getId() {\n return this._id;\n }\n\n /**\n * Sets the unique identifier for this object.\n *\n * @param id - The new identifier string to assign.\n */\n setId(id: string) : this {\n this._id = id;\n\n return this;\n }\n\n /**\n * Returns the runtime class name of this object.\n *\n * @returns The name of the constructor function as a string.\n */\n getClassName() {\n return this.constructor.name;\n }\n};\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n/**\n * Represents a two-dimensional size with width and height in pixels.\n *\n * @category Util\n */\nexport interface Size {\n width: number,\n height: number\n}\n\n/**\n * The sentinel extent meaning \"no upper bound\" on a size axis.\n *\n * @category Util\n */\nexport const UNBOUNDED: number = Number.MAX_SAFE_INTEGER;\n\n/**\n * True when an extent is at or above the unbounded sentinel (recognises the\n * legacy `Number.MAX_VALUE` too).\n *\n * @param n - The extent to test.\n * @returns `true` when `n` is at or above {@link UNBOUNDED}.\n *\n * @category Util\n */\nexport function isUnbounded(n: number): boolean {\n return n >= Number.MAX_SAFE_INTEGER;\n}\n\n/**\n * Caps an extent at the unbounded sentinel so an unbounded sum cannot overflow\n * it.\n *\n * @param n - The extent to cap.\n * @returns `n`, capped at {@link UNBOUNDED}.\n *\n * @category Util\n */\nexport function saturate(n: number): number {\n return Math.min(n, UNBOUNDED);\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n/**\n * A border specification built from complete CSS border strings.\n * `border` is the all-sides fallback; each per-side field overrides it for\n * that side. An unspecified side falls back to `border`, then to `\"none\"`.\n *\n * @category Util\n */\nexport interface BorderOptions {\n /** CSS `border` shorthand applied to all four sides (e.g. `\"1px solid rgb(...)\"`, `\"none\"`, `\"var(--x)\"`). */\n border?: string;\n /** CSS `border-top` value; overrides `border` for the top side. */\n borderTop?: string;\n /** CSS `border-right` value; overrides `border` for the right side. */\n borderRight?: string;\n /** CSS `border-bottom` value; overrides `border` for the bottom side. */\n borderBottom?: string;\n /** CSS `border-left` value; overrides `border` for the left side. */\n borderLeft?: string;\n}\n\n/**\n * Expands a {@link BorderOptions} into the four camelCase longhand style keys\n * (`borderTop`/`borderRight`/`borderBottom`/`borderLeft`) that `StyleRule.setMany`\n * consumes. Each side resolves via `side ?? border ?? \"none\"`, so a pure-longhand\n * map replays deterministically regardless of what else touched the rule.\n *\n * @param border - The border specification to expand.\n *\n * @returns A map of the four longhand keys to their resolved CSS values.\n *\n * @category Util\n */\nexport function borderToStyle(border: BorderOptions): Record<string, string | null> {\n const all = border.border ?? \"none\";\n\n return {\n borderTop: border.borderTop ?? all,\n borderRight: border.borderRight ?? all,\n borderBottom: border.borderBottom ?? all,\n borderLeft: border.borderLeft ?? all,\n };\n}\n\n/**\n * Best-effort leading-`<n>px` width of one side's CSS value. Returns `0` for\n * `undefined`, `none`, `0`, `var(...)`, or any non-`px` leading token. Used both\n * to parse the always-`<n>px` values `getComputedStyle` returns (authoritative,\n * post-render) and to estimate a width from a spec string before an element exists.\n *\n * @param value - A single side's CSS border value, or `undefined`.\n *\n * @returns The leading pixel width, or `0` when none can be parsed.\n *\n * @category Util\n */\nexport function borderSideWidth(value: string | undefined): number {\n if (!value) {\n return 0;\n }\n\n const match = value.trim().match(/^([\\d.]+)px\\b/i);\n\n return match ? parseFloat(match[1]) : 0;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { BaseObject } from \"~/core/BaseObject.js\";\n\n/**\n * Represents the four directional inset (padding/margin) values for a rectangular area.\n * All values are expressed in pixels.\n *\n * @example\n * ```typescript\n * import { Insets } from '@jimka/typescript-ui/primitive';\n*\n * component.setInsets(new Insets(8, 12, 8, 12)); // top, right, bottom, left\n * ```\n *\n * @category Util\n */\nexport class Insets extends BaseObject {\n\n private _top: number;\n private _right: number;\n private _bottom: number;\n private _left: number;\n\n /**\n * @param top - Top inset in pixels.\n * @param right - Right inset in pixels.\n * @param bottom - Bottom inset in pixels.\n * @param left - Left inset in pixels.\n */\n constructor(top: number, right: number, bottom: number, left: number) {\n super();\n\n this._top = top || 0;\n this._right = right || 0;\n this._bottom = bottom || 0;\n this._left = left || 0;\n }\n\n /**\n * Returns the top inset in pixels.\n *\n * @returns The top inset value, defaulting to `0` if unset.\n */\n getTop() {\n return this._top || 0;\n }\n\n /**\n * Sets the top inset in pixels.\n *\n * @param value - The new top inset value in pixels.\n */\n setTop(value: number) : this {\n this._top = value;\n\n return this;\n }\n\n /**\n * Returns the right inset in pixels.\n *\n * @returns The right inset value, defaulting to `0` if unset.\n */\n getRight() {\n return this._right || 0;\n }\n\n /**\n * Sets the right inset in pixels.\n *\n * @param value - The new right inset value in pixels.\n */\n setRight(value: number) : this {\n this._right = value;\n\n return this;\n }\n\n /**\n * Returns the bottom inset in pixels.\n *\n * @returns The bottom inset value, defaulting to `0` if unset.\n */\n getBottom() {\n return this._bottom || 0;\n }\n\n /**\n * Sets the bottom inset in pixels.\n *\n * @param value - The new bottom inset value in pixels.\n */\n setBottom(value: number) : this {\n this._bottom = value;\n\n return this;\n }\n\n /**\n * Returns the left inset in pixels.\n *\n * @returns The left inset value, defaulting to `0` if unset.\n */\n getLeft() {\n return this._left || 0;\n }\n\n /**\n * Sets the left inset in pixels.\n *\n * @param value - The new left inset value in pixels.\n */\n setLeft(value: number) : this {\n this._left = value;\n\n return this;\n }\n\n /**\n * Sets all four inset values at once.\n *\n * @param top - Top inset in pixels.\n * @param right - Right inset in pixels.\n * @param bottom - Bottom inset in pixels.\n * @param left - Left inset in pixels.\n */\n set(top: number, right: number, bottom: number, left: number) : this {\n this._top = top;\n this._right = right;\n this._bottom = bottom;\n this._left = left;\n\n return this;\n }\n\n /**\n * Returns the insets as a CSS shorthand string (e.g. `\"4px 4px 4px 4px\"`).\n *\n * @returns A CSS margin/padding shorthand string with all four sides in top-right-bottom-left order.\n */\n render() {\n return this.getTop() + \"px \" + this.getRight() + \"px \" + this.getBottom() + \"px \" + this.getLeft() + \"px\";\n }\n};\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n/**\n * CSS `position` values used by the framework.\n *\n * The framework positions every component absolutely (see\n * [ARCHITECTURE.md](/ARCHITECTURE.md) §Positioning). Only three values\n * are exposed:\n *\n * - `ABSOLUTE` — the universal default for every framework component.\n * - `FIXED` — the documented exception for floating overlays that anchor to\n * the viewport (`AnimatedDropdown`, `Popover`, `Notification`, `Dialog`,\n * `DialogBackdrop`). Set internally by these subclasses; never by callers.\n * - `STATIC` — the documented exception for an HTML element whose native\n * semantics require in-flow rendering (currently only `Legend`, which needs\n * the notch in its parent `<fieldset>`'s border).\n *\n * Other CSS values (`relative`, `sticky`, `initial`, `inherit`) are\n * intentionally **not** members. Application code does not call\n * `setPosition` — that setter is `protected` on `Component`.\n *\n * @category Util\n */\nexport enum Position {\n STATIC = \"static\",\n FIXED = \"fixed\",\n ABSOLUTE = \"absolute\",\n}\n"],"mappings":"sCA2CO,IAAU,GAAV,SAAA,EAAA,CAKH,IAAI,EAA2B,GAC3B,EAA4B,GAC5B,EAA4B,GAC5B,EAA6B,GAK7B,EAAoB,EAKlB,EAAqB,IAAI,IASxB,SAAS,gBAAgB,EAAc,EAA8B,CAAC,EAAS,CAClF,IAAM,EAAU,EAAI,OAAO,YAAY,EAAM,CAAO,EAEpD,MAAO,CAAE,MAAO,EAAQ,MAAO,OAAQ,EAAQ,MAAO,CAC1D,mCASO,SAAS,iBAAiB,EAAc,EAAsC,CACjF,OAAO,gBAAgB,EAAM,CAAO,CAAC,CAAC,KAC1C,qCAUO,SAAS,kBAAkB,EAAiB,EAAwC,CACvF,OAAO,EAAI,OAAO,kBAAkB,EAAO,CAAO,CACtD,uCAQA,SAAS,eAAwB,CAC7B,GAAI,GAAoB,EACpB,OAAO,EAGX,IAAM,EAAS,EAAI,OAAO,YAAY,sBAAsB,EACtD,EAAS,WAAW,CAAG,EAO7B,MAFA,GAAmB,MAAM,CAAM,EAAI,EAAI,EAEhC,CACX,CAQA,SAAS,gBAAyB,CAC9B,GAAI,GAAqB,EACrB,OAAO,EAGX,IAAM,EAAS,EAAI,OAAO,YAAY,mBAAmB,EACnD,EAAS,WAAW,CAAG,EAI7B,MAFA,GAAoB,MAAM,CAAM,EAAI,GAAK,EAElC,CACX,CA2BO,SAAS,aAAa,EAAmE,CAAC,EAAW,CACxG,IAAI,EAAK,EAAQ,YAAc,eAAe,EAExC,EAAc,EAAQ,aAAe,GAQ3C,OANI,IAAgB,GAChB,GAAM,cAAc,EACb,OAAO,GAAgB,WAC9B,GAAM,GAGH,KAAK,MAAM,CAAE,CACxB,6BAsBO,SAAS,qBAA8B,CAC1C,GAAI,GAAqB,EACrB,OAAO,EAGX,IAAM,E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O,GAAO,EACnB,KAAK,OAAS,GAAS,EACvB,KAAK,QAAU,GAAU,EACzB,KAAK,MAAQ,GAAQ,CACzB,CAOA,QAAS,CACL,OAAO,KAAK,MAAQ,CACxB,CAOA,OAAO,EAAsB,CAGzB,MAFA,MAAK,KAAO,EAEL,IACX,CAOA,UAAW,CACP,OAAO,KAAK,QAAU,CAC1B,CAOA,SAAS,EAAsB,CAG3B,MAFA,MAAK,OAAS,EAEP,IACX,CAOA,WAAY,CACR,OAAO,KAAK,SAAW,CAC3B,CAOA,UAAU,EAAsB,CAG5B,MAFA,MAAK,QAAU,EAER,IACX,CAOA,SAAU,CACN,OAAO,KAAK,OAAS,CACzB,CAOA,QAAQ,EAAsB,CAG1B,MAFA,MAAK,MAAQ,EAEN,IACX,CAUA,IAAI,EAAa,EAAe,EAAgB,EAAqB,CAMjE,MALA,MAAK,KAAO,EACZ,KAAK,OAAS,EACd,KAAK,QAAU,EACf,KAAK,MAAQ,EAEN,IACX,CAOA,QAAS,CACL,OAAO,KAAK,OAAO,EAAI,MAAQ,KAAK,SAAS,EAAI,MAAQ,KAAK,UAAU,EAAI,MAAQ,KAAK,QAAQ,EAAI,IACzG,CACJ,ECzHY,EAAL,SAAA,EAAA,OACH,GAAA,OAAA,SACA,EAAA,MAAA,QACA,EAAA,SAAA,YACJ,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{S as e,h as t,t as n,v as r}from"./Component-B0ShfPVi.js";import{t as i}from"./Glyph-_VeBacS2.js";import{n as a}from"./Checkbox-D0JYK-wc.js";import{r as o}from"./VBox-DfJPWXqc.js";import{circle as s}from"./glyphs/solid/circle.es.js";i.register(s);var c={outline:`none`},RadioButton=class extends a{_ring;_dot;constructor(t,a,s){super({...a??{}},{...c,...s??{}}),this.setLayoutManager(new o),this._ring=new n,this._ring.setPreferredSize({width:16,height:16}),this._ring.setMinSize({width:16,height:16}),this._ring.setMaxSize({width:16,height:16}),this._ring.setSize({width:16,height:16}),this._ring.setBackgroundColor(`var(--ts-ui-radio-bg, var(--ts-ui-form-bg, rgb(255, 255, 255)))`),this._ring.setBorder(`1px solid var(--ts-ui-form-border, rgb(160, 160, 160))`),this._ring.setBorderRadius(`50%`),this._ring.setCursor(`pointer`),this._dot=new i(`circle`),this._dot.setForegroundColor(`var(--ts-ui-radio-dot-color, rgb(255, 255, 255))`),this._dot.setPreferredSize({width:8,height:8}),this._dot.setMaxSize({width:8,height:8}),this._dot.setX(3),this._dot.setY(3),this._dot.setOpacity(0),this._dot.setPointerEvents(`none`),r.isReducedMotion()||(this._dot.setTransition(`opacity 120ms ease-out`),this._ring.setTransition(`background-color 120ms ease-out, border-color 120ms ease-out`)),this._ring.addComponent(this._dot),super.addComponent(this._ring),this.getAria().setRole(`radio`),this.getAria().setTabIndex(0),this.getAria().setChecked(!1),e.addListener(this._ring,`click`,()=>this.activateFromPointer()),this.installKeyboard(),this._options.label===void 0&&this._options.text===void 0&&t!==void 0?this._options.label=t:this._options.label===void 0&&this._options.text!==void 0&&(this._options.label=this._options.text),this._options.value!==void 0&&this._options.selected===void 0&&(this._options.selected=this._options.value),this._options.selected!==void 0&&this.applySelected(this._options.selected),this._options.label!==void 0&&this.applyLabel(this._options.label),this._options.enabled!==void 0&&this.applyEnabled(this._options.enabled),this._options.readOnly!==void 0&&this.applyReadOnly(this._options.readOnly)}applyOptions(e){return super.applyOptions(e),e.selected!==void 0&&(this._options.selected=e.selected),e.value!==void 0&&(this._options.value=e.value),e.label!==void 0&&(this._options.label=e.label),e.text!==void 0&&(this._options.text=e.text),e.radioName!==void 0&&(this._options.radioName=e.radioName),e.enabled!==void 0&&(this._options.enabled=e.enabled),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}activate(){this.isSelected()||(this.setSelected(!0),e.fireEvent(this,`change`))}getInteractiveSurface(){return this._ring}isSelected(){return this._options.selected??!1}setSelected(e){let t=!!e;return t===this.isSelected()?this:(this._options.selected=t,this.applySelected(t),this.notifyChange(t),this)}getValue(){return this.isSelected()}setValue(e){return this.setSelected(e)}setRadioName(e){return this._options.radioName=e,this}clearRadioName(){return this._options.radioName=void 0,this}getRadioName(){return this._options.radioName??null}on(t,n){return t===`action`?(e.addListener(this,`change`,n),this):super.on(t,n)}off(t,n){return t===`action`?(e.removeListener(this,`change`,n),this):super.off(t,n)}applySelected(e){this.getAria().setChecked(e),this._ring.setBackgroundColor(e?`var(--ts-ui-radio-bg-selected, rgb(30, 100, 200))`:`var(--ts-ui-radio-bg, var(--ts-ui-form-bg, rgb(255, 255, 255)))`),this._ring.setBorder(e?`1px solid var(--ts-ui-radio-bg-selected, rgb(30, 100, 200))`:`1px solid var(--ts-ui-form-border, rgb(160, 160, 160))`),this._dot.setOpacity(+!!e)}},l=t(RadioButton);export{l as t};
|
|
2
|
-
//# sourceMappingURL=RadioButton-BEwpqg1k.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButton-BEwpqg1k.js","names":[],"sources":["../../src/typescript/lib/component/input/RadioButton.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Animation } from \"~/core/Animation.js\";\nimport { AbstractBooleanInput, AbstractBooleanInputOptions } from \"~/component/input/AbstractBooleanInput.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { Event } from \"~/core/Event.js\";\nimport { Glyph } from \"~/component/display/Glyph.js\";\nimport { HBox } from \"~/layout/HBox.js\";\nimport { callable } from \"~/core/Callable.js\";\nimport { circle } from \"~/glyphs/solid/circle.js\";\n\n// Idempotent registration: makes the `\"circle\"` glyph available for the dot\n// regardless of which control imports first.\nGlyph.register(circle);\n\n/**\n * Construction-time options for {@link RadioButton}.\n *\n * @category Components\n */\nexport interface RadioButtonOptions extends AbstractBooleanInputOptions {\n selected?: boolean;\n value?: boolean;\n text?: string;\n radioName?: string;\n /**\n * Construction-time listener bag — the declarative form of `on()`. Adds the\n * radio button's `action` shorthand to the inherited `change` / `binding`.\n */\n listeners?: {\n action?: () => void;\n change?: (value: boolean) => void;\n binding?: () => void;\n };\n}\n\nconst _defaultRadioButtonOptions: Partial<RadioButtonOptions> = {\n outline: \"none\",\n};\n\n/**\n * A custom-drawn radio button rendered as a focusable `<div>` with\n * `role=\"radio\"`. The ring + dot is drawn with framework primitives; the\n * native `<input type=\"radio\">` is intentionally not used. Group selection\n * is coordinated by [`ButtonGroup`](/api/overlay/classes/ButtonGroup); keyboard\n * navigation within a group is provided by\n * [`RovingTabIndex`](/api/core/classes/RovingTabIndex).\n *\n * @category Components\n */\nclass RadioButton<TOptions extends RadioButtonOptions = RadioButtonOptions>\n extends AbstractBooleanInput<TOptions>\n{\n private _ring: Component;\n private _dot: Glyph;\n\n /**\n * Constructs a RadioButton.\n *\n * @param text - Optional label text. Equivalent to `options.label`; kept\n * positional for back-compat with consumers that wrote\n * `new RadioButton(\"Hello\")`.\n * @param options - Optional construction-time options bag.\n * @param subclassDefaults - Per-subclass default bag layered over this\n * class's defaults; subclasses forward their `_defaultXxxOptions`\n * constant here.\n */\n constructor(text?: string, options?: RadioButtonOptions, subclassDefaults?: Partial<RadioButtonOptions>);\n constructor(text?: string, options?: TOptions, subclassDefaults?: Partial<TOptions>) {\n super(\n { ...(options ?? {}) } as TOptions,\n { ..._defaultRadioButtonOptions, ...(subclassDefaults ?? {}) } as Partial<TOptions>,\n );\n\n this.setLayoutManager(new HBox());\n\n this._ring = new Component();\n this._ring.setPreferredSize({ width: 16, height: 16 });\n // Min = preferred = max so the outer HBox shrink-on-overallocation\n // can't collapse the ring graphic when the radio is packed into a\n // tight container with siblings that have flexible widths.\n this._ring.setMinSize({ width: 16, height: 16 });\n this._ring.setMaxSize({ width: 16, height: 16 });\n this._ring.setSize({ width: 16, height: 16 });\n this._ring.setBackgroundColor(\"var(--ts-ui-radio-bg, var(--ts-ui-form-bg, rgb(255, 255, 255)))\");\n this._ring.setBorder(\"1px solid var(--ts-ui-form-border, rgb(160, 160, 160))\");\n this._ring.setBorderRadius(\"50%\");\n // The ring owns the click + cursor surface so the pointer/click area\n // matches the visible graphic exactly. The root stays inert (default\n // cursor, no click listener), so clicks on a label or in any\n // stretched empty space don't select and don't show the pointer cursor.\n this._ring.setCursor(\"pointer\");\n\n this._dot = new Glyph(\"circle\");\n this._dot.setForegroundColor(\"var(--ts-ui-radio-dot-color, rgb(255, 255, 255))\");\n this._dot.setPreferredSize({ width: 8, height: 8 });\n this._dot.setMaxSize({ width: 8, height: 8 });\n this._dot.setX(3);\n this._dot.setY(3);\n this._dot.setOpacity(0);\n // Pass-through so clicks on the dot still hit the ring underneath.\n this._dot.setPointerEvents(\"none\");\n\n if (!Animation.isReducedMotion()) {\n this._dot.setTransition(\"opacity 120ms ease-out\");\n this._ring.setTransition(\"background-color 120ms ease-out, border-color 120ms ease-out\");\n }\n\n this._ring.addComponent(this._dot);\n super.addComponent(this._ring);\n\n this.getAria().setRole(\"radio\");\n this.getAria().setTabIndex(0);\n this.getAria().setChecked(false);\n\n // The ring owns the user-select click so the pointer/click + cursor\n // surface is exactly the visible 16 × 16 graphic — clicks on a label or\n // in any stretched empty area pass through to the root, which has no\n // listener of its own. This pointer line stays per-subclass (a closure\n // over the widget `this`) because a listener registered on the child\n // ring would otherwise bind `this` to the ring; only the keyboard path,\n // registered on the root, moves into the base.\n Event.addListener(this._ring, \"click\", () => this.activateFromPointer());\n this.installKeyboard();\n\n // The positional `text` arg wins only when `options.label` (or\n // `options.text`) was not provided.\n if (this._options.label === undefined && this._options.text === undefined && text !== undefined) {\n this._options.label = text;\n } else if (this._options.label === undefined && this._options.text !== undefined) {\n this._options.label = this._options.text;\n }\n\n if (this._options.value !== undefined && this._options.selected === undefined) {\n this._options.selected = this._options.value;\n }\n\n if (this._options.selected !== undefined) {\n this.applySelected(this._options.selected);\n }\n\n if (this._options.label !== undefined) {\n this.applyLabel(this._options.label);\n }\n\n if (this._options.enabled !== undefined) {\n this.applyEnabled(this._options.enabled);\n }\n\n if (this._options.readOnly !== undefined) {\n this.applyReadOnly(this._options.readOnly);\n }\n }\n\n /**\n * Applies a {@link RadioButtonOptions} bag. Inherited Component fields\n * cascade through `super.applyOptions`; radio-button-specific fields are\n * stored pure on `_options` so the constructor body can dispatch them\n * after children are built.\n *\n * @param options - The options bag carrying the values to apply.\n *\n * @returns This component, for method chaining.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n if (options.selected !== undefined) this._options.selected = options.selected;\n if (options.value !== undefined) this._options.value = options.value;\n if (options.label !== undefined) this._options.label = options.label;\n if (options.text !== undefined) this._options.text = options.text;\n if (options.radioName !== undefined) this._options.radioName = options.radioName;\n if (options.enabled !== undefined) this._options.enabled = options.enabled;\n if (options.readOnly !== undefined) this._options.readOnly = options.readOnly;\n\n return this;\n }\n\n /**\n * Activates the radio button from a click or key: radio buttons can only be\n * selected, never directly deselected by the user (the `ButtonGroup`\n * deselects siblings on change), so this selects and fires the DOM `change`\n * only on a real off→on transition. The enabled/read-only guard is applied\n * by the base before this runs.\n */\n protected activate(): void {\n if (!this.isSelected()) {\n this.setSelected(true);\n Event.fireEvent(this, \"change\");\n }\n }\n\n /**\n * Returns the inner ring graphic — the click + cursor surface.\n *\n * @returns The ring component.\n */\n protected getInteractiveSurface(): Component {\n return this._ring;\n }\n\n /**\n * Returns whether the radio button is currently selected.\n *\n * @returns `true` when selected.\n */\n isSelected(): boolean {\n return this._options.selected ?? false;\n }\n\n /**\n * Sets the selected state and updates the visual + ARIA cache. Used both\n * by user-driven selection and by `ButtonGroup` when it deselects\n * siblings.\n *\n * @param value - `true` to select, `false` to deselect.\n *\n * @returns This component, for method chaining.\n */\n setSelected(value: boolean): this {\n const next = !!value;\n if (next === this.isSelected()) {\n return this;\n }\n\n this._options.selected = next;\n this.applySelected(next);\n this.notifyChange(next);\n\n return this;\n }\n\n /**\n * Returns the current value (alias for {@link isSelected}, satisfies\n * [`Bindable`](/api/core/interfaces/Bindable)).\n *\n * @returns `true` when selected.\n */\n getValue(): boolean {\n return this.isSelected();\n }\n\n /**\n * Sets the value (alias for {@link setSelected}, satisfies [`Bindable`](/api/core/interfaces/Bindable)).\n *\n * @param value - The new selected state.\n *\n * @returns This component, for method chaining.\n */\n setValue(value: boolean): this {\n return this.setSelected(value);\n }\n\n /**\n * Back-compat shim that stores the supplied group name on `_options` but\n * does not emit a `name` attribute (the host element is no longer\n * `<input>`). Consumers that read the group name through\n * {@link getRadioName} keep working.\n *\n * @param name - Group name string.\n *\n * @returns This component, for method chaining.\n */\n setRadioName(name: string): this {\n this._options.radioName = name;\n\n return this;\n }\n\n /**\n * Clears the back-compat radio-name field.\n *\n * @returns This component, for method chaining.\n */\n clearRadioName(): this {\n this._options.radioName = undefined;\n\n return this;\n }\n\n /**\n * Returns the group name set via {@link setRadioName}, or `null`.\n *\n * @returns The group name string, or `null`.\n */\n getRadioName(): string | null {\n return this._options.radioName ?? null;\n }\n\n /**\n * Registers a listener for one of this radio button's events.\n * `\"action\"` is a typed semantic shorthand over {@link Event.addListener}\n * for the DOM change event — fired on user-driven selection and used by\n * [`ButtonGroup`](/api/overlay/classes/ButtonGroup) to enforce mutual\n * exclusivity. `\"change\"` and `\"binding\"` are the inherited\n * {@link AbstractInput} listener-bag events.\n *\n * @param event - The event name.\n * @param listener - The callback to invoke when the event fires.\n *\n * @returns This component, for method chaining.\n */\n on(event: \"action\", listener: Event.Listener): this;\n on(event: \"change\", listener: (value: boolean) => void): this;\n on(event: \"binding\", listener: () => void): this;\n on(event: \"action\" | \"change\" | \"binding\", listener: Function): this {\n if (event === \"action\") {\n Event.addListener(this, \"change\", listener as Event.Listener);\n\n return this;\n }\n\n return super.on(event as \"change\", listener as (value: boolean) => void);\n }\n\n /**\n * Removes a previously registered listener. The exact callback\n * reference must match the one passed to {@link on}.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The callback to remove.\n *\n * @returns This component, for method chaining.\n */\n off(event: \"action\" | \"change\" | \"binding\", listener: Function): this {\n if (event === \"action\") {\n Event.removeListener(this, \"change\", listener as Event.Listener);\n\n return this;\n }\n\n return super.off(event, listener);\n }\n\n /**\n * Updates the visual + ARIA state for the given selected flag.\n */\n private applySelected(selected: boolean): void {\n this.getAria().setChecked(selected);\n\n this._ring.setBackgroundColor(selected\n ? \"var(--ts-ui-radio-bg-selected, rgb(30, 100, 200))\"\n : \"var(--ts-ui-radio-bg, var(--ts-ui-form-bg, rgb(255, 255, 255)))\");\n this._ring.setBorder(selected\n ? \"1px solid var(--ts-ui-radio-bg-selected, rgb(30, 100, 200))\"\n : \"1px solid var(--ts-ui-form-border, rgb(160, 160, 160))\");\n\n this._dot.setOpacity(selected ? 1 : 0);\n }\n\n}\n\nconst RadioButtonCallable = callable(RadioButton);\ntype RadioButtonCallable<TOptions extends RadioButtonOptions = RadioButtonOptions> = RadioButton<TOptions>;\nexport {\n RadioButton as _RadioButton,\n RadioButtonCallable as RadioButton\n};\n"],"mappings":"gPAaA,EAAM,SAAS,CAAM,EAuBrB,IAAM,EAA0D,CAC5D,QAAS,MACb,EAYM,YAAN,cACY,CACZ,CACI,MACA,KAcA,YAAY,EAAe,EAAoB,EAAsC,CACjF,MACI,CAAE,GAAI,GAAW,CAAC,CAAG,EACrB,CAAE,GAAG,EAA4B,GAAI,GAAoB,CAAC,CAAG,CACjE,EAEA,KAAK,iBAAiB,IAAI,CAAM,EAEhC,KAAK,MAAQ,IAAI,EACjB,KAAK,MAAM,iBAAiB,CAAE,MAAO,GAAI,OAAQ,EAAG,CAAC,EAIrD,KAAK,MAAM,WAAW,CAAE,MAAO,GAAI,OAAQ,EAAG,CAAC,EAC/C,KAAK,MAAM,WAAW,CAAE,MAAO,GAAI,OAAQ,EAAG,CAAC,EAC/C,KAAK,MAAM,QAAQ,CAAE,MAAO,GAAI,OAAQ,EAAG,CAAC,EAC5C,KAAK,MAAM,mBAAmB,iEAAiE,EAC/F,KAAK,MAAM,UAAU,wDAAwD,EAC7E,KAAK,MAAM,gBAAgB,KAAK,EAKhC,KAAK,MAAM,UAAU,SAAS,EAE9B,KAAK,KAAO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