@nvidia-elements/forms 2.0.6 → 2.0.7

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +8 -0
  3. package/dist/custom-elements.json +10 -10
  4. package/dist/examples/csv.examples.js.map +1 -1
  5. package/dist/examples/light.examples.js.map +1 -1
  6. package/dist/examples/light.examples.json +2 -2
  7. package/dist/examples/simple.examples.js.map +1 -1
  8. package/dist/examples/simple.examples.json +2 -2
  9. package/dist/examples/visualization.examples.js.map +1 -1
  10. package/dist/examples/visualization.examples.json +2 -2
  11. package/dist/index.js +1 -1
  12. package/dist/internal/controllers/state-active.controller.js.map +1 -1
  13. package/dist/internal/controllers/state-current.controller.js +1 -1
  14. package/dist/internal/controllers/state-current.controller.js.map +1 -1
  15. package/dist/internal/controllers/state-disabled.controller.d.ts +1 -1
  16. package/dist/internal/controllers/state-disabled.controller.js.map +1 -1
  17. package/dist/internal/controllers/state-selected.controller.js.map +1 -1
  18. package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
  19. package/dist/internal/controllers/type-button.controller.js.map +1 -1
  20. package/dist/internal/controllers/type-command.controller.js.map +1 -1
  21. package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
  22. package/dist/internal/controllers/type-popover-trigger.controller.d.ts +1 -1
  23. package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
  24. package/dist/internal/controllers/type-submit.controller.d.ts +1 -1
  25. package/dist/internal/controllers/type-submit.controller.js.map +1 -1
  26. package/dist/{mixins/button.types.d.ts → internal/types/button.d.ts} +4 -1
  27. package/dist/mixins/button.d.ts +2 -2
  28. package/dist/mixins/button.js +2 -2
  29. package/dist/mixins/button.js.map +1 -1
  30. package/dist/mixins/checkbox.d.ts +2 -0
  31. package/dist/mixins/checkbox.js +4 -4
  32. package/dist/mixins/checkbox.js.map +1 -1
  33. package/dist/mixins/control.js +3 -3
  34. package/dist/mixins/control.js.map +1 -1
  35. package/dist/mixins/select.d.ts +4 -1
  36. package/dist/mixins/select.js +1 -1
  37. package/dist/mixins/select.js.map +1 -1
  38. package/dist/mixins/slider.d.ts +8 -3
  39. package/dist/mixins/slider.js +1 -1
  40. package/dist/mixins/slider.js.map +1 -1
  41. package/package.json +40 -14
