m3-svelte 6.0.3 → 7.0.0

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 (59) hide show
  1. package/package/buttons/Button.svelte +39 -33
  2. package/package/buttons/Button.svelte.d.ts +7 -5
  3. package/package/buttons/ConnectedButtons.svelte +0 -6
  4. package/package/buttons/FAB.svelte +1 -4
  5. package/package/buttons/SplitButton.svelte +3 -6
  6. package/package/containers/Card.svelte +4 -6
  7. package/package/containers/ListItem.svelte +25 -20
  8. package/package/containers/ListItem.svelte.d.ts +7 -6
  9. package/package/containers/MenuItem.svelte +3 -4
  10. package/package/containers/Snackbar.svelte +2 -5
  11. package/package/etc/colors.d.ts +13 -0
  12. package/package/{misc → etc}/colors.js +36 -23
  13. package/package/etc/layer.css +38 -0
  14. package/package/etc/layer.d.ts +1 -0
  15. package/package/etc/layer.js +142 -0
  16. package/package/etc/recommended-styles.css +8 -0
  17. package/package/{misc → etc}/styles.css +75 -47
  18. package/package/{misc → etc}/tailwind-styles.css +0 -2
  19. package/package/etc/unocss-preset.d.ts +3 -0
  20. package/package/etc/unocss-preset.js +85 -0
  21. package/package/forms/Checkbox.svelte +1 -3
  22. package/package/forms/Chip.svelte +22 -14
  23. package/package/forms/Chip.svelte.d.ts +5 -2
  24. package/package/forms/DateField.svelte +9 -13
  25. package/package/forms/DateFieldOutlined.svelte +9 -13
  26. package/package/forms/RadioAnim1.svelte +1 -3
  27. package/package/forms/RadioAnim2.svelte +1 -3
  28. package/package/forms/RadioAnim3.svelte +1 -3
  29. package/package/forms/Select.svelte +4 -7
  30. package/package/forms/SelectOutlined.svelte +2 -5
  31. package/package/forms/Slider.svelte +1 -1
  32. package/package/forms/TextField.svelte +2 -5
  33. package/package/forms/TextFieldMultiline.svelte +2 -3
  34. package/package/forms/TextFieldOutlined.svelte +2 -5
  35. package/package/forms/TextFieldOutlinedMultiline.svelte +2 -3
  36. package/package/forms/_picker/FocusPicker.svelte +1 -4
  37. package/package/forms/_picker/Header.svelte +28 -33
  38. package/package/forms/_picker/Item.svelte +1 -12
  39. package/package/index.d.ts +3 -7
  40. package/package/index.js +3 -7
  41. package/package/misc/animation.js +5 -1
  42. package/package/misc/badge.js +1 -1
  43. package/package/misc/easing.js +4 -3
  44. package/package/misc/typing-utils.d.ts +14 -5
  45. package/package/nav/NavCMLXItem.svelte +7 -10
  46. package/package/nav/NavCMLXItem.svelte.d.ts +2 -2
  47. package/package/nav/Tabs.svelte +1 -4
  48. package/package/nav/TabsLink.svelte +7 -4
  49. package/package/nav/VariableTabs.svelte +1 -4
  50. package/package/nav/VariableTabsLink.svelte +1 -3
  51. package/package.json +38 -19
  52. package/package/buttons/TogglePrimitive.svelte +0 -22
  53. package/package/buttons/TogglePrimitive.svelte.d.ts +0 -11
  54. package/package/misc/Layer.svelte +0 -213
  55. package/package/misc/Layer.svelte.d.ts +0 -3
  56. package/package/misc/colors.d.ts +0 -4
  57. package/package/misc/recommended-styles.css +0 -41
  58. package/package/misc/utils.d.ts +0 -6
  59. package/package/misc/utils.js +0 -39
