@nvidia-elements/forms 2.0.10 → 2.0.12
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/CHANGELOG.md +35 -0
- package/dist/custom-elements.json +21 -1
- package/dist/examples/csv.examples.js +1 -2
- package/dist/examples/csv.examples.js.map +1 -1
- package/dist/examples/light.examples.js +1 -2
- package/dist/examples/light.examples.js.map +1 -1
- package/dist/examples/simple.examples.js +1 -2
- package/dist/examples/simple.examples.js.map +1 -1
- package/dist/examples/visualization.examples.js +1 -2
- package/dist/examples/visualization.examples.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/controllers/state-active.controller.js +1 -2
- package/dist/internal/controllers/state-active.controller.js.map +1 -1
- package/dist/internal/controllers/state-current.controller.js +3 -16
- package/dist/internal/controllers/state-current.controller.js.map +1 -1
- package/dist/internal/controllers/state-disabled.controller.js +1 -2
- package/dist/internal/controllers/state-disabled.controller.js.map +1 -1
- package/dist/internal/controllers/state-expanded.controller.js +1 -2
- package/dist/internal/controllers/state-expanded.controller.js.map +1 -1
- package/dist/internal/controllers/state-pressed.controller.js +1 -2
- package/dist/internal/controllers/state-pressed.controller.js.map +1 -1
- package/dist/internal/controllers/state-readonly.controller.js +1 -2
- package/dist/internal/controllers/state-readonly.controller.js.map +1 -1
- package/dist/internal/controllers/state-selected.controller.js +3 -16
- package/dist/internal/controllers/state-selected.controller.js.map +1 -1
- package/dist/internal/controllers/type-anchor.controller.js +1 -2
- package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.js +8 -8
- package/dist/internal/controllers/type-button.controller.js.map +1 -1
- package/dist/internal/controllers/type-command.controller.js +1 -2
- package/dist/internal/controllers/type-command.controller.js.map +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.js +2 -3
- package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.js +1 -2
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/internal/controllers/type-submit.controller.js +2 -7
- package/dist/internal/controllers/type-submit.controller.js.map +1 -1
- package/dist/internal/errors.js +1 -2
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/index.js +1 -2
- package/dist/internal/schema.js +1 -2
- package/dist/internal/schema.js.map +1 -1
- package/dist/internal/utils.js +1 -2
- package/dist/internal/utils.js.map +1 -1
- package/dist/mixins/button.js +12 -19
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/checkbox.js +2 -9
- package/dist/mixins/checkbox.js.map +1 -1
- package/dist/mixins/control.js +3 -12
- package/dist/mixins/control.js.map +1 -1
- package/dist/mixins/select.js +1 -2
- package/dist/mixins/select.js.map +1 -1
- package/dist/mixins/slider.js +1 -2
- package/dist/mixins/slider.js.map +1 -1
- package/dist/validators/index.js +1 -2
- package/dist/validators/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/controllers/type-button.controller.ts
|
|
2
2
|
var e = class {
|
|
3
3
|
#e = null;
|
|
4
4
|
#t = 0;
|
|
5
|
+
#n;
|
|
5
6
|
constructor(e) {
|
|
6
7
|
this.host = e, this.host.addController(this);
|
|
7
8
|
}
|
|
8
9
|
hostConnected() {
|
|
9
|
-
this.host.hasAttribute("tabindex") && (this.#t = this.host.tabIndex);
|
|
10
|
+
this.#n === void 0 && this.host.hasAttribute("tabindex") && (this.#t = this.host.tabIndex);
|
|
10
11
|
}
|
|
11
12
|
hostUpdated() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
this.#r(), this.host.readOnly ? (this.host._internals.role && this.host._internals.role !== "none" && (this.#e = this.host._internals.role), this.host._internals.role = "none") : !this.host._internals.role || this.host._internals.role === "none" ? this.host._internals.role = this.#e ?? "button" : this.#e = this.host._internals.role;
|
|
14
|
+
}
|
|
15
|
+
#r() {
|
|
16
|
+
let e = this.host.disabled || this.host.readOnly, t = this.#n === void 0 || this.#n && !e;
|
|
17
|
+
e && this.#n === !1 && (this.#t = this.host.tabIndex), this.#n = e, this.host.readOnly ? (this.host.tabIndex = -1, this.host.removeAttribute("tabindex")) : this.host.disabled ? this.host.tabIndex = -1 : t && (this.host.tabIndex = this.#t);
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
|
-
//#endregion
|
|
20
20
|
export { e as TypeButtonController };
|
|
21
21
|
|
|
22
22
|
//# sourceMappingURL=type-button.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-button.controller.js","names":[],"sources":["../../../src/internal/controllers/type-button.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype ButtonBehaviorHost = ReactiveElement & {\n disabled: boolean;\n readOnly: boolean;\n _internals?: ElementInternals;\n};\n\nexport class TypeButtonController<T extends ButtonBehaviorHost> implements ReactiveController {\n #enabledRole: string | null = null;\n #
|
|
1
|
+
{"version":3,"file":"type-button.controller.js","names":["TypeButtonController","host","#unavailable","#enabledTabIndex","#updateTabIndex","#enabledRole","unavailable","restore"],"sources":["../../../src/internal/controllers/type-button.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype ButtonBehaviorHost = ReactiveElement & {\n disabled: boolean;\n readOnly: boolean;\n _internals?: ElementInternals;\n};\n\nexport class TypeButtonController<T extends ButtonBehaviorHost> implements ReactiveController {\n #enabledRole: string | null = null;\n #enabledTabIndex = 0;\n #unavailable?: boolean;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n if (this.#unavailable === undefined && this.host.hasAttribute('tabindex')) {\n this.#enabledTabIndex = this.host.tabIndex;\n }\n }\n\n hostUpdated() {\n this.#updateTabIndex();\n if (this.host.readOnly) {\n if (this.host._internals!.role && this.host._internals!.role !== 'none') {\n this.#enabledRole = this.host._internals!.role;\n }\n\n this.host._internals!.role = 'none';\n return;\n }\n\n if (!this.host._internals!.role || this.host._internals!.role === 'none') {\n this.host._internals!.role = this.#enabledRole ?? 'button';\n } else {\n this.#enabledRole = this.host._internals!.role;\n }\n }\n\n #updateTabIndex() {\n const unavailable = this.host.disabled || this.host.readOnly;\n const restore = this.#unavailable === undefined || (this.#unavailable && !unavailable);\n\n if (unavailable && this.#unavailable === false) {\n this.#enabledTabIndex = this.host.tabIndex;\n }\n\n this.#unavailable = unavailable;\n if (this.host.readOnly) {\n this.host.tabIndex = -1;\n this.host.removeAttribute('tabindex');\n } else if (this.host.disabled) {\n this.host.tabIndex = -1;\n } else if (restore) {\n this.host.tabIndex = this.#enabledTabIndex;\n }\n }\n}\n"],"mappings":";AAWA,IAAaA,IAAb,MAA8F;CAC5F,KAA8B;CAC9B,KAAmB;CACnB;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,AAAI,KAAKC,OAAiB,KAAA,KAAa,KAAK,KAAK,aAAa,UAAU,MACtE,KAAKC,KAAmB,KAAK,KAAK;CAEtC;CAEA,cAAc;EAEZ,AADA,KAAKC,GAAgB,GACjB,KAAK,KAAK,YACR,KAAK,KAAK,WAAY,QAAQ,KAAK,KAAK,WAAY,SAAS,WAC/D,KAAKC,KAAe,KAAK,KAAK,WAAY,OAG5C,KAAK,KAAK,WAAY,OAAO,UAI3B,CAAC,KAAK,KAAK,WAAY,QAAQ,KAAK,KAAK,WAAY,SAAS,SAChE,KAAK,KAAK,WAAY,OAAO,KAAKA,MAAgB,WAElD,KAAKA,KAAe,KAAK,KAAK,WAAY;CAE9C;CAEA,KAAkB;EAChB,IAAMC,IAAc,KAAK,KAAK,YAAY,KAAK,KAAK,UAC9CC,IAAU,KAAKL,OAAiB,KAAA,KAAc,KAAKA,MAAgB,CAACI;EAO1E,AALIA,KAAe,KAAKJ,OAAiB,OACvC,KAAKC,KAAmB,KAAK,KAAK,WAGpC,KAAKD,KAAeI,GAChB,KAAK,KAAK,YACZ,KAAK,KAAK,WAAW,IACrB,KAAK,KAAK,gBAAgB,UAAU,KAC3B,KAAK,KAAK,WACnB,KAAK,KAAK,WAAW,KACZC,MACT,KAAK,KAAK,WAAW,KAAKJ;CAE9B;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/type-command.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
#e;
|
|
5
5
|
constructor(e, { events: t = ["click"] } = {}) {
|
|
@@ -31,7 +31,6 @@ var t = class {
|
|
|
31
31
|
return t ? e(this.host.getRootNode()).find((e) => e.id === t) ?? null : null;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { t as TypeCommandController };
|
|
36
35
|
|
|
37
36
|
//# sourceMappingURL=type-command.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-command.controller.js","names":[],"sources":["../../../src/internal/controllers/type-command.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype CommandBehaviorHost = ReactiveElement & {\n command?: string;\n commandForElement: HTMLElement | null;\n disabled?: boolean;\n readOnly?: boolean;\n};\n\ntype TypeCommandControllerOptions = {\n events?: readonly string[];\n};\n\nexport class TypeCommandController<T extends CommandBehaviorHost> implements ReactiveController {\n readonly #events: readonly string[];\n\n constructor(\n private host: T,\n { events = ['click'] }: TypeCommandControllerOptions = {}\n ) {\n this.#events = [...new Set(events)];\n this.host.addController(this);\n }\n\n hostUpdated() {\n this.#removeCommandBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.#events.forEach(eventType => this.host.addEventListener(eventType, this.#onCommand));\n }\n }\n\n hostDisconnected() {\n this.#removeCommandBehavior();\n }\n\n #removeCommandBehavior() {\n this.#events.forEach(eventType => this.host.removeEventListener(eventType, this.#onCommand));\n }\n\n #onCommand = (event: Event) => {\n if (!event.defaultPrevented) {\n this.invoke();\n }\n };\n\n /** Dispatches the configured command for controls that handle their own activation. */\n invoke() {\n if (this.host.readOnly || this.host.disabled || !this.host.command) {\n return false;\n }\n\n const target = this.target;\n if (!target) {\n console.warn(\n 'commandForElement',\n this.host.commandForElement || this.host.getAttribute('commandfor'),\n 'not found'\n );\n return false;\n }\n\n target.dispatchEvent(new globalThis.CommandEvent('command', { command: this.host.command, source: this.host }));\n return true;\n }\n\n get target(): HTMLElement | null {\n if (this.host.commandForElement) {\n return this.host.commandForElement;\n }\n\n const id = this.host.getAttribute('commandfor');\n if (!id) {\n return null;\n }\n\n return getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(el => el.id === id) ?? null;\n }\n}\n"],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"type-command.controller.js","names":["TypeCommandController","host","#events","events","#removeCommandBehavior","eventType","#onCommand","event","target","id","getFlattenedDOMTree","el"],"sources":["../../../src/internal/controllers/type-command.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype CommandBehaviorHost = ReactiveElement & {\n command?: string;\n commandForElement: HTMLElement | null;\n disabled?: boolean;\n readOnly?: boolean;\n};\n\ntype TypeCommandControllerOptions = {\n events?: readonly string[];\n};\n\nexport class TypeCommandController<T extends CommandBehaviorHost> implements ReactiveController {\n readonly #events: readonly string[];\n\n constructor(\n private host: T,\n { events = ['click'] }: TypeCommandControllerOptions = {}\n ) {\n this.#events = [...new Set(events)];\n this.host.addController(this);\n }\n\n hostUpdated() {\n this.#removeCommandBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.#events.forEach(eventType => this.host.addEventListener(eventType, this.#onCommand));\n }\n }\n\n hostDisconnected() {\n this.#removeCommandBehavior();\n }\n\n #removeCommandBehavior() {\n this.#events.forEach(eventType => this.host.removeEventListener(eventType, this.#onCommand));\n }\n\n #onCommand = (event: Event) => {\n if (!event.defaultPrevented) {\n this.invoke();\n }\n };\n\n /** Dispatches the configured command for controls that handle their own activation. */\n invoke() {\n if (this.host.readOnly || this.host.disabled || !this.host.command) {\n return false;\n }\n\n const target = this.target;\n if (!target) {\n console.warn(\n 'commandForElement',\n this.host.commandForElement || this.host.getAttribute('commandfor'),\n 'not found'\n );\n return false;\n }\n\n target.dispatchEvent(new globalThis.CommandEvent('command', { command: this.host.command, source: this.host }));\n return true;\n }\n\n get target(): HTMLElement | null {\n if (this.host.commandForElement) {\n return this.host.commandForElement;\n }\n\n const id = this.host.getAttribute('commandfor');\n if (!id) {\n return null;\n }\n\n return getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(el => el.id === id) ?? null;\n }\n}\n"],"mappings":";;AAiBA,IAAaA,IAAb,MAAgG;CAC9F;CAEA,YACE,GACA,EAAE,YAAS,CAAC,OAAO,MAAoC,CAAC,GACxD;EAEA,AAJQ,KAAA,OAAAC,GAGR,KAAKC,KAAU,CAAC,GAAG,IAAI,IAAIC,CAAM,CAAC,GAClC,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,cAAc;EAEZ,AADA,KAAKC,GAAuB,GACxB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,YACpC,KAAKF,GAAQ,SAAQ,MAAa,KAAK,KAAK,iBAAiBG,GAAW,KAAKC,EAAU,CAAC;CAE5F;CAEA,mBAAmB;EACjB,KAAKF,GAAuB;CAC9B;CAEA,KAAyB;EACvB,KAAKF,GAAQ,SAAQ,MAAa,KAAK,KAAK,oBAAoBG,GAAW,KAAKC,EAAU,CAAC;CAC7F;CAEA,MAAc,MAAiB;EAC7B,AAAKC,EAAM,oBACT,KAAK,OAAO;CAEhB;CAGA,SAAS;EACP,IAAI,KAAK,KAAK,YAAY,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,SACzD,OAAO;EAGT,IAAMC,IAAS,KAAK;EAWpB,OAVKA,KASLA,EAAO,cAAc,IAAI,WAAW,aAAa,WAAW;GAAE,SAAS,KAAK,KAAK;GAAS,QAAQ,KAAK;EAAK,CAAC,CAAC,GACvG,OATL,QAAQ,KACN,qBACA,KAAK,KAAK,qBAAqB,KAAK,KAAK,aAAa,YAAY,GAClE,WACF,GACO;CAKX;CAEA,IAAI,SAA6B;EAC/B,IAAI,KAAK,KAAK,mBACZ,OAAO,KAAK,KAAK;EAGnB,IAAMC,IAAK,KAAK,KAAK,aAAa,YAAY;EAK9C,OAJKA,IAIEC,EAAoB,KAAK,KAAK,YAAY,CAAgB,CAAC,CAAC,MAAK,MAAMC,EAAG,OAAOF,CAAE,KAAK,OAHtF;CAIX;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/type-interest-invoker.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
#e = null;
|
|
5
5
|
constructor(e) {
|
|
@@ -31,7 +31,7 @@ var t = class {
|
|
|
31
31
|
let e = this.host.getAttribute("interestfor");
|
|
32
32
|
if (e) return this.#e = null, this.#s(e);
|
|
33
33
|
let t = this.host.interestForElement;
|
|
34
|
-
if (
|
|
34
|
+
if (t && t !== this.#e) return this.#e = null, t;
|
|
35
35
|
}
|
|
36
36
|
#o() {
|
|
37
37
|
let e = this.host.popoverTargetElement;
|
|
@@ -43,7 +43,6 @@ var t = class {
|
|
|
43
43
|
return t ? e(this.host.getRootNode()).find((e) => e.id === t) ?? null : null;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
//#endregion
|
|
47
46
|
export { t as TypeInterestInvokerController };
|
|
48
47
|
|
|
49
48
|
//# sourceMappingURL=type-interest-invoker.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-interest-invoker.controller.js","names":[],"sources":["../../../src/internal/controllers/type-interest-invoker.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype InterestInvokerHost = ReactiveElement & {\n interestForElement: HTMLElement | null;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypeInterestInvokerController<T extends InterestInvokerHost> implements ReactiveController {\n #inferredInterestForElement: HTMLElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('mouseenter', this.#onInterest);\n this.host.addEventListener('mouseleave', this.#onLoseInterest);\n this.host.addEventListener('focus', this.#onInterest);\n this.host.addEventListener('blur', this.#onLoseInterest);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('mouseenter', this.#onInterest);\n this.host.removeEventListener('mouseleave', this.#onLoseInterest);\n this.host.removeEventListener('focus', this.#onInterest);\n this.host.removeEventListener('blur', this.#onLoseInterest);\n }\n\n #onInterest = (event: Event) => {\n if (event.type === 'focus' && !this.host.matches(':focus-visible')) {\n return;\n }\n\n if (this.host.popoverTargetElement?.matches(':popover-open')) {\n return;\n }\n\n this.#dispatchInterestEvent('interest');\n };\n\n #onLoseInterest = () => this.#dispatchInterestEvent('loseinterest');\n\n #dispatchInterestEvent(type: 'interest' | 'loseinterest') {\n const target = this.#getInterestForElement();\n if (!target) {\n return;\n }\n\n const event = new Event(type, { cancelable: true }) as InterestEvent;\n event.source = this.host;\n target.dispatchEvent(event);\n }\n\n #getInterestForElement() {\n const explicitTarget = this.#getExplicitInterestForElement();\n if (explicitTarget !== undefined) {\n return explicitTarget;\n }\n\n const inferredTarget = this.#getHintPopoverTarget();\n const previousTarget = this.#inferredInterestForElement;\n this.#inferredInterestForElement = inferredTarget;\n if (inferredTarget && this.host.interestForElement !== inferredTarget) {\n this.host.interestForElement = inferredTarget;\n } else if (!inferredTarget && previousTarget && this.host.interestForElement === previousTarget) {\n this.host.interestForElement = null;\n }\n return inferredTarget;\n }\n\n #getExplicitInterestForElement(): HTMLElement | null | undefined {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef) {\n this.#inferredInterestForElement = null;\n return this.#getElementById(interestForIdRef);\n }\n\n const interestForElement = this.host.interestForElement;\n if (!interestForElement || interestForElement === this.#inferredInterestForElement) {\n return undefined;\n }\n\n this.#inferredInterestForElement = null;\n return interestForElement;\n }\n\n #getHintPopoverTarget() {\n const popoverTarget = this.host.popoverTargetElement;\n if (popoverTarget instanceof HTMLElement && popoverTarget.popover === 'hint') {\n return popoverTarget;\n }\n\n const target = this.#getElementById(this.host.getAttribute('popovertarget'));\n return target instanceof HTMLElement && target.popover === 'hint' ? target : null;\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.host.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n}\n"],"mappings":";;AAaA,
|
|
1
|
+
{"version":3,"file":"type-interest-invoker.controller.js","names":["TypeInterestInvokerController","host","#onInterest","#onLoseInterest","event","#dispatchInterestEvent","target","#getInterestForElement","type","explicitTarget","#getExplicitInterestForElement","inferredTarget","#getHintPopoverTarget","previousTarget","#inferredInterestForElement","interestForIdRef","#getElementById","interestForElement","popoverTarget","id","getFlattenedDOMTree","element"],"sources":["../../../src/internal/controllers/type-interest-invoker.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype InterestInvokerHost = ReactiveElement & {\n interestForElement: HTMLElement | null;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypeInterestInvokerController<T extends InterestInvokerHost> implements ReactiveController {\n #inferredInterestForElement: HTMLElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('mouseenter', this.#onInterest);\n this.host.addEventListener('mouseleave', this.#onLoseInterest);\n this.host.addEventListener('focus', this.#onInterest);\n this.host.addEventListener('blur', this.#onLoseInterest);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('mouseenter', this.#onInterest);\n this.host.removeEventListener('mouseleave', this.#onLoseInterest);\n this.host.removeEventListener('focus', this.#onInterest);\n this.host.removeEventListener('blur', this.#onLoseInterest);\n }\n\n #onInterest = (event: Event) => {\n if (event.type === 'focus' && !this.host.matches(':focus-visible')) {\n return;\n }\n\n if (this.host.popoverTargetElement?.matches(':popover-open')) {\n return;\n }\n\n this.#dispatchInterestEvent('interest');\n };\n\n #onLoseInterest = () => this.#dispatchInterestEvent('loseinterest');\n\n #dispatchInterestEvent(type: 'interest' | 'loseinterest') {\n const target = this.#getInterestForElement();\n if (!target) {\n return;\n }\n\n const event = new Event(type, { cancelable: true }) as InterestEvent;\n event.source = this.host;\n target.dispatchEvent(event);\n }\n\n #getInterestForElement() {\n const explicitTarget = this.#getExplicitInterestForElement();\n if (explicitTarget !== undefined) {\n return explicitTarget;\n }\n\n const inferredTarget = this.#getHintPopoverTarget();\n const previousTarget = this.#inferredInterestForElement;\n this.#inferredInterestForElement = inferredTarget;\n if (inferredTarget && this.host.interestForElement !== inferredTarget) {\n this.host.interestForElement = inferredTarget;\n } else if (!inferredTarget && previousTarget && this.host.interestForElement === previousTarget) {\n this.host.interestForElement = null;\n }\n return inferredTarget;\n }\n\n #getExplicitInterestForElement(): HTMLElement | null | undefined {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef) {\n this.#inferredInterestForElement = null;\n return this.#getElementById(interestForIdRef);\n }\n\n const interestForElement = this.host.interestForElement;\n if (!interestForElement || interestForElement === this.#inferredInterestForElement) {\n return undefined;\n }\n\n this.#inferredInterestForElement = null;\n return interestForElement;\n }\n\n #getHintPopoverTarget() {\n const popoverTarget = this.host.popoverTargetElement;\n if (popoverTarget instanceof HTMLElement && popoverTarget.popover === 'hint') {\n return popoverTarget;\n }\n\n const target = this.#getElementById(this.host.getAttribute('popovertarget'));\n return target instanceof HTMLElement && target.popover === 'hint' ? target : null;\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.host.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n}\n"],"mappings":";;AAaA,IAAaA,IAAb,MAAwG;CACtG,KAAkD;CAElD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAId,AAHA,KAAK,KAAK,iBAAiB,cAAc,KAAKC,EAAW,GACzD,KAAK,KAAK,iBAAiB,cAAc,KAAKC,EAAe,GAC7D,KAAK,KAAK,iBAAiB,SAAS,KAAKD,EAAW,GACpD,KAAK,KAAK,iBAAiB,QAAQ,KAAKC,EAAe;CACzD;CAEA,mBAAmB;EAIjB,AAHA,KAAK,KAAK,oBAAoB,cAAc,KAAKD,EAAW,GAC5D,KAAK,KAAK,oBAAoB,cAAc,KAAKC,EAAe,GAChE,KAAK,KAAK,oBAAoB,SAAS,KAAKD,EAAW,GACvD,KAAK,KAAK,oBAAoB,QAAQ,KAAKC,EAAe;CAC5D;CAEA,MAAe,MAAiB;EAC9B,AAAIC,EAAM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MAAWC,EAAQ,OAAOF,CAAE,KAAK,OAAQ;CAC1G;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e, getHostAnchor as t } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/type-popover-trigger.controller.ts
|
|
3
3
|
var n = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -38,7 +38,6 @@ var n = class {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
//#endregion
|
|
42
41
|
export { n as TypePopoverTriggerController };
|
|
43
42
|
|
|
44
43
|
//# sourceMappingURL=type-popover-trigger.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-popover-trigger.controller.js","names":[],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../types/button.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#onClick);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#onClick);\n }\n\n #resolvedPopoverTarget: HTMLElement | null | undefined;\n\n #resolvePopoverTarget() {\n const popoverTargetElement = this.host.popoverTargetElement;\n const controllerResolvedTarget = popoverTargetElement === this.#resolvedPopoverTarget;\n\n if (!this.host.getAttribute('popovertarget')) {\n this.#resolvedPopoverTarget = undefined;\n if (controllerResolvedTarget) {\n this.host.popoverTargetElement = null;\n return null;\n }\n\n return popoverTargetElement;\n }\n\n if (popoverTargetElement && !controllerResolvedTarget) {\n return popoverTargetElement;\n }\n\n const resolvedPopoverTarget =\n getFlattenedDOMTree(this.host.getRootNode()).find(\n element => element.id === this.host.getAttribute('popovertarget')\n ) ?? null;\n if (resolvedPopoverTarget !== popoverTargetElement) {\n this.host.popoverTargetElement = resolvedPopoverTarget;\n }\n this.#resolvedPopoverTarget = resolvedPopoverTarget;\n\n return resolvedPopoverTarget;\n }\n\n #onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || this.host.disabled) {\n return;\n }\n\n const popoverTargetElement = this.#resolvePopoverTarget();\n if (!popoverTargetElement) {\n return;\n }\n\n if (this.#invokePopover(popoverTargetElement)) {\n this.#handoverInterest();\n }\n };\n\n #getPopoverSource(popoverTargetElement: HTMLElement) {\n if ((popoverTargetElement as PopoverAnchorElement).anchor) {\n return getHostAnchor(popoverTargetElement as PopoverAnchorElement);\n }\n\n return this.host as HTMLElement;\n }\n\n #invokePopover(popoverTargetElement: HTMLElement) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n return false;\n }\n\n const source = this.#getPopoverSource(popoverTargetElement);\n if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n\n return popoverTargetElement.matches(':popover-open');\n }\n\n #handoverInterest() {\n if (this.host.interestForElement) {\n const loseInterest = new Event('loseinterest', { cancelable: true }) as InterestEvent;\n loseInterest.source = this.host;\n this.host.interestForElement.dispatchEvent(loseInterest);\n }\n }\n}\n"],"mappings":";;AAiBA,
|
|
1
|
+
{"version":3,"file":"type-popover-trigger.controller.js","names":["TypePopoverTriggerController","host","#onClick","popoverTargetElement","controllerResolvedTarget","#resolvedPopoverTarget","resolvedPopoverTarget","getFlattenedDOMTree","element","event","#resolvePopoverTarget","#invokePopover","#handoverInterest","getHostAnchor","source","#getPopoverSource","loseInterest"],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../types/button.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#onClick);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#onClick);\n }\n\n #resolvedPopoverTarget: HTMLElement | null | undefined;\n\n #resolvePopoverTarget() {\n const popoverTargetElement = this.host.popoverTargetElement;\n const controllerResolvedTarget = popoverTargetElement === this.#resolvedPopoverTarget;\n\n if (!this.host.getAttribute('popovertarget')) {\n this.#resolvedPopoverTarget = undefined;\n if (controllerResolvedTarget) {\n this.host.popoverTargetElement = null;\n return null;\n }\n\n return popoverTargetElement;\n }\n\n if (popoverTargetElement && !controllerResolvedTarget) {\n return popoverTargetElement;\n }\n\n const resolvedPopoverTarget =\n getFlattenedDOMTree(this.host.getRootNode()).find(\n element => element.id === this.host.getAttribute('popovertarget')\n ) ?? null;\n if (resolvedPopoverTarget !== popoverTargetElement) {\n this.host.popoverTargetElement = resolvedPopoverTarget;\n }\n this.#resolvedPopoverTarget = resolvedPopoverTarget;\n\n return resolvedPopoverTarget;\n }\n\n #onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || this.host.disabled) {\n return;\n }\n\n const popoverTargetElement = this.#resolvePopoverTarget();\n if (!popoverTargetElement) {\n return;\n }\n\n if (this.#invokePopover(popoverTargetElement)) {\n this.#handoverInterest();\n }\n };\n\n #getPopoverSource(popoverTargetElement: HTMLElement) {\n if ((popoverTargetElement as PopoverAnchorElement).anchor) {\n return getHostAnchor(popoverTargetElement as PopoverAnchorElement);\n }\n\n return this.host as HTMLElement;\n }\n\n #invokePopover(popoverTargetElement: HTMLElement) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n return false;\n }\n\n const source = this.#getPopoverSource(popoverTargetElement);\n if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n\n return popoverTargetElement.matches(':popover-open');\n }\n\n #handoverInterest() {\n if (this.host.interestForElement) {\n const loseInterest = new Event('loseinterest', { cancelable: true }) as InterestEvent;\n loseInterest.source = this.host;\n this.host.interestForElement.dispatchEvent(loseInterest);\n }\n }\n}\n"],"mappings":";;AAiBA,IAAaA,IAAb,MAAsG;CACpG,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAQ;CACnD;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAKA,EAAQ;CACtD;CAEA;CAEA,KAAwB;EACtB,IAAMC,IAAuB,KAAK,KAAK,sBACjCC,IAA2BD,MAAyB,KAAKE;EAE/D,IAAI,CAAC,KAAK,KAAK,aAAa,eAAe,GAOzC,OANA,KAAKA,KAAyB,KAAA,GAC1BD,KACF,KAAK,KAAK,uBAAuB,MAC1B,QAGFD;EAGT,IAAIA,KAAwB,CAACC,GAC3B,OAAOD;EAGT,IAAMG,IACJC,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAC3C,MAAWC,EAAQ,OAAO,KAAK,KAAK,aAAa,eAAe,CAClE,KAAK;EAMP,OALIF,MAA0BH,MAC5B,KAAK,KAAK,uBAAuBG,IAEnC,KAAKD,KAAyBC,GAEvBA;CACT;CAEA,MAAY,MAAsB;EAChC,IAAIG,EAAM,oBAAoB,KAAK,KAAK,UACtC;EAGF,IAAMN,IAAuB,KAAKO,GAAsB;EACxD,AAAKP,KAID,KAAKQ,GAAeR,CAAoB,KAC1C,KAAKS,GAAkB;CAE3B;CAEA,GAAkB,GAAmC;EAKnD,OAJKT,EAA8C,SAC1CU,EAAcV,CAA4C,IAG5D,KAAK;CACd;CAEA,GAAe,GAAmC;EAChD,IAAI,KAAK,KAAK,wBAAwB,QAEpC,OADAA,EAAqB,YAAY,GAC1B;EAGT,IAAMW,IAAS,KAAKC,GAAkBZ,CAAoB;EAO1D,OANI,KAAK,KAAK,wBAAwB,SACpCA,EAAqB,YAAY,EAAE,UAAO,CAAC,IAE3CA,EAAqB,cAAc,EAAE,UAAO,CAAC,GAGxCA,EAAqB,QAAQ,eAAe;CACrD;CAEA,KAAoB;EAClB,IAAI,KAAK,KAAK,oBAAoB;GAChC,IAAMa,IAAe,IAAI,MAAM,gBAAgB,EAAE,YAAY,GAAK,CAAC;GAEnE,AADA,EAAa,SAAS,KAAK,MAC3B,KAAK,KAAK,mBAAmB,cAAcA,CAAY;EACzD;CACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stopEvent as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/type-submit.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
#e;
|
|
5
5
|
#t;
|
|
@@ -26,11 +26,7 @@ var t = class {
|
|
|
26
26
|
(e.key === " " || e.key === "Enter" || e.code === "Space" || e.code === "Enter") && this.host.click();
|
|
27
27
|
};
|
|
28
28
|
#o = (t) => {
|
|
29
|
-
|
|
30
|
-
e(t);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
this.host.type === "submit" && this.host.form instanceof HTMLFormElement ? this.#s(this.host.form) : this.host.type === "reset" && this.host.form instanceof HTMLFormElement && this.host.form.reset();
|
|
29
|
+
this.host.disabled ? e(t) : this.host.type === "submit" && this.host.form instanceof HTMLFormElement ? this.#s(this.host.form) : this.host.type === "reset" && this.host.form instanceof HTMLFormElement && this.host.form.reset();
|
|
34
30
|
};
|
|
35
31
|
#s(e) {
|
|
36
32
|
this.#u(), this.#l(), this.#n = e, e.addEventListener("submit", this.#c, { once: !0 }), this.#t?.remove(), e.appendChild(this.#t), e.requestSubmit(this.#t);
|
|
@@ -48,7 +44,6 @@ var t = class {
|
|
|
48
44
|
this.#n?.removeEventListener("submit", this.#c), this.#n = void 0, this.#t?.remove(), this.#t = void 0;
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
|
-
//#endregion
|
|
52
47
|
export { t as TypeSubmitController };
|
|
53
48
|
|
|
54
49
|
//# sourceMappingURL=type-submit.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-submit.controller.js","names":[],"sources":["../../../src/internal/controllers/type-submit.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { stopEvent } from '../utils.js';\nimport type { ButtonType } from '../types/button.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype SubmitHost = ReactiveElement & {\n disabled: boolean;\n form: HTMLFormElement | null | string;\n name?: string;\n readOnly: boolean;\n type?: ButtonType;\n value?: string;\n};\n\nexport class TypeSubmitController<T extends SubmitHost> implements ReactiveController {\n #defaultType: ButtonType | undefined;\n #submitter: HTMLButtonElement | undefined;\n #submitterForm: HTMLFormElement | undefined;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get defaultType() {\n return this.#defaultType;\n }\n\n hostUpdated() {\n this.#setButtonType();\n this.#removeSubmitBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#onSubmitClick);\n this.host.addEventListener('keyup', this.#onSubmitKeyup);\n }\n }\n\n hostDisconnected() {\n this.#removeSubmitBehavior();\n this.#removeSubmitter();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.form instanceof HTMLFormElement) {\n this.#defaultType = 'submit';\n }\n }\n\n #removeSubmitBehavior() {\n this.host.removeEventListener('click', this.#onSubmitClick);\n this.host.removeEventListener('keyup', this.#onSubmitKeyup);\n }\n\n #onSubmitKeyup = (event: KeyboardEvent) => {\n if (event.key === ' ' || event.key === 'Enter' || event.code === 'Space' || event.code === 'Enter') {\n this.host.click();\n }\n };\n\n #onSubmitClick = (event: Event) => {\n if (this.host.disabled) {\n stopEvent(event);\n return;\n }\n\n if (this.host.type === 'submit' && this.host.form instanceof HTMLFormElement) {\n this.#requestSubmit(this.host.form);\n } else if (this.host.type === 'reset' && this.host.form instanceof HTMLFormElement) {\n this.host.form.reset();\n }\n };\n\n #requestSubmit(form: HTMLFormElement) {\n this.#removeSubmitter();\n this.#createSubmitter();\n this.#submitterForm = form;\n form.addEventListener('submit', this.#onSubmit, { once: true });\n this.#submitter?.remove();\n form.appendChild(this.#submitter!);\n form.requestSubmit(this.#submitter);\n }\n\n #onSubmit = () => {\n const submitter = this.#submitter;\n this.#submitterForm = undefined;\n setTimeout(() => {\n submitter?.remove();\n if (this.#submitter === submitter) {\n this.#submitter = undefined;\n }\n }, 0);\n };\n\n #createSubmitter() {\n if (!this.#submitter) {\n this.#submitter = globalThis.document.createElement('button');\n this.#submitter.type = 'submit';\n this.#submitter.style.display = 'none';\n }\n\n this.#submitter.name = this.host.name ?? '';\n this.#submitter.value = this.host.value ?? '';\n }\n\n #removeSubmitter() {\n this.#submitterForm?.removeEventListener('submit', this.#onSubmit);\n this.#submitterForm = undefined;\n this.#submitter?.remove();\n this.#submitter = undefined;\n }\n}\n"],"mappings":";;AAgBA,
|
|
1
|
+
{"version":3,"file":"type-submit.controller.js","names":["TypeSubmitController","host","#defaultType","#setButtonType","#removeSubmitBehavior","#onSubmitClick","#onSubmitKeyup","#removeSubmitter","event","stopEvent","#requestSubmit","#createSubmitter","#submitterForm","form","#onSubmit","#submitter","submitter"],"sources":["../../../src/internal/controllers/type-submit.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { stopEvent } from '../utils.js';\nimport type { ButtonType } from '../types/button.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype SubmitHost = ReactiveElement & {\n disabled: boolean;\n form: HTMLFormElement | null | string;\n name?: string;\n readOnly: boolean;\n type?: ButtonType;\n value?: string;\n};\n\nexport class TypeSubmitController<T extends SubmitHost> implements ReactiveController {\n #defaultType: ButtonType | undefined;\n #submitter: HTMLButtonElement | undefined;\n #submitterForm: HTMLFormElement | undefined;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get defaultType() {\n return this.#defaultType;\n }\n\n hostUpdated() {\n this.#setButtonType();\n this.#removeSubmitBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#onSubmitClick);\n this.host.addEventListener('keyup', this.#onSubmitKeyup);\n }\n }\n\n hostDisconnected() {\n this.#removeSubmitBehavior();\n this.#removeSubmitter();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.form instanceof HTMLFormElement) {\n this.#defaultType = 'submit';\n }\n }\n\n #removeSubmitBehavior() {\n this.host.removeEventListener('click', this.#onSubmitClick);\n this.host.removeEventListener('keyup', this.#onSubmitKeyup);\n }\n\n #onSubmitKeyup = (event: KeyboardEvent) => {\n if (event.key === ' ' || event.key === 'Enter' || event.code === 'Space' || event.code === 'Enter') {\n this.host.click();\n }\n };\n\n #onSubmitClick = (event: Event) => {\n if (this.host.disabled) {\n stopEvent(event);\n return;\n }\n\n if (this.host.type === 'submit' && this.host.form instanceof HTMLFormElement) {\n this.#requestSubmit(this.host.form);\n } else if (this.host.type === 'reset' && this.host.form instanceof HTMLFormElement) {\n this.host.form.reset();\n }\n };\n\n #requestSubmit(form: HTMLFormElement) {\n this.#removeSubmitter();\n this.#createSubmitter();\n this.#submitterForm = form;\n form.addEventListener('submit', this.#onSubmit, { once: true });\n this.#submitter?.remove();\n form.appendChild(this.#submitter!);\n form.requestSubmit(this.#submitter);\n }\n\n #onSubmit = () => {\n const submitter = this.#submitter;\n this.#submitterForm = undefined;\n setTimeout(() => {\n submitter?.remove();\n if (this.#submitter === submitter) {\n this.#submitter = undefined;\n }\n }, 0);\n };\n\n #createSubmitter() {\n if (!this.#submitter) {\n this.#submitter = globalThis.document.createElement('button');\n this.#submitter.type = 'submit';\n this.#submitter.style.display = 'none';\n }\n\n this.#submitter.name = this.host.name ?? '';\n this.#submitter.value = this.host.value ?? '';\n }\n\n #removeSubmitter() {\n this.#submitterForm?.removeEventListener('submit', this.#onSubmit);\n this.#submitterForm = undefined;\n this.#submitter?.remove();\n this.#submitter = undefined;\n }\n}\n"],"mappings":";;AAgBA,IAAaA,IAAb,MAAsF;CACpF;CACA;CACA;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,cAAc;EAChB,OAAO,KAAKC;CACd;CAEA,cAAc;EAGZ,AAFA,KAAKC,GAAe,GACpB,KAAKC,GAAsB,GACvB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,aACpC,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAc,GACvD,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAc;CAE3D;CAEA,mBAAmB;EAEjB,AADA,KAAKF,GAAsB,GAC3B,KAAKG,GAAiB;CACxB;CAEA,KAAiB;EACf,AAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAAa,MAAM,KAA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AHA,KAAKH,IAAgB,oBAAoB,UAAU,KAAKE,EAAS,GACjE,KAAKF,KAAiB,KAAA,GACtB,KAAKG,IAAY,OAAO,GACxB,KAAKA,KAAa,KAAA;CACpB;AACF"}
|
package/dist/internal/errors.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/errors.ts
|
|
2
2
|
var e = class extends Error {
|
|
3
3
|
constructor(e, t) {
|
|
4
4
|
super(`(${e}): ${t}`), this.name = "FormControlError";
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { e as FormControlError };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../src/internal/errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport class FormControlError extends Error {\n constructor(formControlName: string, message: string) {\n super(`(${formControlName}): ${message}`);\n this.name = 'FormControlError';\n }\n}\n"],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"errors.js","names":["FormControlError","formControlName","message"],"sources":["../../src/internal/errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport class FormControlError extends Error {\n constructor(formControlName: string, message: string) {\n super(`(${formControlName}): ${message}`);\n this.name = 'FormControlError';\n }\n}\n"],"mappings":";AAGA,IAAaA,IAAb,cAAsC,MAAM;CAC1C,YAAY,GAAyB,GAAiB;EAEpD,AADA,MAAM,IAAIC,EAAgB,KAAKC,GAAS,GACxC,KAAK,OAAO;CACd;AACF"}
|
package/dist/internal/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as TypeCommandController };
|
|
1
|
+
export { TypeCommandController } from "./controllers/type-command.controller.js";
|
package/dist/internal/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormControlError as e } from "./errors.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/schema.ts
|
|
3
3
|
function t(t, n, r) {
|
|
4
4
|
let i = f(n, r);
|
|
5
5
|
if (i === void 0) throw new e(t, `unsupported value type ${typeof n}`);
|
|
@@ -81,7 +81,6 @@ function f(e, t) {
|
|
|
81
81
|
default: return;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
//#endregion
|
|
85
84
|
export { f as parseControlValue, t as parseValueSchema, d as validateSchema };
|
|
86
85
|
|
|
87
86
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../src/internal/schema.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Schema } from './types.js';\nimport { FormControlError } from './errors.js';\n\nexport function parseValueSchema<T>(formControlName: string, value: string, schema: Schema): T {\n const parsedValue = parseControlValue(value, schema);\n if (parsedValue === undefined) {\n throw new FormControlError(formControlName, `unsupported value type ${typeof value}`);\n }\n return parsedValue as T;\n}\n\ntype ValidationResult = { validity: Partial<ValidityState>; message: string };\n\nconst VALID: ValidationResult = { validity: { valid: true }, message: '' };\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidationResult {\n return { validity: { ...validity, valid: false }, message };\n}\n\nfunction validateString(schema: Schema & { type: 'string' }, value: unknown): ValidationResult {\n if (typeof value !== 'string') {\n return invalid({ typeMismatch: true }, `expected string, got ${typeof value}`);\n }\n if (schema.minLength !== undefined && value.length < schema.minLength) {\n return invalid({ tooShort: true }, `string length ${value.length} is less than minimum length ${schema.minLength}`);\n }\n if (schema.maxLength !== undefined && value.length > schema.maxLength) {\n return invalid(\n { tooLong: true },\n `string length ${value.length} is greater than maximum length ${schema.maxLength}`\n );\n }\n if (schema.pattern && !new RegExp(schema.pattern).test(value)) {\n return invalid({ patternMismatch: true }, `string does not match pattern ${schema.pattern}`);\n }\n return VALID;\n}\n\nfunction validateNumber(schema: Schema & { type: 'number' }, value: unknown): ValidationResult {\n if (typeof value !== 'number') {\n return invalid({ typeMismatch: true }, `expected type number, received type ${typeof value}`);\n }\n if (isNaN(value as unknown as number)) {\n return invalid({ typeMismatch: true }, `expected type number, received type NaN`);\n }\n if (schema.minimum !== undefined && value < schema.minimum) {\n return invalid({ rangeUnderflow: true }, `number ${value} is less than minimum ${schema.minimum}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n return invalid({ rangeOverflow: true }, `number ${value} is greater than maximum ${schema.maximum}`);\n }\n return VALID;\n}\n\nfunction validateBoolean(value: unknown): ValidationResult {\n if (typeof value !== 'boolean') {\n return invalid({ typeMismatch: true }, `expected boolean, got ${typeof value}`);\n }\n return VALID;\n}\n\nfunction validateArray(schema: Schema & { type: 'array' }, value: unknown): ValidationResult {\n if (!Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type array, received type ${typeof value}`);\n }\n if (schema.minItems !== undefined && value.length < schema.minItems) {\n return invalid(\n { rangeUnderflow: true },\n `array length ${value.length} is less than minimum length ${schema.minItems}`\n );\n }\n if (schema.maxItems !== undefined && value.length > schema.maxItems) {\n return invalid(\n { rangeOverflow: true },\n `array length ${value.length} is greater than maximum length ${schema.maxItems}`\n );\n }\n for (const item of value) {\n const result = validateSchema(schema.items, item);\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateObjectProperty(\n property: { name: string; schema: Schema },\n value: Record<string, unknown>,\n required?: string[]\n): ValidationResult {\n const { name, schema: propSchema } = property;\n const propValue = value[name];\n if (propValue === undefined) {\n if (required?.includes(name)) {\n return invalid({ valueMissing: true }, `missing required property: ${name}`);\n }\n return VALID;\n }\n return validateSchema(propSchema, propValue);\n}\n\nfunction validateObject(schema: Schema & { type: 'object' }, value: unknown): ValidationResult {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type object, received type ${typeof value}`);\n }\n\n const valueProperties = Object.keys(value as object);\n const schemaProperties = Object.keys(schema.properties);\n\n const additionalProps = valueProperties.filter(prop => !schemaProperties.includes(prop));\n if (additionalProps.length > 0 && !schema.additionalProperties) {\n return invalid({ badInput: true }, `additional properties not allowed: ${additionalProps.join(', ')}`);\n }\n\n for (const [prop, propSchema] of Object.entries(schema.properties)) {\n const result = validateObjectProperty(\n { name: prop, schema: propSchema },\n value as Record<string, unknown>,\n schema.required\n );\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateEnum(schema: Schema & { type: 'enum' }, value: unknown): ValidationResult {\n if (!schema.enum.includes(value as string | number)) {\n return invalid({ typeMismatch: true }, `value must be one of: ${schema.enum.join(', ')}`);\n }\n return VALID;\n}\n\nexport function validateSchema(schema: Schema, value: unknown): ValidationResult {\n if (!schema || typeof schema !== 'object') {\n return invalid({ badInput: true }, 'invalid schema, schema must be a non-null object');\n }\n\n if (!('type' in schema)) {\n return invalid({ badInput: true }, 'schema must have \"type\" property');\n }\n\n switch (schema.type) {\n case 'string':\n return validateString(schema, value);\n case 'number':\n return validateNumber(schema, value);\n case 'boolean':\n return validateBoolean(value);\n case 'array':\n return validateArray(schema, value);\n case 'object':\n return validateObject(schema, value);\n case 'enum':\n return validateEnum(schema, value);\n default:\n return invalid({ badInput: true }, `unsupported type: ${(schema as { type: string }).type}`);\n }\n}\n\nexport function parseControlValue<T>(value: string, schema: Schema): T | undefined {\n const schemaType = schema.type;\n\n switch (schemaType) {\n case 'string':\n return value as T;\n case 'number':\n return parseFloat(value) as T;\n case 'boolean':\n return (!!value || value === 'true') as T;\n case 'array':\n case 'object':\n return JSON.parse(value) as T;\n case 'enum':\n return (schema.enum.includes(value) ? value : undefined) as T;\n default: {\n const _exhaustiveCheck: never = schem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KAAK,WACH,OAAQ,CAAC,CAAC,KAAS,MAAU;EAC/B,KAAK;EACL,KAAK,UACH,OAAO,KAAK,MAAM,CAAK;EACzB,KAAK,QACH,OAAQ,EAAO,KAAK,SAAS,CAAK,IAAI,IAAQ,KAAA;EAChD,SAEE;CAEJ;AACF"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":["parseValueSchema","parsedValue","parseControlValue","value","schema","FormControlError","formControlName","VALID","invalid","validity","validateString","validateNumber","validateBoolean","validateArray","item","result","validateSchema","validateObjectProperty","propSchema","property","propValue","name","required","validateObject","valueProperties","schemaProperties","additionalProps","prop","validateEnum"],"sources":["../../src/internal/schema.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Schema } from './types.js';\nimport { FormControlError } from './errors.js';\n\nexport function parseValueSchema<T>(formControlName: string, value: string, schema: Schema): T {\n const parsedValue = parseControlValue(value, schema);\n if (parsedValue === undefined) {\n throw new FormControlError(formControlName, `unsupported value type ${typeof value}`);\n }\n return parsedValue as T;\n}\n\ntype ValidationResult = { validity: Partial<ValidityState>; message: string };\n\nconst VALID: ValidationResult = { validity: { valid: true }, message: '' };\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidationResult {\n return { validity: { ...validity, valid: false }, message };\n}\n\nfunction validateString(schema: Schema & { type: 'string' }, value: unknown): ValidationResult {\n if (typeof value !== 'string') {\n return invalid({ typeMismatch: true }, `expected string, got ${typeof value}`);\n }\n if (schema.minLength !== undefined && value.length < schema.minLength) {\n return invalid({ tooShort: true }, `string length ${value.length} is less than minimum length ${schema.minLength}`);\n }\n if (schema.maxLength !== undefined && value.length > schema.maxLength) {\n return invalid(\n { tooLong: true },\n `string length ${value.length} is greater than maximum length ${schema.maxLength}`\n );\n }\n if (schema.pattern && !new RegExp(schema.pattern).test(value)) {\n return invalid({ patternMismatch: true }, `string does not match pattern ${schema.pattern}`);\n }\n return VALID;\n}\n\nfunction validateNumber(schema: Schema & { type: 'number' }, value: unknown): ValidationResult {\n if (typeof value !== 'number') {\n return invalid({ typeMismatch: true }, `expected type number, received type ${typeof value}`);\n }\n if (isNaN(value as unknown as number)) {\n return invalid({ typeMismatch: true }, `expected type number, received type NaN`);\n }\n if (schema.minimum !== undefined && value < schema.minimum) {\n return invalid({ rangeUnderflow: true }, `number ${value} is less than minimum ${schema.minimum}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n return invalid({ rangeOverflow: true }, `number ${value} is greater than maximum ${schema.maximum}`);\n }\n return VALID;\n}\n\nfunction validateBoolean(value: unknown): ValidationResult {\n if (typeof value !== 'boolean') {\n return invalid({ typeMismatch: true }, `expected boolean, got ${typeof value}`);\n }\n return VALID;\n}\n\nfunction validateArray(schema: Schema & { type: 'array' }, value: unknown): ValidationResult {\n if (!Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type array, received type ${typeof value}`);\n }\n if (schema.minItems !== undefined && value.length < schema.minItems) {\n return invalid(\n { rangeUnderflow: true },\n `array length ${value.length} is less than minimum length ${schema.minItems}`\n );\n }\n if (schema.maxItems !== undefined && value.length > schema.maxItems) {\n return invalid(\n { rangeOverflow: true },\n `array length ${value.length} is greater than maximum length ${schema.maxItems}`\n );\n }\n for (const item of value) {\n const result = validateSchema(schema.items, item);\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateObjectProperty(\n property: { name: string; schema: Schema },\n value: Record<string, unknown>,\n required?: string[]\n): ValidationResult {\n const { name, schema: propSchema } = property;\n const propValue = value[name];\n if (propValue === undefined) {\n if (required?.includes(name)) {\n return invalid({ valueMissing: true }, `missing required property: ${name}`);\n }\n return VALID;\n }\n return validateSchema(propSchema, propValue);\n}\n\nfunction validateObject(schema: Schema & { type: 'object' }, value: unknown): ValidationResult {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type object, received type ${typeof value}`);\n }\n\n const valueProperties = Object.keys(value as object);\n const schemaProperties = Object.keys(schema.properties);\n\n const additionalProps = valueProperties.filter(prop => !schemaProperties.includes(prop));\n if (additionalProps.length > 0 && !schema.additionalProperties) {\n return invalid({ badInput: true }, `additional properties not allowed: ${additionalProps.join(', ')}`);\n }\n\n for (const [prop, propSchema] of Object.entries(schema.properties)) {\n const result = validateObjectProperty(\n { name: prop, schema: propSchema },\n value as Record<string, unknown>,\n schema.required\n );\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateEnum(schema: Schema & { type: 'enum' }, value: unknown): ValidationResult {\n if (!schema.enum.includes(value as string | number)) {\n return invalid({ typeMismatch: true }, `value must be one of: ${schema.enum.join(', ')}`);\n }\n return VALID;\n}\n\nexport function validateSchema(schema: Schema, value: unknown): ValidationResult {\n if (!schema || typeof schema !== 'object') {\n return invalid({ badInput: true }, 'invalid schema, schema must be a non-null object');\n }\n\n if (!('type' in schema)) {\n return invalid({ badInput: true }, 'schema must have \"type\" property');\n }\n\n switch (schema.type) {\n case 'string':\n return validateString(schema, value);\n case 'number':\n return validateNumber(schema, value);\n case 'boolean':\n return validateBoolean(value);\n case 'array':\n return validateArray(schema, value);\n case 'object':\n return validateObject(schema, value);\n case 'enum':\n return validateEnum(schema, value);\n default:\n return invalid({ badInput: true }, `unsupported type: ${(schema as { type: string }).type}`);\n }\n}\n\nexport function parseControlValue<T>(value: string, schema: Schema): T | undefined {\n const schemaType = schema.type;\n\n switch (schemaType) {\n case 'string':\n return value as T;\n case 'number':\n return parseFloat(value) as T;\n case 'boolean':\n return (!!value || value === 'true') as T;\n case 'array':\n case 'object':\n return JSON.parse(value) as T;\n case 'enum':\n return (schema.enum.includes(value) ? value : undefined) as T;\n default: {\n const _exhaustiveCheck: never = schemaType;\n return undefined;\n }\n }\n}\n"],"mappings":";;AAMA,SAAgBA,EAAoB,GAAyB,GAAe,GAAmB;CAC7F,IAAMC,IAAcC,EAAkBC,GAAOC,CAAM;CAC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AK,UACH,OAAOD;EACT,KAAK,UACH,OAAO,WAAWA,CAAK;EACzB,KAAK,WACH,OAAQ,CAAC,CAACA,KAASA,MAAU;EAC/B,KAAK;EACL,KAAK,UACH,OAAO,KAAK,MAAMA,CAAK;EACzB,KAAK,QACH,OAAQC,EAAO,KAAK,SAASD,CAAK,IAAIA,IAAQ,KAAA;EAChD,SAEE;CAEJ;AACF"}
|
package/dist/internal/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/utils.ts
|
|
2
2
|
function e(e) {
|
|
3
3
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
4
4
|
let t = Object.getPrototypeOf(e);
|
|
@@ -53,7 +53,6 @@ function p(e) {
|
|
|
53
53
|
function m(e) {
|
|
54
54
|
return typeof HTMLSlotElement < "u" && e instanceof HTMLSlotElement && !!e.assignedElements;
|
|
55
55
|
}
|
|
56
|
-
//#endregion
|
|
57
56
|
export { t as attachInternals, r as getFlattenedDOMTree, i as getHostAnchor, a as getStringValue, o as hasAttributeValue, s as isFormElement, e as isObjectLiteral, c as removeEmptyTextNode, l as setAttributeValue, u as stopEvent, n as toggleState };
|
|
58
57
|
|
|
59
58
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/internal/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isObjectLiteral(item: unknown) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) {\n return false;\n }\n const proto = Object.getPrototypeOf(item);\n return proto === null || proto === Object.prototype;\n}\n\nexport function attachInternals(element: HTMLElement & { _internals?: ElementInternals }) {\n if (element._internals === undefined) {\n element._internals = element.attachInternals() as unknown as ElementInternals;\n }\n\n return element._internals;\n}\n\nexport function toggleState(internals: ElementInternals, state: string, force: boolean) {\n if (force) {\n internals.states.add(state);\n } else {\n internals.states.delete(state);\n }\n}\n\nexport type PopoverAnchorElement = HTMLElement & { anchor?: HTMLElement | string; _activeTrigger?: HTMLElement };\n\nexport function getFlattenedDOMTree(node: Node, depth = 10): HTMLElement[] {\n return (\n Array.from(getChildren(node)).reduce(\n (p: unknown[], n: Node) => [\n ...p,\n [n, [...Array.from(getChildren(n)).map(i => [i, getFlattenedDOMTree(i, depth)])]]\n ],\n []\n ) as unknown as HTMLElement[]\n ).flat(depth);\n}\n\nexport function getHostAnchor(host: PopoverAnchorElement) {\n const anchor = host.anchor ?? host._activeTrigger;\n\n if (typeof anchor === 'string' && anchor.length) {\n if (!host.parentNode) {\n return globalThis.document.body;\n }\n\n return (\n getFlattenedDOMTree(host.parentNode as Node).find(element => element.id === anchor) ?? globalThis.document.body\n );\n }\n\n if (anchor instanceof HTMLElement && anchor !== globalThis.document.body) {\n return anchor;\n }\n\n return globalThis.document.body;\n}\n\nexport function getStringValue(value: unknown) {\n if (typeof value === 'string' && value.length) {\n return value;\n }\n\n return value === '' ? '' : null;\n}\n\nexport function hasAttributeValue(element: HTMLElement, attribute: string, value: string | null) {\n return value === null ? !element.hasAttribute(attribute) : element.getAttribute(attribute) === value;\n}\n\nexport function isFormElement(value: unknown): value is HTMLFormElement {\n return typeof HTMLFormElement !== 'undefined' && value instanceof HTMLFormElement;\n}\n\nexport function onKeys(events: string[], event: KeyboardEvent, callback: () => void) {\n if (events.includes(event.code)) {\n callback();\n }\n}\n\nexport function removeEmptyTextNode(node: Node) {\n if ((node as Text)?.wholeText?.trim() === '') {\n node.parentNode?.removeChild(node);\n }\n}\n\nexport function setAttributeValue(element: HTMLElement, attribute: string, value: string | null) {\n if (value === null) {\n element.removeAttribute(attribute);\n } else {\n element.setAttribute(attribute, value);\n }\n}\n\nexport function stopEvent(event: Event) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nfunction getChildren(node: Node): Element[] {\n if (isDocumentNode(node)) {\n return Array.from(node.documentElement.children);\n }\n\n if (isElementWithShadowRoot(node)) {\n return Array.from(node.shadowRoot.children);\n }\n\n if (isSlotElement(node)) {\n const slotted = node.assignedElements();\n return slotted.length ? slotted : Array.from(node.children);\n }\n\n return Array.from((node as HTMLElement).children ?? []);\n}\n\nfunction isDocumentNode(node: Node): node is Document {\n return typeof Document !== 'undefined' && node instanceof Document && Boolean(node.documentElement);\n}\n\nfunction isElementWithShadowRoot(node: Node): node is HTMLElement & { shadowRoot: ShadowRoot } {\n return typeof HTMLElement !== 'undefined' && node instanceof HTMLElement && Boolean(node.shadowRoot);\n}\n\nfunction isSlotElement(node: Node): node is HTMLSlotElement {\n return typeof HTMLSlotElement !== 'undefined' && node instanceof HTMLSlotElement && Boolean(node.assignedElements);\n}\n"],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"utils.js","names":["isObjectLiteral","item","proto","attachInternals","element","toggleState","force","internals","state","getFlattenedDOMTree","getChildren","node","p","i","depth","getHostAnchor","anchor","host","getStringValue","value","hasAttributeValue","attribute","isFormElement","removeEmptyTextNode","setAttributeValue","stopEvent","event","isDocumentNode","isElementWithShadowRoot","isSlotElement","slotted"],"sources":["../../src/internal/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isObjectLiteral(item: unknown) {\n if (!item || typeof item !== 'object' || Array.isArray(item)) {\n return false;\n }\n const proto = Object.getPrototypeOf(item);\n return proto === null || proto === Object.prototype;\n}\n\nexport function attachInternals(element: HTMLElement & { _internals?: ElementInternals }) {\n if (element._internals === undefined) {\n element._internals = element.attachInternals() as unknown as ElementInternals;\n }\n\n return element._internals;\n}\n\nexport function toggleState(internals: ElementInternals, state: string, force: boolean) {\n if (force) {\n internals.states.add(state);\n } else {\n internals.states.delete(state);\n }\n}\n\nexport type PopoverAnchorElement = HTMLElement & { anchor?: HTMLElement | string; _activeTrigger?: HTMLElement };\n\nexport function getFlattenedDOMTree(node: Node, depth = 10): HTMLElement[] {\n return (\n Array.from(getChildren(node)).reduce(\n (p: unknown[], n: Node) => [\n ...p,\n [n, [...Array.from(getChildren(n)).map(i => [i, getFlattenedDOMTree(i, depth)])]]\n ],\n []\n ) as unknown as HTMLElement[]\n ).flat(depth);\n}\n\nexport function getHostAnchor(host: PopoverAnchorElement) {\n const anchor = host.anchor ?? host._activeTrigger;\n\n if (typeof anchor === 'string' && anchor.length) {\n if (!host.parentNode) {\n return globalThis.document.body;\n }\n\n return (\n getFlattenedDOMTree(host.parentNode as Node).find(element => element.id === anchor) ?? globalThis.document.body\n );\n }\n\n if (anchor instanceof HTMLElement && anchor !== globalThis.document.body) {\n return anchor;\n }\n\n return globalThis.document.body;\n}\n\nexport function getStringValue(value: unknown) {\n if (typeof value === 'string' && value.length) {\n return value;\n }\n\n return value === '' ? '' : null;\n}\n\nexport function hasAttributeValue(element: HTMLElement, attribute: string, value: string | null) {\n return value === null ? !element.hasAttribute(attribute) : element.getAttribute(attribute) === value;\n}\n\nexport function isFormElement(value: unknown): value is HTMLFormElement {\n return typeof HTMLFormElement !== 'undefined' && value instanceof HTMLFormElement;\n}\n\nexport function onKeys(events: string[], event: KeyboardEvent, callback: () => void) {\n if (events.includes(event.code)) {\n callback();\n }\n}\n\nexport function removeEmptyTextNode(node: Node) {\n if ((node as Text)?.wholeText?.trim() === '') {\n node.parentNode?.removeChild(node);\n }\n}\n\nexport function setAttributeValue(element: HTMLElement, attribute: string, value: string | null) {\n if (value === null) {\n element.removeAttribute(attribute);\n } else {\n element.setAttribute(attribute, value);\n }\n}\n\nexport function stopEvent(event: Event) {\n event.preventDefault();\n event.stopPropagation();\n}\n\nfunction getChildren(node: Node): Element[] {\n if (isDocumentNode(node)) {\n return Array.from(node.documentElement.children);\n }\n\n if (isElementWithShadowRoot(node)) {\n return Array.from(node.shadowRoot.children);\n }\n\n if (isSlotElement(node)) {\n const slotted = node.assignedElements();\n return slotted.length ? slotted : Array.from(node.children);\n }\n\n return Array.from((node as HTMLElement).children ?? []);\n}\n\nfunction isDocumentNode(node: Node): node is Document {\n return typeof Document !== 'undefined' && node instanceof Document && Boolean(node.documentElement);\n}\n\nfunction isElementWithShadowRoot(node: Node): node is HTMLElement & { shadowRoot: ShadowRoot } {\n return typeof HTMLElement !== 'undefined' && node instanceof HTMLElement && Boolean(node.shadowRoot);\n}\n\nfunction isSlotElement(node: Node): node is HTMLSlotElement {\n return typeof HTMLSlotElement !== 'undefined' && node instanceof HTMLSlotElement && Boolean(node.assignedElements);\n}\n"],"mappings":";AAGA,SAAgBA,EAAgB,GAAe;CAC7C,IAAI,CAACC,KAAQ,OAAOA,KAAS,YAAY,MAAM,QAAQA,CAAI,GACzD,OAAO;CAET,IAAMC,IAAQ,OAAO,eAAeD,CAAI;CACxC,OAAOC,MAAU,QAAQA,MAAU,OAAO;AAC5C;AAEA,SAAgBC,EAAgB,GAA0D;CAKxF,OAJIC,EAAQ,eAAe,KAAA,MACzB,EAAQ,aAAaA,EAAQ,gBAAgB,IAGxCA,EAAQ;AACjB;AAEA,SAAgBC,EAAY,GAA6B,GAAe,GAAgB;CACtF,AAAIC,IACFC,EAAU,OAAO,IAAIC,CAAK,IAE1BD,EAAU,OAAO,OAAOC,CAAK;AAEjC;AAIA,SAAgBC,EAAoB,GAAY,IAAQ,IAAmB;CACzE,OACE,MAAM,KAAKC,EAAYC,CAAI,CAAC,CAAC,CAAC,QAC3B,GAAc,MAAY,CACzB,GAAGC,GACH,CAAC,GAAG,CAAC,GAAG,MAAM,KAAKF,EAAY,CAAC,CAAC,CAAC,CAAC,KAAI,MAAK,CAACG,GAAGJ,EAAoBI,GAAGC,CAAK,CAAC,CAAC,CAAC,CAAC,CAClF,GACA,CAAC,CACH,CAAC,CACD,KAAKA,CAAK;AACd;AAEA,SAAgBC,EAAc,GAA4B;CACxD,IAAMC,IAASC,EAAK,UAAUA,EAAK;CAgBnC,OAdI,OAAOD,KAAW,YAAYA,EAAO,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,SAASgB,EAAe,GAA8B;CACpD,OAAO,OAAO,WAAa,OAAehB,aAAgB,YAAY,EAAQA,EAAK;AACrF;AAEA,SAASiB,EAAwB,GAA8D;CAC7F,OAAO,OAAO,cAAgB,OAAejB,aAAgB,eAAe,EAAQA,EAAK;AAC3F;AAEA,SAASkB,EAAc,GAAqC;CAC1D,OAAO,OAAO,kBAAoB,OAAelB,aAAgB,mBAAmB,EAAQA,EAAK;AACnG"}
|
package/dist/mixins/button.js
CHANGED
|
@@ -12,7 +12,7 @@ import { StateExpandedController as h } from "../internal/controllers/state-expa
|
|
|
12
12
|
import { StatePressedController as g } from "../internal/controllers/state-pressed.controller.js";
|
|
13
13
|
import { StateReadOnlyController as _ } from "../internal/controllers/state-readonly.controller.js";
|
|
14
14
|
import { StateSelectedController as v } from "../internal/controllers/state-selected.controller.js";
|
|
15
|
-
|
|
15
|
+
// src/mixins/button.ts
|
|
16
16
|
var y = {
|
|
17
17
|
commandfor: "commandForElement",
|
|
18
18
|
interestfor: "interestForElement",
|
|
@@ -242,21 +242,15 @@ function b(b) {
|
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
#y(e, t, n) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.#D({
|
|
255
|
-
property: e,
|
|
256
|
-
value: n,
|
|
257
|
-
reflect: !1
|
|
258
|
-
});
|
|
259
|
-
}
|
|
245
|
+
e !== "commandfor" && e !== "interestfor" && e !== "popovertarget" && (e === "form" && (i(this.#a) && n === null || (this.#a = n, this.#j("form", t))), e === "popovertargetaction" ? this.#D({
|
|
246
|
+
property: "popoverTargetAction",
|
|
247
|
+
value: n,
|
|
248
|
+
reflect: !1
|
|
249
|
+
}) : this.#D({
|
|
250
|
+
property: e,
|
|
251
|
+
value: n,
|
|
252
|
+
reflect: !1
|
|
253
|
+
}));
|
|
260
254
|
}
|
|
261
255
|
#b(e, t) {
|
|
262
256
|
let n = y[e];
|
|
@@ -276,7 +270,7 @@ function b(b) {
|
|
|
276
270
|
}
|
|
277
271
|
#w({ property: e, value: t, reflect: n, attribute: i = e }) {
|
|
278
272
|
let a = this.#T(e);
|
|
279
|
-
a
|
|
273
|
+
(a !== t || n && !r(this, i, t ? "" : null)) && (this.#E(e, t), !(n && this.#A(i, t ? "" : null)) && (this.#j(e, a), this.#g()));
|
|
280
274
|
}
|
|
281
275
|
#T(e) {
|
|
282
276
|
return {
|
|
@@ -292,7 +286,7 @@ function b(b) {
|
|
|
292
286
|
}
|
|
293
287
|
#D({ property: e, value: t, attribute: i = e, reflect: a = !0 }) {
|
|
294
288
|
let o = this.#O(e), s = n(t);
|
|
295
|
-
o
|
|
289
|
+
(o !== s || a && !r(this, i, s)) && (this.#k(e, s), !(a && this.#A(i, s)) && (this.#j(e, o), this.#g()));
|
|
296
290
|
}
|
|
297
291
|
#O(e) {
|
|
298
292
|
return {
|
|
@@ -328,7 +322,6 @@ function b(b) {
|
|
|
328
322
|
}
|
|
329
323
|
};
|
|
330
324
|
}
|
|
331
|
-
//#endregion
|
|
332
325
|
export { b as ButtonFormControlMixin };
|
|
333
326
|
|
|
334
327
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../src/mixins/button.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeAnchorController } from '../internal/controllers/type-anchor.controller.js';\nimport { TypeButtonController } from '../internal/controllers/type-button.controller.js';\nimport { TypeCommandController } from '../internal/controllers/type-command.controller.js';\nimport { TypeInterestInvokerController } from '../internal/controllers/type-interest-invoker.controller.js';\nimport { TypeSubmitController } from '../internal/controllers/type-submit.controller.js';\nimport { TypePopoverTriggerController } from '../internal/controllers/type-popover-trigger.controller.js';\nimport { StateActiveController } from '../internal/controllers/state-active.controller.js';\nimport { StateCurrentController } from '../internal/controllers/state-current.controller.js';\nimport { StateDisabledController } from '../internal/controllers/state-disabled.controller.js';\nimport { StateExpandedController } from '../internal/controllers/state-expanded.controller.js';\nimport { StatePressedController } from '../internal/controllers/state-pressed.controller.js';\nimport { StateReadOnlyController } from '../internal/controllers/state-readonly.controller.js';\nimport { StateSelectedController } from '../internal/controllers/state-selected.controller.js';\nimport type { ReactiveController } from '../internal/controllers/types.js';\nimport {\n attachInternals,\n getFlattenedDOMTree,\n getStringValue,\n hasAttributeValue,\n isFormElement,\n setAttributeValue\n} from '../internal/utils.js';\nimport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\nexport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\n\ntype ChangedProperties = Map<PropertyKey, unknown>;\ninterface ButtonFormControlHost {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n updateComplete?: Promise<unknown>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & ButtonFormControlHost) & { observedAttributes?: string[] };\n\ninterface BooleanStateOptions {\n property: string;\n value: boolean;\n reflect: boolean;\n attribute?: string;\n}\n\ninterface StringStateOptions {\n property: string;\n value: unknown;\n attribute?: string;\n reflect?: boolean;\n}\n\nconst ELEMENT_TARGET_PROPERTIES = {\n commandfor: 'commandForElement',\n interestfor: 'interestForElement',\n popovertarget: 'popoverTargetElement'\n} as const;\ntype ElementTargetAttribute = keyof typeof ELEMENT_TARGET_PROPERTIES;\ntype ElementTargetProperty = (typeof ELEMENT_TARGET_PROPERTIES)[ElementTargetAttribute];\n\ntype ButtonFormControlConstructor<TBase extends Constructor> = new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & ButtonFormControlMixinInstance;\nexport type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonFormControlConstructor<TBase> & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds native button-style form, command, popover, and interaction behavior.\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/button/\n */\nexport function ButtonFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): ButtonFormControlMixinReturn<TBase> {\n return class ButtonFormControlBase extends SuperClass {\n static formAssociated = true;\n\n #command: string | undefined;\n #current: CurrentState | undefined;\n #disabled = false;\n #elementTargets: Record<ElementTargetProperty, HTMLElement | null> = {\n commandForElement: null,\n interestForElement: null,\n popoverTargetElement: null\n };\n #expanded: boolean | undefined;\n #form: string | HTMLFormElement | null = null;\n #hasConnected = false;\n #name: string | undefined;\n #pendingAttributeReflections = new Map<string, string | null>();\n #popoverTargetAction: PopoverTargetAction | undefined;\n #pressed: boolean | undefined;\n #readOnly = false;\n #selected: boolean | undefined;\n #syncQueued = false;\n #type: ButtonType | undefined;\n #value: string | undefined;\n\n _internals = attachInternals(this);\n\n static get observedAttributes() {\n return (super.observedAttributes ?? []).concat([\n 'pressed',\n 'expanded',\n 'readonly',\n 'form',\n 'name',\n 'value',\n 'type',\n 'disabled',\n 'selected',\n 'current',\n 'popovertarget',\n 'popovertargetaction',\n 'commandfor',\n 'command',\n 'interestfor'\n ]);\n }\n\n get pressed(): boolean {\n return this.#pressed as boolean;\n }\n\n set pressed(value: boolean | unknown) {\n this.#setBooleanState({ property: 'pressed', value: Boolean(value), reflect: true });\n }\n\n get expanded(): boolean {\n return this.#expanded as boolean;\n }\n\n set expanded(value: boolean | unknown) {\n this.#setBooleanState({ property: 'expanded', value: Boolean(value), reflect: true });\n }\n\n get readOnly(): boolean {\n return this.#readOnly || (this._typeAnchorController?.readOnly ?? false);\n }\n\n set readOnly(value: boolean | unknown) {\n this.#setBooleanState({ property: 'readOnly', value: Boolean(value), reflect: true, attribute: 'readonly' });\n }\n\n get readonly(): boolean {\n return this.readOnly;\n }\n\n set readonly(value: boolean) {\n this.readOnly = value;\n }\n\n set form(form: string | HTMLFormElement | null) {\n const oldValue = this.form;\n this.#form = form;\n if (typeof form === 'string') {\n this.setAttribute('form', form);\n } else {\n this.removeAttribute('form');\n }\n this.#requestHostUpdate('form', oldValue);\n this.#queueBehaviorSync();\n }\n\n get form(): HTMLFormElement | null | string {\n if (this.#form && typeof this.#form !== 'string') {\n return this.#form;\n }\n\n if (typeof this.#form === 'string' && typeof globalThis.document !== 'undefined') {\n const rootNode = this.getRootNode() as Document | ShadowRoot;\n const form = rootNode.getElementById ? rootNode.getElementById(this.#form) : null;\n return isFormElement(form) ? form : null;\n }\n\n return this._internals?.form ?? null;\n }\n\n get name(): string {\n return this.#name as string;\n }\n\n set name(value: string | unknown) {\n this.#setStringState({ property: 'name', value });\n }\n\n get value(): string {\n return this.#value as string;\n }\n\n set value(value: string | unknown) {\n this.#setStringState({ property: 'value', value });\n }\n\n get type(): ButtonType {\n return (this.#type ?? this._typeSubmitController?.defaultType) as ButtonType;\n }\n\n set type(value: ButtonType | unknown) {\n this.#setStringState({ property: 'type', value });\n }\n\n get disabled(): boolean {\n return this.#disabled;\n }\n\n set disabled(value: boolean | unknown) {\n this.#setBooleanState({ property: 'disabled', value: Boolean(value), reflect: true });\n }\n\n get selected(): boolean {\n return this.#selected as boolean;\n }\n\n set selected(value: boolean | unknown) {\n this.#setBooleanState({ property: 'selected', value: Boolean(value), reflect: true });\n }\n\n get current(): CurrentState {\n return this.#current as CurrentState;\n }\n\n set current(value: CurrentState | unknown) {\n this.#setStringState({ property: 'current', value });\n }\n\n get popoverTargetElement(): HTMLElement | null {\n return this.#getElementTarget('popovertarget');\n }\n\n set popoverTargetElement(value: HTMLElement | null) {\n this.#setElementTarget('popovertarget', value);\n }\n\n get popoverTargetAction(): PopoverTargetAction {\n return this.#popoverTargetAction === 'show' || this.#popoverTargetAction === 'hide'\n ? this.#popoverTargetAction\n : 'toggle';\n }\n\n set popoverTargetAction(value: PopoverTargetAction | unknown) {\n this.#setStringState({ property: 'popoverTargetAction', value, attribute: 'popovertargetaction' });\n }\n\n get commandForElement(): HTMLElement | null {\n return this.#getElementTarget('commandfor');\n }\n\n set commandForElement(value: HTMLElement | null) {\n this.#setElementTarget('commandfor', value);\n }\n\n get command(): string {\n return this.#command as string;\n }\n\n set command(value: string | unknown) {\n this.#setStringState({ property: 'command', value });\n }\n\n get interestForElement(): HTMLElement | null {\n return this.#getElementTarget('interestfor');\n }\n\n set interestForElement(value: HTMLElement | null) {\n this.#setElementTarget('interestfor', value);\n }\n\n protected _controllers?: Set<ReactiveController>;\n protected _typeAnchorController = new TypeAnchorController(this);\n protected _typeButtonController = new TypeButtonController(this);\n protected _typeSubmitController = new TypeSubmitController(this);\n protected _typeCommandController = new TypeCommandController(this);\n protected _typeInterestInvokerController = new TypeInterestInvokerController(this);\n protected _typePopoverTriggerController = new TypePopoverTriggerController(this);\n protected _stateActiveController = new StateActiveController(this);\n protected _stateDisabledController = new StateDisabledController(this);\n protected _stateExpandedController = new StateExpandedController(this);\n protected _statePressedController = new StatePressedController(this);\n protected _stateSelectedController = new StateSelectedController(this);\n protected _stateCurrentController = new StateCurrentController(this);\n protected _stateReadOnlyController = new StateReadOnlyController(this);\n\n addController(controller: ReactiveController) {\n this._controllers ??= new Set<ReactiveController>();\n this._controllers.add(controller);\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n this._controllers?.forEach(controller => controller.hostConnected?.());\n attachInternals(this);\n this.#hasConnected = true;\n this.#flushPendingAttributeReflections();\n\n this.#syncBehavior();\n this.#queueBehaviorSync();\n }\n\n disconnectedCallback() {\n this._controllers?.forEach(controller => controller.hostDisconnected?.());\n super.disconnectedCallback?.();\n }\n\n protected updated(changedProperties: ChangedProperties) {\n const superUpdated = Object.getPrototypeOf(ButtonFormControlBase.prototype).updated as\n | ((changedProperties: ChangedProperties) => void)\n | undefined;\n superUpdated?.call(this, changedProperties);\n this.#syncQueued = false;\n this.#syncBehavior();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n\n if (oldValue === newValue) {\n return;\n }\n\n this.#handleBooleanAttributeChange(name, newValue);\n this.#handleElementTargetAttributeChange(name, oldValue);\n this.#handleStringAttributeChange(name, oldValue, newValue);\n }\n\n #queueBehaviorSync() {\n if (!this.isConnected || this.#syncQueued) {\n return;\n }\n\n this.#syncQueued = true;\n void this.#getHostUpdateComplete().then(() => {\n if (!this.#syncQueued) return;\n this.#syncQueued = false;\n if (this.isConnected) this.#syncBehavior();\n });\n }\n\n #syncBehavior() {\n this._controllers?.forEach(controller => controller.hostUpdated?.());\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'pressed' || name === 'expanded' || name === 'selected' || name === 'disabled') {\n this.#setBooleanState({ property: name, value: newValue !== null, reflect: false });\n }\n\n if (name === 'readonly') {\n this.#setBooleanState({ property: 'readOnly', value: newValue !== null, reflect: false });\n }\n }\n\n #handleStringAttributeChange(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'commandfor' || name === 'interestfor' || name === 'popovertarget') {\n return;\n }\n\n if (name === 'form') {\n if (!(isFormElement(this.#form) && newValue === null)) {\n this.#form = newValue;\n this.#requestHostUpdate('form', oldValue);\n }\n }\n\n if (name === 'popovertargetaction') {\n this.#setStringState({ property: 'popoverTargetAction', value: newValue, reflect: false });\n return;\n }\n\n this.#setStringState({ property: name, value: newValue, reflect: false });\n }\n\n #handleElementTargetAttributeChange(name: string, oldValue: string | null) {\n const property = ELEMENT_TARGET_PROPERTIES[name as ElementTargetAttribute];\n if (!property) {\n return;\n }\n\n const oldTarget = this.#elementTargets[property] ?? this.#getElementById(oldValue);\n this.#elementTargets[property] = null;\n this.#requestHostUpdate(property, oldTarget);\n this.#queueBehaviorSync();\n }\n\n #getElementTarget(attribute: ElementTargetAttribute) {\n return (\n this.#elementTargets[ELEMENT_TARGET_PROPERTIES[attribute]] ?? this.#getElementById(this.getAttribute(attribute))\n );\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n\n #setElementTarget(attribute: ElementTargetAttribute, value: HTMLElement | null) {\n const property = ELEMENT_TARGET_PROPERTIES[attribute];\n const oldValue = this[property];\n if (oldValue === value && hasAttributeValue(this, attribute, value ? '' : null)) {\n return;\n }\n setAttributeValue(this, attribute, value ? '' : null);\n this.#elementTargets[property] = value;\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #setBooleanState({ property, value, reflect, attribute = property }: BooleanStateOptions) {\n const oldValue = this.#getBooleanValue(property);\n if (oldValue === value && (!reflect || hasAttributeValue(this, attribute, value ? '' : null))) {\n return;\n }\n\n this.#setBooleanValue(property, value);\n if (reflect && this.#reflectAttribute(attribute, value ? '' : null)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getBooleanValue(property: string) {\n return {\n disabled: this.#disabled,\n expanded: this.#expanded,\n pressed: this.#pressed,\n readOnly: this.#readOnly,\n selected: this.#selected\n }[property];\n }\n\n #setBooleanValue(property: string, value: boolean) {\n if (property === 'disabled') {\n this.#disabled = value;\n } else if (property === 'expanded') {\n this.#expanded = value;\n } else if (property === 'pressed') {\n this.#pressed = value;\n } else if (property === 'readOnly') {\n this.#readOnly = value;\n } else if (property === 'selected') {\n this.#selected = value;\n }\n }\n\n #setStringState({ property, value, attribute = property, reflect = true }: StringStateOptions) {\n const oldValue = this.#getStringValue(property);\n const nextValue = getStringValue(value);\n if (oldValue === nextValue && (!reflect || hasAttributeValue(this, attribute, nextValue))) {\n return;\n }\n\n this.#setStringValue(property, nextValue);\n if (reflect && this.#reflectAttribute(attribute, nextValue)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getStringValue(property: string) {\n return {\n command: this.#command,\n current: this.#current,\n name: this.#name,\n popoverTargetAction: this.#popoverTargetAction,\n type: this.#type,\n value: this.#value\n }[property];\n }\n\n #setStringValue(property: string, value: string | null) {\n const setters: Record<string, () => void> = {\n command: () => (this.#command = value ?? undefined),\n current: () => (this.#current = value as CurrentState),\n name: () => (this.#name = value ?? undefined),\n popoverTargetAction: () => (this.#popoverTargetAction = value as PopoverTargetAction),\n type: () => (this.#type = value as ButtonType),\n value: () => (this.#value = value ?? undefined)\n };\n setters[property]?.();\n }\n\n #reflectAttribute(attribute: string, value: string | null) {\n if (!this.isConnected && !this.#hasConnected) {\n if (!this.hasAttribute(attribute)) {\n this.#pendingAttributeReflections.set(attribute, value);\n }\n return true;\n }\n\n setAttributeValue(this, attribute, value);\n return false;\n }\n\n #requestHostUpdate(name?: string, oldValue?: unknown) {\n this.requestUpdate?.(name, oldValue);\n }\n\n #getHostUpdateComplete() {\n return this.updateComplete ?? Promise.resolve();\n }\n\n #flushPendingAttributeReflections() {\n this.#pendingAttributeReflections.forEach((value, attribute) => setAttributeValue(this, attribute, value));\n this.#pendingAttributeReflections.clear();\n }\n } as unknown as ButtonFormControlMixinReturn<TBase>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgEA,IAAM,IAA4B;CAChC,YAAY;CACZ,aAAa;CACb,eAAe;AACjB;AAgBA,SAAgB,EACd,GACqC;CACrC,OAAO,MAAM,UAA8B,EAAW;;GA+Mf,aA1MzB,KAAA,KAAA,IACyD,KAAA,KAAA;IACnE,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;GACxB,GAEyC,KAAA,KAAA,MACzB,KAAA,KAAA,IAEe,KAAA,qBAAA,IAAI,IAA2B,GAGlD,KAAA,KAAA,IAEE,KAAA,KAAA,IAID,KAAA,aAAA,EAAgB,IAAI,GA2KC,KAAA,wBAAA,IAAI,EAAqB,IAAI,GAC7B,KAAA,wBAAA,IAAI,EAAqB,IAAI,GAC7B,KAAA,wBAA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
+
{"version":3,"file":"button.js","names":["ELEMENT_TARGET_PROPERTIES","ButtonFormControlMixin","ButtonFormControlBase","SuperClass","_args","#disabled","#elementTargets","#form","#hasConnected","#pendingAttributeReflections","#readOnly","#syncQueued","attachInternals","TypeAnchorController","TypeButtonController","TypeSubmitController","TypeCommandController","TypeInterestInvokerController","TypePopoverTriggerController","StateActiveController","StateDisabledController","StateExpandedController","StatePressedController","StateSelectedController","StateCurrentController","StateReadOnlyController","#pressed","#setBooleanState","value","#expanded","oldValue","form","#requestHostUpdate","#queueBehaviorSync","rootNode","isFormElement","#name","#setStringState","#value","#type","#selected","#current","#getElementTarget","#setElementTarget","#popoverTargetAction","#command","controller","#flushPendingAttributeReflections","#syncBehavior","changedProperties","name","newValue","#handleBooleanAttributeChange","#handleElementTargetAttributeChange","#handleStringAttributeChange","#getHostUpdateComplete","property","oldTarget","#getElementById","attribute","id","getFlattenedDOMTree","element","hasAttributeValue","setAttributeValue","#getBooleanValue","reflect","#setBooleanValue","#reflectAttribute","#getStringValue","nextValue","getStringValue","#setStringValue"],"sources":["../../src/mixins/button.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeAnchorController } from '../internal/controllers/type-anchor.controller.js';\nimport { TypeButtonController } from '../internal/controllers/type-button.controller.js';\nimport { TypeCommandController } from '../internal/controllers/type-command.controller.js';\nimport { TypeInterestInvokerController } from '../internal/controllers/type-interest-invoker.controller.js';\nimport { TypeSubmitController } from '../internal/controllers/type-submit.controller.js';\nimport { TypePopoverTriggerController } from '../internal/controllers/type-popover-trigger.controller.js';\nimport { StateActiveController } from '../internal/controllers/state-active.controller.js';\nimport { StateCurrentController } from '../internal/controllers/state-current.controller.js';\nimport { StateDisabledController } from '../internal/controllers/state-disabled.controller.js';\nimport { StateExpandedController } from '../internal/controllers/state-expanded.controller.js';\nimport { StatePressedController } from '../internal/controllers/state-pressed.controller.js';\nimport { StateReadOnlyController } from '../internal/controllers/state-readonly.controller.js';\nimport { StateSelectedController } from '../internal/controllers/state-selected.controller.js';\nimport type { ReactiveController } from '../internal/controllers/types.js';\nimport {\n attachInternals,\n getFlattenedDOMTree,\n getStringValue,\n hasAttributeValue,\n isFormElement,\n setAttributeValue\n} from '../internal/utils.js';\nimport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\nexport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\n\ntype ChangedProperties = Map<PropertyKey, unknown>;\ninterface ButtonFormControlHost {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n updateComplete?: Promise<unknown>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & ButtonFormControlHost) & { observedAttributes?: string[] };\n\ninterface BooleanStateOptions {\n property: string;\n value: boolean;\n reflect: boolean;\n attribute?: string;\n}\n\ninterface StringStateOptions {\n property: string;\n value: unknown;\n attribute?: string;\n reflect?: boolean;\n}\n\nconst ELEMENT_TARGET_PROPERTIES = {\n commandfor: 'commandForElement',\n interestfor: 'interestForElement',\n popovertarget: 'popoverTargetElement'\n} as const;\ntype ElementTargetAttribute = keyof typeof ELEMENT_TARGET_PROPERTIES;\ntype ElementTargetProperty = (typeof ELEMENT_TARGET_PROPERTIES)[ElementTargetAttribute];\n\ntype ButtonFormControlConstructor<TBase extends Constructor> = new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & ButtonFormControlMixinInstance;\nexport type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonFormControlConstructor<TBase> & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds native button-style form, command, popover, and interaction behavior.\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/button/\n */\nexport function ButtonFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): ButtonFormControlMixinReturn<TBase> {\n return class ButtonFormControlBase extends SuperClass {\n static formAssociated = true;\n\n #command: string | undefined;\n #current: CurrentState | undefined;\n #disabled = false;\n #elementTargets: Record<ElementTargetProperty, HTMLElement | null> = {\n commandForElement: null,\n interestForElement: null,\n popoverTargetElement: null\n };\n #expanded: boolean | undefined;\n #form: string | HTMLFormElement | null = null;\n #hasConnected = false;\n #name: string | undefined;\n #pendingAttributeReflections = new Map<string, string | null>();\n #popoverTargetAction: PopoverTargetAction | undefined;\n #pressed: boolean | undefined;\n #readOnly = false;\n #selected: boolean | undefined;\n #syncQueued = false;\n #type: ButtonType | undefined;\n #value: string | undefined;\n\n _internals = attachInternals(this);\n\n static get observedAttributes() {\n return (super.observedAttributes ?? []).concat([\n 'pressed',\n 'expanded',\n 'readonly',\n 'form',\n 'name',\n 'value',\n 'type',\n 'disabled',\n 'selected',\n 'current',\n 'popovertarget',\n 'popovertargetaction',\n 'commandfor',\n 'command',\n 'interestfor'\n ]);\n }\n\n get pressed(): boolean {\n return this.#pressed as boolean;\n }\n\n set pressed(value: boolean | unknown) {\n this.#setBooleanState({ property: 'pressed', value: Boolean(value), reflect: true });\n }\n\n get expanded(): boolean {\n return this.#expanded as boolean;\n }\n\n set expanded(value: boolean | unknown) {\n this.#setBooleanState({ property: 'expanded', value: Boolean(value), reflect: true });\n }\n\n get readOnly(): boolean {\n return this.#readOnly || (this._typeAnchorController?.readOnly ?? false);\n }\n\n set readOnly(value: boolean | unknown) {\n this.#setBooleanState({ property: 'readOnly', value: Boolean(value), reflect: true, attribute: 'readonly' });\n }\n\n get readonly(): boolean {\n return this.readOnly;\n }\n\n set readonly(value: boolean) {\n this.readOnly = value;\n }\n\n set form(form: string | HTMLFormElement | null) {\n const oldValue = this.form;\n this.#form = form;\n if (typeof form === 'string') {\n this.setAttribute('form', form);\n } else {\n this.removeAttribute('form');\n }\n this.#requestHostUpdate('form', oldValue);\n this.#queueBehaviorSync();\n }\n\n get form(): HTMLFormElement | null | string {\n if (this.#form && typeof this.#form !== 'string') {\n return this.#form;\n }\n\n if (typeof this.#form === 'string' && typeof globalThis.document !== 'undefined') {\n const rootNode = this.getRootNode() as Document | ShadowRoot;\n const form = rootNode.getElementById ? rootNode.getElementById(this.#form) : null;\n return isFormElement(form) ? form : null;\n }\n\n return this._internals?.form ?? null;\n }\n\n get name(): string {\n return this.#name as string;\n }\n\n set name(value: string | unknown) {\n this.#setStringState({ property: 'name', value });\n }\n\n get value(): string {\n return this.#value as string;\n }\n\n set value(value: string | unknown) {\n this.#setStringState({ property: 'value', value });\n }\n\n get type(): ButtonType {\n return (this.#type ?? this._typeSubmitController?.defaultType) as ButtonType;\n }\n\n set type(value: ButtonType | unknown) {\n this.#setStringState({ property: 'type', value });\n }\n\n get disabled(): boolean {\n return this.#disabled;\n }\n\n set disabled(value: boolean | unknown) {\n this.#setBooleanState({ property: 'disabled', value: Boolean(value), reflect: true });\n }\n\n get selected(): boolean {\n return this.#selected as boolean;\n }\n\n set selected(value: boolean | unknown) {\n this.#setBooleanState({ property: 'selected', value: Boolean(value), reflect: true });\n }\n\n get current(): CurrentState {\n return this.#current as CurrentState;\n }\n\n set current(value: CurrentState | unknown) {\n this.#setStringState({ property: 'current', value });\n }\n\n get popoverTargetElement(): HTMLElement | null {\n return this.#getElementTarget('popovertarget');\n }\n\n set popoverTargetElement(value: HTMLElement | null) {\n this.#setElementTarget('popovertarget', value);\n }\n\n get popoverTargetAction(): PopoverTargetAction {\n return this.#popoverTargetAction === 'show' || this.#popoverTargetAction === 'hide'\n ? this.#popoverTargetAction\n : 'toggle';\n }\n\n set popoverTargetAction(value: PopoverTargetAction | unknown) {\n this.#setStringState({ property: 'popoverTargetAction', value, attribute: 'popovertargetaction' });\n }\n\n get commandForElement(): HTMLElement | null {\n return this.#getElementTarget('commandfor');\n }\n\n set commandForElement(value: HTMLElement | null) {\n this.#setElementTarget('commandfor', value);\n }\n\n get command(): string {\n return this.#command as string;\n }\n\n set command(value: string | unknown) {\n this.#setStringState({ property: 'command', value });\n }\n\n get interestForElement(): HTMLElement | null {\n return this.#getElementTarget('interestfor');\n }\n\n set interestForElement(value: HTMLElement | null) {\n this.#setElementTarget('interestfor', value);\n }\n\n protected _controllers?: Set<ReactiveController>;\n protected _typeAnchorController = new TypeAnchorController(this);\n protected _typeButtonController = new TypeButtonController(this);\n protected _typeSubmitController = new TypeSubmitController(this);\n protected _typeCommandController = new TypeCommandController(this);\n protected _typeInterestInvokerController = new TypeInterestInvokerController(this);\n protected _typePopoverTriggerController = new TypePopoverTriggerController(this);\n protected _stateActiveController = new StateActiveController(this);\n protected _stateDisabledController = new StateDisabledController(this);\n protected _stateExpandedController = new StateExpandedController(this);\n protected _statePressedController = new StatePressedController(this);\n protected _stateSelectedController = new StateSelectedController(this);\n protected _stateCurrentController = new StateCurrentController(this);\n protected _stateReadOnlyController = new StateReadOnlyController(this);\n\n addController(controller: ReactiveController) {\n this._controllers ??= new Set<ReactiveController>();\n this._controllers.add(controller);\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n this._controllers?.forEach(controller => controller.hostConnected?.());\n attachInternals(this);\n this.#hasConnected = true;\n this.#flushPendingAttributeReflections();\n\n this.#syncBehavior();\n this.#queueBehaviorSync();\n }\n\n disconnectedCallback() {\n this._controllers?.forEach(controller => controller.hostDisconnected?.());\n super.disconnectedCallback?.();\n }\n\n protected updated(changedProperties: ChangedProperties) {\n const superUpdated = Object.getPrototypeOf(ButtonFormControlBase.prototype).updated as\n | ((changedProperties: ChangedProperties) => void)\n | undefined;\n superUpdated?.call(this, changedProperties);\n this.#syncQueued = false;\n this.#syncBehavior();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n\n if (oldValue === newValue) {\n return;\n }\n\n this.#handleBooleanAttributeChange(name, newValue);\n this.#handleElementTargetAttributeChange(name, oldValue);\n this.#handleStringAttributeChange(name, oldValue, newValue);\n }\n\n #queueBehaviorSync() {\n if (!this.isConnected || this.#syncQueued) {\n return;\n }\n\n this.#syncQueued = true;\n void this.#getHostUpdateComplete().then(() => {\n if (!this.#syncQueued) return;\n this.#syncQueued = false;\n if (this.isConnected) this.#syncBehavior();\n });\n }\n\n #syncBehavior() {\n this._controllers?.forEach(controller => controller.hostUpdated?.());\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'pressed' || name === 'expanded' || name === 'selected' || name === 'disabled') {\n this.#setBooleanState({ property: name, value: newValue !== null, reflect: false });\n }\n\n if (name === 'readonly') {\n this.#setBooleanState({ property: 'readOnly', value: newValue !== null, reflect: false });\n }\n }\n\n #handleStringAttributeChange(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'commandfor' || name === 'interestfor' || name === 'popovertarget') {\n return;\n }\n\n if (name === 'form') {\n if (!(isFormElement(this.#form) && newValue === null)) {\n this.#form = newValue;\n this.#requestHostUpdate('form', oldValue);\n }\n }\n\n if (name === 'popovertargetaction') {\n this.#setStringState({ property: 'popoverTargetAction', value: newValue, reflect: false });\n return;\n }\n\n this.#setStringState({ property: name, value: newValue, reflect: false });\n }\n\n #handleElementTargetAttributeChange(name: string, oldValue: string | null) {\n const property = ELEMENT_TARGET_PROPERTIES[name as ElementTargetAttribute];\n if (!property) {\n return;\n }\n\n const oldTarget = this.#elementTargets[property] ?? this.#getElementById(oldValue);\n this.#elementTargets[property] = null;\n this.#requestHostUpdate(property, oldTarget);\n this.#queueBehaviorSync();\n }\n\n #getElementTarget(attribute: ElementTargetAttribute) {\n return (\n this.#elementTargets[ELEMENT_TARGET_PROPERTIES[attribute]] ?? this.#getElementById(this.getAttribute(attribute))\n );\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n\n #setElementTarget(attribute: ElementTargetAttribute, value: HTMLElement | null) {\n const property = ELEMENT_TARGET_PROPERTIES[attribute];\n const oldValue = this[property];\n if (oldValue === value && hasAttributeValue(this, attribute, value ? '' : null)) {\n return;\n }\n setAttributeValue(this, attribute, value ? '' : null);\n this.#elementTargets[property] = value;\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #setBooleanState({ property, value, reflect, attribute = property }: BooleanStateOptions) {\n const oldValue = this.#getBooleanValue(property);\n if (oldValue === value && (!reflect || hasAttributeValue(this, attribute, value ? '' : null))) {\n return;\n }\n\n this.#setBooleanValue(property, value);\n if (reflect && this.#reflectAttribute(attribute, value ? '' : null)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getBooleanValue(property: string) {\n return {\n disabled: this.#disabled,\n expanded: this.#expanded,\n pressed: this.#pressed,\n readOnly: this.#readOnly,\n selected: this.#selected\n }[property];\n }\n\n #setBooleanValue(property: string, value: boolean) {\n if (property === 'disabled') {\n this.#disabled = value;\n } else if (property === 'expanded') {\n this.#expanded = value;\n } else if (property === 'pressed') {\n this.#pressed = value;\n } else if (property === 'readOnly') {\n this.#readOnly = value;\n } else if (property === 'selected') {\n this.#selected = value;\n }\n }\n\n #setStringState({ property, value, attribute = property, reflect = true }: StringStateOptions) {\n const oldValue = this.#getStringValue(property);\n const nextValue = getStringValue(value);\n if (oldValue === nextValue && (!reflect || hasAttributeValue(this, attribute, nextValue))) {\n return;\n }\n\n this.#setStringValue(property, nextValue);\n if (reflect && this.#reflectAttribute(attribute, nextValue)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getStringValue(property: string) {\n return {\n command: this.#command,\n current: this.#current,\n name: this.#name,\n popoverTargetAction: this.#popoverTargetAction,\n type: this.#type,\n value: this.#value\n }[property];\n }\n\n #setStringValue(property: string, value: string | null) {\n const setters: Record<string, () => void> = {\n command: () => (this.#command = value ?? undefined),\n current: () => (this.#current = value as CurrentState),\n name: () => (this.#name = value ?? undefined),\n popoverTargetAction: () => (this.#popoverTargetAction = value as PopoverTargetAction),\n type: () => (this.#type = value as ButtonType),\n value: () => (this.#value = value ?? undefined)\n };\n setters[property]?.();\n }\n\n #reflectAttribute(attribute: string, value: string | null) {\n if (!this.isConnected && !this.#hasConnected) {\n if (!this.hasAttribute(attribute)) {\n this.#pendingAttributeReflections.set(attribute, value);\n }\n return true;\n }\n\n setAttributeValue(this, attribute, value);\n return false;\n }\n\n #requestHostUpdate(name?: string, oldValue?: unknown) {\n this.requestUpdate?.(name, oldValue);\n }\n\n #getHostUpdateComplete() {\n return this.updateComplete ?? Promise.resolve();\n }\n\n #flushPendingAttributeReflections() {\n this.#pendingAttributeReflections.forEach((value, attribute) => setAttributeValue(this, attribute, value));\n this.#pendingAttributeReflections.clear();\n }\n } as unknown as ButtonFormControlMixinReturn<TBase>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgEA,IAAMA,IAA4B;CAChC,YAAY;CACZ,aAAa;CACb,eAAe;AACjB;AAgBA,SAAgBC,EACd,GACqC;CACrC,OAAO,MAAMC,UAA8BC,EAAW;;GA+Mf,A,aA1MzB,KAAAE,KAAA,IACyD,KAAAC,KAAA;IACnE,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;GACxB,GAEyC,KAAAC,KAAA,MACzB,KAAAC,KAAA,IAEe,KAAAC,qBAAA,IAAI,IAA2B,GAGlD,KAAAC,KAAA,IAEE,KAAAC,KAAA,IAID,KAAA,aAAAC,EAAgB,IAAI,GA2KC,KAAA,wBAAA,IAAIC,EAAqB,IAAI,GAC7B,KAAA,wBAAA,IAAIC,EAAqB,IAAI,GAC7B,KAAA,wBAAA,IAAIC,EAAqB,IAAI,GAC5B,KAAA,yBAAA,IAAIC,EAAsB,IAAI,GACtB,KAAA,iCAAA,IAAIC,EAA8B,IAAI,GACvC,KAAA,gCAAA,IAAIC,EAA6B,IAAI,GAC5C,KAAA,yBAAA,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