@nvidia-elements/forms 2.0.3 → 2.0.4
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 +34 -0
- package/dist/custom-elements.json +53 -1
- package/dist/index.js +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.js +32 -21
- package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.d.ts +0 -1
- package/dist/internal/controllers/type-popover-trigger.controller.js +2 -2
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/mixins/button.js +133 -143
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/button.types.d.ts +1 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## <small>2.0.4 (2026-07-21)</small>
|
|
2
|
+
|
|
3
|
+
* fix(cli): improve api metadata ([b2c13ab](https://github.com/NVIDIA/elements/commit/b2c13ab))
|
|
4
|
+
* fix(cli): mute interactions on non tty sessions ([ba3230a](https://github.com/NVIDIA/elements/commit/ba3230a))
|
|
5
|
+
* fix(code): include custom data documentation references ([f4efebb](https://github.com/NVIDIA/elements/commit/f4efebb))
|
|
6
|
+
* fix(core): align root tree nodes ([6008461](https://github.com/NVIDIA/elements/commit/6008461))
|
|
7
|
+
* fix(core): api documentation ([a02b9e2](https://github.com/NVIDIA/elements/commit/a02b9e2))
|
|
8
|
+
* fix(core): collapsed tab group ([b7be2d9](https://github.com/NVIDIA/elements/commit/b7be2d9))
|
|
9
|
+
* fix(core): ensure proper property and attribute reflection for button types ([af780c6](https://github.com/NVIDIA/elements/commit/af780c6))
|
|
10
|
+
* fix(core): include custom data documentation references ([bf9168c](https://github.com/NVIDIA/elements/commit/bf9168c))
|
|
11
|
+
* fix(core): page header text wrap issue ([03c481f](https://github.com/NVIDIA/elements/commit/03c481f))
|
|
12
|
+
* fix(forms): proper property and attribute reflection for button mixin ([e6093dd](https://github.com/NVIDIA/elements/commit/e6093dd))
|
|
13
|
+
* fix(lint): enhance data binding checks and update test cases for popover triggers ([56e4701](https://github.com/NVIDIA/elements/commit/56e4701))
|
|
14
|
+
* fix(lint): support framework event bindings ([4a1e72d](https://github.com/NVIDIA/elements/commit/4a1e72d))
|
|
15
|
+
* fix(markdown): include custom data documentation references ([b887400](https://github.com/NVIDIA/elements/commit/b887400))
|
|
16
|
+
* fix(monaco): include custom data documentation references ([75f42f5](https://github.com/NVIDIA/elements/commit/75f42f5))
|
|
17
|
+
* chore(ci): indexnow doc updates ([669552f](https://github.com/NVIDIA/elements/commit/669552f))
|
|
18
|
+
* chore(ci): update lighthouse ([b5b71ca](https://github.com/NVIDIA/elements/commit/b5b71ca))
|
|
19
|
+
* chore(ci): update metrics ([96ebb4b](https://github.com/NVIDIA/elements/commit/96ebb4b))
|
|
20
|
+
* chore(docs): add custom data reference tests ([af48603](https://github.com/NVIDIA/elements/commit/af48603))
|
|
21
|
+
* chore(internals): generate custom data references ([3f2bd36](https://github.com/NVIDIA/elements/commit/3f2bd36))
|
|
22
|
+
* chore(release): @nvidia-elements/cli-v2.1.5 [skip ci] ([7e217b8](https://github.com/NVIDIA/elements/commit/7e217b8))
|
|
23
|
+
* chore(release): @nvidia-elements/code-v2.0.2 [skip ci] ([f69e036](https://github.com/NVIDIA/elements/commit/f69e036))
|
|
24
|
+
* chore(release): @nvidia-elements/core-v2.1.0 [skip ci] ([9a874bd](https://github.com/NVIDIA/elements/commit/9a874bd))
|
|
25
|
+
* chore(release): @nvidia-elements/core-v2.1.1 [skip ci] ([3e67a33](https://github.com/NVIDIA/elements/commit/3e67a33))
|
|
26
|
+
* chore(release): @nvidia-elements/core-v2.1.2 [skip ci] ([051719c](https://github.com/NVIDIA/elements/commit/051719c))
|
|
27
|
+
* chore(release): @nvidia-elements/core-v2.1.3 [skip ci] ([b6c09ba](https://github.com/NVIDIA/elements/commit/b6c09ba))
|
|
28
|
+
* chore(release): @nvidia-elements/lint-v2.1.0 [skip ci] ([e668854](https://github.com/NVIDIA/elements/commit/e668854))
|
|
29
|
+
* chore(release): @nvidia-elements/lint-v2.1.1 [skip ci] ([efb7a71](https://github.com/NVIDIA/elements/commit/efb7a71))
|
|
30
|
+
* chore(release): @nvidia-elements/markdown-v2.0.2 [skip ci] ([953ef48](https://github.com/NVIDIA/elements/commit/953ef48))
|
|
31
|
+
* chore(release): @nvidia-elements/monaco-v2.0.2 [skip ci] ([12820b1](https://github.com/NVIDIA/elements/commit/12820b1))
|
|
32
|
+
* chore(release): @nvidia-elements/styles-v2.1.0 [skip ci] ([25eb987](https://github.com/NVIDIA/elements/commit/25eb987))
|
|
33
|
+
* feat(lint): add prefer-aria-label-in-compact-containers rule ([130279f](https://github.com/NVIDIA/elements/commit/130279f))
|
|
34
|
+
|
|
1
35
|
## <small>2.0.3 (2026-07-18)</small>
|
|
2
36
|
|
|
3
37
|
* chore(ci): improve test coverage ([4ef2eb3](https://github.com/NVIDIA/elements/commit/4ef2eb3))
|
|
@@ -576,6 +576,17 @@
|
|
|
576
576
|
"description": "",
|
|
577
577
|
"name": "TypeInterestInvokerController",
|
|
578
578
|
"members": [
|
|
579
|
+
{
|
|
580
|
+
"kind": "field",
|
|
581
|
+
"name": "#inferredInterestForElement",
|
|
582
|
+
"privacy": "private",
|
|
583
|
+
"type": {
|
|
584
|
+
"text": "HTMLElement | null",
|
|
585
|
+
"_sourceAliases": [],
|
|
586
|
+
"values": []
|
|
587
|
+
},
|
|
588
|
+
"default": "null"
|
|
589
|
+
},
|
|
579
590
|
{
|
|
580
591
|
"kind": "method",
|
|
581
592
|
"name": "hostConnected"
|
|
@@ -596,8 +607,49 @@
|
|
|
596
607
|
},
|
|
597
608
|
{
|
|
598
609
|
"kind": "method",
|
|
599
|
-
"name": "#
|
|
610
|
+
"name": "#dispatchInterestEvent",
|
|
611
|
+
"privacy": "private",
|
|
612
|
+
"parameters": [
|
|
613
|
+
{
|
|
614
|
+
"name": "type",
|
|
615
|
+
"type": {
|
|
616
|
+
"text": "'interest' | 'loseinterest'"
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"kind": "method",
|
|
623
|
+
"name": "#getInterestForElement",
|
|
624
|
+
"privacy": "private"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"kind": "method",
|
|
628
|
+
"name": "#getExplicitInterestForElement",
|
|
629
|
+
"privacy": "private",
|
|
630
|
+
"return": {
|
|
631
|
+
"type": {
|
|
632
|
+
"text": "HTMLElement | null | undefined"
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"kind": "method",
|
|
638
|
+
"name": "#getHintPopoverTarget",
|
|
600
639
|
"privacy": "private"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"kind": "method",
|
|
643
|
+
"name": "#getElementById",
|
|
644
|
+
"privacy": "private",
|
|
645
|
+
"parameters": [
|
|
646
|
+
{
|
|
647
|
+
"name": "id",
|
|
648
|
+
"type": {
|
|
649
|
+
"text": "string | null"
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
]
|
|
601
653
|
}
|
|
602
654
|
]
|
|
603
655
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,46 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e } from "../utils.js";
|
|
2
2
|
//#region src/internal/controllers/type-interest-invoker.controller.ts
|
|
3
3
|
var t = class {
|
|
4
|
+
#e = null;
|
|
4
5
|
constructor(e) {
|
|
5
6
|
this.host = e, this.host.addController(this);
|
|
6
7
|
}
|
|
7
8
|
hostConnected() {
|
|
8
|
-
this.host.addEventListener("mouseenter", this.#
|
|
9
|
+
this.host.addEventListener("mouseenter", this.#t), this.host.addEventListener("mouseleave", this.#n), this.host.addEventListener("focus", this.#t), this.host.addEventListener("blur", this.#n);
|
|
9
10
|
}
|
|
10
11
|
hostDisconnected() {
|
|
11
|
-
this.host.removeEventListener("mouseenter", this.#
|
|
12
|
+
this.host.removeEventListener("mouseenter", this.#t), this.host.removeEventListener("mouseleave", this.#n), this.host.removeEventListener("focus", this.#t), this.host.removeEventListener("blur", this.#n);
|
|
12
13
|
}
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
let e = new Event("interest", { cancelable: !0 });
|
|
16
|
-
e.source = this.host, this.host.interestForElement.dispatchEvent(e);
|
|
17
|
-
}
|
|
14
|
+
#t = (e) => {
|
|
15
|
+
e.type === "focus" && !this.host.matches(":focus-visible") || this.host.popoverTargetElement?.matches(":popover-open") || this.#r("interest");
|
|
18
16
|
};
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
#n = () => this.#r("loseinterest");
|
|
18
|
+
#r(e) {
|
|
19
|
+
let t = this.#i();
|
|
20
|
+
if (!t) return;
|
|
21
|
+
let n = new Event(e, { cancelable: !0 });
|
|
22
|
+
n.source = this.host, t.dispatchEvent(n);
|
|
23
|
+
}
|
|
24
|
+
#i() {
|
|
25
|
+
let e = this.#a();
|
|
26
|
+
if (e !== void 0) return e;
|
|
27
|
+
let t = this.#o(), n = this.#e;
|
|
28
|
+
return this.#e = t, t && this.host.interestForElement !== t ? this.host.interestForElement = t : !t && n && this.host.interestForElement === n && (this.host.interestForElement = null), t;
|
|
29
|
+
}
|
|
30
|
+
#a() {
|
|
31
|
+
let e = this.host.getAttribute("interestfor");
|
|
32
|
+
if (e) return this.#e = null, this.#s(e);
|
|
33
|
+
let t = this.host.interestForElement;
|
|
34
|
+
if (!(!t || t === this.#e)) return this.#e = null, t;
|
|
35
|
+
}
|
|
36
|
+
#o() {
|
|
37
|
+
let e = this.host.popoverTargetElement;
|
|
38
|
+
if (e instanceof HTMLElement && e.popover === "hint") return e;
|
|
39
|
+
let t = this.#s(this.host.getAttribute("popovertarget"));
|
|
40
|
+
return t instanceof HTMLElement && t.popover === "hint" ? t : null;
|
|
41
|
+
}
|
|
42
|
+
#s(t) {
|
|
43
|
+
return t ? e(this.host.getRootNode()).find((e) => e.id === t) ?? null : null;
|
|
33
44
|
}
|
|
34
45
|
};
|
|
35
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-interest-invoker.controller.js","names":["#onInterest","#onLoseInterest","#
|
|
1
|
+
{"version":3,"file":"type-interest-invoker.controller.js","names":["#onInterest","#onLoseInterest","#dispatchInterestEvent","#getInterestForElement","#getExplicitInterestForElement","#getHintPopoverTarget","#inferredInterestForElement","#getElementById"],"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,IAAa,IAAb,MAAwG;CACtG,KAAkD;CAElD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,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B,MAC5B,KAAKC,GAAgB,CAAgB;EAG9C,IAAM,IAAqB,KAAK,KAAK;EACjC,OAAC,KAAsB,MAAuB,KAAKD,KAKvD,OADA,KAAKA,KAA8B,MAC5B;CACT;CAEA,KAAwB;EACtB,IAAM,IAAgB,KAAK,KAAK;EAChC,IAAI,aAAyB,eAAe,EAAc,YAAY,QACpE,OAAO;EAGT,IAAM,IAAS,KAAKC,GAAgB,KAAK,KAAK,aAAa,eAAe,CAAC;EAC3E,OAAO,aAAkB,eAAe,EAAO,YAAY,SAAS,IAAS;CAC/E;CAEA,GAAgB,GAAmB;EACjC,OAAO,IAAM,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAAK,MAAW,EAAQ,OAAO,CAAE,KAAK,OAAQ;CAC1G;AACF"}
|
|
@@ -5,7 +5,6 @@ type PopoverTriggerHost = ReactiveElement & {
|
|
|
5
5
|
interestForElement: HTMLElement | null;
|
|
6
6
|
popoverTargetAction?: PopoverTargetAction;
|
|
7
7
|
popoverTargetElement: HTMLElement | null;
|
|
8
|
-
popovertarget?: string;
|
|
9
8
|
};
|
|
10
9
|
export declare class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {
|
|
11
10
|
#private;
|
|
@@ -13,9 +13,9 @@ var n = class {
|
|
|
13
13
|
#e;
|
|
14
14
|
#t() {
|
|
15
15
|
let t = this.host.popoverTargetElement, n = t === this.#e;
|
|
16
|
-
if (!this.host.popovertarget) return this.#e = void 0, n ? (this.host.popoverTargetElement = null, null) : t;
|
|
16
|
+
if (!this.host.getAttribute("popovertarget")) return this.#e = void 0, n ? (this.host.popoverTargetElement = null, null) : t;
|
|
17
17
|
if (t && !n) return t;
|
|
18
|
-
let r = e(this.host.getRootNode()).find((e) => e.id === this.host.popovertarget) ?? null;
|
|
18
|
+
let r = e(this.host.getRootNode()).find((e) => e.id === this.host.getAttribute("popovertarget")) ?? null;
|
|
19
19
|
return r !== t && (this.host.popoverTargetElement = r), this.#e = r, r;
|
|
20
20
|
}
|
|
21
21
|
#n = (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-popover-trigger.controller.js","names":["#onClick","#resolvedPopoverTarget","#resolvePopoverTarget","#invokePopover","#handoverInterest","#getPopoverSource"],"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 '../../mixins/button.types.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
|
|
1
|
+
{"version":3,"file":"type-popover-trigger.controller.js","names":["#onClick","#resolvedPopoverTarget","#resolvePopoverTarget","#invokePopover","#handoverInterest","#getPopoverSource"],"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 '../../mixins/button.types.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 InterestEv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xC,EAAqB,QAAQ,eAAe;CACrD;CAEA,KAAoB;EAClB,IAAI,KAAK,KAAK,oBAAoB;GAChC,IAAM,IAAe,IAAI,MAAM,gBAAgB,EAAE,YAAY,GAAK,CAAC;GAEnE,AADA,EAAa,SAAS,KAAK,MAC3B,KAAK,KAAK,mBAAmB,cAAc,CAAY;EACzD;CACF;AACF"}
|
package/dist/mixins/button.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import { attachInternals as e,
|
|
2
|
-
import { TypeAnchorController as
|
|
3
|
-
import { TypeButtonController as
|
|
4
|
-
import { TypeCommandController as
|
|
5
|
-
import { TypeInterestInvokerController as
|
|
6
|
-
import { TypeSubmitController as
|
|
7
|
-
import { TypePopoverTriggerController as
|
|
8
|
-
import { StateActiveController as
|
|
9
|
-
import { StateCurrentController as
|
|
10
|
-
import { StateDisabledController as
|
|
11
|
-
import { StateExpandedController as
|
|
12
|
-
import { StatePressedController as
|
|
13
|
-
import { StateReadOnlyController as
|
|
14
|
-
import { StateSelectedController as
|
|
1
|
+
import { attachInternals as e, getFlattenedDOMTree as t, getStringValue as n, hasAttributeValue as r, isFormElement as i, setAttributeValue as a } from "../internal/utils.js";
|
|
2
|
+
import { TypeAnchorController as o } from "../internal/controllers/type-anchor.controller.js";
|
|
3
|
+
import { TypeButtonController as s } from "../internal/controllers/type-button.controller.js";
|
|
4
|
+
import { TypeCommandController as c } from "../internal/controllers/type-command.controller.js";
|
|
5
|
+
import { TypeInterestInvokerController as l } from "../internal/controllers/type-interest-invoker.controller.js";
|
|
6
|
+
import { TypeSubmitController as u } from "../internal/controllers/type-submit.controller.js";
|
|
7
|
+
import { TypePopoverTriggerController as d } from "../internal/controllers/type-popover-trigger.controller.js";
|
|
8
|
+
import { StateActiveController as f } from "../internal/controllers/state-active.controller.js";
|
|
9
|
+
import { StateCurrentController as p } from "../internal/controllers/state-current.controller.js";
|
|
10
|
+
import { StateDisabledController as m } from "../internal/controllers/state-disabled.controller.js";
|
|
11
|
+
import { StateExpandedController as h } from "../internal/controllers/state-expanded.controller.js";
|
|
12
|
+
import { StatePressedController as g } from "../internal/controllers/state-pressed.controller.js";
|
|
13
|
+
import { StateReadOnlyController as _ } from "../internal/controllers/state-readonly.controller.js";
|
|
14
|
+
import { StateSelectedController as v } from "../internal/controllers/state-selected.controller.js";
|
|
15
15
|
//#region src/mixins/button.ts
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
var y = {
|
|
17
|
+
commandfor: "commandForElement",
|
|
18
|
+
interestfor: "interestForElement",
|
|
19
|
+
popovertarget: "popoverTargetElement"
|
|
20
|
+
};
|
|
21
|
+
function b(b) {
|
|
22
|
+
return class x extends b {
|
|
18
23
|
constructor(...t) {
|
|
19
|
-
super(...t), this.#
|
|
24
|
+
super(...t), this.#n = !1, this.#r = {
|
|
25
|
+
commandForElement: null,
|
|
26
|
+
interestForElement: null,
|
|
27
|
+
popoverTargetElement: null
|
|
28
|
+
}, this.#a = null, this.#o = !1, this.#c = /* @__PURE__ */ new Map(), this.#d = !1, this.#p = !1, this._internals = e(this), this._typeAnchorController = new o(this), this._typeButtonController = new s(this), this._typeSubmitController = new u(this), this._typeCommandController = new c(this), this._typeInterestInvokerController = new l(this), this._typePopoverTriggerController = new d(this), this._stateActiveController = new f(this), this._stateDisabledController = new m(this), this._stateExpandedController = new h(this), this._statePressedController = new g(this), this._stateSelectedController = new v(this), this._stateCurrentController = new p(this), this._stateReadOnlyController = new _(this);
|
|
20
29
|
}
|
|
21
30
|
static {
|
|
22
31
|
this.formAssociated = !0;
|
|
@@ -37,11 +46,6 @@ function v(v) {
|
|
|
37
46
|
#p;
|
|
38
47
|
#m;
|
|
39
48
|
#h;
|
|
40
|
-
#g;
|
|
41
|
-
#_;
|
|
42
|
-
#v;
|
|
43
|
-
#y;
|
|
44
|
-
#b;
|
|
45
49
|
static get observedAttributes() {
|
|
46
50
|
return (super.observedAttributes ?? []).concat([
|
|
47
51
|
"pressed",
|
|
@@ -62,30 +66,30 @@ function v(v) {
|
|
|
62
66
|
]);
|
|
63
67
|
}
|
|
64
68
|
get pressed() {
|
|
65
|
-
return this.#
|
|
69
|
+
return this.#u;
|
|
66
70
|
}
|
|
67
71
|
set pressed(e) {
|
|
68
|
-
this.#
|
|
72
|
+
this.#w({
|
|
69
73
|
property: "pressed",
|
|
70
74
|
value: !!e,
|
|
71
75
|
reflect: !0
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
get expanded() {
|
|
75
|
-
return this.#
|
|
79
|
+
return this.#i;
|
|
76
80
|
}
|
|
77
81
|
set expanded(e) {
|
|
78
|
-
this.#
|
|
82
|
+
this.#w({
|
|
79
83
|
property: "expanded",
|
|
80
84
|
value: !!e,
|
|
81
85
|
reflect: !0
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
88
|
get readOnly() {
|
|
85
|
-
return this.#
|
|
89
|
+
return this.#d || !!this._typeAnchorController?.readOnly;
|
|
86
90
|
}
|
|
87
91
|
set readOnly(e) {
|
|
88
|
-
this.#
|
|
92
|
+
this.#w({
|
|
89
93
|
property: "readOnly",
|
|
90
94
|
value: !!e,
|
|
91
95
|
reflect: !0,
|
|
@@ -100,245 +104,231 @@ function v(v) {
|
|
|
100
104
|
}
|
|
101
105
|
set form(e) {
|
|
102
106
|
let t = this.form;
|
|
103
|
-
this.#
|
|
107
|
+
this.#a = e, typeof e == "string" ? this.setAttribute("form", e) : this.removeAttribute("form"), this.#j("form", t), this.#g();
|
|
104
108
|
}
|
|
105
109
|
get form() {
|
|
106
|
-
if (this.#
|
|
107
|
-
if (typeof this.#
|
|
108
|
-
let e = this.getRootNode(), t = e.getElementById ? e.getElementById(this.#
|
|
109
|
-
return
|
|
110
|
+
if (this.#a && typeof this.#a != "string") return this.#a;
|
|
111
|
+
if (typeof this.#a == "string" && globalThis.document !== void 0) {
|
|
112
|
+
let e = this.getRootNode(), t = e.getElementById ? e.getElementById(this.#a) : null;
|
|
113
|
+
return i(t) ? t : null;
|
|
110
114
|
}
|
|
111
115
|
return this._internals?.form ?? null;
|
|
112
116
|
}
|
|
113
117
|
get name() {
|
|
114
|
-
return this.#
|
|
118
|
+
return this.#s;
|
|
115
119
|
}
|
|
116
120
|
set name(e) {
|
|
117
|
-
this.#
|
|
121
|
+
this.#D({
|
|
118
122
|
property: "name",
|
|
119
123
|
value: e
|
|
120
124
|
});
|
|
121
125
|
}
|
|
122
126
|
get value() {
|
|
123
|
-
return this.#
|
|
127
|
+
return this.#h;
|
|
124
128
|
}
|
|
125
129
|
set value(e) {
|
|
126
|
-
this.#
|
|
130
|
+
this.#D({
|
|
127
131
|
property: "value",
|
|
128
132
|
value: e
|
|
129
133
|
});
|
|
130
134
|
}
|
|
131
135
|
get type() {
|
|
132
|
-
return this.#
|
|
136
|
+
return this.#m ?? this._typeSubmitController?.defaultType;
|
|
133
137
|
}
|
|
134
138
|
set type(e) {
|
|
135
|
-
this.#
|
|
139
|
+
this.#D({
|
|
136
140
|
property: "type",
|
|
137
141
|
value: e
|
|
138
142
|
});
|
|
139
143
|
}
|
|
140
144
|
get disabled() {
|
|
141
|
-
return this.#
|
|
145
|
+
return this.#n;
|
|
142
146
|
}
|
|
143
147
|
set disabled(e) {
|
|
144
|
-
this.#
|
|
148
|
+
this.#w({
|
|
145
149
|
property: "disabled",
|
|
146
150
|
value: !!e,
|
|
147
151
|
reflect: !0
|
|
148
152
|
});
|
|
149
153
|
}
|
|
150
154
|
get selected() {
|
|
151
|
-
return this.#
|
|
155
|
+
return this.#f;
|
|
152
156
|
}
|
|
153
157
|
set selected(e) {
|
|
154
|
-
this.#
|
|
158
|
+
this.#w({
|
|
155
159
|
property: "selected",
|
|
156
160
|
value: !!e,
|
|
157
161
|
reflect: !0
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
get current() {
|
|
161
|
-
return this.#
|
|
165
|
+
return this.#t;
|
|
162
166
|
}
|
|
163
167
|
set current(e) {
|
|
164
|
-
this.#
|
|
168
|
+
this.#D({
|
|
165
169
|
property: "current",
|
|
166
170
|
value: e
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
173
|
get popoverTargetElement() {
|
|
170
|
-
return this.#
|
|
174
|
+
return this.#x("popovertarget");
|
|
171
175
|
}
|
|
172
176
|
set popoverTargetElement(e) {
|
|
173
|
-
|
|
174
|
-
this.#p = e, this.#M("popoverTargetElement", t), this.#x();
|
|
175
|
-
}
|
|
176
|
-
get popovertarget() {
|
|
177
|
-
return this.#m;
|
|
178
|
-
}
|
|
179
|
-
set popovertarget(e) {
|
|
180
|
-
this.#O({
|
|
181
|
-
property: "popovertarget",
|
|
182
|
-
value: e
|
|
183
|
-
});
|
|
177
|
+
this.#C("popovertarget", e);
|
|
184
178
|
}
|
|
185
179
|
get popoverTargetAction() {
|
|
186
|
-
return this.#
|
|
180
|
+
return this.#l === "show" || this.#l === "hide" ? this.#l : "toggle";
|
|
187
181
|
}
|
|
188
182
|
set popoverTargetAction(e) {
|
|
189
|
-
this.#
|
|
183
|
+
this.#D({
|
|
190
184
|
property: "popoverTargetAction",
|
|
191
185
|
value: e,
|
|
192
186
|
attribute: "popovertargetaction"
|
|
193
187
|
});
|
|
194
188
|
}
|
|
195
189
|
get commandForElement() {
|
|
196
|
-
return this.#
|
|
190
|
+
return this.#x("commandfor");
|
|
197
191
|
}
|
|
198
192
|
set commandForElement(e) {
|
|
199
|
-
|
|
200
|
-
this.#t = e, this.#M("commandForElement", t), this.#x();
|
|
201
|
-
}
|
|
202
|
-
get commandfor() {
|
|
203
|
-
return this.#n;
|
|
204
|
-
}
|
|
205
|
-
set commandfor(e) {
|
|
206
|
-
this.#O({
|
|
207
|
-
property: "commandfor",
|
|
208
|
-
value: e
|
|
209
|
-
});
|
|
193
|
+
this.#C("commandfor", e);
|
|
210
194
|
}
|
|
211
195
|
get command() {
|
|
212
196
|
return this.#e;
|
|
213
197
|
}
|
|
214
198
|
set command(e) {
|
|
215
|
-
this.#
|
|
199
|
+
this.#D({
|
|
216
200
|
property: "command",
|
|
217
201
|
value: e
|
|
218
202
|
});
|
|
219
203
|
}
|
|
220
204
|
get interestForElement() {
|
|
221
|
-
return this.#
|
|
205
|
+
return this.#x("interestfor");
|
|
222
206
|
}
|
|
223
207
|
set interestForElement(e) {
|
|
224
|
-
|
|
225
|
-
this.#c = e, this.#M("interestForElement", t), this.#x();
|
|
226
|
-
}
|
|
227
|
-
get interestfor() {
|
|
228
|
-
return this.#l;
|
|
229
|
-
}
|
|
230
|
-
set interestfor(e) {
|
|
231
|
-
this.#O({
|
|
232
|
-
property: "interestfor",
|
|
233
|
-
value: e
|
|
234
|
-
});
|
|
208
|
+
this.#C("interestfor", e);
|
|
235
209
|
}
|
|
236
210
|
addController(e) {
|
|
237
211
|
this._controllers ??= /* @__PURE__ */ new Set(), this._controllers.add(e);
|
|
238
212
|
}
|
|
239
213
|
connectedCallback() {
|
|
240
|
-
super.connectedCallback?.(), this._controllers?.forEach((e) => e.hostConnected?.()), e(this), this.#
|
|
214
|
+
super.connectedCallback?.(), this._controllers?.forEach((e) => e.hostConnected?.()), e(this), this.#o = !0, this.#N(), this.#_(), this.#g();
|
|
241
215
|
}
|
|
242
216
|
disconnectedCallback() {
|
|
243
217
|
this._controllers?.forEach((e) => e.hostDisconnected?.()), super.disconnectedCallback?.();
|
|
244
218
|
}
|
|
245
219
|
updated(e) {
|
|
246
|
-
Object.getPrototypeOf(
|
|
220
|
+
Object.getPrototypeOf(x.prototype).updated?.call(this, e), this.#p = !1, this.#_();
|
|
247
221
|
}
|
|
248
222
|
attributeChangedCallback(e, t, n) {
|
|
249
|
-
super.attributeChangedCallback?.(e, t, n), t !== n && (this.#
|
|
223
|
+
super.attributeChangedCallback?.(e, t, n), t !== n && (this.#v(e, n), this.#b(e, t), this.#y(e, t, n));
|
|
250
224
|
}
|
|
251
|
-
#
|
|
252
|
-
!this.isConnected || this.#
|
|
253
|
-
this.#
|
|
225
|
+
#g() {
|
|
226
|
+
!this.isConnected || this.#p || (this.#p = !0, this.#M().then(() => {
|
|
227
|
+
this.#p && (this.#p = !1, this.isConnected && this.#_());
|
|
254
228
|
}));
|
|
255
229
|
}
|
|
256
|
-
#
|
|
230
|
+
#_() {
|
|
257
231
|
this._controllers?.forEach((e) => e.hostUpdated?.());
|
|
258
232
|
}
|
|
259
|
-
#
|
|
260
|
-
(e === "pressed" || e === "expanded" || e === "selected" || e === "disabled") && this.#
|
|
233
|
+
#v(e, t) {
|
|
234
|
+
(e === "pressed" || e === "expanded" || e === "selected" || e === "disabled") && this.#w({
|
|
261
235
|
property: e,
|
|
262
236
|
value: t !== null,
|
|
263
237
|
reflect: !1
|
|
264
|
-
}), e === "readonly" && this.#
|
|
238
|
+
}), e === "readonly" && this.#w({
|
|
265
239
|
property: "readOnly",
|
|
266
240
|
value: t !== null,
|
|
267
241
|
reflect: !1
|
|
268
242
|
});
|
|
269
243
|
}
|
|
270
|
-
#
|
|
271
|
-
e === "
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
244
|
+
#y(e, t, n) {
|
|
245
|
+
if (!(e === "commandfor" || e === "interestfor" || e === "popovertarget")) {
|
|
246
|
+
if (e === "form" && (i(this.#a) && n === null || (this.#a = n, this.#j("form", t))), e === "popovertargetaction") {
|
|
247
|
+
this.#D({
|
|
248
|
+
property: "popoverTargetAction",
|
|
249
|
+
value: n,
|
|
250
|
+
reflect: !1
|
|
251
|
+
});
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.#D({
|
|
255
|
+
property: e,
|
|
256
|
+
value: n,
|
|
257
|
+
reflect: !1
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
#b(e, t) {
|
|
262
|
+
let n = y[e];
|
|
263
|
+
if (!n) return;
|
|
264
|
+
let r = this.#r[n] ?? this.#S(t);
|
|
265
|
+
this.#r[n] = null, this.#j(n, r), this.#g();
|
|
280
266
|
}
|
|
281
|
-
#
|
|
282
|
-
|
|
283
|
-
a === t && (!r || n(this, i, t ? "" : null)) || (this.#D(e, t), !(r && this.#j(i, t ? "" : null)) && (this.#M(e, a), this.#x()));
|
|
267
|
+
#x(e) {
|
|
268
|
+
return this.#r[y[e]] ?? this.#S(this.getAttribute(e));
|
|
284
269
|
}
|
|
285
|
-
#
|
|
270
|
+
#S(e) {
|
|
271
|
+
return e ? t(this.getRootNode()).find((t) => t.id === e) ?? null : null;
|
|
272
|
+
}
|
|
273
|
+
#C(e, t) {
|
|
274
|
+
let n = y[e], i = this[n];
|
|
275
|
+
i === t && r(this, e, t ? "" : null) || (a(this, e, t ? "" : null), this.#r[n] = t, this.#j(n, i), this.#g());
|
|
276
|
+
}
|
|
277
|
+
#w({ property: e, value: t, reflect: n, attribute: i = e }) {
|
|
278
|
+
let a = this.#T(e);
|
|
279
|
+
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
|
+
}
|
|
281
|
+
#T(e) {
|
|
286
282
|
return {
|
|
287
|
-
disabled: this.#
|
|
288
|
-
expanded: this.#
|
|
289
|
-
pressed: this.#
|
|
290
|
-
readOnly: this.#
|
|
291
|
-
selected: this.#
|
|
283
|
+
disabled: this.#n,
|
|
284
|
+
expanded: this.#i,
|
|
285
|
+
pressed: this.#u,
|
|
286
|
+
readOnly: this.#d,
|
|
287
|
+
selected: this.#f
|
|
292
288
|
}[e];
|
|
293
289
|
}
|
|
294
|
-
#
|
|
295
|
-
e === "disabled" ? this.#
|
|
290
|
+
#E(e, t) {
|
|
291
|
+
e === "disabled" ? this.#n = t : e === "expanded" ? this.#i = t : e === "pressed" ? this.#u = t : e === "readOnly" ? this.#d = t : e === "selected" && (this.#f = t);
|
|
296
292
|
}
|
|
297
|
-
#
|
|
298
|
-
let o = this.#
|
|
299
|
-
o === s && (!a ||
|
|
293
|
+
#D({ property: e, value: t, attribute: i = e, reflect: a = !0 }) {
|
|
294
|
+
let o = this.#O(e), s = n(t);
|
|
295
|
+
o === s && (!a || r(this, i, s)) || (this.#k(e, s), !(a && this.#A(i, s)) && (this.#j(e, o), this.#g()));
|
|
300
296
|
}
|
|
301
|
-
#
|
|
297
|
+
#O(e) {
|
|
302
298
|
return {
|
|
303
299
|
command: this.#e,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
popovertarget: this.#m,
|
|
310
|
-
type: this.#y,
|
|
311
|
-
value: this.#b
|
|
300
|
+
current: this.#t,
|
|
301
|
+
name: this.#s,
|
|
302
|
+
popoverTargetAction: this.#l,
|
|
303
|
+
type: this.#m,
|
|
304
|
+
value: this.#h
|
|
312
305
|
}[e];
|
|
313
306
|
}
|
|
314
|
-
#
|
|
307
|
+
#k(e, t) {
|
|
315
308
|
({
|
|
316
309
|
command: () => this.#e = t ?? void 0,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
popovertarget: () => this.#m = t ?? void 0,
|
|
323
|
-
type: () => this.#y = t,
|
|
324
|
-
value: () => this.#b = t ?? void 0
|
|
310
|
+
current: () => this.#t = t,
|
|
311
|
+
name: () => this.#s = t ?? void 0,
|
|
312
|
+
popoverTargetAction: () => this.#l = t,
|
|
313
|
+
type: () => this.#m = t,
|
|
314
|
+
value: () => this.#h = t ?? void 0
|
|
325
315
|
})[e]?.();
|
|
326
316
|
}
|
|
327
|
-
#
|
|
328
|
-
return !this.isConnected && !this.#
|
|
317
|
+
#A(e, t) {
|
|
318
|
+
return !this.isConnected && !this.#o ? (this.hasAttribute(e) || this.#c.set(e, t), !0) : (a(this, e, t), !1);
|
|
329
319
|
}
|
|
330
|
-
#
|
|
320
|
+
#j(e, t) {
|
|
331
321
|
this.requestUpdate?.(e, t);
|
|
332
322
|
}
|
|
333
|
-
#
|
|
323
|
+
#M() {
|
|
334
324
|
return this.updateComplete ?? Promise.resolve();
|
|
335
325
|
}
|
|
336
|
-
#
|
|
337
|
-
this.#
|
|
326
|
+
#N() {
|
|
327
|
+
this.#c.forEach((e, t) => a(this, t, e)), this.#c.clear();
|
|
338
328
|
}
|
|
339
329
|
};
|
|
340
330
|
}
|
|
341
331
|
//#endregion
|
|
342
|
-
export {
|
|
332
|
+
export { b as ButtonFormControlMixin };
|
|
343
333
|
|
|
344
334
|
//# sourceMappingURL=button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":["#pressed","#setBooleanState","#expanded","#readOnly","#form","#requestHostUpdate","#queueBehaviorSync","#name","#setStringState","#value","#type","#disabled","#selected","#current","#popoverTargetElement","#popovertarget","#popoverTargetAction","#commandForElement","#commandfor","#command","#interestForElement","#interestfor","#hasConnected","#flushPendingAttributeReflections","#syncBehavior","#syncQueued","#handleBooleanAttributeChange","#handleStringAttributeChange","#getHostUpdateComplete","#getBooleanValue","#setBooleanValue","#reflectAttribute","#getStringValue","#setStringValue","#pendingAttributeReflections"],"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 getStringValue,\n hasAttributeValue,\n isFormElement,\n setAttributeValue\n} from '../internal/utils.js';\nimport type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.js';\nexport type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.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\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 #commandForElement: HTMLElement | null = null;\n #commandfor: string | null = null;\n #current: CurrentState | undefined;\n #disabled = false;\n #expanded: boolean | undefined;\n #form: string | HTMLFormElement | null = null;\n #hasConnected = false;\n #interestForElement: HTMLElement | null = null;\n #interestfor: string | null = null;\n #name: string | undefined;\n #pendingAttributeReflections = new Map<string, string | null>();\n #popoverTargetAction: PopoverTargetAction | undefined;\n #popoverTargetElement: HTMLElement | null = null;\n #popovertarget: string | 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 || Boolean(this._typeAnchorController?.readOnly);\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.#popoverTargetElement;\n }\n\n set popoverTargetElement(value: HTMLElement | null) {\n const oldValue = this.#popoverTargetElement;\n this.#popoverTargetElement = value;\n this.#requestHostUpdate('popoverTargetElement', oldValue);\n this.#queueBehaviorSync();\n }\n\n get popovertarget(): string {\n return this.#popovertarget as string;\n }\n\n set popovertarget(value: string | unknown) {\n this.#setStringState({ property: 'popovertarget', value });\n }\n\n get popoverTargetAction(): PopoverTargetAction {\n return this.#popoverTargetAction as PopoverTargetAction;\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.#commandForElement;\n }\n\n set commandForElement(value: HTMLElement | null) {\n const oldValue = this.#commandForElement;\n this.#commandForElement = value;\n this.#requestHostUpdate('commandForElement', oldValue);\n this.#queueBehaviorSync();\n }\n\n get commandfor(): string | null {\n return this.#commandfor;\n }\n\n set commandfor(value: string | null | unknown) {\n this.#setStringState({ property: '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.#interestForElement;\n }\n\n set interestForElement(value: HTMLElement | null) {\n const oldValue = this.#interestForElement;\n this.#interestForElement = value;\n this.#requestHostUpdate('interestForElement', oldValue);\n this.#queueBehaviorSync();\n }\n\n get interestfor(): string | null {\n return this.#interestfor;\n }\n\n set interestfor(value: string | null | unknown) {\n this.#setStringState({ property: '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.#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 === '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 }\n\n this.#setStringState({ property: name, value: newValue, reflect: false });\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 commandfor: this.#commandfor,\n current: this.#current,\n interestfor: this.#interestfor,\n name: this.#name,\n popoverTargetAction: this.#popoverTargetAction,\n popovertarget: this.#popovertarget,\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 commandfor: () => (this.#commandfor = value),\n current: () => (this.#current = value as CurrentState),\n interestfor: () => (this.#interestfor = value),\n name: () => (this.#name = value ?? undefined),\n popoverTargetAction: () => (this.#popoverTargetAction = value as PopoverTargetAction),\n popovertarget: () => (this.#popovertarget = value ?? undefined),\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":";;;;;;;;;;;;;;;AAiEA,SAAgB,EACd,GACqC;CACrC,OAAO,MAAM,UAA8B,EAAW;;0BAIX,gBACZ,gBAEjB,cAE6B,gBACzB,cAC0B,gBACZ,gCAEC,IAAI,IAA2B,aAElB,gBAGhC,cAEE,sBAID,EAAgB,IAAI,gCA0MC,IAAI,EAAqB,IAAI,gCAC7B,IAAI,EAAqB,IAAI,gCAC7B,IAAI,EAAqB,IAAI,iCAC5B,IAAI,EAAsB,IAAI,yCACtB,IAAI,EAA8B,IAAI,wCACvC,IAAI,EAA6B,IAAI,iCAC5C,IAAI,EAAsB,IAAI,mCAC5B,IAAI,EAAwB,IAAI,mCAChC,IAAI,EAAwB,IAAI,kCACjC,IAAI,EAAuB,IAAI,mCAC9B,IAAI,EAAwB,IAAI,kCACjC,IAAI,EAAuB,IAAI,mCAC9B,IAAI,EAAwB,IAAI;;;yBA9O7C;;EAExB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAIA,WAAW,qBAAqB;GAC9B,QAAQ,MAAM,sBAAsB,CAAC,EAAA,CAAG,OAAO;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;EAEA,IAAI,UAAmB;GACrB,OAAO,KAAKA;EACd;EAEA,IAAI,QAAQ,GAA0B;GACpC,KAAKC,GAAiB;IAAE,UAAU;IAAW,OAAO,EAAQ;IAAQ,SAAS;GAAK,CAAC;EACrF;EAEA,IAAI,WAAoB;GACtB,OAAO,KAAKC;EACd;EAEA,IAAI,SAAS,GAA0B;GACrC,KAAKD,GAAiB;IAAE,UAAU;IAAY,OAAO,EAAQ;IAAQ,SAAS;GAAK,CAAC;EAC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AAoB;GACpD,KAAK,gBAAgB,GAAM,CAAQ;EACrC;EAEA,KAAyB;GACvB,OAAO,KAAK,kBAAkB,QAAQ,QAAQ;EAChD;EAEA,KAAoC;GAElC,AADA,KAAKA,GAA6B,SAAS,GAAO,MAAc,EAAkB,MAAM,GAAW,CAAK,CAAC,GACzG,KAAKA,GAA6B,MAAM;EAC1C;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"button.js","names":["#pressed","#setBooleanState","#expanded","#readOnly","#form","#requestHostUpdate","#queueBehaviorSync","#name","#setStringState","#value","#type","#disabled","#selected","#current","#getElementTarget","#setElementTarget","#popoverTargetAction","#command","#hasConnected","#flushPendingAttributeReflections","#syncBehavior","#syncQueued","#handleBooleanAttributeChange","#handleElementTargetAttributeChange","#handleStringAttributeChange","#getHostUpdateComplete","#elementTargets","#getElementById","#getBooleanValue","#setBooleanValue","#reflectAttribute","#getStringValue","#setStringValue","#pendingAttributeReflections"],"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 { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.js';\nexport type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.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 || Boolean(this._typeAnchorController?.readOnly);\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":";;;;;;;;;;;;;;;AAsDA,IAAM,IAA4B;CAChC,YAAY;CACZ,aAAa;CACb,eAAe;AACjB;AAgBA,SAAgB,EACd,GACqC;CACrC,OAAO,MAAM,UAA8B,EAAW;;0BAKxC,cACyD;IACnE,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;GACxB,aAEyC,gBACzB,8BAEe,IAAI,IAA2B,aAGlD,cAEE,sBAID,EAAgB,IAAI,gCA2KC,IAAI,EAAqB,IAAI,gCAC7B,IAAI,EAAqB,IAAI,gCAC7B,IAAI,EAAqB,IAAI,iCAC5B,IAAI,EAAsB,IAAI,yCACtB,IAAI,EAA8B,IAAI,wCACvC,IAAI,EAA6B,IAAI,iCAC5C,IAAI,EAAsB,IAAI,mCAC5B,IAAI,EAAwB,IAAI,mCAChC,IAAI,EAAwB,IAAI,kCACjC,IAAI,EAAuB,IAAI,mCAC9B,IAAI,EAAwB,IAAI,kCACjC,IAAI,EAAuB,IAAI,mCAC9B,IAAI,EAAwB,IAAI;;;yBA9M7C;;EAExB;EACA;EACA;EACA;EAKA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAIA,WAAW,qBAAqB;GAC9B,QAAQ,MAAM,sB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AAM,KAAKN;IACX,qBAAqB,KAAKS;IAC1B,MAAM,KAAKN;IACX,OAAO,KAAKD;GACd,EAAE;EACJ;EAEA,GAAgB,GAAkB,GAAsB;GAStD,CAAA;IAPE,eAAgB,KAAKQ,KAAW,KAAS,KAAA;IACzC,eAAgB,KAAKJ,KAAW;IAChC,YAAa,KAAKN,KAAQ,KAAS,KAAA;IACnC,2BAA4B,KAAKS,KAAuB;IACxD,YAAa,KAAKN,KAAQ;IAC1B,aAAc,KAAKD,KAAS,KAAS,KAAA;GAEvC,EAAA,CAAQ,EAAS,GAAG;EACtB;EAEA,GAAkB,GAAmB,GAAsB;GASzD,OARI,CAAC,KAAK,eAAe,CAAC,KAAKS,MACxB,KAAK,aAAa,CAAS,KAC9B,KAAKe,GAA6B,IAAI,GAAW,CAAK,GAEjD,OAGT,EAAkB,MAAM,GAAW,CAAK,GACjC;EACT;EAEA,GAAmB,GAAe,GAAoB;GACpD,KAAK,gBAAgB,GAAM,CAAQ;EACrC;EAEA,KAAyB;GACvB,OAAO,KAAK,kBAAkB,QAAQ,QAAQ;EAChD;EAEA,KAAoC;GAElC,AADA,KAAKA,GAA6B,SAAS,GAAO,MAAc,EAAkB,MAAM,GAAW,CAAK,CAAC,GACzG,KAAKA,GAA6B,MAAM;EAC1C;CACF;AACF"}
|
|
@@ -75,15 +75,10 @@ export interface ButtonFormControlMixinInstance {
|
|
|
75
75
|
/**
|
|
76
76
|
* Establishes a relationship between a popover and its invoker button.
|
|
77
77
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/popoverTargetElement
|
|
78
|
-
*/
|
|
79
|
-
popoverTargetElement: HTMLElement | null;
|
|
80
|
-
/**
|
|
81
|
-
* The id reference of the element that receives the popover.
|
|
82
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#popovertarget
|
|
83
78
|
* @attr popovertarget
|
|
84
79
|
* @reflect
|
|
85
80
|
*/
|
|
86
|
-
|
|
81
|
+
popoverTargetElement: HTMLElement | null;
|
|
87
82
|
/**
|
|
88
83
|
* The popover target action to perform on the popover target element.
|
|
89
84
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/popoverTargetAction
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nvidia-elements/forms",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"release": {
|
|
5
5
|
"extends": "../../release.config.js"
|
|
6
6
|
},
|
|
@@ -96,11 +96,11 @@
|
|
|
96
96
|
"typescript": "6.0.3",
|
|
97
97
|
"vite": "8.1.4",
|
|
98
98
|
"vitest": "4.1.10",
|
|
99
|
-
"@nvidia-elements/styles": "2.0
|
|
99
|
+
"@nvidia-elements/styles": "2.1.0",
|
|
100
|
+
"@internals/testing": "0.0.0",
|
|
100
101
|
"@internals/eslint": "0.0.0",
|
|
101
102
|
"@internals/vite": "0.0.0",
|
|
102
|
-
"@nvidia-elements/lint": "2.
|
|
103
|
-
"@internals/testing": "0.0.0"
|
|
103
|
+
"@nvidia-elements/lint": "2.1.1"
|
|
104
104
|
},
|
|
105
105
|
"wireit": {
|
|
106
106
|
"dev": {
|