@@ -0,0 +1,142 @@
1
+ import "./layer.css";
2
+ const activePointerRipples = [];
3
+ const activeKeyboardRipples = [];
4
+ const isEnabled = (node) => {
5
+ if (node instanceof HTMLButtonElement && node.disabled)
6
+ return false;
7
+ if (node instanceof HTMLInputElement && node.disabled)
8
+ return false;
9
+ if (node instanceof HTMLLabelElement) {
10
+ const control = node.control;
11
+ if (control instanceof HTMLInputElement && control.disabled)
12
+ return false;
13
+ }
14
+ return true;
15
+ };
16
+ const createRippleSvg = (node, x, y, width, height) => {
17
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)
18
+ return null;
19
+ const size = Math.hypot(Math.max(x, width - x), Math.max(y, height - y)) * 2.5;
20
+ const speed = Math.max(Math.min(Math.log(size) * 50, 600), 200);
21
+ const gradient = document.createElementNS("http://www.w3.org/2000/svg", "radialGradient");
22
+ gradient.id = `ripple-${Date.now()}-${Math.random().toString(36).slice(2)}`;
23
+ const stops = [
24
+ { offset: "0%", opacity: "0.12" },
25
+ { offset: "70%", opacity: "0.12" },
26
+ { offset: "100%", opacity: "0" },
27
+ ];
28
+ for (const { offset, opacity } of stops) {
29
+ const stop = document.createElementNS("http://www.w3.org/2000/svg", "stop");
30
+ stop.setAttribute("offset", offset);
31
+ stop.setAttribute("stop-color", "currentColor");
32
+ stop.setAttribute("stop-opacity", opacity);
33
+ gradient.appendChild(stop);
34
+ }
35
+ const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
36
+ circle.setAttribute("cx", `${x}`);
37
+ circle.setAttribute("cy", `${y}`);
38
+ circle.setAttribute("r", "0");
39
+ circle.setAttribute("fill", `url(#${gradient.id})`);
40
+ const expand = document.createElementNS("http://www.w3.org/2000/svg", "animate");
41
+ expand.setAttribute("attributeName", "r");
42
+ expand.setAttribute("from", "0");
43
+ expand.setAttribute("to", `${size / 2}`);
44
+ expand.setAttribute("dur", `${speed}ms`);
45
+ expand.setAttribute("fill", "freeze");
46
+ expand.setAttribute("calcMode", "spline");
47
+ expand.setAttribute("keySplines", "0.4 0, 0.2 1");
48
+ circle.appendChild(expand);
49
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
50
+ svg.classList.add("active-ripple");
51
+ svg.style.cssText = [
52
+ "position: absolute",
53
+ "inset: 0",
54
+ "width: 100%",
55
+ "height: 100%",
56
+ "overflow: hidden",
57
+ "border-radius: inherit",
58
+ "pointer-events: none",
59
+ ].join(";");
60
+ svg.appendChild(gradient);
61
+ svg.appendChild(circle);
62
+ const ua = navigator.userAgent;
63
+ const isFirefox = ua.includes("Firefox");
64
+ const isTrulySafari = !ua.includes("Chrome") && ua.includes("Safari");
65
+ if (!isFirefox && !isTrulySafari && size > 100) {
66
+ const filter = document.createElementNS("http://www.w3.org/2000/svg", "filter");
67
+ filter.id = `noise-${Date.now()}-${Math.random().toString(36).slice(2)}`;
68
+ const turb = document.createElementNS("http://www.w3.org/2000/svg", "feTurbulence");
69
+ turb.setAttribute("type", "fractalNoise");
70
+ turb.setAttribute("baseFrequency", "0.6");
71
+ turb.setAttribute("seed", Math.random().toString());
72
+ const blur = document.createElementNS("http://www.w3.org/2000/svg", "feDisplacementMap");
73
+ blur.setAttribute("in", "SourceGraphic");
74
+ // implicitly uses result of previous filter primitive as in2
75
+ blur.setAttribute("scale", `${size ** 2 * 0.0002}`);
76
+ blur.setAttribute("xChannelSelector", "R");
77
+ blur.setAttribute("yChannelSelector", "B");
78
+ filter.appendChild(turb);
79
+ filter.appendChild(blur);
80
+ circle.setAttribute("filter", `url(#${filter.id})`);
81
+ svg.appendChild(filter);
82
+ }
83
+ node.appendChild(svg);
84
+ return () => {
85
+ const fade = document.createElementNS("http://www.w3.org/2000/svg", "animate");
86
+ fade.setAttribute("attributeName", "opacity");
87
+ fade.setAttribute("from", "1");
88
+ fade.setAttribute("to", "0");
89
+ fade.setAttribute("dur", "800ms");
90
+ fade.setAttribute("fill", "freeze");
91
+ fade.setAttribute("calcMode", "spline");
92
+ fade.setAttribute("keySplines", "0.4 0, 0.2 1");
93
+ circle.appendChild(fade);
94
+ fade.beginElement();
95
+ setTimeout(() => svg.remove(), 800);
96
+ };
97
+ };
98
+ if (typeof document != "undefined") {
99
+ document.documentElement.classList.add("js");
100
+ // Pointer events
101
+ document.addEventListener("pointerdown", (e) => {
102
+ if (e.button != 0)
103
+ return;
104
+ const layer = e.target.closest(".m3-layer");
105
+ if (!layer || !isEnabled(layer))
106
+ return;
107
+ const rect = layer.getBoundingClientRect();
108
+ const cancel = createRippleSvg(layer, e.clientX - rect.left, e.clientY - rect.top, rect.width, rect.height);
109
+ if (cancel) {
110
+ activePointerRipples.push(cancel);
111
+ }
112
+ });
113
+ const cancelPointerRipples = () => {
114
+ for (const cancel of activePointerRipples)
115
+ cancel();
116
+ activePointerRipples.length = 0;
117
+ };
118
+ document.addEventListener("pointerup", cancelPointerRipples);
119
+ document.addEventListener("dragend", cancelPointerRipples);
120
+ // Keyboard events
121
+ document.addEventListener("keydown", (e) => {
122
+ if (e.repeat)
123
+ return;
124
+ const target = e.target;
125
+ const layer = target.closest(".m3-layer");
126
+ if (!layer || !isEnabled(layer))
127
+ return;
128
+ const isActivate = e.key == "Enter" || (e.key == " " && layer.tagName == "BUTTON");
129
+ if (!isActivate)
130
+ return;
131
+ const rect = layer.getBoundingClientRect();
132
+ const cancel = createRippleSvg(layer, rect.width / 2, rect.height / 2, rect.width, rect.height);
133
+ if (cancel) {
134
+ activeKeyboardRipples.push(cancel);
135
+ }
136
+ });
137
+ document.addEventListener("keyup", () => {
138
+ for (const cancel of activeKeyboardRipples)
139
+ cancel();
140
+ activeKeyboardRipples.length = 0;
141
+ });
142
+ }
@@ -0,0 +1,8 @@
1
+ [placeholder]::placeholder {
2
+ color: --translucent(var(--m3c-on-surface), 0.5);
3
+ opacity: 1;
4
+ }
5
+ ::selection {
6
+ background-color: var(--m3c-tertiary-container);
7
+ color: var(--m3c-on-tertiary-container);
8
+ }
@@ -1,10 +1,32 @@
1
- @function --translucent(--color, --opacity) {
2
- result: oklab(from var(--color) l a b / var(--opacity));
3
- }
4
- /* DEPRECATED: This default --m3-density function will be removed in a future version.
5
- For new themes, pick which option you actually want. */
6
- @function --m3-density(--size) {
7
- result: calc(var(--size) + (var(--m3v-density, 0) * 0.25rem));
1
+ @layer base {
2
+ /* Reset a few things */
3
+ *,
4
+ *::before,
5
+ *::after {
6
+ box-sizing: inherit;
7
+ }
8
+ .m3-container {
9
+ box-sizing: border-box;
10
+ -webkit-tap-highlight-color: transparent;
11
+ }
12
+ .m3-container a,
13
+ a.m3-container {
14
+ text-decoration: none;
15
+ }
16
+ .m3-container dialog,
17
+ dialog.m3-container {
18
+ margin: auto;
19
+ }
20
+
21
+ :root {
22
+ accent-color: var(--m3c-primary);
23
+ }
24
+ * {
25
+ outline: none;
26
+ }
27
+ :focus-visible {
28
+ @apply --m3-focused-outward;
29
+ }
8
30
  }
9
31
 
10
32
  @layer tokens {
@@ -39,7 +61,7 @@
39
61
  --m3-optical-centering-coefficient: 0.11;
40
62
 
41
63
  /* Typography */
42
- --m3-font: Roboto, system-ui;
64
+ --m3-font: "Google Sans Flex", Roboto, system-ui;
43
65
  --m3-font-mono: "Google Sans Code", "Roboto Mono", monospace;
44
66
 
45
67
  /* Expressive easing */
@@ -120,12 +142,7 @@
120
142
  );
121
143
  }
