@stackific/md3 0.1.0 → 0.1.2

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.
Files changed (113) hide show
  1. package/README.md +1 -43
  2. package/dist/md3.css +1 -1
  3. package/dist/md3.js +1 -621
  4. package/package.json +2 -5
  5. package/src/main.js +0 -5
  6. package/src/runtime/elements/dialogs.js +0 -72
  7. package/src/runtime/elements/fields.js +0 -181
  8. package/src/runtime/elements/menus.js +0 -42
  9. package/src/runtime/elements/pages.js +0 -7
  10. package/src/runtime/elements/progress.js +0 -35
  11. package/src/runtime/elements/sliders.js +0 -78
  12. package/src/runtime/elements/snackbars.js +0 -27
  13. package/src/runtime/helpers/ripples.js +0 -46
  14. package/src/runtime/md3.js +0 -141
  15. package/src/runtime/palette.js +0 -64
  16. package/src/runtime/settings/theme.js +0 -194
  17. package/src/runtime/utils.js +0 -165
  18. package/src/styles/_config.scss +0 -142
  19. package/src/styles/_mixins.scss +0 -80
  20. package/src/styles/elements/_badges.scss +0 -65
  21. package/src/styles/elements/_bars.scss +0 -83
  22. package/src/styles/elements/_buttons.scss +0 -119
  23. package/src/styles/elements/_cards.scss +0 -32
  24. package/src/styles/elements/_chips.scss +0 -46
  25. package/src/styles/elements/_dialogs.scss +0 -143
  26. package/src/styles/elements/_dividers.scss +0 -46
  27. package/src/styles/elements/_expansions.scss +0 -19
  28. package/src/styles/elements/_fields.scss +0 -458
  29. package/src/styles/elements/_grids.scss +0 -35
  30. package/src/styles/elements/_icons.scss +0 -70
  31. package/src/styles/elements/_layouts.scss +0 -24
  32. package/src/styles/elements/_lists.scss +0 -76
  33. package/src/styles/elements/_main-layouts.scss +0 -45
  34. package/src/styles/elements/_media.scss +0 -104
  35. package/src/styles/elements/_menus.scss +0 -289
  36. package/src/styles/elements/_navigations.scss +0 -450
  37. package/src/styles/elements/_overlays.scss +0 -34
  38. package/src/styles/elements/_pages.scss +0 -28
  39. package/src/styles/elements/_progress.scss +0 -141
  40. package/src/styles/elements/_selections.scss +0 -248
  41. package/src/styles/elements/_shapes.scss +0 -151
  42. package/src/styles/elements/_sliders.scss +0 -336
  43. package/src/styles/elements/_snackbars.scss +0 -44
  44. package/src/styles/elements/_tables.scss +0 -67
  45. package/src/styles/elements/_tabs.scss +0 -49
  46. package/src/styles/elements/_tooltips.scss +0 -125
  47. package/src/styles/helpers/_alignments.scss +0 -29
  48. package/src/styles/helpers/_blurs.scss +0 -26
  49. package/src/styles/helpers/_colors.scss +0 -39
  50. package/src/styles/helpers/_directions.scss +0 -30
  51. package/src/styles/helpers/_elevates.scss +0 -20
  52. package/src/styles/helpers/_forms.scss +0 -76
  53. package/src/styles/helpers/_margins.scss +0 -39
  54. package/src/styles/helpers/_opacities.scss +0 -18
  55. package/src/styles/helpers/_paddings.scss +0 -35
  56. package/src/styles/helpers/_positions.scss +0 -44
  57. package/src/styles/helpers/_responsive.scss +0 -24
  58. package/src/styles/helpers/_ripples.scss +0 -40
  59. package/src/styles/helpers/_scrolls.scss +0 -7
  60. package/src/styles/helpers/_shadows.scss +0 -22
  61. package/src/styles/helpers/_sizes.scss +0 -34
  62. package/src/styles/helpers/_spaces.scss +0 -22
  63. package/src/styles/helpers/_typography.scss +0 -132
  64. package/src/styles/helpers/_waves.scss +0 -52
  65. package/src/styles/helpers/_zoom.scss +0 -18
  66. package/src/styles/md3.scss +0 -61
  67. package/src/styles/settings/_fonts.scss +0 -42
  68. package/src/styles/settings/_globals.scss +0 -104
  69. package/src/styles/settings/_reset.scss +0 -82
  70. package/src/styles/settings/_theme.scss +0 -126
  71. package/src/styles/settings/_themes.scss +0 -1525
  72. /package/dist/{shapes → assets}/arch.svg +0 -0
  73. /package/dist/{shapes → assets}/arrow.svg +0 -0
  74. /package/dist/{shapes → assets}/boom.svg +0 -0
  75. /package/dist/{shapes → assets}/bun.svg +0 -0
  76. /package/dist/{shapes → assets}/burst.svg +0 -0
  77. /package/dist/{shapes → assets}/circle.svg +0 -0
  78. /package/dist/{shapes → assets}/clamshell.svg +0 -0
  79. /package/dist/{shapes → assets}/diamond.svg +0 -0
  80. /package/dist/{shapes → assets}/fan.svg +0 -0
  81. /package/dist/{shapes → assets}/flower.svg +0 -0
  82. /package/dist/{shapes → assets}/gem.svg +0 -0
  83. /package/dist/{shapes → assets}/ghost-ish.svg +0 -0
  84. /package/dist/{shapes → assets}/heart.svg +0 -0
  85. /package/dist/{shapes → assets}/leaf-clover4.svg +0 -0
  86. /package/dist/{shapes → assets}/leaf-clover8.svg +0 -0
  87. /package/dist/{shapes → assets}/loading-indicator.svg +0 -0
  88. /package/dist/{fonts → assets}/material-symbols-outlined.woff2 +0 -0
  89. /package/dist/{fonts → assets}/material-symbols-rounded.woff2 +0 -0
  90. /package/dist/{fonts → assets}/material-symbols-sharp.woff2 +0 -0
  91. /package/dist/{fonts → assets}/material-symbols-subset.woff2 +0 -0
  92. /package/dist/{shapes → assets}/oval.svg +0 -0
  93. /package/dist/{shapes → assets}/pentagon.svg +0 -0
  94. /package/dist/{shapes → assets}/pill.svg +0 -0
  95. /package/dist/{shapes → assets}/pixel-circle.svg +0 -0
  96. /package/dist/{shapes → assets}/pixel-triangle.svg +0 -0
  97. /package/dist/{shapes → assets}/puffy-diamond.svg +0 -0
  98. /package/dist/{shapes → assets}/puffy.svg +0 -0
  99. /package/dist/{shapes → assets}/semicircle.svg +0 -0
  100. /package/dist/{shapes → assets}/sided-cookie12.svg +0 -0
  101. /package/dist/{shapes → assets}/sided-cookie4.svg +0 -0
  102. /package/dist/{shapes → assets}/sided-cookie6.svg +0 -0
  103. /package/dist/{shapes → assets}/sided-cookie7.svg +0 -0
  104. /package/dist/{shapes → assets}/sided-cookie9.svg +0 -0
  105. /package/dist/{shapes → assets}/slanted.svg +0 -0
  106. /package/dist/{shapes → assets}/soft-boom.svg +0 -0
  107. /package/dist/{shapes → assets}/soft-burst.svg +0 -0
  108. /package/dist/{shapes → assets}/square.svg +0 -0
  109. /package/dist/{shapes → assets}/sunny.svg +0 -0
  110. /package/dist/{shapes → assets}/triangle.svg +0 -0
  111. /package/dist/{shapes → assets}/very-sunny.svg +0 -0
  112. /package/dist/{shapes → assets}/wavy-circle.svg +0 -0
  113. /package/dist/{shapes → assets}/wavy.svg +0 -0
