@mattilsynet/design 1.0.6 → 1.0.7
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/mtds/avatar/avatar.stories.d.ts +1 -0
- package/mtds/badge/badge.d.ts +2 -2
- package/mtds/badge/badge.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.d.ts +1 -0
- package/mtds/breadcrumbs/breadcrumbs-observer.js +12 -0
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -0
- package/mtds/breadcrumbs/breadcrumbs.js +13 -21
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
- package/mtds/button/button.d.ts +1 -1
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.d.ts +9 -1
- package/mtds/card/card.js +22 -8
- package/mtds/card/card.js.map +1 -1
- package/mtds/card/card.stories.d.ts +1 -1
- package/mtds/dialog/dialog-observer.d.ts +1 -2
- package/mtds/dialog/dialog-observer.js +19 -17
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.d.ts +4 -2
- package/mtds/dialog/dialog.js +11 -15
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/dialog/dialog.stories.d.ts +1 -0
- package/mtds/divider/divider.d.ts +2 -2
- package/mtds/divider/divider.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.d.ts +1 -0
- package/mtds/errorsummary/errorsummary-observer.js +10 -0
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -0
- package/mtds/errorsummary/errorsummary.js +11 -17
- package/mtds/errorsummary/errorsummary.js.map +1 -1
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js +47 -48
- package/mtds/external/@u-elements/u-datalist/dist/u-datalist.js.map +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js +9 -8
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
- package/mtds/external/@u-elements/u-tags/dist/u-tags.js +160 -162
- package/mtds/external/@u-elements/u-tags/dist/u-tags.js.map +1 -1
- package/mtds/field/field-helper.d.ts +1 -0
- package/mtds/field/field-observer.d.ts +1 -2
- package/mtds/field/field-observer.js +32 -41
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +7 -0
- package/mtds/field/field.js +49 -34
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +4 -2
- package/mtds/fieldset/fieldset-observer.d.ts +1 -2
- package/mtds/fieldset/fieldset-observer.js +12 -16
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/index.d.ts +3 -3
- package/mtds/index.iife.js +6 -5
- package/mtds/index.iife.js.map +1 -1
- package/mtds/index.js +13 -24
- package/mtds/index.js.map +1 -1
- package/mtds/layout/app-observer.d.ts +1 -2
- package/mtds/layout/app-observer.js +11 -16
- package/mtds/layout/app-observer.js.map +1 -1
- package/mtds/layout/layout.d.ts +17 -6
- package/mtds/layout/layout.js +12 -9
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/logo/logo-observer.d.ts +1 -2
- package/mtds/logo/logo-observer.js +14 -18
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/popover/popover-observer.d.ts +1 -2
- package/mtds/popover/popover-observer.js +12 -21
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/react-types.d.ts +11 -0
- package/mtds/react.js +42 -40
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +34 -34
- package/mtds/styles.module.css.js +58 -56
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.d.ts +1 -2
- package/mtds/table/table-observer.js +10 -14
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/tag/tag.d.ts +2 -6
- package/mtds/tag/tag.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +27 -20
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/utils.d.ts +2 -19
- package/mtds/utils.js +32 -26
- package/mtds/utils.js.map +1 -1
- package/package.json +18 -18
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
var
|
|
2
|
-
for (var
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
for (var
|
|
6
|
-
|
|
1
|
+
var ht = Object.defineProperty, j = Object.getOwnPropertySymbols, ft = Object.prototype.hasOwnProperty, mt = Object.prototype.propertyIsEnumerable, X = (t, e, i) => e in t ? ht(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, Q = (t, e) => {
|
|
2
|
+
for (var i in e || (e = {}))
|
|
3
|
+
ft.call(e, i) && X(t, i, e[i]);
|
|
4
|
+
if (j)
|
|
5
|
+
for (var i of j(e))
|
|
6
|
+
mt.call(e, i) && X(t, i, e[i]);
|
|
7
7
|
return t;
|
|
8
|
-
}, h = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u",
|
|
9
|
-
/^Mac/i.test(((
|
|
8
|
+
}, h = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", Z = h && /android/i.test(navigator.userAgent), _t = h && /firefox/i.test(navigator.userAgent), L = h && /iPad|iPhone|iPod/.test(navigator.userAgent), tt = h && /^((?!chrome|android).)*safari/i.test(navigator.userAgent), W, bt = h && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
|
|
9
|
+
/^Mac/i.test(((W = navigator.userAgentData) == null ? void 0 : W.platform) || navigator.platform), gt = `${Z ? "data" : "aria"}-labelledby`, N = `${tt ? "aria" : "data"}-multiselectable`, et = ":host(:not([hidden])) { display: block }", it = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", H = typeof HTMLElement > "u" ? class {
|
|
10
10
|
} : HTMLElement;
|
|
11
|
-
function a(t, e,
|
|
12
|
-
var
|
|
13
|
-
return
|
|
11
|
+
function a(t, e, i) {
|
|
12
|
+
var n;
|
|
13
|
+
return i === void 0 ? (n = t.getAttribute(e)) != null ? n : null : (i === null ? t.removeAttribute(e) : t.getAttribute(e) !== i && t.setAttribute(e, i), null);
|
|
14
14
|
}
|
|
15
|
-
var
|
|
16
|
-
for (const
|
|
17
|
-
|
|
18
|
-
}, I = (t, ...e) =>
|
|
19
|
-
|
|
15
|
+
var nt = (t, e, i) => {
|
|
16
|
+
for (const n of i[0].split(","))
|
|
17
|
+
i[0] = n, Element.prototype[`${t}EventListener`].apply(e, i);
|
|
18
|
+
}, I = (t, ...e) => nt("add", t, e), x = (t, ...e) => nt("remove", t, e), ot = (t, e) => t.attachShadow({ mode: "open" }).append(
|
|
19
|
+
g("slot"),
|
|
20
20
|
// Unnamed slot does automatically render all top element nodes
|
|
21
|
-
|
|
21
|
+
g("style", e)
|
|
22
22
|
), T = /* @__PURE__ */ new WeakMap(), w = (t, e) => {
|
|
23
23
|
if (e === void 0) return T.get(t);
|
|
24
24
|
try {
|
|
@@ -26,43 +26,42 @@ var ot = (t, e, n) => {
|
|
|
26
26
|
} catch {
|
|
27
27
|
}
|
|
28
28
|
if (e) {
|
|
29
|
-
const
|
|
30
|
-
(
|
|
29
|
+
const i = new MutationObserver(
|
|
30
|
+
(n) => t.handleEvent({ type: "mutation", detail: n })
|
|
31
31
|
);
|
|
32
|
-
|
|
32
|
+
i.observe(t, e), T.set(t, i);
|
|
33
33
|
}
|
|
34
|
-
},
|
|
34
|
+
}, Et = (t) => {
|
|
35
35
|
const e = "key" in t && (t.key === " " || t.key === "Enter");
|
|
36
36
|
return e && t.preventDefault(), e && t.target instanceof HTMLElement && t.target.click(), e;
|
|
37
37
|
}, O = (t) => {
|
|
38
38
|
var e;
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
-
},
|
|
42
|
-
const
|
|
43
|
-
if (e && (
|
|
44
|
-
return
|
|
39
|
+
const i = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
|
|
40
|
+
return i instanceof Document || i instanceof ShadowRoot ? i : document;
|
|
41
|
+
}, yt = 0, M = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++yt).toString(32)}`), t.id) : "", g = (t, e, i) => {
|
|
42
|
+
const n = document.createElement(t);
|
|
43
|
+
if (e && (n.textContent = e), i) for (const [o, l] of Object.entries(i)) a(n, o, l);
|
|
44
|
+
return n;
|
|
45
45
|
}, B = {
|
|
46
46
|
define: (t, e) => !h || window.customElements.get(t) || window.customElements.define(t, e)
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return e.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", a(e, "aria-live", t), document.body.appendChild(e);
|
|
47
|
+
}, rt = (t) => {
|
|
48
|
+
const e = g("div");
|
|
49
|
+
return e.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", a(e, "aria-live", t), e;
|
|
51
50
|
};
|
|
52
|
-
function A(t, e,
|
|
51
|
+
function A(t, e, i) {
|
|
53
52
|
if (!e) return Object.keys(t).map((o) => `data-sr-${o}`);
|
|
54
|
-
const
|
|
55
|
-
return
|
|
53
|
+
const n = (e == null ? void 0 : e.startsWith("data-sr-")) && e.slice(8);
|
|
54
|
+
return n && i && t[n] && (t[n] = i), [];
|
|
56
55
|
}
|
|
57
|
-
var R = "disabled",
|
|
56
|
+
var R = "disabled", y = "selected", It = class extends H {
|
|
58
57
|
// Using ES2015 syntax for backwards compatibility
|
|
59
58
|
static get observedAttributes() {
|
|
60
|
-
return [R,
|
|
59
|
+
return [R, y];
|
|
61
60
|
}
|
|
62
61
|
constructor() {
|
|
63
|
-
super(),
|
|
62
|
+
super(), ot(
|
|
64
63
|
this,
|
|
65
|
-
`${
|
|
64
|
+
`${et}:host(:focus){${it}}:host{ cursor: pointer }`
|
|
66
65
|
);
|
|
67
66
|
}
|
|
68
67
|
connectedCallback() {
|
|
@@ -73,10 +72,10 @@ var R = "disabled", g = "selected", xt = class extends H {
|
|
|
73
72
|
}
|
|
74
73
|
/** Sets or retrieves whether the option in the list box is the default item. */
|
|
75
74
|
get defaultSelected() {
|
|
76
|
-
return this[
|
|
75
|
+
return this[y];
|
|
77
76
|
}
|
|
78
77
|
set defaultSelected(t) {
|
|
79
|
-
this[
|
|
78
|
+
this[y] = t;
|
|
80
79
|
}
|
|
81
80
|
get disabled() {
|
|
82
81
|
return a(this, R) !== null;
|
|
@@ -102,10 +101,10 @@ var R = "disabled", g = "selected", xt = class extends H {
|
|
|
102
101
|
a(this, "label", t);
|
|
103
102
|
}
|
|
104
103
|
get selected() {
|
|
105
|
-
return a(this,
|
|
104
|
+
return a(this, y) !== null;
|
|
106
105
|
}
|
|
107
106
|
set selected(t) {
|
|
108
|
-
a(this,
|
|
107
|
+
a(this, y, t ? "" : null);
|
|
109
108
|
}
|
|
110
109
|
/** Sets or retrieves the text string specified by the option tag. */
|
|
111
110
|
get text() {
|
|
@@ -123,106 +122,106 @@ var R = "disabled", g = "selected", xt = class extends H {
|
|
|
123
122
|
a(this, "value", t);
|
|
124
123
|
}
|
|
125
124
|
};
|
|
126
|
-
B.define("u-option",
|
|
127
|
-
var P = !1,
|
|
125
|
+
B.define("u-option", It);
|
|
126
|
+
var P = !1, q, xt = 0, _, Ct = tt && !L, at = "click,focusout,input,keydown,mousedown,mouseup", Y = {
|
|
128
127
|
singular: "%d hit",
|
|
129
128
|
plural: "%d hits"
|
|
130
|
-
},
|
|
129
|
+
}, Tt = class extends H {
|
|
131
130
|
constructor() {
|
|
132
|
-
super(), this._blurTimer = 0, this._input = null, this._root = null, this._value = "", this._texts =
|
|
131
|
+
super(), this._blurTimer = 0, this._input = null, this._root = null, this._value = "", this._texts = Q({}, Y), ot(
|
|
133
132
|
this,
|
|
134
|
-
`${
|
|
133
|
+
`${et}::slotted(u-option[disabled]) { display: none !important }`
|
|
135
134
|
// Hide disabled options
|
|
136
135
|
);
|
|
137
136
|
}
|
|
138
137
|
// Speed up translated texts
|
|
139
138
|
// Using ES2015 syntax for backwards compatibility
|
|
140
139
|
static get observedAttributes() {
|
|
141
|
-
return ["id", ...A(
|
|
140
|
+
return ["id", ...A(Y)];
|
|
142
141
|
}
|
|
143
142
|
connectedCallback() {
|
|
144
|
-
this.hidden = !0, this._root = O(this),
|
|
143
|
+
this.hidden = !0, this._root = O(this), _ || (_ = rt("assertive")), _.isConnected || document.body.appendChild(_), a(this, "role", "listbox"), I(this._root, "focusin", this), I(this._root, "focus", this, !0), setTimeout(() => this.attributeChangedCallback());
|
|
145
144
|
}
|
|
146
145
|
disconnectedCallback() {
|
|
147
146
|
x(this._root || this, "focus", this, !0), x(this._root || this, "focusin", this), U(this), this._root = null;
|
|
148
147
|
}
|
|
149
|
-
attributeChangedCallback(t, e,
|
|
150
|
-
var
|
|
151
|
-
A(this._texts, t,
|
|
152
|
-
const o = (
|
|
153
|
-
for (const l of o || [])
|
|
148
|
+
attributeChangedCallback(t, e, i) {
|
|
149
|
+
var n;
|
|
150
|
+
A(this._texts, t, i);
|
|
151
|
+
const o = (n = this._root) == null ? void 0 : n.querySelectorAll(`input[list="${this.id}"]`);
|
|
152
|
+
for (const l of o || []) ut(this, l);
|
|
154
153
|
}
|
|
155
154
|
handleEvent(t) {
|
|
156
155
|
const { type: e } = t;
|
|
157
|
-
t.defaultPrevented || (e === "click" &&
|
|
156
|
+
t.defaultPrevented || (e === "click" && St(this, t), (e === "focus" || e === "focusin") && wt(this, t), e === "focusout" && At(this), e === "keydown" && kt(this, t), (e === "mutation" || e === "input") && lt(this, t), e === "mouseup" && (P = !1), e === "mousedown" && (P = this.contains(t.target)));
|
|
158
157
|
}
|
|
159
158
|
get options() {
|
|
160
159
|
return this.getElementsByTagName("u-option");
|
|
161
160
|
}
|
|
162
|
-
},
|
|
163
|
-
var
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
!
|
|
161
|
+
}, wt = (t, { target: e }) => {
|
|
162
|
+
var i;
|
|
163
|
+
const n = t._input === e;
|
|
164
|
+
if (n || t.contains(e)) return clearTimeout(t._blurTimer);
|
|
165
|
+
!n && e instanceof HTMLInputElement && a(e, "list") === t.id && (t._input && U(t), t._input = e, a(t, gt, M((i = t._input.labels) == null ? void 0 : i[0])), I(t._root || t, at, t), w(t, {
|
|
167
166
|
attributeFilter: ["value"],
|
|
168
167
|
// Listen for value changes to show u-options
|
|
169
168
|
attributes: !0,
|
|
170
169
|
childList: !0,
|
|
171
170
|
subtree: !0
|
|
172
|
-
}),
|
|
173
|
-
},
|
|
171
|
+
}), E(t, !0));
|
|
172
|
+
}, At = (t) => {
|
|
174
173
|
P || (t._blurTimer = setTimeout(() => U(t)));
|
|
175
|
-
},
|
|
176
|
-
var
|
|
177
|
-
const
|
|
174
|
+
}, St = (t, { target: e }) => {
|
|
175
|
+
var i, n, o, l, c;
|
|
176
|
+
const s = a(t, N) !== "true", u = [...t.options].find((r) => r.contains(e));
|
|
178
177
|
if (t._input === e)
|
|
179
|
-
|
|
180
|
-
else if (
|
|
178
|
+
E(t, !0);
|
|
179
|
+
else if (u && S(u)) {
|
|
181
180
|
for (const r of t.options)
|
|
182
|
-
r ===
|
|
183
|
-
(
|
|
181
|
+
r === u ? r.selected = !0 : s && (r.selected = !1);
|
|
182
|
+
(n = (i = Object.getOwnPropertyDescriptor(
|
|
184
183
|
HTMLInputElement.prototype,
|
|
185
184
|
"value"
|
|
186
|
-
)) == null ? void 0 :
|
|
185
|
+
)) == null ? void 0 : i.set) == null || n.call(t._input, u.value), s && ((o = t._input) == null || o.focus(), E(t, !1)), (l = t._input) == null || l.dispatchEvent(
|
|
187
186
|
new Event("input", { bubbles: !0, composed: !0 })
|
|
188
|
-
), (
|
|
187
|
+
), (c = t._input) == null || c.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
189
188
|
}
|
|
190
|
-
},
|
|
191
|
-
var
|
|
189
|
+
}, kt = (t, e) => {
|
|
190
|
+
var i, n;
|
|
192
191
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
193
|
-
e.key !== "Escape" &&
|
|
194
|
-
const { key: o } = e, l = (
|
|
195
|
-
let
|
|
196
|
-
if (o === "ArrowDown" && (
|
|
197
|
-
return
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
t.hidden = !e, t.popover && t.togglePopover(e), t._input &&
|
|
192
|
+
e.key !== "Escape" && E(t, !0);
|
|
193
|
+
const { key: o } = e, l = (i = t._root) == null ? void 0 : i.activeElement, c = st(t), s = c.indexOf(l);
|
|
194
|
+
let u = -1;
|
|
195
|
+
if (o === "ArrowDown" && (u = (s + 1) % c.length), o === "ArrowUp" && (u = (~s ? s : c.length) - 1), ~s && ((o === "Home" || o === "PageUp") && (u = 0), (o === "End" || o === "PageDown") && (u = c.length - 1), o === "Enter"))
|
|
196
|
+
return c[s].click(), e.preventDefault();
|
|
197
|
+
if (c[u]) for (const r of c) r.tabIndex = -1;
|
|
198
|
+
c[u] && e.preventDefault(), (n = c[u] || t._input) == null || n.focus(), o === "Escape" && E(t, !1);
|
|
199
|
+
}, E = (t, e) => {
|
|
200
|
+
t.hidden = !e, t.popover && t.togglePopover(e), t._input && ut(t, t._input, e), e && lt(t);
|
|
202
201
|
}, U = (t) => {
|
|
203
|
-
x(t._root || t,
|
|
202
|
+
x(t._root || t, at, t), w(t, !1), E(t, !1), t._input = null;
|
|
204
203
|
}, st = (t) => [...t.options].filter(
|
|
205
204
|
(e) => !e.disabled && e.offsetWidth && e.offsetHeight
|
|
206
205
|
// Checks disabled or visibility (since hidden attribute can be overwritten by display: block)
|
|
207
|
-
), S = (t) => t instanceof HTMLOptionElement || t.getAttribute("role") === "option",
|
|
208
|
-
a(e, "popovertarget", M(t)), a(e, "aria-autocomplete", "list"), a(e, "aria-controls", M(t)), a(e, "aria-expanded", `${
|
|
209
|
-
},
|
|
210
|
-
var
|
|
211
|
-
const
|
|
212
|
-
if (!((e == null ? void 0 : e.type) === "mutation" || t._value !==
|
|
213
|
-
const l = t.hidden,
|
|
214
|
-
t.hidden = !0, t._value =
|
|
206
|
+
), S = (t) => t instanceof HTMLOptionElement || t.getAttribute("role") === "option", ut = (t, e, i = !1) => {
|
|
207
|
+
a(e, "popovertarget", M(t)), a(e, "aria-autocomplete", "list"), a(e, "aria-controls", M(t)), a(e, "aria-expanded", `${Ct || i}`), a(e, "autocomplete", "off"), a(e, "role", "combobox");
|
|
208
|
+
}, z = (t) => (t == null ? void 0 : t.toLowerCase().trim()) || "", lt = (t, e) => {
|
|
209
|
+
var i;
|
|
210
|
+
const n = z((i = t._input) == null ? void 0 : i.value);
|
|
211
|
+
if (!((e == null ? void 0 : e.type) === "mutation" || t._value !== n)) return;
|
|
212
|
+
const l = t.hidden, c = a(t, N) !== "true", s = e instanceof InputEvent && !dt(e);
|
|
213
|
+
t.hidden = !0, t._value = n;
|
|
215
214
|
for (const r of t.options) {
|
|
216
|
-
const
|
|
217
|
-
r.hidden = !
|
|
215
|
+
const d = [r.value, r.label, r.text].map(z);
|
|
216
|
+
r.hidden = !d.some((v) => v.includes(n)), c && s && S(r) && (r.selected = d.includes(n));
|
|
218
217
|
}
|
|
219
218
|
t.hidden = l;
|
|
220
|
-
const
|
|
221
|
-
clearTimeout(
|
|
222
|
-
const { length: r } =
|
|
223
|
-
|
|
224
|
-
}, 1e3), L &&
|
|
225
|
-
r.title = `${
|
|
219
|
+
const u = st(t);
|
|
220
|
+
clearTimeout(q), q = setTimeout(() => {
|
|
221
|
+
const { length: r } = u.filter(S), d = ++xt % 2 ? " " : "", v = `${`${t._texts[r === 1 ? "singular" : "plural"]}`.replace("%d", `${r}`)}`;
|
|
222
|
+
_ && (_.textContent = `${!r && t.innerText.trim() || v}${d}`);
|
|
223
|
+
}, 1e3), L && u.map((r, d, v) => {
|
|
224
|
+
r.title = `${d + 1}/${v}`;
|
|
226
225
|
});
|
|
227
226
|
};
|
|
228
227
|
h && Object.defineProperty(HTMLInputElement.prototype, "list", {
|
|
@@ -232,34 +231,34 @@ h && Object.defineProperty(HTMLInputElement.prototype, "list", {
|
|
|
232
231
|
return O(this).getElementById(a(this, "list") || "");
|
|
233
232
|
}
|
|
234
233
|
});
|
|
235
|
-
B.define("u-datalist",
|
|
236
|
-
var ct = " ".repeat(100),
|
|
234
|
+
B.define("u-datalist", Tt);
|
|
235
|
+
var ct = " ".repeat(100), Lt = "insertReplacementText", F = ({
|
|
237
236
|
value: t
|
|
238
237
|
}) => t.split(ct)[0];
|
|
239
|
-
function
|
|
238
|
+
function dt(t) {
|
|
240
239
|
var e;
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
(l) => l.value ===
|
|
240
|
+
const i = t instanceof Event && t.type === "input" && t.target instanceof HTMLInputElement && (!t.inputType || t.inputType === Lt);
|
|
241
|
+
if (i) {
|
|
242
|
+
const n = t.target.value, o = Array.from(((e = t.target.list) == null ? void 0 : e.options) || []).some(
|
|
243
|
+
(l) => l.value === n && !S(l)
|
|
245
244
|
);
|
|
246
|
-
t.target.value =
|
|
245
|
+
t.target.value = n.split(ct)[o ? 1 : 0];
|
|
247
246
|
}
|
|
248
|
-
return
|
|
247
|
+
return i;
|
|
249
248
|
}
|
|
250
|
-
var
|
|
249
|
+
var b, Ot = Z || L, $t = _t || bt, G = "input,focusin,focusout,keydown", J = {
|
|
251
250
|
added: "Added",
|
|
252
251
|
remove: "Press to remove",
|
|
253
252
|
removed: "Removed",
|
|
254
253
|
empty: "No selected",
|
|
255
254
|
found: "Navigate left to find %d selected",
|
|
256
255
|
of: "of"
|
|
257
|
-
},
|
|
256
|
+
}, Dt = class extends H {
|
|
258
257
|
constructor() {
|
|
259
|
-
super(), this._blurAnnounceReset = !1, this._blurTimer = 0, this._focusIndex = null, this._root = null, this._texts =
|
|
260
|
-
|
|
258
|
+
super(), this._blurAnnounceReset = !1, this._blurTimer = 0, this._focusIndex = null, this._root = null, this._texts = Q({}, J), this.attachShadow({ mode: "open" }).append(
|
|
259
|
+
g("slot"),
|
|
261
260
|
// Content slot
|
|
262
|
-
|
|
261
|
+
g(
|
|
263
262
|
"style",
|
|
264
263
|
`:host(:not([hidden])){ display: inline-block }
|
|
265
264
|
::slotted(data) { cursor: pointer; display: inline-block; outline: none; pointer-events: none }
|
|
@@ -271,19 +270,19 @@ var $t = tt || L, Dt = bt || gt, y = at("polite"), J = "input,focusin,focusout,k
|
|
|
271
270
|
}
|
|
272
271
|
// Using ES2015 syntax for backwards compatibility
|
|
273
272
|
static get observedAttributes() {
|
|
274
|
-
return A(
|
|
273
|
+
return A(J);
|
|
275
274
|
}
|
|
276
275
|
connectedCallback() {
|
|
277
|
-
this._root = O(this),
|
|
276
|
+
this._root = O(this), b || (b = rt("polite")), b.isConnected || document.body.appendChild(b), w(this, { childList: !0 }), I(this._root, "click", this), I(this, G, this), setTimeout(() => k(this));
|
|
278
277
|
}
|
|
279
|
-
attributeChangedCallback(t, e,
|
|
280
|
-
A(this._texts, t,
|
|
278
|
+
attributeChangedCallback(t, e, i) {
|
|
279
|
+
A(this._texts, t, i);
|
|
281
280
|
}
|
|
282
281
|
disconnectedCallback() {
|
|
283
|
-
w(this, !1), x(this._root || this, "click", this), x(this,
|
|
282
|
+
w(this, !1), x(this._root || this, "click", this), x(this, G, this), this._root = null;
|
|
284
283
|
}
|
|
285
284
|
handleEvent(t) {
|
|
286
|
-
t.defaultPrevented || (t.type === "click" &&
|
|
285
|
+
t.defaultPrevented || (t.type === "click" && Pt(this, t), t.type === "focusin" && Rt(this, t), t.type === "focusout" && Mt(this), t.type === "input" && Ft(this, t), t.type === "keydown" && Nt(this, t), t.type === "mutation" && k(this, t));
|
|
287
286
|
}
|
|
288
287
|
get items() {
|
|
289
288
|
return this.querySelectorAll("data");
|
|
@@ -298,70 +297,69 @@ var $t = tt || L, Dt = bt || gt, y = at("polite"), J = "input,focusin,focusout,k
|
|
|
298
297
|
detail: { item: e, action: e.isConnected ? "remove" : "add" }
|
|
299
298
|
})
|
|
300
299
|
), k = (t, e) => {
|
|
301
|
-
var
|
|
302
|
-
const
|
|
303
|
-
a(t, "role", "group"), a(t, "aria-label",
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
a(f, "aria-label", ht), a(f, "role", "button"), f.tabIndex = -1, f.value = f.value || ((j = f.textContent) == null ? void 0 : j.trim()) || "", v.push(f.value);
|
|
300
|
+
var i, n, o, l, c;
|
|
301
|
+
const s = t._texts, u = Number.isNaN(t._focusIndex) ? null : e == null ? void 0 : e.detail[0], r = (u == null ? void 0 : u.addedNodes[0]) || (u == null ? void 0 : u.removedNodes[0]), d = `${r ? `${r.isConnected ? s.added : s.removed} ${r.textContent}, ` : ""}`, v = ((o = (n = (i = t.control) == null ? void 0 : i.labels) == null ? void 0 : n[0]) == null ? void 0 : o.textContent) || "", f = [];
|
|
302
|
+
a(t, "role", "group"), a(t, "aria-label", v), t.items.forEach((p, $, { length: D }) => {
|
|
303
|
+
const vt = `${d}${p.textContent}, ${s.remove}, ${$ + 1} ${s.of} ${D}`;
|
|
304
|
+
a(p, "aria-label", vt), a(p, "role", "button"), p.tabIndex = -1, p.value = (p.value || p.textContent || "").trim(), f.push(p.value);
|
|
307
305
|
});
|
|
308
|
-
const m = t.control, pt = `${
|
|
306
|
+
const m = t.control, pt = `${d}${v}, ${f.length ? s.found.replace("%d", `${f.length}`) : s.empty}`, C = m && document.getElementById(a(m, "list") || ""), K = C == null ? void 0 : C.children;
|
|
309
307
|
m && a(m, "aria-label", pt), C && a(C, N, "true");
|
|
310
|
-
for (const
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
314
|
-
t._blurAnnounceReset = !1,
|
|
315
|
-
if (
|
|
308
|
+
for (const p of K || [])
|
|
309
|
+
p.selected = f.includes(F(p));
|
|
310
|
+
if (d) {
|
|
311
|
+
const p = t.items[(t._focusIndex || 1) - 1] || m, $ = p === ((l = O(t)) == null ? void 0 : l.activeElement), D = K || t.items;
|
|
312
|
+
t._blurAnnounceReset = !1, p === m ? ($ && (Ot && b ? b.textContent = d : (c = D[0]) == null || c.focus()), setTimeout(() => p == null ? void 0 : p.focus(), 100)) : p == null || p.focus(), setTimeout(() => {
|
|
313
|
+
if (!$t) return k(t);
|
|
316
314
|
t._blurAnnounceReset = !0;
|
|
317
315
|
}, 500);
|
|
318
316
|
}
|
|
319
|
-
},
|
|
317
|
+
}, Rt = (t, { target: e }) => {
|
|
320
318
|
clearTimeout(t._blurTimer), t._focusIndex = [...t.items].indexOf(e);
|
|
321
|
-
},
|
|
319
|
+
}, Mt = (t) => {
|
|
322
320
|
t._blurAnnounceReset && k(t), t._blurTimer = setTimeout(() => {
|
|
323
321
|
t._focusIndex = null;
|
|
324
322
|
});
|
|
325
|
-
},
|
|
323
|
+
}, Pt = (t, { target: e, clientX: i, clientY: n }) => {
|
|
326
324
|
var o;
|
|
327
|
-
const l = t.contains(e) ? [...t.items] : null,
|
|
328
|
-
const { top: r, right:
|
|
329
|
-
return
|
|
325
|
+
const l = t.contains(e) ? [...t.items] : null, c = l == null ? void 0 : l.find((u) => u.contains(e)), s = l == null ? void 0 : l.find((u) => {
|
|
326
|
+
const { top: r, right: d, bottom: v, left: f } = u.getBoundingClientRect();
|
|
327
|
+
return n >= r && n <= v && i >= f && i <= d;
|
|
330
328
|
});
|
|
331
|
-
|
|
332
|
-
},
|
|
333
|
-
var
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
336
|
-
const o = F(
|
|
329
|
+
c ? V(t, c) && c.remove() : s ? s.focus() : e === t && ((o = t.control) == null || o.focus());
|
|
330
|
+
}, Ft = (t, e) => {
|
|
331
|
+
var i;
|
|
332
|
+
const n = e.target;
|
|
333
|
+
if (!dt(e) || !(n != null && n.value.trim())) return;
|
|
334
|
+
const o = F(n), l = [...t.items], s = [...((i = n == null ? void 0 : n.list) == null ? void 0 : i.children) || []].find((d) => F(d) === o), u = l.find((d) => d.value === o), r = g("data", (s == null ? void 0 : s.text) || o, {
|
|
337
335
|
value: o
|
|
338
336
|
});
|
|
339
|
-
if (
|
|
340
|
-
if (
|
|
337
|
+
if (n.value = "", !!V(t, u || r)) {
|
|
338
|
+
if (u) return u.remove();
|
|
341
339
|
if (!l[0]) return t.prepend(r);
|
|
342
340
|
l[l.length - 1].insertAdjacentElement("afterend", r);
|
|
343
341
|
}
|
|
344
|
-
},
|
|
345
|
-
var
|
|
346
|
-
const { key: o, repeat: l, target:
|
|
347
|
-
let r =
|
|
348
|
-
if (!(r === -1 || !
|
|
349
|
-
if (o === "ArrowRight" && !
|
|
350
|
-
else if (o === "ArrowLeft" && !
|
|
342
|
+
}, Nt = (t, e) => {
|
|
343
|
+
var i, n;
|
|
344
|
+
const { key: o, repeat: l, target: c } = e, s = t.control === c ? t.control : null, u = s == null ? void 0 : s.selectionEnd;
|
|
345
|
+
let r = s ? t.items.length : (i = t._focusIndex) != null ? i : -1;
|
|
346
|
+
if (!(r === -1 || !s && Et(e))) {
|
|
347
|
+
if (o === "ArrowRight" && !s) r += 1;
|
|
348
|
+
else if (o === "ArrowLeft" && !u) r -= 1;
|
|
351
349
|
else {
|
|
352
|
-
if (o === "Enter" &&
|
|
353
|
-
return e.preventDefault(),
|
|
354
|
-
if ((o === "Backspace" || o === "Delete") && !
|
|
355
|
-
const
|
|
356
|
-
if (e.preventDefault(),
|
|
357
|
-
|
|
350
|
+
if (o === "Enter" && s)
|
|
351
|
+
return e.preventDefault(), s.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
352
|
+
if ((o === "Backspace" || o === "Delete") && !u) {
|
|
353
|
+
const d = !l && t.items[r];
|
|
354
|
+
if (e.preventDefault(), d) return V(t, d) && d.remove();
|
|
355
|
+
s && (r -= 1);
|
|
358
356
|
} else return;
|
|
359
357
|
}
|
|
360
|
-
e.preventDefault(), (
|
|
358
|
+
e.preventDefault(), (n = t.items[Math.max(0, r)] || t.control) == null || n.focus();
|
|
361
359
|
}
|
|
362
360
|
};
|
|
363
|
-
B.define("u-tags",
|
|
361
|
+
B.define("u-tags", Dt);
|
|
364
362
|
export {
|
|
365
|
-
|
|
363
|
+
Dt as UHTMLTagsElement
|
|
366
364
|
};
|
|
367
365
|
//# sourceMappingURL=u-tags.js.map
|