@nvidia-elements/core 2.23.4 → 2.23.5
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 +10 -0
- package/dist/accordion/accordion2.js +49 -49
- package/dist/accordion/accordion2.js.map +1 -1
- package/dist/alert/alert-group2.js +22 -21
- package/dist/alert/alert-group2.js.map +1 -1
- package/dist/alert/alert2.js +29 -28
- package/dist/alert/alert2.js.map +1 -1
- package/dist/avatar/avatar-group2.js +9 -9
- package/dist/avatar/avatar-group2.js.map +1 -1
- package/dist/avatar/avatar2.js +12 -11
- package/dist/avatar/avatar2.js.map +1 -1
- package/dist/badge/badge2.js +27 -26
- package/dist/badge/badge2.js.map +1 -1
- package/dist/breadcrumb/breadcrumb2.js +17 -17
- package/dist/breadcrumb/breadcrumb2.js.map +1 -1
- package/dist/bundles/index.js +6 -6
- package/dist/button/button2.js +12 -12
- package/dist/button/button2.js.map +1 -1
- package/dist/button-group/button-group2.js +18 -18
- package/dist/button-group/button-group2.js.map +1 -1
- package/dist/card/card2.js +28 -28
- package/dist/card/card2.js.map +1 -1
- package/dist/chat-message/chat-message2.js +15 -14
- package/dist/chat-message/chat-message2.js.map +1 -1
- package/dist/checkbox/checkbox-group2.js +8 -8
- package/dist/checkbox/checkbox-group2.js.map +1 -1
- package/dist/checkbox/checkbox2.js +8 -8
- package/dist/checkbox/checkbox2.js.map +1 -1
- package/dist/color/color2.js +21 -21
- package/dist/color/color2.js.map +1 -1
- package/dist/combobox/combobox2.js +37 -37
- package/dist/combobox/combobox2.js.map +1 -1
- package/dist/copy-button/copy-button.d.ts +1 -1
- package/dist/copy-button/copy-button2.js +21 -21
- package/dist/copy-button/copy-button2.js.map +1 -1
- package/dist/custom-elements.json +0 -76
- package/dist/date/date2.js +19 -19
- package/dist/date/date2.js.map +1 -1
- package/dist/datetime/datetime2.js +19 -19
- package/dist/datetime/datetime2.js.map +1 -1
- package/dist/dialog/dialog-footer2.js +7 -7
- package/dist/dialog/dialog-footer2.js.map +1 -1
- package/dist/dialog/dialog-header2.js +7 -7
- package/dist/dialog/dialog-header2.js.map +1 -1
- package/dist/dialog/dialog2.js +25 -25
- package/dist/dialog/dialog2.js.map +1 -1
- package/dist/divider/divider2.js +12 -12
- package/dist/divider/divider2.js.map +1 -1
- package/dist/dot/dot2.js +17 -16
- package/dist/dot/dot2.js.map +1 -1
- package/dist/drag-handle/drag-handle2.js +12 -12
- package/dist/drag-handle/drag-handle2.js.map +1 -1
- package/dist/drawer/drawer-content2.js +7 -7
- package/dist/drawer/drawer-content2.js.map +1 -1
- package/dist/drawer/drawer-footer2.js +7 -7
- package/dist/drawer/drawer-footer2.js.map +1 -1
- package/dist/drawer/drawer-header2.js +7 -7
- package/dist/drawer/drawer-header2.js.map +1 -1
- package/dist/drawer/drawer2.js +21 -21
- package/dist/drawer/drawer2.js.map +1 -1
- package/dist/dropdown/dropdown-footer2.js +7 -7
- package/dist/dropdown/dropdown-footer2.js.map +1 -1
- package/dist/dropdown/dropdown-header2.js +7 -7
- package/dist/dropdown/dropdown-header2.js.map +1 -1
- package/dist/dropdown/dropdown2.js +21 -21
- package/dist/dropdown/dropdown2.js.map +1 -1
- package/dist/dropdown-group/dropdown-group.js +10 -10
- package/dist/dropdown-group/dropdown-group.js.map +1 -1
- package/dist/dropzone/dropzone2.js +19 -19
- package/dist/dropzone/dropzone2.js.map +1 -1
- package/dist/file/file2.js +8 -8
- package/dist/file/file2.js.map +1 -1
- package/dist/format-bytes/format-bytes2.js +13 -13
- package/dist/format-bytes/format-bytes2.js.map +1 -1
- package/dist/format-datetime/format-datetime2.js +14 -14
- package/dist/format-datetime/format-datetime2.js.map +1 -1
- package/dist/format-number/format-number2.js +20 -20
- package/dist/format-number/format-number2.js.map +1 -1
- package/dist/format-relative-time/format-relative-time2.js +11 -11
- package/dist/format-relative-time/format-relative-time2.js.map +1 -1
- package/dist/format-truncate/format-truncate2.js +21 -21
- package/dist/format-truncate/format-truncate2.js.map +1 -1
- package/dist/forms/control/control2.js +30 -29
- package/dist/forms/control/control2.js.map +1 -1
- package/dist/forms/control-group/control-group2.js +19 -18
- package/dist/forms/control-group/control-group2.js.map +1 -1
- package/dist/forms/control-message/control-message2.js +15 -15
- package/dist/forms/control-message/control-message2.js.map +1 -1
- package/dist/gauge/gauge2.js +20 -20
- package/dist/gauge/gauge2.js.map +1 -1
- package/dist/ghost/ghost2.js +10 -10
- package/dist/ghost/ghost2.js.map +1 -1
- package/dist/grid/cell/cell2.js +9 -9
- package/dist/grid/cell/cell2.js.map +1 -1
- package/dist/grid/column/column2.js +16 -16
- package/dist/grid/column/column2.js.map +1 -1
- package/dist/grid/footer/footer2.js +12 -12
- package/dist/grid/footer/footer2.js.map +1 -1
- package/dist/grid/grid2.js +30 -30
- package/dist/grid/grid2.js.map +1 -1
- package/dist/grid/header/header2.js +20 -20
- package/dist/grid/header/header2.js.map +1 -1
- package/dist/grid/placeholder/placeholder2.js +9 -9
- package/dist/grid/placeholder/placeholder2.js.map +1 -1
- package/dist/grid/row/row2.js +15 -15
- package/dist/grid/row/row2.js.map +1 -1
- package/dist/icon/icon2.js +40 -40
- package/dist/icon/icon2.js.map +1 -1
- package/dist/icon-button/icon-button2.js +17 -17
- package/dist/icon-button/icon-button2.js.map +1 -1
- package/dist/iframe/iframe2.js +7 -7
- package/dist/iframe/iframe2.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/input/input-group2.js +8 -8
- package/dist/input/input-group2.js.map +1 -1
- package/dist/input/input2.js +10 -10
- package/dist/input/input2.js.map +1 -1
- package/dist/internal/controllers/state-expanded.controller.js +1 -1
- package/dist/internal/controllers/state-expanded.controller.js.map +1 -1
- package/dist/internal/controllers/state-highlighted.controller.js +1 -1
- package/dist/internal/controllers/state-highlighted.controller.js.map +1 -1
- package/dist/internal/controllers/state-scroll.controller.js +1 -1
- package/dist/internal/controllers/state-scroll.controller.js.map +1 -1
- package/dist/internal/controllers/state-selected.controller.js +1 -1
- package/dist/internal/controllers/state-selected.controller.js.map +1 -1
- package/dist/internal/controllers/type-anchor.controller.js +1 -1
- package/dist/internal/controllers/type-anchor.controller.js.map +1 -1
- package/dist/internal/controllers/type-closable.controller.js +1 -1
- package/dist/internal/controllers/type-closable.controller.js.map +1 -1
- package/dist/internal/controllers/type-expandable.controller.js +1 -1
- package/dist/internal/controllers/type-expandable.controller.js.map +1 -1
- package/dist/internal/controllers/type-native-popover.controller.js +6 -6
- package/dist/internal/controllers/type-native-popover.controller.js.map +1 -1
- package/dist/internal/controllers/type-popover.controller.examples.js.map +1 -1
- package/dist/internal/controllers/type-selectable.controller.js +1 -1
- package/dist/internal/controllers/type-selectable.controller.js.map +1 -1
- package/dist/internal/index.d.ts +0 -1
- package/dist/internal/index.js +57 -61
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/styles/index.d.ts +0 -1
- package/dist/internal/styles/index.js +5 -15
- package/dist/internal/styles/index.js.map +1 -1
- package/dist/internal/utils/a11y.d.ts +0 -3
- package/dist/internal/utils/a11y.js +6 -9
- package/dist/internal/utils/a11y.js.map +1 -1
- package/dist/joystick/joystick2.js +19 -19
- package/dist/joystick/joystick2.js.map +1 -1
- package/dist/logo/logo2.js +14 -13
- package/dist/logo/logo2.js.map +1 -1
- package/dist/menu/menu-group2.js +20 -20
- package/dist/menu/menu-group2.js.map +1 -1
- package/dist/menu/menu-item2.js +11 -11
- package/dist/menu/menu-item2.js.map +1 -1
- package/dist/menu/menu2.js +14 -14
- package/dist/menu/menu2.js.map +1 -1
- package/dist/month/month2.js +19 -19
- package/dist/month/month2.js.map +1 -1
- package/dist/notification/notification-group2.js +13 -13
- package/dist/notification/notification-group2.js.map +1 -1
- package/dist/notification/notification2.js +31 -31
- package/dist/notification/notification2.js.map +1 -1
- package/dist/page/page-panel/page-panel-content2.js +7 -7
- package/dist/page/page-panel/page-panel-content2.js.map +1 -1
- package/dist/page/page-panel/page-panel-footer2.js +9 -9
- package/dist/page/page-panel/page-panel-footer2.js.map +1 -1
- package/dist/page/page-panel/page-panel-header2.js +9 -9
- package/dist/page/page-panel/page-panel-header2.js.map +1 -1
- package/dist/page/page-panel/page-panel2.js +15 -15
- package/dist/page/page-panel/page-panel2.js.map +1 -1
- package/dist/page/page2.js +13 -13
- package/dist/page/page2.js.map +1 -1
- package/dist/page-header/page-header2.js +10 -10
- package/dist/page-header/page-header2.js.map +1 -1
- package/dist/page-loader/page-loader2.js +13 -13
- package/dist/page-loader/page-loader2.js.map +1 -1
- package/dist/pagination/pagination2.js +34 -34
- package/dist/pagination/pagination2.js.map +1 -1
- package/dist/panel/panel2.js +36 -36
- package/dist/panel/panel2.js.map +1 -1
- package/dist/password/password2.js +19 -19
- package/dist/password/password2.js.map +1 -1
- package/dist/preferences-input/preferences-input.d.ts +1 -1
- package/dist/preferences-input/preferences-input2.js +25 -25
- package/dist/preferences-input/preferences-input2.js.map +1 -1
- package/dist/progress-bar/progress-bar2.js +13 -13
- package/dist/progress-bar/progress-bar2.js.map +1 -1
- package/dist/progress-dot/progress-dot2.js +15 -15
- package/dist/progress-dot/progress-dot2.js.map +1 -1
- package/dist/progress-ring/progress-ring2.js +20 -20
- package/dist/progress-ring/progress-ring2.js.map +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip2.js +28 -28
- package/dist/progressive-filter-chip/progressive-filter-chip2.js.map +1 -1
- package/dist/pulse/pulse2.js +15 -15
- package/dist/pulse/pulse2.js.map +1 -1
- package/dist/radio/radio-group2.js +8 -8
- package/dist/radio/radio-group2.js.map +1 -1
- package/dist/radio/radio2.js +8 -8
- package/dist/radio/radio2.js.map +1 -1
- package/dist/range/range2.js +16 -16
- package/dist/range/range2.js.map +1 -1
- package/dist/resize-handle/resize-handle2.js +17 -17
- package/dist/resize-handle/resize-handle2.js.map +1 -1
- package/dist/search/search2.js +20 -20
- package/dist/search/search2.js.map +1 -1
- package/dist/select/select2.js +32 -32
- package/dist/select/select2.js.map +1 -1
- package/dist/skeleton/skeleton2.js +14 -14
- package/dist/skeleton/skeleton2.js.map +1 -1
- package/dist/sort-button/sort-button.d.ts +1 -1
- package/dist/sort-button/sort-button2.js +16 -16
- package/dist/sort-button/sort-button2.js.map +1 -1
- package/dist/sparkline/sparkline2.js +45 -44
- package/dist/sparkline/sparkline2.js.map +1 -1
- package/dist/star-rating/star-rating2.js +14 -14
- package/dist/star-rating/star-rating2.js.map +1 -1
- package/dist/steps/steps2.js +32 -32
- package/dist/steps/steps2.js.map +1 -1
- package/dist/switch/switch-group2.js +8 -8
- package/dist/switch/switch-group2.js.map +1 -1
- package/dist/switch/switch2.js +8 -8
- package/dist/switch/switch2.js.map +1 -1
- package/dist/tabs/tabs-group2.js +18 -18
- package/dist/tabs/tabs-group2.js.map +1 -1
- package/dist/tabs/tabs-item-group2.js +9 -9
- package/dist/tabs/tabs-item-group2.js.map +1 -1
- package/dist/tabs/tabs2.js +28 -28
- package/dist/tabs/tabs2.js.map +1 -1
- package/dist/tag/tag2.js +19 -18
- package/dist/tag/tag2.js.map +1 -1
- package/dist/textarea/textarea2.js +9 -9
- package/dist/textarea/textarea2.js.map +1 -1
- package/dist/time/time2.js +19 -19
- package/dist/time/time2.js.map +1 -1
- package/dist/toast/toast2.js +28 -28
- package/dist/toast/toast2.js.map +1 -1
- package/dist/toggletip/toggletip-footer2.js +7 -7
- package/dist/toggletip/toggletip-footer2.js.map +1 -1
- package/dist/toggletip/toggletip-header2.js +7 -7
- package/dist/toggletip/toggletip-header2.js.map +1 -1
- package/dist/toggletip/toggletip2.js +23 -23
- package/dist/toggletip/toggletip2.js.map +1 -1
- package/dist/toolbar/toolbar2.js +20 -19
- package/dist/toolbar/toolbar2.js.map +1 -1
- package/dist/tooltip/tooltip2.js +20 -20
- package/dist/tooltip/tooltip2.js.map +1 -1
- package/dist/tree/tree-node2.js +39 -39
- package/dist/tree/tree-node2.js.map +1 -1
- package/dist/tree/tree2.js +20 -20
- package/dist/tree/tree2.js.map +1 -1
- package/dist/week/week2.js +19 -19
- package/dist/week/week2.js.map +1 -1
- package/dist/workspace/panel/panel2.js +14 -14
- package/dist/workspace/panel/panel2.js.map +1 -1
- package/dist/workspace/panel-content/panel-content2.js +7 -7
- package/dist/workspace/panel-content/panel-content2.js.map +1 -1
- package/dist/workspace/panel-footer/panel-footer2.js +9 -9
- package/dist/workspace/panel-footer/panel-footer2.js.map +1 -1
- package/dist/workspace/panel-header/panel-header2.js +16 -16
- package/dist/workspace/panel-header/panel-header2.js.map +1 -1
- package/dist/workspace/workspace2.js +97 -97
- package/dist/workspace/workspace2.js.map +1 -1
- package/package.json +2 -2
- package/dist/internal/decorators/scoped-registry.d.ts +0 -2
- package/dist/internal/decorators/scoped-registry.js +0 -36
- package/dist/internal/decorators/scoped-registry.js.map +0 -1
- package/dist/internal/styles/base.js +0 -5
- package/dist/internal/styles/base.js.map +0 -1
- package/dist/internal/styles/interaction-state.js +0 -5
- package/dist/internal/styles/interaction-state.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select2.js","names":["styles","globalStyles","_decorate","__decorate","select_default","select_global_default","i18nDefaults","Select","Control","_args","#i18nController","I18nController","#observers","#optionObservers","useStyles","Icon","Dropdown","Menu","MenuItem","Tag","#select","#options","#dropdown","#menuItems","#input","#tags","#caret","#placeholderOption","o","#multipleSelectLabel","option","label","#selectValue","nothing","#menu","ifDefined","i","#closeDropdown","#openDropdown","props","#setupCustomSelectUI","getElementUpdate","onChildListMutation","#syncOptionSelectedStates","#disconnectObservers","#setupOverflowListener","#syncSelectValueStates","observer","#overflowObserver","#observedTags","options","appendRootNodeStyle","#setupObservers","#observeTags","onListboxActivate","focusElementTimeout","input","inputWidth","inputEntry","entries","entry","#updateMultipleOverflow","tags","selected","width","property","i18n","scopedRegistry"],"sources":["../../src/select/select.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PropertyValues } from 'lit';\nimport { html, nothing } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n focusElementTimeout,\n onListboxActivate,\n useStyles,\n onChildListMutation,\n getElementUpdate,\n scopedRegistry,\n appendRootNodeStyle\n} from '@nvidia-elements/core/internal';\nimport { i18n, I18nController, type I18nDefaults } from '@nvidia-elements/foundations/internal/i18n';\nimport { Control } from '@nvidia-elements/core/forms';\nimport { Icon } from '@nvidia-elements/core/icon';\nimport { Menu, MenuItem } from '@nvidia-elements/core/menu';\nimport { Dropdown } from '@nvidia-elements/core/dropdown';\nimport { Tag } from '@nvidia-elements/core/tag';\nimport styles from './select.css?inline';\nimport globalStyles from './select.global.css?inline';\n\nconst i18nDefaults = {\n select: 'select',\n selected: 'selected'\n} satisfies I18nDefaults;\n\n/**\n * @element nve-select\n * @description A select is a control that enables users to select an option from a list of options.\n * @documentation https://nvidia.github.io/elements/docs/elements/select/\n * @since 0.3.0\n * @entrypoint \\@nvidia-elements/core/select\n * @cssprop --padding\n * @cssprop --font-size\n * @cssprop --height\n * @cssprop --background\n * @cssprop --color\n * @cssprop --border-radius\n * @cssprop --border\n * @cssprop --border-bottom\n * @cssprop --cursor\n * @cssprop --font-weight\n * @cssprop --text-align\n * @cssprop --scroll-height\n * @cssprop --width\n * @cssprop --control-width\n * @cssprop --max-width\n * @cssprop --min-width\n * @cssprop --box-shadow\n * @cssprop --max-height\n * @cssprop --text-transform\n * @csspart tag\n * @csspart menu - The dropdown menu element\n * @csspart menu-item - The menu item elements\n * @csspart icon - The icon element\n * @csspart caret - The caret/chevron icon element\n * @csspart dropdown - The dropdown popup element\n * @slot - Select input element\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select\n */\n@i18n<Select>()\n@scopedRegistry()\nexport class Select extends Control {\n static styles = useStyles([...Control.styles, styles]);\n\n static readonly metadata = {\n tag: 'nve-select',\n version: '0.0.0'\n };\n\n static elementDefinitions = {\n [Icon.metadata.tag]: Icon,\n [Dropdown.metadata.tag]: Dropdown,\n [Menu.metadata.tag]: Menu,\n [MenuItem.metadata.tag]: MenuItem,\n [Tag.metadata.tag]: Tag\n };\n\n /** Flat container option applies when embedding the component within another containing element */\n @property({ type: String, reflect: true }) container?: 'flat' | 'inline';\n\n #i18nController: I18nController<this> = new I18nController<this>(this, i18nDefaults);\n\n /** Updates internal string values for internationalization. */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n get #select() {\n return this.input as unknown as HTMLSelectElement;\n }\n\n get #options() {\n return Array.from(this.#select?.options ? this.#select.options : []);\n }\n\n get #dropdown() {\n return this.shadowRoot!.querySelector<Dropdown>(Dropdown.metadata.tag);\n }\n\n get #menuItems() {\n return this.shadowRoot!.querySelectorAll<MenuItem>(MenuItem.metadata.tag);\n }\n\n get #input() {\n return this.shadowRoot!.querySelector<HTMLElement>('[input]');\n }\n\n get #tags() {\n return this.shadowRoot!.querySelector('.tags');\n }\n\n get #caret() {\n return this.shadowRoot!.querySelector<Icon>('[name=\"caret\"]');\n }\n\n get #placeholderOption() {\n return this.#options.find(o => o.selected && o.hidden && o.disabled);\n }\n\n #observers: (MutationObserver | ResizeObserver)[] = [];\n #overflowObserver?: ResizeObserver;\n #observedTags?: Element | null;\n\n get #multipleSelectLabel() {\n const option = this.#placeholderOption;\n const label = option ? option.innerText : `${this.#select.selectedOptions.length} ${this.i18n.selected}`;\n return html`<div class=\"tags-label ${option ? 'placeholder' : ''}\" aria-hidden=\"true\">${label}</div>`;\n }\n\n protected get prefixContent() {\n return this.#select?.multiple && this.#select?.size === 0\n ? html`\n ${this.#multipleSelectLabel}\n <div class=\"tags\">\n ${this.#options\n .filter(o => o.selected && o !== this.#placeholderOption)\n .map(\n o => html`\n <nve-tag part=\"tag\" readonly color=\"gray-slate\" closable .value=${o.value} @click=${() => this.#selectValue(o, false)}>${o.textContent}</nve-tag>`\n )}\n </div>`\n : nothing;\n }\n\n get #menu() {\n return html`\n <nve-menu part=\"menu\" role=\"listbox\" style=\"--width: 100%; --min-width: fit-content\" aria-label=${ifDefined(this.i18n.select)}>\n ${this.#options\n .filter(o => o !== this.#placeholderOption)\n .map(\n (o, i) => html`\n <nve-menu-item part=\"menu-item\" role=\"option\" @click=${() => this.#selectValue(o, !o.selected)} ?selected=${o.selected} ?disabled=${o.disabled} ?hidden=${!!o.hidden} aria-selected=${o.selected}>\n <slot name=\"option-${i + 1}\">\n <nve-icon part=\"icon\" name=\"check\" size=\"sm\" aria-hidden=\"true\"></nve-icon> ${o.innerText}\n </slot>\n </nve-menu-item>`\n )}\n </nve-menu>`;\n }\n\n protected get suffixContent() {\n return this.#select?.size === 0\n ? html`\n <nve-icon name=\"caret\" part=\"caret\" direction=\"down\" size=\"sm\" aria-hidden=\"true\"></nve-icon>\n <nve-dropdown part=\"dropdown\" @close=${this.#closeDropdown} @open=${this.#openDropdown} hidden .anchor=${this.#input} position=\"bottom\">\n ${this.#menu}\n </nve-dropdown>`\n : this.#menu;\n }\n\n async firstUpdated(props: PropertyValues<this>) {\n super.firstUpdated(props);\n await this.updateComplete;\n this.#setupCustomSelectUI();\n }\n\n #syncSelectValueStates() {\n this.#observers.push(\n getElementUpdate(this.#select, 'value', () => this.requestUpdate()),\n onChildListMutation(this.#select, () => this.requestUpdate(), { attributes: true, subtree: true }),\n onChildListMutation(this.#select, () => this.#syncOptionSelectedStates(), { subtree: true })\n );\n }\n\n #optionObservers = new Map<HTMLOptionElement, MutationObserver>();\n\n #setupObservers() {\n this.#disconnectObservers();\n this.#setupOverflowListener();\n this.#syncSelectValueStates();\n this.#syncOptionSelectedStates();\n }\n\n #disconnectObservers() {\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers = [];\n this.#optionObservers.clear();\n this.#overflowObserver = undefined;\n this.#observedTags = undefined;\n }\n\n #syncOptionSelectedStates() {\n const options = new Set(this.#options);\n\n this.#optionObservers.forEach((observer, option) => {\n if (!options.has(option)) {\n observer.disconnect();\n this.#optionObservers.delete(option);\n this.#observers = this.#observers.filter(o => o !== observer);\n }\n });\n\n this.#options.forEach(o => {\n if (!this.#optionObservers.has(o)) {\n const observer = getElementUpdate(o, 'selected', () => this.requestUpdate());\n this.#optionObservers.set(o, observer);\n this.#observers.push(observer);\n }\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n appendRootNodeStyle(this, globalStyles);\n void this.updateComplete.then(() => {\n if (this.isConnected) {\n this.#setupObservers();\n }\n });\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.#disconnectObservers();\n }\n\n async updated(props: PropertyValues<this>) {\n super.updated(props);\n if (this.#select?.size && this.#select?.size !== 0) {\n this._internals.states.add('size');\n this.style.setProperty('--size', `${this.#select.size}`);\n } else {\n this._internals.states.delete('size');\n this.style.removeProperty('--size');\n }\n\n if (this.#select?.multiple && this.#select?.size === 0) {\n this._internals.states.add('multiple');\n } else {\n this._internals.states.delete('multiple');\n }\n this.#observeTags();\n }\n\n #setupCustomSelectUI() {\n if (this.#select?.size === 0) {\n onListboxActivate(this.#select, () => {\n this.requestUpdate(); // update menu items\n this.#dropdown!.style.setProperty('--min-width', `${this.#input!.getBoundingClientRect().width}px`);\n this.#dropdown!.showPopover();\n focusElementTimeout(this.#menuItems[0] as HTMLElement);\n });\n }\n }\n\n #openDropdown() {\n this.#dropdown!.hidden = false;\n this.#caret!.direction = 'up';\n }\n\n #closeDropdown() {\n this.#dropdown!.hidden = true;\n this.#caret!.direction = 'down';\n }\n\n #setupOverflowListener() {\n const input = this.#input;\n if (!input) return;\n let inputWidth: number | undefined;\n const observer = new ResizeObserver(entries => {\n const inputEntry = entries.find(entry => entry.target === input);\n if (inputEntry) inputWidth = inputEntry.contentRect.width;\n if (this.isConnected && inputWidth !== undefined) this.#updateMultipleOverflow(inputWidth);\n });\n this.#overflowObserver = observer;\n this.#observers.push(observer);\n observer.observe(input);\n this.#observeTags();\n }\n\n #observeTags() {\n const observer = this.#overflowObserver;\n if (!observer) return;\n const tags = this.#tags;\n if (tags === this.#observedTags) return;\n if (this.#observedTags) observer.unobserve(this.#observedTags);\n this.#observedTags = tags;\n if (tags) observer.observe(tags);\n else this._internals.states.delete('multiple-overflow');\n }\n\n async #selectValue(option: HTMLOptionElement, selected: boolean) {\n if (this.#select.multiple || (!this.#select.multiple && option.value !== this.#select.value)) {\n option.selected = selected;\n }\n\n // native select only the first selected option determines the select input value\n if (this.#select.selectedOptions.length < 1) {\n this.#select.value = selected ? option.value : '';\n }\n\n this.#select.dispatchEvent(new Event('input', { bubbles: true }));\n this.#select.dispatchEvent(new Event('change', { bubbles: true }));\n this.requestUpdate();\n\n if (!this.#select.multiple && this.#dropdown) {\n this.#dropdown.hidePopover();\n } else {\n await this.updateComplete;\n this.#updateMultipleOverflow(this.#input!.getBoundingClientRect().width);\n }\n }\n\n #updateMultipleOverflow(width: number) {\n const tags = this.#tags;\n if (this.#select?.multiple && tags && tags.getBoundingClientRect().width > width - 48) {\n this._internals.states.add('multiple-overflow');\n } else {\n this._internals.states.delete('multiple-overflow');\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAMM,IAAe;CACnB,QAAQ;CACR,UAAU;AACZ,GAsCaC,IAAN,cAAqBC,EAAQ;;EAyHf,A,aAtGqB,KAAAE,KAAA,IAAIC,EAAqB,MAAML,CAAY,GAGhD,KAAA,OAAA,KAAKI,GAAgB,MAkCJ,KAAAE,KAAA,CAAC,GAiElC,KAAAC,qBAAA,IAAI,IAAyC;;;EAxHhD,KAAA,SAAAC,EAAU,CAAC,GAAGN,EAAQ,QAAQR,CAAM,CAAC;;;EAE1B,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;;EAE4B,KAAA,qBAAA;IACzBe,EAAK,SAAS,MAAMA;IACpBC,EAAS,SAAS,MAAMA;IACxBC,EAAK,SAAS,MAAMA;IACpBC,EAAS,SAAS,MAAMA;IACxBC,EAAI,SAAS,MAAMA;EACtB;;CAKA;CAKA,IAAIC,KAAU;EACZ,OAAO,KAAK;CACd;CAEA,IAAIC,KAAW;EACb,OAAO,MAAM,K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YAAY,KAAKE,KACjC,KAAKA,GAAU,YAAY,KAE3B,MAAM,KAAK,gBACX,KAAKuC,GAAwB,KAAKrC,GAAQ,sBAAsB,CAAC,CAAC,KAAK;CAE3E;CAEA,GAAwB,GAAe;EACrC,IAAMsC,IAAO,KAAKrC;EAClB,AAAI,KAAKL,IAAS,YAAY0C,KAAQA,EAAK,sBAAsB,CAAC,CAAC,QAAQE,IAAQ,KACjF,KAAK,WAAW,OAAO,IAAI,mBAAmB,IAE9C,KAAK,WAAW,OAAO,OAAO,mBAAmB;CAErD;AACF;AA3PG9D,EAAA,CAAA+D,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA1D,EAAA,WAAA,aAAA,KAAA,CAAA,GAKxCL,EAAA,CAAA+D,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA1D,EAAA,WAAA,QAAA,KAAA,CAAA,GAxB3B,IAAAL,EAAA,CAAAgE,EAAa,GACbC,EAAe,CAAA,GAAA5D,CAAA"}
|
|
1
|
+
{"version":3,"file":"select2.js","names":["styles","globalStyles","_decorate","__decorate","select_default","select_global_default","i18nDefaults","Select","Control","_args","#i18nController","I18nController","#observers","#optionObservers","useStyles","Icon","Dropdown","Menu","MenuItem","Tag","#select","#options","#dropdown","#menuItems","#input","#tags","#caret","#placeholderOption","o","#multipleSelectLabel","option","label","#selectValue","nothing","#menu","ifDefined","i","#closeDropdown","#openDropdown","props","#setupCustomSelectUI","getElementUpdate","onChildListMutation","#syncOptionSelectedStates","#disconnectObservers","#setupOverflowListener","#syncSelectValueStates","observer","#overflowObserver","#observedTags","options","appendRootNodeStyle","#setupObservers","#observeTags","onListboxActivate","focusElementTimeout","input","inputWidth","inputEntry","entries","entry","#updateMultipleOverflow","tags","selected","width","property","i18n","scopedRegistry"],"sources":["../../src/select/select.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PropertyValues } from 'lit';\nimport { html, nothing } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n focusElementTimeout,\n onListboxActivate,\n onChildListMutation,\n getElementUpdate,\n appendRootNodeStyle\n} from '@nvidia-elements/core/internal';\nimport { scopedRegistry } from '@nvidia-elements/foundations/internal/decorators';\nimport { useStyles } from '@nvidia-elements/foundations/internal/styles';\nimport { i18n, I18nController, type I18nDefaults } from '@nvidia-elements/foundations/internal/i18n';\nimport { Control } from '@nvidia-elements/core/forms';\nimport { Icon } from '@nvidia-elements/core/icon';\nimport { Menu, MenuItem } from '@nvidia-elements/core/menu';\nimport { Dropdown } from '@nvidia-elements/core/dropdown';\nimport { Tag } from '@nvidia-elements/core/tag';\nimport styles from './select.css?inline';\nimport globalStyles from './select.global.css?inline';\n\nconst i18nDefaults = {\n select: 'select',\n selected: 'selected'\n} satisfies I18nDefaults;\n\n/**\n * @element nve-select\n * @description A select is a control that enables users to select an option from a list of options.\n * @documentation https://nvidia.github.io/elements/docs/elements/select/\n * @since 0.3.0\n * @entrypoint \\@nvidia-elements/core/select\n * @cssprop --padding\n * @cssprop --font-size\n * @cssprop --height\n * @cssprop --background\n * @cssprop --color\n * @cssprop --border-radius\n * @cssprop --border\n * @cssprop --border-bottom\n * @cssprop --cursor\n * @cssprop --font-weight\n * @cssprop --text-align\n * @cssprop --scroll-height\n * @cssprop --width\n * @cssprop --control-width\n * @cssprop --max-width\n * @cssprop --min-width\n * @cssprop --box-shadow\n * @cssprop --max-height\n * @cssprop --text-transform\n * @csspart tag\n * @csspart menu - The dropdown menu element\n * @csspart menu-item - The menu item elements\n * @csspart icon - The icon element\n * @csspart caret - The caret/chevron icon element\n * @csspart dropdown - The dropdown popup element\n * @slot - Select input element\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select\n */\n@i18n<Select>()\n@scopedRegistry()\nexport class Select extends Control {\n static styles = useStyles([...Control.styles, styles]);\n\n static readonly metadata = {\n tag: 'nve-select',\n version: '0.0.0'\n };\n\n static elementDefinitions = {\n [Icon.metadata.tag]: Icon,\n [Dropdown.metadata.tag]: Dropdown,\n [Menu.metadata.tag]: Menu,\n [MenuItem.metadata.tag]: MenuItem,\n [Tag.metadata.tag]: Tag\n };\n\n /** Flat container option applies when embedding the component within another containing element */\n @property({ type: String, reflect: true }) container?: 'flat' | 'inline';\n\n #i18nController: I18nController<this> = new I18nController<this>(this, i18nDefaults);\n\n /** Updates internal string values for internationalization. */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n get #select() {\n return this.input as unknown as HTMLSelectElement;\n }\n\n get #options() {\n return Array.from(this.#select?.options ? this.#select.options : []);\n }\n\n get #dropdown() {\n return this.shadowRoot!.querySelector<Dropdown>(Dropdown.metadata.tag);\n }\n\n get #menuItems() {\n return this.shadowRoot!.querySelectorAll<MenuItem>(MenuItem.metadata.tag);\n }\n\n get #input() {\n return this.shadowRoot!.querySelector<HTMLElement>('[input]');\n }\n\n get #tags() {\n return this.shadowRoot!.querySelector('.tags');\n }\n\n get #caret() {\n return this.shadowRoot!.querySelector<Icon>('[name=\"caret\"]');\n }\n\n get #placeholderOption() {\n return this.#options.find(o => o.selected && o.hidden && o.disabled);\n }\n\n #observers: (MutationObserver | ResizeObserver)[] = [];\n #overflowObserver?: ResizeObserver;\n #observedTags?: Element | null;\n\n get #multipleSelectLabel() {\n const option = this.#placeholderOption;\n const label = option ? option.innerText : `${this.#select.selectedOptions.length} ${this.i18n.selected}`;\n return html`<div class=\"tags-label ${option ? 'placeholder' : ''}\" aria-hidden=\"true\">${label}</div>`;\n }\n\n protected get prefixContent() {\n return this.#select?.multiple && this.#select?.size === 0\n ? html`\n ${this.#multipleSelectLabel}\n <div class=\"tags\">\n ${this.#options\n .filter(o => o.selected && o !== this.#placeholderOption)\n .map(\n o => html`\n <nve-tag part=\"tag\" readonly color=\"gray-slate\" closable .value=${o.value} @click=${() => this.#selectValue(o, false)}>${o.textContent}</nve-tag>`\n )}\n </div>`\n : nothing;\n }\n\n get #menu() {\n return html`\n <nve-menu part=\"menu\" role=\"listbox\" style=\"--width: 100%; --min-width: fit-content\" aria-label=${ifDefined(this.i18n.select)}>\n ${this.#options\n .filter(o => o !== this.#placeholderOption)\n .map(\n (o, i) => html`\n <nve-menu-item part=\"menu-item\" role=\"option\" @click=${() => this.#selectValue(o, !o.selected)} ?selected=${o.selected} ?disabled=${o.disabled} ?hidden=${!!o.hidden} aria-selected=${o.selected}>\n <slot name=\"option-${i + 1}\">\n <nve-icon part=\"icon\" name=\"check\" size=\"sm\" aria-hidden=\"true\"></nve-icon> ${o.innerText}\n </slot>\n </nve-menu-item>`\n )}\n </nve-menu>`;\n }\n\n protected get suffixContent() {\n return this.#select?.size === 0\n ? html`\n <nve-icon name=\"caret\" part=\"caret\" direction=\"down\" size=\"sm\" aria-hidden=\"true\"></nve-icon>\n <nve-dropdown part=\"dropdown\" @close=${this.#closeDropdown} @open=${this.#openDropdown} hidden .anchor=${this.#input} position=\"bottom\">\n ${this.#menu}\n </nve-dropdown>`\n : this.#menu;\n }\n\n async firstUpdated(props: PropertyValues<this>) {\n super.firstUpdated(props);\n await this.updateComplete;\n this.#setupCustomSelectUI();\n }\n\n #syncSelectValueStates() {\n this.#observers.push(\n getElementUpdate(this.#select, 'value', () => this.requestUpdate()),\n onChildListMutation(this.#select, () => this.requestUpdate(), { attributes: true, subtree: true }),\n onChildListMutation(this.#select, () => this.#syncOptionSelectedStates(), { subtree: true })\n );\n }\n\n #optionObservers = new Map<HTMLOptionElement, MutationObserver>();\n\n #setupObservers() {\n this.#disconnectObservers();\n this.#setupOverflowListener();\n this.#syncSelectValueStates();\n this.#syncOptionSelectedStates();\n }\n\n #disconnectObservers() {\n this.#observers.forEach(observer => observer.disconnect());\n this.#observers = [];\n this.#optionObservers.clear();\n this.#overflowObserver = undefined;\n this.#observedTags = undefined;\n }\n\n #syncOptionSelectedStates() {\n const options = new Set(this.#options);\n\n this.#optionObservers.forEach((observer, option) => {\n if (!options.has(option)) {\n observer.disconnect();\n this.#optionObservers.delete(option);\n this.#observers = this.#observers.filter(o => o !== observer);\n }\n });\n\n this.#options.forEach(o => {\n if (!this.#optionObservers.has(o)) {\n const observer = getElementUpdate(o, 'selected', () => this.requestUpdate());\n this.#optionObservers.set(o, observer);\n this.#observers.push(observer);\n }\n });\n }\n\n connectedCallback() {\n super.connectedCallback();\n appendRootNodeStyle(this, globalStyles);\n void this.updateComplete.then(() => {\n if (this.isConnected) {\n this.#setupObservers();\n }\n });\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.#disconnectObservers();\n }\n\n async updated(props: PropertyValues<this>) {\n super.updated(props);\n if (this.#select?.size && this.#select?.size !== 0) {\n this._internals.states.add('size');\n this.style.setProperty('--size', `${this.#select.size}`);\n } else {\n this._internals.states.delete('size');\n this.style.removeProperty('--size');\n }\n\n if (this.#select?.multiple && this.#select?.size === 0) {\n this._internals.states.add('multiple');\n } else {\n this._internals.states.delete('multiple');\n }\n this.#observeTags();\n }\n\n #setupCustomSelectUI() {\n if (this.#select?.size === 0) {\n onListboxActivate(this.#select, () => {\n this.requestUpdate(); // update menu items\n this.#dropdown!.style.setProperty('--min-width', `${this.#input!.getBoundingClientRect().width}px`);\n this.#dropdown!.showPopover();\n focusElementTimeout(this.#menuItems[0] as HTMLElement);\n });\n }\n }\n\n #openDropdown() {\n this.#dropdown!.hidden = false;\n this.#caret!.direction = 'up';\n }\n\n #closeDropdown() {\n this.#dropdown!.hidden = true;\n this.#caret!.direction = 'down';\n }\n\n #setupOverflowListener() {\n const input = this.#input;\n if (!input) return;\n let inputWidth: number | undefined;\n const observer = new ResizeObserver(entries => {\n const inputEntry = entries.find(entry => entry.target === input);\n if (inputEntry) inputWidth = inputEntry.contentRect.width;\n if (this.isConnected && inputWidth !== undefined) this.#updateMultipleOverflow(inputWidth);\n });\n this.#overflowObserver = observer;\n this.#observers.push(observer);\n observer.observe(input);\n this.#observeTags();\n }\n\n #observeTags() {\n const observer = this.#overflowObserver;\n if (!observer) return;\n const tags = this.#tags;\n if (tags === this.#observedTags) return;\n if (this.#observedTags) observer.unobserve(this.#observedTags);\n this.#observedTags = tags;\n if (tags) observer.observe(tags);\n else this._internals.states.delete('multiple-overflow');\n }\n\n async #selectValue(option: HTMLOptionElement, selected: boolean) {\n if (this.#select.multiple || (!this.#select.multiple && option.value !== this.#select.value)) {\n option.selected = selected;\n }\n\n // native select only the first selected option determines the select input value\n if (this.#select.selectedOptions.length < 1) {\n this.#select.value = selected ? option.value : '';\n }\n\n this.#select.dispatchEvent(new Event('input', { bubbles: true }));\n this.#select.dispatchEvent(new Event('change', { bubbles: true }));\n this.requestUpdate();\n\n if (!this.#select.multiple && this.#dropdown) {\n this.#dropdown.hidePopover();\n } else {\n await this.updateComplete;\n this.#updateMultipleOverflow(this.#input!.getBoundingClientRect().width);\n }\n }\n\n #updateMultipleOverflow(width: number) {\n const tags = this.#tags;\n if (this.#select?.multiple && tags && tags.getBoundingClientRect().width > width - 48) {\n this._internals.states.add('multiple-overflow');\n } else {\n this._internals.states.delete('multiple-overflow');\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,IAAMM,IAAe;CACnB,QAAQ;CACR,UAAU;AACZ,GAsCaC,IAAN,cAAqBC,EAAQ;;EAyHf,A,aAtGqB,KAAAE,KAAA,IAAIC,EAAqB,MAAML,CAAY,GAGhD,KAAA,OAAA,KAAKI,GAAgB,MAkCJ,KAAAE,KAAA,CAAC,GAiElC,KAAAC,qBAAA,IAAI,IAAyC;;;EAxHhD,KAAA,SAAAC,EAAU,CAAC,GAAGN,EAAQ,QAAQR,CAAM,CAAC;;;EAE1B,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;;EAE4B,KAAA,qBAAA;IACzBe,EAAK,SAAS,MAAMA;IACpBC,EAAS,SAAS,MAAMA;IACxBC,EAAK,SAAS,MAAMA;IACpBC,EAAS,SAAS,MAAMA;IACxBC,EAA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A,GAAQ,cAAc,IAAI,MAAM,UAAU,EAAE,SAAS,GAAK,CAAC,CAAC,GACjE,KAAK,cAAc,GAEf,CAAC,KAAKA,GAAQ,YAAY,KAAKE,KACjC,KAAKA,GAAU,YAAY,KAE3B,MAAM,KAAK,gBACX,KAAKuC,GAAwB,KAAKrC,GAAQ,sBAAsB,CAAC,CAAC,KAAK;CAE3E;CAEA,GAAwB,GAAe;EACrC,IAAMsC,IAAO,KAAKrC;EAClB,AAAI,KAAKL,IAAS,YAAY0C,KAAQA,EAAK,sBAAsB,CAAC,CAAC,QAAQE,IAAQ,KACjF,KAAK,WAAW,OAAO,IAAI,mBAAmB,IAE9C,KAAK,WAAW,OAAO,OAAO,mBAAmB;CAErD;AACF;AA3PG9D,EAAA,CAAA+D,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAA1D,EAAA,WAAA,aAAA,KAAA,CAAA,GAKxCL,EAAA,CAAA+D,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA1D,EAAA,WAAA,QAAA,KAAA,CAAA,GAxB3B,IAAAL,EAAA,CAAAgE,EAAa,GACbC,EAAe,CAAA,GAAA5D,CAAA"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import n from "
|
|
4
|
-
import r from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import e from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
2
|
+
import t from "./skeleton.js";
|
|
3
|
+
import { attachInternals as n } from "@nvidia-elements/foundations/internal/a11y";
|
|
4
|
+
import { LitElement as r, html as i } from "lit";
|
|
5
|
+
import { property as a } from "lit/decorators/property.js";
|
|
6
|
+
import { useStyles as o } from "@nvidia-elements/foundations/internal/styles";
|
|
7
7
|
// src/skeleton/skeleton.ts
|
|
8
|
-
var s = class extends
|
|
8
|
+
var s = class extends r {
|
|
9
9
|
constructor(...e) {
|
|
10
10
|
super(...e), this.hidden = !1;
|
|
11
11
|
}
|
|
12
12
|
static {
|
|
13
|
-
this.styles =
|
|
13
|
+
this.styles = o([t]);
|
|
14
14
|
}
|
|
15
15
|
static {
|
|
16
16
|
this.metadata = {
|
|
17
17
|
tag: "nve-skeleton",
|
|
18
|
-
version: "2.23.
|
|
18
|
+
version: "2.23.5"
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
|
-
return
|
|
22
|
+
return i`<div internal-host><div class="animate"></div><slot @slotchange="${this.#e}"></slot></div>`;
|
|
23
23
|
}
|
|
24
24
|
connectedCallback() {
|
|
25
|
-
super.connectedCallback(),
|
|
25
|
+
super.connectedCallback(), n(this), this._internals.ariaBusy = "true";
|
|
26
26
|
}
|
|
27
27
|
updated(e) {
|
|
28
28
|
super.updated(e), this._internals.ariaBusy = `${!this.hidden}`;
|
|
@@ -31,13 +31,13 @@ var s = class extends i {
|
|
|
31
31
|
e.target.assignedNodes().some((e) => e.nodeType === Node.ELEMENT_NODE || e.nodeType === Node.TEXT_NODE && e.textContent?.trim() !== "") ? this._internals.states.add("slotted") : this._internals.states.delete("slotted");
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
e([a({
|
|
35
35
|
type: String,
|
|
36
36
|
reflect: !0
|
|
37
|
-
})], s.prototype, "effect", void 0),
|
|
37
|
+
})], s.prototype, "effect", void 0), e([a({
|
|
38
38
|
type: String,
|
|
39
39
|
reflect: !0
|
|
40
|
-
})], s.prototype, "shape", void 0),
|
|
40
|
+
})], s.prototype, "shape", void 0), e([a({
|
|
41
41
|
type: Boolean,
|
|
42
42
|
reflect: !0
|
|
43
43
|
})], s.prototype, "hidden", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton2.js","names":["styles","_decorate","__decorate","skeleton_default","Skeleton","LitElement","_args","useStyles","#slotchange","attachInternals","props","event","node","property"],"sources":["../../src/skeleton/skeleton.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { attachInternals
|
|
1
|
+
{"version":3,"file":"skeleton2.js","names":["styles","_decorate","__decorate","skeleton_default","Skeleton","LitElement","_args","useStyles","#slotchange","attachInternals","props","event","node","property"],"sources":["../../src/skeleton/skeleton.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, LitElement, type PropertyValues } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { attachInternals } from '@nvidia-elements/foundations/internal/a11y';\nimport { useStyles } from '@nvidia-elements/foundations/internal/styles';\nimport styles from './skeleton.css?inline';\n\n/**\n * @element nve-skeleton\n * @description A loading placeholder component that displays animated placeholder shapes while content loads.\n * @documentation https://nvidia.github.io/elements/docs/elements/skeleton/\n * @since 1.44.0\n * @entrypoint \\@nvidia-elements/core/skeleton\n * @slot - Loaded content that replaces the placeholder when provided.\n * @cssprop --background\n * @cssprop --border-radius\n * @cssprop --min-height\n * @aria https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live\n */\nexport class Skeleton extends LitElement {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-skeleton',\n version: '0.0.0'\n };\n\n /** Visual animation style shown while content loads. */\n @property({ type: String, reflect: true }) effect: 'shimmer' | 'pulse';\n\n /** Geometry of the placeholder — rounded corners or a full pill outline. */\n @property({ type: String, reflect: true }) shape: 'round' | 'pill';\n\n /** Hides the skeleton host when `true` and sets `aria-busy` to the inverse visibility state. */\n @property({ type: Boolean, reflect: true }) hidden = false;\n\n /** @private */\n declare _internals: ElementInternals;\n\n render() {\n return html`\n <div internal-host>\n <div class=\"animate\"></div>\n <slot @slotchange=${this.#slotchange}></slot>\n </div>\n `;\n }\n\n connectedCallback() {\n super.connectedCallback();\n attachInternals(this);\n this._internals.ariaBusy = 'true';\n }\n\n updated(props: PropertyValues<this>) {\n super.updated(props);\n this._internals.ariaBusy = `${!this.hidden}`;\n }\n\n #slotchange(event: Event) {\n const target = event.target as HTMLSlotElement;\n const hasContent = target\n .assignedNodes()\n .some(\n node =>\n node.nodeType === Node.ELEMENT_NODE || (node.nodeType === Node.TEXT_NODE && node.textContent?.trim() !== '')\n );\n\n if (hasContent) {\n this._internals.states.add('slotted');\n } else {\n this._internals.states.delete('slotted');\n }\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAaI,IAAb,cAA8BC,EAAW;;EAec,A,aAAA,KAAA,SAAA;;;EAdrC,KAAA,SAAAE,EAAU,CAACP,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;CAcA,SAAS;EACP,OAAO,CAAI,oEAGa,KAAKQ,GAAY;CAG3C;CAEA,oBAAoB;EAGlB,AAFA,MAAM,kBAAkB,GACxBC,EAAgB,IAAI,GACpB,KAAK,WAAW,WAAW;CAC7B;CAEA,QAAQ,GAA6B;EAEnC,AADA,MAAM,QAAQC,CAAK,GACnB,KAAK,WAAW,WAAW,GAAG,CAAC,KAAK;CACtC;CAEA,GAAY,GAAc;EASxB,AAReC,EAAM,OAElB,cAAc,CAAC,CACf,MACC,MACEC,EAAK,aAAa,KAAK,gBAAiBA,EAAK,aAAa,KAAK,aAAaA,EAAK,aAAa,KAAK,MAAM,EAG3G,IACF,KAAK,WAAW,OAAO,IAAI,SAAS,IAEpC,KAAK,WAAW,OAAO,OAAO,SAAS;CAE3C;AACF;AA9CGX,EAAA,CAAAY,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAAT,EAAA,WAAA,UAAA,KAAA,CAAA,GAGxCH,EAAA,CAAAY,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAAT,EAAA,WAAA,SAAA,KAAA,CAAA,GAGxCH,EAAA,CAAAY,EAAS;CAAE,MAAM;CAAS,SAAS;AAAK,CAAC,CAAA,GAAAT,EAAA,WAAA,UAAA,KAAA,CAAA"}
|
|
@@ -32,7 +32,7 @@ export declare class SortButton extends SortButton_base {
|
|
|
32
32
|
/**
|
|
33
33
|
* Updates internal string values for internationalization.
|
|
34
34
|
*/
|
|
35
|
-
i18n: Partial<import("@nvidia-elements/
|
|
35
|
+
i18n: Partial<import("@nvidia-elements/foundations/internal/i18n").I18nStrings & {
|
|
36
36
|
__set: boolean;
|
|
37
37
|
}>;
|
|
38
38
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import n from "
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import e from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
2
|
+
import { Icon as t } from "../icon/icon2.js";
|
|
3
|
+
import n from "./sort-button.js";
|
|
4
|
+
import { LitElement as r, html as i } from "lit";
|
|
5
|
+
import { property as a } from "lit/decorators/property.js";
|
|
6
|
+
import { I18nController as o } from "@nvidia-elements/foundations/internal/i18n";
|
|
7
|
+
import { scopedRegistry as s } from "@nvidia-elements/foundations/internal/decorators";
|
|
8
|
+
import { useStyles as c } from "@nvidia-elements/foundations/internal/styles";
|
|
9
9
|
import { ButtonFormControlMixin as l } from "@nvidia-elements/forms/mixins";
|
|
10
10
|
// src/sort-button/sort-button.ts
|
|
11
11
|
var u = { sort: "sort" }, d = {
|
|
12
12
|
none: "ascending",
|
|
13
13
|
ascending: "descending",
|
|
14
14
|
descending: "none"
|
|
15
|
-
}, f = class extends l(
|
|
15
|
+
}, f = class extends l(r) {
|
|
16
16
|
static {
|
|
17
|
-
this.styles =
|
|
17
|
+
this.styles = c([n]);
|
|
18
18
|
}
|
|
19
19
|
static {
|
|
20
20
|
this.metadata = {
|
|
21
21
|
tag: "nve-sort-button",
|
|
22
|
-
version: "2.23.
|
|
22
|
+
version: "2.23.5"
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
static {
|
|
26
|
-
this.elementDefinitions = { [
|
|
26
|
+
this.elementDefinitions = { [t.metadata.tag]: t };
|
|
27
27
|
}
|
|
28
28
|
#e;
|
|
29
29
|
render() {
|
|
30
|
-
return
|
|
30
|
+
return i`<div internal-host focus-within><nve-icon part="icon" .name="${this.sort === "descending" ? "sort-descending" : "sort-ascending"}" aria-hidden="true"></nve-icon></div>`;
|
|
31
31
|
}
|
|
32
32
|
constructor() {
|
|
33
|
-
super(), this.sort = "none", this.#e = new
|
|
33
|
+
super(), this.sort = "none", this.#e = new o(this, u), this.i18n = this.#e.i18n, this.#t = () => {
|
|
34
34
|
this._internals.ariaLabel = `${this.#e.i18n.sort} ${d[this.sort]}`, this.dispatchEvent(new CustomEvent("sort", {
|
|
35
35
|
detail: {
|
|
36
36
|
value: this.sort,
|
|
@@ -49,10 +49,10 @@ var u = { sort: "sort" }, d = {
|
|
|
49
49
|
}
|
|
50
50
|
#t;
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
e([a({
|
|
53
53
|
type: String,
|
|
54
54
|
reflect: !0
|
|
55
|
-
})], f.prototype, "sort", void 0),
|
|
55
|
+
})], f.prototype, "sort", void 0), e([a({ type: Object })], f.prototype, "i18n", void 0), f = e([s()], f);
|
|
56
56
|
export { f as SortButton };
|
|
57
57
|
|
|
58
58
|
//# sourceMappingURL=sort-button2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-button2.js","names":["styles","_decorate","__decorate","sort_button_default","i18nDefaults","nextSort","SortButton","ButtonFormControlMixin","LitElement","useStyles","Icon","#i18nController","I18nController","#onClick","property","scopedRegistry"],"sources":["../../src/sort-button/sort-button.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 { ButtonFormControlMixin } from '@nvidia-elements/forms/mixins';\nimport { Icon } from '@nvidia-elements/core/icon';\nimport {
|
|
1
|
+
{"version":3,"file":"sort-button2.js","names":["styles","_decorate","__decorate","sort_button_default","i18nDefaults","nextSort","SortButton","ButtonFormControlMixin","LitElement","useStyles","Icon","#i18nController","I18nController","#onClick","property","scopedRegistry"],"sources":["../../src/sort-button/sort-button.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 { ButtonFormControlMixin } from '@nvidia-elements/forms/mixins';\nimport { Icon } from '@nvidia-elements/core/icon';\nimport { scopedRegistry } from '@nvidia-elements/foundations/internal/decorators';\nimport { useStyles } from '@nvidia-elements/foundations/internal/styles';\nimport { I18nController, type I18nDefaults } from '@nvidia-elements/foundations/internal/i18n';\nimport styles from './sort-button.css?inline';\n\nconst i18nDefaults = {\n sort: 'sort'\n} satisfies I18nDefaults;\n\nconst nextSort = {\n none: 'ascending',\n ascending: 'descending',\n descending: 'none'\n};\n\n/**\n * @element nve-sort-button\n * @description A sort button is a control that enables users to sort a list of items in ascending or descending order.\n * @documentation https://nvidia.github.io/elements/docs/elements/sort-button/\n * @since 0.11.0\n * @entrypoint \\@nvidia-elements/core/sort-button\n * @event sort - Dispatched on activation with `detail: { value, next }`, where `value` is the current sort and `next` follows the cycle `none` → `ascending` → `descending` → `none`.\n * @cssprop --width\n * @cssprop --height\n * @cssprop --border-radius\n * @cssprop --color\n * @csspart icon - The icon element\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/\n */\n@scopedRegistry()\nexport class SortButton extends ButtonFormControlMixin(LitElement) {\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-sort-button',\n version: '0.0.0'\n };\n\n static elementDefinitions = {\n [Icon.metadata.tag]: Icon\n };\n\n /**\n * The current sort value, can be ascending, descending, or none.\n */\n @property({ type: String, reflect: true }) sort: 'ascending' | 'descending' | 'none' = 'none';\n\n #i18nController: I18nController<this> = new I18nController<this>(this, i18nDefaults);\n\n /**\n * Updates internal string values for internationalization.\n */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n render() {\n return html`\n <div internal-host focus-within>\n <nve-icon part=\"icon\" .name=${this.sort === 'descending' ? 'sort-descending' : 'sort-ascending'} aria-hidden=\"true\"></nve-icon>\n </div>\n `;\n }\n\n constructor() {\n super();\n this.type = 'button';\n }\n\n connectedCallback() {\n super.connectedCallback();\n this._internals.role = 'spinbutton';\n this.addEventListener('click', this.#onClick);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('click', this.#onClick);\n }\n\n #onClick = () => {\n this._internals.ariaLabel = `${this.#i18nController.i18n.sort} ${nextSort[this.sort]}`;\n this.dispatchEvent(\n new CustomEvent('sort', {\n detail: { value: this.sort, next: nextSort[this.sort] },\n bubbles: true,\n composed: true\n })\n );\n };\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAMI,IAAe,EACnB,MAAM,OACR,GAEMC,IAAW;CACf,MAAM;CACN,WAAW;CACX,YAAY;AACd,GAiBaC,IAAN,cAAyBC,EAAuBC,CAAU,CAAC,CAAC;;EACjD,KAAA,SAAAC,EAAU,CAACT,CAAM,CAAC;;;EAEP,KAAA,WAAA;GACzB,KAAK;GACL,SAAS;EACX;;;EAE4B,KAAA,qBAAA,GACzBU,EAAK,SAAS,MAAMA,EACvB;;CAOA;CAOA,SAAS;EACP,OAAO,CAAI,gEAEuB,KAAK,SAAS,eAAe,oBAAoB,iBAAiB;CAGtG;CAEA,cAAc;EAEZ,AADA,MAAM,GAlB+E,KAAA,OAAA,QAE/C,KAAAC,KAAA,IAAIC,EAAqB,MAAMR,CAAY,GAKhD,KAAA,OAAA,KAAKO,GAAgB,MA0BvC,KAAAE,WAAA;GAEf,AADA,KAAK,WAAW,YAAY,GAAG,KAAKF,GAAgB,KAAK,KAAK,GAAGN,EAAS,KAAK,SAC/E,KAAK,cACH,IAAI,YAAY,QAAQ;IACtB,QAAQ;KAAE,OAAO,KAAK;KAAM,MAAMA,EAAS,KAAK;IAAM;IACtD,SAAS;IACT,UAAU;GACZ,CAAC,CACH;EACF,GAvBE,KAAK,OAAO;CACd;CAEA,oBAAoB;EAGlB,AAFA,MAAM,kBAAkB,GACxB,KAAK,WAAW,OAAO,cACvB,KAAK,iBAAiB,SAAS,KAAKQ,EAAQ;CAC9C;CAEA,uBAAuB;EAErB,AADA,MAAM,qBAAqB,GAC3B,KAAK,oBAAoB,SAAS,KAAKA,EAAQ;CACjD;CAEA;AAUF;AA3CGZ,EAAA,CAAAa,EAAS;CAAE,MAAM;CAAQ,SAAS;AAAK,CAAC,CAAA,GAAAR,EAAA,WAAA,QAAA,KAAA,CAAA,GAOxCL,EAAA,CAAAa,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAR,EAAA,WAAA,QAAA,KAAA,CAAA,GAvB3B,IAAAL,EAAA,CAAAc,EAAe,CAAA,GAAAT,CAAA"}
|
|
@@ -1,127 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import i from "
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { LitElement as
|
|
7
|
-
import { property as
|
|
1
|
+
import { statusStateStyles as e, supportStateStyles as t } from "../internal/styles/index.js";
|
|
2
|
+
import n from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
3
|
+
import { calculateDomain as r, calculateSymbolIndices as i, calculateViewBox as a, toAreaPath as o, toColumnRects as s, toInterpolation as c, toLinePath as l, toPlotPoints as u, toValidData as d, toWinLossRects as f, valueToY as p } from "./sparkline.utils.js";
|
|
4
|
+
import m from "./sparkline.js";
|
|
5
|
+
import { attachInternals as h } from "@nvidia-elements/foundations/internal/a11y";
|
|
6
|
+
import { LitElement as g, html as _, nothing as v, svg as y } from "lit";
|
|
7
|
+
import { property as b } from "lit/decorators/property.js";
|
|
8
|
+
import { useStyles as x } from "@nvidia-elements/foundations/internal/styles";
|
|
8
9
|
import { state as S } from "lit/decorators/state.js";
|
|
9
10
|
// src/sparkline/sparkline.ts
|
|
10
|
-
var C = class extends
|
|
11
|
+
var C = class extends g {
|
|
11
12
|
constructor(...e) {
|
|
12
13
|
super(...e), this.data = [], this.mark = "line", this.interpolation = "linear", this.denoteFirst = !1, this.denoteLast = !1, this.denoteMin = !1, this.denoteMax = !1, this.intervalLength = .6, this.validData = [];
|
|
13
14
|
}
|
|
14
15
|
static {
|
|
15
|
-
this.styles =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
this.styles = x([
|
|
17
|
+
m,
|
|
18
|
+
e,
|
|
19
|
+
t
|
|
19
20
|
]);
|
|
20
21
|
}
|
|
21
22
|
static {
|
|
22
23
|
this.metadata = {
|
|
23
24
|
tag: "nve-sparkline",
|
|
24
|
-
version: "2.23.
|
|
25
|
+
version: "2.23.5"
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
render() {
|
|
28
|
-
return
|
|
29
|
+
return _`<div internal-host>${this.#e()}</div>`;
|
|
29
30
|
}
|
|
30
31
|
connectedCallback() {
|
|
31
|
-
super.connectedCallback(),
|
|
32
|
+
super.connectedCallback(), h(this), this._internals.role = "img";
|
|
32
33
|
}
|
|
33
34
|
willUpdate(e) {
|
|
34
|
-
super.willUpdate(e), e.has("data") && (this.validData =
|
|
35
|
+
super.willUpdate(e), e.has("data") && (this.validData = d(this.data));
|
|
35
36
|
}
|
|
36
37
|
#e() {
|
|
37
|
-
let { width: e, height: t } =
|
|
38
|
+
let { width: e, height: t } = a(this.mark, this.validData.length, this.intervalLength);
|
|
38
39
|
switch (this.mark) {
|
|
39
40
|
case "line":
|
|
40
41
|
case "area":
|
|
41
42
|
case "gradient": return this.#t(e, t);
|
|
42
43
|
case "column": return this.#a(e, t);
|
|
43
44
|
case "winloss": return this.#o(50, e, t);
|
|
44
|
-
default: return this.mark,
|
|
45
|
+
default: return this.mark, v;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
updated(e) {
|
|
48
49
|
super.updated(e);
|
|
49
|
-
let { width: t, height: n } =
|
|
50
|
+
let { width: t, height: n } = a(this.mark, this.validData.length, this.intervalLength), r = t / n, i = Number.isFinite(r) && r > 0 ? r : 1;
|
|
50
51
|
this.style.setProperty("--_aspect-ratio", i.toFixed(4));
|
|
51
52
|
}
|
|
52
53
|
#t(e, t) {
|
|
53
|
-
let n =
|
|
54
|
+
let n = r(this.validData, {
|
|
54
55
|
explicitMin: this.min,
|
|
55
56
|
explicitMax: this.max
|
|
56
57
|
});
|
|
57
|
-
if (!n) return
|
|
58
|
-
let
|
|
58
|
+
if (!n) return v;
|
|
59
|
+
let a = p(0, n), s = n.min < 0 && n.max > 0, d = u(this.validData, n, { width: e }), f = i(this.validData, {
|
|
59
60
|
first: this.denoteFirst,
|
|
60
61
|
last: this.denoteLast,
|
|
61
62
|
min: this.denoteMin,
|
|
62
63
|
max: this.denoteMax
|
|
63
|
-
}),
|
|
64
|
-
return
|
|
64
|
+
}), m = c(this.interpolation), h = l(d, m, e), g = this.mark === "area" || this.mark === "gradient" ? o(d, m, 100) : "";
|
|
65
|
+
return y`<svg viewBox="0 0 ${e} ${t}" preserveAspectRatio="xMidYMid meet" aria-hidden="true">${this.mark === "gradient" ? this.#n(t) : v} ${g.length ? this.mark === "gradient" ? y`<path class="area" d="${g}" style="fill:url(#gradient)"></path>` : y`<path class="area" d="${g}"></path>` : v} ${s ? this.#r(a, e) : v} ${h ? y`<path class="line" d="${h}" vector-effect="non-scaling-stroke"></path>` : v}</svg> ${this.#i(d, f)}`;
|
|
65
66
|
}
|
|
66
67
|
#n(e) {
|
|
67
|
-
return
|
|
68
|
+
return y`<defs><linearGradient id="gradient" x1="0" y1="0" x2="0" y2="${e}" gradientUnits="userSpaceOnUse"><stop offset="0%" style="stop-color:var(--gradient-max-color)"></stop><stop offset="100%" style="stop-color:var(--gradient-min-color)"></stop></linearGradient></defs>`;
|
|
68
69
|
}
|
|
69
70
|
#r(e, t) {
|
|
70
|
-
return
|
|
71
|
+
return y`<line class="zero-line" vector-effect="non-scaling-stroke" x1="0" y1="${e.toFixed(2)}" x2="${t}" y2="${e.toFixed(2)}"></line>`;
|
|
71
72
|
}
|
|
72
73
|
#i(e, t) {
|
|
73
|
-
return e.length === 0 || t.size === 0 ?
|
|
74
|
+
return e.length === 0 || t.size === 0 ? v : _`${Array.from(t).map((t) => {
|
|
74
75
|
let n = e[t];
|
|
75
|
-
if (!n) return
|
|
76
|
+
if (!n) return v;
|
|
76
77
|
let r = `--x: ${n.x.toFixed(2)}; --y: ${n.y.toFixed(2)}`;
|
|
77
|
-
return
|
|
78
|
+
return _`<span style="${r}" class="accent"></span>`;
|
|
78
79
|
})}`;
|
|
79
80
|
}
|
|
80
81
|
#a(e, t) {
|
|
81
|
-
let n =
|
|
82
|
+
let n = r(this.validData, {
|
|
82
83
|
explicitMin: this.min,
|
|
83
84
|
explicitMax: this.max,
|
|
84
85
|
includeZero: !0
|
|
85
86
|
});
|
|
86
|
-
if (!n) return
|
|
87
|
-
let
|
|
88
|
-
return
|
|
87
|
+
if (!n) return v;
|
|
88
|
+
let i = p(0, n), a = n.min < 0 && n.max > 0, o = u(this.validData, n, { width: e }), c = s(o, i, e);
|
|
89
|
+
return y`<svg viewBox="0 0 ${e} ${t}" preserveAspectRatio="xMidYMid meet" aria-hidden="true">${a ? this.#r(i, e) : v} ${c.map((e) => y`<rect class="column" x="${e.x.toFixed(2)}" y="${e.y.toFixed(2)}" width="${e.width.toFixed(2)}" height="${e.height.toFixed(2)}"></rect>`)}</svg>`;
|
|
89
90
|
}
|
|
90
91
|
#o(e, t, n) {
|
|
91
|
-
if (this.validData.length === 0) return
|
|
92
|
-
let r =
|
|
92
|
+
if (this.validData.length === 0) return v;
|
|
93
|
+
let r = f(this.validData, e, {
|
|
93
94
|
width: t,
|
|
94
95
|
height: n
|
|
95
96
|
});
|
|
96
|
-
return
|
|
97
|
+
return y`<svg viewBox="0 0 ${t} ${n}" preserveAspectRatio="xMidYMid meet" aria-hidden="true">${this.#r(e, t)} ${r.map((e) => y`<rect class="${e.className}" x="${e.x.toFixed(2)}" y="${e.y.toFixed(2)}" width="${e.width.toFixed(2)}" height="${e.height.toFixed(2)}"></rect>`)}</svg>`;
|
|
97
98
|
}
|
|
98
99
|
};
|
|
99
|
-
|
|
100
|
+
n([b({ type: Array })], C.prototype, "data", void 0), n([b({ type: String })], C.prototype, "mark", void 0), n([b({ type: String })], C.prototype, "interpolation", void 0), n([b({
|
|
100
101
|
type: String,
|
|
101
102
|
reflect: !0
|
|
102
|
-
})], C.prototype, "status", void 0),
|
|
103
|
+
})], C.prototype, "status", void 0), n([b({
|
|
103
104
|
type: String,
|
|
104
105
|
reflect: !0
|
|
105
|
-
})], C.prototype, "size", void 0),
|
|
106
|
+
})], C.prototype, "size", void 0), n([b({
|
|
106
107
|
type: Boolean,
|
|
107
108
|
attribute: "denote-first",
|
|
108
109
|
reflect: !0
|
|
109
|
-
})], C.prototype, "denoteFirst", void 0),
|
|
110
|
+
})], C.prototype, "denoteFirst", void 0), n([b({
|
|
110
111
|
type: Boolean,
|
|
111
112
|
attribute: "denote-last",
|
|
112
113
|
reflect: !0
|
|
113
|
-
})], C.prototype, "denoteLast", void 0),
|
|
114
|
+
})], C.prototype, "denoteLast", void 0), n([b({
|
|
114
115
|
type: Boolean,
|
|
115
116
|
attribute: "denote-min",
|
|
116
117
|
reflect: !0
|
|
117
|
-
})], C.prototype, "denoteMin", void 0),
|
|
118
|
+
})], C.prototype, "denoteMin", void 0), n([b({
|
|
118
119
|
type: Boolean,
|
|
119
120
|
attribute: "denote-max",
|
|
120
121
|
reflect: !0
|
|
121
|
-
})], C.prototype, "denoteMax", void 0),
|
|
122
|
+
})], C.prototype, "denoteMax", void 0), n([b({
|
|
122
123
|
type: Number,
|
|
123
124
|
attribute: "interval-length"
|
|
124
|
-
})], C.prototype, "intervalLength", void 0),
|
|
125
|
+
})], C.prototype, "intervalLength", void 0), n([b({ type: Number })], C.prototype, "min", void 0), n([b({ type: Number })], C.prototype, "max", void 0), n([S()], C.prototype, "validData", void 0);
|
|
125
126
|
export { C as Sparkline };
|
|
126
127
|
|
|
127
128
|
//# sourceMappingURL=sparkline2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sparkline2.js","names":["styles","_decorate","__decorate","sparkline_default","Sparkline","LitElement","_args","useStyles","statusStateStyles","supportStateStyles","#renderChart","attachInternals","changedProperties","toValidData","calculateViewBox","#renderLineVariant","width","height","#renderColumn","#renderWinLoss","nothing","props","aspectRatio","validAspectRatio","domain","calculateDomain","baselineY","valueToY","drawZeroLine","plotPoints","toPlotPoints","symbolIndices","calculateSymbolIndices","interpolation","toInterpolation","linePath","toLinePath","areaPath","toAreaPath","#renderGradientDef","#renderZeroLine","#renderAccents","position","points","accentIndices","point","index","style","showZeroLine","rects","toColumnRects","rect","toWinLossRects","property","state"],"sources":["../../src/sparkline/sparkline.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PropertyValues, SVGTemplateResult } from 'lit';\nimport { html, LitElement, nothing, svg } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { state } from 'lit/decorators/state.js';\nimport type {\n DataElement,\n Interpolation,\n Point,\n SizeExpanded,\n SparklineMark,\n SupportStatus,\n TaskStatus\n} from '@nvidia-elements/core/internal';\nimport { attachInternals, statusStateStyles, supportStateStyles, useStyles } from '@nvidia-elements/core/internal';\nimport {\n calculateDomain,\n calculateSymbolIndices,\n calculateViewBox,\n PRECISION,\n toAreaPath,\n toColumnRects,\n toInterpolation,\n toLinePath,\n toPlotPoints,\n toValidData,\n toWinLossRects,\n valueToY,\n VIEW_HEIGHT\n} from './sparkline.utils.js';\nimport styles from './sparkline.css?inline';\n\n/**\n * @element nve-sparkline\n * @description A sparkline is a compact, word-sized chart with typographic scale, for data-dense layouts (text, tables, cards, dashboards).\n * @documentation https://nvidia.github.io/elements/docs/elements/sparkline/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/sparkline\n * @cssprop --height - Height (defaults to 1em and scales with parent font-size).\n * @cssprop --line-color\n * @cssprop --line-width\n * @cssprop --fill-color - Color used by area and column marks.\n * @cssprop --gradient-max-color\n * @cssprop --gradient-min-color\n * @cssprop --zero-line-color\n * @cssprop --zero-line-width\n * @cssprop --win-color Color used to represent positive values (wins).\n * @cssprop --loss-color Color used to represent negative values (losses).\n * @cssprop --draw-color Color used to represent zero values (draws / neutral outcomes).\n * @cssprop --symbol-color\n * @cssprop --symbol-border-color\n * @cssprop --symbol-border-width\n * @cssprop --symbol-radius - symbol circle radius in SVG units.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img\n */\nexport class Sparkline extends LitElement implements DataElement<number[]> {\n static styles = useStyles([styles, statusStateStyles, supportStateStyles]);\n\n static readonly metadata = {\n tag: 'nve-sparkline',\n version: '0.0.0'\n };\n\n /** Numeric values representing a data series. */\n @property({ type: Array }) data: number[] = [];\n\n /** Controls the visual representation of data points. */\n @property({ type: String }) mark: SparklineMark = 'line';\n\n /** Controls how the chart connects intermediate values between points in a data series. Defaults to `linear`. */\n @property({ type: String }) interpolation: Interpolation = 'linear';\n\n /** Applies semantic status colors used across Elements status patterns. */\n @property({ type: String, reflect: true }) status?: TaskStatus | SupportStatus;\n\n /** Controls the sparkline size with explicit font-size tokens. Omit to auto-scale with parent font-size (1em). */\n @property({ type: String, reflect: true }) size?: SizeExpanded;\n\n /** Denotes the first data point by rendering a symbol at its position. */\n @property({ type: Boolean, attribute: 'denote-first', reflect: true })\n denoteFirst = false;\n\n /** Denotes the last data point by rendering a symbol at its position. */\n @property({ type: Boolean, attribute: 'denote-last', reflect: true })\n denoteLast = false;\n\n /** Denotes all minimum-value data points by rendering symbols at their positions. */\n @property({ type: Boolean, attribute: 'denote-min', reflect: true })\n denoteMin = false;\n\n /** Denotes all maximum-value data points by rendering symbols at their positions. */\n @property({ type: Boolean, attribute: 'denote-max', reflect: true })\n denoteMax = false;\n\n /** Controls spacing between points in a line, in em (1 = chart height). Defaults to `0.6`. */\n @property({ type: Number, attribute: 'interval-length' }) intervalLength = 0.6;\n\n /** Lower bound for the y-axis domain. When undefined, derives the bound from data. */\n @property({ type: Number }) min?: number;\n\n /** Upper bound for the y-axis domain. When undefined, derives the bound from data. */\n @property({ type: Number }) max?: number;\n\n /** Cached valid numeric values derived from data property. */\n @state() private validData: number[] = [];\n\n /** @private */\n declare _internals: ElementInternals;\n\n render() {\n return html`<div internal-host>${this.#renderChart()}</div>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n attachInternals(this);\n this._internals.role = 'img';\n }\n\n willUpdate(changedProperties: PropertyValues<this>) {\n super.willUpdate(changedProperties);\n\n if (changedProperties.has('data')) {\n this.validData = toValidData(this.data);\n }\n }\n\n #renderChart(): SVGTemplateResult | typeof nothing {\n const { width, height } = calculateViewBox(this.mark, this.validData.length, this.intervalLength);\n\n switch (this.mark) {\n case 'line':\n case 'area':\n case 'gradient':\n return this.#renderLineVariant(width, height);\n case 'column':\n return this.#renderColumn(width, height);\n case 'winloss':\n return this.#renderWinLoss(VIEW_HEIGHT / 2, width, height);\n default:\n const _exhaustiveCheck: never = this.mark;\n return nothing;\n }\n }\n\n updated(props: PropertyValues<this>) {\n super.updated(props);\n\n const { width, height } = calculateViewBox(this.mark, this.validData.length, this.intervalLength);\n const aspectRatio = width / height;\n const validAspectRatio = Number.isFinite(aspectRatio) && aspectRatio > 0 ? aspectRatio : 1;\n this.style.setProperty('--_aspect-ratio', validAspectRatio.toFixed(4));\n }\n\n #renderLineVariant(width: number, height: number) {\n const domain = calculateDomain(this.validData, { explicitMin: this.min, explicitMax: this.max });\n if (!domain) return nothing;\n\n const baselineY = valueToY(0, domain);\n const drawZeroLine = domain.min < 0 && domain.max > 0;\n\n const plotPoints = toPlotPoints(this.validData, domain, { width });\n const symbolIndices = calculateSymbolIndices(this.validData, {\n first: this.denoteFirst,\n last: this.denoteLast,\n min: this.denoteMin,\n max: this.denoteMax\n });\n const interpolation = toInterpolation(this.interpolation);\n\n const linePath = toLinePath(plotPoints, interpolation, width);\n const drawArea = this.mark === 'area' || this.mark === 'gradient';\n const areaPath = drawArea ? toAreaPath(plotPoints, interpolation, VIEW_HEIGHT) : '';\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${this.mark === 'gradient' ? this.#renderGradientDef(height) : nothing}\n\n ${\n areaPath.length\n ? this.mark === 'gradient'\n ? svg`<path class=\"area\" d=${areaPath} style=\"fill: url(#gradient)\"></path>`\n : svg`<path class=\"area\" d=${areaPath}></path>`\n : nothing\n }\n\n ${drawZeroLine ? this.#renderZeroLine(baselineY, width) : nothing}\n\n ${linePath ? svg`<path class=\"line\" d=${linePath} vector-effect=\"non-scaling-stroke\"></path>` : nothing}\n </svg>\n ${this.#renderAccents(plotPoints, symbolIndices)}\n `;\n }\n\n #renderGradientDef(height: number) {\n return svg`\n <defs>\n <linearGradient id=\"gradient\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"${height}\" gradientUnits=\"userSpaceOnUse\">\n <stop offset=\"0%\" style=\"stop-color: var(--gradient-max-color)\"></stop>\n <stop offset=\"100%\" style=\"stop-color: var(--gradient-min-color)\"></stop>\n </linearGradient>\n </defs>\n `;\n }\n\n #renderZeroLine(position: number, width: number) {\n return svg`\n <line\n class=\"zero-line\"\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n y1=\"${position.toFixed(PRECISION)}\"\n x2=\"${width}\"\n y2=\"${position.toFixed(PRECISION)}\">\n </line>\n `;\n }\n\n #renderAccents(points: Point[], accentIndices: Set<number>) {\n if (points.length === 0 || accentIndices.size === 0) return nothing;\n\n return html`\n ${Array.from(accentIndices).map(index => {\n const point = points[index];\n if (!point) return nothing;\n\n const style = `--x: ${point.x.toFixed(PRECISION)}; --y: ${point.y.toFixed(PRECISION)}`;\n return html`\n <span style=${style} class=\"accent\"></span>\n `;\n })}\n `;\n }\n\n #renderColumn(width: number, height: number) {\n const domain = calculateDomain(this.validData, {\n explicitMin: this.min,\n explicitMax: this.max,\n includeZero: true\n });\n if (!domain) return nothing;\n\n const baselineY = valueToY(0, domain);\n const showZeroLine = domain.min < 0 && domain.max > 0;\n const plotPoints = toPlotPoints(this.validData, domain, { width });\n const rects = toColumnRects(plotPoints, baselineY, width);\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${showZeroLine ? this.#renderZeroLine(baselineY, width) : nothing}\n\n ${rects.map(rect => {\n return svg`<rect class=\"column\" x=\"${rect.x.toFixed(PRECISION)}\" y=\"${rect.y.toFixed(PRECISION)}\" width=\"${rect.width.toFixed(PRECISION)}\" height=\"${rect.height.toFixed(PRECISION)}\"></rect>`;\n })}\n </svg>\n `;\n }\n\n #renderWinLoss(baselineY: number, width: number, height: number) {\n if (this.validData.length === 0) return nothing;\n\n const rects = toWinLossRects(this.validData, baselineY, { width, height });\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${this.#renderZeroLine(baselineY, width)}\n\n ${rects.map(rect => {\n return svg`<rect class=\"${rect.className}\" x=\"${rect.x.toFixed(PRECISION)}\" y=\"${rect.y.toFixed(PRECISION)}\" width=\"${rect.width.toFixed(PRECISION)}\" height=\"${rect.height.toFixed(PRECISION)}\"></rect>`;\n })}\n </svg>\n `;\n }\n}\n"],"mappings":";;;;;;;;;AAyDA,IAAaI,IAAb,cA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D,EAAA,WAAA,kBAAA,KAAA,CAAA,GAGvDH,EAAA,CAAAoD,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAjD,EAAA,WAAA,OAAA,KAAA,CAAA,GAGzBH,EAAA,CAAAoD,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAjD,EAAA,WAAA,OAAA,KAAA,CAAA,GAGzBH,EAAA,CAAAqD,EAAM,CAAA,GAAAlD,EAAA,WAAA,aAAA,KAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"sparkline2.js","names":["styles","_decorate","__decorate","sparkline_default","Sparkline","LitElement","_args","useStyles","statusStateStyles","supportStateStyles","#renderChart","attachInternals","changedProperties","toValidData","calculateViewBox","#renderLineVariant","width","height","#renderColumn","#renderWinLoss","nothing","props","aspectRatio","validAspectRatio","domain","calculateDomain","baselineY","valueToY","drawZeroLine","plotPoints","toPlotPoints","symbolIndices","calculateSymbolIndices","interpolation","toInterpolation","linePath","toLinePath","areaPath","toAreaPath","#renderGradientDef","#renderZeroLine","#renderAccents","position","points","accentIndices","point","index","style","showZeroLine","rects","toColumnRects","rect","toWinLossRects","property","state"],"sources":["../../src/sparkline/sparkline.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PropertyValues, SVGTemplateResult } from 'lit';\nimport { html, LitElement, nothing, svg } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { state } from 'lit/decorators/state.js';\nimport type {\n DataElement,\n Interpolation,\n Point,\n SizeExpanded,\n SparklineMark,\n SupportStatus,\n TaskStatus\n} from '@nvidia-elements/core/internal';\nimport { statusStateStyles, supportStateStyles } from '@nvidia-elements/core/internal';\nimport { attachInternals } from '@nvidia-elements/foundations/internal/a11y';\nimport { useStyles } from '@nvidia-elements/foundations/internal/styles';\nimport {\n calculateDomain,\n calculateSymbolIndices,\n calculateViewBox,\n PRECISION,\n toAreaPath,\n toColumnRects,\n toInterpolation,\n toLinePath,\n toPlotPoints,\n toValidData,\n toWinLossRects,\n valueToY,\n VIEW_HEIGHT\n} from './sparkline.utils.js';\nimport styles from './sparkline.css?inline';\n\n/**\n * @element nve-sparkline\n * @description A sparkline is a compact, word-sized chart with typographic scale, for data-dense layouts (text, tables, cards, dashboards).\n * @documentation https://nvidia.github.io/elements/docs/elements/sparkline/\n * @since 0.0.0\n * @entrypoint \\@nvidia-elements/core/sparkline\n * @cssprop --height - Height (defaults to 1em and scales with parent font-size).\n * @cssprop --line-color\n * @cssprop --line-width\n * @cssprop --fill-color - Color used by area and column marks.\n * @cssprop --gradient-max-color\n * @cssprop --gradient-min-color\n * @cssprop --zero-line-color\n * @cssprop --zero-line-width\n * @cssprop --win-color Color used to represent positive values (wins).\n * @cssprop --loss-color Color used to represent negative values (losses).\n * @cssprop --draw-color Color used to represent zero values (draws / neutral outcomes).\n * @cssprop --symbol-color\n * @cssprop --symbol-border-color\n * @cssprop --symbol-border-width\n * @cssprop --symbol-radius - symbol circle radius in SVG units.\n * @aria https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img\n */\nexport class Sparkline extends LitElement implements DataElement<number[]> {\n static styles = useStyles([styles, statusStateStyles, supportStateStyles]);\n\n static readonly metadata = {\n tag: 'nve-sparkline',\n version: '0.0.0'\n };\n\n /** Numeric values representing a data series. */\n @property({ type: Array }) data: number[] = [];\n\n /** Controls the visual representation of data points. */\n @property({ type: String }) mark: SparklineMark = 'line';\n\n /** Controls how the chart connects intermediate values between points in a data series. Defaults to `linear`. */\n @property({ type: String }) interpolation: Interpolation = 'linear';\n\n /** Applies semantic status colors used across Elements status patterns. */\n @property({ type: String, reflect: true }) status?: TaskStatus | SupportStatus;\n\n /** Controls the sparkline size with explicit font-size tokens. Omit to auto-scale with parent font-size (1em). */\n @property({ type: String, reflect: true }) size?: SizeExpanded;\n\n /** Denotes the first data point by rendering a symbol at its position. */\n @property({ type: Boolean, attribute: 'denote-first', reflect: true })\n denoteFirst = false;\n\n /** Denotes the last data point by rendering a symbol at its position. */\n @property({ type: Boolean, attribute: 'denote-last', reflect: true })\n denoteLast = false;\n\n /** Denotes all minimum-value data points by rendering symbols at their positions. */\n @property({ type: Boolean, attribute: 'denote-min', reflect: true })\n denoteMin = false;\n\n /** Denotes all maximum-value data points by rendering symbols at their positions. */\n @property({ type: Boolean, attribute: 'denote-max', reflect: true })\n denoteMax = false;\n\n /** Controls spacing between points in a line, in em (1 = chart height). Defaults to `0.6`. */\n @property({ type: Number, attribute: 'interval-length' }) intervalLength = 0.6;\n\n /** Lower bound for the y-axis domain. When undefined, derives the bound from data. */\n @property({ type: Number }) min?: number;\n\n /** Upper bound for the y-axis domain. When undefined, derives the bound from data. */\n @property({ type: Number }) max?: number;\n\n /** Cached valid numeric values derived from data property. */\n @state() private validData: number[] = [];\n\n /** @private */\n declare _internals: ElementInternals;\n\n render() {\n return html`<div internal-host>${this.#renderChart()}</div>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n attachInternals(this);\n this._internals.role = 'img';\n }\n\n willUpdate(changedProperties: PropertyValues<this>) {\n super.willUpdate(changedProperties);\n\n if (changedProperties.has('data')) {\n this.validData = toValidData(this.data);\n }\n }\n\n #renderChart(): SVGTemplateResult | typeof nothing {\n const { width, height } = calculateViewBox(this.mark, this.validData.length, this.intervalLength);\n\n switch (this.mark) {\n case 'line':\n case 'area':\n case 'gradient':\n return this.#renderLineVariant(width, height);\n case 'column':\n return this.#renderColumn(width, height);\n case 'winloss':\n return this.#renderWinLoss(VIEW_HEIGHT / 2, width, height);\n default:\n const _exhaustiveCheck: never = this.mark;\n return nothing;\n }\n }\n\n updated(props: PropertyValues<this>) {\n super.updated(props);\n\n const { width, height } = calculateViewBox(this.mark, this.validData.length, this.intervalLength);\n const aspectRatio = width / height;\n const validAspectRatio = Number.isFinite(aspectRatio) && aspectRatio > 0 ? aspectRatio : 1;\n this.style.setProperty('--_aspect-ratio', validAspectRatio.toFixed(4));\n }\n\n #renderLineVariant(width: number, height: number) {\n const domain = calculateDomain(this.validData, { explicitMin: this.min, explicitMax: this.max });\n if (!domain) return nothing;\n\n const baselineY = valueToY(0, domain);\n const drawZeroLine = domain.min < 0 && domain.max > 0;\n\n const plotPoints = toPlotPoints(this.validData, domain, { width });\n const symbolIndices = calculateSymbolIndices(this.validData, {\n first: this.denoteFirst,\n last: this.denoteLast,\n min: this.denoteMin,\n max: this.denoteMax\n });\n const interpolation = toInterpolation(this.interpolation);\n\n const linePath = toLinePath(plotPoints, interpolation, width);\n const drawArea = this.mark === 'area' || this.mark === 'gradient';\n const areaPath = drawArea ? toAreaPath(plotPoints, interpolation, VIEW_HEIGHT) : '';\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${this.mark === 'gradient' ? this.#renderGradientDef(height) : nothing}\n\n ${\n areaPath.length\n ? this.mark === 'gradient'\n ? svg`<path class=\"area\" d=${areaPath} style=\"fill: url(#gradient)\"></path>`\n : svg`<path class=\"area\" d=${areaPath}></path>`\n : nothing\n }\n\n ${drawZeroLine ? this.#renderZeroLine(baselineY, width) : nothing}\n\n ${linePath ? svg`<path class=\"line\" d=${linePath} vector-effect=\"non-scaling-stroke\"></path>` : nothing}\n </svg>\n ${this.#renderAccents(plotPoints, symbolIndices)}\n `;\n }\n\n #renderGradientDef(height: number) {\n return svg`\n <defs>\n <linearGradient id=\"gradient\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"${height}\" gradientUnits=\"userSpaceOnUse\">\n <stop offset=\"0%\" style=\"stop-color: var(--gradient-max-color)\"></stop>\n <stop offset=\"100%\" style=\"stop-color: var(--gradient-min-color)\"></stop>\n </linearGradient>\n </defs>\n `;\n }\n\n #renderZeroLine(position: number, width: number) {\n return svg`\n <line\n class=\"zero-line\"\n vector-effect=\"non-scaling-stroke\"\n x1=\"0\"\n y1=\"${position.toFixed(PRECISION)}\"\n x2=\"${width}\"\n y2=\"${position.toFixed(PRECISION)}\">\n </line>\n `;\n }\n\n #renderAccents(points: Point[], accentIndices: Set<number>) {\n if (points.length === 0 || accentIndices.size === 0) return nothing;\n\n return html`\n ${Array.from(accentIndices).map(index => {\n const point = points[index];\n if (!point) return nothing;\n\n const style = `--x: ${point.x.toFixed(PRECISION)}; --y: ${point.y.toFixed(PRECISION)}`;\n return html`\n <span style=${style} class=\"accent\"></span>\n `;\n })}\n `;\n }\n\n #renderColumn(width: number, height: number) {\n const domain = calculateDomain(this.validData, {\n explicitMin: this.min,\n explicitMax: this.max,\n includeZero: true\n });\n if (!domain) return nothing;\n\n const baselineY = valueToY(0, domain);\n const showZeroLine = domain.min < 0 && domain.max > 0;\n const plotPoints = toPlotPoints(this.validData, domain, { width });\n const rects = toColumnRects(plotPoints, baselineY, width);\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${showZeroLine ? this.#renderZeroLine(baselineY, width) : nothing}\n\n ${rects.map(rect => {\n return svg`<rect class=\"column\" x=\"${rect.x.toFixed(PRECISION)}\" y=\"${rect.y.toFixed(PRECISION)}\" width=\"${rect.width.toFixed(PRECISION)}\" height=\"${rect.height.toFixed(PRECISION)}\"></rect>`;\n })}\n </svg>\n `;\n }\n\n #renderWinLoss(baselineY: number, width: number, height: number) {\n if (this.validData.length === 0) return nothing;\n\n const rects = toWinLossRects(this.validData, baselineY, { width, height });\n\n return svg`\n <svg viewBox=\"0 0 ${width} ${height}\" preserveAspectRatio=\"xMidYMid meet\" aria-hidden=\"true\">\n ${this.#renderZeroLine(baselineY, width)}\n\n ${rects.map(rect => {\n return svg`<rect class=\"${rect.className}\" x=\"${rect.x.toFixed(PRECISION)}\" y=\"${rect.y.toFixed(PRECISION)}\" width=\"${rect.width.toFixed(PRECISION)}\" height=\"${rect.height.toFixed(PRECISION)}\"></rect>`;\n })}\n </svg>\n `;\n }\n}\n"],"mappings":";;;;;;;;;;AA2DA,IA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,CAAA,GAAAjD,EAAA,WAAA,kBAAA,KAAA,CAAA,GAGvDH,EAAA,CAAAoD,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAjD,EAAA,WAAA,OAAA,KAAA,CAAA,GAGzBH,EAAA,CAAAoD,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAAjD,EAAA,WAAA,OAAA,KAAA,CAAA,GAGzBH,EAAA,CAAAqD,EAAM,CAAA,GAAAlD,EAAA,WAAA,aAAA,KAAA,CAAA"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { getElementUpdate as e } from "../internal/utils/dom.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import r from "../
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import o from "
|
|
8
|
-
import {
|
|
2
|
+
import t from "../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
3
|
+
import { Icon as n } from "../icon/icon2.js";
|
|
4
|
+
import { Control as r } from "../forms/control/control2.js";
|
|
5
|
+
import i from "./star-rating.js";
|
|
6
|
+
import { html as a } from "lit";
|
|
7
|
+
import { scopedRegistry as o } from "@nvidia-elements/foundations/internal/decorators";
|
|
8
|
+
import { useStyles as s } from "@nvidia-elements/foundations/internal/styles";
|
|
9
9
|
import { state as c } from "lit/decorators/state.js";
|
|
10
10
|
// src/star-rating/star-rating.ts
|
|
11
|
-
var l = class extends
|
|
11
|
+
var l = class extends r {
|
|
12
12
|
constructor(...e) {
|
|
13
13
|
super(...e), this.min = 0, this.max = 5, this.value = 0, this.active = 0, this.precision = .5;
|
|
14
14
|
}
|
|
15
15
|
static {
|
|
16
|
-
this.styles =
|
|
16
|
+
this.styles = s([...r.styles, i]);
|
|
17
17
|
}
|
|
18
18
|
static {
|
|
19
19
|
this.metadata = {
|
|
20
20
|
tag: "nve-star-rating",
|
|
21
|
-
version: "2.23.
|
|
21
|
+
version: "2.23.5"
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
static {
|
|
25
|
-
this.elementDefinitions = { [
|
|
25
|
+
this.elementDefinitions = { [n.metadata.tag]: n };
|
|
26
26
|
}
|
|
27
27
|
firstUpdated(t) {
|
|
28
28
|
super.firstUpdated(t), e(this.input, "max", (e) => {
|
|
@@ -34,9 +34,9 @@ var l = class extends a {
|
|
|
34
34
|
}), this.input.addEventListener("input", () => this.value = this.input.valueAsNumber), this.value = this.input.valueAsNumber;
|
|
35
35
|
}
|
|
36
36
|
get prefixContent() {
|
|
37
|
-
return
|
|
37
|
+
return a`<div aria-hidden="true" class="stars" @mouseleave="${() => this.active = 0}">${Array(this.max).fill("").map((e, t) => {
|
|
38
38
|
let n = t + 1, r = (this.active || this.value) - t;
|
|
39
|
-
return
|
|
39
|
+
return a`<nve-icon part="icon" @click="${() => this.#n(this.#t(t, n))}" @mousemove="${(e) => this.#e(e, t, n)}" name="${r >= 1 ? "star" : r >= .5 ? "star-half" : "star-stroke"}"></nve-icon>`;
|
|
40
40
|
})}</div>`;
|
|
41
41
|
}
|
|
42
42
|
#e(e, t, n) {
|
|
@@ -50,7 +50,7 @@ var l = class extends a {
|
|
|
50
50
|
this.input.valueAsNumber = e === this.value ? 0 : e, this.input.dispatchEvent(new Event("input", { bubbles: !0 })), this.input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
|
|
53
|
+
t([c()], l.prototype, "min", void 0), t([c()], l.prototype, "max", void 0), t([c()], l.prototype, "value", void 0), t([c()], l.prototype, "active", void 0), t([c()], l.prototype, "precision", void 0), l = t([o()], l);
|
|
54
54
|
export { l as StarRating };
|
|
55
55
|
|
|
56
56
|
//# sourceMappingURL=star-rating2.js.map
|