@@ -1 +1 @@
1
- {"version":3,"file":"type-interest-invoker.controller.js","names":["#onInterest","#onLoseInterest","#dispatchInterestEvent","#getInterestForElement","#getExplicitInterestForElement","#getHintPopoverTarget","#inferredInterestForElement","#getElementById"],"sources":["../../../src/internal/controllers/type-interest-invoker.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype InterestInvokerHost = ReactiveElement & {\n interestForElement: HTMLElement | null;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypeInterestInvokerController<T extends InterestInvokerHost> implements ReactiveController {\n #inferredInterestForElement: HTMLElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('mouseenter', this.#onInterest);\n this.host.addEventListener('mouseleave', this.#onLoseInterest);\n this.host.addEventListener('focus', this.#onInterest);\n this.host.addEventListener('blur', this.#onLoseInterest);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('mouseenter', this.#onInterest);\n this.host.removeEventListener('mouseleave', this.#onLoseInterest);\n this.host.removeEventListener('focus', this.#onInterest);\n this.host.removeEventListener('blur', this.#onLoseInterest);\n }\n\n #onInterest = (event: Event) => {\n if (event.type === 'focus' && !this.host.matches(':focus-visible')) {\n return;\n }\n\n if (this.host.popoverTargetElement?.matches(':popover-open')) {\n return;\n }\n\n this.#dispatchInterestEvent('interest');\n };\n\n #onLoseInterest = () => this.#dispatchInterestEvent('loseinterest');\n\n #dispatchInterestEvent(type: 'interest' | 'loseinterest') {\n const target = this.#getInterestForElement();\n if (!target) {\n return;\n }\n\n const event = new Event(type, { cancelable: true }) as InterestEvent;\n event.source = this.host;\n target.dispatchEvent(event);\n }\n\n #getInterestForElement() {\n const explicitTarget = this.#getExplicitInterestForElement();\n if (explicitTarget !== undefined) {\n return explicitTarget;\n }\n\n const inferredTarget = this.#getHintPopoverTarget();\n const previousTarget = this.#inferredInterestForElement;\n this.#inferredInterestForElement = inferredTarget;\n if (inferredTarget && this.host.interestForElement !== inferredTarget) {\n this.host.interestForElement = inferredTarget;\n } else if (!inferredTarget && previousTarget && this.host.interestForElement === previousTarget) {\n this.host.interestForElement = null;\n }\n return inferredTarget;\n }\n\n #getExplicitInterestForElement(): HTMLElement | null | undefined {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef) {\n this.#inferredInterestForElement = null;\n return this.#getElementById(interestForIdRef);\n }\n\n const interestForElement = this.host.interestForElement;\n if (!interestForElement || interestForElement === this.#inferredInterestForElement) {\n return undefined;\n }\n\n this.#inferredInterestForElement = null;\n return interestForElement;\n }\n\n #getHintPopoverTarget() {\n const popoverTarget = this.host.popoverTargetElement;\n if (popoverTarget instanceof HTMLElement && popoverTarget.popover === 'hint') {\n return popoverTarget;\n }\n\n const target = this.#getElementById(this.host.getAttribute('popovertarget'));\n return target instanceof HTMLElement && target.popover === 'hint' ? target : null;\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.host.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAwG;CACtG,KAAkD;CAElD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAId,AAHA,KAAK,KAAK,iBAAiB,cAAc,KAAKA,EAAW,GACzD,KAAK,KAAK,iBAAiB,cAAc,KAAKC,EA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8B,MAC5B;CACT;CAEA,KAAwB;EACtB,IAAM,IAAgB,KAAK,KAAK;EAChC,IAAI,aAAyB,eAAe,EAAc,YAAY,QACpE,OAAO;EAGT,IAAM,IAAS,KAAKC,GAAgB,KAAK,KAAK,aAAa,eAAe,CAAC;EAC3E,OAAO,aAAkB,eAAe,EAAO,YAAY,SAAS,IAAS;CAC/E;CAEA,GAAgB,GAAmB;EACjC,OAAO,IAAM,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAAK,MAAW,EAAQ,OAAO,CAAE,KAAK,OAAQ;CAC1G;AACF"}
1
+ {"version":3,"file":"type-interest-invoker.controller.js","names":[],"sources":["../../../src/internal/controllers/type-interest-invoker.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype InterestInvokerHost = ReactiveElement & {\n interestForElement: HTMLElement | null;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypeInterestInvokerController<T extends InterestInvokerHost> implements ReactiveController {\n #inferredInterestForElement: HTMLElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('mouseenter', this.#onInterest);\n this.host.addEventListener('mouseleave', this.#onLoseInterest);\n this.host.addEventListener('focus', this.#onInterest);\n this.host.addEventListener('blur', this.#onLoseInterest);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('mouseenter', this.#onInterest);\n this.host.removeEventListener('mouseleave', this.#onLoseInterest);\n this.host.removeEventListener('focus', this.#onInterest);\n this.host.removeEventListener('blur', this.#onLoseInterest);\n }\n\n #onInterest = (event: Event) => {\n if (event.type === 'focus' && !this.host.matches(':focus-visible')) {\n return;\n }\n\n if (this.host.popoverTargetElement?.matches(':popover-open')) {\n return;\n }\n\n this.#dispatchInterestEvent('interest');\n };\n\n #onLoseInterest = () => this.#dispatchInterestEvent('loseinterest');\n\n #dispatchInterestEvent(type: 'interest' | 'loseinterest') {\n const target = this.#getInterestForElement();\n if (!target) {\n return;\n }\n\n const event = new Event(type, { cancelable: true }) as InterestEvent;\n event.source = this.host;\n target.dispatchEvent(event);\n }\n\n #getInterestForElement() {\n const explicitTarget = this.#getExplicitInterestForElement();\n if (explicitTarget !== undefined) {\n return explicitTarget;\n }\n\n const inferredTarget = this.#getHintPopoverTarget();\n const previousTarget = this.#inferredInterestForElement;\n this.#inferredInterestForElement = inferredTarget;\n if (inferredTarget && this.host.interestForElement !== inferredTarget) {\n this.host.interestForElement = inferredTarget;\n } else if (!inferredTarget && previousTarget && this.host.interestForElement === previousTarget) {\n this.host.interestForElement = null;\n }\n return inferredTarget;\n }\n\n #getExplicitInterestForElement(): HTMLElement | null | undefined {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef) {\n this.#inferredInterestForElement = null;\n return this.#getElementById(interestForIdRef);\n }\n\n const interestForElement = this.host.interestForElement;\n if (!interestForElement || interestForElement === this.#inferredInterestForElement) {\n return undefined;\n }\n\n this.#inferredInterestForElement = null;\n return interestForElement;\n }\n\n #getHintPopoverTarget() {\n const popoverTarget = this.host.popoverTargetElement;\n if (popoverTarget instanceof HTMLElement && popoverTarget.popover === 'hint') {\n return popoverTarget;\n }\n\n const target = this.#getElementById(this.host.getAttribute('popovertarget'));\n return target instanceof HTMLElement && target.popover === 'hint' ? target : null;\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.host.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAwG;CACtG,KAAkD;CAElD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAId,AAHA,KAAK,KAAK,iBAAiB,cAA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MAAuB,KAAK,KAKvD,OADA,KAAK,KAA8B,MAC5B;CACT;CAEA,KAAwB;EACtB,IAAM,IAAgB,KAAK,KAAK;EAChC,IAAI,aAAyB,eAAe,EAAc,YAAY,QACpE,OAAO;EAGT,IAAM,IAAS,KAAK,GAAgB,KAAK,KAAK,aAAa,eAAe,CAAC;EAC3E,OAAO,aAAkB,eAAe,EAAO,YAAY,SAAS,IAAS;CAC/E;CAEA,GAAgB,GAAmB;EACjC,OAAO,IAAM,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAAK,MAAW,EAAQ,OAAO,CAAE,KAAK,OAAQ;CAC1G;AACF"}
@@ -1,4 +1,4 @@
1
- import type { PopoverTargetAction } from '../../mixins/button.types.js';
1
+ import type { PopoverTargetAction } from '../types/button.js';
2
2
  import type { ReactiveController, ReactiveElement } from './types.js';
3
3
  type PopoverTriggerHost = ReactiveElement & {
4
4
  disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"type-popover-trigger.controller.js","names":["#onClick","#resolvedPopoverTarget","#resolvePopoverTarget","#invokePopover","#handoverInterest","#getPopoverSource"],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../../mixins/button.types.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#onClick);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#onClick);\n }\n\n #resolvedPopoverTarget: HTMLElement | null | undefined;\n\n #resolvePopoverTarget() {\n const popoverTargetElement = this.host.popoverTargetElement;\n const controllerResolvedTarget = popoverTargetElement === this.#resolvedPopoverTarget;\n\n if (!this.host.getAttribute('popovertarget')) {\n this.#resolvedPopoverTarget = undefined;\n if (controllerResolvedTarget) {\n this.host.popoverTargetElement = null;\n return null;\n }\n\n return popoverTargetElement;\n }\n\n if (popoverTargetElement && !controllerResolvedTarget) {\n return popoverTargetElement;\n }\n\n const resolvedPopoverTarget =\n getFlattenedDOMTree(this.host.getRootNode()).find(\n element => element.id === this.host.getAttribute('popovertarget')\n ) ?? null;\n if (resolvedPopoverTarget !== popoverTargetElement) {\n this.host.popoverTargetElement = resolvedPopoverTarget;\n }\n this.#resolvedPopoverTarget = resolvedPopoverTarget;\n\n return resolvedPopoverTarget;\n }\n\n #onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || this.host.disabled) {\n return;\n }\n\n const popoverTargetElement = this.#resolvePopoverTarget();\n if (!popoverTargetElement) {\n return;\n }\n\n if (this.#invokePopover(popoverTargetElement)) {\n this.#handoverInterest();\n }\n };\n\n #getPopoverSource(popoverTargetElement: HTMLElement) {\n if ((popoverTargetElement as PopoverAnchorElement).anchor) {\n return getHostAnchor(popoverTargetElement as PopoverAnchorElement);\n }\n\n return this.host as HTMLElement;\n }\n\n #invokePopover(popoverTargetElement: HTMLElement) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n return false;\n }\n\n const source = this.#getPopoverSource(popoverTargetElement);\n if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n\n return popoverTargetElement.matches(':popover-open');\n }\n\n #handoverInterest() {\n if (this.host.interestForElement) {\n const loseInterest = new Event('loseinterest', { cancelable: true }) as InterestEvent;\n loseInterest.source =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Q,eAAe;CACrD;CAEA,KAAoB;EAClB,IAAI,KAAK,KAAK,oBAAoB;GAChC,IAAM,IAAe,IAAI,MAAM,gBAAgB,EAAE,YAAY,GAAK,CAAC;GAEnE,AADA,EAAa,SAAS,KAAK,MAC3B,KAAK,KAAK,mBAAmB,cAAc,CAAY;EACzD;CACF;AACF"}
1
+ {"version":3,"file":"type-popover-trigger.controller.js","names":[],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../types/button.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#onClick);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#onClick);\n }\n\n #resolvedPopoverTarget: HTMLElement | null | undefined;\n\n #resolvePopoverTarget() {\n const popoverTargetElement = this.host.popoverTargetElement;\n const controllerResolvedTarget = popoverTargetElement === this.#resolvedPopoverTarget;\n\n if (!this.host.getAttribute('popovertarget')) {\n this.#resolvedPopoverTarget = undefined;\n if (controllerResolvedTarget) {\n this.host.popoverTargetElement = null;\n return null;\n }\n\n return popoverTargetElement;\n }\n\n if (popoverTargetElement && !controllerResolvedTarget) {\n return popoverTargetElement;\n }\n\n const resolvedPopoverTarget =\n getFlattenedDOMTree(this.host.getRootNode()).find(\n element => element.id === this.host.getAttribute('popovertarget')\n ) ?? null;\n if (resolvedPopoverTarget !== popoverTargetElement) {\n this.host.popoverTargetElement = resolvedPopoverTarget;\n }\n this.#resolvedPopoverTarget = resolvedPopoverTarget;\n\n return resolvedPopoverTarget;\n }\n\n #onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || this.host.disabled) {\n return;\n }\n\n const popoverTargetElement = this.#resolvePopoverTarget();\n if (!popoverTargetElement) {\n return;\n }\n\n if (this.#invokePopover(popoverTargetElement)) {\n this.#handoverInterest();\n }\n };\n\n #getPopoverSource(popoverTargetElement: HTMLElement) {\n if ((popoverTargetElement as PopoverAnchorElement).anchor) {\n return getHostAnchor(popoverTargetElement as PopoverAnchorElement);\n }\n\n return this.host as HTMLElement;\n }\n\n #invokePopover(popoverTargetElement: HTMLElement) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n return false;\n }\n\n const source = this.#getPopoverSource(popoverTargetElement);\n if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n\n return popoverTargetElement.matches(':popover-open');\n }\n\n #handoverInterest() {\n if (this.host.interestForElement) {\n const loseInterest = new Event('loseinterest', { cancelable: true }) as InterestEvent;\n loseInterest.source = this.host;\n this.host.interestForElement.dispatchEvent(loseInterest);\n }\n }\n}\n"],"mappings":";;AAiBA,IAAa,IAAb,MAAsG;CACpG,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,KAAK,KAAK,iBAAiB,SAAS,KAAK,EAAQ;CACnD;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAK,EAAQ;CACtD;CAEA;CAEA,KAAwB;EACtB,IAAM,IAAuB,KAAK,KAAK,sBACjC,IAA2B,MAAyB,KAAK;EAE/D,IAAI,CAAC,KAAK,KAAK,aAAa,eAAe,GAOzC,OANA,KAAK,KAAyB,KAAA,GAC1B,KACF,KAAK,KAAK,uBAAuB,MAC1B,QAGF;EAGT,IAAI,KAAwB,CAAC,GAC3B,OAAO;EAGT,IAAM,IACJ,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAC3C,MAAW,EAAQ,OAAO,KAAK,KAAK,aAAa,eAAe,CAClE,KAAK;EAMP,OALI,MAA0B,MAC5B,KAAK,KAAK,uBAAuB,IAEnC,KAAK,KAAyB,GAEvB;CACT;CAEA,MAAY,MAAsB;EAChC,IAAI,EAAM,oBAAoB,KAAK,KAAK,UACtC;EAGF,IAAM,IAAuB,KAAK,GAAsB;EACnD,KAID,KAAK,GAAe,CAAoB,KAC1C,KAAK,GAAkB;CAE3B;CAEA,GAAkB,GAAmC;EAKnD,OAJK,EAA8C,SAC1C,EAAc,CAA4C,IAG5D,KAAK;CACd;CAEA,GAAe,GAAmC;EAChD,IAAI,KAAK,KAAK,wBAAwB,QAEpC,OADA,EAAqB,YAAY,GAC1B;EAGT,IAAM,IAAS,KAAK,GAAkB,CAAoB;EAO1D,OANI,KAAK,KAAK,wBAAwB,SACpC,EAAqB,YAAY,EAAE,UAAO,CAAC,IAE3C,EAAqB,cAAc,EAAE,UAAO,CAAC,GAGxC,EAAqB,QAAQ,eAAe;CACrD;CAEA,KAAoB;EAClB,IAAI,KAAK,KAAK,oBAAoB;GAChC,IAAM,IAAe,IAAI,MAAM,gBAAgB,EAAE,YAAY,GAAK,CAAC;GAEnE,AADA,EAAa,SAAS,KAAK,MAC3B,KAAK,KAAK,mBAAmB,cAAc,CAAY;EACzD;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import type { ButtonType } from '../../mixins/button.types.js';
1
+ import type { ButtonType } from '../types/button.js';
2
2
  import type { ReactiveController, ReactiveElement } from './types.js';
3
3
  type SubmitHost = ReactiveElement & {
4
4
  disabled: boolean;
@@ -1 +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,aAAa,MAAM,KAAK,KAAK,KAAK,gBAAgB,oBAClF,KAAKL,KAAe;CAExB;CAEA,KAAwB;EAEtB,AADA,KAAK,KAAK,oBAAoB,SAAS,KAAKG,EAAc,GAC1D,KAAK,KA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ller.js","names":[],"sources":["../../../src/internal/controllers/type-submit.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { onKeys, stopEvent } from '../utils.js';\nimport type { ButtonType } from '../types/button.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype SubmitHost = ReactiveElement & {\n disabled: boolean;\n form: HTMLFormElement | null | string;\n name?: string;\n readOnly: boolean;\n type?: ButtonType;\n value?: string;\n};\n\nexport class TypeSubmitController<T extends SubmitHost> implements ReactiveController {\n #defaultType: ButtonType | undefined;\n #submitter: HTMLButtonElement | undefined;\n #submitterForm: HTMLFormElement | undefined;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get defaultType() {\n return this.#defaultType;\n }\n\n hostUpdated() {\n this.#setButtonType();\n this.#removeSubmitBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.host.addEventListener('click', this.#onSubmitClick);\n this.host.addEventListener('keyup', this.#onSubmitKeyup);\n }\n }\n\n hostDisconnected() {\n this.#removeSubmitBehavior();\n this.#removeSubmitter();\n }\n\n #setButtonType() {\n if (!this.host.type && !this.host.hasAttribute('type') && this.host.form instanceof HTMLFormElement) {\n this.#defaultType = 'submit';\n }\n }\n\n #removeSubmitBehavior() {\n this.host.removeEventListener('click', this.#onSubmitClick);\n this.host.removeEventListener('keyup', this.#onSubmitKeyup);\n }\n\n #onSubmitKeyup = (event: KeyboardEvent) => {\n 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,KAAK;CACd;CAEA,cAAc;EAGZ,AAFA,KAAK,GAAe,GACpB,KAAK,GAAsB,GACvB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,aACpC,KAAK,KAAK,iBAAiB,SAAS,KAAK,EAAc,GACvD,KAAK,KAAK,iBAAiB,SAAS,KAAK,EAAc;CAE3D;CAEA,mBAAmB;EAEjB,AADA,KAAK,GAAsB,GAC3B,KAAK,GAAiB;CACxB;CAEA,KAAiB;EACf,AAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,KAAK,aAAa,MAAM,KAAK,KAAK,KAAK,gBAAgB,oBAClF,KAAK,KAAe;CAExB;CAEA,KAAwB;EAEtB,AADA,KAAK,KAAK,oBAAoB,SAAS,KAAK,EAAc,GAC1D,KAAK,KAAK,oBAAoB,SAAS,KAAK,EAAc;CAC5D;CAEA,MAAkB,MAAyB;EACzC,EAAO,CAAC,SAAS,OAAO,GAAG,SAAa,KAAK,KAAK,MAAM,CAAC;CAC3D;CAEA,MAAkB,MAAiB;EACjC,IAAI,KAAK,KAAK,UAAU;GACtB,EAAU,CAAK;GACf;EACF;EAEA,AAAI,KAAK,KAAK,SAAS,YAAY,KAAK,KAAK,gBAAgB,kBAC3D,KAAK,GAAe,KAAK,KAAK,IAAI,IACzB,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,gBAAgB,mBACjE,KAAK,KAAK,KAAK,MAAM;CAEzB;CAEA,GAAe,GAAuB;EAOpC,AANA,KAAK,GAAiB,GACtB,KAAK,GAAiB,GACtB,KAAK,KAAiB,GACtB,EAAK,iBAAiB,UAAU,KAAK,IAAW,EAAE,MAAM,GAAK,CAAC,GAC9D,KAAK,IAAY,OAAO,GACxB,EAAK,YAAY,KAAK,EAAW,GACjC,EAAK,cAAc,KAAK,EAAU;CACpC;CAEA,WAAkB;EAChB,IAAM,IAAY,KAAK;EAEvB,AADA,KAAK,KAAiB,KAAA,GACtB,iBAAiB;GAEf,AADA,GAAW,OAAO,GACd,KAAK,OAAe,MACtB,KAAK,KAAa,KAAA;EAEtB,GAAG,CAAC;CACN;CAEA,KAAmB;EAQjB,AAPK,KAAK,OACR,KAAK,KAAa,WAAW,SAAS,cAAc,QAAQ,GAC5D,KAAK,GAAW,OAAO,UACvB,KAAK,GAAW,MAAM,UAAU,SAGlC,KAAK,GAAW,OAAO,KAAK,KAAK,QAAQ,IACzC,KAAK,GAAW,QAAQ,KAAK,KAAK,SAAS;CAC7C;CAEA,KAAmB;EAIjB,AAHA,KAAK,IAAgB,oBAAoB,UAAU,KAAK,EAAS,GACjE,KAAK,KAAiB,KAAA,GACtB,KAAK,IAAY,OAAO,GACxB,KAAK,KAAa,KAAA;CACpB;AACF"}
@@ -23,6 +23,8 @@ export interface ButtonFormControlMixinInstance {
23
23
  * @reflect
24
24
  */
25
25
  readOnly: boolean;
26
+ /** @deprecated Use readOnly instead. */
27
+ readonly: boolean;
26
28
  /**
27
29
  * Associates the button with a form. Set the property to a form element or its ID. The HTML attribute accepts only
28
30
  * the form ID. Reading the property returns the associated form element or `null`.
@@ -71,7 +73,8 @@ export interface ButtonFormControlMixinInstance {
71
73
  * @attr current
72
74
  * @reflect
73
75
  */
74
- current: CurrentState;
76
+ get current(): CurrentState;
77
+ set current(value: CurrentState | null | undefined);
75
78
  /**
76
79
  * Establishes a relationship between a popover and its invoker button.
77
80
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/popoverTargetElement
@@ -1,5 +1,5 @@
1
- import type { ButtonFormControlMixinInstance } from './button.types.js';
2
- export type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.js';
1
+ import type { ButtonFormControlMixinInstance } from '../internal/types/button.js';
2
+ export type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from '../internal/types/button.js';
3
3
  interface ButtonFormControlHost {
4
4
  connectedCallback?(): void;
5
5
  disconnectedCallback?(): void;
@@ -86,7 +86,7 @@ function b(b) {
86
86
  });
87
87
  }
88
88
  get readOnly() {
89
- return this.#d || !!this._typeAnchorController?.readOnly;
89
+ return this.#d || (this._typeAnchorController?.readOnly ?? !1);
90
90
  }
91
91
  set readOnly(e) {
92
92
  this.#w({
@@ -242,7 +242,7 @@ function b(b) {
242
242
  });
243
243
  }
244
244
  #y(e, t, n) {
245
- if (!(e === "commandfor" || e === "interestfor" || e === "popovertarget")) {
245
+ if (e !== "commandfor" && e !== "interestfor" && e !== "popovertarget") {
246
246
  if (e === "form" && (i(this.#a) && n === null || (this.#a = n, this.#j("form", t))), e === "popovertargetaction") {
247
247
  this.#D({
248
248
  property: "popoverTargetAction",
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","names":["#pressed","#setBooleanState","#expanded","#readOnly","#form","#requestHostUpdate","#queueBehaviorSync","#name","#setStringState","#value","#type","#disabled","#selected","#current","#getElementTarget","#setElementTarget","#popoverTargetAction","#command","#hasConnected","#flushPendingAttributeReflections","#syncBehavior","#syncQueued","#handleBooleanAttributeChange","#handleElementTargetAttributeChange","#handleStringAttributeChange","#getHostUpdateComplete","#elementTargets","#getElementById","#getBooleanValue","#setBooleanValue","#reflectAttribute","#getStringValue","#setStringValue","#pendingAttributeReflections"],"sources":["../../src/mixins/button.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeAnchorController } from '../internal/controllers/type-anchor.controller.js';\nimport { TypeButtonController } from '../internal/controllers/type-button.controller.js';\nimport { TypeCommandController } from '../internal/controllers/type-command.controller.js';\nimport { TypeInterestInvokerController } from '../internal/controllers/type-interest-invoker.controller.js';\nimport { TypeSubmitController } from '../internal/controllers/type-submit.controller.js';\nimport { TypePopoverTriggerController } from '../internal/controllers/type-popover-trigger.controller.js';\nimport { StateActiveController } from '../internal/controllers/state-active.controller.js';\nimport { StateCurrentController } from '../internal/controllers/state-current.controller.js';\nimport { StateDisabledController } from '../internal/controllers/state-disabled.controller.js';\nimport { StateExpandedController } from '../internal/controllers/state-expanded.controller.js';\nimport { StatePressedController } from '../internal/controllers/state-pressed.controller.js';\nimport { StateReadOnlyController } from '../internal/controllers/state-readonly.controller.js';\nimport { StateSelectedController } from '../internal/controllers/state-selected.controller.js';\nimport type { ReactiveController } from '../internal/controllers/types.js';\nimport {\n attachInternals,\n getFlattenedDOMTree,\n getStringValue,\n hasAttributeValue,\n isFormElement,\n setAttributeValue\n} from '../internal/utils.js';\nimport type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.js';\nexport type { ButtonFormControlMixinInstance, ButtonType, CurrentState, PopoverTargetAction } from './button.types.js';\n\ntype ChangedProperties = Map<PropertyKey, unknown>;\ninterface ButtonFormControlHost {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n updateComplete?: Promise<unknown>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & ButtonFormControlHost) & { observedAttributes?: string[] };\n\ninterface BooleanStateOptions {\n property: string;\n value: boolean;\n reflect: boolean;\n attribute?: string;\n}\n\ninterface StringStateOptions {\n property: string;\n value: unknown;\n attribute?: string;\n reflect?: boolean;\n}\n\nconst ELEMENT_TARGET_PROPERTIES = {\n commandfor: 'commandForElement',\n interestfor: 'interestForElement',\n popovertarget: 'popoverTargetElement'\n} as const;\ntype ElementTargetAttribute = keyof typeof ELEMENT_TARGET_PROPERTIES;\ntype ElementTargetProperty = (typeof ELEMENT_TARGET_PROPERTIES)[ElementTargetAttribute];\n\ntype ButtonFormControlConstructor<TBase extends Constructor> = new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & ButtonFormControlMixinInstance;\nexport type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonFormControlConstructor<TBase> & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds native button-style form, command, popover, and interaction behavior.\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/button/\n */\nexport function ButtonFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): ButtonFormControlMixinReturn<TBase> {\n return class ButtonFormControlBase extends SuperClass {\n static formAssociated = true;\n\n #command: string | undefined;\n #current: CurrentState | undefined;\n #disabled = false;\n #elementTargets: Record<ElementTargetProperty, HTMLElement | null> = {\n commandForElement: null,\n interestForElement: null,\n popoverTargetElement: null\n };\n #expanded: boolean | undefined;\n #form: string | HTMLFormElement | null = null;\n #hasConnected = false;\n #name: string | undefined;\n #pendingAttributeReflections = new Map<string, string | null>();\n #popoverTargetAction: PopoverTargetAction | undefined;\n #pressed: boolean | undefined;\n #readOnly = false;\n #selected: boolean | undefined;\n #syncQueued = false;\n #type: ButtonType | undefined;\n #value: string | undefined;\n\n _internals = attachInternals(this);\n\n static get observedAttributes() {\n return (super.observedAttributes ?? []).concat([\n 'pressed',\n 'expanded',\n 'readonly',\n 'form',\n 'name',\n 'value',\n 'type',\n 'disabled',\n 'selected',\n 'current',\n 'popovertarget',\n 'popovertargetaction',\n 'commandfor',\n 'command',\n 'interestfor'\n ]);\n }\n\n get pressed(): boolean {\n return this.#pressed as boolean;\n }\n\n set pressed(value: boolean | unknown) {\n this.#setBooleanState({ property: 'pressed', value: Boolean(value), reflect: true });\n }\n\n get expanded(): boolean {\n return this.#expanded as boolean;\n }\n\n set expanded(value: boolean | unknown) {\n this.#setBooleanState({ property: 'expanded', value: Boolean(value), reflect: true });\n }\n\n get readOnly(): boolean {\n return this.#readOnly || Boolean(this._typeAnchorController?.readOnly);\n }\n\n set readOnly(value: boolean | unknown) {\n this.#setBooleanState({ property: 'readOnly', value: Boolean(value), reflect: true, attribute: 'readonly' });\n }\n\n get readonly(): boolean {\n return this.readOnly;\n }\n\n set readonly(value: boolean) {\n this.readOnly = value;\n }\n\n set form(form: string | HTMLFormElement | null) {\n const oldValue = this.form;\n this.#form = form;\n if (typeof form === 'string') {\n this.setAttribute('form', form);\n } else {\n this.removeAttribute('form');\n }\n this.#requestHostUpdate('form', oldValue);\n this.#queueBehaviorSync();\n }\n\n get form(): HTMLFormElement | null | string {\n if (this.#form && typeof this.#form !== 'string') {\n return this.#form;\n }\n\n if (typeof this.#form === 'string' && typeof globalThis.document !== 'undefined') {\n const rootNode = this.getRootNode() as Document | ShadowRoot;\n const form = rootNode.getElementById ? rootNode.getElementById(this.#form) : null;\n return isFormElement(form) ? form : null;\n }\n\n return this._internals?.form ?? null;\n }\n\n get name(): string {\n return this.#name as string;\n }\n\n set name(value: string | unknown) {\n this.#setStringState({ property: 'name', value });\n }\n\n get value(): string {\n return this.#value as string;\n }\n\n set value(value: string | unknown) {\n this.#setStringState({ property: 'value', value });\n }\n\n get type(): ButtonType {\n return (this.#type ?? this._typeSubmitController?.defaultType) as ButtonType;\n }\n\n set type(value: ButtonType | unknown) {\n this.#setStringState({ property: 'type', value });\n }\n\n get disabled(): boolean {\n return this.#disabled;\n }\n\n set disabled(value: boolean | unknown) {\n this.#setBooleanState({ property: 'disabled', value: Boolean(value), reflect: true });\n }\n\n get selected(): boolean {\n return this.#selected as boolean;\n }\n\n set selected(value: boolean | unknown) {\n this.#setBooleanState({ property: 'selected', value: Boolean(value), reflect: true });\n }\n\n get current(): CurrentState {\n return this.#current as CurrentState;\n }\n\n set current(value: CurrentState | unknown) {\n this.#setStringState({ property: 'current', value });\n }\n\n get popoverTargetElement(): HTMLElement | null {\n return this.#getElementTarget('popovertarget');\n }\n\n set popoverTargetElement(value: HTMLElement | null) {\n this.#setElementTarget('popovertarget', value);\n }\n\n get popoverTargetAction(): PopoverTargetAction {\n return this.#popoverTargetAction === 'show' || this.#popoverTargetAction === 'hide'\n ? this.#popoverTargetAction\n : 'toggle';\n }\n\n set popoverTargetAction(value: PopoverTargetAction | unknown) {\n this.#setStringState({ property: 'popoverTargetAction', value, attribute: 'popovertargetaction' });\n }\n\n get commandForElement(): HTMLElement | null {\n return this.#getElementTarget('commandfor');\n }\n\n set commandForElement(value: HTMLElement | null) {\n this.#setElementTarget('commandfor', value);\n }\n\n get command(): string {\n return this.#command as string;\n }\n\n set command(value: string | unknown) {\n this.#setStringState({ property: 'command', value });\n }\n\n get interestForElement(): HTMLElement | null {\n return this.#getElementTarget('interestfor');\n }\n\n set interestForElement(value: HTMLElement | null) {\n this.#setElementTarget('interestfor', value);\n }\n\n protected _controllers?: Set<ReactiveController>;\n protected _typeAnchorController = new TypeAnchorController(this);\n protected _typeButtonController = new TypeButtonController(this);\n protected _typeSubmitController = new TypeSubmitController(this);\n protected _typeCommandController = new TypeCommandController(this);\n protected _typeInterestInvokerController = new TypeInterestInvokerController(this);\n protected _typePopoverTriggerController = new TypePopoverTriggerController(this);\n protected _stateActiveController = new StateActiveController(this);\n protected _stateDisabledController = new StateDisabledController(this);\n protected _stateExpandedController = new StateExpandedController(this);\n protected _statePressedController = new StatePressedController(this);\n protected _stateSelectedController = new StateSelectedController(this);\n protected _stateCurrentController = new StateCurrentController(this);\n protected _stateReadOnlyController = new StateReadOnlyController(this);\n\n addController(controller: ReactiveController) {\n this._controllers ??= new Set<ReactiveController>();\n this._controllers.add(controller);\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n this._controllers?.forEach(controller => controller.hostConnected?.());\n attachInternals(this);\n this.#hasConnected = true;\n this.#flushPendingAttributeReflections();\n\n this.#syncBehavior();\n this.#queueBehaviorSync();\n }\n\n disconnectedCallback() {\n this._controllers?.forEach(controller => controller.hostDisconnected?.());\n super.disconnectedCallback?.();\n }\n\n protected updated(changedProperties: ChangedProperties) {\n const superUpdated = Object.getPrototypeOf(ButtonFormControlBase.prototype).updated as\n | ((changedProperties: ChangedProperties) => void)\n | undefined;\n superUpdated?.call(this, changedProperties);\n this.#syncQueued = false;\n this.#syncBehavior();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n\n if (oldValue === newValue) {\n return;\n }\n\n this.#handleBooleanAttributeChange(name, newValue);\n this.#handleElementTargetAttributeChange(name, oldValue);\n this.#handleStringAttributeChange(name, oldValue, newValue);\n }\n\n #queueBehaviorSync() {\n if (!this.isConnected || this.#syncQueued) {\n return;\n }\n\n this.#syncQueued = true;\n void this.#getHostUpdateComplete().then(() => {\n if (!this.#syncQueued) return;\n this.#syncQueued = false;\n if (this.isConnected) this.#syncBehavior();\n });\n }\n\n #syncBehavior() {\n this._controllers?.forEach(controller => controller.hostUpdated?.());\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'pressed' || name === 'expanded' || name === 'selected' || name === 'disabled') {\n this.#setBooleanState({ property: name, value: newValue !== null, reflect: false });\n }\n\n if (name === 'readonly') {\n this.#setBooleanState({ property: 'readOnly', value: newValue !== null, reflect: false });\n }\n }\n\n #handleStringAttributeChange(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'commandfor' || name === 'interestfor' || name === 'popovertarget') {\n return;\n }\n\n if (name === 'form') {\n if (!(isFormElement(this.#form) && newValue === null)) {\n this.#form = newValue;\n this.#requestHostUpdate('form', oldValue);\n }\n }\n\n if (name === 'popovertargetaction') {\n this.#setStringState({ property: 'popoverTargetAction', value: newValue, reflect: false });\n return;\n }\n\n this.#setStringState({ property: name, value: newValue, reflect: false });\n }\n\n #handleElementTargetAttributeChange(name: string, oldValue: string | null) {\n const property = ELEMENT_TARGET_PROPERTIES[name as ElementTargetAttribute];\n if (!property) {\n return;\n }\n\n const oldTarget = this.#elementTargets[property] ?? this.#getElementById(oldValue);\n this.#elementTargets[property] = null;\n this.#requestHostUpdate(property, oldTarget);\n this.#queueBehaviorSync();\n }\n\n #getElementTarget(attribute: ElementTargetAttribute) {\n return (\n this.#elementTargets[ELEMENT_TARGET_PROPERTIES[attribute]] ?? this.#getElementById(this.getAttribute(attribute))\n );\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n\n #setElementTarget(attribute: ElementTargetAttribute, value: HTMLElement | null) {\n const property = ELEMENT_TARGET_PROPERTIES[attribute];\n const oldValue = this[property];\n if (oldValue === value && hasAttributeValue(this, attribute, value ? '' : null)) {\n return;\n }\n setAttributeValue(this, attribute, value ? '' : null);\n this.#elementTargets[property] = value;\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #setBooleanState({ property, value, reflect, attribute = property }: BooleanStateOptions) {\n const oldValue = this.#getBooleanValue(property);\n if (oldValue === value && (!reflect || hasAttributeValue(this, attribute, value ? '' : null))) {\n return;\n }\n\n this.#setBooleanValue(property, value);\n if (reflect && this.#reflectAttribute(attribute, value ? '' : null)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getBooleanValue(property: string) {\n return {\n disabled: this.#disabled,\n expanded: this.#expanded,\n pressed: this.#pressed,\n readOnly: this.#readOnly,\n selected: this.#selected\n }[property];\n }\n\n #setBooleanValue(property: string, value: boolean) {\n if (property === 'disabled') {\n this.#disabled = value;\n } else if (property === 'expanded') {\n this.#expanded = value;\n } else if (property === 'pressed') {\n this.#pressed = value;\n } else if (property === 'readOnly') {\n this.#readOnly = value;\n } else if (property === 'selected') {\n this.#selected = value;\n }\n }\n\n #setStringState({ property, value, attribute = property, reflect = true }: StringStateOptions) {\n const oldValue = this.#getStringValue(property);\n const nextValue = getStringValue(value);\n if (oldValue === nextValue && (!reflect || hasAttributeValue(this, attribute, nextValue))) {\n return;\n }\n\n this.#setStringValue(property, nextValue);\n if (reflect && this.#reflectAttribute(attribute, nextValue)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getStringValue(property: string) {\n return {\n command: this.#command,\n current: this.#current,\n name: this.#name,\n popoverTargetAction: this.#popoverTargetAction,\n type: this.#type,\n value: this.#value\n }[property];\n }\n\n #setStringValue(property: string, value: string | null) {\n const setters: Record<string, () => void> = {\n command: () => (this.#command = value ?? undefined),\n current: () => (this.#current = value as CurrentState),\n name: () => (this.#name = value ?? undefined),\n popoverTargetAction: () => (this.#popoverTargetAction = value as PopoverTargetAction),\n type: () => (this.#type = value as ButtonType),\n value: () => (this.#value = value ?? undefined)\n };\n setters[property]?.();\n }\n\n #reflectAttribute(attribute: string, value: string | null) {\n if (!this.isConnected && !this.#hasConnected) {\n if (!this.hasAttribute(attribute)) {\n this.#pendingAttributeReflections.set(attribute, value);\n }\n return true;\n }\n\n setAttributeValue(this, attribute, value);\n return false;\n }\n\n #requestHostUpdate(name?: string, oldValue?: unknown) {\n this.requestUpdate?.(name, oldValue);\n }\n\n #getHostUpdateComplete() {\n return this.updateComplete ?? Promise.resolve();\n }\n\n #flushPendingAttributeReflections() {\n this.#pendingAttributeReflections.forEach((value, attribute) => setAttributeValue(this, attribute, value));\n this.#pendingAttribut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AK,eAAe,CAAC,KAAKS,MACxB,KAAK,aAAa,CAAS,KAC9B,KAAKe,GAA6B,IAAI,GAAW,CAAK,GAEjD,OAGT,EAAkB,MAAM,GAAW,CAAK,GACjC;EACT;EAEA,GAAmB,GAAe,GAAoB;GACpD,KAAK,gBAAgB,GAAM,CAAQ;EACrC;EAEA,KAAyB;GACvB,OAAO,KAAK,kBAAkB,QAAQ,QAAQ;EAChD;EAEA,KAAoC;GAElC,AADA,KAAKA,GAA6B,SAAS,GAAO,MAAc,EAAkB,MAAM,GAAW,CAAK,CAAC,GACzG,KAAKA,GAA6B,MAAM;EAC1C;CACF;AACF"}
1
+ {"version":3,"file":"button.js","names":[],"sources":["../../src/mixins/button.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TypeAnchorController } from '../internal/controllers/type-anchor.controller.js';\nimport { TypeButtonController } from '../internal/controllers/type-button.controller.js';\nimport { TypeCommandController } from '../internal/controllers/type-command.controller.js';\nimport { TypeInterestInvokerController } from '../internal/controllers/type-interest-invoker.controller.js';\nimport { TypeSubmitController } from '../internal/controllers/type-submit.controller.js';\nimport { TypePopoverTriggerController } from '../internal/controllers/type-popover-trigger.controller.js';\nimport { StateActiveController } from '../internal/controllers/state-active.controller.js';\nimport { StateCurrentController } from '../internal/controllers/state-current.controller.js';\nimport { StateDisabledController } from '../internal/controllers/state-disabled.controller.js';\nimport { StateExpandedController } from '../internal/controllers/state-expanded.controller.js';\nimport { StatePressedController } from '../internal/controllers/state-pressed.controller.js';\nimport { StateReadOnlyController } from '../internal/controllers/state-readonly.controller.js';\nimport { StateSelectedController } from '../internal/controllers/state-selected.controller.js';\nimport type { ReactiveController } from '../internal/controllers/types.js';\nimport {\n attachInternals,\n getFlattenedDOMTree,\n getStringValue,\n hasAttributeValue,\n isFormElement,\n setAttributeValue\n} from '../internal/utils.js';\nimport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\nexport type {\n ButtonFormControlMixinInstance,\n ButtonType,\n CurrentState,\n PopoverTargetAction\n} from '../internal/types/button.js';\n\ntype ChangedProperties = Map<PropertyKey, unknown>;\ninterface ButtonFormControlHost {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n updateComplete?: Promise<unknown>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Constructor = (new (...args: any[]) => HTMLElement & ButtonFormControlHost) & { observedAttributes?: string[] };\n\ninterface BooleanStateOptions {\n property: string;\n value: boolean;\n reflect: boolean;\n attribute?: string;\n}\n\ninterface StringStateOptions {\n property: string;\n value: unknown;\n attribute?: string;\n reflect?: boolean;\n}\n\nconst ELEMENT_TARGET_PROPERTIES = {\n commandfor: 'commandForElement',\n interestfor: 'interestForElement',\n popovertarget: 'popoverTargetElement'\n} as const;\ntype ElementTargetAttribute = keyof typeof ELEMENT_TARGET_PROPERTIES;\ntype ElementTargetProperty = (typeof ELEMENT_TARGET_PROPERTIES)[ElementTargetAttribute];\n\ntype ButtonFormControlConstructor<TBase extends Constructor> = new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & ButtonFormControlMixinInstance;\nexport type ButtonFormControlMixinReturn<TBase extends Constructor> = ButtonFormControlConstructor<TBase> & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\n/**\n * @description A mixin that adds native button-style form, command, popover, and interaction behavior.\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/button/\n */\nexport function ButtonFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): ButtonFormControlMixinReturn<TBase> {\n return class ButtonFormControlBase extends SuperClass {\n static formAssociated = true;\n\n #command: string | undefined;\n #current: CurrentState | undefined;\n #disabled = false;\n #elementTargets: Record<ElementTargetProperty, HTMLElement | null> = {\n commandForElement: null,\n interestForElement: null,\n popoverTargetElement: null\n };\n #expanded: boolean | undefined;\n #form: string | HTMLFormElement | null = null;\n #hasConnected = false;\n #name: string | undefined;\n #pendingAttributeReflections = new Map<string, string | null>();\n #popoverTargetAction: PopoverTargetAction | undefined;\n #pressed: boolean | undefined;\n #readOnly = false;\n #selected: boolean | undefined;\n #syncQueued = false;\n #type: ButtonType | undefined;\n #value: string | undefined;\n\n _internals = attachInternals(this);\n\n static get observedAttributes() {\n return (super.observedAttributes ?? []).concat([\n 'pressed',\n 'expanded',\n 'readonly',\n 'form',\n 'name',\n 'value',\n 'type',\n 'disabled',\n 'selected',\n 'current',\n 'popovertarget',\n 'popovertargetaction',\n 'commandfor',\n 'command',\n 'interestfor'\n ]);\n }\n\n get pressed(): boolean {\n return this.#pressed as boolean;\n }\n\n set pressed(value: boolean | unknown) {\n this.#setBooleanState({ property: 'pressed', value: Boolean(value), reflect: true });\n }\n\n get expanded(): boolean {\n return this.#expanded as boolean;\n }\n\n set expanded(value: boolean | unknown) {\n this.#setBooleanState({ property: 'expanded', value: Boolean(value), reflect: true });\n }\n\n get readOnly(): boolean {\n return this.#readOnly || (this._typeAnchorController?.readOnly ?? false);\n }\n\n set readOnly(value: boolean | unknown) {\n this.#setBooleanState({ property: 'readOnly', value: Boolean(value), reflect: true, attribute: 'readonly' });\n }\n\n get readonly(): boolean {\n return this.readOnly;\n }\n\n set readonly(value: boolean) {\n this.readOnly = value;\n }\n\n set form(form: string | HTMLFormElement | null) {\n const oldValue = this.form;\n this.#form = form;\n if (typeof form === 'string') {\n this.setAttribute('form', form);\n } else {\n this.removeAttribute('form');\n }\n this.#requestHostUpdate('form', oldValue);\n this.#queueBehaviorSync();\n }\n\n get form(): HTMLFormElement | null | string {\n if (this.#form && typeof this.#form !== 'string') {\n return this.#form;\n }\n\n if (typeof this.#form === 'string' && typeof globalThis.document !== 'undefined') {\n const rootNode = this.getRootNode() as Document | ShadowRoot;\n const form = rootNode.getElementById ? rootNode.getElementById(this.#form) : null;\n return isFormElement(form) ? form : null;\n }\n\n return this._internals?.form ?? null;\n }\n\n get name(): string {\n return this.#name as string;\n }\n\n set name(value: string | unknown) {\n this.#setStringState({ property: 'name', value });\n }\n\n get value(): string {\n return this.#value as string;\n }\n\n set value(value: string | unknown) {\n this.#setStringState({ property: 'value', value });\n }\n\n get type(): ButtonType {\n return (this.#type ?? this._typeSubmitController?.defaultType) as ButtonType;\n }\n\n set type(value: ButtonType | unknown) {\n this.#setStringState({ property: 'type', value });\n }\n\n get disabled(): boolean {\n return this.#disabled;\n }\n\n set disabled(value: boolean | unknown) {\n this.#setBooleanState({ property: 'disabled', value: Boolean(value), reflect: true });\n }\n\n get selected(): boolean {\n return this.#selected as boolean;\n }\n\n set selected(value: boolean | unknown) {\n this.#setBooleanState({ property: 'selected', value: Boolean(value), reflect: true });\n }\n\n get current(): CurrentState {\n return this.#current as CurrentState;\n }\n\n set current(value: CurrentState | unknown) {\n this.#setStringState({ property: 'current', value });\n }\n\n get popoverTargetElement(): HTMLElement | null {\n return this.#getElementTarget('popovertarget');\n }\n\n set popoverTargetElement(value: HTMLElement | null) {\n this.#setElementTarget('popovertarget', value);\n }\n\n get popoverTargetAction(): PopoverTargetAction {\n return this.#popoverTargetAction === 'show' || this.#popoverTargetAction === 'hide'\n ? this.#popoverTargetAction\n : 'toggle';\n }\n\n set popoverTargetAction(value: PopoverTargetAction | unknown) {\n this.#setStringState({ property: 'popoverTargetAction', value, attribute: 'popovertargetaction' });\n }\n\n get commandForElement(): HTMLElement | null {\n return this.#getElementTarget('commandfor');\n }\n\n set commandForElement(value: HTMLElement | null) {\n this.#setElementTarget('commandfor', value);\n }\n\n get command(): string {\n return this.#command as string;\n }\n\n set command(value: string | unknown) {\n this.#setStringState({ property: 'command', value });\n }\n\n get interestForElement(): HTMLElement | null {\n return this.#getElementTarget('interestfor');\n }\n\n set interestForElement(value: HTMLElement | null) {\n this.#setElementTarget('interestfor', value);\n }\n\n protected _controllers?: Set<ReactiveController>;\n protected _typeAnchorController = new TypeAnchorController(this);\n protected _typeButtonController = new TypeButtonController(this);\n protected _typeSubmitController = new TypeSubmitController(this);\n protected _typeCommandController = new TypeCommandController(this);\n protected _typeInterestInvokerController = new TypeInterestInvokerController(this);\n protected _typePopoverTriggerController = new TypePopoverTriggerController(this);\n protected _stateActiveController = new StateActiveController(this);\n protected _stateDisabledController = new StateDisabledController(this);\n protected _stateExpandedController = new StateExpandedController(this);\n protected _statePressedController = new StatePressedController(this);\n protected _stateSelectedController = new StateSelectedController(this);\n protected _stateCurrentController = new StateCurrentController(this);\n protected _stateReadOnlyController = new StateReadOnlyController(this);\n\n addController(controller: ReactiveController) {\n this._controllers ??= new Set<ReactiveController>();\n this._controllers.add(controller);\n }\n\n connectedCallback() {\n super.connectedCallback?.();\n this._controllers?.forEach(controller => controller.hostConnected?.());\n attachInternals(this);\n this.#hasConnected = true;\n this.#flushPendingAttributeReflections();\n\n this.#syncBehavior();\n this.#queueBehaviorSync();\n }\n\n disconnectedCallback() {\n this._controllers?.forEach(controller => controller.hostDisconnected?.());\n super.disconnectedCallback?.();\n }\n\n protected updated(changedProperties: ChangedProperties) {\n const superUpdated = Object.getPrototypeOf(ButtonFormControlBase.prototype).updated as\n | ((changedProperties: ChangedProperties) => void)\n | undefined;\n superUpdated?.call(this, changedProperties);\n this.#syncQueued = false;\n this.#syncBehavior();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n\n if (oldValue === newValue) {\n return;\n }\n\n this.#handleBooleanAttributeChange(name, newValue);\n this.#handleElementTargetAttributeChange(name, oldValue);\n this.#handleStringAttributeChange(name, oldValue, newValue);\n }\n\n #queueBehaviorSync() {\n if (!this.isConnected || this.#syncQueued) {\n return;\n }\n\n this.#syncQueued = true;\n void this.#getHostUpdateComplete().then(() => {\n if (!this.#syncQueued) return;\n this.#syncQueued = false;\n if (this.isConnected) this.#syncBehavior();\n });\n }\n\n #syncBehavior() {\n this._controllers?.forEach(controller => controller.hostUpdated?.());\n }\n\n #handleBooleanAttributeChange(name: string, newValue: string | null) {\n if (name === 'pressed' || name === 'expanded' || name === 'selected' || name === 'disabled') {\n this.#setBooleanState({ property: name, value: newValue !== null, reflect: false });\n }\n\n if (name === 'readonly') {\n this.#setBooleanState({ property: 'readOnly', value: newValue !== null, reflect: false });\n }\n }\n\n #handleStringAttributeChange(name: string, oldValue: string | null, newValue: string | null) {\n if (name === 'commandfor' || name === 'interestfor' || name === 'popovertarget') {\n return;\n }\n\n if (name === 'form') {\n if (!(isFormElement(this.#form) && newValue === null)) {\n this.#form = newValue;\n this.#requestHostUpdate('form', oldValue);\n }\n }\n\n if (name === 'popovertargetaction') {\n this.#setStringState({ property: 'popoverTargetAction', value: newValue, reflect: false });\n return;\n }\n\n this.#setStringState({ property: name, value: newValue, reflect: false });\n }\n\n #handleElementTargetAttributeChange(name: string, oldValue: string | null) {\n const property = ELEMENT_TARGET_PROPERTIES[name as ElementTargetAttribute];\n if (!property) {\n return;\n }\n\n const oldTarget = this.#elementTargets[property] ?? this.#getElementById(oldValue);\n this.#elementTargets[property] = null;\n this.#requestHostUpdate(property, oldTarget);\n this.#queueBehaviorSync();\n }\n\n #getElementTarget(attribute: ElementTargetAttribute) {\n return (\n this.#elementTargets[ELEMENT_TARGET_PROPERTIES[attribute]] ?? this.#getElementById(this.getAttribute(attribute))\n );\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.getRootNode()).find(element => element.id === id) ?? null) : null;\n }\n\n #setElementTarget(attribute: ElementTargetAttribute, value: HTMLElement | null) {\n const property = ELEMENT_TARGET_PROPERTIES[attribute];\n const oldValue = this[property];\n if (oldValue === value && hasAttributeValue(this, attribute, value ? '' : null)) {\n return;\n }\n setAttributeValue(this, attribute, value ? '' : null);\n this.#elementTargets[property] = value;\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #setBooleanState({ property, value, reflect, attribute = property }: BooleanStateOptions) {\n const oldValue = this.#getBooleanValue(property);\n if (oldValue === value && (!reflect || hasAttributeValue(this, attribute, value ? '' : null))) {\n return;\n }\n\n this.#setBooleanValue(property, value);\n if (reflect && this.#reflectAttribute(attribute, value ? '' : null)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getBooleanValue(property: string) {\n return {\n disabled: this.#disabled,\n expanded: this.#expanded,\n pressed: this.#pressed,\n readOnly: this.#readOnly,\n selected: this.#selected\n }[property];\n }\n\n #setBooleanValue(property: string, value: boolean) {\n if (property === 'disabled') {\n this.#disabled = value;\n } else if (property === 'expanded') {\n this.#expanded = value;\n } else if (property === 'pressed') {\n this.#pressed = value;\n } else if (property === 'readOnly') {\n this.#readOnly = value;\n } else if (property === 'selected') {\n this.#selected = value;\n }\n }\n\n #setStringState({ property, value, attribute = property, reflect = true }: StringStateOptions) {\n const oldValue = this.#getStringValue(property);\n const nextValue = getStringValue(value);\n if (oldValue === nextValue && (!reflect || hasAttributeValue(this, attribute, nextValue))) {\n return;\n }\n\n this.#setStringValue(property, nextValue);\n if (reflect && this.#reflectAttribute(attribute, nextValue)) {\n return;\n }\n this.#requestHostUpdate(property, oldValue);\n this.#queueBehaviorSync();\n }\n\n #getStringValue(property: string) {\n return {\n command: this.#command,\n current: this.#current,\n name: this.#name,\n popoverTargetAction: this.#popoverTargetAction,\n type: this.#type,\n value: this.#value\n }[property];\n }\n\n #setStringValue(property: string, value: string | null) {\n const setters: Record<string, () => void> = {\n command: () => (this.#command = value ?? undefined),\n current: () => (this.#current = value as CurrentState),\n name: () => (this.#name = value ?? undefined),\n popoverTargetAction: () => (this.#popoverTargetAction = value as PopoverTargetAction),\n type: () => (this.#type = value as ButtonType),\n value: () => (this.#value = value ?? undefined)\n };\n setters[property]?.();\n }\n\n #reflectAttribute(attribute: string, value: string | null) {\n if (!this.isConnected && !this.#hasConnected) {\n if (!this.hasAttribute(attribute)) {\n this.#pendingAttributeReflections.set(attribute, value);\n }\n return true;\n }\n\n setAttributeValue(this, attribute, value);\n return false;\n }\n\n #requestHostUpdate(name?: string, oldValue?: unknown) {\n this.requestUpdate?.(name, oldValue);\n }\n\n #getHostUpdateComplete() {\n return this.updateComplete ?? Promise.resolve();\n }\n\n #flushPendingAttributeReflections() {\n this.#pendingAttributeReflections.forEach((value, attribute) => setAttributeValue(this, attribute, value));\n this.#pendingAttributeReflections.clear();\n }\n } as unknown as ButtonFormControlMixinReturn<TBase>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgEA,IAAM,IAA4B;CAChC,YAAY;CACZ,aAAa;CACb,eAAe;AACjB;AAgBA,SAAgB,EACd,GACqC;CACrC,OAAO,MAAM,UAA8B,EAAW;;GA+Mf,aA1MzB,KAAA,KAAA,IACyD,KAAA,KAAA;IACnE,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;GACxB,GAEyC,KAAA,KAAA,MACzB,KAAA,KAAA,IAEe,KAAA,qBAAA,IAAI,IAA2B,GAGlD,KAAA,KAAA,IAEE,KAAA,KAAA,IAID,KAAA,aAAA,EAAgB,IAAI,GA2KC,KAAA,wBAAA,IAAI,EAAqB,IAAI,GAC7B,KAAA,wBAAA,IAAI,EAAqB,IAAI,GAC7B,KAAA,wBAAA,IAAI,EAAqB,IAAI,GAC5B,KAAA,yBAAA,IAAI,EAAsB,IAAI,GACtB,KAAA,iCAAA,IAAI,EAA8B,IAAI,GACvC,KAAA,gCAAA,IAAI,EAA6B,IAAI,GAC5C,KAAA,yBAAA,IAAI,EAAsB,IAAI,GAC5B,KAAA,2BAAA,IAAI,EAAwB,IAAI,GAChC,KAAA,2BAAA,IAAI,EAAwB,IAAI,GACjC,KAAA,0BAAA,IAAI,EAAuB,IAAI,GAC9B,KAAA,2BAAA,IAAI,EAAwB,IAAI,GACjC,KAAA,0BAAA,IAAI,EAAuB,IAAI,GAC9B,KAAA,2BAAA,IAAI,EAAwB,IAAI;;;GA9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AS,KAAK;IACd,MAAM,KAAK;IACX,qBAAqB,KAAK;IAC1B,MAAM,KAAK;IACX,OAAO,KAAK;GACd,EAAE;EACJ;EAEA,GAAgB,GAAkB,GAAsB;GAStD,CAAA;IAPE,eAAgB,KAAK,KAAW,KAAS,KAAA;IACzC,eAAgB,KAAK,KAAW;IAChC,YAAa,KAAK,KAAQ,KAAS,KAAA;IACnC,2BAA4B,KAAK,KAAuB;IACxD,YAAa,KAAK,KAAQ;IAC1B,aAAc,KAAK,KAAS,KAAS,KAAA;GAEvC,EAAA,CAAQ,EAAS,GAAG;EACtB;EAEA,GAAkB,GAAmB,GAAsB;GASzD,OARI,CAAC,KAAK,eAAe,CAAC,KAAK,MACxB,KAAK,aAAa,CAAS,KAC9B,KAAK,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,KAAK,GAA6B,SAAS,GAAO,MAAc,EAAkB,MAAM,GAAW,CAAK,CAAC,GACzG,KAAK,GAA6B,MAAM;EAC1C;CACF;AACF"}
@@ -24,6 +24,8 @@ export interface CheckboxFormControlMixinInstance extends FormControlMixinInstan
24
24
  * @reflect
25
25
  */
26
26
  indeterminate: boolean;
27
+ /** Restores the checked state from a saved form value. */
28
+ formStateRestoreCallback(state: string | null, reason?: string): void;
27
29
  updateCheckedState(): void;
28
30
  /**
29
31
  * Toggles the checked state.
@@ -20,19 +20,19 @@ function i(i) {
20
20
  return this.#e;
21
21
  }
22
22
  set checked(e) {
23
- this.#s(!!e), this.#i = !0, this.toggleAttribute("checked", this.#e), this.#i = !1;
23
+ this.#s(e ?? !1), this.#i = !0, this.toggleAttribute("checked", this.#e), this.#i = !1;
24
24
  }
25
25
  get disabled() {
26
26
  return super.disabled;
27
27
  }
28
28
  set disabled(e) {
29
- super.disabled = !!e, r.has(this) && this.updateCheckedState();
29
+ super.disabled = e ?? !1, r.has(this) && this.updateCheckedState();
30
30
  }
31
31
  get indeterminate() {
32
32
  return this.#n;
33
33
  }
34
34
  set indeterminate(e) {
35
- this.#c(!!e), this.toggleAttribute("indeterminate", this.#n);
35
+ this.#c(e ?? !1), this.toggleAttribute("indeterminate", this.#n);
36
36
  }
37
37
  get type() {
38
38
  return "checkbox";
@@ -84,7 +84,7 @@ function i(i) {
84
84
  return this.noValidate ? (this.setValidity({}), !0) : this.#t ? (this.setValidity({ customError: !0 }, this.#t), !1) : this.required && !this.checked ? (this.setValidity({ valueMissing: !0 }, "Select this option"), !1) : super.checkValidity();
85
85
  }
86
86
  #o(e, t) {
87
- return e === "checked" ? (this.#s(t !== null), !0) : e === "indeterminate" ? (this.#c(t !== null), !0) : e === "value" ? (this.#l(t ?? "on"), !0) : !1;
87
+ return e === "checked" ? (this.#s(t !== null), !0) : e === "indeterminate" ? (this.#c(t !== null), !0) : e === "value" && (this.#l(t ?? "on"), !0);
88
88
  }
89
89
  #s(e) {
90
90
  let t = this.#e;
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.js","names":["#checked","#setChecked","#reflectingChecked","#indeterminate","#setIndeterminate","#setValue","#initialChecked","#handleCheckboxAttributeChange","#checkCheckboxValidity","#customValidityMessage"],"sources":["../../src/mixins/checkbox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { FormControlValue } from '../internal/types.js';\nimport { toggleState } from '../internal/utils.js';\nimport { FormControlMixin, type FormControlMixinInstance } from './index.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 type CheckboxFormControlValue = Extract<FormControlValue, string>;\n\nexport interface CheckboxFormControlMixinInstance extends FormControlMixinInstance<CheckboxFormControlValue> {\n /**\n * Shows whether the checkbox currently has a checked value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#checked\n * @attr checked\n * @reflect\n */\n checked: boolean;\n\n /**\n * Indicates whether the checkbox is visually indeterminate.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/indeterminate\n * @attr indeterminate\n * @reflect\n */\n indeterminate: boolean;\n\n updateCheckedState(): void;\n\n /**\n * Toggles the checked state.\n */\n toggle(event?: Event): void;\n}\n\nexport type CheckboxFormControlMixinReturn<TBase extends Constructor> = (new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & CheckboxFormControlMixinInstance) & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\ninterface CheckboxBaseInstance extends HTMLElement, FormControlMixinInstance<CheckboxFormControlValue> {\n connectedCallback(): void;\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n}\n\ntype CheckboxBaseConstructor<TBase extends Constructor> = (new (\n ...args: ConstructorParameters<TBase>\n) => CheckboxBaseInstance) & {\n formAssociated: boolean;\n observedAttributes: string[];\n};\n\nconst checkboxValues = new WeakMap<object, string>();\nconst constructedCheckboxes = new WeakSet();\n\n/**\n * @description A mixin that adds native checkbox-style form control behavior.\n */\nexport function CheckboxFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): CheckboxFormControlMixinReturn<TBase> {\n const Base = FormControlMixin<TBase, CheckboxFormControlValue>(SuperClass) as CheckboxBaseConstructor<TBase>;\n\n return class CheckboxFormControlBase extends Base {\n #checked = false;\n\n #customValidityMessage = '';\n\n #indeterminate = false;\n\n #initialChecked: boolean | undefined;\n\n #reflectingChecked = false;\n\n constructor(...args: ConstructorParameters<TBase>) {\n super(...args);\n constructedCheckboxes.add(this);\n }\n\n static get observedAttributes() {\n return super.observedAttributes.concat(['checked', 'indeterminate']);\n }\n\n get checked(): boolean {\n return this.#checked;\n }\n\n set checked(value: boolean) {\n this.#setChecked(Boolean(value));\n this.#reflectingChecked = true;\n this.toggleAttribute('checked', this.#checked);\n this.#reflectingChecked = false;\n }\n\n override get disabled(): boolean {\n return super.disabled;\n }\n\n override set disabled(value: boolean) {\n super.disabled = Boolean(value);\n if (constructedCheckboxes.has(this)) {\n this.updateCheckedState();\n }\n }\n\n get indeterminate(): boolean {\n return this.#indeterminate;\n }\n\n set indeterminate(value: boolean) {\n this.#setIndeterminate(Boolean(value));\n this.toggleAttribute('indeterminate', this.#indeterminate);\n }\n\n override get type(): string {\n return 'checkbox';\n }\n\n override set type(_value: string) {}\n\n override get value(): CheckboxFormControlValue {\n return checkboxValues.get(this) ?? 'on';\n }\n\n override set value(value: CheckboxFormControlValue | number | boolean) {\n this.#setValue(getCheckboxValue(value));\n this.setAttribute('value', this.value);\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#initialChecked ??= this.checked;\n this.updateCheckedState();\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue) {\n return;\n }\n\n if (this.#handleCheckboxAttributeChange(name, newValue)) {\n if (name === 'checked' && !this.#reflectingChecked) {\n this.#initialChecked = this.checked;\n }\n return;\n }\n\n super.attributeChangedCallback?.(name, oldValue, newValue);\n }\n\n override formResetCallback() {\n this.checked = this.#initialChecked ?? false;\n this.indeterminate = false;\n this.updateCheckedState();\n }\n\n override formStateRestoreCallback(state: string | null, _reason?: string) {\n this.checked = state !== null;\n this.updateCheckedState();\n }\n\n override reportValidity() {\n this.#checkCheckboxValidity();\n return this._internals.reportValidity();\n }\n\n override checkValidity() {\n return this.#checkCheckboxValidity();\n }\n\n override setCustomValidity(message: string) {\n this.#customValidityMessage = message;\n this.checkValidity();\n }\n\n override _updateFormState() {\n this.updateCheckedState();\n }\n\n updateCheckedState() {\n this._internals.setFormValue(this.name && this.checked && !this.disabled ? this.value : null);\n toggleState(this._internals, 'checked', this.checked);\n toggleState(this._internals, 'indeterminate', this.indeterminate);\n this.checkValidity();\n }\n\n toggle(event?: Event) {\n if (this.disabled || this.readOnly || event?.defaultPrevented) {\n return;\n }\n\n this.checked = !this.checked;\n this.indeterminate = false;\n this.dispatchInputEvent();\n this.dispatchChangeEvent();\n }\n\n #checkCheckboxValidity() {\n if (this.noValidate) {\n this.setValidity({});\n return true;\n }\n\n if (this.#customValidityMessage) {\n this.setValidity({ customError: true }, this.#customValidityMessage);\n return false;\n }\n\n if (this.required && !this.checked) {\n this.setValidity({ valueMissing: true }, 'Select this option');\n return false;\n }\n\n return super.checkValidity();\n }\n\n #handleCheckboxAttributeChange(name: string, newValue: string | null) {\n if (name === 'checked') {\n this.#setChecked(newValue !== null);\n return true;\n }\n\n if (name === 'indeterminate') {\n this.#setIndeterminate(newValue !== null);\n return true;\n }\n\n if (name === 'value') {\n this.#setValue(newValue ?? 'on');\n return true;\n }\n\n return false;\n }\n\n #setChecked(checked: boolean) {\n const previousValue = this.#checked;\n this.#checked = checked;\n this.updateCheckedState();\n this.requestUpdate?.('checked', previousValue);\n }\n\n #setIndeterminate(indeterminate: boolean) {\n const previousValue = this.#indeterminate;\n this.#indeterminate = indeterminate;\n toggleState(this._internals, 'indeterminate', indeterminate);\n this.requestUpdate?.('indeterminate', previousValue);\n }\n\n #setValue(value: string) {\n const previousValue = this.value;\n checkboxValues.set(this, value);\n this.updateCheckedState();\n this.requestUpdate?.('value', previousValue);\n }\n } as unknown as CheckboxFormControlMixinReturn<TBase>;\n}\n\nfunction getCheckboxValue(value: unknown) {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return `${value}`;\n }\n\n return 'on';\n}\n"],"mappings":";;;AAgEA,IAAM,oBAAiB,IAAI,QAAwB,GAC7C,oBAAwB,IA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+B,GAAc,GAAyB;GAgBpE,OAfI,MAAS,aACX,KAAKR,GAAY,MAAa,IAAI,GAC3B,MAGL,MAAS,mBACX,KAAKG,GAAkB,MAAa,IAAI,GACjC,MAGL,MAAS,WACX,KAAKC,GAAU,KAAY,IAAI,GACxB,MAGF;EACT;EAEA,GAAY,GAAkB;GAC5B,IAAM,IAAgB,KAAKL;GAG3B,AAFA,KAAKA,KAAW,GAChB,KAAK,mBAAmB,GACxB,KAAK,gBAAgB,WAAW,CAAa;EAC/C;EAEA,GAAkB,GAAwB;GACxC,IAAM,IAAgB,KAAKG;GAG3B,AAFA,KAAKA,KAAiB,GACtB,EAAY,KAAK,YAAY,iBAAiB,CAAa,GAC3D,KAAK,gBAAgB,iBAAiB,CAAa;EACrD;EAEA,GAAU,GAAe;GACvB,IAAM,IAAgB,KAAK;GAG3B,AAFA,EAAe,IAAI,MAAM,CAAK,GAC9B,KAAK,mBAAmB,GACxB,KAAK,gBAAgB,SAAS,CAAa;EAC7C;CACF;AACF;AAEA,SAAS,EAAiB,GAAgB;CAKxC,OAJI,OAAO,KAAU,YAAY,OAAO,KAAU,YAAY,OAAO,KAAU,YACtE,GAAG,MAGL;AACT"}
1
+ {"version":3,"file":"checkbox.js","names":[],"sources":["../../src/mixins/checkbox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { FormControlValue } from '../internal/types.js';\nimport { toggleState } from '../internal/utils.js';\nimport { FormControlMixin, type FormControlMixinInstance } from './index.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 type CheckboxFormControlValue = Extract<FormControlValue, string>;\n\nexport interface CheckboxFormControlMixinInstance extends FormControlMixinInstance<CheckboxFormControlValue> {\n /**\n * Shows whether the checkbox currently has a checked value.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#checked\n * @attr checked\n * @reflect\n */\n checked: boolean;\n\n /**\n * Indicates whether the checkbox is visually indeterminate.\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/indeterminate\n * @attr indeterminate\n * @reflect\n */\n indeterminate: boolean;\n\n /** Restores the checked state from a saved form value. */\n formStateRestoreCallback(state: string | null, reason?: string): void;\n\n updateCheckedState(): void;\n\n /**\n * Toggles the checked state.\n */\n toggle(event?: Event): void;\n}\n\nexport type CheckboxFormControlMixinReturn<TBase extends Constructor> = (new (\n ...args: ConstructorParameters<TBase>\n) => InstanceType<TBase> & CheckboxFormControlMixinInstance) & {\n formAssociated: boolean;\n observedAttributes: string[];\n} & Omit<TBase, 'prototype'>;\n\ninterface CheckboxBaseInstance extends HTMLElement, FormControlMixinInstance<CheckboxFormControlValue> {\n connectedCallback(): void;\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;\n requestUpdate?(name?: string, oldValue?: unknown): void;\n}\n\ntype CheckboxBaseConstructor<TBase extends Constructor> = (new (\n ...args: ConstructorParameters<TBase>\n) => CheckboxBaseInstance) & {\n formAssociated: boolean;\n observedAttributes: string[];\n};\n\nconst checkboxValues = new WeakMap<object, string>();\nconst constructedCheckboxes = new WeakSet();\n\n/**\n * @description A mixin that adds native checkbox-style form control behavior.\n */\nexport function CheckboxFormControlMixin<TBase extends Constructor>(\n SuperClass: TBase\n): CheckboxFormControlMixinReturn<TBase> {\n const Base = FormControlMixin<TBase, CheckboxFormControlValue>(SuperClass) as CheckboxBaseConstructor<TBase>;\n\n return class CheckboxFormControlBase extends Base {\n #checked = false;\n\n #customValidityMessage = '';\n\n #indeterminate = false;\n\n #initialChecked: boolean | undefined;\n\n #reflectingChecked = false;\n\n constructor(...args: ConstructorParameters<TBase>) {\n super(...args);\n constructedCheckboxes.add(this);\n }\n\n static get observedAttributes() {\n return super.observedAttributes.concat(['checked', 'indeterminate']);\n }\n\n get checked(): boolean {\n return this.#checked;\n }\n\n set checked(value: boolean) {\n this.#setChecked(value ?? false);\n this.#reflectingChecked = true;\n this.toggleAttribute('checked', this.#checked);\n this.#reflectingChecked = false;\n }\n\n override get disabled(): boolean {\n return super.disabled;\n }\n\n override set disabled(value: boolean) {\n super.disabled = value ?? false;\n if (constructedCheckboxes.has(this)) {\n this.updateCheckedState();\n }\n }\n\n get indeterminate(): boolean {\n return this.#indeterminate;\n }\n\n set indeterminate(value: boolean) {\n this.#setIndeterminate(value ?? false);\n this.toggleAttribute('indeterminate', this.#indeterminate);\n }\n\n override get type(): string {\n return 'checkbox';\n }\n\n override set type(_value: string) {}\n\n override get value(): CheckboxFormControlValue {\n return checkboxValues.get(this) ?? 'on';\n }\n\n override set value(value: CheckboxFormControlValue | number | boolean) {\n this.#setValue(getCheckboxValue(value));\n this.setAttribute('value', this.value);\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#initialChecked ??= this.checked;\n this.updateCheckedState();\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n if (oldValue === newValue) {\n return;\n }\n\n if (this.#handleCheckboxAttributeChange(name, newValue)) {\n if (name === 'checked' && !this.#reflectingChecked) {\n this.#initialChecked = this.checked;\n }\n return;\n }\n\n super.attributeChangedCallback?.(name, oldValue, newValue);\n }\n\n override formResetCallback() {\n this.checked = this.#initialChecked ?? false;\n this.indeterminate = false;\n this.updateCheckedState();\n }\n\n override formStateRestoreCallback(state: string | null, _reason?: string) {\n this.checked = state !== null;\n this.updateCheckedState();\n }\n\n override reportValidity() {\n this.#checkCheckboxValidity();\n return this._internals.reportValidity();\n }\n\n override checkValidity() {\n return this.#checkCheckboxValidity();\n }\n\n override setCustomValidity(message: string) {\n this.#customValidityMessage = message;\n this.checkValidity();\n }\n\n override _updateFormState() {\n this.updateCheckedState();\n }\n\n updateCheckedState() {\n this._internals.setFormValue(this.name && this.checked && !this.disabled ? this.value : null);\n toggleState(this._internals, 'checked', this.checked);\n toggleState(this._internals, 'indeterminate', this.indeterminate);\n this.checkValidity();\n }\n\n toggle(event?: Event) {\n if (this.disabled || this.readOnly || event?.defaultPrevented) {\n return;\n }\n\n this.checked = !this.checked;\n this.indeterminate = false;\n this.dispatchInputEvent();\n this.dispatchChangeEvent();\n }\n\n #checkCheckboxValidity() {\n if (this.noValidate) {\n this.setValidity({});\n return true;\n }\n\n if (this.#customValidityMessage) {\n this.setValidity({ customError: true }, this.#customValidityMessage);\n return false;\n }\n\n if (this.required && !this.checked) {\n this.setValidity({ valueMissing: true }, 'Select this option');\n return false;\n }\n\n return super.checkValidity();\n }\n\n #handleCheckboxAttributeChange(name: string, newValue: string | null) {\n if (name === 'checked') {\n this.#setChecked(newValue !== null);\n return true;\n }\n\n if (name === 'indeterminate') {\n this.#setIndeterminate(newValue !== null);\n return true;\n }\n\n if (name === 'value') {\n this.#setValue(newValue ?? 'on');\n return true;\n }\n\n return false;\n }\n\n #setChecked(checked: boolean) {\n const previousValue = this.#checked;\n this.#checked = checked;\n this.updateCheckedState();\n this.requestUpdate?.('checked', previousValue);\n }\n\n #setIndeterminate(indeterminate: boolean) {\n const previousValue = this.#indeterminate;\n this.#indeterminate = indeterminate;\n toggleState(this._internals, 'indeterminate', indeterminate);\n this.requestUpdate?.('indeterminate', previousValue);\n }\n\n #setValue(value: string) {\n const previousValue = this.value;\n checkboxValues.set(this, value);\n this.updateCheckedState();\n this.requestUpdate?.('value', previousValue);\n }\n } as unknown as CheckboxFormControlMixinReturn<TBase>;\n}\n\nfunction getCheckboxValue(value: unknown) {\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return `${value}`;\n }\n\n return 'on';\n}\n"],"mappings":";;;AAmEA,IAAM,oBAAiB,IAAI,QAAwB,GAC7C,oBAAwB,IAAI,QAAQ;AAK1C,SAAgB,EACd,GACuC;CACv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GAC3B,MAGL,MAAS,mBACX,KAAK,GAAkB,MAAa,IAAI,GACjC,MAGL,MAAS,YACX,KAAK,GAAU,KAAY,IAAI,GACxB;EAIX;EAEA,GAAY,GAAkB;GAC5B,IAAM,IAAgB,KAAK;GAG3B,AAFA,KAAK,KAAW,GAChB,KAAK,mBAAmB,GACxB,KAAK,gBAAgB,WAAW,CAAa;EAC/C;EAEA,GAAkB,GAAwB;GACxC,IAAM,IAAgB,KAAK;GAG3B,AAFA,KAAK,KAAiB,GACtB,EAAY,KAAK,YAAY,iBAAiB,CAAa,GAC3D,KAAK,gBAAgB,iBAAiB,CAAa;EACrD;EAEA,GAAU,GAAe;GACvB,IAAM,IAAgB,KAAK;GAG3B,AAFA,EAAe,IAAI,MAAM,CAAK,GAC9B,KAAK,mBAAmB,GACxB,KAAK,gBAAgB,SAAS,CAAa;EAC7C;CACF;AACF;AAEA,SAAS,EAAiB,GAAgB;CAKxC,OAJI,OAAO,KAAU,YAAY,OAAO,KAAU,YAAY,OAAO,KAAU,YACtE,GAAG,MAGL;AACT"}
@@ -245,10 +245,10 @@ function a(a) {
245
245
  this.value = e === null ? void 0 : t(this.localName, e, this._metadata.valueSchema), this._initialValue = structuredClone(this.value), this.#t = !0;
246
246
  }
247
247
  #u(e, t) {
248
- return e === "readonly" ? (this.readOnly = t !== null, !0) : e === "disabled" ? (this.disabled = t !== null, !0) : e === "required" ? (this.required = t !== null, !0) : e === "novalidate" ? (this.noValidate = t !== null, this.checkValidity(), !0) : !1;
248
+ return e === "readonly" ? (this.readOnly = t !== null, !0) : e === "disabled" ? (this.disabled = t !== null, !0) : e === "required" ? (this.required = t !== null, !0) : e === "novalidate" && (this.noValidate = t !== null, this.checkValidity(), !0);
249
249
  }
250
250
  #d(e, t) {
251
- return e === "name" ? (this.name = t ?? "", !0) : e === "pattern" ? (this.pattern = t ?? "", !0) : !1;
251
+ return e === "name" ? (this.name = t ?? "", !0) : e === "pattern" && (this.pattern = t ?? "", !0);
252
252
  }
253
253
  #f(e, t) {
254
254
  e === "min" ? this.min = u(t) : e === "max" ? this.max = u(t) : e === "step" ? this.step = u(t) : e === "minlength" ? this.minLength = f(t) : e === "maxlength" && (this.maxLength = f(t));
@@ -281,7 +281,7 @@ function a(a) {
281
281
  }), this._internals.setFormValue(e);
282
282
  } else if (Array.isArray(this.value)) {
283
283
  let e = new FormData();
284
- this.value.forEach((t) => e.append(`${this.name}`, t)), this._internals.setFormValue(e);
284
+ this.value.forEach((t) => e.append(this.name, t)), this._internals.setFormValue(e);
285
285
  } else this._internals.setFormValue(this.value);
286
286
  }
287
287
  _requestUpdate() {