@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.
- package/CHANGELOG.md +84 -0
- package/README.md +8 -0
- package/dist/custom-elements.json +10 -10
- package/dist/examples/csv.examples.js.map +1 -1
- package/dist/examples/light.examples.js.map +1 -1
- package/dist/examples/light.examples.json +2 -2
- package/dist/examples/simple.examples.js.map +1 -1
- package/dist/examples/simple.examples.json +2 -2
- package/dist/examples/visualization.examples.js.map +1 -1
- package/dist/examples/visualization.examples.json +2 -2
- package/dist/index.js +1 -1
- package/dist/internal/controllers/state-active.controller.js.map +1 -1
- package/dist/internal/controllers/state-current.controller.js +1 -1
- package/dist/internal/controllers/state-current.controller.js.map +1 -1
- package/dist/internal/controllers/state-disabled.controller.d.ts +1 -1
- package/dist/internal/controllers/state-disabled.controller.js.map +1 -1
- package/dist/internal/controllers/state-selected.controller.js.map +1 -1
- package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.js.map +1 -1
- package/dist/internal/controllers/type-command.controller.js.map +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.d.ts +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/internal/controllers/type-submit.controller.d.ts +1 -1
- package/dist/internal/controllers/type-submit.controller.js.map +1 -1
- package/dist/{mixins/button.types.d.ts → internal/types/button.d.ts} +4 -1
- package/dist/mixins/button.d.ts +2 -2
- package/dist/mixins/button.js +2 -2
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/checkbox.d.ts +2 -0
- package/dist/mixins/checkbox.js +4 -4
- package/dist/mixins/checkbox.js.map +1 -1
- package/dist/mixins/control.js +3 -3
- package/dist/mixins/control.js.map +1 -1
- package/dist/mixins/select.d.ts +4 -1
- package/dist/mixins/select.js +1 -1
- package/dist/mixins/select.js.map +1 -1
- package/dist/mixins/slider.d.ts +8 -3
- package/dist/mixins/slider.js +1 -1
- package/dist/mixins/slider.js.map +1 -1
- package/package.json +40 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
+
## [2.0.7](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.6...@nvidia-elements/forms-v2.0.7) (2026-10-07)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **cli:** improve validation commands ([0a9586b](https://github.com/NVIDIA/elements/commit/0a9586be9b6ae1ca3d08ea1cfecefcae26d2af22))
|
|
6
|
+
* **code:** support code element slot content ([25486f5](https://github.com/NVIDIA/elements/commit/25486f52fa95ac2cb865a20748467d4d5729e673))
|
|
7
|
+
* **core:** add dot and cross patterns to viewport gridlines ([2693005](https://github.com/NVIDIA/elements/commit/26930057a5e4da4a0c2fb0d9fcfebf95c3dd9bc3))
|
|
8
|
+
* **core:** add format-truncate ([d6c0f2e](https://github.com/NVIDIA/elements/commit/d6c0f2e4ac9b27185a4ccbef511e9165b063aecf))
|
|
9
|
+
* **core:** add icon appearances ([d20ccf3](https://github.com/NVIDIA/elements/commit/d20ccf3c621d91e61988435c2ffaeb039f913c17))
|
|
10
|
+
* **core:** add internal gesture and key navigation controllers ([3b46234](https://github.com/NVIDIA/elements/commit/3b46234bab24edc46f906e76cbc7ed95a6197a26))
|
|
11
|
+
* **core:** add viewport ([0e9e892](https://github.com/NVIDIA/elements/commit/0e9e892de5d41c2a64d1e9adcfaa7a9df2c4deef))
|
|
12
|
+
* **core:** add viewport minimap ([c3cc189](https://github.com/NVIDIA/elements/commit/c3cc1891132f6ae6ab27c94fcdfe79d38b592230))
|
|
13
|
+
* **core:** format-bytes ([bfd2e5e](https://github.com/NVIDIA/elements/commit/bfd2e5e32648a8a8678badc729ce892716168664))
|
|
14
|
+
* **core:** menu group ([d9a24e9](https://github.com/NVIDIA/elements/commit/d9a24e961e1c5394367e7ae9bf931d9e1e2d58b0))
|
|
15
|
+
* **core:** swap reviewed icon svgs ([f5f232e](https://github.com/NVIDIA/elements/commit/f5f232ec2377d25d520873bb0378364f3d7fe397))
|
|
16
|
+
* **core:** tag slots ([c4e0edd](https://github.com/NVIDIA/elements/commit/c4e0edd7b5bdd8c619ca969fd537352466fc759a))
|
|
17
|
+
* **lint:** add additional icon alias deprecations ([a574e85](https://github.com/NVIDIA/elements/commit/a574e85010a928714a88e8ae136095172cab0701))
|
|
18
|
+
* **lint:** add css rules ([c876f89](https://github.com/NVIDIA/elements/commit/c876f89879814536abbb4f7fb0d65e255d018292))
|
|
19
|
+
* **lint:** improve slotted element checks ([0e1985d](https://github.com/NVIDIA/elements/commit/0e1985deb9edba09cbcbd9eec121e445d3559624))
|
|
20
|
+
* **lint:** support markdown linting ([652e751](https://github.com/NVIDIA/elements/commit/652e7517bb9c0f17a2e4cc1a4760206f414b24d2))
|
|
21
|
+
* **pi:** pi extension ([88dea55](https://github.com/NVIDIA/elements/commit/88dea552fd28da8a31c95ff713218bda73d64e64))
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **ci:** ignore test runner artifacts in knip cache ([7415260](https://github.com/NVIDIA/elements/commit/74152608703345d5507ba5f64e5f1535f98b36e3))
|
|
26
|
+
* **ci:** pin conventionalcommits preset for release notes ([6c93057](https://github.com/NVIDIA/elements/commit/6c93057adec0a1d8fb22335a84af1bb4b9be41ae))
|
|
27
|
+
* **ci:** preserve authored contents in example metadata ([0ea8618](https://github.com/NVIDIA/elements/commit/0ea86182b4c654c4d8301bad7fbc06f0d3b11187))
|
|
28
|
+
* **ci:** stabilize monaco worker bundle lighthouse checks ([0f18d6c](https://github.com/NVIDIA/elements/commit/0f18d6c5ef2364d4b7cecd2119e6902633c22fc1))
|
|
29
|
+
* **cli:** improve skill tool call and creation steps ([b30455c](https://github.com/NVIDIA/elements/commit/b30455cad0deab646ad20ccd18bdafda39056860))
|
|
30
|
+
* **cli:** mcp app rendering and schema tools ([5cf5f51](https://github.com/NVIDIA/elements/commit/5cf5f51e8b77468451024a9a31f247ac0beb5373))
|
|
31
|
+
* **cli:** ui resources ([166a537](https://github.com/NVIDIA/elements/commit/166a5374c9aa022a2cc86c262d5165acdee7112e))
|
|
32
|
+
* **cli:** update @inquirer/prompts to 8.7.2 ([b6984b5](https://github.com/NVIDIA/elements/commit/b6984b58a80a666b7a83aac1e109337e90c469d1))
|
|
33
|
+
* **cli:** update bun to 1.4.2 ([0e84e28](https://github.com/NVIDIA/elements/commit/0e84e2880ca5ff09405d0d88d16ef12d9341623e))
|
|
34
|
+
* **cli:** update dependencies ([ff596a1](https://github.com/NVIDIA/elements/commit/ff596a1d484954a575f16a3fe389758388f87bda))
|
|
35
|
+
* **cli:** update dependencies and migration skill ([932ffce](https://github.com/NVIDIA/elements/commit/932ffce3fc8ce5d5df1dd09cf5b856b261427fc6))
|
|
36
|
+
* **cli:** update marked to 18.0.11 ([cb9a5e3](https://github.com/NVIDIA/elements/commit/cb9a5e3e521ecbd87aacb724da9c1f14119f7fc7))
|
|
37
|
+
* **cli:** update marked to 18.0.14 ([b24d6cb](https://github.com/NVIDIA/elements/commit/b24d6cb07ee47cf392214e0a934f1caee31eb510))
|
|
38
|
+
* **code:** bundle side effects ([13f6528](https://github.com/NVIDIA/elements/commit/13f652860adf0b7e7ef96477d1ac1a5d87652e32))
|
|
39
|
+
* **code:** bundle treeshaking ([cf6beb7](https://github.com/NVIDIA/elements/commit/cf6beb71e6e805f6241e6e0c36100f00611d6c71))
|
|
40
|
+
* **core:** add initial selected item focus handling for tabs ([9d617f4](https://github.com/NVIDIA/elements/commit/9d617f44c43f577f21bcdaa3ba14c6397ed1fc17))
|
|
41
|
+
* **core:** bundle side effects ([d29d5e6](https://github.com/NVIDIA/elements/commit/d29d5e6670b0fac0742b60e18d3efd01373bd0e0))
|
|
42
|
+
* **core:** bundle treeshaking ([e3e80be](https://github.com/NVIDIA/elements/commit/e3e80bee5ca61f36ca5532ba55a9213fd1f8899a))
|
|
43
|
+
* **core:** clean up combobox option observers across connections ([3af4742](https://github.com/NVIDIA/elements/commit/3af4742f53a3d6c09b59b0ac445da9bb268de73e))
|
|
44
|
+
* **core:** control message metadata ([1abec58](https://github.com/NVIDIA/elements/commit/1abec58e758c1cf02ba4e9587066bafe677f896a))
|
|
45
|
+
* **core:** debounce scroll tracking state updates ([ce5b688](https://github.com/NVIDIA/elements/commit/ce5b688310d13dcc51e26bd0434599fecc610e4b))
|
|
46
|
+
* **core:** enhance gesture recognizer ([0be2399](https://github.com/NVIDIA/elements/commit/0be2399b37982fde94c061ed811c280b29e3a3ae))
|
|
47
|
+
* **core:** format bytes ([385fd83](https://github.com/NVIDIA/elements/commit/385fd83e9a7874aa2daecb400770a752b835b1fb))
|
|
48
|
+
* **core:** gauge fill alignment ([2bef645](https://github.com/NVIDIA/elements/commit/2bef645a8526d8153c8f0de871a0ad89f8933223))
|
|
49
|
+
* **core:** improve viewport height bounds for nve-page ([7c3b839](https://github.com/NVIDIA/elements/commit/7c3b839915c76c08090306534f4166cf36949635))
|
|
50
|
+
* **core:** missing animation timing for progress-bar ([05150d4](https://github.com/NVIDIA/elements/commit/05150d4c97a500f0f728d9a9d9aea3f468a2b8aa))
|
|
51
|
+
* **core:** pointer solid icon ([bf3ff31](https://github.com/NVIDIA/elements/commit/bf3ff31efa313a54130d0aca68176bf5b34dca88))
|
|
52
|
+
* **core:** preserve accessors during property observation ([37c137d](https://github.com/NVIDIA/elements/commit/37c137d305273cbf4382908cd00d0ca2dd273036))
|
|
53
|
+
* **core:** resolve page panel stacking and visibility ([3bd2fc9](https://github.com/NVIDIA/elements/commit/3bd2fc9d2e3fa9ba740a486cd7a826bb17ffcaa2))
|
|
54
|
+
* **core:** restore tree keyboard navigation ([e024c11](https://github.com/NVIDIA/elements/commit/e024c114f69e8396a6f451273254c5ed24ce4dc5))
|
|
55
|
+
* **core:** support solid icon variants and icon registry aliases ([e455331](https://github.com/NVIDIA/elements/commit/e455331f87033755667fd6c5d253c5dd2b58823c)), closes [PR#264](https://github.com/NVIDIA/PR/issues/264)
|
|
56
|
+
* **core:** textarea slots ([0f8fb33](https://github.com/NVIDIA/elements/commit/0f8fb33a38c60a08aaf37e774a92338cf5416401))
|
|
57
|
+
* **core:** update icon build script ([ad3d51c](https://github.com/NVIDIA/elements/commit/ad3d51cb44a385695ab5d5efe84bfb6f78a4b707))
|
|
58
|
+
* **core:** update icons with aspect ratios ([2021d95](https://github.com/NVIDIA/elements/commit/2021d9596a8e525a3351f6ce0c4d32604ac196ae))
|
|
59
|
+
* **docs:** align card presentation ([f811f0a](https://github.com/NVIDIA/elements/commit/f811f0a685ffcb95c68c6bd2bb48129cf8349561))
|
|
60
|
+
* **docs:** align card title typography ([056404a](https://github.com/NVIDIA/elements/commit/056404a2a6717e325106cd78bda82983e2f76d90))
|
|
61
|
+
* **docs:** correct example api mapping and summary fallback ([f0dd837](https://github.com/NVIDIA/elements/commit/f0dd837756f44f05f1c115384d18e02a40cff32d))
|
|
62
|
+
* **docs:** correct jsdelivr bundle urls ([c7432be](https://github.com/NVIDIA/elements/commit/c7432be0394225f3d9d7b2c193b7e491c751c9a9))
|
|
63
|
+
* **docs:** make page title weights consistent ([07bc98b](https://github.com/NVIDIA/elements/commit/07bc98b12a646f4050d2cc873d7ed3a00b8304f7))
|
|
64
|
+
* **docs:** preserve example content through html processing ([7055d3c](https://github.com/NVIDIA/elements/commit/7055d3ce12a10b0e494da9c73c8f34fce62b9884))
|
|
65
|
+
* **docs:** preserve example source during development reloads ([162082b](https://github.com/NVIDIA/elements/commit/162082b8bead05283646ae68ad3ecd391be8c962))
|
|
66
|
+
* **docs:** prevent runtime errors when loading examples pages in dev ([1d57c69](https://github.com/NVIDIA/elements/commit/1d57c690819c009a1abac037b00f631d18db076a))
|
|
67
|
+
* **docs:** refine navigation group titles ([2e3c3e0](https://github.com/NVIDIA/elements/commit/2e3c3e089e07c0b2f261a58bd966bf2f772333a9))
|
|
68
|
+
* **docs:** update responsive pattern icon ([6126e1c](https://github.com/NVIDIA/elements/commit/6126e1c2bc9fff2a222ce81c88f51de47149cad7))
|
|
69
|
+
* **docs:** use canvas background for component headers ([5547c47](https://github.com/NVIDIA/elements/commit/5547c473f0f20dffe29ac8de8a24513126c56f99))
|
|
70
|
+
* **forms:** form state restore callback types ([8a060db](https://github.com/NVIDIA/elements/commit/8a060db7366b54ec22e8163a36ee18613a0c479c))
|
|
71
|
+
* **lint:** allow external svg icon sources ([c55f4df](https://github.com/NVIDIA/elements/commit/c55f4df9771a15f9a183d221f2af361dfe9ba04c))
|
|
72
|
+
* **lint:** no-excessive-primary-actions rule to handle popover elements ([398c0df](https://github.com/NVIDIA/elements/commit/398c0df6a2987e8ece663d8c2994d1626a1b2596))
|
|
73
|
+
* **lint:** skip generated eleventy vite directories in eslint ([92e5d50](https://github.com/NVIDIA/elements/commit/92e5d506fe0a951c354641a1aad2b1a9dd75a212))
|
|
74
|
+
* **lint:** suggest removing slot="default" when unnamed slot is not first ([84372f1](https://github.com/NVIDIA/elements/commit/84372f1d1173473bc6f89f89e870c0080c226f46))
|
|
75
|
+
* **lint:** update eslint ([2a3ad12](https://github.com/NVIDIA/elements/commit/2a3ad1217db5aadfdef4a89f796f96348dc0f330))
|
|
76
|
+
* **media:** since version release ([583f6bc](https://github.com/NVIDIA/elements/commit/583f6bcd5384e4d4c5ca953b2f9e74cfbb313750))
|
|
77
|
+
* **pi:** update to pi.dev 1.0.0 ([3d44c15](https://github.com/NVIDIA/elements/commit/3d44c159c4c45b38789aa96615faaf0f97e798f6))
|
|
78
|
+
* **starters:** update @angular/* to 22.1.4 ([3370f7d](https://github.com/NVIDIA/elements/commit/3370f7de561dd44723ca8a96b61fd18f65a99841))
|
|
79
|
+
* **starters:** update angular to 22.1.3 ([273d4e9](https://github.com/NVIDIA/elements/commit/273d4e9fc1e2ae425a7276e9daf064d1ee53ca02))
|
|
80
|
+
* **starters:** update nuxt to 4.5.2 ([0862866](https://github.com/NVIDIA/elements/commit/08628664a6e01d455c6c349902ee244026bd12f2))
|
|
81
|
+
* **starters:** update solid-js to 1.9.15 ([1753732](https://github.com/NVIDIA/elements/commit/17537324b004ef58566b8da43b588d3010d9f022))
|
|
82
|
+
* **styles:** native text-box support ([d562bb2](https://github.com/NVIDIA/elements/commit/d562bb2eb5b487eb9a42713848a1a43eaf772d0d))
|
|
83
|
+
* **themes:** update default status contrast ([52af067](https://github.com/NVIDIA/elements/commit/52af0677b6b63c85353b77ca624a29c1c8d9b05a))
|
|
84
|
+
|
|
1
85
|
## <small>2.0.6 (2026-08-07)</small>
|
|
2
86
|
|
|
3
87
|
* chore(ci): add github dependabot skill ([4cb37a7](https://github.com/NVIDIA/elements/commit/4cb37a7))
|
package/README.md
CHANGED
|
@@ -18,3 +18,11 @@ npm install @nvidia-elements/forms
|
|
|
18
18
|
```javascript
|
|
19
19
|
import { FormControl } from '@nvidia-elements/forms';
|
|
20
20
|
```
|
|
21
|
+
|
|
22
|
+
## NVIDIA Elements Skill
|
|
23
|
+
|
|
24
|
+
Install the Elements agent skill with the open [skills](https://www.skills.sh/nvidia/elements/elements) CLI:
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
npx skills add https://github.com/nvidia/elements --skill elements
|
|
28
|
+
```
|
|
@@ -1065,6 +1065,12 @@
|
|
|
1065
1065
|
"declarations": [],
|
|
1066
1066
|
"exports": []
|
|
1067
1067
|
},
|
|
1068
|
+
{
|
|
1069
|
+
"kind": "javascript-module",
|
|
1070
|
+
"path": "/src/internal/types/button.js",
|
|
1071
|
+
"declarations": [],
|
|
1072
|
+
"exports": []
|
|
1073
|
+
},
|
|
1068
1074
|
{
|
|
1069
1075
|
"kind": "javascript-module",
|
|
1070
1076
|
"path": "/src/internal/utils.js",
|
|
@@ -1424,7 +1430,7 @@
|
|
|
1424
1430
|
"name": "ButtonFormControlMixinInstance",
|
|
1425
1431
|
"declaration": {
|
|
1426
1432
|
"name": "ButtonFormControlMixinInstance",
|
|
1427
|
-
"module": "
|
|
1433
|
+
"module": "../internal/types/button.js"
|
|
1428
1434
|
}
|
|
1429
1435
|
},
|
|
1430
1436
|
{
|
|
@@ -1432,7 +1438,7 @@
|
|
|
1432
1438
|
"name": "ButtonType",
|
|
1433
1439
|
"declaration": {
|
|
1434
1440
|
"name": "ButtonType",
|
|
1435
|
-
"module": "
|
|
1441
|
+
"module": "../internal/types/button.js"
|
|
1436
1442
|
}
|
|
1437
1443
|
},
|
|
1438
1444
|
{
|
|
@@ -1440,7 +1446,7 @@
|
|
|
1440
1446
|
"name": "CurrentState",
|
|
1441
1447
|
"declaration": {
|
|
1442
1448
|
"name": "CurrentState",
|
|
1443
|
-
"module": "
|
|
1449
|
+
"module": "../internal/types/button.js"
|
|
1444
1450
|
}
|
|
1445
1451
|
},
|
|
1446
1452
|
{
|
|
@@ -1448,7 +1454,7 @@
|
|
|
1448
1454
|
"name": "PopoverTargetAction",
|
|
1449
1455
|
"declaration": {
|
|
1450
1456
|
"name": "PopoverTargetAction",
|
|
1451
|
-
"module": "
|
|
1457
|
+
"module": "../internal/types/button.js"
|
|
1452
1458
|
}
|
|
1453
1459
|
},
|
|
1454
1460
|
{
|
|
@@ -1461,12 +1467,6 @@
|
|
|
1461
1467
|
}
|
|
1462
1468
|
]
|
|
1463
1469
|
},
|
|
1464
|
-
{
|
|
1465
|
-
"kind": "javascript-module",
|
|
1466
|
-
"path": "/src/mixins/button.types.js",
|
|
1467
|
-
"declarations": [],
|
|
1468
|
-
"exports": []
|
|
1469
|
-
},
|
|
1470
1470
|
{
|
|
1471
1471
|
"kind": "javascript-module",
|
|
1472
1472
|
"path": "/src/mixins/checkbox.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.examples.js","names":[
|
|
1
|
+
{"version":3,"file":"csv.examples.js","names":[],"sources":["../../src/examples/csv.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement, nothing } from 'lit';\nimport type { ValidatorResult } from '@nvidia-elements/forms';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixins';\nimport '@nvidia-elements/core/textarea/define.js';\nimport '@nvidia-elements/core/dropdown/define.js';\nimport '@nvidia-elements/core/checkbox/define.js';\nimport '@nvidia-elements/core/grid/define.js';\nimport './csv.examples.js';\n\nexport default {\n title: 'Labs/Forms/Examples',\n component: ['forms']\n};\n\n/**\n * @summary CSV grid form control with input validation and editable textarea.\n * @tags test-case\n */\nexport const CSV = {\n render: () => html`\n <style>\n ui-csv-grid:invalid {\n outline: 2px dashed red;\n }\n </style>\n <form nve-layout=\"grid span:6 gap:lg pad:lg align:stretch align:center\" style=\"min-width: 1000px;\">\n <nve-textarea style=\"width: max-content\">\n <label>CSV</label>\n <textarea name=\"input\" rows=\"20\" cols=\"50\">${csv}</textarea>\n </nve-textarea>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-csv-grid name=\"csv\"></ui-csv-grid>\n </form>\n <script type=\"module\">\n const form = document.querySelector('form');\n form.elements.csv.value = form.elements.input.value;\n form.addEventListener('input', (e) => {\n form.elements.csv.value = form.elements.input.value;\n });\n </script>\n `\n};\n\nconst csv = `\nresource_id,cpu_usage_percent,memory_usage_gb,storage_used_tb,network_traffic_gb\ninstance-001,45.2,8.5,2.3,156.7\ninstance-002,78.9,12.3,4.1,289.4\ninstance-003,23.4,4.2,1.5,89.3\ninstance-004,92.1,16.7,5.8,412.6\ninstance-005,34.7,6.8,2.9,178.2\ninstance-006,67.8,10.1,3.7,256.9\ninstance-007,12.5,2.9,0.8,45.6\ninstance-008,88.3,14.5,4.9,378.1\ninstance-009,56.4,9.2,3.2,198.5\ninstance-010,41.2,7.6,2.5,167.8`.trim();\n\nexport type CSVValue = string;\n\nexport class CSVExample extends FormControlMixin<typeof LitElement, CSVValue>(LitElement) {\n static readonly metadata = {\n tag: 'ui-csv-grid',\n version: '0.0.0',\n validators: [csvStringValidator],\n valueSchema: {\n type: 'string' as const\n },\n };\n\n static styles = [\n css`:host {\n display: block;\n width: 100%;\n }`\n ];\n\n get #getCSV() {\n const rows = this.value!.trim().split('\\n');\n return {\n columns: rows[0]!.split(','),\n rows: rows.slice(1).map(row => row.split(','))\n };\n }\n\n render() {\n return this.value\n ? html`\n <nve-grid>\n <nve-grid-header>\n ${this.#getCSV.columns.map(column => html`<nve-grid-column>${column}</nve-grid-column>`)}\n </nve-grid-header>\n ${this.#getCSV.rows.map(row => html`<nve-grid-row>${row.map(cell => html`<nve-grid-cell>${cell}</nve-grid-cell>`)}</nve-grid-row>`)}\n </nve-grid>\n `\n : nothing;\n }\n}\n\ncustomElements.get('ui-csv-grid') || customElements.define('ui-csv-grid', CSVExample);\n\nfunction csvStringValidator(value: unknown): ValidatorResult {\n const message = isValidCSV(value as string);\n if (message !== true) {\n return { validity: { badInput: true }, message };\n } else {\n return { validity: {} };\n }\n}\n\nfunction hasUnclosedQuotes(line: string): boolean {\n let inQuotes = false;\n for (let j = 0; j < line.length; j++) {\n if (line[j] === '\"' && !(j > 0 && line[j - 1] === '\\\\')) {\n inQuotes = !inQuotes;\n }\n }\n return inQuotes;\n}\n\nfunction countColumns(line: string): number {\n return (line.match(/,/g) || []).length + 1;\n}\n\nfunction validateLine(line: string, expectedColumns: number): true | string {\n if (hasUnclosedQuotes(line)) {\n return 'csv contains unclosed quotes';\n }\n\n if (countColumns(line) !== expectedColumns) {\n return 'csv contains invalid column count';\n }\n\n return true;\n}\n\nfunction isValidCSV(csvString: string): true | string {\n if (!csvString || csvString.trim().length === 0) {\n return 'empty';\n }\n\n const lines = csvString.split('\\n');\n const columnCount = countColumns(lines[0]!);\n\n for (const line of lines) {\n if (line.trim().length === 0) {\n continue;\n }\n\n const result = validateLine(line, columnCount);\n if (result !== true) {\n return result;\n }\n }\n\n return true;\n}\n"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.examples.js","names":[
|
|
1
|
+
{"version":3,"file":"light.examples.js","names":[],"sources":["../../src/examples/light.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement, nothing, unsafeCSS } from 'lit';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixins';\nimport './light.examples.js';\n\nexport default {\n title: 'Labs/Forms/Examples'\n};\n\n/**\n * @summary Light card form control with toggle and dim range inputs.\n * @tags test-case\n */\nexport const CardToggle = {\n render: () => html`\n<form nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card value='{\"status\": \"on\", \"dim\": 75}' name=\"office-light\"></ui-light-card>\n <pre id=\"light-card-value\"></pre>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('form');\n const pre = document.querySelector('#light-card-value');\n const lightCard = document.querySelector('ui-light-card[name=\"office-light\"]');\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log('change', e.target.value, Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log('input', e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\n/**\n * @summary Light card form events including submit, reset, and invalid state handling.\n * @tags test-case\n */\nexport const Events = {\n render: () => html`\n<form id=\"novalidate-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card novalidate name=\"novalidate-light\" value='{\"status\": \"on\", \"dim\": 75}'></ui-light-card>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n </div>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('#novalidate-form');\n const pre = form.querySelector('pre');\n const button = form.querySelector('button');\n const light = form.querySelector('[name=\"novalidate-light\"]');\n pre.textContent = JSON.stringify(light.value, null, 2);\n\n button.addEventListener('click', () => {\n light.value = { status: 'invalid', dim: -1 };\n });\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('change', e.target.value);\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('input', e.target.value);\n });\n\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('submit', Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('reset', (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('reset', Object.fromEntries(new FormData(form)));\n });\n });\n\n light.addEventListener('invalid', (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log('invalid', Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\nconst styles = /* css */ `\n:host,\n*,\n*:before,\n*:after {\n box-sizing: border-box;\n}\n\n:host {\n display: block;\n max-width: 240px;\n}\n\n:host(:invalid) {\n outline: 2px dashed red;\n}\n\nform {\n position: relative;\n min-width: 50px;\n min-height: 50px;\n display: flex;\n align-items: center;\n gap: var(--nve-ref-space-xs);\n background: var(--nve-sys-interaction-background-200);\n padding: var(--nve-ref-size-300);\n border-radius: var(--nve-ref-border-radius-lg);\n}\n\nnve-icon {\n position: absolute;\n top: 16px;\n left: 16px;\n pointer-events: none;\n z-index: 99;\n}\n\ninput[name='status'] {\n opacity: 0;\n height: 20px;\n width: 20px;\n}\n`;\n\nexport interface LightCardValue {\n status: 'off' | 'on';\n dim: number;\n}\n\n/**\n * Custom element integrating the FormControlMixin with LitElement for form validation.\n */\nexport class LightCard extends FormControlMixin<typeof LitElement, LightCardValue>(LitElement) {\n static readonly metadata = {\n tag: 'ui-light-card',\n version: '0.0.0',\n strict: false,\n valueSchema: {\n type: 'object' as const,\n properties: {\n status: {\n type: 'enum' as const,\n enum: ['off', 'on']\n },\n dim: {\n type: 'number' as const,\n minimum: 0,\n maximum: 100\n }\n },\n required: ['status', 'dim']\n }\n };\n\n static styles = unsafeCSS(styles);\n\n render() {\n return this.value\n ? html`\n <form @input=${this.#updateValue} @change=${this.#updateValue}>\n <nve-icon size=\"lg\" name=\"lightbulb\" style=\"--color: ${this.value.status === 'on' ? 'var(--nve-ref-color-yellow-nova-900)' : 'initial'}; opacity: ${this.value.status === 'on' ? this.value.dim / 100 + 0.3 : 0.5};\"></nve-icon>\n ${\n this.readOnly\n ? nothing\n : html`\n <input type=\"checkbox\" name=\"status\" .checked=${this.value.status === 'on'} ?disabled=${this.readOnly} aria-label=\"Light Status\">\n <input type=\"range\" name=\"dim\" .valueAsNumber=${this.value.dim} ?disabled=${this.readOnly} min=${LightCard.metadata.valueSchema.properties.dim.minimum ?? 0} max=${LightCard.metadata.valueSchema.properties.dim.maximum ?? 100} aria-label=\"Light Dim\">\n `\n }\n </form>`\n : nothing;\n }\n\n constructor() {\n super();\n this.value = { status: 'off', dim: 50 };\n }\n\n #updateValue(event: Event) {\n const form = this.shadowRoot?.querySelector('form') as HTMLFormElement;\n this.value = { status: form.status.checked ? 'on' : 'off', dim: form.dim.valueAsNumber };\n this.dispatchUpdateEvent(event.type as 'input' | 'change');\n }\n}\n\ncustomElements.get('ui-light-card') ?? customElements.define('ui-light-card', LightCard);"],"mappings":";AAGA,IAAA,IAAe"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{
|
|
5
5
|
"id": "forms-examples-light-card-toggle",
|
|
6
6
|
"name": "CardToggle",
|
|
7
|
-
"template": "<form nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card value='{\"status\": \"on\", \"dim\": 75}' name=\"office-light\"></ui-light-card>\n <pre id=\"light-card-value\"></pre>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const pre = document.querySelector(\"#light-card-value\");\n const lightCard = document.querySelector('ui-light-card[name=\"office-light\"]');\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"change\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"input\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
7
|
+
"template": "<form nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card value='{\"status\": \"on\", \"dim\": 75}' name=\"office-light\"></ui-light-card>\n <pre id=\"light-card-value\"></pre>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const pre = document.querySelector(\"#light-card-value\");\n const lightCard = document.querySelector('ui-light-card[name=\"office-light\"]');\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"change\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(lightCard.value, null, 2);\n console.log(\"input\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
8
8
|
"summary": "Light card form control with toggle and dim range inputs.",
|
|
9
9
|
"description": "",
|
|
10
10
|
"composition": false,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{
|
|
16
16
|
"id": "forms-examples-light-events",
|
|
17
17
|
"name": "Events",
|
|
18
|
-
"template": "<form id=\"novalidate-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card novalidate name=\"novalidate-light\" value='{\"status\": \"on\", \"dim\": 75}'></ui-light-card>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n </div>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"#novalidate-form\");\n const pre = form.querySelector(\"pre\");\n const button = form.querySelector(\"button\");\n const light = form.querySelector('[name=\"novalidate-light\"]');\n pre.textContent = JSON.stringify(light.value, null, 2);\n button.addEventListener(\"click\", () => {\n light.value = { status: \"invalid\", dim: -1 };\n });\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"change\", e.target.value);\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"input\", e.target.value);\n });\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"submit\", Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"reset\", (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"reset\", Object.fromEntries(new FormData(form)));\n });\n });\n light.addEventListener(\"invalid\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"invalid\", Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
18
|
+
"template": "<form id=\"novalidate-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-light-card novalidate name=\"novalidate-light\" value='{\"status\": \"on\", \"dim\": 75}'></ui-light-card>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n </div>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector(\"#novalidate-form\");\n const pre = form.querySelector(\"pre\");\n const button = form.querySelector(\"button\");\n const light = form.querySelector('[name=\"novalidate-light\"]');\n pre.textContent = JSON.stringify(light.value, null, 2);\n\n button.addEventListener(\"click\", () => {\n light.value = { status: \"invalid\", dim: -1 };\n });\n\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"change\", e.target.value);\n });\n\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"input\", e.target.value);\n });\n\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"submit\", Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener(\"reset\", (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"reset\", Object.fromEntries(new FormData(form)));\n });\n });\n\n light.addEventListener(\"invalid\", (e) => {\n pre.textContent = JSON.stringify(light.value, null, 2);\n console.log(\"invalid\", Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
19
19
|
"summary": "Light card form events including submit, reset, and invalid state handling.",
|
|
20
20
|
"description": "",
|
|
21
21
|
"composition": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple.examples.js","names":[
|
|
1
|
+
{"version":3,"file":"simple.examples.js","names":[],"sources":["../../src/examples/simple.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement, nothing } from 'lit';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixins';\n\nexport default {\n title: 'Labs/Forms/Examples'\n};\n\n/**\n * @summary Quality control form with checkbox inputs and schema-based validation.\n * @tags test-case\n */\nexport const QualityCheck = {\n render: () => html`\n<form nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control value='{\"good\": true, \"fast\": true, \"cheap\": false}' name=\"quality\"></ui-quality-control>\n <pre id=\"quality-control-value\"></pre>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('form');\n const pre = document.querySelector('#quality-control-value');\n const qualityControl = document.querySelector('ui-quality-control[name=\"quality\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('change', e.target.value, Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('input', e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\n/**\n * @summary Quality control form events with strict mode toggle and invalid state handling.\n * @tags test-case\n */\nexport const Events = {\n render: () => html`\n<form id=\"simple-events-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control name=\"quality\" value='{\"good\": true, \"fast\": true, \"cheap\": false}'></ui-quality-control>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n <label>\n <input type=\"checkbox\" name=\"strict\" checked />\n strict mode\n </label>\n </div>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector('#simple-events-form');\n const pre = form.querySelector('pre');\n const button = form.querySelector('button');\n const qualityControl = form.querySelector('[name=\"quality\"]');\n const strict = form.querySelector('[name=\"strict\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n\n strict.addEventListener('change', (e) => {\n qualityControl.constructor.metadata.strict = e.target.checked;\n });\n\n button.addEventListener('click', () => {\n qualityControl.value = { good: true, fast: true, cheap: true };\n console.log('click', qualityControl.value);\n });\n\n form.addEventListener('change', (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('change', e.target.value);\n });\n\n form.addEventListener('input', (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('input', e.target.value);\n });\n\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('submit', Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener('reset', (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log('reset', Object.fromEntries(new FormData(form)));\n });\n });\n\n qualityControl.addEventListener('invalid', (e) => {\n console.log('invalid', Object.fromEntries(new FormData(form)));\n });\n</script>\n`\n};\n\nexport interface QualityControlValue {\n good: boolean;\n fast: boolean;\n cheap: boolean;\n}\n\nfunction qualityValidator(value: unknown) {\n const v = value as QualityControlValue;\n if (v.good && v.fast && v.cheap) {\n return {\n validity: { badInput: true },\n message: 'at least one value must be false'\n };\n }\n return { validity: { } };\n}\n\n/**\n * Custom element integrating the FormControlMixin with LitElement for form validation.\n */\nexport class QualityControl extends FormControlMixin<typeof LitElement, QualityControlValue>(LitElement) {\n static styles = [\n css`\n :host {\n display: block;\n }\n\n :host(:invalid) {\n outline: 2px dashed red;\n }\n `\n ];\n\n static readonly metadata = {\n tag: 'ui-quality-control',\n version: '0.0.0',\n strict: true,\n validators: [qualityValidator],\n valueSchema: {\n type: 'object' as const,\n properties: {\n good: {\n type: 'boolean' as const\n },\n fast: {\n type: 'boolean' as const\n },\n cheap: {\n type: 'boolean' as const\n }\n },\n required: ['good', 'fast', 'cheap']\n }\n };\n\n render() {\n return this.value\n ? html`\n <form @input=${this.#updateValue} @change=${this.#updateValue}>\n <label>\n <input type=\"checkbox\" name=\"good\" .checked=${this.value.good} ?disabled=${this.disabled || this.readOnly} aria-label=\"Good\">\n Good\n </label>\n <label>\n <input type=\"checkbox\" name=\"fast\" .checked=${this.value.fast} ?disabled=${this.disabled || this.readOnly} aria-label=\"Fast\">\n Fast\n </label>\n <label>\n <input type=\"checkbox\" name=\"cheap\" .checked=${this.value.cheap} ?disabled=${this.disabled || this.readOnly} aria-label=\"Cheap\">\n Cheap\n </label>\n </form>`\n : nothing;\n }\n\n constructor() {\n super();\n this.value = { good: true, fast: true, cheap: true };\n }\n\n #updateValue(event: Event) {\n const form = this.shadowRoot?.querySelector('form') as HTMLFormElement;\n this.value = { good: form.good.checked, fast: form.fast.checked, cheap: form.cheap.checked };\n this.dispatchUpdateEvent(event.type as 'input' | 'change');\n }\n}\n\ncustomElements.get('ui-quality-control') ?? customElements.define('ui-quality-control', QualityControl);"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{
|
|
5
5
|
"id": "forms-examples-simple-quality-check",
|
|
6
6
|
"name": "QualityCheck",
|
|
7
|
-
"template": "<form nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control value='{\"good\": true, \"fast\": true, \"cheap\": false}' name=\"quality\"></ui-quality-control>\n <pre id=\"quality-control-value\"></pre>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const pre = document.querySelector(\"#quality-control-value\");\n const qualityControl = document.querySelector('ui-quality-control[name=\"quality\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"change\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"input\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
7
|
+
"template": "<form nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control value='{\"good\": true, \"fast\": true, \"cheap\": false}' name=\"quality\"></ui-quality-control>\n <pre id=\"quality-control-value\"></pre>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const pre = document.querySelector(\"#quality-control-value\");\n const qualityControl = document.querySelector('ui-quality-control[name=\"quality\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"change\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"input\", e.target.value, Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
8
8
|
"summary": "Quality control form with checkbox inputs and schema-based validation.",
|
|
9
9
|
"description": "",
|
|
10
10
|
"composition": false,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{
|
|
16
16
|
"id": "forms-examples-simple-events",
|
|
17
17
|
"name": "Events",
|
|
18
|
-
"template": "<form id=\"simple-events-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control name=\"quality\" value='{\"good\": true, \"fast\": true, \"cheap\": false}'></ui-quality-control>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n <label>\n <input type=\"checkbox\" name=\"strict\" checked />\n strict mode\n </label>\n </div>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"#simple-events-form\");\n const pre = form.querySelector(\"pre\");\n const button = form.querySelector(\"button\");\n const qualityControl = form.querySelector('[name=\"quality\"]');\n const strict = form.querySelector('[name=\"strict\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n strict.addEventListener(\"change\", (e) => {\n qualityControl.constructor.metadata.strict = e.target.checked;\n });\n button.addEventListener(\"click\", () => {\n qualityControl.value = { good: true, fast: true, cheap: true };\n console.log(\"click\", qualityControl.value);\n });\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"change\", e.target.value);\n });\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"input\", e.target.value);\n });\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"submit\", Object.fromEntries(new FormData(form)));\n });\n form.addEventListener(\"reset\", (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"reset\", Object.fromEntries(new FormData(form)));\n });\n });\n qualityControl.addEventListener(\"invalid\", (e) => {\n console.log(\"invalid\", Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
18
|
+
"template": "<form id=\"simple-events-form\" nve-layout=\"column gap:lg pad:lg\">\n <ui-quality-control name=\"quality\" value='{\"good\": true, \"fast\": true, \"cheap\": false}'></ui-quality-control>\n <pre></pre>\n <div nve-layout=\"row gap:sm\">\n <button type=\"button\">set invalid value</button>\n <button type=\"reset\">reset</button>\n <button type=\"submit\">submit</button>\n <label>\n <input type=\"checkbox\" name=\"strict\" checked />\n strict mode\n </label>\n </div>\n</form>\n\n<script type=\"module\">\n const form = document.querySelector(\"#simple-events-form\");\n const pre = form.querySelector(\"pre\");\n const button = form.querySelector(\"button\");\n const qualityControl = form.querySelector('[name=\"quality\"]');\n const strict = form.querySelector('[name=\"strict\"]');\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n\n strict.addEventListener(\"change\", (e) => {\n qualityControl.constructor.metadata.strict = e.target.checked;\n });\n\n button.addEventListener(\"click\", () => {\n qualityControl.value = { good: true, fast: true, cheap: true };\n console.log(\"click\", qualityControl.value);\n });\n\n form.addEventListener(\"change\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"change\", e.target.value);\n });\n\n form.addEventListener(\"input\", (e) => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"input\", e.target.value);\n });\n\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"submit\", Object.fromEntries(new FormData(form)));\n });\n\n form.addEventListener(\"reset\", (e) => {\n // reset event fires before the value is reset\n setTimeout(() => {\n pre.textContent = JSON.stringify(qualityControl.value, null, 2);\n console.log(\"reset\", Object.fromEntries(new FormData(form)));\n });\n });\n\n qualityControl.addEventListener(\"invalid\", (e) => {\n console.log(\"invalid\", Object.fromEntries(new FormData(form)));\n });\n</script>\n",
|
|
19
19
|
"summary": "Quality control form events with strict mode toggle and invalid state handling.",
|
|
20
20
|
"description": "",
|
|
21
21
|
"composition": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visualization.examples.js","names":[
|
|
1
|
+
{"version":3,"file":"visualization.examples.js","names":[],"sources":["../../src/examples/visualization.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement, nothing } from 'lit';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixins';\nimport '@nvidia-elements/core/color/define.js';\nimport '@nvidia-elements/core/radio/define.js';\nimport '@nvidia-elements/core/range/define.js';\nimport './visualization.examples.js';\n\nexport default {\n title: 'Labs/Forms/Examples'\n};\n\n/**\n * @summary Animated canvas visualization driven by form controls for color, shape, scale, and particle count.\n * @tags test-case\n */\nexport const CanvasParticles = {\n render: () => html`\n<section nve-layout=\"row gap:lg pad:lg align:center\">\n <form nve-layout=\"column gap:lg pad:lg\">\n <nve-color>\n <label>Color</label>\n <input type=\"color\" name=\"color\" value=\"#26ab40\" />\n </nve-color>\n <nve-radio-group>\n <label>Shape</label>\n <nve-radio>\n <label>Circle</label>\n <input type=\"radio\" name=\"shape\" value=\"circle\" checked/>\n </nve-radio>\n <nve-radio>\n <label>Square</label>\n <input type=\"radio\" name=\"shape\" value=\"square\" />\n </nve-radio>\n </nve-radio-group>\n <nve-range>\n <label>Scale</label>\n <input type=\"range\" name=\"scale\" value=\"20\" min=\"5\" max=\"100\" />\n </nve-range>\n <nve-range>\n <label>Particle Count</label>\n <input type=\"range\" name=\"particleCount\" value=\"100\" min=\"1\" max=\"10000\" />\n </nve-range>\n </form>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-entity-draw name=\"draw\" value='{\"color\": \"#26ab40\", \"shape\": \"circle\", \"scale\": 20, \"particleCount\": 100}'></ui-entity-draw>\n</section>\n<script type=\"module\">\n const form = document.querySelector('form');\n const draw = document.querySelector('ui-entity-draw');\n form.addEventListener('input', (e) => {\n draw.value = {\n color: form.elements.color.value,\n shape: form.elements.shape.value,\n scale: form.elements.scale.valueAsNumber,\n particleCount: form.elements.particleCount.valueAsNumber\n }\n });\n</script>\n`\n};\n\nconst styles = css`\n:host {\n display: block;\n}\n\nform {\n background: var(--nve-sys-layer-container-background);\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 1rem;\n border-radius: 0.5rem;\n box-shadow: 0 0 0.5rem 0 rgba(0, 0, 0, 0.1);\n}\n\nlabel {\n display: flex;\n align-items: center;\n line-height: 1;\n gap: 0.5rem;\n}\n\ninput {\n margin: 4px 0;\n}\n\npre {\n background: color-mix(in oklab, var(--nve-sys-layer-container-background) 100%, var(--nve-sys-text-muted-color) 7%);\n padding: 12px;\n margin: 0;\n}\n`;\n\nexport interface DrawValue {\n color: string;\n shape: 'circle' | 'square';\n scale: number;\n particleCount: number;\n}\n\nexport class Draw extends FormControlMixin<typeof LitElement, DrawValue>(LitElement) {\n static readonly metadata = {\n version: '0.0.0',\n tag: 'ui-entity-draw',\n valueSchema: {\n type: 'object' as const,\n properties: {\n color: {\n type: 'string' as const,\n format: 'color'\n },\n shape: {\n type: 'enum' as const,\n enum: ['circle', 'square']\n },\n scale: {\n type: 'number' as const,\n minimum: 1,\n maximum: 100\n },\n particleCount: {\n type: 'number' as const,\n minimum: 1,\n maximum: 10000\n }\n },\n required: ['color', 'shape', 'scale', 'particleCount']\n }\n };\n\n static styles = [\n styles,\n css`canvas {border: var(--nve-ref-border-width-sm) solid var(--nve-ref-border-color-muted);}`\n ];\n\n #shapes: Array<{ x: number; y: number; rotation: number }> = [];\n #canvas?: HTMLCanvasElement;\n #animationFrame?: number;\n\n render() {\n return this.value\n ? html`\n <form>\n <canvas name=\"canvas\" width=\"400\" height=\"400\"></canvas>\n <pre>${JSON.stringify(this.value, null, 2)}</pre>\n </form>\n `\n : nothing;\n }\n\n constructor() {\n super();\n this.updateValue({ color: '#000000', shape: 'circle', scale: 50, particleCount: 20 });\n }\n\n firstUpdated() {\n this.#canvas = this.renderRoot.querySelector('canvas') ?? undefined;\n this.#startAnimation();\n }\n\n updated(changedProperties: Map<string, unknown>) {\n super.updated(changedProperties);\n if (this.value && this.value.particleCount !== this.#shapes.length) {\n this.#shapes = new Array(this.value.particleCount).fill(0).map(() => {\n return { x: Math.random() * 400, y: Math.random() * 400, rotation: Math.random() * Math.PI * 2 };\n });\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.#animationFrame) {\n cancelAnimationFrame(this.#animationFrame);\n }\n }\n\n #startAnimation() {\n const animate = () => {\n if (this.value) {\n this.#render(this.value);\n }\n this.#animationFrame = requestAnimationFrame(animate);\n };\n animate();\n }\n\n #render(value: DrawValue) {\n const ctx = this.#canvas!.getContext('2d')!;\n ctx.clearRect(0, 0, this.#canvas!.width, this.#canvas!.height);\n\n const size = value.scale / 2.5;\n this.#shapes.forEach((shape, i) => {\n shape.y += Math.sin((Date.now() + i * 500) / 1000) * 0.5;\n shape.x += Math.cos((Date.now() + i * 500) / 1000) * 0.5;\n shape.rotation += 0.01;\n shape.x = (shape.x + this.#canvas!.width) % this.#canvas!.width;\n shape.y = (shape.y + this.#canvas!.height) % this.#canvas!.height;\n\n ctx.save();\n ctx.translate(shape.x, shape.y);\n ctx.rotate(shape.rotation);\n ctx.fillStyle = value.color;\n\n if (value.shape === 'circle') {\n ctx.beginPath();\n ctx.arc(0, 0, size / 2, 0, Math.PI * 2);\n ctx.fill();\n } else {\n ctx.fillRect(-size / 2, -size / 2, size, size);\n }\n\n ctx.restore();\n });\n }\n}\n\ncustomElements.get('ui-entity-draw') || customElements.define('ui-entity-draw', Draw);\n"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
{
|
|
5
5
|
"id": "forms-examples-visualization-canvas-particles",
|
|
6
6
|
"name": "CanvasParticles",
|
|
7
|
-
"template": "<section nve-layout=\"row gap:lg pad:lg align:center\">\n <form nve-layout=\"column gap:lg pad:lg\">\n <nve-color>\n <label>Color</label>\n <input type=\"color\" name=\"color\" value=\"#26ab40\" />\n </nve-color>\n <nve-radio-group>\n <label>Shape</label>\n <nve-radio>\n <label>Circle</label>\n <input type=\"radio\" name=\"shape\" value=\"circle\" checked />\n </nve-radio>\n <nve-radio>\n <label>Square</label>\n <input type=\"radio\" name=\"shape\" value=\"square\" />\n </nve-radio>\n </nve-radio-group>\n <nve-range>\n <label>Scale</label>\n <input type=\"range\" name=\"scale\" value=\"20\" min=\"5\" max=\"100\" />\n </nve-range>\n <nve-range>\n <label>Particle Count</label>\n <input type=\"range\" name=\"particleCount\" value=\"100\" min=\"1\" max=\"10000\" />\n </nve-range>\n </form>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-entity-draw
|
|
7
|
+
"template": "<section nve-layout=\"row gap:lg pad:lg align:center\">\n <form nve-layout=\"column gap:lg pad:lg\">\n <nve-color>\n <label>Color</label>\n <input type=\"color\" name=\"color\" value=\"#26ab40\" />\n </nve-color>\n <nve-radio-group>\n <label>Shape</label>\n <nve-radio>\n <label>Circle</label>\n <input type=\"radio\" name=\"shape\" value=\"circle\" checked />\n </nve-radio>\n <nve-radio>\n <label>Square</label>\n <input type=\"radio\" name=\"shape\" value=\"square\" />\n </nve-radio>\n </nve-radio-group>\n <nve-range>\n <label>Scale</label>\n <input type=\"range\" name=\"scale\" value=\"20\" min=\"5\" max=\"100\" />\n </nve-range>\n <nve-range>\n <label>Particle Count</label>\n <input type=\"range\" name=\"particleCount\" value=\"100\" min=\"1\" max=\"10000\" />\n </nve-range>\n </form>\n <nve-divider orientation=\"vertical\"></nve-divider>\n <ui-entity-draw name=\"draw\" value='{\"color\": \"#26ab40\", \"shape\": \"circle\", \"scale\": 20, \"particleCount\": 100}'></ui-entity-draw>\n</section>\n<script type=\"module\">\n const form = document.querySelector(\"form\");\n const draw = document.querySelector(\"ui-entity-draw\");\n form.addEventListener(\"input\", (e) => {\n draw.value = {\n color: form.elements.color.value,\n shape: form.elements.shape.value,\n scale: form.elements.scale.valueAsNumber,\n particleCount: form.elements.particleCount.valueAsNumber,\n };\n });\n</script>\n",
|
|
8
8
|
"summary": "Animated canvas visualization driven by form controls for color, shape, scale, and particle count.",
|
|
9
9
|
"description": "",
|
|
10
10
|
"composition": true,
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{
|
|
16
16
|
"id": "forms-examples-visualization-styles",
|
|
17
17
|
"name": "styles",
|
|
18
|
-
"template": ":host { display: block; } form { background: var(--nve-sys-layer-container-background); display: flex; flex-direction
|
|
18
|
+
"template": ":host { display: block; } form { background: var(--nve-sys-layer-container-background); display: flex; flex-direction: column; gap: 6px; padding: 1rem; border-radius: 0.5rem; box-shadow: 0 0 0.5rem 0 rgba(0, 0, 0, 0.1);\n} label { display: flex; align-items: center; line-height: 1; gap: 0.5rem; } input { margin: 4px 0; } pre { background: color-mix(in oklab, var(--nve-sys-layer-container-background) 100%, var(--nve-sys-text-muted-color)\n7%); padding: 12px; margin: 0; }\n",
|
|
19
19
|
"summary": "",
|
|
20
20
|
"description": "",
|
|
21
21
|
"composition": false,
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-active.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"state-active.controller.js","names":[],"sources":["../../../src/internal/controllers/state-active.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Active = ReactiveElement & { disabled: boolean; _internals?: ElementInternals };\n\nexport class StateActiveController<T extends Active> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n this.host.addEventListener('keypress', this.#onActive as EventListener);\n this.host.addEventListener('mousedown', this.#onActive as EventListener);\n this.host.addEventListener('keyup', this.#onInactive);\n this.host.addEventListener('blur', this.#onInactive);\n this.host.addEventListener('mouseup', this.#onInactive);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('keypress', this.#onActive as EventListener);\n this.host.removeEventListener('mousedown', this.#onActive as EventListener);\n this.host.removeEventListener('keyup', this.#onInactive);\n this.host.removeEventListener('blur', this.#onInactive);\n this.host.removeEventListener('mouseup', this.#onInactive);\n }\n\n #onActive = (event: KeyboardEvent | PointerEvent) => {\n if (!this.host.disabled && this.#isValidActiveEvent(event)) {\n this.host._internals!.states.add('active');\n }\n\n if (event instanceof KeyboardEvent && event.code === 'Space' && event.target === this.host) {\n event.preventDefault();\n }\n };\n\n #onInactive = () => {\n this.host._internals!.states.delete('active');\n };\n\n #isValidActiveEvent(event: KeyboardEvent | PointerEvent) {\n return event instanceof KeyboardEvent ? event.code === 'Space' || event.code === 'Enter' : true;\n }\n}\n"],"mappings":";;AAQA,IAAa,IAAb,MAAmF;CACjF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAMd,AALA,EAAgB,KAAK,IAAI,GACzB,KAAK,KAAK,iBAAiB,YAAY,KAAK,EAA0B,GACtE,KAAK,KAAK,iBAAiB,aAAa,KAAK,EAA0B,GACvE,KAAK,KAAK,iBAAiB,SAAS,KAAK,EAAW,GACpD,KAAK,KAAK,iBAAiB,QAAQ,KAAK,EAAW,GACnD,KAAK,KAAK,iBAAiB,WAAW,KAAK,EAAW;CACxD;CAEA,mBAAmB;EAKjB,AAJA,KAAK,KAAK,oBAAoB,YAAY,KAAK,EAA0B,GACzE,KAAK,KAAK,oBAAoB,aAAa,KAAK,EAA0B,GAC1E,KAAK,KAAK,oBAAoB,SAAS,KAAK,EAAW,GACvD,KAAK,KAAK,oBAAoB,QAAQ,KAAK,EAAW,GACtD,KAAK,KAAK,oBAAoB,WAAW,KAAK,EAAW;CAC3D;CAEA,MAAa,MAAwC;EAKnD,AAJI,CAAC,KAAK,KAAK,YAAY,KAAK,GAAoB,CAAK,KACvD,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,GAGvC,aAAiB,iBAAiB,EAAM,SAAS,WAAW,EAAM,WAAW,KAAK,QACpF,EAAM,eAAe;CAEzB;CAEA,WAAoB;EAClB,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ;CAC9C;CAEA,GAAoB,GAAqC;EACvD,OAAO,aAAiB,gBAAgB,EAAM,SAAS,WAAW,EAAM,SAAS,UAAU;CAC7F;AACF"}
|
|
@@ -17,7 +17,7 @@ var n = class {
|
|
|
17
17
|
this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !!this.host.current), this.#t();
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
this.host._internals.ariaCurrent = this.host.current === null || this.host.current === void 0 ? null :
|
|
20
|
+
this.host._internals.ariaCurrent = this.host.current === null || this.host.current === void 0 ? null : this.host.current, t(this.host._internals, "current", !!this.host.current);
|
|
21
21
|
}
|
|
22
22
|
#t() {
|
|
23
23
|
let e = this.host.querySelector("a"), t = !this.host.readOnly && this.host._internals.states.has("anchor") && !!(this.host.selected || this.host.current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-current.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"state-current.controller.js","names":[],"sources":["../../../src/internal/controllers/state-current.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Current = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateCurrentController<T extends Current> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaCurrent =\n this.host.current === null || this.host.current === undefined ? null : this.host.current;\n\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAqF;CACnF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAGtB,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAK,GACnD,KAAK,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,cAAc,MACpC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ,GACxE,KAAK,GAA4B;GACjC;EACF;EAKA,AAHA,KAAK,KAAK,WAAY,cACpB,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,IAAY,OAAO,KAAK,KAAK,SAEnF,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAK,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAK,KAAuB;GAC5B;EACF;EAGA,AADA,KAAK,IAAsB,gBAAgB,cAAc,GACzD,KAAK,KAAuB;CAC9B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-disabled.controller.js","names":[],"sources":["../../../src/internal/controllers/state-disabled.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Disabled = ReactiveElement & {
|
|
1
|
+
{"version":3,"file":"state-disabled.controller.js","names":[],"sources":["../../../src/internal/controllers/state-disabled.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Disabled = ReactiveElement & {\n disabled: boolean | null | undefined;\n readOnly?: boolean;\n _internals?: ElementInternals;\n};\n\n/**\n * Adds disabled support for interactive custom elements including CSS State psuedo-selector :state(disabled) and aria-disabled.\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled\n */\nexport class StateDisabledController<T extends Disabled> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.disabled !== null && this.host.disabled !== undefined) {\n this.host._internals!.ariaDisabled = `${this.host.disabled}`;\n } else {\n this.host._internals!.ariaDisabled = null;\n }\n\n if (this.host.disabled) {\n this.host._internals!.states.add('disabled');\n } else {\n this.host._internals!.states.delete('disabled');\n }\n\n if (this.host.readOnly) {\n this.host._internals!.ariaDisabled = null;\n }\n }\n}\n"],"mappings":";;AAiBA,IAAa,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAaZ,AAZI,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IACxD,KAAK,KAAK,WAAY,eAAe,GAAG,KAAK,KAAK,aAElD,KAAK,KAAK,WAAY,eAAe,MAGnC,KAAK,KAAK,WACZ,KAAK,KAAK,WAAY,OAAO,IAAI,UAAU,IAE3C,KAAK,KAAK,WAAY,OAAO,OAAO,UAAU,GAG5C,KAAK,KAAK,aACZ,KAAK,KAAK,WAAY,eAAe;CAEzC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-selected.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"state-selected.controller.js","names":[],"sources":["../../../src/internal/controllers/state-selected.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Selected = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateSelectedController<T extends Selected> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaSelected =\n this.host.selected === null || this.host.selected === undefined ? null : `${this.host.selected}`;\n\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAa,IAAb,MAAuF;CACrF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAGtB,AAFA,KAAK,KAAK,WAAY,eAAe,MACrC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAK,GACpD,KAAK,GAA4B;GACjC;EACF;EAEA,IAAI,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,GAAG;GAG9C,AAFA,KAAK,KAAK,WAAY,eAAe,MACrC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS,GAC1E,KAAK,GAA4B;GACjC;EACF;EAKA,AAHA,KAAK,KAAK,WAAY,eACpB,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,YAExF,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;CAEA,KAA8B;EAC5B,IAAM,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvD,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,IAAI,KAAU,GAAW;GAGvB,AAFA,KAAK,IAAsB,gBAAgB,cAAc,GACzD,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAK,KAAuB;GAC5B;EACF;EAGA,AADA,KAAK,IAAsB,gBAAgB,cAAc,GACzD,KAAK,KAAuB;CAC9B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-anchor.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"type-anchor.controller.js","names":[],"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,KAAK;CACd;CAEA,cAAc;EACZ,KAAK,GAA4B;EACjC,IAAM,IAAS,KAAK;EAcpB,AAbA,KAAK,KAAY,EAAQ,GAErB,IACF,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,IAEzC,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ,GAG1C,KAAK,OACP,KAAK,GAAc,MAAM,iBAAiB,QAC1C,KAAK,KAAK,MAAM,SAAS,YAG3B,KAAK,GAA0B,CAAM;CACvC;CAEA,mBAAmB;EACjB,KAAK,GAA2B;CAClC;CAEA,IAAI,KAAU;EACZ,OAAO,KAAK,MAAkB,KAAK;CACrC;CAEA,IAAI,KAAiB;EACnB,OAAO,KAAK,KAAK,YACb,cAA+B,yBAAyB,CAAC,EACzD,iBAAiB,CAAC,EAClB,MAAK,MAAW,GAAS,YAAY,GAAG;CAC9C;CAEA,IAAI,KAAgB;EAClB,OAAO,KAAK,KAAK,eAAe,YAAY,MAAO,KAAK,KAAK,gBAAsC;CACrG;CAEA,IAAI,KAAe;EACjB,OAAO,KAAK,KAAK,YAAY,cAA+B,kBAAkB;CAChF;CAEA,IAAI,KAAc;EAChB,OAAO,KAAK,KAAK,YAAY,cAA+B,mBAAmB;CACjF;CAEA,KAA8B;EAC5B,AAAI,KAAK,MAAW,KAAK,OACvB,KAAK,GAAQ,OAAO,UACpB,KAAK,IAAc,cAAc,CAAC,CAAC,SAAQ,MAAQ,EAAoB,CAAI,CAAC;CAEhF;CAEA,GAA0B,GAA8C;EAGtE,AAFA,KAAK,GAA2B,GAChC,KAAK,KAAqB,KAAU,MACpC,KAAK,IAAoB,iBAAiB,SAAS,KAAK,EAAc;CACxE;CAEA,KAA6B;EAE3B,AADA,KAAK,IAAoB,oBAAoB,SAAS,KAAK,EAAc,GACzE,KAAK,KAAqB;CAC5B;CAEA,MAAkB,MAAiB;EACjC,AAAI,KAAK,KAAK,aACZ,EAAM,eAAe,GACrB,EAAM,yBAAyB;CAEnC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-button.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"type-button.controller.js","names":[],"sources":["../../../src/internal/controllers/type-button.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype ButtonBehaviorHost = ReactiveElement & {\n disabled: boolean;\n readOnly: boolean;\n _internals?: ElementInternals;\n};\n\nexport class TypeButtonController<T extends ButtonBehaviorHost> implements ReactiveController {\n #enabledRole: string | null = null;\n #initialTabIndex = 0;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n if (this.host.hasAttribute('tabindex')) {\n this.#initialTabIndex = this.host.tabIndex;\n }\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n if (this.host._internals!.role && this.host._internals!.role !== 'none') {\n this.#enabledRole = this.host._internals!.role;\n }\n\n this.host._internals!.role = 'none';\n this.host.tabIndex = -1;\n this.host.removeAttribute('tabindex');\n return;\n }\n\n if (!this.host._internals!.role || this.host._internals!.role === 'none') {\n this.host._internals!.role = this.#enabledRole ?? 'button';\n } else {\n this.#enabledRole = this.host._internals!.role;\n }\n\n this.host.tabIndex = this.host.disabled ? -1 : this.#initialTabIndex;\n }\n}\n"],"mappings":";AAWA,IAAa,IAAb,MAA8F;CAC5F,KAA8B;CAC9B,KAAmB;CAEnB,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,AAAI,KAAK,KAAK,aAAa,UAAU,MACnC,KAAK,KAAmB,KAAK,KAAK;CAEtC;CAEA,cAAc;EACZ,IAAI,KAAK,KAAK,UAAU;GAOtB,AANI,KAAK,KAAK,WAAY,QAAQ,KAAK,KAAK,WAAY,SAAS,WAC/D,KAAK,KAAe,KAAK,KAAK,WAAY,OAG5C,KAAK,KAAK,WAAY,OAAO,QAC7B,KAAK,KAAK,WAAW,IACrB,KAAK,KAAK,gBAAgB,UAAU;GACpC;EACF;EAQA,AANI,CAAC,KAAK,KAAK,WAAY,QAAQ,KAAK,KAAK,WAAY,SAAS,SAChE,KAAK,KAAK,WAAY,OAAO,KAAK,MAAgB,WAElD,KAAK,KAAe,KAAK,KAAK,WAAY,MAG5C,KAAK,KAAK,WAAW,KAAK,KAAK,WAAW,KAAK,KAAK;CACtD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-command.controller.js","names":[
|
|
1
|
+
{"version":3,"file":"type-command.controller.js","names":[],"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,KAAK,KAAU,CAAC,GAAG,IAAI,IAAI,CAAM,CAAC,GAClC,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,cAAc;EAEZ,AADA,KAAK,GAAuB,GACxB,CAAC,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,YACpC,KAAK,GAAQ,SAAQ,MAAa,KAAK,KAAK,iBAAiB,GAAW,KAAK,EAAU,CAAC;CAE5F;CAEA,mBAAmB;EACjB,KAAK,GAAuB;CAC9B;CAEA,KAAyB;EACvB,KAAK,GAAQ,SAAQ,MAAa,KAAK,KAAK,oBAAoB,GAAW,KAAK,EAAU,CAAC;CAC7F;CAEA,MAAc,MAAiB;EAC7B,AAAK,EAAM,oBACT,KAAK,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"}
|