@timlassiter11/yatl-ui 0.0.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/dist/index.d.mts +768 -0
- package/dist/index.d.ts +768 -0
- package/dist/index.js +4650 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4599 -0
- package/dist/index.mjs.map +1 -0
- package/dist/yatl.min.global.js +2331 -0
- package/dist/yatl.min.global.js.map +1 -0
- package/package.json +78 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4599 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __reflectGet = Reflect.get;
|
|
5
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
7
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
|
+
if (decorator = decorators[i])
|
|
9
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
10
|
+
if (kind && result) __defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
14
|
+
|
|
15
|
+
// src/setup-context.ts
|
|
16
|
+
import { ContextRoot } from "@lit/context";
|
|
17
|
+
var root = new ContextRoot();
|
|
18
|
+
root.attach(document.documentElement);
|
|
19
|
+
|
|
20
|
+
// src/components/button/button.ts
|
|
21
|
+
import { html } from "lit";
|
|
22
|
+
import { customElement, property } from "lit/decorators.js";
|
|
23
|
+
|
|
24
|
+
// src/components/base/base.ts
|
|
25
|
+
import { LitElement } from "lit";
|
|
26
|
+
|
|
27
|
+
// src/styles/components/host.styles.ts
|
|
28
|
+
import { css } from "lit";
|
|
29
|
+
var host_styles_default = css`
|
|
30
|
+
:host {
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([data-group-position]) {
|
|
35
|
+
margin-right: -1px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([data-group-position='middle']) {
|
|
39
|
+
--button-radius: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([data-group-position='first']) {
|
|
43
|
+
--button-radius: var(--button-group-radius) 0 0 var(--button-group-radius);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host([data-group-position='last']) {
|
|
47
|
+
--button-radius: 0 var(--button-group-radius) var(--button-group-radius) 0;
|
|
48
|
+
margin-right: 0;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
// src/components/base/base.ts
|
|
53
|
+
var YatlBase = class extends LitElement {
|
|
54
|
+
static {
|
|
55
|
+
this.styles = [host_styles_default];
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/components/button/button.styles.ts
|
|
60
|
+
import { css as css2 } from "lit";
|
|
61
|
+
var button_styles_default = css2`
|
|
62
|
+
:host {
|
|
63
|
+
--button-border-style: var(--yatl-button-border-style, solid);
|
|
64
|
+
--button-radius: var(--yatl-button-radius, var(--yatl-radius-s));
|
|
65
|
+
--button-padding: var(--yatl-button-padding, var(--yatl-spacing-s));
|
|
66
|
+
--button-hover-bg: var(
|
|
67
|
+
--yatl-button-hover-bg,
|
|
68
|
+
color-mix(in srgb, var(--yatl-color-mix) 10%, var(--button-bg))
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
display: inline-block;
|
|
72
|
+
|
|
73
|
+
/* Appearance sets color, variant decides how to use it */
|
|
74
|
+
--appearance-text: var(--yatl-text-inverse);
|
|
75
|
+
--appearance-color: var(--yatl-color-neutral);
|
|
76
|
+
|
|
77
|
+
--button-text: var(--yatl-button-text, var(--appearance-text));
|
|
78
|
+
--button-bg: var(--yatl-button-bg, var(--appearance-color));
|
|
79
|
+
--button-border-width: var(--yatl-button-border-width, 1px);
|
|
80
|
+
--button-border-color: var(--yatl-button-border, var(--appearance-color));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[part='base'] {
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: 100%;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
padding: var(--button-padding);
|
|
91
|
+
border-radius: var(--button-radius);
|
|
92
|
+
color: var(--button-text);
|
|
93
|
+
font-size: large;
|
|
94
|
+
font-weight: 500;
|
|
95
|
+
background-color: var(--button-bg);
|
|
96
|
+
border: var(--button-border-width) solid var(--button-border-color);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([disabled]) [part='base'] {
|
|
100
|
+
opacity: 0.5;
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
filter: grayscale(100%);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host(:not([disabled])) [part='base']:hover {
|
|
106
|
+
background-color: var(--button-hover-bg);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:host([color='brand']) {
|
|
110
|
+
--appearance-color: var(--yatl-color-brand);
|
|
111
|
+
--appearance-text: var(--yatl-text-brand);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host([color='danger']) {
|
|
115
|
+
--appearance-color: var(--yatl-color-danger);
|
|
116
|
+
--appearance-text: white;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host([color='warning']) {
|
|
120
|
+
--appearance-color: var(--yatl-color-warning);
|
|
121
|
+
--appearance-text: white;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([color='success']) {
|
|
125
|
+
--appearance-color: var(--yatl-color-success);
|
|
126
|
+
--appearance-text: white;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host([color='raised']) {
|
|
130
|
+
--appearance-color: var(--yatl-surface-2);
|
|
131
|
+
--appearance-text: var(--yatl-text-1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host([color='muted']) {
|
|
135
|
+
--appearance-color: var(--yatl-text-3);
|
|
136
|
+
--appearance-text: white;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host([variant='outline']) {
|
|
140
|
+
--button-bg: transparent;
|
|
141
|
+
--button-text: var(--appearance-color);
|
|
142
|
+
--button-border-color: var(--appearance-color);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:host([variant='plain']) {
|
|
146
|
+
--button-text: var(--appearance-color);
|
|
147
|
+
--button-bg: transparent;
|
|
148
|
+
--button-border-width: 0;
|
|
149
|
+
}
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
// src/components/button/button.ts
|
|
153
|
+
var YatlButton = class extends YatlBase {
|
|
154
|
+
constructor() {
|
|
155
|
+
super(...arguments);
|
|
156
|
+
this.disabled = false;
|
|
157
|
+
this.type = "button";
|
|
158
|
+
this.variant = "neutral";
|
|
159
|
+
this.color = "neutral";
|
|
160
|
+
}
|
|
161
|
+
render() {
|
|
162
|
+
return html`
|
|
163
|
+
<button part="base" type=${this.type} ?disabled=${this.disabled}>
|
|
164
|
+
<slot name="start"></slot>
|
|
165
|
+
<slot></slot>
|
|
166
|
+
<slot name="end"></slot>
|
|
167
|
+
</button>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
YatlButton.styles = [...__superGet(YatlButton, YatlButton, "styles"), button_styles_default];
|
|
172
|
+
__decorateClass([
|
|
173
|
+
property({ type: Boolean, reflect: true })
|
|
174
|
+
], YatlButton.prototype, "disabled", 2);
|
|
175
|
+
__decorateClass([
|
|
176
|
+
property({ type: String, reflect: true })
|
|
177
|
+
], YatlButton.prototype, "type", 2);
|
|
178
|
+
__decorateClass([
|
|
179
|
+
property({ type: String, reflect: true })
|
|
180
|
+
], YatlButton.prototype, "variant", 2);
|
|
181
|
+
__decorateClass([
|
|
182
|
+
property({ type: String, reflect: true })
|
|
183
|
+
], YatlButton.prototype, "color", 2);
|
|
184
|
+
YatlButton = __decorateClass([
|
|
185
|
+
customElement("yatl-button")
|
|
186
|
+
], YatlButton);
|
|
187
|
+
|
|
188
|
+
// src/components/button-group/button-group.ts
|
|
189
|
+
import { html as html4 } from "lit";
|
|
190
|
+
import { customElement as customElement4 } from "lit/decorators.js";
|
|
191
|
+
|
|
192
|
+
// src/utils/common.ts
|
|
193
|
+
function getEffectiveChildren(node) {
|
|
194
|
+
if (node instanceof HTMLSlotElement) {
|
|
195
|
+
const assigned = node.assignedElements({ flatten: true });
|
|
196
|
+
if (assigned.length > 0) {
|
|
197
|
+
return assigned.flatMap(getEffectiveChildren);
|
|
198
|
+
}
|
|
199
|
+
const fallback = Array.from(node.children);
|
|
200
|
+
return fallback.flatMap(getEffectiveChildren);
|
|
201
|
+
}
|
|
202
|
+
if (node instanceof Element) {
|
|
203
|
+
return [node];
|
|
204
|
+
}
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
var DateConverter = class {
|
|
208
|
+
fromAttribute(value) {
|
|
209
|
+
if (!value) return void 0;
|
|
210
|
+
const [year, month, day] = value.split("-").map(Number);
|
|
211
|
+
const date = new Date(year, month - 1, day);
|
|
212
|
+
return isNaN(date.getTime()) ? void 0 : date;
|
|
213
|
+
}
|
|
214
|
+
toAttribute(value) {
|
|
215
|
+
if (typeof value === "string") {
|
|
216
|
+
value = this.fromAttribute(value);
|
|
217
|
+
}
|
|
218
|
+
if (!value || isNaN(value.getTime())) return null;
|
|
219
|
+
const year = value.getFullYear();
|
|
220
|
+
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
221
|
+
const day = String(value.getDate()).padStart(2, "0");
|
|
222
|
+
return `${year}-${month}-${day}`;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
var dateConverter = new DateConverter();
|
|
226
|
+
function* activeElements(activeElement = document.activeElement) {
|
|
227
|
+
if (activeElement === null || activeElement === void 0) return;
|
|
228
|
+
yield activeElement;
|
|
229
|
+
if ("shadowRoot" in activeElement && activeElement.shadowRoot && activeElement.shadowRoot.mode !== "closed") {
|
|
230
|
+
yield* activeElements(activeElement.shadowRoot.activeElement);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function animateWithClass(element, className, timeout = 350) {
|
|
234
|
+
await new Promise((resolve) => {
|
|
235
|
+
const controller = new AbortController();
|
|
236
|
+
const { signal } = controller;
|
|
237
|
+
if (element.classList.contains(className)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
element.classList.remove(className);
|
|
241
|
+
element.classList.add(className);
|
|
242
|
+
let timer = 0;
|
|
243
|
+
const onEnd = () => {
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
element.classList.remove(className);
|
|
246
|
+
resolve();
|
|
247
|
+
controller.abort();
|
|
248
|
+
};
|
|
249
|
+
timer = window.setTimeout(() => {
|
|
250
|
+
onEnd();
|
|
251
|
+
}, timeout);
|
|
252
|
+
element.addEventListener("animationend", onEnd, { once: true, signal });
|
|
253
|
+
element.addEventListener("animationcancel", onEnd, { once: true, signal });
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// src/utils/slot-controller.ts
|
|
258
|
+
var HasSlotController = class {
|
|
259
|
+
constructor(host, ...slotNames) {
|
|
260
|
+
this.slotNames = [];
|
|
261
|
+
this.handleSlotChange = (event) => {
|
|
262
|
+
const slot = event.target;
|
|
263
|
+
if (this.slotNames.includes("[default]") && !slot.name || slot.name && this.slotNames.includes(slot.name)) {
|
|
264
|
+
this.host.requestUpdate();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
(this.host = host).addController(this);
|
|
268
|
+
this.slotNames = slotNames;
|
|
269
|
+
}
|
|
270
|
+
hasDefaultSlot() {
|
|
271
|
+
return [...this.host.childNodes].some((node) => {
|
|
272
|
+
if (node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
276
|
+
const el = node;
|
|
277
|
+
const tagName = el.tagName.toLowerCase();
|
|
278
|
+
if (tagName === "wa-visually-hidden") {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (!el.hasAttribute("slot")) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
hasNamedSlot(name) {
|
|
289
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
290
|
+
}
|
|
291
|
+
test(slotName) {
|
|
292
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
293
|
+
}
|
|
294
|
+
hostConnected() {
|
|
295
|
+
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
|
|
296
|
+
}
|
|
297
|
+
hostDisconnected() {
|
|
298
|
+
this.host.shadowRoot.removeEventListener(
|
|
299
|
+
"slotchange",
|
|
300
|
+
this.handleSlotChange
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
function getInnerHTML(nodes, callback) {
|
|
305
|
+
let html28 = "";
|
|
306
|
+
for (const node of nodes) {
|
|
307
|
+
if (callback) {
|
|
308
|
+
const customHTML = callback(node);
|
|
309
|
+
if (customHTML !== void 0) {
|
|
310
|
+
html28 += customHTML;
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
315
|
+
html28 += node.outerHTML;
|
|
316
|
+
}
|
|
317
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
318
|
+
html28 += node.textContent;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return html28;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// src/components/dropdown/dropdown.ts
|
|
325
|
+
import {
|
|
326
|
+
autoUpdate,
|
|
327
|
+
computePosition,
|
|
328
|
+
flip,
|
|
329
|
+
offset,
|
|
330
|
+
shift,
|
|
331
|
+
size
|
|
332
|
+
} from "@floating-ui/dom";
|
|
333
|
+
import { html as html3 } from "lit";
|
|
334
|
+
import { customElement as customElement3, property as property3, query } from "lit/decorators.js";
|
|
335
|
+
|
|
336
|
+
// src/events/dialog.ts
|
|
337
|
+
import { YatlEvent } from "@timlassiter11/yatl";
|
|
338
|
+
var YatlDialogShowRequest = class _YatlDialogShowRequest extends YatlEvent {
|
|
339
|
+
static {
|
|
340
|
+
this.EVENT_NAME = "yatl-dialog-show-request";
|
|
341
|
+
}
|
|
342
|
+
constructor() {
|
|
343
|
+
super(_YatlDialogShowRequest.EVENT_NAME, { cancelable: true });
|
|
344
|
+
}
|
|
345
|
+
clone() {
|
|
346
|
+
return new _YatlDialogShowRequest();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var YatlDialogShowEvent = class _YatlDialogShowEvent extends YatlEvent {
|
|
350
|
+
static {
|
|
351
|
+
this.EVENT_NAME = "yatl-dialog-show";
|
|
352
|
+
}
|
|
353
|
+
constructor() {
|
|
354
|
+
super(_YatlDialogShowEvent.EVENT_NAME);
|
|
355
|
+
}
|
|
356
|
+
clone() {
|
|
357
|
+
return new _YatlDialogShowEvent();
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var YatlDialogHideRequest = class _YatlDialogHideRequest extends YatlEvent {
|
|
361
|
+
constructor(source) {
|
|
362
|
+
super(_YatlDialogHideRequest.EVENT_NAME, { cancelable: true });
|
|
363
|
+
this.source = source;
|
|
364
|
+
}
|
|
365
|
+
static {
|
|
366
|
+
this.EVENT_NAME = "yatl-dialog-hide-request";
|
|
367
|
+
}
|
|
368
|
+
clone() {
|
|
369
|
+
return new _YatlDialogHideRequest(this.source);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
var YatlDialogHideEvent = class _YatlDialogHideEvent extends YatlEvent {
|
|
373
|
+
static {
|
|
374
|
+
this.EVENT_NAME = "yatl-dialog-hide";
|
|
375
|
+
}
|
|
376
|
+
constructor() {
|
|
377
|
+
super(_YatlDialogHideEvent.EVENT_NAME);
|
|
378
|
+
}
|
|
379
|
+
clone() {
|
|
380
|
+
return new _YatlDialogHideEvent();
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// src/events/dropdown.ts
|
|
385
|
+
import { YatlEvent as YatlEvent2 } from "@timlassiter11/yatl";
|
|
386
|
+
var YatlDropdownOpenRequest = class _YatlDropdownOpenRequest extends YatlEvent2 {
|
|
387
|
+
static {
|
|
388
|
+
this.EVENT_NAME = "yatl-dropdown-open-request";
|
|
389
|
+
}
|
|
390
|
+
constructor() {
|
|
391
|
+
super(_YatlDropdownOpenRequest.EVENT_NAME, { cancelable: true });
|
|
392
|
+
}
|
|
393
|
+
clone() {
|
|
394
|
+
return new _YatlDropdownOpenRequest();
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
var YatlDropdownOpenEvent = class _YatlDropdownOpenEvent extends YatlEvent2 {
|
|
398
|
+
static {
|
|
399
|
+
this.EVENT_NAME = "yatl-dropdown-open";
|
|
400
|
+
}
|
|
401
|
+
constructor() {
|
|
402
|
+
super(_YatlDropdownOpenEvent.EVENT_NAME);
|
|
403
|
+
}
|
|
404
|
+
clone() {
|
|
405
|
+
return new _YatlDropdownOpenEvent();
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
var YatlDropdownCloseRequest = class _YatlDropdownCloseRequest extends YatlEvent2 {
|
|
409
|
+
static {
|
|
410
|
+
this.EVENT_NAME = "yatl-dropdown-close-request";
|
|
411
|
+
}
|
|
412
|
+
constructor() {
|
|
413
|
+
super(_YatlDropdownCloseRequest.EVENT_NAME, { cancelable: true });
|
|
414
|
+
}
|
|
415
|
+
clone() {
|
|
416
|
+
return new _YatlDropdownCloseRequest();
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var YatlDropdownCloseEvent = class _YatlDropdownCloseEvent extends YatlEvent2 {
|
|
420
|
+
static {
|
|
421
|
+
this.EVENT_NAME = "yatl-dropdown-close";
|
|
422
|
+
}
|
|
423
|
+
constructor() {
|
|
424
|
+
super(_YatlDropdownCloseEvent.EVENT_NAME);
|
|
425
|
+
}
|
|
426
|
+
clone() {
|
|
427
|
+
return new _YatlDropdownCloseEvent();
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
var YatlDropdownSelectEvent = class _YatlDropdownSelectEvent extends YatlEvent2 {
|
|
431
|
+
constructor(item) {
|
|
432
|
+
super(_YatlDropdownSelectEvent.EVENT_NAME, { cancelable: true });
|
|
433
|
+
this.item = item;
|
|
434
|
+
}
|
|
435
|
+
static {
|
|
436
|
+
this.EVENT_NAME = "yatl-dropdown-select";
|
|
437
|
+
}
|
|
438
|
+
clone() {
|
|
439
|
+
return new _YatlDropdownSelectEvent(this.item);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// src/events/table-toolbar.ts
|
|
444
|
+
import { YatlEvent as YatlEvent3 } from "@timlassiter11/yatl";
|
|
445
|
+
var YatlToolbarSearchInput = class _YatlToolbarSearchInput extends YatlEvent3 {
|
|
446
|
+
constructor(value) {
|
|
447
|
+
super(_YatlToolbarSearchInput.EVENT_NAME);
|
|
448
|
+
this.value = value;
|
|
449
|
+
}
|
|
450
|
+
static {
|
|
451
|
+
this.EVENT_NAME = "yatl-toolbar-search-input";
|
|
452
|
+
}
|
|
453
|
+
clone() {
|
|
454
|
+
return new _YatlToolbarSearchInput(this.value);
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var YatlToolbarSearchChange = class _YatlToolbarSearchChange extends YatlEvent3 {
|
|
458
|
+
constructor(value) {
|
|
459
|
+
super(_YatlToolbarSearchChange.EVENT_NAME);
|
|
460
|
+
this.value = value;
|
|
461
|
+
}
|
|
462
|
+
static {
|
|
463
|
+
this.EVENT_NAME = "yatl-toolbar-search-change";
|
|
464
|
+
}
|
|
465
|
+
clone() {
|
|
466
|
+
return new _YatlToolbarSearchChange(this.value);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
var YatlToolbarExportClick = class _YatlToolbarExportClick extends YatlEvent3 {
|
|
470
|
+
static {
|
|
471
|
+
this.EVENT_NAME = "yatl-toolbar-export-click";
|
|
472
|
+
}
|
|
473
|
+
constructor() {
|
|
474
|
+
super(_YatlToolbarExportClick.EVENT_NAME);
|
|
475
|
+
}
|
|
476
|
+
clone() {
|
|
477
|
+
return new _YatlToolbarExportClick();
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
// src/events/tag.ts
|
|
482
|
+
import { YatlEvent as YatlEvent4 } from "@timlassiter11/yatl";
|
|
483
|
+
var YatlTagDismissEvent = class _YatlTagDismissEvent extends YatlEvent4 {
|
|
484
|
+
static {
|
|
485
|
+
this.EVENT_NAME = "yatl-tag-dismiss";
|
|
486
|
+
}
|
|
487
|
+
constructor() {
|
|
488
|
+
super(_YatlTagDismissEvent.EVENT_NAME);
|
|
489
|
+
}
|
|
490
|
+
clone() {
|
|
491
|
+
return new _YatlTagDismissEvent();
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
// src/components/option/option.ts
|
|
496
|
+
import { html as html2, nothing } from "lit";
|
|
497
|
+
import { customElement as customElement2, property as property2 } from "lit/decorators.js";
|
|
498
|
+
|
|
499
|
+
// src/components/option/option.styles.ts
|
|
500
|
+
import { css as css3 } from "lit";
|
|
501
|
+
var option_styles_default = css3`
|
|
502
|
+
:host {
|
|
503
|
+
--option-color: var(--yatl-option-color, var(--yatl-text-1));
|
|
504
|
+
--option-font-size: var(--yatl-option-font-size, 16px);
|
|
505
|
+
--option-bg: var(--yatl-option-bg, transparent);
|
|
506
|
+
--option-hover-bg: var(--yatl-option-hover-bg, var(--yatl-color-brand));
|
|
507
|
+
--option-padding: var(--yatl-option-padding, var(--yatl-spacing-s));
|
|
508
|
+
--option-gap: var(--yatl-option-gap, var(--yatl-spacing-xs));
|
|
509
|
+
--option-radius: var(--yatl-option-radius, var(--yatl-radius-s));
|
|
510
|
+
--option-focus-ring: var(
|
|
511
|
+
--yatl-option-focus-ring,
|
|
512
|
+
3px solid var(--yatl-color-brand)
|
|
513
|
+
);
|
|
514
|
+
--option-focus-bg: var(
|
|
515
|
+
--yatl-option-focus-bg,
|
|
516
|
+
color-mix(in srgb, var(--yatl-color-mix), 5%, transparent)
|
|
517
|
+
);
|
|
518
|
+
--option-disabled-color: var(
|
|
519
|
+
--yatl-option-disabled-color,
|
|
520
|
+
var(--yatl-text-3)
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
border-radius: var(--option-radius);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
:host(:focus-visible) {
|
|
527
|
+
z-index: 1;
|
|
528
|
+
outline: var(--option-focus-ring);
|
|
529
|
+
background-color: var(--option-focus-bg);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
[part='base'] {
|
|
533
|
+
display: flex;
|
|
534
|
+
align-items: center;
|
|
535
|
+
cursor: pointer;
|
|
536
|
+
white-space: nowrap;
|
|
537
|
+
user-select: none;
|
|
538
|
+
color: var(--option-color);
|
|
539
|
+
font-size: var(--option-font-size);
|
|
540
|
+
background-color: var(--option-bg);
|
|
541
|
+
padding: var(--option-padding);
|
|
542
|
+
border-radius: var(--option-radius);
|
|
543
|
+
transition: background 0.1s ease;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
:host([disabled]) [part='base'] {
|
|
547
|
+
color: var(--option-disabled-color);
|
|
548
|
+
cursor: not-allowed;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
:host(:not([disabled])) [part='base']:hover {
|
|
552
|
+
background-color: var(--option-hover-bg);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
[part='label'] {
|
|
556
|
+
flex: 1 1 100%;
|
|
557
|
+
display: inline-flex;
|
|
558
|
+
align-items: center;
|
|
559
|
+
line-height: normal;
|
|
560
|
+
overflow-x: hidden;
|
|
561
|
+
text-overflow: ellipsis;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
[part='start'],
|
|
565
|
+
[part='end'] {
|
|
566
|
+
flex: 0 0 0%;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
[part='check'] {
|
|
570
|
+
width: 18px;
|
|
571
|
+
height: 18px;
|
|
572
|
+
margin-right: var(--yatl-spacing-s);
|
|
573
|
+
display: flex;
|
|
574
|
+
align-items: center;
|
|
575
|
+
justify-content: center;
|
|
576
|
+
border: 1px solid transparent;
|
|
577
|
+
border-radius: 3px;
|
|
578
|
+
opacity: 0;
|
|
579
|
+
transform: scale(0.5);
|
|
580
|
+
transition: all 0.2s cubic-bezier(0.12, 0.4, 0.29, 1.46);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
:host([checked]) [part='check'] {
|
|
584
|
+
opacity: 1;
|
|
585
|
+
transform: scale(1);
|
|
586
|
+
}
|
|
587
|
+
`;
|
|
588
|
+
|
|
589
|
+
// src/components/option/option.ts
|
|
590
|
+
var YatlOption = class extends YatlBase {
|
|
591
|
+
constructor() {
|
|
592
|
+
super(...arguments);
|
|
593
|
+
this.value = "on";
|
|
594
|
+
this.checkable = false;
|
|
595
|
+
this.checked = false;
|
|
596
|
+
this.disabled = false;
|
|
597
|
+
this.label = "";
|
|
598
|
+
this.handleItemClicked = (event) => {
|
|
599
|
+
if (this.disabled) {
|
|
600
|
+
event.stopPropagation();
|
|
601
|
+
event.preventDefault();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
if (this.checkable) {
|
|
605
|
+
this.checked = !this.checked;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
render() {
|
|
610
|
+
return html2`
|
|
611
|
+
<span part="base">
|
|
612
|
+
<slot part="start" name="start"></slot>
|
|
613
|
+
${this.renderCheck()} ${this.renderLabel()}
|
|
614
|
+
<slot part="end" name="end"></slot>
|
|
615
|
+
</span>
|
|
616
|
+
`;
|
|
617
|
+
}
|
|
618
|
+
renderLabel() {
|
|
619
|
+
return html2`<span part="label">${this.label}</span>`;
|
|
620
|
+
}
|
|
621
|
+
renderCheck() {
|
|
622
|
+
return this.checkable ? html2`<yatl-icon part="check" name="check"></yatl-icon>` : nothing;
|
|
623
|
+
}
|
|
624
|
+
connectedCallback() {
|
|
625
|
+
super.connectedCallback();
|
|
626
|
+
this.addEventListener("click", this.handleItemClicked);
|
|
627
|
+
}
|
|
628
|
+
disconnectedCallback() {
|
|
629
|
+
super.disconnectedCallback();
|
|
630
|
+
this.removeEventListener("click", this.handleItemClicked);
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
YatlOption.styles = [...__superGet(YatlOption, YatlOption, "styles"), option_styles_default];
|
|
634
|
+
__decorateClass([
|
|
635
|
+
property2({ type: String, reflect: true })
|
|
636
|
+
], YatlOption.prototype, "value", 2);
|
|
637
|
+
__decorateClass([
|
|
638
|
+
property2({ type: Boolean, reflect: true })
|
|
639
|
+
], YatlOption.prototype, "checkable", 2);
|
|
640
|
+
__decorateClass([
|
|
641
|
+
property2({ type: Boolean, reflect: true })
|
|
642
|
+
], YatlOption.prototype, "checked", 2);
|
|
643
|
+
__decorateClass([
|
|
644
|
+
property2({ type: Boolean, reflect: true })
|
|
645
|
+
], YatlOption.prototype, "disabled", 2);
|
|
646
|
+
__decorateClass([
|
|
647
|
+
property2({ type: String, reflect: true })
|
|
648
|
+
], YatlOption.prototype, "label", 2);
|
|
649
|
+
YatlOption = __decorateClass([
|
|
650
|
+
customElement2("yatl-option")
|
|
651
|
+
], YatlOption);
|
|
652
|
+
|
|
653
|
+
// src/components/dropdown/dropdown.styles.ts
|
|
654
|
+
import { css as css4 } from "lit";
|
|
655
|
+
var dropdown_styles_default = css4`
|
|
656
|
+
:host {
|
|
657
|
+
--dropdown-menu-bg: var(--yatl-dropdown-menu-bg, var(--yatl-surface-3));
|
|
658
|
+
--dropdown-menu-padding: var(
|
|
659
|
+
--yatl-dropdown-menu-padding,
|
|
660
|
+
var(--yatl-spacing-s)
|
|
661
|
+
);
|
|
662
|
+
--dropdown-menu-radius: var(
|
|
663
|
+
--yatl-dropdown-menu-radius,
|
|
664
|
+
var(--yatl-radius-m)
|
|
665
|
+
);
|
|
666
|
+
--dropdown-menu-border: var(
|
|
667
|
+
--yatl-dropdown-menu-border,
|
|
668
|
+
var(--yatl-border-color)
|
|
669
|
+
);
|
|
670
|
+
--dropdown-menu-open-bg: var(
|
|
671
|
+
--yatl-dropdown-menu-open-bg,
|
|
672
|
+
var(--yatl-color-brand)
|
|
673
|
+
);
|
|
674
|
+
|
|
675
|
+
overflow: visible !important;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
[part='base'] {
|
|
679
|
+
position: relative;
|
|
680
|
+
height: 100%;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
[part='menu'] {
|
|
684
|
+
position: fixed;
|
|
685
|
+
top: 0;
|
|
686
|
+
left: 0;
|
|
687
|
+
width: max-content;
|
|
688
|
+
box-sizing: border-box;
|
|
689
|
+
z-index: 1000;
|
|
690
|
+
background: var(--dropdown-menu-bg);
|
|
691
|
+
border: 1px solid var(--dropdown-menu-border);
|
|
692
|
+
border-radius: var(--dropdown-menu-radius);
|
|
693
|
+
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 50%);
|
|
694
|
+
padding: var(--dropdown-menu-padding);
|
|
695
|
+
display: none;
|
|
696
|
+
flex-direction: column;
|
|
697
|
+
overflow-y: auto;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
:host([open]) ::slotted(yatl-button[slot='trigger']) {
|
|
701
|
+
--yatl-button-bg: var(--dropdown-menu-open-bg);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
[part='trigger'] {
|
|
705
|
+
display: contents;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
:host([open]) [part='menu'] {
|
|
709
|
+
display: flex;
|
|
710
|
+
}
|
|
711
|
+
`;
|
|
712
|
+
|
|
713
|
+
// src/components/dropdown/dropdown.ts
|
|
714
|
+
var YatlDropdown = class extends YatlBase {
|
|
715
|
+
constructor() {
|
|
716
|
+
super(...arguments);
|
|
717
|
+
this.open = false;
|
|
718
|
+
this.matchWidth = false;
|
|
719
|
+
this.handleKeydown = (event) => {
|
|
720
|
+
if (this.open) {
|
|
721
|
+
if (event.key === "Escape") {
|
|
722
|
+
this.open = false;
|
|
723
|
+
this.referenceElement?.focus();
|
|
724
|
+
} else if (["ArrowUp", "ArrowDown", "Home", "End", " "].includes(event.key)) {
|
|
725
|
+
const items = this.getItems();
|
|
726
|
+
const activeItem = this.getActiveItem(items);
|
|
727
|
+
if (activeItem) {
|
|
728
|
+
activeItem.tabIndex = -1;
|
|
729
|
+
}
|
|
730
|
+
let itemToFocus;
|
|
731
|
+
const activeItemIndex = activeItem ? items.indexOf(activeItem) : -1;
|
|
732
|
+
if (event.key === "ArrowUp") {
|
|
733
|
+
if (activeItemIndex > 0) {
|
|
734
|
+
itemToFocus = items[activeItemIndex - 1];
|
|
735
|
+
} else {
|
|
736
|
+
itemToFocus = items[items.length - 1];
|
|
737
|
+
}
|
|
738
|
+
} else if (event.key === "ArrowDown") {
|
|
739
|
+
if (activeItemIndex !== -1 && activeItemIndex < items.length - 1) {
|
|
740
|
+
itemToFocus = items[activeItemIndex + 1];
|
|
741
|
+
} else {
|
|
742
|
+
itemToFocus = items[0];
|
|
743
|
+
}
|
|
744
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
745
|
+
const composedPath = event.composedPath();
|
|
746
|
+
const trigger = this.referenceElement;
|
|
747
|
+
if (trigger && composedPath.includes(trigger)) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
itemToFocus = event.key === "Home" ? items[0] : items[items.length - 1];
|
|
751
|
+
} else if (event.key === " ") {
|
|
752
|
+
event.preventDefault();
|
|
753
|
+
event.stopPropagation();
|
|
754
|
+
activeItem?.click();
|
|
755
|
+
}
|
|
756
|
+
if (itemToFocus) {
|
|
757
|
+
event.preventDefault();
|
|
758
|
+
event.stopPropagation();
|
|
759
|
+
itemToFocus.tabIndex = 0;
|
|
760
|
+
itemToFocus.focus();
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
this.handleDocumentFocusin = (event) => {
|
|
767
|
+
const path = event.composedPath();
|
|
768
|
+
if (!path.includes(this)) {
|
|
769
|
+
this.open = false;
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
// #region Render
|
|
774
|
+
render() {
|
|
775
|
+
return html3`
|
|
776
|
+
<div part="base">
|
|
777
|
+
<div part="trigger">
|
|
778
|
+
<slot
|
|
779
|
+
name="trigger"
|
|
780
|
+
@click=${this.handleTriggerClick}
|
|
781
|
+
@keydown=${this.handleTriggerKeydown}
|
|
782
|
+
></slot>
|
|
783
|
+
</div>
|
|
784
|
+
<div part="menu" @click=${this.handleItemClick}>
|
|
785
|
+
<slot></slot>
|
|
786
|
+
</div>
|
|
787
|
+
</div>
|
|
788
|
+
`;
|
|
789
|
+
}
|
|
790
|
+
// #endregion
|
|
791
|
+
// #region Lifecycle
|
|
792
|
+
updated(changedProperties) {
|
|
793
|
+
super.updated(changedProperties);
|
|
794
|
+
if (changedProperties.has("open")) {
|
|
795
|
+
if (this.open) {
|
|
796
|
+
this.addListeners();
|
|
797
|
+
this.dispatchEvent(new YatlDropdownOpenEvent());
|
|
798
|
+
} else {
|
|
799
|
+
this.removeListeners();
|
|
800
|
+
this.dispatchEvent(new YatlDropdownCloseEvent());
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
disconnectedCallback() {
|
|
805
|
+
super.disconnectedCallback();
|
|
806
|
+
this.removeListeners();
|
|
807
|
+
}
|
|
808
|
+
// #endregion
|
|
809
|
+
// #region Event Handlers
|
|
810
|
+
handleTriggerClick(event) {
|
|
811
|
+
if (event.pointerId === -1 && this.open) {
|
|
812
|
+
event.preventDefault();
|
|
813
|
+
event.stopPropagation();
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
const requestEvent = this.open ? new YatlDropdownCloseRequest() : new YatlDropdownOpenRequest();
|
|
817
|
+
if (!this.dispatchEvent(requestEvent)) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
this.open = !this.open;
|
|
821
|
+
}
|
|
822
|
+
handleItemClick(event) {
|
|
823
|
+
const item = event.target;
|
|
824
|
+
if (!(item instanceof YatlOption)) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
const selectEvent = new YatlDropdownSelectEvent(item);
|
|
828
|
+
if (this.dispatchEvent(selectEvent)) {
|
|
829
|
+
this.open = false;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
handleTriggerKeydown(event) {
|
|
833
|
+
if (!this.open && event.key === " ") {
|
|
834
|
+
this.open = true;
|
|
835
|
+
event.preventDefault();
|
|
836
|
+
event.stopPropagation();
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
// #endregion
|
|
840
|
+
// #region Utilities
|
|
841
|
+
addListeners() {
|
|
842
|
+
this.startPositioning();
|
|
843
|
+
document.addEventListener("click", this.handleDocumentFocusin);
|
|
844
|
+
document.addEventListener("focusin", this.handleDocumentFocusin);
|
|
845
|
+
document.addEventListener("keydown", this.handleKeydown);
|
|
846
|
+
}
|
|
847
|
+
removeListeners() {
|
|
848
|
+
this.autoUpdateCleanup?.();
|
|
849
|
+
document.removeEventListener("click", this.handleDocumentFocusin);
|
|
850
|
+
document.removeEventListener("focusin", this.handleDocumentFocusin);
|
|
851
|
+
document.removeEventListener("keydown", this.handleKeydown);
|
|
852
|
+
}
|
|
853
|
+
getItems(includeDisabled = false) {
|
|
854
|
+
const items = this.defaultSlot?.assignedElements({ flatten: true }).filter((i) => i instanceof YatlOption) ?? [];
|
|
855
|
+
return includeDisabled ? items : items.filter((i) => !i.disabled);
|
|
856
|
+
}
|
|
857
|
+
getActiveItem(items) {
|
|
858
|
+
const activeElement = [...activeElements()].find(
|
|
859
|
+
(i) => i instanceof YatlOption
|
|
860
|
+
);
|
|
861
|
+
return items.find((item) => item === activeElement);
|
|
862
|
+
}
|
|
863
|
+
async startPositioning() {
|
|
864
|
+
const menu = this.menuElement;
|
|
865
|
+
const trigger = this.referenceElement;
|
|
866
|
+
if (!trigger) {
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
this.autoUpdateCleanup = autoUpdate(trigger, menu, () => {
|
|
870
|
+
computePosition(trigger, menu, {
|
|
871
|
+
placement: "bottom-start",
|
|
872
|
+
strategy: "fixed",
|
|
873
|
+
middleware: [
|
|
874
|
+
offset(4),
|
|
875
|
+
size({
|
|
876
|
+
apply: ({ rects, availableHeight, elements }) => {
|
|
877
|
+
const maxHeight = 400;
|
|
878
|
+
const screenBuffer = 10;
|
|
879
|
+
const actualMaxHeight = Math.min(
|
|
880
|
+
maxHeight,
|
|
881
|
+
availableHeight - screenBuffer
|
|
882
|
+
);
|
|
883
|
+
const styles = {
|
|
884
|
+
"max-height": `${actualMaxHeight}px`
|
|
885
|
+
};
|
|
886
|
+
if (this.matchWidth) {
|
|
887
|
+
styles["width"] = `${rects.reference.width}px`;
|
|
888
|
+
} else {
|
|
889
|
+
styles["min-width"] = `${rects.reference.width}px`;
|
|
890
|
+
}
|
|
891
|
+
Object.assign(elements.floating.style, styles);
|
|
892
|
+
},
|
|
893
|
+
padding: 10
|
|
894
|
+
}),
|
|
895
|
+
flip(),
|
|
896
|
+
shift({ padding: 5 })
|
|
897
|
+
]
|
|
898
|
+
}).then(({ x, y }) => {
|
|
899
|
+
Object.assign(menu.style, {
|
|
900
|
+
left: `${x}px`,
|
|
901
|
+
top: `${y}px`
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
get referenceElement() {
|
|
907
|
+
return this.triggerSlot?.assignedElements({ flatten: true }).at(0);
|
|
908
|
+
}
|
|
909
|
+
// #endregion
|
|
910
|
+
};
|
|
911
|
+
YatlDropdown.styles = [...__superGet(YatlDropdown, YatlDropdown, "styles"), dropdown_styles_default];
|
|
912
|
+
__decorateClass([
|
|
913
|
+
query('[part="menu"]')
|
|
914
|
+
], YatlDropdown.prototype, "menuElement", 2);
|
|
915
|
+
__decorateClass([
|
|
916
|
+
query('slot[name="trigger"]')
|
|
917
|
+
], YatlDropdown.prototype, "triggerSlot", 2);
|
|
918
|
+
__decorateClass([
|
|
919
|
+
query("slot:not([name])")
|
|
920
|
+
], YatlDropdown.prototype, "defaultSlot", 2);
|
|
921
|
+
__decorateClass([
|
|
922
|
+
property3({ type: Boolean, reflect: true })
|
|
923
|
+
], YatlDropdown.prototype, "open", 2);
|
|
924
|
+
__decorateClass([
|
|
925
|
+
property3({ type: Boolean, attribute: "match-width" })
|
|
926
|
+
], YatlDropdown.prototype, "matchWidth", 2);
|
|
927
|
+
YatlDropdown = __decorateClass([
|
|
928
|
+
customElement3("yatl-dropdown")
|
|
929
|
+
], YatlDropdown);
|
|
930
|
+
|
|
931
|
+
// src/components/button-group/button-group.styles.ts
|
|
932
|
+
import { css as css5 } from "lit";
|
|
933
|
+
var button_group_styles_default = css5`
|
|
934
|
+
:host {
|
|
935
|
+
display: inline-flex;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
[part='base'] {
|
|
939
|
+
display: flex;
|
|
940
|
+
flex-direction: row;
|
|
941
|
+
align-items: stretch;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
::slotted(*) {
|
|
945
|
+
--button-group-radius: var(
|
|
946
|
+
--yatl-button-group-radius,
|
|
947
|
+
var(--yatl-radius-m)
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
`;
|
|
951
|
+
|
|
952
|
+
// src/components/button-group/button-group.ts
|
|
953
|
+
var YatlButtonGroup = class extends YatlBase {
|
|
954
|
+
render() {
|
|
955
|
+
return html4`
|
|
956
|
+
<div part="base">
|
|
957
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
958
|
+
</div>
|
|
959
|
+
`;
|
|
960
|
+
}
|
|
961
|
+
handleSlotChange(event) {
|
|
962
|
+
const slot = event.target;
|
|
963
|
+
const elements = getEffectiveChildren(slot);
|
|
964
|
+
const count = elements.length;
|
|
965
|
+
elements.forEach((element, index) => {
|
|
966
|
+
if (element instanceof YatlDropdown) {
|
|
967
|
+
const trigger = element.querySelector('[slot="trigger"]');
|
|
968
|
+
if (trigger) {
|
|
969
|
+
const children = getEffectiveChildren(trigger);
|
|
970
|
+
element = children.find((c) => c instanceof YatlButton) ?? element;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
let position = "middle";
|
|
974
|
+
if (count === 1) position = "single";
|
|
975
|
+
else if (index === 0) position = "first";
|
|
976
|
+
else if (index === count - 1) position = "last";
|
|
977
|
+
element.setAttribute("data-group-position", position);
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
YatlButtonGroup.styles = [...__superGet(YatlButtonGroup, YatlButtonGroup, "styles"), button_group_styles_default];
|
|
982
|
+
YatlButtonGroup = __decorateClass([
|
|
983
|
+
customElement4("yatl-button-group")
|
|
984
|
+
], YatlButtonGroup);
|
|
985
|
+
|
|
986
|
+
// src/components/card/card.ts
|
|
987
|
+
import { html as html5 } from "lit";
|
|
988
|
+
import { customElement as customElement5 } from "lit/decorators.js";
|
|
989
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
990
|
+
|
|
991
|
+
// src/components/card/card.styles.ts
|
|
992
|
+
import { css as css6 } from "lit";
|
|
993
|
+
var card_styles_default = css6`
|
|
994
|
+
:host {
|
|
995
|
+
--card-bg: var(--yatl-card-bg, var(--yatl-surface-1));
|
|
996
|
+
--card-text: var(--yatl-card-text, var(--yatl-text-1));
|
|
997
|
+
|
|
998
|
+
--card-border-width: var(--yatl-card-border-width, 1px);
|
|
999
|
+
--card-border-style: var(--yatl-card-border-style, solid);
|
|
1000
|
+
--card-border-color: var(
|
|
1001
|
+
--yatl-card-border-color,
|
|
1002
|
+
var(--yatl-border-color)
|
|
1003
|
+
);
|
|
1004
|
+
--card-border-radius: var(--yatl-card-border-radius, var(--yatl-radius-l));
|
|
1005
|
+
|
|
1006
|
+
--card-header-font-size: var(--yatl-card-header-font-size, x-large);
|
|
1007
|
+
--card-header-font-wieght: var(--yatl-card-header-font-weight, 700);
|
|
1008
|
+
--card-header-padding: var(
|
|
1009
|
+
--yatl-card-header-padding,
|
|
1010
|
+
var(--yatl-spacing-m)
|
|
1011
|
+
);
|
|
1012
|
+
--card-header-border-width: var(
|
|
1013
|
+
--yatl-card-header-border-width,
|
|
1014
|
+
var(--card-border-width)
|
|
1015
|
+
);
|
|
1016
|
+
|
|
1017
|
+
--card-footer-font-size: var(--yatl-card-footer-font-size, medium);
|
|
1018
|
+
--card-footer-font-weight: var(--yatl-card-footer-font-weight, normal);
|
|
1019
|
+
--card-footer-padding: var(
|
|
1020
|
+
--yatl-card-footer-padding,
|
|
1021
|
+
var(--yatl-spacing-m)
|
|
1022
|
+
);
|
|
1023
|
+
--card-footer-border-width: var(
|
|
1024
|
+
--yatl-card-footer-border-width,
|
|
1025
|
+
var(--card-border-width)
|
|
1026
|
+
);
|
|
1027
|
+
|
|
1028
|
+
display: flex;
|
|
1029
|
+
flex-direction: column;
|
|
1030
|
+
color: var(--card-text);
|
|
1031
|
+
background-color: var(--card-bg);
|
|
1032
|
+
border-width: var(--card-border-width);
|
|
1033
|
+
border-style: var(--card-border-style);
|
|
1034
|
+
border-color: var(--card-border-color);
|
|
1035
|
+
border-radius: var(--card-border-radius);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
[part='header'],
|
|
1039
|
+
[part='footer'] {
|
|
1040
|
+
display: flex;
|
|
1041
|
+
flex-direction: row;
|
|
1042
|
+
justify-content: space-between;
|
|
1043
|
+
align-items: center;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
[part='header'] {
|
|
1047
|
+
font-size: var(--card-header-font-size);
|
|
1048
|
+
font-weight: var(--card-header-font-wieght);
|
|
1049
|
+
padding: var(--card-header-padding);
|
|
1050
|
+
border-block-end: var(--card-header-border-width) var(--card-border-style)
|
|
1051
|
+
var(--card-border-color);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
[part='footer'] {
|
|
1055
|
+
font-size: var(--card-footer-font-size);
|
|
1056
|
+
font-weight: var(--card-footer-font-weight);
|
|
1057
|
+
padding: var(--card-footer-padding);
|
|
1058
|
+
border-block-start: var(--card-footer-border-width) var(--card-border-style)
|
|
1059
|
+
var(--card-border-color);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
[part='header']:not(.has-header),
|
|
1063
|
+
[part='footer']:not(.has-footer) {
|
|
1064
|
+
display: none;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
.divider {
|
|
1068
|
+
flex-grow: 1;
|
|
1069
|
+
}
|
|
1070
|
+
`;
|
|
1071
|
+
|
|
1072
|
+
// src/components/card/card.ts
|
|
1073
|
+
var YatlCard = class extends YatlBase {
|
|
1074
|
+
constructor() {
|
|
1075
|
+
super(...arguments);
|
|
1076
|
+
this.slotController = new HasSlotController(
|
|
1077
|
+
this,
|
|
1078
|
+
"header-start",
|
|
1079
|
+
"header-end",
|
|
1080
|
+
"footer-start",
|
|
1081
|
+
"footer-end"
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
render() {
|
|
1085
|
+
const hasHeader = this.slotController.test("header-start") || this.slotController.test("header-end");
|
|
1086
|
+
const hasFooter = this.slotController.test("footer-start") || this.slotController.test("footer-end");
|
|
1087
|
+
return html5`
|
|
1088
|
+
<header part="header" class=${classMap({ "has-header": hasHeader })}>
|
|
1089
|
+
<slot name="header-start"></slot>
|
|
1090
|
+
<slot name="header">
|
|
1091
|
+
<div class="divider"></div>
|
|
1092
|
+
</slot>
|
|
1093
|
+
<slot name="header-end"></slot>
|
|
1094
|
+
</header>
|
|
1095
|
+
|
|
1096
|
+
<slot part="body"></slot>
|
|
1097
|
+
|
|
1098
|
+
<footer part="footer" class=${classMap({ "has-footer": hasFooter })}>
|
|
1099
|
+
<slot name="footer-start"></slot>
|
|
1100
|
+
<slot name="footer">
|
|
1101
|
+
<div class="divider"></div>
|
|
1102
|
+
</slot>
|
|
1103
|
+
<slot name="footer-end"></slot>
|
|
1104
|
+
</footer>
|
|
1105
|
+
`;
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
YatlCard.styles = [...__superGet(YatlCard, YatlCard, "styles"), card_styles_default];
|
|
1109
|
+
YatlCard = __decorateClass([
|
|
1110
|
+
customElement5("yatl-card")
|
|
1111
|
+
], YatlCard);
|
|
1112
|
+
|
|
1113
|
+
// src/components/confirmation-dialog/confirmation-dialog.ts
|
|
1114
|
+
import { html as html6 } from "lit";
|
|
1115
|
+
import { customElement as customElement6, property as property4, query as query2 } from "lit/decorators.js";
|
|
1116
|
+
|
|
1117
|
+
// src/components/confirmation-dialog/confirmation-dialog.styles.ts
|
|
1118
|
+
import { css as css7 } from "lit";
|
|
1119
|
+
var confirmation_dialog_styles_default = css7``;
|
|
1120
|
+
|
|
1121
|
+
// src/events/confirmation-dialog.ts
|
|
1122
|
+
import { YatlEvent as YatlEvent5 } from "@timlassiter11/yatl";
|
|
1123
|
+
var YatlConfirmationDialogAcceptEvent = class _YatlConfirmationDialogAcceptEvent extends YatlEvent5 {
|
|
1124
|
+
static {
|
|
1125
|
+
this.EVENT_NAME = "yatl-confirmation-dialog-accept";
|
|
1126
|
+
}
|
|
1127
|
+
constructor() {
|
|
1128
|
+
super(_YatlConfirmationDialogAcceptEvent.EVENT_NAME);
|
|
1129
|
+
}
|
|
1130
|
+
clone() {
|
|
1131
|
+
return new _YatlConfirmationDialogAcceptEvent();
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
var YatlConfirmationDialogRejectEvent = class _YatlConfirmationDialogRejectEvent extends YatlEvent5 {
|
|
1135
|
+
static {
|
|
1136
|
+
this.EVENT_NAME = "yatl-confirmation-dialog-reject";
|
|
1137
|
+
}
|
|
1138
|
+
constructor() {
|
|
1139
|
+
super(_YatlConfirmationDialogRejectEvent.EVENT_NAME);
|
|
1140
|
+
}
|
|
1141
|
+
clone() {
|
|
1142
|
+
return new _YatlConfirmationDialogRejectEvent();
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
// src/components/confirmation-dialog/confirmation-dialog.ts
|
|
1147
|
+
var YatlConfirmationDialog = class extends YatlBase {
|
|
1148
|
+
constructor() {
|
|
1149
|
+
super(...arguments);
|
|
1150
|
+
this.open = false;
|
|
1151
|
+
this.modal = false;
|
|
1152
|
+
this.label = "";
|
|
1153
|
+
this.acceptText = "Yes";
|
|
1154
|
+
this.rejectText = "No";
|
|
1155
|
+
}
|
|
1156
|
+
async show() {
|
|
1157
|
+
if (!this.hasUpdated) {
|
|
1158
|
+
await this.updateComplete;
|
|
1159
|
+
}
|
|
1160
|
+
this.open = true;
|
|
1161
|
+
await this.dialogElement.show();
|
|
1162
|
+
}
|
|
1163
|
+
async hide() {
|
|
1164
|
+
if (!this.hasUpdated) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
this.open = false;
|
|
1168
|
+
await this.dialogElement.hide();
|
|
1169
|
+
}
|
|
1170
|
+
async confirm() {
|
|
1171
|
+
await this.show();
|
|
1172
|
+
const ret = await new Promise((resolve, _reject) => {
|
|
1173
|
+
this.addEventListener(
|
|
1174
|
+
"yatl-confirmation-dialog-accept",
|
|
1175
|
+
() => resolve(true),
|
|
1176
|
+
{ once: true }
|
|
1177
|
+
);
|
|
1178
|
+
this.addEventListener(
|
|
1179
|
+
"yatl-confirmation-dialog-reject",
|
|
1180
|
+
() => resolve(false),
|
|
1181
|
+
{ once: true }
|
|
1182
|
+
);
|
|
1183
|
+
});
|
|
1184
|
+
return ret;
|
|
1185
|
+
}
|
|
1186
|
+
async accept() {
|
|
1187
|
+
const event = new YatlConfirmationDialogAcceptEvent();
|
|
1188
|
+
this.dispatchEvent(event);
|
|
1189
|
+
await this.hide();
|
|
1190
|
+
}
|
|
1191
|
+
async reject() {
|
|
1192
|
+
const event = new YatlConfirmationDialogRejectEvent();
|
|
1193
|
+
this.dispatchEvent(event);
|
|
1194
|
+
await this.hide();
|
|
1195
|
+
}
|
|
1196
|
+
render() {
|
|
1197
|
+
return html6`
|
|
1198
|
+
<yatl-dialog
|
|
1199
|
+
label=${this.label}
|
|
1200
|
+
?open=${this.open}
|
|
1201
|
+
?modal=${this.modal}
|
|
1202
|
+
@yatl-dialog-show-request=${this.handleDialogShow}
|
|
1203
|
+
@yatl-dialog-hide-request=${this.handleDialogHide}
|
|
1204
|
+
>
|
|
1205
|
+
<slot></slot>
|
|
1206
|
+
<slot name="actions" slot="footer-actions">
|
|
1207
|
+
<yatl-button @click=${this.reject}> ${this.rejectText} </yatl-button>
|
|
1208
|
+
<yatl-button @click=${this.accept}> ${this.acceptText} </yatl-button>
|
|
1209
|
+
</slot>
|
|
1210
|
+
</yatl-dialog>
|
|
1211
|
+
`;
|
|
1212
|
+
}
|
|
1213
|
+
handleDialogShow() {
|
|
1214
|
+
this.open = true;
|
|
1215
|
+
}
|
|
1216
|
+
handleDialogHide() {
|
|
1217
|
+
if (this.open) {
|
|
1218
|
+
this.open = false;
|
|
1219
|
+
this.reject();
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
YatlConfirmationDialog.styles = [...__superGet(YatlConfirmationDialog, YatlConfirmationDialog, "styles"), confirmation_dialog_styles_default];
|
|
1224
|
+
__decorateClass([
|
|
1225
|
+
query2("yatl-dialog")
|
|
1226
|
+
], YatlConfirmationDialog.prototype, "dialogElement", 2);
|
|
1227
|
+
__decorateClass([
|
|
1228
|
+
property4({ type: Boolean })
|
|
1229
|
+
], YatlConfirmationDialog.prototype, "open", 2);
|
|
1230
|
+
__decorateClass([
|
|
1231
|
+
property4({ type: Boolean })
|
|
1232
|
+
], YatlConfirmationDialog.prototype, "modal", 2);
|
|
1233
|
+
__decorateClass([
|
|
1234
|
+
property4({ type: String })
|
|
1235
|
+
], YatlConfirmationDialog.prototype, "label", 2);
|
|
1236
|
+
__decorateClass([
|
|
1237
|
+
property4({ type: String, attribute: "accept-text" })
|
|
1238
|
+
], YatlConfirmationDialog.prototype, "acceptText", 2);
|
|
1239
|
+
__decorateClass([
|
|
1240
|
+
property4({ type: String, attribute: "reject-text" })
|
|
1241
|
+
], YatlConfirmationDialog.prototype, "rejectText", 2);
|
|
1242
|
+
YatlConfirmationDialog = __decorateClass([
|
|
1243
|
+
customElement6("yatl-confirmation-dialog")
|
|
1244
|
+
], YatlConfirmationDialog);
|
|
1245
|
+
|
|
1246
|
+
// src/components/dialog/dialog.ts
|
|
1247
|
+
import { html as html7 } from "lit";
|
|
1248
|
+
import { customElement as customElement7, property as property5, query as query3 } from "lit/decorators.js";
|
|
1249
|
+
|
|
1250
|
+
// src/components/dialog/dialog.styles.ts
|
|
1251
|
+
import { css as css8 } from "lit";
|
|
1252
|
+
var dialog_styles_default = css8`
|
|
1253
|
+
:host {
|
|
1254
|
+
--dialog-bg: var(--yatl-dialog-bg, var(--yatl-surface-3));
|
|
1255
|
+
--dialog-text: var(--yatl-dialog-text, var(--yatl-text-1));
|
|
1256
|
+
--dialog-radius: var(--yatl-dialog-radius, var(--yatl-radius-l));
|
|
1257
|
+
--dialog-border-width: var(--yatl-dialog-border-width, 1px);
|
|
1258
|
+
--dialog-border-style: var(--yatl-dialog-border-style, solid);
|
|
1259
|
+
--dialog-border-color: var(
|
|
1260
|
+
--yatl-dialog-border-color,
|
|
1261
|
+
var(--yatl-border-color)
|
|
1262
|
+
);
|
|
1263
|
+
--dialog-width: var(--yatl-dialog-width, 500px);
|
|
1264
|
+
--dialog-padding: var(--yatl-dialog-padding, var(--yatl-spacing-s));
|
|
1265
|
+
--dialog-header-font-size: var(--yatl-dialog-header-font-size, medium);
|
|
1266
|
+
--dialog-header-font-weight: var(--yatl-dialog-header-font-weight, 700);
|
|
1267
|
+
--dialog-header-padding: var(
|
|
1268
|
+
--yatl-dialog-header-padding,
|
|
1269
|
+
var(--yatl-spacing-m)
|
|
1270
|
+
);
|
|
1271
|
+
--dialog-body-padding: var(
|
|
1272
|
+
--yatl-dialog-body-padding,
|
|
1273
|
+
var(--yatl-spacing-l)
|
|
1274
|
+
);
|
|
1275
|
+
|
|
1276
|
+
--dialog-show-duration: var(--yatl-dialog-show-duration, 250ms);
|
|
1277
|
+
--dialog-hide-duration: var(--yatl-dialog-hide-duration, 250ms);
|
|
1278
|
+
--dialog-pulse-duration: var(--yatl-dialog-pulse-duration, 250ms);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
dialog {
|
|
1282
|
+
border: none;
|
|
1283
|
+
background: none;
|
|
1284
|
+
|
|
1285
|
+
&.show {
|
|
1286
|
+
animation: show-dialog var(--dialog-show-duration) ease;
|
|
1287
|
+
|
|
1288
|
+
&::backdrop {
|
|
1289
|
+
animation: show-backdrop var(--dialog-show-duration, 200ms) ease;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
&.hide {
|
|
1294
|
+
animation: show-dialog var(--dialog-hide-duration) ease reverse;
|
|
1295
|
+
|
|
1296
|
+
&::backdrop {
|
|
1297
|
+
animation: show-backdrop var(--dialog-hide-duration, 200ms) ease reverse;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
&.pulse {
|
|
1302
|
+
animation: pulse var(--dialog-pulse-duration) ease;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
dialog:focus-visible {
|
|
1307
|
+
outline: none;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
dialog::backdrop {
|
|
1311
|
+
background-color: color-mix(in oklab, black 60%, transparent);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
yatl-card {
|
|
1315
|
+
--card-bg: var(--dialog-bg);
|
|
1316
|
+
--card-text: var(--dialog-text);
|
|
1317
|
+
--card-border-radius: var(--dialog-radius);
|
|
1318
|
+
--card-border-width: var(--dialog-border-width);
|
|
1319
|
+
--card-border-style: var(--dialog-border-style);
|
|
1320
|
+
--card-border-color: var(--dialog-border-color);
|
|
1321
|
+
--card-header-font-size: var(--dialog-header-font-size);
|
|
1322
|
+
--card-header-font-weight: var(--dialog-header-font-weight);
|
|
1323
|
+
--card-header-padding: var(--dialog-header-padding);
|
|
1324
|
+
|
|
1325
|
+
padding: var(--dialog-padding);
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
[part='header'] {
|
|
1329
|
+
display: flex;
|
|
1330
|
+
flex-direction: row;
|
|
1331
|
+
justify-content: space-between;
|
|
1332
|
+
align-items: center;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
[part='label'] {
|
|
1336
|
+
margin: 0;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
[part='header-actions'],
|
|
1340
|
+
[part='footer-actions'] {
|
|
1341
|
+
display: flex;
|
|
1342
|
+
flex-direction: row;
|
|
1343
|
+
align-items: center;
|
|
1344
|
+
justify-content: flex-end;
|
|
1345
|
+
gap: var(--yatl-spacing-s);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
[part='body'] {
|
|
1349
|
+
padding: var(--dialog-body-padding);
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
@keyframes pulse {
|
|
1353
|
+
0% {
|
|
1354
|
+
scale: 1;
|
|
1355
|
+
}
|
|
1356
|
+
50% {
|
|
1357
|
+
scale: 1.02;
|
|
1358
|
+
}
|
|
1359
|
+
100% {
|
|
1360
|
+
scale: 1;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
@keyframes show-dialog {
|
|
1365
|
+
from {
|
|
1366
|
+
opacity: 0;
|
|
1367
|
+
scale: 0.8;
|
|
1368
|
+
}
|
|
1369
|
+
to {
|
|
1370
|
+
opacity: 1;
|
|
1371
|
+
scale: 1;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
@keyframes show-backdrop {
|
|
1376
|
+
from {
|
|
1377
|
+
opacity: 0;
|
|
1378
|
+
}
|
|
1379
|
+
to {
|
|
1380
|
+
opacity: 1;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
`;
|
|
1384
|
+
|
|
1385
|
+
// src/components/dialog/dialog.ts
|
|
1386
|
+
var YatlDialog = class extends YatlBase {
|
|
1387
|
+
constructor() {
|
|
1388
|
+
super(...arguments);
|
|
1389
|
+
this._open = false;
|
|
1390
|
+
this.label = "";
|
|
1391
|
+
this.modal = false;
|
|
1392
|
+
}
|
|
1393
|
+
get transitionComplete() {
|
|
1394
|
+
return this._transitionPromise;
|
|
1395
|
+
}
|
|
1396
|
+
set transitionComplete(promise) {
|
|
1397
|
+
promise?.then(() => this._transitionPromise = void 0);
|
|
1398
|
+
this._transitionPromise = promise;
|
|
1399
|
+
}
|
|
1400
|
+
get isTransitioning() {
|
|
1401
|
+
return !!this._transitionPromise;
|
|
1402
|
+
}
|
|
1403
|
+
get open() {
|
|
1404
|
+
return this._open;
|
|
1405
|
+
}
|
|
1406
|
+
set open(value) {
|
|
1407
|
+
if (this._open === value) {
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
const oldValue = this._open;
|
|
1411
|
+
this._open = value;
|
|
1412
|
+
if (this.hasUpdated) {
|
|
1413
|
+
if (this.open && !this.dialogElement.open) {
|
|
1414
|
+
this.show();
|
|
1415
|
+
} else if (!this.open && this.dialogElement.open) {
|
|
1416
|
+
this.hide();
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
this.requestUpdate("open", oldValue);
|
|
1420
|
+
}
|
|
1421
|
+
async show() {
|
|
1422
|
+
if (this.isTransitioning) {
|
|
1423
|
+
return this.transitionComplete;
|
|
1424
|
+
}
|
|
1425
|
+
const requestEvent = new YatlDialogShowRequest();
|
|
1426
|
+
this.dispatchEvent(requestEvent);
|
|
1427
|
+
if (requestEvent.defaultPrevented) {
|
|
1428
|
+
this.open = false;
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (!this.hasUpdated) {
|
|
1432
|
+
await this.updateComplete;
|
|
1433
|
+
}
|
|
1434
|
+
this.dialogElement.showModal();
|
|
1435
|
+
this.open = true;
|
|
1436
|
+
this.transitionComplete = animateWithClass(this.dialogElement, "show");
|
|
1437
|
+
await this.transitionComplete;
|
|
1438
|
+
const event = new YatlDialogShowEvent();
|
|
1439
|
+
this.dispatchEvent(event);
|
|
1440
|
+
}
|
|
1441
|
+
async hide() {
|
|
1442
|
+
await this.requestClose(this.dialogElement);
|
|
1443
|
+
}
|
|
1444
|
+
firstUpdated(_changedProperties) {
|
|
1445
|
+
if (this.open) {
|
|
1446
|
+
this.dialogElement?.showModal();
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
render() {
|
|
1450
|
+
return html7`
|
|
1451
|
+
<dialog
|
|
1452
|
+
popover
|
|
1453
|
+
@cancel=${this.handleDialogCancel}
|
|
1454
|
+
@pointerdown=${this.handleDialogPointerdown}
|
|
1455
|
+
>
|
|
1456
|
+
<yatl-card part="base">
|
|
1457
|
+
<slot part="header" name="header" slot="header-start">
|
|
1458
|
+
<h2 part="label">
|
|
1459
|
+
${this.label || " "}
|
|
1460
|
+
</h2>
|
|
1461
|
+
</slot>
|
|
1462
|
+
<slot
|
|
1463
|
+
part="header-actions"
|
|
1464
|
+
name="header-actions"
|
|
1465
|
+
slot="header-end"
|
|
1466
|
+
></slot>
|
|
1467
|
+
<yatl-button
|
|
1468
|
+
slot="header-end"
|
|
1469
|
+
variant="plain"
|
|
1470
|
+
@click=${this.handleCloseClick}
|
|
1471
|
+
><yatl-icon name="close"></yatl-icon
|
|
1472
|
+
></yatl-button>
|
|
1473
|
+
<div part="body">
|
|
1474
|
+
<slot></slot>
|
|
1475
|
+
</div>
|
|
1476
|
+
<slot part="footer" name="footer" slot="footer-start"></slot>
|
|
1477
|
+
<slot
|
|
1478
|
+
part="footer-actions"
|
|
1479
|
+
name="footer-actions"
|
|
1480
|
+
slot="footer-end"
|
|
1481
|
+
></slot>
|
|
1482
|
+
</yatl-card>
|
|
1483
|
+
</dialog>
|
|
1484
|
+
`;
|
|
1485
|
+
}
|
|
1486
|
+
async requestClose(source) {
|
|
1487
|
+
if (!this.hasUpdated) {
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
if (this.isTransitioning) {
|
|
1491
|
+
return this.transitionComplete;
|
|
1492
|
+
}
|
|
1493
|
+
const requestEvent = new YatlDialogHideRequest(source);
|
|
1494
|
+
this.dispatchEvent(requestEvent);
|
|
1495
|
+
if (requestEvent.defaultPrevented) {
|
|
1496
|
+
this.open = true;
|
|
1497
|
+
animateWithClass(this.dialogElement, "pulse");
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
this.transitionComplete = animateWithClass(this.dialogElement, "hide");
|
|
1501
|
+
this.open = false;
|
|
1502
|
+
await this.transitionComplete;
|
|
1503
|
+
this.dialogElement.close();
|
|
1504
|
+
const event = new YatlDialogHideEvent();
|
|
1505
|
+
this.dispatchEvent(event);
|
|
1506
|
+
}
|
|
1507
|
+
handleCloseClick(event) {
|
|
1508
|
+
const target = event.target;
|
|
1509
|
+
this.requestClose(target);
|
|
1510
|
+
}
|
|
1511
|
+
handleDialogPointerdown(event) {
|
|
1512
|
+
if (event.target === this.dialogElement) {
|
|
1513
|
+
if (!this.modal) {
|
|
1514
|
+
this.requestClose(this.dialogElement);
|
|
1515
|
+
} else {
|
|
1516
|
+
animateWithClass(this.dialogElement, "pulse");
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
handleDialogCancel(event) {
|
|
1521
|
+
event.preventDefault();
|
|
1522
|
+
if (!this.isTransitioning && event.target === this.dialogElement) {
|
|
1523
|
+
this.requestClose(this.dialogElement);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
YatlDialog.styles = [...__superGet(YatlDialog, YatlDialog, "styles"), dialog_styles_default];
|
|
1528
|
+
__decorateClass([
|
|
1529
|
+
query3("dialog")
|
|
1530
|
+
], YatlDialog.prototype, "dialogElement", 2);
|
|
1531
|
+
__decorateClass([
|
|
1532
|
+
property5({ type: String })
|
|
1533
|
+
], YatlDialog.prototype, "label", 2);
|
|
1534
|
+
__decorateClass([
|
|
1535
|
+
property5({ type: Boolean })
|
|
1536
|
+
], YatlDialog.prototype, "modal", 2);
|
|
1537
|
+
__decorateClass([
|
|
1538
|
+
property5({ type: Boolean })
|
|
1539
|
+
], YatlDialog.prototype, "open", 1);
|
|
1540
|
+
YatlDialog = __decorateClass([
|
|
1541
|
+
customElement7("yatl-dialog")
|
|
1542
|
+
], YatlDialog);
|
|
1543
|
+
|
|
1544
|
+
// src/components/icon/icon.ts
|
|
1545
|
+
import { html as html8, nothing as nothing2 } from "lit";
|
|
1546
|
+
import { customElement as customElement8, property as property6 } from "lit/decorators.js";
|
|
1547
|
+
|
|
1548
|
+
// src/icons.ts
|
|
1549
|
+
import { svg } from "lit";
|
|
1550
|
+
var sunIcon = svg`
|
|
1551
|
+
<circle cx="12" cy="12" r="5" />
|
|
1552
|
+
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" />
|
|
1553
|
+
`;
|
|
1554
|
+
var moonIcon = svg`
|
|
1555
|
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
|
1556
|
+
`;
|
|
1557
|
+
var trashIcon = svg`
|
|
1558
|
+
<path d="M3 6h18" />
|
|
1559
|
+
<path d="M19 6v14c0 1.1-.9 2-2 2H7c-1.1 0-2-.9-2-2V6" />
|
|
1560
|
+
<path d="M8 6V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2v2" />
|
|
1561
|
+
<line x1="10" y1="11" x2="10" y2="17" />
|
|
1562
|
+
<line x1="14" y1="11" x2="14" y2="17" />
|
|
1563
|
+
`;
|
|
1564
|
+
var closeIcon = svg`
|
|
1565
|
+
<path d="M18 6L6 18M6 6l12 12" stroke-linecap="round" stroke-linejoin="round" />
|
|
1566
|
+
`;
|
|
1567
|
+
var chevronDownIcon = svg`
|
|
1568
|
+
<path d="M6 9l6 6 6-6" />
|
|
1569
|
+
`;
|
|
1570
|
+
var checkIcon = svg`
|
|
1571
|
+
<path fill="currentColor" d="M18.7,7.2c-0.4-0.4-1-0.4-1.4,0l-7.5,7.5l-3.1-3.1c0,0,0,0,0,0c-0.4-0.4-1-0.4-1.4,0c-0.4,0.4-0.4,1,0,1.4l3.8,3.8c0.2,0.2,0.4,0.3,0.7,0.3c0.3,0,0.5-0.1,0.7-0.3l8.2-8.2C19.1,8.2,19.1,7.6,18.7,7.2z"/>
|
|
1572
|
+
`;
|
|
1573
|
+
var columnsIcon = svg`
|
|
1574
|
+
<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18"/>
|
|
1575
|
+
`;
|
|
1576
|
+
var downloadIcon = svg`
|
|
1577
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
1578
|
+
<polyline points="7 10 12 15 17 10" />
|
|
1579
|
+
<line x1="12" y1="15" x2="12" y2="3" />
|
|
1580
|
+
`;
|
|
1581
|
+
var icons = {
|
|
1582
|
+
sun: sunIcon,
|
|
1583
|
+
moon: moonIcon,
|
|
1584
|
+
trash: trashIcon,
|
|
1585
|
+
close: closeIcon,
|
|
1586
|
+
"chevron-down": chevronDownIcon,
|
|
1587
|
+
check: checkIcon,
|
|
1588
|
+
columns: columnsIcon,
|
|
1589
|
+
download: downloadIcon
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
// src/components/icon/icon.styles.ts
|
|
1593
|
+
import { css as css9 } from "lit";
|
|
1594
|
+
var icon_styles_default = css9`
|
|
1595
|
+
:host {
|
|
1596
|
+
display: inline-flex;
|
|
1597
|
+
align-items: center;
|
|
1598
|
+
justify-content: center;
|
|
1599
|
+
width: 1em;
|
|
1600
|
+
height: 1em;
|
|
1601
|
+
color: inherit;
|
|
1602
|
+
flex-shrink: 0;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
svg {
|
|
1606
|
+
width: 100%;
|
|
1607
|
+
height: 100%;
|
|
1608
|
+
|
|
1609
|
+
fill: none;
|
|
1610
|
+
stroke: currentColor;
|
|
1611
|
+
stroke-width: var(--icon-stroke-width, 2px);
|
|
1612
|
+
stroke-linecap: round;
|
|
1613
|
+
stroke-linejoin: round;
|
|
1614
|
+
}
|
|
1615
|
+
`;
|
|
1616
|
+
|
|
1617
|
+
// src/components/icon/icon.ts
|
|
1618
|
+
var YatlIcon = class extends YatlBase {
|
|
1619
|
+
constructor() {
|
|
1620
|
+
super(...arguments);
|
|
1621
|
+
this.name = "";
|
|
1622
|
+
this.viewBox = "0 0 24 24";
|
|
1623
|
+
this.label = "";
|
|
1624
|
+
}
|
|
1625
|
+
render() {
|
|
1626
|
+
const svg3 = icons[this.name];
|
|
1627
|
+
return html8`
|
|
1628
|
+
<svg
|
|
1629
|
+
part="svg"
|
|
1630
|
+
viewBox=${this.viewBox}
|
|
1631
|
+
aria-hidden=${this.label ? "false" : "true"}
|
|
1632
|
+
aria-label=${this.label || void 0}
|
|
1633
|
+
role=${this.label ? "img" : "presentation"}
|
|
1634
|
+
>
|
|
1635
|
+
${svg3 ?? nothing2}
|
|
1636
|
+
</svg>
|
|
1637
|
+
`;
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
YatlIcon.styles = [...__superGet(YatlIcon, YatlIcon, "styles"), icon_styles_default];
|
|
1641
|
+
__decorateClass([
|
|
1642
|
+
property6({ type: String })
|
|
1643
|
+
], YatlIcon.prototype, "name", 2);
|
|
1644
|
+
__decorateClass([
|
|
1645
|
+
property6({ type: String })
|
|
1646
|
+
], YatlIcon.prototype, "viewBox", 2);
|
|
1647
|
+
__decorateClass([
|
|
1648
|
+
property6({ type: String })
|
|
1649
|
+
], YatlIcon.prototype, "label", 2);
|
|
1650
|
+
YatlIcon = __decorateClass([
|
|
1651
|
+
customElement8("yatl-icon")
|
|
1652
|
+
], YatlIcon);
|
|
1653
|
+
|
|
1654
|
+
// src/components/table-ui/table-ui.ts
|
|
1655
|
+
import { html as html9 } from "lit";
|
|
1656
|
+
import { customElement as customElement9, property as property7 } from "lit/decorators.js";
|
|
1657
|
+
import { YatlTable } from "@timlassiter11/yatl";
|
|
1658
|
+
|
|
1659
|
+
// src/components/table-ui/table-ui.styles.ts
|
|
1660
|
+
import { css as css10 } from "lit";
|
|
1661
|
+
var table_ui_styles_default = css10`
|
|
1662
|
+
[part='shell'] {
|
|
1663
|
+
display: flex;
|
|
1664
|
+
flex-direction: column;
|
|
1665
|
+
gap: var(--yatl-spacing-m);
|
|
1666
|
+
height: 100%;
|
|
1667
|
+
width: 100%;
|
|
1668
|
+
}
|
|
1669
|
+
`;
|
|
1670
|
+
|
|
1671
|
+
// src/components/table-ui/table-ui.ts
|
|
1672
|
+
var YatlTableUi = class extends YatlTable {
|
|
1673
|
+
constructor() {
|
|
1674
|
+
super(...arguments);
|
|
1675
|
+
this.showColumnPicker = true;
|
|
1676
|
+
this.showExportButton = true;
|
|
1677
|
+
this.handleTableExportClicked = () => {
|
|
1678
|
+
this.export(document.title);
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
render() {
|
|
1682
|
+
return html9`
|
|
1683
|
+
<div part="shell">
|
|
1684
|
+
<yatl-toolbar
|
|
1685
|
+
?showColumnPicker=${this.showColumnPicker}
|
|
1686
|
+
?showExportButton=${this.showExportButton}
|
|
1687
|
+
.controller=${this.controller}
|
|
1688
|
+
@yatl-toolbar-export-click=${this.handleTableExportClicked}
|
|
1689
|
+
><slot name="toolbar-button-group" slot="button-group"></slot
|
|
1690
|
+
><slot name="toolbar"></slot
|
|
1691
|
+
></yatl-toolbar>
|
|
1692
|
+
${super.render()}
|
|
1693
|
+
</div>
|
|
1694
|
+
`;
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
YatlTableUi.styles = [...__superGet(YatlTableUi, YatlTableUi, "styles"), table_ui_styles_default];
|
|
1698
|
+
__decorateClass([
|
|
1699
|
+
property7({ type: Boolean })
|
|
1700
|
+
], YatlTableUi.prototype, "showColumnPicker", 2);
|
|
1701
|
+
__decorateClass([
|
|
1702
|
+
property7({ type: Boolean })
|
|
1703
|
+
], YatlTableUi.prototype, "showExportButton", 2);
|
|
1704
|
+
YatlTableUi = __decorateClass([
|
|
1705
|
+
customElement9("yatl-table-ui")
|
|
1706
|
+
], YatlTableUi);
|
|
1707
|
+
|
|
1708
|
+
// src/components/table-view/table-view.ts
|
|
1709
|
+
import { html as html10 } from "lit";
|
|
1710
|
+
import { customElement as customElement10 } from "lit/decorators.js";
|
|
1711
|
+
import { ContextProvider } from "@lit/context";
|
|
1712
|
+
|
|
1713
|
+
// src/context.ts
|
|
1714
|
+
import { createContext } from "@lit/context";
|
|
1715
|
+
var tableContext = createContext(
|
|
1716
|
+
/* @__PURE__ */ Symbol("table-controller")
|
|
1717
|
+
);
|
|
1718
|
+
|
|
1719
|
+
// src/components/table-view/table-view.styles.ts
|
|
1720
|
+
import { css as css11 } from "lit";
|
|
1721
|
+
var table_view_styles_default = css11`
|
|
1722
|
+
main {
|
|
1723
|
+
width: 100%;
|
|
1724
|
+
height: 100%;
|
|
1725
|
+
overflow: hidden;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
[part='view'] {
|
|
1729
|
+
display: flex;
|
|
1730
|
+
flex-direction: row;
|
|
1731
|
+
height: 100%;
|
|
1732
|
+
width: 100%;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
[part='sidebar'] {
|
|
1736
|
+
display: flex;
|
|
1737
|
+
flex-direction: column;
|
|
1738
|
+
overflow-y: auto;
|
|
1739
|
+
padding-right: var(--yatl-spacing-m);
|
|
1740
|
+
margin-right: var(--yatl-spacing-m);
|
|
1741
|
+
min-width: 300px;
|
|
1742
|
+
gap: var(--yatl-spacing-l);
|
|
1743
|
+
}
|
|
1744
|
+
`;
|
|
1745
|
+
|
|
1746
|
+
// src/components/table-view/table-view.ts
|
|
1747
|
+
var YatlTableView = class extends YatlTableUi {
|
|
1748
|
+
constructor() {
|
|
1749
|
+
super(...arguments);
|
|
1750
|
+
this.tableContext = new ContextProvider(this, {
|
|
1751
|
+
context: tableContext,
|
|
1752
|
+
initialValue: this.controller
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
willUpdate(changedProperties) {
|
|
1756
|
+
if (changedProperties.has("controller")) {
|
|
1757
|
+
this.tableContext.setValue(this.controller);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
render() {
|
|
1761
|
+
return html10`
|
|
1762
|
+
<div part="view">
|
|
1763
|
+
<aside part="sidebar">
|
|
1764
|
+
<slot name="sidebar-start"></slot>
|
|
1765
|
+
<slot part="filters" name="filters"></slot>
|
|
1766
|
+
<slot name="sidebar-end"></slot>
|
|
1767
|
+
</aside>
|
|
1768
|
+
<main>${super.render()}</main>
|
|
1769
|
+
</div>
|
|
1770
|
+
`;
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
YatlTableView.styles = [...__superGet(YatlTableView, YatlTableView, "styles"), table_view_styles_default];
|
|
1774
|
+
YatlTableView = __decorateClass([
|
|
1775
|
+
customElement10("yatl-table-view")
|
|
1776
|
+
], YatlTableView);
|
|
1777
|
+
|
|
1778
|
+
// src/components/tag/tag.ts
|
|
1779
|
+
import { html as html11, nothing as nothing3 } from "lit";
|
|
1780
|
+
import { customElement as customElement11, property as property8 } from "lit/decorators.js";
|
|
1781
|
+
|
|
1782
|
+
// src/components/tag/tag.styles.ts
|
|
1783
|
+
import { css as css12 } from "lit";
|
|
1784
|
+
var tag_styles_default = css12`
|
|
1785
|
+
:host {
|
|
1786
|
+
--tag-radius: var(--yatl-tag-border-radius, var(--yatl-radius-s));
|
|
1787
|
+
--tag-border-color: var(--yatl-tag-border-color, var(--yatl-border-color));
|
|
1788
|
+
--tag-padding: var(--yatl-tag-padding, var(--yatl-spacing-s));
|
|
1789
|
+
--tag-color: var(--yatl-tag-color, var(--yatl-text-3));
|
|
1790
|
+
|
|
1791
|
+
border-radius: var(--tag-radius);
|
|
1792
|
+
border: 1px solid var(--tag-border-color);
|
|
1793
|
+
display: flex;
|
|
1794
|
+
align-items: center;
|
|
1795
|
+
padding: var(--tag-padding);
|
|
1796
|
+
font-size: 0.85rem;
|
|
1797
|
+
color: var(--tag-color);
|
|
1798
|
+
white-space: nowrap;
|
|
1799
|
+
text-overflow: ellipsis;
|
|
1800
|
+
user-select: none;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
[part='dismiss-button'] {
|
|
1804
|
+
appearance: none;
|
|
1805
|
+
background: none;
|
|
1806
|
+
border: none;
|
|
1807
|
+
margin: 0;
|
|
1808
|
+
padding: 0;
|
|
1809
|
+
flex-shrink: 0;
|
|
1810
|
+
margin-left: var(--yatl-spacing-xs);
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1813
|
+
yatl-button {
|
|
1814
|
+
border: none;
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
yatl-button[part='dismiss-button']::part(base) {
|
|
1818
|
+
padding: 0;
|
|
1819
|
+
margin: 0;
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
yatl-button[part='dismiss-button']::part(base):hover {
|
|
1823
|
+
color: var(--yatl-text-1);
|
|
1824
|
+
background: none;
|
|
1825
|
+
}
|
|
1826
|
+
`;
|
|
1827
|
+
|
|
1828
|
+
// src/components/tag/tag.ts
|
|
1829
|
+
var YatlTag = class extends YatlBase {
|
|
1830
|
+
constructor() {
|
|
1831
|
+
super(...arguments);
|
|
1832
|
+
this.dismissable = false;
|
|
1833
|
+
}
|
|
1834
|
+
render() {
|
|
1835
|
+
return html11`<slot></slot>${this.renderClearIcon()}`;
|
|
1836
|
+
}
|
|
1837
|
+
renderClearIcon() {
|
|
1838
|
+
if (!this.dismissable) {
|
|
1839
|
+
return nothing3;
|
|
1840
|
+
}
|
|
1841
|
+
return html11`
|
|
1842
|
+
<yatl-button
|
|
1843
|
+
variant="plain"
|
|
1844
|
+
color="muted"
|
|
1845
|
+
part="dismiss-button"
|
|
1846
|
+
@click=${this.dismissClick}
|
|
1847
|
+
>
|
|
1848
|
+
<yatl-icon name="close"></yatl-icon>
|
|
1849
|
+
</yatl-button>
|
|
1850
|
+
`;
|
|
1851
|
+
}
|
|
1852
|
+
dismissClick(event) {
|
|
1853
|
+
event.stopPropagation();
|
|
1854
|
+
event.preventDefault();
|
|
1855
|
+
this.dispatchEvent(new YatlTagDismissEvent());
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
YatlTag.styles = [...__superGet(YatlTag, YatlTag, "styles"), tag_styles_default];
|
|
1859
|
+
__decorateClass([
|
|
1860
|
+
property8({ type: Boolean, reflect: true })
|
|
1861
|
+
], YatlTag.prototype, "dismissable", 2);
|
|
1862
|
+
YatlTag = __decorateClass([
|
|
1863
|
+
customElement11("yatl-tag")
|
|
1864
|
+
], YatlTag);
|
|
1865
|
+
|
|
1866
|
+
// src/components/toolbar/toolbar.ts
|
|
1867
|
+
import { html as html12, nothing as nothing4 } from "lit";
|
|
1868
|
+
import { customElement as customElement12, property as property9 } from "lit/decorators.js";
|
|
1869
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
1870
|
+
|
|
1871
|
+
// src/components/toolbar/toolbar.styles.ts
|
|
1872
|
+
import { css as css13 } from "lit";
|
|
1873
|
+
var toolbar_styles_default = css13`
|
|
1874
|
+
:host {
|
|
1875
|
+
box-sizing: border-box;
|
|
1876
|
+
--toolbar-search-radius: var(
|
|
1877
|
+
--yatl-toolbar-search-radius,
|
|
1878
|
+
var(--yatl-radius-m)
|
|
1879
|
+
);
|
|
1880
|
+
--toolbar-search-padding: var(
|
|
1881
|
+
--yatl-toolbar-search-padding,
|
|
1882
|
+
var(--yatl-spacing-m)
|
|
1883
|
+
);
|
|
1884
|
+
--toolbar-search-bg: var(--yatl-toolbar-search-bg, var(--yatl-surface-2));
|
|
1885
|
+
--toolbar-search-outline-color: var(
|
|
1886
|
+
--yatl-toolbar-search-outline-color,
|
|
1887
|
+
var(--yatl-color-brand)
|
|
1888
|
+
);
|
|
1889
|
+
--toolbar-search-outline-width: var(
|
|
1890
|
+
--yatl-toolbar-search-outline-width,
|
|
1891
|
+
3px
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
[part='base'] {
|
|
1896
|
+
display: flex;
|
|
1897
|
+
flex-direction: row;
|
|
1898
|
+
gap: 10px;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
[part='search'] {
|
|
1902
|
+
flex-grow: 1;
|
|
1903
|
+
line-height: 1;
|
|
1904
|
+
font-size: large;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
yatl-button-group yatl-button {
|
|
1908
|
+
height: 100%;
|
|
1909
|
+
}
|
|
1910
|
+
`;
|
|
1911
|
+
|
|
1912
|
+
// src/components/toolbar/toolbar.ts
|
|
1913
|
+
var YatlToolbar = class extends YatlBase {
|
|
1914
|
+
constructor() {
|
|
1915
|
+
super(...arguments);
|
|
1916
|
+
this.showColumnPicker = true;
|
|
1917
|
+
this.showExportButton = true;
|
|
1918
|
+
this.handleDropdownSelect = (event) => {
|
|
1919
|
+
event.preventDefault();
|
|
1920
|
+
this.controller?.toggleColumnVisibility(
|
|
1921
|
+
event.item.value,
|
|
1922
|
+
event.item.checked
|
|
1923
|
+
);
|
|
1924
|
+
};
|
|
1925
|
+
this.onSearchInput = (event) => {
|
|
1926
|
+
const input = event.currentTarget;
|
|
1927
|
+
this.controller?.search(input.value);
|
|
1928
|
+
this.dispatchEvent(new YatlToolbarSearchInput(input.value));
|
|
1929
|
+
};
|
|
1930
|
+
this.onSearchChange = (event) => {
|
|
1931
|
+
const input = event.currentTarget;
|
|
1932
|
+
this.dispatchEvent(new YatlToolbarSearchChange(input.value));
|
|
1933
|
+
};
|
|
1934
|
+
this.onExportClick = (_event) => {
|
|
1935
|
+
this.dispatchEvent(new YatlToolbarExportClick());
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
get controller() {
|
|
1939
|
+
return this._controller;
|
|
1940
|
+
}
|
|
1941
|
+
set controller(controller) {
|
|
1942
|
+
if (this._controller === controller) {
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
this._controller = controller;
|
|
1946
|
+
controller?.attach(this);
|
|
1947
|
+
}
|
|
1948
|
+
render() {
|
|
1949
|
+
return html12`
|
|
1950
|
+
<div part="base">
|
|
1951
|
+
<yatl-input
|
|
1952
|
+
part="search"
|
|
1953
|
+
type="search"
|
|
1954
|
+
placeholder="Search"
|
|
1955
|
+
.value=${this.controller?.searchQuery ?? ""}
|
|
1956
|
+
@input=${this.onSearchInput}
|
|
1957
|
+
@change=${this.onSearchChange}
|
|
1958
|
+
></yatl-input>
|
|
1959
|
+
<yatl-button-group>
|
|
1960
|
+
${this.showColumnPicker ? this.renderColumnPicker() : nothing4}
|
|
1961
|
+
${this.showExportButton ? this.renderExportButton() : nothing4}
|
|
1962
|
+
<slot name="button-group"></slot>
|
|
1963
|
+
</yatl-button-group>
|
|
1964
|
+
<slot></slot>
|
|
1965
|
+
</div>
|
|
1966
|
+
`;
|
|
1967
|
+
}
|
|
1968
|
+
renderColumnPicker() {
|
|
1969
|
+
return html12`
|
|
1970
|
+
<yatl-dropdown
|
|
1971
|
+
part="column-picker"
|
|
1972
|
+
@yatl-dropdown-select=${this.handleDropdownSelect}
|
|
1973
|
+
>
|
|
1974
|
+
<yatl-button
|
|
1975
|
+
slot="trigger"
|
|
1976
|
+
part="column-picker-trigger"
|
|
1977
|
+
title="Show/hide columns"
|
|
1978
|
+
color="raised"
|
|
1979
|
+
>
|
|
1980
|
+
<slot name="column-picker-icon">
|
|
1981
|
+
<yatl-icon name="columns"></yatl-icon>
|
|
1982
|
+
</slot>
|
|
1983
|
+
</yatl-button>
|
|
1984
|
+
${repeat(
|
|
1985
|
+
this.controller?.displayColumns ?? [],
|
|
1986
|
+
(s) => s.field,
|
|
1987
|
+
(s) => this.renderColumnVisibilityToggle(s)
|
|
1988
|
+
)}
|
|
1989
|
+
</yatl-dropdown>
|
|
1990
|
+
`;
|
|
1991
|
+
}
|
|
1992
|
+
renderColumnVisibilityToggle(column) {
|
|
1993
|
+
const state6 = this.controller.getColumnState(column.field);
|
|
1994
|
+
return html12`
|
|
1995
|
+
<yatl-option
|
|
1996
|
+
part="column-picker-item"
|
|
1997
|
+
checkable
|
|
1998
|
+
label=${column.title ?? column.field}
|
|
1999
|
+
.checked=${state6.visible}
|
|
2000
|
+
.value=${state6.field}
|
|
2001
|
+
></yatl-option>
|
|
2002
|
+
`;
|
|
2003
|
+
}
|
|
2004
|
+
renderExportButton() {
|
|
2005
|
+
return html12`
|
|
2006
|
+
<yatl-button type="button" color="raised" @click=${this.onExportClick}>
|
|
2007
|
+
<slot name="export-button-icon">
|
|
2008
|
+
<yatl-icon name="download"></yatl-icon>
|
|
2009
|
+
</slot>
|
|
2010
|
+
</yatl-button>
|
|
2011
|
+
`;
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
YatlToolbar.styles = [...__superGet(YatlToolbar, YatlToolbar, "styles"), toolbar_styles_default];
|
|
2015
|
+
__decorateClass([
|
|
2016
|
+
property9({ attribute: false })
|
|
2017
|
+
], YatlToolbar.prototype, "controller", 1);
|
|
2018
|
+
__decorateClass([
|
|
2019
|
+
property9({ type: Boolean })
|
|
2020
|
+
], YatlToolbar.prototype, "showColumnPicker", 2);
|
|
2021
|
+
__decorateClass([
|
|
2022
|
+
property9({ type: Boolean })
|
|
2023
|
+
], YatlToolbar.prototype, "showExportButton", 2);
|
|
2024
|
+
YatlToolbar = __decorateClass([
|
|
2025
|
+
customElement12("yatl-toolbar")
|
|
2026
|
+
], YatlToolbar);
|
|
2027
|
+
|
|
2028
|
+
// src/components/filter-components/base-filter/base-filter.ts
|
|
2029
|
+
import { consume } from "@lit/context";
|
|
2030
|
+
import { property as property10 } from "lit/decorators.js";
|
|
2031
|
+
import {
|
|
2032
|
+
getNestedValue,
|
|
2033
|
+
setNestedValue
|
|
2034
|
+
} from "@timlassiter11/yatl";
|
|
2035
|
+
var YatlBaseFilter = class extends YatlBase {
|
|
2036
|
+
constructor() {
|
|
2037
|
+
super(...arguments);
|
|
2038
|
+
this.field = "";
|
|
2039
|
+
this.label = "";
|
|
2040
|
+
}
|
|
2041
|
+
get controller() {
|
|
2042
|
+
return this._controller;
|
|
2043
|
+
}
|
|
2044
|
+
set controller(controller) {
|
|
2045
|
+
const oldValue = this._controller;
|
|
2046
|
+
if (oldValue === controller) {
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
oldValue?.detach(this);
|
|
2050
|
+
controller?.attach(this);
|
|
2051
|
+
this._controller = controller;
|
|
2052
|
+
this.updateFilterOptions();
|
|
2053
|
+
this.updateFilters();
|
|
2054
|
+
this.requestUpdate("controller", oldValue);
|
|
2055
|
+
}
|
|
2056
|
+
get value() {
|
|
2057
|
+
return this._value;
|
|
2058
|
+
}
|
|
2059
|
+
set value(value) {
|
|
2060
|
+
const oldValue = this._value;
|
|
2061
|
+
if (oldValue === value) {
|
|
2062
|
+
return;
|
|
2063
|
+
}
|
|
2064
|
+
this._value = value;
|
|
2065
|
+
this.updateFilterOptions();
|
|
2066
|
+
this.updateFilters();
|
|
2067
|
+
this.requestUpdate("value", oldValue);
|
|
2068
|
+
}
|
|
2069
|
+
get filters() {
|
|
2070
|
+
if (!this.controller || typeof this.controller.filters === "function") {
|
|
2071
|
+
return void 0;
|
|
2072
|
+
}
|
|
2073
|
+
return structuredClone(this.controller.filters);
|
|
2074
|
+
}
|
|
2075
|
+
set filters(filters) {
|
|
2076
|
+
if (filters === void 0 || !this.controller || typeof this.controller.filters === "function") {
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
this.controller.filters = filters;
|
|
2080
|
+
}
|
|
2081
|
+
get options() {
|
|
2082
|
+
return this._filterOptions ?? this.controller?.getColumnFilterValues(this.field) ?? /* @__PURE__ */ new Map();
|
|
2083
|
+
}
|
|
2084
|
+
willUpdate(changedProperties) {
|
|
2085
|
+
super.willUpdate(changedProperties);
|
|
2086
|
+
const filters = this.filters;
|
|
2087
|
+
if (filters === void 0) {
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
const filtersValue = getNestedValue(filters ?? {}, this.field);
|
|
2091
|
+
if (!filtersValue) {
|
|
2092
|
+
this.value = void 0;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
updateFilters() {
|
|
2096
|
+
if (!this.controller || !this.field) {
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
const filters = this.filters ?? {};
|
|
2100
|
+
setNestedValue(filters, this.field, this.value);
|
|
2101
|
+
this.filters = filters;
|
|
2102
|
+
}
|
|
2103
|
+
updateFilterOptions() {
|
|
2104
|
+
if (this.value === void 0) {
|
|
2105
|
+
this._filterOptions = void 0;
|
|
2106
|
+
} else if (this._filterOptions === void 0) {
|
|
2107
|
+
this._filterOptions = this.controller?.getColumnFilterValues(
|
|
2108
|
+
this.field
|
|
2109
|
+
);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
};
|
|
2113
|
+
__decorateClass([
|
|
2114
|
+
consume({ context: tableContext, subscribe: true }),
|
|
2115
|
+
property10({ attribute: false })
|
|
2116
|
+
], YatlBaseFilter.prototype, "controller", 1);
|
|
2117
|
+
__decorateClass([
|
|
2118
|
+
property10({ attribute: false })
|
|
2119
|
+
], YatlBaseFilter.prototype, "value", 1);
|
|
2120
|
+
__decorateClass([
|
|
2121
|
+
property10({ type: String })
|
|
2122
|
+
], YatlBaseFilter.prototype, "field", 2);
|
|
2123
|
+
__decorateClass([
|
|
2124
|
+
property10({ type: String })
|
|
2125
|
+
], YatlBaseFilter.prototype, "label", 2);
|
|
2126
|
+
|
|
2127
|
+
// src/components/filter-components/date-filter/date-filter.ts
|
|
2128
|
+
import { html as html13 } from "lit";
|
|
2129
|
+
import { customElement as customElement13 } from "lit/decorators.js";
|
|
2130
|
+
|
|
2131
|
+
// src/components/filter-components/date-filter/date-filter.styles.ts
|
|
2132
|
+
import { css as css14 } from "lit";
|
|
2133
|
+
var date_filter_styles_default = css14``;
|
|
2134
|
+
|
|
2135
|
+
// src/components/filter-components/date-filter/date-filter.ts
|
|
2136
|
+
import { live } from "lit/directives/live.js";
|
|
2137
|
+
var YatlDateFilter = class extends YatlBaseFilter {
|
|
2138
|
+
render() {
|
|
2139
|
+
return html13`
|
|
2140
|
+
<yatl-date-input
|
|
2141
|
+
name=${this.field}
|
|
2142
|
+
label=${this.label}
|
|
2143
|
+
.value=${live(this.value)}
|
|
2144
|
+
@change=${this.handleChange}
|
|
2145
|
+
>
|
|
2146
|
+
</yatl-date-input>
|
|
2147
|
+
`;
|
|
2148
|
+
}
|
|
2149
|
+
handleChange(event) {
|
|
2150
|
+
event.stopPropagation();
|
|
2151
|
+
const target = event.target;
|
|
2152
|
+
this.value = target.value ? new Date(target.value) : void 0;
|
|
2153
|
+
}
|
|
2154
|
+
};
|
|
2155
|
+
YatlDateFilter.styles = [...__superGet(YatlDateFilter, YatlDateFilter, "styles"), date_filter_styles_default];
|
|
2156
|
+
YatlDateFilter = __decorateClass([
|
|
2157
|
+
customElement13("yatl-date-filter")
|
|
2158
|
+
], YatlDateFilter);
|
|
2159
|
+
|
|
2160
|
+
// src/components/filter-components/search-filter/search-filter.ts
|
|
2161
|
+
import { html as html14, nothing as nothing5 } from "lit";
|
|
2162
|
+
import { customElement as customElement14, property as property11 } from "lit/decorators.js";
|
|
2163
|
+
import { repeat as repeat2 } from "lit/directives/repeat.js";
|
|
2164
|
+
|
|
2165
|
+
// src/components/filter-components/search-filter/search-filter.styles.ts
|
|
2166
|
+
import { css as css15 } from "lit";
|
|
2167
|
+
var search_filter_styles_default = css15`
|
|
2168
|
+
[part='option-count'] {
|
|
2169
|
+
font-size: small;
|
|
2170
|
+
color: var(--yatl-text-3);
|
|
2171
|
+
}
|
|
2172
|
+
`;
|
|
2173
|
+
|
|
2174
|
+
// src/components/filter-components/search-filter/search-filter.ts
|
|
2175
|
+
var YatlSearchFilter = class extends YatlBaseFilter {
|
|
2176
|
+
constructor() {
|
|
2177
|
+
super(...arguments);
|
|
2178
|
+
this.size = 4;
|
|
2179
|
+
}
|
|
2180
|
+
render() {
|
|
2181
|
+
return html14`
|
|
2182
|
+
<yatl-search-select
|
|
2183
|
+
name=${this.field}
|
|
2184
|
+
label=${this.label}
|
|
2185
|
+
size=${this.size}
|
|
2186
|
+
.value=${this.value ?? []}
|
|
2187
|
+
@change=${this.handleSelectChange}
|
|
2188
|
+
>
|
|
2189
|
+
${this.renderSelectOptions()}
|
|
2190
|
+
</yatl-search-select>
|
|
2191
|
+
`;
|
|
2192
|
+
}
|
|
2193
|
+
renderSelectOptions() {
|
|
2194
|
+
if (!this.controller || !this.field) {
|
|
2195
|
+
return nothing5;
|
|
2196
|
+
}
|
|
2197
|
+
return repeat2(
|
|
2198
|
+
this.options.entries(),
|
|
2199
|
+
([value, _count]) => value,
|
|
2200
|
+
([value, count]) => this.renderDropdownOption(String(value ?? ""), count)
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
renderDropdownOption(value, count) {
|
|
2204
|
+
return html14`
|
|
2205
|
+
<yatl-option value=${value} label=${value} checkable>
|
|
2206
|
+
<span part="option-count" slot="end">${count}</span>
|
|
2207
|
+
</yatl-option>
|
|
2208
|
+
`;
|
|
2209
|
+
}
|
|
2210
|
+
handleSelectChange(event) {
|
|
2211
|
+
const target = event.target;
|
|
2212
|
+
this.value = target.value.length ? target.value : void 0;
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
YatlSearchFilter.styles = [...__superGet(YatlSearchFilter, YatlSearchFilter, "styles"), search_filter_styles_default];
|
|
2216
|
+
__decorateClass([
|
|
2217
|
+
property11({ type: Number })
|
|
2218
|
+
], YatlSearchFilter.prototype, "size", 2);
|
|
2219
|
+
YatlSearchFilter = __decorateClass([
|
|
2220
|
+
customElement14("yatl-search-filter")
|
|
2221
|
+
], YatlSearchFilter);
|
|
2222
|
+
|
|
2223
|
+
// src/components/filter-components/select-filter/select-filter.ts
|
|
2224
|
+
import { html as html15, nothing as nothing6 } from "lit";
|
|
2225
|
+
import { customElement as customElement15, property as property12 } from "lit/decorators.js";
|
|
2226
|
+
import { repeat as repeat3 } from "lit/directives/repeat.js";
|
|
2227
|
+
|
|
2228
|
+
// src/components/filter-components/select-filter/select-filter.styles.ts
|
|
2229
|
+
import { css as css16 } from "lit";
|
|
2230
|
+
var select_filter_styles_default = css16`
|
|
2231
|
+
[part='option-count'] {
|
|
2232
|
+
font-size: small;
|
|
2233
|
+
color: var(--yatl-text-3);
|
|
2234
|
+
}
|
|
2235
|
+
`;
|
|
2236
|
+
|
|
2237
|
+
// src/components/filter-components/select-filter/select-filter.ts
|
|
2238
|
+
var YatlSelectFilter = class extends YatlBaseFilter {
|
|
2239
|
+
constructor() {
|
|
2240
|
+
super(...arguments);
|
|
2241
|
+
this.placeholder = "";
|
|
2242
|
+
this.maxTags = 3;
|
|
2243
|
+
this.multi = false;
|
|
2244
|
+
this.clearable = false;
|
|
2245
|
+
}
|
|
2246
|
+
render() {
|
|
2247
|
+
return html15`
|
|
2248
|
+
<yatl-select
|
|
2249
|
+
name=${this.field}
|
|
2250
|
+
label=${this.label}
|
|
2251
|
+
placeholder=${this.placeholder}
|
|
2252
|
+
max-tags=${this.maxTags}
|
|
2253
|
+
?multi=${this.multi}
|
|
2254
|
+
?clearable=${this.clearable}
|
|
2255
|
+
.value=${this.value ?? []}
|
|
2256
|
+
@change=${this.handleSelectChange}
|
|
2257
|
+
>
|
|
2258
|
+
${this.renderSelectOptions()}
|
|
2259
|
+
</yatl-select>
|
|
2260
|
+
`;
|
|
2261
|
+
}
|
|
2262
|
+
renderSelectOptions() {
|
|
2263
|
+
if (!this.controller || !this.field) {
|
|
2264
|
+
return nothing6;
|
|
2265
|
+
}
|
|
2266
|
+
return repeat3(
|
|
2267
|
+
this.options.entries(),
|
|
2268
|
+
([value, _count]) => value,
|
|
2269
|
+
([value, count]) => this.renderDropdownOption(String(value ?? ""), count)
|
|
2270
|
+
);
|
|
2271
|
+
}
|
|
2272
|
+
renderDropdownOption(value, count) {
|
|
2273
|
+
return html15`
|
|
2274
|
+
<yatl-option value=${value} label=${value} checkable>
|
|
2275
|
+
<span part="option-count" slot="end">${count}</span>
|
|
2276
|
+
</yatl-option>
|
|
2277
|
+
`;
|
|
2278
|
+
}
|
|
2279
|
+
handleSelectChange(event) {
|
|
2280
|
+
const target = event.target;
|
|
2281
|
+
this.value = target.value.length ? target.value : void 0;
|
|
2282
|
+
}
|
|
2283
|
+
};
|
|
2284
|
+
YatlSelectFilter.styles = [...__superGet(YatlSelectFilter, YatlSelectFilter, "styles"), select_filter_styles_default];
|
|
2285
|
+
__decorateClass([
|
|
2286
|
+
property12({ type: String })
|
|
2287
|
+
], YatlSelectFilter.prototype, "placeholder", 2);
|
|
2288
|
+
__decorateClass([
|
|
2289
|
+
property12({ type: Number, attribute: "max-tags" })
|
|
2290
|
+
], YatlSelectFilter.prototype, "maxTags", 2);
|
|
2291
|
+
__decorateClass([
|
|
2292
|
+
property12({ type: Boolean, reflect: true })
|
|
2293
|
+
], YatlSelectFilter.prototype, "multi", 2);
|
|
2294
|
+
__decorateClass([
|
|
2295
|
+
property12({ type: Boolean, reflect: true })
|
|
2296
|
+
], YatlSelectFilter.prototype, "clearable", 2);
|
|
2297
|
+
YatlSelectFilter = __decorateClass([
|
|
2298
|
+
customElement15("yatl-select-filter")
|
|
2299
|
+
], YatlSelectFilter);
|
|
2300
|
+
|
|
2301
|
+
// src/components/form-controls/form-control/form-control.ts
|
|
2302
|
+
import { html as html16, LitElement as LitElement2 } from "lit";
|
|
2303
|
+
import { property as property13, query as query4 } from "lit/decorators.js";
|
|
2304
|
+
import { classMap as classMap2 } from "lit/directives/class-map.js";
|
|
2305
|
+
|
|
2306
|
+
// src/components/form-controls/form-control/form-control.styles.ts
|
|
2307
|
+
import { css as css17 } from "lit";
|
|
2308
|
+
var form_control_styles_default = css17`
|
|
2309
|
+
:host {
|
|
2310
|
+
--input-radius: var(--yatl-input-radius, var(--yatl-radius-m));
|
|
2311
|
+
--input-padding: var(--yatl-input-padding, var(--yatl-spacing-m));
|
|
2312
|
+
--input-bg: var(--yatl-input-bg, var(--yatl-surface-2));
|
|
2313
|
+
--input-text: var(--yatl-input-text, var(--yatl-text-1));
|
|
2314
|
+
--input-line-height: var(--yatl-input-line-height, 1.2);
|
|
2315
|
+
--input-min-height: var(
|
|
2316
|
+
--yatl-input-min-height,
|
|
2317
|
+
round(
|
|
2318
|
+
calc(2 * var(--input-padding) + 1em * var(--input-line-height)),
|
|
2319
|
+
1px
|
|
2320
|
+
)
|
|
2321
|
+
);
|
|
2322
|
+
--input-outline-color: var(
|
|
2323
|
+
--yatl-input-outline-color,
|
|
2324
|
+
var(--yatl-color-brand)
|
|
2325
|
+
);
|
|
2326
|
+
--input-outline-width: var(--yatl-input-outline-width, 3px);
|
|
2327
|
+
--input-label-text: var(--yatl-input-label-text, var(--yatl-text-1));
|
|
2328
|
+
--input-label-font-size: var(--yatl-input-label-font-size, large);
|
|
2329
|
+
--input-label-font-weight: var(--yatl-input-label-font-weight, 700);
|
|
2330
|
+
|
|
2331
|
+
--input-hint-text: var(--yatl-input-hint-text, var(--yatl-text-3));
|
|
2332
|
+
--input-hint-font-size: var(--yatl-input-hint-font-size, small);
|
|
2333
|
+
--input-error-text: var(--yatl-input-error-text, var(--yatl-color-danger));
|
|
2334
|
+
--input-error-font-size: var(--yatl-input-error-font-size, small);
|
|
2335
|
+
--input-placeholder-color: var(
|
|
2336
|
+
--yatl-input-placeholder-color,
|
|
2337
|
+
var(--yatl-text-2)
|
|
2338
|
+
);
|
|
2339
|
+
|
|
2340
|
+
display: flex;
|
|
2341
|
+
flex-direction: column;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
:host([inline]) {
|
|
2345
|
+
flex-direction: row;
|
|
2346
|
+
align-items: flex-start;
|
|
2347
|
+
gap: var(--yatl-spacing-s);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
.text-input {
|
|
2351
|
+
display: flex;
|
|
2352
|
+
flex-direction: row;
|
|
2353
|
+
gap: 0;
|
|
2354
|
+
|
|
2355
|
+
box-sizing: border-box;
|
|
2356
|
+
border-radius: var(--input-radius);
|
|
2357
|
+
color: var(--input-text);
|
|
2358
|
+
background-color: var(--input-bg);
|
|
2359
|
+
line-height: var(--input-line-height);
|
|
2360
|
+
border: none;
|
|
2361
|
+
font-size: large;
|
|
2362
|
+
padding: var(--input-padding);
|
|
2363
|
+
width: 100%;
|
|
2364
|
+
min-height: var(--input-min-height);
|
|
2365
|
+
justify-content: center;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
.text-input:focus,
|
|
2369
|
+
.text:focus-visible {
|
|
2370
|
+
outline: var(--input-outline-width) solid var(--input-outline-color);
|
|
2371
|
+
outline-offset: calc(var(--input-outline-width) * -1);
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
[part='label'] {
|
|
2375
|
+
color: var(--input-label-text);
|
|
2376
|
+
font-size: var(--input-label-font-size);
|
|
2377
|
+
font-weight: var(--input-label-font-weight);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
[part='label']:not(.has-label) {
|
|
2381
|
+
display: none;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
:host(:not([inline])) [part='label'] {
|
|
2385
|
+
margin-block-end: var(--yatl-spacing-s);
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
input:not([type='checkbox']):not([type='radio']) {
|
|
2389
|
+
height: 100%;
|
|
2390
|
+
min-width: 0px;
|
|
2391
|
+
flex: 1 1 auto;
|
|
2392
|
+
|
|
2393
|
+
margin: 0px;
|
|
2394
|
+
padding: 0px;
|
|
2395
|
+
padding-block: 0px;
|
|
2396
|
+
|
|
2397
|
+
border: none;
|
|
2398
|
+
outline: none;
|
|
2399
|
+
box-shadow: none;
|
|
2400
|
+
|
|
2401
|
+
color: inherit;
|
|
2402
|
+
background-color: transparent;
|
|
2403
|
+
appearance: none;
|
|
2404
|
+
|
|
2405
|
+
cursor: inherit;
|
|
2406
|
+
font: inherit;
|
|
2407
|
+
transition: inherit;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
[part='hint'] {
|
|
2411
|
+
color: var(--input-hint-text);
|
|
2412
|
+
font-size: var(--input-hint-font-size);
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
[part='hint']:not(.has-hint) {
|
|
2416
|
+
display: none;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
[part='error'] {
|
|
2420
|
+
color: var(--input-error-text);
|
|
2421
|
+
font-size: var(--input-error-font-size);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
[part='error']:not(.has-error) {
|
|
2425
|
+
display: none;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
[part='start'],
|
|
2429
|
+
[part='end'] {
|
|
2430
|
+
display: inline-flex;
|
|
2431
|
+
flex: 0 0 auto;
|
|
2432
|
+
align-items: center;
|
|
2433
|
+
cursor: default;
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
input::placeholder {
|
|
2437
|
+
color: var(--input-placeholder-color);
|
|
2438
|
+
}
|
|
2439
|
+
`;
|
|
2440
|
+
|
|
2441
|
+
// src/components/form-controls/form-control/form-control.ts
|
|
2442
|
+
var YatlFormControl = class extends YatlBase {
|
|
2443
|
+
constructor() {
|
|
2444
|
+
super();
|
|
2445
|
+
this.slotController = new HasSlotController(
|
|
2446
|
+
this,
|
|
2447
|
+
"hint",
|
|
2448
|
+
"label",
|
|
2449
|
+
"error"
|
|
2450
|
+
);
|
|
2451
|
+
/**
|
|
2452
|
+
* Used to associate the label with the control element
|
|
2453
|
+
*/
|
|
2454
|
+
this.inputId = "input";
|
|
2455
|
+
this.name = "";
|
|
2456
|
+
this.label = "";
|
|
2457
|
+
this.hint = "";
|
|
2458
|
+
this.disabled = false;
|
|
2459
|
+
this.readonly = false;
|
|
2460
|
+
this.required = false;
|
|
2461
|
+
this.inline = false;
|
|
2462
|
+
this._errorText = "";
|
|
2463
|
+
this.requiredText = "This field is required";
|
|
2464
|
+
this.handleInputChange = (event) => {
|
|
2465
|
+
if (this.onValueChange?.(event)) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
event.stopPropagation();
|
|
2469
|
+
this.setFormValue(this.formValue);
|
|
2470
|
+
this.dispatchEvent(
|
|
2471
|
+
new Event(event.type, { bubbles: true, composed: true })
|
|
2472
|
+
);
|
|
2473
|
+
};
|
|
2474
|
+
this.internals = this.attachInternals();
|
|
2475
|
+
}
|
|
2476
|
+
static {
|
|
2477
|
+
this.formAssociated = true;
|
|
2478
|
+
}
|
|
2479
|
+
static {
|
|
2480
|
+
this.shadowRootOptions = {
|
|
2481
|
+
...LitElement2.shadowRootOptions,
|
|
2482
|
+
delegatesFocus: true
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
static {
|
|
2486
|
+
this.styles = [...super.styles, form_control_styles_default];
|
|
2487
|
+
}
|
|
2488
|
+
onValueChange(_event) {
|
|
2489
|
+
}
|
|
2490
|
+
get errorText() {
|
|
2491
|
+
return this._errorText || this.validationMessage;
|
|
2492
|
+
}
|
|
2493
|
+
set errorText(newValue) {
|
|
2494
|
+
const oldValue = this.errorText;
|
|
2495
|
+
if (newValue === oldValue) return;
|
|
2496
|
+
this._errorText = newValue;
|
|
2497
|
+
this.updateValidity();
|
|
2498
|
+
this.requestUpdate("errorText", oldValue);
|
|
2499
|
+
}
|
|
2500
|
+
get hasLabel() {
|
|
2501
|
+
return this.label ? true : this.slotController.test("label");
|
|
2502
|
+
}
|
|
2503
|
+
get hasHint() {
|
|
2504
|
+
return this.hint ? true : this.slotController.test("hint");
|
|
2505
|
+
}
|
|
2506
|
+
get hasError() {
|
|
2507
|
+
return this.errorText ? true : this.slotController.test("error");
|
|
2508
|
+
}
|
|
2509
|
+
createRenderRoot() {
|
|
2510
|
+
const root2 = super.createRenderRoot();
|
|
2511
|
+
root2.addEventListener("input", this.handleInputChange);
|
|
2512
|
+
root2.addEventListener("change", this.handleInputChange);
|
|
2513
|
+
return root2;
|
|
2514
|
+
}
|
|
2515
|
+
connectedCallback() {
|
|
2516
|
+
super.connectedCallback();
|
|
2517
|
+
if (!this.value && this.defaultValue) {
|
|
2518
|
+
this.value = this.defaultValue;
|
|
2519
|
+
}
|
|
2520
|
+
this.setFormValue(this.formValue);
|
|
2521
|
+
}
|
|
2522
|
+
willUpdate(changedProperties) {
|
|
2523
|
+
if (changedProperties.has("required")) {
|
|
2524
|
+
if (this.formControl && this.formControl.required !== this.required) {
|
|
2525
|
+
this.formControl.required = this.required;
|
|
2526
|
+
}
|
|
2527
|
+
this.updateValidity();
|
|
2528
|
+
}
|
|
2529
|
+
if (changedProperties.has("requiredText")) {
|
|
2530
|
+
this.updateValidity();
|
|
2531
|
+
}
|
|
2532
|
+
if (changedProperties.has("disabled")) {
|
|
2533
|
+
this.setFormValue(this.formValue);
|
|
2534
|
+
this.toggleState("disabled", this.disabled);
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
render() {
|
|
2538
|
+
return html16`
|
|
2539
|
+
${this.renderLabel()} ${this.renderBase(this.renderInput())}
|
|
2540
|
+
${this.renderHint()} ${this.renderErrorText()}
|
|
2541
|
+
`;
|
|
2542
|
+
}
|
|
2543
|
+
renderBase(contents) {
|
|
2544
|
+
return html16`
|
|
2545
|
+
<div part="base" class="text-input">
|
|
2546
|
+
<slot part="start" name="start"></slot>
|
|
2547
|
+
${contents}
|
|
2548
|
+
<slot part="end" name="end"></slot>
|
|
2549
|
+
</div>
|
|
2550
|
+
`;
|
|
2551
|
+
}
|
|
2552
|
+
renderLabel() {
|
|
2553
|
+
return html16`
|
|
2554
|
+
<label for="input">
|
|
2555
|
+
<slot name="label">
|
|
2556
|
+
<div part="label" class=${classMap2({ "has-label": this.hasLabel })}>
|
|
2557
|
+
${this.label}
|
|
2558
|
+
</div>
|
|
2559
|
+
</slot>
|
|
2560
|
+
</label>
|
|
2561
|
+
`;
|
|
2562
|
+
}
|
|
2563
|
+
renderHint() {
|
|
2564
|
+
return html16`
|
|
2565
|
+
<slot
|
|
2566
|
+
name="hint"
|
|
2567
|
+
class=${classMap2({ "has-hint": this.hasHint && !this.hasError })}
|
|
2568
|
+
>
|
|
2569
|
+
<span part="hint">${this.hint}</span>
|
|
2570
|
+
</slot>
|
|
2571
|
+
`;
|
|
2572
|
+
}
|
|
2573
|
+
renderErrorText() {
|
|
2574
|
+
return html16`
|
|
2575
|
+
<slot name="error" class=${classMap2({ "has-error": this.hasError })}>
|
|
2576
|
+
<span part="error">${this.errorText}</span>
|
|
2577
|
+
</slot>
|
|
2578
|
+
`;
|
|
2579
|
+
}
|
|
2580
|
+
get hasErrorText() {
|
|
2581
|
+
return !!this.errorText;
|
|
2582
|
+
}
|
|
2583
|
+
get labels() {
|
|
2584
|
+
return this.internals.labels;
|
|
2585
|
+
}
|
|
2586
|
+
get states() {
|
|
2587
|
+
return this.internals.states;
|
|
2588
|
+
}
|
|
2589
|
+
get validity() {
|
|
2590
|
+
return this.internals.validity;
|
|
2591
|
+
}
|
|
2592
|
+
get validationMessage() {
|
|
2593
|
+
return this.internals.validationMessage;
|
|
2594
|
+
}
|
|
2595
|
+
get willValidate() {
|
|
2596
|
+
return this.internals.willValidate;
|
|
2597
|
+
}
|
|
2598
|
+
get form() {
|
|
2599
|
+
return this.internals.form;
|
|
2600
|
+
}
|
|
2601
|
+
setFormValue(value) {
|
|
2602
|
+
value ||= null;
|
|
2603
|
+
this.internals.setFormValue(this.disabled ? null : value);
|
|
2604
|
+
this.updateValidity();
|
|
2605
|
+
}
|
|
2606
|
+
setValidity(flags, message, anchor) {
|
|
2607
|
+
this.internals.setValidity(flags, message, anchor);
|
|
2608
|
+
}
|
|
2609
|
+
checkValidity() {
|
|
2610
|
+
this.updateValidity();
|
|
2611
|
+
return this.internals.checkValidity();
|
|
2612
|
+
}
|
|
2613
|
+
reportValidity() {
|
|
2614
|
+
const valid = this.checkValidity();
|
|
2615
|
+
if (!valid) {
|
|
2616
|
+
this.focus();
|
|
2617
|
+
}
|
|
2618
|
+
return valid;
|
|
2619
|
+
}
|
|
2620
|
+
formResetCallback() {
|
|
2621
|
+
this.value = this.defaultValue;
|
|
2622
|
+
}
|
|
2623
|
+
updateValidity() {
|
|
2624
|
+
if (this._errorText) {
|
|
2625
|
+
this.setValidity({ customError: true }, this._errorText);
|
|
2626
|
+
} else if (this.required && !this.value) {
|
|
2627
|
+
this.setValidity({ valueMissing: true }, this.requiredText);
|
|
2628
|
+
} else if (this.formControl && !this.formControl.checkValidity()) {
|
|
2629
|
+
this.setValidity(
|
|
2630
|
+
this.formControl.validity,
|
|
2631
|
+
this.formControl.validationMessage
|
|
2632
|
+
);
|
|
2633
|
+
} else {
|
|
2634
|
+
this.setValidity({});
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
toggleState(name, state6) {
|
|
2638
|
+
state6 ??= !this.states.has(name);
|
|
2639
|
+
if (state6) {
|
|
2640
|
+
this.states.add(name);
|
|
2641
|
+
} else {
|
|
2642
|
+
this.states.delete(name);
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
__decorateClass([
|
|
2647
|
+
query4("input")
|
|
2648
|
+
], YatlFormControl.prototype, "formControl", 2);
|
|
2649
|
+
__decorateClass([
|
|
2650
|
+
query4('slot[name="label"]')
|
|
2651
|
+
], YatlFormControl.prototype, "labelSlot", 2);
|
|
2652
|
+
__decorateClass([
|
|
2653
|
+
query4('slot[name=""]'),
|
|
2654
|
+
property13({ type: String })
|
|
2655
|
+
], YatlFormControl.prototype, "name", 2);
|
|
2656
|
+
__decorateClass([
|
|
2657
|
+
property13({ type: String })
|
|
2658
|
+
], YatlFormControl.prototype, "label", 2);
|
|
2659
|
+
__decorateClass([
|
|
2660
|
+
property13({ type: String })
|
|
2661
|
+
], YatlFormControl.prototype, "hint", 2);
|
|
2662
|
+
__decorateClass([
|
|
2663
|
+
property13({ type: Boolean, reflect: true })
|
|
2664
|
+
], YatlFormControl.prototype, "disabled", 2);
|
|
2665
|
+
__decorateClass([
|
|
2666
|
+
property13({ type: Boolean, reflect: true })
|
|
2667
|
+
], YatlFormControl.prototype, "readonly", 2);
|
|
2668
|
+
__decorateClass([
|
|
2669
|
+
property13({ type: Boolean, reflect: true })
|
|
2670
|
+
], YatlFormControl.prototype, "required", 2);
|
|
2671
|
+
__decorateClass([
|
|
2672
|
+
property13({ type: Boolean, reflect: true })
|
|
2673
|
+
], YatlFormControl.prototype, "inline", 2);
|
|
2674
|
+
__decorateClass([
|
|
2675
|
+
property13({ type: String, attribute: "error-text" })
|
|
2676
|
+
], YatlFormControl.prototype, "errorText", 1);
|
|
2677
|
+
__decorateClass([
|
|
2678
|
+
property13({ type: String, attribute: "required-text" })
|
|
2679
|
+
], YatlFormControl.prototype, "requiredText", 2);
|
|
2680
|
+
|
|
2681
|
+
// src/components/form-controls/checkbox/checkbox.ts
|
|
2682
|
+
import { html as html17 } from "lit";
|
|
2683
|
+
import { customElement as customElement16, property as property14, state } from "lit/decorators.js";
|
|
2684
|
+
import { live as live2 } from "lit/directives/live.js";
|
|
2685
|
+
|
|
2686
|
+
// src/components/form-controls/checkbox/checkbox.styles.ts
|
|
2687
|
+
import { css as css18 } from "lit";
|
|
2688
|
+
var checkbox_styles_default = css18`
|
|
2689
|
+
:host {
|
|
2690
|
+
--checkbox-accent-color: var(
|
|
2691
|
+
--yatl-checkbox-accent-color,
|
|
2692
|
+
var(--yatl-color-brand)
|
|
2693
|
+
);
|
|
2694
|
+
--checkbox-label-font-weight: var(--yatl-checkbox-font-weight, 600);
|
|
2695
|
+
--checkbox-label-font-szie: var(--yatl-checkbox-font-size, 1rem);
|
|
2696
|
+
--checkbox-size: var(--yatl-checkbox-size, 1.25rem);
|
|
2697
|
+
--checkbox-bg: var(--yatl-checkbox-bg, var(--yatl-surface-1));
|
|
2698
|
+
--checkbox-border: var(--yatl-checkbox-border, var(--yatl-border-color));
|
|
2699
|
+
|
|
2700
|
+
display: inline-flex;
|
|
2701
|
+
align-items: center;
|
|
2702
|
+
gap: var(--yatl-spacing-xs);
|
|
2703
|
+
vertical-align: middle;
|
|
2704
|
+
cursor: pointer;
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
[part='base'] {
|
|
2708
|
+
display: flex;
|
|
2709
|
+
align-items: center;
|
|
2710
|
+
justify-content: center;
|
|
2711
|
+
width: var(--checkbox-size);
|
|
2712
|
+
height: var(--checkbox-size);
|
|
2713
|
+
flex-shrink: 0;
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
[part='input'] {
|
|
2717
|
+
appearance: none;
|
|
2718
|
+
-webkit-appearance: none;
|
|
2719
|
+
margin: 0;
|
|
2720
|
+
|
|
2721
|
+
width: 100%;
|
|
2722
|
+
height: 100%;
|
|
2723
|
+
|
|
2724
|
+
border: 1px solid var(--checkbox-border);
|
|
2725
|
+
border-radius: 4px;
|
|
2726
|
+
background-color: var(--checkbox-bg);
|
|
2727
|
+
cursor: pointer;
|
|
2728
|
+
position: relative;
|
|
2729
|
+
transition: all 0.1s ease-in-out;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
[part='input']:checked {
|
|
2733
|
+
background-color: var(--checkbox-accent-color);
|
|
2734
|
+
border-color: var(--checkbox-accent-color);
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
[part='input']::after {
|
|
2738
|
+
content: '';
|
|
2739
|
+
position: absolute;
|
|
2740
|
+
left: 50%;
|
|
2741
|
+
top: 45%;
|
|
2742
|
+
width: 25%;
|
|
2743
|
+
height: 55%;
|
|
2744
|
+
|
|
2745
|
+
border: solid white;
|
|
2746
|
+
border-width: 0 2px 2px 0;
|
|
2747
|
+
|
|
2748
|
+
transform: translate(-50%, -50%) rotate(45deg) scale(0);
|
|
2749
|
+
transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
[part='input']:checked::after {
|
|
2753
|
+
transform: translate(-50%, -50%) rotate(45deg) scale(1);
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
[part='label'] {
|
|
2757
|
+
font-size: var(--checkbox-label-font-size);
|
|
2758
|
+
font-weight: var(--checkbox-label-font-weight);
|
|
2759
|
+
color: var(--checkbox-label-color);
|
|
2760
|
+
line-height: 1.4;
|
|
2761
|
+
cursor: pointer;
|
|
2762
|
+
user-select: none;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
[part='input']:focus-visible {
|
|
2766
|
+
outline: 2px solid var(--checkbox-accent-color);
|
|
2767
|
+
outline-offset: 2px;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
:host(:hover) [part='input'] {
|
|
2771
|
+
border-color: var(--checkbox-accent-color);
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
:host([disabled]) {
|
|
2775
|
+
opacity: 0.6;
|
|
2776
|
+
pointer-events: none;
|
|
2777
|
+
cursor: not-allowed;
|
|
2778
|
+
}
|
|
2779
|
+
`;
|
|
2780
|
+
|
|
2781
|
+
// src/components/form-controls/checkbox/checkbox.ts
|
|
2782
|
+
var YatlCheckbox = class extends YatlFormControl {
|
|
2783
|
+
constructor() {
|
|
2784
|
+
super();
|
|
2785
|
+
this._value = this.getAttribute("value") ?? "on";
|
|
2786
|
+
this.defaultChecked = this.hasAttribute("checked");
|
|
2787
|
+
this.alwaysInclude = false;
|
|
2788
|
+
this.inline = true;
|
|
2789
|
+
this._checked = this.hasAttribute("checked");
|
|
2790
|
+
this.handleClick = (event) => {
|
|
2791
|
+
const path = event.composedPath();
|
|
2792
|
+
if (!this.formControl || path.includes(this.formControl)) {
|
|
2793
|
+
return;
|
|
2794
|
+
}
|
|
2795
|
+
event.preventDefault();
|
|
2796
|
+
event.stopPropagation();
|
|
2797
|
+
this.formControl.click();
|
|
2798
|
+
};
|
|
2799
|
+
this.addEventListener("click", (event) => this.handleClick(event));
|
|
2800
|
+
}
|
|
2801
|
+
get value() {
|
|
2802
|
+
return this._value;
|
|
2803
|
+
}
|
|
2804
|
+
set value(value) {
|
|
2805
|
+
if (this._value === value) {
|
|
2806
|
+
return;
|
|
2807
|
+
}
|
|
2808
|
+
const oldValue = this._value;
|
|
2809
|
+
this._value = value;
|
|
2810
|
+
this.updateFormValue();
|
|
2811
|
+
this.requestUpdate("value", oldValue);
|
|
2812
|
+
}
|
|
2813
|
+
get defaultValue() {
|
|
2814
|
+
return this.value;
|
|
2815
|
+
}
|
|
2816
|
+
get uncheckedValue() {
|
|
2817
|
+
return this._uncheckedValue;
|
|
2818
|
+
}
|
|
2819
|
+
set uncheckedValue(value) {
|
|
2820
|
+
const oldValue = this.uncheckedValue;
|
|
2821
|
+
this._uncheckedValue = value;
|
|
2822
|
+
this.updateFormValue();
|
|
2823
|
+
this.requestUpdate("uncheckedValue", oldValue);
|
|
2824
|
+
}
|
|
2825
|
+
get checked() {
|
|
2826
|
+
return this._checked;
|
|
2827
|
+
}
|
|
2828
|
+
set checked(value) {
|
|
2829
|
+
this._checked = value;
|
|
2830
|
+
this.toggleState("checked", value);
|
|
2831
|
+
this.updateFormValue();
|
|
2832
|
+
}
|
|
2833
|
+
get formValue() {
|
|
2834
|
+
if (this._checked) {
|
|
2835
|
+
return this.value || "on";
|
|
2836
|
+
} else if (this.alwaysInclude) {
|
|
2837
|
+
return this.uncheckedValue ?? "off";
|
|
2838
|
+
}
|
|
2839
|
+
return null;
|
|
2840
|
+
}
|
|
2841
|
+
formResetCallback() {
|
|
2842
|
+
this.checked = this.defaultChecked;
|
|
2843
|
+
}
|
|
2844
|
+
connectedCallback() {
|
|
2845
|
+
super.connectedCallback();
|
|
2846
|
+
this.updateFormValue();
|
|
2847
|
+
}
|
|
2848
|
+
render() {
|
|
2849
|
+
return html17`
|
|
2850
|
+
<div part="base">${this.renderInput()}</div>
|
|
2851
|
+
${this.renderLabel()} ${this.renderHint()} ${this.renderErrorText()}
|
|
2852
|
+
`;
|
|
2853
|
+
}
|
|
2854
|
+
renderInput() {
|
|
2855
|
+
return html17`
|
|
2856
|
+
<input
|
|
2857
|
+
part="input"
|
|
2858
|
+
id=${this.inputId}
|
|
2859
|
+
name=${this.name}
|
|
2860
|
+
type="checkbox"
|
|
2861
|
+
value=${this.value}
|
|
2862
|
+
.checked=${live2(this.checked)}
|
|
2863
|
+
?readonly=${this.readonly}
|
|
2864
|
+
?disabled=${this.disabled}
|
|
2865
|
+
?required=${this.required}
|
|
2866
|
+
/>
|
|
2867
|
+
`;
|
|
2868
|
+
}
|
|
2869
|
+
updateFormValue() {
|
|
2870
|
+
this.setFormValue(this.formValue);
|
|
2871
|
+
}
|
|
2872
|
+
onValueChange(event) {
|
|
2873
|
+
this.checked = event.target.checked;
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
YatlCheckbox.styles = [...__superGet(YatlCheckbox, YatlCheckbox, "styles"), checkbox_styles_default];
|
|
2877
|
+
__decorateClass([
|
|
2878
|
+
property14({ type: String, reflect: true })
|
|
2879
|
+
], YatlCheckbox.prototype, "value", 1);
|
|
2880
|
+
__decorateClass([
|
|
2881
|
+
property14({ type: String, attribute: "unchecked-value" })
|
|
2882
|
+
], YatlCheckbox.prototype, "uncheckedValue", 1);
|
|
2883
|
+
__decorateClass([
|
|
2884
|
+
property14({ type: Boolean, attribute: "checked" })
|
|
2885
|
+
], YatlCheckbox.prototype, "defaultChecked", 2);
|
|
2886
|
+
__decorateClass([
|
|
2887
|
+
property14({ type: Boolean, attribute: "always-include" })
|
|
2888
|
+
], YatlCheckbox.prototype, "alwaysInclude", 2);
|
|
2889
|
+
__decorateClass([
|
|
2890
|
+
state()
|
|
2891
|
+
], YatlCheckbox.prototype, "_checked", 2);
|
|
2892
|
+
YatlCheckbox = __decorateClass([
|
|
2893
|
+
customElement16("yatl-checkbox")
|
|
2894
|
+
], YatlCheckbox);
|
|
2895
|
+
|
|
2896
|
+
// src/components/form-controls/date-input/date-input.ts
|
|
2897
|
+
import { html as html18 } from "lit";
|
|
2898
|
+
import { customElement as customElement17, property as property15 } from "lit/decorators.js";
|
|
2899
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
2900
|
+
import { live as live3 } from "lit/directives/live.js";
|
|
2901
|
+
|
|
2902
|
+
// src/components/form-controls/date-input/date-input.styles.ts
|
|
2903
|
+
import { css as css19 } from "lit";
|
|
2904
|
+
var date_input_styles_default = css19``;
|
|
2905
|
+
|
|
2906
|
+
// src/components/form-controls/date-input/date-input.ts
|
|
2907
|
+
var YatlDateInput = class extends YatlFormControl {
|
|
2908
|
+
constructor() {
|
|
2909
|
+
super(...arguments);
|
|
2910
|
+
this.placeholder = "";
|
|
2911
|
+
this.size = 10;
|
|
2912
|
+
}
|
|
2913
|
+
get value() {
|
|
2914
|
+
return this._value ? new Date(this._value) : void 0;
|
|
2915
|
+
}
|
|
2916
|
+
set value(value) {
|
|
2917
|
+
const oldValue = this._value;
|
|
2918
|
+
if (oldValue?.getTime() === value?.getTime()) {
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
this._value = value ? new Date(value) : void 0;
|
|
2922
|
+
this.requestUpdate("value", oldValue);
|
|
2923
|
+
}
|
|
2924
|
+
get formValue() {
|
|
2925
|
+
return dateConverter.toAttribute(this.value);
|
|
2926
|
+
}
|
|
2927
|
+
renderInput() {
|
|
2928
|
+
const min = dateConverter.toAttribute(this.min) ?? void 0;
|
|
2929
|
+
const max = dateConverter.toAttribute(this.max) ?? void 0;
|
|
2930
|
+
return html18`
|
|
2931
|
+
<input
|
|
2932
|
+
part="input"
|
|
2933
|
+
name=${this.name}
|
|
2934
|
+
type="date"
|
|
2935
|
+
size=${this.size}
|
|
2936
|
+
.value=${live3(this.formValue ?? "")}
|
|
2937
|
+
min=${ifDefined(min)}
|
|
2938
|
+
max=${ifDefined(max)}
|
|
2939
|
+
placeholder=${this.placeholder}
|
|
2940
|
+
?readonly=${this.readonly}
|
|
2941
|
+
?disabled=${this.disabled}
|
|
2942
|
+
?required=${this.required}
|
|
2943
|
+
/>
|
|
2944
|
+
`;
|
|
2945
|
+
}
|
|
2946
|
+
onValueChange(event) {
|
|
2947
|
+
const input = event.target;
|
|
2948
|
+
this.value = dateConverter.fromAttribute(input.value);
|
|
2949
|
+
}
|
|
2950
|
+
};
|
|
2951
|
+
YatlDateInput.styles = [...__superGet(YatlDateInput, YatlDateInput, "styles"), date_input_styles_default];
|
|
2952
|
+
__decorateClass([
|
|
2953
|
+
property15({ type: String })
|
|
2954
|
+
], YatlDateInput.prototype, "placeholder", 2);
|
|
2955
|
+
__decorateClass([
|
|
2956
|
+
property15({ type: Number })
|
|
2957
|
+
], YatlDateInput.prototype, "size", 2);
|
|
2958
|
+
__decorateClass([
|
|
2959
|
+
property15({ converter: dateConverter, reflect: true })
|
|
2960
|
+
], YatlDateInput.prototype, "min", 2);
|
|
2961
|
+
__decorateClass([
|
|
2962
|
+
property15({ converter: dateConverter, reflect: true })
|
|
2963
|
+
], YatlDateInput.prototype, "max", 2);
|
|
2964
|
+
__decorateClass([
|
|
2965
|
+
property15({ converter: dateConverter, attribute: "value" })
|
|
2966
|
+
], YatlDateInput.prototype, "defaultValue", 2);
|
|
2967
|
+
__decorateClass([
|
|
2968
|
+
property15({ attribute: false })
|
|
2969
|
+
], YatlDateInput.prototype, "value", 1);
|
|
2970
|
+
YatlDateInput = __decorateClass([
|
|
2971
|
+
customElement17("yatl-date-input")
|
|
2972
|
+
], YatlDateInput);
|
|
2973
|
+
|
|
2974
|
+
// src/components/form-controls/input/input.ts
|
|
2975
|
+
import { html as html19, nothing as nothing7 } from "lit";
|
|
2976
|
+
import { customElement as customElement18, property as property16 } from "lit/decorators.js";
|
|
2977
|
+
import { ifDefined as ifDefined2 } from "lit/directives/if-defined.js";
|
|
2978
|
+
import { live as live4 } from "lit/directives/live.js";
|
|
2979
|
+
|
|
2980
|
+
// src/components/form-controls/input/input.styles.ts
|
|
2981
|
+
import { css as css20 } from "lit";
|
|
2982
|
+
var input_styles_default = css20`
|
|
2983
|
+
:host {
|
|
2984
|
+
--input-count-text: var(--yatl-input-count-text, var(--yatl-text-3));
|
|
2985
|
+
--input-count-font-size: var(--yatl-input-count-font-size, small);
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
[part='label-row'] {
|
|
2989
|
+
display: flex;
|
|
2990
|
+
flex-direction: row;
|
|
2991
|
+
justify-content: space-between;
|
|
2992
|
+
align-items: baseline;
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
[part='label-spacer'] {
|
|
2996
|
+
flex-grow: 1;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
[part='label-count'] {
|
|
3000
|
+
color: var(--input-count-text);
|
|
3001
|
+
font-size: var(--input-count-font-size);
|
|
3002
|
+
}
|
|
3003
|
+
`;
|
|
3004
|
+
|
|
3005
|
+
// src/components/form-controls/input/input.ts
|
|
3006
|
+
var YatlInput = class extends YatlFormControl {
|
|
3007
|
+
constructor() {
|
|
3008
|
+
super(...arguments);
|
|
3009
|
+
this.type = "text";
|
|
3010
|
+
this.size = 15;
|
|
3011
|
+
this.placeholder = "";
|
|
3012
|
+
this.passwordToggle = false;
|
|
3013
|
+
this.showCount = false;
|
|
3014
|
+
this.defaultValue = "";
|
|
3015
|
+
this.value = "";
|
|
3016
|
+
}
|
|
3017
|
+
get formValue() {
|
|
3018
|
+
return this.value;
|
|
3019
|
+
}
|
|
3020
|
+
renderInput() {
|
|
3021
|
+
return html19`
|
|
3022
|
+
<input
|
|
3023
|
+
part="input"
|
|
3024
|
+
name=${this.name}
|
|
3025
|
+
type=${this.type}
|
|
3026
|
+
size=${this.size}
|
|
3027
|
+
.value=${live4(this.value)}
|
|
3028
|
+
value=${this.defaultValue}
|
|
3029
|
+
placeholder=${this.placeholder}
|
|
3030
|
+
minlength=${ifDefined2(this.minlength)}
|
|
3031
|
+
maxlength=${ifDefined2(this.maxlength)}
|
|
3032
|
+
pattern=${ifDefined2(this.pattern)}
|
|
3033
|
+
?readonly=${this.readonly}
|
|
3034
|
+
?disabled=${this.disabled}
|
|
3035
|
+
?required=${this.required}
|
|
3036
|
+
/>
|
|
3037
|
+
`;
|
|
3038
|
+
}
|
|
3039
|
+
renderLabel() {
|
|
3040
|
+
if (!this.label && !this.showCount) {
|
|
3041
|
+
return nothing7;
|
|
3042
|
+
}
|
|
3043
|
+
return html19`
|
|
3044
|
+
<label part="label">
|
|
3045
|
+
<slot>
|
|
3046
|
+
<span part="label-row">
|
|
3047
|
+
${super.renderLabel()}
|
|
3048
|
+
<span part="label-spacer"></span>
|
|
3049
|
+
${this.renderCount()}
|
|
3050
|
+
</span>
|
|
3051
|
+
</slot>
|
|
3052
|
+
</label>
|
|
3053
|
+
`;
|
|
3054
|
+
}
|
|
3055
|
+
renderCount() {
|
|
3056
|
+
const count = this.maxlength ? `${this.value.length}/${this.maxlength}` : `${this.value.length}`;
|
|
3057
|
+
return html19`<span part="label-count">${count}</span>`;
|
|
3058
|
+
}
|
|
3059
|
+
onValueChange(event) {
|
|
3060
|
+
this.value = event.target.value;
|
|
3061
|
+
}
|
|
3062
|
+
};
|
|
3063
|
+
YatlInput.styles = [...__superGet(YatlInput, YatlInput, "styles"), input_styles_default];
|
|
3064
|
+
__decorateClass([
|
|
3065
|
+
property16({ type: String })
|
|
3066
|
+
], YatlInput.prototype, "type", 2);
|
|
3067
|
+
__decorateClass([
|
|
3068
|
+
property16({ type: Number })
|
|
3069
|
+
], YatlInput.prototype, "size", 2);
|
|
3070
|
+
__decorateClass([
|
|
3071
|
+
property16()
|
|
3072
|
+
], YatlInput.prototype, "pattern", 2);
|
|
3073
|
+
__decorateClass([
|
|
3074
|
+
property16({ type: String })
|
|
3075
|
+
], YatlInput.prototype, "placeholder", 2);
|
|
3076
|
+
__decorateClass([
|
|
3077
|
+
property16({ type: Boolean, attribute: "password-toggle" })
|
|
3078
|
+
], YatlInput.prototype, "passwordToggle", 2);
|
|
3079
|
+
__decorateClass([
|
|
3080
|
+
property16({ type: Number })
|
|
3081
|
+
], YatlInput.prototype, "minlength", 2);
|
|
3082
|
+
__decorateClass([
|
|
3083
|
+
property16({ type: Number })
|
|
3084
|
+
], YatlInput.prototype, "maxlength", 2);
|
|
3085
|
+
__decorateClass([
|
|
3086
|
+
property16({ type: Boolean, attribute: "show-count" })
|
|
3087
|
+
], YatlInput.prototype, "showCount", 2);
|
|
3088
|
+
__decorateClass([
|
|
3089
|
+
property16({ type: String, attribute: "value" })
|
|
3090
|
+
], YatlInput.prototype, "defaultValue", 2);
|
|
3091
|
+
__decorateClass([
|
|
3092
|
+
property16({ attribute: false })
|
|
3093
|
+
], YatlInput.prototype, "value", 2);
|
|
3094
|
+
YatlInput = __decorateClass([
|
|
3095
|
+
customElement18("yatl-input")
|
|
3096
|
+
], YatlInput);
|
|
3097
|
+
|
|
3098
|
+
// src/components/form-controls/number-input/number-input.ts
|
|
3099
|
+
import { html as html20 } from "lit";
|
|
3100
|
+
import { customElement as customElement19, property as property17 } from "lit/decorators.js";
|
|
3101
|
+
import { ifDefined as ifDefined3 } from "lit/directives/if-defined.js";
|
|
3102
|
+
import { live as live5 } from "lit/directives/live.js";
|
|
3103
|
+
|
|
3104
|
+
// src/components/form-controls/number-input/number-input.styles.ts
|
|
3105
|
+
import { css as css21 } from "lit";
|
|
3106
|
+
var number_input_styles_default = css21``;
|
|
3107
|
+
|
|
3108
|
+
// src/components/form-controls/number-input/number-input.ts
|
|
3109
|
+
var YatlNumberInput = class extends YatlFormControl {
|
|
3110
|
+
constructor() {
|
|
3111
|
+
super(...arguments);
|
|
3112
|
+
this.placeholder = "";
|
|
3113
|
+
this.size = 4;
|
|
3114
|
+
}
|
|
3115
|
+
get formValue() {
|
|
3116
|
+
return this.value ? String(this.value) : "";
|
|
3117
|
+
}
|
|
3118
|
+
renderInput() {
|
|
3119
|
+
return html20`
|
|
3120
|
+
<input
|
|
3121
|
+
part="input"
|
|
3122
|
+
name=${this.name}
|
|
3123
|
+
type="number"
|
|
3124
|
+
size=${this.size}
|
|
3125
|
+
.value=${live5(this.formValue)}
|
|
3126
|
+
min=${ifDefined3(this.min)}
|
|
3127
|
+
max=${ifDefined3(this.max)}
|
|
3128
|
+
?readonly=${this.readonly}
|
|
3129
|
+
?disabled=${this.disabled}
|
|
3130
|
+
?required=${this.required}
|
|
3131
|
+
/>
|
|
3132
|
+
`;
|
|
3133
|
+
}
|
|
3134
|
+
onValueChange(event) {
|
|
3135
|
+
const input = event.target;
|
|
3136
|
+
this.value = Number(input.value);
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
YatlNumberInput.styles = [...__superGet(YatlNumberInput, YatlNumberInput, "styles"), number_input_styles_default];
|
|
3140
|
+
__decorateClass([
|
|
3141
|
+
property17({ type: String })
|
|
3142
|
+
], YatlNumberInput.prototype, "placeholder", 2);
|
|
3143
|
+
__decorateClass([
|
|
3144
|
+
property17({ type: Number })
|
|
3145
|
+
], YatlNumberInput.prototype, "size", 2);
|
|
3146
|
+
__decorateClass([
|
|
3147
|
+
property17({ type: Number })
|
|
3148
|
+
], YatlNumberInput.prototype, "min", 2);
|
|
3149
|
+
__decorateClass([
|
|
3150
|
+
property17({ type: Number })
|
|
3151
|
+
], YatlNumberInput.prototype, "max", 2);
|
|
3152
|
+
__decorateClass([
|
|
3153
|
+
property17({ type: Number, attribute: "value" })
|
|
3154
|
+
], YatlNumberInput.prototype, "defaultValue", 2);
|
|
3155
|
+
__decorateClass([
|
|
3156
|
+
property17({ attribute: false })
|
|
3157
|
+
], YatlNumberInput.prototype, "value", 2);
|
|
3158
|
+
YatlNumberInput = __decorateClass([
|
|
3159
|
+
customElement19("yatl-number-input")
|
|
3160
|
+
], YatlNumberInput);
|
|
3161
|
+
|
|
3162
|
+
// src/components/form-controls/radio/radio.ts
|
|
3163
|
+
import { html as html21 } from "lit";
|
|
3164
|
+
import { customElement as customElement20, property as property18, state as state2 } from "lit/decorators.js";
|
|
3165
|
+
import { live as live6 } from "lit/directives/live.js";
|
|
3166
|
+
|
|
3167
|
+
// src/components/form-controls/radio/radio.styles.ts
|
|
3168
|
+
import { css as css22 } from "lit";
|
|
3169
|
+
var radio_styles_default = css22`
|
|
3170
|
+
:host {
|
|
3171
|
+
--radio-color: var(--yatl-radio-color, var(--yatl-text-1));
|
|
3172
|
+
--radio-bg: var(--yatl-radio-bg, var(--yatl-surface-1));
|
|
3173
|
+
--radio-accent-color: var(
|
|
3174
|
+
--yatl-checkbox-accent-color,
|
|
3175
|
+
var(--yatl-color-brand)
|
|
3176
|
+
);
|
|
3177
|
+
--radio-label-font-weight: var(--yatl-radio-font-weight, 600);
|
|
3178
|
+
--radio-label-font-szie: var(--yatl-radio-font-size, 1rem);
|
|
3179
|
+
--radio-size: var(--yatl-radio-size, 1.25rem);
|
|
3180
|
+
--radio-scale: var(--yatl-radio-scale, 0.7);
|
|
3181
|
+
--radio-border-width: var(--yatl-radio-border-width, 1px);
|
|
3182
|
+
--radio-border-style: var(--yatl-radio-border-style, solid);
|
|
3183
|
+
--radio-border-color: var(
|
|
3184
|
+
--yatl-radio-border-color,
|
|
3185
|
+
var(--yatl-border-color)
|
|
3186
|
+
);
|
|
3187
|
+
--radio-focus-color: var(--yatl-radio-focus-color, var(--yatl-color-brand));
|
|
3188
|
+
--radio-transition: var(--yatl-radio-transition, 0.2s ease-in-out);
|
|
3189
|
+
|
|
3190
|
+
display: inline-flex;
|
|
3191
|
+
align-items: center;
|
|
3192
|
+
gap: var(--yatl-spacing-xs);
|
|
3193
|
+
vertical-align: middle;
|
|
3194
|
+
cursor: pointer;
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
[part='base'] {
|
|
3198
|
+
flex: 0 0 auto;
|
|
3199
|
+
position: relative;
|
|
3200
|
+
display: inline-flex;
|
|
3201
|
+
align-items: center;
|
|
3202
|
+
justify-content: center;
|
|
3203
|
+
width: var(--radio-size);
|
|
3204
|
+
height: var(--radio-size);
|
|
3205
|
+
border-width: var(--radio-border-width);
|
|
3206
|
+
border-style: var(--radio-border-style);
|
|
3207
|
+
border-color: var(--radio-border-color);
|
|
3208
|
+
border-radius: 50%;
|
|
3209
|
+
background-color: var(--radio-bg);
|
|
3210
|
+
color: transparent;
|
|
3211
|
+
transition:
|
|
3212
|
+
background 250ms,
|
|
3213
|
+
border-color 250ms,
|
|
3214
|
+
box-shadow 250ms,
|
|
3215
|
+
color 250ms;
|
|
3216
|
+
transition-timing-function: ease;
|
|
3217
|
+
margin-inline-end: 0.5em;
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
[part='input'] {
|
|
3221
|
+
opacity: 0;
|
|
3222
|
+
width: 0;
|
|
3223
|
+
height: 0;
|
|
3224
|
+
position: absolute;
|
|
3225
|
+
margin: 0;
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
[part='radio'] {
|
|
3229
|
+
display: flex;
|
|
3230
|
+
fill: currentColor;
|
|
3231
|
+
width: var(--radio-size);
|
|
3232
|
+
height: var(--radio-size);
|
|
3233
|
+
scale: var(--radio-scale);
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
:host(:not(:state(checked))) svg circle {
|
|
3237
|
+
opacity: 0;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
:host(:state(checked)) [part='base'] {
|
|
3241
|
+
color: var(--radio-accent-color);
|
|
3242
|
+
border-color: var(--radio-accent-color);
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
:host(:focus-visible) [part='base'] {
|
|
3246
|
+
outline: var(--radio-focus-color);
|
|
3247
|
+
outline-offset: 3px;
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
:host(:hover) [part='base'] {
|
|
3251
|
+
border-color: var(--radio-accent-color);
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
:host([disabled]) {
|
|
3255
|
+
opacity: 0.6;
|
|
3256
|
+
cursor: not-allowed;
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
:host([disabled]) [part='radio'] {
|
|
3260
|
+
pointer-events: none;
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
[part='label'] {
|
|
3264
|
+
font-size: var(--checkbox-label-font-size);
|
|
3265
|
+
font-weight: var(--checkbox-label-font-weight);
|
|
3266
|
+
color: var(--checkbox-label-color);
|
|
3267
|
+
line-height: 1;
|
|
3268
|
+
cursor: pointer;
|
|
3269
|
+
user-select: none;
|
|
3270
|
+
}
|
|
3271
|
+
`;
|
|
3272
|
+
|
|
3273
|
+
// src/components/form-controls/radio/radio.ts
|
|
3274
|
+
var YatlRadio = class extends YatlFormControl {
|
|
3275
|
+
constructor() {
|
|
3276
|
+
super();
|
|
3277
|
+
this._value = this.getAttribute("value") ?? "on";
|
|
3278
|
+
this.defaultChecked = this.hasAttribute("checked");
|
|
3279
|
+
this.alwaysInclude = false;
|
|
3280
|
+
this.inline = true;
|
|
3281
|
+
this._checked = this.hasAttribute("checked");
|
|
3282
|
+
this.handleClick = (event) => {
|
|
3283
|
+
const path = event.composedPath();
|
|
3284
|
+
if (!this.formControl || path.includes(this.formControl)) {
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
3287
|
+
event.preventDefault();
|
|
3288
|
+
event.stopPropagation();
|
|
3289
|
+
this.formControl.click();
|
|
3290
|
+
};
|
|
3291
|
+
this.addEventListener("click", (event) => this.handleClick(event));
|
|
3292
|
+
}
|
|
3293
|
+
get value() {
|
|
3294
|
+
return this._value;
|
|
3295
|
+
}
|
|
3296
|
+
set value(value) {
|
|
3297
|
+
if (this._value === value) {
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
const oldValue = this._value;
|
|
3301
|
+
this._value = value;
|
|
3302
|
+
this.updateFormValue();
|
|
3303
|
+
this.requestUpdate("value", oldValue);
|
|
3304
|
+
}
|
|
3305
|
+
get defaultValue() {
|
|
3306
|
+
return this.value;
|
|
3307
|
+
}
|
|
3308
|
+
get uncheckedValue() {
|
|
3309
|
+
return this._uncheckedValue;
|
|
3310
|
+
}
|
|
3311
|
+
set uncheckedValue(value) {
|
|
3312
|
+
const oldValue = this.uncheckedValue;
|
|
3313
|
+
this._uncheckedValue = value;
|
|
3314
|
+
this.updateFormValue();
|
|
3315
|
+
this.requestUpdate("uncheckedValue", oldValue);
|
|
3316
|
+
}
|
|
3317
|
+
get checked() {
|
|
3318
|
+
return this._checked;
|
|
3319
|
+
}
|
|
3320
|
+
set checked(value) {
|
|
3321
|
+
this._checked = value;
|
|
3322
|
+
this.toggleState("checked", value);
|
|
3323
|
+
this.updateFormValue();
|
|
3324
|
+
}
|
|
3325
|
+
get formValue() {
|
|
3326
|
+
if (this._checked) {
|
|
3327
|
+
return this.value || "on";
|
|
3328
|
+
} else if (this.alwaysInclude) {
|
|
3329
|
+
return this.uncheckedValue ?? "off";
|
|
3330
|
+
}
|
|
3331
|
+
return null;
|
|
3332
|
+
}
|
|
3333
|
+
formResetCallback() {
|
|
3334
|
+
this.checked = this.defaultChecked;
|
|
3335
|
+
}
|
|
3336
|
+
connectedCallback() {
|
|
3337
|
+
super.connectedCallback();
|
|
3338
|
+
this.checked = this.defaultChecked;
|
|
3339
|
+
this.updateFormValue();
|
|
3340
|
+
}
|
|
3341
|
+
render() {
|
|
3342
|
+
return html21`
|
|
3343
|
+
<div part="base">${this.renderInput()}</div>
|
|
3344
|
+
${this.renderLabel()} ${this.renderHint()} ${this.renderErrorText()}
|
|
3345
|
+
`;
|
|
3346
|
+
}
|
|
3347
|
+
renderInput() {
|
|
3348
|
+
return html21`
|
|
3349
|
+
<input
|
|
3350
|
+
part="input"
|
|
3351
|
+
id=${this.inputId}
|
|
3352
|
+
name=${this.name}
|
|
3353
|
+
type="radio"
|
|
3354
|
+
value=${this.value}
|
|
3355
|
+
.checked=${live6(this.checked)}
|
|
3356
|
+
?readonly=${this.readonly}
|
|
3357
|
+
?disabled=${this.disabled}
|
|
3358
|
+
?required=${this.required}
|
|
3359
|
+
/>
|
|
3360
|
+
<svg viewBox="0 0 16 16" part="radio">
|
|
3361
|
+
<circle cx="8" cy="8" r="8" />
|
|
3362
|
+
</svg>
|
|
3363
|
+
`;
|
|
3364
|
+
}
|
|
3365
|
+
updateFormValue() {
|
|
3366
|
+
this.setFormValue(this.formValue);
|
|
3367
|
+
}
|
|
3368
|
+
onValueChange(event) {
|
|
3369
|
+
this.checked = event.target.checked;
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
YatlRadio.styles = [...__superGet(YatlRadio, YatlRadio, "styles"), radio_styles_default];
|
|
3373
|
+
__decorateClass([
|
|
3374
|
+
property18({ type: String, reflect: true })
|
|
3375
|
+
], YatlRadio.prototype, "value", 1);
|
|
3376
|
+
__decorateClass([
|
|
3377
|
+
property18({ type: String, attribute: "unchecked-value" })
|
|
3378
|
+
], YatlRadio.prototype, "uncheckedValue", 1);
|
|
3379
|
+
__decorateClass([
|
|
3380
|
+
property18({ type: Boolean, attribute: "checked" })
|
|
3381
|
+
], YatlRadio.prototype, "defaultChecked", 2);
|
|
3382
|
+
__decorateClass([
|
|
3383
|
+
property18({ type: Boolean, attribute: "always-include" })
|
|
3384
|
+
], YatlRadio.prototype, "alwaysInclude", 2);
|
|
3385
|
+
__decorateClass([
|
|
3386
|
+
state2()
|
|
3387
|
+
], YatlRadio.prototype, "_checked", 2);
|
|
3388
|
+
YatlRadio = __decorateClass([
|
|
3389
|
+
customElement20("yatl-radio")
|
|
3390
|
+
], YatlRadio);
|
|
3391
|
+
|
|
3392
|
+
// src/components/form-controls/radio-group/radio-group.ts
|
|
3393
|
+
import { html as html22 } from "lit";
|
|
3394
|
+
import { customElement as customElement21, property as property19 } from "lit/decorators.js";
|
|
3395
|
+
|
|
3396
|
+
// src/components/form-controls/radio-group/radio-group.styles.ts
|
|
3397
|
+
import { css as css23 } from "lit";
|
|
3398
|
+
var radio_group_styles_default = css23`
|
|
3399
|
+
[part='base'] {
|
|
3400
|
+
display: flex;
|
|
3401
|
+
flex-direction: column;
|
|
3402
|
+
gap: var(--yatl-radio-group-gap, var(--yatl-spacing-s));
|
|
3403
|
+
}
|
|
3404
|
+
`;
|
|
3405
|
+
|
|
3406
|
+
// src/components/form-controls/radio-group/radio-group.ts
|
|
3407
|
+
var YatlRadioGroup = class extends YatlFormControl {
|
|
3408
|
+
constructor() {
|
|
3409
|
+
super(...arguments);
|
|
3410
|
+
this.defaultValue = this.getAttribute("value") ?? "";
|
|
3411
|
+
this.value = this.getAttribute("value") ?? "";
|
|
3412
|
+
}
|
|
3413
|
+
get formValue() {
|
|
3414
|
+
return this.value;
|
|
3415
|
+
}
|
|
3416
|
+
connectedCallback() {
|
|
3417
|
+
super.connectedCallback();
|
|
3418
|
+
if (!this.value) {
|
|
3419
|
+
const children = this.getAllChildren();
|
|
3420
|
+
let defaultChild = children.find((c) => c.hasAttribute("checked"));
|
|
3421
|
+
if (!defaultChild && this.required) {
|
|
3422
|
+
defaultChild = children.at(0);
|
|
3423
|
+
}
|
|
3424
|
+
const defaultValue = defaultChild?.getAttribute("value");
|
|
3425
|
+
if (defaultValue) {
|
|
3426
|
+
this.value = defaultValue;
|
|
3427
|
+
}
|
|
3428
|
+
for (const child of children) {
|
|
3429
|
+
const childValue = child.getAttribute("value");
|
|
3430
|
+
child.toggleAttribute("checked", childValue === this.value);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
render() {
|
|
3435
|
+
return html22`
|
|
3436
|
+
${this.renderLabel()}
|
|
3437
|
+
<div part="base">${this.renderInput()}</div>
|
|
3438
|
+
${this.renderHint()} ${this.renderErrorText()}
|
|
3439
|
+
`;
|
|
3440
|
+
}
|
|
3441
|
+
renderInput() {
|
|
3442
|
+
return html22`<slot
|
|
3443
|
+
part="group"
|
|
3444
|
+
@slotchange=${this.syncChildStates}
|
|
3445
|
+
></slot> `;
|
|
3446
|
+
}
|
|
3447
|
+
onValueChange(event) {
|
|
3448
|
+
event.stopPropagation();
|
|
3449
|
+
if (event.type === "change") {
|
|
3450
|
+
const target = event.target;
|
|
3451
|
+
this.value = target.value;
|
|
3452
|
+
this.syncChildStates();
|
|
3453
|
+
return false;
|
|
3454
|
+
}
|
|
3455
|
+
return true;
|
|
3456
|
+
}
|
|
3457
|
+
syncChildStates() {
|
|
3458
|
+
for (const element of this.getAllChildren()) {
|
|
3459
|
+
element.checked = element.value === this.value;
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
getAllChildren(includeDisabled = false) {
|
|
3463
|
+
const elements = [...this.querySelectorAll("*")];
|
|
3464
|
+
if (includeDisabled) {
|
|
3465
|
+
return elements;
|
|
3466
|
+
}
|
|
3467
|
+
return elements.filter((c) => !c.disabled);
|
|
3468
|
+
}
|
|
3469
|
+
};
|
|
3470
|
+
YatlRadioGroup.styles = [...__superGet(YatlRadioGroup, YatlRadioGroup, "styles"), radio_group_styles_default];
|
|
3471
|
+
__decorateClass([
|
|
3472
|
+
property19({ type: String, attribute: "value" })
|
|
3473
|
+
], YatlRadioGroup.prototype, "defaultValue", 2);
|
|
3474
|
+
__decorateClass([
|
|
3475
|
+
property19({ type: String, attribute: false })
|
|
3476
|
+
], YatlRadioGroup.prototype, "value", 2);
|
|
3477
|
+
YatlRadioGroup = __decorateClass([
|
|
3478
|
+
customElement21("yatl-radio-group")
|
|
3479
|
+
], YatlRadioGroup);
|
|
3480
|
+
|
|
3481
|
+
// src/components/form-controls/search-select/search-select.ts
|
|
3482
|
+
import { html as html23, LitElement as LitElement3 } from "lit";
|
|
3483
|
+
import { customElement as customElement22, property as property20, state as state3 } from "lit/decorators.js";
|
|
3484
|
+
import { repeat as repeat4 } from "lit/directives/repeat.js";
|
|
3485
|
+
|
|
3486
|
+
// src/components/form-controls/search-select/search-select.styles.ts
|
|
3487
|
+
import { css as css24 } from "lit";
|
|
3488
|
+
var search_select_styles_default = css24`
|
|
3489
|
+
:host {
|
|
3490
|
+
--option-height: var(--yatl-select-option-height, 35px);
|
|
3491
|
+
--options-gap: var(--yatl-select-options-gap, 0);
|
|
3492
|
+
/* We need individual padding variables to calculate text-input height */
|
|
3493
|
+
--input-padding-left: var(
|
|
3494
|
+
--yatl-select-input-padding-left,
|
|
3495
|
+
var(--yatl-spacing-m)
|
|
3496
|
+
);
|
|
3497
|
+
--input-padding-right: var(
|
|
3498
|
+
--yatl-select-input-padding-right,
|
|
3499
|
+
var(--yatl-spacing-m)
|
|
3500
|
+
);
|
|
3501
|
+
--input-padding-top: var(
|
|
3502
|
+
--yatl-select-input-padding-top,
|
|
3503
|
+
var(--yatl-spacing-m)
|
|
3504
|
+
);
|
|
3505
|
+
--input-padding-bottom: var(
|
|
3506
|
+
--yatl-select-input-padding-bottom,
|
|
3507
|
+
var(--yatl-spacing-m)
|
|
3508
|
+
);
|
|
3509
|
+
|
|
3510
|
+
--input-separator-width: var(--yatl-select-input-separator-width, 1px);
|
|
3511
|
+
--input-separator-color: var(
|
|
3512
|
+
--yatl-select-input-separator-color,
|
|
3513
|
+
var(--yatl-border-color)
|
|
3514
|
+
);
|
|
3515
|
+
}
|
|
3516
|
+
|
|
3517
|
+
[part='options'] {
|
|
3518
|
+
display: flex;
|
|
3519
|
+
flex-direction: column;
|
|
3520
|
+
gap: var(--options-gap);
|
|
3521
|
+
overflow-y: auto;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
.text-input {
|
|
3525
|
+
display: flex;
|
|
3526
|
+
flex-direction: column;
|
|
3527
|
+
height: calc(
|
|
3528
|
+
var(--option-height) * var(--size, 4) + var(--input-padding-top) +
|
|
3529
|
+
var(--input-padding-bottom)
|
|
3530
|
+
);
|
|
3531
|
+
overflow: auto;
|
|
3532
|
+
justify-content: flex-start;
|
|
3533
|
+
padding: 0;
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
/* Need the specificity to override form control styles */
|
|
3537
|
+
.text-input > input[part='search'] {
|
|
3538
|
+
flex: 0 0 0%;
|
|
3539
|
+
padding-left: var(--input-padding-left);
|
|
3540
|
+
padding-right: var(--input-padding-right);
|
|
3541
|
+
padding-top: var(--input-padding-top);
|
|
3542
|
+
padding-bottom: var(--input-padding-bottom);
|
|
3543
|
+
border-bottom-width: var(--input-separator-width);
|
|
3544
|
+
border-bottom-style: solid;
|
|
3545
|
+
border-bottom-color: var(--input-separator-color);
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
[part='selected-trash-icon'] {
|
|
3549
|
+
opacity: 0;
|
|
3550
|
+
transition: opacity 0.1s ease;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
[part='empty-options'] {
|
|
3554
|
+
padding: var(--yatl-spacing-m);
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
/* Make all options the same size */
|
|
3558
|
+
yatl-option,
|
|
3559
|
+
::slotted(yatl-option) {
|
|
3560
|
+
flex-shrink: 0;
|
|
3561
|
+
height: var(--option-height);
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
yatl-option::part(check) {
|
|
3565
|
+
opacity: 0;
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
yatl-option {
|
|
3569
|
+
--yatl-option-hover-bg: var(--yatl-color-danger);
|
|
3570
|
+
}
|
|
3571
|
+
|
|
3572
|
+
yatl-option:hover [part='selected-trash-icon'] {
|
|
3573
|
+
opacity: 1;
|
|
3574
|
+
}
|
|
3575
|
+
`;
|
|
3576
|
+
|
|
3577
|
+
// src/components/form-controls/search-select/search-select.ts
|
|
3578
|
+
var YatlSearchSelect = class extends YatlFormControl {
|
|
3579
|
+
constructor() {
|
|
3580
|
+
super();
|
|
3581
|
+
this.noMatch = false;
|
|
3582
|
+
this.hasFocus = false;
|
|
3583
|
+
this.placeholder = "Search";
|
|
3584
|
+
this.noResultsText = "No matching options...";
|
|
3585
|
+
this.matchWidth = true;
|
|
3586
|
+
this.size = 4;
|
|
3587
|
+
this.defaultValue = [];
|
|
3588
|
+
this._value = [];
|
|
3589
|
+
this.handleOptionClick = (event) => {
|
|
3590
|
+
if (event.target instanceof YatlOption) {
|
|
3591
|
+
this.hasFocus = true;
|
|
3592
|
+
event.preventDefault();
|
|
3593
|
+
event.stopPropagation();
|
|
3594
|
+
this.toggleOption(event.target.value, event.target.checked);
|
|
3595
|
+
this.dispatchChange();
|
|
3596
|
+
}
|
|
3597
|
+
};
|
|
3598
|
+
this.handleFocus = (event) => {
|
|
3599
|
+
const path = event.composedPath();
|
|
3600
|
+
if (!path.includes(this)) {
|
|
3601
|
+
this.hasFocus = false;
|
|
3602
|
+
} else if (this.formControl && path.includes(this.formControl)) {
|
|
3603
|
+
this.hasFocus = true;
|
|
3604
|
+
}
|
|
3605
|
+
};
|
|
3606
|
+
this.addEventListener("click", this.handleOptionClick);
|
|
3607
|
+
}
|
|
3608
|
+
get value() {
|
|
3609
|
+
return [...this._value];
|
|
3610
|
+
}
|
|
3611
|
+
set value(value) {
|
|
3612
|
+
const oldValue = this._value;
|
|
3613
|
+
this._value = [...value];
|
|
3614
|
+
this.setFormValue(this.formValue);
|
|
3615
|
+
this.updateSelectedOptions();
|
|
3616
|
+
this.requestUpdate("value", oldValue);
|
|
3617
|
+
}
|
|
3618
|
+
get formValue() {
|
|
3619
|
+
const data = new FormData();
|
|
3620
|
+
for (const value of this.value) {
|
|
3621
|
+
data.append(this.name, value);
|
|
3622
|
+
}
|
|
3623
|
+
return data;
|
|
3624
|
+
}
|
|
3625
|
+
get hasSelection() {
|
|
3626
|
+
return this.value.length > 0;
|
|
3627
|
+
}
|
|
3628
|
+
connectedCallback() {
|
|
3629
|
+
super.connectedCallback();
|
|
3630
|
+
document.addEventListener("focusin", this.handleFocus);
|
|
3631
|
+
}
|
|
3632
|
+
disconnectedCallback() {
|
|
3633
|
+
super.disconnectedCallback();
|
|
3634
|
+
document.removeEventListener("focusin", this.handleFocus);
|
|
3635
|
+
}
|
|
3636
|
+
toggleOption(value, state6) {
|
|
3637
|
+
const newValue = new Set(this.value);
|
|
3638
|
+
if (state6 === void 0) {
|
|
3639
|
+
state6 = !this.value.includes(value);
|
|
3640
|
+
}
|
|
3641
|
+
if (state6) {
|
|
3642
|
+
newValue.add(value);
|
|
3643
|
+
} else {
|
|
3644
|
+
newValue.delete(value);
|
|
3645
|
+
}
|
|
3646
|
+
this.value = [...newValue];
|
|
3647
|
+
}
|
|
3648
|
+
render() {
|
|
3649
|
+
return html23`
|
|
3650
|
+
${this.renderLabel()}
|
|
3651
|
+
<div part="base">${this.renderInput()}</div>
|
|
3652
|
+
${this.renderHint()}${this.renderErrorText()}
|
|
3653
|
+
`;
|
|
3654
|
+
}
|
|
3655
|
+
renderInput() {
|
|
3656
|
+
return html23`
|
|
3657
|
+
<div class="text-input" style=${`--size: ${this.size + 1}`}>
|
|
3658
|
+
<input
|
|
3659
|
+
part="search"
|
|
3660
|
+
type="search"
|
|
3661
|
+
placeholder=${this.placeholder}
|
|
3662
|
+
@input=${this.handleInput}
|
|
3663
|
+
/>
|
|
3664
|
+
${this.renderContents()}
|
|
3665
|
+
</div>
|
|
3666
|
+
`;
|
|
3667
|
+
}
|
|
3668
|
+
renderContents() {
|
|
3669
|
+
if ((this.hasFocus || !this.hasSelection) && !this.noMatch) {
|
|
3670
|
+
return html23`<slot
|
|
3671
|
+
part="options"
|
|
3672
|
+
@slotchange=${this.handleSlotChange}
|
|
3673
|
+
></slot>`;
|
|
3674
|
+
} else if (this.noMatch) {
|
|
3675
|
+
return html23`<span part="empty-options">${this.noResultsText}</span>`;
|
|
3676
|
+
}
|
|
3677
|
+
return this.renderSelectedOptions();
|
|
3678
|
+
}
|
|
3679
|
+
renderSelectedOptions() {
|
|
3680
|
+
const options = this.getSelectedOptions();
|
|
3681
|
+
return repeat4(
|
|
3682
|
+
options,
|
|
3683
|
+
(option) => option.value,
|
|
3684
|
+
(option) => this.renderOption(option)
|
|
3685
|
+
);
|
|
3686
|
+
}
|
|
3687
|
+
renderOption(option) {
|
|
3688
|
+
return html23`
|
|
3689
|
+
<yatl-option
|
|
3690
|
+
value=${option.value}
|
|
3691
|
+
label=${option.label}
|
|
3692
|
+
checkable
|
|
3693
|
+
@click=${this.handleSelectedOptionClick}
|
|
3694
|
+
>
|
|
3695
|
+
<yatl-icon
|
|
3696
|
+
part="selected-trash-icon"
|
|
3697
|
+
slot="end"
|
|
3698
|
+
name="trash"
|
|
3699
|
+
></yatl-icon>
|
|
3700
|
+
</yatl-option>
|
|
3701
|
+
`;
|
|
3702
|
+
}
|
|
3703
|
+
handleInput(event) {
|
|
3704
|
+
event.stopPropagation();
|
|
3705
|
+
const query5 = event.target.value.toLocaleLowerCase();
|
|
3706
|
+
this.updateVisibleOptions(query5);
|
|
3707
|
+
}
|
|
3708
|
+
handleSlotChange() {
|
|
3709
|
+
this.updateSelectedOptions();
|
|
3710
|
+
}
|
|
3711
|
+
handleSelectedOptionClick(event) {
|
|
3712
|
+
event.stopPropagation();
|
|
3713
|
+
const target = event.currentTarget;
|
|
3714
|
+
this.toggleOption(target.value, false);
|
|
3715
|
+
target.remove();
|
|
3716
|
+
this.dispatchChange();
|
|
3717
|
+
}
|
|
3718
|
+
updateVisibleOptions(query5) {
|
|
3719
|
+
let noMatch = query5 ? true : false;
|
|
3720
|
+
for (const option of this.getAllOptions()) {
|
|
3721
|
+
if (!query5) {
|
|
3722
|
+
option.hidden = false;
|
|
3723
|
+
continue;
|
|
3724
|
+
}
|
|
3725
|
+
const text = option.label.toLocaleLowerCase();
|
|
3726
|
+
const match = text?.includes(query5) ?? false;
|
|
3727
|
+
option.hidden = !match;
|
|
3728
|
+
if (match) {
|
|
3729
|
+
noMatch = false;
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
this.noMatch = noMatch;
|
|
3733
|
+
}
|
|
3734
|
+
updateSelectedOptions() {
|
|
3735
|
+
for (const option of this.getAllOptions()) {
|
|
3736
|
+
option.checkable = true;
|
|
3737
|
+
option.checked = this.value.includes(option.value);
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
getSelectedOptions() {
|
|
3741
|
+
const options = this.getAllOptions().filter((o) => o.checked);
|
|
3742
|
+
const optionMap = new Map(options.map((o) => [o.value, o]));
|
|
3743
|
+
return this.value.map((v) => optionMap.get(v)).filter((o) => o !== void 0);
|
|
3744
|
+
}
|
|
3745
|
+
getAllOptions(includeDisabled = false) {
|
|
3746
|
+
const options = [...this.querySelectorAll(":not([slot])")];
|
|
3747
|
+
return includeDisabled ? options : options.filter((o) => !o.disabled);
|
|
3748
|
+
}
|
|
3749
|
+
dispatchChange() {
|
|
3750
|
+
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
|
3751
|
+
}
|
|
3752
|
+
};
|
|
3753
|
+
YatlSearchSelect.styles = [...__superGet(YatlSearchSelect, YatlSearchSelect, "styles"), search_select_styles_default];
|
|
3754
|
+
YatlSearchSelect.shadowRootOptions = {
|
|
3755
|
+
...LitElement3.shadowRootOptions,
|
|
3756
|
+
// We have to use manual focus delegation for this one
|
|
3757
|
+
// or else when the user tries to clear a selection option
|
|
3758
|
+
// it sends focus to the input and shows all the options.
|
|
3759
|
+
delegatesFocus: false
|
|
3760
|
+
};
|
|
3761
|
+
__decorateClass([
|
|
3762
|
+
state3()
|
|
3763
|
+
], YatlSearchSelect.prototype, "noMatch", 2);
|
|
3764
|
+
__decorateClass([
|
|
3765
|
+
state3()
|
|
3766
|
+
], YatlSearchSelect.prototype, "hasFocus", 2);
|
|
3767
|
+
__decorateClass([
|
|
3768
|
+
property20({ type: String })
|
|
3769
|
+
], YatlSearchSelect.prototype, "placeholder", 2);
|
|
3770
|
+
__decorateClass([
|
|
3771
|
+
property20({ type: String, attribute: "no-results-text" })
|
|
3772
|
+
], YatlSearchSelect.prototype, "noResultsText", 2);
|
|
3773
|
+
__decorateClass([
|
|
3774
|
+
property20({ type: Boolean, attribute: "match-width" })
|
|
3775
|
+
], YatlSearchSelect.prototype, "matchWidth", 2);
|
|
3776
|
+
__decorateClass([
|
|
3777
|
+
property20({ type: Number, reflect: true })
|
|
3778
|
+
], YatlSearchSelect.prototype, "size", 2);
|
|
3779
|
+
__decorateClass([
|
|
3780
|
+
property20({ type: Array, attribute: "value" })
|
|
3781
|
+
], YatlSearchSelect.prototype, "defaultValue", 2);
|
|
3782
|
+
__decorateClass([
|
|
3783
|
+
property20({ attribute: false })
|
|
3784
|
+
], YatlSearchSelect.prototype, "value", 1);
|
|
3785
|
+
YatlSearchSelect = __decorateClass([
|
|
3786
|
+
customElement22("yatl-search-select")
|
|
3787
|
+
], YatlSearchSelect);
|
|
3788
|
+
|
|
3789
|
+
// src/components/form-controls/select/select.ts
|
|
3790
|
+
import { html as html24, nothing as nothing8 } from "lit";
|
|
3791
|
+
import { customElement as customElement23, property as property21 } from "lit/decorators.js";
|
|
3792
|
+
import { repeat as repeat5 } from "lit/directives/repeat.js";
|
|
3793
|
+
|
|
3794
|
+
// src/components/form-controls/select/select.styles.ts
|
|
3795
|
+
import { css as css25 } from "lit";
|
|
3796
|
+
var select_styles_default = css25`
|
|
3797
|
+
:host {
|
|
3798
|
+
--select-arrow-color: var(--yatl-select-arrow-color, var(--yatl-text-3));
|
|
3799
|
+
--select-arrow-hover-color: var(
|
|
3800
|
+
--yatl-select-arrow-hover-color,
|
|
3801
|
+
var(--yatl-text-1)
|
|
3802
|
+
);
|
|
3803
|
+
--select-clear-color: var(--yatl-select-clear-color, var(--yatl-text-3));
|
|
3804
|
+
--select-clear-hover-color: var(
|
|
3805
|
+
--yatl-select-clear-hover-color,
|
|
3806
|
+
var(--yatl-text-1)
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
.text-input {
|
|
3811
|
+
display: flex;
|
|
3812
|
+
flex-direction: column;
|
|
3813
|
+
align-items: flex-start;
|
|
3814
|
+
position: relative;
|
|
3815
|
+
padding: 0 var(--input-padding);
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
[part='input'] {
|
|
3819
|
+
width: 100%;
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
.input-row {
|
|
3823
|
+
display: flex;
|
|
3824
|
+
flex-direction: row;
|
|
3825
|
+
align-items: center;
|
|
3826
|
+
width: 100%;
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
[part='tags'] {
|
|
3830
|
+
display: flex;
|
|
3831
|
+
flex-direction: row;
|
|
3832
|
+
gap: var(--yatl-spacing-xs);
|
|
3833
|
+
flex-wrap: wrap;
|
|
3834
|
+
margin-left: calc(var(--yatl-spacing-s) * -1);
|
|
3835
|
+
flex-grow: 1;
|
|
3836
|
+
padding: var(--yatl-spacing-xs) 0;
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
:host(:not([multi])) [part='tags'] {
|
|
3840
|
+
display: none;
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3843
|
+
[part='clear-icon'],
|
|
3844
|
+
[part='arrow-icon'] {
|
|
3845
|
+
display: inline-flex;
|
|
3846
|
+
align-items: center;
|
|
3847
|
+
justify-content: center;
|
|
3848
|
+
width: 1.15rem;
|
|
3849
|
+
height: 1.15rem;
|
|
3850
|
+
background-color: inherit;
|
|
3851
|
+
margin-left: var(--yatl-spacing-xs);
|
|
3852
|
+
z-index: 1;
|
|
3853
|
+
flex-shrink: 0;
|
|
3854
|
+
}
|
|
3855
|
+
|
|
3856
|
+
yatl-button[part='clear-icon'] {
|
|
3857
|
+
border: none;
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3860
|
+
yatl-button[part='clear-icon']::part(base) {
|
|
3861
|
+
appearance: none;
|
|
3862
|
+
background: none;
|
|
3863
|
+
border: none;
|
|
3864
|
+
margin: 0;
|
|
3865
|
+
padding: 0;
|
|
3866
|
+
color: var(--select-clear-color);
|
|
3867
|
+
margin-right: var(--yatl-spacing-xs);
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
[part='arrow-icon'] {
|
|
3871
|
+
transition: transform 0.2s ease-in-out;
|
|
3872
|
+
pointer-events: none;
|
|
3873
|
+
color: var(--select-arrow-color);
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
:host(:hover) [part='arrow-icon'] {
|
|
3877
|
+
color: var(--select-arrow-hover-color);
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
[part='clear-icon']:hover ~ [part='arrow-icon'] {
|
|
3881
|
+
color: var(--select-arrow-color, gray);
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
[part='clear-icon']:hover {
|
|
3885
|
+
color: var(--select-clear-hover-color);
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3888
|
+
:host(:state(open)) [part='arrow-icon'],
|
|
3889
|
+
:host([open]) [part='arrow-icon'] {
|
|
3890
|
+
transform: rotate(-180deg);
|
|
3891
|
+
}
|
|
3892
|
+
`;
|
|
3893
|
+
|
|
3894
|
+
// src/components/form-controls/select/select.ts
|
|
3895
|
+
var YatlSelect = class extends YatlFormControl {
|
|
3896
|
+
constructor() {
|
|
3897
|
+
super(...arguments);
|
|
3898
|
+
this.placeholder = "";
|
|
3899
|
+
this.multi = false;
|
|
3900
|
+
this.maxTags = 3;
|
|
3901
|
+
this.defaultValue = [];
|
|
3902
|
+
this.open = false;
|
|
3903
|
+
this.clearable = false;
|
|
3904
|
+
// Mutable value types need to be copied
|
|
3905
|
+
// so the user's changes don't mess things up.
|
|
3906
|
+
this._value = [];
|
|
3907
|
+
}
|
|
3908
|
+
get value() {
|
|
3909
|
+
return [...this._value];
|
|
3910
|
+
}
|
|
3911
|
+
set value(value) {
|
|
3912
|
+
const oldValue = this._value;
|
|
3913
|
+
this._value = [...value];
|
|
3914
|
+
this.updateSelectedOptions();
|
|
3915
|
+
this.setFormValue(this.formValue);
|
|
3916
|
+
this.requestUpdate("value", oldValue);
|
|
3917
|
+
}
|
|
3918
|
+
get formValue() {
|
|
3919
|
+
const data = new FormData();
|
|
3920
|
+
for (const value of this.value) {
|
|
3921
|
+
data.append(this.name, value);
|
|
3922
|
+
}
|
|
3923
|
+
return data;
|
|
3924
|
+
}
|
|
3925
|
+
toggleOption(value, state6) {
|
|
3926
|
+
const newValue = new Set(this.multi ? this.value : []);
|
|
3927
|
+
if (state6 === void 0) {
|
|
3928
|
+
state6 = !this.value.includes(value);
|
|
3929
|
+
}
|
|
3930
|
+
if (state6) {
|
|
3931
|
+
newValue.add(value);
|
|
3932
|
+
} else {
|
|
3933
|
+
newValue.delete(value);
|
|
3934
|
+
}
|
|
3935
|
+
this.value = [...newValue];
|
|
3936
|
+
}
|
|
3937
|
+
render() {
|
|
3938
|
+
return html24`
|
|
3939
|
+
${this.renderLabel()}
|
|
3940
|
+
<div part="base">${this.renderInput()}</div>
|
|
3941
|
+
${this.renderHint()}${this.renderErrorText()}
|
|
3942
|
+
`;
|
|
3943
|
+
}
|
|
3944
|
+
renderInput() {
|
|
3945
|
+
return html24`
|
|
3946
|
+
<yatl-dropdown
|
|
3947
|
+
.open=${this.open}
|
|
3948
|
+
@yatl-dropdown-select=${this.handleDropdownSelect}
|
|
3949
|
+
@yatl-dropdown-open=${this.handleDropdownToggle}
|
|
3950
|
+
@yatl-dropdown-close=${this.handleDropdownToggle}
|
|
3951
|
+
>
|
|
3952
|
+
<div class="text-input" slot="trigger" tabindex="0">
|
|
3953
|
+
<div class="input-row">
|
|
3954
|
+
${this.renderDisplayValue()}${this.renderTags()}
|
|
3955
|
+
${this.renderClearIcon()} ${this.renderArrowIcon()}
|
|
3956
|
+
</div>
|
|
3957
|
+
</div>
|
|
3958
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
3959
|
+
</yatl-dropdown>
|
|
3960
|
+
`;
|
|
3961
|
+
}
|
|
3962
|
+
renderDisplayValue() {
|
|
3963
|
+
if (this.multi) {
|
|
3964
|
+
return nothing8;
|
|
3965
|
+
}
|
|
3966
|
+
const selectedOption = this.getSelectedOptions().at(0);
|
|
3967
|
+
const displayValue = selectedOption?.label;
|
|
3968
|
+
return html24`
|
|
3969
|
+
<span part="input">${displayValue ?? this.placeholder}</span>
|
|
3970
|
+
`;
|
|
3971
|
+
}
|
|
3972
|
+
renderTags() {
|
|
3973
|
+
if (!this.multi) {
|
|
3974
|
+
return nothing8;
|
|
3975
|
+
}
|
|
3976
|
+
let extraTag = nothing8;
|
|
3977
|
+
const selectedOptions = this.getSelectedOptions();
|
|
3978
|
+
if (selectedOptions.length > this.maxTags) {
|
|
3979
|
+
extraTag = html24`<yatl-tag
|
|
3980
|
+
>+${selectedOptions.length - this.maxTags}</yatl-tag
|
|
3981
|
+
>`;
|
|
3982
|
+
}
|
|
3983
|
+
return html24`
|
|
3984
|
+
<div part="tags">
|
|
3985
|
+
${repeat5(
|
|
3986
|
+
selectedOptions.slice(0, this.maxTags),
|
|
3987
|
+
(option) => option.value,
|
|
3988
|
+
(option) => this.renderTag(option)
|
|
3989
|
+
)}
|
|
3990
|
+
${extraTag}
|
|
3991
|
+
</div>
|
|
3992
|
+
`;
|
|
3993
|
+
}
|
|
3994
|
+
renderTag(option) {
|
|
3995
|
+
return html24`<yatl-tag
|
|
3996
|
+
dismissable
|
|
3997
|
+
@yatl-tag-dismiss=${(event) => this.handleTagDissmiss(option, event)}
|
|
3998
|
+
>${option.label}</yatl-tag
|
|
3999
|
+
>`;
|
|
4000
|
+
}
|
|
4001
|
+
renderClearIcon() {
|
|
4002
|
+
if (!this.clearable || this.value.length === 0) {
|
|
4003
|
+
return nothing8;
|
|
4004
|
+
}
|
|
4005
|
+
return html24`
|
|
4006
|
+
<yatl-button
|
|
4007
|
+
part="clear-icon"
|
|
4008
|
+
slot="end"
|
|
4009
|
+
@click=${this.handleClearButtonClick}
|
|
4010
|
+
>
|
|
4011
|
+
<yatl-icon name="close"></yatl-icon>
|
|
4012
|
+
</yatl-button>
|
|
4013
|
+
`;
|
|
4014
|
+
}
|
|
4015
|
+
renderArrowIcon() {
|
|
4016
|
+
return html24`
|
|
4017
|
+
<yatl-icon part="arrow-icon" name="chevron-down"></yatl-icon>
|
|
4018
|
+
`;
|
|
4019
|
+
}
|
|
4020
|
+
handleTagDissmiss(option, event) {
|
|
4021
|
+
event.target.remove();
|
|
4022
|
+
this.toggleOption(option.value, false);
|
|
4023
|
+
this.dispatchChange();
|
|
4024
|
+
}
|
|
4025
|
+
handleSlotChange() {
|
|
4026
|
+
this.updateSelectedOptions();
|
|
4027
|
+
}
|
|
4028
|
+
handleClearButtonClick(event) {
|
|
4029
|
+
event.stopPropagation();
|
|
4030
|
+
this.value = [];
|
|
4031
|
+
this.dispatchChange();
|
|
4032
|
+
}
|
|
4033
|
+
handleDropdownToggle(event) {
|
|
4034
|
+
const target = event.target;
|
|
4035
|
+
if (target.open) {
|
|
4036
|
+
this.states.add("open");
|
|
4037
|
+
} else {
|
|
4038
|
+
this.states.delete("open");
|
|
4039
|
+
}
|
|
4040
|
+
this.open = target.open;
|
|
4041
|
+
}
|
|
4042
|
+
handleDropdownSelect(event) {
|
|
4043
|
+
if (this.multi) {
|
|
4044
|
+
event.preventDefault();
|
|
4045
|
+
}
|
|
4046
|
+
const item = event.item;
|
|
4047
|
+
this.toggleOption(item.value, item.checked);
|
|
4048
|
+
this.dispatchChange();
|
|
4049
|
+
}
|
|
4050
|
+
updateSelectedOptions() {
|
|
4051
|
+
for (const option of this.getAllOptions()) {
|
|
4052
|
+
option.checkable = true;
|
|
4053
|
+
option.checked = this.value.includes(option.value);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
getSelectedOptions() {
|
|
4057
|
+
const options = this.getAllOptions().filter((o) => o.checked);
|
|
4058
|
+
const optionMap = new Map(options.map((o) => [o.value, o]));
|
|
4059
|
+
return this.value.map((v) => optionMap.get(v)).filter((o) => o !== void 0);
|
|
4060
|
+
}
|
|
4061
|
+
getAllOptions() {
|
|
4062
|
+
return [...this.querySelectorAll("yatl-option")];
|
|
4063
|
+
}
|
|
4064
|
+
dispatchChange() {
|
|
4065
|
+
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
|
|
4066
|
+
}
|
|
4067
|
+
};
|
|
4068
|
+
YatlSelect.styles = [...__superGet(YatlSelect, YatlSelect, "styles"), select_styles_default];
|
|
4069
|
+
__decorateClass([
|
|
4070
|
+
property21({ type: String })
|
|
4071
|
+
], YatlSelect.prototype, "placeholder", 2);
|
|
4072
|
+
__decorateClass([
|
|
4073
|
+
property21({ type: Boolean, reflect: true })
|
|
4074
|
+
], YatlSelect.prototype, "multi", 2);
|
|
4075
|
+
__decorateClass([
|
|
4076
|
+
property21({ type: Number, attribute: "max-tags" })
|
|
4077
|
+
], YatlSelect.prototype, "maxTags", 2);
|
|
4078
|
+
__decorateClass([
|
|
4079
|
+
property21({ type: Array, attribute: "value" })
|
|
4080
|
+
], YatlSelect.prototype, "defaultValue", 2);
|
|
4081
|
+
__decorateClass([
|
|
4082
|
+
property21({ type: Boolean, reflect: true })
|
|
4083
|
+
], YatlSelect.prototype, "open", 2);
|
|
4084
|
+
__decorateClass([
|
|
4085
|
+
property21({ type: Boolean, reflect: true })
|
|
4086
|
+
], YatlSelect.prototype, "clearable", 2);
|
|
4087
|
+
__decorateClass([
|
|
4088
|
+
property21({ attribute: false })
|
|
4089
|
+
], YatlSelect.prototype, "value", 1);
|
|
4090
|
+
YatlSelect = __decorateClass([
|
|
4091
|
+
customElement23("yatl-select")
|
|
4092
|
+
], YatlSelect);
|
|
4093
|
+
|
|
4094
|
+
// src/components/form-controls/switch/switch.ts
|
|
4095
|
+
import { html as html25 } from "lit";
|
|
4096
|
+
import { customElement as customElement24, property as property22, state as state4 } from "lit/decorators.js";
|
|
4097
|
+
import { live as live7 } from "lit/directives/live.js";
|
|
4098
|
+
|
|
4099
|
+
// src/components/form-controls/switch/switch.styles.ts
|
|
4100
|
+
import { css as css26 } from "lit";
|
|
4101
|
+
var switch_styles_default = css26`
|
|
4102
|
+
:host {
|
|
4103
|
+
--switch-color: var(--yatl-switch-color, var(--yatl-text-1));
|
|
4104
|
+
--switch-bg: var(--yatl-switch-bg, var(--yatl-surface-1));
|
|
4105
|
+
--switch-accent: var(--yatl-switch-accent, var(--yatl-color-brand));
|
|
4106
|
+
--switch-border-color: var(
|
|
4107
|
+
--yatl-switch-border-color,
|
|
4108
|
+
var(--yatl-border-color)
|
|
4109
|
+
);
|
|
4110
|
+
|
|
4111
|
+
--height: var(--yatl-switch-size, 1rem);
|
|
4112
|
+
--width: calc(var(--height) * 1.75);
|
|
4113
|
+
--thumb-size: 0.75em;
|
|
4114
|
+
|
|
4115
|
+
display: inline-flex;
|
|
4116
|
+
line-height: var(--yatl-switch-line-height, 1);
|
|
4117
|
+
cursor: pointer;
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
[part='base'] {
|
|
4121
|
+
position: relative;
|
|
4122
|
+
width: fit-content;
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
[part='label'] {
|
|
4126
|
+
position: relative;
|
|
4127
|
+
display: flex;
|
|
4128
|
+
align-items: center;
|
|
4129
|
+
font: inherit;
|
|
4130
|
+
color: var(--wa-form-control-value-color);
|
|
4131
|
+
vertical-align: middle;
|
|
4132
|
+
cursor: pointer;
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
.switch {
|
|
4136
|
+
flex: 0 0 auto;
|
|
4137
|
+
position: relative;
|
|
4138
|
+
display: flex;
|
|
4139
|
+
align-items: center;
|
|
4140
|
+
justify-content: center;
|
|
4141
|
+
width: var(--width);
|
|
4142
|
+
height: var(--height);
|
|
4143
|
+
background-color: var(--switch-bg);
|
|
4144
|
+
border: 1px solid var(--switch-border-color);
|
|
4145
|
+
border-radius: var(--height);
|
|
4146
|
+
transition-property: translate, background, border-color, box-shadow;
|
|
4147
|
+
transition-duration: 150ms;
|
|
4148
|
+
transition-timing-function: ease;
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
.switch .thumb {
|
|
4152
|
+
aspect-ratio: 1 / 1;
|
|
4153
|
+
width: var(--thumb-size);
|
|
4154
|
+
height: var(--thumb-size);
|
|
4155
|
+
background-color: var(--switch-border-color);
|
|
4156
|
+
border-radius: 50%;
|
|
4157
|
+
translate: calc((var(--width) - var(--height)) / -2);
|
|
4158
|
+
transition: inherit;
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
.input {
|
|
4162
|
+
position: absolute;
|
|
4163
|
+
opacity: 0;
|
|
4164
|
+
padding: 0;
|
|
4165
|
+
margin: 0;
|
|
4166
|
+
pointer-events: none;
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
label:not(.disabled) .input:focus-visible ~ .switch .thumb {
|
|
4170
|
+
outline: var(--wa-focus-ring);
|
|
4171
|
+
outline-offset: var(--wa-focus-ring-offset);
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
:host(:hover) .switch {
|
|
4175
|
+
border-color: var(--switch-accent);
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
:host(:state(checked)) .switch {
|
|
4179
|
+
background-color: var(--switch-accent);
|
|
4180
|
+
border-color: var(--switch-accent);
|
|
4181
|
+
}
|
|
4182
|
+
|
|
4183
|
+
:host(:state(checked)) .switch .thumb {
|
|
4184
|
+
background-color: var(--switch-bg);
|
|
4185
|
+
translate: calc((var(--width) - var(--height)) / 2);
|
|
4186
|
+
}
|
|
4187
|
+
|
|
4188
|
+
[part~='label'] {
|
|
4189
|
+
display: inline-block;
|
|
4190
|
+
line-height: var(--height);
|
|
4191
|
+
margin-inline-start: 0.5em;
|
|
4192
|
+
user-select: none;
|
|
4193
|
+
-webkit-user-select: none;
|
|
4194
|
+
}
|
|
4195
|
+
`;
|
|
4196
|
+
|
|
4197
|
+
// src/components/form-controls/switch/switch.ts
|
|
4198
|
+
var YatlSwitch = class extends YatlFormControl {
|
|
4199
|
+
constructor() {
|
|
4200
|
+
super();
|
|
4201
|
+
this._value = this.getAttribute("value") ?? "on";
|
|
4202
|
+
this.defaultChecked = this.hasAttribute("checked");
|
|
4203
|
+
this.alwaysInclude = false;
|
|
4204
|
+
this.inline = true;
|
|
4205
|
+
this._checked = this.hasAttribute("checked");
|
|
4206
|
+
this.handleClick = (event) => {
|
|
4207
|
+
const path = event.composedPath();
|
|
4208
|
+
if (!this.formControl || path.includes(this.formControl)) {
|
|
4209
|
+
return;
|
|
4210
|
+
}
|
|
4211
|
+
event.preventDefault();
|
|
4212
|
+
event.stopPropagation();
|
|
4213
|
+
this.formControl.click();
|
|
4214
|
+
};
|
|
4215
|
+
this.addEventListener("click", (event) => this.handleClick(event));
|
|
4216
|
+
}
|
|
4217
|
+
get value() {
|
|
4218
|
+
return this._value;
|
|
4219
|
+
}
|
|
4220
|
+
set value(value) {
|
|
4221
|
+
if (this._value === value) {
|
|
4222
|
+
return;
|
|
4223
|
+
}
|
|
4224
|
+
const oldValue = this._value;
|
|
4225
|
+
this._value = value;
|
|
4226
|
+
this.updateFormValue();
|
|
4227
|
+
this.requestUpdate("value", oldValue);
|
|
4228
|
+
}
|
|
4229
|
+
get defaultValue() {
|
|
4230
|
+
return this.value;
|
|
4231
|
+
}
|
|
4232
|
+
get uncheckedValue() {
|
|
4233
|
+
return this._uncheckedValue;
|
|
4234
|
+
}
|
|
4235
|
+
set uncheckedValue(value) {
|
|
4236
|
+
const oldValue = this.uncheckedValue;
|
|
4237
|
+
this._uncheckedValue = value;
|
|
4238
|
+
this.updateFormValue();
|
|
4239
|
+
this.requestUpdate("uncheckedValue", oldValue);
|
|
4240
|
+
}
|
|
4241
|
+
get checked() {
|
|
4242
|
+
return this._checked;
|
|
4243
|
+
}
|
|
4244
|
+
set checked(value) {
|
|
4245
|
+
this._checked = value;
|
|
4246
|
+
this.toggleState("checked", value);
|
|
4247
|
+
this.updateFormValue();
|
|
4248
|
+
}
|
|
4249
|
+
get formValue() {
|
|
4250
|
+
if (this._checked) {
|
|
4251
|
+
return this.value || "on";
|
|
4252
|
+
} else if (this.alwaysInclude) {
|
|
4253
|
+
return this.uncheckedValue ?? "off";
|
|
4254
|
+
}
|
|
4255
|
+
return null;
|
|
4256
|
+
}
|
|
4257
|
+
formResetCallback() {
|
|
4258
|
+
this.checked = this.defaultChecked;
|
|
4259
|
+
}
|
|
4260
|
+
connectedCallback() {
|
|
4261
|
+
super.connectedCallback();
|
|
4262
|
+
this.checked = this.defaultChecked;
|
|
4263
|
+
this.updateFormValue();
|
|
4264
|
+
}
|
|
4265
|
+
render() {
|
|
4266
|
+
return html25`
|
|
4267
|
+
<div part="base">${this.renderInput()}</div>
|
|
4268
|
+
${this.renderLabel()} ${this.renderHint()} ${this.renderErrorText()}
|
|
4269
|
+
`;
|
|
4270
|
+
}
|
|
4271
|
+
renderInput() {
|
|
4272
|
+
return html25`
|
|
4273
|
+
<input
|
|
4274
|
+
class="input"
|
|
4275
|
+
id=${this.inputId}
|
|
4276
|
+
name=${this.name}
|
|
4277
|
+
type="checkbox"
|
|
4278
|
+
value=${this.value}
|
|
4279
|
+
.checked=${live7(this.checked)}
|
|
4280
|
+
?readonly=${this.readonly}
|
|
4281
|
+
?disabled=${this.disabled}
|
|
4282
|
+
?required=${this.required}
|
|
4283
|
+
role="switch"
|
|
4284
|
+
/>
|
|
4285
|
+
<span part="control" class="switch">
|
|
4286
|
+
<span part="thumb" class="thumb"></span>
|
|
4287
|
+
</span>
|
|
4288
|
+
`;
|
|
4289
|
+
}
|
|
4290
|
+
updateFormValue() {
|
|
4291
|
+
this.setFormValue(this.formValue);
|
|
4292
|
+
}
|
|
4293
|
+
onValueChange(event) {
|
|
4294
|
+
this.checked = event.target.checked;
|
|
4295
|
+
}
|
|
4296
|
+
};
|
|
4297
|
+
YatlSwitch.styles = [...__superGet(YatlSwitch, YatlSwitch, "styles"), switch_styles_default];
|
|
4298
|
+
__decorateClass([
|
|
4299
|
+
property22({ type: String, reflect: true })
|
|
4300
|
+
], YatlSwitch.prototype, "value", 1);
|
|
4301
|
+
__decorateClass([
|
|
4302
|
+
property22({ type: String, attribute: "unchecked-value" })
|
|
4303
|
+
], YatlSwitch.prototype, "uncheckedValue", 1);
|
|
4304
|
+
__decorateClass([
|
|
4305
|
+
property22({ type: Boolean, attribute: "checked" })
|
|
4306
|
+
], YatlSwitch.prototype, "defaultChecked", 2);
|
|
4307
|
+
__decorateClass([
|
|
4308
|
+
property22({ type: Boolean, attribute: "always-include" })
|
|
4309
|
+
], YatlSwitch.prototype, "alwaysInclude", 2);
|
|
4310
|
+
__decorateClass([
|
|
4311
|
+
state4()
|
|
4312
|
+
], YatlSwitch.prototype, "_checked", 2);
|
|
4313
|
+
YatlSwitch = __decorateClass([
|
|
4314
|
+
customElement24("yatl-switch")
|
|
4315
|
+
], YatlSwitch);
|
|
4316
|
+
|
|
4317
|
+
// src/components/form-controls/typeahead/typeahead.ts
|
|
4318
|
+
import { html as html26, nothing as nothing9 } from "lit";
|
|
4319
|
+
import { customElement as customElement25, property as property23, state as state5 } from "lit/decorators.js";
|
|
4320
|
+
import { live as live8 } from "lit/directives/live.js";
|
|
4321
|
+
import { repeat as repeat6 } from "lit/directives/repeat.js";
|
|
4322
|
+
|
|
4323
|
+
// src/components/form-controls/typeahead/typeahead.styles.ts
|
|
4324
|
+
import { css as css27 } from "lit";
|
|
4325
|
+
var typeahead_styles_default = css27``;
|
|
4326
|
+
|
|
4327
|
+
// src/components/form-controls/typeahead/typeahead.ts
|
|
4328
|
+
var YatlTypeahead = class extends YatlFormControl {
|
|
4329
|
+
constructor() {
|
|
4330
|
+
super(...arguments);
|
|
4331
|
+
this._uri = "";
|
|
4332
|
+
this._minQueryLength = 3;
|
|
4333
|
+
this._searchParam = "search";
|
|
4334
|
+
this._debounceTimer = 0;
|
|
4335
|
+
this.loading = false;
|
|
4336
|
+
this.error = false;
|
|
4337
|
+
this.options = /* @__PURE__ */ new Set();
|
|
4338
|
+
this.open = false;
|
|
4339
|
+
this.placeholder = "";
|
|
4340
|
+
this.defaultValue = "";
|
|
4341
|
+
this.value = "";
|
|
4342
|
+
this.searchDebounce = 200;
|
|
4343
|
+
}
|
|
4344
|
+
get formValue() {
|
|
4345
|
+
return this.value;
|
|
4346
|
+
}
|
|
4347
|
+
get uri() {
|
|
4348
|
+
return this._uri;
|
|
4349
|
+
}
|
|
4350
|
+
set uri(uri) {
|
|
4351
|
+
if (this._uri === uri) {
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
const oldValue = this._uri;
|
|
4355
|
+
this._uri = uri;
|
|
4356
|
+
this.scheduleUpdate();
|
|
4357
|
+
this.requestUpdate("uri", oldValue);
|
|
4358
|
+
}
|
|
4359
|
+
get minQueryLength() {
|
|
4360
|
+
return this._minQueryLength;
|
|
4361
|
+
}
|
|
4362
|
+
set minQueryLength(value) {
|
|
4363
|
+
if (this._minQueryLength === value) {
|
|
4364
|
+
return;
|
|
4365
|
+
}
|
|
4366
|
+
const oldValue = this._minQueryLength;
|
|
4367
|
+
const wasSearching = this.canSearch;
|
|
4368
|
+
this._minQueryLength = value;
|
|
4369
|
+
if (!wasSearching && this.canSearch) {
|
|
4370
|
+
this.scheduleUpdate();
|
|
4371
|
+
}
|
|
4372
|
+
this.requestUpdate("minQueryLength", oldValue);
|
|
4373
|
+
}
|
|
4374
|
+
get searchParam() {
|
|
4375
|
+
return this._searchParam;
|
|
4376
|
+
}
|
|
4377
|
+
set searchParam(value) {
|
|
4378
|
+
if (this._searchParam === value) {
|
|
4379
|
+
return;
|
|
4380
|
+
}
|
|
4381
|
+
const oldValue = this._searchParam;
|
|
4382
|
+
this._searchParam = value;
|
|
4383
|
+
this.scheduleUpdate();
|
|
4384
|
+
this.requestUpdate("searchParam", oldValue);
|
|
4385
|
+
}
|
|
4386
|
+
get hasOptions() {
|
|
4387
|
+
return this.options.size > 0;
|
|
4388
|
+
}
|
|
4389
|
+
get canSearch() {
|
|
4390
|
+
return !!this.uri && this.value.length >= this.minQueryLength;
|
|
4391
|
+
}
|
|
4392
|
+
render() {
|
|
4393
|
+
return html26`
|
|
4394
|
+
${this.renderLabel()}
|
|
4395
|
+
<yatl-dropdown
|
|
4396
|
+
.open=${live8(this.open)}
|
|
4397
|
+
@yatl-dropdown-select=${this.handleDropdownSelect}
|
|
4398
|
+
@yatl-dropdown-open-request=${this.handleDropdownRequest}
|
|
4399
|
+
@yatl-dropdown-close-request=${this.handleDropdownRequest}
|
|
4400
|
+
@yatl-dropdown-close=${this.handleDropdownClose}
|
|
4401
|
+
>
|
|
4402
|
+
<div slot="trigger" part="base" class="text-input">
|
|
4403
|
+
<slot part="start" name="start"></slot>
|
|
4404
|
+
<input
|
|
4405
|
+
slot="trigger"
|
|
4406
|
+
part="input"
|
|
4407
|
+
id="input"
|
|
4408
|
+
name=${this.name}
|
|
4409
|
+
type="text"
|
|
4410
|
+
.value=${live8(this.value)}
|
|
4411
|
+
value=${this.defaultValue}
|
|
4412
|
+
placeholder=${this.placeholder}
|
|
4413
|
+
?readonly=${this.readonly}
|
|
4414
|
+
?disabled=${this.disabled}
|
|
4415
|
+
?required=${this.required}
|
|
4416
|
+
/>
|
|
4417
|
+
<slot part="end" name="end"></slot>
|
|
4418
|
+
</div>
|
|
4419
|
+
${this.renderDropdownContent()}
|
|
4420
|
+
</yatl-dropdown>
|
|
4421
|
+
${this.renderHint()} ${this.renderErrorText()}
|
|
4422
|
+
`;
|
|
4423
|
+
}
|
|
4424
|
+
renderInput() {
|
|
4425
|
+
}
|
|
4426
|
+
renderDropdownContent() {
|
|
4427
|
+
if (this.error) {
|
|
4428
|
+
return html26`<span class="message" part="error"
|
|
4429
|
+
>Failed to get results</span
|
|
4430
|
+
>`;
|
|
4431
|
+
}
|
|
4432
|
+
if (this.loading) {
|
|
4433
|
+
return html26`<span class="message" part="loading">Loading...</span>`;
|
|
4434
|
+
}
|
|
4435
|
+
if (this.canSearch && !this.hasOptions) {
|
|
4436
|
+
return html26`<span class="message" part="empty-options"
|
|
4437
|
+
>No results found...</span
|
|
4438
|
+
>`;
|
|
4439
|
+
}
|
|
4440
|
+
if (this.hasOptions) {
|
|
4441
|
+
return repeat6(this.options, (option) => this.renderOption(option));
|
|
4442
|
+
}
|
|
4443
|
+
return nothing9;
|
|
4444
|
+
}
|
|
4445
|
+
renderOption(option) {
|
|
4446
|
+
return html26`<yatl-option value=${option} label=${option}></yatl-option>`;
|
|
4447
|
+
}
|
|
4448
|
+
onValueChange(event) {
|
|
4449
|
+
if (event.type === "change") {
|
|
4450
|
+
return true;
|
|
4451
|
+
}
|
|
4452
|
+
const target = event.target;
|
|
4453
|
+
if (this.value !== target.value) {
|
|
4454
|
+
this.value = target.value;
|
|
4455
|
+
this.scheduleFetch();
|
|
4456
|
+
this.open = this.canSearch;
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
handleDropdownSelect(event) {
|
|
4460
|
+
this.value = event.item.value;
|
|
4461
|
+
}
|
|
4462
|
+
handleDropdownRequest(event) {
|
|
4463
|
+
event.preventDefault();
|
|
4464
|
+
}
|
|
4465
|
+
handleDropdownClose() {
|
|
4466
|
+
this.open = false;
|
|
4467
|
+
}
|
|
4468
|
+
scheduleFetch() {
|
|
4469
|
+
if (!this.canSearch) {
|
|
4470
|
+
return;
|
|
4471
|
+
}
|
|
4472
|
+
this.loading = true;
|
|
4473
|
+
clearTimeout(this._debounceTimer);
|
|
4474
|
+
this._debounceTimer = window.setTimeout(
|
|
4475
|
+
() => this.updateOptions(),
|
|
4476
|
+
this.searchDebounce
|
|
4477
|
+
);
|
|
4478
|
+
}
|
|
4479
|
+
async updateOptions() {
|
|
4480
|
+
if (!this.canSearch) {
|
|
4481
|
+
return;
|
|
4482
|
+
}
|
|
4483
|
+
let url;
|
|
4484
|
+
try {
|
|
4485
|
+
url = new URL(this.uri);
|
|
4486
|
+
} catch {
|
|
4487
|
+
url = new URL(this.uri, window.location.toString());
|
|
4488
|
+
}
|
|
4489
|
+
let json;
|
|
4490
|
+
url.searchParams.set(this.searchParam, this.value);
|
|
4491
|
+
try {
|
|
4492
|
+
const response = await fetch(url);
|
|
4493
|
+
if (!response.ok) {
|
|
4494
|
+
this.error = true;
|
|
4495
|
+
return;
|
|
4496
|
+
}
|
|
4497
|
+
json = await response.json();
|
|
4498
|
+
} catch {
|
|
4499
|
+
this.error = true;
|
|
4500
|
+
return;
|
|
4501
|
+
} finally {
|
|
4502
|
+
this.loading = false;
|
|
4503
|
+
}
|
|
4504
|
+
let options;
|
|
4505
|
+
if (this.parser) {
|
|
4506
|
+
options = this.parser(json);
|
|
4507
|
+
} else if (Array.isArray(json)) {
|
|
4508
|
+
options = json.map((o) => String(o));
|
|
4509
|
+
} else {
|
|
4510
|
+
options = [String(json)];
|
|
4511
|
+
}
|
|
4512
|
+
this.options = new Set(options);
|
|
4513
|
+
}
|
|
4514
|
+
};
|
|
4515
|
+
YatlTypeahead.styles = [...__superGet(YatlTypeahead, YatlTypeahead, "styles"), typeahead_styles_default];
|
|
4516
|
+
__decorateClass([
|
|
4517
|
+
state5()
|
|
4518
|
+
], YatlTypeahead.prototype, "loading", 2);
|
|
4519
|
+
__decorateClass([
|
|
4520
|
+
state5()
|
|
4521
|
+
], YatlTypeahead.prototype, "error", 2);
|
|
4522
|
+
__decorateClass([
|
|
4523
|
+
state5()
|
|
4524
|
+
], YatlTypeahead.prototype, "options", 2);
|
|
4525
|
+
__decorateClass([
|
|
4526
|
+
state5()
|
|
4527
|
+
], YatlTypeahead.prototype, "open", 2);
|
|
4528
|
+
__decorateClass([
|
|
4529
|
+
property23({ type: String })
|
|
4530
|
+
], YatlTypeahead.prototype, "placeholder", 2);
|
|
4531
|
+
__decorateClass([
|
|
4532
|
+
property23({ type: String, attribute: "value" })
|
|
4533
|
+
], YatlTypeahead.prototype, "defaultValue", 2);
|
|
4534
|
+
__decorateClass([
|
|
4535
|
+
property23({ attribute: false })
|
|
4536
|
+
], YatlTypeahead.prototype, "value", 2);
|
|
4537
|
+
__decorateClass([
|
|
4538
|
+
property23({ type: String })
|
|
4539
|
+
], YatlTypeahead.prototype, "uri", 1);
|
|
4540
|
+
__decorateClass([
|
|
4541
|
+
property23({ type: Number, attribute: "min-query-length" })
|
|
4542
|
+
], YatlTypeahead.prototype, "minQueryLength", 1);
|
|
4543
|
+
__decorateClass([
|
|
4544
|
+
property23({ type: String, attribute: "search-param" })
|
|
4545
|
+
], YatlTypeahead.prototype, "searchParam", 1);
|
|
4546
|
+
__decorateClass([
|
|
4547
|
+
property23({ type: Number, attribute: "search-debounce" })
|
|
4548
|
+
], YatlTypeahead.prototype, "searchDebounce", 2);
|
|
4549
|
+
__decorateClass([
|
|
4550
|
+
property23({ attribute: false })
|
|
4551
|
+
], YatlTypeahead.prototype, "parser", 2);
|
|
4552
|
+
YatlTypeahead = __decorateClass([
|
|
4553
|
+
customElement25("yatl-typeahead")
|
|
4554
|
+
], YatlTypeahead);
|
|
4555
|
+
|
|
4556
|
+
// src/index.ts
|
|
4557
|
+
import { html as html27, noChange, nothing as nothing10, svg as svg2 } from "lit";
|
|
4558
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
4559
|
+
export {
|
|
4560
|
+
HasSlotController,
|
|
4561
|
+
YatlBaseFilter,
|
|
4562
|
+
YatlButton,
|
|
4563
|
+
YatlButtonGroup,
|
|
4564
|
+
YatlCard,
|
|
4565
|
+
YatlCheckbox,
|
|
4566
|
+
YatlConfirmationDialog,
|
|
4567
|
+
YatlDateFilter,
|
|
4568
|
+
YatlDateInput,
|
|
4569
|
+
YatlDialog,
|
|
4570
|
+
YatlDropdown,
|
|
4571
|
+
YatlFormControl,
|
|
4572
|
+
YatlIcon,
|
|
4573
|
+
YatlInput,
|
|
4574
|
+
YatlNumberInput,
|
|
4575
|
+
YatlOption,
|
|
4576
|
+
YatlRadio,
|
|
4577
|
+
YatlRadioGroup,
|
|
4578
|
+
YatlSearchFilter,
|
|
4579
|
+
YatlSearchSelect,
|
|
4580
|
+
YatlSelect,
|
|
4581
|
+
YatlSelectFilter,
|
|
4582
|
+
YatlSwitch,
|
|
4583
|
+
YatlTableUi,
|
|
4584
|
+
YatlTableView,
|
|
4585
|
+
YatlTag,
|
|
4586
|
+
YatlToolbar,
|
|
4587
|
+
YatlTypeahead,
|
|
4588
|
+
activeElements,
|
|
4589
|
+
animateWithClass,
|
|
4590
|
+
dateConverter,
|
|
4591
|
+
getEffectiveChildren,
|
|
4592
|
+
getInnerHTML,
|
|
4593
|
+
html27 as html,
|
|
4594
|
+
noChange,
|
|
4595
|
+
nothing10 as nothing,
|
|
4596
|
+
svg2 as svg,
|
|
4597
|
+
unsafeHTML
|
|
4598
|
+
};
|
|
4599
|
+
//# sourceMappingURL=index.mjs.map
|