@jimka/typescript-ui 0.4.1 → 0.5.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/{AbstractBooleanInput-DE5NNJT0.js → AbstractBooleanInput-CbW7ZrDT.js} +2 -2
- package/dist/lib/{AbstractBooleanInput-DE5NNJT0.js.map → AbstractBooleanInput-CbW7ZrDT.js.map} +1 -1
- package/dist/lib/{AbstractInput-BxfrmD2W.js → AbstractInput-B10DfLOf.js} +2 -2
- package/dist/lib/{AbstractInput-BxfrmD2W.js.map → AbstractInput-B10DfLOf.js.map} +1 -1
- package/dist/lib/Anchor-BsblS5it.js +2 -0
- package/dist/lib/Anchor-BsblS5it.js.map +1 -0
- package/dist/lib/AnchorConstraints-Bfkt8019.js +2 -0
- package/dist/lib/AnchorConstraints-Bfkt8019.js.map +1 -0
- package/dist/lib/{AnimatedDropdown-QLNasu_Y.js → AnimatedDropdown-kL47HPGP.js} +2 -2
- package/dist/lib/{AnimatedDropdown-QLNasu_Y.js.map → AnimatedDropdown-kL47HPGP.js.map} +1 -1
- package/dist/lib/Border-CNS6aEXB.js +2 -0
- package/dist/lib/{Border-CKKUk5G9.js.map → Border-CNS6aEXB.js.map} +1 -1
- package/dist/lib/Button-T16zSZip.js +2 -0
- package/dist/lib/Button-T16zSZip.js.map +1 -0
- package/dist/lib/{Card-a4dzYrbX.js → Card-CD3jxshU.js} +2 -2
- package/dist/lib/{Card-a4dzYrbX.js.map → Card-CD3jxshU.js.map} +1 -1
- package/dist/lib/CodeEditor-BGlB232h.js +2 -0
- package/dist/lib/CodeEditor-BGlB232h.js.map +1 -0
- package/dist/lib/ComboBox-C9FYMuLv.js +2 -0
- package/dist/lib/ComboBox-C9FYMuLv.js.map +1 -0
- package/dist/lib/Component-w65rPK75.js +2 -0
- package/dist/lib/Component-w65rPK75.js.map +1 -0
- package/dist/lib/Container-C7RPLQEc.js +2 -0
- package/dist/lib/{Container-0bsG2Q8Z.js.map → Container-C7RPLQEc.js.map} +1 -1
- package/dist/lib/DOM-Ba8YRVel.js +2 -0
- package/dist/lib/{DOM-67StIm5G.js.map → DOM-Ba8YRVel.js.map} +1 -1
- package/dist/lib/DragManager-UvPHSoRm.js +2 -0
- package/dist/lib/{DragManager-DRor_-1x.js.map → DragManager-UvPHSoRm.js.map} +1 -1
- package/dist/lib/{FieldDecorator-Bpx8J8n9.js → FieldDecorator-HG65hEtk.js} +2 -2
- package/dist/lib/{FieldDecorator-Bpx8J8n9.js.map → FieldDecorator-HG65hEtk.js.map} +1 -1
- package/dist/lib/{Fit-CL1m1nIZ.js → Fit-Cg3dPyZg.js} +2 -2
- package/dist/lib/{Fit-CL1m1nIZ.js.map → Fit-Cg3dPyZg.js.map} +1 -1
- package/dist/lib/FloatingPanel-D5buuVrQ.js +2 -0
- package/dist/lib/FloatingPanel-D5buuVrQ.js.map +1 -0
- package/dist/lib/{Glyph-wN7bk7mg.js → Glyph-DeJF_zsR.js} +2 -2
- package/dist/lib/{Glyph-wN7bk7mg.js.map → Glyph-DeJF_zsR.js.map} +1 -1
- package/dist/lib/{Grid-DHHmaB-Y.js → Grid-BYBohJIA.js} +2 -2
- package/dist/lib/{Grid-DHHmaB-Y.js.map → Grid-BYBohJIA.js.map} +1 -1
- package/dist/lib/{GridConstraints-DVc1BmlP.js → GridConstraints-Bts284FI.js} +2 -2
- package/dist/lib/{GridConstraints-DVc1BmlP.js.map → GridConstraints-Bts284FI.js.map} +1 -1
- package/dist/lib/{Header-2hKwQo_u.js → Header-BIFJK9nR.js} +2 -2
- package/dist/lib/{Header-2hKwQo_u.js.map → Header-BIFJK9nR.js.map} +1 -1
- package/dist/lib/{IconText-DC7Xe34b.js → IconText-Dsb1xS-E.js} +2 -2
- package/dist/lib/{IconText-DC7Xe34b.js.map → IconText-Dsb1xS-E.js.map} +1 -1
- package/dist/lib/LanguageRegistry-CcVnbKuh.js +2 -0
- package/dist/lib/LanguageRegistry-CcVnbKuh.js.map +1 -0
- package/dist/lib/LayoutSerialization-ySzY1h2l.js +2 -0
- package/dist/lib/{LayoutSerialization-D5bBas4W.js.map → LayoutSerialization-ySzY1h2l.js.map} +1 -1
- package/dist/lib/LayoutSizes-DKDK1Cle.js +2 -0
- package/dist/lib/LayoutSizes-DKDK1Cle.js.map +1 -0
- package/dist/lib/List-BPd-IXZR.js +2 -0
- package/dist/lib/{List-CG4NvwuV.js.map → List-BPd-IXZR.js.map} +1 -1
- package/dist/lib/MemoryStore-BgP7-Uzn.js +2 -0
- package/dist/lib/{MemoryStore-DT6iWWco.js.map → MemoryStore-BgP7-Uzn.js.map} +1 -1
- package/dist/lib/Menu-C0roOCY7.js +2 -0
- package/dist/lib/Menu-C0roOCY7.js.map +1 -0
- package/dist/lib/{MenuButton-wy_0RskC.js → MenuButton-BR4KOFld.js} +2 -2
- package/dist/lib/{MenuButton-wy_0RskC.js.map → MenuButton-BR4KOFld.js.map} +1 -1
- package/dist/lib/Panel-CpNQTLNF.js +2 -0
- package/dist/lib/{Panel-Rd9zkNXx.js.map → Panel-CpNQTLNF.js.map} +1 -1
- package/dist/lib/{Position-Ck_KD4cR.js → Position-PBVBW1JS.js} +2 -2
- package/dist/lib/{Position-Ck_KD4cR.js.map → Position-PBVBW1JS.js.map} +1 -1
- package/dist/lib/{ProgressSpinner-yt-VXyCb.js → ProgressSpinner-lAsK26C-.js} +2 -2
- package/dist/lib/{ProgressSpinner-yt-VXyCb.js.map → ProgressSpinner-lAsK26C-.js.map} +1 -1
- package/dist/lib/RadioButton-CCcIaL54.js +2 -0
- package/dist/lib/RadioButton-CCcIaL54.js.map +1 -0
- package/dist/lib/{RovingTabIndex-DFJyoveq.js → RovingTabIndex-C2Vzq0IX.js} +2 -2
- package/dist/lib/{RovingTabIndex-DFJyoveq.js.map → RovingTabIndex-C2Vzq0IX.js.map} +1 -1
- package/dist/lib/Scrollbar-C3ZZyZ1e.js +2 -0
- package/dist/lib/Scrollbar-C3ZZyZ1e.js.map +1 -0
- package/dist/lib/Slider-DZ9drUxn.js +2 -0
- package/dist/lib/Slider-DZ9drUxn.js.map +1 -0
- package/dist/lib/{Spacer-qalSEJ5i.js → Spacer-SDhOMp2g.js} +2 -2
- package/dist/lib/{Spacer-qalSEJ5i.js.map → Spacer-SDhOMp2g.js.map} +1 -1
- package/dist/lib/TabButton-DNo4ZgV8.js +2 -0
- package/dist/lib/TabButton-DNo4ZgV8.js.map +1 -0
- package/dist/lib/Text-CdHf3B-1.js +2 -0
- package/dist/lib/Text-CdHf3B-1.js.map +1 -0
- package/dist/lib/{Tooltip-Dro4DOZs.js → Tooltip-B_UF5bXD.js} +2 -2
- package/dist/lib/{Tooltip-Dro4DOZs.js.map → Tooltip-B_UF5bXD.js.map} +1 -1
- package/dist/lib/Tree-C7qLbIYH.js +2 -0
- package/dist/lib/Tree-C7qLbIYH.js.map +1 -0
- package/dist/lib/VBox-32fxpkDl.js +2 -0
- package/dist/lib/VBox-32fxpkDl.js.map +1 -0
- package/dist/lib/{Validator-Du8PqS5i.js → Validator-Cjs1EU5Q.js} +2 -2
- package/dist/lib/{Validator-Du8PqS5i.js.map → Validator-Cjs1EU5Q.js.map} +1 -1
- package/dist/lib/{VirtualScroller-Bv4KXGKW.js → VirtualScroller-cvFNMS7U.js} +2 -2
- package/dist/lib/{VirtualScroller-Bv4KXGKW.js.map → VirtualScroller-cvFNMS7U.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/container.es.js.map +1 -1
- package/dist/lib/component/diagram.es.js +1 -1
- package/dist/lib/component/diagram.es.js.map +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 +3 -3
- 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/list.es.js.map +1 -1
- package/dist/lib/component/menubar.es.js +1 -1
- package/dist/lib/component/menubar.es.js.map +1 -1
- package/dist/lib/component/table.es.js +2 -2
- package/dist/lib/component/table.es.js.map +1 -1
- package/dist/lib/component/tree.es.js +1 -1
- package/dist/lib/component/tree.es.js.map +1 -1
- package/dist/lib/core.es.js +1 -1
- package/dist/lib/core.es.js.map +1 -1
- package/dist/lib/data.es.js +1 -1
- package/dist/lib/glyphs/solid/index.es.js +1 -1
- package/dist/lib/languages-Dl8qdL8a.js +2 -0
- package/dist/lib/languages-Dl8qdL8a.js.map +1 -0
- package/dist/lib/layout.es.js +1 -1
- package/dist/lib/layout.es.js.map +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/router.es.js.map +1 -1
- package/dist/lib/selectionsEqual-BrTxPMmK.js +2 -0
- package/dist/lib/{selectionsEqual-Ci3_uflt.js.map → selectionsEqual-BrTxPMmK.js.map} +1 -1
- package/dist/lib/types/component/button/TabButton.d.ts +1 -1
- package/dist/lib/types/component/button/ToggleButton.d.ts +1 -1
- package/dist/lib/types/component/chart/ChartLegend.d.ts +1 -1
- package/dist/lib/types/component/container/FloatingPanel.d.ts +23 -0
- package/dist/lib/types/component/container/ScrollStrip.d.ts +1 -1
- package/dist/lib/types/component/container/Scrollbar.d.ts +1 -3
- package/dist/lib/types/component/container/TabBar.d.ts +1 -1
- package/dist/lib/types/component/container/index.d.ts +2 -0
- package/dist/lib/types/component/diagram/DiagramGroupNode.d.ts +1 -1
- package/dist/lib/types/component/display/Markdown.d.ts +42 -1
- package/dist/lib/types/component/display/MarkdownMinimap.d.ts +38 -0
- package/dist/lib/types/component/display/MarkdownViewer.d.ts +60 -0
- package/dist/lib/types/component/display/index.d.ts +6 -0
- package/dist/lib/types/component/editor/CodeEditor.d.ts +13 -0
- package/dist/lib/types/component/editor/index.d.ts +1 -1
- package/dist/lib/types/component/input/Checkbox.d.ts +1 -1
- package/dist/lib/types/component/input/RadioButton.d.ts +1 -1
- package/dist/lib/types/component/input/Slider.d.ts +1 -1
- package/dist/lib/types/component/input/Text.d.ts +0 -2
- package/dist/lib/types/component/input/Toggle.d.ts +1 -1
- package/dist/lib/types/component/menubar/MenuBar.d.ts +1 -1
- package/dist/lib/types/component/menubar/ToolBar.d.ts +1 -0
- package/dist/lib/types/component/table/Body.d.ts +1 -0
- package/dist/lib/types/component/table/cell/SortPriorityBadge.d.ts +1 -1
- package/dist/lib/types/component/table/cell/editor/CellEditorPool.d.ts +1 -0
- package/dist/lib/types/component/table/cell/editor/Date.d.ts +1 -0
- package/dist/lib/types/component/table/cell/editor/DateTime.d.ts +1 -0
- package/dist/lib/types/component/table/cell/editor/Time.d.ts +1 -0
- package/dist/lib/types/component/tree/Tree.d.ts +9 -1
- package/dist/lib/types/component/tree/index.d.ts +1 -1
- package/dist/lib/types/component/tree/renderer/Label.d.ts +1 -1
- package/dist/lib/types/core/Component.d.ts +5 -0
- package/dist/lib/types/core/Theme.d.ts +4 -2
- package/dist/lib/types/layout/LayoutManager.d.ts +8 -0
- package/dist/lib/validation.es.js +1 -1
- package/llms.txt +3 -0
- package/package.json +15 -15
- package/dist/lib/AnchorConstraints-DdDYSDkf.js +0 -2
- package/dist/lib/AnchorConstraints-DdDYSDkf.js.map +0 -1
- package/dist/lib/Border-CKKUk5G9.js +0 -2
- package/dist/lib/Button-MZDYJOMC.js +0 -2
- package/dist/lib/Button-MZDYJOMC.js.map +0 -1
- package/dist/lib/ComboBox-C04SfXAR.js +0 -2
- package/dist/lib/ComboBox-C04SfXAR.js.map +0 -1
- package/dist/lib/Component-fRQvgaEY.js +0 -2
- package/dist/lib/Component-fRQvgaEY.js.map +0 -1
- package/dist/lib/Container-0bsG2Q8Z.js +0 -2
- package/dist/lib/DOM-67StIm5G.js +0 -2
- package/dist/lib/DragManager-DRor_-1x.js +0 -2
- package/dist/lib/LayoutSerialization-D5bBas4W.js +0 -2
- package/dist/lib/LayoutSizes-qNaURyiw.js +0 -2
- package/dist/lib/LayoutSizes-qNaURyiw.js.map +0 -1
- package/dist/lib/List-CG4NvwuV.js +0 -2
- package/dist/lib/MemoryStore-DT6iWWco.js +0 -2
- package/dist/lib/Menu-CrZy2u0g.js +0 -2
- package/dist/lib/Menu-CrZy2u0g.js.map +0 -1
- package/dist/lib/Panel-Rd9zkNXx.js +0 -2
- package/dist/lib/RadioButton-D23rId-V.js +0 -2
- package/dist/lib/RadioButton-D23rId-V.js.map +0 -1
- package/dist/lib/Scrollbar-SOj9psiP.js +0 -2
- package/dist/lib/Scrollbar-SOj9psiP.js.map +0 -1
- package/dist/lib/Slider-DBnAZ-F7.js +0 -2
- package/dist/lib/Slider-DBnAZ-F7.js.map +0 -1
- package/dist/lib/TabButton-DKECTTk1.js +0 -2
- package/dist/lib/TabButton-DKECTTk1.js.map +0 -1
- package/dist/lib/Text-KB5LksJl.js +0 -2
- package/dist/lib/Text-KB5LksJl.js.map +0 -1
- package/dist/lib/VBox-P3WFGkPc.js +0 -2
- package/dist/lib/VBox-P3WFGkPc.js.map +0 -1
- package/dist/lib/selectionsEqual-Ci3_uflt.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{l as e}from"./Position-
|
|
2
|
-
//# sourceMappingURL=AbstractBooleanInput-
|
|
1
|
+
import{l as e}from"./Position-PBVBW1JS.js";import{S as t}from"./Component-w65rPK75.js";import{t as n}from"./Text-CdHf3B-1.js";import{t as r}from"./AbstractInput-B10DfLOf.js";var AbstractBooleanInput=class extends r{_label=null;getLabel(){return this._options.label??null}setLabel(e){return this._options.label=e,this.applyLabel(e),this}getBaseline(){return this._label===null?this.wrapInnerBaseline(e.measureTextBaseline()):this.wrapInnerBaseline(this._label.getBaseline())}applyLabel(e){if(e===null){this._label!==null&&(super.removeComponent(this._label),this._label=null);return}this._label===null?(this._label=new n(e),this._label.setPointerEvents(`none`),super.addComponent(this._label)):this._label.setText(e)}applyEnabled(e){this.getAria().setDisabled(!e),this.getAria().setTabIndex(e?0:-1),this.getInteractiveSurface().setCursor(e?`pointer`:`default`)}applyReadOnly(e){this.getAria().setReadOnly(e)}handleActivationKey(e){this.activationKeys().includes(e.key)&&(e.preventDefault(),this.isEnabled()&&!this.isReadOnly()&&this.activate())}installKeyboard(){t.addListener(this,`keydown`,this.handleActivationKey)}activateFromPointer(){this.isEnabled()&&!this.isReadOnly()&&this.activate()}activationKeys(){return[` `]}};export{AbstractBooleanInput as t};
|
|
2
|
+
//# sourceMappingURL=AbstractBooleanInput-CbW7ZrDT.js.map
|
package/dist/lib/{AbstractBooleanInput-DE5NNJT0.js.map → AbstractBooleanInput-CbW7ZrDT.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractBooleanInput-
|
|
1
|
+
{"version":3,"file":"AbstractBooleanInput-CbW7ZrDT.js","names":[],"sources":["../../src/typescript/lib/component/input/AbstractBooleanInput.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { AbstractInput, AbstractInputOptions } from \"~/component/input/AbstractInput.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { Event } from \"~/core/Event.js\";\nimport { Text } from \"~/component/input/Text.js\";\nimport { Util } from \"~/core/Util.js\";\n\n/**\n * Construction-time options shared by the boolean-valued controls\n * ({@link Checkbox}, {@link RadioButton}, {@link Toggle}). Concrete subclasses\n * extend this with their own value / selected / indeterminate fields.\n *\n * @category Components\n */\nexport interface AbstractBooleanInputOptions extends AbstractInputOptions {\n label?: string | null;\n}\n\n/**\n * Abstract base for the three boolean-valued form controls — {@link Checkbox},\n * {@link RadioButton}, {@link Toggle}. Owns the mechanics they share verbatim:\n * the optional inline `_label` {@link Text} (mount / replace / remove), the\n * enabled / read-only ARIA + tabindex + interactive-surface cursor reflection,\n * the label-or-text baseline, and the keyboard-activation wiring routed through\n * the same enabled/read-only guard as pointer activation.\n *\n * Each subclass supplies only what differs: its inner graphic (the interactive\n * surface), the value mutation performed on activation, and — for {@link Toggle}\n * — the activation keys and a pill-centred baseline override. The value\n * semantics (`isSelected` /\n * `setSelected` / `getValue` / `setValue`, indeterminate handling, `ButtonGroup`\n * change firing, synthetic-click behaviour) stay in the subclasses.\n *\n * Not wrapped with `callable()` — abstract classes are never instantiated.\n *\n * @category Components\n */\nabstract class AbstractBooleanInput<\n TOptions extends AbstractBooleanInputOptions = AbstractBooleanInputOptions\n>\n extends AbstractInput<boolean, TOptions>\n{\n // Written by `applyLabel` from the subclass constructor body (after\n // super()), never by a cascade-dispatched setter, so a plain `= null`\n // initializer is safe.\n protected _label: Text | null = null;\n\n /**\n * Returns the label text, or `null` when none was set.\n *\n * @returns The label string, or `null`.\n */\n getLabel(): string | null {\n return this._options.label ?? null;\n }\n\n /**\n * Sets the inline label text. Pass `null` to remove the label entirely.\n *\n * @param text - The label text, or `null` to clear.\n *\n * @returns This component, for method chaining.\n */\n setLabel(text: string | null): this {\n this._options.label = text;\n this.applyLabel(text);\n\n return this;\n }\n\n /**\n * Returns the offset from the top of the control to its inline label's text\n * baseline, or — when there is no label — to the text baseline the graphic\n * would share with a label, so a label-less graphic still sits on a row's\n * baseline.\n *\n * @returns The baseline offset in pixels.\n *\n * @remarks A `null` baseline auto-centres the graphic within the row's\n * text-line height, which floats a small graphic to the row centre once a\n * tall sibling (e.g. a `TextArea`) inflates the row's descent. Returning the\n * text-line baseline keeps the graphic aligned exactly as a labelled\n * control's graphic would be. {@link Toggle} overrides this for its taller\n * pill.\n */\n getBaseline(): number | null {\n if (this._label === null) {\n return this.wrapInnerBaseline(Util.measureTextBaseline());\n }\n\n return this.wrapInnerBaseline(this._label.getBaseline());\n }\n\n /**\n * Mounts, replaces, or removes the inline label.\n *\n * @param text - The label text, or `null` to remove the label.\n */\n protected applyLabel(text: string | null): void {\n if (text === null) {\n if (this._label !== null) {\n super.removeComponent(this._label);\n this._label = null;\n }\n\n return;\n }\n\n if (this._label === null) {\n this._label = new Text(text);\n this._label.setPointerEvents(\"none\");\n super.addComponent(this._label);\n } else {\n this._label.setText(text);\n }\n }\n\n /**\n * Reflects the enabled flag in the ARIA tree, the tabindex, and the\n * interactive surface's cursor.\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.getInteractiveSurface().setCursor(value ? \"pointer\" : \"default\");\n }\n\n /**\n * Reflects the read-only flag in the ARIA tree.\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 * Keydown handler: activates the control when the pressed key is one of\n * {@link activationKeys} and the control is enabled and not read-only.\n *\n * @param e - The keyboard event.\n */\n private handleActivationKey(e: KeyboardEvent): void {\n if (!this.activationKeys().includes(e.key)) {\n return;\n }\n\n e.preventDefault();\n\n if (this.isEnabled() && !this.isReadOnly()) {\n this.activate();\n }\n }\n\n /**\n * Wires the keyboard-activation listener on the focused root. Called from\n * each subclass constructor after its graphic is built.\n */\n protected installKeyboard(): void {\n Event.addListener(this, \"keydown\", this.handleActivationKey);\n }\n\n /**\n * Activates the control from a pointer click, subject to the same\n * enabled/read-only guard as the keyboard path. Wired by each subclass\n * onto its interactive surface (so the hit area is exactly the visible\n * graphic).\n */\n protected activateFromPointer(): void {\n if (this.isEnabled() && !this.isReadOnly()) {\n this.activate();\n }\n }\n\n /**\n * Keys that activate the control. Defaults to Space; {@link Toggle} widens\n * it to Space and Enter.\n *\n * @returns The activation key strings.\n */\n protected activationKeys(): string[] {\n return [\" \"];\n }\n\n /**\n * Subclass hook: perform the value mutation for an activation (click or\n * key). Called only after the enabled/read-only guard has passed.\n */\n protected abstract activate(): void;\n\n /**\n * Subclass hook: the inner graphic that owns the click + cursor surface\n * ({@link Checkbox}'s box, {@link RadioButton}'s ring, {@link Toggle}'s\n * track).\n *\n * @returns The interactive surface component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B,CAQA,gBAAqC,CACjC,MAAO,CAAC,GAAG,CACf,CAgBJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./Component-
|
|
2
|
-
//# sourceMappingURL=AbstractInput-
|
|
1
|
+
import{t as e}from"./Component-w65rPK75.js";import{t}from"./ListenerBag-WPdKuuds.js";var AbstractInput=class extends e{_listeners=new t;constructor(e,t){super(e,t),this.applyListeners(e?.listeners)}isEnabled(){return this._options.enabled??!0}setEnabled(e){return this._options.enabled=!!e,this.applyEnabled(this._options.enabled),this}isReadOnly(){return this._options.readOnly??!1}setReadOnly(e){return this._options.readOnly=!!e,this.applyReadOnly(this._options.readOnly),this}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}notifyChange(e){this.emit(`change`,e),this.emit(`binding`)}applyOptions(e){return super.applyOptions(e),e.enabled!==void 0&&(this._options.enabled=e.enabled),e.readOnly!==void 0&&(this._options.readOnly=e.readOnly),this}};export{AbstractInput as t};
|
|
2
|
+
//# sourceMappingURL=AbstractInput-B10DfLOf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractInput-
|
|
1
|
+
{"version":3,"file":"AbstractInput-B10DfLOf.js","names":[],"sources":["../../src/typescript/lib/component/input/AbstractInput.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { Bindable } from \"~/core/Bindable.js\";\nimport { ListenerBag } from \"~/core/ListenerBag.js\";\n\n/**\n * String-literal union of the events emitted by every {@link AbstractInput}\n * subclass.\n *\n * @category Components\n */\nexport type AbstractInputEvent = \"change\" | \"binding\";\n\n/**\n * Construction-time options for {@link AbstractInput}. Extended by every\n * value-bearing input control so the `enabled` / `readOnly` flags share a\n * single options surface.\n *\n * @category Components\n */\nexport interface AbstractInputOptions extends ComponentOptions {\n enabled?: boolean;\n readOnly?: boolean;\n /**\n * Construction-time listener bag — the declarative form of `on()`. Each\n * entry is wired as if `on(event, fn)` had been called. Concrete subclasses\n * that expose `on(\"action\", …)` widen this with their own `action?` key.\n */\n listeners?: {\n change?: (value: any) => void;\n binding?: () => void;\n };\n}\n\n/**\n * Abstract base for every value-bearing input control in the framework.\n *\n * Owns the [`Bindable`](/api/core/interfaces/Bindable) value contract, the\n * change/binding listener bookkeeping, and the cached `_options.enabled` /\n * `_options.readOnly` state. Concrete subclasses own their value storage\n * and implement the `applyEnabled` / `applyReadOnly` hooks for their own\n * visual + ARIA wiring.\n *\n * Not wrapped with `callable()` — abstract classes are never instantiated;\n * the [ARCHITECTURE.md](/ARCHITECTURE.md) rule about callable-wrapping\n * applies only to concrete component subclasses.\n *\n * @category Components\n */\nabstract class AbstractInput<\n TValue,\n TOptions extends AbstractInputOptions = AbstractInputOptions\n>\n extends Component<TOptions>\n implements Bindable<TValue>\n{\n private _listeners: ListenerBag<AbstractInputEvent> = new ListenerBag<AbstractInputEvent>();\n\n /**\n * @param options - Caller-supplied options bag.\n * @param subclassDefaults - Per-subclass default bag layered over this\n * class's defaults; forwarded to `Component` so the cascade can merge\n * it before dispatching setters.\n */\n constructor(options?: TOptions, subclassDefaults?: Partial<TOptions>) {\n super(options, subclassDefaults);\n\n // Listener wiring runs here — NOT inside `applyOptions` — because\n // Component's constructor calls `applyOptions` from inside super(),\n // before the class-field `_listeners` initializer has run. Wiring\n // after super() guarantees `_listeners` exists. A subclass that adds\n // `action` to its bag is wired by this same call (it iterates every\n // key), so leaves must not call `applyListeners` again.\n this.applyListeners(options?.listeners);\n }\n\n /**\n * Returns the current value. Concrete subclasses define the storage —\n * `Checkbox` aliases `isSelected`, `Slider` reads `_options.value`,\n * picker fields keep a private `_value` outside the options bag.\n *\n * @returns The current value.\n */\n abstract getValue(): TValue;\n\n /**\n * Sets the current value. Concrete subclasses implement the storage\n * write, normalisation, and any listener-firing for user-driven\n * commits.\n *\n * @param value - The new value.\n *\n * @returns This component, for method chaining.\n */\n abstract setValue(value: TValue): this;\n\n /**\n * Returns whether the control is enabled.\n *\n * @returns `true` when enabled (defaults to `true` when unset).\n */\n isEnabled(): boolean {\n return this._options.enabled ?? true;\n }\n\n /**\n * Enables or disables the control. Dispatches `applyEnabled` so the\n * subclass can reflect the state in its visuals + ARIA tree.\n *\n * @param value - `true` to enable, `false` to disable.\n *\n * @returns This component, for method chaining.\n */\n setEnabled(value: boolean): this {\n this._options.enabled = !!value;\n this.applyEnabled(this._options.enabled);\n\n return this;\n }\n\n /**\n * Returns whether the control is read-only.\n *\n * @returns `true` when read-only (defaults to `false` when unset).\n */\n isReadOnly(): boolean {\n return this._options.readOnly ?? false;\n }\n\n /**\n * Marks the control as read-only. Dispatches `applyReadOnly` so the\n * subclass can reflect the state in its visuals + ARIA tree.\n *\n * @param value - `true` to mark read-only.\n *\n * @returns This component, for method chaining.\n */\n setReadOnly(value: boolean): this {\n this._options.readOnly = !!value;\n this.applyReadOnly(this._options.readOnly);\n\n return this;\n }\n\n /**\n * Registers a listener for one of this input's events.\n *\n * @param event - `\"change\"` fires on every committed value change with\n * the new value; `\"binding\"` fires on every user-driven change with\n * no arguments (consumed by [`Binding`](/api/core/classes/Binding)).\n * @param listener - The callback to invoke when the event fires.\n *\n * @returns This component, for method chaining.\n */\n on(event: \"change\", listener: (value: TValue) => void): this;\n on(event: \"binding\", listener: () => void): this;\n on(event: AbstractInputEvent, listener: Function): this {\n this._listeners.add(event, listener);\n\n return this;\n }\n\n /**\n * Removes a previously registered listener. The exact callback\n * reference must match.\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: AbstractInputEvent, listener: Function): this {\n this._listeners.remove(event, listener);\n\n return this;\n }\n\n /**\n * Fires every registered listener for `event` with `payload`, in\n * registration order. Subclasses call this after committing a\n * user-driven value change.\n *\n * @param event - The event to emit.\n * @param payload - Forwarded to each listener.\n */\n protected emit(event: \"change\", value: TValue): void;\n protected emit(event: \"binding\"): void;\n protected emit(event: AbstractInputEvent, ...payload: unknown[]): void {\n this._listeners.fire(event, ...payload);\n }\n\n /**\n * Fires `\"change\"` listeners with `value` and `\"binding\"` listeners\n * with no arguments. Subclasses call this after committing a\n * user-driven value change.\n *\n * @param value - The newly committed value.\n */\n protected notifyChange(value: TValue): void {\n this.emit(\"change\", value);\n this.emit(\"binding\");\n }\n\n /**\n * Subclass hook: reflect the enabled state in visuals + ARIA. Called\n * from {@link setEnabled} after the cached state is updated.\n *\n * @param value - The new enabled state.\n */\n protected abstract applyEnabled(value: boolean): void;\n\n /**\n * Subclass hook: reflect the read-only state in visuals + ARIA. Called\n * from {@link setReadOnly} after the cached state is updated.\n *\n * @param value - The new read-only state.\n */\n protected abstract applyReadOnly(value: boolean): void;\n\n /**\n * Applies an {@link AbstractInputOptions} bag, caching the `enabled` /\n * `readOnly` flags on `_options`. The setters are intentionally NOT\n * dispatched here: subclasses build their children after `super()`\n * returns and dispatch `applyEnabled` / `applyReadOnly` themselves from\n * the constructor tail once those children exist (otherwise the abstract\n * `applyX` hooks would fire against half-built state).\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.enabled !== undefined) this._options.enabled = options.enabled;\n if (options.readOnly !== undefined) this._options.readOnly = options.readOnly;\n\n return this;\n }\n}\n\nexport { AbstractInput };\n"],"mappings":"qFAkDA,IAAe,cAAf,cAIY,CAEZ,CACI,WAAsD,IAAI,EAQ1D,YAAY,EAAoB,EAAsC,CAClE,MAAM,EAAS,CAAgB,EAQ/B,KAAK,eAAe,GAAS,SAAS,CAC1C,CA2BA,WAAqB,CACjB,OAAO,KAAK,SAAS,SAAW,EACpC,CAUA,WAAW,EAAsB,CAI7B,MAHA,MAAK,SAAS,QAAU,CAAC,CAAC,EAC1B,KAAK,aAAa,KAAK,SAAS,OAAO,EAEhC,IACX,CAOA,YAAsB,CAClB,OAAO,KAAK,SAAS,UAAY,EACrC,CAUA,YAAY,EAAsB,CAI9B,MAHA,MAAK,SAAS,SAAW,CAAC,CAAC,EAC3B,KAAK,cAAc,KAAK,SAAS,QAAQ,EAElC,IACX,CAcA,GAAG,EAA2B,EAA0B,CAGpD,OAFA,KAAK,WAAW,IAAI,EAAO,CAAQ,EAE5B,IACX,CAWA,IAAI,EAA2B,EAA0B,CAGrD,OAFA,KAAK,WAAW,OAAO,EAAO,CAAQ,EAE/B,IACX,CAYA,KAAe,EAA2B,GAAG,EAA0B,CACnE,KAAK,WAAW,KAAK,EAAO,GAAG,CAAO,CAC1C,CASA,aAAuB,EAAqB,CACxC,KAAK,KAAK,SAAU,CAAK,EACzB,KAAK,KAAK,SAAS,CACvB,CA8BA,aAAuB,EAAyB,CAM5C,OALA,MAAM,aAAa,CAAO,EAEtB,EAAQ,UAAa,IAAA,KAAW,KAAK,SAAS,QAAW,EAAQ,SACjE,EAAQ,WAAa,IAAA,KAAW,KAAK,SAAS,SAAW,EAAQ,UAE9D,IACX,CACJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as e,h as t}from"./Component-w65rPK75.js";var Anchor=class extends e{constructor(e){super(),e&&this.applyOptions(e)}resolve(e,t){if(e!==void 0)return typeof e==`number`?e:t*e.percent/100}resolveAxis(e,t,n,r,i,a,o){if(e!==void 0&&t!==void 0){let n=Math.max(0,r-e-t);return{start:o+e,extent:n}}let s=n??i;return e===void 0?t===void 0?{start:a,extent:s}:{start:o+r-t-s,extent:s}:{start:o+e,extent:s}}doLayout(){let e=this.getContainer();if(!e)return;let t=e.getInnerSize();if(!t)return;let n=e.getContentInsets(),r=n.getLeft(),i=n.getTop();for(let n of e.getLaidOutComponents()){let e=this.getLayoutConstraints(n),a=n.getPreferredSize(),o=n.getSize(),s=a?.width??o?.width??0,c=a?.height??o?.height??0,l=this.resolveAxis(this.resolve(e?.left,t.width),this.resolve(e?.right,t.width),this.resolve(e?.width,t.width),t.width,s,n.getX(),r),u=this.resolveAxis(this.resolve(e?.top,t.height),this.resolve(e?.bottom,t.height),this.resolve(e?.height,t.height),t.height,c,n.getY(),i);this.commitBounds(n,l.start,u.start,l.extent,u.extent)}}},n=t(Anchor);export{n as t};
|
|
2
|
+
//# sourceMappingURL=Anchor-BsblS5it.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Anchor-BsblS5it.js","names":[],"sources":["../../src/typescript/lib/layout/Anchor.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutManager, LayoutManagerOptions } from \"~/layout/LayoutManager.js\";\nimport { AnchorConstraints } from \"~/layout/AnchorConstraints.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * A length used by an {@link Anchor} constraint, expressed either in **pixels**\n * (a bare `number`) or as a **percentage** of the container's inner extent\n * (`{ percent }`, on a 0–100 scale). The percentage resolves against inner width\n * for horizontal fields (`left` / `right` / `width`) and inner height for\n * vertical fields (`top` / `bottom` / `height`).\n *\n * @category Layouts\n */\nexport type AnchorValue = number | { percent: number };\n\n/**\n * Construction-time options for {@link Anchor}.\n *\n * @category Layouts\n */\nexport interface AnchorOptions extends LayoutManagerOptions {\n}\n\n/**\n * The resolved placement of a child along one axis: a `start` offset in the\n * container's coordinate space and the `extent` (width or height) to commit.\n */\ninterface AxisResult {\n start: number;\n extent: number;\n}\n\n/**\n * A resize-reactive layout manager that positions each child by edge-relative\n * and proportional offsets, re-resolving them on every `doLayout` pass so a\n * child stays pinned to a container edge — or stretched between two edges — as\n * the container resizes. It is the reactive counterpart to the static\n * [`Absolute`](/api/layout/classes/Absolute) manager, which never reads the\n * container's inner size.\n *\n * Per child (via {@link AnchorConstraints}) an axis can: pin a fixed distance\n * from one edge (`left` / `right` / `top` / `bottom`), derive its extent from\n * the container when both opposing edges are set (stretch), or take an explicit\n * `width` / `height`. Any offset or size may be a pixel `number` or an\n * {@link AnchorValue} percentage of the container's inner extent.\n *\n * Like `Absolute`, `Anchor` commits rects directly through `commitBounds`,\n * bypassing the cell clamp — a child sized larger than the container is\n * committed at its computed size and may overflow, which a host `Panel` with\n * `autoScroll: \"auto\"` scrolls natively. It imposes no intrinsic preferred,\n * min, or max size on its host.\n *\n * @category Layouts\n */\nclass Anchor extends LayoutManager {\n\n constructor(options?: AnchorOptions) {\n // LayoutManager's constructor takes no options; applied via applyOptions below.\n // eslint-disable-next-line local/forward-super-options\n super();\n\n if (options) {\n this.applyOptions(options);\n }\n }\n\n /**\n * Resolves an {@link AnchorValue} to pixels against the given extent.\n * Returns the number unchanged for a pixel value, `extent * percent / 100`\n * for a percentage tag, and `undefined` when the field is unset.\n *\n * @param value - The pixel-or-percent value, or `undefined` if unset.\n * @param extent - The container inner extent the percentage resolves against.\n * @returns The resolved pixel value, or `undefined` when `value` is unset.\n */\n private resolve(value: AnchorValue | undefined, extent: number): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value === \"number\") {\n return value;\n }\n\n // Percent is on a 0–100 (CSS-style) scale, resolved against the inner extent.\n return extent * value.percent / 100;\n }\n\n /**\n * Resolves one axis's placement from its near edge, far edge, and explicit\n * size against the container inner extent, applying the precedence rules:\n * both edges stretch (size ignored); near edge pins the start; far edge pins\n * the end; neither edge falls back to the child's own start. The `origin`\n * (the inset on this axis) is added for every anchored row but **not** for\n * the no-edge fallback, matching {@link Absolute}, which commits the child's\n * own `getX` / `getY` without an inset offset.\n *\n * @param near - Resolved `left` / `top` offset, or `undefined` if unset.\n * @param far - Resolved `right` / `bottom` offset, or `undefined` if unset.\n * @param size - Resolved explicit `width` / `height`, or `undefined` if unset.\n * @param inner - The container's inner extent on this axis.\n * @param preferred - The child's preferred extent on this axis.\n * @param ownStart - The child's own `getX` / `getY` on this axis.\n * @param origin - The inset on this axis added to anchored placements.\n * @returns The `{ start, extent }` to commit on this axis.\n */\n private resolveAxis(near: number | undefined, far: number | undefined, size: number | undefined,\n inner: number, preferred: number, ownStart: number, origin: number): AxisResult {\n if (near !== undefined && far !== undefined) {\n // Stretch between both edges; explicit size is ignored. Clamp the\n // derived extent at 0 so an over-constrained pair never goes negative.\n const extent = Math.max(0, inner - near - far);\n\n return { start: origin + near, extent };\n }\n\n const extent = size ?? preferred;\n\n if (near !== undefined) {\n return { start: origin + near, extent };\n }\n\n if (far !== undefined) {\n return { start: origin + inner - far - extent, extent };\n }\n\n // No edge constrained: keep the child's own position, like Absolute, and\n // do not add the inset origin so mixed Anchor/Absolute usage is consistent.\n return { start: ownStart, extent };\n }\n\n /**\n * Resolves each child's rect from its {@link AnchorConstraints} against the\n * container's current inner size and insets, then commits via the base\n * `commitBounds` (bypassing the cell clamp). Bails before the container\n * connects, when `getInnerSize` is still `null`.\n */\n doLayout(): void {\n const container = this.getContainer();\n\n if (!container) {\n return;\n }\n\n const inner = container.getInnerSize();\n\n if (!inner) {\n return;\n }\n\n const insets = container.getContentInsets();\n const originX = insets.getLeft();\n const originY = insets.getTop();\n\n for (const component of container.getLaidOutComponents()) {\n const cons = this.getLayoutConstraints(component) as AnchorConstraints | undefined;\n\n const preferredSize = component.getPreferredSize();\n const size = component.getSize();\n const prefW = preferredSize?.width ?? size?.width ?? 0;\n const prefH = preferredSize?.height ?? size?.height ?? 0;\n\n const xAxis = this.resolveAxis(this.resolve(cons?.left, inner.width),\n this.resolve(cons?.right, inner.width), this.resolve(cons?.width, inner.width),\n inner.width, prefW, component.getX(), originX);\n\n const yAxis = this.resolveAxis(this.resolve(cons?.top, inner.height),\n this.resolve(cons?.bottom, inner.height), this.resolve(cons?.height, inner.height),\n inner.height, prefH, component.getY(), originY);\n\n this.commitBounds(component, xAxis.start, yAxis.start, xAxis.extent, yAxis.extent);\n }\n }\n}\n\nconst AnchorCallable = callable(Anchor);\ntype AnchorCallable = Anchor;\nexport {\n Anchor as _Anchor,\n AnchorCallable as Anchor\n};\n"],"mappings":"mDAwDA,IAAM,OAAN,cAAqB,CAAc,CAE/B,YAAY,EAAyB,CAGjC,MAAM,EAEF,GACA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C/D,KAAK,QAAQ,GAAM,OAAQ,EAAM,MAAM,EAAG,KAAK,QAAQ,GAAM,OAAQ,EAAM,MAAM,EACjF,EAAM,OAAQ,EAAO,EAAU,KAAK,EAAG,CAAO,EAElD,KAAK,aAAa,EAAW,EAAM,MAAO,EAAM,MAAO,EAAM,OAAQ,EAAM,MAAM,CACrF,CACJ,CACJ,EAEM,EAAiB,EAAS,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnchorConstraints-Bfkt8019.js","names":[],"sources":["../../src/typescript/lib/layout/AnchorConstraints.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutConstraints } from \"~/layout/LayoutConstraints.js\";\nimport { AnchorValue } from \"~/layout/Anchor.js\";\n\n/**\n * Per-child layout constraints for components added to an {@link Anchor}\n * container. Each edge offset pins the child a fixed distance (pixels) or a\n * proportion ({@link AnchorValue} `{ percent }`, on a 0–100 scale) from that\n * side of the container's inner box; setting **both** opposing edges of an axis\n * stretches the child between them. `width` / `height` give an explicit extent\n * (pixels or percent) used when at most one edge of an axis is constrained.\n *\n * @remarks Each axis resolves independently from three inputs — the near edge,\n * the far edge, and the explicit size — against the container's inner extent\n * (post-insets) for that axis. When both edges of an axis are set, the explicit\n * size for that axis is ignored (the pair derives the extent), mirroring CSS\n * `position: absolute`. When neither edge of an axis is set, the child keeps its\n * own `getX` / `getY` on that axis, behaving like {@link Absolute} there, so an\n * application can anchor one axis and hand-place the other.\n *\n * Percentages resolve against the container's **inner** size (the same\n * coordinate space the committed rect lives in), not its border box.\n *\n * @category Layouts\n */\nexport class AnchorConstraints extends LayoutConstraints {\n\n /** Distance from the container's inner left edge to the child's left edge. */\n left?: AnchorValue;\n\n /** Distance from the container's inner right edge to the child's right edge. */\n right?: AnchorValue;\n\n /** Distance from the container's inner top edge to the child's top edge. */\n top?: AnchorValue;\n\n /** Distance from the container's inner bottom edge to the child's bottom edge. */\n bottom?: AnchorValue;\n\n /**\n * Explicit width; used when at most one horizontal edge is constrained.\n * Ignored when both {@link AnchorConstraints.left} and\n * {@link AnchorConstraints.right} are set (the pair derives the width).\n */\n width?: AnchorValue;\n\n /**\n * Explicit height; used when at most one vertical edge is constrained.\n * Ignored when both {@link AnchorConstraints.top} and\n * {@link AnchorConstraints.bottom} are set (the pair derives the height).\n */\n height?: AnchorValue;\n\n constructor() {\n super();\n }\n}\n"],"mappings":"oDA0BA,IAAa,kBAAb,cAAuC,CAAkB,CAGrD,KAGA,MAGA,IAGA,OAOA,MAOA,OAEA,aAAc,CACV,MAAM,CACV,CACJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./DOM-
|
|
2
|
-
//# sourceMappingURL=AnimatedDropdown-
|
|
1
|
+
import{t as e}from"./DOM-Ba8YRVel.js";import{t}from"./Position-PBVBW1JS.js";import{h as n,t as r,v as i}from"./Component-w65rPK75.js";import{a,r as o}from"./Tooltip-B_UF5bXD.js";var s=120,c=4,l=new WeakMap,u={cancel:()=>{}},d={visible:!1,animated:!0,durationMs:s,translatePx:c},AnimatedDropdown=class extends r{_dismissing=!1;_open=!1;_closeHandler=null;_anchorElement=null;_showAnimation=null;_hideAnimation=null;constructor(e,n){super(e,{...d,...n??{}}),this.setPosition(t.FIXED)}applyOptions(e){return super.applyOptions(e),this.setAnimated(e.animated??this.isAnimated()),this.setDurationMs(e.durationMs??this.getDurationMs()),this.setTranslatePx(e.translatePx??this.getTranslatePx()),this}setAnimated(e){return this._options.animated=e,this}isAnimated(){return this._options.animated??this._defaultOptions.animated}setDurationMs(e){return this._options.durationMs=e,this}getDurationMs(){return this._options.durationMs??this._defaultOptions.durationMs}setTranslatePx(e){return this._options.translatePx=e,this}getTranslatePx(){return this._options.translatePx??this._defaultOptions.translatePx}showAnimated(){a.register(this),this.setZIndex(a.getZIndex(this)),this._dismissing=!1,this._open=!0;let e=this.getElement(!0);return a.mount(e),this.setVisible(!0),this.isAnimated()?(this.setWillChange(`opacity, transform`),this._showAnimation?.cancel(),this._showAnimation=i.play(e,{from:{opacity:`0`,transform:`translateY(-${this.getTranslatePx()}px)`},to:{opacity:`1`,transform:`translateY(0)`},durationMs:this.getDurationMs(),properties:[`opacity`,`transform`],onComplete:()=>{this.setWillChange(null),this.onShowComplete()}}),this):(this.onShowComplete(),this)}hideAnimated(){this._open=!1;let e=this.getElement(),finalize=()=>{this.setVisible(!1),this.removeElement(),a.unregister(this),this.onHideComplete()};return!e||!this.isAnimated()?(finalize(),this):(this._dismissing=!0,this.setWillChange(`opacity, transform`),this._hideAnimation?.cancel(),this._hideAnimation=i.play(e,{to:{opacity:`0`,transform:`translateY(-${this.getTranslatePx()}px)`},durationMs:this.getDurationMs(),properties:[`opacity`,`transform`],onComplete:()=>{if(!this._dismissing){this.setWillChange(null);return}this._dismissing=!1,this.setWillChange(null),finalize()}}),this)}onZIndexChanged(e){this.setZIndex(e)}isOpen(){return this._open}handleKey(e){return!1}placeAnchored(t){let n={width:this.getWidth(),height:this.getHeight()},r=e.source.getViewportSize(),{x:i,y:a}=o(t,n,r,{axis:`vertical`});return this.setX(i),this.setY(a),this}onShowComplete(){}onHideComplete(){}destructor(){this._showAnimation?.cancel(),this._showAnimation=null,this._hideAnimation?.cancel(),this._hideAnimation=null,a.unregister(this),super.destructor()}getLayerElement(){return this.getElement()??null}getDismissMode(){return`click-outside`}requestClose(){if(this._closeHandler){this._closeHandler();return}this.hideAnimated()}getAnchorElement(){return this._anchorElement}getBand(){return a.Band.Dropdown}setCloseHandler(e){return this._closeHandler=e,this}setAnchorElement(e){return this._anchorElement=e,this}};function fadeShow(e,t){let n=t?.durationMs??s,r=t?.translatePx??c,a=t?.animated??!0;l.set(e,!1);let o=e.getElement();return!o||!a?(t?.onComplete?.(),u):(e.setWillChange(`opacity, transform`),i.play(o,{from:{opacity:`0`,transform:`translateY(-${r}px)`},to:{opacity:`1`,transform:`translateY(0)`},durationMs:n,properties:[`opacity`,`transform`],onComplete:()=>{e.setWillChange(null),t?.onComplete?.()}}))}function fadeHideAndDetach(e,t){let n=t?.durationMs??s,r=t?.translatePx??c,a=t?.animated??!0,o=e.getElement(),finalize=()=>{e.setVisible(!1),e.removeElement(),t?.onComplete?.()};return!o||!a?(finalize(),u):(l.set(e,!0),e.setWillChange(`opacity, transform`),i.play(o,{to:{opacity:`0`,transform:`translateY(-${r}px)`},durationMs:n,properties:[`opacity`,`transform`],onComplete:()=>{if(!l.get(e)){e.setWillChange(null);return}l.set(e,!1),e.setWillChange(null),finalize()}}))}var f=n(AnimatedDropdown);export{fadeHideAndDetach as n,fadeShow as r,f as t};
|
|
2
|
+
//# sourceMappingURL=AnimatedDropdown-kL47HPGP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnimatedDropdown-QLNasu_Y.js","names":[],"sources":["../../src/typescript/lib/core/AnimatedDropdown.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { Animation } from \"~/core/Animation.js\";\nimport { Position } from \"~/primitive/Position.js\";\nimport { LayerManager, DismissableLayer, LayerDismissMode } from \"~/core/LayerManager.js\";\nimport { positionAnchored } from \"~/core/OverlayPosition.js\";\nimport { callable } from \"~/core/Callable.js\";\nimport { DOM, type Rect, type Handle } from \"~/core/DOM.js\";\n\n/** Default fade duration in milliseconds. Matches `MENU_ANIM_DURATION_MS` from `Menu`. */\nconst DEFAULT_DURATION_MS: number = 120;\n\n/** Default entrance vertical-offset distance in pixels. */\nconst DEFAULT_TRANSLATE_PX: number = 4;\n\n/**\n * Per-component `_dismissing` flag used by the free-function form\n * (`fadeShow` / `fadeHideAndDetach`). `WeakMap`-keyed so a `Component` that\n * never opts into the helper carries no extra state.\n */\nconst _dismissingByComponent: WeakMap<Component, boolean> = new WeakMap();\n\n/** Handle for the fade paths that finish before there is anything to cancel. */\nconst NOOP_HANDLE: Animation.CancelHandle = { cancel: (): void => {} };\n\n/**\n * Construction-time options for {@link AnimatedDropdown}.\n *\n * @category Core\n */\nexport interface AnimatedDropdownOptions extends ComponentOptions {\n /** When false, `showAnimated` / `hideAnimated` skip the transition. Default: true. */\n animated?: boolean;\n /** Fade duration in milliseconds. Default: 120. */\n durationMs?: number;\n /** Vertical translation distance in pixels for the entrance. Default: 4. */\n translatePx?: number;\n}\n\n/**\n * Options forwarded to the free-function forms `fadeShow` / `fadeHideAndDetach`.\n *\n * @category Core\n */\nexport interface FadeOptions {\n /** Fade duration in milliseconds. Default: 120. */\n durationMs?: number;\n /** Vertical translation distance in pixels for the entrance. Default: 4. */\n translatePx?: number;\n /** When false, the helper bypasses the transition and applies the end state synchronously. Default: true. */\n animated?: boolean;\n /** Called once the fade completes (or immediately when animation is disabled). */\n onComplete?: () => void;\n}\n\n/**\n * User-overridable visual defaults forwarded to `super` via the options bag.\n * These are a pure fallback: a caller value wins, otherwise the getters\n * (`isVisible`, `isAnimated`, `getDurationMs`, `getTranslatePx`) resolve the\n * default — `visible: false` is folded by `Component.isVisible`, the rest are\n * dispatched from `applyOptions` as `options.X ?? this.getX()`.\n */\nconst _defaultAnimatedDropdownOptions: Partial<AnimatedDropdownOptions> = {\n visible: false,\n animated: true,\n durationMs: DEFAULT_DURATION_MS,\n translatePx: DEFAULT_TRANSLATE_PX,\n};\n\n/**\n * Floating panel that fades in on `showAnimated` and fades out + detaches on\n * `hideAnimated`. Subclasses (e.g. picker dropdowns for `ComboBox`, `DateField`,\n * `TimeField`, `DateTimeField`) own the panel's interactive content; this base\n * class owns only the open/close lifecycle, the `opacity + translateY`\n * transition, the dismissing-flag re-entrancy guard, and the `will-change`\n * pre-promotion.\n *\n * Positioning math (anchor rect, viewport clamping, flip-above-anchor) lives\n * in the host component or in a subclass — `AnimatedDropdown` does not\n * presume anything about where it should appear.\n *\n * ## Pointer-down contract for hosts mounted under a re-used input element\n *\n * Hosts that compose this dropdown alongside a focusable element whose `blur`\n * commits state (e.g. [`CellEditorPool`](/api/component/table/classes/CellEditorPool)'s pooled editors) must call\n * `event.preventDefault()` on **`pointerdown`** inside the dropdown so the\n * host element keeps focus while the dropdown's selection callback runs. The\n * callback then explicitly drives commit. If the dropdown does not suppress\n * the blur, the editor's blur listener fires first, commits the stale value,\n * and the dropdown's later write goes to a no-longer-active editor.\n *\n * @category Core\n */\nclass AnimatedDropdown<TOptions extends AnimatedDropdownOptions = AnimatedDropdownOptions> extends Component<TOptions> implements DismissableLayer {\n\n // Set true while a fade-out is in flight; reset to false either when the\n // fade completes (so the deferred detach runs) or when a fresh `showAnimated`\n // re-displays the dropdown mid-fade (the deferred detach skips because the\n // dropdown is back on screen).\n private _dismissing: boolean = false;\n private _open: boolean = false;\n\n // Host-supplied close thunk invoked from `requestClose` instead of the\n // bare `hideAnimated`, so the host (a picker field, a ComboBox) can run\n // its own teardown (caret rotation, aria-expanded, commit) when the\n // manager dismisses the layer on an outside click. Null until a host\n // opts into the `\"click-outside\"` dismiss path.\n private _closeHandler: (() => void) | null = null;\n\n // Anchor element (the trigger) excluded from the manager's outside-click\n // test so the click that toggles the dropdown does not immediately\n // re-close it. Null for dropdowns whose host owns the toggle gating.\n private _anchorElement: Handle | null = null;\n\n // In-flight entrance / exit fades, cancelled on teardown so their fallback\n // timers cannot fire against this dropdown's released element handle.\n private _showAnimation: Animation.CancelHandle | null = null;\n private _hideAnimation: Animation.CancelHandle | null = null;\n\n /**\n * @param options - Optional construction-time options.\n * @param subclassDefaults - Per-subclass default bag layered over this\n * class's defaults. Subclasses-of-subclasses forward their own defaults\n * here so the deepest class's values win.\n */\n constructor(options?: AnimatedDropdownOptions, subclassDefaults?: Partial<AnimatedDropdownOptions>) {\n super(\n options as TOptions,\n { ..._defaultAnimatedDropdownOptions, ...(subclassDefaults ?? {}) } as Partial<TOptions>,\n );\n\n // Floating overlays anchor to the viewport, not to a layout-managed\n // ancestor — `Position.FIXED` is the documented exception to the\n // framework's \"every component is absolute\" rule. See\n // ARCHITECTURE.md §Positioning.\n this.setPosition(Position.FIXED);\n }\n\n /**\n * Applies an {@link AnimatedDropdownOptions} bag, dispatching dropdown-specific\n * fields after inherited Component fields.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n // These carry a class default and seed construction-time state, so\n // always dispatch the caller value or the class default.\n this.setAnimated(options.animated ?? this.isAnimated());\n this.setDurationMs(options.durationMs ?? this.getDurationMs());\n this.setTranslatePx(options.translatePx ?? this.getTranslatePx());\n\n return this;\n }\n\n /**\n * Enables or disables the fade transition. When false, `showAnimated` /\n * `hideAnimated` apply visibility synchronously.\n *\n * @param value - true to enable the fade; false for instant show/hide.\n */\n setAnimated(value: boolean): this {\n this._options.animated = value;\n\n return this;\n }\n\n /**\n * Returns whether the fade transition is enabled.\n *\n * @returns true when the fade transition runs on show/hide.\n */\n isAnimated(): boolean {\n return this._options.animated ?? this._defaultOptions.animated!;\n }\n\n /**\n * Sets the fade duration in milliseconds.\n *\n * @param ms - Duration in milliseconds.\n */\n setDurationMs(ms: number): this {\n this._options.durationMs = ms;\n\n return this;\n }\n\n /**\n * Returns the configured fade duration in milliseconds.\n *\n * @returns The duration in milliseconds.\n */\n getDurationMs(): number {\n return this._options.durationMs ?? this._defaultOptions.durationMs!;\n }\n\n /**\n * Sets the entrance vertical-offset distance in pixels.\n *\n * @param px - Translation distance in pixels.\n */\n setTranslatePx(px: number): this {\n this._options.translatePx = px;\n\n return this;\n }\n\n /**\n * Returns the configured entrance vertical-offset distance.\n *\n * @returns The translation distance in pixels.\n */\n getTranslatePx(): number {\n return this._options.translatePx ?? this._defaultOptions.translatePx!;\n }\n\n /**\n * Mounts the dropdown on `document.documentElement` (if not already mounted)\n * and plays the entrance fade. Cancels any in-flight fade-out so a fresh\n * show mid-dismiss keeps the panel on screen.\n */\n showAnimated(): this {\n // Register on the central layer tree. `LayerManager.register` is a\n // no-op when this layer is already registered (a `_dismissing`-\n // cancelled mid-fade re-show), so the tree never double-pushes.\n LayerManager.register(this);\n\n // Mirror the manager's band-based z-stamp onto the element so the\n // dropdown lands above its opener (which registered earlier).\n this.setZIndex(LayerManager.getZIndex(this));\n\n this._dismissing = false;\n this._open = true;\n\n const el = this.getElement(true)!;\n\n LayerManager.mount(el);\n\n this.setVisible(true);\n\n if (!this.isAnimated()) {\n this.onShowComplete();\n return this;\n }\n\n this.setWillChange(\"opacity, transform\");\n\n this._showAnimation?.cancel();\n this._showAnimation = Animation.play(el, {\n from: { opacity: \"0\", transform: `translateY(-${this.getTranslatePx()}px)` },\n to: { opacity: \"1\", transform: \"translateY(0)\" },\n durationMs: this.getDurationMs(),\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n this.setWillChange(null);\n this.onShowComplete();\n },\n });\n\n return this;\n }\n\n /**\n * Plays the exit fade, then hides and detaches the dropdown when the\n * transition completes. A fresh `showAnimated` during the fade cancels the\n * deferred detach by flipping the `_dismissing` flag, so the panel stays\n * mounted.\n */\n hideAnimated(): this {\n this._open = false;\n\n const el = this.getElement();\n const finalize = (): void => {\n this.setVisible(false);\n this.removeElement();\n\n // Pop from the central layer tree. `onHideComplete` runs after\n // this so a subclass override sees the layer as already-closed.\n LayerManager.unregister(this);\n\n this.onHideComplete();\n };\n\n if (!el || !this.isAnimated()) {\n finalize();\n return this;\n }\n\n this._dismissing = true;\n this.setWillChange(\"opacity, transform\");\n\n this._hideAnimation?.cancel();\n this._hideAnimation = Animation.play(el, {\n to: { opacity: \"0\", transform: `translateY(-${this.getTranslatePx()}px)` },\n durationMs: this.getDurationMs(),\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n if (!this._dismissing) {\n this.setWillChange(null);\n return;\n }\n this._dismissing = false;\n this.setWillChange(null);\n finalize();\n },\n });\n\n return this;\n }\n\n /**\n * Mirrors a manager-allocated z-index onto the element when the dropdown —\n * or the window / surface it was opened inside — is raised via\n * {@link LayerManager.bringToFront}. Without this, the dropdown reads its\n * z once in {@link showAnimated} and never updates; raising its host window\n * (a `mousedown` brings the window to front) would then re-stamp the host\n * above the dropdown's stale z, hiding the open panel — and its fade-out —\n * behind the window.\n *\n * @param zIndex - The fresh z-index assigned by the manager.\n */\n onZIndexChanged(zIndex: number): void {\n this.setZIndex(zIndex);\n }\n\n /**\n * Returns whether the dropdown is currently open (showing or fading in).\n *\n * @returns true when the dropdown is open.\n */\n isOpen(): boolean {\n return this._open;\n }\n\n /**\n * Subclass hook: handle a keystroke arriving via the host input's `keydown`\n * listener while the dropdown is open. Subclasses with a navigation surface\n * (e.g. [`DatePickerDropdown`](/api/component/input/classes/DatePickerDropdown))\n * override to consume arrows / Page / Home / End / type-ahead. The base\n * implementation returns `false` so plain dropdowns without keyboard\n * semantics let the host input's contract run.\n *\n * @param _e - The keyboard event forwarded from the host input.\n * @returns True when the dropdown consumed the keystroke (caller should `preventDefault`).\n */\n handleKey(_e: KeyboardEvent): boolean {\n return false;\n }\n\n /**\n * Places the dropdown relative to an anchor rect at its current\n * width/height. Picks the better of \"below\" or \"above\" the anchor\n * vertically (more available space wins when neither side fully fits).\n * Horizontally the panel left-aligns to the anchor, flipping to\n * right-align with the anchor's right edge when the left alignment\n * would overflow the viewport, and clamping only when neither alignment\n * fits.\n *\n * Callers set `setWidth`/`setHeight` first, then invoke this helper.\n *\n * @param rect - The anchor element's bounding rect (typically from\n * `DOM.source.getElementRect(anchorEl)`).\n */\n placeAnchored(rect: Rect): this {\n const size = { width: this.getWidth(), height: this.getHeight() };\n const vp = DOM.source.getViewportSize();\n\n // Vertical growth: prefer below, flip above when below overflows and\n // above has room. Horizontally: align to the anchor's left, flip to\n // its right when that overflows, clamp only as a last resort. The\n // flip/align/clamp geometry lives in the shared pure primitive.\n const { x, y } = positionAnchored(rect, size, vp, { axis: \"vertical\" });\n\n this.setX(x);\n this.setY(y);\n\n return this;\n }\n\n /**\n * Hook invoked after the entrance fade completes (or immediately when\n * animation is disabled). Override to wire post-show state.\n */\n protected onShowComplete(): void {\n // default: no-op\n }\n\n /**\n * Hook invoked after the exit fade completes (or immediately when\n * animation is disabled). Override to wire post-hide cleanup.\n */\n protected onHideComplete(): void {\n // default: no-op\n }\n\n /**\n * Cancels any in-flight entrance / exit fade, then defers to the base\n * class. Cancelling first keeps the fade's fallback timer from firing after\n * `super.destructor()` has released this dropdown's element handle.\n */\n protected destructor(): void {\n this._showAnimation?.cancel();\n this._showAnimation = null;\n this._hideAnimation?.cancel();\n this._hideAnimation = null;\n\n // `hideAnimated`'s completion callback is the only place the dropdown\n // leaves the layer tree, and cancelling above suppressed it. A layer\n // left registered is walked on the next document pointerdown, where the\n // containment test resolves the element handle released below — the\n // very use-after-free this cancellation exists to prevent. Idempotent,\n // so the already-unregistered cases cost nothing.\n LayerManager.unregister(this);\n\n super.destructor();\n }\n\n // ----- DismissableLayer -----\n\n /**\n * Returns the dropdown's root element for the central layer tree.\n *\n * @returns The dropdown's element, or null when not yet rendered.\n */\n getLayerElement(): Handle | null {\n return this.getElement() ?? null;\n }\n\n /**\n * Returns the dismiss mode the document-level handlers consult. The\n * dropdown is `\"click-outside\"`: the manager closes it when a\n * `pointerdown` lands outside both the dropdown's layer subtree and its\n * anchor. A click inside a descendant layer counts as inside, so a nested\n * dropdown keeps its opener open.\n *\n * @returns The layer dismiss mode.\n */\n getDismissMode(): LayerDismissMode {\n return \"click-outside\";\n }\n\n /**\n * Advisory close request from the manager. Runs the host-supplied close\n * thunk when one is set (so the host can rotate a caret, clear\n * aria-expanded, or commit), otherwise the standard exit fade + detach.\n */\n requestClose(): void {\n if (this._closeHandler) {\n this._closeHandler();\n\n return;\n }\n\n this.hideAnimated();\n }\n\n /**\n * Returns the anchor element excluded from the manager's outside-click\n * test, or null when the host gates the toggle itself.\n *\n * @returns The anchor element, or null.\n */\n getAnchorElement(): Handle | null {\n return this._anchorElement;\n }\n\n /**\n * Returns the dropdown's z-index band so an unrelated top-level dropdown\n * stacks in the dropdown family.\n *\n * @returns The dropdown band base.\n */\n getBand(): number {\n return LayerManager.Band.Dropdown;\n }\n\n /**\n * Installs the close thunk the manager calls from {@link requestClose}\n * when this dropdown is dismissed by an outside click. The host passes its\n * own close routine so the dropdown's teardown and the host's UI state\n * (caret, aria-expanded, commit) stay in lockstep.\n *\n * @param handler - The host's close routine, or null to fall back to\n * {@link hideAnimated}.\n * @returns This dropdown, for method chaining.\n */\n setCloseHandler(handler: (() => void) | null): this {\n this._closeHandler = handler;\n\n return this;\n }\n\n /**\n * Records the anchor (trigger) element excluded from the manager's\n * outside-click test, so the gesture that opened the dropdown does not\n * immediately re-close it.\n *\n * @param el - The anchor element, or null to clear it.\n * @returns This dropdown, for method chaining.\n */\n setAnchorElement(el: Handle | null): this {\n this._anchorElement = el;\n\n return this;\n }\n\n}\n\n/**\n * Plays the standard dropdown-style entrance fade on the given component's\n * element. Mirror of {@link AnimatedDropdown.showAnimated} for components that\n * extend `Component` directly and cannot re-parent to `AnimatedDropdown`.\n *\n * Cancels any in-flight fade-out queued by {@link fadeHideAndDetach} so a\n * fresh show mid-dismiss keeps the panel on screen.\n *\n * @param component - The component to fade in.\n * @param options - Optional duration / translate / animated overrides.\n * @returns A handle the caller stores and cancels on its own teardown.\n */\nexport function fadeShow(component: Component, options?: FadeOptions): Animation.CancelHandle {\n const durationMs = options?.durationMs ?? DEFAULT_DURATION_MS;\n const translatePx = options?.translatePx ?? DEFAULT_TRANSLATE_PX;\n const animated = options?.animated ?? true;\n\n _dismissingByComponent.set(component, false);\n\n const el = component.getElement();\n\n if (!el) {\n options?.onComplete?.();\n return NOOP_HANDLE;\n }\n\n if (!animated) {\n options?.onComplete?.();\n return NOOP_HANDLE;\n }\n\n component.setWillChange(\"opacity, transform\");\n\n return Animation.play(el, {\n from: { opacity: \"0\", transform: `translateY(-${translatePx}px)` },\n to: { opacity: \"1\", transform: \"translateY(0)\" },\n durationMs: durationMs,\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n component.setWillChange(null);\n options?.onComplete?.();\n },\n });\n}\n\n/**\n * Plays the standard dropdown-style exit fade on the given component's\n * element, then hides and detaches it from the DOM when the transition\n * completes.\n *\n * A fresh {@link fadeShow} during the fade cancels the deferred detach so the\n * panel stays mounted.\n *\n * @param component - The component to fade out and detach.\n * @param options - Optional duration / translate / animated overrides; `onComplete` fires after detach.\n * @returns A handle the caller stores and cancels on its own teardown.\n */\nexport function fadeHideAndDetach(component: Component, options?: FadeOptions): Animation.CancelHandle {\n const durationMs = options?.durationMs ?? DEFAULT_DURATION_MS;\n const translatePx = options?.translatePx ?? DEFAULT_TRANSLATE_PX;\n const animated = options?.animated ?? true;\n\n const el = component.getElement();\n const finalize = (): void => {\n component.setVisible(false);\n component.removeElement();\n options?.onComplete?.();\n };\n\n if (!el || !animated) {\n finalize();\n return NOOP_HANDLE;\n }\n\n _dismissingByComponent.set(component, true);\n component.setWillChange(\"opacity, transform\");\n\n return Animation.play(el, {\n to: { opacity: \"0\", transform: `translateY(-${translatePx}px)` },\n durationMs: durationMs,\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n if (!_dismissingByComponent.get(component)) {\n component.setWillChange(null);\n return;\n }\n _dismissingByComponent.set(component, false);\n component.setWillChange(null);\n finalize();\n },\n });\n}\n\nconst AnimatedDropdownCallable = callable(AnimatedDropdown);\ntype AnimatedDropdownCallable<TOptions extends AnimatedDropdownOptions = AnimatedDropdownOptions> = AnimatedDropdown<TOptions>;\nexport {\n AnimatedDropdown as _AnimatedDropdown,\n AnimatedDropdownCallable as AnimatedDropdown\n};\n"],"mappings":"kLAWA,IAAM,EAA8B,IAG9B,EAA+B,EAO/B,EAAsD,IAAI,QAG1D,EAAsC,CAAE,WAAoB,CAAC,CAAE,EAuC/D,EAAoE,CACtE,QAAa,GACb,SAAa,GACb,WAAa,EACb,YAAa,CACjB,EA0BM,iBAAN,cAAmG,CAAgD,CAM/I,YAAgC,GAChC,MAAgC,GAOhC,cAA6C,KAK7C,eAAwC,KAIxC,eAAwD,KACxD,eAAwD,KAQxD,YAAY,EAAmC,EAAqD,CAChG,MACI,EACA,CAAE,GAAG,EAAiC,GAAI,GA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,IAAK,UAAW,eAAe,EAAY,IAAK,EAC3D,aACZ,WAAY,CAAC,UAAW,WAAW,EACnC,eAAkB,CACd,GAAI,CAAC,EAAuB,IAAI,CAAS,EAAG,CACxC,EAAU,cAAc,IAAI,EAC5B,MACJ,CACA,EAAuB,IAAI,EAAW,EAAK,EAC3C,EAAU,cAAc,IAAI,EAC5B,SAAS,CACb,CACJ,CAAC,EACL,CAEA,IAAM,EAA2B,EAAS,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"AnimatedDropdown-kL47HPGP.js","names":[],"sources":["../../src/typescript/lib/core/AnimatedDropdown.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { Animation } from \"~/core/Animation.js\";\nimport { Position } from \"~/primitive/Position.js\";\nimport { LayerManager, DismissableLayer, LayerDismissMode } from \"~/core/LayerManager.js\";\nimport { positionAnchored } from \"~/core/OverlayPosition.js\";\nimport { callable } from \"~/core/Callable.js\";\nimport { DOM, type Rect, type Handle } from \"~/core/DOM.js\";\n\n/** Default fade duration in milliseconds. Matches `MENU_ANIM_DURATION_MS` from `Menu`. */\nconst DEFAULT_DURATION_MS: number = 120;\n\n/** Default entrance vertical-offset distance in pixels. */\nconst DEFAULT_TRANSLATE_PX: number = 4;\n\n/**\n * Per-component `_dismissing` flag used by the free-function form\n * (`fadeShow` / `fadeHideAndDetach`). `WeakMap`-keyed so a `Component` that\n * never opts into the helper carries no extra state.\n */\nconst _dismissingByComponent: WeakMap<Component, boolean> = new WeakMap();\n\n/** Handle for the fade paths that finish before there is anything to cancel. */\nconst NOOP_HANDLE: Animation.CancelHandle = { cancel: (): void => {} };\n\n/**\n * Construction-time options for {@link AnimatedDropdown}.\n *\n * @category Core\n */\nexport interface AnimatedDropdownOptions extends ComponentOptions {\n /** When false, `showAnimated` / `hideAnimated` skip the transition. Default: true. */\n animated?: boolean;\n /** Fade duration in milliseconds. Default: 120. */\n durationMs?: number;\n /** Vertical translation distance in pixels for the entrance. Default: 4. */\n translatePx?: number;\n}\n\n/**\n * Options forwarded to the free-function forms `fadeShow` / `fadeHideAndDetach`.\n *\n * @category Core\n */\nexport interface FadeOptions {\n /** Fade duration in milliseconds. Default: 120. */\n durationMs?: number;\n /** Vertical translation distance in pixels for the entrance. Default: 4. */\n translatePx?: number;\n /** When false, the helper bypasses the transition and applies the end state synchronously. Default: true. */\n animated?: boolean;\n /** Called once the fade completes (or immediately when animation is disabled). */\n onComplete?: () => void;\n}\n\n/**\n * User-overridable visual defaults forwarded to `super` via the options bag.\n * These are a pure fallback: a caller value wins, otherwise the getters\n * (`isVisible`, `isAnimated`, `getDurationMs`, `getTranslatePx`) resolve the\n * default — `visible: false` is folded by `Component.isVisible`, the rest are\n * dispatched from `applyOptions` as `options.X ?? this.getX()`.\n */\nconst _defaultAnimatedDropdownOptions: Partial<AnimatedDropdownOptions> = {\n visible: false,\n animated: true,\n durationMs: DEFAULT_DURATION_MS,\n translatePx: DEFAULT_TRANSLATE_PX,\n};\n\n/**\n * Floating panel that fades in on `showAnimated` and fades out + detaches on\n * `hideAnimated`. Subclasses (e.g. picker dropdowns for `ComboBox`, `DateField`,\n * `TimeField`, `DateTimeField`) own the panel's interactive content; this base\n * class owns only the open/close lifecycle, the `opacity + translateY`\n * transition, the dismissing-flag re-entrancy guard, and the `will-change`\n * pre-promotion.\n *\n * Positioning math (anchor rect, viewport clamping, flip-above-anchor) lives\n * in the host component or in a subclass — `AnimatedDropdown` does not\n * presume anything about where it should appear.\n *\n * ## Pointer-down contract for hosts mounted under a re-used input element\n *\n * Hosts that compose this dropdown alongside a focusable element whose `blur`\n * commits state (e.g. [`CellEditorPool`](/api/component/table/classes/CellEditorPool)'s pooled editors) must call\n * `event.preventDefault()` on **`pointerdown`** inside the dropdown so the\n * host element keeps focus while the dropdown's selection callback runs. The\n * callback then explicitly drives commit. If the dropdown does not suppress\n * the blur, the editor's blur listener fires first, commits the stale value,\n * and the dropdown's later write goes to a no-longer-active editor.\n *\n * @category Core\n */\nclass AnimatedDropdown<TOptions extends AnimatedDropdownOptions = AnimatedDropdownOptions> extends Component<TOptions> implements DismissableLayer {\n\n // Set true while a fade-out is in flight; reset to false either when the\n // fade completes (so the deferred detach runs) or when a fresh `showAnimated`\n // re-displays the dropdown mid-fade (the deferred detach skips because the\n // dropdown is back on screen).\n private _dismissing: boolean = false;\n private _open: boolean = false;\n\n // Host-supplied close thunk invoked from `requestClose` instead of the\n // bare `hideAnimated`, so the host (a picker field, a ComboBox) can run\n // its own teardown (caret rotation, aria-expanded, commit) when the\n // manager dismisses the layer on an outside click. Null until a host\n // opts into the `\"click-outside\"` dismiss path.\n private _closeHandler: (() => void) | null = null;\n\n // Anchor element (the trigger) excluded from the manager's outside-click\n // test so the click that toggles the dropdown does not immediately\n // re-close it. Null for dropdowns whose host owns the toggle gating.\n private _anchorElement: Handle | null = null;\n\n // In-flight entrance / exit fades, cancelled on teardown so their fallback\n // timers cannot fire against this dropdown's released element handle.\n private _showAnimation: Animation.CancelHandle | null = null;\n private _hideAnimation: Animation.CancelHandle | null = null;\n\n /**\n * @param options - Optional construction-time options.\n * @param subclassDefaults - Per-subclass default bag layered over this\n * class's defaults. Subclasses-of-subclasses forward their own defaults\n * here so the deepest class's values win.\n */\n constructor(options?: AnimatedDropdownOptions, subclassDefaults?: Partial<AnimatedDropdownOptions>) {\n super(\n options as TOptions,\n { ..._defaultAnimatedDropdownOptions, ...(subclassDefaults ?? {}) } as Partial<TOptions>,\n );\n\n // Floating overlays anchor to the viewport, not to a layout-managed\n // ancestor — `Position.FIXED` is the documented exception to the\n // framework's \"every component is absolute\" rule. See\n // ARCHITECTURE.md §Positioning.\n this.setPosition(Position.FIXED);\n }\n\n /**\n * Applies an {@link AnimatedDropdownOptions} bag, dispatching dropdown-specific\n * fields after inherited Component fields.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: TOptions): this {\n super.applyOptions(options);\n\n // These carry a class default and seed construction-time state, so\n // always dispatch the caller value or the class default.\n this.setAnimated(options.animated ?? this.isAnimated());\n this.setDurationMs(options.durationMs ?? this.getDurationMs());\n this.setTranslatePx(options.translatePx ?? this.getTranslatePx());\n\n return this;\n }\n\n /**\n * Enables or disables the fade transition. When false, `showAnimated` /\n * `hideAnimated` apply visibility synchronously.\n *\n * @param value - true to enable the fade; false for instant show/hide.\n */\n setAnimated(value: boolean): this {\n this._options.animated = value;\n\n return this;\n }\n\n /**\n * Returns whether the fade transition is enabled.\n *\n * @returns true when the fade transition runs on show/hide.\n */\n isAnimated(): boolean {\n return this._options.animated ?? this._defaultOptions.animated!;\n }\n\n /**\n * Sets the fade duration in milliseconds.\n *\n * @param ms - Duration in milliseconds.\n */\n setDurationMs(ms: number): this {\n this._options.durationMs = ms;\n\n return this;\n }\n\n /**\n * Returns the configured fade duration in milliseconds.\n *\n * @returns The duration in milliseconds.\n */\n getDurationMs(): number {\n return this._options.durationMs ?? this._defaultOptions.durationMs!;\n }\n\n /**\n * Sets the entrance vertical-offset distance in pixels.\n *\n * @param px - Translation distance in pixels.\n */\n setTranslatePx(px: number): this {\n this._options.translatePx = px;\n\n return this;\n }\n\n /**\n * Returns the configured entrance vertical-offset distance.\n *\n * @returns The translation distance in pixels.\n */\n getTranslatePx(): number {\n return this._options.translatePx ?? this._defaultOptions.translatePx!;\n }\n\n /**\n * Mounts the dropdown on `document.documentElement` (if not already mounted)\n * and plays the entrance fade. Cancels any in-flight fade-out so a fresh\n * show mid-dismiss keeps the panel on screen.\n */\n showAnimated(): this {\n // Register on the central layer tree. `LayerManager.register` is a\n // no-op when this layer is already registered (a `_dismissing`-\n // cancelled mid-fade re-show), so the tree never double-pushes.\n LayerManager.register(this);\n\n // Mirror the manager's band-based z-stamp onto the element so the\n // dropdown lands above its opener (which registered earlier).\n this.setZIndex(LayerManager.getZIndex(this));\n\n this._dismissing = false;\n this._open = true;\n\n const el = this.getElement(true)!;\n\n LayerManager.mount(el);\n\n this.setVisible(true);\n\n if (!this.isAnimated()) {\n this.onShowComplete();\n return this;\n }\n\n this.setWillChange(\"opacity, transform\");\n\n this._showAnimation?.cancel();\n this._showAnimation = Animation.play(el, {\n from: { opacity: \"0\", transform: `translateY(-${this.getTranslatePx()}px)` },\n to: { opacity: \"1\", transform: \"translateY(0)\" },\n durationMs: this.getDurationMs(),\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n this.setWillChange(null);\n this.onShowComplete();\n },\n });\n\n return this;\n }\n\n /**\n * Plays the exit fade, then hides and detaches the dropdown when the\n * transition completes. A fresh `showAnimated` during the fade cancels the\n * deferred detach by flipping the `_dismissing` flag, so the panel stays\n * mounted.\n */\n hideAnimated(): this {\n this._open = false;\n\n const el = this.getElement();\n const finalize = (): void => {\n this.setVisible(false);\n this.removeElement();\n\n // Pop from the central layer tree. `onHideComplete` runs after\n // this so a subclass override sees the layer as already-closed.\n LayerManager.unregister(this);\n\n this.onHideComplete();\n };\n\n if (!el || !this.isAnimated()) {\n finalize();\n return this;\n }\n\n this._dismissing = true;\n this.setWillChange(\"opacity, transform\");\n\n this._hideAnimation?.cancel();\n this._hideAnimation = Animation.play(el, {\n to: { opacity: \"0\", transform: `translateY(-${this.getTranslatePx()}px)` },\n durationMs: this.getDurationMs(),\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n if (!this._dismissing) {\n this.setWillChange(null);\n return;\n }\n this._dismissing = false;\n this.setWillChange(null);\n finalize();\n },\n });\n\n return this;\n }\n\n /**\n * Mirrors a manager-allocated z-index onto the element when the dropdown —\n * or the window / surface it was opened inside — is raised via\n * {@link LayerManager.bringToFront}. Without this, the dropdown reads its\n * z once in {@link showAnimated} and never updates; raising its host window\n * (a `mousedown` brings the window to front) would then re-stamp the host\n * above the dropdown's stale z, hiding the open panel — and its fade-out —\n * behind the window.\n *\n * @param zIndex - The fresh z-index assigned by the manager.\n */\n onZIndexChanged(zIndex: number): void {\n this.setZIndex(zIndex);\n }\n\n /**\n * Returns whether the dropdown is currently open (showing or fading in).\n *\n * @returns true when the dropdown is open.\n */\n isOpen(): boolean {\n return this._open;\n }\n\n /**\n * Subclass hook: handle a keystroke arriving via the host input's `keydown`\n * listener while the dropdown is open. Subclasses with a navigation surface\n * (e.g. [`DatePickerDropdown`](/api/component/input/classes/DatePickerDropdown))\n * override to consume arrows / Page / Home / End / type-ahead. The base\n * implementation returns `false` so plain dropdowns without keyboard\n * semantics let the host input's contract run.\n *\n * @param _e - The keyboard event forwarded from the host input.\n * @returns True when the dropdown consumed the keystroke (caller should `preventDefault`).\n */\n handleKey(_e: KeyboardEvent): boolean {\n return false;\n }\n\n /**\n * Places the dropdown relative to an anchor rect at its current\n * width/height. Picks the better of \"below\" or \"above\" the anchor\n * vertically (more available space wins when neither side fully fits).\n * Horizontally the panel left-aligns to the anchor, flipping to\n * right-align with the anchor's right edge when the left alignment\n * would overflow the viewport, and clamping only when neither alignment\n * fits.\n *\n * Callers set `setWidth`/`setHeight` first, then invoke this helper.\n *\n * @param rect - The anchor element's bounding rect (typically from\n * `DOM.source.getElementRect(anchorEl)`).\n */\n placeAnchored(rect: Rect): this {\n const size = { width: this.getWidth(), height: this.getHeight() };\n const vp = DOM.source.getViewportSize();\n\n // Vertical growth: prefer below, flip above when below overflows and\n // above has room. Horizontally: align to the anchor's left, flip to\n // its right when that overflows, clamp only as a last resort. The\n // flip/align/clamp geometry lives in the shared pure primitive.\n const { x, y } = positionAnchored(rect, size, vp, { axis: \"vertical\" });\n\n this.setX(x);\n this.setY(y);\n\n return this;\n }\n\n /**\n * Hook invoked after the entrance fade completes (or immediately when\n * animation is disabled). Override to wire post-show state.\n */\n protected onShowComplete(): void {\n // default: no-op\n }\n\n /**\n * Hook invoked after the exit fade completes (or immediately when\n * animation is disabled). Override to wire post-hide cleanup.\n */\n protected onHideComplete(): void {\n // default: no-op\n }\n\n /**\n * Cancels any in-flight entrance / exit fade, then defers to the base\n * class. Cancelling first keeps the fade's fallback timer from firing after\n * `super.destructor()` has released this dropdown's element handle.\n */\n protected destructor(): void {\n this._showAnimation?.cancel();\n this._showAnimation = null;\n this._hideAnimation?.cancel();\n this._hideAnimation = null;\n\n // `hideAnimated`'s completion callback is the only place the dropdown\n // leaves the layer tree, and cancelling above suppressed it. A layer\n // left registered is walked on the next document pointerdown, where the\n // containment test resolves the element handle released below — the\n // very use-after-free this cancellation exists to prevent. Idempotent,\n // so the already-unregistered cases cost nothing.\n LayerManager.unregister(this);\n\n super.destructor();\n }\n\n // ----- DismissableLayer -----\n\n /**\n * Returns the dropdown's root element for the central layer tree.\n *\n * @returns The dropdown's element, or null when not yet rendered.\n */\n getLayerElement(): Handle | null {\n return this.getElement() ?? null;\n }\n\n /**\n * Returns the dismiss mode the document-level handlers consult. The\n * dropdown is `\"click-outside\"`: the manager closes it when a\n * `pointerdown` lands outside both the dropdown's layer subtree and its\n * anchor. A click inside a descendant layer counts as inside, so a nested\n * dropdown keeps its opener open.\n *\n * @returns The layer dismiss mode.\n */\n getDismissMode(): LayerDismissMode {\n return \"click-outside\";\n }\n\n /**\n * Advisory close request from the manager. Runs the host-supplied close\n * thunk when one is set (so the host can rotate a caret, clear\n * aria-expanded, or commit), otherwise the standard exit fade + detach.\n */\n requestClose(): void {\n if (this._closeHandler) {\n this._closeHandler();\n\n return;\n }\n\n this.hideAnimated();\n }\n\n /**\n * Returns the anchor element excluded from the manager's outside-click\n * test, or null when the host gates the toggle itself.\n *\n * @returns The anchor element, or null.\n */\n getAnchorElement(): Handle | null {\n return this._anchorElement;\n }\n\n /**\n * Returns the dropdown's z-index band so an unrelated top-level dropdown\n * stacks in the dropdown family.\n *\n * @returns The dropdown band base.\n */\n getBand(): number {\n return LayerManager.Band.Dropdown;\n }\n\n /**\n * Installs the close thunk the manager calls from {@link requestClose}\n * when this dropdown is dismissed by an outside click. The host passes its\n * own close routine so the dropdown's teardown and the host's UI state\n * (caret, aria-expanded, commit) stay in lockstep.\n *\n * @param handler - The host's close routine, or null to fall back to\n * {@link hideAnimated}.\n * @returns This dropdown, for method chaining.\n */\n setCloseHandler(handler: (() => void) | null): this {\n this._closeHandler = handler;\n\n return this;\n }\n\n /**\n * Records the anchor (trigger) element excluded from the manager's\n * outside-click test, so the gesture that opened the dropdown does not\n * immediately re-close it.\n *\n * @param el - The anchor element, or null to clear it.\n * @returns This dropdown, for method chaining.\n */\n setAnchorElement(el: Handle | null): this {\n this._anchorElement = el;\n\n return this;\n }\n\n}\n\n/**\n * Plays the standard dropdown-style entrance fade on the given component's\n * element. Mirror of {@link AnimatedDropdown.showAnimated} for components that\n * extend `Component` directly and cannot re-parent to `AnimatedDropdown`.\n *\n * Cancels any in-flight fade-out queued by {@link fadeHideAndDetach} so a\n * fresh show mid-dismiss keeps the panel on screen.\n *\n * @param component - The component to fade in.\n * @param options - Optional duration / translate / animated overrides.\n * @returns A handle the caller stores and cancels on its own teardown.\n */\nexport function fadeShow(component: Component, options?: FadeOptions): Animation.CancelHandle {\n const durationMs = options?.durationMs ?? DEFAULT_DURATION_MS;\n const translatePx = options?.translatePx ?? DEFAULT_TRANSLATE_PX;\n const animated = options?.animated ?? true;\n\n _dismissingByComponent.set(component, false);\n\n const el = component.getElement();\n\n if (!el) {\n options?.onComplete?.();\n return NOOP_HANDLE;\n }\n\n if (!animated) {\n options?.onComplete?.();\n return NOOP_HANDLE;\n }\n\n component.setWillChange(\"opacity, transform\");\n\n return Animation.play(el, {\n from: { opacity: \"0\", transform: `translateY(-${translatePx}px)` },\n to: { opacity: \"1\", transform: \"translateY(0)\" },\n durationMs: durationMs,\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n component.setWillChange(null);\n options?.onComplete?.();\n },\n });\n}\n\n/**\n * Plays the standard dropdown-style exit fade on the given component's\n * element, then hides and detaches it from the DOM when the transition\n * completes.\n *\n * A fresh {@link fadeShow} during the fade cancels the deferred detach so the\n * panel stays mounted.\n *\n * @param component - The component to fade out and detach.\n * @param options - Optional duration / translate / animated overrides; `onComplete` fires after detach.\n * @returns A handle the caller stores and cancels on its own teardown.\n */\nexport function fadeHideAndDetach(component: Component, options?: FadeOptions): Animation.CancelHandle {\n const durationMs = options?.durationMs ?? DEFAULT_DURATION_MS;\n const translatePx = options?.translatePx ?? DEFAULT_TRANSLATE_PX;\n const animated = options?.animated ?? true;\n\n const el = component.getElement();\n const finalize = (): void => {\n component.setVisible(false);\n component.removeElement();\n options?.onComplete?.();\n };\n\n if (!el || !animated) {\n finalize();\n return NOOP_HANDLE;\n }\n\n _dismissingByComponent.set(component, true);\n component.setWillChange(\"opacity, transform\");\n\n return Animation.play(el, {\n to: { opacity: \"0\", transform: `translateY(-${translatePx}px)` },\n durationMs: durationMs,\n properties: [\"opacity\", \"transform\"],\n onComplete: () => {\n if (!_dismissingByComponent.get(component)) {\n component.setWillChange(null);\n return;\n }\n _dismissingByComponent.set(component, false);\n component.setWillChange(null);\n finalize();\n },\n });\n}\n\nconst AnimatedDropdownCallable = callable(AnimatedDropdown);\ntype AnimatedDropdownCallable<TOptions extends AnimatedDropdownOptions = AnimatedDropdownOptions> = AnimatedDropdown<TOptions>;\nexport {\n AnimatedDropdown as _AnimatedDropdown,\n AnimatedDropdownCallable as AnimatedDropdown\n};\n"],"mappings":"kLAWA,IAAM,EAA8B,IAG9B,EAA+B,EAO/B,EAAsD,IAAI,QAG1D,EAAsC,CAAE,WAAoB,CAAC,CAAE,EAuC/D,EAAoE,CACtE,QAAa,GACb,SAAa,GACb,WAAa,EACb,YAAa,CACjB,EA0BM,iBAAN,cAAmG,CAAgD,CAM/I,YAAgC,GAChC,MAAgC,GAOhC,cAA6C,KAK7C,eAAwC,KAIxC,eAAwD,KACxD,eAAwD,KAQxD,YAAY,EAAmC,EAAqD,CAChG,MACI,EACA,CAAE,GAAG,EAAiC,GAAI,GAAoB,CAAC,CAAG,CACtE,EAMA,KAAK,YAAY,EAAS,KAAK,CACnC,CAQA,aAAuB,EAAyB,CAS5C,OARA,MAAM,aAAa,CAAO,EAI1B,KAAK,YAAY,EAAQ,UAAY,KAAK,WAAW,CAAC,EACtD,KA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,EAC5B,MACJ,CACA,EAAuB,IAAI,EAAW,EAAK,EAC3C,EAAU,cAAc,IAAI,EAC5B,SAAS,CACb,CACJ,CAAC,EACL,CAEA,IAAM,EAA2B,EAAS,gBAAgB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./DOM-Ba8YRVel.js";import{a as t,s as n}from"./Position-PBVBW1JS.js";import{S as r,b as i,f as a,h as o,m as s,t as c,v as l}from"./Component-w65rPK75.js";import{t as u}from"./ListenerBag-WPdKuuds.js";import{t as d}from"./Tooltip-B_UF5bXD.js";import{t as f}from"./Placement-7kqdaK4Z.js";import{t as p}from"./LayoutConstraints-LIHYYd2F.js";function beginPointerDrag(t){e.sink.apply(e.source.getBody(),{style:{pointerEvents:`none`}}),e.sink.apply(e.source.getDocumentElement(),{style:{cursor:t}})}function endPointerDrag(){e.sink.apply(e.source.getBody(),{style:{pointerEvents:``}}),e.sink.apply(e.source.getDocumentElement(),{style:{cursor:``}})}var m=200,h=`cubic-bezier(0.4, 0, 0.6, 1)`,g={cancel:()=>{}};function track(e,t){let n=null,r=!1,prune=()=>{r=!0;let t=n===null?-1:e.indexOf(n);t>=0&&e.splice(t,1)},{handle:i,cleanup:a}=t(prune);r||(n={cancel:()=>i.cancel(),settle:()=>{i.cancel(),a()}},e.push(n))}function primeCollapse(e,t,n,r,i){let cleanup=()=>{for(let e of n)e.setTransition(null);e.setWillChange(null)};if(l.isReducedMotion())return r(),{handle:g,cleanup};let a=t.map(e=>`${e} ${m}ms ${h}`).join(`, `);for(let e of n)e.setTransition(a);return e.setWillChange(t.join(`, `)),{handle:l.afterTransition({component:e,property:i??t[0],durationMs:m,fallbackBufferMs:40,onComplete:()=>{cleanup(),r()}}),cleanup}}function captureRect(e){return{x:e.getX(),y:e.getY(),width:e.getWidth(),height:e.getHeight()}}function parseCubicBezier(e){let t=e.match(/cubic-bezier\(([^)]+)\)/);if(!t)return e=>e;let[n,r,i,a]=t[1].split(`,`).map(e=>parseFloat(e)),o=3*n,s=3*(i-n)-o,c=1-o-s,l=3*r,u=3*(a-r)-l,d=1-l-u,sampleX=e=>((c*e+s)*e+o)*e,sampleY=e=>((d*e+u)*e+l)*e,sampleDX=e=>(3*c*e+2*s)*e+o;return e=>{let t=e;for(let n=0;n<8;n+=1){let n=sampleX(t)-e;if(Math.abs(n)<1e-6)return sampleY(t);let r=sampleDX(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;for(t=e;n<r;){let i=sampleX(t);if(Math.abs(i-e)<1e-6)break;i<e?n=t:r=t,t=(n+r)/2}return sampleY(t)}}var _=parseCubicBezier(h),lerp=(e,t,n)=>e+(t-e)*n,lerpRect=(e,t,n)=>({x:lerp(e.x,t.x,n),y:lerp(e.y,t.y,n),width:lerp(e.width,t.width,n),height:lerp(e.height,t.height,n)});function commitRect(e,t,n){e.setAutoCommitStyle(!1),e.setX(t.x),e.setY(t.y),e.setWidth(t.width),e.setHeight(t.height),n&&e.doLayout(),e.setAutoCommitStyle(!0)}function animateLayout(t,n){if(l.isReducedMotion()){for(let e of t)commitRect(e.component,e.end,e.relayout);return n?.(),()=>{}}let r=!1,i=0;for(let e of t)commitRect(e.component,e.start,e.relayout);let a=performance.now(),frame=o=>{if(r)return;let s=Math.min(1,(o-a)/m),c=_(s);for(let e of t)commitRect(e.component,s>=1?e.end:lerpRect(e.start,e.end,c),e.relayout);s<1?i=e.sink.requestAnimationFrame(frame):n?.()};return i=e.sink.requestAnimationFrame(frame),()=>{r=!0,i&&e.sink.cancelAnimationFrame(i)}}function runCollapse(e,t,n,r,i,a){r?.(),track(i,e=>primeCollapse(t,[`clip-path`],[t],e,`clip-path`));let o=n.filter(e=>!e.relayout).map(e=>e.component);o.length>0&&track(i,e=>primeCollapse(o[0],[`background-color`],o,e,`background-color`));let s=n.map(e=>captureRect(e.component));return e.doLayout(),animateLayout(n.map((e,t)=>({component:e.component,relayout:e.relayout,start:s[t],end:captureRect(e.component)})),a)}var v=10,y=40,b={east:0,south:90,west:180,north:-90},x=null;function ensureCollapseButtonClassRule(){x||=new i({scope:`class`,name:`CollapseButton`,styles:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,boxSizing:`border-box`,width:`${v}px`,height:`${y}px`,borderRadius:`2px`,background:`var(--ts-ui-button-bg, #e8e8e8)`,border:`1px solid var(--ts-ui-button-border, #c8c8c8)`,boxShadow:`var(--ts-ui-button-shadow, 0 1px 2px rgba(0, 0, 0, 0.2))`,textAlign:`center`,fontSize:`9px`,lineHeight:`38px`,color:`var(--ts-ui-collapse-button-color, rgb(100,100,100))`,pointerEvents:`auto`,userSelect:`none`}})}var CollapseButton=class extends c{_listeners=new u;constructor(e){ensureCollapseButtonClassRule(),super({tag:`span`,cursor:`pointer`,...e??{}}),this._direction??=`east`,this.applyRotation(),this.applyListeners(e?.listeners),r.addListener(this,`dblclick`,this.onDoubleClick),r.addListener(this,`mousedown`,this.onMouseDown)}applyOptions(e){return super.applyOptions(e),e.direction!==void 0&&this.setDirection(e.direction),this}render(){let t=super.render();return e.sink.apply(t,{text:`▶`}),t}applyRotation(){let e=b[this._direction];this.createStyleRule(``).set(`transform`,`translate(-50%, -50%) rotate(${e}deg)`)}setStripMode(e){return this.createStyleRule(``).set(`width`,`${e?18:v}px`),this}getDirection(){return this._direction}setDirection(e){return this._direction=e,this.applyRotation(),this}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e){this._listeners.fire(e)}onDoubleClick(e){return this.emit(`collapse`),!0}onMouseDown(e){return!0}},S=o(CollapseButton),C={west:`east`,east:`west`,north:`south`,south:`north`},w={orientation:`horizontal`,collapsible:!0,movable:!0},SplitGutter=class extends c{_opaque=!1;_collapseDirection=`west`;_expandedBackground=`var(--ts-ui-gutter-bg, #AAAAAA)`;_tooltipText=``;_listeners=new u;constructor(e,t,n){super(t,{...w,...n??{}}),e&&t?.orientation===void 0&&(this._direction=e),this._expandedBackground=t?.expandedBackground??`var(--ts-ui-gutter-bg, #AAAAAA)`,this.setBackgroundColor(this._expandedBackground),this._collapseDirection=t?.collapseDirection??(this._direction===`horizontal`?`west`:`north`),this._collapseButton=new S({direction:this._collapseDirection,listeners:{collapse:()=>this.emit(`collapse`)}}),this._collapseButton.setVisible(this._collapsible),t?.opaque&&this.setOpaque(!0),this._movable||this.setPointerEvents(`none`),this._movable&&r.addListener(this,`mousedown`,this.onDragStart),this.applyListeners(t?.listeners),this.updateTooltip()}init(t){super.init(t);let n=t||this.getElement();return n&&e.sink.appendChild(n,this._collapseButton.getElement(!0)),this}isCollapsible(){return this._collapsible??this._defaultOptions.collapsible}setCollapsible(e){return this._collapsible=e,this._collapseButton?.setVisible(e),this._collapseButton&&this.updateTooltip(),this}applyOptions(e){return super.applyOptions(e),this.setDirection(e.orientation??this.getDirection()),this.setCollapsible(e.collapsible??this.isCollapsible()),this.setMovable(e.movable??this.isMovable()),this}isMovable(){return this._movable??this._defaultOptions.movable}setMovable(e){return this._movable=e,this}isOpaque(){return this._opaque}setOpaque(e){return this._opaque=e,e?(this.setBackgroundColor(`var(--ts-ui-button-bg, #e8e8e8)`),this.setBackgroundImage(`var(--ts-ui-button-bg, linear-gradient(rgb(241, 241, 241), rgb(200, 200, 200)))`),this.setBorder(`1px solid var(--ts-ui-button-border, #c8c8c8)`),this._collapseButton?.setDirection(C[this._collapseDirection])):(this.clearBackgroundImage(),this.clearBorder(),this.setBackgroundColor(this._expandedBackground),this._collapseButton?.setDirection(this._collapseDirection)),this._collapseButton?.setStripMode(e),this.applyCursor(),this.updateTooltip(),this}getCollapseDirection(){return this._collapseDirection}setCollapseDirection(e){return this._collapseDirection=e,this._collapseButton?.setDirection(this._opaque?C[e]:e),this.updateTooltip(),this}updateTooltip(){if(!this._collapsible){this._tooltipText!==``&&(d.detach(this),this._collapseButton&&d.detach(this._collapseButton),this._tooltipText=``);return}let e=`Double-click to ${this._opaque?`expand`:`collapse`} ${this._opaque?C[this._collapseDirection]:this._collapseDirection}ward`;e!==this._tooltipText&&(this._tooltipText=e,d.attach(this,e),this._collapseButton&&d.attach(this._collapseButton,e))}getDirection(){return this._direction??this._defaultOptions.orientation}setDirection(e){return e||=`horizontal`,this._direction=e,this}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}destructor(){this._collapseButton?.dispose(),super.destructor()}_dispatchDrag(e){this.emit(`drag`,e)}onDragStart(e){if(this._opaque)return;let t=this._direction===`horizontal`?e.clientX:e.clientY;this.emit(`dragstart`,t),r.addViewportListener(this,`mouseup`,this.onDragStop),r.addViewportListener(this,`touchend`,this.onDragStop),r.addViewportListener(this,`touchcancel`,this.onDragStop),r.addViewportListener(this,`mousemove`,this.onDrag),r.addViewportListener(this,`touchmove`,this.onDrag),beginPointerDrag(this.dragCursor())}onDragStop(){return r.removeViewportListener(this,`mouseup`,this.onDragStop),r.removeViewportListener(this,`touchend`,this.onDragStop),r.removeViewportListener(this,`touchcancel`,this.onDragStop),r.removeViewportListener(this,`mousemove`,this.onDrag),r.removeViewportListener(this,`touchmove`,this.onDrag),endPointerDrag(),this.emit(`dragend`),!0}onDrag(e){let t;return t=this._direction===`horizontal`?e.clientX:e.clientY,this._dispatchDrag(t),!0}dragCursor(){return this._direction==`horizontal`?`ew-resize`:`ns-resize`}applyCursor(){this._movable&&!this._opaque?this.setCursor(this.dragCursor()):this.setCursor(`default`)}render(){let e=super.render();return this.applyCursor(),e}},T=o(SplitGutter),E=4,D={[f.NORTH]:`north`,[f.SOUTH]:`south`,[f.WEST]:`west`,[f.EAST]:`east`},Border=class extends a{_northComponent=null;_southComponent=null;_westComponent=null;_eastComponent=null;_centerComponent=null;_spacing=5;_collapsed=new Map;_collapsible=new Map;_gutters=new Map;_collapseAnimation=null;_pendingCollapseTransitions=[];_collapsing=!1;constructor(e){super(),e&&this.applyOptions(e)}applyOptions(e){super.applyOptions(e),e.spacing!==void 0&&this.setComponentSpacing(e.spacing)}setLayoutConstraints(e,t){switch(t||(t=new p,t.placement=f.CENTER),t.placement||(t.placement=f.CENTER),t.placement){case f.NORTH:this._northComponent=e;break;case f.SOUTH:this._southComponent=e;break;case f.WEST:this._westComponent=e;break;case f.EAST:this._eastComponent=e;break;case f.CENTER:this._centerComponent=e}return t.placement===f.CENTER?this._collapsible.set(f.CENTER,!1):this._collapsible.set(t.placement,t.collapsible??!1),super.setLayoutConstraints(e,t)}delLayoutConstraints(e){return this._northComponent===e?this._northComponent=null:this._southComponent===e?this._southComponent=null:this._westComponent===e?this._westComponent=null:this._eastComponent===e?this._eastComponent=null:this._centerComponent===e&&(this._centerComponent=null),super.delLayoutConstraints(e)}getComponentSpacing(){return this._spacing}setComponentSpacing(e){return this._spacing=e,this}getRegionComponent(e){switch(e){case f.NORTH:return this._northComponent;case f.SOUTH:return this._southComponent;case f.WEST:return this._westComponent;case f.EAST:return this._eastComponent;case f.CENTER:return this._centerComponent}}isRegionCollapsed(e){return this._collapsed.get(e)??!1}setRegionCollapsed(e,t){if(e===f.CENTER||!this.isRegionCollapsible(e))return this;let n=this.getRegionComponent(e);if(!n||(this._collapsed.get(e)??!1)===t)return this;let r=this.getContainer();if(!r)return this;let i=this._collapsing;this._collapsing=!0,i||r.doLayout(),this._collapsed.set(e,t),this.ensureGutter(e);let a=[...[this._northComponent,this._southComponent,this._westComponent,this._eastComponent,this._centerComponent].filter(e=>e!=null).map(e=>({component:e,relayout:!0})),...[...this._gutters.values()].map(e=>({component:e,relayout:!1}))];return this._collapseAnimation=runCollapse(r,n,a,this._collapseAnimation,this._pendingCollapseTransitions,()=>{this._collapseAnimation=null,this._collapsing=!1,r.doLayout()}),this}isRegionCollapsible(e){return e===f.CENTER?!1:this._collapsible.get(e)??!1}setRegionCollapsible(e,t){return e===f.CENTER?this:(this._collapsible.set(e,t),this.getContainer()?.scheduleLayout(),this)}ensureGutter(t){let n=this._gutters.get(t);if(n)return n;let r=this.getContainer();return n=new T(t===f.NORTH||t===f.SOUTH?`vertical`:`horizontal`,{movable:!1,opaque:!1,collapseDirection:D[t],expandedBackground:`transparent`,listeners:{collapse:()=>this.setRegionCollapsed(t,!this.isRegionCollapsed(t))}}),n.setVisible(!1),e.sink.appendChild(r.getElement(),n.getElement(!0)),this._gutters.set(t,n),n}regionExtent(e,t){return this.isRegionCollapsed(e)?18:t}flooredMainExtent(e,t,n){let r=t?n?t.height:t.width:0;return Math.max(e,r)}applyRegionClip(e,t){if(this.isRegionCollapsible(t)){if(!this.isRegionCollapsed(t)){e.setClipPath(`inset(0 0 0 0)`);return}switch(t){case f.WEST:e.setClipPath(`inset(0 100% 0 0)`);break;case f.EAST:e.setClipPath(`inset(0 0 0 100%)`);break;case f.NORTH:e.setClipPath(`inset(0 0 100% 0)`);break;case f.SOUTH:e.setClipPath(`inset(100% 0 0 0)`)}}}updateRegionGutter(e,t,n,r,i){let a=this.getRegionComponent(e);if(!a)return;if(!this.isRegionCollapsible(e)){a.setVisible(!0),this._gutters.get(e)?.setVisible(!1);return}let o=this.isRegionCollapsed(e),s=this.ensureGutter(e);a.setVisible(!0),s.setOpaque(o),s.setVisible(!0);let c=o?{x:t,y:n,width:r,height:i}:this.innerEdgeTrack(e,t,n,r,i);s.setX(c.x),s.setY(c.y),s.setWidth(c.width),s.setHeight(c.height)}innerEdgeTrack(e,t,n,r,i){switch(e){case f.NORTH:return{x:t,y:n+i,width:r,height:E};case f.SOUTH:return{x:t,y:n-E,width:r,height:E};case f.WEST:return{x:t+r,y:n,width:E,height:i};case f.EAST:return{x:t-E,y:n,width:E,height:i};default:return{x:t,y:n,width:r,height:i}}}laidOut(e){return e&&e.isDisplayed()?e:null}getPreferredSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=0,a=0,o=0,s=0,c=this.laidOut(this._northComponent),l=this.laidOut(this._southComponent),u=this.laidOut(this._westComponent),d=this.laidOut(this._centerComponent),p=this.laidOut(this._eastComponent);if(c){let e=c.getPreferredSize();if(e){let t=this.flooredMainExtent(e.height,c.getMinSize(),!0);i=Math.max(i,e.width),a+=this.isRegionCollapsed(f.NORTH)?18:t}}if(l){let e=l.getPreferredSize();if(e){let t=this.flooredMainExtent(e.height,l.getMinSize(),!0);i=Math.max(i,e.width),a+=this.isRegionCollapsed(f.SOUTH)?18:t}}if(u){let e=u.getPreferredSize();if(e){let t=this.flooredMainExtent(e.width,u.getMinSize(),!1);o+=this.isRegionCollapsed(f.WEST)?18:t,s=Math.max(s,e.height)}}if(d){let e=d.getPreferredSize();e&&(o+=e.width,s=Math.max(s,e.height))}if(p){let e=p.getPreferredSize();if(e){let t=this.flooredMainExtent(e.width,p.getMinSize(),!1);o+=this.isRegionCollapsed(f.EAST)?18:t,s=Math.max(s,e.height)}}return i=Math.max(i,o),a+=s,{width:i+n,height:a+r}}getMinSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=0,a=0,o=0,s=0,c=this.laidOut(this._northComponent),l=this.laidOut(this._southComponent),u=this.laidOut(this._westComponent),d=this.laidOut(this._centerComponent),p=this.laidOut(this._eastComponent);if(c){let e=c.getMinSize();e&&(i=Math.max(i,e.width),a+=this.isRegionCollapsed(f.NORTH)?18:e.height)}if(l){let e=l.getMinSize();e&&(i=Math.max(i,e.width),a+=this.isRegionCollapsed(f.SOUTH)?18:e.height)}if(u){let e=u.getMinSize();e&&(o+=this.isRegionCollapsed(f.WEST)?18:e.width,s=Math.max(s,e.height))}if(d){let e=d.getMinSize();e&&(o+=e.width,s=Math.max(s,e.height))}if(p){let e=p.getMinSize();e&&(o+=this.isRegionCollapsed(f.EAST)?18:e.width,s=Math.max(s,e.height))}return i=Math.max(i,o),a+=s,{width:i+n,height:a+r}}getMaxSize(){let e=this.getContainer();if(!e)return null;let r=e.getPerimeterSize(),i=r.left+r.right,a=r.top+r.bottom,maxOf=e=>this.laidOut(e)?e.getMaxSize()??{width:t,height:t}:null,o=maxOf(this._northComponent),s=maxOf(this._southComponent),c=maxOf(this._westComponent),l=maxOf(this._centerComponent),u=maxOf(this._eastComponent),d=0,f=0,p=!1;for(let e of[c,l,u])e&&(p=!0,d+=e.width,f=Math.max(f,e.height));let m=t;o&&(m=Math.min(m,o.width)),s&&(m=Math.min(m,s.width)),p&&(m=Math.min(m,d));let h=0;return o&&(h+=o.height),p&&(h+=f),s&&(h+=s.height),{width:n(m+i),height:n(h+a)}}computeTotalMinSize(){if(!this.getContainer())return{width:0,height:0};let e=this.laidOut(this._westComponent)?.getMinSize(),t=this.laidOut(this._centerComponent)?.getMinSize(),n=this.laidOut(this._eastComponent)?.getMinSize(),r=this.laidOut(this._northComponent)?.getMinSize(),i=this.laidOut(this._southComponent)?.getMinSize(),a=[];e&&a.push(this.isRegionCollapsed(f.WEST)?18:e.width),t&&a.push(t.width),n&&a.push(this.isRegionCollapsed(f.EAST)?18:n.width);let o=[];r&&o.push(this.isRegionCollapsed(f.NORTH)?18:r.height),t&&o.push(t.height),i&&o.push(this.isRegionCollapsed(f.SOUTH)?18:i.height);let s=0,c=0;for(let e of a)s+=e;s+=Math.max(0,a.length-1)*this._spacing,r&&(s=Math.max(s,r.width)),i&&(s=Math.max(s,i.width));for(let e of o)c+=e;return c+=Math.max(0,o.length-1)*this._spacing,{width:s,height:c}}clearSkippedRegionFrames(...e){[this._northComponent,this._southComponent,this._westComponent,this._centerComponent,this._eastComponent].forEach((t,n)=>{t&&!e[n]&&t.clearClipFrame()})}doLayout(){let e=this.getContainer();if(!e)return;let t=e.getInnerSize();if(!t)return;let n=e.getContentInsets();t=this.inflateForOverflow(t);let r=this.laidOut(this._northComponent),i=this.laidOut(this._southComponent),a=this.laidOut(this._westComponent),o=this.laidOut(this._centerComponent),c=this.laidOut(this._eastComponent);this.clearSkippedRegionFrames(r,i,a,o,c);let l=t.width,u=t.height,d,p,m,h;if(r){let e=this.getLayoutConstraints(r);if(!e)throw Error(`Unable to determine layout constraints for north component.`);let t=r.getPreferredSize();if(!t)throw Error(`Unable to determine preferred size for north component.`);let u=this.flooredMainExtent(t.height,r.getMinSize(),!0),d=this.regionExtent(f.NORTH,u),m=e.ignoreParentInsets?0:n.getLeft(),h=e.ignoreParentInsets?0:n.getTop(),g=l+(e.ignoreParentInsets?n.getLeft()+n.getRight():0),_=e.ignoreParentInsets?n.getTop():0;p=d+_,this.isRegionCollapsible(f.NORTH)||this._collapsing?(this.placeComponent(r,m,h,g,u+_,s.BOTH),r.clearClipFrame(),this.applyRegionClip(r,f.NORTH)):(r.setClipPath(null),r.setClipFrame(m,h,g,u+_),this.commitBounds(r,0,0,g,u+_)),this.updateRegionGutter(f.NORTH,m,h,g,p),(a||o||c||i)&&(p+=this._spacing)}else p=0;if(h=u-p,i){let e=i.getPreferredSize();if(!e)throw Error(`Unable to determine preferred size for south component.`);let t=this.flooredMainExtent(e.height,i.getMinSize(),!0),r=this.regionExtent(f.SOUTH,t),a=n.getLeft(),o=n.getTop()+u-r;h-=this._spacing,h-=r;let c=n.getTop()+u-t;this.isRegionCollapsible(f.SOUTH)||this._collapsing?(this.placeComponent(i,a,c,l,t,s.BOTH),i.clearClipFrame(),this.applyRegionClip(i,f.SOUTH)):(i.setClipPath(null),i.setClipFrame(a,c,l,t),this.commitBounds(i,0,0,l,t)),this.updateRegionGutter(f.SOUTH,a,o,l,r)}let g=0,_=0;if(c){let e=c.getPreferredSize();if(!e)throw Error(`Unable to determine preferred size for east component.`);let t=this.flooredMainExtent(e.width,c.getMinSize(),!1);_=t,g=this.regionExtent(f.EAST,t)}if(a){let e=a.getPreferredSize();if(!e)throw Error(`Unable to determine preferred size for west component.`);let t=this.flooredMainExtent(e.width,a.getMinSize(),!1),r=Math.max(0,Math.min(this.regionExtent(f.WEST,t),l-g)),i=n.getLeft(),c=n.getTop()+p;d=r;let u=Math.max(0,Math.min(t,l-g));this.isRegionCollapsible(f.WEST)||this._collapsing?(this.placeComponent(a,i,c,u,h,s.BOTH),a.clearClipFrame(),this.applyRegionClip(a,f.WEST)):(a.setClipPath(null),a.setClipFrame(i,c,u,h),this.commitBounds(a,0,0,u,h)),this.updateRegionGutter(f.WEST,i,c,r,h),o&&(d+=this._spacing)}else d=0;if(m=l-d,c){m-=this._spacing,m-=g;let e=n.getLeft()+l-g,t=n.getTop()+p,r=n.getLeft()+l-_;this.isRegionCollapsible(f.EAST)||this._collapsing?(this.placeComponent(c,r,t,_,h,s.BOTH),c.clearClipFrame(),this.applyRegionClip(c,f.EAST)):(c.setClipPath(null),c.setClipFrame(r,t,_,h),this.commitBounds(c,0,0,_,h)),this.updateRegionGutter(f.EAST,e,t,g,h)}if(o){let e=n.getLeft()+d,t=n.getTop()+p;this._collapsing?(this.placeComponent(o,e,t,m,h,s.BOTH),o.clearClipFrame()):(o.setClipFrame(e,t,m,h),this.commitBounds(o,0,0,m,h))}}detach(){this._collapseAnimation?.(),this._collapseAnimation=null,this._collapsing=!1;let t=(this.getContainer()?.getComponents().length??0)>0;for(let e of this._pendingCollapseTransitions)t?e.settle():e.cancel();this._pendingCollapseTransitions.length=0,super.detach();for(let t of this._gutters.values()){let n=t.getElement(),r=n?e.source.getParentNode(n):null;n&&r&&e.sink.removeChild(r,n),t.dispose()}this._gutters.clear();for(let e of[f.NORTH,f.SOUTH,f.WEST,f.EAST,f.CENTER])this.getRegionComponent(e)?.clearClipFrame();return this}},O=o(Border);export{beginPointerDrag as a,runCollapse as i,T as n,endPointerDrag as o,S as r,O as t};
|
|
2
|
+
//# sourceMappingURL=Border-CNS6aEXB.js.map
|