@@ -1,72 +0,0 @@
1
- import {
2
- addClass, next, prev, hasTag, insertBefore, wait, create,
3
- hasClass, removeClass, on, off, queryAllDataUi, blurActiveElement, query, onWeak,
4
- } from "../utils.js";
5
-
6
- const _dialogs = [];
7
-
8
- function onKeydownDialog(e) {
9
- if (e.key === "Escape") {
10
- const dialog = e.currentTarget;
11
- void updateDialog(dialog, dialog);
12
- }
13
- }
14
-
15
- function focusOnDialogOrElement(dialog) {
16
- const element = query("[autofocus]", dialog) ?? dialog;
17
- element.focus();
18
- }
19
-
20
- function closeDialog(dialog, overlay) {
21
- removeClass(queryAllDataUi(dialog.id), "active");
22
- removeClass(dialog, "active");
23
- removeClass(overlay, "active");
24
-
25
- dialog.close();
26
- _dialogs.pop();
27
-
28
- const previousDialog = _dialogs[_dialogs.length - 1];
29
- if (previousDialog) previousDialog.focus();
30
- }
31
-
32
- async function openDialog(dialog, overlay, isModal, from) {
33
- if (!hasTag(from, "button") && !hasClass(from, "button") && !hasClass(from, "chip")) addClass(from, "active");
34
- addClass(overlay, "active");
35
- addClass(dialog, "active");
36
-
37
- if (isModal) dialog.showModal();
38
- else dialog.show();
39
-
40
- await wait(90);
41
-
42
- if (!isModal) on(dialog, "keydown", onKeydownDialog, false);
43
- _dialogs.push(dialog);
44
- focusOnDialogOrElement(dialog);
45
- }
46
-
47
- function onClickOverlay(e) {
48
- const overlay = e.currentTarget;
49
- const dialog = next(overlay);
50
- if (hasTag(dialog, "dialog")) closeDialog(dialog, overlay);
51
- }
52
-
53
- export async function updateDialog(from, dialog) {
54
- blurActiveElement();
55
-
56
- let overlay = prev(dialog);
57
- const isActive = hasClass(dialog, "active") || dialog.open;
58
- const isModal = hasClass(dialog, "modal");
59
-
60
- if (!isModal) off(dialog, "keydown", onKeydownDialog, false);
61
-
62
- if (!hasClass(overlay, "overlay")) {
63
- overlay = create({ class: "overlay" });
64
- insertBefore(overlay, dialog);
65
- await wait(90);
66
- }
67
-
68
- if (!isModal) onWeak(overlay, "click", onClickOverlay, false);
69
-
70
- if (isActive) closeDialog(dialog, overlay);
71
- else void openDialog(dialog, overlay, isModal, from);
72
- }
@@ -1,181 +0,0 @@
1
- import {
2
- query, next, prev, hasType, parent, queryAll, onWeak,
3
- isChrome, isMac, isIOS, rootSizeInPixels,
4
- } from "../utils.js";
5
-
6
- function updatePlaceholder(element) {
7
- if (!element.placeholder) element.placeholder = " ";
8
- }
9
-
10
- function onClickLabel(e) {
11
- const label = e.currentTarget;
12
- const field = parent(label);
13
- const input = query("input:not([type=file], [type=checkbox], [type=radio]), select, textarea", field);
14
- if (input) input.focus();
15
- }
16
-
17
- function onFocusInput(e) {
18
- updateInput(e.currentTarget);
19
- }
20
-
21
- function onBlurInput(e) {
22
- updateInput(e.currentTarget);
23
- }
24
-
25
- function onChangeFile(e) {
26
- updateFile(e.currentTarget);
27
- }
28
-
29
- function onChangeColor(e) {
30
- updateColor(e.currentTarget);
31
- }
32
-
33
- function onKeydownFile(e) {
34
- updateFile(e.currentTarget, e);
35
- }
36
-
37
- function onKeydownColor(e) {
38
- updateColor(e.currentTarget, e);
39
- }
40
-
41
- function onPasswordIconClick(e) {
42
- const icon = e.currentTarget;
43
- const input = query("input", parent(icon));
44
- if (input && icon.textContent?.includes("visibility")) {
45
- if (input.type === "password") {
46
- input.type = "text";
47
- icon.textContent = "visibility_off";
48
- } else {
49
- input.type = "password";
50
- icon.textContent = "visibility";
51
- }
52
- }
53
- }
54
-
55
- function onInputTextarea(e) {
56
- updateTextarea(e.currentTarget);
57
- }
58
-
59
- function onClickLabelDelegation(e) {
60
- const from = e.target.closest(".field > label");
61
- if (!from) return;
62
-
63
- Object.defineProperty(e, "currentTarget", { value: from, configurable: true });
64
- onClickLabel(e);
65
- }
66
-
67
- function updateAllLabels() {
68
- const body = document.body;
69
- if (!body) return;
70
-
71
- onWeak(body, "click", onClickLabelDelegation);
72
- }
73
-
74
- function updateAllInputs() {
75
- const inputs = queryAll(".field > input:not([type=file], [type=color], [type=range])");
76
- for (let i = 0; i < inputs.length; i++) {
77
- onWeak(inputs[i], "focus", onFocusInput);
78
- onWeak(inputs[i], "blur", onBlurInput);
79
- updateInput(inputs[i]);
80
- }
81
- }
82
-
83
- function updateAllSelects() {
84
- const selects = queryAll(".field > select");
85
- for (let i = 0; i < selects.length; i++) {
86
- onWeak(selects[i], "focus", onFocusInput);
87
- onWeak(selects[i], "blur", onBlurInput);
88
- }
89
- }
90
-
91
- function updateAllFiles() {
92
- const files = queryAll(".field > input[type=file]");
93
- for (let i = 0; i < files.length; i++) {
94
- onWeak(files[i], "change", onChangeFile);
95
- updateFile(files[i]);
96
- }
97
- }
98
-
99
- function updateAllColors() {
100
- const colors = queryAll(".field > input[type=color]");
101
- for (let i = 0; i < colors.length; i++) {
102
- onWeak(colors[i], "change", onChangeColor);
103
- updateColor(colors[i]);
104
- }
105
- }
106
-
107
- function updateAllTextareas() {
108
- const textareas = queryAll(".field > textarea");
109
- for (let i = 0; i < textareas.length; i++) {
110
- onWeak(textareas[i], "focus", onFocusInput);
111
- onWeak(textareas[i], "blur", onBlurInput);
112
- updatePlaceholder(textareas[i]);
113
-
114
- if (isChrome && !isMac && !isIOS) continue;
115
-
116
- onWeak(textareas[i], "input", onInputTextarea);
117
- updateTextarea(textareas[i]);
118
- }
119
- }
120
-
121
- function updateAllPasswordIcons() {
122
- const icons = queryAll(".field:has(> input[type=password]) > i, a");
123
- for (let i = 0; i < icons.length; i++) onWeak(icons[i], "click", onPasswordIconClick);
124
- }
125
-
126
- function updateInput(input) {
127
- if (hasType(input, "number") && !input.value) input.value = "";
128
- updatePlaceholder(input);
129
- }
130
-
131
- function updateFile(input, e) {
132
- if (e?.key === "Enter") {
133
- const previousInput = prev(input);
134
- if (!hasType(previousInput, "file")) return;
135
- previousInput.click();
136
- return;
137
- }
138
-
139
- const nextInput = next(input);
140
- if (!hasType(nextInput, "text")) return;
141
- nextInput.value = input.files ? Array.from(input.files).map((x) => x.name).join(", ") : "";
142
- nextInput.readOnly = true;
143
- onWeak(nextInput, "keydown", onKeydownFile, false);
144
- updateInput(nextInput);
145
- }
146
-
147
- function updateColor(input, e) {
148
- if (e?.key === "Enter") {
149
- const previousInput = prev(input);
150
- if (!hasType(previousInput, "color")) return;
151
- previousInput.click();
152
- return;
153
- }
154
-
155
- const nextInput = next(input);
156
- if (!hasType(nextInput, "text")) return;
157
- nextInput.readOnly = true;
158
- nextInput.value = input.value;
159
- onWeak(nextInput, "keydown", onKeydownColor, false);
160
- updateInput(nextInput);
161
- }
162
-
163
- function updateTextarea(textarea) {
164
- updatePlaceholder(textarea);
165
-
166
- if (textarea.hasAttribute("rows")) return;
167
-
168
- const rootSize = rootSizeInPixels();
169
- textarea.style.blockSize = "auto";
170
- textarea.style.blockSize = `${textarea.scrollHeight - rootSize}px`;
171
- }
172
-
173
- export function updateAllFields() {
174
- updateAllLabels();
175
- updateAllInputs();
176
- updateAllSelects();
177
- updateAllFiles();
178
- updateAllColors();
179
- updateAllTextareas();
180
- updateAllPasswordIcons();
181
- }
@@ -1,42 +0,0 @@
1
- import {
2
- query, queryAll, addClass, on, off, hasTag, hasClass, removeClass, blurActiveElement,
3
- } from "../utils.js";
4
-
5
- let _timeoutMenu;
6
-
7
- function onClickDocument(e) {
8
- off(document.body, "click", onClickDocument);
9
- const body = e.target;
10
- const menus = queryAll("menu.active");
11
- for (let i = 0; i < menus.length; i++) updateMenu(body, menus[i], e);
12
- }
13
-
14
- function focusOnMenuOrInput(menu) {
15
- setTimeout(() => {
16
- const input = query(".field > input", menu);
17
- if (input) input.focus();
18
- else menu.focus();
19
- }, 90);
20
- }
21
-
22
- export function updateMenu(from, menu, e) {
23
- if (_timeoutMenu) clearTimeout(_timeoutMenu);
24
-
25
- _timeoutMenu = setTimeout(() => {
26
- on(document.body, "click", onClickDocument);
27
- if (!hasTag(document.activeElement, "input")) blurActiveElement();
28
-
29
- const isActive = hasClass(menu, "active");
30
- const isEvent = e?.target === from;
31
- const isChild = !!from.closest("menu");
32
-
33
- if ((!isActive && isChild) || (isActive && isEvent)) {
34
- removeClass(menu, "active");
35
- return;
36
- }
37
-
38
- removeClass(queryAll("menu.active"), "active");
39
- addClass(menu, "active");
40
- focusOnMenuOrInput(menu);
41
- }, 90);
42
- }
@@ -1,7 +0,0 @@
1
- import { addClass, parent, removeClass, queryAll } from "../utils.js";
2
-
3
- export function updatePage(page) {
4
- const container = parent(page);
5
- if (container) removeClass(queryAll(":scope > .page", container), "active");
6
- addClass(page, "active");
7
- }
@@ -1,35 +0,0 @@
1
- import { queryAll, hasTag, off, on, isMac, isIOS, isChrome, hasClass } from "../utils.js";
2
-
3
- function onInputDocument(e) {
4
- const progress = e.target;
5
-
6
- if (hasTag(progress, "progress")) {
7
- updateProgress(progress);
8
- } else {
9
- updateAllProgress();
10
- }
11
- }
12
-
13
- function updateProgress(progress) {
14
- requestAnimationFrame(() => {
15
- if (!progress.hasAttribute("value") && !progress.hasAttribute("max")) {
16
- const value = hasClass(progress, "circle") ? "50" : "100";
17
- progress.style.setProperty("--_value", value);
18
- progress.setAttribute("value", value);
19
- progress.setAttribute("max", "100");
20
- progress.classList.add("indeterminate");
21
- } else {
22
- progress.style.setProperty("--_value", String(progress.value));
23
- }
24
- });
25
- }
26
-
27
- export function updateAllProgress() {
28
- if (isChrome && !isMac && !isIOS) return;
29
-
30
- const body = document.body;
31
- const progresses = queryAll("progress");
32
- if (!progresses.length) off(body, "input", onInputDocument, false);
33
- else on(body, "input", onInputDocument, false);
34
- for (let i = 0; i < progresses.length; i++) updateProgress(progresses[i]);
35
- }
@@ -1,78 +0,0 @@
1
- import {
2
- query, queryAll, hasClass, on, off, parent, hasTag, onWeak, rootSizeInPixels,
3
- } from "../utils.js";
4
-
5
- function onInputDocument(e) {
6
- const input = e.target;
7
- if (!hasTag(input, "input") && !hasTag(input, "select")) return;
8
-
9
- if (input.type === "range") {
10
- input.focus();
11
- updateRange(input);
12
- } else {
13
- updateAllRanges();
14
- }
15
- }
16
-
17
- function onChangeInput(e) {
18
- const isCoarse = window.matchMedia("(pointer: coarse)").matches;
19
- if (!isCoarse) return;
20
-
21
- const input = e.target;
22
- input.blur();
23
- }
24
-
25
- function updateAllRanges() {
26
- const body = document.body;
27
- const ranges = queryAll(".slider > input[type=range]");
28
- if (!ranges.length) off(body, "input", onInputDocument, false);
29
- else on(body, "input", onInputDocument, false);
30
- for (let i = 0; i < ranges.length; i++) updateRange(ranges[i]);
31
- }
32
-
33
- function updateRange(input) {
34
- onWeak(input, "change", onChangeInput);
35
-
36
- const label = parent(input);
37
- const bar = query("span", label);
38
- const inputs = queryAll("input", label);
39
- if (!inputs.length || !bar) return;
40
-
41
- const rootSize = rootSizeInPixels();
42
- const thumb = hasClass(label, "max") ? 0 : (0.25 * rootSize * 100) / inputs[0].offsetWidth;
43
- const percents = [];
44
- const values = [];
45
- for (let i = 0, n = inputs.length; i < n; i++) {
46
- const min = parseFloat(inputs[i].min) || 0;
47
- const max = parseFloat(inputs[i].max) || 100;
48
- const value = parseFloat(inputs[i].value) || 0;
49
- const percent = ((value - min) * 100) / (max - min);
50
- const fix = thumb / 2 - (thumb * percent) / 100;
51
- percents.push(percent + fix);
52
- values.push(value);
53
- }
54
-
55
- let percent = percents[0];
56
- let start = 0;
57
- let end = 100 - start - percent;
58
- let value1 = values[0];
59
- let value2 = values[1] || 0;
60
- if (inputs.length > 1) {
61
- percent = Math.abs(percents[1] - percents[0]);
62
- start = percents[1] > percents[0] ? percents[0] : percents[1];
63
- end = 100 - start - percent;
64
-
65
- if (value2 > value1) {
66
- value1 = values[1] || 0;
67
- value2 = values[0];
68
- }
69
- }
70
-
71
- requestAnimationFrame(() => {
72
- label.style.cssText = `--_start: ${start}%; --_end: ${end}%; --_value1: '${value1}'; --_value2: '${value2}';`;
73
- });
74
- }
75
-
76
- export function updateAllSliders() {
77
- updateAllRanges();
78
- }
@@ -1,27 +0,0 @@
1
- import { queryAll, addClass, removeClass, blurActiveElement, onWeak } from "../utils.js";
2
-
3
- let _timeoutSnackbar;
4
-
5
- function onClickSnackbar(e) {
6
- const snackbar = e.currentTarget;
7
- removeClass(snackbar, "active");
8
-
9
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
10
- }
11
-
12
- export function updateSnackbar(snackbar, milliseconds) {
13
- blurActiveElement();
14
-
15
- const activeSnackbars = queryAll(".snackbar.active");
16
- for (let i = 0; i < activeSnackbars.length; i++) removeClass(activeSnackbars[i], "active");
17
- addClass(snackbar, "active");
18
- onWeak(snackbar, "click", onClickSnackbar);
19
-
20
- if (_timeoutSnackbar) clearTimeout(_timeoutSnackbar);
21
-
22
- if (milliseconds === -1) return;
23
-
24
- _timeoutSnackbar = setTimeout(() => {
25
- removeClass(snackbar, "active");
26
- }, milliseconds ?? 6000);
27
- }
@@ -1,46 +0,0 @@
1
- import { onWeak } from "../utils.js";
2
-
3
- function updateRipple(e) {
4
- const isMouseEvent = e instanceof MouseEvent;
5
- const element = e.currentTarget;
6
- const rect = element.getBoundingClientRect();
7
- const diameter = Math.max(rect.width, rect.height);
8
- const radius = diameter / 2;
9
- const x = isMouseEvent ? e.clientX - rect.left - radius : (rect.width / 2) - radius;
10
- const y = isMouseEvent ? e.clientY - rect.top - radius : (rect.height / 2) - radius;
11
- const rippleContainer = document.createElement("div");
12
- rippleContainer.className = "ripple-js";
13
-
14
- const ripple = document.createElement("div");
15
- ripple.style.inlineSize = ripple.style.blockSize = `${diameter}px`;
16
- ripple.style.left = `${x}px`;
17
- ripple.style.top = `${y}px`;
18
- onWeak(ripple, "animationend", () => { rippleContainer.remove(); });
19
-
20
- rippleContainer.appendChild(ripple);
21
- element.appendChild(rippleContainer);
22
- }
23
-
24
- function onMousedownRippleDelegation(e) {
25
- const from = e.target.closest(".slow-ripple, .ripple, .fast-ripple");
26
- if (!from) return;
27
-
28
- Object.defineProperty(e, "currentTarget", { value: from, configurable: true });
29
- updateRipple(e);
30
- }
31
-
32
- function onKeydownRippleDelegation(e) {
33
- const from = e.target.closest(".slow-ripple, .ripple, .fast-ripple");
34
- if (!from || e.key !== " ") return;
35
-
36
- Object.defineProperty(e, "currentTarget", { value: from, configurable: true });
37
- updateRipple(e);
38
- }
39
-
40
- export function updateAllRipples() {
41
- const body = document.body;
42
- if (!body) return;
43
-
44
- onWeak(body, "mousedown", onMousedownRippleDelegation);
45
- onWeak(body, "keydown", onKeydownRippleDelegation);
46
- }
@@ -1,141 +0,0 @@
1
- import { updateAllFields } from "./elements/fields.js";
2
- import { updateAllSliders } from "./elements/sliders.js";
3
- import {
4
- attachAutoListener,
5
- getThemes,
6
- readStoredMode,
7
- readStoredTheme,
8
- updateMode,
9
- updateTheme,
10
- } from "./settings/theme.js";
11
- import {
12
- addClass, guid, hasClass, hasTag, onWeak, query, removeClass, updateAllClickable,
13
- } from "./utils.js";
14
- import { updateDialog } from "./elements/dialogs.js";
15
- import { updateMenu } from "./elements/menus.js";
16
- import { updateSnackbar } from "./elements/snackbars.js";
17
- import { updatePage } from "./elements/pages.js";
18
- import { updateAllRipples } from "./helpers/ripples.js";
19
- import { updateAllProgress } from "./elements/progress.js";
20
-
21
- let _timeoutMutation;
22
- let _mutation = null;
23
-
24
- function onMutation() {
25
- if (_timeoutMutation) clearTimeout(_timeoutMutation);
26
- _timeoutMutation = setTimeout(() => _ui(), 180);
27
- }
28
-
29
- async function run(from, to, options, e) {
30
- if (!to) {
31
- to = query(from.getAttribute("data-ui"));
32
- if (!to) {
33
- from.classList.toggle("active");
34
- return;
35
- }
36
- }
37
-
38
- updateAllClickable(from);
39
-
40
- if (hasTag(to, "dialog")) {
41
- requestAnimationFrame(() => updateDialog(from, to));
42
- return;
43
- }
44
-
45
- if (hasTag(to, "menu")) {
46
- requestAnimationFrame(() => updateMenu(from, to, e));
47
- return;
48
- }
49
-
50
- if (hasClass(to, "snackbar")) {
51
- requestAnimationFrame(() => updateSnackbar(to, options));
52
- return;
53
- }
54
-
55
- if (hasClass(to, "page")) {
56
- requestAnimationFrame(() => updatePage(to));
57
- return;
58
- }
59
-
60
- if (hasClass(to, "active")) {
61
- removeClass(from, "active");
62
- removeClass(to, "active");
63
- return;
64
- }
65
-
66
- addClass(to, "active");
67
- }
68
-
69
- function setup() {
70
- if (globalThis.ui || _mutation || !globalThis.MutationObserver) return;
71
- _mutation = new MutationObserver(onMutation);
72
- _mutation.observe(document.body, { childList: true, subtree: true });
73
- onMutation();
74
- }
75
-
76
- function onClickDataUi(e) {
77
- const from = e.target.closest("[data-ui]");
78
- if (from) void run(from, null, null, e);
79
- }
80
-
81
- function onKeydownDataUi(e) {
82
- const from = e.target.closest("[data-ui]");
83
- if (from && hasTag(from, "a") && !from.getAttribute("href") && e.key === "Enter") {
84
- void run(from, null, null, e);
85
- }
86
- }
87
-
88
- function updateAllDataUis() {
89
- const body = document.body;
90
- if (!body) return;
91
-
92
- onWeak(body, "click", onClickDataUi);
93
- onWeak(body, "keydown", onKeydownDataUi);
94
- }
95
-
96
- function _ui(selector, options) {
97
- if (selector) {
98
- if (selector === "setup") { setup(); return undefined; }
99
- if (selector === "guid") return guid();
100
- if (selector === "mode") return updateMode(options);
101
- if (selector === "theme") return updateTheme(options);
102
- if (selector === "themes") return getThemes();
103
-
104
- const to = query(selector);
105
- if (!to) return undefined;
106
- void run(to, to, options);
107
- }
108
-
109
- updateAllDataUis();
110
- updateAllFields();
111
- updateAllRipples();
112
- updateAllSliders();
113
- updateAllProgress();
114
- return undefined;
115
- }
116
-
117
- function start() {
118
- if (globalThis.ui) return;
119
-
120
- // Stored preference wins over the HTML default — the user's last choice
121
- // outranks `<html data-mode="…">` hardcoded in markup. If neither is set,
122
- // default to "auto" so the OS theme drives.
123
- const root = globalThis.document?.documentElement;
124
- if (root) {
125
- updateMode(readStoredMode() || root.dataset.mode || "auto");
126
- // Theme persistence: stored choice beats the HTML default, same as mode.
127
- // If neither is set, leave data-theme alone — bare :root carries the
128
- // implicit default (first theme in $themes).
129
- const storedTheme = readStoredTheme();
130
- if (storedTheme) updateTheme(storedTheme);
131
- }
132
- attachAutoListener();
133
-
134
- setup();
135
- globalThis.ui = _ui;
136
- }
137
-
138
- start();
139
-
140
- export const ui = globalThis.ui;
141
- export default ui;
@@ -1,64 +0,0 @@
1
- // Generated by scripts/build-palette.mjs from
2
- // src/styles/_config.scss ($material-palette)
3
- // src/styles/settings/_themes.scss ($themes)
4
- // DO NOT EDIT — re-run `pnpm build` (or `node scripts/build-palette.mjs`).
5
-
6
- export const palette = {
7
- "red": "#F44336",
8
- "pink": "#E91E63",
9
- "purple": "#9C27B0",
10
- "deep-purple": "#673AB7",
11
- "blue": "#2196F3",
12
- "light-blue": "#03A9F4",
13
- "cyan": "#00BCD4",
14
- "green": "#4CAF50",
15
- "light-green": "#8BC34A",
16
- "lime": "#CDDC39",
17
- "yellow": "#FFEB3B",
18
- "amber": "#FFC107",
19
- "orange": "#FF9800",
20
- "deep-orange": "#FF5722",
21
- "brown": "#795548",
22
- "blue-grey": "#607D8B",
23
- "stackific": "#1447E6",
24
- "hello-pumpkin": "#FF8F00",
25
- "sea-lettuce": "#63A002",
26
- "olive": "#7C7C67",
27
- "nord": "#5E81AC",
28
- "vega-violet": "#AD46FF",
29
- "wild-strawberry": "#F6339A",
30
- "heliotrope-magenta": "#E12AFB",
31
- "voodoo-violet": "#804792",
32
- "red-orchid": "#C0001C",
33
- "green-brown": "#6E5D00",
34
- "shakshuka": "#AB350F",
35
- "purple-honeycreeper": "#8E51FF",
36
- "maldives": "#00B8DB",
37
- "verditer": "#00BBA7",
38
- "fennel": "#00BC7D",
39
- "gold": "#EFB100",
40
- "vitamin-c": "#FD9A00",
41
- "burtuqali": "#FF6900",
42
- };
43
-
44
- export const themes = [
45
- "stackific",
46
- "hello-pumpkin",
47
- "sea-lettuce",
48
- "olive",
49
- "nord",
50
- "vega-violet",
51
- "wild-strawberry",
52
- "heliotrope-magenta",
53
- "voodoo-violet",
54
- "red-orchid",
55
- "green-brown",
56
- "shakshuka",
57
- "purple-honeycreeper",
58
- "maldives",
59
- "verditer",
60
- "fennel",
61
- "gold",
62
- "vitamin-c",
63
- "burtuqali",
64
- ];