@ulu/frontend 0.2.0-beta.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.dev.md +36 -13
- package/README.md +3 -1
- package/dist/es/core/events.js +36 -25
- package/dist/es/core/settings.js +33 -22
- package/dist/es/index.js +92 -88
- package/dist/es/ui/dialog.js +57 -46
- package/dist/es/ui/index.d.ts +2 -0
- package/dist/es/ui/modal-builder.js +39 -28
- package/dist/es/ui/overflow-scroller.js +30 -24
- package/dist/es/ui/programmatic-modal.js +55 -0
- package/dist/es/ui/proxy-click.js +37 -26
- package/dist/es/ui/resizer.js +57 -49
- package/dist/es/ui/slider.d.ts.map +1 -1
- package/dist/es/ui/slider.js +90 -67
- package/dist/es/ui/tab-manager.d.ts +145 -0
- package/dist/es/ui/tab-manager.d.ts.map +1 -0
- package/dist/es/ui/tab-manager.js +155 -0
- package/dist/es/ui/tabs.d.ts +5 -5
- package/dist/es/ui/tabs.d.ts.map +1 -1
- package/dist/es/ui/tabs.js +34 -51
- package/dist/es/ui/theme-toggle.js +80 -69
- package/dist/es/ui/tooltip.js +53 -44
- package/dist/es/utils/floating-ui.js +35 -24
- package/dist/umd/frontend.css +1 -0
- package/dist/umd/ulu-frontend.umd.js +40 -47
- package/lib/js/exports.md +1 -0
- package/lib/js/ui/index.js +8 -0
- package/lib/js/ui/slider.js +3 -3
- package/lib/js/ui/tab-manager.js +324 -0
- package/lib/js/ui/tabs.js +33 -92
- package/lib/scss/_breakpoint.scss +3 -3
- package/lib/scss/_button.scss +3 -3
- package/lib/scss/_color.scss +3 -2
- package/lib/scss/_element.scss +10 -4
- package/lib/scss/_layout.scss +11 -4
- package/lib/scss/_selector.scss +2 -1
- package/lib/scss/_typography.scss +9 -10
- package/lib/scss/_utils.scss +52 -19
- package/lib/scss/base/_elements.scss +1 -1
- package/lib/scss/components/_basic-hero.scss +1 -1
- package/lib/scss/components/_button-verbose.scss +2 -2
- package/lib/scss/components/_callout.scss +3 -4
- package/lib/scss/components/_css-icon.scss +2 -2
- package/lib/scss/components/_data-grid.scss +5 -5
- package/lib/scss/components/_flipcard.scss +3 -2
- package/lib/scss/components/_index.scss +6 -0
- package/lib/scss/components/_panel.scss +1 -1
- package/lib/scss/components/_popover.scss +9 -6
- package/lib/scss/components/_tabs.scss +20 -5
- package/lib/scss/components/_tagged.scss +59 -0
- package/package.json +25 -35
- package/dist/umd/style.css +0 -1
- package/lib/js/ui/dialog.todo +0 -3
package/dist/es/ui/tabs.js
CHANGED
|
@@ -1,64 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var s = Object.getOwnPropertySymbols;
|
|
3
|
+
var d = Object.prototype.hasOwnProperty, f = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var c = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, l = (i, e) => {
|
|
5
|
+
for (var t in e || (e = {}))
|
|
6
|
+
d.call(e, t) && c(i, t, e[t]);
|
|
7
|
+
if (s)
|
|
8
|
+
for (var t of s(e))
|
|
9
|
+
f.call(e, t) && c(i, t, e[t]);
|
|
10
|
+
return i;
|
|
11
|
+
};
|
|
12
|
+
import { TabManager as p } from "./tab-manager.js";
|
|
13
|
+
import { ComponentInitializer as b } from "../core/component.js";
|
|
14
|
+
import { ensureId as m } from "../utils/id.js";
|
|
15
|
+
const h = [], w = new b({
|
|
4
16
|
type: "tabs",
|
|
5
17
|
baseAttribute: "data-ulu-tablist"
|
|
6
18
|
});
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
19
|
+
function M() {
|
|
20
|
+
const i = () => {
|
|
21
|
+
w.init({
|
|
10
22
|
coreEvents: ["pageModified"],
|
|
11
23
|
withData: !0,
|
|
12
|
-
setup({ element:
|
|
13
|
-
|
|
24
|
+
setup({ element: e, data: t, initialize: o }) {
|
|
25
|
+
y(e, t), o();
|
|
14
26
|
}
|
|
15
|
-
})
|
|
27
|
+
});
|
|
16
28
|
};
|
|
17
|
-
document.readyState === "complete" ?
|
|
18
|
-
}
|
|
19
|
-
function m(e, n = {}) {
|
|
20
|
-
const t = Object.assign({}, n);
|
|
21
|
-
t.vertical && (t.allArrows = !0);
|
|
22
|
-
const o = { element: e, options: n };
|
|
23
|
-
return o.ariaTablist = f(e, {
|
|
24
|
-
onOpen(...a) {
|
|
25
|
-
a.unshift(o), g.apply(null, a);
|
|
26
|
-
},
|
|
27
|
-
...t
|
|
28
|
-
}), l.push(o), t.equalHeights && w(e), o;
|
|
29
|
+
document.readyState === "complete" ? i() : window.addEventListener("load", i);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
o === a.id && n.open(a);
|
|
37
|
-
});
|
|
31
|
+
function y(i, e = {}) {
|
|
32
|
+
const t = l({}, e);
|
|
33
|
+
t.vertical && (t.allArrows = !0), t.openByUrlHash && (t.setUrlHash = !0), [...i.children].forEach((n) => {
|
|
34
|
+
if (!n.hasAttribute("aria-controls")) {
|
|
35
|
+
const r = document.querySelector(`[aria-labelledby="${n.id}"]`);
|
|
36
|
+
r && (m(r), n.setAttribute("aria-controls", r.id));
|
|
38
37
|
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function g({ options: e }, n, t) {
|
|
42
|
-
e.openByUrlHash && window.history && window.history.replaceState(null, "", `#${t.id}`);
|
|
43
|
-
}
|
|
44
|
-
function w(e) {
|
|
45
|
-
const t = [...e.children].map((i) => document.querySelector(`[aria-labelledby="${i.id}"]`)), h = [...t[0].parentElement.querySelectorAll("img")].map((i) => d(i));
|
|
46
|
-
function d(i) {
|
|
47
|
-
return new Promise((r) => {
|
|
48
|
-
i.complete ? r(i) : (i.onload = r, i.onerror = r);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
Promise.all(h).then(() => {
|
|
52
|
-
const i = t.map((s) => {
|
|
53
|
-
let c = s.offsetHeight;
|
|
54
|
-
return s.hidden && (s.hidden = !1, c = s.offsetHeight, s.setAttribute("hidden", "hidden")), c;
|
|
55
|
-
}), r = Math.max(...i);
|
|
56
|
-
t.forEach((s) => s.style.minHeight = `${r}px`);
|
|
57
38
|
});
|
|
39
|
+
const a = { element: i, options: e };
|
|
40
|
+
return a.tabManager = new p(i, t), h.push(a), a;
|
|
58
41
|
}
|
|
59
42
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
M as init,
|
|
44
|
+
w as initializer,
|
|
45
|
+
h as instances,
|
|
46
|
+
y as setup
|
|
64
47
|
};
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var j = Object.defineProperty, O = Object.defineProperties;
|
|
2
|
+
var R = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var C = Object.getOwnPropertySymbols;
|
|
4
|
+
var w = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var E = (e, t, r) => t in e ? j(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, h = (e, t) => {
|
|
6
|
+
for (var r in t || (t = {}))
|
|
7
|
+
w.call(t, r) && E(e, r, t[r]);
|
|
8
|
+
if (C)
|
|
9
|
+
for (var r of C(t))
|
|
10
|
+
K.call(t, r) && E(e, r, t[r]);
|
|
11
|
+
return e;
|
|
12
|
+
}, b = (e, t) => O(e, R(t));
|
|
13
|
+
import { ComponentInitializer as D } from "../core/component.js";
|
|
14
|
+
import { getCoreEventName as k } from "../core/events.js";
|
|
15
|
+
import { resolveClasses as y } from "../utils/dom.js";
|
|
16
|
+
import { hasRequiredProps as z } from "@ulu/utils/object.js";
|
|
17
|
+
import { getElements as A } from "@ulu/utils/browser/dom.js";
|
|
18
|
+
const c = new D({
|
|
7
19
|
type: "theme-toggle",
|
|
8
20
|
baseAttribute: "data-ulu-theme-toggle"
|
|
9
|
-
}),
|
|
10
|
-
`[${
|
|
11
|
-
),
|
|
12
|
-
`[${
|
|
13
|
-
),
|
|
21
|
+
}), _ = c.attributeSelector("label"), N = c.attributeSelector("icon"), M = c.getAttribute("remote"), S = c.getAttribute("init"), x = c.getAttribute("state"), F = (e) => document.querySelectorAll(
|
|
22
|
+
`[${M}="${e}"]`
|
|
23
|
+
), I = (e) => document.querySelectorAll(
|
|
24
|
+
`[${M}="${e}"]:not([${S}])`
|
|
25
|
+
), q = ["target"], U = z(q), L = (e, t) => e ? t() : null, Q = {
|
|
14
26
|
/**
|
|
15
27
|
* Object of each theme that should be toggle/cycled through
|
|
16
28
|
*/
|
|
@@ -66,125 +78,124 @@ const c = new M({
|
|
|
66
78
|
*/
|
|
67
79
|
debug: !1
|
|
68
80
|
};
|
|
69
|
-
let
|
|
70
|
-
function
|
|
71
|
-
|
|
81
|
+
let T = h({}, Q);
|
|
82
|
+
function re(e) {
|
|
83
|
+
T = Object.assign({}, T, e);
|
|
72
84
|
}
|
|
73
|
-
function
|
|
85
|
+
function oe() {
|
|
74
86
|
c.init({
|
|
75
87
|
coreEvents: ["pageModified"],
|
|
76
88
|
withData: !0,
|
|
77
|
-
setup({ element: e, data:
|
|
78
|
-
|
|
89
|
+
setup({ element: e, data: t, initialize: r }) {
|
|
90
|
+
B(e, t), r();
|
|
79
91
|
}
|
|
80
92
|
});
|
|
81
93
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
console.error(`Missing a required option: ${
|
|
94
|
+
function B(e, t) {
|
|
95
|
+
const r = Object.assign({}, Q, t);
|
|
96
|
+
if (!U(r)) {
|
|
97
|
+
console.error(`Missing a required option: ${q.join(", ")}`);
|
|
86
98
|
return;
|
|
87
99
|
}
|
|
88
|
-
const
|
|
100
|
+
const o = r.group, n = { toggle: e, options: r }, u = G(r);
|
|
89
101
|
if (!u) {
|
|
90
102
|
console.error("Unable to resolve initial key");
|
|
91
103
|
return;
|
|
92
104
|
}
|
|
93
|
-
|
|
105
|
+
v(u, n), e.addEventListener("click", a), l(), document.addEventListener(k("pageModified"), l);
|
|
94
106
|
function s(g) {
|
|
95
|
-
const d =
|
|
107
|
+
const d = A(r.target)[0].dataset.uluThemeToggleState, f = J(d, r);
|
|
96
108
|
if (!f) {
|
|
97
109
|
console.error("Issue getting next theme key");
|
|
98
110
|
return;
|
|
99
111
|
}
|
|
100
|
-
|
|
112
|
+
v(f, b(h({}, n), { event: g }));
|
|
101
113
|
}
|
|
102
114
|
function a(g) {
|
|
103
115
|
s(g);
|
|
104
116
|
}
|
|
105
117
|
function l() {
|
|
106
|
-
if (!
|
|
107
|
-
|
|
118
|
+
if (!o) return;
|
|
119
|
+
I(o).forEach((i) => {
|
|
108
120
|
i.addEventListener("click", a), c.initializeElement(i);
|
|
109
121
|
});
|
|
110
122
|
}
|
|
111
123
|
function m() {
|
|
112
|
-
if (!
|
|
113
|
-
|
|
114
|
-
i.removeEventListener("click", a), i.removeAttribute(
|
|
124
|
+
if (!o) return;
|
|
125
|
+
I(o).forEach((i) => {
|
|
126
|
+
i.removeEventListener("click", a), i.removeAttribute(S, "");
|
|
115
127
|
});
|
|
116
128
|
}
|
|
117
|
-
function
|
|
118
|
-
e.removeEventListener("click", a), e.removeAttribute(
|
|
129
|
+
function p() {
|
|
130
|
+
e.removeEventListener("click", a), e.removeAttribute(S, ""), m(), document.removeEventListener(k("pageModified"), l);
|
|
119
131
|
}
|
|
120
132
|
return {
|
|
121
|
-
destroy:
|
|
133
|
+
destroy: p,
|
|
122
134
|
toggle: e,
|
|
123
|
-
options:
|
|
135
|
+
options: r,
|
|
124
136
|
toggleState: s,
|
|
125
137
|
setState(g) {
|
|
126
|
-
|
|
138
|
+
v(g, n);
|
|
127
139
|
}
|
|
128
140
|
};
|
|
129
141
|
}
|
|
130
|
-
function
|
|
142
|
+
function v(e, t) {
|
|
131
143
|
if (!e) {
|
|
132
144
|
console.error("Missing key");
|
|
133
145
|
return;
|
|
134
146
|
}
|
|
135
|
-
const { toggle:
|
|
136
|
-
targets:
|
|
137
|
-
toggles: [
|
|
147
|
+
const { toggle: r, options: o } = t, { themes: n, group: u } = o, s = {
|
|
148
|
+
targets: A(o.target),
|
|
149
|
+
toggles: [r, ...u ? F(u) : []]
|
|
138
150
|
};
|
|
139
151
|
if (!s.targets.length || !s.toggles.length) {
|
|
140
152
|
console.error("Issue setting state, couldn't find needed elements", s);
|
|
141
153
|
return;
|
|
142
154
|
}
|
|
143
|
-
const a = n[e], l =
|
|
144
|
-
...r,
|
|
155
|
+
const a = n[e], l = V(e, n), m = b(h({}, t), {
|
|
145
156
|
key: e,
|
|
146
157
|
elements: s,
|
|
147
158
|
theme: a,
|
|
148
159
|
otherThemes: l
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const
|
|
160
|
+
});
|
|
161
|
+
o.debug && c.log("Set state context", m);
|
|
162
|
+
const p = P(l, "targetClass"), g = P(l, "iconClass");
|
|
152
163
|
s.targets.forEach((i) => {
|
|
153
|
-
i.setAttribute(
|
|
164
|
+
i.setAttribute(x, e), i.classList.remove(...p), i.classList.add(...y(a.targetClass));
|
|
154
165
|
}), s.toggles.forEach((i) => {
|
|
155
|
-
const d = i.querySelector(
|
|
156
|
-
d && (d.textContent = a.label), f && (f.classList.remove(...g), f.classList.add(...
|
|
157
|
-
}),
|
|
166
|
+
const d = i.querySelector(_), f = i.querySelector(N);
|
|
167
|
+
d && (d.textContent = a.label), f && (f.classList.remove(...g), f.classList.add(...y(a.iconClass))), i.setAttribute(x, e);
|
|
168
|
+
}), o.onChange && o.onChange(m), o.savePreference && localStorage.setItem($(o), e);
|
|
158
169
|
}
|
|
159
|
-
function
|
|
160
|
-
const { savePreference:
|
|
170
|
+
function G(e) {
|
|
171
|
+
const { savePreference: t, checkMediaQuery: r, themes: o, initialState: n } = e, u = $(e), s = L(t, () => localStorage.getItem(u)), a = L(r, () => H(o)), l = s || a || n;
|
|
161
172
|
return e.debug && (c.log("Preference Saved", s), c.log("Media Query Preference", a), c.log("Initial State:", n)), l || c.logError("Failed to resolve initial theme (pass 'initialState' to options)"), l;
|
|
162
173
|
}
|
|
163
|
-
function
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
return window.matchMedia(
|
|
174
|
+
function H(e) {
|
|
175
|
+
const t = Object.entries(e).find(([r, o]) => {
|
|
176
|
+
if (o.mediaQuery)
|
|
177
|
+
return window.matchMedia(o.mediaQuery).matches;
|
|
167
178
|
});
|
|
168
|
-
return
|
|
179
|
+
return t ? t[0] : null;
|
|
169
180
|
}
|
|
170
|
-
function
|
|
171
|
-
const { themes:
|
|
172
|
-
return
|
|
181
|
+
function J(e, t) {
|
|
182
|
+
const { themes: r } = t, o = Object.keys(r), n = o.findIndex((s) => s === e), u = n === -1 ? 0 : (n + 1) % o.length;
|
|
183
|
+
return o[u];
|
|
173
184
|
}
|
|
174
|
-
function
|
|
175
|
-
return Object.entries(
|
|
185
|
+
function V(e, t) {
|
|
186
|
+
return Object.entries(t).filter(([o]) => o !== e).map(([o, n]) => n);
|
|
176
187
|
}
|
|
177
|
-
function
|
|
178
|
-
return e.reduce((
|
|
188
|
+
function P(e, t) {
|
|
189
|
+
return e.reduce((r, o) => r.concat(y(o[t])), []);
|
|
179
190
|
}
|
|
180
|
-
function
|
|
181
|
-
const { storagePrefix:
|
|
182
|
-
return
|
|
191
|
+
function $(e) {
|
|
192
|
+
const { storagePrefix: t, group: r } = e;
|
|
193
|
+
return r ? `${t}${r}` : t;
|
|
183
194
|
}
|
|
184
195
|
export {
|
|
185
|
-
|
|
186
|
-
|
|
196
|
+
Q as defaults,
|
|
197
|
+
oe as init,
|
|
187
198
|
c as initializer,
|
|
188
|
-
|
|
189
|
-
|
|
199
|
+
re as setDefaults,
|
|
200
|
+
B as setupToggle
|
|
190
201
|
};
|
package/dist/es/ui/tooltip.js
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var f = Object.getOwnPropertySymbols;
|
|
3
|
+
var y = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var u = (i, t, e) => t in i ? E(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, g = (i, t) => {
|
|
5
|
+
for (var e in t || (t = {}))
|
|
6
|
+
y.call(t, e) && u(i, e, t[e]);
|
|
7
|
+
if (f)
|
|
8
|
+
for (var e of f(t))
|
|
9
|
+
C.call(t, e) && u(i, e, t[e]);
|
|
10
|
+
return i;
|
|
11
|
+
};
|
|
12
|
+
var m = (i, t, e) => u(i, typeof t != "symbol" ? t + "" : t, e);
|
|
13
|
+
import { ComponentInitializer as b } from "../core/component.js";
|
|
14
|
+
import { getUluEventName as w } from "../core/events.js";
|
|
15
|
+
import { createFloatingUi as A } from "../utils/floating-ui.js";
|
|
16
|
+
import { createElementFromHtml as H } from "@ulu/utils/browser/dom.js";
|
|
17
|
+
import { logError as v } from "../utils/class-logger.js";
|
|
18
|
+
import { ensureId as S, newId as I } from "../utils/id.js";
|
|
19
|
+
const d = new b({
|
|
11
20
|
type: "tooltip",
|
|
12
21
|
baseAttribute: "data-ulu-tooltip"
|
|
13
|
-
}),
|
|
14
|
-
function
|
|
22
|
+
}), L = d.getAttribute("body"), F = d.attributeSelector("body"), O = d.attributeSelector("arrow");
|
|
23
|
+
function T() {
|
|
15
24
|
d.init({
|
|
16
25
|
coreEvents: ["pageModified"],
|
|
17
26
|
withData: !0,
|
|
18
|
-
setup({ element:
|
|
27
|
+
setup({ element: i, data: t, initialize: e }) {
|
|
19
28
|
const n = typeof t == "object" ? t : {};
|
|
20
|
-
typeof t == "string" && (n.content = t), e(), new
|
|
29
|
+
typeof t == "string" && (n.content = t), e(), new p({ trigger: i }, n);
|
|
21
30
|
}
|
|
22
31
|
});
|
|
23
32
|
}
|
|
@@ -25,10 +34,10 @@ const a = class a {
|
|
|
25
34
|
constructor(t, e, n) {
|
|
26
35
|
const { trigger: s } = t;
|
|
27
36
|
if (!s) {
|
|
28
|
-
|
|
37
|
+
v(this, "missing required trigger");
|
|
29
38
|
return;
|
|
30
39
|
}
|
|
31
|
-
this.options = Object.assign({}, a.defaults, e), this.floatingOptions = Object.assign({}, a.defaultFloatingOptions, n), this.elements = {
|
|
40
|
+
this.options = Object.assign({}, a.defaults, e), this.floatingOptions = Object.assign({}, a.defaultFloatingOptions, n), this.elements = g({}, t), this.handlers = {}, this.isOpen = !1, S(s), this.setup();
|
|
32
41
|
}
|
|
33
42
|
setup() {
|
|
34
43
|
this.createContentElement(), this.attachHandlers(), this.setupAccessibility();
|
|
@@ -48,40 +57,40 @@ const a = class a {
|
|
|
48
57
|
const o = s ? this.getAnchorElement() : document.querySelector(t);
|
|
49
58
|
return o ? n ? o.innerHTML : o.innerText : "";
|
|
50
59
|
} else
|
|
51
|
-
|
|
60
|
+
v(this, "Could not resolve inner content");
|
|
52
61
|
}
|
|
53
62
|
getAnchorElement() {
|
|
54
63
|
const { trigger: t } = this.elements, { href: e } = t, n = e ? e.split("#")[1] : null, s = n ? document.getElementById(n) : null;
|
|
55
64
|
return s || console.error("Unable to get 'fromAnchor' element", t), s;
|
|
56
65
|
}
|
|
57
66
|
createContentElement() {
|
|
58
|
-
const { options: t } = this, e =
|
|
59
|
-
t.isHtml ? n.innerHTML = s : n.textContent = s, e.id =
|
|
67
|
+
const { options: t } = this, e = H(t.template(t)), n = e.querySelector(F), s = this.getInnerContent();
|
|
68
|
+
t.isHtml ? n.innerHTML = s : n.textContent = s, e.id = I(), t.contentClass && e.classList.add(t.contentClass), this.elements.content = e, this.elements.contentArrow = e.querySelector(O), document.body.appendChild(e);
|
|
60
69
|
}
|
|
61
70
|
attachHandlers() {
|
|
62
71
|
const { trigger: t } = this.elements, { showEvents: e, hideEvents: n, delay: s } = this.options;
|
|
63
72
|
let o = null;
|
|
64
|
-
const c = (
|
|
73
|
+
const c = (r) => {
|
|
65
74
|
o || (o = setTimeout(() => {
|
|
66
|
-
this.show(
|
|
75
|
+
this.show(r), clearTimeout(o);
|
|
67
76
|
}, s));
|
|
68
|
-
},
|
|
69
|
-
o && (clearTimeout(o), o = null), this.hide(
|
|
70
|
-
}, h = (
|
|
71
|
-
|
|
77
|
+
}, l = (r) => {
|
|
78
|
+
o && (clearTimeout(o), o = null), this.hide(r);
|
|
79
|
+
}, h = (r) => {
|
|
80
|
+
r.key === "Escape" && this.hide(r);
|
|
72
81
|
};
|
|
73
|
-
e.forEach((
|
|
74
|
-
t.addEventListener(
|
|
75
|
-
}), n.forEach((
|
|
76
|
-
t.addEventListener(
|
|
77
|
-
}), document.addEventListener("keydown", h), this.handlers = { onShow: c, onHide:
|
|
82
|
+
e.forEach((r) => {
|
|
83
|
+
t.addEventListener(r, c);
|
|
84
|
+
}), n.forEach((r) => {
|
|
85
|
+
t.addEventListener(r, l);
|
|
86
|
+
}), document.addEventListener("keydown", h), this.handlers = { onShow: c, onHide: l, onDocumentKeydown: h };
|
|
78
87
|
}
|
|
79
88
|
destroyHandlers() {
|
|
80
89
|
const { trigger: t } = this, { onShow: e, onHide: n, onDocumentKeydown: s } = this.handlers, { showEvents: o, hideEvents: c } = this.options;
|
|
81
|
-
e && o.forEach((
|
|
82
|
-
t.removeEventListener(
|
|
83
|
-
}), n && c.forEach((
|
|
84
|
-
t.removeEventListener(
|
|
90
|
+
e && o.forEach((l) => {
|
|
91
|
+
t.removeEventListener(l, e);
|
|
92
|
+
}), n && c.forEach((l) => {
|
|
93
|
+
t.removeEventListener(l, n);
|
|
85
94
|
}), s && document.removeEventListener("keydown", s);
|
|
86
95
|
}
|
|
87
96
|
setState(t, e) {
|
|
@@ -89,14 +98,14 @@ const a = class a {
|
|
|
89
98
|
instance: this,
|
|
90
99
|
isOpen: t,
|
|
91
100
|
event: e
|
|
92
|
-
}, { trigger: s, content: o } = this.elements, { openClass: c } = this.options,
|
|
93
|
-
|
|
101
|
+
}, { trigger: s, content: o } = this.elements, { openClass: c } = this.options, l = (h) => h.classList[t ? "add" : "remove"](c);
|
|
102
|
+
l(s), l(o), this.isOpen = t, this.options.onChange(n), s.dispatchEvent(this.createEvent("change", n)), this.destroyFloatingInstance(), t && this.createFloatingInstance();
|
|
94
103
|
}
|
|
95
104
|
createEvent(t, e) {
|
|
96
|
-
return new CustomEvent(
|
|
105
|
+
return new CustomEvent(w("tooltip:" + t), { detail: e });
|
|
97
106
|
}
|
|
98
107
|
createFloatingInstance() {
|
|
99
|
-
this.floatingCleanup =
|
|
108
|
+
this.floatingCleanup = A(this.elements, this.floatingOptions);
|
|
100
109
|
}
|
|
101
110
|
destroyFloatingInstance() {
|
|
102
111
|
this.floatingCleanup && (this.floatingCleanup(), this.floatingCleanup = null);
|
|
@@ -111,7 +120,7 @@ const a = class a {
|
|
|
111
120
|
/**
|
|
112
121
|
* Defaults options
|
|
113
122
|
*/
|
|
114
|
-
|
|
123
|
+
m(a, "defaults", {
|
|
115
124
|
/**
|
|
116
125
|
* Should the tooltip and content be linked accessibly
|
|
117
126
|
* - Note tooltips can only apply to interactive elements! (ie button, input, role="...", etc)
|
|
@@ -161,7 +170,7 @@ u(a, "defaults", {
|
|
|
161
170
|
template(t) {
|
|
162
171
|
return `
|
|
163
172
|
<div class="popover popover--tooltip">
|
|
164
|
-
<div class="popover__inner" ${
|
|
173
|
+
<div class="popover__inner" ${L}>
|
|
165
174
|
</div>
|
|
166
175
|
<span class="popover__arrow" data-ulu-tooltip-arrow></span>
|
|
167
176
|
</div>
|
|
@@ -173,12 +182,12 @@ u(a, "defaults", {
|
|
|
173
182
|
*/
|
|
174
183
|
onChange(t) {
|
|
175
184
|
}
|
|
176
|
-
}),
|
|
185
|
+
}), m(a, "defaultFloatingOptions", {
|
|
177
186
|
// strategy: "fixed"
|
|
178
187
|
});
|
|
179
|
-
let
|
|
188
|
+
let p = a;
|
|
180
189
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
p as Tooltip,
|
|
191
|
+
T as init,
|
|
183
192
|
d as initializer
|
|
184
193
|
};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var f = Object.getOwnPropertySymbols;
|
|
3
|
+
var h = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var c = (n, e, t) => e in n ? b(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, o = (n, e) => {
|
|
5
|
+
for (var t in e || (e = {}))
|
|
6
|
+
h.call(e, t) && c(n, t, e[t]);
|
|
7
|
+
if (f)
|
|
8
|
+
for (var t of f(e))
|
|
9
|
+
j.call(e, t) && c(n, t, e[t]);
|
|
10
|
+
return n;
|
|
11
|
+
};
|
|
12
|
+
import { autoUpdate as w, computePosition as $, inline as A, offset as O, flip as U, shift as D, arrow as F } from "@floating-ui/dom";
|
|
13
|
+
const k = {
|
|
3
14
|
strategy: "absolute",
|
|
4
15
|
placement: "bottom",
|
|
5
16
|
inline: !1,
|
|
@@ -11,36 +22,36 @@ const $ = {
|
|
|
11
22
|
arrow: !0
|
|
12
23
|
// Options for arrow (not element)
|
|
13
24
|
};
|
|
14
|
-
function
|
|
15
|
-
const t = Object.assign({},
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
placement:
|
|
19
|
-
strategy:
|
|
25
|
+
function B(n, e) {
|
|
26
|
+
const t = Object.assign({}, k, e), { placement: p, strategy: u } = t, { trigger: r, content: s, contentArrow: a } = n;
|
|
27
|
+
return w(r, s, () => {
|
|
28
|
+
$(r, s, {
|
|
29
|
+
placement: p,
|
|
30
|
+
strategy: u,
|
|
20
31
|
middleware: [
|
|
21
|
-
...
|
|
22
|
-
...
|
|
23
|
-
...
|
|
24
|
-
...
|
|
25
|
-
...
|
|
32
|
+
...l(A, t.inline),
|
|
33
|
+
...l(O, t.offset),
|
|
34
|
+
...l(U, t.flip),
|
|
35
|
+
...l(D, t.shift),
|
|
36
|
+
...l(F, a && t.arrow, { element: a })
|
|
26
37
|
]
|
|
27
|
-
}).then((
|
|
28
|
-
const { x
|
|
38
|
+
}).then((m) => {
|
|
39
|
+
const { x, y: d, middlewareData: g, placement: y } = m, i = g.arrow;
|
|
29
40
|
Object.assign(s.style, {
|
|
30
|
-
left: `${
|
|
31
|
-
top: `${
|
|
32
|
-
}), s.setAttribute("data-placement",
|
|
41
|
+
left: `${x}px`,
|
|
42
|
+
top: `${d}px`
|
|
43
|
+
}), s.setAttribute("data-placement", y), i && Object.assign(a.style, {
|
|
33
44
|
// position: "absolute",
|
|
34
|
-
left: (
|
|
35
|
-
top: (
|
|
45
|
+
left: (i == null ? void 0 : i.x) != null ? `${i.x}px` : "",
|
|
46
|
+
top: (i == null ? void 0 : i.y) != null ? `${i.y}px` : ""
|
|
36
47
|
});
|
|
37
48
|
});
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
51
|
+
function l(n, e, t = {}) {
|
|
52
|
+
return e ? typeof e == "object" ? [n(o(o({}, e), t))] : [n(t)] : [];
|
|
42
53
|
}
|
|
43
54
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
B as createFloatingUi,
|
|
56
|
+
k as defaults
|
|
46
57
|
};
|