@nvidia-elements/forms 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/custom-elements.json +86 -2
- package/dist/index.js +1 -1
- package/dist/internal/controllers/state-active.controller.d.ts +1 -1
- package/dist/internal/controllers/state-current.controller.d.ts +1 -1
- package/dist/internal/controllers/state-disabled.controller.d.ts +1 -1
- package/dist/internal/controllers/state-expanded.controller.d.ts +1 -1
- package/dist/internal/controllers/state-pressed.controller.d.ts +1 -1
- package/dist/internal/controllers/state-readonly.controller.d.ts +1 -1
- package/dist/internal/controllers/state-selected.controller.d.ts +1 -1
- package/dist/internal/controllers/type-anchor.controller.d.ts +1 -1
- package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.d.ts +1 -1
- package/dist/internal/controllers/type-command.controller.d.ts +5 -2
- package/dist/internal/controllers/type-command.controller.js +10 -9
- package/dist/internal/controllers/type-command.controller.js.map +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.d.ts +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.js +32 -21
- package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.d.ts +2 -3
- package/dist/internal/controllers/type-popover-trigger.controller.js +2 -2
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/internal/controllers/type-submit.controller.d.ts +2 -2
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +2 -0
- package/dist/internal/schema.d.ts +1 -1
- package/dist/internal/schema.js +1 -1
- package/dist/internal/schema.js.map +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/mixins/button.d.ts +1 -1
- package/dist/mixins/button.js +133 -143
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/button.types.d.ts +1 -6
- package/dist/mixins/checkbox.d.ts +2 -2
- package/dist/mixins/control.d.ts +1 -1
- package/dist/mixins/control.js.map +1 -1
- package/dist/mixins/select.d.ts +2 -2
- package/dist/mixins/select.js.map +1 -1
- package/dist/mixins/slider.d.ts +2 -2
- package/dist/mixins/slider.js.map +1 -1
- package/dist/validators/index.d.ts +1 -1
- package/package.json +16 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
## <small>2.0.4 (2026-07-21)</small>
|
|
2
|
+
|
|
3
|
+
* fix(cli): improve api metadata ([b2c13ab](https://github.com/NVIDIA/elements/commit/b2c13ab))
|
|
4
|
+
* fix(cli): mute interactions on non tty sessions ([ba3230a](https://github.com/NVIDIA/elements/commit/ba3230a))
|
|
5
|
+
* fix(code): include custom data documentation references ([f4efebb](https://github.com/NVIDIA/elements/commit/f4efebb))
|
|
6
|
+
* fix(core): align root tree nodes ([6008461](https://github.com/NVIDIA/elements/commit/6008461))
|
|
7
|
+
* fix(core): api documentation ([a02b9e2](https://github.com/NVIDIA/elements/commit/a02b9e2))
|
|
8
|
+
* fix(core): collapsed tab group ([b7be2d9](https://github.com/NVIDIA/elements/commit/b7be2d9))
|
|
9
|
+
* fix(core): ensure proper property and attribute reflection for button types ([af780c6](https://github.com/NVIDIA/elements/commit/af780c6))
|
|
10
|
+
* fix(core): include custom data documentation references ([bf9168c](https://github.com/NVIDIA/elements/commit/bf9168c))
|
|
11
|
+
* fix(core): page header text wrap issue ([03c481f](https://github.com/NVIDIA/elements/commit/03c481f))
|
|
12
|
+
* fix(forms): proper property and attribute reflection for button mixin ([e6093dd](https://github.com/NVIDIA/elements/commit/e6093dd))
|
|
13
|
+
* fix(lint): enhance data binding checks and update test cases for popover triggers ([56e4701](https://github.com/NVIDIA/elements/commit/56e4701))
|
|
14
|
+
* fix(lint): support framework event bindings ([4a1e72d](https://github.com/NVIDIA/elements/commit/4a1e72d))
|
|
15
|
+
* fix(markdown): include custom data documentation references ([b887400](https://github.com/NVIDIA/elements/commit/b887400))
|
|
16
|
+
* fix(monaco): include custom data documentation references ([75f42f5](https://github.com/NVIDIA/elements/commit/75f42f5))
|
|
17
|
+
* chore(ci): indexnow doc updates ([669552f](https://github.com/NVIDIA/elements/commit/669552f))
|
|
18
|
+
* chore(ci): update lighthouse ([b5b71ca](https://github.com/NVIDIA/elements/commit/b5b71ca))
|
|
19
|
+
* chore(ci): update metrics ([96ebb4b](https://github.com/NVIDIA/elements/commit/96ebb4b))
|
|
20
|
+
* chore(docs): add custom data reference tests ([af48603](https://github.com/NVIDIA/elements/commit/af48603))
|
|
21
|
+
* chore(internals): generate custom data references ([3f2bd36](https://github.com/NVIDIA/elements/commit/3f2bd36))
|
|
22
|
+
* chore(release): @nvidia-elements/cli-v2.1.5 [skip ci] ([7e217b8](https://github.com/NVIDIA/elements/commit/7e217b8))
|
|
23
|
+
* chore(release): @nvidia-elements/code-v2.0.2 [skip ci] ([f69e036](https://github.com/NVIDIA/elements/commit/f69e036))
|
|
24
|
+
* chore(release): @nvidia-elements/core-v2.1.0 [skip ci] ([9a874bd](https://github.com/NVIDIA/elements/commit/9a874bd))
|
|
25
|
+
* chore(release): @nvidia-elements/core-v2.1.1 [skip ci] ([3e67a33](https://github.com/NVIDIA/elements/commit/3e67a33))
|
|
26
|
+
* chore(release): @nvidia-elements/core-v2.1.2 [skip ci] ([051719c](https://github.com/NVIDIA/elements/commit/051719c))
|
|
27
|
+
* chore(release): @nvidia-elements/core-v2.1.3 [skip ci] ([b6c09ba](https://github.com/NVIDIA/elements/commit/b6c09ba))
|
|
28
|
+
* chore(release): @nvidia-elements/lint-v2.1.0 [skip ci] ([e668854](https://github.com/NVIDIA/elements/commit/e668854))
|
|
29
|
+
* chore(release): @nvidia-elements/lint-v2.1.1 [skip ci] ([efb7a71](https://github.com/NVIDIA/elements/commit/efb7a71))
|
|
30
|
+
* chore(release): @nvidia-elements/markdown-v2.0.2 [skip ci] ([953ef48](https://github.com/NVIDIA/elements/commit/953ef48))
|
|
31
|
+
* chore(release): @nvidia-elements/monaco-v2.0.2 [skip ci] ([12820b1](https://github.com/NVIDIA/elements/commit/12820b1))
|
|
32
|
+
* chore(release): @nvidia-elements/styles-v2.1.0 [skip ci] ([25eb987](https://github.com/NVIDIA/elements/commit/25eb987))
|
|
33
|
+
* feat(lint): add prefer-aria-label-in-compact-containers rule ([130279f](https://github.com/NVIDIA/elements/commit/130279f))
|
|
34
|
+
|
|
35
|
+
## <small>2.0.3 (2026-07-18)</small>
|
|
36
|
+
|
|
37
|
+
* chore(ci): improve test coverage ([4ef2eb3](https://github.com/NVIDIA/elements/commit/4ef2eb3))
|
|
38
|
+
* chore(ci): update lighthouse ([4bffdb2](https://github.com/NVIDIA/elements/commit/4bffdb2))
|
|
39
|
+
* chore(ci): update stylelint to version ([522e1c4](https://github.com/NVIDIA/elements/commit/522e1c4))
|
|
40
|
+
* chore(ci): upgrade built to ts7 rc ([77117a1](https://github.com/NVIDIA/elements/commit/77117a1))
|
|
41
|
+
* chore(release): @nvidia-elements/core-v2.0.4 [skip ci] ([d91da36](https://github.com/NVIDIA/elements/commit/d91da36))
|
|
42
|
+
* feat(core): gauge ([70e115d](https://github.com/NVIDIA/elements/commit/70e115d))
|
|
43
|
+
* feat(styles): add grow option for nve-text ([0b895ff](https://github.com/NVIDIA/elements/commit/0b895ff))
|
|
44
|
+
* fix(docs): enhance decorator transpilation ([a08584b](https://github.com/NVIDIA/elements/commit/a08584b))
|
|
45
|
+
* fix(forms): export controller ([1808462](https://github.com/NVIDIA/elements/commit/1808462))
|
|
46
|
+
|
|
1
47
|
## <small>2.0.2 (2026-07-08)</small>
|
|
2
48
|
|
|
3
49
|
* fix(cli): correct case sensitive identifiers ([6c8cd2b](https://github.com/NVIDIA/elements/commit/6c8cd2b))
|
|
@@ -503,6 +503,23 @@
|
|
|
503
503
|
"description": "",
|
|
504
504
|
"name": "TypeCommandController",
|
|
505
505
|
"members": [
|
|
506
|
+
{
|
|
507
|
+
"kind": "field",
|
|
508
|
+
"name": "#events",
|
|
509
|
+
"privacy": "private",
|
|
510
|
+
"type": {
|
|
511
|
+
"text": "readonly string[]",
|
|
512
|
+
"_sourceAliases": [],
|
|
513
|
+
"values": [
|
|
514
|
+
{
|
|
515
|
+
"value": "readonly string[]",
|
|
516
|
+
"description": ""
|
|
517
|
+
}
|
|
518
|
+
]
|
|
519
|
+
},
|
|
520
|
+
"readonly": true,
|
|
521
|
+
"default": "[...new Set(events)]"
|
|
522
|
+
},
|
|
506
523
|
{
|
|
507
524
|
"kind": "method",
|
|
508
525
|
"name": "hostUpdated"
|
|
@@ -518,7 +535,7 @@
|
|
|
518
535
|
},
|
|
519
536
|
{
|
|
520
537
|
"kind": "field",
|
|
521
|
-
"name": "#
|
|
538
|
+
"name": "#onCommand",
|
|
522
539
|
"privacy": "private"
|
|
523
540
|
},
|
|
524
541
|
{
|
|
@@ -559,6 +576,17 @@
|
|
|
559
576
|
"description": "",
|
|
560
577
|
"name": "TypeInterestInvokerController",
|
|
561
578
|
"members": [
|
|
579
|
+
{
|
|
580
|
+
"kind": "field",
|
|
581
|
+
"name": "#inferredInterestForElement",
|
|
582
|
+
"privacy": "private",
|
|
583
|
+
"type": {
|
|
584
|
+
"text": "HTMLElement | null",
|
|
585
|
+
"_sourceAliases": [],
|
|
586
|
+
"values": []
|
|
587
|
+
},
|
|
588
|
+
"default": "null"
|
|
589
|
+
},
|
|
562
590
|
{
|
|
563
591
|
"kind": "method",
|
|
564
592
|
"name": "hostConnected"
|
|
@@ -579,8 +607,49 @@
|
|
|
579
607
|
},
|
|
580
608
|
{
|
|
581
609
|
"kind": "method",
|
|
582
|
-
"name": "#
|
|
610
|
+
"name": "#dispatchInterestEvent",
|
|
611
|
+
"privacy": "private",
|
|
612
|
+
"parameters": [
|
|
613
|
+
{
|
|
614
|
+
"name": "type",
|
|
615
|
+
"type": {
|
|
616
|
+
"text": "'interest' | 'loseinterest'"
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"kind": "method",
|
|
623
|
+
"name": "#getInterestForElement",
|
|
583
624
|
"privacy": "private"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"kind": "method",
|
|
628
|
+
"name": "#getExplicitInterestForElement",
|
|
629
|
+
"privacy": "private",
|
|
630
|
+
"return": {
|
|
631
|
+
"type": {
|
|
632
|
+
"text": "HTMLElement | null | undefined"
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"kind": "method",
|
|
638
|
+
"name": "#getHintPopoverTarget",
|
|
639
|
+
"privacy": "private"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
"kind": "method",
|
|
643
|
+
"name": "#getElementById",
|
|
644
|
+
"privacy": "private",
|
|
645
|
+
"parameters": [
|
|
646
|
+
{
|
|
647
|
+
"name": "id",
|
|
648
|
+
"type": {
|
|
649
|
+
"text": "string | null"
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
]
|
|
584
653
|
}
|
|
585
654
|
]
|
|
586
655
|
}
|
|
@@ -855,6 +924,21 @@
|
|
|
855
924
|
}
|
|
856
925
|
]
|
|
857
926
|
},
|
|
927
|
+
{
|
|
928
|
+
"kind": "javascript-module",
|
|
929
|
+
"path": "/src/internal/index.js",
|
|
930
|
+
"declarations": [],
|
|
931
|
+
"exports": [
|
|
932
|
+
{
|
|
933
|
+
"kind": "js",
|
|
934
|
+
"name": "TypeCommandController",
|
|
935
|
+
"declaration": {
|
|
936
|
+
"name": "TypeCommandController",
|
|
937
|
+
"module": "./controllers/type-command.controller.js"
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
]
|
|
941
|
+
},
|
|
858
942
|
{
|
|
859
943
|
"kind": "javascript-module",
|
|
860
944
|
"path": "/src/internal/schema.js",
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-anchor.controller.js","names":["#readOnly","#updateAnchorSlotAssignment","#anchor","#parentAnchor","#setupAnchorClickBehavior","#removeAnchorClickBehavior","#slottedAnchor","#defaultSlot","#anchorSlot","#anchorClickTarget","#onAnchorClick"],"sources":["../../../src/internal/controllers/type-anchor.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { removeEmptyTextNode } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype AnchorBehaviorHost = ReactiveElement & {\n disabled: boolean;\n readOnly: boolean;\n _internals?: ElementInternals;\n};\n\nexport class TypeAnchorController<T extends AnchorBehaviorHost> implements ReactiveController {\n #anchorClickTarget: HTMLAnchorElement | null = null;\n #readOnly = false;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get readOnly() {\n return this.#readOnly;\n }\n\n hostUpdated() {\n this.#updateAnchorSlotAssignment();\n const anchor = this.#anchor;\n this.#readOnly = Boolean(anchor);\n\n if (anchor) {\n this.host._internals!.states.add('anchor');\n } else {\n this.host._internals!.states.delete('anchor');\n }\n\n if (this.#parentAnchor) {\n this.#parentAnchor.style.textDecoration = 'none';\n this.host.style.cursor = 'pointer';\n }\n\n this.#setupAnchorClickBehavior(anchor);\n }\n\n hostDisconnected() {\n this.#removeAnchorClickBehavior();\n }\n\n get #anchor() {\n return this.#slottedAnchor ?? this.#parentAnchor;\n }\n\n get #slottedAnchor() {\n return this.host.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot, slot[name=anchor]')\n ?.assignedElements()\n ?.find(element => element?.tagName === 'A') as HTMLAnchorElement | undefined;\n }\n\n get #parentAnchor() {\n return this.host.parentElement?.tagName === 'A' ? (this.host.parentElement as HTMLAnchorElement) : null;\n }\n\n get #defaultSlot() {\n return this.host.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n }\n\n get #anchorSlot() {\n return this.host.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=anchor]');\n }\n\n #updateAnchorSlotAssignment() {\n if (this.#anchor && this.#anchorSlot) {\n this.#anchor.slot = 'anchor';\n this.#defaultSlot?.assignedNodes().forEach(node => removeEmptyTextNode(node));\n }\n }\n\n #setupAnchorClickBehavior(anchor: HTMLAnchorElement | null | undefined) {\n this.#removeAnchorClickBehavior();\n this.#anchorClickTarget = anchor ?? null;\n this.#anchorClickTarget?.addEventListener('click', this.#onAnchorClick);\n }\n\n #removeAnchorClickBehavior() {\n this.#anchorClickTarget?.removeEventListener('click', this.#onAnchorClick);\n this.#anchorClickTarget = null;\n }\n\n #onAnchorClick = (event: Event) => {\n if (this.host.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n}\n"],"mappings":";;AAYA,IAAa,IAAb,MAA8F;CAC5F,KAA+C;CAC/C,KAAY;CAEZ,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,WAAW;EACb,OAAO,KAAKA;CACd;CAEA,cAAc;EACZ,KAAKC,GAA4B;EACjC,IAAM,IAAS,KAAKC;EAcpB,AAbA,KAAKF,KAAY,EAAQ,GAErB,IACF,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,IAEzC,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ,GAG1C,KAAKG,OACP,KAAKA,GAAc,MAAM,iBAAiB,QAC1C,KAAK,KAAK,MAAM,SAAS,YAG3B,KAAKC,GAA0B,CAAM;CACvC;CAEA,mBAAmB;EACjB,KAAKC,GAA2B;CAClC;CAEA,IAAIH,KAAU;EACZ,OAAO,KAAKI,MAAkB,KAAKH;CACrC;CAEA,IAAIG,KAAiB;EACnB,OAAO,KAAK,KAAK,YACb,cAA+B,yBAAyB,
|
|
1
|
+
{"version":3,"file":"type-anchor.controller.js","names":["#readOnly","#updateAnchorSlotAssignment","#anchor","#parentAnchor","#setupAnchorClickBehavior","#removeAnchorClickBehavior","#slottedAnchor","#defaultSlot","#anchorSlot","#anchorClickTarget","#onAnchorClick"],"sources":["../../../src/internal/controllers/type-anchor.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { removeEmptyTextNode } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype AnchorBehaviorHost = ReactiveElement & {\n disabled: boolean;\n readOnly: boolean;\n _internals?: ElementInternals;\n};\n\nexport class TypeAnchorController<T extends AnchorBehaviorHost> implements ReactiveController {\n #anchorClickTarget: HTMLAnchorElement | null = null;\n #readOnly = false;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n get readOnly() {\n return this.#readOnly;\n }\n\n hostUpdated() {\n this.#updateAnchorSlotAssignment();\n const anchor = this.#anchor;\n this.#readOnly = Boolean(anchor);\n\n if (anchor) {\n this.host._internals!.states.add('anchor');\n } else {\n this.host._internals!.states.delete('anchor');\n }\n\n if (this.#parentAnchor) {\n this.#parentAnchor.style.textDecoration = 'none';\n this.host.style.cursor = 'pointer';\n }\n\n this.#setupAnchorClickBehavior(anchor);\n }\n\n hostDisconnected() {\n this.#removeAnchorClickBehavior();\n }\n\n get #anchor() {\n return this.#slottedAnchor ?? this.#parentAnchor;\n }\n\n get #slottedAnchor() {\n return this.host.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot, slot[name=anchor]')\n ?.assignedElements()\n ?.find(element => element?.tagName === 'A') as HTMLAnchorElement | undefined;\n }\n\n get #parentAnchor() {\n return this.host.parentElement?.tagName === 'A' ? (this.host.parentElement as HTMLAnchorElement) : null;\n }\n\n get #defaultSlot() {\n return this.host.shadowRoot?.querySelector<HTMLSlotElement>('slot:not([name])');\n }\n\n get #anchorSlot() {\n return this.host.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=anchor]');\n }\n\n #updateAnchorSlotAssignment() {\n if (this.#anchor && this.#anchorSlot) {\n this.#anchor.slot = 'anchor';\n this.#defaultSlot?.assignedNodes().forEach(node => removeEmptyTextNode(node));\n }\n }\n\n #setupAnchorClickBehavior(anchor: HTMLAnchorElement | null | undefined) {\n this.#removeAnchorClickBehavior();\n this.#anchorClickTarget = anchor ?? null;\n this.#anchorClickTarget?.addEventListener('click', this.#onAnchorClick);\n }\n\n #removeAnchorClickBehavior() {\n this.#anchorClickTarget?.removeEventListener('click', this.#onAnchorClick);\n this.#anchorClickTarget = null;\n }\n\n #onAnchorClick = (event: Event) => {\n if (this.host.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n}\n"],"mappings":";;AAYA,IAAa,IAAb,MAA8F;CAC5F,KAA+C;CAC/C,KAAY;CAEZ,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,WAAW;EACb,OAAO,KAAKA;CACd;CAEA,cAAc;EACZ,KAAKC,GAA4B;EACjC,IAAM,IAAS,KAAKC;EAcpB,AAbA,KAAKF,KAAY,EAAQ,GAErB,IACF,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,IAEzC,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ,GAG1C,KAAKG,OACP,KAAKA,GAAc,MAAM,iBAAiB,QAC1C,KAAK,KAAK,MAAM,SAAS,YAG3B,KAAKC,GAA0B,CAAM;CACvC;CAEA,mBAAmB;EACjB,KAAKC,GAA2B;CAClC;CAEA,IAAIH,KAAU;EACZ,OAAO,KAAKI,MAAkB,KAAKH;CACrC;CAEA,IAAIG,KAAiB;EACnB,OAAO,KAAK,KAAK,YACb,cAA+B,yBAAyB,CAAC,EACzD,iBAAiB,CAAC,EAClB,MAAK,MAAW,GAAS,YAAY,GAAG;CAC9C;CAEA,IAAIH,KAAgB;EAClB,OAAO,KAAK,KAAK,eAAe,YAAY,MAAO,KAAK,KAAK,gBAAsC;CACrG;CAEA,IAAII,KAAe;EACjB,OAAO,KAAK,KAAK,YAAY,cAA+B,kBAAkB;CAChF;CAEA,IAAIC,KAAc;EAChB,OAAO,KAAK,KAAK,YAAY,cAA+B,mBAAmB;CACjF;CAEA,KAA8B;EAC5B,AAAI,KAAKN,MAAW,KAAKM,OACvB,KAAKN,GAAQ,OAAO,UACpB,KAAKK,IAAc,cAAc,CAAC,CAAC,SAAQ,MAAQ,EAAoB,CAAI,CAAC;CAEhF;CAEA,GAA0B,GAA8C;EAGtE,AAFA,KAAKF,GAA2B,GAChC,KAAKI,KAAqB,KAAU,MACpC,KAAKA,IAAoB,iBAAiB,SAAS,KAAKC,EAAc;CACxE;CAEA,KAA6B;EAE3B,AADA,KAAKD,IAAoB,oBAAoB,SAAS,KAAKC,EAAc,GACzE,KAAKD,KAAqB;CAC5B;CAEA,MAAkB,MAAiB;EACjC,AAAI,KAAK,KAAK,aACZ,EAAM,eAAe,GACrB,EAAM,yBAAyB;CAEnC;AACF"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from './types.js';
|
|
1
|
+
import type { ReactiveController, ReactiveElement } from './types.js';
|
|
2
2
|
type CommandBehaviorHost = ReactiveElement & {
|
|
3
3
|
command?: string;
|
|
4
4
|
commandForElement: HTMLElement | null;
|
|
5
5
|
disabled: boolean;
|
|
6
6
|
readOnly: boolean;
|
|
7
7
|
};
|
|
8
|
+
type TypeCommandControllerOptions = {
|
|
9
|
+
events?: readonly string[];
|
|
10
|
+
};
|
|
8
11
|
export declare class TypeCommandController<T extends CommandBehaviorHost> implements ReactiveController {
|
|
9
12
|
#private;
|
|
10
13
|
private host;
|
|
11
|
-
constructor(host: T);
|
|
14
|
+
constructor(host: T, { events }?: TypeCommandControllerOptions);
|
|
12
15
|
hostUpdated(): void;
|
|
13
16
|
hostDisconnected(): void;
|
|
14
17
|
get target(): HTMLElement | null;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e } from "../utils.js";
|
|
2
2
|
//#region src/internal/controllers/type-command.controller.ts
|
|
3
3
|
var t = class {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
#e;
|
|
5
|
+
constructor(e, { events: t = ["click"] } = {}) {
|
|
6
|
+
this.host = e, this.#e = [...new Set(t)], this.host.addController(this);
|
|
6
7
|
}
|
|
7
8
|
hostUpdated() {
|
|
8
|
-
this.#
|
|
9
|
+
this.#t(), !this.host.readOnly && !this.host.disabled && this.#e.forEach((e) => this.host.addEventListener(e, this.#n));
|
|
9
10
|
}
|
|
10
11
|
hostDisconnected() {
|
|
11
|
-
this.#
|
|
12
|
+
this.#t();
|
|
12
13
|
}
|
|
13
|
-
#
|
|
14
|
-
this.host.removeEventListener(
|
|
14
|
+
#t() {
|
|
15
|
+
this.#e.forEach((e) => this.host.removeEventListener(e, this.#n));
|
|
15
16
|
}
|
|
16
|
-
#
|
|
17
|
-
e.defaultPrevented || this.#
|
|
17
|
+
#n = (e) => {
|
|
18
|
+
e.defaultPrevented || this.#r();
|
|
18
19
|
};
|
|
19
|
-
#
|
|
20
|
+
#r() {
|
|
20
21
|
if (this.host.readOnly || this.host.disabled || !this.host.command) return !1;
|
|
21
22
|
let e = this.target;
|
|
22
23
|
return e ? (e.dispatchEvent(new globalThis.CommandEvent("command", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-command.controller.js","names":["#removeCommandBehavior","#
|
|
1
|
+
{"version":3,"file":"type-command.controller.js","names":["#events","#removeCommandBehavior","#onCommand","#dispatchCommand"],"sources":["../../../src/internal/controllers/type-command.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype CommandBehaviorHost = ReactiveElement & {\n command?: string;\n commandForElement: HTMLElement | null;\n disabled: boolean;\n readOnly: boolean;\n};\n\ntype TypeCommandControllerOptions = {\n events?: readonly string[];\n};\n\nexport class TypeCommandController<T extends CommandBehaviorHost> implements ReactiveController {\n readonly #events: readonly string[];\n\n constructor(\n private host: T,\n { events = ['click'] }: TypeCommandControllerOptions = {}\n ) {\n this.#events = [...new Set(events)];\n this.host.addController(this);\n }\n\n hostUpdated() {\n this.#removeCommandBehavior();\n if (!this.host.readOnly && !this.host.disabled) {\n this.#events.forEach(eventType => this.host.addEventListener(eventType, this.#onCommand));\n }\n }\n\n hostDisconnected() {\n this.#removeCommandBehavior();\n }\n\n #removeCommandBehavior() {\n this.#events.forEach(eventType => this.host.removeEventListener(eventType, this.#onCommand));\n }\n\n #onCommand = (event: Event) => {\n if (!event.defaultPrevented) {\n this.#dispatchCommand();\n }\n };\n\n #dispatchCommand() {\n if (this.host.readOnly || this.host.disabled || !this.host.command) {\n return false;\n }\n\n const target = this.target;\n if (!target) {\n console.warn(\n 'commandForElement',\n this.host.commandForElement || this.host.getAttribute('commandfor'),\n 'not found'\n );\n return false;\n }\n\n target.dispatchEvent(new globalThis.CommandEvent('command', { command: this.host.command, source: this.host }));\n return true;\n }\n\n get target(): HTMLElement | null {\n if (this.host.commandForElement) {\n return this.host.commandForElement;\n }\n\n const id = this.host.getAttribute('commandfor');\n if (!id) {\n return null;\n }\n\n return getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(el => el.id === id) ?? null;\n }\n}\n"],"mappings":";;AAiBA,IAAa,IAAb,MAAgG;CAC9F;CAEA,YACE,GACA,EAAE,YAAS,CAAC,OAAO,MAAoC,CAAC,GACxD;EAEA,AAJQ,KAAA,OAAA,GAGR,KAAKA,KAAU,CAAC,GAAG,IAAI,IAAI,CAAM,CAAC,GAClC,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,cAAc;EAEZ,AADA,KAAKC,GAAuB,GACxB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,YACpC,KAAKD,GAAQ,SAAQ,MAAa,KAAK,KAAK,iBAAiB,GAAW,KAAKE,EAAU,CAAC;CAE5F;CAEA,mBAAmB;EACjB,KAAKD,GAAuB;CAC9B;CAEA,KAAyB;EACvB,KAAKD,GAAQ,SAAQ,MAAa,KAAK,KAAK,oBAAoB,GAAW,KAAKE,EAAU,CAAC;CAC7F;CAEA,MAAc,MAAiB;EAC7B,AAAK,EAAM,oBACT,KAAKC,GAAiB;CAE1B;CAEA,KAAmB;EACjB,IAAI,KAAK,KAAK,YAAY,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,SACzD,OAAO;EAGT,IAAM,IAAS,KAAK;EAWpB,OAVK,KASL,EAAO,cAAc,IAAI,WAAW,aAAa,WAAW;GAAE,SAAS,KAAK,KAAK;GAAS,QAAQ,KAAK;EAAK,CAAC,CAAC,GACvG,OATL,QAAQ,KACN,qBACA,KAAK,KAAK,qBAAqB,KAAK,KAAK,aAAa,YAAY,GAClE,WACF,GACO;CAKX;CAEA,IAAI,SAA6B;EAC/B,IAAI,KAAK,KAAK,mBACZ,OAAO,KAAK,KAAK;EAGnB,IAAM,IAAK,KAAK,KAAK,aAAa,YAAY;EAK9C,OAJK,IAIE,EAAoB,KAAK,KAAK,YAAY,CAAgB,CAAC,CAAC,MAAK,MAAM,EAAG,OAAO,CAAE,KAAK,OAHtF;CAIX;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactiveController, ReactiveElement } from './types.js';
|
|
1
|
+
import type { ReactiveController, ReactiveElement } from './types.js';
|
|
2
2
|
type InterestInvokerHost = ReactiveElement & {
|
|
3
3
|
interestForElement: HTMLElement | null;
|
|
4
4
|
popoverTargetElement: HTMLElement | null;
|
|
@@ -1,35 +1,46 @@
|
|
|
1
1
|
import { getFlattenedDOMTree as e } from "../utils.js";
|
|
2
2
|
//#region src/internal/controllers/type-interest-invoker.controller.ts
|
|
3
3
|
var t = class {
|
|
4
|
+
#e = null;
|
|
4
5
|
constructor(e) {
|
|
5
6
|
this.host = e, this.host.addController(this);
|
|
6
7
|
}
|
|
7
8
|
hostConnected() {
|
|
8
|
-
this.host.addEventListener("mouseenter", this.#
|
|
9
|
+
this.host.addEventListener("mouseenter", this.#t), this.host.addEventListener("mouseleave", this.#n), this.host.addEventListener("focus", this.#t), this.host.addEventListener("blur", this.#n);
|
|
9
10
|
}
|
|
10
11
|
hostDisconnected() {
|
|
11
|
-
this.host.removeEventListener("mouseenter", this.#
|
|
12
|
+
this.host.removeEventListener("mouseenter", this.#t), this.host.removeEventListener("mouseleave", this.#n), this.host.removeEventListener("focus", this.#t), this.host.removeEventListener("blur", this.#n);
|
|
12
13
|
}
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
let e = new Event("interest", { cancelable: !0 });
|
|
16
|
-
e.source = this.host, this.host.interestForElement.dispatchEvent(e);
|
|
17
|
-
}
|
|
14
|
+
#t = (e) => {
|
|
15
|
+
e.type === "focus" && !this.host.matches(":focus-visible") || this.host.popoverTargetElement?.matches(":popover-open") || this.#r("interest");
|
|
18
16
|
};
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
#n = () => this.#r("loseinterest");
|
|
18
|
+
#r(e) {
|
|
19
|
+
let t = this.#i();
|
|
20
|
+
if (!t) return;
|
|
21
|
+
let n = new Event(e, { cancelable: !0 });
|
|
22
|
+
n.source = this.host, t.dispatchEvent(n);
|
|
23
|
+
}
|
|
24
|
+
#i() {
|
|
25
|
+
let e = this.#a();
|
|
26
|
+
if (e !== void 0) return e;
|
|
27
|
+
let t = this.#o(), n = this.#e;
|
|
28
|
+
return this.#e = t, t && this.host.interestForElement !== t ? this.host.interestForElement = t : !t && n && this.host.interestForElement === n && (this.host.interestForElement = null), t;
|
|
29
|
+
}
|
|
30
|
+
#a() {
|
|
31
|
+
let e = this.host.getAttribute("interestfor");
|
|
32
|
+
if (e) return this.#e = null, this.#s(e);
|
|
33
|
+
let t = this.host.interestForElement;
|
|
34
|
+
if (!(!t || t === this.#e)) return this.#e = null, t;
|
|
35
|
+
}
|
|
36
|
+
#o() {
|
|
37
|
+
let e = this.host.popoverTargetElement;
|
|
38
|
+
if (e instanceof HTMLElement && e.popover === "hint") return e;
|
|
39
|
+
let t = this.#s(this.host.getAttribute("popovertarget"));
|
|
40
|
+
return t instanceof HTMLElement && t.popover === "hint" ? t : null;
|
|
41
|
+
}
|
|
42
|
+
#s(t) {
|
|
43
|
+
return t ? e(this.host.getRootNode()).find((e) => e.id === t) ?? null : null;
|
|
33
44
|
}
|
|
34
45
|
};
|
|
35
46
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-interest-invoker.controller.js","names":["#onInterest","#onLoseInterest","#
|
|
1
|
+
{"version":3,"file":"type-interest-invoker.controller.js","names":["#onInterest","#onLoseInterest","#dispatchInterestEvent","#getInterestForElement","#getExplicitInterestForElement","#getHintPopoverTarget","#inferredInterestForElement","#getElementById"],"sources":["../../../src/internal/controllers/type-interest-invoker.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getFlattenedDOMTree } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype InterestInvokerHost = ReactiveElement & {\n interestForElement: HTMLElement | null;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypeInterestInvokerController<T extends InterestInvokerHost> implements ReactiveController {\n #inferredInterestForElement: HTMLElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('mouseenter', this.#onInterest);\n this.host.addEventListener('mouseleave', this.#onLoseInterest);\n this.host.addEventListener('focus', this.#onInterest);\n this.host.addEventListener('blur', this.#onLoseInterest);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('mouseenter', this.#onInterest);\n this.host.removeEventListener('mouseleave', this.#onLoseInterest);\n this.host.removeEventListener('focus', this.#onInterest);\n this.host.removeEventListener('blur', this.#onLoseInterest);\n }\n\n #onInterest = (event: Event) => {\n if (event.type === 'focus' && !this.host.matches(':focus-visible')) {\n return;\n }\n\n if (this.host.popoverTargetElement?.matches(':popover-open')) {\n return;\n }\n\n this.#dispatchInterestEvent('interest');\n };\n\n #onLoseInterest = () => this.#dispatchInterestEvent('loseinterest');\n\n #dispatchInterestEvent(type: 'interest' | 'loseinterest') {\n const target = this.#getInterestForElement();\n if (!target) {\n return;\n }\n\n const event = new Event(type, { cancelable: true }) as InterestEvent;\n event.source = this.host;\n target.dispatchEvent(event);\n }\n\n #getInterestForElement() {\n const explicitTarget = this.#getExplicitInterestForElement();\n if (explicitTarget !== undefined) {\n return explicitTarget;\n }\n\n const inferredTarget = this.#getHintPopoverTarget();\n const previousTarget = this.#inferredInterestForElement;\n this.#inferredInterestForElement = inferredTarget;\n if (inferredTarget && this.host.interestForElement !== inferredTarget) {\n this.host.interestForElement = inferredTarget;\n } else if (!inferredTarget && previousTarget && this.host.interestForElement === previousTarget) {\n this.host.interestForElement = null;\n }\n return inferredTarget;\n }\n\n #getExplicitInterestForElement(): HTMLElement | null | undefined {\n const interestForIdRef = this.host.getAttribute('interestfor');\n if (interestForIdRef) {\n this.#inferredInterestForElement = null;\n return this.#getElementById(interestForIdRef);\n }\n\n const interestForElement = this.host.interestForElement;\n if (!interestForElement || interestForElement === this.#inferredInterestForElement) {\n return undefined;\n }\n\n this.#inferredInterestForElement = null;\n return interestForElement;\n }\n\n #getHintPopoverTarget() {\n const popoverTarget = this.host.popoverTargetElement;\n if (popoverTarget instanceof HTMLElement && popoverTarget.popover === 'hint') {\n return popoverTarget;\n }\n\n const target = this.#getElementById(this.host.getAttribute('popovertarget'));\n return target instanceof HTMLElement && target.popover === 'hint' ? target : null;\n }\n\n #getElementById(id: string | null) {\n return id ? (getFlattenedDOMTree(this.host.getRootNode()).find(element => element.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uBAAuB,MAC/E,KAAK,KAAK,qBAAqB,OAE1B;CACT;CAEA,KAAiE;EAC/D,IAAM,IAAmB,KAAK,KAAK,aAAa,aAAa;EAC7D,IAAI,GAEF,OADA,KAAKA,KAA8B,MAC5B,KAAKC,GAAgB,CAAgB;EAG9C,IAAM,IAAqB,KAAK,KAAK;EACjC,OAAC,KAAsB,MAAuB,KAAKD,KAKvD,OADA,KAAKA,KAA8B,MAC5B;CACT;CAEA,KAAwB;EACtB,IAAM,IAAgB,KAAK,KAAK;EAChC,IAAI,aAAyB,eAAe,EAAc,YAAY,QACpE,OAAO;EAGT,IAAM,IAAS,KAAKC,GAAgB,KAAK,KAAK,aAAa,eAAe,CAAC;EAC3E,OAAO,aAAkB,eAAe,EAAO,YAAY,SAAS,IAAS;CAC/E;CAEA,GAAgB,GAAmB;EACjC,OAAO,IAAM,EAAoB,KAAK,KAAK,YAAY,CAAC,CAAC,CAAC,MAAK,MAAW,EAAQ,OAAO,CAAE,KAAK,OAAQ;CAC1G;AACF"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { PopoverTargetAction } from '../../mixins/button.types.js';
|
|
2
|
-
import { ReactiveController, ReactiveElement } from './types.js';
|
|
1
|
+
import type { PopoverTargetAction } from '../../mixins/button.types.js';
|
|
2
|
+
import type { ReactiveController, ReactiveElement } from './types.js';
|
|
3
3
|
type PopoverTriggerHost = ReactiveElement & {
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
interestForElement: HTMLElement | null;
|
|
6
6
|
popoverTargetAction?: PopoverTargetAction;
|
|
7
7
|
popoverTargetElement: HTMLElement | null;
|
|
8
|
-
popovertarget?: string;
|
|
9
8
|
};
|
|
10
9
|
export declare class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {
|
|
11
10
|
#private;
|
|
@@ -13,9 +13,9 @@ var n = class {
|
|
|
13
13
|
#e;
|
|
14
14
|
#t() {
|
|
15
15
|
let t = this.host.popoverTargetElement, n = t === this.#e;
|
|
16
|
-
if (!this.host.popovertarget) return this.#e = void 0, n ? (this.host.popoverTargetElement = null, null) : t;
|
|
16
|
+
if (!this.host.getAttribute("popovertarget")) return this.#e = void 0, n ? (this.host.popoverTargetElement = null, null) : t;
|
|
17
17
|
if (t && !n) return t;
|
|
18
|
-
let r = e(this.host.getRootNode()).find((e) => e.id === this.host.popovertarget) ?? null;
|
|
18
|
+
let r = e(this.host.getRootNode()).find((e) => e.id === this.host.getAttribute("popovertarget")) ?? null;
|
|
19
19
|
return r !== t && (this.host.popoverTargetElement = r), this.#e = r, r;
|
|
20
20
|
}
|
|
21
21
|
#n = (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-popover-trigger.controller.js","names":["#onClick","#resolvedPopoverTarget","#resolvePopoverTarget","#invokePopover","#handoverInterest","#getPopoverSource"],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../../mixins/button.types.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n
|
|
1
|
+
{"version":3,"file":"type-popover-trigger.controller.js","names":["#onClick","#resolvedPopoverTarget","#resolvePopoverTarget","#invokePopover","#handoverInterest","#getPopoverSource"],"sources":["../../../src/internal/controllers/type-popover-trigger.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PopoverTargetAction } from '../../mixins/button.types.js';\nimport { getFlattenedDOMTree, getHostAnchor } from '../utils.js';\nimport type { PopoverAnchorElement } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype InterestEvent = Event & { source: HTMLElement };\n\ntype PopoverTriggerHost = ReactiveElement & {\n disabled: boolean;\n interestForElement: HTMLElement | null;\n popoverTargetAction?: PopoverTargetAction;\n popoverTargetElement: HTMLElement | null;\n};\n\nexport class TypePopoverTriggerController<T extends PopoverTriggerHost> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('click', this.#onClick);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#onClick);\n }\n\n #resolvedPopoverTarget: HTMLElement | null | undefined;\n\n #resolvePopoverTarget() {\n const popoverTargetElement = this.host.popoverTargetElement;\n const controllerResolvedTarget = popoverTargetElement === this.#resolvedPopoverTarget;\n\n if (!this.host.getAttribute('popovertarget')) {\n this.#resolvedPopoverTarget = undefined;\n if (controllerResolvedTarget) {\n this.host.popoverTargetElement = null;\n return null;\n }\n\n return popoverTargetElement;\n }\n\n if (popoverTargetElement && !controllerResolvedTarget) {\n return popoverTargetElement;\n }\n\n const resolvedPopoverTarget =\n getFlattenedDOMTree(this.host.getRootNode()).find(\n element => element.id === this.host.getAttribute('popovertarget')\n ) ?? null;\n if (resolvedPopoverTarget !== popoverTargetElement) {\n this.host.popoverTargetElement = resolvedPopoverTarget;\n }\n this.#resolvedPopoverTarget = resolvedPopoverTarget;\n\n return resolvedPopoverTarget;\n }\n\n #onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || this.host.disabled) {\n return;\n }\n\n const popoverTargetElement = this.#resolvePopoverTarget();\n if (!popoverTargetElement) {\n return;\n }\n\n if (this.#invokePopover(popoverTargetElement)) {\n this.#handoverInterest();\n }\n };\n\n #getPopoverSource(popoverTargetElement: HTMLElement) {\n if ((popoverTargetElement as PopoverAnchorElement).anchor) {\n return getHostAnchor(popoverTargetElement as PopoverAnchorElement);\n }\n\n return this.host as HTMLElement;\n }\n\n #invokePopover(popoverTargetElement: HTMLElement) {\n if (this.host.popoverTargetAction === 'hide') {\n popoverTargetElement.hidePopover();\n return false;\n }\n\n const source = this.#getPopoverSource(popoverTargetElement);\n if (this.host.popoverTargetAction === 'show') {\n popoverTargetElement.showPopover({ source });\n } else {\n popoverTargetElement.togglePopover({ source });\n }\n\n return popoverTargetElement.matches(':popover-open');\n }\n\n #handoverInterest() {\n if (this.host.interestForElement) {\n const loseInterest = new Event('loseinterest', { cancelable: true }) as 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,KAAKA,EAAQ;CACnD;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAKA,EAAQ;CACtD;CAEA;CAEA,KAAwB;EACtB,IAAM,IAAuB,KAAK,KAAK,sBACjC,IAA2B,MAAyB,KAAKC;EAE/D,IAAI,CAAC,KAAK,KAAK,aAAa,eAAe,GAOzC,OANA,KAAKA,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,KAAKA,KAAyB,GAEvB;CACT;CAEA,MAAY,MAAsB;EAChC,IAAI,EAAM,oBAAoB,KAAK,KAAK,UACtC;EAGF,IAAM,IAAuB,KAAKC,GAAsB;EACnD,KAID,KAAKC,GAAe,CAAoB,KAC1C,KAAKC,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,KAAKC,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,5 +1,5 @@
|
|
|
1
|
-
import { ButtonType } from '../../mixins/button.types.js';
|
|
2
|
-
import { ReactiveController, ReactiveElement } from './types.js';
|
|
1
|
+
import type { ButtonType } from '../../mixins/button.types.js';
|
|
2
|
+
import type { ReactiveController, ReactiveElement } from './types.js';
|
|
3
3
|
type SubmitHost = ReactiveElement & {
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
form: HTMLFormElement | null | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TypeCommandController } from './controllers/type-command.controller.js';
|
package/dist/internal/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../src/internal/schema.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Schema } from './types.js';\nimport { FormControlError } from './errors.js';\n\nexport function parseValueSchema<T>(formControlName: string, value: string, schema: Schema): T {\n const parsedValue = parseControlValue(value, schema);\n if (parsedValue === undefined) {\n throw new FormControlError(formControlName, `unsupported value type ${typeof value}`);\n }\n return parsedValue as T;\n}\n\ntype ValidationResult = { validity: Partial<ValidityState>; message: string };\n\nconst VALID: ValidationResult = { validity: { valid: true }, message: '' };\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidationResult {\n return { validity: { ...validity, valid: false }, message };\n}\n\nfunction validateString(schema: Schema & { type: 'string' }, value: unknown): ValidationResult {\n if (typeof value !== 'string') {\n return invalid({ typeMismatch: true }, `expected string, got ${typeof value}`);\n }\n if (schema.minLength !== undefined && value.length < schema.minLength) {\n return invalid({ tooShort: true }, `string length ${value.length} is less than minimum length ${schema.minLength}`);\n }\n if (schema.maxLength !== undefined && value.length > schema.maxLength) {\n return invalid(\n { tooLong: true },\n `string length ${value.length} is greater than maximum length ${schema.maxLength}`\n );\n }\n if (schema.pattern && !new RegExp(schema.pattern).test(value)) {\n return invalid({ patternMismatch: true }, `string does not match pattern ${schema.pattern}`);\n }\n return VALID;\n}\n\nfunction validateNumber(schema: Schema & { type: 'number' }, value: unknown): ValidationResult {\n if (typeof value !== 'number') {\n return invalid({ typeMismatch: true }, `expected type number, received type ${typeof value}`);\n }\n if (isNaN(value as unknown as number)) {\n return invalid({ typeMismatch: true }, `expected type number, received type NaN`);\n }\n if (schema.minimum !== undefined && value < schema.minimum) {\n return invalid({ rangeUnderflow: true }, `number ${value} is less than minimum ${schema.minimum}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n return invalid({ rangeOverflow: true }, `number ${value} is greater than maximum ${schema.maximum}`);\n }\n return VALID;\n}\n\nfunction validateBoolean(value: unknown): ValidationResult {\n if (typeof value !== 'boolean') {\n return invalid({ typeMismatch: true }, `expected boolean, got ${typeof value}`);\n }\n return VALID;\n}\n\nfunction validateArray(schema: Schema & { type: 'array' }, value: unknown): ValidationResult {\n if (!Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type array, received type ${typeof value}`);\n }\n if (schema.minItems !== undefined && value.length < schema.minItems) {\n return invalid(\n { rangeUnderflow: true },\n `array length ${value.length} is less than minimum length ${schema.minItems}`\n );\n }\n if (schema.maxItems !== undefined && value.length > schema.maxItems) {\n return invalid(\n { rangeOverflow: true },\n `array length ${value.length} is greater than maximum length ${schema.maxItems}`\n );\n }\n for (const item of value) {\n const result = validateSchema(schema.items, item);\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateObjectProperty(\n property: { name: string; schema: Schema },\n value: Record<string, unknown>,\n required?: string[]\n): ValidationResult {\n const { name, schema: propSchema } = property;\n const propValue = value[name];\n if (propValue === undefined) {\n if (required?.includes(name)) {\n return invalid({ valueMissing: true }, `missing required property: ${name}`);\n }\n return VALID;\n }\n return validateSchema(propSchema, propValue);\n}\n\nfunction validateObject(schema: Schema & { type: 'object' }, value: unknown): ValidationResult {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type object, received type ${typeof value}`);\n }\n\n const valueProperties = Object.keys(value as object);\n const schemaProperties = Object.keys(schema.properties);\n\n const additionalProps = valueProperties.filter(prop => !schemaProperties.includes(prop));\n if (additionalProps.length > 0 && !schema.additionalProperties) {\n return invalid({ badInput: true }, `additional properties not allowed: ${additionalProps.join(', ')}`);\n }\n\n for (const [prop, propSchema] of Object.entries(schema.properties)) {\n const result = validateObjectProperty(\n { name: prop, schema: propSchema },\n value as Record<string, unknown>,\n schema.required\n );\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateEnum(schema: Schema & { type: 'enum' }, value: unknown): ValidationResult {\n if (!schema.enum.includes(value as string | number)) {\n return invalid({ typeMismatch: true }, `value must be one of: ${schema.enum.join(', ')}`);\n }\n return VALID;\n}\n\nexport function validateSchema(schema: Schema, value: unknown): ValidationResult {\n if (!schema || typeof schema !== 'object') {\n return invalid({ badInput: true }, 'invalid schema, schema must be a non-null object');\n }\n\n if (!('type' in schema)) {\n return invalid({ badInput: true }, 'schema must have \"type\" property');\n }\n\n switch (schema.type) {\n case 'string':\n return validateString(schema, value);\n case 'number':\n return validateNumber(schema, value);\n case 'boolean':\n return validateBoolean(value);\n case 'array':\n return validateArray(schema, value);\n case 'object':\n return validateObject(schema, value);\n case 'enum':\n return validateEnum(schema, value);\n default:\n return invalid({ badInput: true }, `unsupported type: ${(schema as { type: string }).type}`);\n }\n}\n\nexport function parseControlValue<T>(value: string, schema: Schema): T | undefined {\n const schemaType = schema.type;\n\n switch (schemaType) {\n case 'string':\n return value as T;\n case 'number':\n return parseFloat(value) as T;\n case 'boolean':\n return (!!value || value === 'true') as T;\n case 'array':\n case 'object':\n return JSON.parse(value) as T;\n case 'enum':\n return (schema.enum.includes(value) ? value : undefined) as T;\n default: {\n const _exhaustiveCheck: never = schemaType;\n return undefined;\n }\n }\n}\n"],"mappings":";;AAMA,SAAgB,EAAoB,GAAyB,GAAe,GAAmB;CAC7F,IAAM,IAAc,EAAkB,GAAO,CAAM;CACnD,IAAI,MAAgB,KAAA,GAClB,MAAM,IAAI,EAAiB,GAAiB,0BAA0B,OAAO,GAAO;CAEtF,OAAO;AACT;AAIA,IAAM,IAA0B;CAAE,UAAU,EAAE,OAAO,GAAK;CAAG,SAAS;AAAG;AAEzE,SAAS,EAAQ,GAAkC,GAAmC;CACpF,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU,OAAO;EAAM;EAAG;CAAQ;AAC5D;AAEA,SAAS,EAAe,GAAqC,GAAkC;CAgB7F,OAfI,OAAO,KAAU,WAGjB,EAAO,cAAc,KAAA,KAAa,EAAM,SAAS,EAAO,YACnD,EAAQ,EAAE,UAAU,GAAK,GAAG,iBAAiB,EAAM,OAAO,+BAA+B,EAAO,WAAW,IAEhH,EAAO,cAAc,KAAA,KAAa,EAAM,SAAS,EAAO,YACnD,EACL,EAAE,SAAS,GAAK,GAChB,iBAAiB,EAAM,OAAO,kCAAkC,EAAO,WACzE,IAEE,EAAO,WAAW,CAAC,IAAI,OAAO,EAAO,O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AkC;CAGvE,QAAQ,EAAO,MAAf;EACE,KAAK,UACH,OAAO,EAAe,GAAQ,CAAK;EACrC,KAAK,UACH,OAAO,EAAe,GAAQ,CAAK;EACrC,KAAK,WACH,OAAO,EAAgB,CAAK;EAC9B,KAAK,SACH,OAAO,EAAc,GAAQ,CAAK;EACpC,KAAK,UACH,OAAO,EAAe,GAAQ,CAAK;EACrC,KAAK,QACH,OAAO,EAAa,GAAQ,CAAK;EACnC,SACE,OAAO,EAAQ,EAAE,UAAU,GAAK,GAAG,qBAAsB,EAA4B,MAAM;CAC/F;AACF;AAEA,SAAgB,EAAqB,GAAe,GAA+B;CAGjF,QAFmB,EAAO,MAE1B;EACE,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO,WAAW,CAAK;EACzB,KAAK,WACH,OAAQ,CAAC,CAAC,KAAS,MAAU;EAC/B,KAAK;EACL,KAAK,UACH,OAAO,KAAK,MAAM,CAAK;EACzB,KAAK,QACH,OAAQ,EAAO,KAAK,SAAS,CAAK,IAAI,IAAQ,KAAA;EAChD,SAEE;CAEJ;AACF"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/internal/schema.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Schema } from './types.js';\nimport { FormControlError } from './errors.js';\n\nexport function parseValueSchema<T>(formControlName: string, value: string, schema: Schema): T {\n const parsedValue = parseControlValue(value, schema);\n if (parsedValue === undefined) {\n throw new FormControlError(formControlName, `unsupported value type ${typeof value}`);\n }\n return parsedValue as T;\n}\n\ntype ValidationResult = { validity: Partial<ValidityState>; message: string };\n\nconst VALID: ValidationResult = { validity: { valid: true }, message: '' };\n\nfunction invalid(validity: Partial<ValidityState>, message: string): ValidationResult {\n return { validity: { ...validity, valid: false }, message };\n}\n\nfunction validateString(schema: Schema & { type: 'string' }, value: unknown): ValidationResult {\n if (typeof value !== 'string') {\n return invalid({ typeMismatch: true }, `expected string, got ${typeof value}`);\n }\n if (schema.minLength !== undefined && value.length < schema.minLength) {\n return invalid({ tooShort: true }, `string length ${value.length} is less than minimum length ${schema.minLength}`);\n }\n if (schema.maxLength !== undefined && value.length > schema.maxLength) {\n return invalid(\n { tooLong: true },\n `string length ${value.length} is greater than maximum length ${schema.maxLength}`\n );\n }\n if (schema.pattern && !new RegExp(schema.pattern).test(value)) {\n return invalid({ patternMismatch: true }, `string does not match pattern ${schema.pattern}`);\n }\n return VALID;\n}\n\nfunction validateNumber(schema: Schema & { type: 'number' }, value: unknown): ValidationResult {\n if (typeof value !== 'number') {\n return invalid({ typeMismatch: true }, `expected type number, received type ${typeof value}`);\n }\n if (isNaN(value as unknown as number)) {\n return invalid({ typeMismatch: true }, `expected type number, received type NaN`);\n }\n if (schema.minimum !== undefined && value < schema.minimum) {\n return invalid({ rangeUnderflow: true }, `number ${value} is less than minimum ${schema.minimum}`);\n }\n if (schema.maximum !== undefined && value > schema.maximum) {\n return invalid({ rangeOverflow: true }, `number ${value} is greater than maximum ${schema.maximum}`);\n }\n return VALID;\n}\n\nfunction validateBoolean(value: unknown): ValidationResult {\n if (typeof value !== 'boolean') {\n return invalid({ typeMismatch: true }, `expected boolean, got ${typeof value}`);\n }\n return VALID;\n}\n\nfunction validateArray(schema: Schema & { type: 'array' }, value: unknown): ValidationResult {\n if (!Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type array, received type ${typeof value}`);\n }\n if (schema.minItems !== undefined && value.length < schema.minItems) {\n return invalid(\n { rangeUnderflow: true },\n `array length ${value.length} is less than minimum length ${schema.minItems}`\n );\n }\n if (schema.maxItems !== undefined && value.length > schema.maxItems) {\n return invalid(\n { rangeOverflow: true },\n `array length ${value.length} is greater than maximum length ${schema.maxItems}`\n );\n }\n for (const item of value) {\n const result = validateSchema(schema.items, item);\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateObjectProperty(\n property: { name: string; schema: Schema },\n value: Record<string, unknown>,\n required?: string[]\n): ValidationResult {\n const { name, schema: propSchema } = property;\n const propValue = value[name];\n if (propValue === undefined) {\n if (required?.includes(name)) {\n return invalid({ valueMissing: true }, `missing required property: ${name}`);\n }\n return VALID;\n }\n return validateSchema(propSchema, propValue);\n}\n\nfunction validateObject(schema: Schema & { type: 'object' }, value: unknown): ValidationResult {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return invalid({ typeMismatch: true }, `expected type object, received type ${typeof value}`);\n }\n\n const valueProperties = Object.keys(value as object);\n const schemaProperties = Object.keys(schema.properties);\n\n const additionalProps = valueProperties.filter(prop => !schemaProperties.includes(prop));\n if (additionalProps.length > 0 && !schema.additionalProperties) {\n return invalid({ badInput: true }, `additional properties not allowed: ${additionalProps.join(', ')}`);\n }\n\n for (const [prop, propSchema] of Object.entries(schema.properties)) {\n const result = validateObjectProperty(\n { name: prop, schema: propSchema },\n value as Record<string, unknown>,\n schema.required\n );\n if (!result.validity.valid) {\n return result;\n }\n }\n return VALID;\n}\n\nfunction validateEnum(schema: Schema & { type: 'enum' }, value: unknown): ValidationResult {\n if (!schema.enum.includes(value as string | number)) {\n return invalid({ typeMismatch: true }, `value must be one of: ${schema.enum.join(', ')}`);\n }\n return VALID;\n}\n\nexport function validateSchema(schema: Schema, value: unknown): ValidationResult {\n if (!schema || typeof schema !== 'object') {\n return invalid({ badInput: true }, 'invalid schema, schema must be a non-null object');\n }\n\n if (!('type' in schema)) {\n return invalid({ badInput: true }, 'schema must have \"type\" property');\n }\n\n switch (schema.type) {\n case 'string':\n return validateString(schema, value);\n case 'number':\n return validateNumber(schema, value);\n case 'boolean':\n return validateBoolean(value);\n case 'array':\n return validateArray(schema, value);\n case 'object':\n return validateObject(schema, value);\n case 'enum':\n return validateEnum(schema, value);\n default:\n return invalid({ badInput: true }, `unsupported type: ${(schema as { type: string }).type}`);\n }\n}\n\nexport function parseControlValue<T>(value: string, schema: Schema): T | undefined {\n const schemaType = schema.type;\n\n switch (schemaType) {\n case 'string':\n return value as T;\n case 'number':\n return parseFloat(value) as T;\n case 'boolean':\n return (!!value || value === 'true') as T;\n case 'array':\n case 'object':\n return JSON.parse(value) as T;\n case 'enum':\n return (schema.enum.includes(value) ? value : undefined) as T;\n default: {\n const _exhaustiveCheck: never = schemaType;\n return undefined;\n }\n }\n}\n"],"mappings":";;AAMA,SAAgB,EAAoB,GAAyB,GAAe,GAAmB;CAC7F,IAAM,IAAc,EAAkB,GAAO,CAAM;CACnD,IAAI,MAAgB,KAAA,GAClB,MAAM,IAAI,EAAiB,GAAiB,0BAA0B,OAAO,GAAO;CAEtF,OAAO;AACT;AAIA,IAAM,IAA0B;CAAE,UAAU,EAAE,OAAO,GAAK;CAAG,SAAS;AAAG;AAEzE,SAAS,EAAQ,GAAkC,GAAmC;CACpF,OAAO;EAAE,UAAU;GAAE,GAAG;GAAU,OAAO;EAAM;EAAG;CAAQ;AAC5D;AAEA,SAAS,EAAe,GAAqC,GAAkC;CAgB7F,OAfI,OAAO,KAAU,WAGjB,EAAO,cAAc,KAAA,KAAa,EAAM,SAAS,EAAO,YACnD,EAAQ,EAAE,UAAU,GAAK,GAAG,iBAAiB,EAAM,OAAO,+BAA+B,EAAO,WAAW,IAEhH,EAAO,cAAc,KAAA,KAAa,EAAM,SAAS,EAAO,YACnD,EACL,EAAE,SAAS,GAAK,GAChB,iBAAiB,EAAM,OAAO,kCAAkC,EAAO,WACzE,IAEE,EAAO,WAAW,CAAC,IAAI,OAAO,EAAO,OAAO,CAAC,CAAC,KAAK,CAAK,IACnD,EAAQ,EAAE,iBAAiB,GAAK,GAAG,iCAAiC,EAAO,SAAS,IAEtF,IAdE,EAAQ,EAAE,cAAc,GAAK,GAAG,wBAAwB,OAAO,GAAO;AAejF;AAEA,SAAS,EAAe,GAAqC,GAAkC;CAa7F,OAZI,OAAO,KAAU,WAGjB,MAAM,CAA0B,IAC3B,EAAQ,EAAE,cAAc,GAAK,GAAG,yCAAyC,IAE9E,EA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