@nvidia-elements/forms 2.0.11 → 2.0.13
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 +40 -0
- package/dist/custom-elements.json +8 -39
- package/dist/examples/csv.examples.js +1 -2
- package/dist/examples/csv.examples.js.map +1 -1
- package/dist/examples/light.examples.js +1 -2
- package/dist/examples/light.examples.js.map +1 -1
- package/dist/examples/simple.examples.js +1 -2
- package/dist/examples/simple.examples.js.map +1 -1
- package/dist/examples/visualization.examples.js +1 -2
- package/dist/examples/visualization.examples.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/controllers/state-active.controller.js +1 -2
- package/dist/internal/controllers/state-active.controller.js.map +1 -1
- package/dist/internal/controllers/state-current.controller.js +3 -16
- package/dist/internal/controllers/state-current.controller.js.map +1 -1
- package/dist/internal/controllers/state-disabled.controller.js +1 -2
- package/dist/internal/controllers/state-disabled.controller.js.map +1 -1
- package/dist/internal/controllers/state-expanded.controller.js +1 -2
- package/dist/internal/controllers/state-expanded.controller.js.map +1 -1
- package/dist/internal/controllers/state-pressed.controller.js +1 -2
- package/dist/internal/controllers/state-pressed.controller.js.map +1 -1
- package/dist/internal/controllers/state-readonly.controller.js +1 -2
- package/dist/internal/controllers/state-readonly.controller.js.map +1 -1
- package/dist/internal/controllers/state-selected.controller.js +3 -16
- package/dist/internal/controllers/state-selected.controller.js.map +1 -1
- package/dist/internal/controllers/type-anchor.controller.js +1 -2
- package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.js +2 -7
- package/dist/internal/controllers/type-button.controller.js.map +1 -1
- package/dist/internal/controllers/type-command.controller.js +1 -2
- package/dist/internal/controllers/type-command.controller.js.map +1 -1
- package/dist/internal/controllers/type-interest-invoker.controller.js +2 -3
- package/dist/internal/controllers/type-interest-invoker.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover-trigger.controller.js +1 -2
- package/dist/internal/controllers/type-popover-trigger.controller.js.map +1 -1
- package/dist/internal/controllers/type-submit.controller.js +2 -7
- package/dist/internal/controllers/type-submit.controller.js.map +1 -1
- package/dist/internal/errors.js +1 -2
- package/dist/internal/errors.js.map +1 -1
- package/dist/internal/index.js +1 -2
- package/dist/internal/schema.js +1 -2
- package/dist/internal/schema.js.map +1 -1
- package/dist/internal/types.d.ts +0 -3
- package/dist/internal/utils.d.ts +0 -2
- package/dist/internal/utils.js +2 -3
- package/dist/internal/utils.js.map +1 -1
- package/dist/mixins/button.d.ts +6 -0
- package/dist/mixins/button.js +12 -19
- package/dist/mixins/button.js.map +1 -1
- package/dist/mixins/checkbox.js +2 -9
- package/dist/mixins/checkbox.js.map +1 -1
- package/dist/mixins/control.js +3 -12
- package/dist/mixins/control.js.map +1 -1
- package/dist/mixins/index.d.ts +5 -0
- package/dist/mixins/select.js +1 -2
- package/dist/mixins/select.js.map +1 -1
- package/dist/mixins/slider.js +1 -2
- package/dist/mixins/slider.js.map +1 -1
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/index.js +1 -2
- package/dist/validators/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
## [2.0.13](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.12...@nvidia-elements/forms-v2.0.13) (2026-11-07)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **core:** add configurable tabs indicator animation duration ([0cc3093](https://github.com/NVIDIA/elements/commit/0cc3093056d6a6e24d9e8876fb444d3ccc0ba3b6))
|
|
6
|
+
* **core:** add ghost and workspace ([c2bdec9](https://github.com/NVIDIA/elements/commit/c2bdec9701628add8dc364786023a6019660aee3))
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **cli:** drop unused utilities ([71dcf96](https://github.com/NVIDIA/elements/commit/71dcf96ff531cd4ef69db6e55f08fbeecb005015))
|
|
11
|
+
* **core:** drop obsolete checkbox clip-path fallback ([8cddf24](https://github.com/NVIDIA/elements/commit/8cddf24eab9f15f444ddc25152277ebd864116bd))
|
|
12
|
+
* **core:** drop obsolete constructed stylesheet polyfill ([30b0684](https://github.com/NVIDIA/elements/commit/30b068411d1bd067e60935eb8ab60d8b6ad85268))
|
|
13
|
+
* **core:** drop obsolete element internals polyfill ([bb0649c](https://github.com/NVIDIA/elements/commit/bb0649ced505ef4cfc0f050302046794a935441a))
|
|
14
|
+
* **core:** drop obsolete formdata polyfill ([7831582](https://github.com/NVIDIA/elements/commit/78315824a2a9bfb81a615986a181d695b5bf6acc))
|
|
15
|
+
* **core:** drop obsolete logo color-mix fallback ([93ea57f](https://github.com/NVIDIA/elements/commit/93ea57f6ed300fce24952f5b44a4f5dc5b7b87b1))
|
|
16
|
+
* **core:** drop unused utilities ([9e4b1bc](https://github.com/NVIDIA/elements/commit/9e4b1bc6b942de163d33ed71ae676041dd8fb4e6))
|
|
17
|
+
* **core:** re-render bugfixes ([48e5ac4](https://github.com/NVIDIA/elements/commit/48e5ac4e5c66e0c9659e47095698fe33bfc68629))
|
|
18
|
+
* **docs:** update 3d-force-graph to 1.80.2 ([86a69e9](https://github.com/NVIDIA/elements/commit/86a69e92a607dc254ca7df2e3e4428ae0d6126e5))
|
|
19
|
+
* **forms:** drop unused utilities ([c538a47](https://github.com/NVIDIA/elements/commit/c538a47e79366919f43fb8f35950c52159f40d6c))
|
|
20
|
+
* **themes:** correct rounding issue ([3c22eef](https://github.com/NVIDIA/elements/commit/3c22eef05362992c8a50ebc82664e6d0a76a4692))
|
|
21
|
+
|
|
22
|
+
## [2.0.12](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.11...@nvidia-elements/forms-v2.0.12) (2026-11-03)
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* **core:** scroll box invoker command support ([4b41419](https://github.com/NVIDIA/elements/commit/4b414197911ba0c5b3fd942f9f51a89b0768c419))
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **cli:** update notice ([21a6510](https://github.com/NVIDIA/elements/commit/21a6510164469615358937cdf833edc05bfa9cb8))
|
|
31
|
+
* **core:** correct dropdown group navigation and popover rendering ([5bf985f](https://github.com/NVIDIA/elements/commit/5bf985f1b0e434e8b5d08f1b29b18accbfd65c14))
|
|
32
|
+
* **core:** correct gesture termination handling ([0aab542](https://github.com/NVIDIA/elements/commit/0aab542b206b25933d921416a62f8a70c44b2723))
|
|
33
|
+
* **core:** iframe separate theme script and resize handling ([9391e0b](https://github.com/NVIDIA/elements/commit/9391e0beffe1751d80c2cb8da981e20906fb48a9))
|
|
34
|
+
* **core:** refresh menu tab order when items change ([024ff58](https://github.com/NVIDIA/elements/commit/024ff582b0d01ec8f63c629922bbf77d8e72c989))
|
|
35
|
+
* **core:** remove obsolete inset-area popover fallback ([8a1d913](https://github.com/NVIDIA/elements/commit/8a1d9131f75c6c9879bef3413688e7a22a7d2306))
|
|
36
|
+
* **core:** remove unused polyfill ([427b3ef](https://github.com/NVIDIA/elements/commit/427b3ef8bf1fb4d70a86ede95b719e7aea1bd58e))
|
|
37
|
+
* **forms:** remove obsolete popover trigger fallback ([0973027](https://github.com/NVIDIA/elements/commit/09730270e6d81c8d9139cfb56aef9d9c5a2344f6))
|
|
38
|
+
* **markdown:** update notice ([1315538](https://github.com/NVIDIA/elements/commit/1315538849bc452a321c3043411fd5e555025e75))
|
|
39
|
+
* **pi:** update notice ([561c535](https://github.com/NVIDIA/elements/commit/561c535744d599f26fb2692f00b089ed8eac74ef))
|
|
40
|
+
|
|
1
41
|
## [2.0.11](https://github.com/NVIDIA/elements/compare/@nvidia-elements/forms-v2.0.10...@nvidia-elements/forms-v2.0.11) (2026-11-02)
|
|
2
42
|
|
|
3
43
|
### Features
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"type": {
|
|
13
13
|
"text": "string"
|
|
14
14
|
},
|
|
15
|
-
"default": "'0.0.0'"
|
|
15
|
+
"default": "'0.0.0'",
|
|
16
|
+
"privacy": "public"
|
|
16
17
|
}
|
|
17
18
|
],
|
|
18
19
|
"exports": [
|
|
@@ -1241,33 +1242,6 @@
|
|
|
1241
1242
|
}
|
|
1242
1243
|
]
|
|
1243
1244
|
},
|
|
1244
|
-
{
|
|
1245
|
-
"kind": "function",
|
|
1246
|
-
"name": "onKeys",
|
|
1247
|
-
"parameters": [
|
|
1248
|
-
{
|
|
1249
|
-
"name": "events",
|
|
1250
|
-
"type": {
|
|
1251
|
-
"text": "string[]",
|
|
1252
|
-
"_sourceAliases": []
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
{
|
|
1256
|
-
"name": "event",
|
|
1257
|
-
"type": {
|
|
1258
|
-
"text": "KeyboardEvent",
|
|
1259
|
-
"_sourceAliases": []
|
|
1260
|
-
}
|
|
1261
|
-
},
|
|
1262
|
-
{
|
|
1263
|
-
"name": "callback",
|
|
1264
|
-
"type": {
|
|
1265
|
-
"text": "() => void",
|
|
1266
|
-
"_sourceAliases": []
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
]
|
|
1270
|
-
},
|
|
1271
1245
|
{
|
|
1272
1246
|
"kind": "function",
|
|
1273
1247
|
"name": "removeEmptyTextNode",
|
|
@@ -1387,14 +1361,6 @@
|
|
|
1387
1361
|
"module": "/src/internal/utils.js"
|
|
1388
1362
|
}
|
|
1389
1363
|
},
|
|
1390
|
-
{
|
|
1391
|
-
"kind": "js",
|
|
1392
|
-
"name": "onKeys",
|
|
1393
|
-
"declaration": {
|
|
1394
|
-
"name": "onKeys",
|
|
1395
|
-
"module": "/src/internal/utils.js"
|
|
1396
|
-
}
|
|
1397
|
-
},
|
|
1398
1364
|
{
|
|
1399
1365
|
"kind": "js",
|
|
1400
1366
|
"name": "removeEmptyTextNode",
|
|
@@ -1441,7 +1407,8 @@
|
|
|
1441
1407
|
"_sourceAliases": []
|
|
1442
1408
|
}
|
|
1443
1409
|
}
|
|
1444
|
-
]
|
|
1410
|
+
],
|
|
1411
|
+
"privacy": "public"
|
|
1445
1412
|
}
|
|
1446
1413
|
],
|
|
1447
1414
|
"exports": [
|
|
@@ -1698,7 +1665,8 @@
|
|
|
1698
1665
|
}
|
|
1699
1666
|
}
|
|
1700
1667
|
],
|
|
1701
|
-
"description": "Given a json schema, check the value against the schema\nJSON Schema follows the OpenAI JSON Schema for structured outputs\nhttps://platform.openai.com/docs/guides/structured-outputs\n\n- All fields or function parameters must specify required\n- Require additionalProperties: false on all objects\n- Structured Outputs support the following types:\n - String\n - Number\n - Boolean\n - Object\n - Array\n - Enum"
|
|
1668
|
+
"description": "Given a json schema, check the value against the schema\nJSON Schema follows the OpenAI JSON Schema for structured outputs\nhttps://platform.openai.com/docs/guides/structured-outputs\n\n- All fields or function parameters must specify required\n- Require additionalProperties: false on all objects\n- Structured Outputs support the following types:\n - String\n - Number\n - Boolean\n - Object\n - Array\n - Enum",
|
|
1669
|
+
"privacy": "public"
|
|
1702
1670
|
},
|
|
1703
1671
|
{
|
|
1704
1672
|
"kind": "function",
|
|
@@ -1723,7 +1691,8 @@
|
|
|
1723
1691
|
"_sourceAliases": []
|
|
1724
1692
|
}
|
|
1725
1693
|
}
|
|
1726
|
-
]
|
|
1694
|
+
],
|
|
1695
|
+
"privacy": "public"
|
|
1727
1696
|
}
|
|
1728
1697
|
],
|
|
1729
1698
|
"exports": [
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"csv.examples.js","names":["csv_examples_default"],"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,IAAAA,IAAc"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"light.examples.js","names":["light_examples_default"],"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,IAAAA,IAAe"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"simple.examples.js","names":["simple_examples_default"],"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,IAAAA,IAAc"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"visualization.examples.js","names":["visualization_examples_default"],"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,IAAAA,IAAc"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport const VERSION = '0.0.0';\n\nexport * from './internal/types.js';\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","names":["VERSION"],"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/** @public */\nexport const VERSION = '0.0.0';\n\n/** @public */\nexport * from './internal/types.js';\n"],"mappings":";AAIA,IAAaA,IAAU"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-active.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -20,7 +20,6 @@ var t = class {
|
|
|
20
20
|
return e instanceof KeyboardEvent ? e.code === "Space" || e.code === "Enter" : !0;
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { t as StateActiveController };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=state-active.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"state-active.controller.js","names":["StateActiveController","host","attachInternals","#onActive","#onInactive","#isValidActiveEvent","event"],"sources":["../../../src/internal/controllers/state-active.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Active = ReactiveElement & { disabled: boolean; _internals?: ElementInternals };\n\nexport class StateActiveController<T extends Active> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n this.host.addEventListener('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,IAAaA,IAAb,MAAmF;CACjF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EAMd,AALAC,EAAgB,KAAK,IAAI,GACzB,KAAK,KAAK,iBAAiB,YAAY,KAAKC,EAA0B,GACtE,KAAK,KAAK,iBAAiB,aAAa,KAAKA,EAA0B,GACvE,KAAK,KAAK,iBAAiB,SAAS,KAAKC,EAAW,GACpD,KAAK,KAAK,iBAAiB,QAAQ,KAAKA,EAAW,GACnD,KAAK,KAAK,iBAAiB,WAAW,KAAKA,EAAW;CACxD;CAEA,mBAAmB;EAKjB,AAJA,KAAK,KAAK,oBAAoB,YAAY,KAAKD,EAA0B,GACzE,KAAK,KAAK,oBAAoB,aAAa,KAAKA,EAA0B,GAC1E,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAW,GACvD,KAAK,KAAK,oBAAoB,QAAQ,KAAKA,EAAW,GACtD,KAAK,KAAK,oBAAoB,WAAW,KAAKA,EAAW;CAC3D;CAEA,MAAa,MAAwC;EAKnD,AAJI,CAAC,KAAK,KAAK,YAAY,KAAKC,GAAoBC,CAAK,KACvD,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,GAGvCA,aAAiB,iBAAiBA,EAAM,SAAS,WAAWA,EAAM,WAAW,KAAK,QACpFA,EAAM,eAAe;CAEzB;CAEA,WAAoB;EAClB,KAAK,KAAK,WAAY,OAAO,OAAO,QAAQ;CAC9C;CAEA,GAAoB,GAAqC;EACvD,OAAOA,aAAiB,gBAAgBA,EAAM,SAAS,WAAWA,EAAM,SAAS,UAAU;CAC7F;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e, toggleState as t } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-current.controller.ts
|
|
3
3
|
var n = class {
|
|
4
4
|
#e = null;
|
|
5
5
|
constructor(e) {
|
|
@@ -9,26 +9,13 @@ var n = class {
|
|
|
9
9
|
e(this.host);
|
|
10
10
|
}
|
|
11
11
|
hostUpdated() {
|
|
12
|
-
|
|
13
|
-
this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !1), this.#t();
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (this.host._internals?.states.has("anchor")) {
|
|
17
|
-
this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !!this.host.current), this.#t();
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
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);
|
|
12
|
+
this.host.readOnly ? (this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !1), this.#t()) : this.host._internals?.states.has("anchor") ? (this.host._internals.ariaCurrent = null, t(this.host._internals, "current", !!this.host.current), this.#t()) : (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
13
|
}
|
|
22
14
|
#t() {
|
|
23
15
|
let e = this.host.querySelector("a"), t = !this.host.readOnly && this.host._internals.states.has("anchor") && !!(this.host.selected || this.host.current);
|
|
24
|
-
|
|
25
|
-
this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this.#e?.removeAttribute("aria-current"), this.#e = null;
|
|
16
|
+
e && t ? (this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e) : (this.#e?.removeAttribute("aria-current"), this.#e = null);
|
|
29
17
|
}
|
|
30
18
|
};
|
|
31
|
-
//#endregion
|
|
32
19
|
export { n as StateCurrentController };
|
|
33
20
|
|
|
34
21
|
//# sourceMappingURL=state-current.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"state-current.controller.js","names":["StateCurrentController","host","toggleState","#syncAnchorCurrentAttribute","anchor","isCurrent","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-current.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Current = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateCurrentController<T extends Current> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaCurrent = null;\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaCurrent =\n this.host.current === null || this.host.current === undefined ? null : this.host.current;\n\n toggleState(this.host._internals!, 'current', Boolean(this.host.current));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAaA,IAAb,MAAqF;CACnF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,AAAI,KAAK,KAAK,YACZ,KAAK,KAAK,WAAY,cAAc,MACpCC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAK,GACnD,KAAKC,GAA4B,KAI/B,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,KAC3C,KAAK,KAAK,WAAY,cAAc,MACpCD,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ,GACxE,KAAKC,GAA4B,MAInC,KAAK,KAAK,WAAY,cACpB,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,IAAY,OAAO,KAAK,KAAK,SAEnFD,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;CAEA,KAA8B;EAC5B,IAAME,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvDC,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,AAAID,KAAUC,KACZ,KAAKC,IAAsB,gBAAgB,cAAc,GACzDF,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAKE,KAAuBF,MAI9B,KAAKE,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-disabled.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -11,7 +11,6 @@ var t = class {
|
|
|
11
11
|
this.host.disabled !== null && this.host.disabled !== void 0 ? this.host._internals.ariaDisabled = `${this.host.disabled}` : this.host._internals.ariaDisabled = null, this.host.disabled ? this.host._internals.states.add("disabled") : this.host._internals.states.delete("disabled"), this.host.readOnly && (this.host._internals.ariaDisabled = null);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { t as StateDisabledController };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=state-disabled.controller.js.map
|
|
@@ -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 & {\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,
|
|
1
|
+
{"version":3,"file":"state-disabled.controller.js","names":["StateDisabledController","host"],"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,IAAaA,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,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,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e, toggleState as t } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-expanded.controller.ts
|
|
3
3
|
var n = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -11,7 +11,6 @@ var n = class {
|
|
|
11
11
|
this.host._internals.ariaExpanded = this.host.expanded === null || this.host.expanded === void 0 ? null : `${this.host.expanded}`, t(this.host._internals, "expanded", !!this.host.expanded);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { n as StateExpandedController };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=state-expanded.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-expanded.controller.js","names":[],"sources":["../../../src/internal/controllers/state-expanded.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Expanded = ReactiveElement & { expanded?: boolean | null; _internals?: ElementInternals };\n\nexport class StateExpandedController<T extends Expanded> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaExpanded =\n this.host.expanded === null || this.host.expanded === undefined ? null : `${this.host.expanded}`;\n\n toggleState(this.host._internals!, 'expanded', Boolean(this.host.expanded));\n }\n}\n"],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"state-expanded.controller.js","names":["StateExpandedController","host","toggleState"],"sources":["../../../src/internal/controllers/state-expanded.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Expanded = ReactiveElement & { expanded?: boolean | null; _internals?: ElementInternals };\n\nexport class StateExpandedController<T extends Expanded> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaExpanded =\n this.host.expanded === null || this.host.expanded === undefined ? null : `${this.host.expanded}`;\n\n toggleState(this.host._internals!, 'expanded', Boolean(this.host.expanded));\n }\n}\n"],"mappings":";;AAQA,IAAaA,IAAb,MAAuF;CACrF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAIZ,AAHA,KAAK,KAAK,WAAY,eACpB,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,YAExFC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e, toggleState as t } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-pressed.controller.ts
|
|
3
3
|
var n = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -11,7 +11,6 @@ var n = class {
|
|
|
11
11
|
this.host._internals.ariaPressed = this.host.pressed === null || this.host.pressed === void 0 ? null : `${this.host.pressed}`, t(this.host._internals, "pressed", !!this.host.pressed);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { n as StatePressedController };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=state-pressed.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-pressed.controller.js","names":[],"sources":["../../../src/internal/controllers/state-pressed.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Pressed = ReactiveElement & { pressed?: boolean | null; _internals?: ElementInternals };\n\nexport class StatePressedController<T extends Pressed> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaPressed =\n this.host.pressed === null || this.host.pressed === undefined ? null : `${this.host.pressed}`;\n\n toggleState(this.host._internals!, 'pressed', Boolean(this.host.pressed));\n }\n}\n"],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"state-pressed.controller.js","names":["StatePressedController","host","toggleState"],"sources":["../../../src/internal/controllers/state-pressed.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Pressed = ReactiveElement & { pressed?: boolean | null; _internals?: ElementInternals };\n\nexport class StatePressedController<T extends Pressed> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n this.host._internals!.ariaPressed =\n this.host.pressed === null || this.host.pressed === undefined ? null : `${this.host.pressed}`;\n\n toggleState(this.host._internals!, 'pressed', Boolean(this.host.pressed));\n }\n}\n"],"mappings":";;AAQA,IAAaA,IAAb,MAAqF;CACnF,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EAIZ,AAHA,KAAK,KAAK,WAAY,cACpB,KAAK,KAAK,YAAY,QAAQ,KAAK,KAAK,YAAY,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,WAEtFC,EAAY,KAAK,KAAK,YAAa,WAAW,EAAQ,KAAK,KAAK,OAAQ;CAC1E;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-readonly.controller.ts
|
|
3
3
|
var t = class {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
this.host = e, this.host.addController(this);
|
|
@@ -11,7 +11,6 @@ var t = class {
|
|
|
11
11
|
this.host.readOnly && (this.host._internals.ariaDisabled = null, this.host._internals.ariaExpanded = null, this.host._internals.ariaPressed = null, this.host._internals.ariaSelected = null, this.host._internals.ariaCurrent = null, this.host._internals.states.delete("expanded"), this.host._internals.states.delete("pressed"), this.host._internals.states.delete("selected"), this.host._internals.states.delete("current"));
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
//#endregion
|
|
15
14
|
export { t as StateReadOnlyController };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=state-readonly.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-readonly.controller.js","names":[],"sources":["../../../src/internal/controllers/state-readonly.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';\nimport { attachInternals } from '../utils.js';\n\ntype ReadOnlyState = ReactiveElement & { readOnly?: boolean; _internals?: ElementInternals };\n\nexport class StateReadOnlyController<T extends ReadOnlyState> 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.readOnly) {\n this.host._internals!.ariaDisabled = null;\n this.host._internals!.ariaExpanded = null;\n this.host._internals!.ariaPressed = null;\n this.host._internals!.ariaSelected = null;\n this.host._internals!.ariaCurrent = null;\n this.host._internals!.states.delete('expanded');\n this.host._internals!.states.delete('pressed');\n this.host._internals!.states.delete('selected');\n this.host._internals!.states.delete('current');\n }\n }\n}\n"],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"state-readonly.controller.js","names":["StateReadOnlyController","host"],"sources":["../../../src/internal/controllers/state-readonly.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';\nimport { attachInternals } from '../utils.js';\n\ntype ReadOnlyState = ReactiveElement & { readOnly?: boolean; _internals?: ElementInternals };\n\nexport class StateReadOnlyController<T extends ReadOnlyState> 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.readOnly) {\n this.host._internals!.ariaDisabled = null;\n this.host._internals!.ariaExpanded = null;\n this.host._internals!.ariaPressed = null;\n this.host._internals!.ariaSelected = null;\n this.host._internals!.ariaCurrent = null;\n this.host._internals!.states.delete('expanded');\n this.host._internals!.states.delete('pressed');\n this.host._internals!.states.delete('selected');\n this.host._internals!.states.delete('current');\n }\n }\n}\n"],"mappings":";;AAQA,IAAaA,IAAb,MAA4F;CAC1F,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,AAAI,KAAK,KAAK,aACZ,KAAK,KAAK,WAAY,eAAe,MACrC,KAAK,KAAK,WAAY,eAAe,MACrC,KAAK,KAAK,WAAY,cAAc,MACpC,KAAK,KAAK,WAAY,eAAe,MACrC,KAAK,KAAK,WAAY,cAAc,MACpC,KAAK,KAAK,WAAY,OAAO,OAAO,UAAU,GAC9C,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS,GAC7C,KAAK,KAAK,WAAY,OAAO,OAAO,UAAU,GAC9C,KAAK,KAAK,WAAY,OAAO,OAAO,SAAS;CAEjD;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attachInternals as e, toggleState as t } from "../utils.js";
|
|
2
|
-
|
|
2
|
+
// src/internal/controllers/state-selected.controller.ts
|
|
3
3
|
var n = class {
|
|
4
4
|
#e = null;
|
|
5
5
|
constructor(e) {
|
|
@@ -9,26 +9,13 @@ var n = class {
|
|
|
9
9
|
e(this.host);
|
|
10
10
|
}
|
|
11
11
|
hostUpdated() {
|
|
12
|
-
|
|
13
|
-
this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !1), this.#t();
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (this.host._internals?.states.has("anchor")) {
|
|
17
|
-
this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !!this.host.selected), this.#t();
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
this.host._internals.ariaSelected = this.host.selected === null || this.host.selected === void 0 ? null : `${this.host.selected}`, t(this.host._internals, "selected", !!this.host.selected);
|
|
12
|
+
this.host.readOnly ? (this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !1), this.#t()) : this.host._internals?.states.has("anchor") ? (this.host._internals.ariaSelected = null, t(this.host._internals, "selected", !!this.host.selected), this.#t()) : (this.host._internals.ariaSelected = this.host.selected === null || this.host.selected === void 0 ? null : `${this.host.selected}`, t(this.host._internals, "selected", !!this.host.selected));
|
|
21
13
|
}
|
|
22
14
|
#t() {
|
|
23
15
|
let e = this.host.querySelector("a"), t = !this.host.readOnly && this.host._internals.states.has("anchor") && !!(this.host.selected || this.host.current);
|
|
24
|
-
|
|
25
|
-
this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
this.#e?.removeAttribute("aria-current"), this.#e = null;
|
|
16
|
+
e && t ? (this.#e?.removeAttribute("aria-current"), e.setAttribute("aria-current", this.host.current ?? "page"), this.#e = e) : (this.#e?.removeAttribute("aria-current"), this.#e = null);
|
|
29
17
|
}
|
|
30
18
|
};
|
|
31
|
-
//#endregion
|
|
32
19
|
export { n as StateSelectedController };
|
|
33
20
|
|
|
34
21
|
//# sourceMappingURL=state-selected.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"state-selected.controller.js","names":["StateSelectedController","host","toggleState","#syncAnchorCurrentAttribute","anchor","isCurrent","#anchorCurrentTarget"],"sources":["../../../src/internal/controllers/state-selected.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { attachInternals, toggleState } from '../utils.js';\nimport type { ReactiveController, ReactiveElement } from './types.js';\n\ntype Selected = ReactiveElement & {\n current?: string | null;\n readOnly?: boolean;\n selected?: boolean | null;\n _internals?: ElementInternals;\n};\n\nexport class StateSelectedController<T extends Selected> implements ReactiveController {\n #anchorCurrentTarget: HTMLAnchorElement | null = null;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n attachInternals(this.host);\n }\n\n hostUpdated() {\n if (this.host.readOnly) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', false);\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n if (this.host._internals?.states.has('anchor')) {\n this.host._internals!.ariaSelected = null;\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n this.#syncAnchorCurrentAttribute();\n return;\n }\n\n this.host._internals!.ariaSelected =\n this.host.selected === null || this.host.selected === undefined ? null : `${this.host.selected}`;\n\n toggleState(this.host._internals!, 'selected', Boolean(this.host.selected));\n }\n\n #syncAnchorCurrentAttribute() {\n const anchor = this.host.querySelector<HTMLAnchorElement>('a');\n const isCurrent =\n !this.host.readOnly &&\n this.host._internals!.states.has('anchor') &&\n Boolean(this.host.selected || this.host.current);\n\n if (anchor && isCurrent) {\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n anchor.setAttribute('aria-current', this.host.current ?? 'page');\n this.#anchorCurrentTarget = anchor;\n return;\n }\n\n this.#anchorCurrentTarget?.removeAttribute('aria-current');\n this.#anchorCurrentTarget = null;\n }\n}\n"],"mappings":";;AAaA,IAAaA,IAAb,MAAuF;CACrF,KAAiD;CAEjD,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAAC,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,EAAgB,KAAK,IAAI;CAC3B;CAEA,cAAc;EACZ,AAAI,KAAK,KAAK,YACZ,KAAK,KAAK,WAAY,eAAe,MACrCC,EAAY,KAAK,KAAK,YAAa,YAAY,EAAK,GACpD,KAAKC,GAA4B,KAI/B,KAAK,KAAK,YAAY,OAAO,IAAI,QAAQ,KAC3C,KAAK,KAAK,WAAY,eAAe,MACrCD,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS,GAC1E,KAAKC,GAA4B,MAInC,KAAK,KAAK,WAAY,eACpB,KAAK,KAAK,aAAa,QAAQ,KAAK,KAAK,aAAa,KAAA,IAAY,OAAO,GAAG,KAAK,KAAK,YAExFD,EAAY,KAAK,KAAK,YAAa,YAAY,EAAQ,KAAK,KAAK,QAAS;CAC5E;CAEA,KAA8B;EAC5B,IAAME,IAAS,KAAK,KAAK,cAAiC,GAAG,GACvDC,IACJ,CAAC,KAAK,KAAK,YACX,KAAK,KAAK,WAAY,OAAO,IAAI,QAAQ,KACzC,GAAQ,KAAK,KAAK,YAAY,KAAK,KAAK;EAE1C,AAAID,KAAUC,KACZ,KAAKC,IAAsB,gBAAgB,cAAc,GACzDF,EAAO,aAAa,gBAAgB,KAAK,KAAK,WAAW,MAAM,GAC/D,KAAKE,KAAuBF,MAI9B,KAAKE,IAAsB,gBAAgB,cAAc,GACzD,KAAKA,KAAuB;CAC9B;AACF"}
|