m3-svelte 4.6.7 → 5.1.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 (46) 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/Slider.svelte +207 -31
  24. package/package/forms/Slider.svelte.d.ts +7 -1
  25. package/package/forms/SliderTicks.svelte +8 -238
  26. package/package/forms/SliderTicks.svelte.d.ts +9 -5
  27. package/package/forms/TextField.svelte +13 -31
  28. package/package/forms/TextField.svelte.d.ts +5 -8
  29. package/package/forms/TextFieldMultiline.svelte +1 -3
  30. package/package/forms/TextFieldOutlined.svelte +15 -36
  31. package/package/forms/TextFieldOutlined.svelte.d.ts +5 -8
  32. package/package/forms/TextFieldOutlinedMultiline.svelte +3 -7
  33. package/package/forms/_picker/Actions.svelte +3 -3
  34. package/package/forms/_picker/CalendarPicker.svelte +1 -1
  35. package/package/forms/_picker/FocusPicker.svelte +6 -1
  36. package/package/forms/_picker/Item.svelte +3 -3
  37. package/package/forms/_picker/Item.svelte.d.ts +1 -1
  38. package/package/index.d.ts +2 -3
  39. package/package/index.js +2 -3
  40. package/package/misc/_ripple.svelte +4 -4
  41. package/package/misc/_ripplesimple.svelte +4 -4
  42. package/package/misc/typing-utils.d.ts +3 -0
  43. package/package/misc/typing-utils.js +1 -0
  44. package/package/nav/NavCMLXItem.svelte +1 -0
  45. package/package/utils/ChipChooser.svelte +1 -1
  46. package/package.json +2 -2
@@ -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;