m3-svelte 4.6.7 → 5.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 (42) hide show
  1. package/package/buttons/Button.svelte +3 -13
  2. package/package/buttons/Button.svelte.d.ts +3 -6
  3. package/package/buttons/FAB.svelte +3 -5
  4. package/package/buttons/FAB.svelte.d.ts +2 -3
  5. package/package/buttons/SplitButton.svelte +3 -3
  6. package/package/buttons/SplitButton.svelte.d.ts +1 -1
  7. package/package/containers/Card.svelte +9 -10
  8. package/package/containers/Card.svelte.d.ts +3 -4
  9. package/package/containers/Dialog.svelte +1 -1
  10. package/package/containers/ListItem.svelte +9 -21
  11. package/package/containers/ListItem.svelte.d.ts +5 -6
  12. package/package/containers/MenuItem.svelte +3 -3
  13. package/package/containers/MenuItem.svelte.d.ts +1 -1
  14. package/package/containers/Snackbar.svelte +11 -2
  15. package/package/containers/Snackbar.svelte.d.ts +1 -0
  16. package/package/containers/StandardSideSheet.svelte +1 -1
  17. package/package/forms/Chip.svelte +3 -5
  18. package/package/forms/Chip.svelte.d.ts +2 -3
  19. package/package/{utils → forms}/DateField.svelte +12 -11
  20. package/package/{utils → forms}/DateField.svelte.d.ts +3 -2
  21. package/package/{utils → forms}/DateFieldOutlined.svelte +14 -15
  22. package/package/{utils → forms}/DateFieldOutlined.svelte.d.ts +3 -2
  23. package/package/forms/TextField.svelte +13 -31
  24. package/package/forms/TextField.svelte.d.ts +5 -8
  25. package/package/forms/TextFieldMultiline.svelte +1 -3
  26. package/package/forms/TextFieldOutlined.svelte +15 -36
  27. package/package/forms/TextFieldOutlined.svelte.d.ts +5 -8
  28. package/package/forms/TextFieldOutlinedMultiline.svelte +3 -7
  29. package/package/forms/_picker/Actions.svelte +3 -3
  30. package/package/forms/_picker/CalendarPicker.svelte +1 -1
  31. package/package/forms/_picker/FocusPicker.svelte +6 -1
  32. package/package/forms/_picker/Item.svelte +3 -3
  33. package/package/forms/_picker/Item.svelte.d.ts +1 -1
  34. package/package/index.d.ts +2 -2
  35. package/package/index.js +2 -2
  36. package/package/misc/_ripple.svelte +4 -4
  37. package/package/misc/_ripplesimple.svelte +4 -4
  38. package/package/misc/typing-utils.d.ts +3 -0
  39. package/package/misc/typing-utils.js +1 -0
  40. package/package/nav/NavCMLXItem.svelte +1 -0
  41. package/package/utils/ChipChooser.svelte +1 -1
  42. package/package.json +1 -1
@@ -9,9 +9,9 @@
9
9
 
10
10
  // If you want a toggle button, use `for` with a checkbox input.
11
11
  type ActionProps =
12
- | ({ click?: () => void; disabled?: boolean } & HTMLButtonAttributes)
12
+ | ({ for: string } & HTMLLabelAttributes)
13
13
  | ({ href: string } & HTMLAnchorAttributes)
