@nvidia-elements/core 2.2.2 → 2.3.0
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 +27 -0
- package/dist/accordion/accordion2.js +4 -4
- package/dist/alert/alert-group2.js +1 -1
- package/dist/alert/alert.examples.js.map +1 -1
- package/dist/alert/alert.examples.json +7 -3
- package/dist/alert/alert2.js +1 -1
- package/dist/avatar/avatar-group2.js +1 -1
- package/dist/avatar/avatar2.js +1 -1
- package/dist/badge/badge2.js +1 -1
- package/dist/breadcrumb/breadcrumb2.js +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundles/index.d.ts +61 -8
- package/dist/bundles/index.js +6 -6
- package/dist/button/button2.js +1 -1
- package/dist/button-group/button-group2.js +1 -1
- package/dist/card/card.examples.js.map +1 -1
- package/dist/card/card.examples.json +10 -4
- package/dist/card/card2.js +4 -4
- package/dist/chat-message/chat-message2.js +1 -1
- package/dist/checkbox/checkbox-group2.js +1 -1
- package/dist/checkbox/checkbox2.js +1 -1
- package/dist/color/color2.js +1 -1
- package/dist/combobox/combobox2.js +1 -1
- package/dist/copy-button/copy-button2.js +1 -1
- package/dist/custom-elements-jsx.d.ts +47 -10
- package/dist/custom-elements-vue.d.ts +47 -10
- package/dist/custom-elements.json +394 -17
- package/dist/data.html.json +65 -7
- package/dist/data.snippets.json +27 -27
- package/dist/date/date2.js +1 -1
- package/dist/datetime/datetime2.js +1 -1
- package/dist/dialog/dialog-footer2.js +1 -1
- package/dist/dialog/dialog-header2.js +1 -1
- package/dist/dialog/dialog.d.ts +1 -1
- package/dist/dialog/dialog2.js +1 -1
- package/dist/dialog/dialog2.js.map +1 -1
- package/dist/divider/divider2.js +1 -1
- package/dist/dot/dot2.js +1 -1
- package/dist/drawer/drawer-content2.js +1 -1
- package/dist/drawer/drawer-footer2.js +1 -1
- package/dist/drawer/drawer-header2.js +1 -1
- package/dist/drawer/drawer.d.ts +1 -1
- package/dist/drawer/drawer2.js +1 -1
- package/dist/drawer/drawer2.js.map +1 -1
- package/dist/dropdown/dropdown-footer2.js +1 -1
- package/dist/dropdown/dropdown-header2.js +1 -1
- package/dist/dropdown/dropdown.d.ts +3 -3
- package/dist/dropdown/dropdown2.js +1 -1
- package/dist/dropdown/dropdown2.js.map +1 -1
- package/dist/dropdown-group/dropdown-group.js +1 -1
- package/dist/dropzone/dropzone2.js +1 -1
- package/dist/file/file2.js +1 -1
- package/dist/format-bytes/define.d.ts +6 -0
- package/dist/format-bytes/define.js +7 -0
- package/dist/format-bytes/define.js.map +1 -0
- package/dist/format-bytes/format-bytes.d.ts +53 -0
- package/dist/format-bytes/format-bytes.examples.js +6 -0
- package/dist/format-bytes/format-bytes.examples.js.map +1 -0
- package/dist/format-bytes/format-bytes.examples.json +69 -0
- package/dist/format-bytes/format-bytes.js +6 -0
- package/dist/format-bytes/format-bytes.js.map +1 -0
- package/dist/format-bytes/format-bytes2.js +182 -0
- package/dist/format-bytes/format-bytes2.js.map +1 -0
- package/dist/format-bytes/index.d.ts +1 -0
- package/dist/format-bytes/index.js +2 -0
- package/dist/format-datetime/format-datetime2.js +1 -1
- package/dist/format-number/format-number2.js +1 -1
- package/dist/format-relative-time/format-relative-time2.js +1 -1
- package/dist/forms/control/control.js +1 -1
- package/dist/forms/control/control.js.map +1 -1
- package/dist/forms/control/control2.js +9 -21
- package/dist/forms/control/control2.js.map +1 -1
- package/dist/forms/control-group/control-group2.js +1 -1
- package/dist/forms/control-message/control-message2.js +1 -1
- package/dist/gauge/gauge.examples.js.map +1 -1
- package/dist/gauge/gauge.examples.json +1 -1
- package/dist/gauge/gauge2.js +1 -1
- package/dist/grid/cell/cell2.js +1 -1
- package/dist/grid/column/column2.js +1 -1
- package/dist/grid/footer/footer2.js +1 -1
- package/dist/grid/grid.examples.js.map +1 -1
- package/dist/grid/grid.examples.json +6 -2
- package/dist/grid/grid2.js +1 -1
- package/dist/grid/header/header2.js +1 -1
- package/dist/grid/placeholder/placeholder2.js +1 -1
- package/dist/grid/row/row2.js +1 -1
- package/dist/icon/icon2.js +2 -2
- package/dist/icon-button/icon-button2.js +1 -1
- package/dist/index.js +1 -1
- package/dist/input/input-group2.js +1 -1
- package/dist/input/input.js +1 -1
- package/dist/input/input.js.map +1 -1
- package/dist/input/input2.js +1 -1
- package/dist/internal/services/global.service.js +1 -1
- package/dist/logo/logo2.js +1 -1
- package/dist/menu/menu-item2.js +1 -1
- package/dist/menu/menu2.js +1 -1
- package/dist/month/month2.js +1 -1
- package/dist/notification/notification-group2.js +1 -1
- package/dist/notification/notification.d.ts +1 -1
- package/dist/notification/notification2.js +1 -1
- package/dist/notification/notification2.js.map +1 -1
- package/dist/page/page-panel/page-panel-content2.js +1 -1
- package/dist/page/page-panel/page-panel-footer2.js +1 -1
- package/dist/page/page-panel/page-panel-header2.js +1 -1
- package/dist/page/page-panel/page-panel2.js +1 -1
- package/dist/page/page.d.ts +1 -0
- package/dist/page/page.js +1 -1
- package/dist/page/page.js.map +1 -1
- package/dist/page/page2.js +1 -1
- package/dist/page/page2.js.map +1 -1
- package/dist/page-header/page-header2.js +1 -1
- package/dist/page-loader/page-loader2.js +1 -1
- package/dist/pagination/pagination2.js +1 -1
- package/dist/panel/panel2.js +4 -4
- package/dist/password/password2.js +1 -1
- package/dist/preferences-input/preferences-input2.js +1 -1
- package/dist/progress-bar/progress-bar2.js +1 -1
- package/dist/progress-ring/progress-ring2.js +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip2.js +1 -1
- package/dist/pulse/pulse2.js +1 -1
- package/dist/radio/radio-group2.js +1 -1
- package/dist/radio/radio2.js +1 -1
- package/dist/range/range2.js +1 -1
- package/dist/resize-handle/resize-handle2.js +1 -1
- package/dist/search/search2.js +1 -1
- package/dist/select/select.js +1 -1
- package/dist/select/select.js.map +1 -1
- package/dist/select/select2.js +1 -1
- package/dist/skeleton/skeleton2.js +1 -1
- package/dist/sort-button/sort-button2.js +1 -1
- package/dist/sparkline/sparkline2.js +1 -1
- package/dist/star-rating/star-rating2.js +1 -1
- package/dist/steps/steps2.js +2 -2
- package/dist/switch/switch-group2.js +1 -1
- package/dist/switch/switch2.js +1 -1
- package/dist/tabs/tabs-group2.js +1 -1
- package/dist/tabs/tabs2.js +2 -2
- package/dist/tag/tag2.js +1 -1
- package/dist/textarea/textarea2.js +1 -1
- package/dist/time/time2.js +1 -1
- package/dist/toast/toast.d.ts +1 -1
- package/dist/toast/toast2.js +1 -1
- package/dist/toast/toast2.js.map +1 -1
- package/dist/toggletip/toggletip-footer2.js +1 -1
- package/dist/toggletip/toggletip-header2.js +1 -1
- package/dist/toggletip/toggletip.examples.js.map +1 -1
- package/dist/toggletip/toggletip.examples.json +1 -1
- package/dist/toggletip/toggletip2.js +1 -1
- package/dist/toolbar/toolbar.examples.js.map +1 -1
- package/dist/toolbar/toolbar.examples.json +1 -1
- package/dist/toolbar/toolbar2.js +1 -1
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip2.js +1 -1
- package/dist/tooltip/tooltip2.js.map +1 -1
- package/dist/tree/tree-node2.js +1 -1
- package/dist/tree/tree2.js +1 -1
- package/dist/week/week2.js +1 -1
- package/package.json +26 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","names":[],"sources":["../../src/format-bytes/define.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { define } from '@nvidia-elements/core/internal';\nimport { FormatBytes } from '@nvidia-elements/core/format-bytes';\n\ndefine(FormatBytes);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nve-format-bytes': FormatBytes;\n }\n}\n"],"mappings":";;;AAMA,EAAO,CAAW"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export type FormatBytesDisplay = 'decimal' | 'binary';
|
|
3
|
+
export type FormatBytesUnit = 'b' | 'kb' | 'mb' | 'gb' | 'tb' | 'pb';
|
|
4
|
+
export type FormatBytesUnitDisplay = 'short' | 'long';
|
|
5
|
+
/**
|
|
6
|
+
* @element nve-format-bytes
|
|
7
|
+
* @description Formats a byte count as localized, human-readable decimal or binary units.
|
|
8
|
+
* @documentation https://nvidia.github.io/elements/docs/elements/format-bytes/
|
|
9
|
+
* @since 0.0.0
|
|
10
|
+
* @entrypoint \@nvidia-elements/core/format-bytes
|
|
11
|
+
* @slot - Numeric byte count to format (such as 1048576). Serves as fallback before hydration.
|
|
12
|
+
* @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data
|
|
13
|
+
*/
|
|
14
|
+
export declare class FormatBytes extends LitElement {
|
|
15
|
+
#private;
|
|
16
|
+
static styles: import("lit").CSSResult[];
|
|
17
|
+
static readonly metadata: {
|
|
18
|
+
tag: string;
|
|
19
|
+
version: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Optional byte count for values supplied by JavaScript or bound data.
|
|
23
|
+
* By default, the component formats the element's text content, which also serves as the SSR fallback.
|
|
24
|
+
* When both are present, this property takes precedence.
|
|
25
|
+
*/
|
|
26
|
+
value?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Unit system: 'decimal' uses powers of 1000 and 'binary' uses powers of 1024.
|
|
29
|
+
*/
|
|
30
|
+
display: FormatBytesDisplay;
|
|
31
|
+
/**
|
|
32
|
+
* Optional unit magnitude. When omitted, the component selects a unit from the byte count.
|
|
33
|
+
*/
|
|
34
|
+
unit?: FormatBytesUnit;
|
|
35
|
+
/**
|
|
36
|
+
* Unit label length: 'short' renders labels such as 'mb'; 'long' renders labels such as 'megabytes'.
|
|
37
|
+
*/
|
|
38
|
+
unitDisplay: FormatBytesUnitDisplay;
|
|
39
|
+
/**
|
|
40
|
+
* Language tag (such as en-US or de-DE) used to format the number.
|
|
41
|
+
* Defaults to document.documentElement.lang or the runtime default.
|
|
42
|
+
*/
|
|
43
|
+
locale?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Pad fraction output to at least this many digits.
|
|
46
|
+
*/
|
|
47
|
+
minimumFractionDigits?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Round fraction output to at most this many digits. Defaults to two effective digits after the decimal point.
|
|
50
|
+
*/
|
|
51
|
+
maximumFractionDigits?: number;
|
|
52
|
+
render(): import("lit").TemplateResult<1>;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-bytes.examples.js","names":[],"sources":["../../src/format-bytes/format-bytes.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html } from 'lit';\nimport '@nvidia-elements/core/format-bytes/define.js';\n\nexport default {\n title: 'Elements/FormatBytes',\n component: 'nve-format-bytes'\n};\n\n/**\n * @summary Automatic decimal conversion for concise file sizes and storage metrics. The component selects the appropriate unit from the byte count.\n */\nexport const Default = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes>1024</nve-format-bytes>\n <nve-format-bytes>1048576</nve-format-bytes>\n <nve-format-bytes>1073741824</nve-format-bytes>\n </div>\n `\n};\n\n/**\n * @summary Forced unit magnitudes for comparing byte counts on a consistent scale. Use when values need the same unit across a table or chart.\n */\nexport const Unit = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes unit=\"kb\">1048576</nve-format-bytes>\n <nve-format-bytes unit=\"mb\">1048576</nve-format-bytes>\n <nve-format-bytes unit=\"gb\">1048576</nve-format-bytes>\n </div>\n `\n};\n\n/**\n * @summary Short and long unit labels for compact metrics or explanatory text. Long labels improve clarity when space allows.\n */\nexport const UnitDisplay = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes unit-display=\"short\">1048576</nve-format-bytes>\n <nve-format-bytes unit-display=\"long\">1048576</nve-format-bytes>\n <nve-format-bytes display=\"binary\" unit-display=\"long\">1048576</nve-format-bytes>\n </div>\n `\n};\n\n/**\n * @summary Fraction digit controls for matching the precision of storage measurements. Use fixed digits when values must align visually.\n */\nexport const Precision = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes maximum-fraction-digits=\"0\">1234567</nve-format-bytes>\n <nve-format-bytes maximum-fraction-digits=\"2\">1234567</nve-format-bytes>\n <nve-format-bytes minimum-fraction-digits=\"3\" maximum-fraction-digits=\"3\">1234567</nve-format-bytes>\n </div>\n `\n};\n\n/**\n * @summary Explicit locale formatting for audiences whose numeric separators differ from the document language. Unit labels remain lowercase English.\n */\nexport const Locale = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes locale=\"en-US\">1048576</nve-format-bytes>\n <nve-format-bytes locale=\"de-DE\">1048576</nve-format-bytes>\n <nve-format-bytes locale=\"fr-FR\">1048576</nve-format-bytes>\n </div>\n `\n};\n\n/**\n * @summary Value attribute input for JavaScript or bound data. It takes precedence over text content while the text remains an SSR fallback.\n */\nexport const Value = {\n render: () => html`<nve-format-bytes value=\"1048576\">1024</nve-format-bytes>`\n};\n\n/**\n * @summary Decimal and binary conversion for matching SI or IEC storage conventions. Use the convention expected by the surrounding product.\n */\nexport const Display = {\n render: () => html`\n <div nve-layout=\"column gap:sm\">\n <nve-format-bytes display=\"decimal\">1024</nve-format-bytes>\n <nve-format-bytes display=\"binary\">1024</nve-format-bytes>\n </div>\n `\n};\n"],"mappings":";AAGA,IAAA,IAAS"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"element": "nve-format-bytes",
|
|
3
|
+
"entrypoint": "@nvidia-elements/core/format-bytes/format-bytes.examples.json",
|
|
4
|
+
"items": [
|
|
5
|
+
{
|
|
6
|
+
"id": "format-bytes",
|
|
7
|
+
"name": "Default",
|
|
8
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes>1024</nve-format-bytes>\n <nve-format-bytes>1048576</nve-format-bytes>\n <nve-format-bytes>1073741824</nve-format-bytes>\n</div>\n",
|
|
9
|
+
"summary": "Automatic decimal conversion for concise file sizes and storage metrics. The component selects the appropriate unit from the byte count.",
|
|
10
|
+
"description": "",
|
|
11
|
+
"composition": false,
|
|
12
|
+
"tags": []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "format-bytes-unit",
|
|
16
|
+
"name": "Unit",
|
|
17
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes unit=\"kb\">1048576</nve-format-bytes>\n <nve-format-bytes unit=\"mb\">1048576</nve-format-bytes>\n <nve-format-bytes unit=\"gb\">1048576</nve-format-bytes>\n</div>\n",
|
|
18
|
+
"summary": "Forced unit magnitudes for comparing byte counts on a consistent scale. Use when values need the same unit across a table or chart.",
|
|
19
|
+
"description": "",
|
|
20
|
+
"composition": false,
|
|
21
|
+
"tags": []
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "format-bytes-unit-display",
|
|
25
|
+
"name": "UnitDisplay",
|
|
26
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes unit-display=\"short\">1048576</nve-format-bytes>\n <nve-format-bytes unit-display=\"long\">1048576</nve-format-bytes>\n <nve-format-bytes display=\"binary\" unit-display=\"long\">1048576</nve-format-bytes>\n</div>\n",
|
|
27
|
+
"summary": "Short and long unit labels for compact metrics or explanatory text. Long labels improve clarity when space allows.",
|
|
28
|
+
"description": "",
|
|
29
|
+
"composition": false,
|
|
30
|
+
"tags": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "format-bytes-precision",
|
|
34
|
+
"name": "Precision",
|
|
35
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes maximum-fraction-digits=\"0\">1234567</nve-format-bytes>\n <nve-format-bytes maximum-fraction-digits=\"2\">1234567</nve-format-bytes>\n <nve-format-bytes minimum-fraction-digits=\"3\" maximum-fraction-digits=\"3\">1234567</nve-format-bytes>\n</div>\n",
|
|
36
|
+
"summary": "Fraction digit controls for matching the precision of storage measurements. Use fixed digits when values must align visually.",
|
|
37
|
+
"description": "",
|
|
38
|
+
"composition": false,
|
|
39
|
+
"tags": []
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "format-bytes-locale",
|
|
43
|
+
"name": "Locale",
|
|
44
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes locale=\"en-US\">1048576</nve-format-bytes>\n <nve-format-bytes locale=\"de-DE\">1048576</nve-format-bytes>\n <nve-format-bytes locale=\"fr-FR\">1048576</nve-format-bytes>\n</div>\n",
|
|
45
|
+
"summary": "Explicit locale formatting for audiences whose numeric separators differ from the document language. Unit labels remain lowercase English.",
|
|
46
|
+
"description": "",
|
|
47
|
+
"composition": false,
|
|
48
|
+
"tags": []
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "format-bytes-value",
|
|
52
|
+
"name": "Value",
|
|
53
|
+
"template": "<nve-format-bytes value=\"1048576\">1024</nve-format-bytes>\n",
|
|
54
|
+
"summary": "Value attribute input for JavaScript or bound data. It takes precedence over text content while the text remains an SSR fallback.",
|
|
55
|
+
"description": "",
|
|
56
|
+
"composition": false,
|
|
57
|
+
"tags": []
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "format-bytes-display",
|
|
61
|
+
"name": "Display",
|
|
62
|
+
"template": "<div nve-layout=\"column gap:sm\">\n <nve-format-bytes display=\"decimal\">1024</nve-format-bytes>\n <nve-format-bytes display=\"binary\">1024</nve-format-bytes>\n</div>\n",
|
|
63
|
+
"summary": "Decimal and binary conversion for matching SI or IEC storage conventions. Use the convention expected by the surrounding product.",
|
|
64
|
+
"description": "",
|
|
65
|
+
"composition": false,
|
|
66
|
+
"tags": []
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-bytes.js","names":[],"sources":["../../src/format-bytes/format-bytes.css?inline"],"sourcesContent":["/* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */\n/* SPDX-License-Identifier: Apache-2.0 */\n\n:host {\n display: inline;\n}\n\n[internal-host] {\n color: var(--nve-sys-text-color, inherit);\n}\n\nslot {\n display: none;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { LogService as e } from "../internal/services/log.service.js";
|
|
2
|
+
import { typeSSR as t } from "../internal/controllers/type-ssr.controller.js";
|
|
3
|
+
import { useStyles as n } from "../internal/styles/index.js";
|
|
4
|
+
import r from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/decorate.js";
|
|
5
|
+
import i from "./format-bytes.js";
|
|
6
|
+
import { LitElement as a, html as o } from "lit";
|
|
7
|
+
import { property as s } from "lit/decorators/property.js";
|
|
8
|
+
//#region src/format-bytes/format-bytes.ts
|
|
9
|
+
var c = [
|
|
10
|
+
"b",
|
|
11
|
+
"kb",
|
|
12
|
+
"mb",
|
|
13
|
+
"gb",
|
|
14
|
+
"tb",
|
|
15
|
+
"pb"
|
|
16
|
+
], l = ["decimal", "binary"], u = ["short", "long"], d = {
|
|
17
|
+
b: {
|
|
18
|
+
short: "b",
|
|
19
|
+
singular: "byte",
|
|
20
|
+
plural: "bytes"
|
|
21
|
+
},
|
|
22
|
+
kb: {
|
|
23
|
+
short: "kb",
|
|
24
|
+
singular: "kilobyte",
|
|
25
|
+
plural: "kilobytes"
|
|
26
|
+
},
|
|
27
|
+
mb: {
|
|
28
|
+
short: "mb",
|
|
29
|
+
singular: "megabyte",
|
|
30
|
+
plural: "megabytes"
|
|
31
|
+
},
|
|
32
|
+
gb: {
|
|
33
|
+
short: "gb",
|
|
34
|
+
singular: "gigabyte",
|
|
35
|
+
plural: "gigabytes"
|
|
36
|
+
},
|
|
37
|
+
tb: {
|
|
38
|
+
short: "tb",
|
|
39
|
+
singular: "terabyte",
|
|
40
|
+
plural: "terabytes"
|
|
41
|
+
},
|
|
42
|
+
pb: {
|
|
43
|
+
short: "pb",
|
|
44
|
+
singular: "petabyte",
|
|
45
|
+
plural: "petabytes"
|
|
46
|
+
}
|
|
47
|
+
}, f = {
|
|
48
|
+
b: {
|
|
49
|
+
short: "b",
|
|
50
|
+
singular: "byte",
|
|
51
|
+
plural: "bytes"
|
|
52
|
+
},
|
|
53
|
+
kb: {
|
|
54
|
+
short: "kib",
|
|
55
|
+
singular: "kibibyte",
|
|
56
|
+
plural: "kibibytes"
|
|
57
|
+
},
|
|
58
|
+
mb: {
|
|
59
|
+
short: "mib",
|
|
60
|
+
singular: "mebibyte",
|
|
61
|
+
plural: "mebibytes"
|
|
62
|
+
},
|
|
63
|
+
gb: {
|
|
64
|
+
short: "gib",
|
|
65
|
+
singular: "gibibyte",
|
|
66
|
+
plural: "gibibytes"
|
|
67
|
+
},
|
|
68
|
+
tb: {
|
|
69
|
+
short: "tib",
|
|
70
|
+
singular: "tebibyte",
|
|
71
|
+
plural: "tebibytes"
|
|
72
|
+
},
|
|
73
|
+
pb: {
|
|
74
|
+
short: "pib",
|
|
75
|
+
singular: "pebibyte",
|
|
76
|
+
plural: "pebibytes"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function p(e) {
|
|
80
|
+
return l.some((t) => t === e);
|
|
81
|
+
}
|
|
82
|
+
function m(e) {
|
|
83
|
+
return c.some((t) => t === e);
|
|
84
|
+
}
|
|
85
|
+
function h(e) {
|
|
86
|
+
return u.some((t) => t === e);
|
|
87
|
+
}
|
|
88
|
+
var g = class extends a {
|
|
89
|
+
constructor(...e) {
|
|
90
|
+
super(...e), this.display = "decimal", this.unitDisplay = "short";
|
|
91
|
+
}
|
|
92
|
+
static {
|
|
93
|
+
this.styles = n([i]);
|
|
94
|
+
}
|
|
95
|
+
static {
|
|
96
|
+
this.metadata = {
|
|
97
|
+
tag: "nve-format-bytes",
|
|
98
|
+
version: "2.3.0"
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
get #e() {
|
|
102
|
+
let e = Number.isNaN(this.value) ? this.getAttribute("value") ?? this.value : this.value;
|
|
103
|
+
return String(e ?? this.textContent?.trim() ?? "");
|
|
104
|
+
}
|
|
105
|
+
get #t() {
|
|
106
|
+
return this.locale ?? (globalThis.document?.documentElement?.lang || void 0);
|
|
107
|
+
}
|
|
108
|
+
get #n() {
|
|
109
|
+
let t = this.#e;
|
|
110
|
+
if (!t) return null;
|
|
111
|
+
let n = Number(t);
|
|
112
|
+
return Number.isFinite(n) ? n : (e.warn(`format-bytes: invalid numeric value "${t}"`), null);
|
|
113
|
+
}
|
|
114
|
+
#r(e, t) {
|
|
115
|
+
let n = t === "binary" ? 1024 : 1e3, r = Math.abs(e);
|
|
116
|
+
for (let e = c.length - 1; e > 0; e--) {
|
|
117
|
+
let t = c[e];
|
|
118
|
+
if (t && r >= n ** e) return t;
|
|
119
|
+
}
|
|
120
|
+
return "b";
|
|
121
|
+
}
|
|
122
|
+
#i(e, t) {
|
|
123
|
+
let n = this.display === "binary" ? f[e] : d[e];
|
|
124
|
+
return this.unitDisplay === "short" ? n.short : Math.abs(t) === 1 ? n.singular : n.plural;
|
|
125
|
+
}
|
|
126
|
+
#a(t, n) {
|
|
127
|
+
e.warn(`format-bytes: invalid ${t} value "${String(n)}"`);
|
|
128
|
+
}
|
|
129
|
+
#o() {
|
|
130
|
+
return p(this.display) ? h(this.unitDisplay) ? this.unit !== void 0 && !m(this.unit) ? (this.#a("unit", this.unit), !1) : !0 : (this.#a("unit-display", this.unitDisplay), !1) : (this.#a("display", this.display), !1);
|
|
131
|
+
}
|
|
132
|
+
get #s() {
|
|
133
|
+
let e = this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 0, 2);
|
|
134
|
+
return {
|
|
135
|
+
minimumFractionDigits: this.minimumFractionDigits,
|
|
136
|
+
maximumFractionDigits: e
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
#c(e) {
|
|
140
|
+
return Number(new Intl.NumberFormat("en-US-u-nu-latn", {
|
|
141
|
+
...this.#s,
|
|
142
|
+
useGrouping: !1
|
|
143
|
+
}).format(e));
|
|
144
|
+
}
|
|
145
|
+
#l(e) {
|
|
146
|
+
return new Intl.NumberFormat(this.#t, this.#s).format(e);
|
|
147
|
+
}
|
|
148
|
+
get #u() {
|
|
149
|
+
let t = this.#e;
|
|
150
|
+
if (!t) return "";
|
|
151
|
+
let n = this.#n;
|
|
152
|
+
if (n === null || !this.#o()) return t;
|
|
153
|
+
let r = this.unit ?? this.#r(n, this.display), i = c.indexOf(r), a = n / (this.display === "binary" ? 1024 : 1e3) ** i;
|
|
154
|
+
try {
|
|
155
|
+
let e = this.#c(a);
|
|
156
|
+
return `${this.#l(e)} ${this.#i(r, e)}`;
|
|
157
|
+
} catch (n) {
|
|
158
|
+
let r = n instanceof Error ? n.message : String(n);
|
|
159
|
+
return e.warn(`format-bytes: ${r}`), t;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
render() {
|
|
163
|
+
return o`<data internal-host value="${this.#e}">${this.#u}<slot @slotchange="${this.#d}" hidden></slot></data>`;
|
|
164
|
+
}
|
|
165
|
+
#d() {
|
|
166
|
+
this.requestUpdate();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
r([s({ type: Number })], g.prototype, "value", void 0), r([s({ type: String })], g.prototype, "display", void 0), r([s({ type: String })], g.prototype, "unit", void 0), r([s({
|
|
170
|
+
type: String,
|
|
171
|
+
attribute: "unit-display"
|
|
172
|
+
})], g.prototype, "unitDisplay", void 0), r([s({ type: String })], g.prototype, "locale", void 0), r([s({
|
|
173
|
+
type: Number,
|
|
174
|
+
attribute: "minimum-fraction-digits"
|
|
175
|
+
})], g.prototype, "minimumFractionDigits", void 0), r([s({
|
|
176
|
+
type: Number,
|
|
177
|
+
attribute: "maximum-fraction-digits"
|
|
178
|
+
})], g.prototype, "maximumFractionDigits", void 0), g = r([t()], g);
|
|
179
|
+
//#endregion
|
|
180
|
+
export { g as FormatBytes };
|
|
181
|
+
|
|
182
|
+
//# sourceMappingURL=format-bytes2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-bytes2.js","names":["#rawValue","#resolvedLocale","#parsedValue","#warnInvalidOption","#numberFormatOptions","#formattedBytes","#hasValidConfiguration","#resolveAutoUnit","#roundNumber","#formatNumber","#formatLabel","#onSlotChange"],"sources":["../../src/format-bytes/format-bytes.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { LogService, typeSSR, useStyles } from '@nvidia-elements/core/internal';\nimport styles from './format-bytes.css?inline';\n\nexport type FormatBytesDisplay = 'decimal' | 'binary';\nexport type FormatBytesUnit = 'b' | 'kb' | 'mb' | 'gb' | 'tb' | 'pb';\nexport type FormatBytesUnitDisplay = 'short' | 'long';\n\ninterface UnitLabels {\n short: string;\n singular: string;\n plural: string;\n}\n\nconst UNITS: readonly FormatBytesUnit[] = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];\nconst DISPLAYS: readonly FormatBytesDisplay[] = ['decimal', 'binary'];\nconst UNIT_DISPLAYS: readonly FormatBytesUnitDisplay[] = ['short', 'long'];\n\nconst DECIMAL_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'b', singular: 'byte', plural: 'bytes' },\n kb: { short: 'kb', singular: 'kilobyte', plural: 'kilobytes' },\n mb: { short: 'mb', singular: 'megabyte', plural: 'megabytes' },\n gb: { short: 'gb', singular: 'gigabyte', plural: 'gigabytes' },\n tb: { short: 'tb', singular: 'terabyte', plural: 'terabytes' },\n pb: { short: 'pb', singular: 'petabyte', plural: 'petabytes' }\n};\n\nconst BINARY_LABELS: Record<FormatBytesUnit, UnitLabels> = {\n b: { short: 'b', singular: 'byte', plural: 'bytes' },\n kb: { short: 'kib', singular: 'kibibyte', plural: 'kibibytes' },\n mb: { short: 'mib', singular: 'mebibyte', plural: 'mebibytes' },\n gb: { short: 'gib', singular: 'gibibyte', plural: 'gibibytes' },\n tb: { short: 'tib', singular: 'tebibyte', plural: 'tebibytes' },\n pb: { short: 'pib', singular: 'pebibyte', plural: 'pebibytes' }\n};\n\nfunction isDisplay(value: unknown): value is FormatBytesDisplay {\n return DISPLAYS.some(display => display === value);\n}\n\nfunction isUnit(value: unknown): value is FormatBytesUnit {\n return UNITS.some(unit => unit === value);\n}\n\nfunction isUnitDisplay(value: unknown): value is FormatBytesUnitDisplay {\n return UNIT_DISPLAYS.some(unitDisplay => unitDisplay === value);\n}\n\n/**\n * @element nve-format-bytes\n * @description Formats a byte count as localized, human-readable decimal or binary units.\n * @documentation https://nvidia.github.io/elements/docs/elements/format-bytes/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/format-bytes\n * @slot - Numeric byte count to format (such as 1048576). Serves as fallback before hydration.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/data\n */\n@typeSSR()\nexport class FormatBytes extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-format-bytes',\n version: '0.0.0'\n };\n\n /**\n * Optional byte count for values supplied by JavaScript or bound data.\n * By default, the component formats the element's text content, which also serves as the SSR fallback.\n * When both are present, this property takes precedence.\n */\n @property({ type: Number }) value?: number;\n\n /**\n * Unit system: 'decimal' uses powers of 1000 and 'binary' uses powers of 1024.\n */\n @property({ type: String }) display: FormatBytesDisplay = 'decimal';\n\n /**\n * Optional unit magnitude. When omitted, the component selects a unit from the byte count.\n */\n @property({ type: String }) unit?: FormatBytesUnit;\n\n /**\n * Unit label length: 'short' renders labels such as 'mb'; 'long' renders labels such as 'megabytes'.\n */\n @property({ type: String, attribute: 'unit-display' }) unitDisplay: FormatBytesUnitDisplay = 'short';\n\n /**\n * Language tag (such as en-US or de-DE) used to format the number.\n * Defaults to document.documentElement.lang or the runtime default.\n */\n @property({ type: String }) locale?: string;\n\n /**\n * Pad fraction output to at least this many digits.\n */\n @property({ type: Number, attribute: 'minimum-fraction-digits' }) minimumFractionDigits?: number;\n\n /**\n * Round fraction output to at most this many digits. Defaults to two effective digits after the decimal point.\n */\n @property({ type: Number, attribute: 'maximum-fraction-digits' }) maximumFractionDigits?: number;\n\n get #rawValue(): string {\n const value = Number.isNaN(this.value) ? (this.getAttribute('value') ?? this.value) : this.value;\n return String(value ?? this.textContent?.trim() ?? '');\n }\n\n get #resolvedLocale(): string | undefined {\n return this.locale ?? (globalThis.document?.documentElement?.lang || undefined);\n }\n\n get #parsedValue(): number | null {\n const rawValue = this.#rawValue;\n if (!rawValue) return null;\n\n const numericValue = Number(rawValue);\n if (Number.isFinite(numericValue)) return numericValue;\n\n LogService.warn(`format-bytes: invalid numeric value \"${rawValue}\"`);\n return null;\n }\n\n #resolveAutoUnit(value: number, display: FormatBytesDisplay): FormatBytesUnit {\n const base = display === 'binary' ? 1024 : 1000;\n const absoluteValue = Math.abs(value);\n\n for (let index = UNITS.length - 1; index > 0; index--) {\n const unit = UNITS[index];\n if (unit && absoluteValue >= base ** index) return unit;\n }\n\n return 'b';\n }\n\n #formatLabel(unit: FormatBytesUnit, convertedValue: number): string {\n const labels = this.display === 'binary' ? BINARY_LABELS[unit] : DECIMAL_LABELS[unit];\n if (this.unitDisplay === 'short') return labels.short;\n return Math.abs(convertedValue) === 1 ? labels.singular : labels.plural;\n }\n\n #warnInvalidOption(name: string, value: unknown): void {\n LogService.warn(`format-bytes: invalid ${name} value \"${String(value)}\"`);\n }\n\n #hasValidConfiguration(): boolean {\n if (!isDisplay(this.display)) {\n this.#warnInvalidOption('display', this.display);\n return false;\n }\n if (!isUnitDisplay(this.unitDisplay)) {\n this.#warnInvalidOption('unit-display', this.unitDisplay);\n return false;\n }\n if (this.unit !== undefined && !isUnit(this.unit)) {\n this.#warnInvalidOption('unit', this.unit);\n return false;\n }\n return true;\n }\n\n get #numberFormatOptions(): Intl.NumberFormatOptions {\n const effectiveMaximumFractionDigits = this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 0, 2);\n return {\n minimumFractionDigits: this.minimumFractionDigits,\n maximumFractionDigits: effectiveMaximumFractionDigits\n };\n }\n\n #roundNumber(value: number): number {\n return Number(\n new Intl.NumberFormat('en-US-u-nu-latn', {\n ...this.#numberFormatOptions,\n useGrouping: false\n }).format(value)\n );\n }\n\n #formatNumber(value: number): string {\n return new Intl.NumberFormat(this.#resolvedLocale, this.#numberFormatOptions).format(value);\n }\n\n get #formattedBytes(): string {\n const rawValue = this.#rawValue;\n if (!rawValue) return '';\n\n const numericValue = this.#parsedValue;\n if (numericValue === null) return rawValue;\n if (!this.#hasValidConfiguration()) return rawValue;\n\n const resolvedUnit = this.unit ?? this.#resolveAutoUnit(numericValue, this.display);\n const unitIndex = UNITS.indexOf(resolvedUnit);\n const base = this.display === 'binary' ? 1024 : 1000;\n const convertedValue = numericValue / base ** unitIndex;\n\n try {\n const roundedValue = this.#roundNumber(convertedValue);\n return `${this.#formatNumber(roundedValue)} ${this.#formatLabel(resolvedUnit, roundedValue)}`;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n LogService.warn(`format-bytes: ${message}`);\n return rawValue;\n }\n }\n\n render() {\n return html`<data internal-host value=${this.#rawValue}>${this.#formattedBytes}<slot @slotchange=${this.#onSlotChange} hidden></slot></data>`;\n }\n\n #onSlotChange() {\n this.requestUpdate();\n }\n}\n"],"mappings":";;;;;;;;AAkBA,IAAM,IAAoC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI,GACtE,IAA0C,CAAC,WAAW,QAAQ,GAC9D,IAAmD,CAAC,SAAS,MAAM,GAEnE,IAAsD;CAC1D,GAAG;EAAE,OAAO;EAAK,UAAU;EAAQ,QAAQ;CAAQ;CACnD,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY;CAC7D,IAAI;EAAE,OAAO;EAAM,UAAU;EAAY,QAAQ;CAAY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CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,MAK/D,EAAS;CAAE,MAAM;CAAQ,WAAW;AAA0B,CAAC,CAAA,GAAA,EAAA,WAAA,yBAAA,KAAA,CAAA,UA7CjE,EAAQ,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './format-bytes.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/forms/control/control.css?inline
|
|
2
|
-
var e = ":host{--cursor: pointer;--accent-color: var(--nve-sys-accent-secondary-background);--color: var(--nve-sys-interaction-field-color);--label-color: var(--nve-sys-interaction-field-color);--label-text-transform: none;--label-font-weight: var(--nve-ref-font-weight-medium);--label-font-size: var(--nve-ref-font-size-100);--control-width: 100%;--control-height: var(--nve-sys-interaction-field-height);--_label-width: var(--label-width, 180px);--nve-sys-interaction-state-base: var(--background, var(--nve-sys-layer-canvas-background));--opacity: 1;--filter: none;contain:content}::slotted(*){color-scheme:var(--nve-sys-color-scheme);font-family:inherit}::slotted(label){font-weight:var(--label-font-weight)!important;font-size:var(--label-font-size)!important;color:var(--label-color)!important;cursor:var(--cursor)!important;text-transform:var(--label-text-transform)!important;display:inline-block!important;line-height:1em!important;align-self:center!important}:host(:state(disabled)),:host(:state(disabled)) ::slotted(nve-control-message:not([status])){--cursor: not-allowed}:host(:state(disabled)){--opacity: var(--nve-ref-opacity-500)}:host(:state(invalid)) ::slotted(nve-control-message:not([error],[status])){display:none}:host([fit-content]){--control-width: fit-content;--label-width: fit-content;--width: fit-content}:host([nve-control]) ::slotted(input:focus),:host([nve-control]) ::slotted(select:focus),:host([nve-control]) ::slotted(textarea:focus),:host([nve-control]:focus-within) [internal-host]:has(nve-icon-button:focus) [input],[internal-host]:has(nve-icon-button){outline:0!important}@container style(--control-type: custom){[input]{outline:0!important}}::slotted(nve-button[nve-control]){width:100%}[input]{cursor:var(--cursor);min-height:var(--control-height);opacity:var(--opacity);filter:var(--filter);grid-area:input;display:flex;line-height:1}:host([nve-control=\"inline\"]){[internal-host]{min-height:var(--control-height)}[input]{min-height:min-content}}slot{line-height:1;width:100%}slot[name=label]{grid-area:label;display:inline-flex;align-self:center}slot[name=messages]{grid-area:messages;display:inline-flex}[name=messages]:not(:has-slotted),[name=label]:not(:has-slotted){display:none!important}[internal-host]{display:grid;width:100%;gap:var(--nve-ref-space-xs);grid-template-columns:1fr 1fr 1fr;grid-template-rows:auto;grid-template-areas:\"input input input\"}:host([nve-control=\"inline\"]) [internal-host]{align-items:center;grid-template-columns:auto 1fr 1fr;slot[name=label],slot[name=messages]{align-items:center}::slotted(label){font-weight:var(--nve-ref-font-weight-regular)!important;color:var(--color)!important;width:100%}slot[name=label]{line-height:1;width:100%}}:host([layout=\"horizontal\"]) [internal-host],:host([layout=\"horizontal-inline\"]) [internal-host]{grid-template-columns:var(--_label-width) 1fr minmax(0,var(--_label-width))}[internal-host]{&:has([name=label]:has-slotted){grid-template-areas:\"label label label\" \"input input input\"}&:has([name=messages]:has-slotted){grid-template-areas:\"input input input\" \"messages messages messages\"}&:has([name=label]:has-slotted):has([name=messages]:has-slotted){grid-template-areas:\"label label label\" \"input input input\" \"messages messages messages\"}}:host([layout=\"horizontal\"]),:host([layout=\"horizontal-inline\"]){[internal-host]{&:has([name=messages]:has-slotted){grid-template-areas:\"label input input\" \". messages messages\"}&:not(:has([name=messages]:has-slotted)){grid-template-areas:\"label input input\"}}}:host([nve-control=\"inline\"]){--control-height: auto;width:fit-content;[internal-host]{grid-template-areas:\"input input input\";&:has([name=label]:has-slotted){grid-template-areas:\"input label label\"}&:has([name=messages]:has-slotted){grid-template-areas:\"input input input\" \"messages messages messages\"}&:has([name=label]:has-slotted):has([name=messages]:has-slotted){grid-template-areas:\"input label label\" \"messages messages messages\"}}}";
|
|
2
|
+
var e = ":host{--cursor: pointer;--accent-color: var(--nve-sys-accent-secondary-background);--color: var(--nve-sys-interaction-field-color);--label-color: var(--nve-sys-interaction-field-color);--label-text-transform: none;--label-font-weight: var(--nve-ref-font-weight-medium);--label-font-size: var(--nve-ref-font-size-100);--control-width: 100%;--control-height: var(--nve-sys-interaction-field-height);--_label-width: var(--label-width, 180px);--nve-sys-interaction-state-base: var(--background, var(--nve-sys-layer-canvas-background));--opacity: 1;--filter: none;contain:content}::slotted(*){color-scheme:var(--nve-sys-color-scheme);font-family:inherit}::slotted(label){font-weight:var(--label-font-weight)!important;font-size:var(--label-font-size)!important;color:var(--label-color)!important;cursor:var(--cursor)!important;text-transform:var(--label-text-transform)!important;display:inline-block!important;line-height:1em!important;align-self:center!important}:host(:state(disabled)),:host(:state(disabled)) ::slotted(nve-control-message:not([status])){--cursor: not-allowed}:host(:state(disabled)){--opacity: var(--nve-ref-opacity-500)}:host(:state(invalid)) ::slotted(nve-control-message:not([error],[status])){display:none}:host([fit-content]){--control-width: fit-content;--label-width: fit-content;--width: fit-content}:host([fit-text]){--max-width: fit-content;--width: fit-content;::slotted(input),::slotted(select){field-sizing:content}}:host([nve-control]) ::slotted(input:focus),:host([nve-control]) ::slotted(select:focus),:host([nve-control]) ::slotted(textarea:focus),:host([nve-control]:focus-within) [internal-host]:has(nve-icon-button:focus) [input],[internal-host]:has(nve-icon-button){outline:0!important}@container style(--control-type: custom){[input]{outline:0!important}}::slotted(nve-button[nve-control]){width:100%}[input]{cursor:var(--cursor);min-height:var(--control-height);opacity:var(--opacity);filter:var(--filter);grid-area:input;display:flex;line-height:1}:host([nve-control=\"inline\"]){[internal-host]{min-height:var(--control-height)}[input]{min-height:min-content}}slot{line-height:1;width:100%}slot[name=label]{grid-area:label;display:inline-flex;align-self:center}slot[name=messages]{grid-area:messages;display:inline-flex}[name=messages]:not(:has-slotted),[name=label]:not(:has-slotted){display:none!important}[internal-host]{display:grid;width:100%;gap:var(--nve-ref-space-xs);grid-template-columns:1fr 1fr 1fr;grid-template-rows:auto;grid-template-areas:\"input input input\"}:host([nve-control=\"inline\"]) [internal-host]{align-items:center;grid-template-columns:auto 1fr 1fr;slot[name=label],slot[name=messages]{align-items:center}::slotted(label){font-weight:var(--nve-ref-font-weight-regular)!important;color:var(--color)!important;width:100%}slot[name=label]{line-height:1;width:100%}}:host([layout=\"horizontal\"]) [internal-host],:host([layout=\"horizontal-inline\"]) [internal-host]{grid-template-columns:var(--_label-width) 1fr minmax(0,var(--_label-width))}[internal-host]{&:has([name=label]:has-slotted){grid-template-areas:\"label label label\" \"input input input\"}&:has([name=messages]:has-slotted){grid-template-areas:\"input input input\" \"messages messages messages\"}&:has([name=label]:has-slotted):has([name=messages]:has-slotted){grid-template-areas:\"label label label\" \"input input input\" \"messages messages messages\"}}:host([layout=\"horizontal\"]),:host([layout=\"horizontal-inline\"]){[internal-host]{&:has([name=messages]:has-slotted){grid-template-areas:\"label input input\" \". messages messages\"}&:not(:has([name=messages]:has-slotted)){grid-template-areas:\"label input input\"}}}:host([nve-control=\"inline\"]){--control-height: auto;width:fit-content;[internal-host]{grid-template-areas:\"input input input\";&:has([name=label]:has-slotted){grid-template-areas:\"input label label\"}&:has([name=messages]:has-slotted){grid-template-areas:\"input input input\" \"messages messages messages\"}&:has([name=label]:has-slotted):has([name=messages]:has-slotted){grid-template-areas:\"input label label\" \"messages messages messages\"}}}";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { e as default };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.js","names":[],"sources":["../../../src/forms/control/control.css?inline"],"sourcesContent":["/* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */\n/* SPDX-License-Identifier: Apache-2.0 */\n\n:host {\n --cursor: pointer;\n --accent-color: var(--nve-sys-accent-secondary-background);\n --color: var(--nve-sys-interaction-field-color);\n --label-color: var(--nve-sys-interaction-field-color);\n --label-text-transform: none;\n --label-font-weight: var(--nve-ref-font-weight-medium);\n --label-font-size: var(--nve-ref-font-size-100);\n --control-width: 100%;\n --control-height: var(--nve-sys-interaction-field-height);\n --_label-width: var(--label-width, 180px);\n --nve-sys-interaction-state-base: var(--background, var(--nve-sys-layer-canvas-background));\n --opacity: 1;\n --filter: none;\n contain: content;\n}\n\n::slotted(*) {\n color-scheme: var(--nve-sys-color-scheme);\n font-family: inherit;\n}\n\n::slotted(label) {\n font-weight: var(--label-font-weight) !important;\n font-size: var(--label-font-size) !important;\n color: var(--label-color) !important;\n cursor: var(--cursor) !important;\n text-transform: var(--label-text-transform) !important;\n display: inline-block !important;\n line-height: 1em !important;\n align-self: center !important;\n}\n\n:host(:state(disabled)),\n:host(:state(disabled)) ::slotted(nve-control-message:not([status])) {\n --cursor: not-allowed;\n}\n\n:host(:state(disabled)) {\n --opacity: var(--nve-ref-opacity-500);\n}\n\n:host(:state(invalid)) ::slotted(nve-control-message:not([error], [status])) {\n display: none;\n}\n\n:host([fit-content]) {\n --control-width: fit-content;\n --label-width: fit-content;\n --width: fit-content;\n}\n\n:host([nve-control]) ::slotted(input:focus),\n:host([nve-control]) ::slotted(select:focus),\n:host([nve-control]) ::slotted(textarea:focus),\n:host([nve-control]:focus-within) [internal-host]:has(nve-icon-button:focus) [input],\n[internal-host]:has(nve-icon-button) {\n outline: 0 !important;\n}\n\n@container style(--control-type: custom) {\n [input] {\n outline: 0 !important;\n }\n}\n\n::slotted(nve-button[nve-control]) {\n width: 100%;\n}\n\n[input] {\n cursor: var(--cursor);\n min-height: var(--control-height);\n opacity: var(--opacity);\n filter: var(--filter);\n grid-area: input;\n display: flex;\n line-height: 1;\n}\n\n:host([nve-control='inline']) {\n [internal-host] {\n min-height: var(--control-height);\n }\n\n [input] {\n min-height: min-content;\n }\n}\n\nslot {\n line-height: 1;\n width: 100%;\n}\n\nslot[name='label'] {\n grid-area: label;\n display: inline-flex;\n align-self: center;\n}\n\nslot[name='messages'] {\n grid-area: messages;\n display: inline-flex;\n}\n\n[name='messages']:not(:has-slotted),\n[name='label']:not(:has-slotted) {\n display: none !important;\n}\n\n[internal-host] {\n display: grid;\n width: 100%;\n gap: var(--nve-ref-space-xs);\n grid-template-columns: 1fr 1fr 1fr;\n grid-template-rows: auto;\n grid-template-areas: 'input input input';\n}\n\n:host([nve-control='inline']) [internal-host] {\n align-items: center;\n grid-template-columns: auto 1fr 1fr;\n\n slot[name='label'],\n slot[name='messages'] {\n align-items: center;\n }\n\n & ::slotted(label) {\n font-weight: var(--nve-ref-font-weight-regular) !important;\n color: var(--color) !important;\n width: 100%;\n }\n\n slot[name='label'] {\n line-height: 1;\n width: 100%;\n }\n}\n\n:host([layout='horizontal']) [internal-host],\n:host([layout='horizontal-inline']) [internal-host] {\n grid-template-columns: var(--_label-width) 1fr minmax(0, var(--_label-width));\n}\n\n/** block controls */\n[internal-host] {\n &:has([name='label']:has-slotted) {\n grid-template-areas:\n 'label label label'\n 'input input input';\n }\n\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input input input'\n 'messages messages messages';\n }\n\n &:has([name='label']:has-slotted):has([name='messages']:has-slotted) {\n grid-template-areas:\n 'label label label'\n 'input input input'\n 'messages messages messages';\n }\n}\n\n:host([layout='horizontal']),\n:host([layout='horizontal-inline']) {\n [internal-host] {\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'label input input'\n '. messages messages';\n }\n\n &:not(:has([name='messages']:has-slotted)) {\n grid-template-areas: 'label input input';\n }\n }\n}\n\n/** inline controls */\n:host([nve-control='inline']) {\n --control-height: auto;\n width: fit-content;\n\n [internal-host] {\n grid-template-areas: 'input input input';\n\n &:has([name='label']:has-slotted) {\n grid-template-areas: 'input label label';\n }\n\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input input input'\n 'messages messages messages';\n }\n\n &:has([name='label']:has-slotted):has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input label label'\n 'messages messages messages';\n }\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"control.js","names":[],"sources":["../../../src/forms/control/control.css?inline"],"sourcesContent":["/* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */\n/* SPDX-License-Identifier: Apache-2.0 */\n\n:host {\n --cursor: pointer;\n --accent-color: var(--nve-sys-accent-secondary-background);\n --color: var(--nve-sys-interaction-field-color);\n --label-color: var(--nve-sys-interaction-field-color);\n --label-text-transform: none;\n --label-font-weight: var(--nve-ref-font-weight-medium);\n --label-font-size: var(--nve-ref-font-size-100);\n --control-width: 100%;\n --control-height: var(--nve-sys-interaction-field-height);\n --_label-width: var(--label-width, 180px);\n --nve-sys-interaction-state-base: var(--background, var(--nve-sys-layer-canvas-background));\n --opacity: 1;\n --filter: none;\n contain: content;\n}\n\n::slotted(*) {\n color-scheme: var(--nve-sys-color-scheme);\n font-family: inherit;\n}\n\n::slotted(label) {\n font-weight: var(--label-font-weight) !important;\n font-size: var(--label-font-size) !important;\n color: var(--label-color) !important;\n cursor: var(--cursor) !important;\n text-transform: var(--label-text-transform) !important;\n display: inline-block !important;\n line-height: 1em !important;\n align-self: center !important;\n}\n\n:host(:state(disabled)),\n:host(:state(disabled)) ::slotted(nve-control-message:not([status])) {\n --cursor: not-allowed;\n}\n\n:host(:state(disabled)) {\n --opacity: var(--nve-ref-opacity-500);\n}\n\n:host(:state(invalid)) ::slotted(nve-control-message:not([error], [status])) {\n display: none;\n}\n\n:host([fit-content]) {\n --control-width: fit-content;\n --label-width: fit-content;\n --width: fit-content;\n}\n\n:host([fit-text]) {\n --max-width: fit-content;\n --width: fit-content;\n\n ::slotted(input),\n ::slotted(select) {\n field-sizing: content;\n }\n}\n\n:host([nve-control]) ::slotted(input:focus),\n:host([nve-control]) ::slotted(select:focus),\n:host([nve-control]) ::slotted(textarea:focus),\n:host([nve-control]:focus-within) [internal-host]:has(nve-icon-button:focus) [input],\n[internal-host]:has(nve-icon-button) {\n outline: 0 !important;\n}\n\n@container style(--control-type: custom) {\n [input] {\n outline: 0 !important;\n }\n}\n\n::slotted(nve-button[nve-control]) {\n width: 100%;\n}\n\n[input] {\n cursor: var(--cursor);\n min-height: var(--control-height);\n opacity: var(--opacity);\n filter: var(--filter);\n grid-area: input;\n display: flex;\n line-height: 1;\n}\n\n:host([nve-control='inline']) {\n [internal-host] {\n min-height: var(--control-height);\n }\n\n [input] {\n min-height: min-content;\n }\n}\n\nslot {\n line-height: 1;\n width: 100%;\n}\n\nslot[name='label'] {\n grid-area: label;\n display: inline-flex;\n align-self: center;\n}\n\nslot[name='messages'] {\n grid-area: messages;\n display: inline-flex;\n}\n\n[name='messages']:not(:has-slotted),\n[name='label']:not(:has-slotted) {\n display: none !important;\n}\n\n[internal-host] {\n display: grid;\n width: 100%;\n gap: var(--nve-ref-space-xs);\n grid-template-columns: 1fr 1fr 1fr;\n grid-template-rows: auto;\n grid-template-areas: 'input input input';\n}\n\n:host([nve-control='inline']) [internal-host] {\n align-items: center;\n grid-template-columns: auto 1fr 1fr;\n\n slot[name='label'],\n slot[name='messages'] {\n align-items: center;\n }\n\n & ::slotted(label) {\n font-weight: var(--nve-ref-font-weight-regular) !important;\n color: var(--color) !important;\n width: 100%;\n }\n\n slot[name='label'] {\n line-height: 1;\n width: 100%;\n }\n}\n\n:host([layout='horizontal']) [internal-host],\n:host([layout='horizontal-inline']) [internal-host] {\n grid-template-columns: var(--_label-width) 1fr minmax(0, var(--_label-width));\n}\n\n/** block controls */\n[internal-host] {\n &:has([name='label']:has-slotted) {\n grid-template-areas:\n 'label label label'\n 'input input input';\n }\n\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input input input'\n 'messages messages messages';\n }\n\n &:has([name='label']:has-slotted):has([name='messages']:has-slotted) {\n grid-template-areas:\n 'label label label'\n 'input input input'\n 'messages messages messages';\n }\n}\n\n:host([layout='horizontal']),\n:host([layout='horizontal-inline']) {\n [internal-host] {\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'label input input'\n '. messages messages';\n }\n\n &:not(:has([name='messages']:has-slotted)) {\n grid-template-areas: 'label input input';\n }\n }\n}\n\n/** inline controls */\n:host([nve-control='inline']) {\n --control-height: auto;\n width: fit-content;\n\n [internal-host] {\n grid-template-areas: 'input input input';\n\n &:has([name='label']:has-slotted) {\n grid-template-areas: 'input label label';\n }\n\n &:has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input input input'\n 'messages messages messages';\n }\n\n &:has([name='label']:has-slotted):has([name='messages']:has-slotted) {\n grid-template-areas:\n 'input label label'\n 'messages messages messages';\n }\n }\n}\n"],"mappings":""}
|
|
@@ -15,11 +15,9 @@ import { property as S } from "lit/decorators/property.js";
|
|
|
15
15
|
var C = class extends v {
|
|
16
16
|
constructor(...t) {
|
|
17
17
|
super(...t), this.fitText = !1, this.fitContent = !1, this.#e = new e(this), this.i18n = this.#e.i18n, this.nveControl = "", this.#i = [], this._associateDatalist = !0, this.#a = () => {
|
|
18
|
-
this.#
|
|
18
|
+
this.#f(), this.input && this.#i.length === 0 && this.#l();
|
|
19
19
|
}, this.#u = () => {
|
|
20
|
-
this.#
|
|
21
|
-
}, this.#f = () => {
|
|
22
|
-
this.#p();
|
|
20
|
+
this.#f(), this.#p();
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
#e;
|
|
@@ -50,7 +48,7 @@ var C = class extends v {
|
|
|
50
48
|
static {
|
|
51
49
|
this.metadata = {
|
|
52
50
|
tag: "nve-control",
|
|
53
|
-
version: "2.
|
|
51
|
+
version: "2.3.0"
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
54
|
render() {
|
|
@@ -60,7 +58,7 @@ var C = class extends v {
|
|
|
60
58
|
super.connectedCallback(), o(this), t(this, g), this.shadowRoot.addEventListener("slotchange", this.#a);
|
|
61
59
|
}
|
|
62
60
|
disconnectedCallback() {
|
|
63
|
-
super.disconnectedCallback(), this.shadowRoot.removeEventListener("slotchange", this.#a), this.shadowRoot.removeEventListener("slotchange", this.#u), this
|
|
61
|
+
super.disconnectedCallback(), this.shadowRoot.removeEventListener("slotchange", this.#a), this.shadowRoot.removeEventListener("slotchange", this.#u), this.#i.forEach((e) => e.disconnect()), this.#i.length = 0;
|
|
64
62
|
}
|
|
65
63
|
#a;
|
|
66
64
|
reset() {
|
|
@@ -88,29 +86,19 @@ var C = class extends v {
|
|
|
88
86
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio");
|
|
89
87
|
}
|
|
90
88
|
#l() {
|
|
91
|
-
this.#i.push(...m(this, this.#n), ...f(this), ...p(this, this.#n), h(this), n(this, ["hidden", "status"], () => this.#
|
|
89
|
+
this.#i.push(...m(this, this.#n), ...f(this), ...p(this, this.#n), h(this), n(this, ["hidden", "status"], () => this.#f())), this.#d(), this.#p(), this.shadowRoot.addEventListener("slotchange", this.#u);
|
|
92
90
|
}
|
|
93
91
|
#u;
|
|
94
92
|
#d() {
|
|
95
|
-
this.fitText && (this.#p(), this.input.addEventListener("input", this.#f), this.input.addEventListener("change", this.#f));
|
|
96
|
-
}
|
|
97
|
-
#f;
|
|
98
|
-
#p() {
|
|
99
|
-
if (this.input.tagName === "INPUT") {
|
|
100
|
-
let e = this.input.type === "text" ? 0 : 4;
|
|
101
|
-
this.style.setProperty("--control-width", `${this.input.value.length + e}ch`), this.input.style.setProperty("max-width", `${this.input.value.length + 2}ch`, "important");
|
|
102
|
-
} else this.input.tagName === "SELECT" && this.style.setProperty("--control-width", `${this.input.options[this.input.selectedIndex].textContent.length + 4}ch`);
|
|
103
|
-
}
|
|
104
|
-
#m() {
|
|
105
93
|
this.input.showPicker || (this.input.showPicker = () => this.input.focus());
|
|
106
94
|
}
|
|
107
|
-
#
|
|
95
|
+
#f() {
|
|
108
96
|
this.input && (this.toggleAttribute("multiple", this.input?.multiple), this.input?.hasAttribute("size") ? this.setAttribute("size", "") : this.removeAttribute("size"));
|
|
109
97
|
}
|
|
110
|
-
#
|
|
111
|
-
this.#
|
|
98
|
+
#p() {
|
|
99
|
+
this.#m(), a(this.#t, this.input), r(Array.from(this.#n), this.input), this._associateDatalist && i(this.querySelector("datalist"), this.input);
|
|
112
100
|
}
|
|
113
|
-
#
|
|
101
|
+
#m() {
|
|
114
102
|
let e = this.querySelector("label") || this.shadowRoot.querySelector("slot").assignedNodes({ flatten: !0 }).find((e) => e.tagName === "LABEL");
|
|
115
103
|
e && (e.slot = "label");
|
|
116
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control2.js","names":["#i18nController","#updateStyleStates","#observers","#setupInput","#setupFitText","#updateAssociations","#getCharacterWidth","#label","#messages","#input","#onRootSlotchange","#onInputSlotchange","#onFitTextUpdate","#resetInputValue","#resetSelectValue","#isCheckedInput","#polyfillShowPicker","#assignLabel"],"sources":["../../../src/forms/control/control.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TemplateResult } from 'lit';\nimport { LitElement, html, nothing, isServer } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport {\n attachInternals,\n useStyles,\n associateLabel,\n associateAriaDescribedBy,\n associateDataList,\n appendRootNodeStyle,\n getAttributeListChanges,\n I18nController,\n hostAttr,\n typeSSR\n} from '@nvidia-elements/core/internal';\nimport type { ControlMessage } from '../control-message/control-message.js';\nimport {\n setupControlValidationStates,\n setupControlStates,\n setupControlStatusStates,\n inputQuery,\n type ControlStateCleanup\n} from '../utils/states.js';\nimport { setupControlLayoutStates } from '../utils/layout.js';\nimport globalStyles from './control.global.css?inline';\nimport styles from './control.css?inline';\n\ninterface ResettableControl {\n getAttribute: Element['getAttribute'];\n value: string;\n}\n\ntype ControlInput = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | ResettableControl;\n\n/**\n * @element nve-control\n * @description Wraps a form input with its associated label and validation messages, managing layout and accessibility associations.\n * @documentation https://nvidia.github.io/elements/docs/elements/control/\n * @since 0.3.0\n * @entrypoint \\@nvidia-elements/core/forms\n * @slot - Control input element\n * @slot label - Label element\n * @cssprop --cursor\n * @cssprop --accent-color\n * @cssprop --color\n * @cssprop --label-color\n * @cssprop --label-width\n * @cssprop --label-font-weight\n * @cssprop --label-font-size\n * @cssprop --control-width\n * @cssprop --control-height\n\n * @aria https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals\n * @package true\n */\n@typeSSR()\nexport class Control extends LitElement {\n /** Set current visual state for control. This overrides any validation states active. */\n @property({ type: String }) status: 'warning' | 'error' | 'success' | 'disabled';\n\n /** Set current control + label + control message layout. Layouts will collapse based on available container space. */\n @property({ type: String, reflect: true }) layout:\n | 'vertical'\n | 'vertical-inline'\n | 'horizontal'\n | 'horizontal-inline';\n\n /** Sets the input to match the width of the active text content of the control value. Only applicable to vertical input box type controls (input, select) */\n @property({ type: Boolean, reflect: true, attribute: 'fit-text' }) fitText = false;\n\n /** Sets the input to match native default content block */\n @property({ type: Boolean, reflect: true, attribute: 'fit-content' }) fitContent = false;\n\n #i18nController: I18nController<this> = new I18nController<this>(this);\n\n /** Enables internal string values to update for internationalization. */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n /** Set the visual prominence of the control */\n @property({ type: String, reflect: true }) prominence: 'muted';\n\n get #label() {\n return this.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot[name=\"label\"]')\n ?.assignedElements({ flatten: true })?.[0] as HTMLLabelElement;\n }\n\n get #messages() {\n return (this.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot[name=\"messages\"]')\n ?.assignedElements({ flatten: true }) ?? []) as ControlMessage[];\n }\n\n #input: HTMLInputElement;\n\n /** @private */\n get input(): HTMLInputElement {\n if (!isServer && !this.#input) {\n const slotted =\n this.querySelector('slot')\n ?.assignedElements()\n ?.find(i => i.matches(inputQuery)) ??\n Array.from(this.shadowRoot!.querySelector('slot')?.assignedElements({ flatten: true }) ?? []).find(i =>\n i.matches(inputQuery)\n );\n this.#input = (slotted ? slotted : this.querySelector(inputQuery)) as HTMLInputElement;\n }\n\n return this.#input;\n }\n\n /** @private */\n protected get prefixContent(): typeof nothing | TemplateResult {\n return nothing;\n }\n\n /** @private */\n protected get suffixContent(): typeof nothing | TemplateResult {\n return nothing;\n }\n\n @hostAttr({ attribute: 'nve-control' }) protected nveControl = '';\n\n /** @private */\n declare _internals: ElementInternals;\n\n #observers: (MutationObserver | ResizeObserver | ControlStateCleanup)[] = [];\n\n protected _associateDatalist = true;\n\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-control',\n version: '0.0.0'\n };\n\n render() {\n return this.nveControl !== 'inline'\n ? html`\n <div internal-host part=\"_internal-host\">\n <slot name=\"label\" part=\"_label\"></slot>\n <div input part=\"_input\">\n ${this.prefixContent}\n <slot></slot>\n ${this.suffixContent}\n </div>\n <slot name=\"messages\" part=\"_messages\"></slot>\n </div>\n `\n : html`\n <div internal-host part=\"_internal-host\">\n <div input part=\"_input\"><slot interaction-state></slot></div>\n <slot name=\"label\" part=\"_label\"></slot>\n <slot name=\"messages\" part=\"_messages\"></slot>\n </div>\n `;\n }\n\n connectedCallback() {\n super.connectedCallback();\n attachInternals(this);\n appendRootNodeStyle(this, globalStyles);\n this.shadowRoot!.addEventListener('slotchange', this.#onRootSlotchange);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.shadowRoot!.removeEventListener('slotchange', this.#onRootSlotchange);\n this.shadowRoot!.removeEventListener('slotchange', this.#onInputSlotchange);\n if (this.fitText && this.input) {\n this.input.removeEventListener('input', this.#onFitTextUpdate);\n this.input.removeEventListener('change', this.#onFitTextUpdate);\n }\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers.length = 0;\n }\n\n #onRootSlotchange = () => {\n this.#updateStyleStates();\n\n if (this.input && this.#observers.length === 0) {\n this.#setupInput();\n this.#setupFitText();\n }\n };\n\n /** Resets control value to initial attribute value and clears any active validation rules. */\n reset() {\n this.#resetInputValue(this.input as ControlInput);\n this.requestUpdate();\n this.dispatchEvent(new CustomEvent('reset', { bubbles: true, composed: true }));\n }\n\n #resetInputValue(input: ControlInput) {\n if (input instanceof HTMLSelectElement) {\n this.#resetSelectValue(input);\n return;\n }\n\n if (this.#isCheckedInput(input)) {\n input.checked = input.defaultChecked;\n input.indeterminate = false;\n return;\n }\n\n input.value =\n input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement\n ? input.defaultValue\n : (input.getAttribute('value') ?? '');\n }\n\n #resetSelectValue(input: HTMLSelectElement) {\n const hasDefaultSelection = Array.from(input.options).some(option => option.defaultSelected);\n Array.from(input.options).forEach(option => (option.selected = option.defaultSelected));\n if (!input.multiple && !hasDefaultSelection) input.selectedIndex = 0;\n }\n\n #isCheckedInput(input: ControlInput): input is HTMLInputElement {\n return input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio');\n }\n\n #setupInput() {\n this.#observers.push(\n ...setupControlValidationStates(this, this.#messages),\n ...setupControlStates(this),\n ...setupControlStatusStates(this, this.#messages),\n setupControlLayoutStates(this),\n getAttributeListChanges(this, ['hidden', 'status'], () => this.#updateStyleStates())\n );\n\n this.#polyfillShowPicker();\n this.#updateAssociations();\n this.shadowRoot!.addEventListener('slotchange', this.#onInputSlotchange);\n }\n\n #onInputSlotchange = () => {\n this.#updateStyleStates();\n this.#updateAssociations();\n };\n\n #setupFitText() {\n if (this.fitText) {\n this.#getCharacterWidth();\n this.input.addEventListener('input', this.#onFitTextUpdate);\n this.input.addEventListener('change', this.#onFitTextUpdate);\n }\n }\n\n #onFitTextUpdate = () => {\n this.#getCharacterWidth();\n };\n\n #getCharacterWidth() {\n if (this.input.tagName === 'INPUT') {\n const offset = this.input.type !== 'text' ? 4 : 0;\n this.style.setProperty('--control-width', `${this.input.value.length + offset}ch`);\n this.input.style.setProperty('max-width', `${this.input.value.length + 2}ch`, 'important');\n } else if (this.input.tagName === 'SELECT') {\n this.style.setProperty(\n '--control-width',\n `${(this.input as unknown as HTMLSelectElement).options[(this.input as unknown as HTMLSelectElement).selectedIndex]!.textContent!.length + 4}ch`\n );\n }\n }\n\n #polyfillShowPicker() {\n if (!this.input.showPicker) {\n this.input.showPicker = () => this.input.focus();\n }\n }\n\n #updateStyleStates() {\n if (this.input) {\n this.toggleAttribute('multiple', this.input?.multiple);\n this.input?.hasAttribute('size') ? this.setAttribute('size', '') : this.removeAttribute('size');\n }\n }\n\n #updateAssociations() {\n this.#assignLabel();\n associateLabel(this.#label, this.input);\n associateAriaDescribedBy(Array.from(this.#messages), this.input);\n\n if (this._associateDatalist) {\n associateDataList(this.querySelector<HTMLDataListElement>('datalist')!, this.input);\n }\n }\n\n #assignLabel() {\n const label =\n this.querySelector('label') ||\n (this.shadowRoot!.querySelector('slot')!\n .assignedNodes({ flatten: true })\n .find((i: Node) => (i as HTMLElement).tagName === 'LABEL') as HTMLLabelElement);\n if (label) {\n label.slot = 'label';\n }\n }\n\n protected showPicker() {\n try {\n this.input.showPicker();\n } catch {\n //\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2DO,IAAA,IAAA,cAAsB,EAAW;;8BAYuC,sBAGM,cAE3C,IAAI,EAAqB,IAAI,eAGlC,KAAKA,GAAgB,wBA6CO,cAKW,CAAC,6BAE5C,oBAkDL;GAGxB,AAFA,KAAKC,GAAmB,GAEpB,KAAK,SAAS,KAAKC,GAAW,WAAW,MAC3C,KAAKC,GAAY,GACjB,KAAKC,GAAc;EAEvB,mBAmD2B;GAEzB,AADA,KAAKH,GAAmB,GACxB,KAAKI,GAAoB;EAC3B,mBAUyB;GACvB,KAAKC,GAAmB;EAC1B;;CAlLA;CAQA,IAAIC,KAAS;EACX,OAAO,KAAK,YACR,cAA+B,sBAAoB,CAAC,EACpD,iBAAiB,EAAE,SAAS,GAAK,CAAC,CAAC,GAAG;CAC5C;CAEA,IAAIC,KAAY;EACd,OAAQ,KAAK,YACT,cAA+B,yBAAuB,CAAC,EACvD,iBAAiB,EAAE,SAAS,GAAK,CAAC,KAAK,CAAC;CAC9C;CAEA;CAGA,IAAI,QAA0B;EAC5B,IAAI,CAAC,KAAY,CAAC,KAAKC,IAAQ;GAC7B,IAAM,IACJ,KAAK,cAAc,MAAM,CAAC,EACtB,iBAAiB,CAAC,EAClB,MAAK,MAAK,EAA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E,MAAM;CAAS,SAAS;CAAM,WAAW;AAAc,CAAC,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,MAKnE,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,MAGzB,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,MA0CxC,EAAS,EAAE,WAAW,cAAc,CAAC,CAAA,GAAA,EAAA,WAAA,cAAA,KAAA,CAAA,UAlEvC,EAAQ,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"control2.js","names":["#i18nController","#updateStyleStates","#observers","#setupInput","#updateAssociations","#label","#messages","#input","#onRootSlotchange","#onInputSlotchange","#resetInputValue","#resetSelectValue","#isCheckedInput","#polyfillShowPicker","#assignLabel"],"sources":["../../../src/forms/control/control.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TemplateResult } from 'lit';\nimport { LitElement, html, nothing, isServer } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport {\n attachInternals,\n useStyles,\n associateLabel,\n associateAriaDescribedBy,\n associateDataList,\n appendRootNodeStyle,\n getAttributeListChanges,\n I18nController,\n hostAttr,\n typeSSR\n} from '@nvidia-elements/core/internal';\nimport type { ControlMessage } from '../control-message/control-message.js';\nimport {\n setupControlValidationStates,\n setupControlStates,\n setupControlStatusStates,\n inputQuery,\n type ControlStateCleanup\n} from '../utils/states.js';\nimport { setupControlLayoutStates } from '../utils/layout.js';\nimport globalStyles from './control.global.css?inline';\nimport styles from './control.css?inline';\n\ninterface ResettableControl {\n getAttribute: Element['getAttribute'];\n value: string;\n}\n\ntype ControlInput = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | ResettableControl;\n\n/**\n * @element nve-control\n * @description Wraps a form input with its associated label and validation messages, managing layout and accessibility associations.\n * @documentation https://nvidia.github.io/elements/docs/elements/control/\n * @since 0.3.0\n * @entrypoint \\@nvidia-elements/core/forms\n * @slot - Control input element\n * @slot label - Label element\n * @cssprop --cursor\n * @cssprop --accent-color\n * @cssprop --color\n * @cssprop --label-color\n * @cssprop --label-width\n * @cssprop --label-font-weight\n * @cssprop --label-font-size\n * @cssprop --control-width\n * @cssprop --control-height\n\n * @aria https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals\n * @package true\n */\n@typeSSR()\nexport class Control extends LitElement {\n /** Set current visual state for control. This overrides any validation states active. */\n @property({ type: String }) status: 'warning' | 'error' | 'success' | 'disabled';\n\n /** Set current control + label + control message layout. Layouts will collapse based on available container space. */\n @property({ type: String, reflect: true }) layout:\n | 'vertical'\n | 'vertical-inline'\n | 'horizontal'\n | 'horizontal-inline';\n\n /** Sets the input to match the width of the active text content of the control value. Only applicable to vertical input box type controls (input, select) */\n @property({ type: Boolean, reflect: true, attribute: 'fit-text' }) fitText = false;\n\n /** Sets the input to match native default content block */\n @property({ type: Boolean, reflect: true, attribute: 'fit-content' }) fitContent = false;\n\n #i18nController: I18nController<this> = new I18nController<this>(this);\n\n /** Enables internal string values to update for internationalization. */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n /** Set the visual prominence of the control */\n @property({ type: String, reflect: true }) prominence: 'muted';\n\n get #label() {\n return this.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot[name=\"label\"]')\n ?.assignedElements({ flatten: true })?.[0] as HTMLLabelElement;\n }\n\n get #messages() {\n return (this.shadowRoot\n ?.querySelector<HTMLSlotElement>('slot[name=\"messages\"]')\n ?.assignedElements({ flatten: true }) ?? []) as ControlMessage[];\n }\n\n #input: HTMLInputElement;\n\n /** @private */\n get input(): HTMLInputElement {\n if (!isServer && !this.#input) {\n const slotted =\n this.querySelector('slot')\n ?.assignedElements()\n ?.find(i => i.matches(inputQuery)) ??\n Array.from(this.shadowRoot!.querySelector('slot')?.assignedElements({ flatten: true }) ?? []).find(i =>\n i.matches(inputQuery)\n );\n this.#input = (slotted ? slotted : this.querySelector(inputQuery)) as HTMLInputElement;\n }\n\n return this.#input;\n }\n\n /** @private */\n protected get prefixContent(): typeof nothing | TemplateResult {\n return nothing;\n }\n\n /** @private */\n protected get suffixContent(): typeof nothing | TemplateResult {\n return nothing;\n }\n\n @hostAttr({ attribute: 'nve-control' }) protected nveControl = '';\n\n /** @private */\n declare _internals: ElementInternals;\n\n #observers: (MutationObserver | ResizeObserver | ControlStateCleanup)[] = [];\n\n protected _associateDatalist = true;\n\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-control',\n version: '0.0.0'\n };\n\n render() {\n return this.nveControl !== 'inline'\n ? html`\n <div internal-host part=\"_internal-host\">\n <slot name=\"label\" part=\"_label\"></slot>\n <div input part=\"_input\">\n ${this.prefixContent}\n <slot></slot>\n ${this.suffixContent}\n </div>\n <slot name=\"messages\" part=\"_messages\"></slot>\n </div>\n `\n : html`\n <div internal-host part=\"_internal-host\">\n <div input part=\"_input\"><slot interaction-state></slot></div>\n <slot name=\"label\" part=\"_label\"></slot>\n <slot name=\"messages\" part=\"_messages\"></slot>\n </div>\n `;\n }\n\n connectedCallback() {\n super.connectedCallback();\n attachInternals(this);\n appendRootNodeStyle(this, globalStyles);\n this.shadowRoot!.addEventListener('slotchange', this.#onRootSlotchange);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.shadowRoot!.removeEventListener('slotchange', this.#onRootSlotchange);\n this.shadowRoot!.removeEventListener('slotchange', this.#onInputSlotchange);\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers.length = 0;\n }\n\n #onRootSlotchange = () => {\n this.#updateStyleStates();\n\n if (this.input && this.#observers.length === 0) {\n this.#setupInput();\n }\n };\n\n /** Resets control value to initial attribute value and clears any active validation rules. */\n reset() {\n this.#resetInputValue(this.input as ControlInput);\n this.requestUpdate();\n this.dispatchEvent(new CustomEvent('reset', { bubbles: true, composed: true }));\n }\n\n #resetInputValue(input: ControlInput) {\n if (input instanceof HTMLSelectElement) {\n this.#resetSelectValue(input);\n return;\n }\n\n if (this.#isCheckedInput(input)) {\n input.checked = input.defaultChecked;\n input.indeterminate = false;\n return;\n }\n\n input.value =\n input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement\n ? input.defaultValue\n : (input.getAttribute('value') ?? '');\n }\n\n #resetSelectValue(input: HTMLSelectElement) {\n const hasDefaultSelection = Array.from(input.options).some(option => option.defaultSelected);\n Array.from(input.options).forEach(option => (option.selected = option.defaultSelected));\n if (!input.multiple && !hasDefaultSelection) input.selectedIndex = 0;\n }\n\n #isCheckedInput(input: ControlInput): input is HTMLInputElement {\n return input instanceof HTMLInputElement && (input.type === 'checkbox' || input.type === 'radio');\n }\n\n #setupInput() {\n this.#observers.push(\n ...setupControlValidationStates(this, this.#messages),\n ...setupControlStates(this),\n ...setupControlStatusStates(this, this.#messages),\n setupControlLayoutStates(this),\n getAttributeListChanges(this, ['hidden', 'status'], () => this.#updateStyleStates())\n );\n\n this.#polyfillShowPicker();\n this.#updateAssociations();\n this.shadowRoot!.addEventListener('slotchange', this.#onInputSlotchange);\n }\n\n #onInputSlotchange = () => {\n this.#updateStyleStates();\n this.#updateAssociations();\n };\n\n #polyfillShowPicker() {\n if (!this.input.showPicker) {\n this.input.showPicker = () => this.input.focus();\n }\n }\n\n #updateStyleStates() {\n if (this.input) {\n this.toggleAttribute('multiple', this.input?.multiple);\n this.input?.hasAttribute('size') ? this.setAttribute('size', '') : this.removeAttribute('size');\n }\n }\n\n #updateAssociations() {\n this.#assignLabel();\n associateLabel(this.#label, this.input);\n associateAriaDescribedBy(Array.from(this.#messages), this.input);\n\n if (this._associateDatalist) {\n associateDataList(this.querySelector<HTMLDataListElement>('datalist')!, this.input);\n }\n }\n\n #assignLabel() {\n const label =\n this.querySelector('label') ||\n (this.shadowRoot!.querySelector('slot')!\n .assignedNodes({ flatten: true })\n .find((i: Node) => (i as HTMLElement).tagName === 'LABEL') as HTMLLabelElement);\n if (label) {\n label.slot = 'label';\n }\n }\n\n protected showPicker() {\n try {\n this.input.showPicker();\n } catch {\n //\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2DO,IAAA,IAAA,cAAsB,EAAW;;8BAYuC,sBAGM,cAE3C,IAAI,EAAqB,IAAI,eAGlC,KAAKA,GAAgB,wBA6CO,cAKW,CAAC,6BAE5C,oBA8CL;GAGxB,AAFA,KAAKC,GAAmB,GAEpB,KAAK,SAAS,KAAKC,GAAW,WAAW,KAC3C,KAAKC,GAAY;EAErB,mBAmD2B;GAEzB,AADA,KAAKF,GAAmB,GACxB,KAAKG,GAAoB;EAC3B;;CAjKA;CAQA,IAAIC,KAAS;EACX,OAAO,KAAK,YACR,cAA+B,sBAAoB,CAAC,EACpD,iBAAiB,EAAE,SAAS,GAAK,CAAC,CAAC,GAAG;CAC5C;CAEA,IAAIC,KAAY;EACd,OAAQ,KAAK,YACT,cAA+B,yBAAuB,CAAC,EACvD,iBAAiB,EAAE,SAAS,GAAK,CAAC,KAAK,CAAC;CAC9C;CAEA;CAGA,IAAI,QAA0B;EAC5B,IAAI,CAAC,KAAY,CAAC,KAAKC,IAAQ;GAC7B,IAAM,IACJ,KAAK,cAAc,MAAM,CAAC,EACtB,iBAAiB,CAAC,EAClB,MAAK,MAAK,EAAE,QAAA,oDAAkB,CAAC,KACnC,MAAM,KAAK,KAAK,WAAY,cAAc,MAAM,CAAC,EAAE,iBAAiB,EAAE,SAAS,GAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAK,MACjG,EAAE,QAAA,oDAAkB,CACtB;GACF,KAAKA,KAAU,KAAoB,KAAK,cAAc,CAAU;EAClE;EAEA,OAAO,KAAKA;CACd;CAGA,IAAc,gBAAiD;EAC7D,OAAO;CACT;CAGA,IAAc,gBAAiD;EAC7D,OAAO;CACT;CAOA;;gBAIgB,EAAU,CAAC,CAAM,CAAC;;;kBAEP;GACzB,KAAK;GACL,SAAS;EACX;;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