122
144
  }
123
- /* Not tokens because they may be dynamically get/set and aren't generally constant */
124
- @property --m3v-bottom-offset {
125
- syntax: "<length>";
126
- inherits: true;
127
- initial-value: 0;
128
- }
145
+ /* Background is dynamic, so not a token */
129
146
  :root {
130
147
  --m3v-background: var(--m3c-surface);
131
148
  }
@@ -135,21 +152,21 @@
135
152
  font-family: var(--m3-font);
136
153
  font-size: 3.563rem;
137
154
  line-height: 1.123;
138
- letter-spacing: 0;
155
+ /*letter-spacing: 0;*/
139
156
  font-weight: 400;
140
157
  }
141
158
  @mixin --m3-display-medium {
142
159
  font-family: var(--m3-font);
143
160
  font-size: 2.813rem;
144
161
  line-height: 1.156;
145
- letter-spacing: 0;
162
+ /*letter-spacing: 0;*/
146
163
  font-weight: 400;
147
164
  }
148
165
  @mixin --m3-display-small {
149
166
  font-family: var(--m3-font);
150
167
  font-size: 2.25rem;
151
168
  line-height: 1.222;
152
- letter-spacing: 0;
169
+ /*letter-spacing: 0;*/
153
170
  font-weight: 400;
154
171
  }
