@nvidia-elements/forms 2.0.12 → 2.0.14
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 +51 -0
- package/dist/custom-elements.json +8 -39
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/controllers/state-active.controller.js +2 -2
- package/dist/internal/controllers/state-active.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/internal/types.d.ts +0 -3
- package/dist/internal/utils.d.ts +0 -2
- package/dist/internal/utils.js +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/mixins/button.d.ts +6 -0
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/index.d.ts +5 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
## [2.0.14](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.13...@nvidia-elements/forms-v2.0.14) (2026-11-16)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **core:** add dashboard ([83e5ced](https://github.com/NVIDIA/elements/commit/83e5ced893821ab74cad106473c92ecb04443949))
|
|
6
|
+
* **core:** iframe sandbox options ([849eb85](https://github.com/NVIDIA/elements/commit/849eb854b9f96692d2607f2db4aee62b7487b05f))
|
|
7
|
+
* **core:** support for grid virtual-list ([32fd01e](https://github.com/NVIDIA/elements/commit/32fd01e61b004bb07c0a54ce7cb6c747b09eaa55))
|
|
8
|
+
* **foundations:** add placement translation keys ([a3d4d53](https://github.com/NVIDIA/elements/commit/a3d4d5386df3c71e3d273c1175b140fab04efc9d))
|
|
9
|
+
* **foundations:** virtual-list ([aa4ef9e](https://github.com/NVIDIA/elements/commit/aa4ef9e20dd0ec9e4ce8a4be69c6678f11c86b12))
|
|
10
|
+
* **styles:** add text shimmer support ([c96b621](https://github.com/NVIDIA/elements/commit/c96b6215099331152632805a18d9638230cb3da6))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **core:** drop obsolete panel transition prefix ([dead5e0](https://github.com/NVIDIA/elements/commit/dead5e0cc7cb0202e83f64cd8242755e06ac91db))
|
|
15
|
+
* **core:** drop obsolete progress appearance prefixes ([2192b3c](https://github.com/NVIDIA/elements/commit/2192b3c42e09842685e90c2ce5440b2005c9f7bb))
|
|
16
|
+
* **core:** drop obsolete scoped registry polyfill ([520e03b](https://github.com/NVIDIA/elements/commit/520e03b0244592f100edcfedc45ea2871d1cecc5))
|
|
17
|
+
* **core:** improve icon registry bundling performance ([64db7b9](https://github.com/NVIDIA/elements/commit/64db7b972645a624e11dd97249c49a6b0b2d60f7))
|
|
18
|
+
* **core:** improve workspace performance ([3a580b8](https://github.com/NVIDIA/elements/commit/3a580b889927a3df365f149b19a4de07bd69bc10))
|
|
19
|
+
* **core:** refactor to use foundations internals ([6405764](https://github.com/NVIDIA/elements/commit/6405764abcd16224406fdc57a811cd745ec54971))
|
|
20
|
+
* **core:** size overlays with the dynamic viewport ([3458d95](https://github.com/NVIDIA/elements/commit/3458d9566cbf6740ced6cdf9650296e0cadfe336))
|
|
21
|
+
* **forms:** use keydown for button active state ([486875c](https://github.com/NVIDIA/elements/commit/486875c082a15f2bc7a72a091759a93cfa3f8a2b))
|
|
22
|
+
* **foundations:** add shared decorator ([fa642a4](https://github.com/NVIDIA/elements/commit/fa642a4c81c7e0ec2f00d646452bcd7d595b1e34))
|
|
23
|
+
* **lint:** add new nve-text values ([80c106e](https://github.com/NVIDIA/elements/commit/80c106e33b4d057d2f5907882b490b4a46890742))
|
|
24
|
+
* **markdown:** update to use foundations internals ([33f1490](https://github.com/NVIDIA/elements/commit/33f149046c791aad70e35b439869fd4d05efe6ed))
|
|
25
|
+
* **media:** update icon imports ([7d95c48](https://github.com/NVIDIA/elements/commit/7d95c485bfbdaa180d858fc1ecf51941342e2cdf))
|
|
26
|
+
* **media:** update to use foundations internals ([24d2296](https://github.com/NVIDIA/elements/commit/24d2296596c18955cfe8723f0e1c67ccc53cbfeb))
|
|
27
|
+
* **pi:** update typebox to 1.4.6 ([e2635d1](https://github.com/NVIDIA/elements/commit/e2635d17980a706b044d9a3d814334de489aa72a))
|
|
28
|
+
* **starters:** update [@angular](https://github.com/angular) packages to 22.2.6 ([39be6b3](https://github.com/NVIDIA/elements/commit/39be6b3fbef2498f8898210bdc58d94ba2eb42d7))
|
|
29
|
+
* **viewport:** update to use foundations internals ([a5510ec](https://github.com/NVIDIA/elements/commit/a5510ec63d0933d0d8b245c6160e0b3bf2e1f1bc))
|
|
30
|
+
|
|
31
|
+
## [2.0.13](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.12...@nvidia-elements/forms-v2.0.13) (2026-11-07)
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **core:** add configurable tabs indicator animation duration ([0cc3093](https://github.com/NVIDIA/elements/commit/0cc3093056d6a6e24d9e8876fb444d3ccc0ba3b6))
|
|
36
|
+
* **core:** add ghost and workspace ([c2bdec9](https://github.com/NVIDIA/elements/commit/c2bdec9701628add8dc364786023a6019660aee3))
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* **cli:** drop unused utilities ([71dcf96](https://github.com/NVIDIA/elements/commit/71dcf96ff531cd4ef69db6e55f08fbeecb005015))
|
|
41
|
+
* **core:** drop obsolete checkbox clip-path fallback ([8cddf24](https://github.com/NVIDIA/elements/commit/8cddf24eab9f15f444ddc25152277ebd864116bd))
|
|
42
|
+
* **core:** drop obsolete constructed stylesheet polyfill ([30b0684](https://github.com/NVIDIA/elements/commit/30b068411d1bd067e60935eb8ab60d8b6ad85268))
|
|
43
|
+
* **core:** drop obsolete element internals polyfill ([bb0649c](https://github.com/NVIDIA/elements/commit/bb0649ced505ef4cfc0f050302046794a935441a))
|
|
44
|
+
* **core:** drop obsolete formdata polyfill ([7831582](https://github.com/NVIDIA/elements/commit/78315824a2a9bfb81a615986a181d695b5bf6acc))
|
|
45
|
+
* **core:** drop obsolete logo color-mix fallback ([93ea57f](https://github.com/NVIDIA/elements/commit/93ea57f6ed300fce24952f5b44a4f5dc5b7b87b1))
|
|
46
|
+
* **core:** drop unused utilities ([9e4b1bc](https://github.com/NVIDIA/elements/commit/9e4b1bc6b942de163d33ed71ae676041dd8fb4e6))
|
|
47
|
+
* **core:** re-render bugfixes ([48e5ac4](https://github.com/NVIDIA/elements/commit/48e5ac4e5c66e0c9659e47095698fe33bfc68629))
|
|
48
|
+
* **docs:** update 3d-force-graph to 1.80.2 ([86a69e9](https://github.com/NVIDIA/elements/commit/86a69e92a607dc254ca7df2e3e4428ae0d6126e5))
|
|
49
|
+
* **forms:** drop unused utilities ([c538a47](https://github.com/NVIDIA/elements/commit/c538a47e79366919f43fb8f35950c52159f40d6c))
|
|
50
|
+
* **themes:** correct rounding issue ([3c22eef](https://github.com/NVIDIA/elements/commit/3c22eef05362992c8a50ebc82664e6d0a76a4692))
|
|
51
|
+
|
|
1
52
|
## [2.0.12](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.11...@nvidia-elements/forms-v2.0.12) (2026-11-03)
|
|
2
53
|
|
|
3
54
|
### Features
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"type": {
|
|
13
13
|
"text": "string"
|
|
14
14
|
},
|
|
15
|
-
"default": "'0.0.0'"
|
|
15
|
+
"default": "'0.0.0'",
|
|
16
|
+
"privacy": "public"
|
|
16
17
|
}
|
|
17
18
|
],
|
|
18
19
|
"exports": [
|
|
@@ -1241,33 +1242,6 @@
|
|
|
1241
1242
|
}
|
|
1242
1243
|
]
|
|
1243
1244
|
},
|
|
1244
|
-
{
|
|
1245
|
-
"kind": "function",
|
|
1246
|
-
"name": "onKeys",
|
|
1247
|
-
"parameters": [
|
|
1248
|
-
{
|
|
1249
|
-
"name": "events",
|
|
1250
|
-
"type": {
|
|
1251
|
-
"text": "string[]",
|
|
1252
|
-
"_sourceAliases": []
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
{
|
|
1256
|
-
"name": "event",
|
|
1257
|
-
"type": {
|
|
1258
|
-
"text": "KeyboardEvent",
|
|
1259
|
-
"_sourceAliases": []
|
|
1260
|
-
}
|
|
1261
|
-
},
|
|
1262
|
-
{
|
|
1263
|
-
"name": "callback",
|
|
1264
|
-
"type": {
|
|
1265
|
-
"text": "() => void",
|
|
1266
|
-
"_sourceAliases": []
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
]
|
|
1270
|
-
},
|
|
1271
1245
|
{
|
|
1272
1246
|
"kind": "function",
|
|
1273
1247
|
"name": "removeEmptyTextNode",
|
|
@@ -1387,14 +1361,6 @@
|
|
|
1387
1361
|
"module": "/src/internal/utils.js"
|
|
1388
1362
|
}
|
|
1389
1363
|
},
|
|
1390
|
-
{
|
|
1391
|
-
"kind": "js",
|
|
1392
|
-
"name": "onKeys",
|
|
1393
|
-
"declaration": {
|
|
1394
|
-
"name": "onKeys",
|
|
1395
|
-
"module": "/src/internal/utils.js"
|
|
1396
|
-
}
|
|
1397
|
-
},
|
|
1398
1364
|
{
|
|
1399
1365
|
"kind": "js",
|
|
1400
1366
|
"name": "removeEmptyTextNode",
|
|
@@ -1441,7 +1407,8 @@
|
|
|
1441
1407
|
"_sourceAliases": []
|
|
1442
1408
|
}
|
|
1443
1409
|
}
|
|
1444
|
-
]
|
|
1410
|
+
],
|
|
1411
|
+
"privacy": "public"
|
|
1445
1412
|
}
|
|
1446
1413
|
],
|
|
1447
1414
|
"exports": [
|
|
@@ -1698,7 +1665,8 @@
|
|
|
1698
1665
|
}
|
|
1699
1666
|
}
|
|
1700
1667
|
],
|
|
1701
|
-
"description": "Given a json schema, check the value against the schema\nJSON Schema follows the OpenAI JSON Schema for structured outputs\nhttps://platform.openai.com/docs/guides/structured-outputs\n\n- All fields or function parameters must specify required\n- Require additionalProperties: false on all objects\n- Structured Outputs support the following types:\n - String\n - Number\n - Boolean\n - Object\n - Array\n - Enum"
|
|
1668
|
+
"description": "Given a json schema, check the value against the schema\nJSON Schema follows the OpenAI JSON Schema for structured outputs\nhttps://platform.openai.com/docs/guides/structured-outputs\n\n- All fields or function parameters must specify required\n- Require additionalProperties: false on all objects\n- Structured Outputs support the following types:\n - String\n - Number\n - Boolean\n - Object\n - Array\n - Enum",
|
|
1669
|
+
"privacy": "public"
|
|
1702
1670
|
},
|
|
1703
1671
|
{
|
|
1704
1672
|
"kind": "function",
|
|
@@ -1723,7 +1691,8 @@
|
|
|
1723
1691
|
"_sourceAliases": []
|
|
1724
1692
|
}
|
|
1725
1693
|
}
|
|
1726
|
-
]
|
|
1694
|
+
],
|
|
1695
|
+
"privacy": "public"
|
|
1727
1696
|
}
|
|
1728
1697
|
],
|
|
1729
1698
|
"exports": [
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["VERSION"],"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport const VERSION = '0.0.0';\n\nexport * from './internal/types.js';\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","names":["VERSION"],"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/** @public */\nexport const VERSION = '0.0.0';\n\n/** @public */\nexport * from './internal/types.js';\n"],"mappings":";AAIA,IAAaA,IAAU"}
|
|
@@ -5,10 +5,10 @@ var t = class {
|
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
6
6
|
}
|
|
7
7
|
hostConnected() {
|
|
8
|
-
e(this.host), this.host.addEventListener("
|
|
8
|
+
e(this.host), this.host.addEventListener("keydown", this.#e), this.host.addEventListener("mousedown", this.#e), this.host.addEventListener("keyup", this.#t), this.host.addEventListener("blur", this.#t), this.host.addEventListener("mouseup", this.#t);
|
|
9
9
|
}
|
|
10
10
|
hostDisconnected() {
|
|
11
|
-
this.host.removeEventListener("
|
|
11
|
+
this.host.removeEventListener("keydown", this.#e), this.host.removeEventListener("mousedown", this.#e), this.host.removeEventListener("keyup", this.#t), this.host.removeEventListener("blur", this.#t), this.host.removeEventListener("mouseup", this.#t);
|
|
12
12
|
}
|
|
13
13
|
#e = (e) => {
|
|
14
14
|
!this.host.disabled && this.#n(e) && this.host._internals.states.add("active"), e instanceof KeyboardEvent && e.code === "Space" && e.target === this.host && e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-active.controller.js","names":["StateActiveController","host","attachInternals","#onActive","#onInactive","#isValidActiveEvent","event"],"sources":["../../../src/internal/controllers/state-active.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Active = ReactiveElement & { disabled: boolean; _internals?: ElementInternals };\n\nexport class StateActiveController<T extends Active> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n this.host.addEventListener('
|
|
1
|
+
{"version":3,"file":"state-active.controller.js","names":["StateActiveController","host","attachInternals","#onActive","#onInactive","#isValidActiveEvent","event"],"sources":["../../../src/internal/controllers/state-active.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Active = ReactiveElement & { disabled: boolean; _internals?: ElementInternals };\n\nexport class StateActiveController<T extends Active> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n this.host.addEventListener('keydown', this.#onActive as EventListener);\n this.host.addEventListener('mousedown', this.#onActive as EventListener);\n this.host.addEventListener('keyup', this.#onInactive);\n this.host.addEventListener('blur', this.#onInactive);\n this.host.addEventListener('mouseup', this.#onInactive);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('keydown', this.#onActive as EventListener);\n this.host.removeEventListener('mousedown', this.#onActive as EventListener);\n this.host.removeEventListener('keyup', this.#onInactive);\n this.host.removeEventListener('blur', this.#onInactive);\n this.host.removeEventListener('mouseup', this.#onInactive);\n }\n\n #onActive = (event: KeyboardEvent | PointerEvent) => {\n if (!this.host.disabled && this.#isValidActiveEvent(event)) {\n this.host._internals!.states.add('active');\n }\n\n if (event instanceof KeyboardEvent && event.code === 'Space' && event.target === this.host) {\n event.preventDefault();\n }\n };\n\n #onInactive = () => {\n this.host._internals!.states.delete('active');\n };\n\n #isValidActiveEvent(event: KeyboardEvent | PointerEvent) {\n return event instanceof KeyboardEvent ? event.code === 'Space' || event.code === 'Enter' : true;\n }\n}\n"],"mappings":";;AAQA,IAAaA,IAAb,MAAmF;CACjF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAMd,AALAC,EAAgB,KAAK,IAAI,GACzB,KAAK,KAAK,iBAAiB,WAAW,KAAKC,EAA0B,GACrE,KAAK,KAAK,iBAAiB,aAAa,KAAKA,EAA0B,GACvE,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAW,GACpD,KAAK,KAAK,iBAAiB,QAAQ,KAAKA,EAAW,GACnD,KAAK,KAAK,iBAAiB,WAAW,KAAKA,EAAW;CACxD;CAEA,mBAAmB;EAKjB,AAJA,KAAK,KAAK,oBAAoB,WAAW,KAAKD,EAA0B,GACxE,KAAK,KAAK,oBAAoB,aAAa,KAAKA,EAA0B,GAC1E,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAW,GACvD,KAAK,KAAK,oBAAoB,QAAQ,KAAKA,EAAW,GACtD,KAAK,KAAK,oBAAoB,WAAW,KAAKA,EAAW;CAC3D;CAEA,MAAa,MAAwC;EAKnD,AAJI,CAAC,KAAK,KAAK,YAAY,KAAKC,GAAoBC,CAAK,KACvD,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,GAGvCA,aAAiB,iBAAiBA,EAAM,SAAS,WAAWA,EAAM,WAAW,KAAK,QACpFA,EAAM,eAAe;CAEzB;CAEA,WAAoB;EAClB,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ;CAC9C;CAEA,GAAoB,GAAqC;EACvD,OAAOA,aAAiB,gBAAgBA,EAAM,SAAS,WAAWA,EAAM,SAAS,UAAU;CAC7F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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);\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,CAAoB,IAGpC,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"}
|
package/dist/internal/types.d.ts
CHANGED
package/dist/internal/utils.d.ts
CHANGED
|
@@ -5,14 +5,12 @@ export declare function attachInternals(element: HTMLElement & {
|
|
|
5
5
|
export declare function toggleState(internals: ElementInternals, state: string, force: boolean): void;
|
|
6
6
|
export type PopoverAnchorElement = HTMLElement & {
|
|
7
7
|
anchor?: HTMLElement | string;
|
|
8
|
-
_activeTrigger?: HTMLElement;
|
|
9
8
|
};
|
|
10
9
|
export declare function getFlattenedDOMTree(node: Node, depth?: number): HTMLElement[];
|
|
11
10
|
export declare function getHostAnchor(host: PopoverAnchorElement): HTMLElement;
|
|
12
11
|
export declare function getStringValue(value: unknown): string | null;
|
|
13
12
|
export declare function hasAttributeValue(element: HTMLElement, attribute: string, value: string | null): boolean;
|
|
14
13
|
export declare function isFormElement(value: unknown): value is HTMLFormElement;
|
|
15
|
-
export declare function onKeys(events: string[], event: KeyboardEvent, callback: () => void): void;
|
|
16
14
|
export declare function removeEmptyTextNode(node: Node): void;
|
|
17
15
|
export declare function setAttributeValue(element: HTMLElement, attribute: string, value: string | null): void;
|
|
18
16
|
export declare function stopEvent(event: Event): void;
|
package/dist/internal/utils.js
CHANGED
|
@@ -14,7 +14,7 @@ function r(e, t = 10) {
|
|
|
14
14
|
return Array.from(d(e)).reduce((e, n) => [...e, [n, [...Array.from(d(n)).map((e) => [e, r(e, t)])]]], []).flat(t);
|
|
15
15
|
}
|
|
16
16
|
function i(e) {
|
|
17
|
-
let t = e.anchor
|
|
17
|
+
let t = e.anchor;
|
|
18
18
|
return typeof t == "string" && t.length ? e.parentNode ? r(e.parentNode).find((e) => e.id === t) ?? globalThis.document.body : globalThis.document.body : t instanceof HTMLElement && t !== globalThis.document.body ? t : globalThis.document.body;
|
|
19
19
|
}
|
|
20
20
|
function a(e) {
|
|
@@ -1 +1 @@
|
|
|
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()
|
|
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();\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 };\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;\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 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,g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B,GAAmB,GAAsB;CAC/F,AAAIL,MAAU,OACZf,EAAQ,gBAAgBiB,CAAS,IAEjCjB,EAAQ,aAAaiB,GAAWF,CAAK;AAEzC;AAEA,SAAgBM,EAAU,GAAc;CAEtC,AADAC,EAAM,eAAe,GACrBA,EAAM,gBAAgB;AACxB;AAEA,SAAShB,EAAY,GAAuB;CAC1C,IAAIiB,EAAehB,CAAI,GACrB,OAAO,MAAM,KAAKA,EAAK,gBAAgB,QAAQ;CAGjD,IAAIiB,EAAwBjB,CAAI,GAC9B,OAAO,MAAM,KAAKA,EAAK,WAAW,QAAQ;CAG5C,IAAIkB,EAAclB,CAAI,GAAG;EACvB,IAAMmB,IAAUnB,EAAK,iBAAiB;EACtC,OAAOmB,EAAQ,SAASA,IAAU,MAAM,KAAKnB,EAAK,QAAQ;CAC5D;CAEA,OAAO,MAAM,KAAMA,EAAqB,YAAY,CAAC,CAAC;AACxD;AAEA,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.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ButtonFormControlMixinInstance } from '../internal/types/button.js';
|
|
2
|
+
/** @public */
|
|
2
3
|
export type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from '../internal/types/button.js';
|
|
3
4
|
interface ButtonFormControlHost {
|
|
4
5
|
connectedCallback?(): void;
|
|
@@ -11,6 +12,9 @@ type Constructor = (new (...args: any[]) => HTMLElement & ButtonFormControlHost)
|
|
|
11
12
|
observedAttributes?: string[];
|
|
12
13
|
};
|
|
13
14
|
type ButtonFormControlConstructor<TBase extends Constructor> = new (...args: ConstructorParameters<TBase>) => InstanceType<TBase> & ButtonFormControlMixinInstance;
|
|
15
|
+
/** @public
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
14
18
|
export type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonFormControlConstructor<TBase> & {
|
|
15
19
|
formAssociated: boolean;
|
|
16
20
|
observedAttributes: string[];
|
|
@@ -18,5 +22,7 @@ export type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonForm
|
|
|
18
22
|
/**
|
|
19
23
|
* @description A mixin that adds native button-style form, command, popover, and interaction behavior.
|
|
20
24
|
* @aria https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
25
|
+
* @public
|
|
21
26
|
*/
|
|
27
|
+
/** @public */
|
|
22
28
|
export declare function ButtonFormControlMixin<TBase extends Constructor>(SuperClass: TBase): ButtonFormControlMixinReturn<TBase>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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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;IACL,SAAS,KAAKY;IACd,SAAS,KAAKJ;IACd,MAAM,KAAKL;IACX,qBAAqB,KAAKQ;IAC1B,MAAM,KAAKL;IACX,OAAO,KAAKD;GACd,EAAEkB;EACJ;EAEA,GAAgB,GAAkB,GAAsB;GAStD,CAAA;IAPE,eAAgB,KAAKX,KAAWjB,KAAS,KAAA;IACzC,eAAgB,KAAKa,KAAWb;IAChC,YAAa,KAAKQ,KAAQR,KAAS,KAAA;IACnC,2BAA4B,KAAKgB,KAAuBhB;IACxD,YAAa,KAAKW,KAAQX;IAC1B,aAAc,KAAKU,KAASV,KAAS,KAAA;GAEvC,EAAA,CAAQ4B,EAAS,GAAG;EACtB;EAEA,GAAkB,GAAmB,GAAsB;GASzD,OARI,CAAC,KAAK,eAAe,CAAC,KAAKhD,MACxB,KAAK,aAAamD,CAAS,KAC9B,KAAKlD,GAA6B,IAAIkD,GAAW/B,CAAK,GAEjD,OAGToC,EAAkB,MAAML,GAAW/B,CAAK,GACjC;EACT;EAEA,GAAmB,GAAe,GAAoB;GACpD,KAAK,gBAAgBsB,GAAMpB,CAAQ;EACrC;EAEA,KAAyB;GACvB,OAAO,KAAK,kBAAkB,QAAQ,QAAQ;EAChD;EAEA,KAAoC;GAElC,AADA,KAAKrB,GAA6B,SAAS,GAAO,MAAcuD,EAAkB,MAAML,GAAW/B,CAAK,CAAC,GACzG,KAAKnB,GAA6B,MAAM;EAC1C;CACF;AACF"}
|
|
1
|
+
{"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';\n/** @public */\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;\n/** @public\n * @public\n */\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 * @public\n */\n/** @public */\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":";;;;;;;;;;;;;;;AAiEA,IAAMA,IAA4B;CAChC,YAAY;CACZ,aAAa;CACb,eAAe;AACjB;AAqBA,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,IAAIC,EAAsB,IAAI,GAC5B,KAAA,2BAAA,IAAIC,EAAwB,IAAI,GAChC,KAAA,2BAAA,IAAIC,EAAwB,IAAI,GACjC,KAAA,0BAAA,IAAIC,EAAuB,IAAI,GAC9B,KAAA,2BAAA,IAAIC,EAAwB,IAAI,GACjC,KAAA,0BAAA,IAAIC,EAAuB,IAAI,GAC9B,KAAA,2BAAA,IAAIC,EAAwB,IAAI;;;GA9M7C,KAAA,iBAAA;;EAExB;E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ist/mixins/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ import type { FormControlInstance, ValidatorResult } from '../internal/types.js'
|
|
|
13
13
|
* - Object
|
|
14
14
|
* - Array
|
|
15
15
|
* - Enum
|
|
16
|
+
* @public
|
|
16
17
|
*/
|
|
17
18
|
export declare function valueSchemaValidator(value: unknown, element: FormControlInstance): ValidatorResult;
|
|
19
|
+
/** @public */
|
|
18
20
|
export declare function requiredValidator(value: unknown, element: FormControlInstance): ValidatorResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["valueSchemaValidator","metadata","element","validateSchema","value","requiredValidator"],"sources":["../../src/validators/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { validateSchema } from '../internal/schema.js';\nimport type { FormControl, FormControlInstance, ValidatorResult } from '../internal/types.js';\n\n/**\n * Given a json schema, check the value against the schema\n * JSON Schema follows the OpenAI JSON Schema for structured outputs\n * https://platform.openai.com/docs/guides/structured-outputs\n *\n * - All fields or function parameters must specify required\n * - Require additionalProperties: false on all objects\n * - Structured Outputs support the following types:\n * - String\n * - Number\n * - Boolean\n * - Object\n * - Array\n * - Enum\n */\nexport function valueSchemaValidator(value: unknown, element: FormControlInstance): ValidatorResult {\n const metadata = (element.constructor as FormControl).metadata;\n return validateSchema(metadata.valueSchema, value);\n}\n\nexport function requiredValidator(value: unknown, element: FormControlInstance): ValidatorResult {\n if (element.required && (value === undefined || value === null || value === '')) {\n return { validity: { valueMissing: true, valid: false }, message: 'This field is required' };\n }\n return { validity: { valid: true }, message: '' };\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","names":["valueSchemaValidator","metadata","element","validateSchema","value","requiredValidator"],"sources":["../../src/validators/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { validateSchema } from '../internal/schema.js';\nimport type { FormControl, FormControlInstance, ValidatorResult } from '../internal/types.js';\n\n/**\n * Given a json schema, check the value against the schema\n * JSON Schema follows the OpenAI JSON Schema for structured outputs\n * https://platform.openai.com/docs/guides/structured-outputs\n *\n * - All fields or function parameters must specify required\n * - Require additionalProperties: false on all objects\n * - Structured Outputs support the following types:\n * - String\n * - Number\n * - Boolean\n * - Object\n * - Array\n * - Enum\n * @public\n */\nexport function valueSchemaValidator(value: unknown, element: FormControlInstance): ValidatorResult {\n const metadata = (element.constructor as FormControl).metadata;\n return validateSchema(metadata.valueSchema, value);\n}\n\n/** @public */\nexport function requiredValidator(value: unknown, element: FormControlInstance): ValidatorResult {\n if (element.required && (value === undefined || value === null || value === '')) {\n return { validity: { valueMissing: true, valid: false }, message: 'This field is required' };\n }\n return { validity: { valid: true }, message: '' };\n}\n"],"mappings":";;AAsBA,SAAgBA,EAAqB,GAAgB,GAA+C;CAClG,IAAMC,IAAYC,EAAQ,YAA4B;CACtD,OAAOC,EAAeF,EAAS,aAAaG,CAAK;AACnD;AAGA,SAAgBC,EAAkB,GAAgB,GAA+C;CAI/F,OAHIH,EAAQ,aAAaE,KAAiC,QAAQA,MAAU,MACnE;EAAE,UAAU;GAAE,cAAc;GAAM,OAAO;EAAM;EAAG,SAAS;CAAyB,IAEtF;EAAE,UAAU,EAAE,OAAO,GAAK;EAAG,SAAS;CAAG;AAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nvidia-elements/forms",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"release": {
|
|
5
5
|
"extends": "../../release.config.js"
|
|
6
6
|
},
|
|
@@ -85,22 +85,22 @@
|
|
|
85
85
|
"sideEffects": [],
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@eslint/js": "10.0.1",
|
|
88
|
-
"@nvidia-elements/styles": "2.
|
|
88
|
+
"@nvidia-elements/styles": "2.2.0",
|
|
89
89
|
"@internals/testing": "0.0.0",
|
|
90
90
|
"@internals/eslint": "0.0.0",
|
|
91
91
|
"@internals/vite": "0.0.0",
|
|
92
|
-
"@nvidia-elements/lint": "2.9.
|
|
92
|
+
"@nvidia-elements/lint": "2.9.2",
|
|
93
93
|
"@typescript/lib-dom": "npm:@types/web@0.0.312",
|
|
94
|
-
"@vitest/browser": "5.0
|
|
95
|
-
"@vitest/coverage-istanbul": "5.0
|
|
94
|
+
"@vitest/browser": "5.1.0",
|
|
95
|
+
"@vitest/coverage-istanbul": "5.1.0",
|
|
96
96
|
"axe-core": "4.14.0",
|
|
97
|
-
"eslint": "10.
|
|
97
|
+
"eslint": "10.14.0",
|
|
98
98
|
"lit": "3.3.3",
|
|
99
99
|
"publint": "0.3.25",
|
|
100
100
|
"typescript": "6.0.3",
|
|
101
101
|
"typescript-7": "npm:typescript@7.0.2",
|
|
102
102
|
"vite": "8.3.5",
|
|
103
|
-
"vitest": "5.0
|
|
103
|
+
"vitest": "5.1.0"
|
|
104
104
|
},
|
|
105
105
|
"wireit": {
|
|
106
106
|
"dev": {
|