@nvidia-elements/core 0.2.0 → 0.2.1
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 +7 -0
- package/dist/accordion/accordion2.js +4 -4
- package/dist/alert/alert-group2.js +1 -1
- 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/bundles/index.js +1 -1
- package/dist/button/button2.js +1 -1
- package/dist/button-group/button-group2.js +1 -1
- 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.json +5 -0
- package/dist/data.snippets.json +9 -9
- 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/dialog2.js +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/drawer2.js +1 -1
- package/dist/dropdown/dropdown-footer2.js +1 -1
- package/dist/dropdown/dropdown-header2.js +1 -1
- package/dist/dropdown/dropdown2.js +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-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/control2.js +1 -1
- package/dist/forms/control-group/control-group2.js +1 -1
- package/dist/forms/control-message/control-message2.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/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/input2.js +1 -1
- package/dist/internal/controllers/type-native-popover.controller.js +18 -15
- package/dist/internal/controllers/type-native-popover.controller.js.map +1 -1
- package/dist/internal/controllers/type-touch.controller.js +1 -0
- package/dist/internal/controllers/type-touch.controller.js.map +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/notification2.js +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/page2.js +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 +2 -1
- package/dist/preferences-input/preferences-input2.js.map +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/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/toast2.js +1 -1
- package/dist/toggletip/toggletip-footer2.js +1 -1
- package/dist/toggletip/toggletip-header2.js +1 -1
- package/dist/toggletip/toggletip2.js +1 -1
- package/dist/toolbar/toolbar2.js +1 -1
- package/dist/tooltip/tooltip2.js +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 +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-native-popover.controller.js","names":["#nativeTriggers","#updateLegacyTriggers","#setupLegacyTriggers","#setupModalLightDismiss","#toggleFocus","#parseInterestDelay","#interestTimeout","#observers","#pointerdownWithinModal","#legacyHostTrigger","#previousLegacyTrigger"],"sources":["../../../src/internal/controllers/type-native-popover.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { clickOutsideElementBounds, generateId, getAttributeListChanges } from '../utils/dom.js';\nimport { attachInternals } from '../utils/a11y.js';\nimport { focusElement } from '../utils/focus.js';\nimport { getHostAnchor, getHostTrigger, hasOpenPopover } from './type-native-popover.utils.js';\nimport type { PopoverType } from '../types/index.js';\nimport type { InterestEvent } from './type-interest.controller.js';\n\nexport interface NativePopover extends ReactiveElement {\n anchor?: HTMLElement | string;\n closeTimeout?: number;\n popoverType?: PopoverType;\n modal?: boolean;\n popoverDismissible?: boolean;\n _activeTrigger?: HTMLElement;\n _internals?: ElementInternals;\n\n /** @deprecated */\n trigger?: HTMLElement | string;\n /** @deprecated */\n openDelay?: number;\n /** @deprecated */\n behaviorTrigger?: boolean;\n}\n\n/**\n * https://open-ui.org/components/popup.research.explainer\n */\nexport class TypeNativePopoverController<T extends NativePopover> implements ReactiveController {\n get #nativeTriggers(): HTMLElement[] {\n const root = this.host.getRootNode() as HTMLElement;\n const popoverTargetTriggers = Array.from(\n root.querySelectorAll(`[popovertarget=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const commandForTriggers = Array.from(\n root.querySelectorAll(`[commandfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const interestForTriggers = Array.from(\n root.querySelectorAll(`[interestfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n return [...popoverTargetTriggers, ...commandForTriggers, ...interestForTriggers];\n }\n\n constructor(private host: T) {\n this.host.addController(this);\n\n const showPopover = this.host.showPopover;\n this.host.showPopover = (options?: ShowPopoverOptions) => {\n if (this.host.isConnected) {\n // provide legacy fallback for source anchor or trigger if not provided, this can happen if the popover is dynamically created in the DOM without the use of the standard popover api or legacy trigger based api\n let source: HTMLElement | Element | null = options?.source ?? null;\n if (!source) {\n if (this.host.anchor) {\n source = getHostAnchor(this.host);\n } else if (this.host.trigger) {\n source = getHostTrigger(this.host, this.host.trigger);\n } else {\n source = globalThis.document.activeElement;\n }\n }\n\n showPopover.call(this.host, { source: source as HTMLElement });\n }\n };\n }\n\n // eslint-disable-next-line max-lines-per-function\n async hostConnected() {\n attachInternals(this.host);\n this.host.popover = this.host.popoverType ?? null;\n await this.host.updateComplete;\n this.host.setAttribute('nve-popover', '');\n this.#updateLegacyTriggers();\n this.#setupLegacyTriggers(); // eslint-disable-line @typescript-eslint/no-floating-promises\n this.#setupModalLightDismiss();\n this.host.inert = this.host.matches(':not(:popover-open)') && !!this.#nativeTriggers.length;\n\n this.host.addEventListener('beforetoggle', e => {\n if (e.newState === 'open') {\n this.host._internals!.states.add('transition-start');\n }\n });\n\n this.host.addEventListener('toggle', (e: ToggleEvent) => {\n if (this.host.behaviorTrigger) {\n this.host.hidden = e.newState === 'closed';\n }\n\n if (e.newState === 'open' && this.host.closeTimeout) {\n setTimeout(() => this.host.hidePopover(), this.host.closeTimeout);\n }\n\n this.host.inert = this.host.matches(':not(:popover-open)');\n\n if (this.host.modal) {\n this.#toggleFocus(e.newState === 'open', e.target as HTMLElement);\n }\n\n this.host.dispatchEvent(\n new CustomEvent(e.newState === 'open' && e.oldState !== 'open' ? 'open' : 'close', {\n bubbles: true,\n composed: true,\n detail: { trigger: e.source }\n })\n );\n });\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API#creating_declarative_popovers\n this.host.addEventListener('command', ((e: CommandEvent) => {\n if (e.command === 'toggle-popover') {\n this.host.togglePopover({ source: e.source as HTMLElement });\n }\n\n if (e.command === 'hide-popover') {\n this.host.hidePopover();\n }\n\n if (e.command === 'show-popover') {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }) as EventListener);\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using_interest_invokers\n this.host.addEventListener('interest', ((e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n const interestDelayStart = this.host.openDelay ?? this.#parseInterestDelay();\n if (interestDelayStart) {\n this.#interestTimeout = setTimeout(() => {\n if (this.host.isConnected) {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }, interestDelayStart);\n } else {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }\n }) as EventListener);\n\n this.host.addEventListener('loseinterest', ((e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n this.host.hidePopover();\n }\n\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }) as EventListener);\n }\n\n #interestTimeout: ReturnType<typeof setTimeout> | null = null;\n #observers: MutationObserver[] = [];\n #previousLegacyTrigger: HTMLButtonElement | null = null;\n\n async hostUpdated() {\n this.host.popover = this.host.popoverType ?? null;\n this.#updateLegacyTriggers();\n }\n\n hostDisconnected() {\n this.#observers.forEach(observer => observer.disconnect());\n\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }\n\n #parseInterestDelay(): number {\n const style = getComputedStyle(this.host);\n const raw = (style as unknown as { interestDelayStart: string }).interestDelayStart;\n if (!raw) {\n return 0;\n }\n const value = parseFloat(raw);\n return raw.endsWith('ms') ? value : value * 1000;\n }\n\n #pointerdownWithinModal = false;\n\n #setupModalLightDismiss() {\n this.host.addEventListener('pointerdown', e => {\n if (this.host.modal && this.host.matches(':popover-open')) {\n this.#pointerdownWithinModal = clickOutsideElementBounds(e, this.host);\n }\n });\n\n this.host.addEventListener('pointerup', e => {\n if (\n this.#pointerdownWithinModal &&\n this.host.popoverDismissible &&\n this.host.modal &&\n this.host.matches(':popover-open') &&\n !hasOpenPopover(this.host) &&\n clickOutsideElementBounds(e, this.host)\n ) {\n this.host.hidePopover();\n }\n });\n }\n\n get #legacyHostTrigger(): HTMLElement | null {\n return this.host.trigger ? (getHostTrigger(this.host, this.host.trigger) as HTMLButtonElement) : null;\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n async #setupLegacyTriggers() {\n await new Promise(r => requestAnimationFrame(r));\n\n // setup hidden updates for legacy triggers\n this.#observers.push(\n getAttributeListChanges(this.host, ['hidden'], () => {\n if (this.host.isConnected && !this.host.hidden && !this.host.matches(':popover-open')) {\n this.host.showPopover();\n }\n\n if (this.host.isConnected && this.host.hidden && this.host.matches(':popover-open')) {\n this.host.hidePopover();\n }\n })\n );\n\n // determine if popover is open by default\n if (\n this.host.isConnected &&\n !this.#nativeTriggers.length &&\n !this.host.hidden &&\n !this.host.matches(':popover-open')\n ) {\n this.host.popover = 'manual';\n this.host.showPopover();\n }\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n #updateLegacyTriggers() {\n const trigger = this.#legacyHostTrigger as HTMLButtonElement;\n\n // Clean up previous trigger if it changed\n if (this.#previousLegacyTrigger && this.#previousLegacyTrigger !== trigger) {\n this.#previousLegacyTrigger.popoverTargetElement = null;\n this.#previousLegacyTrigger.removeAttribute('popovertarget');\n }\n\n // if not a hint type setup native popovertarget\n if (trigger) {\n if (this.host.popoverType === 'hint') {\n trigger.addEventListener('mouseenter', () => this.host.showPopover({ source: trigger as HTMLElement }));\n trigger.addEventListener('mouseleave', () => this.host.hidePopover());\n trigger.addEventListener('focusout', () => this.host.hidePopover());\n } else {\n this.host.id = this.host.id ? this.host.id : generateId();\n trigger.popoverTargetElement = this.host;\n trigger.setAttribute('popovertarget', this.host.id);\n }\n this.#previousLegacyTrigger = trigger;\n }\n }\n\n #toggleFocus(open: boolean, target: HTMLElement) {\n if (open) {\n // only focus popover if not the active element and not containing the active element already\n if ((this.host.getRootNode() as Document).activeElement !== this.host && !this.host.shadowRoot!.activeElement) {\n focusElement(this.host);\n }\n } else {\n focusElement(target);\n }\n }\n}\n"],"mappings":";;;;;AA+BA,IAAa,IAAb,MAAgG;CAC9F,IAAIA,KAAiC;EACnC,IAAM,IAAO,KAAK,KAAK,YAAY,GAC7B,IAAwB,MAAM,KAClC,EAAK,iBAAiB,mBAAmB,IAAI,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,GAAG,CACnG,GAEM,IAAqB,MAAM,KAC/B,EAAK,iBAAiB,gBAAgB,IAAI,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,GAAG,CAChG,GA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UACtB,CAAC,KAAK,KAAK,UACX,CAAC,KAAK,KAAK,QAAQ,eAAe,MAElC,KAAK,KAAK,UAAU,UACpB,KAAK,KAAK,YAAY;CAE1B;CAKA,KAAwB;EACtB,IAAM,IAAU,KAAKS;EASrB,AANI,KAAKC,MAA0B,KAAKA,OAA2B,MACjE,KAAKA,GAAuB,uBAAuB,MACnD,KAAKA,GAAuB,gBAAgB,eAAe,IAIzD,MACE,KAAK,KAAK,gBAAgB,UAC5B,EAAQ,iBAAiB,oBAAoB,KAAK,KAAK,YAAY,EAAE,QAAQ,EAAuB,CAAC,CAAC,GACtG,EAAQ,iBAAiB,oBAAoB,KAAK,KAAK,YAAY,CAAC,GACpE,EAAQ,iBAAiB,kBAAkB,KAAK,KAAK,YAAY,CAAC,MAElE,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,EAAW,GACxD,EAAQ,uBAAuB,KAAK,MACpC,EAAQ,aAAa,iBAAiB,KAAK,KAAK,EAAE,IAEpD,KAAKA,KAAyB;CAElC;CAEA,GAAa,GAAe,GAAqB;EAC/C,AAAI,IAEG,KAAK,KAAK,YAAY,EAAe,kBAAkB,KAAK,QAAQ,CAAC,KAAK,KAAK,WAAY,iBAC9F,EAAa,KAAK,IAAI,IAGxB,EAAa,CAAM;CAEvB;AACF"}
|
|
1
|
+
{"version":3,"file":"type-native-popover.controller.js","names":["#nativeTriggers","#updateLegacyTriggers","#setupLegacyTriggers","#setupModalLightDismiss","#clearInterestTimeout","#toggleFocus","#parseInterestDelay","#interestTimeout","#observers","#pointerdownWithinModal","#legacyHostTrigger","#previousLegacyTrigger"],"sources":["../../../src/internal/controllers/type-native-popover.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveController, ReactiveElement } from 'lit';\nimport { clickOutsideElementBounds, generateId, getAttributeListChanges } from '../utils/dom.js';\nimport { attachInternals } from '../utils/a11y.js';\nimport { focusElement } from '../utils/focus.js';\nimport { getHostAnchor, getHostTrigger, hasOpenPopover } from './type-native-popover.utils.js';\nimport type { PopoverType } from '../types/index.js';\nimport type { InterestEvent } from './type-interest.controller.js';\n\nexport interface NativePopover extends ReactiveElement {\n anchor?: HTMLElement | string;\n closeTimeout?: number;\n popoverType?: PopoverType;\n modal?: boolean;\n popoverDismissible?: boolean;\n _activeTrigger?: HTMLElement;\n _internals?: ElementInternals;\n\n /** @deprecated */\n trigger?: HTMLElement | string;\n /** @deprecated */\n openDelay?: number;\n /** @deprecated */\n behaviorTrigger?: boolean;\n}\n\n/**\n * https://open-ui.org/components/popup.research.explainer\n */\nexport class TypeNativePopoverController<T extends NativePopover> implements ReactiveController {\n get #nativeTriggers(): HTMLElement[] {\n const root = this.host.getRootNode() as HTMLElement;\n const popoverTargetTriggers = Array.from(\n root.querySelectorAll(`[popovertarget=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const commandForTriggers = Array.from(\n root.querySelectorAll(`[commandfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n const interestForTriggers = Array.from(\n root.querySelectorAll(`[interestfor=\"${CSS.escape ? CSS.escape(this.host.id) : this.host.id}\"]`)\n ) as HTMLElement[];\n\n return [...popoverTargetTriggers, ...commandForTriggers, ...interestForTriggers];\n }\n\n constructor(private host: T) {\n this.host.addController(this);\n\n const showPopover = this.host.showPopover;\n this.host.showPopover = (options?: ShowPopoverOptions) => {\n if (this.host.isConnected) {\n // provide legacy fallback for source anchor or trigger if not provided, this can happen if the popover is dynamically created in the DOM without the use of the standard popover api or legacy trigger based api\n let source: HTMLElement | Element | null = options?.source ?? null;\n if (!source) {\n if (this.host.anchor) {\n source = getHostAnchor(this.host);\n } else if (this.host.trigger) {\n source = getHostTrigger(this.host, this.host.trigger);\n } else {\n source = globalThis.document.activeElement;\n }\n }\n\n showPopover.call(this.host, { source: source as HTMLElement });\n }\n };\n }\n\n // eslint-disable-next-line max-lines-per-function\n async hostConnected() {\n attachInternals(this.host);\n this.host.popover = this.host.popoverType ?? null;\n await this.host.updateComplete;\n this.host.setAttribute('nve-popover', '');\n this.#updateLegacyTriggers();\n this.#setupLegacyTriggers(); // eslint-disable-line @typescript-eslint/no-floating-promises\n this.#setupModalLightDismiss();\n this.host.inert = this.host.matches(':not(:popover-open)') && !!this.#nativeTriggers.length;\n\n this.host.addEventListener('beforetoggle', e => {\n if (e.newState === 'open') {\n this.host._internals!.states.add('transition-start');\n }\n });\n\n this.host.addEventListener('toggle', (e: ToggleEvent) => {\n if (this.host.behaviorTrigger) {\n this.host.hidden = e.newState === 'closed';\n }\n\n if (e.newState === 'open' && this.host.closeTimeout) {\n setTimeout(() => this.host.hidePopover(), this.host.closeTimeout);\n }\n\n if (e.newState === 'closed') {\n this.#clearInterestTimeout();\n }\n\n this.host.inert = this.host.matches(':not(:popover-open)');\n\n if (this.host.modal) {\n this.#toggleFocus(e.newState === 'open', e.target as HTMLElement);\n }\n\n this.host.dispatchEvent(\n new CustomEvent(e.newState === 'open' && e.oldState !== 'open' ? 'open' : 'close', {\n bubbles: true,\n composed: true,\n detail: { trigger: e.source }\n })\n );\n });\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API#creating_declarative_popovers\n this.host.addEventListener('command', ((e: CommandEvent) => {\n if (e.command === 'toggle-popover') {\n this.host.togglePopover({ source: e.source as HTMLElement });\n }\n\n if (e.command === 'hide-popover') {\n this.host.hidePopover();\n this.#clearInterestTimeout();\n }\n\n if (e.command === 'show-popover') {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }) as EventListener);\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using_interest_invokers\n this.host.addEventListener('interest', ((e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n const interestDelayStart = this.host.openDelay ?? this.#parseInterestDelay();\n if (interestDelayStart) {\n this.#interestTimeout = setTimeout(() => {\n if (this.host.isConnected) {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }, interestDelayStart);\n } else {\n this.host.showPopover({ source: e.source as HTMLElement });\n }\n }\n }) as EventListener);\n\n this.host.addEventListener('loseinterest', ((e: InterestEvent) => {\n const isCustomElement = e.source?.localName.includes('-');\n if (isCustomElement) {\n this.host.hidePopover();\n }\n\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }) as EventListener);\n }\n\n #interestTimeout: ReturnType<typeof setTimeout> | null = null;\n #observers: MutationObserver[] = [];\n #previousLegacyTrigger: HTMLButtonElement | null = null;\n\n async hostUpdated() {\n this.host.popover = this.host.popoverType ?? null;\n this.#updateLegacyTriggers();\n }\n\n hostDisconnected() {\n this.#observers.forEach(observer => observer.disconnect());\n this.#clearInterestTimeout();\n }\n\n #clearInterestTimeout() {\n if (this.#interestTimeout) {\n clearTimeout(this.#interestTimeout);\n this.#interestTimeout = null;\n }\n }\n\n #parseInterestDelay(): number {\n const style = getComputedStyle(this.host);\n const raw = (style as unknown as { interestDelayStart: string }).interestDelayStart;\n if (!raw) {\n return 0;\n }\n const value = parseFloat(raw);\n return raw.endsWith('ms') ? value : value * 1000;\n }\n\n #pointerdownWithinModal = false;\n\n #setupModalLightDismiss() {\n this.host.addEventListener('pointerdown', e => {\n if (this.host.modal && this.host.matches(':popover-open')) {\n this.#pointerdownWithinModal = clickOutsideElementBounds(e, this.host);\n }\n });\n\n this.host.addEventListener('pointerup', e => {\n if (\n this.#pointerdownWithinModal &&\n this.host.popoverDismissible &&\n this.host.modal &&\n this.host.matches(':popover-open') &&\n !hasOpenPopover(this.host) &&\n clickOutsideElementBounds(e, this.host)\n ) {\n this.host.hidePopover();\n }\n });\n }\n\n get #legacyHostTrigger(): HTMLElement | null {\n return this.host.trigger ? (getHostTrigger(this.host, this.host.trigger) as HTMLButtonElement) : null;\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n async #setupLegacyTriggers() {\n await new Promise(r => requestAnimationFrame(r));\n\n // setup hidden updates for legacy triggers\n this.#observers.push(\n getAttributeListChanges(this.host, ['hidden'], () => {\n if (this.host.isConnected && !this.host.hidden && !this.host.matches(':popover-open')) {\n this.host.showPopover();\n }\n\n if (this.host.isConnected && this.host.hidden && this.host.matches(':popover-open')) {\n this.host.hidePopover();\n }\n })\n );\n\n // determine if popover is open by default\n if (\n this.host.isConnected &&\n !this.#nativeTriggers.length &&\n !this.host.hidden &&\n !this.host.matches(':popover-open')\n ) {\n this.host.popover = 'manual';\n this.host.showPopover();\n }\n }\n\n /**\n * @deprecated Legacy behavior that allows popovers to show as open by default when using the legacy trigger based api\n */\n #updateLegacyTriggers() {\n const trigger = this.#legacyHostTrigger as HTMLButtonElement;\n\n // Clean up previous trigger if it changed\n if (this.#previousLegacyTrigger && this.#previousLegacyTrigger !== trigger) {\n this.#previousLegacyTrigger.popoverTargetElement = null;\n this.#previousLegacyTrigger.removeAttribute('popovertarget');\n }\n\n // if not a hint type setup native popovertarget\n if (trigger) {\n if (this.host.popoverType === 'hint') {\n trigger.addEventListener('mouseenter', () => this.host.showPopover({ source: trigger as HTMLElement }));\n trigger.addEventListener('mouseleave', () => this.host.hidePopover());\n trigger.addEventListener('focusout', () => this.host.hidePopover());\n } else {\n this.host.id = this.host.id ? this.host.id : generateId();\n trigger.popoverTargetElement = this.host;\n trigger.setAttribute('popovertarget', this.host.id);\n }\n this.#previousLegacyTrigger = trigger;\n }\n }\n\n #toggleFocus(open: boolean, target: HTMLElement) {\n if (open) {\n // only focus popover if not the active element and not containing the active element already\n if ((this.host.getRootNode() as Document).activeElement !== this.host && !this.host.shadowRoot!.activeElement) {\n focusElement(this.host);\n }\n } else {\n focusElement(target);\n }\n }\n}\n"],"mappings":";;;;;AA+BA,IAAa,IAAb,MAAgG;CAC9F,IAAIA,KAAiC;EACnC,IAAM,IAAO,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|
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
42
|
#i = (e) => {
|
|
43
|
+
/* istanbul ignore else -- #start registers #end only after setting #startPosition. */
|
|
43
44
|
this.#e && (globalThis.document.removeEventListener("pointerup", this.#i, !1), globalThis.document.removeEventListener("pointermove", this.#r, !1), this.host.dispatchEvent(new t("nve-touch-end", this.#a(e))), this.host.releasePointerCapture(this.#t), this.#t = null);
|
|
44
45
|
};
|
|
45
46
|
#a(t) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-touch.controller.js","names":["#start","#end","#move","#startPosition","#pointerId","#getCoordinatesFromPointerEvent"],"sources":["../../../src/internal/controllers/type-touch.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveElement, ReactiveController } from 'lit';\nimport type { LegacyDecoratorTarget, OffsetPoint, Point } from '../types/index.js';\nimport { getDifference } from '../utils/objects.js';\n\nexport class NveTouchEvent extends Event {\n x: number;\n y: number;\n offsetX: number;\n offsetY: number;\n\n constructor(event: 'nve-touch-start' | 'nve-touch-move' | 'nve-touch-end', point: Point & OffsetPoint) {\n super(event);\n this.x = point.x;\n this.y = point.y;\n this.offsetX = point.offsetX;\n this.offsetY = point.offsetY;\n }\n}\n\n/**\n * @event nve-touch-start\n * @event nve-touch-move\n * @event nve-touch-end\n */\nexport function typeTouch<T extends ReactiveElement>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => target.addInitializer!((instance: T) => new TypeTouchController(instance));\n}\n\nexport class TypeTouchController<T extends ReactiveElement> implements ReactiveController {\n #startPosition: Point;\n #pointerId: number;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('pointerdown', this.#start);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('pointerdown', this.#start);\n globalThis.document.removeEventListener('pointerup', this.#end);\n globalThis.document.removeEventListener('pointermove', this.#move);\n }\n\n #start = (e: PointerEvent) => {\n if (e.composedPath().find(el => el === this.host)) {\n this.#startPosition = { x: e.clientX, y: e.clientY };\n this.#pointerId = e.pointerId;\n this.host.setPointerCapture(this.#pointerId);\n globalThis.document.addEventListener('pointerup', this.#end);\n globalThis.document.addEventListener('pointermove', this.#move);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-start', { ...this.#startPosition, offsetX: 0, offsetY: 0 }));\n }\n };\n\n #move = (e: PointerEvent) => {\n requestAnimationFrame(() => {\n const point = this.#getCoordinatesFromPointerEvent(e);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-move', point));\n this.#startPosition = { x: e.clientX, y: e.clientY };\n });\n };\n\n #end = (e: PointerEvent) => {\n if (this.#startPosition) {\n globalThis.document.removeEventListener('pointerup', this.#end, false);\n globalThis.document.removeEventListener('pointermove', this.#move, false);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-end', this.#getCoordinatesFromPointerEvent(e)));\n this.host.releasePointerCapture(this.#pointerId);\n this.#pointerId = null as unknown as number;\n }\n };\n\n #getCoordinatesFromPointerEvent(e: PointerEvent) {\n const value = {\n offsetX: getDifference(this.#startPosition.x, e.clientX),\n offsetY: getDifference(this.#startPosition.y, e.clientY),\n x: e.clientX,\n y: e.clientY\n };\n return value;\n }\n}\n"],"mappings":";;AAOA,IAAa,IAAb,cAAmC,MAAM;CAMvC,YAAY,GAA+D,GAA4B;EAKrG,AAJA,MAAM,CAAK,GACX,KAAK,IAAI,EAAM,GACf,KAAK,IAAI,EAAM,GACf,KAAK,UAAU,EAAM,SACrB,KAAK,UAAU,EAAM;CACvB;AACF;AAOA,SAAgB,IAAuD;CACrE,QAAQ,MAAkC,EAAO,gBAAiB,MAAgB,IAAI,EAAoB,CAAQ,CAAC;AACrH;AAEA,IAAa,IAAb,MAA0F;CACxF;CACA;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,KAAK,KAAK,iBAAiB,eAAe,KAAKA,EAAM;CACvD;CAEA,mBAAmB;EAGjB,AAFA,KAAK,KAAK,oBAAoB,eAAe,KAAKA,EAAM,GACxD,WAAW,SAAS,oBAAoB,aAAa,KAAKC,EAAI,GAC9D,WAAW,SAAS,oBAAoB,eAAe,KAAKC,EAAK;CACnE;CAEA,MAAU,MAAoB;EAC5B,AAAI,EAAE,aAAa,EAAE,MAAK,MAAM,MAAO,KAAK,IAAI,MAC9C,KAAKC,KAAiB;GAAE,GAAG,EAAE;GAAS,GAAG,EAAE;EAAQ,GACnD,KAAKC,KAAa,EAAE,WACpB,KAAK,KAAK,kBAAkB,KAAKA,EAAU,GAC3C,WAAW,SAAS,iBAAiB,aAAa,KAAKH,EAAI,GAC3D,WAAW,SAAS,iBAAiB,eAAe,KAAKC,EAAK,GAC9D,KAAK,KAAK,cAAc,IAAI,EAAc,mBAAmB;GAAE,GAAG,KAAKC;GAAgB,SAAS;GAAG,SAAS;EAAE,CAAC,CAAC;CAEpH;CAEA,MAAS,MAAoB;EAC3B,4BAA4B;GAC1B,IAAM,IAAQ,KAAKE,GAAgC,CAAC;GAEpD,AADA,KAAK,KAAK,cAAc,IAAI,EAAc,kBAAkB,CAAK,CAAC,GAClE,KAAKF,KAAiB;IAAE,GAAG,EAAE;IAAS,GAAG,EAAE;GAAQ;EACrD,CAAC;CACH;CAEA,MAAQ,MAAoB
|
|
1
|
+
{"version":3,"file":"type-touch.controller.js","names":["#start","#end","#move","#startPosition","#pointerId","#getCoordinatesFromPointerEvent"],"sources":["../../../src/internal/controllers/type-touch.controller.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { ReactiveElement, ReactiveController } from 'lit';\nimport type { LegacyDecoratorTarget, OffsetPoint, Point } from '../types/index.js';\nimport { getDifference } from '../utils/objects.js';\n\nexport class NveTouchEvent extends Event {\n x: number;\n y: number;\n offsetX: number;\n offsetY: number;\n\n constructor(event: 'nve-touch-start' | 'nve-touch-move' | 'nve-touch-end', point: Point & OffsetPoint) {\n super(event);\n this.x = point.x;\n this.y = point.y;\n this.offsetX = point.offsetX;\n this.offsetY = point.offsetY;\n }\n}\n\n/**\n * @event nve-touch-start\n * @event nve-touch-move\n * @event nve-touch-end\n */\nexport function typeTouch<T extends ReactiveElement>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => target.addInitializer!((instance: T) => new TypeTouchController(instance));\n}\n\nexport class TypeTouchController<T extends ReactiveElement> implements ReactiveController {\n #startPosition: Point;\n #pointerId: number;\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n hostConnected() {\n this.host.addEventListener('pointerdown', this.#start);\n }\n\n hostDisconnected() {\n this.host.removeEventListener('pointerdown', this.#start);\n globalThis.document.removeEventListener('pointerup', this.#end);\n globalThis.document.removeEventListener('pointermove', this.#move);\n }\n\n #start = (e: PointerEvent) => {\n if (e.composedPath().find(el => el === this.host)) {\n this.#startPosition = { x: e.clientX, y: e.clientY };\n this.#pointerId = e.pointerId;\n this.host.setPointerCapture(this.#pointerId);\n globalThis.document.addEventListener('pointerup', this.#end);\n globalThis.document.addEventListener('pointermove', this.#move);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-start', { ...this.#startPosition, offsetX: 0, offsetY: 0 }));\n }\n };\n\n #move = (e: PointerEvent) => {\n requestAnimationFrame(() => {\n const point = this.#getCoordinatesFromPointerEvent(e);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-move', point));\n this.#startPosition = { x: e.clientX, y: e.clientY };\n });\n };\n\n #end = (e: PointerEvent) => {\n /* istanbul ignore else -- #start registers #end only after setting #startPosition. */\n if (this.#startPosition) {\n globalThis.document.removeEventListener('pointerup', this.#end, false);\n globalThis.document.removeEventListener('pointermove', this.#move, false);\n this.host.dispatchEvent(new NveTouchEvent('nve-touch-end', this.#getCoordinatesFromPointerEvent(e)));\n this.host.releasePointerCapture(this.#pointerId);\n this.#pointerId = null as unknown as number;\n }\n };\n\n #getCoordinatesFromPointerEvent(e: PointerEvent) {\n const value = {\n offsetX: getDifference(this.#startPosition.x, e.clientX),\n offsetY: getDifference(this.#startPosition.y, e.clientY),\n x: e.clientX,\n y: e.clientY\n };\n return value;\n }\n}\n"],"mappings":";;AAOA,IAAa,IAAb,cAAmC,MAAM;CAMvC,YAAY,GAA+D,GAA4B;EAKrG,AAJA,MAAM,CAAK,GACX,KAAK,IAAI,EAAM,GACf,KAAK,IAAI,EAAM,GACf,KAAK,UAAU,EAAM,SACrB,KAAK,UAAU,EAAM;CACvB;AACF;AAOA,SAAgB,IAAuD;CACrE,QAAQ,MAAkC,EAAO,gBAAiB,MAAgB,IAAI,EAAoB,CAAQ,CAAC;AACrH;AAEA,IAAa,IAAb,MAA0F;CACxF;CACA;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,gBAAgB;EACd,KAAK,KAAK,iBAAiB,eAAe,KAAKA,EAAM;CACvD;CAEA,mBAAmB;EAGjB,AAFA,KAAK,KAAK,oBAAoB,eAAe,KAAKA,EAAM,GACxD,WAAW,SAAS,oBAAoB,aAAa,KAAKC,EAAI,GAC9D,WAAW,SAAS,oBAAoB,eAAe,KAAKC,EAAK;CACnE;CAEA,MAAU,MAAoB;EAC5B,AAAI,EAAE,aAAa,EAAE,MAAK,MAAM,MAAO,KAAK,IAAI,MAC9C,KAAKC,KAAiB;GAAE,GAAG,EAAE;GAAS,GAAG,EAAE;EAAQ,GACnD,KAAKC,KAAa,EAAE,WACpB,KAAK,KAAK,kBAAkB,KAAKA,EAAU,GAC3C,WAAW,SAAS,iBAAiB,aAAa,KAAKH,EAAI,GAC3D,WAAW,SAAS,iBAAiB,eAAe,KAAKC,EAAK,GAC9D,KAAK,KAAK,cAAc,IAAI,EAAc,mBAAmB;GAAE,GAAG,KAAKC;GAAgB,SAAS;GAAG,SAAS;EAAE,CAAC,CAAC;CAEpH;CAEA,MAAS,MAAoB;EAC3B,4BAA4B;GAC1B,IAAM,IAAQ,KAAKE,GAAgC,CAAC;GAEpD,AADA,KAAK,KAAK,cAAc,IAAI,EAAc,kBAAkB,CAAK,CAAC,GAClE,KAAKF,KAAiB;IAAE,GAAG,EAAE;IAAS,GAAG,EAAE;GAAQ;EACrD,CAAC;CACH;CAEA,MAAQ,MAAoB;;EAE1B,AAAI,KAAKA,OACP,WAAW,SAAS,oBAAoB,aAAa,KAAKF,IAAM,EAAK,GACrE,WAAW,SAAS,oBAAoB,eAAe,KAAKC,IAAO,EAAK,GACxE,KAAK,KAAK,cAAc,IAAI,EAAc,iBAAiB,KAAKG,GAAgC,CAAC,CAAC,CAAC,GACnG,KAAK,KAAK,sBAAsB,KAAKD,EAAU,GAC/C,KAAKA,KAAa;CAEtB;CAEA,GAAgC,GAAiB;EAO/C,OAAO;GALL,SAAS,EAAc,KAAKD,GAAe,GAAG,EAAE,OAAO;GACvD,SAAS,EAAc,KAAKA,GAAe,GAAG,EAAE,OAAO;GACvD,GAAG,EAAE;GACL,GAAG,EAAE;EAEA;CACT;AACF"}
|
|
@@ -19,7 +19,7 @@ var a = class {
|
|
|
19
19
|
i18nRegistry: {},
|
|
20
20
|
audit: {}
|
|
21
21
|
}
|
|
22
|
-
}, globalThis.NVE_ELEMENTS.state.versions = Array.from(new Set([...globalThis.NVE_ELEMENTS.state.versions, "0.2.
|
|
22
|
+
}, globalThis.NVE_ELEMENTS.state.versions = Array.from(new Set([...globalThis.NVE_ELEMENTS.state.versions, "0.2.1"])), globalThis.NVE_ELEMENTS.state.scopedRegistry ??= {}, globalThis.NVE_ELEMENTS.state.scopedRegistry["0.2.1"] = i(), globalThis.NVE_ELEMENTS.state.versions.length > 1 && globalThis.NVE_ELEMENTS.state.env !== "production" && console.warn(e(), `\n\n${JSON.stringify(globalThis.NVE_ELEMENTS.state.versions, null, 2)}`);
|
|
23
23
|
}
|
|
24
24
|
get state() {
|
|
25
25
|
return globalThis.NVE_ELEMENTS.state;
|
package/dist/logo/logo2.js
CHANGED
package/dist/menu/menu-item2.js
CHANGED
package/dist/menu/menu2.js
CHANGED
package/dist/month/month2.js
CHANGED
package/dist/page/page2.js
CHANGED
package/dist/panel/panel2.js
CHANGED
|
@@ -21,7 +21,7 @@ var g = class extends f {
|
|
|
21
21
|
static {
|
|
22
22
|
this.metadata = {
|
|
23
23
|
tag: "nve-panel-header",
|
|
24
|
-
version: "0.2.
|
|
24
|
+
version: "0.2.1"
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
render() {
|
|
@@ -37,7 +37,7 @@ var g = class extends f {
|
|
|
37
37
|
static {
|
|
38
38
|
this.metadata = {
|
|
39
39
|
tag: "nve-panel-content",
|
|
40
|
-
version: "0.2.
|
|
40
|
+
version: "0.2.1"
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
render() {
|
|
@@ -50,7 +50,7 @@ var g = class extends f {
|
|
|
50
50
|
static {
|
|
51
51
|
this.metadata = {
|
|
52
52
|
tag: "nve-panel-footer",
|
|
53
|
-
version: "0.2.
|
|
53
|
+
version: "0.2.1"
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
@@ -69,7 +69,7 @@ var g = class extends f {
|
|
|
69
69
|
static {
|
|
70
70
|
this.metadata = {
|
|
71
71
|
tag: "nve-panel",
|
|
72
|
-
version: "0.2.
|
|
72
|
+
version: "0.2.1"
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
static {
|
|
@@ -43,7 +43,7 @@ var x = class extends g(d) {
|
|
|
43
43
|
static {
|
|
44
44
|
this.metadata = {
|
|
45
45
|
tag: "nve-preferences-input",
|
|
46
|
-
version: "0.2.
|
|
46
|
+
version: "0.2.1",
|
|
47
47
|
valueSchema: {
|
|
48
48
|
type: "object",
|
|
49
49
|
properties: {
|
|
@@ -90,6 +90,7 @@ var x = class extends g(d) {
|
|
|
90
90
|
}), this.#t();
|
|
91
91
|
}
|
|
92
92
|
#t() {
|
|
93
|
+
/* istanbul ignore else -- Lit SSR mode is not reachable in browser unit tests. */
|
|
93
94
|
if (!p) {
|
|
94
95
|
let e = b();
|
|
95
96
|
JSON.stringify(this.activePreferences) !== JSON.stringify(e) && (this.activePreferences = e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preferences-input2.js","names":["#setColorScheme","#setScale","#setReducedMotion","#i18nController","#updatePreferences","#update"],"sources":["../../src/preferences-input/preferences-input.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, isServer, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { I18nController, scopedRegistry, useStyles } from '@nvidia-elements/core/internal';\nimport { state } from 'lit/decorators/state.js';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixin';\nimport { type IconName, Icon } from '@nvidia-elements/core/icon';\nimport { Control } from '@nvidia-elements/core/forms';\nimport { Divider } from '@nvidia-elements/core/divider';\nimport { Menu, MenuItem } from '@nvidia-elements/core/menu';\nimport { Switch } from '@nvidia-elements/core/switch';\nimport styles from './preferences-input.css?inline';\n\nexport type ColorScheme = 'auto' | 'light' | 'dark' | 'high-contrast';\nexport type Scale = 'default' | 'compact' | 'relaxed';\nexport type Variant = 'reduced-motion';\n\nconst colorSchemes: ColorScheme[] = ['auto', 'light', 'dark', 'high-contrast'];\nconst scales: Scale[] = ['default', 'compact'];\nconst colorSchemesIcons = {\n auto: 'computer',\n light: 'sun',\n dark: 'moon',\n 'high-contrast': 'circle-half'\n} satisfies Record<ColorScheme, IconName>;\n\nfunction getActivePreferences(element = globalThis.document.documentElement) {\n const computedStyle = getComputedStyle(element);\n\n return {\n light: computedStyle.getPropertyValue('--nve-config-color-scheme-light') === 'true',\n dark: computedStyle.getPropertyValue('--nve-config-color-scheme-dark') === 'true',\n 'high-contrast': computedStyle.getPropertyValue('--nve-config-color-scheme-high-contrast') === 'true',\n compact: computedStyle.getPropertyValue('--nve-config-scale-compact') === 'true',\n 'reduced-motion': computedStyle.getPropertyValue('--nve-config-reduced-motion') === 'true'\n } satisfies Partial<Record<ColorScheme | Scale | Variant, boolean>>;\n}\n\nexport interface PreferencesInputValue {\n 'color-scheme'?: ColorScheme | string;\n scale?: Scale | string;\n 'reduced-motion'?: boolean;\n}\n\n/**\n * @element nve-preferences-input\n * @description A preferences input is a widget for controlling apperance. Stylesheets register to the preferences input by including a css-property, see Standard for an example.\n * @since 1.23.7\n * @entrypoint \\@nvidia-elements/core/preferences-input\n * @event input - Dispatched when the value has changed\n * @event change - Dispatched when the value has changed\n * @cssprop --color\n * @cssprop --width\n * @csspart control - The control wrapper elements that contain the labels and menus\n * @csspart menu - The menu elements that display color scheme and scale options\n * @csspart menu-item - The individual menu item elements for each selectable option\n * @csspart icon - The icon element displayed next to color scheme options\n * @csspart divider - The divider elements that separate preference sections\n * @csspart switch - The switch element for the reduced motion toggle\n *\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/listbox/\n *\n */\n@scopedRegistry()\nexport class PreferencesInput extends FormControlMixin<typeof LitElement, PreferencesInputValue>(LitElement) {\n #i18nController: I18nController<this> = new I18nController<this>(this);\n\n /**\n * Enables updating internal string values for internationalization.\n */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-preferences-input',\n version: '0.0.0',\n valueSchema: {\n type: 'object' as const,\n properties: {\n 'color-scheme': { type: 'string' as const },\n scale: { type: 'string' as const },\n 'reduced-motion': { type: 'boolean' as const }\n }\n }\n };\n\n static elementDefinitions = {\n [Control.metadata.tag]: Control,\n [Divider.metadata.tag]: Divider,\n [Icon.metadata.tag]: Icon,\n [Menu.metadata.tag]: Menu,\n [MenuItem.metadata.tag]: MenuItem,\n [Switch.metadata.tag]: Switch\n };\n\n @state() private activePreferences: ReturnType<typeof getActivePreferences> = {\n light: false,\n dark: false,\n 'high-contrast': false,\n compact: false,\n 'reduced-motion': false\n };\n\n // eslint-disable-next-line max-lines-per-function\n render() {\n return html`\n <div internal-host>\n <nve-control part=\"control\">\n <label>${this.i18n.colorScheme}</label>\n <nve-menu part=\"menu\" nve-control>\n ${colorSchemes.map(\n value => html`\n <nve-menu-item part=\"menu-item\"\n .selected=${this.value?.['color-scheme'] === value}\n .value=${value}\n @click=${() => this.#setColorScheme(value)}\n >\n <nve-icon part=\"icon\" name=${colorSchemesIcons[value]}></nve-icon> ${value}\n </nve-menu-item>\n `\n )}\n </nve-menu>\n </nve-control>\n ${\n this.activePreferences['compact']\n ? html`\n <nve-divider part=\"divider\"></nve-divider>\n <nve-control part=\"control\">\n <label>${this.i18n.scale}</label>\n <nve-menu part=\"menu\" nve-control>\n ${scales.map(\n value => html`\n <nve-menu-item part=\"menu-item\"\n .selected=${this.value?.['scale'] === value}\n .value=${value}\n @click=${() => this.#setScale(value)}\n >\n ${value}\n </nve-menu-item>\n `\n )}\n </nve-menu>\n </nve-control>\n `\n : ''\n }\n ${\n this.activePreferences['reduced-motion']\n ? html`\n <nve-divider part=\"divider\"></nve-divider>\n <nve-switch part=\"switch\">\n <label>${this.i18n.reducedMotion}</label>\n <input\n type=\"checkbox\"\n value=\"reduced-motion\"\n .checked=${this.value?.['reduced-motion']}\n @change=${(e: { target: HTMLInputElement }) => this.#setReducedMotion(e.target.checked)}\n />\n </nve-switch>`\n : ''\n }\n </div>\n `;\n }\n\n constructor() {\n super();\n this.value = {\n 'color-scheme': 'auto',\n 'reduced-motion': false,\n scale: 'default'\n };\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('nve-control', '');\n this.#updatePreferences();\n }\n\n /** @private */\n updateValue(value: PreferencesInputValue) {\n super.updateValue({ ...this.value, ...value });\n this.#updatePreferences();\n }\n\n #updatePreferences() {\n if (!isServer) {\n const preferences = getActivePreferences();\n if (JSON.stringify(this.activePreferences) !== JSON.stringify(preferences)) {\n this.activePreferences = preferences;\n }\n }\n }\n\n #setColorScheme(value: ColorScheme) {\n this.value = { ...this.value, 'color-scheme': value };\n this.#update();\n }\n\n #setScale(value: Scale) {\n this.value = { ...this.value, scale: value };\n this.#update();\n }\n\n #setReducedMotion(value: boolean) {\n this.value = { ...this.value, 'reduced-motion': value };\n this.#update();\n }\n\n #update() {\n this.dispatchInputEvent();\n this.dispatchChangeEvent();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,IAA8B;CAAC;CAAQ;CAAS;CAAQ;AAAe,GACvE,IAAkB,CAAC,WAAW,SAAS,GACvC,IAAoB;CACxB,MAAM;CACN,OAAO;CACP,MAAM;CACN,iBAAiB;AACnB;AAEA,SAAS,EAAqB,IAAU,WAAW,SAAS,iBAAiB;CAC3E,IAAM,IAAgB,iBAAiB,CAAO;CAE9C,OAAO;EACL,OAAO,EAAc,iBAAiB,iCAAiC,MAAM;EAC7E,MAAM,EAAc,iBAAiB,gCAAgC,MAAM;EAC3E,iBAAiB,EAAc,iBAAiB,yCAAyC,MAAM;EAC/F,SAAS,EAAc,iBAAiB,4BAA4B,MAAM;EAC1E,kBAAkB,EAAc,iBAAiB,6BAA6B,MAAM;CACtF;AACF;AA4BO,IAAA,IAAA,cAA+B,EAA2D,CAAU,EAAE;CAC3G;;gBAOgB,EAAU,CAAC,CAAM,CAAC;;;kBAEP;GACzB,KAAK;GACL,SAAS;GACT,aAAa;IACX,MAAM;IACN,YAAY;KACV,gBAAgB,EAAE,MAAM,SAAkB;KAC1C,OAAO,EAAE,MAAM,SAAkB;KACjC,kBAAkB,EAAE,MAAM,UAAmB;IAC/C;GACF;EACF;;;4BAE4B;IACzB,EAAQ,SAAS,MAAM;IACvB,EAAQ,SAAS,MAAM;IACvB,EAAK,SAAS,MAAM;IACpB,EAAK,SAAS,MAAM;IACpB,EAAS,SAAS,MAAM;IACxB,EAAO,SAAS,MAAM;EACzB;;CAWA,SAAS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O,gBAAgB;EAAM,GACpD,KAAKC,GAAQ;CACf;CAEA,GAAU,GAAc;EAEtB,AADA,KAAK,QAAQ;GAAE,GAAG,KAAK;GAAO,OAAO;EAAM,GAC3C,KAAKA,GAAQ;CACf;CAEA,GAAkB,GAAgB;EAEhC,AADA,KAAK,QAAQ;GAAE,GAAG,KAAK;GAAO,kBAAkB;EAAM,GACtD,KAAKA,GAAQ;CACf;CAEA,KAAU;EAER,AADA,KAAK,mBAAmB,GACxB,KAAK,oBAAoB;CAC3B;AACF;GAjJG,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,MA0BzB,EAAM,CAAA,GAAA,EAAA,WAAA,qBAAA,KAAA,CAAA,UAjCR,EAAe,CAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"preferences-input2.js","names":["#setColorScheme","#setScale","#setReducedMotion","#i18nController","#updatePreferences","#update"],"sources":["../../src/preferences-input/preferences-input.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { html, isServer, LitElement } from 'lit';\nimport { property } from 'lit/decorators/property.js';\nimport { I18nController, scopedRegistry, useStyles } from '@nvidia-elements/core/internal';\nimport { state } from 'lit/decorators/state.js';\nimport { FormControlMixin } from '@nvidia-elements/forms/mixin';\nimport { type IconName, Icon } from '@nvidia-elements/core/icon';\nimport { Control } from '@nvidia-elements/core/forms';\nimport { Divider } from '@nvidia-elements/core/divider';\nimport { Menu, MenuItem } from '@nvidia-elements/core/menu';\nimport { Switch } from '@nvidia-elements/core/switch';\nimport styles from './preferences-input.css?inline';\n\nexport type ColorScheme = 'auto' | 'light' | 'dark' | 'high-contrast';\nexport type Scale = 'default' | 'compact' | 'relaxed';\nexport type Variant = 'reduced-motion';\n\nconst colorSchemes: ColorScheme[] = ['auto', 'light', 'dark', 'high-contrast'];\nconst scales: Scale[] = ['default', 'compact'];\nconst colorSchemesIcons = {\n auto: 'computer',\n light: 'sun',\n dark: 'moon',\n 'high-contrast': 'circle-half'\n} satisfies Record<ColorScheme, IconName>;\n\nfunction getActivePreferences(element = globalThis.document.documentElement) {\n const computedStyle = getComputedStyle(element);\n\n return {\n light: computedStyle.getPropertyValue('--nve-config-color-scheme-light') === 'true',\n dark: computedStyle.getPropertyValue('--nve-config-color-scheme-dark') === 'true',\n 'high-contrast': computedStyle.getPropertyValue('--nve-config-color-scheme-high-contrast') === 'true',\n compact: computedStyle.getPropertyValue('--nve-config-scale-compact') === 'true',\n 'reduced-motion': computedStyle.getPropertyValue('--nve-config-reduced-motion') === 'true'\n } satisfies Partial<Record<ColorScheme | Scale | Variant, boolean>>;\n}\n\nexport interface PreferencesInputValue {\n 'color-scheme'?: ColorScheme | string;\n scale?: Scale | string;\n 'reduced-motion'?: boolean;\n}\n\n/**\n * @element nve-preferences-input\n * @description A preferences input is a widget for controlling apperance. Stylesheets register to the preferences input by including a css-property, see Standard for an example.\n * @since 1.23.7\n * @entrypoint \\@nvidia-elements/core/preferences-input\n * @event input - Dispatched when the value has changed\n * @event change - Dispatched when the value has changed\n * @cssprop --color\n * @cssprop --width\n * @csspart control - The control wrapper elements that contain the labels and menus\n * @csspart menu - The menu elements that display color scheme and scale options\n * @csspart menu-item - The individual menu item elements for each selectable option\n * @csspart icon - The icon element displayed next to color scheme options\n * @csspart divider - The divider elements that separate preference sections\n * @csspart switch - The switch element for the reduced motion toggle\n *\n * @aria https://www.w3.org/WAI/ARIA/apg/patterns/listbox/\n *\n */\n@scopedRegistry()\nexport class PreferencesInput extends FormControlMixin<typeof LitElement, PreferencesInputValue>(LitElement) {\n #i18nController: I18nController<this> = new I18nController<this>(this);\n\n /**\n * Enables updating internal string values for internationalization.\n */\n @property({ type: Object }) i18n = this.#i18nController.i18n;\n\n static styles = useStyles([styles]);\n\n static readonly metadata = {\n tag: 'nve-preferences-input',\n version: '0.0.0',\n valueSchema: {\n type: 'object' as const,\n properties: {\n 'color-scheme': { type: 'string' as const },\n scale: { type: 'string' as const },\n 'reduced-motion': { type: 'boolean' as const }\n }\n }\n };\n\n static elementDefinitions = {\n [Control.metadata.tag]: Control,\n [Divider.metadata.tag]: Divider,\n [Icon.metadata.tag]: Icon,\n [Menu.metadata.tag]: Menu,\n [MenuItem.metadata.tag]: MenuItem,\n [Switch.metadata.tag]: Switch\n };\n\n @state() private activePreferences: ReturnType<typeof getActivePreferences> = {\n light: false,\n dark: false,\n 'high-contrast': false,\n compact: false,\n 'reduced-motion': false\n };\n\n // eslint-disable-next-line max-lines-per-function\n render() {\n return html`\n <div internal-host>\n <nve-control part=\"control\">\n <label>${this.i18n.colorScheme}</label>\n <nve-menu part=\"menu\" nve-control>\n ${colorSchemes.map(\n value => html`\n <nve-menu-item part=\"menu-item\"\n .selected=${this.value?.['color-scheme'] === value}\n .value=${value}\n @click=${() => this.#setColorScheme(value)}\n >\n <nve-icon part=\"icon\" name=${colorSchemesIcons[value]}></nve-icon> ${value}\n </nve-menu-item>\n `\n )}\n </nve-menu>\n </nve-control>\n ${\n this.activePreferences['compact']\n ? html`\n <nve-divider part=\"divider\"></nve-divider>\n <nve-control part=\"control\">\n <label>${this.i18n.scale}</label>\n <nve-menu part=\"menu\" nve-control>\n ${scales.map(\n value => html`\n <nve-menu-item part=\"menu-item\"\n .selected=${this.value?.['scale'] === value}\n .value=${value}\n @click=${() => this.#setScale(value)}\n >\n ${value}\n </nve-menu-item>\n `\n )}\n </nve-menu>\n </nve-control>\n `\n : ''\n }\n ${\n this.activePreferences['reduced-motion']\n ? html`\n <nve-divider part=\"divider\"></nve-divider>\n <nve-switch part=\"switch\">\n <label>${this.i18n.reducedMotion}</label>\n <input\n type=\"checkbox\"\n value=\"reduced-motion\"\n .checked=${this.value?.['reduced-motion']}\n @change=${(e: { target: HTMLInputElement }) => this.#setReducedMotion(e.target.checked)}\n />\n </nve-switch>`\n : ''\n }\n </div>\n `;\n }\n\n constructor() {\n super();\n this.value = {\n 'color-scheme': 'auto',\n 'reduced-motion': false,\n scale: 'default'\n };\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('nve-control', '');\n this.#updatePreferences();\n }\n\n /** @private */\n updateValue(value: PreferencesInputValue) {\n super.updateValue({ ...this.value, ...value });\n this.#updatePreferences();\n }\n\n #updatePreferences() {\n /* istanbul ignore else -- Lit SSR mode is not reachable in browser unit tests. */\n if (!isServer) {\n const preferences = getActivePreferences();\n if (JSON.stringify(this.activePreferences) !== JSON.stringify(preferences)) {\n this.activePreferences = preferences;\n }\n }\n }\n\n #setColorScheme(value: ColorScheme) {\n this.value = { ...this.value, 'color-scheme': value };\n this.#update();\n }\n\n #setScale(value: Scale) {\n this.value = { ...this.value, scale: value };\n this.#update();\n }\n\n #setReducedMotion(value: boolean) {\n this.value = { ...this.value, 'reduced-motion': value };\n this.#update();\n }\n\n #update() {\n this.dispatchInputEvent();\n this.dispatchChangeEvent();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,IAA8B;CAAC;CAAQ;CAAS;CAAQ;AAAe,GACvE,IAAkB,CAAC,WAAW,SAAS,GACvC,IAAoB;CACxB,MAAM;CACN,OAAO;CACP,MAAM;CACN,iBAAiB;AACnB;AAEA,SAAS,EAAqB,IAAU,WAAW,SAAS,iBAAiB;CAC3E,IAAM,IAAgB,iBAAiB,CAAO;CAE9C,OAAO;EACL,OAAO,EAAc,iBAAiB,iCAAiC,MAAM;EAC7E,MAAM,EAAc,iBAAiB,gCAAgC,MAAM;EAC3E,iBAAiB,EAAc,iBAAiB,yCAAyC,MAAM;EAC/F,SAAS,EAAc,iBAAiB,4BAA4B,MAAM;EAC1E,kBAAkB,EAAc,iBAAiB,6BAA6B,MAAM;CACtF;AACF;AA4BO,IAAA,IAAA,cAA+B,EAA2D,CAAU,EAAE;CAC3G;;gBAOgB,EAAU,CAAC,CAAM,CAAC;;;kBAEP;GACzB,KAAK;GACL,SAAS;GACT,aAAa;IAC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AADA,MAAM,YAAY;GAAE,GAAG,KAAK;GAAO,GAAG;EAAM,CAAC,GAC7C,KAAKA,GAAmB;CAC1B;CAEA,KAAqB;;EAEnB,IAAI,CAAC,GAAU;GACb,IAAM,IAAc,EAAqB;GACzC,AAAI,KAAK,UAAU,KAAK,iBAAiB,MAAM,KAAK,UAAU,CAAW,MACvE,KAAK,oBAAoB;EAE7B;CACF;CAEA,GAAgB,GAAoB;EAElC,AADA,KAAK,QAAQ;GAAE,GAAG,KAAK;GAAO,gBAAgB;EAAM,GACpD,KAAKC,GAAQ;CACf;CAEA,GAAU,GAAc;EAEtB,AADA,KAAK,QAAQ;GAAE,GAAG,KAAK;GAAO,OAAO;EAAM,GAC3C,KAAKA,GAAQ;CACf;CAEA,GAAkB,GAAgB;EAEhC,AADA,KAAK,QAAQ;GAAE,GAAG,KAAK;GAAO,kBAAkB;EAAM,GACtD,KAAKA,GAAQ;CACf;CAEA,KAAU;EAER,AADA,KAAK,mBAAmB,GACxB,KAAK,oBAAoB;CAC3B;AACF;GAlJG,EAAS,EAAE,MAAM,OAAO,CAAC,CAAA,GAAA,EAAA,WAAA,QAAA,KAAA,CAAA,MA0BzB,EAAM,CAAA,GAAA,EAAA,WAAA,qBAAA,KAAA,CAAA,UAjCR,EAAe,CAAA,GAAA,CAAA"}
|
package/dist/pulse/pulse2.js
CHANGED
package/dist/radio/radio2.js
CHANGED
package/dist/range/range2.js
CHANGED
package/dist/search/search2.js
CHANGED
package/dist/select/select2.js
CHANGED
package/dist/steps/steps2.js
CHANGED
|
@@ -23,7 +23,7 @@ var v = class extends r {
|
|
|
23
23
|
static {
|
|
24
24
|
this.metadata = {
|
|
25
25
|
tag: "nve-steps-item",
|
|
26
|
-
version: "0.2.
|
|
26
|
+
version: "0.2.1",
|
|
27
27
|
parents: ["nve-steps"]
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -69,7 +69,7 @@ var y = class extends f {
|
|
|
69
69
|
static {
|
|
70
70
|
this.metadata = {
|
|
71
71
|
tag: "nve-steps",
|
|
72
|
-
version: "0.2.
|
|
72
|
+
version: "0.2.1",
|
|
73
73
|
children: ["nve-steps-item"]
|
|
74
74
|
};
|
|
75
75
|
}
|
package/dist/switch/switch2.js
CHANGED
package/dist/tabs/tabs-group2.js
CHANGED
package/dist/tabs/tabs2.js
CHANGED
|
@@ -20,7 +20,7 @@ var _ = class extends o {
|
|
|
20
20
|
static {
|
|
21
21
|
this.metadata = {
|
|
22
22
|
tag: "nve-tabs-item",
|
|
23
|
-
version: "0.2.
|
|
23
|
+
version: "0.2.1",
|
|
24
24
|
parents: ["nve-tabs"]
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -53,7 +53,7 @@ var v = class extends p {
|
|
|
53
53
|
static {
|
|
54
54
|
this.metadata = {
|
|
55
55
|
tag: "nve-tabs",
|
|
56
|
-
version: "0.2.
|
|
56
|
+
version: "0.2.1",
|
|
57
57
|
children: ["nve-tabs-item"]
|
|
58
58
|
};
|
|
59
59
|
}
|
package/dist/tag/tag2.js
CHANGED
package/dist/time/time2.js
CHANGED