155
172
 
@@ -158,21 +175,21 @@
158
175
  font-family: var(--m3-font);
159
176
  font-size: 2rem;
160
177
  line-height: 1.25;
161
- letter-spacing: 0;
178
+ /*letter-spacing: 0;*/
162
179
  font-weight: 400;
163
180
  }
164
181
  @mixin --m3-headline-medium {
165
182
  font-family: var(--m3-font);
166
183
  font-size: 1.75rem;
167
184
  line-height: 1.286;
168
- letter-spacing: 0;
185
+ /*letter-spacing: 0;*/
169
186
  font-weight: 400;
170
187
  }
171
188
  @mixin --m3-headline-small {
172
189
  font-family: var(--m3-font);
173
190
  font-size: 1.5rem;
174
191
  line-height: 1.333;
175
- letter-spacing: 0;
192
+ /*letter-spacing: 0;*/
176
193
  font-weight: 400;
177
194
  }
178
195
 
@@ -181,21 +198,21 @@
181
198
  font-family: var(--m3-font);
182
199
  font-size: 1.375rem;
183
200
  line-height: 1.273;
184
- letter-spacing: 0;
201
+ /*letter-spacing: 0;*/
185
202
  font-weight: 400;
186
203
  }
187
204
  @mixin --m3-title-medium {
188
205
  font-family: var(--m3-font);
189
206
  font-size: 1rem;
190
207
  line-height: 1.5;
191
- letter-spacing: 0;
208
+ /*letter-spacing: 0;*/
192
209
  font-weight: 500;
193
210
  }
194
211
  @mixin --m3-title-small {
195
212
  font-family: var(--m3-font);
196
213
  font-size: 0.875rem;
197
214
  line-height: 1.429;
198
- letter-spacing: 0.006rem;
215
+ /*letter-spacing: 0.006rem;*/
199
216
  font-weight: 500;
200
217
  }
201
218
 
@@ -205,21 +222,21 @@ or for very small text in the content body, such as captions. */
205
222
  font-family: var(--m3-font);
206
223
  font-size: 0.875rem;
207
224
  line-height: 1.429;
208
- letter-spacing: 0.006rem;
225
+ /*letter-spacing: 0.006rem;*/
209
226
  font-weight: 500;
210
227
  }
211
228
  @mixin --m3-label-medium {
212
229
  font-family: var(--m3-font);
213
230
  font-size: 0.75rem;
214
231
  line-height: 1.333;
215
- letter-spacing: 0.031rem;
232
+ /*letter-spacing: 0.031rem;*/
216
233
  font-weight: 500;
217
234
  }
218
235
  @mixin --m3-label-small {
219
236
  font-family: var(--m3-font);
220
237
  font-size: 0.688rem;
221
238
  line-height: 1.455;
222
- letter-spacing: 0.031rem;
239
+ /*letter-spacing: 0.031rem;*/
223
240
  font-weight: 500;
224
241
  }
225
242
 
@@ -228,47 +245,58 @@ or for very small text in the content body, such as captions. */
228
245
  font-family: var(--m3-font);
229
246
  font-size: 1rem;
230
247
  line-height: 1.5;