14
- | ({ for: string } & HTMLLabelAttributes);
14
+ | HTMLButtonAttributes;
15
15
  type Props = {
16
16
  variant?: "elevated" | "filled" | "tonal" | "outlined" | "text";
17
17
  square?: boolean;
@@ -59,18 +59,8 @@
59
59
  {@render children()}
60
60
  </a>
61
61
  {:else}
62
- {@const {
63
- variant = "filled",
64
- click,
65
- disabled,
66
- square = false,
67
- iconType = "none",
68
- children,
69
- ...extra
70
- } = props}
62
+ {@const { variant = "filled", square = false, iconType = "none", children, ...extra } = props}
71
63
  <button
72
- onclick={click}
73
- {disabled}
74
64
  class="m3-container m3-font-label-large {variant} icon-{iconType}"
75
65
  class:square
76
66
  {...extra}
@@ -1,13 +1,10 @@
1
1
  import type { HTMLButtonAttributes, HTMLAnchorAttributes, HTMLLabelAttributes } from "svelte/elements";
2
2
  import type { Snippet } from "svelte";
3
3
  type ActionProps = ({
4
- click?: () => void;
5
- disabled?: boolean;
6
- } & HTMLButtonAttributes) | ({
7
- href: string;
8
- } & HTMLAnchorAttributes) | ({
9
4
  for: string;
10
- } & HTMLLabelAttributes);
5
+ } & HTMLLabelAttributes) | ({
6
+ href: string;
7
+ } & HTMLAnchorAttributes) | HTMLButtonAttributes;
11
8
  type Props = {
12
9
  variant?: "elevated" | "filled" | "tonal" | "outlined" | "text";
13
10
  square?: boolean;
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
- import type { HTMLButtonAttributes } from "svelte/elements";
3
2
  import type { IconifyIcon } from "@iconify/types";
4
3
  import Icon from "../misc/_icon.svelte";
5
4
  import Layer from "../misc/Layer.svelte";
5
+ import type { ButtonAttrs } from "../misc/typing-utils";
6
6
 
7
7
  type ContentProps =
8
8
  | {
@@ -19,7 +19,6 @@
19
19
  let {
20
20
  color = "primary",
21
21
  elevation = "normal",
22
- click,
23
22
  size = "normal",
24
23
  icon,
25
24
  text,
@@ -33,13 +32,12 @@
33
32
  | "secondary"
34
33
  | "tertiary";
35
34
  elevation?: "normal" | "lowered" | "none";
36
- click: () => void;
37
35
  } & ContentProps &
38
- HTMLButtonAttributes = $props();
36
+ ButtonAttrs = $props();
39
37
  </script>
40
38
 
41
39
  <button
42
- onclick={click}
40
+ type="button"
43
41
  class="m3-container m3-font-label-large color-{color} size-{size} elevation-{elevation}"
44
42
  {...extra}
45
43
  >
@@ -1,5 +1,5 @@
1
- import type { HTMLButtonAttributes } from "svelte/elements";
2
1
  import type { IconifyIcon } from "@iconify/types";
2
+ import type { ButtonAttrs } from "../misc/typing-utils";
3
3
  type ContentProps = {
4
4
  size?: "normal";
5
5
  icon?: IconifyIcon;
@@ -12,8 +12,7 @@ type ContentProps = {
12
12
  type $$ComponentProps = {
13
13
  color?: "primary-container" | "secondary-container" | "tertiary-container" | "primary" | "secondary" | "tertiary";
14
14
  elevation?: "normal" | "lowered" | "none";
15
- click: () => void;
16
- } & ContentProps & HTMLButtonAttributes;
15
+ } & ContentProps & ButtonAttrs;
17
16
  declare const Fab: import("svelte").Component<$$ComponentProps, {}, "">;
18
17
  type Fab = ReturnType<typeof Fab>;
19
18
  export default Fab;
@@ -10,14 +10,14 @@
10
10
  y = "down",
11
11
  children,
12
12
  menu,
13
- click,
13
+ onclick,
14
14
  }: {
15
15
  variant: "elevated" | "filled" | "tonal" | "outlined";
16
16
  x?: "inner" | "right";
17
17
  y?: "down" | "up";
18
18
  children: Snippet;
19
19
  menu: Snippet;
20
- click: () => void;
20
+ onclick: () => void;
21
21
  } = $props();
22
22
 
23
23
  const autoclose = (node: HTMLDetailsElement) => {
@@ -36,7 +36,7 @@
36
36
  </script>
37
37
 
38
38
  <div class="m3-container {variant}">
39
- <button class="split m3-font-label-large" onclick={click}>
39
+ <button type="button" class="split m3-font-label-large" {onclick}>
40
40
  <Layer />
41
41
  {@render children()}
42
42
  </button>
@@ -5,7 +5,7 @@ type $$ComponentProps = {
5
5
  y?: "down" | "up";
6
6
  children: Snippet;
7
7
  menu: Snippet;
8
- click: () => void;
8
+ onclick: () => void;
9
9
  };
10
10
  declare const SplitButton: import("svelte").Component<$$ComponentProps, {}, "">;
11
11
  type SplitButton = ReturnType<typeof SplitButton>;
@@ -1,11 +1,10 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
- import type { HTMLAttributes, HTMLButtonAttributes } from "svelte/elements";
3
+ import type { HTMLAttributes } from "svelte/elements";
4
4
  import Layer from "../misc/Layer.svelte";
5
+ import type { ButtonAttrs, NotButton } from "../misc/typing-utils";
5
6
 
6
- type ActionProps =
7
- | ({ click: () => void } & HTMLButtonAttributes)
8
- | HTMLAttributes<HTMLDivElement>;
7
+ type ActionProps = ButtonAttrs | NotButton<HTMLAttributes<HTMLDivElement>>;
9
8
 
10
9
  let props: {
11
10
  variant: "elevated" | "filled" | "outlined";
@@ -13,9 +12,9 @@
13
12
  } & ActionProps = $props();
14
13
  </script>
15
14
 
16
- {#if "click" in props}
17
- {@const { variant, click, children, ...extra } = props}
18
- <button class="m3-container {variant}" onclick={click} {...extra}>
15
+ {#if "onclick" in props}
16
+ {@const { variant, children, ...extra } = props}
17
+ <button type="button" class="m3-container {variant}" {...extra}>
19
18
  <Layer />
20
19
  {@render children()}
21
20
  </button>
@@ -39,7 +38,7 @@
39
38
  border: none;
40
39
  border-radius: var(--m3-card-shape);
41
40
  background-color: rgb(var(--m3-scheme-surface));
42
- --m3-util-background: var(--m3-scheme-surface);
41
+ --m3-util-background: rgb(var(--m3-scheme-surface));
43
42
  color: rgb(var(--m3-scheme-on-surface));
44
43
  }
45
44
 
@@ -61,12 +60,12 @@
61
60
 
62
61
  .elevated {
63
62
  background-color: rgb(var(--m3-scheme-surface-container-low));
64
- --m3-util-background: var(--m3-scheme-surface-container-low);
63
+ --m3-util-background: rgb(var(--m3-scheme-surface-container-low));
65
64
  box-shadow: var(--m3-util-elevation-1);
66
65
  }
67
66
  .filled {
68
67
  background-color: rgb(var(--m3-scheme-surface-container-highest));
69
- --m3-util-background: var(--m3-scheme-surface-container-highest);
68
+ --m3-util-background: rgb(var(--m3-scheme-surface-container-highest));
70
69
  }
71
70
  .outlined {
72
71
  border: solid 1px rgb(var(--m3-scheme-outline-variant));
@@ -1,8 +1,7 @@
1
1
  import type { Snippet } from "svelte";
2
- import type { HTMLAttributes, HTMLButtonAttributes } from "svelte/elements";
3
- type ActionProps = ({
4
- click: () => void;
5
- } & HTMLButtonAttributes) | HTMLAttributes<HTMLDivElement>;
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ import type { ButtonAttrs, NotButton } from "../misc/typing-utils";
4
+ type ActionProps = ButtonAttrs | NotButton<HTMLAttributes<HTMLDivElement>>;
6
5
  type $$ComponentProps = {
7
6
  variant: "elevated" | "filled" | "outlined";
8
7
  children: Snippet;
@@ -80,7 +80,7 @@
80
80
  display: flex;
81
81
  flex-direction: column;
82
82
  background-color: rgb(var(--m3-scheme-surface-container-high));
83
- --m3-util-background: var(--m3-scheme-surface-container-high);
83
+ --m3-util-background: rgb(var(--m3-scheme-surface-container-high));
84
84
  border: none;
85
85
  border-radius: var(--m3-dialog-shape);
86
86
  min-width: 17.5rem;
@@ -1,18 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
- import type {
4
- HTMLAnchorAttributes,
5
- HTMLAttributes,
6
- HTMLButtonAttributes,
7
- HTMLLabelAttributes,
8
- } from "svelte/elements";
3
+ import type { HTMLAnchorAttributes, HTMLAttributes, HTMLLabelAttributes } from "svelte/elements";
9
4
  import Layer from "../misc/Layer.svelte";
5
+ import type { ButtonAttrs, NotButton } from "../misc/typing-utils";
10
6
 
11
7
  type ActionProps =
12
- | HTMLAttributes<HTMLDivElement>
13
- | ({ click: () => void } & HTMLButtonAttributes)
14
- | ({ label: true } & HTMLLabelAttributes)
15
- | ({ href: string } & HTMLAnchorAttributes);
8
+ | NotButton<HTMLAttributes<HTMLDivElement>>
9
+ | ButtonAttrs
10
+ | ({ label: true } & NotButton<HTMLLabelAttributes>)
11
+ | ({ href: string } & NotButton<HTMLAnchorAttributes>);
16
12
 
17
13
  let props: {
18
14
  leading?: Snippet;
@@ -70,17 +66,9 @@
70
66
  <Layer />
71
67
  {@render content(leading, overline, headline, supporting, trailing)}
72
68
  </label>
73
- {:else if "click" in props}
74
- {@const {
75
- leading,
76
- overline = "",
77
- headline = "",
78
- supporting = "",
79
- trailing,
80
- click,
81
- ...extra
82
- } = props}
83
- <button class="m3-container lines-{_lines}" onclick={click} {...extra}>
69
+ {:else if "onclick" in props}
70
+ {@const { leading, overline = "", headline = "", supporting = "", trailing, ...extra } = props}
71
+ <button type="button" class="m3-container lines-{_lines}" {...extra}>
84
72
  <Layer />
85
73
  {@render content(leading, overline, headline, supporting, trailing)}
86
74
  </button>
@@ -1,12 +1,11 @@
1
1
  import type { Snippet } from "svelte";
2
- import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes, HTMLLabelAttributes } from "svelte/elements";
3
- type ActionProps = HTMLAttributes<HTMLDivElement> | ({
4
- click: () => void;
5
- } & HTMLButtonAttributes) | ({
2
+ import type { HTMLAnchorAttributes, HTMLAttributes, HTMLLabelAttributes } from "svelte/elements";
3
+ import type { ButtonAttrs, NotButton } from "../misc/typing-utils";
4
+ type ActionProps = NotButton<HTMLAttributes<HTMLDivElement>> | ButtonAttrs | ({
6
5
  label: true;
7
- } & HTMLLabelAttributes) | ({
6
+ } & NotButton<HTMLLabelAttributes>) | ({
8
7
  href: string;
9
- } & HTMLAnchorAttributes);
8
+ } & NotButton<HTMLAnchorAttributes>);
10
9
  type $$ComponentProps = {
11
10
  leading?: Snippet;
12
11
  overline?: string;
@@ -7,17 +7,17 @@
7
7
  let {
8
8
  icon,
9
9
  disabled = false,
10
- click,
10
+ onclick,
11
11
  children,
12
12
  }: {
13
13
  icon?: IconifyIcon | "space" | undefined;
14
14
  disabled?: boolean;
15
- click: () => void;
15
+ onclick: () => void;
16
16
  children: Snippet;
17
17
  } = $props();
18
18
  </script>
19
19
 
20
- <button class="item m3-font-label-large" {disabled} onclick={click}>
20
+ <button type="button" class="item m3-font-label-large" {disabled} {onclick}>
21
21
  <Layer />
22
22
  {#if icon == "space"}
23
23
  <span class="icon"></span>
@@ -3,7 +3,7 @@ import type { IconifyIcon } from "@iconify/types";
3
3
  type $$ComponentProps = {
4
4
  icon?: IconifyIcon | "space" | undefined;
5
5
  disabled?: boolean;
6
- click: () => void;
6
+ onclick: () => void;
7
7
  children: Snippet;
8
8
  };
9
9
  declare const MenuItem: import("svelte").Component<$$ComponentProps, {}, "">;
@@ -23,8 +23,14 @@
23
23
 
24
24
  type SnackbarConfig = Omit<ComponentProps<typeof SnackbarItem>, "children">;
25
25
 
26
- let { config = {}, ...extra }: { config?: SnackbarConfig } & HTMLAttributes<HTMLDivElement> =
27
- $props();
26
+ let {
27
+ config = {},
28
+ closeButtonTitle = "Close",
29
+ ...extra
30
+ }: {
31
+ config?: SnackbarConfig;
32
+ closeButtonTitle?: string;
33
+ } & HTMLAttributes<HTMLDivElement> = $props();
28
34
  export const show = ({ message, actions = {}, closable = false, timeout = 4000 }: SnackbarIn) => {
29
35
  snackbar = { message, actions, closable, timeout };
30
36
  clearTimeout(timeoutId);
@@ -48,6 +54,7 @@
48
54
  <p class="m3-font-body-medium">{snackbar.message}</p>
49
55
  {#each Object.entries(snackbar.actions) as [key, action]}
50
56
  <button
57
+ type="button"
51
58
  class="action m3-font-label-large"
52
59
  onclick={() => {
53
60
  snackbar = undefined;
@@ -59,7 +66,9 @@
59
66
  {/each}
60
67
  {#if snackbar.closable}
61
68
  <button
69
+ type="button"
62
70
  class="close"
71
+ title={closeButtonTitle}
63
72
  onclick={() => {
64
73
  snackbar = undefined;
65
74
  }}
@@ -10,6 +10,7 @@ import SnackbarItem from "./SnackbarItem.svelte";
10
10
  type SnackbarConfig = Omit<ComponentProps<typeof SnackbarItem>, "children">;
11
11
  type $$ComponentProps = {
12
12
  config?: SnackbarConfig;
13
+ closeButtonTitle?: string;
13
14
  } & HTMLAttributes<HTMLDivElement>;
14
15
  declare const Snackbar: import("svelte").Component<$$ComponentProps, {
15
16
  show: ({ message, actions, closable, timeout }: SnackbarIn) => void;
@@ -18,7 +18,7 @@
18
18
  <div class="m3-container">
19
19
  <div class="header">
20
20
  <span class="m3-font-title-large">{headline}</span>
21
- <Button variant="text" iconType="full" click={close}>
21
+ <Button variant="text" iconType="full" onclick={close}>
22
22
  <Icon icon={iconX} />
23
23
  </Button>
24
24
  </div>
@@ -1,9 +1,9 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte";
3
- import type { HTMLButtonAttributes } from "svelte/elements";
4
3
  import type { IconifyIcon } from "@iconify/types";
5
4
  import Icon from "../misc/_icon.svelte";
6
5
  import Layer from "../misc/Layer.svelte";
6
+ import type { ButtonAttrs } from "../misc/typing-utils";
7
7
 
8
8
  let {
9
9
  variant,
@@ -13,7 +13,6 @@
13
13
  disabled = false,
14
14
  selected = false,
15
15
  children,
16
- click,
17
16
  ...extra
18
17
  }: {
19
18
  /**
@@ -32,16 +31,15 @@
32
31
  disabled?: boolean;
33
32
  selected?: boolean;
34
33
  children: Snippet;
35
- click: () => void;
36
- } & HTMLButtonAttributes = $props();
34
+ } & ButtonAttrs = $props();
37
35
  </script>
38
36
 
39
37
  <button
38
+ type="button"
40
39
  class="m3-container {variant}"
41
40
  class:elevated
42
41
  class:selected
43
42
  {disabled}
44
- onclick={click}
45
43
  {...extra}
46
44
  >
47
45
  <Layer />
@@ -1,6 +1,6 @@
1
1
  import type { Snippet } from "svelte";
2
- import type { HTMLButtonAttributes } from "svelte/elements";
3
2
  import type { IconifyIcon } from "@iconify/types";
3
+ import type { ButtonAttrs } from "../misc/typing-utils";
4
4
  type $$ComponentProps = {
5
5
  /**
6
6
  * general is filter/suggestion since they're the same.
@@ -18,8 +18,7 @@ type $$ComponentProps = {
18
18
  disabled?: boolean;
19
19
  selected?: boolean;
20
20
  children: Snippet;
21
- click: () => void;
22
- } & HTMLButtonAttributes;
21
+ } & ButtonAttrs;
23
22
  declare const Chip: import("svelte").Component<$$ComponentProps, {}, "">;
24
23
  type Chip = ReturnType<typeof Chip>;
25
24
  export default Chip;
@@ -6,22 +6,24 @@
6
6
  import Icon from "../misc/_icon.svelte";
7
7
  import Layer from "../misc/Layer.svelte";
8
8
 
9
- import DatePickerDocked from "../forms/DatePickerDocked.svelte";
9
+ import DatePickerDocked from "./DatePickerDocked.svelte";
10
10
  import { easeEmphasized } from "../misc/easing";
11
11
 
12
12
  let {
13
- label: _label,
14
- date = $bindable(), // TODO: next major release, rename to value
13
+ label,
14
+ value = $bindable(),
15
15
  required = false,
16
16
  disabled = false,
17
17
  error = false,
18
+ datePickerTitle = "Pick date",
18
19
  ...extra
19
20
  }: {
20
21
  label: string;
21
- date?: string;
22
+ value?: string;
22
23
  required?: boolean;
23
24
  disabled?: boolean;
24
25
  error?: boolean;
26
+ datePickerTitle?: string;
25
27
  } & HTMLInputAttributes = $props();
26
28
 
27
29
  const id = $props.id();
@@ -54,8 +56,6 @@ transform: scaleY(${(t * 0.3 + 0.7) * 100}%);
54
56
  opacity: ${Math.min(t * 3, 1)};`,
55
57
  };
56
58
  };
57
-
58
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
59
59
  </script>
60
60
 
61
61
  <div class="m3-container" class:has-js={hasJs} class:disabled class:error use:clickOutside>
@@ -65,23 +65,23 @@ opacity: ${Math.min(t * 3, 1)};`,
65
65
  {disabled}
66
66
  {required}
67
67
  {id}
68
- bind:value={date}
68
+ bind:value
69
69
  {...extra}
70
70
  defaultValue={extra.defaultValue}
71
71
  />
72
72
  <!-- TODO: once https://github.com/sveltejs/svelte/pull/16481 is finished, remove the defaultvalue thing -->
73
73
  <label class="m3-font-body-small" for={id}>{label}</label>
74
- <button type="button" {disabled} onclick={() => (picker = !picker)}>
74
+ <button type="button" {disabled} title={datePickerTitle} onclick={() => (picker = !picker)}>
75
75
  <Layer />
76
76
  <Icon icon={iconCalendar} width="1.5rem" height="1.5rem" />
77
77
  </button>
78
78
  {#if picker}
79
79
  <div class="picker" transition:enterExit>
80
80
  <DatePickerDocked
81
- {date}
81
+ date={value}
82
82
  clearable={!required}
83
83
  close={() => (picker = false)}
84
- setDate={(d) => (date = d)}
84
+ setDate={(d) => (value = d)}
85
85
  />
86
86
  </div>
87
87
  {/if}
@@ -129,7 +129,8 @@ opacity: ${Math.min(t * 3, 1)};`,
129
129
  button {
130
130
  display: none;
131
131
  position: absolute;
132
- width: 3.5rem;
132
+ padding-left: 0.75rem;
133
+ padding-right: 0.75rem;
133
134
  height: 100%;
134
135
  right: 0;
135
136
 
@@ -1,11 +1,12 @@
1
1
  import type { HTMLInputAttributes } from "svelte/elements";
2
2
  type $$ComponentProps = {
3
3
  label: string;
4
- date?: string;
4
+ value?: string;
5
5
  required?: boolean;
6
6
  disabled?: boolean;
7
7
  error?: boolean;
8
+ datePickerTitle?: string;
8
9
  } & HTMLInputAttributes;
9
- declare const DateField: import("svelte").Component<$$ComponentProps, {}, "date">;
10
+ declare const DateField: import("svelte").Component<$$ComponentProps, {}, "value">;
10
11
  type DateField = ReturnType<typeof DateField>;
11
12
  export default DateField;
@@ -6,22 +6,24 @@
6
6
  import Icon from "../misc/_icon.svelte";
7
7
  import Layer from "../misc/Layer.svelte";
8
8
 
9
- import DatePickerDocked from "../forms/DatePickerDocked.svelte";
9
+ import DatePickerDocked from "./DatePickerDocked.svelte";
10
10
  import { easeEmphasized } from "../misc/easing";
11
11
 
12
12
  let {
13
- label: _label,
14
- date = $bindable(), // TODO: next major release, rename to value
13
+ label,
14
+ value = $bindable(),
15
15
  required = false,
16
16
  disabled = false,
17
17
  error = false,
18
+ datePickerTitle = "Pick date",
18
19
  ...extra
19
20
  }: {
20
21
  label: string;
21
- date?: string;
22
+ value?: string;
22
23
  required?: boolean;
23
24
  disabled?: boolean;
24
25
  error?: boolean;
26
+ datePickerTitle?: string;
25
27
  } & HTMLInputAttributes = $props();
26
28
 
27
29
  const id = $props.id();
@@ -54,8 +56,6 @@ transform: scaleY(${(t * 0.3 + 0.7) * 100}%);
54
56
  opacity: ${Math.min(t * 3, 1)};`,
55
57
  };
56
58
  };
57
-
58
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
59
59
  </script>
60
60
 
61
61
  <div class="m3-container" class:has-js={hasJs} class:disabled class:error use:clickOutside>
@@ -65,24 +65,24 @@ opacity: ${Math.min(t * 3, 1)};`,
65
65
  {disabled}
66
66
  {required}
67
67
  {id}
68
- bind:value={date}
68
+ bind:value
69
69
  {...extra}
70
70
  defaultValue={extra.defaultValue}
71
71
  />
72
72
  <!-- TODO: once https://github.com/sveltejs/svelte/pull/16481 is finished, remove the defaultvalue thing -->
73
73
  <div class="layer"></div>
74
74
  <label class="m3-font-body-small" for={id}>{label}</label>
75
- <button type="button" {disabled} onclick={() => (picker = !picker)}>
75
+ <button type="button" {disabled} title={datePickerTitle} onclick={() => (picker = !picker)}>
76
76
  <Layer />
77
77
  <Icon icon={iconCalendar} width="1.5rem" height="1.5rem" />
78
78
  </button>
79
79
  {#if picker}
80
80
  <div class="picker" transition:enterExit>
81
81
  <DatePickerDocked
82
- {date}
82
+ date={value}
83
83
  clearable={!required}
84
84
  close={() => (picker = false)}
85
- setDate={(d) => (date = d)}
85
+ setDate={(d) => (value = d)}
86
86
  />
87
87
  </div>
88
88
  {/if}
@@ -91,7 +91,7 @@ opacity: ${Math.min(t * 3, 1)};`,
91
91
  <style>
92
92
  /*
93
93
  want to customize the label's background?
94
- do this: <DateFieldOutlined --m3-util-background="var(--m3-scheme-surface-container)" />
94
+ do this: <DateFieldOutlined --m3-util-background="rgb(var(--m3-scheme-surface-container))" />
95
95
  */
96
96
  :root {
97
97
  --m3-datefield-outlined-shape: var(--m3-util-rounding-extra-small);
@@ -119,9 +119,7 @@ opacity: ${Math.min(t * 3, 1)};`,
119
119
  left: 0.75rem;
120
120
  top: calc(var(--m3-font-body-small-height, 1rem) * -0.5);
121
121
  color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
122
- background-color: rgb(
123
- var(--m3-util-background, var(--m3-scheme-surface))
124
- ); /* TODO: next breaking change, make --m3-util-background a full color and update the comment above */
122
+ background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
125
123
  padding: 0 0.25rem;
126
124
  &:is(input:hover ~ label) {
127
125
  color: rgb(var(--error, var(--m3-scheme-on-surface)));
@@ -157,7 +155,8 @@ opacity: ${Math.min(t * 3, 1)};`,
157
155
  button {
158
156
  display: none;
159
157
  position: absolute;
160
- width: 3.5rem;
158
+ padding-left: 0.75rem;
159
+ padding-right: 0.75rem;
161
160
  height: 100%;
162
161
  right: 0;
163
162
 
@@ -1,11 +1,12 @@
1
1
  import type { HTMLInputAttributes } from "svelte/elements";
2
2
  type $$ComponentProps = {
3
3
  label: string;
4
- date?: string;
4
+ value?: string;
5
5
  required?: boolean;
6
6
  disabled?: boolean;
7
7
  error?: boolean;
8
+ datePickerTitle?: string;
8
9
  } & HTMLInputAttributes;
9
- declare const DateFieldOutlined: import("svelte").Component<$$ComponentProps, {}, "date">;
10
+ declare const DateFieldOutlined: import("svelte").Component<$$ComponentProps, {}, "value">;
10
11
  type DateFieldOutlined = ReturnType<typeof DateFieldOutlined>;
11
12
  export default DateFieldOutlined;
@@ -1,23 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { IconifyIcon } from "@iconify/types";
3
- import Icon from "../misc/_icon.svelte";
4
3
  import type { HTMLInputAttributes } from "svelte/elements";
5
-
6
- type TrailingProps =
7
- | {
8
- trailingIcon: IconifyIcon;
9
- trailingClick: () => void;
10
- }
11
- | {
12
- trailingIcon?: undefined;
13
- trailingClick?: undefined;
14
- };
4
+ import Icon from "../misc/_icon.svelte";
5
+ import Layer from "../misc/Layer.svelte";
6
+ import type { ButtonAttrs } from "../misc/typing-utils";
15
7
 
16
8
  let {
17
- label: _label,
9
+ label,
18
10
  leadingIcon,
19
- trailingIcon,
20
- trailingClick,
11
+ trailing,
21
12
  disabled = false,
22
13
  required = false,
23
14
  error = false,
@@ -27,22 +18,20 @@
27
18
  }: {
28
19
  label: string;
29
20
  leadingIcon?: IconifyIcon;
21
+ trailing?: { icon: IconifyIcon } & ButtonAttrs;
30
22
  disabled?: boolean;
31
23
  required?: boolean;
32
24
  error?: boolean;
33
25
  value?: string;
34
26
  enter?: () => void;
35
- } & TrailingProps &
36
- HTMLInputAttributes = $props();
27
+ } & HTMLInputAttributes = $props();
37
28
  const id = $props.id();
38
-
39
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
40
29
  </script>
41
30
 
42
31
  <div
43
32
  class="m3-container"
44
33
  class:leading-icon={leadingIcon}
45
- class:trailing-icon={trailingIcon}
34
+ class:trailing-icon={trailing}
46
35
  class:error
47
36
  >
48
37
  <input
@@ -62,9 +51,11 @@
62
51
  {#if leadingIcon}
63
52
  <Icon icon={leadingIcon} class="leading" />
64
53
  {/if}
65
- {#if trailingIcon}
66
- <button onclick={trailingClick} class="trailing">
67
- <Icon icon={trailingIcon} />
54
+ {#if trailing}
55
+ {@const { icon, ...extra } = trailing}
56
+ <button type="button" class="trailing" {...extra}>
57
+ <Layer />
58
+ <Icon {icon} />
68
59
  </button>
69
60
  {/if}
70
61
  </div>
@@ -175,15 +166,6 @@
175
166
  height: 0.125rem;
176
167
  background-color: rgb(var(--error, var(--m3-scheme-primary)));
177
168
  }
178
- @media (hover: hover) {
179
- button:hover {
180
- background-color: rgb(var(--m3-scheme-on-surface-variant) / 0.08);
181
- }
182
- }
183
- button:focus-visible,
184
- button:active {
185
- background-color: rgb(var(--m3-scheme-on-surface-variant) / 0.12);
186
- }
187
169
 
188
170
  .leading-icon > input {
189
171
  padding-left: 3.25rem;
@@ -1,21 +1,18 @@
1
1
  import type { IconifyIcon } from "@iconify/types";
2
2
  import type { HTMLInputAttributes } from "svelte/elements";
3
- type TrailingProps = {
4
- trailingIcon: IconifyIcon;
5
- trailingClick: () => void;
6
- } | {
7
- trailingIcon?: undefined;
8
- trailingClick?: undefined;
9
- };
3
+ import type { ButtonAttrs } from "../misc/typing-utils";
10
4
  type $$ComponentProps = {
11
5
  label: string;
12
6
  leadingIcon?: IconifyIcon;
7
+ trailing?: {
8
+ icon: IconifyIcon;
9
+ } & ButtonAttrs;
13
10
  disabled?: boolean;
14
11
  required?: boolean;
15
12
  error?: boolean;
16
13
  value?: string;
17
14
  enter?: () => void;
18
- } & TrailingProps & HTMLInputAttributes;
15
+ } & HTMLInputAttributes;
19
16
  declare const TextField: import("svelte").Component<$$ComponentProps, {}, "value">;
20
17
  type TextField = ReturnType<typeof TextField>;
21
18
  export default TextField;
@@ -4,7 +4,7 @@
4
4
  import type { HTMLTextareaAttributes } from "svelte/elements";
5
5
 
6
6
  let {
7
- label: _label,
7
+ label,
8
8
  leadingIcon,
9
9
  disabled = false,
10
10
  required = false,
@@ -34,8 +34,6 @@
34
34
  },
35
35
  };
36
36
  };
37
-
38
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
39
37
  </script>
40
38
 
41
39
  <div class="m3-container" class:leading-icon={leadingIcon} class:error use:resize>
@@ -1,23 +1,14 @@
1
1
  <script lang="ts">
2
2
  import type { IconifyIcon } from "@iconify/types";
3
- import Icon from "../misc/_icon.svelte";
4
3
  import type { HTMLInputAttributes } from "svelte/elements";
5
-
6
- type TrailingProps =
7
- | {
8
- trailingIcon: IconifyIcon;
9
- trailingClick: () => void;
10
- }
11
- | {
12
- trailingIcon?: undefined;
13
- trailingClick?: undefined;
14
- };
4
+ import Icon from "../misc/_icon.svelte";
5
+ import Layer from "../misc/Layer.svelte";
6
+ import type { ButtonAttrs } from "../misc/typing-utils";
15
7
 
16
8
  let {
17
- label: _label,
9
+ label,
18
10
  leadingIcon,
19
- trailingIcon,
20
- trailingClick,
11
+ trailing,
21
12
  disabled = false,
22
13
  required = false,
23
14
  error = false,
@@ -27,22 +18,20 @@
27
18
  }: {
28
19
  label: string;
29
20
  leadingIcon?: IconifyIcon;
21
+ trailing?: { icon: IconifyIcon } & ButtonAttrs;
30
22
  disabled?: boolean;
31
23
  required?: boolean;
32
24
  error?: boolean;
33
25
  value?: string;
34
26
  enter?: () => void;
35
- } & TrailingProps &
36
- HTMLInputAttributes = $props();
27
+ } & HTMLInputAttributes = $props();
37
28
  const id = $props.id();
38
-
39
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
40
29
  </script>
41
30
 
42
31
  <div
43
32
  class="m3-container"
44
33
  class:leading-icon={leadingIcon}
45
- class:trailing-icon={trailingIcon}
34
+ class:trailing-icon={trailing}
46
35
  class:error
47
36
  >
48
37
  <input
@@ -62,9 +51,11 @@
62
51
  {#if leadingIcon}
63
52
  <Icon icon={leadingIcon} class="leading" />
64
53
  {/if}
65
- {#if trailingIcon}
66
- <button onclick={trailingClick} class="trailing">
67
- <Icon icon={trailingIcon} />
54
+ {#if trailing}
55
+ {@const { icon, ...extra } = trailing}
56
+ <button type="button" class="trailing" {...extra}>
57
+ <Layer />
58
+ <Icon {icon} />
68
59
  </button>
69
60
  {/if}
70
61
  </div>
@@ -72,7 +63,7 @@
72
63
  <style>
73
64
  /*
74
65
  want to customize the label's background?
75
- do this: <TextFieldOutlined --m3-util-background="var(--m3-scheme-surface-container)" />
66
+ do this: <TextFieldOutlined --m3-util-background="rgb(var(--m3-scheme-surface-container))" />
76
67
  */
77
68
  :root {
78
69
  --m3-textfield-outlined-shape: var(--m3-util-rounding-extra-small);
@@ -101,9 +92,7 @@
101
92
  left: 0.75rem;
102
93
  top: 1rem;
103
94
  color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
104
- background-color: rgb(
105
- var(--m3-util-background, var(--m3-scheme-surface))
106
- ); /* TODO: next breaking change, make --m3-util-background a full color and update the comment above */
95
+ background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
107
96
  padding: 0 0.25rem;
108
97
  &:is(input:hover ~ label) {
109
98
  color: rgb(var(--error, var(--m3-scheme-on-surface)));
@@ -172,16 +161,6 @@
172
161
  cursor: pointer;
173
162
  }
174
163
 
175
- @media (hover: hover) {
176
- button:hover {
177
- background-color: rgb(var(--m3-scheme-on-surface-variant) / 0.08);
178
- }
179
- }
180
- button:focus-visible,
181
- button:active {
182
- background-color: rgb(var(--m3-scheme-on-surface-variant) / 0.12);
183
- }
184
-
185
164
  .leading-icon > input {
186
165
  padding-left: 3.25rem;
187
166
  }
@@ -1,21 +1,18 @@
1
1
  import type { IconifyIcon } from "@iconify/types";
2
2
  import type { HTMLInputAttributes } from "svelte/elements";
3
- type TrailingProps = {
4
- trailingIcon: IconifyIcon;
5
- trailingClick: () => void;
6
- } | {
7
- trailingIcon?: undefined;
8
- trailingClick?: undefined;
9
- };
3
+ import type { ButtonAttrs } from "../misc/typing-utils";
10
4
  type $$ComponentProps = {
11
5
  label: string;
12
6
  leadingIcon?: IconifyIcon;
7
+ trailing?: {
8
+ icon: IconifyIcon;
9
+ } & ButtonAttrs;
13
10
  disabled?: boolean;
14
11
  required?: boolean;
15
12
  error?: boolean;
16
13
  value?: string;
17
14
  enter?: () => void;
18
- } & TrailingProps & HTMLInputAttributes;
15
+ } & HTMLInputAttributes;
19
16
  declare const TextFieldOutlined: import("svelte").Component<$$ComponentProps, {}, "value">;
20
17
  type TextFieldOutlined = ReturnType<typeof TextFieldOutlined>;
21
18
  export default TextFieldOutlined;
@@ -4,7 +4,7 @@
4
4
  import type { HTMLTextareaAttributes } from "svelte/elements";
5
5
 
6
6
  let {
7
- label: _label,
7
+ label,
8
8
  leadingIcon,
9
9
  disabled = false,
10
10
  required = false,
@@ -34,8 +34,6 @@
34
34
  },
35
35
  };
36
36
  };
37
-
38
- let label = $derived(_label || extra.name); // TODO: next breaking version, drop name backsupport
39
37
  </script>
40
38
 
41
39
  <div class="m3-container" class:leading-icon={leadingIcon} class:error use:resize>
@@ -60,7 +58,7 @@
60
58
  <style>
61
59
  /*
62
60
  want to customize the label's background?
63
- do this: <TextFieldOutlinedMultiline --m3-util-background="var(--m3-scheme-surface-container)" />
61
+ do this: <TextFieldOutlinedMultiline --m3-util-background="rgb(var(--m3-scheme-surface-container))" />
64
62
  */
65
63
  :root {
66
64
  --m3-textfield-outlined-shape: var(--m3-util-rounding-extra-small);
@@ -90,9 +88,7 @@
90
88
  left: 0.75rem;
91
89
  top: 1rem;
92
90
  color: rgb(var(--error, var(--m3-scheme-on-surface-variant)));
93
- background-color: rgb(
94
- var(--m3-util-background, var(--m3-scheme-surface))
95
- ); /* TODO: next breaking change, make --m3-util-background a full color and update the comment above */
91
+ background-color: var(--m3-util-background, rgb(var(--m3-scheme-surface)));
96
92
  padding: 0 0.25rem;
97
93
  &:is(textarea:hover ~ label) {
98
94
  color: rgb(var(--error, var(--m3-scheme-on-surface)));
@@ -19,11 +19,11 @@
19
19
  <div class="m3-container">
20
20
  {#if clearable}
21
21
  <span class="left">
22
- <Button variant="text" click={clear} type="button">Clear</Button>
22
+ <Button variant="text" onclick={clear} type="button">Clear</Button>
23
23
  </span>
24
24
  {/if}
25
- <Button variant="text" click={cancel} type="button">Cancel</Button>
26
- <Button variant="text" disabled={!clearable && !chosenDate} click={ok} type="button">OK</Button>
25
+ <Button variant="text" onclick={cancel} type="button">Cancel</Button>
26
+ <Button variant="text" disabled={!clearable && !chosenDate} onclick={ok} type="button">OK</Button>
27
27
  </div>
28
28
 
29
29
  <style>
@@ -45,7 +45,7 @@
45
45
  day.day == today.getDate()}
46
46
  selected={!day.disabled && day.iso == chosenDate}
47
47
  label={day.day.toString()}
48
- click={() => (chosenDate = day.iso)}
48
+ onclick={() => (chosenDate = day.iso)}
49
49
  />
50
50
  {/each}
51
51
  </div>
@@ -16,7 +16,12 @@
16
16
 
17
17
  <div class="m3-container">
18
18
  {#each options as { name, selected, activate }}
19
- <button class="m3-font-body-large" onclick={activate} use:conditionalScroll={selected}>
19
+ <button
20
+ type="button"
21
+ class="m3-font-body-large"
22
+ onclick={activate}
23
+ use:conditionalScroll={selected}
24
+ >
20
25
  <Layer />
21
26
  {#if selected}
22
27
  <Icon icon={iconCheck} />
@@ -6,13 +6,13 @@
6
6
  today,
7
7
  selected,
8
8
  label,
9
- click,
9
+ onclick,
10
10
  }: {
11
11
  disabled: boolean;
12
12
  today: boolean;
13
13
  selected: boolean;
14
14
  label: string;
15
- click: () => void;
15
+ onclick: () => void;
16
16
  } = $props();
17
17
  </script>
18
18
 
@@ -22,7 +22,7 @@
22
22
  type="button"
23
23
  class:today
24
24
  class:selected
25
- onclick={click}
25
+ {onclick}
26
26
  >
27
27
  <Layer />
28
28
  {label}
@@ -3,7 +3,7 @@ type $$ComponentProps = {
3
3
  today: boolean;
4
4
  selected: boolean;
5
5
  label: string;
6
- click: () => void;
6
+ onclick: () => void;
7
7
  };
8
8
  declare const Item: import("svelte").Component<$$ComponentProps, {}, "">;
9
9
  type Item = ReturnType<typeof Item>;
@@ -27,6 +27,8 @@ export { default as CircularProgress } from "./forms/CircularProgress.svelte";
27
27
  export { default as CircularProgressEstimate } from "./forms/CircularProgressEstimate.svelte";
28
28
  export { default as CircularProgressIndeterminate } from "./forms/CircularProgressIndeterminate.svelte";
29
29
  export { default as LoadingIndicator } from "./forms/LoadingIndicator.svelte";
30
+ export { default as DateField } from "./forms/DateField.svelte";
31
+ export { default as DateFieldOutlined } from "./forms/DateFieldOutlined.svelte";
30
32
  export { default as RadioAnim1 } from "./forms/RadioAnim1.svelte";
31
33
  export { default as RadioAnim2 } from "./forms/RadioAnim2.svelte";
32
34
  export { default as RadioAnim3 } from "./forms/RadioAnim3.svelte";
@@ -48,5 +50,3 @@ export { default as VariableTabs } from "./nav/VariableTabs.svelte";
48
50
  export { default as VariableTabsLink } from "./nav/VariableTabsLink.svelte";
49
51
  export { default as ChipChooser } from "./utils/ChipChooser.svelte";
50
52
  export { default as Divider } from "./utils/Divider.svelte";
51
- export { default as DateField } from "./utils/DateField.svelte";
52
- export { default as DateFieldOutlined } from "./utils/DateFieldOutlined.svelte";
package/package/index.js CHANGED
@@ -26,6 +26,8 @@ export { default as CircularProgress } from "./forms/CircularProgress.svelte";
26
26
  export { default as CircularProgressEstimate } from "./forms/CircularProgressEstimate.svelte";
27
27
  export { default as CircularProgressIndeterminate } from "./forms/CircularProgressIndeterminate.svelte";
28
28
  export { default as LoadingIndicator } from "./forms/LoadingIndicator.svelte";
29
+ export { default as DateField } from "./forms/DateField.svelte";
30
+ export { default as DateFieldOutlined } from "./forms/DateFieldOutlined.svelte";
29
31
  export { default as RadioAnim1 } from "./forms/RadioAnim1.svelte";
30
32
  export { default as RadioAnim2 } from "./forms/RadioAnim2.svelte";
31
33
  export { default as RadioAnim3 } from "./forms/RadioAnim3.svelte";
@@ -47,5 +49,3 @@ export { default as VariableTabs } from "./nav/VariableTabs.svelte";
47
49
  export { default as VariableTabsLink } from "./nav/VariableTabsLink.svelte";
48
50
  export { default as ChipChooser } from "./utils/ChipChooser.svelte";
49
51
  export { default as Divider } from "./utils/Divider.svelte";
50
- export { default as DateField } from "./utils/DateField.svelte";
51
- export { default as DateFieldOutlined } from "./utils/DateFieldOutlined.svelte";
@@ -160,10 +160,10 @@
160
160
  transition: opacity var(--m3-util-easing-fast);
161
161
 
162
162
  &:not(
163
- :global(input:disabled + label) > .tint,
164
- :global(input:disabled + .layer-container) > .tint,
165
- :global(:disabled) > .tint
166
- ) {
163
+ :global(input:disabled + label) > .tint,
164
+ :global(input:disabled + .layer-container) > .tint,
165
+ :global(:disabled) > .tint
166
+ ) {
167
167
  @media (hover: hover) {
168
168
  &:is(:global(:hover) > .tint) {
169
169
  opacity: 0.08;
@@ -14,10 +14,10 @@
14
14
  transition: opacity var(--m3-util-easing-fast);
15
15
 
16
16
  &:not(
17
- :global(input:disabled + label) > .tint,
18
- :global(input:disabled + .layer-container) > .tint,
19
- :global(:disabled) > .tint
20
- ) {
17
+ :global(input:disabled + label) > .tint,
18
+ :global(input:disabled + .layer-container) > .tint,
19
+ :global(:disabled) > .tint
20
+ ) {
21
21
  @media (hover: hover) {
22
22
  &:is(:global(:hover) > .tint) {
23
23
  opacity: 0.08;
@@ -0,0 +1,3 @@
1
+ import type { HTMLButtonAttributes } from "svelte/elements";
2
+ export type NotButton<T> = Omit<T, "onclick">;
3
+ export type ButtonAttrs = HTMLButtonAttributes & Required<Pick<HTMLButtonAttributes, "onclick">>;
@@ -0,0 +1 @@
1
+ export {};
@@ -18,6 +18,7 @@
18
18
  {#if "click" in props}
19
19
  {@const { variant, icon, text, selected, click, ...extra } = props}
20
20
  <button
21
+ type="button"
21
22
  onclick={click}
22
23
  class="m3-container m3-font-label-medium {variant}"
23
24
  disabled={selected}
@@ -17,7 +17,7 @@
17
17
  {...option}
18
18
  variant="input"
19
19
  selected={chosenOptions.includes(option.value)}
20
- click={() =>
20
+ onclick={() =>
21
21
  chosenOptions.includes(option.value)
22
22
  ? (chosenOptions = chosenOptions.filter((o) => o != option.value))
23
23
  : (chosenOptions = [...chosenOptions, option.value])}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3-svelte",
3
- "version": "4.6.7",
3
+ "version": "5.0.0",
4
4
  "license": "Apache-2.0 OR GPL-3.0-only",
5
5
  "repository": "KTibow/m3-svelte",
6
6
  "author": {