@nvidia-elements/core 0.2.0 → 0.2.2
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 +11 -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 +4 -4
- 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 +27 -27
- package/dist/date/date2.js +1 -1
- package/dist/datetime/datetime2.js +1 -1
- package/dist/dialog/dialog-footer2.js +1 -1
- package/dist/dialog/dialog-header2.js +1 -1
- package/dist/dialog/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/decorators/scoped-registry.js +24 -6
- package/dist/internal/decorators/scoped-registry.js.map +1 -1
- package/dist/internal/services/global.service.js +1 -1
- package/dist/internal/utils/focus.js +1 -1
- package/dist/internal/utils/focus.js.map +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 +3 -3
|
@@ -23,19 +23,19 @@ var c = class {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
async hostConnected() {
|
|
26
|
-
i(this.host), this.host.popover = this.host.popoverType ?? null, await this.host.updateComplete, this.host.setAttribute("nve-popover", ""), this.#
|
|
26
|
+
i(this.host), this.host.popover = this.host.popoverType ?? null, await this.host.updateComplete, this.host.setAttribute("nve-popover", ""), this.#u(), this.#l(), this.#s(), this.host.inert = this.host.matches(":not(:popover-open)") && !!this.#e.length, this.host.addEventListener("beforetoggle", (e) => {
|
|
27
27
|
e.newState === "open" && this.host._internals.states.add("transition-start");
|
|
28
28
|
}), this.host.addEventListener("toggle", (e) => {
|
|
29
|
-
this.host.behaviorTrigger && (this.host.hidden = e.newState === "closed"), e.newState === "open" && this.host.closeTimeout && setTimeout(() => this.host.hidePopover(), this.host.closeTimeout), this.host.inert = this.host.matches(":not(:popover-open)"), this.host.modal && this.#
|
|
29
|
+
this.host.behaviorTrigger && (this.host.hidden = e.newState === "closed"), e.newState === "open" && this.host.closeTimeout && setTimeout(() => this.host.hidePopover(), this.host.closeTimeout), e.newState === "closed" && this.#i(), this.host.inert = this.host.matches(":not(:popover-open)"), this.host.modal && this.#d(e.newState === "open", e.target), this.host.dispatchEvent(new CustomEvent(e.newState === "open" && e.oldState !== "open" ? "open" : "close", {
|
|
30
30
|
bubbles: !0,
|
|
31
31
|
composed: !0,
|
|
32
32
|
detail: { trigger: e.source }
|
|
33
33
|
}));
|
|
34
34
|
}), this.host.addEventListener("command", ((e) => {
|
|
35
|
-
e.command === "toggle-popover" && this.host.togglePopover({ source: e.source }), e.command === "hide-popover" && this.host.hidePopover(), e.command === "show-popover" && this.host.showPopover({ source: e.source });
|
|
35
|
+
e.command === "toggle-popover" && this.host.togglePopover({ source: e.source }), e.command === "hide-popover" && (this.host.hidePopover(), this.#i()), e.command === "show-popover" && this.host.showPopover({ source: e.source });
|
|
36
36
|
})), this.host.addEventListener("interest", ((e) => {
|
|
37
37
|
if (e.source?.localName.includes("-")) {
|
|
38
|
-
let t = this.host.openDelay ?? this.#
|
|
38
|
+
let t = this.host.openDelay ?? this.#a();
|
|
39
39
|
t ? this.#t = setTimeout(() => {
|
|
40
40
|
this.host.isConnected && this.host.showPopover({ source: e.source });
|
|
41
41
|
}, t) : this.host.showPopover({ source: e.source });
|
|
@@ -48,38 +48,41 @@ var c = class {
|
|
|
48
48
|
#n = [];
|
|
49
49
|
#r = null;
|
|
50
50
|
async hostUpdated() {
|
|
51
|
-
this.host.popover = this.host.popoverType ?? null, this.#
|
|
51
|
+
this.host.popover = this.host.popoverType ?? null, this.#u();
|
|
52
52
|
}
|
|
53
53
|
hostDisconnected() {
|
|
54
|
-
this.#n.forEach((e) => e.disconnect()), this.#
|
|
54
|
+
this.#n.forEach((e) => e.disconnect()), this.#i();
|
|
55
55
|
}
|
|
56
56
|
#i() {
|
|
57
|
+
this.#t &&= (clearTimeout(this.#t), null);
|
|
58
|
+
}
|
|
59
|
+
#a() {
|
|
57
60
|
let e = getComputedStyle(this.host).interestDelayStart;
|
|
58
61
|
if (!e) return 0;
|
|
59
62
|
let t = parseFloat(e);
|
|
60
63
|
return e.endsWith("ms") ? t : t * 1e3;
|
|
61
64
|
}
|
|
62
|
-
#
|
|
63
|
-
#
|
|
65
|
+
#o = !1;
|
|
66
|
+
#s() {
|
|
64
67
|
this.host.addEventListener("pointerdown", (e) => {
|
|
65
|
-
this.host.modal && this.host.matches(":popover-open") && (this.#
|
|
68
|
+
this.host.modal && this.host.matches(":popover-open") && (this.#o = t(e, this.host));
|
|
66
69
|
}), this.host.addEventListener("pointerup", (e) => {
|
|
67
|
-
this.#
|
|
70
|
+
this.#o && this.host.popoverDismissible && this.host.modal && this.host.matches(":popover-open") && !s(this.host) && t(e, this.host) && this.host.hidePopover();
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
|
-
get #
|
|
73
|
+
get #c() {
|
|
71
74
|
return this.host.trigger ? o(this.host, this.host.trigger) : null;
|
|
72
75
|
}
|
|
73
|
-
async #
|
|
76
|
+
async #l() {
|
|
74
77
|
await new Promise((e) => requestAnimationFrame(e)), this.#n.push(r(this.host, ["hidden"], () => {
|
|
75
78
|
this.host.isConnected && !this.host.hidden && !this.host.matches(":popover-open") && this.host.showPopover(), this.host.isConnected && this.host.hidden && this.host.matches(":popover-open") && this.host.hidePopover();
|
|
76
79
|
})), this.host.isConnected && !this.#e.length && !this.host.hidden && !this.host.matches(":popover-open") && (this.host.popover = "manual", this.host.showPopover());
|
|
77
80
|
}
|
|
78
|
-
#
|
|
79
|
-
let e = this.#
|
|
81
|
+
#u() {
|
|
82
|
+
let e = this.#c;
|
|
80
83
|
this.#r && this.#r !== e && (this.#r.popoverTargetElement = null, this.#r.removeAttribute("popovertarget")), e && (this.host.popoverType === "hint" ? (e.addEventListener("mouseenter", () => this.host.showPopover({ source: e })), e.addEventListener("mouseleave", () => this.host.hidePopover()), e.addEventListener("focusout", () => this.host.hidePopover())) : (this.host.id = this.host.id ? this.host.id : n(), e.popoverTargetElement = this.host, e.setAttribute("popovertarget", this.host.id)), this.#r = e);
|
|
81
84
|
}
|
|
82
|
-
#
|
|
85
|
+
#d(t, n) {
|
|
83
86
|
t ? this.host.getRootNode().activeElement !== this.host && !this.host.shadowRoot.activeElement && e(this.host) : e(n);
|
|
84
87
|
}
|
|
85
88
|
};
|
|
@@ -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,GAEM,IAAsB,MAAM,KAChC,EAAK,iBAAiB,iBAAiB,IAAI,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,GAAG,CACjG;EAEA,OAAO;GAAC,GAAG;GAAuB,GAAG;GAAoB,GAAG;EAAmB;CACjF;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;EAE5B,IAAM,IAAc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,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,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,GAEM,I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QAAQ,eAAe,KAChF,KAAK,KAAK,YAAY;EAE1B,CAAC,CACH,GAIE,KAAK,KAAK,eACV,CAAC,KAAKR,GAAgB,UACtB,CAAC,KAAK,KAAK,UACX,CAAC,KAAK,KAAK,QAAQ,eAAe,MAElC,KAAK,KAAK,UAAU,UACpB,KAAK,KAAK,YAAY;CAE1B;CAKA,KAAwB;EACtB,IAAM,IAAU,KAAKU;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"}
|
|
@@ -40,6 +40,7 @@ var r = class {
|
|
|
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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Q,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"}
|
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
import { GlobalStateService as e } from "../services/global.service.js";
|
|
2
2
|
import { defineElement as t, supportsScopedRegistry as n } from "../utils/dom.js";
|
|
3
3
|
//#region src/internal/decorators/scoped-registry.ts
|
|
4
|
-
|
|
4
|
+
var r = /* @__PURE__ */ new WeakSet();
|
|
5
|
+
function i(e, t) {
|
|
6
|
+
return { importNode: (n, r = !1) => e.importNode(n, {
|
|
7
|
+
customElementRegistry: t,
|
|
8
|
+
selfOnly: !r
|
|
9
|
+
}) };
|
|
10
|
+
}
|
|
11
|
+
function a(e, t) {
|
|
12
|
+
if (r.has(e)) return;
|
|
13
|
+
let n = e.prototype, a = n.createRenderRoot;
|
|
14
|
+
a && (r.add(e), Object.defineProperty(n, "createRenderRoot", {
|
|
15
|
+
configurable: !0,
|
|
16
|
+
value() {
|
|
17
|
+
let e = a.call(this);
|
|
18
|
+
return e instanceof ShadowRoot && (this.renderOptions ??= {}, this.renderOptions.creationScope = i(e.ownerDocument, t)), e;
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function o() {
|
|
5
23
|
return (r) => {
|
|
6
24
|
let i = r;
|
|
7
25
|
e.state.scopedRegistry ??= {};
|
|
8
|
-
let
|
|
9
|
-
n && Object.defineProperty(i, "shadowRootOptions", {
|
|
26
|
+
let o = e.state.scopedRegistry[i.metadata.version] ?? customElements;
|
|
27
|
+
n && (Object.defineProperty(i, "shadowRootOptions", {
|
|
10
28
|
configurable: !0,
|
|
11
29
|
value: {
|
|
12
30
|
...i.shadowRootOptions ?? { mode: "open" },
|
|
13
|
-
customElementRegistry:
|
|
31
|
+
customElementRegistry: o
|
|
14
32
|
}
|
|
15
|
-
}), t(i,
|
|
33
|
+
}), a(i, o)), t(i, o);
|
|
16
34
|
};
|
|
17
35
|
}
|
|
18
36
|
//#endregion
|
|
19
|
-
export {
|
|
37
|
+
export { o as scopedRegistry };
|
|
20
38
|
|
|
21
39
|
//# sourceMappingURL=scoped-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-registry.js","names":[],"sources":["../../../src/internal/decorators/scoped-registry.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { GlobalStateService } from '../services/global.service.js';\nimport type { ElementDefinition, LegacyDecoratorTarget } from '../types/index.js';\nimport { defineElement, supportsScopedRegistry } from '../utils/dom.js';\n\n/** decorator which registers element dependencies with the scoped custom element registry when available */\nexport function scopedRegistry(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => {\n const element = target as unknown as ElementDefinition;\n GlobalStateService.state.scopedRegistry ??= {};\n const customElementRegistry = GlobalStateService.state.scopedRegistry[element.metadata.version] ?? customElements;\n if (supportsScopedRegistry) {\n Object.defineProperty(element, 'shadowRootOptions', {\n configurable: true,\n value: { ...(element.shadowRootOptions ?? { mode: 'open' }), customElementRegistry }\n });\n }\n defineElement(element, customElementRegistry);\n };\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"scoped-registry.js","names":[],"sources":["../../../src/internal/decorators/scoped-registry.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { RenderOptions } from 'lit';\nimport { GlobalStateService } from '../services/global.service.js';\nimport type { ElementDefinition, LegacyDecoratorTarget } from '../types/index.js';\nimport { defineElement, supportsScopedRegistry } from '../utils/dom.js';\n\ninterface ScopedRegistryHost extends HTMLElement {\n createRenderRoot?: () => HTMLElement | DocumentFragment;\n renderOptions?: RenderOptions;\n}\n\nconst litCreationScopeElements = new WeakSet<ElementDefinition>();\n\n/** Lit passes a legacy `deep` boolean, but scoped registries require `ImportNodeOptions`. https://html.spec.whatwg.org/multipage/custom-elements.html#scoped-custom-element-registries */\nfunction createScopedCreationScope(ownerDocument: Document, customElementRegistry: CustomElementRegistry) {\n return {\n importNode: (node: Node, deep = false) =>\n ownerDocument.importNode(node, {\n customElementRegistry,\n selfOnly: !deep\n })\n } satisfies NonNullable<RenderOptions['creationScope']>;\n}\n\nfunction attachLitCreationScope(element: ElementDefinition, customElementRegistry: CustomElementRegistry) {\n if (litCreationScopeElements.has(element)) return;\n\n const host = element.prototype as ScopedRegistryHost;\n const createRenderRoot = host.createRenderRoot;\n if (!createRenderRoot) return;\n\n litCreationScopeElements.add(element);\n Object.defineProperty(host, 'createRenderRoot', {\n configurable: true,\n value(this: ScopedRegistryHost) {\n const renderRoot = createRenderRoot.call(this);\n if (renderRoot instanceof ShadowRoot) {\n this.renderOptions ??= {};\n this.renderOptions.creationScope = createScopedCreationScope(renderRoot.ownerDocument, customElementRegistry);\n }\n return renderRoot;\n }\n });\n}\n\n/** decorator which registers element dependencies with the scoped custom element registry when available */\nexport function scopedRegistry(): ClassDecorator {\n return (target: LegacyDecoratorTarget) => {\n const element = target as unknown as ElementDefinition;\n GlobalStateService.state.scopedRegistry ??= {};\n const customElementRegistry = GlobalStateService.state.scopedRegistry[element.metadata.version] ?? customElements;\n if (supportsScopedRegistry) {\n Object.defineProperty(element, 'shadowRootOptions', {\n configurable: true,\n value: { ...(element.shadowRootOptions ?? { mode: 'open' }), customElementRegistry }\n });\n attachLitCreationScope(element, customElementRegistry);\n }\n defineElement(element, customElementRegistry);\n };\n}\n"],"mappings":";;;AAaA,IAAM,oBAA2B,IAAI,QAA2B;AAGhE,SAAS,EAA0B,GAAyB,GAA8C;CACxG,OAAO,EACL,aAAa,GAAY,IAAO,OAC9B,EAAc,WAAW,GAAM;EAC7B;EACA,UAAU,CAAC;CACb,CAAC,EACL;AACF;AAEA,SAAS,EAAuB,GAA4B,GAA8C;CACxG,IAAI,EAAyB,IAAI,CAAO,GAAG;CAE3C,IAAM,IAAO,EAAQ,WACf,IAAmB,EAAK;CACzB,MAEL,EAAyB,IAAI,CAAO,GACpC,OAAO,eAAe,GAAM,oBAAoB;EAC9C,cAAc;EACd,QAAgC;GAC9B,IAAM,IAAa,EAAiB,KAAK,IAAI;GAK7C,OAJI,aAAsB,eACxB,KAAK,kBAAkB,CAAC,GACxB,KAAK,cAAc,gBAAgB,EAA0B,EAAW,eAAe,CAAqB,IAEvG;EACT;CACF,CAAC;AACH;AAGA,SAAgB,IAAiC;CAC/C,QAAQ,MAAkC;EACxC,IAAM,IAAU;EAChB,EAAmB,MAAM,mBAAmB,CAAC;EAC7C,IAAM,IAAwB,EAAmB,MAAM,eAAe,EAAQ,SAAS,YAAY;EAQnG,AAPI,MACF,OAAO,eAAe,GAAS,qBAAqB;GAClD,cAAc;GACd,OAAO;IAAE,GAAI,EAAQ,qBAAqB,EAAE,MAAM,OAAO;IAAI;GAAsB;EACrF,CAAC,GACD,EAAuB,GAAS,CAAqB,IAEvD,EAAc,GAAS,CAAqB;CAC9C;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.2"])), globalThis.NVE_ELEMENTS.state.scopedRegistry ??= {}, globalThis.NVE_ELEMENTS.state.scopedRegistry["0.2.2"] = 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;
|
|
@@ -46,7 +46,7 @@ function s(e, t) {
|
|
|
46
46
|
let n = (e) => e.code === "Space" || e.code === "ArrowUp" || e.code === "ArrowDown";
|
|
47
47
|
e.addEventListener("pointerdown", (e) => {
|
|
48
48
|
e.preventDefault();
|
|
49
|
-
}), e.addEventListener("
|
|
49
|
+
}), e.addEventListener("click", (n) => {
|
|
50
50
|
n.preventDefault(), e.disabled || t(n);
|
|
51
51
|
}), e.addEventListener("keyup", (r) => {
|
|
52
52
|
n(r) && !e.disabled && t(r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus.js","names":[],"sources":["../../../src/internal/utils/focus.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isFocusable(element: Element) {\n return (\n element.matches(\n [\n 'a[href]',\n 'area[href]',\n 'input',\n 'button',\n 'select',\n 'textarea',\n 'iframe',\n 'object',\n 'embed',\n '*[tabindex]',\n '*[contenteditable=true]',\n '[role=button]'\n ].join(',')\n ) &&\n element.matches(':not([disabled], [inert])') &&\n !element.closest(`[inert]`) &&\n !element.closest('[popover]')?.matches(':not(:popover-open)')\n );\n}\n\n/** returns interactive elements that does not require advanced keyboard interactions like arrow/navigation */\nexport function isSimpleFocusable(element: Element) {\n return element.matches(\n [\n 'a[href]',\n 'button:not([disabled])',\n 'input[type=checkbox]',\n 'input[type=radio]',\n 'object',\n 'embed',\n '*[tabindex]',\n '[role=button]:not([disabled])'\n ].join(',')\n );\n}\n\nexport function getActiveElement(root: Document | ShadowRoot = globalThis.document): Element | null {\n if (root.activeElement && root.activeElement.shadowRoot) {\n return getActiveElement(root.activeElement.shadowRoot) ?? root.activeElement;\n } else {\n return root.activeElement;\n }\n}\n\nexport function focusElement(element: HTMLElement) {\n if (element && !isFocusable(element)) {\n element.setAttribute('tabindex', '-1');\n element.focus();\n element.addEventListener('blur', () => element.removeAttribute('tabindex'), { once: true });\n } else {\n element?.focus();\n }\n}\n\nexport function focusElementTimeout(element: HTMLElement) {\n setTimeout(() => focusElement(element));\n}\n\nexport function setActiveKeyListItem(items: NodeListOf<HTMLElement> | HTMLElement[], item: HTMLElement) {\n items.forEach(i => (i.tabIndex = -1));\n item.tabIndex = 0;\n}\n\nexport function initializeKeyListItems(items: NodeListOf<HTMLElement> | HTMLElement[]) {\n items.forEach(i => (i.tabIndex = -1));\n items[0] && (items[0].tabIndex = 0);\n}\n\n/** determines if user interaction is a valid interaction for activating a listbox type */\nexport function onListboxActivate(\n element: HTMLElement & { disabled?: boolean },\n fn: (event: KeyboardEvent | PointerEvent) => void\n) {\n const validKey = (e: KeyboardEvent) => e.code === 'Space' || e.code === 'ArrowUp' || e.code === 'ArrowDown';\n\n element.addEventListener('pointerdown', (e: PointerEvent) => {\n e.preventDefault();\n });\n\n element.addEventListener('
|
|
1
|
+
{"version":3,"file":"focus.js","names":[],"sources":["../../../src/internal/utils/focus.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function isFocusable(element: Element) {\n return (\n element.matches(\n [\n 'a[href]',\n 'area[href]',\n 'input',\n 'button',\n 'select',\n 'textarea',\n 'iframe',\n 'object',\n 'embed',\n '*[tabindex]',\n '*[contenteditable=true]',\n '[role=button]'\n ].join(',')\n ) &&\n element.matches(':not([disabled], [inert])') &&\n !element.closest(`[inert]`) &&\n !element.closest('[popover]')?.matches(':not(:popover-open)')\n );\n}\n\n/** returns interactive elements that does not require advanced keyboard interactions like arrow/navigation */\nexport function isSimpleFocusable(element: Element) {\n return element.matches(\n [\n 'a[href]',\n 'button:not([disabled])',\n 'input[type=checkbox]',\n 'input[type=radio]',\n 'object',\n 'embed',\n '*[tabindex]',\n '[role=button]:not([disabled])'\n ].join(',')\n );\n}\n\nexport function getActiveElement(root: Document | ShadowRoot = globalThis.document): Element | null {\n if (root.activeElement && root.activeElement.shadowRoot) {\n return getActiveElement(root.activeElement.shadowRoot) ?? root.activeElement;\n } else {\n return root.activeElement;\n }\n}\n\nexport function focusElement(element: HTMLElement) {\n if (element && !isFocusable(element)) {\n element.setAttribute('tabindex', '-1');\n element.focus();\n element.addEventListener('blur', () => element.removeAttribute('tabindex'), { once: true });\n } else {\n element?.focus();\n }\n}\n\nexport function focusElementTimeout(element: HTMLElement) {\n setTimeout(() => focusElement(element));\n}\n\nexport function setActiveKeyListItem(items: NodeListOf<HTMLElement> | HTMLElement[], item: HTMLElement) {\n items.forEach(i => (i.tabIndex = -1));\n item.tabIndex = 0;\n}\n\nexport function initializeKeyListItems(items: NodeListOf<HTMLElement> | HTMLElement[]) {\n items.forEach(i => (i.tabIndex = -1));\n items[0] && (items[0].tabIndex = 0);\n}\n\n/** determines if user interaction is a valid interaction for activating a listbox type */\nexport function onListboxActivate(\n element: HTMLElement & { disabled?: boolean },\n fn: (event: KeyboardEvent | PointerEvent) => void\n) {\n const validKey = (e: KeyboardEvent) => e.code === 'Space' || e.code === 'ArrowUp' || e.code === 'ArrowDown';\n\n element.addEventListener('pointerdown', (e: PointerEvent) => {\n e.preventDefault();\n });\n\n // Chrome's LightDismissFromClick runs auto-popover light dismiss from click;\n // opening on pointerup can close immediately in the same gesture.\n // https://issues.chromium.org/issues/408010435\n element.addEventListener('click', (e: PointerEvent) => {\n e.preventDefault();\n\n if (!element.disabled) {\n fn(e);\n }\n });\n\n element.addEventListener('keyup', (e: KeyboardEvent) => {\n if (validKey(e) && !element.disabled) {\n fn(e);\n }\n });\n\n element.addEventListener('keydown', (e: KeyboardEvent) => {\n if (validKey(e) && !element.disabled) {\n e.preventDefault();\n }\n });\n}\n"],"mappings":";AAGA,SAAgB,EAAY,GAAkB;CAC5C,OACE,EAAQ,QACN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,EAAE,KAAK,GAAG,CACZ,KACA,EAAQ,QAAQ,2BAA2B,KAC3C,CAAC,EAAQ,QAAQ,SAAS,KAC1B,CAAC,EAAQ,QAAQ,WAAW,GAAG,QAAQ,qBAAqB;AAEhE;AAGA,SAAgB,EAAkB,GAAkB;CAClD,OAAO,EAAQ,QACb;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,EAAE,KAAK,GAAG,CACZ;AACF;AAEA,SAAgB,EAAiB,IAA8B,WAAW,UAA0B;CAIhG,OAHE,EAAK,iBAAiB,EAAK,cAAc,aACpC,EAAiB,EAAK,cAAc,UAAU,KAAK,EAAK,gBAExD,EAAK;AAEhB;AAEA,SAAgB,EAAa,GAAsB;CACjD,AAAI,KAAW,CAAC,EAAY,CAAO,KACjC,EAAQ,aAAa,YAAY,IAAI,GACrC,EAAQ,MAAM,GACd,EAAQ,iBAAiB,cAAc,EAAQ,gBAAgB,UAAU,GAAG,EAAE,MAAM,GAAK,CAAC,KAE1F,GAAS,MAAM;AAEnB;AAEA,SAAgB,EAAoB,GAAsB;CACxD,iBAAiB,EAAa,CAAO,CAAC;AACxC;AAEA,SAAgB,EAAqB,GAAgD,GAAmB;CAEtG,AADA,EAAM,SAAQ,MAAM,EAAE,WAAW,EAAG,GACpC,EAAK,WAAW;AAClB;AAEA,SAAgB,EAAuB,GAAgD;CAErF,AADA,EAAM,SAAQ,MAAM,EAAE,WAAW,EAAG,GACpC,EAAM,OAAO,EAAM,GAAG,WAAW;AACnC;AAGA,SAAgB,EACd,GACA,GACA;CACA,IAAM,KAAY,MAAqB,EAAE,SAAS,WAAW,EAAE,SAAS,aAAa,EAAE,SAAS;CAuBhG,AArBA,EAAQ,iBAAiB,gBAAgB,MAAoB;EAC3D,EAAE,eAAe;CACnB,CAAC,GAKD,EAAQ,iBAAiB,UAAU,MAAoB;EAGrD,AAFA,EAAE,eAAe,GAEZ,EAAQ,YACX,EAAG,CAAC;CAER,CAAC,GAED,EAAQ,iBAAiB,UAAU,MAAqB;EACtD,AAAI,EAAS,CAAC,KAAK,CAAC,EAAQ,YAC1B,EAAG,CAAC;CAER,CAAC,GAED,EAAQ,iBAAiB,YAAY,MAAqB;EACxD,AAAI,EAAS,CAAC,KAAK,CAAC,EAAQ,YAC1B,EAAE,eAAe;CAErB,CAAC;AACH"}
|
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.2"
|
|
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.2"
|
|
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.2"
|
|
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.2"
|
|
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.2",
|
|
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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AO;EACT;CACF;CAEA,oBAAoB;EAGlB,AAFA,MAAM,kBAAkB,GACxB,KAAK,aAAa,eAAe,EAAE,GACnC,KAAKC,GAAmB;CAC1B;CAGA,YAAY,GAA8B;EAExC,AADA,MAAM,YAAY;GAAE,GAAG,KAAK;GAAO,GAAG;EAAM,CAAC,GAC7C,KAAKA,GAAmB;CAC1B;CAEA,KAAqB;EACnB,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;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;A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