@nvidia-elements/forms 2.0.0 → 2.0.1

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 CHANGED
@@ -1,3 +1,35 @@
1
+ ## <small>2.0.1 (2026-06-13)</small>
2
+
3
+ * feat(cli): improve installer script ([0379d0e](https://github.com/NVIDIA/elements/commit/0379d0e))
4
+ * chore(core): remove unused controllers ([59d8349](https://github.com/NVIDIA/elements/commit/59d8349))
5
+ * chore(media): update peer dependency version ([082a5f2](https://github.com/NVIDIA/elements/commit/082a5f2))
6
+ * chore(release): @nvidia-elements/cli-v2.0.0 [skip ci] ([7b84169](https://github.com/NVIDIA/elements/commit/7b84169))
7
+ * chore(release): @nvidia-elements/cli-v2.0.1 [skip ci] ([b3f6d3b](https://github.com/NVIDIA/elements/commit/b3f6d3b))
8
+ * chore(release): @nvidia-elements/code-v2.0.0 [skip ci] ([beb620d](https://github.com/NVIDIA/elements/commit/beb620d))
9
+ * chore(release): @nvidia-elements/code-v2.0.1 [skip ci] ([005d158](https://github.com/NVIDIA/elements/commit/005d158))
10
+ * chore(release): @nvidia-elements/core-v2.0.0 [skip ci] ([1ab0f53](https://github.com/NVIDIA/elements/commit/1ab0f53))
11
+ * chore(release): @nvidia-elements/core-v2.0.1 [skip ci] ([63a9663](https://github.com/NVIDIA/elements/commit/63a9663))
12
+ * chore(release): @nvidia-elements/lint-v2.0.0 [skip ci] ([fc17e13](https://github.com/NVIDIA/elements/commit/fc17e13))
13
+ * chore(release): @nvidia-elements/lint-v2.0.1 [skip ci] ([fcf4355](https://github.com/NVIDIA/elements/commit/fcf4355))
14
+ * chore(release): @nvidia-elements/markdown-v2.0.0 [skip ci] ([686ff96](https://github.com/NVIDIA/elements/commit/686ff96))
15
+ * chore(release): @nvidia-elements/markdown-v2.0.1 [skip ci] ([931f033](https://github.com/NVIDIA/elements/commit/931f033))
16
+ * chore(release): @nvidia-elements/monaco-v2.0.0 [skip ci] ([50df8a0](https://github.com/NVIDIA/elements/commit/50df8a0))
17
+ * chore(release): @nvidia-elements/monaco-v2.0.1 [skip ci] ([fb21243](https://github.com/NVIDIA/elements/commit/fb21243))
18
+ * chore(release): @nvidia-elements/styles-v2.0.0 [skip ci] ([f44d145](https://github.com/NVIDIA/elements/commit/f44d145))
19
+ * chore(release): @nvidia-elements/styles-v2.0.1 [skip ci] ([d04d043](https://github.com/NVIDIA/elements/commit/d04d043))
20
+ * chore(release): @nvidia-elements/styles-v2.0.2 [skip ci] ([98a4325](https://github.com/NVIDIA/elements/commit/98a4325))
21
+ * chore(themes): add additional tests for css variable completions ([cbf14f8](https://github.com/NVIDIA/elements/commit/cbf14f8))
22
+ * fix(cli): handle pnpm build approvals ([ef8dc26](https://github.com/NVIDIA/elements/commit/ef8dc26))
23
+ * fix(code): update peer dependency version ([67fa50a](https://github.com/NVIDIA/elements/commit/67fa50a))
24
+ * fix(core): select multiple pointer event ([8412f62](https://github.com/NVIDIA/elements/commit/8412f62))
25
+ * fix(core): update peer dependency version ([93ca66e](https://github.com/NVIDIA/elements/commit/93ca66e))
26
+ * fix(forms): improve aria attribute management ([daab45f](https://github.com/NVIDIA/elements/commit/daab45f))
27
+ * fix(lint): update peer dependency version ([582d326](https://github.com/NVIDIA/elements/commit/582d326))
28
+ * fix(markdown): update peer dependency version ([fe76f18](https://github.com/NVIDIA/elements/commit/fe76f18))
29
+ * fix(monaco): update peer dependency version ([bc41db8](https://github.com/NVIDIA/elements/commit/bc41db8))
30
+ * fix(styles): update peer dependency version ([44ef1da](https://github.com/NVIDIA/elements/commit/44ef1da))
31
+ * fix(styles): use logical direction styles ([2edd48c](https://github.com/NVIDIA/elements/commit/2edd48c))
32
+
1
33
  ## 2.0.0 (2026-06-08)
2
34
 
3
35
  * chore(ci): release scope fix ([102f9a3](https://github.com/NVIDIA/elements/commit/102f9a3))
@@ -598,12 +598,48 @@
598
598
  },
599
599
  {
600
600
  "kind": "javascript-module",
601
- "path": "/src/internal/controllers/type-native-button.controller.js",
601
+ "path": "/src/internal/controllers/type-popover-trigger.controller.js",
602
+ "declarations": [
603
+ {
604
+ "kind": "class",
605
+ "description": "",
606
+ "name": "TypePopoverTriggerController",
607
+ "members": [
608
+ {
609
+ "kind": "method",
610
+ "name": "hostConnected"
611
+ },
612
+ {
613
+ "kind": "method",
614
+ "name": "hostDisconnected"
615
+ },
616
+ {
617
+ "kind": "field",
618
+ "name": "#onClick",
619
+ "privacy": "private"
620
+ }
621
+ ]
622
+ }
623
+ ],
624
+ "exports": [
625
+ {
626
+ "kind": "js",
627
+ "name": "TypePopoverTriggerController",
628
+ "declaration": {
629
+ "name": "TypePopoverTriggerController",
630
+ "module": "/src/internal/controllers/type-popover-trigger.controller.js"
631
+ }
632
+ }
633
+ ]
634
+ },
635
+ {
636
+ "kind": "javascript-module",
637
+ "path": "/src/internal/controllers/type-submit.controller.js",
602
638
  "declarations": [
603
639
  {
604
640
  "kind": "class",
605
641
  "description": "",
606
- "name": "TypeNativeButtonController",
642
+ "name": "TypeSubmitController",
607
643
  "members": [
608
644
  {
609
645
  "kind": "field",
@@ -670,17 +706,17 @@
670
706
  },
671
707
  {
672
708
  "kind": "method",
673
- "name": "#removeNativeButtonBehavior",
709
+ "name": "#removeSubmitBehavior",
674
710
  "privacy": "private"
675
711
  },
676
712
  {
677
713
  "kind": "field",
678
- "name": "#onNativeButtonKeyup",
714
+ "name": "#onSubmitKeyup",
679
715
  "privacy": "private"
680
716
  },
681
717
  {
682
718
  "kind": "field",
683
- "name": "#onNativeButtonClick",
719
+ "name": "#onSubmitClick",
684
720
  "privacy": "private"
685
721
  },
686
722
  {
@@ -717,46 +753,10 @@
717
753
  "exports": [
718
754
  {
719
755
  "kind": "js",
720
- "name": "TypeNativeButtonController",
756
+ "name": "TypeSubmitController",
721
757
  "declaration": {
722
- "name": "TypeNativeButtonController",
723
- "module": "/src/internal/controllers/type-native-button.controller.js"
724
- }
725
- }
726
- ]
727
- },
728
- {
729
- "kind": "javascript-module",
730
- "path": "/src/internal/controllers/type-popover-trigger.controller.js",
731
- "declarations": [
732
- {
733
- "kind": "class",
734
- "description": "",
735
- "name": "TypePopoverTriggerController",
736
- "members": [
737
- {
738
- "kind": "method",
739
- "name": "hostConnected"
740
- },
741
- {
742
- "kind": "method",
743
- "name": "hostDisconnected"
744
- },
745
- {
746
- "kind": "field",
747
- "name": "#onClick",
748
- "privacy": "private"
749
- }
750
- ]
751
- }
752
- ],
753
- "exports": [
754
- {
755
- "kind": "js",
756
- "name": "TypePopoverTriggerController",
757
- "declaration": {
758
- "name": "TypePopoverTriggerController",
759
- "module": "/src/internal/controllers/type-popover-trigger.controller.js"
758
+ "name": "TypeSubmitController",
759
+ "module": "/src/internal/controllers/type-submit.controller.js"
760
760
  }
761
761
  }
762
762
  ]
@@ -1543,7 +1543,7 @@
1543
1543
  {
1544
1544
  "name": "element",
1545
1545
  "type": {
1546
- "text": "FormControl",
1546
+ "text": "FormControlInstance",
1547
1547
  "_sourceAliases": []
1548
1548
  }
1549
1549
  }
@@ -1569,7 +1569,7 @@
1569
1569
  {
1570
1570
  "name": "element",
1571
1571
  "type": {
1572
- "text": "FormControl",
1572
+ "text": "FormControlInstance",
1573
1573
  "_sourceAliases": []
1574
1574
  }
1575
1575
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/index.ts
2
- var e = "2.0.0";
2
+ var e = "2.0.1";
3
3
  //#endregion
4
4
  export { e as VERSION };
5
5
 
@@ -10,19 +10,19 @@ var n = class {
10
10
  }
11
11
  hostUpdated() {
12
12
  if (this.host.readOnly) {
13
- this.#t();
13
+ this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !1), this.#t();
14
14
  return;
15
15
  }
16
16
  if (this.host._internals?.states.has("anchor")) {
17
17
  this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !!this.host.current), this.#t();
18
18
  return;
19
19
  }
20
- this.host.current !== null && this.host.current !== void 0 && (this.host._internals.ariaCurrent = `${this.host.current}`), t(this.host._internals, "current", !!this.host.current);
20
+ this.host._internals.ariaCurrent = this.host.current === null || this.host.current === void 0 ? null : `${this.host.current}`, t(this.host._internals, "current", !!this.host.current);
21
21
  }
22
22
  #t() {
23
23
  let e = this.host.querySelector("a"), t = !this.host.readOnly && this.host._internals.states.has("anchor") && !!(this.host.selected || this.host.current);
24
24
  if (e && t) {
25
- this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", "page"), this.#e = e;
25
+ this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e;
26
26
  return;
27
27
  }
28
28
  this.#e?.removeAttribute("aria-current"), this.#e = null;
@@ -1 +1 @@
1
- {"version":3,"file":"state-current.controller.js","names":["#syncAnchorCurrentAttribute","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-current.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Current = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateCurrentController<T extends Current> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host.current !== null && this.host.current !== undefined) {\n this.host._internals!.ariaCurrent = `${this.host.current}`;\n }\n\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAqF;CACnF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GACtB,KAAKA,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ,GACxE,KAAKA,GAA4B;GACjC;EACF;EAMA,AAJI,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,MACtD,KAAK,KAAK,WAAY,cAAc,GAAG,KAAK,KAAK,YAGnD,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAKC,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,MAAM,GAC1C,KAAKA,KAAuB;GAC5B;EACF;EAGA,AADA,KAAKA,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
1
+ {"version":3,"file":"state-current.controller.js","names":["#syncAnchorCurrentAttribute","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-current.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Current = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateCurrentController<T extends Current> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaCurrent =\n this.host.current === null || this.host.current === undefined ? null : `${this.host.current}`;\n\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAqF;CACnF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAGtB,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAK,GACnD,KAAKA,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ,GACxE,KAAKA,GAA4B;GACjC;EACF;EAKA,AAHA,KAAK,KAAK,WAAY,cACpB,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,WAEtF,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAKC,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAKA,KAAuB;GAC5B;EACF;EAGA,AADA,KAAKA,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
@@ -8,7 +8,7 @@ var n = class {
8
8
  e(this.host);
9
9
  }
10
10
  hostUpdated() {
11
- this.host.expanded !== null && this.host.expanded !== void 0 && (this.host._internals.ariaExpanded = `${this.host.expanded}`), t(this.host._internals, "expanded", !!this.host.expanded);
11
+ this.host._internals.ariaExpanded = this.host.expanded === null || this.host.expanded === void 0 ? null : `${this.host.expanded}`, t(this.host._internals, "expanded", !!this.host.expanded);
12
12
  }
13
13
  };
14
14
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"state-expanded.controller.js","names":[],"sources":["../../../src/internal/controllers/state-expanded.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Expanded = ReactiveElement & { expanded?: boolean | null; _internals?: ElementInternals };\n\nexport class StateExpandedController<T extends Expanded> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.expanded !== null && this.host.expanded !== undefined) {\n this.host._internals!.ariaExpanded = `${this.host.expanded}`;\n }\n\n toggleState(this.host._internals!, 'expanded', Boolean(this.host.expanded));\n }\n}\n"],"mappings":";;AAQA,IAAa,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAKZ,AAJI,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,MACxD,KAAK,KAAK,WAAY,eAAe,GAAG,KAAK,KAAK,aAGpD,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;AACF"}
1
+ {"version":3,"file":"state-expanded.controller.js","names":[],"sources":["../../../src/internal/controllers/state-expanded.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Expanded = ReactiveElement & { expanded?: boolean | null; _internals?: ElementInternals };\n\nexport class StateExpandedController<T extends Expanded> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaExpanded =\n this.host.expanded === null || this.host.expanded === undefined ? null : `${this.host.expanded}`;\n\n toggleState(this.host._internals!, 'expanded', Boolean(this.host.expanded));\n }\n}\n"],"mappings":";;AAQA,IAAa,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAIZ,AAHA,KAAK,KAAK,WAAY,eACpB,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,YAExF,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;AACF"}
@@ -8,7 +8,7 @@ var n = class {
8
8
  e(this.host);
9
9
  }
10
10
  hostUpdated() {
11
- this.host.pressed !== null && this.host.pressed !== void 0 && (this.host._internals.ariaPressed = `${this.host.pressed}`), t(this.host._internals, "pressed", !!this.host.pressed);
11
+ this.host._internals.ariaPressed = this.host.pressed === null || this.host.pressed === void 0 ? null : `${this.host.pressed}`, t(this.host._internals, "pressed", !!this.host.pressed);
12
12
  }
13
13
  };
14
14
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"state-pressed.controller.js","names":[],"sources":["../../../src/internal/controllers/state-pressed.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Pressed = ReactiveElement & { pressed?: boolean | null; _internals?: ElementInternals };\n\nexport class StatePressedController<T extends Pressed> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.pressed !== null && this.host.pressed !== undefined) {\n this.host._internals!.ariaPressed = `${this.host.pressed}`;\n }\n\n toggleState(this.host._internals!, 'pressed', Boolean(this.host.pressed));\n }\n}\n"],"mappings":";;AAQA,IAAa,IAAb,MAAqF;CACnF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAKZ,AAJI,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,MACtD,KAAK,KAAK,WAAY,cAAc,GAAG,KAAK,KAAK,YAGnD,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;AACF"}
1
+ {"version":3,"file":"state-pressed.controller.js","names":[],"sources":["../../../src/internal/controllers/state-pressed.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Pressed = ReactiveElement & { pressed?: boolean | null; _internals?: ElementInternals };\n\nexport class StatePressedController<T extends Pressed> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaPressed =\n this.host.pressed === null || this.host.pressed === undefined ? null : `${this.host.pressed}`;\n\n toggleState(this.host._internals!, 'pressed', Boolean(this.host.pressed));\n }\n}\n"],"mappings":";;AAQA,IAAa,IAAb,MAAqF;CACnF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAIZ,AAHA,KAAK,KAAK,WAAY,cACpB,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,WAEtF,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;AACF"}
@@ -10,19 +10,19 @@ var n = class {
10
10
  }
11
11
  hostUpdated() {
12
12
  if (this.host.readOnly) {
13
- this.#t();
13
+ this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !1), this.#t();
14
14
  return;
15
15
  }
16
16
  if (this.host._internals?.states.has("anchor")) {
17
17
  this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !!this.host.selected), this.#t();
18
18
  return;
19
19
  }
20
- this.host.selected !== null && this.host.selected !== void 0 && (this.host._internals.ariaSelected = `${this.host.selected}`), t(this.host._internals, "selected", !!this.host.selected);
20
+ this.host._internals.ariaSelected = this.host.selected === null || this.host.selected === void 0 ? null : `${this.host.selected}`, t(this.host._internals, "selected", !!this.host.selected);
21
21
  }
22
22
  #t() {
23
23
  let e = this.host.querySelector("a"), t = !this.host.readOnly && this.host._internals.states.has("anchor") && !!(this.host.selected || this.host.current);
24
24
  if (e && t) {
25
- this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", "page"), this.#e = e;
25
+ this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e;
26
26
  return;
27
27
  }
28
28
  this.#e?.removeAttribute("aria-current"), this.#e = null;
@@ -1 +1 @@
1
- {"version":3,"file":"state-selected.controller.js","names":["#syncAnchorCurrentAttribute","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-selected.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Selected = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateSelectedController<T extends Selected> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host.selected !== null && this.host.selected !== undefined) {\n this.host._internals!.ariaSelected = `${this.host.selected}`;\n }\n\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAuF;CACrF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GACtB,KAAKA,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,eAAe,MACrC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS,GAC1E,KAAKA,GAA4B;GACjC;EACF;EAMA,AAJI,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,MACxD,KAAK,KAAK,WAAY,eAAe,GAAG,KAAK,KAAK,aAGpD,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAKC,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,MAAM,GAC1C,KAAKA,KAAuB;GAC5B;EACF;EAGA,AADA,KAAKA,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
1
+ {"version":3,"file":"state-selected.controller.js","names":["#syncAnchorCurrentAttribute","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-selected.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Selected = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateSelectedController<T extends Selected> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaSelected =\n this.host.selected === null || this.host.selected === undefined ? null : `${this.host.selected}`;\n\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAuF;CACrF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAGtB,AAFA,KAAK,KAAK,WAAY,eAAe,MACrC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAK,GACpD,KAAKA,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,eAAe,MACrC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS,GAC1E,KAAKA,GAA4B;GACjC;EACF;EAKA,AAHA,KAAK,KAAK,WAAY,eACpB,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,YAExF,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAKC,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAKA,KAAuB;GAC5B;EACF;EAGA,AADA,KAAKA,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { ButtonType } from '../../mixins/button.types.js';
2
2
  import { ReactiveController, ReactiveElement } from './types.js';
3
- type NativeButtonBehaviorHost = ReactiveElement & {
3
+ type SubmitHost = ReactiveElement & {
4
4
  disabled: boolean;
5
5
  form: HTMLFormElement | null | string;
6
6
  name?: string;
@@ -8,7 +8,7 @@ type NativeButtonBehaviorHost = ReactiveElement & {
8
8
  type?: ButtonType;
9
9
  value?: string;
10
10
  };
11
- export declare class TypeNativeButtonController<T extends NativeButtonBehaviorHost> implements ReactiveController {
11
+ export declare class TypeSubmitController<T extends SubmitHost> implements ReactiveController {
12
12
  #private;
13
13
  private host;
14
14
  constructor(host: T);
@@ -1,5 +1,5 @@
1
1
  import { onKeys as e, stopEvent as t } from "../utils.js";
2
- //#region src/internal/controllers/type-native-button.controller.ts
2
+ //#region src/internal/controllers/type-submit.controller.ts
3
3
  var n = class {
4
4
  #e;
5
5
  #t;
@@ -49,6 +49,6 @@ var n = class {
49
49
  }
50
50
  };
51
51
  //#endregion
52
- export { n as TypeNativeButtonController };
52
+ export { n as TypeSubmitController };
53
53
 
54
- //# sourceMappingURL=type-native-button.controller.js.map
54
+ //# sourceMappingURL=type-submit.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-submit.controller.js","names":["#defaultType","#setButtonType","#removeSubmitBehavior","#onSubmitClick","#onSubmitKeyup","#removeSubmitter","#requestSubmit","#createSubmitter","#submitterForm","#onSubmit","#submitter"],"sources":["../../../src/internal/controllers/type-submit.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { onKeys, stopEvent } from '../utils.js';\nimport type { ButtonType } from '../../mixins/button.types.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype SubmitHost = ReactiveElement & {\n disabled: boolean;\n form: HTMLFormElement | null | string;\n name?: string;\n readOnly: boolean;\n type?: ButtonType;\n value?: string;\n};\n\nexport class TypeSubmitController<T extends SubmitHost> implements ReactiveController {\n #defaultType: ButtonType | undefined;\n #submitter: HTMLButtonElement | undefined;\n #submitterForm: HTMLFormElement | undefined;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get defaultType() {\n return this.#defaultType;\n }\n\n hostUpdated() {\n this.#setButtonType();\n this.#removeSubmitBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#onSubmitClick);\n this.host.addEventListener('keyup', this.#onSubmitKeyup);\n }\n }\n\n hostDisconnected() {\n this.#removeSubmitBehavior();\n this.#removeSubmitter();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.form instanceof HTMLFormElement) {\n this.#defaultType = 'submit';\n }\n }\n\n #removeSubmitBehavior() {\n this.host.removeEventListener('click', this.#onSubmitClick);\n this.host.removeEventListener('keyup', this.#onSubmitKeyup);\n }\n\n #onSubmitKeyup = (event: KeyboardEvent) => {\n onKeys(['Enter', 'Space'], event, () => this.host.click());\n };\n\n #onSubmitClick = (event: Event) => {\n if (this.host.disabled) {\n stopEvent(event);\n return;\n }\n\n if (this.host.type === 'submit' && this.host.form instanceof HTMLFormElement) {\n this.#requestSubmit(this.host.form);\n } else if (this.host.type === 'reset' && this.host.form instanceof HTMLFormElement) {\n this.host.form.reset();\n }\n };\n\n #requestSubmit(form: HTMLFormElement) {\n this.#removeSubmitter();\n this.#createSubmitter();\n this.#submitterForm = form;\n form.addEventListener('submit', this.#onSubmit, { once: true });\n this.#submitter?.remove();\n form.appendChild(this.#submitter!);\n form.requestSubmit(this.#submitter);\n }\n\n #onSubmit = () => {\n const submitter = this.#submitter;\n this.#submitterForm = undefined;\n setTimeout(() => {\n submitter?.remove();\n if (this.#submitter === submitter) {\n this.#submitter = undefined;\n }\n }, 0);\n };\n\n #createSubmitter() {\n if (!this.#submitter) {\n this.#submitter = globalThis.document.createElement('button');\n this.#submitter.type = 'submit';\n this.#submitter.style.display = 'none';\n }\n\n this.#submitter.name = this.host.name ?? '';\n this.#submitter.value = this.host.value ?? '';\n }\n\n #removeSubmitter() {\n this.#submitterForm?.removeEventListener('submit', this.#onSubmit);\n this.#submitterForm = undefined;\n this.#submitter?.remove();\n this.#submitter = undefined;\n }\n}\n"],"mappings":";;AAgBA,IAAa,IAAb,MAAsF;CACpF;CACA;CACA;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,cAAc;EAChB,OAAO,KAAKA;CACd;CAEA,cAAc;EAGZ,AAFA,KAAKC,GAAe,GACpB,KAAKC,GAAsB,GACvB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,aACpC,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAc,GACvD,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAc;CAE3D;CAEA,mBAAmB;EAEjB,AADA,KAAKF,GAAsB,GAC3B,KAAKG,GAAiB;CACxB;CAEA,KAAiB;EACf,AAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK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AgB,oBAAoB,UAAU,KAAKC,EAAS,GACjE,KAAKD,KAAiB,KAAA,GACtB,KAAKE,IAAY,OAAO,GACxB,KAAKA,KAAa,KAAA;CACpB;AACF"}
@@ -43,7 +43,7 @@ export interface FormControlMetadata {
43
43
  validators?: Validator[];
44
44
  strict?: boolean;
45
45
  }
46
- interface FormControlInstance extends HTMLElement {
46
+ export interface FormControlInstance extends HTMLElement {
47
47
  value: FormControlValue | undefined;
48
48
  defaultValue: string;
49
49
  form: HTMLFormElement | null;
@@ -87,5 +87,5 @@ export interface ValidatorResult {
87
87
  validity: Partial<ValidityState>;
88
88
  message?: string;
89
89
  }
90
- export type Validator = (value: unknown, element: FormControl) => ValidatorResult;
90
+ export type Validator = (value: unknown, element: FormControlInstance) => ValidatorResult;
91
91
  export {};
@@ -3,7 +3,7 @@ import { TypeAnchorController as a } from "../internal/controllers/type-anchor.c
3
3
  import { TypeButtonController as o } from "../internal/controllers/type-button.controller.js";
4
4
  import { TypeCommandController as s } from "../internal/controllers/type-command.controller.js";
5
5
  import { TypeInterestInvokerController as c } from "../internal/controllers/type-interest-invoker.controller.js";
6
- import { TypeNativeButtonController as l } from "../internal/controllers/type-native-button.controller.js";
6
+ import { TypeSubmitController as l } from "../internal/controllers/type-submit.controller.js";
7
7
  import { TypePopoverTriggerController as u } from "../internal/controllers/type-popover-trigger.controller.js";
8
8
  import { StateActiveController as d } from "../internal/controllers/state-active.controller.js";
9
9
  import { StateCurrentController as f } from "../internal/controllers/state-current.controller.js";
@@ -16,7 +16,7 @@ import { StateSelectedController as _ } from "../internal/controllers/state-sele
16
16
  function v(v) {
17
17
  return class y extends v {
18
18
  constructor(...t) {
19
- super(...t), this.#t = null, this.#n = null, this.#i = !1, this.#o = null, this.#s = !1, this.#c = null, this.#l = null, this.#d = /* @__PURE__ */ new Map(), this.#p = null, this.#g = !1, this.#v = !1, this._internals = e(this), this._typeAnchorController = new a(this), this._typeButtonController = new o(this), this._typeNativeButtonController = new l(this), this._typeCommandController = new s(this), this._typeInterestInvokerController = new c(this), this._typePopoverTriggerController = new u(this), this._stateActiveController = new d(this), this._stateDisabledController = new p(this), this._stateExpandedController = new m(this), this._statePressedController = new h(this), this._stateSelectedController = new _(this), this._stateCurrentController = new f(this), this._stateReadOnlyController = new g(this);
19
+ super(...t), this.#t = null, this.#n = null, this.#i = !1, this.#o = null, this.#s = !1, this.#c = null, this.#l = null, this.#d = /* @__PURE__ */ new Map(), this.#p = null, this.#g = !1, this.#v = !1, this._internals = e(this), this._typeAnchorController = new a(this), this._typeButtonController = new o(this), this._typeSubmitController = new l(this), this._typeCommandController = new s(this), this._typeInterestInvokerController = new c(this), this._typePopoverTriggerController = new u(this), this._stateActiveController = new d(this), this._stateDisabledController = new p(this), this._stateExpandedController = new m(this), this._statePressedController = new h(this), this._stateSelectedController = new _(this), this._stateCurrentController = new f(this), this._stateReadOnlyController = new g(this);
20
20
  }
21
21
  static {
22
22
  this.formAssociated = !0;
@@ -129,7 +129,7 @@ function v(v) {
129
129
  });
130
130
  }
131
131
  get type() {
132
- return this.#y ?? this._typeNativeButtonController?.defaultType;
132
+ return this.#y ?? this._typeSubmitController?.defaultType;
133
133
  }
134
134
  set type(e) {
135
135
  this.#O({
@@ -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 { TypeNativeButtonController } from '../internal/controllers/type-native-button.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._typeNativeButtonController?.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 _typeNativeButtonController = new TypeNativeButtonController(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,sCACvB,IAAI,EAA2B,IAAI,iCACxC,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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kBAAmB,KAAKD,KAAc;IACtC,eAAgB,KAAKL,KAAW;IAChC,mBAAoB,KAAKQ,KAAe;IACxC,YAAa,KAAKd,KAAQ,KAAS,KAAA;IACnC,2BAA4B,KAAKS,KAAuB;IACxD,qBAAsB,KAAKD,KAAiB,KAAS,KAAA;IACrD,YAAa,KAAKL,KAAQ;IAC1B,aAAc,KAAKD,KAAS,KAAS,KAAA;GAEvC,GAAQ,KAAY;EACtB;EAEA,GAAkB,GAAmB,GAAsB;GASzD,OARI,CAAC,KAAK,eAAe,CAAC,KAAKa,MACxB,KAAK,aAAa,CAAS,KAC9B,KAAKY,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"}
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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AAoB,KAAKQ,KAAe;IACxC,YAAa,KAAKd,KAAQ,KAAS,KAAA;IACnC,2BAA4B,KAAKS,KAAuB;IACxD,qBAAsB,KAAKD,KAAiB,KAAS,KAAA;IACrD,YAAa,KAAKL,KAAQ;IAC1B,aAAc,KAAKD,KAAS,KAAS,KAAA;GAEvC,GAAQ,KAAY;EACtB;EAEA,GAAkB,GAAmB,GAAsB;GASzD,OARI,CAAC,KAAK,eAAe,CAAC,KAAKa,MACxB,KAAK,aAAa,CAAS,KAC9B,KAAKY,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"}
@@ -110,8 +110,7 @@ function a(a) {
110
110
  return Number(this.value);
111
111
  }
112
112
  set valueAsNumber(t) {
113
- if (typeof this._value == "number" && typeof t == "number") this.value = t;
114
- else throw new e(this.localName, "cannot set number value on non-number type");
113
+ typeof this._value == "number" && typeof t == "number" ? this.value = t : console.warn(new e(this.localName, "cannot set number value on non-number type").message);
115
114
  }
116
115
  get type() {
117
116
  return this.localName;
@@ -1 +1 @@
1
- {"version":3,"file":"control.js","names":["#hasInitialValue","#syncFormControlStates","#handleValueAttributeChange","#handleBooleanAttributeChange","#handleStringAttributeChange","#handleNumberAttributeChange","#updateValidity","#syncValidityStates","#customValidityMessage","#resetValidityStates","#applyValidityResult","#getValidityResult","#getNativeValidityResult"],"sources":["../../src/mixins/control.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { FormControl, FormControlMetadata, FormControlValue, ValidatorResult } from '../internal/types.js';\nimport { FormControlError } from '../internal/errors.js';\nimport { parseValueSchema } from '../internal/schema.js';\nimport { attachInternals, isObjectLiteral, toggleState } from '../internal/utils.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & {\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}) & {\n observedAttributes?: string[];\n};\n\nexport interface FormControlMixinInstance<T extends FormControlValue> {\n /**\n * The initial value used when the parent form resets.\n */\n defaultValue: string;\n\n /**\n * Prevents the user from changing the control value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly\n * @attr readonly\n * @reflect\n */\n readOnly: boolean;\n\n /**\n * Prevents the user from interacting with the control.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled\n * @attr disabled\n * @reflect\n */\n disabled: boolean;\n\n /**\n * Requires a value before the parent form can submit.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required\n * @attr required\n * @reflect\n */\n required: boolean;\n\n /**\n * Defines the pattern that text values must match.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern\n * @attr pattern\n * @reflect\n */\n pattern: string;\n\n /**\n * Defines the minimum numeric value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min\n * @attr min\n * @reflect\n */\n min: number | null;\n\n /**\n * Defines the maximum numeric value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max\n * @attr max\n * @reflect\n */\n max: number | null;\n\n /**\n * Defines the value granularity for numeric inputs.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step\n * @attr step\n * @reflect\n */\n step: number | null;\n\n /**\n * Defines the minimum text length.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength\n * @attr minlength\n * @reflect\n */\n minLength: number;\n\n /**\n * Defines the maximum text length.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/maxlength\n * @attr maxlength\n * @reflect\n */\n maxLength: number;\n\n /**\n * The name submitted with the control value as part of the form data.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n * @attr name\n * @reflect\n */\n name: string;\n\n /**\n * Disables constraint validation for this control.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/novalidate\n * @attr novalidate\n * @reflect\n */\n noValidate: boolean;\n\n /**\n * The current form control value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/value\n * @attr value\n * @reflect\n */\n value: T | undefined;\n\n /**\n * The form associated with the control.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form\n */\n form: HTMLFormElement | null;\n\n /**\n * Indicates whether the control participates in constraint validation.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n willValidate: boolean;\n\n /**\n * The control validity state.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validity\n */\n validity: ValidityState;\n\n /**\n * The validation message shown when the control is invalid.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage\n */\n validationMessage: string;\n\n /**\n * The current value serialized as a string.\n */\n valueAsString: string;\n\n /**\n * The current value parsed as a number.\n */\n valueAsNumber: number;\n\n /**\n * The control type.\n */\n type: string;\n\n /**\n * Labels associated with the control.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels\n */\n labels: NodeList;\n\n /**\n * Text content from labels associated with the control.\n */\n composedLabel: string;\n\n _metadata: FormControlMetadata;\n _initialValue: T | undefined;\n _validators: NonNullable<FormControlMetadata['validators']>;\n _internals: ElementInternals;\n updateValue(value: T): void;\n _stopInternalPropagation(event: Event): void;\n _handleAttributeChange(name: string, newValue: string | null): void;\n formResetCallback(): void;\n formDisabledCallback(disabled: boolean): void;\n formStateRestoreCallback(state: T, reason: string): void;\n\n /**\n * Reports whether the control satisfies its constraints.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity\n */\n reportValidity(): boolean;\n\n /**\n * Checks whether the control satisfies its constraints.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity\n */\n checkValidity(): boolean;\n setValidity(validity: Partial<ValidityState>, message?: string): void;\n\n /**\n * Sets a custom validation message.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n */\n setCustomValidity(message: string): void;\n\n /**\n * Resets the control value to its initial value.\n */\n reset(): void;\n dispatchInputEvent(): void;\n dispatchChangeEvent(): void;\n dispatchUpdateEvent(type: 'input' | 'change'): void;\n _updateFormState(): void;\n _requestUpdate(): void;\n}\n\nexport type FormControlMixinReturn<TBase extends Constructor, T extends FormControlValue> = (new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & FormControlMixinInstance<T>) & {\n formAssociated: boolean;\n metadata: FormControlMetadata;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds form control functionality to a component.\n * @event input - Dispatched when the value of the component changes as a result of a user action.\n * @event change - Dispatched when the user modifies and commits the element's value.\n * @event reset - Dispatched when the control state was reset to its initial value.\n * @event invalid - Dispatched when the control is invalid.\n */\nexport function FormControlMixin<TBase extends Constructor, T extends FormControlValue>(\n SuperClass: TBase\n): FormControlMixinReturn<TBase, T> {\n return class FormControlBase extends SuperClass {\n static formAssociated = true;\n\n static metadata: FormControlMetadata;\n\n #customValidityMessage = '';\n\n #hasInitialValue = false;\n\n get defaultValue(): string {\n return this.getAttribute('value') ?? '';\n }\n\n set defaultValue(value: string) {\n this.setAttribute('value', value);\n }\n\n /** determine if component is in readonly/non-editable state */\n get readOnly(): boolean {\n return this.getAttribute('readonly') !== null;\n }\n\n set readOnly(value: boolean | unknown) {\n attachInternals(this);\n this.toggleAttribute('readonly', value as boolean);\n toggleState(this._internals, 'readonly', Boolean(value));\n this._requestUpdate();\n }\n\n /** determine if component is in disabled state */\n get disabled(): boolean {\n return this.getAttribute('disabled') !== null;\n }\n\n // unknown forces generation of get/set in type defs see https://github.com/microsoft/TypeScript/issues/58790\n set disabled(value: boolean | unknown) {\n attachInternals(this);\n this.toggleAttribute('disabled', value as boolean);\n this._internals.ariaDisabled = value ? 'true' : 'false';\n toggleState(this._internals, 'disabled', Boolean(value));\n this._requestUpdate();\n }\n\n /** determine if the component value requires input */\n get required(): boolean {\n return this.getAttribute('required') !== null;\n }\n\n set required(value: boolean | unknown) {\n this.toggleAttribute('required', value as boolean);\n toggleState(this._internals, 'required', Boolean(value));\n this.checkValidity();\n this._requestUpdate();\n }\n\n get pattern() {\n return this.getAttribute('pattern') ?? '';\n }\n\n set pattern(value: string) {\n value ? this.setAttribute('pattern', value) : this.removeAttribute('pattern');\n toggleState(this._internals, 'pattern', Boolean(value));\n this.checkValidity();\n this._requestUpdate();\n }\n\n get min(): number | null {\n return getNumberAttribute(this, 'min');\n }\n\n set min(value: number | null) {\n setNumberAttribute(this, 'min', value);\n toggleState(this._internals, 'min', value !== null);\n this._internals.ariaValueMin = value !== null ? `${value}` : null;\n this.checkValidity();\n this._requestUpdate();\n }\n\n get max(): number | null {\n return getNumberAttribute(this, 'max');\n }\n\n set max(value: number | null) {\n setNumberAttribute(this, 'max', value);\n toggleState(this._internals, 'max', value !== null);\n this._internals.ariaValueMax = value !== null ? `${value}` : null;\n this.checkValidity();\n this._requestUpdate();\n }\n\n get step(): number | null {\n return getNumberAttribute(this, 'step');\n }\n\n set step(value: number | null) {\n setNumberAttribute(this, 'step', value);\n toggleState(this._internals, 'step', value !== null);\n this.checkValidity();\n this._requestUpdate();\n }\n\n get minLength(): number {\n return this.hasAttribute('minlength') ? Number(this.getAttribute('minlength')) : -1;\n }\n\n set minLength(value: number) {\n setLengthAttribute(this, 'minlength', value);\n toggleState(this._internals, 'minlength', this.minLength !== -1);\n this.checkValidity();\n this._requestUpdate();\n }\n\n get maxLength(): number {\n return this.hasAttribute('maxlength') ? Number(this.getAttribute('maxlength')) : -1;\n }\n\n set maxLength(value: number) {\n setLengthAttribute(this, 'maxlength', value);\n toggleState(this._internals, 'maxlength', this.maxLength !== -1);\n this.checkValidity();\n this._requestUpdate();\n }\n\n /** name associated to parent form */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(value: string) {\n value ? this.setAttribute('name', value) : this.removeAttribute('name');\n this._updateFormState();\n this._requestUpdate();\n }\n\n /** get determine if component is in no validation state */\n get noValidate(): boolean {\n return this.getAttribute('novalidate') !== null || this._internals.form?.noValidate === true;\n }\n\n /** set determine if component is in no validation state */\n set noValidate(value: boolean | unknown) {\n this.toggleAttribute('novalidate', value as boolean);\n this._requestUpdate();\n }\n\n /** @internal */\n _value: T | undefined;\n\n /** value state of the component */\n set value(value: T | unknown) {\n this.updateValue(value as T);\n this._requestUpdate();\n }\n\n get value(): T | undefined {\n return this._value;\n }\n\n /** @protected */\n updateValue(value: T) {\n const previousValue = this._value;\n this._value = structuredClone(value);\n const valid = this.checkValidity();\n\n if (!valid && this._metadata.strict) {\n this._value = previousValue;\n console.error('FormControlError: (strict mode)', this.validationMessage);\n }\n\n if (!this.#hasInitialValue && !this.isConnected) {\n this._initialValue = structuredClone(this._value);\n this.#hasInitialValue = true;\n }\n\n this._updateFormState();\n }\n\n /** associated parent form */\n get form() {\n return this._internals.form;\n }\n\n /** determine if the component is a candidate for constraint checking */\n get willValidate() {\n return this._internals.willValidate;\n }\n\n /** validity state of the component */\n get validity() {\n return this._internals.validity;\n }\n\n /** validation message of the component */\n get validationMessage() {\n return this._internals.validationMessage;\n }\n\n /** stringified value of the component */\n get valueAsString() {\n return getValueAsString(this.value);\n }\n\n /** parsed number value of the component */\n get valueAsNumber(): number {\n return Number(this.value);\n }\n\n set valueAsNumber(value: number) {\n if (typeof this._value === 'number' && typeof value === 'number') {\n this.value = value as T;\n } else {\n throw new FormControlError(this.localName, 'cannot set number value on non-number type');\n }\n }\n\n get type() {\n return this.localName;\n }\n\n get labels() {\n return this._internals.labels;\n }\n\n get composedLabel() {\n return Array.from(this.labels)\n .map(label => label.textContent)\n .join(' ')\n .trim();\n }\n\n /** @internal */\n get _metadata() {\n return (this.constructor as FormControl).metadata;\n }\n\n /** @internal */\n _internals = attachInternals(this);\n\n /** @internal */\n _initialValue: T | undefined;\n\n /** @internal */\n get _validators() {\n return this._metadata.validators ?? [];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(...args);\n this._initialValue = this.value;\n }\n\n connectedCallback() {\n attachInternals(this);\n if (super.connectedCallback) {\n super.connectedCallback();\n }\n\n this.tabIndex = 0;\n this.#syncFormControlStates();\n this._updateFormState();\n this.checkValidity();\n this.shadowRoot?.addEventListener('input', this._stopInternalPropagation);\n this.shadowRoot?.addEventListener('change', this._stopInternalPropagation);\n }\n\n disconnectedCallback() {\n if (super.disconnectedCallback) {\n super.disconnectedCallback();\n }\n\n this.shadowRoot?.removeEventListener('input', this._stopInternalPropagation);\n this.shadowRoot?.removeEventListener('change', this._stopInternalPropagation);\n }\n\n /**\n * @internal\n * Stop events that originated inside this component's own shadow tree so the\n * mixin can re-dispatch them semantically. Slotted light-DOM events traverse the\n * host's shadow root via slots and must continue bubbling.\n */\n _stopInternalPropagation = (event: Event) => {\n const origin = event.composedPath()[0];\n if (origin instanceof Node && this.shadowRoot?.contains(origin)) {\n event.stopPropagation();\n }\n };\n\n static get observedAttributes() {\n const attrs = super.observedAttributes ?? [];\n return attrs.concat([\n 'value',\n 'readonly',\n 'required',\n 'name',\n 'novalidate',\n 'disabled',\n 'pattern',\n 'min',\n 'max',\n 'step',\n 'minlength',\n 'maxlength'\n ]);\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (super.attributeChangedCallback) {\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n if (newValue === oldValue) {\n return;\n }\n\n this._handleAttributeChange(name, newValue);\n }\n\n /** @internal */\n _handleAttributeChange(name: string, newValue: string | null) {\n if (name === 'value') {\n this.#handleValueAttributeChange(newValue);\n return;\n }\n\n if (this.#handleBooleanAttributeChange(name, newValue)) {\n return;\n }\n\n if (this.#handleStringAttributeChange(name, newValue)) {\n return;\n }\n\n this.#handleNumberAttributeChange(name, newValue);\n }\n\n /** @protected */\n formResetCallback() {\n this.reset();\n }\n\n formDisabledCallback(disabled: boolean) {\n this.disabled = disabled;\n }\n\n /** @protected https://webkit.org/blog/13711/elementinternals-and-form-associated-custom-elements/*/\n formStateRestoreCallback(state: T, _reason: string) {\n this.value = state;\n this.checkValidity();\n }\n\n /** report validity of the component */\n reportValidity() {\n this.#updateValidity();\n return this._internals.reportValidity();\n }\n\n /** check validity of the component */\n checkValidity() {\n this.#updateValidity();\n return this._internals.checkValidity();\n }\n\n /** @protected */\n setValidity(validity: Partial<ValidityState>, message?: string) {\n this._internals.setValidity(validity, message);\n this.#syncValidityStates();\n }\n\n setCustomValidity(message: string) {\n this.#customValidityMessage = message;\n this.#updateValidity();\n }\n\n reset() {\n this.value = this.hasAttribute('value')\n ? parseValueSchema<T>(this.localName, this.defaultValue, this._metadata.valueSchema)\n : structuredClone(this._initialValue);\n this.#resetValidityStates();\n this.checkValidity();\n this.dispatchEvent(new Event('reset', { bubbles: true, cancelable: true, composed: true }));\n }\n\n #updateValidity() {\n if (this.noValidate) {\n this._internals.setValidity({});\n } else {\n this.#applyValidityResult(this.#getValidityResult());\n }\n\n this.#syncValidityStates();\n }\n\n #getValidityResult(): ValidatorResult {\n if (this.#customValidityMessage) {\n return invalid({ customError: true }, this.#customValidityMessage);\n }\n\n const nativeResult = this.#getNativeValidityResult();\n if (!nativeResult.validity.valid) {\n return nativeResult;\n }\n\n for (const validator of this._validators) {\n const result = validator(this.value, this as unknown as FormControl);\n if (!result.validity.valid) {\n return result;\n }\n }\n\n return { validity: { valid: true }, message: '' };\n }\n\n #getNativeValidityResult(): ValidatorResult {\n if (this.required && isEmptyValue(this.value)) {\n return invalid({ valueMissing: true }, 'This field is required');\n }\n\n if (typeof this.value === 'string') {\n return getStringValidity({\n maxLength: this.maxLength,\n minLength: this.minLength,\n pattern: this.pattern,\n value: this.value\n });\n }\n\n if (typeof this.value === 'number') {\n return getNumberValidity({\n max: this.max,\n min: this.min,\n step: this.step,\n value: this.value\n });\n }\n\n return { validity: { valid: true }, message: '' };\n }\n\n #applyValidityResult(result: ValidatorResult) {\n if (result.validity.valid) {\n this._internals.setValidity({});\n return;\n }\n\n this._internals.setValidity(\n result.validity,\n result.message,\n (this.shadowRoot?.activeElement as HTMLElement) ?? undefined\n );\n }\n\n #syncFormControlStates() {\n toggleState(this._internals, 'disabled', this.disabled);\n toggleState(this._internals, 'readonly', this.readOnly);\n toggleState(this._internals, 'required', this.required);\n toggleState(this._internals, 'pattern', Boolean(this.pattern));\n toggleState(this._internals, 'min', this.min !== null);\n toggleState(this._internals, 'max', this.max !== null);\n toggleState(this._internals, 'step', this.step !== null);\n toggleState(this._internals, 'minlength', this.minLength !== -1);\n toggleState(this._internals, 'maxlength', this.maxLength !== -1);\n }\n\n #syncValidityStates() {\n toggleState(this._internals, 'valid', this.validity.valid);\n toggleState(this._internals, 'invalid', !this.validity.valid);\n }\n\n #resetValidityStates() {\n this._internals.states.delete('valid');\n this._internals.states.delete('invalid');\n }\n\n #handleValueAttributeChange(newValue: string | null) {\n this.value =\n newValue === null\n ? (undefined as unknown as T)\n : parseValueSchema<T>(this.localName, newValue, this._metadata.valueSchema);\n this._initialValue = structuredClone(this.value);\n this.#hasInitialValue = true;\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'readonly') {\n this.readOnly = newValue !== null;\n return true;\n }\n\n if (name === 'disabled') {\n this.disabled = newValue !== null;\n return true;\n }\n\n if (name === 'required') {\n this.required = newValue !== null;\n return true;\n }\n\n if (name === 'novalidate') {\n this.noValidate = newValue !== null;\n this.checkValidity();\n return true;\n }\n\n return false;\n }\n\n #handleStringAttributeChange(name: string, newValue: string | null) {\n if (name === 'name') {\n this.name = newValue ?? '';\n return true;\n }\n\n if (name === 'pattern') {\n this.pattern = newValue ?? '';\n return true;\n }\n\n return false;\n }\n\n #handleNumberAttributeChange(name: string, newValue: string | null) {\n if (name === 'min') {\n this.min = getNumberValue(newValue);\n } else if (name === 'max') {\n this.max = getNumberValue(newValue);\n } else if (name === 'step') {\n this.step = getNumberValue(newValue);\n } else if (name === 'minlength') {\n this.minLength = getLengthValue(newValue);\n } else if (name === 'maxlength') {\n this.maxLength = getLengthValue(newValue);\n }\n }\n\n /** @protected */\n dispatchInputEvent() {\n this.dispatchEvent(\n new InputEvent('input', { bubbles: true, cancelable: true, composed: true, data: this.valueAsString })\n );\n }\n\n /** @protected */\n dispatchChangeEvent() {\n this.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));\n }\n\n /** @protected */\n dispatchUpdateEvent(type: 'input' | 'change') {\n if (type === 'input') {\n this.dispatchInputEvent();\n } else if (type === 'change') {\n this.dispatchChangeEvent();\n }\n }\n\n /** @internal */\n _updateFormState() {\n if (!this.name) {\n this._internals.setFormValue(null);\n } else if (typeof this.value === 'number' || typeof this.value === 'boolean') {\n this._internals.setFormValue(`${this.value}`);\n } else if (isObjectLiteral(this.value)) {\n const formData = new FormData();\n Object.entries(this.value as Record<string, unknown>)\n .filter(([key]) => key !== 'value')\n .forEach(([key, value]) => {\n formData.set(`${this.name}-${key}`, `${value}`);\n });\n this._internals.setFormValue(formData);\n } else if (Array.isArray(this.value)) {\n const formData = new FormData();\n this.value.forEach(i => formData.append(`${this.name}`, i));\n this._internals.setFormValue(formData);\n } else {\n this._internals.setFormValue(this.value as null | string | File | FormData);\n }\n }\n\n /** @internal */\n _requestUpdate() {\n if (this.requestUpdate) {\n this.requestUpdate();\n }\n }\n } as unknown as FormControlMixinReturn<TBase, T>;\n}\n\nfunction getValueAsString(value: FormControlValue | undefined) {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (isStringifiablePrimitive(value)) {\n return `${value}`;\n }\n\n if (isFileValue(value)) {\n return value.name;\n }\n\n if (Array.isArray(value) || isObjectLiteral(value)) {\n return JSON.stringify(value);\n }\n\n return JSON.stringify(value) ?? '';\n}\n\nfunction isStringifiablePrimitive(value: FormControlValue): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n\nfunction isFileValue(value: FormControlValue): value is File {\n return typeof File !== 'undefined' && value instanceof File;\n}\n\nfunction getNumberAttribute(element: HTMLElement, name: string) {\n return getNumberValue(element.getAttribute(name));\n}\n\nfunction getNumberValue(value: string | null) {\n if (value === null || value === '') {\n return null;\n }\n\n const number = Number(value);\n return Number.isFinite(number) ? number : null;\n}\n\nfunction setNumberAttribute(element: HTMLElement, name: string, value: number | null) {\n if (value === null || !Number.isFinite(value)) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, `${value}`);\n }\n}\n\nfunction getLengthValue(value: string | null) {\n const length = getNumberValue(value);\n return length === null || length < 0 ? -1 : length;\n}\n\nfunction setLengthAttribute(element: HTMLElement, name: string, value: number) {\n if (value < 0 || !Number.isFinite(value)) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, `${value}`);\n }\n}\n\nfunction isEmptyValue(value: FormControlValue | undefined) {\n return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);\n}\n\ninterface StringValidityOptions {\n value: string;\n pattern: string;\n minLength: number;\n maxLength: number;\n}\n\nfunction getStringValidity({ value, pattern, minLength, maxLength }: StringValidityOptions): ValidatorResult {\n if (pattern && !matchesPattern(value, pattern)) {\n return invalid({ patternMismatch: true }, 'pattern mismatch');\n }\n\n if (minLength !== -1 && value.length < minLength) {\n return invalid({ tooShort: true }, 'value too short');\n }\n\n if (maxLength !== -1 && value.length > maxLength) {\n return invalid({ tooLong: true }, 'value too long');\n }\n\n return { validity: { valid: true }, message: '' };\n}\n\ninterface NumberValidityOptions {\n value: number;\n min: number | null;\n max: number | null;\n step: number | null;\n}\n\nfunction getNumberValidity({ value, min, max, step }: NumberValidityOptions): ValidatorResult {\n if (Number.isNaN(value)) {\n return invalid({ badInput: true }, 'bad input');\n }\n\n if (min !== null && value < min) {\n return invalid({ rangeUnderflow: true }, 'value too low');\n }\n\n if (max !== null && value > max) {\n return invalid({ rangeOverflow: true }, 'value too high');\n }\n\n if (step !== null && step > 0 && hasStepMismatch(value, min ?? 0, step)) {\n return invalid({ stepMismatch: true }, 'step mismatch');\n }\n\n return { validity: { valid: true }, message: '' };\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n try {\n return new RegExp(`^(?:${pattern})$`).test(value);\n } catch {\n // Pattern attributes are consumer-provided regular expressions.\n return true;\n }\n}\n\nfunction hasStepMismatch(value: number, base: number, step: number) {\n const quotient = (value - base) / step;\n return Math.abs(Math.round(quotient) - quotient) > Number.EPSILON;\n}\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidatorResult {\n return { validity: { ...validity, valid: false }, message };\n}\n"],"mappings":";;;;AAkOA,SAAgB,EACd,GACkC;CAClC,OAAO,cAA8B,EAAW;;yBACtB;;EAIxB;EAEA;EAEA,IAAI,eAAuB;GACzB,OAAO,KAAK,aAAa,OAAO,KAAK;EACvC;EAEA,IAAI,aAAa,GAAe;GAC9B,KAAK,aAAa,SAAS,CAAK;EAClC;EAGA,IAAI,WAAoB;GACtB,OAAO,KAAK,aAAa,UAAU,MAAM;EAC3C;EAEA,IAAI,SAAS,GAA0B;GAIrC,AAHA,EAAgB,IAAI,GACpB,KAAK,gBAAgB,YAAY,CAAgB,GACjD,EAAY,KAAK,YAAY,YAAY,EAAQ,CAAM,GACvD,KAAK,eAAe;EACtB;EAGA,IAAI,WAAoB;GACtB,OAAO,KAAK,aAAa,UAAU,MAAM;EAC3C;EAGA,IAAI,SAAS,GAA0B;GAKrC,AAJA,EAAgB,IAAI,GACpB,KAAK,gBAAgB,YAAY,CAAgB,GACjD,KAAK,WAAW,eAAe,IAAQ,SAAS,SAChD,EAAY,KAAK,YAAY,YAAY,EAAQ,CAAM,GACvD,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C;CACnF,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU,OAAO;EAAM;EAAG;CAAQ;AAC5D"}
1
+ {"version":3,"file":"control.js","names":["#hasInitialValue","#syncFormControlStates","#handleValueAttributeChange","#handleBooleanAttributeChange","#handleStringAttributeChange","#handleNumberAttributeChange","#updateValidity","#syncValidityStates","#customValidityMessage","#resetValidityStates","#applyValidityResult","#getValidityResult","#getNativeValidityResult"],"sources":["../../src/mixins/control.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n FormControl,\n FormControlInstance,\n FormControlMetadata,\n FormControlValue,\n ValidatorResult\n} from '../internal/types.js';\nimport { FormControlError } from '../internal/errors.js';\nimport { parseValueSchema } from '../internal/schema.js';\nimport { attachInternals, isObjectLiteral, toggleState } from '../internal/utils.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & {\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}) & {\n observedAttributes?: string[];\n};\n\nexport interface FormControlMixinInstance<T extends FormControlValue> {\n /**\n * The initial value used when the parent form resets.\n */\n defaultValue: string;\n\n /**\n * Prevents the user from changing the control value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly\n * @attr readonly\n * @reflect\n */\n readOnly: boolean;\n\n /**\n * Prevents the user from interacting with the control.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled\n * @attr disabled\n * @reflect\n */\n disabled: boolean;\n\n /**\n * Requires a value before the parent form can submit.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required\n * @attr required\n * @reflect\n */\n required: boolean;\n\n /**\n * Defines the pattern that text values must match.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern\n * @attr pattern\n * @reflect\n */\n pattern: string;\n\n /**\n * Defines the minimum numeric value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min\n * @attr min\n * @reflect\n */\n min: number | null;\n\n /**\n * Defines the maximum numeric value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max\n * @attr max\n * @reflect\n */\n max: number | null;\n\n /**\n * Defines the value granularity for numeric inputs.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step\n * @attr step\n * @reflect\n */\n step: number | null;\n\n /**\n * Defines the minimum text length.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength\n * @attr minlength\n * @reflect\n */\n minLength: number;\n\n /**\n * Defines the maximum text length.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/maxlength\n * @attr maxlength\n * @reflect\n */\n maxLength: number;\n\n /**\n * The name submitted with the control value as part of the form data.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n * @attr name\n * @reflect\n */\n name: string;\n\n /**\n * Disables constraint validation for this control.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/novalidate\n * @attr novalidate\n * @reflect\n */\n noValidate: boolean;\n\n /**\n * The current form control value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/value\n * @attr value\n * @reflect\n */\n value: T | undefined;\n\n /**\n * The form associated with the control.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form\n */\n form: HTMLFormElement | null;\n\n /**\n * Indicates whether the control participates in constraint validation.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n willValidate: boolean;\n\n /**\n * The control validity state.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validity\n */\n validity: ValidityState;\n\n /**\n * The validation message shown when the control is invalid.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage\n */\n validationMessage: string;\n\n /**\n * The current value serialized as a string.\n */\n valueAsString: string;\n\n /**\n * The current value parsed as a number.\n */\n valueAsNumber: number;\n\n /**\n * The control type.\n */\n type: string;\n\n /**\n * Labels associated with the control.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels\n */\n labels: NodeList;\n\n /**\n * Text content from labels associated with the control.\n */\n composedLabel: string;\n\n _metadata: FormControlMetadata;\n _initialValue: T | undefined;\n _validators: NonNullable<FormControlMetadata['validators']>;\n _internals: ElementInternals;\n updateValue(value: T): void;\n _stopInternalPropagation(event: Event): void;\n _handleAttributeChange(name: string, newValue: string | null): void;\n formResetCallback(): void;\n formDisabledCallback(disabled: boolean): void;\n formStateRestoreCallback(state: T, reason: string): void;\n\n /**\n * Reports whether the control satisfies its constraints.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity\n */\n reportValidity(): boolean;\n\n /**\n * Checks whether the control satisfies its constraints.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity\n */\n checkValidity(): boolean;\n setValidity(validity: Partial<ValidityState>, message?: string): void;\n\n /**\n * Sets a custom validation message.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n */\n setCustomValidity(message: string): void;\n\n /**\n * Resets the control value to its initial value.\n */\n reset(): void;\n dispatchInputEvent(): void;\n dispatchChangeEvent(): void;\n dispatchUpdateEvent(type: 'input' | 'change'): void;\n _updateFormState(): void;\n _requestUpdate(): void;\n}\n\nexport type FormControlMixinReturn<TBase extends Constructor, T extends FormControlValue> = (new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & FormControlMixinInstance<T>) & {\n formAssociated: boolean;\n metadata: FormControlMetadata;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds form control functionality to a component.\n * @event input - Dispatched when the value of the component changes as a result of a user action.\n * @event change - Dispatched when the user modifies and commits the element's value.\n * @event reset - Dispatched when the control state was reset to its initial value.\n * @event invalid - Dispatched when the control is invalid.\n */\nexport function FormControlMixin<TBase extends Constructor, T extends FormControlValue>(\n SuperClass: TBase\n): FormControlMixinReturn<TBase, T> {\n return class FormControlBase extends SuperClass {\n static formAssociated = true;\n\n static metadata: FormControlMetadata;\n\n #customValidityMessage = '';\n\n #hasInitialValue = false;\n\n get defaultValue(): string {\n return this.getAttribute('value') ?? '';\n }\n\n set defaultValue(value: string) {\n this.setAttribute('value', value);\n }\n\n /** determine if component is in readonly/non-editable state */\n get readOnly(): boolean {\n return this.getAttribute('readonly') !== null;\n }\n\n set readOnly(value: boolean | unknown) {\n attachInternals(this);\n this.toggleAttribute('readonly', value as boolean);\n toggleState(this._internals, 'readonly', Boolean(value));\n this._requestUpdate();\n }\n\n /** determine if component is in disabled state */\n get disabled(): boolean {\n return this.getAttribute('disabled') !== null;\n }\n\n // unknown forces generation of get/set in type defs see https://github.com/microsoft/TypeScript/issues/58790\n set disabled(value: boolean | unknown) {\n attachInternals(this);\n this.toggleAttribute('disabled', value as boolean);\n this._internals.ariaDisabled = value ? 'true' : 'false';\n toggleState(this._internals, 'disabled', Boolean(value));\n this._requestUpdate();\n }\n\n /** determine if the component value requires input */\n get required(): boolean {\n return this.getAttribute('required') !== null;\n }\n\n set required(value: boolean | unknown) {\n this.toggleAttribute('required', value as boolean);\n toggleState(this._internals, 'required', Boolean(value));\n this.checkValidity();\n this._requestUpdate();\n }\n\n get pattern() {\n return this.getAttribute('pattern') ?? '';\n }\n\n set pattern(value: string) {\n value ? this.setAttribute('pattern', value) : this.removeAttribute('pattern');\n toggleState(this._internals, 'pattern', Boolean(value));\n this.checkValidity();\n this._requestUpdate();\n }\n\n get min(): number | null {\n return getNumberAttribute(this, 'min');\n }\n\n set min(value: number | null) {\n setNumberAttribute(this, 'min', value);\n toggleState(this._internals, 'min', value !== null);\n this._internals.ariaValueMin = value !== null ? `${value}` : null;\n this.checkValidity();\n this._requestUpdate();\n }\n\n get max(): number | null {\n return getNumberAttribute(this, 'max');\n }\n\n set max(value: number | null) {\n setNumberAttribute(this, 'max', value);\n toggleState(this._internals, 'max', value !== null);\n this._internals.ariaValueMax = value !== null ? `${value}` : null;\n this.checkValidity();\n this._requestUpdate();\n }\n\n get step(): number | null {\n return getNumberAttribute(this, 'step');\n }\n\n set step(value: number | null) {\n setNumberAttribute(this, 'step', value);\n toggleState(this._internals, 'step', value !== null);\n this.checkValidity();\n this._requestUpdate();\n }\n\n get minLength(): number {\n return this.hasAttribute('minlength') ? Number(this.getAttribute('minlength')) : -1;\n }\n\n set minLength(value: number) {\n setLengthAttribute(this, 'minlength', value);\n toggleState(this._internals, 'minlength', this.minLength !== -1);\n this.checkValidity();\n this._requestUpdate();\n }\n\n get maxLength(): number {\n return this.hasAttribute('maxlength') ? Number(this.getAttribute('maxlength')) : -1;\n }\n\n set maxLength(value: number) {\n setLengthAttribute(this, 'maxlength', value);\n toggleState(this._internals, 'maxlength', this.maxLength !== -1);\n this.checkValidity();\n this._requestUpdate();\n }\n\n /** name associated to parent form */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(value: string) {\n value ? this.setAttribute('name', value) : this.removeAttribute('name');\n this._updateFormState();\n this._requestUpdate();\n }\n\n /** get determine if component is in no validation state */\n get noValidate(): boolean {\n return this.getAttribute('novalidate') !== null || this._internals.form?.noValidate === true;\n }\n\n /** set determine if component is in no validation state */\n set noValidate(value: boolean | unknown) {\n this.toggleAttribute('novalidate', value as boolean);\n this._requestUpdate();\n }\n\n /** @internal */\n _value: T | undefined;\n\n /** value state of the component */\n set value(value: T | unknown) {\n this.updateValue(value as T);\n this._requestUpdate();\n }\n\n get value(): T | undefined {\n return this._value;\n }\n\n /** @protected */\n updateValue(value: T) {\n const previousValue = this._value;\n this._value = structuredClone(value);\n const valid = this.checkValidity();\n\n if (!valid && this._metadata.strict) {\n this._value = previousValue;\n console.error('FormControlError: (strict mode)', this.validationMessage);\n }\n\n if (!this.#hasInitialValue && !this.isConnected) {\n this._initialValue = structuredClone(this._value);\n this.#hasInitialValue = true;\n }\n\n this._updateFormState();\n }\n\n /** associated parent form */\n get form() {\n return this._internals.form;\n }\n\n /** determine if the component is a candidate for constraint checking */\n get willValidate() {\n return this._internals.willValidate;\n }\n\n /** validity state of the component */\n get validity() {\n return this._internals.validity;\n }\n\n /** validation message of the component */\n get validationMessage() {\n return this._internals.validationMessage;\n }\n\n /** stringified value of the component */\n get valueAsString() {\n return getValueAsString(this.value);\n }\n\n /** parsed number value of the component */\n get valueAsNumber(): number {\n return Number(this.value);\n }\n\n set valueAsNumber(value: number) {\n if (typeof this._value === 'number' && typeof value === 'number') {\n this.value = value as T;\n } else {\n console.warn(new FormControlError(this.localName, 'cannot set number value on non-number type').message);\n }\n }\n\n get type() {\n return this.localName;\n }\n\n get labels() {\n return this._internals.labels;\n }\n\n get composedLabel() {\n return Array.from(this.labels)\n .map(label => label.textContent)\n .join(' ')\n .trim();\n }\n\n /** @internal */\n get _metadata() {\n return (this.constructor as FormControl).metadata;\n }\n\n /** @internal */\n _internals = attachInternals(this);\n\n /** @internal */\n _initialValue: T | undefined;\n\n /** @internal */\n get _validators() {\n return this._metadata.validators ?? [];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(...args: any[]) {\n super(...args);\n this._initialValue = this.value;\n }\n\n connectedCallback() {\n attachInternals(this);\n if (super.connectedCallback) {\n super.connectedCallback();\n }\n\n this.tabIndex = 0;\n this.#syncFormControlStates();\n this._updateFormState();\n this.checkValidity();\n this.shadowRoot?.addEventListener('input', this._stopInternalPropagation);\n this.shadowRoot?.addEventListener('change', this._stopInternalPropagation);\n }\n\n disconnectedCallback() {\n if (super.disconnectedCallback) {\n super.disconnectedCallback();\n }\n\n this.shadowRoot?.removeEventListener('input', this._stopInternalPropagation);\n this.shadowRoot?.removeEventListener('change', this._stopInternalPropagation);\n }\n\n /**\n * @internal\n * Stop events that originated inside this component's own shadow tree so the\n * mixin can re-dispatch them semantically. Slotted light-DOM events traverse the\n * host's shadow root via slots and must continue bubbling.\n */\n _stopInternalPropagation = (event: Event) => {\n const origin = event.composedPath()[0];\n if (origin instanceof Node && this.shadowRoot?.contains(origin)) {\n event.stopPropagation();\n }\n };\n\n static get observedAttributes() {\n const attrs = super.observedAttributes ?? [];\n return attrs.concat([\n 'value',\n 'readonly',\n 'required',\n 'name',\n 'novalidate',\n 'disabled',\n 'pattern',\n 'min',\n 'max',\n 'step',\n 'minlength',\n 'maxlength'\n ]);\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (super.attributeChangedCallback) {\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n if (newValue === oldValue) {\n return;\n }\n\n this._handleAttributeChange(name, newValue);\n }\n\n /** @internal */\n _handleAttributeChange(name: string, newValue: string | null) {\n if (name === 'value') {\n this.#handleValueAttributeChange(newValue);\n return;\n }\n\n if (this.#handleBooleanAttributeChange(name, newValue)) {\n return;\n }\n\n if (this.#handleStringAttributeChange(name, newValue)) {\n return;\n }\n\n this.#handleNumberAttributeChange(name, newValue);\n }\n\n /** @protected */\n formResetCallback() {\n this.reset();\n }\n\n formDisabledCallback(disabled: boolean) {\n this.disabled = disabled;\n }\n\n /** @protected https://webkit.org/blog/13711/elementinternals-and-form-associated-custom-elements/*/\n formStateRestoreCallback(state: T, _reason: string) {\n this.value = state;\n this.checkValidity();\n }\n\n /** report validity of the component */\n reportValidity() {\n this.#updateValidity();\n return this._internals.reportValidity();\n }\n\n /** check validity of the component */\n checkValidity() {\n this.#updateValidity();\n return this._internals.checkValidity();\n }\n\n /** @protected */\n setValidity(validity: Partial<ValidityState>, message?: string) {\n this._internals.setValidity(validity, message);\n this.#syncValidityStates();\n }\n\n setCustomValidity(message: string) {\n this.#customValidityMessage = message;\n this.#updateValidity();\n }\n\n reset() {\n this.value = this.hasAttribute('value')\n ? parseValueSchema<T>(this.localName, this.defaultValue, this._metadata.valueSchema)\n : structuredClone(this._initialValue);\n this.#resetValidityStates();\n this.checkValidity();\n this.dispatchEvent(new Event('reset', { bubbles: true, cancelable: true, composed: true }));\n }\n\n #updateValidity() {\n if (this.noValidate) {\n this._internals.setValidity({});\n } else {\n this.#applyValidityResult(this.#getValidityResult());\n }\n\n this.#syncValidityStates();\n }\n\n #getValidityResult(): ValidatorResult {\n if (this.#customValidityMessage) {\n return invalid({ customError: true }, this.#customValidityMessage);\n }\n\n const nativeResult = this.#getNativeValidityResult();\n if (!nativeResult.validity.valid) {\n return nativeResult;\n }\n\n for (const validator of this._validators) {\n const result = validator(this.value, this as FormControlInstance);\n if (!result.validity.valid) {\n return result;\n }\n }\n\n return { validity: { valid: true }, message: '' };\n }\n\n #getNativeValidityResult(): ValidatorResult {\n if (this.required && isEmptyValue(this.value)) {\n return invalid({ valueMissing: true }, 'This field is required');\n }\n\n if (typeof this.value === 'string') {\n return getStringValidity({\n maxLength: this.maxLength,\n minLength: this.minLength,\n pattern: this.pattern,\n value: this.value\n });\n }\n\n if (typeof this.value === 'number') {\n return getNumberValidity({\n max: this.max,\n min: this.min,\n step: this.step,\n value: this.value\n });\n }\n\n return { validity: { valid: true }, message: '' };\n }\n\n #applyValidityResult(result: ValidatorResult) {\n if (result.validity.valid) {\n this._internals.setValidity({});\n return;\n }\n\n this._internals.setValidity(\n result.validity,\n result.message,\n (this.shadowRoot?.activeElement as HTMLElement) ?? undefined\n );\n }\n\n #syncFormControlStates() {\n toggleState(this._internals, 'disabled', this.disabled);\n toggleState(this._internals, 'readonly', this.readOnly);\n toggleState(this._internals, 'required', this.required);\n toggleState(this._internals, 'pattern', Boolean(this.pattern));\n toggleState(this._internals, 'min', this.min !== null);\n toggleState(this._internals, 'max', this.max !== null);\n toggleState(this._internals, 'step', this.step !== null);\n toggleState(this._internals, 'minlength', this.minLength !== -1);\n toggleState(this._internals, 'maxlength', this.maxLength !== -1);\n }\n\n #syncValidityStates() {\n toggleState(this._internals, 'valid', this.validity.valid);\n toggleState(this._internals, 'invalid', !this.validity.valid);\n }\n\n #resetValidityStates() {\n this._internals.states.delete('valid');\n this._internals.states.delete('invalid');\n }\n\n #handleValueAttributeChange(newValue: string | null) {\n this.value =\n newValue === null\n ? (undefined as unknown as T)\n : parseValueSchema<T>(this.localName, newValue, this._metadata.valueSchema);\n this._initialValue = structuredClone(this.value);\n this.#hasInitialValue = true;\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'readonly') {\n this.readOnly = newValue !== null;\n return true;\n }\n\n if (name === 'disabled') {\n this.disabled = newValue !== null;\n return true;\n }\n\n if (name === 'required') {\n this.required = newValue !== null;\n return true;\n }\n\n if (name === 'novalidate') {\n this.noValidate = newValue !== null;\n this.checkValidity();\n return true;\n }\n\n return false;\n }\n\n #handleStringAttributeChange(name: string, newValue: string | null) {\n if (name === 'name') {\n this.name = newValue ?? '';\n return true;\n }\n\n if (name === 'pattern') {\n this.pattern = newValue ?? '';\n return true;\n }\n\n return false;\n }\n\n #handleNumberAttributeChange(name: string, newValue: string | null) {\n if (name === 'min') {\n this.min = getNumberValue(newValue);\n } else if (name === 'max') {\n this.max = getNumberValue(newValue);\n } else if (name === 'step') {\n this.step = getNumberValue(newValue);\n } else if (name === 'minlength') {\n this.minLength = getLengthValue(newValue);\n } else if (name === 'maxlength') {\n this.maxLength = getLengthValue(newValue);\n }\n }\n\n /** @protected */\n dispatchInputEvent() {\n this.dispatchEvent(\n new InputEvent('input', { bubbles: true, cancelable: true, composed: true, data: this.valueAsString })\n );\n }\n\n /** @protected */\n dispatchChangeEvent() {\n this.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));\n }\n\n /** @protected */\n dispatchUpdateEvent(type: 'input' | 'change') {\n if (type === 'input') {\n this.dispatchInputEvent();\n } else if (type === 'change') {\n this.dispatchChangeEvent();\n }\n }\n\n /** @internal */\n _updateFormState() {\n if (!this.name) {\n this._internals.setFormValue(null);\n } else if (typeof this.value === 'number' || typeof this.value === 'boolean') {\n this._internals.setFormValue(`${this.value}`);\n } else if (isObjectLiteral(this.value)) {\n const formData = new FormData();\n Object.entries(this.value as Record<string, unknown>)\n .filter(([key]) => key !== 'value')\n .forEach(([key, value]) => {\n formData.set(`${this.name}-${key}`, `${value}`);\n });\n this._internals.setFormValue(formData);\n } else if (Array.isArray(this.value)) {\n const formData = new FormData();\n this.value.forEach(i => formData.append(`${this.name}`, i));\n this._internals.setFormValue(formData);\n } else {\n this._internals.setFormValue(this.value as null | string | File | FormData);\n }\n }\n\n /** @internal */\n _requestUpdate() {\n if (this.requestUpdate) {\n this.requestUpdate();\n }\n }\n } as unknown as FormControlMixinReturn<TBase, T>;\n}\n\nfunction getValueAsString(value: FormControlValue | undefined) {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (isStringifiablePrimitive(value)) {\n return `${value}`;\n }\n\n if (isFileValue(value)) {\n return value.name;\n }\n\n if (Array.isArray(value) || isObjectLiteral(value)) {\n return JSON.stringify(value);\n }\n\n return JSON.stringify(value) ?? '';\n}\n\nfunction isStringifiablePrimitive(value: FormControlValue): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n\nfunction isFileValue(value: FormControlValue): value is File {\n return typeof File !== 'undefined' && value instanceof File;\n}\n\nfunction getNumberAttribute(element: HTMLElement, name: string) {\n return getNumberValue(element.getAttribute(name));\n}\n\nfunction getNumberValue(value: string | null) {\n if (value === null || value === '') {\n return null;\n }\n\n const number = Number(value);\n return Number.isFinite(number) ? number : null;\n}\n\nfunction setNumberAttribute(element: HTMLElement, name: string, value: number | null) {\n if (value === null || !Number.isFinite(value)) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, `${value}`);\n }\n}\n\nfunction getLengthValue(value: string | null) {\n const length = getNumberValue(value);\n return length === null || length < 0 ? -1 : length;\n}\n\nfunction setLengthAttribute(element: HTMLElement, name: string, value: number) {\n if (value < 0 || !Number.isFinite(value)) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, `${value}`);\n }\n}\n\nfunction isEmptyValue(value: FormControlValue | undefined) {\n return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);\n}\n\ninterface StringValidityOptions {\n value: string;\n pattern: string;\n minLength: number;\n maxLength: number;\n}\n\nfunction getStringValidity({ value, pattern, minLength, maxLength }: StringValidityOptions): ValidatorResult {\n if (pattern && !matchesPattern(value, pattern)) {\n return invalid({ patternMismatch: true }, 'pattern mismatch');\n }\n\n if (minLength !== -1 && value.length < minLength) {\n return invalid({ tooShort: true }, 'value too short');\n }\n\n if (maxLength !== -1 && value.length > maxLength) {\n return invalid({ tooLong: true }, 'value too long');\n }\n\n return { validity: { valid: true }, message: '' };\n}\n\ninterface NumberValidityOptions {\n value: number;\n min: number | null;\n max: number | null;\n step: number | null;\n}\n\nfunction getNumberValidity({ value, min, max, step }: NumberValidityOptions): ValidatorResult {\n if (Number.isNaN(value)) {\n return invalid({ badInput: true }, 'bad input');\n }\n\n if (min !== null && value < min) {\n return invalid({ rangeUnderflow: true }, 'value too low');\n }\n\n if (max !== null && value > max) {\n return invalid({ rangeOverflow: true }, 'value too high');\n }\n\n if (step !== null && step > 0 && hasStepMismatch(value, min ?? 0, step)) {\n return invalid({ stepMismatch: true }, 'step mismatch');\n }\n\n return { validity: { valid: true }, message: '' };\n}\n\nfunction matchesPattern(value: string, pattern: string) {\n try {\n return new RegExp(`^(?:${pattern})$`).test(value);\n } catch {\n // Pattern attributes are consumer-provided regular expressions.\n return true;\n }\n}\n\nfunction hasStepMismatch(value: number, base: number, step: number) {\n const quotient = (value - base) / step;\n return Math.abs(Math.round(quotient) - quotient) > Number.EPSILON;\n}\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidatorResult {\n return { validity: { ...validity, valid: false }, message };\n}\n"],"mappings":";;;;AAwOA,SAAgB,EACd,GACkC;CAClC,OAAO,cAA8B,EAAW;;yBACtB;;EAIxB;EAEA;EAEA,IAAI,eAAuB;GACzB,OAAO,KAAK,aAAa,OAAO,KAAK;EACvC;EAEA,IAAI,aAAa,GAAe;GAC9B,KAAK,aAAa,SAAS,CAAK;EAClC;EAGA,IAAI,WAAoB;GACtB,OAAO,KAAK,a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AgB,GAAO,KAAO,GAAG,CAAI,IAC7D,EAAQ,EAAE,cAAc,GAAK,GAAG,eAAe,IAGjD;EAAE,UAAU,EAAE,OAAO,GAAK;EAAG,SAAS;CAAG;AAClD;AAEA,SAAS,EAAe,GAAe,GAAiB;CACtD,IAAI;EACF,OAAW,OAAO,OAAO,EAAQ,GAAG,EAAE,KAAK,CAAK;CAClD,QAAQ;EAEN,OAAO;CACT;AACF;AAEA,SAAS,EAAgB,GAAe,GAAc,GAAc;CAClE,IAAM,KAAY,IAAQ,KAAQ;CAClC,OAAO,KAAK,IAAI,KAAK,MAAM,CAAQ,IAAI,CAAQ;AACjD;AAEA,SAAS,EAAQ,GAAkC,GAAkC;CACnF,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU,OAAO;EAAM;EAAG;CAAQ;AAC5D"}
@@ -1,4 +1,4 @@
1
- import { FormControl, ValidatorResult } from '../internal/types.js';
1
+ import { FormControlInstance, ValidatorResult } from '../internal/types.js';
2
2
  /**
3
3
  * Given a json schema, check the value against the schema
4
4
  * JSON Schema follows the OpenAI JSON Schema for structured outputs
@@ -14,5 +14,5 @@ import { FormControl, ValidatorResult } from '../internal/types.js';
14
14
  * - Array
15
15
  * - Enum
16
16
  */
17
- export declare function valueSchemaValidator(value: unknown, element: FormControl): ValidatorResult;
18
- export declare function requiredValidator(value: unknown, element: FormControl): ValidatorResult;
17
+ export declare function valueSchemaValidator(value: unknown, element: FormControlInstance): ValidatorResult;
18
+ export declare function requiredValidator(value: unknown, element: FormControlInstance): ValidatorResult;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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, 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: FormControl): ValidatorResult {\n const metadata = (element as any).constructor.metadata; // eslint-disable-line @typescript-eslint/no-explicit-any\n return validateSchema(metadata.valueSchema, value);\n}\n\nexport function requiredValidator(value: unknown, element: FormControl): ValidatorResult {\n if (\n (element as unknown as { required: boolean }).required &&\n (value === undefined || value === null || value === '')\n ) {\n return { validity: { valueMissing: true, valid: false }, message: 'This field is required' };\n }\n return { validity: { valid: true }, message: '' };\n}\n"],"mappings":";;AAqBA,SAAgB,EAAqB,GAAgB,GAAuC;CAC1F,IAAM,IAAY,EAAgB,YAAY;CAC9C,OAAO,EAAe,EAAS,aAAa,CAAK;AACnD;AAEA,SAAgB,EAAkB,GAAgB,GAAuC;CAOvF,OALG,EAA6C,aAC7C,KAAiC,QAAQ,MAAU,MAE7C;EAAE,UAAU;GAAE,cAAc;GAAM,OAAO;EAAM;EAAG,SAAS;CAAyB,IAEtF;EAAE,UAAU,EAAE,OAAO,GAAK;EAAG,SAAS;CAAG;AAClD"}
1
+ {"version":3,"file":"index.js","names":[],"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":";;AAqBA,SAAgB,EAAqB,GAAgB,GAA+C;CAClG,IAAM,IAAY,EAAQ,YAA4B;CACtD,OAAO,EAAe,EAAS,aAAa,CAAK;AACnD;AAEA,SAAgB,EAAkB,GAAgB,GAA+C;CAI/F,OAHI,EAAQ,aAAa,KAAiC,QAAQ,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.0",
3
+ "version": "2.0.1",
4
4
  "release": {
5
5
  "extends": "../../release.config.js"
6
6
  },
@@ -88,11 +88,11 @@
88
88
  "typescript": "6.0.3",
89
89
  "vite": "8.0.14",
90
90
  "vitest": "4.1.7",
91
+ "@nvidia-elements/styles": "2.0.2",
91
92
  "@internals/eslint": "0.0.0",
92
- "@internals/vite": "0.0.0",
93
93
  "@internals/testing": "0.0.0",
94
- "@nvidia-elements/styles": "0.0.10",
95
- "@nvidia-elements/lint": "0.4.0"
94
+ "@internals/vite": "0.0.0",
95
+ "@nvidia-elements/lint": "2.0.1"
96
96
  },
97
97
  "wireit": {
98
98
  "dev": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-native-button.controller.js","names":["#defaultType","#setButtonType","#removeNativeButtonBehavior","#onNativeButtonClick","#onNativeButtonKeyup","#removeSubmitter","#requestSubmit","#createSubmitter","#submitterForm","#onSubmit","#submitter"],"sources":["../../../src/internal/controllers/type-native-button.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { onKeys, stopEvent } from '../utils.js';\nimport type { ButtonType } from '../../mixins/button.types.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype NativeButtonBehaviorHost = ReactiveElement & {\n disabled: boolean;\n form: HTMLFormElement | null | string;\n name?: string;\n readOnly: boolean;\n type?: ButtonType;\n value?: string;\n};\n\nexport class TypeNativeButtonController<T extends NativeButtonBehaviorHost> implements ReactiveController {\n #defaultType: ButtonType | undefined;\n #submitter: HTMLButtonElement | undefined;\n #submitterForm: HTMLFormElement | undefined;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get defaultType() {\n return this.#defaultType;\n }\n\n hostUpdated() {\n this.#setButtonType();\n this.#removeNativeButtonBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#onNativeButtonClick);\n this.host.addEventListener('keyup', this.#onNativeButtonKeyup);\n }\n }\n\n hostDisconnected() {\n this.#removeNativeButtonBehavior();\n this.#removeSubmitter();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.form instanceof HTMLFormElement) {\n this.#defaultType = 'submit';\n }\n }\n\n #removeNativeButtonBehavior() {\n this.host.removeEventListener('click', this.#onNativeButtonClick);\n this.host.removeEventListener('keyup', this.#onNativeButtonKeyup);\n }\n\n #onNativeButtonKeyup = (event: KeyboardEvent) => {\n onKeys(['Enter', 'Space'], event, () => this.host.click());\n };\n\n #onNativeButtonClick = (event: Event) => {\n if (this.host.disabled) {\n stopEvent(event);\n return;\n }\n\n if (this.host.type === 'submit' && this.host.form instanceof HTMLFormElement) {\n this.#requestSubmit(this.host.form);\n } else if (this.host.type === 'reset' && this.host.form instanceof HTMLFormElement) {\n this.host.form.reset();\n }\n };\n\n #requestSubmit(form: HTMLFormElement) {\n this.#removeSubmitter();\n this.#createSubmitter();\n this.#submitterForm = form;\n form.addEventListener('submit', this.#onSubmit, { once: true });\n this.#submitter?.remove();\n form.appendChild(this.#submitter!);\n form.requestSubmit(this.#submitter);\n }\n\n #onSubmit = () => {\n const submitter = this.#submitter;\n this.#submitterForm = undefined;\n setTimeout(() => {\n submitter?.remove();\n if (this.#submitter === submitter) {\n this.#submitter = undefined;\n }\n }, 0);\n };\n\n #createSubmitter() {\n if (!this.#submitter) {\n this.#submitter = globalThis.document.createElement('button');\n this.#submitter.type = 'submit';\n this.#submitter.style.display = 'none';\n }\n\n this.#submitter.name = this.host.name ?? '';\n this.#submitter.value = this.host.value ?? '';\n }\n\n #removeSubmitter() {\n this.#submitterForm?.removeEventListener('submit', this.#onSubmit);\n this.#submitterForm = undefined;\n this.#submitter?.remove();\n this.#submitter = undefined;\n }\n}\n"],"mappings":";;AAgBA,IAAa,IAAb,MAA0G;CACxG;CACA;CACA;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,cAAc;EAChB,OAAO,KAAKA;CACd;CAEA,cAAc;EAGZ,AAFA,KAAKC,GAAe,GACpB,KAAKC,GAA4B,GAC7B,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,aACpC,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAoB,GAC7D,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAoB;CAEjE;CAEA,mBAAmB;EAEjB,AADA,KAAKF,GAA4B,GACjC,KAAKG,GAAiB;CACxB;CAEA,KAAiB;EACf,AAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAAa,MAAM,KAAK,KAAK,KAAK,gBAAgB,oBAClF,KAAKL,KAAe;CAExB;CAEA,KAA8B;EAE5B,AADA,KAAK,KAAK,oBAAoB,SAAS,KAAKG,EAAoB,GAChE,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAoB;CACl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