231
- letter-spacing: 0;
248
+ /*letter-spacing: 0;*/
232
249
  font-weight: 400;
233
250
  }
234
251
  @mixin --m3-body-medium {
235
252
  font-family: var(--m3-font);
236
253
  font-size: 0.875rem;
237
254
  line-height: 1.429;
238
- letter-spacing: 0.016rem;
255
+ /*letter-spacing: 0.016rem;*/
239
256
  font-weight: 400;
240
257
  }
241
258
  @mixin --m3-body-small {
242
259
  font-family: var(--m3-font);
243
260
  font-size: 0.75rem;
244
261
  line-height: 1.333;
245
- letter-spacing: 0.025rem;
262
+ /*letter-spacing: 0.025rem;*/
246
263
  font-weight: 400;
247
264
  }
248
- @layer base {
249
- /* Reset a few things */
250
- *,
251
- *::before,
252
- *::after {
253
- box-sizing: inherit;
265
+
266
+ @keyframes focus-outward {
267
+ 0% {
268
+ box-shadow: 0 0 0 0px var(--m3c-secondary);
254
269
  }
255
- .m3-container {
256
- box-sizing: border-box;
257
- -webkit-tap-highlight-color: transparent;
270
+ 100% {
271
+ box-shadow: 0 0 0 3px var(--m3c-secondary);
258
272
  }
259
- .m3-container a,
260
- a.m3-container {
261
- text-decoration: none;
273
+ }
274
+ @keyframes focus-inward {
275
+ 0% {
276
+ box-shadow: inset 0 0 0 0px var(--m3c-secondary);
262
277
  }
263
- .m3-container dialog,
264
- dialog.m3-container {
265
- margin: auto;
278
+ 100% {
279
+ box-shadow: inset 0 0 0 3px var(--m3c-secondary);
266
280
  }
267
-
268
- :root {
269
- accent-color: var(--m3c-primary);
281
+ }
282
+ @mixin --m3-focused-outward {
283
+ animation: focus-outward 0.6s cubic-bezier(0.14, 5.63, 0.4, 0.5) forwards;
284
+ }
285
+ @mixin --m3-focused-inward {
286
+ animation: focus-inward 0.6s cubic-bezier(0.14, 5.63, 0.4, 0.5) forwards;
287
+ }
288
+ @mixin --m3-focus-inward {
289
+ &:focus-visible {
290
+ @apply --m3-focused-inward;
270
291
  }
271
292
  }
293
+ @mixin --m3-focus-none {
294
+ animation: none;
295
+ }
296
+
297
+ @function --translucent(--color, --opacity) {
298
+ result: oklab(from var(--color) l a b / var(--opacity));
299
+ }
272
300
 
273
301
  /* Emphasized easing timing function derived from this code:
274
302
  const createBezierLUT = (points: number[][], pointCount: number = 100): number[][] => {
@@ -40,8 +40,6 @@
40
40
  --default-transition-timing-function: var(--ease);
41
41
  --default-transition-duration: var(--m3-duration);
42
42
 
43
- --color-background: var(--m3c-background);
44
- --color-on-background: var(--m3c-on-background);
45
43
  --color-surface: var(--m3c-surface);
46
44
  --color-surface-dim: var(--m3c-surface-dim);
47
45
  --color-surface-bright: var(--m3c-surface-bright);
@@ -0,0 +1,3 @@
1
+ import { type Preset } from "unocss";
2
+ declare const _default: () => Preset<object>;
3
+ export default _default;
@@ -0,0 +1,85 @@
1
+ import { symbols } from "unocss";
2
+ import { colors } from "./colors";
3
+ const easings = ["-fast-spatial", "-spatial", "-slow-spatial", "-fast", "", "-slow"];
4
+ const fontClasses = [
5
+ "display-large",
6
+ "display-medium",
7
+ "display-small",
8
+ "headline-large",
9
+ "headline-medium",
10
+ "headline-small",
11
+ "title-large",
12
+ "title-medium",
13
+ "title-small",
14
+ "label-large",
15
+ "label-medium",
16
+ "label-small",
17
+ "body-large",
18
+ "body-medium",
19
+ "body-small",
20
+ ];
21
+ const preset = {
22
+ name: "m3-svelte",
23
+ theme: {
24
+ breakpoints: {
25
+ m: "37.5rem", // ≅ sm
26
+ x: "52.5rem", // expanded; ≅ md
27
+ l: "75rem", // ≅ lg, xl
28
+ xl: "100rem", // ≅ 2xl
29
+ },
30
+ container: {
31
+ maxWidth: {
32
+ m: "37.5rem", // ≅ sm
33
+ x: "52.5rem", // expanded; ≅ md
34
+ l: "75rem", // ≅ lg, xl
35
+ xl: "100rem",
36
+ },
37
+ },
38
+ spacing: {
39
+ DEFAULT: "0.25rem",
40
+ },
41
+ fontFamily: {
42
+ sans: "var(--m3-font)",
43
+ mono: "var(--m3-font-mono)",
44
+ },
45
+ boxShadow: {
46
+ "1": "var(--m3-elevation-1)",
47
+ "2": "var(--m3-elevation-2)",
48
+ "3": "var(--m3-elevation-3)",
49
+ "4": "var(--m3-elevation-4)",
50
+ "5": "var(--m3-elevation-5)",
51
+ },
52
+ borderRadius: {
53
+ xs: "var(--m3-shape-extra-small)", // 4px
54
+ sm: "var(--m3-shape-small)", // 8px
55
+ md: "var(--m3-shape-medium)", // 12px
56
+ lg: "var(--m3-shape-large)", // 16px
57
+ xl: "var(--m3-shape-extra-large)", // 28px
58
+ },
59
+ colors: {
60
+ ...Object.fromEntries(colors.map((c) => [
61
+ c.name.replaceAll("_", "-"),
62
+ `var(--m3c-${c.name.replaceAll("_", "-")})`,
63
+ ])),
64
+ "v-background": "var(--m3v-background)",
65
+ },
66
+ },
67
+ rules: [
68
+ ...easings.map((e) => [
69
+ `transition${e}`,
70
+ {
71
+ "transition-timing-function": `var(--m3-timing-function${e})`,
72
+ "transition-duration": `var(--m3-duration${e})`,
73
+ },
74
+ ]),
75
+ ...fontClasses.map((c) => [`m3-font-${c}`, { [symbols.body]: `@apply --m3-${c}` }]),
76
+ ],
77
+ preflights: [
78
+ {
79
+ getCSS: () => `:root {
80
+ box-sizing: border-box;
81
+ }`,
82
+ },
83
+ ],
84
+ };
85
+ export default () => preset;
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
- import Layer from "../misc/Layer.svelte";
4
3
  import type { DivAttrs } from "../misc/typing-utils";
5
4
 
6
5
  // MUST BE WRAPPED IN A <label>
@@ -14,8 +13,7 @@
14
13
 
15
14
  <div class="m3-container" {...extra}>
16
15
  {@render children()}
17
- <div class="layer-container">
18
- <Layer />
16
+ <div class="layer-container m3-layer">
19
17
  <div class="checkbox-box"></div>
20
18
  </div>
21
19
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
@@ -2,10 +2,10 @@
2
2
  import type { Snippet } from "svelte";
3
3
  import type { IconifyIcon } from "@iconify/types";
4
4
  import Icon from "../misc/Icon.svelte";
5
- import Layer from "../misc/Layer.svelte";
6
- import type { LabelAttrs, AnchorAttrs, ButtonAttrs } from "../misc/typing-utils";
5
+ import type { AnchorAttrs, ButtonAttrs, NotLink } from "../misc/typing-utils";
6
+ import type { HTMLLabelAttributes } from "svelte/elements";
7
7
 
8
- type ActionProps = LabelAttrs | AnchorAttrs | ButtonAttrs;
8
+ type ActionProps = AnchorAttrs | (NotLink<HTMLLabelAttributes> & { label: true }) | ButtonAttrs;
9
9
 
10
10
  let {
11
11
  variant,
@@ -35,7 +35,6 @@
35
35
  </script>
36
36
 
37
37
  {#snippet content()}
38
- <Layer />
39
38
  {#if icon}
40
39
  <Icon {icon} class="leading" />
41
40
  {/if}
@@ -45,16 +44,22 @@
45
44
  {/if}
46
45
  {/snippet}
47
46
 
48
- {#if "for" in extra}
49
- <label class="m3-container {variant}" class:elevated class:selected {...extra}>
50
- {@render content()}
51
- </label>
52
- {:else if "href" in extra}
53
- <a class="m3-container {variant}" class:elevated class:selected {...extra}>
47
+ {#if extra.href != undefined}
48
+ <a class="m3-container {variant} m3-layer" class:elevated class:selected {...extra}>
54
49
  {@render content()}
55
50
  </a>
51
+ {:else if "label" in extra}
52
+ <label class="m3-container {variant} m3-layer" class:elevated class:selected {...extra}>
53
+ {@render content()}
54
+ </label>
56
55
  {:else}
57
- <button class="m3-container {variant}" class:elevated class:selected {...extra} type="button">
56
+ <button
57
+ class="m3-container {variant} m3-layer"
58
+ class:elevated
59
+ class:selected
60
+ {...extra}
61
+ type="button"
62
+ >
58
63
  {@render content()}
59
64
  </button>
60
65
  {/if}
@@ -76,13 +81,16 @@
76
81
  background-color: var(--m3c-surface);
77
82
  color: var(--m3c-on-surface-variant);
78
83
  border: solid 1px var(--m3c-outline);
79
- position: relative;
80
84
  cursor: pointer;
81
85
  transition: var(--m3-easing-fast);
82
86
  }
83
87
 
84
- .m3-container > :global(:is(.ripple-container, .tint)) {
85
- inset: -1px;
88
+ .m3-container::before,
89
+ .m3-container::after,
90
+ .m3-container > :global(.active-ripple) {
91
+ inset: -1px !important;
92
+ width: calc(100% + 2px) !important;
93
+ height: calc(100% + 2px) !important;
86
94
  }
87
95
  .m3-container > :global(svg) {
88
96
  width: 1.125rem;
@@ -1,7 +1,10 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { IconifyIcon } from "@iconify/types";
3
- import type { LabelAttrs, AnchorAttrs, ButtonAttrs } from "../misc/typing-utils";
4
- type ActionProps = LabelAttrs | AnchorAttrs | ButtonAttrs;
3
+ import type { AnchorAttrs, ButtonAttrs, NotLink } from "../misc/typing-utils";
4
+ import type { HTMLLabelAttributes } from "svelte/elements";
5
+ type ActionProps = AnchorAttrs | (NotLink<HTMLLabelAttributes> & {
6
+ label: true;
7
+ }) | ButtonAttrs;
5
8
  type $$ComponentProps = {
6
9
  /**
7
10
  * general is filter/suggestion since they're the same.
@@ -4,7 +4,6 @@
4
4
  import type { TransitionConfig } from "svelte/transition";
5
5
  import iconCalendar from "@ktibow/iconset-material-symbols/calendar-today-outline";
6
6
  import Icon from "../misc/Icon.svelte";
7
- import Layer from "../misc/Layer.svelte";
8
7
 
9
8
  import DatePickerDocked from "./DatePickerDocked.svelte";
10
9
  import { easeEmphasized } from "../misc/easing";
@@ -66,18 +65,15 @@ opacity: ${Math.min(t * 3, 1)};`,
66
65
  use:clickOutside
67
66
  style:--anchor-name="--{id}"
68
67
  >
69
- <input
70
- type="date"
71
- class="focus-none"
72
- {disabled}
73
- {required}
74
- {id}
75
- bind:value
76
- {...extra}
77
- />
68
+ <input type="date" {disabled} {required} {id} bind:value {...extra} />
78
69
  <label for={id}>{label}</label>
79
- <button type="button" {disabled} title={datePickerTitle} onclick={() => (picker = !picker)}>
80
- <Layer />
70
+ <button
71
+ type="button"
72
+ class="m3-layer"
73
+ {disabled}
74
+ title={datePickerTitle}
75
+ onclick={() => (picker = !picker)}
76
+ >
81
77
  <Icon icon={iconCalendar} size={24} />
82
78
  </button>
83
79
  {#if picker}
@@ -125,12 +121,12 @@ opacity: ${Math.min(t * 3, 1)};`,
125
121
  }
126
122
  input {
127
123
  @apply --m3-body-large;
124
+ @apply --m3-focus-none;
128
125
  position: absolute;
129
126
  inset: 0;
130
127
  width: 100%;
131
128
  height: 100%;
132
129
  border: none;
133
- outline: none;
134
130
 
135
131
  padding: 1rem 1rem 0rem 1rem;
136
132
  padding-inline-start: 0.875rem;