fullstacked 0.12.2-1414 → 0.12.2-1419

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.
@@ -1,669 +0,0 @@
1
- // node_modules/@fullstacked/ui/primitives/icon/index.ts
2
- var iconsDirectory = "/node_modules/@fullstacked/ui/icons";
3
- function setIconsDirectory(directory) {
4
- iconsDirectory = directory;
5
- }
6
- function Icon(name) {
7
- const container = document.createElement("div");
8
- container.classList.add("icon");
9
- loadIcon(name).then((svgData) => container.innerHTML = svgData);
10
- return container;
11
- }
12
- var iconCache = /* @__PURE__ */ new Map();
13
- function loadIcon(name) {
14
- let icon = iconCache.get(name);
15
- if (!icon) {
16
- icon = fetchIcon(name);
17
- iconCache.set(name, icon);
18
- }
19
- return icon;
20
- }
21
- async function fetchIcon(name) {
22
- const response = await fetch(`${iconsDirectory}/${name}.svg`);
23
- return response.text();
24
- }
25
-
26
- // node_modules/@fullstacked/ui/primitives/button/index.ts
27
- function Button(opts) {
28
- const button = document.createElement("button");
29
- if (!opts?.style?.startsWith("icon")) {
30
- button.innerText = opts?.text || "";
31
- }
32
- if (opts?.style && opts?.style !== "default") {
33
- button.classList.add(opts.style);
34
- }
35
- if (opts?.color) {
36
- button.classList.add(opts.color);
37
- }
38
- if (opts?.iconLeft) {
39
- button.prepend(Icon(opts.iconLeft));
40
- }
41
- if (opts?.iconRight) {
42
- button.append(Icon(opts.iconRight));
43
- }
44
- return button;
45
- }
46
-
47
- // node_modules/@fullstacked/ui/primitives/badge/index.ts
48
- function Badge(opts) {
49
- const container = document.createElement("label");
50
- container.classList.add("badge");
51
- if (opts?.type) {
52
- container.classList.add(opts.type);
53
- }
54
- container.innerText = opts?.text || "";
55
- return container;
56
- }
57
-
58
- // node_modules/@fullstacked/ui/inputs/text/index.ts
59
- function InputText(opts) {
60
- const container = document.createElement("div");
61
- container.classList.add("input-text");
62
- if (opts?.label) {
63
- container.innerHTML = `<label>${opts.label}</label>`;
64
- }
65
- const inputContainer = document.createElement("div");
66
- inputContainer.classList.add("input-container");
67
- const input = document.createElement("input");
68
- input.autocapitalize = "off";
69
- inputContainer.append(input);
70
- if (opts?.clear) {
71
- const buttonContainer = document.createElement("div");
72
- buttonContainer.classList.add("button-container");
73
- const clearButton = Button({
74
- style: "icon-small",
75
- iconRight: "Close"
76
- });
77
- clearButton.type = "button";
78
- clearButton.onclick = (e) => {
79
- input.value = "";
80
- buttonContainer.classList.remove("show");
81
- input.dispatchEvent(new KeyboardEvent("keyup"));
82
- };
83
- buttonContainer.append(clearButton);
84
- inputContainer.append(buttonContainer);
85
- input.addEventListener("keyup", () => {
86
- if (input.value) {
87
- buttonContainer.classList.add("show");
88
- } else {
89
- buttonContainer.classList.remove("show");
90
- }
91
- });
92
- }
93
- container.append(inputContainer);
94
- return {
95
- container,
96
- input
97
- };
98
- }
99
-
100
- // node_modules/@fullstacked/ui/inputs/observer.ts
101
- var updateOverriddenInputs = () => {
102
- const inputsChecked = document.querySelectorAll(
103
- "input[type=checkbox], input[type=radio]"
104
- );
105
- inputsChecked.forEach((input) => {
106
- const parent = input.parentElement;
107
- if (input.checked) parent.classList.add("checked");
108
- else parent.classList.remove("checked");
109
- });
110
- const inputsFile = document.querySelectorAll("input[type=file]");
111
- inputsFile.forEach((inputFile) => {
112
- const file = inputFile.files[0];
113
- const fileName = inputFile.nextElementSibling?.children?.[0];
114
- if (!fileName) return;
115
- fileName.innerText = file?.name || "No file chosen";
116
- });
117
- const inputsSelect = document.querySelectorAll("select");
118
- inputsSelect.forEach((inputSelect) => {
119
- if (inputSelect.selectedIndex) {
120
- inputSelect.classList.remove("invalid");
121
- } else {
122
- inputSelect.classList.add("invalid");
123
- }
124
- });
125
- };
126
- var interval = null;
127
- function startObserverInterval() {
128
- if (interval) return;
129
- interval = setInterval(updateOverriddenInputs, 100);
130
- }
131
-
132
- // node_modules/@fullstacked/ui/inputs/file/index.ts
133
- function InputFile(opts) {
134
- startObserverInterval();
135
- const container = document.createElement("div");
136
- container.classList.add("input-file");
137
- if (opts?.label) {
138
- container.innerHTML = `<label>${opts.label}</label>`;
139
- }
140
- const input = document.createElement("input");
141
- input.type = "file";
142
- container.append(input);
143
- const overrideUI = document.createElement("div");
144
- const fileName = document.createElement("span");
145
- fileName.innerText = "No file chosen";
146
- input.addEventListener("change", () => {
147
- const file = input.files[0];
148
- fileName.innerText = file?.name || "No file chosen";
149
- });
150
- const button = Button({
151
- iconRight: "File",
152
- text: "Select"
153
- });
154
- button.onclick = (e) => {
155
- e.preventDefault();
156
- input.click();
157
- };
158
- overrideUI.append(fileName, button);
159
- container.append(overrideUI);
160
- return {
161
- container,
162
- input
163
- };
164
- }
165
-
166
- // node_modules/@fullstacked/ui/inputs/switch/index.ts
167
- function InputSwitch(opts) {
168
- startObserverInterval();
169
- const container = document.createElement("div");
170
- container.classList.add("input-switch");
171
- if (opts?.label) {
172
- container.innerHTML = `<label>${opts.label}</label>`;
173
- }
174
- const input = document.createElement("input");
175
- input.type = "checkbox";
176
- input.addEventListener("change", () => {
177
- if (input.checked) container.classList.add("checked");
178
- else container.classList.remove("checked");
179
- });
180
- container.append(input);
181
- const overrideUI = document.createElement("div");
182
- const switchEl = document.createElement("div");
183
- switchEl.onclick = () => input.click();
184
- switchEl.innerHTML = `<div></div>`;
185
- overrideUI.append(switchEl);
186
- container.append(overrideUI);
187
- return {
188
- input,
189
- container
190
- };
191
- }
192
-
193
- // node_modules/@fullstacked/ui/inputs/checkbox/index.ts
194
- function InputCheckbox() {
195
- startObserverInterval();
196
- const container = document.createElement("div");
197
- container.classList.add("input-checkbox");
198
- const input = document.createElement("input");
199
- input.type = "checkbox";
200
- input.addEventListener("change", () => {
201
- if (input.checked) container.classList.add("checked");
202
- else container.classList.remove("checked");
203
- });
204
- const overrideUI = document.createElement("div");
205
- overrideUI.onclick = () => input.click();
206
- overrideUI.innerHTML = "<div></div>";
207
- container.append(input, overrideUI);
208
- return {
209
- container,
210
- input
211
- };
212
- }
213
-
214
- // node_modules/@fullstacked/ui/inputs/radio/index.ts
215
- function InputRadio() {
216
- startObserverInterval();
217
- const container = document.createElement("div");
218
- container.classList.add("input-radio");
219
- const input = document.createElement("input");
220
- input.type = "radio";
221
- input.addEventListener("change", () => {
222
- if (input.checked) container.classList.add("checked");
223
- else container.classList.remove("checked");
224
- });
225
- const overrideUI = document.createElement("div");
226
- overrideUI.onclick = () => input.click();
227
- overrideUI.innerHTML = "<div></div>";
228
- container.append(input, overrideUI);
229
- return {
230
- container,
231
- input
232
- };
233
- }
234
-
235
- // node_modules/@fullstacked/ui/inputs/predictive/index.ts
236
- var SPACE = String.fromCharCode(160);
237
- function InputPredictive(opts) {
238
- const container = document.createElement("div");
239
- container.classList.add("input-predictive");
240
- if (opts?.label) {
241
- container.innerHTML = `<label>${opts.label}</label>`;
242
- }
243
- const input = document.createElement("div");
244
- input.contentEditable = "true";
245
- input.autocapitalize = "off";
246
- input.setAttribute("autocomplete", "off");
247
- input.setAttribute("autocorrect", "off");
248
- let prediction = document.createElement("span");
249
- prediction.contentEditable = "false";
250
- input.append(prediction);
251
- const spaceRegex = new RegExp(SPACE, "g");
252
- let predictions = [];
253
- let predictionIndex = 0;
254
- const prevPrediction = () => {
255
- if (predictionIndex === 0) {
256
- return;
257
- }
258
- predictionIndex -= 1;
259
- prediction.innerText = predictions.at(predictionIndex);
260
- };
261
- const nextPrediction = () => {
262
- if (predictionIndex === predictions.length - 1) {
263
- return;
264
- }
265
- predictionIndex += 1;
266
- prediction.innerText = predictions.at(predictionIndex);
267
- };
268
- const predict = async () => {
269
- Array.from(input.children).forEach((child) => {
270
- if (child.innerHTML === "" || child instanceof HTMLBRElement) {
271
- child.remove();
272
- }
273
- });
274
- if (prediction.getBoundingClientRect().height == 0) {
275
- input.append(prediction);
276
- }
277
- let value = input.innerText.replace(spaceRegex, " ");
278
- const prevP = prediction.innerText;
279
- if (prevP) {
280
- value = value.slice(0, 0 - prevP.length);
281
- }
282
- const onChangeResult = opts?.onChange?.(value);
283
- if (onChangeResult instanceof Promise) {
284
- predictions = await onChangeResult;
285
- } else {
286
- predictions = onChangeResult;
287
- }
288
- predictions = predictions.map((p) => p.replace(/ /g, SPACE));
289
- if (predictions.length) {
290
- predictionIndex = 0;
291
- prediction.innerText = predictions.at(predictionIndex);
292
- } else {
293
- prediction.innerText = "";
294
- }
295
- };
296
- const replaceCursor = () => {
297
- const range = document.createRange();
298
- const sel = window.getSelection();
299
- const textNodes = Array.from(input.childNodes || []).filter(
300
- (n) => n.nodeType === Node.TEXT_NODE
301
- );
302
- if (textNodes.length) {
303
- input.innerText = textNodes.map((n) => n.textContent).join("");
304
- range.setStart(input.childNodes[0], getValue().length);
305
- } else {
306
- range.setStart(input, 0);
307
- }
308
- range.collapse(true);
309
- sel.removeAllRanges();
310
- sel.addRange(range);
311
- };
312
- const getCursorPos = () => {
313
- const sel = window.getSelection();
314
- return sel.anchorOffset;
315
- };
316
- const applyPrediction = () => {
317
- const p = prediction?.innerText || "";
318
- if (p) {
319
- prediction.innerText = "";
320
- input.innerText += p;
321
- replaceCursor();
322
- }
323
- };
324
- prediction.onclick = () => {
325
- applyPrediction();
326
- };
327
- input.onpaste = () => {
328
- prediction.innerText = "";
329
- setTimeout(() => {
330
- input.innerText = input.innerText;
331
- predict();
332
- setTimeout(replaceCursor);
333
- });
334
- };
335
- input.onblur = () => {
336
- prediction.remove();
337
- };
338
- input.onfocus = () => {
339
- predict();
340
- let value = input.innerText;
341
- const prevP = prediction.innerText;
342
- if (prevP) {
343
- value = value.slice(0, 0 - prevP.length);
344
- }
345
- if (value) {
346
- setTimeout(replaceCursor);
347
- }
348
- };
349
- input.onkeyup = (e) => {
350
- const { key } = e;
351
- if (key === "ArrowUp" || key === "ArrowDown") {
352
- return;
353
- }
354
- predict();
355
- };
356
- input.onkeydown = (e) => {
357
- const { key } = e;
358
- if (key === "ArrowUp" || key === "ArrowDown") {
359
- e.preventDefault();
360
- return key === "ArrowUp" ? prevPrediction() : nextPrediction();
361
- }
362
- const prevP = prediction.innerText;
363
- if (e.key === "Tab") {
364
- e.preventDefault();
365
- if (prediction.innerText != "") {
366
- applyPrediction();
367
- } else if (input.innerText && input.innerText.at(-1) !== SPACE) {
368
- input.innerText += SPACE;
369
- replaceCursor();
370
- }
371
- } else if (e.key === "ArrowRight" && prediction.innerText && getCursorPos() === getValue().length) {
372
- e.preventDefault();
373
- applyPrediction();
374
- } else if (prevP && key == prevP.at(0)) {
375
- prediction.innerText = prediction.innerText.slice(1);
376
- } else {
377
- prediction.innerText = "";
378
- }
379
- };
380
- const getValue = () => {
381
- const clone = input.cloneNode(true);
382
- clone.querySelector("span")?.remove();
383
- return clone.innerText.replace(spaceRegex, " ");
384
- };
385
- container.append(input);
386
- return {
387
- container,
388
- input,
389
- getValue,
390
- clear: () => {
391
- input.innerText = "";
392
- replaceCursor();
393
- }
394
- };
395
- }
396
-
397
- // node_modules/@fullstacked/ui/inputs/select/index.ts
398
- function InputSelect(opts) {
399
- startObserverInterval();
400
- const container = document.createElement("div");
401
- container.classList.add("input-select");
402
- if (opts.label) {
403
- container.innerHTML = `<label>${opts.label}</label>`;
404
- }
405
- const selectAndIconContainer = document.createElement("div");
406
- selectAndIconContainer.classList.add("select-container");
407
- const select = document.createElement("select");
408
- const icon = document.createElement("div");
409
- icon.append(Icon("Arrow"));
410
- selectAndIconContainer.append(select, icon);
411
- container.append(selectAndIconContainer);
412
- const placeholderOption = document.createElement("option");
413
- placeholderOption.selected = true;
414
- placeholderOption.innerText = opts.placeholder || "Choose an option";
415
- select.append(placeholderOption);
416
- select.classList.add("invalid");
417
- const selectOptions = [];
418
- const addOptions = (option) => {
419
- selectOptions.push(option);
420
- const el = document.createElement("option");
421
- el.innerText = option.name;
422
- el.disabled = option.disabled;
423
- if (!el.disabled) {
424
- el.value = selectOptions.length.toString();
425
- }
426
- el.selected = option.selected;
427
- select.append(el);
428
- };
429
- const disablePlaceholder = () => {
430
- placeholderOption.disabled = true;
431
- };
432
- select.onfocus = disablePlaceholder;
433
- select.ontouchstart = disablePlaceholder;
434
- select.onclick = disablePlaceholder;
435
- select.onblur = () => {
436
- placeholderOption.disabled = false;
437
- };
438
- const indexOfIdOrName = (idOrName) => {
439
- return selectOptions.findIndex((item) => {
440
- if (item.id) {
441
- return item.id === idOrName;
442
- }
443
- return item.name === idOrName;
444
- });
445
- };
446
- let selectAPI = {
447
- get value() {
448
- const index = select.selectedIndex - 1;
449
- if (index === -1) {
450
- return void 0;
451
- }
452
- const item = selectOptions.at(index);
453
- return item.id || item.name;
454
- },
455
- set value(v) {
456
- const indexOf = indexOfIdOrName(v);
457
- if (indexOf === -1) return;
458
- select.selectedIndex = indexOf + 1;
459
- },
460
- onchange: (item, index) => {
461
- return { item, index };
462
- }
463
- };
464
- select.onchange = () => {
465
- const index = select.selectedIndex - 1;
466
- const item = selectOptions.at(index);
467
- const value = item.id || item.name;
468
- selectAPI.value = value;
469
- selectAPI.onchange(value, index);
470
- };
471
- return {
472
- container,
473
- select: selectAPI,
474
- options: {
475
- get() {
476
- return selectOptions;
477
- },
478
- add(...options) {
479
- options.forEach(addOptions);
480
- },
481
- remove(nameOrId) {
482
- const indexOf = indexOfIdOrName(nameOrId);
483
- if (indexOf === -1) return;
484
- const selectedIndex = select.selectedIndex - 1;
485
- if (indexOf === selectedIndex) {
486
- select.selectedIndex = 0;
487
- }
488
- selectOptions.splice(indexOf, 1);
489
- }
490
- }
491
- };
492
- }
493
-
494
- // node_modules/@fullstacked/ui/components/button-group/index.ts
495
- function ButtonGroup(buttons) {
496
- const container = document.createElement("div");
497
- container.classList.add("button-group");
498
- container.append(...buttons);
499
- return container;
500
- }
501
-
502
- // node_modules/@fullstacked/ui/components/dialog/index.ts
503
- function Dialog(content) {
504
- const container = document.createElement("div");
505
- container.classList.add("dialog");
506
- const overlay = document.createElement("div");
507
- overlay.classList.add("dialog-overlay");
508
- container.append(content);
509
- overlay.append(container);
510
- document.body.append(overlay);
511
- return {
512
- remove: () => overlay.remove()
513
- };
514
- }
515
-
516
- // node_modules/@fullstacked/ui/components/loader/index.ts
517
- function Loader() {
518
- const container = document.createElement("div");
519
- container.classList.add("loader");
520
- const dummy = document.createElement("div");
521
- container.append(dummy);
522
- const icon = Icon("Loader");
523
- container.append(icon);
524
- return container;
525
- }
526
-
527
- // node_modules/@fullstacked/ui/components/message/index.ts
528
- function Message(opts) {
529
- const container = document.createElement("div");
530
- container.classList.add("message");
531
- if (opts.style) {
532
- container.classList.add(opts.style);
533
- }
534
- const iconName = opts.style === "warning" ? "Warning" : "Info";
535
- const icon = Icon(iconName);
536
- const text = document.createElement("b");
537
- text.innerText = opts.text;
538
- container.append(icon, text);
539
- return container;
540
- }
541
-
542
- // node_modules/@fullstacked/ui/components/popover/index.ts
543
- function Popover(opts) {
544
- const anchorBB = opts.anchor.getBoundingClientRect();
545
- const container = document.createElement("div");
546
- container.classList.add("popover");
547
- let x = anchorBB.x + document.body.scrollLeft;
548
- let y = anchorBB.y + document.body.scrollTop;
549
- switch (opts.align.x) {
550
- case "center":
551
- container.classList.add("center-x");
552
- x += anchorBB.width / 2;
553
- break;
554
- case "right":
555
- container.classList.add("right");
556
- x += anchorBB.width;
557
- break;
558
- }
559
- switch (opts.align.y) {
560
- case "center":
561
- container.classList.add("center-y");
562
- y += anchorBB.height / 2;
563
- break;
564
- case "bottom":
565
- container.classList.add("bottom");
566
- y += anchorBB.height;
567
- break;
568
- }
569
- container.style.left = x + "px";
570
- container.style.top = y + "px";
571
- const overlay = document.createElement("div");
572
- overlay.classList.add("popover-overlay");
573
- container.append(opts.content);
574
- const remove = () => {
575
- overlay.remove();
576
- container.remove();
577
- window.removeEventListener("resize", remove);
578
- unlockScroll(lockedElements);
579
- };
580
- container.addEventListener("click", (e) => {
581
- e.stopPropagation();
582
- remove();
583
- });
584
- container.addEventListener("scroll", (e) => {
585
- e.stopPropagation();
586
- remove();
587
- });
588
- overlay.onclick = (e) => {
589
- e.stopPropagation();
590
- remove();
591
- };
592
- window.addEventListener("resize", remove);
593
- let lockedElements = lockScroll(opts.anchor);
594
- document.body.append(overlay, container);
595
- return {
596
- remove
597
- };
598
- }
599
- var lockedScroll = (e) => {
600
- e.preventDefault();
601
- e.stopPropagation();
602
- return false;
603
- };
604
- var keys = ["ArrowDown", "ArrowUp", "PageUp", "PageDown"];
605
- var lockedKeys = (e) => {
606
- if (keys.includes(e.key)) {
607
- return lockedScroll(e);
608
- }
609
- };
610
- function lockScroll(el, lockedElements = []) {
611
- lockedElements.push(el);
612
- el.addEventListener("scroll", lockedScroll);
613
- el.addEventListener("wheel", lockedScroll);
614
- el.addEventListener("touchmove", lockedScroll);
615
- el.addEventListener("keydown", lockedKeys);
616
- if (el.parentElement) {
617
- lockScroll(el.parentElement, lockedElements);
618
- }
619
- return lockedElements;
620
- }
621
- function unlockScroll(els) {
622
- els.forEach((el) => {
623
- el.removeEventListener("scroll", lockedScroll);
624
- el.removeEventListener("wheel", lockedScroll);
625
- el.removeEventListener("touchmove", lockedScroll);
626
- el.removeEventListener("keydown", lockedKeys);
627
- });
628
- }
629
-
630
- // node_modules/@fullstacked/ui/components/list-item/index.ts
631
- function ListItem(opts) {
632
- const container = document.createElement("div");
633
- container.classList.add("list-item");
634
- const inner = document.createElement("div");
635
- inner.classList.add("inner");
636
- container.append(inner);
637
- if (opts?.content) {
638
- inner.append(opts.content);
639
- }
640
- if (opts?.withProgress) {
641
- const progressBar = document.createElement("div");
642
- progressBar.classList.add("progress");
643
- container.append(progressBar);
644
- const setProgress = (p) => {
645
- progressBar.style.width = p * 100 + "%";
646
- };
647
- return { container, setProgress };
648
- }
649
- return container;
650
- }
651
- export {
652
- Badge,
653
- Button,
654
- ButtonGroup,
655
- Dialog,
656
- Icon,
657
- InputCheckbox,
658
- InputFile,
659
- InputPredictive,
660
- InputRadio,
661
- InputSelect,
662
- InputSwitch,
663
- InputText,
664
- ListItem,
665
- Loader,
666
- Message,
667
- Popover,
668
- setIconsDirectory
669
- };