@letsprogram/ng-oat 0.1.2 → 0.1.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/README.md +5 -7
- package/assets/oat/css/utilities.css +4 -0
- package/assets/oat/oat.min.css +16 -0
- package/fesm2022/letsprogram-ng-oat.mjs +728 -81
- package/package.json +1 -1
- package/types/letsprogram-ng-oat.d.ts +207 -34
- package/assets/oat/js/base.js +0 -107
- package/assets/oat/js/dropdown.js +0 -74
- package/assets/oat/js/index.js +0 -12
- package/assets/oat/js/sidebar.js +0 -22
- package/assets/oat/js/tabs.js +0 -94
- package/assets/oat/js/toast.js +0 -144
- package/assets/oat/js/tooltip.js +0 -36
- package/assets/oat/oat.js +0 -342
- package/assets/oat/oat.min.js +0 -267
package/assets/oat/oat.min.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
(() => {
|
|
2
|
-
var l = class extends HTMLElement {
|
|
3
|
-
#t = !1;
|
|
4
|
-
connectedCallback() {
|
|
5
|
-
this.#t ||
|
|
6
|
-
(document.readyState === 'loading'
|
|
7
|
-
? document.addEventListener('DOMContentLoaded', () => this.#e(), { once: !0 })
|
|
8
|
-
: this.#e());
|
|
9
|
-
}
|
|
10
|
-
#e() {
|
|
11
|
-
this.#t || ((this.#t = !0), this.init());
|
|
12
|
-
}
|
|
13
|
-
disconnectedCallback() {
|
|
14
|
-
this.cleanup();
|
|
15
|
-
}
|
|
16
|
-
cleanup() {}
|
|
17
|
-
handleEvent(t) {
|
|
18
|
-
let e = this[`on${t.type}`];
|
|
19
|
-
e && e.call(this, t);
|
|
20
|
-
}
|
|
21
|
-
keyNav(t, e, n, o, s, a = !1) {
|
|
22
|
-
let { key: r } = t,
|
|
23
|
-
c = -1;
|
|
24
|
-
return (
|
|
25
|
-
r === s
|
|
26
|
-
? (c = (e + 1) % n)
|
|
27
|
-
: r === o
|
|
28
|
-
? (c = (e - 1 + n) % n)
|
|
29
|
-
: a && (r === 'Home' ? (c = 0) : r === 'End' && (c = n - 1)),
|
|
30
|
-
c >= 0 && t.preventDefault(),
|
|
31
|
-
c
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
emit(t, e = null) {
|
|
35
|
-
return this.dispatchEvent(
|
|
36
|
-
new CustomEvent(t, { bubbles: !0, composed: !0, cancelable: !0, detail: e }),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
$(t) {
|
|
40
|
-
return this.querySelector(t);
|
|
41
|
-
}
|
|
42
|
-
$$(t) {
|
|
43
|
-
return Array.from(this.querySelectorAll(t));
|
|
44
|
-
}
|
|
45
|
-
uid() {
|
|
46
|
-
return Math.random().toString(36).slice(2, 10);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
'commandForElement' in HTMLButtonElement.prototype ||
|
|
50
|
-
document.addEventListener('click', (i) => {
|
|
51
|
-
let t = i.target.closest('button[commandfor]');
|
|
52
|
-
if (!t) return;
|
|
53
|
-
let e = document.getElementById(t.getAttribute('commandfor'));
|
|
54
|
-
if (!e) return;
|
|
55
|
-
let n = t.getAttribute('command') || 'toggle';
|
|
56
|
-
e instanceof HTMLDialogElement &&
|
|
57
|
-
(n === 'show-modal' ? e.showModal() : n === 'close' || e.open ? e.close() : e.showModal());
|
|
58
|
-
});
|
|
59
|
-
var u = class extends l {
|
|
60
|
-
#t = [];
|
|
61
|
-
#e = [];
|
|
62
|
-
init() {
|
|
63
|
-
let t = this.$(':scope > [role="tablist"]');
|
|
64
|
-
if (
|
|
65
|
-
((this.#t = t ? [...t.querySelectorAll('[role="tab"]')] : []),
|
|
66
|
-
(this.#e = this.$$(':scope > [role="tabpanel"]')),
|
|
67
|
-
this.#t.length === 0 || this.#e.length === 0)
|
|
68
|
-
) {
|
|
69
|
-
console.warn('ot-tabs: Missing tab or tabpanel elements');
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
(this.#t.forEach((n, o) => {
|
|
73
|
-
let s = this.#e[o];
|
|
74
|
-
if (!s) return;
|
|
75
|
-
let a = n.id || `ot-tab-${this.uid()}`,
|
|
76
|
-
r = s.id || `ot-panel-${this.uid()}`;
|
|
77
|
-
((n.id = a),
|
|
78
|
-
(s.id = r),
|
|
79
|
-
n.setAttribute('aria-controls', r),
|
|
80
|
-
s.setAttribute('aria-labelledby', a));
|
|
81
|
-
}),
|
|
82
|
-
t.addEventListener('click', this),
|
|
83
|
-
t.addEventListener('keydown', this));
|
|
84
|
-
let e = this.#t.findIndex((n) => n.ariaSelected === 'true');
|
|
85
|
-
this.#i(e >= 0 ? e : 0);
|
|
86
|
-
}
|
|
87
|
-
onclick(t) {
|
|
88
|
-
let e = this.#t.indexOf(t.target.closest('[role="tab"]'));
|
|
89
|
-
e >= 0 && this.#i(e);
|
|
90
|
-
}
|
|
91
|
-
onkeydown(t) {
|
|
92
|
-
if (!t.target.closest('[role="tab"]')) return;
|
|
93
|
-
let e = this.keyNav(t, this.activeIndex, this.#t.length, 'ArrowLeft', 'ArrowRight');
|
|
94
|
-
e >= 0 && (this.#i(e), this.#t[e].focus());
|
|
95
|
-
}
|
|
96
|
-
#i(t) {
|
|
97
|
-
(this.#t.forEach((e, n) => {
|
|
98
|
-
let o = n === t;
|
|
99
|
-
((e.ariaSelected = String(o)), (e.tabIndex = o ? 0 : -1));
|
|
100
|
-
}),
|
|
101
|
-
this.#e.forEach((e, n) => {
|
|
102
|
-
e.hidden = n !== t;
|
|
103
|
-
}),
|
|
104
|
-
this.emit('ot-tab-change', { index: t, tab: this.#t[t] }));
|
|
105
|
-
}
|
|
106
|
-
get activeIndex() {
|
|
107
|
-
return this.#t.findIndex((t) => t.ariaSelected === 'true');
|
|
108
|
-
}
|
|
109
|
-
set activeIndex(t) {
|
|
110
|
-
t >= 0 && t < this.#t.length && this.#i(t);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
customElements.define('ot-tabs', u);
|
|
114
|
-
var h = class extends l {
|
|
115
|
-
#t;
|
|
116
|
-
#e;
|
|
117
|
-
#i;
|
|
118
|
-
#n;
|
|
119
|
-
init() {
|
|
120
|
-
((this.#t = this.$('[popover]')),
|
|
121
|
-
(this.#e = this.$('[popovertarget]')),
|
|
122
|
-
!(!this.#t || !this.#e) &&
|
|
123
|
-
(this.#t.addEventListener('toggle', this),
|
|
124
|
-
this.#t.addEventListener('keydown', this),
|
|
125
|
-
(this.#i = () => {
|
|
126
|
-
let t = this.#e.getBoundingClientRect(),
|
|
127
|
-
e = this.#t.getBoundingClientRect();
|
|
128
|
-
((this.#t.style.top = `${t.bottom + e.height > window.innerHeight ? t.top - e.height : t.bottom}px`),
|
|
129
|
-
(this.#t.style.left = `${t.left + e.width > window.innerWidth ? t.right - e.width : t.left}px`));
|
|
130
|
-
})));
|
|
131
|
-
}
|
|
132
|
-
ontoggle(t) {
|
|
133
|
-
t.newState === 'open'
|
|
134
|
-
? (this.#i(),
|
|
135
|
-
window.addEventListener('scroll', this.#i, !0),
|
|
136
|
-
window.addEventListener('resize', this.#i),
|
|
137
|
-
(this.#n = this.$$('[role="menuitem"]')),
|
|
138
|
-
this.#n[0]?.focus(),
|
|
139
|
-
(this.#e.ariaExpanded = 'true'))
|
|
140
|
-
: (this.cleanup(), (this.#n = null), (this.#e.ariaExpanded = 'false'), this.#e.focus());
|
|
141
|
-
}
|
|
142
|
-
onkeydown(t) {
|
|
143
|
-
if (!t.target.matches('[role="menuitem"]')) return;
|
|
144
|
-
let e = this.#n.indexOf(t.target),
|
|
145
|
-
n = this.keyNav(t, e, this.#n.length, 'ArrowUp', 'ArrowDown', !0);
|
|
146
|
-
n >= 0 && this.#n[n].focus();
|
|
147
|
-
}
|
|
148
|
-
cleanup() {
|
|
149
|
-
(window.removeEventListener('scroll', this.#i, !0),
|
|
150
|
-
window.removeEventListener('resize', this.#i));
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
customElements.define('ot-dropdown', h);
|
|
154
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
155
|
-
let i = 'title',
|
|
156
|
-
t = '[title]',
|
|
157
|
-
e = (n) => {
|
|
158
|
-
let o = n.getAttribute(i);
|
|
159
|
-
o &&
|
|
160
|
-
(n.setAttribute('data-tooltip', o),
|
|
161
|
-
n.hasAttribute('aria-label') || n.setAttribute('aria-label', o),
|
|
162
|
-
n.removeAttribute(i));
|
|
163
|
-
};
|
|
164
|
-
(document.querySelectorAll(t).forEach(e),
|
|
165
|
-
new MutationObserver((n) => {
|
|
166
|
-
for (let o of n) {
|
|
167
|
-
e(o.target);
|
|
168
|
-
for (let s of o.addedNodes) s.nodeType === 1 && (e(s), s.querySelectorAll(t).forEach(e));
|
|
169
|
-
}
|
|
170
|
-
}).observe(document.body, {
|
|
171
|
-
childList: !0,
|
|
172
|
-
subtree: !0,
|
|
173
|
-
attributes: !0,
|
|
174
|
-
attributeFilter: [i],
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
177
|
-
document.addEventListener('click', (i) => {
|
|
178
|
-
let t = i.target.closest('[data-sidebar-toggle]');
|
|
179
|
-
if (t) {
|
|
180
|
-
t.closest('[data-sidebar-layout]')?.toggleAttribute('data-sidebar-open');
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (!i.target.closest('[data-sidebar]')) {
|
|
184
|
-
let e = document.querySelector('[data-sidebar-layout][data-sidebar-open]');
|
|
185
|
-
e &&
|
|
186
|
-
window.matchMedia('(max-width: 768px)').matches &&
|
|
187
|
-
e.removeAttribute('data-sidebar-open');
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
var d = {};
|
|
191
|
-
function E(i) {
|
|
192
|
-
if (!d[i]) {
|
|
193
|
-
let t = document.createElement('div');
|
|
194
|
-
((t.className = 'toast-container'),
|
|
195
|
-
t.setAttribute('popover', 'manual'),
|
|
196
|
-
t.setAttribute('data-placement', i),
|
|
197
|
-
document.body.appendChild(t),
|
|
198
|
-
(d[i] = t));
|
|
199
|
-
}
|
|
200
|
-
return d[i];
|
|
201
|
-
}
|
|
202
|
-
function p(i, t = {}) {
|
|
203
|
-
let { placement: e = 'top-right', duration: n = 4e3 } = t,
|
|
204
|
-
o = E(e);
|
|
205
|
-
i.classList.add('toast');
|
|
206
|
-
let s;
|
|
207
|
-
return (
|
|
208
|
-
(i.onmouseenter = () => clearTimeout(s)),
|
|
209
|
-
(i.onmouseleave = () => {
|
|
210
|
-
n > 0 && (s = setTimeout(() => f(i, o), n));
|
|
211
|
-
}),
|
|
212
|
-
i.setAttribute('data-entering', ''),
|
|
213
|
-
o.appendChild(i),
|
|
214
|
-
o.showPopover(),
|
|
215
|
-
requestAnimationFrame(() => {
|
|
216
|
-
requestAnimationFrame(() => {
|
|
217
|
-
i.removeAttribute('data-entering');
|
|
218
|
-
});
|
|
219
|
-
}),
|
|
220
|
-
n > 0 && (s = setTimeout(() => f(i, o), n)),
|
|
221
|
-
i
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
function f(i, t) {
|
|
225
|
-
if (i.hasAttribute('data-exiting')) return;
|
|
226
|
-
i.setAttribute('data-exiting', '');
|
|
227
|
-
let e = () => {
|
|
228
|
-
(i.remove(), t.children.length || t.hidePopover());
|
|
229
|
-
};
|
|
230
|
-
i.addEventListener('transitionend', e, { once: !0 });
|
|
231
|
-
let n = getComputedStyle(i).getPropertyValue('--transition').trim(),
|
|
232
|
-
o = parseFloat(n),
|
|
233
|
-
s = n.endsWith('ms') ? o : o * 1e3;
|
|
234
|
-
setTimeout(e, s);
|
|
235
|
-
}
|
|
236
|
-
function b(i, t, e = {}) {
|
|
237
|
-
let { variant: n = 'info', ...o } = e,
|
|
238
|
-
s = document.createElement('output');
|
|
239
|
-
if ((s.setAttribute('data-variant', n), t)) {
|
|
240
|
-
let r = document.createElement('h6');
|
|
241
|
-
((r.className = 'toast-title'), (r.textContent = t), s.appendChild(r));
|
|
242
|
-
}
|
|
243
|
-
let a = document.createElement('div');
|
|
244
|
-
return ((a.className = 'toast-message'), (a.textContent = i), s.appendChild(a), p(s, o));
|
|
245
|
-
}
|
|
246
|
-
function g(i, t = {}) {
|
|
247
|
-
let e;
|
|
248
|
-
if (
|
|
249
|
-
(i instanceof HTMLTemplateElement
|
|
250
|
-
? (e = i.content.firstElementChild?.cloneNode(!0))
|
|
251
|
-
: i && (e = i.cloneNode(!0)),
|
|
252
|
-
!!e)
|
|
253
|
-
)
|
|
254
|
-
return (e.removeAttribute('id'), p(e, t));
|
|
255
|
-
}
|
|
256
|
-
function v(i) {
|
|
257
|
-
i && d[i]
|
|
258
|
-
? ((d[i].innerHTML = ''), d[i].hidePopover())
|
|
259
|
-
: Object.values(d).forEach((t) => {
|
|
260
|
-
((t.innerHTML = ''), t.hidePopover());
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
var m = window.ot || (window.ot = {});
|
|
264
|
-
m.toast = b;
|
|
265
|
-
m.toast.el = g;
|
|
266
|
-
m.toast.clear = v;
|
|
267
|
-
})();
|