@nvidia-elements/core 0.2.2 → 0.2.4
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 +26 -0
- package/NOTICE.md +4 -4
- package/dist/_virtual/{_@oxc-project_runtime@0.130.0 → _@oxc-project_runtime@0.132.0}/helpers/decorate.js +1 -1
- package/dist/accordion/accordion-header.js +1 -1
- package/dist/accordion/accordion-header.js.map +1 -1
- package/dist/accordion/accordion.d.ts +4 -7
- package/dist/accordion/accordion.examples.js.map +1 -1
- package/dist/accordion/accordion.examples.json +1 -12
- package/dist/accordion/accordion.js +1 -1
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/accordion/accordion2.js +41 -44
- package/dist/accordion/accordion2.js.map +1 -1
- package/dist/alert/alert-group.d.ts +1 -1
- package/dist/alert/alert-group2.js +14 -14
- package/dist/alert/alert.d.ts +1 -1
- package/dist/alert/alert.js +1 -1
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/alert2.js +20 -20
- package/dist/avatar/avatar-group.d.ts +1 -1
- package/dist/avatar/avatar-group2.js +1 -1
- package/dist/avatar/avatar.d.ts +1 -1
- package/dist/avatar/avatar2.js +6 -6
- package/dist/badge/badge.d.ts +3 -3
- package/dist/badge/badge.js +1 -1
- package/dist/badge/badge.js.map +1 -1
- package/dist/badge/badge2.js +22 -23
- package/dist/badge/badge2.js.map +1 -1
- package/dist/breadcrumb/breadcrumb.d.ts +1 -6
- package/dist/breadcrumb/breadcrumb.js +1 -1
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/breadcrumb/breadcrumb2.js +12 -12
- package/dist/breadcrumb/breadcrumb2.js.map +1 -1
- package/dist/bundle.d.ts +14 -0
- package/dist/bundles/index.d.ts +1229 -1877
- package/dist/bundles/index.js +6 -6
- package/dist/button/button.d.ts +7 -4
- package/dist/button/button.js +1 -1
- package/dist/button/button.js.map +1 -1
- package/dist/button/button2.js +13 -13
- package/dist/button/button2.js.map +1 -1
- package/dist/button-group/button-group.d.ts +1 -1
- package/dist/button-group/button-group2.js +15 -15
- package/dist/card/card-header.js +1 -1
- package/dist/card/card-header.js.map +1 -1
- package/dist/card/card.d.ts +4 -7
- package/dist/card/card2.js +18 -18
- package/dist/card/card2.js.map +1 -1
- package/dist/chat-message/chat-message.d.ts +1 -1
- package/dist/chat-message/chat-message2.js +7 -7
- package/dist/checkbox/checkbox-group2.js +7 -7
- package/dist/checkbox/checkbox2.js +7 -7
- package/dist/color/color.d.ts +1 -1
- package/dist/color/color2.js +7 -7
- package/dist/combobox/combobox.d.ts +2 -8
- package/dist/combobox/combobox.examples.js.map +1 -1
- package/dist/combobox/combobox2.js +10 -13
- package/dist/combobox/combobox2.js.map +1 -1
- package/dist/copy-button/copy-button.d.ts +1 -1
- package/dist/copy-button/copy-button2.js +11 -11
- package/dist/copy-button/copy-button2.js.map +1 -1
- package/dist/custom-elements-jsx.d.ts +374 -646
- package/dist/custom-elements-vue.d.ts +374 -646
- package/dist/custom-elements.json +5999 -15468
- package/dist/data.html.json +322 -191
- package/dist/data.snippets.json +30 -30
- package/dist/date/date.d.ts +1 -1
- package/dist/date/date2.js +7 -7
- package/dist/datetime/datetime.d.ts +1 -1
- package/dist/datetime/datetime2.js +7 -7
- package/dist/dialog/dialog-footer.d.ts +1 -1
- package/dist/dialog/dialog-footer2.js +6 -6
- package/dist/dialog/dialog-header.d.ts +1 -1
- package/dist/dialog/dialog-header2.js +6 -6
- package/dist/dialog/dialog.d.ts +1 -1
- package/dist/dialog/dialog.examples.js.map +1 -1
- package/dist/dialog/dialog2.js +19 -19
- package/dist/divider/divider.d.ts +1 -1
- package/dist/divider/divider2.js +5 -5
- package/dist/dot/dot.d.ts +1 -1
- package/dist/dot/dot2.js +8 -8
- package/dist/drawer/drawer-content.d.ts +1 -1
- package/dist/drawer/drawer-content2.js +6 -6
- package/dist/drawer/drawer-footer.d.ts +1 -1
- package/dist/drawer/drawer-footer2.js +6 -6
- package/dist/drawer/drawer-header.d.ts +1 -1
- package/dist/drawer/drawer-header2.js +6 -6
- package/dist/drawer/drawer.d.ts +1 -1
- package/dist/drawer/drawer2.js +19 -19
- package/dist/dropdown/dropdown-footer.d.ts +1 -1
- package/dist/dropdown/dropdown-footer2.js +6 -6
- package/dist/dropdown/dropdown-header.d.ts +1 -1
- package/dist/dropdown/dropdown-header2.js +6 -6
- package/dist/dropdown/dropdown.d.ts +1 -1
- package/dist/dropdown/dropdown2.js +16 -16
- package/dist/dropdown-group/dropdown-group.d.ts +1 -1
- package/dist/dropdown-group/dropdown-group.js +16 -16
- package/dist/dropzone/dropzone.d.ts +2 -405
- package/dist/dropzone/dropzone2.js +14 -14
- package/dist/dropzone/dropzone2.js.map +1 -1
- package/dist/file/file2.js +1 -1
- package/dist/format-datetime/format-datetime.d.ts +1 -1
- package/dist/format-datetime/format-datetime2.js +10 -10
- package/dist/format-number/format-number.d.ts +1 -1
- package/dist/format-number/format-number2.js +16 -16
- package/dist/format-relative-time/format-relative-time.d.ts +1 -1
- package/dist/format-relative-time/format-relative-time2.js +7 -7
- package/dist/forms/control/control2.js +19 -19
- package/dist/forms/control-group/control-group.d.ts +1 -1
- package/dist/forms/control-group/control-group.js +1 -1
- package/dist/forms/control-group/control-group.js.map +1 -1
- package/dist/forms/control-group/control-group2.js +6 -6
- package/dist/forms/control-message/control-message.d.ts +1 -1
- package/dist/forms/control-message/control-message2.js +9 -9
- package/dist/grid/cell/cell.d.ts +1 -1
- package/dist/grid/cell/cell2.js +1 -1
- package/dist/grid/column/column.d.ts +1 -1
- package/dist/grid/column/column2.js +10 -10
- package/dist/grid/footer/footer.d.ts +1 -1
- package/dist/grid/footer/footer2.js +6 -6
- package/dist/grid/grid.d.ts +3 -2
- package/dist/grid/grid.examples.js.map +1 -1
- package/dist/grid/grid2.js +38 -30
- package/dist/grid/grid2.js.map +1 -1
- package/dist/grid/header/header.d.ts +1 -1
- package/dist/grid/header/header2.js +9 -9
- package/dist/grid/placeholder/placeholder.d.ts +1 -1
- package/dist/grid/placeholder/placeholder2.js +1 -1
- package/dist/grid/row/row.d.ts +1 -1
- package/dist/grid/row/row2.js +9 -9
- package/dist/icon/icon.d.ts +1 -1
- package/dist/icon/icon2.js +29 -21
- package/dist/icon/icon2.js.map +1 -1
- package/dist/icon/icons.d.ts +0 -2
- package/dist/icon/icons.js.map +1 -1
- package/dist/icon-button/icon-button.d.ts +1 -1
- package/dist/icon-button/icon-button.js +1 -1
- package/dist/icon-button/icon-button.js.map +1 -1
- package/dist/icon-button/icon-button2.js +9 -9
- package/dist/index.js +4 -4
- package/dist/input/input-group.examples.js.map +1 -1
- package/dist/input/input-group.examples.json +11 -0
- package/dist/input/input-group.js +1 -1
- package/dist/input/input-group.js.map +1 -1
- package/dist/input/input-group2.js +1 -1
- package/dist/input/input2.js +6 -6
- package/dist/internal/controllers/keynav-grid.controller.js +39 -39
- package/dist/internal/controllers/state-scroll.controller.d.ts +1 -0
- package/dist/internal/controllers/state-scroll.controller.js +25 -8
- package/dist/internal/controllers/state-scroll.controller.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.examples.js.map +1 -1
- package/dist/internal/controllers/type-button.controller.examples.json +1 -1
- package/dist/internal/controllers/type-command.controller.d.ts +6 -1
- package/dist/internal/controllers/type-command.controller.js +20 -14
- package/dist/internal/controllers/type-command.controller.js.map +1 -1
- package/dist/internal/controllers/type-native-popover.controller.js +28 -21
- package/dist/internal/controllers/type-native-popover.controller.js.map +1 -1
- package/dist/internal/controllers/type-native-popover.utils.js +7 -7
- package/dist/internal/index.d.ts +0 -1
- package/dist/internal/index.js +40 -41
- package/dist/internal/services/global.service.js +1 -1
- package/dist/internal/types/index.d.ts +0 -10
- package/dist/internal/types/index.js +0 -3
- package/dist/internal/types/index.js.map +1 -1
- package/dist/logo/logo.d.ts +1 -1
- package/dist/logo/logo2.js +6 -6
- package/dist/menu/menu-item.d.ts +5 -3
- package/dist/menu/menu-item2.js +12 -12
- package/dist/menu/menu-item2.js.map +1 -1
- package/dist/menu/menu.d.ts +1 -1
- package/dist/menu/menu.examples.js.map +1 -1
- package/dist/menu/menu.examples.json +1 -1
- package/dist/menu/menu2.js +10 -10
- package/dist/month/month.d.ts +1 -1
- package/dist/month/month2.js +7 -7
- package/dist/notification/notification-group.d.ts +1 -1
- package/dist/notification/notification-group2.js +11 -11
- package/dist/notification/notification.d.ts +2 -1
- package/dist/notification/notification.examples.js.map +1 -1
- package/dist/notification/notification.examples.json +0 -11
- package/dist/notification/notification2.js +36 -28
- package/dist/notification/notification2.js.map +1 -1
- package/dist/page/page-panel/page-panel-content.d.ts +1 -1
- package/dist/page/page-panel/page-panel-content2.js +1 -1
- package/dist/page/page-panel/page-panel-footer.d.ts +1 -1
- package/dist/page/page-panel/page-panel-footer2.js +6 -6
- package/dist/page/page-panel/page-panel-header.d.ts +1 -1
- package/dist/page/page-panel/page-panel-header2.js +6 -6
- package/dist/page/page-panel/page-panel.d.ts +2 -17
- package/dist/page/page-panel/page-panel.global.js +1 -1
- package/dist/page/page-panel/page-panel.global.js.map +1 -1
- package/dist/page/page-panel/page-panel2.js +21 -44
- package/dist/page/page-panel/page-panel2.js.map +1 -1
- package/dist/page/page.d.ts +1 -1
- package/dist/page/page.examples.js.map +1 -1
- package/dist/page/page.examples.json +0 -32
- package/dist/page/page2.js +9 -9
- package/dist/page-header/page-header.d.ts +1 -1
- package/dist/page-header/page-header2.js +1 -1
- package/dist/page-loader/page-loader.d.ts +1 -1
- package/dist/page-loader/page-loader2.js +10 -10
- package/dist/pagination/pagination.d.ts +2 -405
- package/dist/pagination/pagination2.js +17 -17
- package/dist/pagination/pagination2.js.map +1 -1
- package/dist/panel/panel.d.ts +8 -5
- package/dist/panel/panel.examples.js.map +1 -1
- package/dist/panel/panel2.js +21 -21
- package/dist/panel/panel2.js.map +1 -1
- package/dist/password/password.d.ts +1 -1
- package/dist/password/password2.js +7 -7
- package/dist/preferences-input/preferences-input.d.ts +2 -405
- package/dist/preferences-input/preferences-input2.js +9 -9
- package/dist/preferences-input/preferences-input2.js.map +1 -1
- package/dist/progress-bar/progress-bar.d.ts +1 -1
- package/dist/progress-bar/progress-bar2.js +8 -8
- package/dist/progress-ring/progress-ring.d.ts +1 -3
- package/dist/progress-ring/progress-ring2.js +17 -22
- package/dist/progress-ring/progress-ring2.js.map +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip.d.ts +1 -1
- package/dist/progressive-filter-chip/progressive-filter-chip2.js +15 -15
- package/dist/pulse/pulse.d.ts +1 -1
- package/dist/pulse/pulse2.js +6 -6
- package/dist/radio/radio-group2.js +7 -7
- package/dist/radio/radio2.js +7 -7
- package/dist/range/range.d.ts +1 -1
- package/dist/range/range2.js +5 -5
- package/dist/resize-handle/resize-handle.d.ts +2 -405
- package/dist/resize-handle/resize-handle2.js +16 -16
- package/dist/resize-handle/resize-handle2.js.map +1 -1
- package/dist/search/search.d.ts +1 -1
- package/dist/search/search2.js +8 -8
- package/dist/select/select.d.ts +2 -2
- package/dist/select/select2.js +18 -18
- package/dist/skeleton/skeleton.d.ts +1 -1
- package/dist/skeleton/skeleton2.js +7 -7
- package/dist/sort-button/sort-button.d.ts +5 -3
- package/dist/sort-button/sort-button2.js +19 -19
- package/dist/sort-button/sort-button2.js.map +1 -1
- package/dist/sparkline/sparkline.d.ts +1 -1
- package/dist/sparkline/sparkline2.js +14 -14
- package/dist/star-rating/star-rating.d.ts +1 -1
- package/dist/star-rating/star-rating2.js +6 -6
- package/dist/steps/steps.d.ts +6 -4
- package/dist/steps/steps2.js +36 -36
- package/dist/steps/steps2.js.map +1 -1
- package/dist/switch/switch-group2.js +6 -6
- package/dist/switch/switch2.js +7 -7
- package/dist/tabs/tabs-group.d.ts +1 -1
- package/dist/tabs/tabs-group2.js +21 -21
- package/dist/tabs/tabs-item.js +1 -1
- package/dist/tabs/tabs-item.js.map +1 -1
- package/dist/tabs/tabs.d.ts +6 -8
- package/dist/tabs/tabs.global.js +1 -1
- package/dist/tabs/tabs.global.js.map +1 -1
- package/dist/tabs/tabs.js +1 -1
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tabs/tabs2.js +30 -30
- package/dist/tabs/tabs2.js.map +1 -1
- package/dist/tag/tag.d.ts +6 -3
- package/dist/tag/tag2.js +20 -20
- package/dist/tag/tag2.js.map +1 -1
- package/dist/textarea/textarea2.js +1 -1
- package/dist/time/time.d.ts +1 -1
- package/dist/time/time2.js +7 -7
- package/dist/toast/toast.d.ts +3 -4
- package/dist/toast/toast2.js +21 -21
- package/dist/toast/toast2.js.map +1 -1
- package/dist/toggletip/toggletip-footer.d.ts +1 -1
- package/dist/toggletip/toggletip-footer2.js +6 -6
- package/dist/toggletip/toggletip-header.d.ts +1 -1
- package/dist/toggletip/toggletip-header2.js +6 -6
- package/dist/toggletip/toggletip.d.ts +1 -1
- package/dist/toggletip/toggletip.examples.js.map +1 -1
- package/dist/toggletip/toggletip2.js +17 -17
- package/dist/toolbar/toolbar.d.ts +1 -1
- package/dist/toolbar/toolbar2.js +11 -11
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip2.js +16 -16
- package/dist/tree/tree-node.d.ts +1 -1
- package/dist/tree/tree-node2.js +30 -30
- package/dist/tree/tree.d.ts +1 -1
- package/dist/tree/tree2.js +14 -14
- package/dist/week/week.d.ts +1 -1
- package/dist/week/week2.js +7 -7
- package/package.json +15 -15
- package/dist/internal/base/button.d.ts +0 -114
- package/dist/internal/base/button.js +0 -117
- package/dist/internal/base/button.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GlobalStateService as e } from "../services/global.service.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { onChildListMutation as t, throttle as n } from "../utils/events.js";
|
|
3
|
+
import { LogService as r } from "../services/log.service.js";
|
|
4
|
+
import { focusElement as i, getActiveElement as a, initializeKeyListItems as o, isSimpleFocusable as s, setActiveKeyListItem as c } from "../utils/focus.js";
|
|
5
|
+
import { KeynavCode as l, getFlattenedDOMTree as u, getFlattenedFocusableItems as d, hasInvalidDOMGrid as f, isContextMenuClick as p, validKeyNavigationCode as m } from "../utils/dom.js";
|
|
6
6
|
//#region src/internal/controllers/keynav-grid.controller.ts
|
|
7
7
|
function h() {
|
|
8
8
|
return (e) => e.addInitializer((e) => new g(e));
|
|
@@ -26,58 +26,58 @@ var g = class {
|
|
|
26
26
|
this.host = e, this.host.addController(this);
|
|
27
27
|
}
|
|
28
28
|
async hostConnected() {
|
|
29
|
-
await this.host.updateComplete,
|
|
29
|
+
await this.host.updateComplete, o(this.#r), this.#t.grid.addEventListener("keyup", (e) => this.#s(e)), this.#t.grid.addEventListener("keydown", (e) => this.#a(e)), this.#t.grid.addEventListener("mouseup", (e) => this.#i(e)), this.#e.push(t(this.host, n(() => o(this.#r), 500)));
|
|
30
30
|
}
|
|
31
31
|
hostDisconnected() {
|
|
32
32
|
this.#e.forEach((e) => e?.disconnect());
|
|
33
33
|
}
|
|
34
34
|
#i(e) {
|
|
35
|
-
if (!
|
|
35
|
+
if (!p(e)) {
|
|
36
36
|
let t = e.composedPath()[0], n = this.#r.find((e) => e === t) ? t : null;
|
|
37
37
|
n && this.#o(e, n);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
#a(t) {
|
|
41
|
-
let
|
|
42
|
-
if (e.state.env !== "production" &&
|
|
43
|
-
|
|
41
|
+
let n = Array.from(this.#n), i = Array.from(this.#r);
|
|
42
|
+
if (e.state.env !== "production" && f(n)) {
|
|
43
|
+
r.warn("Invalid grid structure, all rows must have the same number of cells");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
if (
|
|
47
|
-
let { x: e, y:
|
|
46
|
+
if (m(t) && s(a())) {
|
|
47
|
+
let { x: e, y: r } = y(i, n, {
|
|
48
48
|
code: t.code,
|
|
49
49
|
ctrlKey: t.ctrlKey,
|
|
50
50
|
dir: this.host.dir
|
|
51
|
-
}),
|
|
52
|
-
this.#o(t,
|
|
51
|
+
}), a = Array.from(u(n[r])).filter((e) => !!i.find((t) => t === e))[e];
|
|
52
|
+
this.#o(t, a), t.preventDefault();
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
#o(e,
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
let
|
|
55
|
+
#o(e, t) {
|
|
56
|
+
c(this.#r, t);
|
|
57
|
+
let n = d(t), r = n.filter((e) => s(e));
|
|
58
|
+
r.length === 1 && n.length === 1 ? i(r[0]) : i(t);
|
|
59
|
+
let a = {
|
|
60
60
|
code: e instanceof KeyboardEvent ? e.code : null,
|
|
61
61
|
shiftKey: e.shiftKey,
|
|
62
|
-
activeItem:
|
|
62
|
+
activeItem: t
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
t.dispatchEvent(new CustomEvent("nve-key-change", {
|
|
65
65
|
bubbles: !0,
|
|
66
66
|
composed: !0,
|
|
67
|
-
detail:
|
|
67
|
+
detail: a
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
70
|
#s(e) {
|
|
71
71
|
let t = Array.from(this.#r).find((e) => e.tabIndex === 0);
|
|
72
|
-
e.code === "Escape" && t?.focus(), e.code === "Enter" && t === e.composedPath()[0] &&
|
|
72
|
+
e.code === "Escape" && t?.focus(), e.code === "Enter" && t === e.composedPath()[0] && d(t)[0]?.focus();
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
function _(e, t) {
|
|
76
|
-
let n = t === "rtl" ?
|
|
77
|
-
return e ===
|
|
76
|
+
let n = t === "rtl" ? l.ArrowRight : l.ArrowLeft, r = t === "rtl" ? l.ArrowLeft : l.ArrowRight;
|
|
77
|
+
return e === l.ArrowUp ? {
|
|
78
78
|
dx: 0,
|
|
79
79
|
dy: -1
|
|
80
|
-
} : e ===
|
|
80
|
+
} : e === l.ArrowDown ? {
|
|
81
81
|
dx: 0,
|
|
82
82
|
dy: 1
|
|
83
83
|
} : e === n ? {
|
|
@@ -86,39 +86,39 @@ function _(e, t) {
|
|
|
86
86
|
} : e === r ? {
|
|
87
87
|
dx: 1,
|
|
88
88
|
dy: 0
|
|
89
|
-
} : e ===
|
|
89
|
+
} : e === l.PageUp ? {
|
|
90
90
|
dx: 0,
|
|
91
91
|
dy: -4
|
|
92
|
-
} : e ===
|
|
92
|
+
} : e === l.PageDown ? {
|
|
93
93
|
dx: 0,
|
|
94
94
|
dy: 4
|
|
95
95
|
} : null;
|
|
96
96
|
}
|
|
97
97
|
function v(e, t, n) {
|
|
98
|
-
let { x: r, y: i } = t, { columnCount: a, rowCount:
|
|
99
|
-
return e ===
|
|
98
|
+
let { x: r, y: i } = t, { columnCount: a, rowCount: o, ctrlKey: s } = n;
|
|
99
|
+
return e === l.End ? {
|
|
100
100
|
x: a,
|
|
101
|
-
y:
|
|
102
|
-
} : e ===
|
|
101
|
+
y: s ? o : i
|
|
102
|
+
} : e === l.Home ? {
|
|
103
103
|
x: 0,
|
|
104
|
-
y:
|
|
104
|
+
y: s ? 0 : i
|
|
105
105
|
} : {
|
|
106
106
|
x: r,
|
|
107
107
|
y: i
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
function y(e, t, n) {
|
|
111
|
-
let r = e.find((e) => e.tabIndex === 0), i = t.find((e) =>
|
|
112
|
-
return d ? (
|
|
113
|
-
x:
|
|
114
|
-
y:
|
|
111
|
+
let r = e.find((e) => e.tabIndex === 0), i = t.find((e) => u(e).find((e) => e === r)), a = Array.from(u(i)).filter((t) => !!e.find((e) => e === t)), o = t.length - 1, s = a.length - 1, c = a.indexOf(r), l = t.indexOf(i), d = _(n.code, n.dir);
|
|
112
|
+
return d ? (c = Math.max(0, Math.min(s, c + d.dx)), l = Math.max(0, Math.min(o, l + d.dy))) : {x: c, y: l} = v(n.code, {
|
|
113
|
+
x: c,
|
|
114
|
+
y: l
|
|
115
115
|
}, {
|
|
116
|
-
columnCount:
|
|
116
|
+
columnCount: s,
|
|
117
117
|
rowCount: o,
|
|
118
118
|
ctrlKey: n.ctrlKey
|
|
119
119
|
}), {
|
|
120
|
-
x:
|
|
121
|
-
y:
|
|
120
|
+
x: c,
|
|
121
|
+
y: l
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
@@ -5,26 +5,43 @@ function n() {
|
|
|
5
5
|
return (e) => e.addInitializer((e) => new r(e));
|
|
6
6
|
}
|
|
7
7
|
var r = class {
|
|
8
|
-
|
|
8
|
+
#e;
|
|
9
|
+
get #t() {
|
|
9
10
|
return this.host.stateScrollConfig?.target || this.host;
|
|
10
11
|
}
|
|
11
|
-
get #
|
|
12
|
+
get #n() {
|
|
12
13
|
return this.host.stateScrollConfig?.scrollOffset ?? 0;
|
|
13
14
|
}
|
|
14
15
|
constructor(e) {
|
|
15
16
|
this.host = e, this.host.addController(this);
|
|
16
17
|
}
|
|
17
18
|
async hostConnected() {
|
|
18
|
-
await this.host.updateComplete, t(this.host), this.#r()
|
|
19
|
+
await this.host.updateComplete, t(this.host), this.#r();
|
|
20
|
+
}
|
|
21
|
+
hostUpdated() {
|
|
22
|
+
this.#r();
|
|
19
23
|
}
|
|
20
24
|
hostDisconnected() {
|
|
21
|
-
this.#
|
|
25
|
+
this.#s();
|
|
22
26
|
}
|
|
23
|
-
#n = () => {
|
|
24
|
-
this.host._internals.states.delete("scrolling"), e(this.#e, this.#t) && this.host.dispatchEvent(new CustomEvent("scrollboxend")), this.#r();
|
|
25
|
-
};
|
|
26
27
|
#r() {
|
|
27
|
-
|
|
28
|
+
let e = this.#t;
|
|
29
|
+
this.#e !== e && (this.#s(), this.#e = e, this.#e.addEventListener("scrollend", this.#i), this.#o());
|
|
30
|
+
}
|
|
31
|
+
#i = () => {
|
|
32
|
+
this.host._internals.states.delete("scrolling"), this.#e && e(this.#e, this.#n) && this.host.dispatchEvent(new CustomEvent("scrollboxend", {
|
|
33
|
+
bubbles: !0,
|
|
34
|
+
composed: !0
|
|
35
|
+
})), this.#o();
|
|
36
|
+
};
|
|
37
|
+
#a = () => {
|
|
38
|
+
this.host._internals.states.add("scrolling");
|
|
39
|
+
};
|
|
40
|
+
#o() {
|
|
41
|
+
this.#e?.removeEventListener("scroll", this.#a), this.#e?.addEventListener("scroll", this.#a, { once: !0 });
|
|
42
|
+
}
|
|
43
|
+
#s() {
|
|
44
|
+
this.#e?.removeEventListener("scroll", this.#a), this.#e?.removeEventListener("scrollend", this.#i), this.#e = void 0;
|
|
28
45
|
}
|
|
29
46
|
};
|
|
30
47
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-scroll.controller.js","names":["#target","#offset","#
|
|
1
|
+
{"version":3,"file":"state-scroll.controller.js","names":["#target","#offset","#syncTarget","#removeTargetListeners","#activeTarget","#onScrollEnd","#startScroll","#onScroll"],"sources":["../../../src/internal/controllers/state-scroll.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 type { LegacyDecoratorTarget } from '../types/index.js';\nimport { attachInternals, endOfScrollBox } from '@nvidia-elements/core/internal';\n\n/**\n * Adds active scroll state detection\n */\nexport function stateScroll<T extends Scroll>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new StateScrollController(instance));\n}\n\nexport interface StateScrollConfig {\n target?: HTMLElement;\n scrollOffset?: number;\n}\n\nexport type Scroll = ReactiveElement & {\n _internals?: ElementInternals;\n stateScrollConfig?: StateScrollConfig;\n};\n\nexport class StateScrollController<T extends Scroll> implements ReactiveController {\n #activeTarget?: HTMLElement;\n\n get #target(): HTMLElement {\n const target = this.host.stateScrollConfig?.target;\n return target ? target : this.host;\n }\n\n get #offset() {\n return this.host.stateScrollConfig?.scrollOffset ?? 0;\n }\n\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n async hostConnected() {\n await this.host.updateComplete;\n attachInternals(this.host);\n this.#syncTarget();\n }\n\n hostUpdated() {\n this.#syncTarget();\n }\n\n hostDisconnected() {\n this.#removeTargetListeners();\n }\n\n #syncTarget() {\n const target = this.#target;\n if (this.#activeTarget === target) return;\n\n this.#removeTargetListeners();\n this.#activeTarget = target;\n this.#activeTarget.addEventListener('scrollend', this.#onScrollEnd);\n this.#startScroll();\n }\n\n #onScrollEnd = () => {\n this.host._internals!.states.delete('scrolling');\n\n if (this.#activeTarget && endOfScrollBox(this.#activeTarget, this.#offset)) {\n this.host.dispatchEvent(new CustomEvent('scrollboxend', { bubbles: true, composed: true }));\n }\n\n this.#startScroll();\n };\n\n #onScroll = () => {\n this.host._internals!.states.add('scrolling');\n };\n\n #startScroll() {\n this.#activeTarget?.removeEventListener('scroll', this.#onScroll);\n this.#activeTarget?.addEventListener('scroll', this.#onScroll, { once: true });\n }\n\n #removeTargetListeners() {\n this.#activeTarget?.removeEventListener('scroll', this.#onScroll);\n this.#activeTarget?.removeEventListener('scrollend', this.#onScrollEnd);\n this.#activeTarget = undefined;\n }\n}\n"],"mappings":";;;AAUA,SAAgB,IAAgD;CAC9D,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAsB,CAAQ,CAAC;AAC/E;AAYA,IAAa,IAAb,MAAmF;CACjF;CAEA,IAAIA,KAAuB;EAEzB,OADe,KAAK,KAAK,mBAAmB,UACnB,KAAK;CAChC;CAEA,IAAIC,KAAU;EACZ,OAAO,KAAK,KAAK,mBAAmB,gBAAgB;CACtD;CAEA,YAAY,GAAiB;EAC3B,AADkB,KAAA,OAAA,GAClB,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,MAAM,gBAAgB;EAGpB,AAFA,MAAM,KAAK,KAAK,gBAChB,EAAgB,KAAK,IAAI,GACzB,KAAKC,GAAY;CACnB;CAEA,cAAc;EACZ,KAAKA,GAAY;CACnB;CAEA,mBAAmB;EACjB,KAAKC,GAAuB;CAC9B;CAEA,KAAc;EACZ,IAAM,IAAS,KAAKH;EAChB,KAAKI,OAAkB,MAE3B,KAAKD,GAAuB,GAC5B,KAAKC,KAAgB,GACrB,KAAKA,GAAc,iBAAiB,aAAa,KAAKC,EAAY,GAClE,KAAKC,GAAa;CACpB;CAEA,WAAqB;EAOnB,AANA,KAAK,KAAK,WAAY,OAAO,OAAO,WAAW,GAE3C,KAAKF,MAAiB,EAAe,KAAKA,IAAe,KAAKH,EAAO,KACvE,KAAK,KAAK,cAAc,IAAI,YAAY,gBAAgB;GAAE,SAAS;GAAM,UAAU;EAAK,CAAC,CAAC,GAG5F,KAAKK,GAAa;CACpB;CAEA,WAAkB;EAChB,KAAK,KAAK,WAAY,OAAO,IAAI,WAAW;CAC9C;CAEA,KAAe;EAEb,AADA,KAAKF,IAAe,oBAAoB,UAAU,KAAKG,EAAS,GAChE,KAAKH,IAAe,iBAAiB,UAAU,KAAKG,IAAW,EAAE,MAAM,GAAK,CAAC;CAC/E;CAEA,KAAyB;EAGvB,AAFA,KAAKH,IAAe,oBAAoB,UAAU,KAAKG,EAAS,GAChE,KAAKH,IAAe,oBAAoB,aAAa,KAAKC,EAAY,GACtE,KAAKD,KAAgB,KAAA;CACvB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-button.controller.examples.js","names":[],"sources":["../../../src/internal/controllers/type-button.controller.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html } from 'lit';\nimport {
|
|
1
|
+
{"version":3,"file":"type-button.controller.examples.js","names":[],"sources":["../../../src/internal/controllers/type-button.controller.examples.ts"],"sourcesContent":["// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { css, html, LitElement } from 'lit';\nimport { ButtonFormControlMixin } from '@nvidia-elements/forms/mixins';\nimport '@nvidia-elements/core/card/define.js';\nimport '@nvidia-elements/core/button/define.js';\nimport '@nvidia-elements/core/icon-button/define.js';\n\nexport default {\n title: 'Internal/Controllers'\n}\n\nclass UIButton extends ButtonFormControlMixin(LitElement) {\n static styles = [css`\n :host {\n --background: hsl(0, 0%, 90%);\n --color: hsl(0, 0%, 0%);\n --cursor: pointer;\n display: inline-flex;\n position: relative;\n }\n\n [internal-host] {\n background: var(--background);\n color: var(--color);\n cursor: var(--cursor);\n padding: 8px 12px;\n min-width: 75px;\n text-align: center;\n }\n\n /* element states */\n :host(:hover) {\n --background: hsl(0, 0%, 95%);\n }\n\n :host(:state(active)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(pressed)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(expanded)) {\n --background: hsl(0, 0%, 85%);\n }\n\n :host(:state(disabled)) {\n --background: hsl(0, 0%, 80%);\n --color: hsl(0, 0%, 60%);\n --cursor: not-allowed;\n }\n\n :host(:state(readonly)) {\n --cursor: initial;\n --color: blue;\n }\n\n /* anchor styles */\n [internal-host]:focus-within {\n outline: Highlight solid 2px;\n outline: 5px auto -webkit-focus-ring-color;\n }\n\n ::slotted(a) {\n color: var(--color) !important;\n text-decoration: none !important;\n outline: 0 !important;\n }\n\n ::slotted(a)::after {\n position: absolute;\n content: '';\n inset: 0;\n display: block;\n }\n `]\n}\n\ncustomElements.get('ui-button') || customElements.define('ui-button', UIButton);\n\n/**\n * Example of custom element button using the button form control mixin.\n * When a custom element applies the mixin it inherits button behaviors and states.\n * @summary Custom button element using ButtonFormControlMixin with pressed, expanded, disabled, and link states.\n * @tags test-case\n */\nexport const TypeButtonDemo = {\n render: () => html`\n<ui-button>button</ui-button>\n<ui-button pressed>pressed</ui-button>\n<ui-button expanded>expanded</ui-button>\n<ui-button selected>selected</ui-button>\n<ui-button disabled>disabled</ui-button>\n<ui-button><a href=\"#\">link</a></ui-button>\n\n<form id=\"type-button-demo-form\" style=\"display: inline-flex;\">\n <ui-button type=\"submit\">submit</ui-button>\n</form>\n<script type=\"module\">\n const form = document.querySelector('#type-button-demo-form');\n form.addEventListener('submit', (e) => {\n e.preventDefault();\n alert('submit!');\n });\n</script>`\n};\n"],"mappings":";AAGA,IAAA,IAAc"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"id": "internal-controllers-type-button.controller-type-button-demo",
|
|
6
6
|
"name": "TypeButtonDemo",
|
|
7
7
|
"template": "<ui-button>button</ui-button>\n<ui-button pressed>pressed</ui-button>\n<ui-button expanded>expanded</ui-button>\n<ui-button selected>selected</ui-button>\n<ui-button disabled>disabled</ui-button>\n<ui-button><a href=\"#\">link</a></ui-button>\n<form id=\"type-button-demo-form\" style=\"display: inline-flex\">\n <ui-button type=\"submit\">submit</ui-button>\n</form>\n<script type=\"module\">\n const form = document.querySelector(\"#type-button-demo-form\");\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n alert(\"submit!\");\n });\n</script>\n",
|
|
8
|
-
"summary": "Custom button element using
|
|
8
|
+
"summary": "Custom button element using ButtonFormControlMixin with pressed, expanded, disabled, and link states.",
|
|
9
9
|
"description": "",
|
|
10
10
|
"composition": false,
|
|
11
11
|
"tags": [
|
|
@@ -14,7 +14,12 @@ export type Command = ReactiveElement & HTMLElement & {
|
|
|
14
14
|
export declare class TypeCommandController<T extends Command> implements ReactiveController {
|
|
15
15
|
#private;
|
|
16
16
|
private host;
|
|
17
|
-
constructor(host: T);
|
|
17
|
+
constructor(host: T, options?: TypeCommandControllerOptions);
|
|
18
|
+
get target(): HTMLElement | null;
|
|
18
19
|
hostUpdated(): Promise<void>;
|
|
19
20
|
hostDisconnected(): void;
|
|
21
|
+
dispatchCommand(): boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface TypeCommandControllerOptions {
|
|
24
|
+
trigger?: 'click' | 'manual';
|
|
20
25
|
}
|
|
@@ -4,27 +4,33 @@ function t() {
|
|
|
4
4
|
return (e) => e.addInitializer((e) => new n(e));
|
|
5
5
|
}
|
|
6
6
|
var n = class {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
#e;
|
|
8
|
+
constructor(e, t = {}) {
|
|
9
|
+
this.host = e, this.#e = t.trigger ?? "click", this.host.addController(this);
|
|
10
|
+
}
|
|
11
|
+
get target() {
|
|
12
|
+
return this.host.commandForElement ? this.host.commandForElement : this.host.commandfor ? e(this.host.getRootNode()).find((e) => e.id === this.host.commandfor) ?? null : null;
|
|
9
13
|
}
|
|
10
14
|
async hostUpdated() {
|
|
11
|
-
await this.host.updateComplete, this.#
|
|
15
|
+
await this.host.updateComplete, this.#t();
|
|
12
16
|
}
|
|
13
17
|
hostDisconnected() {
|
|
14
|
-
this.host.removeEventListener("click", this.#
|
|
18
|
+
this.host.removeEventListener("click", this.#n);
|
|
15
19
|
}
|
|
16
|
-
#
|
|
17
|
-
|
|
20
|
+
#t() {
|
|
21
|
+
this.#e === "manual" || this.host.readOnly || this.host.disabled ? this.host.removeEventListener("click", this.#n) : this.host.addEventListener("click", this.#n);
|
|
18
22
|
}
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
let t = e(this.host.getRootNode()).find((e) => e.id === this.host.commandfor || e === this.host.commandForElement);
|
|
22
|
-
t ? t.dispatchEvent(new globalThis.CommandEvent("command", {
|
|
23
|
-
command: this.host.command,
|
|
24
|
-
source: this.host
|
|
25
|
-
})) : console.warn("commandForElement", this.host.commandfor || this.host.commandForElement, "not found");
|
|
26
|
-
}
|
|
23
|
+
#n = (e) => {
|
|
24
|
+
e.defaultPrevented || this.dispatchCommand();
|
|
27
25
|
};
|
|
26
|
+
dispatchCommand() {
|
|
27
|
+
if (this.host.readOnly || this.host.disabled || !this.host.command) return !1;
|
|
28
|
+
let e = this.target;
|
|
29
|
+
return e ? (e.dispatchEvent(new globalThis.CommandEvent("command", {
|
|
30
|
+
command: this.host.command,
|
|
31
|
+
source: this.host
|
|
32
|
+
})), !0) : ((this.host.commandfor || this.host.commandForElement) && console.warn("commandForElement", this.host.commandfor || this.host.commandForElement, "not found"), !1);
|
|
33
|
+
}
|
|
28
34
|
};
|
|
29
35
|
//#endregion
|
|
30
36
|
export { n as TypeCommandController, t as typeCommand };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-command.controller.js","names":["#updateListener","#triggerCommand"],"sources":["../../../src/internal/controllers/type-command.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 type { LegacyDecoratorTarget } from '../types/index.js';\nimport { getFlattenedDOMTree } from '../utils/dom.js';\n\n/**\n * Adds Invoker Commands API support for interactive custom elements.\n * https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API\n */\nexport function typeCommand<T extends Command>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new TypeCommandController(instance));\n}\n\nexport type Command = ReactiveElement &\n HTMLElement & {\n command: string;\n commandfor: string | null;\n commandForElement: HTMLElement | null;\n readOnly: boolean;\n disabled: boolean;\n };\n\nexport class TypeCommandController<T extends Command> implements ReactiveController {\n constructor(private host: T) {\n this.host.addController(this);\n }\n\n async hostUpdated() {\n await this.host.updateComplete;\n this.#updateListener();\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#triggerCommand);\n }\n\n #updateListener() {\n if (
|
|
1
|
+
{"version":3,"file":"type-command.controller.js","names":["#trigger","#updateListener","#triggerCommand"],"sources":["../../../src/internal/controllers/type-command.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 type { LegacyDecoratorTarget } from '../types/index.js';\nimport { getFlattenedDOMTree } from '../utils/dom.js';\n\n/**\n * Adds Invoker Commands API support for interactive custom elements.\n * https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API\n */\nexport function typeCommand<T extends Command>(): ClassDecorator {\n return (target: LegacyDecoratorTarget) =>\n target.addInitializer!((instance: T) => new TypeCommandController(instance));\n}\n\nexport type Command = ReactiveElement &\n HTMLElement & {\n command: string;\n commandfor: string | null;\n commandForElement: HTMLElement | null;\n readOnly: boolean;\n disabled: boolean;\n };\n\nexport class TypeCommandController<T extends Command> implements ReactiveController {\n #trigger: 'click' | 'manual';\n\n constructor(\n private host: T,\n options: TypeCommandControllerOptions = {}\n ) {\n this.#trigger = options.trigger ?? 'click';\n this.host.addController(this);\n }\n\n get target(): HTMLElement | null {\n if (this.host.commandForElement) {\n return this.host.commandForElement;\n }\n\n if (!this.host.commandfor) {\n return null;\n }\n\n return (\n getFlattenedDOMTree(this.host.getRootNode() as HTMLElement).find(el => el.id === this.host.commandfor) ?? null\n );\n }\n\n async hostUpdated() {\n await this.host.updateComplete;\n this.#updateListener();\n }\n\n hostDisconnected() {\n this.host.removeEventListener('click', this.#triggerCommand);\n }\n\n #updateListener() {\n if (this.#trigger === 'manual' || this.host.readOnly || this.host.disabled) {\n this.host.removeEventListener('click', this.#triggerCommand);\n } else {\n this.host.addEventListener('click', this.#triggerCommand);\n }\n }\n\n #triggerCommand = (event: Event) => {\n if (event.defaultPrevented) {\n return;\n }\n\n this.dispatchCommand();\n };\n\n dispatchCommand() {\n if (this.host.readOnly || this.host.disabled || !this.host.command) {\n return false;\n }\n\n const target = this.target;\n if (!target) {\n if (this.host.commandfor || this.host.commandForElement) {\n console.warn('commandForElement', this.host.commandfor || this.host.commandForElement, 'not found');\n }\n return false;\n }\n\n target.dispatchEvent(new globalThis.CommandEvent('command', { command: this.host.command, source: this.host }));\n return true;\n }\n}\n\nexport interface TypeCommandControllerOptions {\n trigger?: 'click' | 'manual';\n}\n"],"mappings":";;AAWA,SAAgB,IAAiD;CAC/D,QAAQ,MACN,EAAO,gBAAiB,MAAgB,IAAI,EAAsB,CAAQ,CAAC;AAC/E;AAWA,IAAa,IAAb,MAAoF;CAClF;CAEA,YACE,GACA,IAAwC,CAAC,GACzC;EAEA,AAJQ,KAAA,OAAA,GAGR,KAAKA,KAAW,EAAQ,WAAW,SACnC,KAAK,KAAK,cAAc,IAAI;CAC9B;CAEA,IAAI,SAA6B;EAS/B,OARI,KAAK,KAAK,oBACL,KAAK,KAAK,oBAGd,KAAK,KAAK,aAKb,EAAoB,KAAK,KAAK,YAAY,CAAgB,EAAE,MAAK,MAAM,EAAG,OAAO,KAAK,KAAK,UAAU,KAAK,OAJnG;CAMX;CAEA,MAAM,cAAc;EAElB,AADA,MAAM,KAAK,KAAK,gBAChB,KAAKC,GAAgB;CACvB;CAEA,mBAAmB;EACjB,KAAK,KAAK,oBAAoB,SAAS,KAAKC,EAAe;CAC7D;CAEA,KAAkB;EAChB,AAAI,KAAKF,OAAa,YAAY,KAAK,KAAK,YAAY,KAAK,KAAK,WAChE,KAAK,KAAK,oBAAoB,SAAS,KAAKE,EAAe,IAE3D,KAAK,KAAK,iBAAiB,SAAS,KAAKA,EAAe;CAE5D;CAEA,MAAmB,MAAiB;EAC9B,EAAM,oBAIV,KAAK,gBAAgB;CACvB;CAEA,kBAAkB;EAChB,IAAI,KAAK,KAAK,YAAY,KAAK,KAAK,YAAY,CAAC,KAAK,KAAK,SACzD,OAAO;EAGT,IAAM,IAAS,KAAK;EASpB,OARK,KAOL,EAAO,cAAc,IAAI,WAAW,aAAa,WAAW;GAAE,SAAS,KAAK,KAAK;GAAS,QAAQ,KAAK;EAAK,CAAC,CAAC,GACvG,QAPD,KAAK,KAAK,cAAc,KAAK,KAAK,sBACpC,QAAQ,KAAK,qBAAqB,KAAK,KAAK,cAAc,KAAK,KAAK,mBAAmB,WAAW,GAE7F;CAKX;AACF"}
|
|
@@ -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.#p(), this.#f(), this.#u(), 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 &&
|
|
29
|
+
this.host.behaviorTrigger && (this.host.hidden = e.newState === "closed"), e.newState === "open" && this.host.closeTimeout && this.#a(), e.newState === "closed" && (this.#s(), this.#o()), this.host.inert = this.host.matches(":not(:popover-open)"), this.host.modal && this.#m(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(), this.#
|
|
35
|
+
e.command === "toggle-popover" && this.host.togglePopover({ source: e.source }), e.command === "hide-popover" && (this.host.hidePopover(), this.#s()), 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.#c();
|
|
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 });
|
|
@@ -45,44 +45,51 @@ var c = class {
|
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
47
|
#t = null;
|
|
48
|
-
#n =
|
|
49
|
-
#r =
|
|
48
|
+
#n = null;
|
|
49
|
+
#r = [];
|
|
50
|
+
#i = null;
|
|
50
51
|
async hostUpdated() {
|
|
51
|
-
this.host.popover = this.host.popoverType ?? null, this.#
|
|
52
|
+
this.host.popover = this.host.popoverType ?? null, this.#p();
|
|
52
53
|
}
|
|
53
54
|
hostDisconnected() {
|
|
54
|
-
this.#
|
|
55
|
+
this.#r.forEach((e) => e.disconnect()), this.#s(), this.#o();
|
|
55
56
|
}
|
|
56
|
-
#
|
|
57
|
+
#a() {
|
|
58
|
+
this.#o(), this.host.closeTimeout && (this.#n = setTimeout(() => this.host.hidePopover(), this.host.closeTimeout));
|
|
59
|
+
}
|
|
60
|
+
#o() {
|
|
61
|
+
this.#n &&= (clearTimeout(this.#n), null);
|
|
62
|
+
}
|
|
63
|
+
#s() {
|
|
57
64
|
this.#t &&= (clearTimeout(this.#t), null);
|
|
58
65
|
}
|
|
59
|
-
#
|
|
66
|
+
#c() {
|
|
60
67
|
let e = getComputedStyle(this.host).interestDelayStart;
|
|
61
68
|
if (!e) return 0;
|
|
62
69
|
let t = parseFloat(e);
|
|
63
70
|
return e.endsWith("ms") ? t : t * 1e3;
|
|
64
71
|
}
|
|
65
|
-
#
|
|
66
|
-
#
|
|
72
|
+
#l = !1;
|
|
73
|
+
#u() {
|
|
67
74
|
this.host.addEventListener("pointerdown", (e) => {
|
|
68
|
-
this.host.modal && this.host.matches(":popover-open") && (this.#
|
|
75
|
+
this.host.modal && this.host.matches(":popover-open") && (this.#l = t(e, this.host));
|
|
69
76
|
}), this.host.addEventListener("pointerup", (e) => {
|
|
70
|
-
this.#
|
|
77
|
+
this.#l && this.host.popoverDismissible && this.host.modal && this.host.matches(":popover-open") && !s(this.host) && t(e, this.host) && this.host.hidePopover();
|
|
71
78
|
});
|
|
72
79
|
}
|
|
73
|
-
get #
|
|
80
|
+
get #d() {
|
|
74
81
|
return this.host.trigger ? o(this.host, this.host.trigger) : null;
|
|
75
82
|
}
|
|
76
|
-
async #
|
|
77
|
-
await new Promise((e) => requestAnimationFrame(e)), this.#
|
|
83
|
+
async #f() {
|
|
84
|
+
await new Promise((e) => requestAnimationFrame(e)), this.#r.push(r(this.host, ["hidden"], () => {
|
|
78
85
|
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();
|
|
79
86
|
})), this.host.isConnected && !this.#e.length && !this.host.hidden && !this.host.matches(":popover-open") && (this.host.popover = "manual", this.host.showPopover());
|
|
80
87
|
}
|
|
81
|
-
#
|
|
82
|
-
let e = this.#
|
|
83
|
-
this.#
|
|
88
|
+
#p() {
|
|
89
|
+
let e = this.#d;
|
|
90
|
+
this.#i && this.#i !== e && (this.#i.popoverTargetElement = null, this.#i.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.#i = e);
|
|
84
91
|
}
|
|
85
|
-
#
|
|
92
|
+
#m(t, n) {
|
|
86
93
|
t ? this.host.getRootNode().activeElement !== this.host && !this.host.shadowRoot.activeElement && e(this.host) : e(n);
|
|
87
94
|
}
|
|
88
95
|
};
|
|
@@ -1 +1 @@
|
|
|
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);\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,iBAC9F,EAAa,KAAK,IAAI,IAGxB,EAAa,CAAM;CAEvB;AACF"}
|
|
1
|
+
{"version":3,"file":"type-native-popover.controller.js","names":["#nativeTriggers","#updateLegacyTriggers","#setupLegacyTriggers","#setupModalLightDismiss","#setCloseTimeout","#clearInterestTimeout","#clearCloseTimeout","#toggleFocus","#parseInterestDelay","#interestTimeout","#observers","#closeTimeout","#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 this.#setCloseTimeout();\n }\n\n if (e.newState === 'closed') {\n this.#clearInterestTimeout();\n this.#clearCloseTimeout();\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 #closeTimeout: 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 this.#clearCloseTimeout();\n }\n\n #setCloseTimeout() {\n this.#clearCloseTimeout();\n if (this.host.closeTimeout) {\n this.#closeTimeout = setTimeout(() => this.host.hidePopover(), this.host.closeTimeout);\n }\n }\n\n #clearCloseTimeout() {\n if (this.#closeTimeout) {\n clearTimeout(this.#closeTimeout);\n this.#closeTimeout = null;\n }\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,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,GA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KAAK,KAAK,UAAU,KAAK,KAAK,QAAQ,eAAe,KAChF,KAAK,KAAK,YAAY;EAE1B,CAAC,CACH,GAIE,KAAK,KAAK,eACV,CAAC,KAAKV,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,KAAKa;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,20 +1,20 @@
|
|
|
1
1
|
import { getIdMatchNotFoundWarning as e } from "../utils/audit-logs.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { LogService as t } from "../services/log.service.js";
|
|
3
|
+
import { getFlattenedDOMTree as n } from "../utils/dom.js";
|
|
4
4
|
//#region src/internal/controllers/type-native-popover.utils.ts
|
|
5
|
-
function r(e,
|
|
6
|
-
return typeof
|
|
5
|
+
function r(e, t) {
|
|
6
|
+
return typeof t == "string" ? n(e.parentNode).filter((e) => e?.id !== "").find((e) => e.id === t) ?? globalThis.document.body : t;
|
|
7
7
|
}
|
|
8
8
|
function i(r) {
|
|
9
9
|
let i = r.anchor ?? r._activeTrigger;
|
|
10
10
|
if (typeof i == "string" && i?.length) {
|
|
11
|
-
let a =
|
|
12
|
-
return a ||
|
|
11
|
+
let a = n(r.parentNode).find((e) => e.id === i);
|
|
12
|
+
return a || t.warn(e(i)), a ?? globalThis.document.body;
|
|
13
13
|
} else if (i && i !== globalThis.document.body) return i;
|
|
14
14
|
else return globalThis.document.body;
|
|
15
15
|
}
|
|
16
16
|
function a(e) {
|
|
17
|
-
return !!
|
|
17
|
+
return !!n(e).filter((e) => e.popover && e.matches(":popover-open")).length;
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
20
|
export { i as getHostAnchor, r as getHostTrigger, a as hasOpenPopover };
|
package/dist/internal/index.d.ts
CHANGED