contain-css-svelte 1.1.20 → 1.2.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 (94) hide show
  1. package/dist/Card.svelte +15 -6
  2. package/dist/Card.svelte.d.ts +4 -5
  3. package/dist/controls/Button.svelte +19 -5
  4. package/dist/controls/Button.svelte.d.ts +4 -4
  5. package/dist/controls/ButtonLink.svelte +17 -14
  6. package/dist/controls/ButtonLink.svelte.d.ts +4 -4
  7. package/dist/controls/Checkbox.svelte +15 -8
  8. package/dist/controls/Checkbox.svelte.d.ts +4 -4
  9. package/dist/controls/CircleButton.svelte +14 -7
  10. package/dist/controls/CircleButton.svelte.d.ts +4 -4
  11. package/dist/controls/Input.svelte +14 -3
  12. package/dist/controls/Input.svelte.d.ts +4 -3
  13. package/dist/controls/Option.svelte +4 -3
  14. package/dist/controls/Option.svelte.d.ts +3 -2
  15. package/dist/controls/RadioButton.svelte +14 -7
  16. package/dist/controls/RadioButton.svelte.d.ts +4 -4
  17. package/dist/controls/Select.svelte +15 -3
  18. package/dist/controls/Select.svelte.d.ts +4 -3
  19. package/dist/controls/Slider.svelte +5 -11
  20. package/dist/controls/Slider.svelte.d.ts +3 -3
  21. package/dist/controls/TabItem.svelte +24 -5
  22. package/dist/controls/TabItem.svelte.d.ts +4 -4
  23. package/dist/controls/Toggle.svelte +21 -5
  24. package/dist/controls/Toggle.svelte.d.ts +4 -4
  25. package/dist/dropdowns/DropdownMenu.svelte +18 -6
  26. package/dist/dropdowns/DropdownMenu.svelte.d.ts +4 -4
  27. package/dist/layout/Accordion.svelte +17 -2
  28. package/dist/layout/Accordion.svelte.d.ts +5 -3
  29. package/dist/layout/Bar.svelte +13 -7
  30. package/dist/layout/Bar.svelte.d.ts +4 -4
  31. package/dist/layout/Column.svelte.d.ts +3 -3
  32. package/dist/layout/ColumnContainer.svelte +12 -9
  33. package/dist/layout/ColumnContainer.svelte.d.ts +4 -4
  34. package/dist/layout/Columns.svelte +4 -3
  35. package/dist/layout/Columns.svelte.d.ts +7 -3
  36. package/dist/layout/Container.svelte +23 -8
  37. package/dist/layout/Container.svelte.d.ts +7 -5
  38. package/dist/layout/DataList.svelte +15 -7
  39. package/dist/layout/DataList.svelte.d.ts +5 -4
  40. package/dist/layout/DataListItem.svelte +14 -8
  41. package/dist/layout/DataListItem.svelte.d.ts +4 -4
  42. package/dist/layout/Fieldset.svelte +16 -8
  43. package/dist/layout/Fieldset.svelte.d.ts +6 -3
  44. package/dist/layout/Form.svelte +17 -8
  45. package/dist/layout/Form.svelte.d.ts +8 -6
  46. package/dist/layout/FormItem.svelte +12 -7
  47. package/dist/layout/FormItem.svelte.d.ts +4 -3
  48. package/dist/layout/FormProvider.svelte +3 -0
  49. package/dist/layout/GridLayout.svelte +14 -9
  50. package/dist/layout/GridLayout.svelte.d.ts +4 -4
  51. package/dist/layout/GridRow.svelte +6 -10
  52. package/dist/layout/GridRow.svelte.d.ts +3 -2
  53. package/dist/layout/Hero.svelte +14 -8
  54. package/dist/layout/Hero.svelte.d.ts +4 -4
  55. package/dist/layout/Inline.svelte +16 -15
  56. package/dist/layout/Inline.svelte.d.ts +4 -4
  57. package/dist/layout/MenuList.svelte +13 -6
  58. package/dist/layout/MenuList.svelte.d.ts +4 -4
  59. package/dist/layout/Page.svelte +14 -8
  60. package/dist/layout/Page.svelte.d.ts +11 -3
  61. package/dist/layout/ResponsiveText.svelte +4 -0
  62. package/dist/layout/Row.svelte.d.ts +3 -3
  63. package/dist/layout/RowContainer.svelte +12 -9
  64. package/dist/layout/RowContainer.svelte.d.ts +4 -4
  65. package/dist/layout/Sidebar.svelte +17 -6
  66. package/dist/layout/Sidebar.svelte.d.ts +12 -4
  67. package/dist/layout/SplitPane.svelte +8 -14
  68. package/dist/layout/SplitPane.svelte.d.ts +16 -2
  69. package/dist/layout/Stack.svelte +16 -15
  70. package/dist/layout/Stack.svelte.d.ts +4 -4
  71. package/dist/layout/TabBar.svelte +12 -2
  72. package/dist/layout/TabBar.svelte.d.ts +17 -10
  73. package/dist/layout/Table.svelte +5 -1
  74. package/dist/layout/Tile.svelte +40 -27
  75. package/dist/layout/Tile.svelte.d.ts +32 -10
  76. package/dist/misc/Code.svelte +2 -0
  77. package/dist/misc/Progress.svelte +25 -8
  78. package/dist/misc/Progress.svelte.d.ts +15 -8
  79. package/dist/misc/Tag.svelte +97 -44
  80. package/dist/misc/Tag.svelte.d.ts +17 -5
  81. package/dist/overlays/Dialog.svelte +18 -5
  82. package/dist/overlays/Dialog.svelte.d.ts +5 -3
  83. package/dist/overlays/Tooltip.svelte +21 -3
  84. package/dist/overlays/Tooltip.svelte.d.ts +5 -3
  85. package/dist/styleProps.d.ts +67 -0
  86. package/dist/styleProps.js +76 -0
  87. package/dist/types.d.ts +40 -1
  88. package/dist/types.js +1 -1
  89. package/dist/typography/Text.svelte +4 -11
  90. package/dist/typography/TextLayout.svelte +4 -7
  91. package/dist/typography/TextLayout.svelte.d.ts +4 -3
  92. package/dist/util.d.ts +60 -3
  93. package/dist/util.js +101 -11
  94. package/package.json +1 -1
package/dist/Card.svelte CHANGED
@@ -1,8 +1,17 @@
1
- <script lang="ts">import { injectVars } from "./util";
2
- let { header, footer, children, height, fixedHeight, center, ...restProps } = $props();
3
- const cssVars = $derived(injectVars({ height, ...restProps }, "card", [
4
- "bg",
5
- "fg",
1
+ <script lang="ts">import { elementProps } from "./util";
2
+ import { COLOR_VARS, TYPOGRAPHY_CONTAINER_VARS, } from "./styleProps";
3
+ let { header, footer, children, height, fixedHeight, center, class: className, ...restProps } = $props();
4
+ /* `height` is destructured (the $effect below reads it), so it has to be
5
+ handed back explicitly -- rest props no longer carry it. */
6
+ /* The shorthands card's own CSS backs, one group per mixin it
7
+ includes. The Props type is derived from this same array, so what the
8
+ component accepts and what it emits cannot drift apart. */
9
+ const CARD_VARS = [
10
+ ...COLOR_VARS,
11
+ ...TYPOGRAPHY_CONTAINER_VARS,
12
+ ];
13
+ const el = $derived(elementProps({ height, ...restProps }, "card", [
14
+ ...CARD_VARS,
6
15
  "padding",
7
16
  "width",
8
17
  "height",
@@ -19,7 +28,7 @@ let hasHeader = $derived(Boolean(header));
19
28
  let hasFooter = $derived(Boolean(footer));
20
29
  </script>
21
30
 
22
- <div class="card" class:center class:fixedHeight style={cssVars}>
31
+ <div class={["card", className]} class:center class:fixedHeight {...el}>
23
32
  <header class:hide={!hasHeader}>
24
33
  {#if header}{@render header()}{/if}
25
34
  </header>
@@ -1,14 +1,13 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLAttributes } from "svelte/elements";
3
- import type { CardStyleProps } from "./types";
4
- type Props = {
3
+ import type { CardStyleProps, ContainProps } from "./types";
4
+ import { type StyleProps } from "./styleProps";
5
+ declare const Card: import("svelte").Component<ContainProps<HTMLAttributes<HTMLElement>, {
5
6
  header?: Snippet;
6
7
  footer?: Snippet;
7
8
  children?: Snippet;
8
9
  center?: boolean;
9
- height?: string;
10
10
  fixedHeight?: boolean;
11
- } & CardStyleProps & HTMLAttributes<HTMLElement>;
12
- declare const Card: import("svelte").Component<Props, {}, "">;
11
+ }, CardStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant", "lineWidth"]>>, {}, "">;
13
12
  type Card = ReturnType<typeof Card>;
14
13
  export default Card;
@@ -1,10 +1,24 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { primary = false, secondary = false, warning = false, danger = false, success = false, info = false, icon, children, ...restProps } = $props();
3
- const style = $derived(injectVars(restProps, "button", ["bg", "fg", "padding", "width", "height"]));
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { primary = false, secondary = false, warning = false, danger = false, success = false, info = false, icon, children, class: className, ...restProps } = $props();
4
+ /* The shorthands button's own CSS backs, one group per mixin it
5
+ includes. The Props type is derived from this same array, so what the
6
+ component accepts and what it emits cannot drift apart. */
7
+ const BUTTON_VARS = [
8
+ ...COLOR_VARS,
9
+ ...PADDING_VARS,
10
+ ...RADIUS_VARS,
11
+ ...TYPOGRAPHY_VARS,
12
+ ];
13
+ const el = $derived(elementProps(restProps, "button", [
14
+ ...BUTTON_VARS,
15
+ "width",
16
+ "height",
17
+ ]));
4
18
  </script>
5
19
 
6
20
  <button
7
- {style}
21
+ class={className}
8
22
  class:primary
9
23
  class:secondary
10
24
  class:warning
@@ -12,7 +26,7 @@ const style = $derived(injectVars(restProps, "button", ["bg", "fg", "padding", "
12
26
  class:success
13
27
  class:info
14
28
  class:has-icon={icon}
15
- {...restProps}
29
+ {...el}
16
30
  >
17
31
  <span class="content">{@render children?.()}</span>
18
32
  {#if icon}
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLButtonAttributes } from "svelte/elements";
3
- import type { BaseStyleProps } from "../types";
4
- type Props = {
3
+ import type { BaseStyleProps, ContainProps } from "../types";
4
+ import { type StyleProps } from "../styleProps";
5
+ declare const Button: import("svelte").Component<ContainProps<HTMLButtonAttributes, {
5
6
  primary?: boolean;
6
7
  secondary?: boolean;
7
8
  warning?: boolean;
@@ -10,7 +11,6 @@ type Props = {
10
11
  info?: boolean;
11
12
  icon?: Snippet;
12
13
  children?: Snippet;
13
- } & BaseStyleProps & HTMLButtonAttributes;
14
- declare const Button: import("svelte").Component<Props, {}, "">;
14
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "">;
15
15
  type Button = ReturnType<typeof Button>;
16
16
  export default Button;
@@ -1,25 +1,28 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { primary = false, secondary = false, warning = false, danger = false, success = false, info = false, href = "#", id = null, icon, children, ...restProps } = $props();
3
- const inlineStyle = $derived(restProps.style);
4
- const elementProps = $derived.by(() => {
5
- const { style: _, ...rest } = restProps;
6
- return rest;
7
- });
8
- const style = $derived(`${injectVars(elementProps, "button", [
9
- "bg",
10
- "fg",
11
- "padding",
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { primary = false, secondary = false, warning = false, danger = false, success = false, info = false, href = "#", id = null, icon, children, class: className, ...restProps } = $props();
4
+ /* The shorthands button's own CSS backs, one group per mixin it
5
+ includes. The Props type is derived from this same array, so what the
6
+ component accepts and what it emits cannot drift apart. */
7
+ const BUTTON_LINK_VARS = [
8
+ ...COLOR_VARS,
9
+ ...PADDING_VARS,
10
+ ...RADIUS_VARS,
11
+ ...TYPOGRAPHY_VARS,
12
+ ];
13
+ const el = $derived(elementProps(restProps, "button", [
14
+ ...BUTTON_LINK_VARS,
12
15
  "width",
13
16
  "height",
14
- ])}${inlineStyle ?? ""}`);
17
+ ]));
15
18
  const iconSlotted = $derived(Boolean(icon));
16
19
  </script>
17
20
 
18
21
  <a
19
22
  role="button"
20
- {style}
21
23
  {href}
22
24
  id={id ?? undefined}
25
+ class={className}
23
26
  class:primary
24
27
  class:secondary
25
28
  class:warning
@@ -27,7 +30,7 @@ const iconSlotted = $derived(Boolean(icon));
27
30
  class:success
28
31
  class:info
29
32
  class:has-icon={iconSlotted}
30
- {...elementProps}
33
+ {...el}
31
34
  >
32
35
  <span class="content">{@render children?.()}</span>
33
36
  <span class:hidden={!iconSlotted} class="icon">
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLAnchorAttributes } from "svelte/elements";
3
- import type { BaseStyleProps } from "../types";
4
- type Props = {
3
+ import type { BaseStyleProps, ContainProps } from "../types";
4
+ import { type StyleProps } from "../styleProps";
5
+ declare const ButtonLink: import("svelte").Component<ContainProps<HTMLAnchorAttributes, {
5
6
  primary?: boolean;
6
7
  secondary?: boolean;
7
8
  warning?: boolean;
@@ -12,7 +13,6 @@ type Props = {
12
13
  id?: string | null;
13
14
  icon?: Snippet;
14
15
  children?: Snippet;
15
- } & BaseStyleProps & HTMLAnchorAttributes;
16
- declare const ButtonLink: import("svelte").Component<Props, {}, "">;
16
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "">;
17
17
  type ButtonLink = ReturnType<typeof ButtonLink>;
18
18
  export default ButtonLink;
@@ -1,8 +1,15 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { checked = $bindable(undefined), name = "", value = undefined, group = $bindable(undefined), children, ...restProps } = $props();
3
- const style = $derived(injectVars(restProps, "checkbox", [
4
- "bg",
5
- "fg",
1
+ <script lang="ts">import { splitProps } from "../util";
2
+ import { COLOR_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { checked = $bindable(undefined), name = "", value = undefined, group = $bindable(undefined), children, class: className, ...restProps } = $props();
4
+ /* The shorthands checkbox's own CSS backs, one group per mixin it
5
+ includes. The Props type is derived from this same array, so what the
6
+ component accepts and what it emits cannot drift apart. */
7
+ const CHECKBOX_VARS = [
8
+ ...COLOR_VARS,
9
+ ...TYPOGRAPHY_VARS,
10
+ ];
11
+ const el = $derived(splitProps(restProps, "checkbox", [
12
+ ...CHECKBOX_VARS,
6
13
  "padding",
7
14
  "width",
8
15
  "height",
@@ -29,7 +36,7 @@ function handleGroupChange(event) {
29
36
  let ref = $state(null);
30
37
  </script>
31
38
 
32
- <div class="label-sizing-box" {style}>
39
+ <div class={["label-sizing-box", className]} style={el.style}>
33
40
  <label class="checkbox-item">
34
41
  {#if useGroup}
35
42
  <input
@@ -38,14 +45,14 @@ let ref = $state(null);
38
45
  {value}
39
46
  checked={isChecked}
40
47
  onchange={handleGroupChange}
41
- {...restProps}
48
+ {...el.attrs}
42
49
  />
43
50
  {:else}
44
51
  <input
45
52
  name={name || (ref && ref.textContent) || undefined}
46
53
  type="checkbox"
47
54
  bind:checked
48
- {...restProps}
55
+ {...el.attrs}
49
56
  />
50
57
  {/if}
51
58
  <span bind:this={ref}>{@render children?.()}</span>
@@ -1,13 +1,13 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLInputAttributes } from "svelte/elements";
3
- import type { BaseStyleProps } from "../types";
4
- type Props = {
3
+ import type { BaseStyleProps, ContainProps } from "../types";
4
+ import { type StyleProps } from "../styleProps";
5
+ declare const Checkbox: import("svelte").Component<ContainProps<HTMLInputAttributes, {
5
6
  checked?: boolean | undefined;
6
7
  name?: string;
7
8
  value?: any;
8
9
  group?: any[];
9
10
  children?: Snippet;
10
- } & BaseStyleProps & Omit<HTMLInputAttributes, "value">;
11
- declare const Checkbox: import("svelte").Component<Props, {}, "group" | "checked">;
11
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>, "type" | "value">, {}, "checked" | "group">;
12
12
  type Checkbox = ReturnType<typeof Checkbox>;
13
13
  export default Checkbox;
@@ -1,8 +1,15 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { primary = false, warning = false, danger = false, success = false, info = false, type = "button", children, ...restProps } = $props();
3
- const style = $derived(injectVars(restProps, "mini-button", [
4
- "bg",
5
- "fg",
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { primary = false, warning = false, danger = false, success = false, info = false, type = "button", children, class: className, ...restProps } = $props();
4
+ /* The shorthands mini-button's own CSS backs, one group per mixin it
5
+ includes. The Props type is derived from this same array, so what the
6
+ component accepts and what it emits cannot drift apart. */
7
+ const CIRCLE_BUTTON_VARS = [
8
+ ...COLOR_VARS,
9
+ ...TYPOGRAPHY_VARS,
10
+ ];
11
+ const el = $derived(elementProps(restProps, "mini-button", [
12
+ ...CIRCLE_BUTTON_VARS,
6
13
  "padding",
7
14
  "width",
8
15
  "height",
@@ -10,14 +17,14 @@ const style = $derived(injectVars(restProps, "mini-button", [
10
17
  </script>
11
18
 
12
19
  <button
13
- {style}
14
20
  {type}
21
+ class={className}
15
22
  class:primary
16
23
  class:warning
17
24
  class:danger
18
25
  class:success
19
26
  class:info
20
- {...restProps}
27
+ {...el}
21
28
  >
22
29
  {@render children?.()}
23
30
  </button>
@@ -1,6 +1,7 @@
1
1
  import type { HTMLButtonAttributes } from "svelte/elements";
2
- import type { BaseStyleProps } from "../types";
3
- type Props = {
2
+ import type { BaseStyleProps, ContainProps } from "../types";
3
+ import { type StyleProps } from "../styleProps";
4
+ declare const CircleButton: import("svelte").Component<ContainProps<HTMLButtonAttributes, {
4
5
  primary?: boolean;
5
6
  warning?: boolean;
6
7
  danger?: boolean;
@@ -8,7 +9,6 @@ type Props = {
8
9
  info?: boolean;
9
10
  type?: "button" | "submit" | "reset";
10
11
  children?: import("svelte").Snippet;
11
- } & BaseStyleProps & HTMLButtonAttributes;
12
- declare const CircleButton: import("svelte").Component<Props, {}, "">;
12
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "">;
13
13
  type CircleButton = ReturnType<typeof CircleButton>;
14
14
  export default CircleButton;
@@ -1,8 +1,19 @@
1
- <script lang="ts">let { value = $bindable(""), placeholder = "", ...restProps } = $props();
2
- export {};
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { value = $bindable(""), placeholder = "", class: className, ...restProps } = $props();
4
+ /* The shorthands this component's own CSS backs, one group per mixin
5
+ it includes. The Props type is derived from this same array, so what
6
+ the component accepts and what it emits cannot drift apart. */
7
+ const INPUT_VARS = [
8
+ ...COLOR_VARS,
9
+ ...PADDING_VARS,
10
+ ...RADIUS_VARS,
11
+ ...TYPOGRAPHY_VARS,
12
+ ];
13
+ const el = $derived(elementProps(restProps, "input", INPUT_VARS));
3
14
  </script>
4
15
 
5
- <input bind:value {placeholder} {...restProps} />
16
+ <input bind:value {placeholder} class={className} {...el} />
6
17
 
7
18
  <style>/* Logical, not top/bottom/left/right: margin-block/margin-inline already take
8
19
  one value (both sides equal) or two (start end), so there is no separate
@@ -1,8 +1,9 @@
1
1
  import type { HTMLInputAttributes } from "svelte/elements";
2
- type Props = {
2
+ import type { ContainProps } from "../types";
3
+ import { type StyleProps } from "../styleProps";
4
+ declare const Input: import("svelte").Component<ContainProps<HTMLInputAttributes, {
3
5
  value?: string | number;
4
6
  placeholder?: string;
5
- } & HTMLInputAttributes;
6
- declare const Input: import("svelte").Component<Props, {}, "value">;
7
+ }, StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "value">;
7
8
  type Input = ReturnType<typeof Input>;
8
9
  export default Input;
@@ -1,4 +1,6 @@
1
- <script lang="ts">let { children, value, ...restProps } = $props();
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ let { children, value, class: className, ...restProps } = $props();
3
+ const el = $derived(elementProps(restProps, "option"));
2
4
  let template = $state();
3
5
  // Extracted from the rendered children, in the DOM.
4
6
  let textContent = $state("");
@@ -31,10 +33,9 @@ $effect(() => {
31
33
  });
32
34
  return () => observer.disconnect();
33
35
  });
34
- export {};
35
36
  </script>
36
37
 
37
- <option data-html={htmlContent} {value} {...restProps}>
38
+ <option data-html={htmlContent} {value} class={className} {...el}>
38
39
  {@html textContent}
39
40
  </option>
40
41
 
@@ -1,8 +1,9 @@
1
1
  import type { HTMLOptionAttributes } from "svelte/elements";
2
- type Props = {
2
+ import type { ContainProps } from "../types";
3
+ type Props = ContainProps<HTMLOptionAttributes, {
3
4
  children?: import("svelte").Snippet;
4
5
  value?: any;
5
- } & Omit<HTMLOptionAttributes, "value">;
6
+ }, {}, "value">;
6
7
  declare const Option: import("svelte").Component<Props, {}, "">;
7
8
  type Option = ReturnType<typeof Option>;
8
9
  export default Option;
@@ -1,8 +1,15 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { group = $bindable(undefined), value = undefined, children, ...restProps } = $props();
3
- let style = $derived(injectVars(restProps, "radio-button", [
4
- "bg",
5
- "fg",
1
+ <script lang="ts">import { splitProps } from "../util";
2
+ import { COLOR_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { group = $bindable(undefined), value = undefined, children, class: className, ...restProps } = $props();
4
+ /* The shorthands radio-button's own CSS backs, one group per mixin it
5
+ includes. The Props type is derived from this same array, so what the
6
+ component accepts and what it emits cannot drift apart. */
7
+ const RADIO_BUTTON_VARS = [
8
+ ...COLOR_VARS,
9
+ ...TYPOGRAPHY_VARS,
10
+ ];
11
+ const el = $derived(splitProps(restProps, "radio-button", [
12
+ ...RADIO_BUTTON_VARS,
6
13
  "padding",
7
14
  "width",
8
15
  "height",
@@ -15,14 +22,14 @@ function handleChange() {
15
22
  }
16
23
  </script>
17
24
 
18
- <div class="label-sizing-box" {style}>
25
+ <div class={["label-sizing-box", className]} style={el.style}>
19
26
  <label class="radio-item">
20
27
  <input
21
28
  {value}
22
29
  type="radio"
23
30
  checked={isChecked}
24
31
  onchange={handleChange}
25
- {...restProps}
32
+ {...el.attrs}
26
33
  />
27
34
  <span>{@render children?.()}</span>
28
35
  </label>
@@ -1,11 +1,11 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLInputAttributes } from "svelte/elements";
3
- import type { BaseStyleProps } from "../types";
4
- type Props = {
3
+ import type { BaseStyleProps, ContainProps } from "../types";
4
+ import { type StyleProps } from "../styleProps";
5
+ declare const RadioButton: import("svelte").Component<ContainProps<HTMLInputAttributes, {
5
6
  group?: any;
6
7
  value?: any;
7
8
  children?: Snippet;
8
- } & BaseStyleProps & Omit<HTMLInputAttributes, "value">;
9
- declare const RadioButton: import("svelte").Component<Props, {}, "group">;
9
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>, "type" | "value">, {}, "group">;
10
10
  type RadioButton = ReturnType<typeof RadioButton>;
11
11
  export default RadioButton;
@@ -1,6 +1,18 @@
1
- <script lang="ts">import DropdownMenu from "../dropdowns/DropdownMenu.svelte";
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ import DropdownMenu from "../dropdowns/DropdownMenu.svelte";
2
4
  import { onMount, tick } from "svelte";
3
- let { value = $bindable(), children, "data-audit-action": dropdownAuditAction = null, matchMode = "prefix", typeaheadMode = "focus", ...restProps } = $props();
5
+ let { value = $bindable(), children, "data-audit-action": dropdownAuditAction = null, matchMode = "prefix", typeaheadMode = "focus", class: className, ...restProps } = $props();
6
+ /* The shorthands this component's own CSS backs, one group per mixin
7
+ it includes. The Props type is derived from this same array, so what
8
+ the component accepts and what it emits cannot drift apart. */
9
+ const SELECT_VARS = [
10
+ ...COLOR_VARS,
11
+ ...PADDING_VARS,
12
+ ...RADIUS_VARS,
13
+ ...TYPOGRAPHY_VARS,
14
+ ];
15
+ const el = $derived(elementProps(restProps, "select", SELECT_VARS));
4
16
  let selectElement = $state();
5
17
  let observer;
6
18
  let resizeObserver;
@@ -91,7 +103,7 @@ $effect(() => {
91
103
  });
92
104
  </script>
93
105
 
94
- <select bind:value bind:this={selectElement} {...restProps}>
106
+ <select bind:value bind:this={selectElement} class={className} {...el}>
95
107
  {@render children?.()}
96
108
  </select>
97
109
  <div class="dropdown-wrapper" style:--target-width={targetWidth}>
@@ -1,6 +1,8 @@
1
1
  import type { HTMLSelectAttributes } from "svelte/elements";
2
+ import type { ContainProps } from "../types";
3
+ import { type StyleProps } from "../styleProps";
2
4
  import type { MatchMode, TypeaheadMode } from "../dropdowns/DropdownMenu.svelte";
3
- type Props = {
5
+ declare const Select: import("svelte").Component<ContainProps<HTMLSelectAttributes, {
4
6
  value?: any;
5
7
  children?: import("svelte").Snippet;
6
8
  "data-audit-action"?: string | null;
@@ -8,7 +10,6 @@ type Props = {
8
10
  matchMode?: MatchMode;
9
11
  /** See {@link TypeaheadMode} on DropdownMenu -- focus a match or filter the list. */
10
12
  typeaheadMode?: TypeaheadMode;
11
- } & HTMLSelectAttributes;
12
- declare const Select: import("svelte").Component<Props, {}, "value">;
13
+ }, StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "value">;
13
14
  type Select = ReturnType<typeof Select>;
14
15
  export default Select;
@@ -1,26 +1,20 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { value = $bindable(0), min = 0, max = 100, step = 1, ...restProps } = $props();
3
- const inlineStyle = $derived(restProps.style);
4
- const elementProps = $derived.by(() => {
5
- const { style: _, ...rest } = restProps;
6
- return rest;
7
- });
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ let { value = $bindable(0), min = 0, max = 100, step = 1, class: className, ...restProps } = $props();
8
3
  const normalizedMin = $derived(Number.isFinite(min) ? min : 0);
9
4
  const normalizedMax = $derived(Number.isFinite(max) && max > normalizedMin ? max : normalizedMin + 1);
10
5
  const clampedValue = $derived(Math.min(Math.max(Number(value) || 0, normalizedMin), normalizedMax));
11
6
  const fillPercent = $derived(((clampedValue - normalizedMin) / (normalizedMax - normalizedMin)) * 100);
12
- const style = $derived(`${injectVars(elementProps, "slider", ["bg", "fg", "padding", "width", "height"])}--slider-percent: ${fillPercent}%;${inlineStyle ?? ""}`);
7
+ const el = $derived(elementProps(restProps, "slider", ["bg", "fg", "padding", "width", "height"], `--slider-percent: ${fillPercent}%;`));
13
8
  </script>
14
9
 
15
10
  <input
16
- class="slider"
11
+ class={["slider", className]}
17
12
  type="range"
18
13
  bind:value
19
14
  {min}
20
15
  {max}
21
16
  {step}
22
- {style}
23
- {...elementProps}
17
+ {...el}
24
18
  />
25
19
 
26
20
  <style>/* Logical, not top/bottom/left/right: margin-block/margin-inline already take
@@ -1,11 +1,11 @@
1
1
  import type { HTMLInputAttributes } from "svelte/elements";
2
- import type { BaseStyleProps } from "../types";
3
- type Props = {
2
+ import type { BaseStyleProps, ContainProps } from "../types";
3
+ type Props = ContainProps<HTMLInputAttributes, {
4
4
  value?: number;
5
5
  min?: number;
6
6
  max?: number;
7
7
  step?: number | "any";
8
- } & BaseStyleProps & Omit<HTMLInputAttributes, "type" | "value" | "min" | "max" | "step">;
8
+ }, BaseStyleProps, "type" | "value" | "min" | "max" | "step">;
9
9
  declare const Slider: import("svelte").Component<Props, {}, "value">;
10
10
  type Slider = ReturnType<typeof Slider>;
11
11
  export default Slider;
@@ -1,11 +1,30 @@
1
- <script lang="ts">import { injectVars } from "../util";
1
+ <script lang="ts">import { elementProps } from "../util";
2
+ import { COLOR_VARS, PADDING_VARS, RADIUS_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
2
3
  import Button from "./Button.svelte";
3
- const { active = false, icon, children, ...restProps } = $props();
4
- const style = $derived(injectVars(restProps, "tab", ["bg", "fg", "padding", "width", "height"]));
4
+ const { active = false, icon, children, class: className, ...restProps } = $props();
5
+ /* Everything goes to the Button, not to the wrapper. The wrapper is
6
+ `display: contents`, so it generates no box -- a caller's `style` put
7
+ there would be silently inert. The variables work on the Button too:
8
+ `.tab > button`'s rules read --tab-bg and friends, and a custom property
9
+ resolves on the element it is declared on. */
10
+ /* The shorthands tab's own CSS backs, one group per mixin it
11
+ includes. The Props type is derived from this same array, so what the
12
+ component accepts and what it emits cannot drift apart. */
13
+ const TAB_ITEM_VARS = [
14
+ ...COLOR_VARS,
15
+ ...PADDING_VARS,
16
+ ...RADIUS_VARS,
17
+ ...TYPOGRAPHY_VARS,
18
+ ];
19
+ const el = $derived(elementProps(restProps, "tab", [
20
+ ...TAB_ITEM_VARS,
21
+ "width",
22
+ "height",
23
+ ]));
5
24
  </script>
6
25
 
7
- <div class="tab" class:active {style}>
8
- <Button primary={active} {icon} {...restProps}>
26
+ <div class="tab" class:active>
27
+ <Button primary={active} {icon} class={className} {...el}>
9
28
  {@render children?.()}
10
29
  </Button>
11
30
  </div>
@@ -1,11 +1,11 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { HTMLAttributes } from "svelte/elements";
3
- import type { BaseStyleProps } from "../types";
4
- type Props = {
3
+ import type { BaseStyleProps, ContainProps } from "../types";
4
+ import { type StyleProps } from "../styleProps";
5
+ declare const TabItem: import("svelte").Component<ContainProps<HTMLAttributes<HTMLButtonElement>, {
5
6
  active?: boolean;
6
7
  icon?: Snippet;
7
8
  children?: Snippet;
8
- } & BaseStyleProps & HTMLAttributes<HTMLButtonElement>;
9
- declare const TabItem: import("svelte").Component<Props, {}, "">;
9
+ }, BaseStyleProps & StyleProps<readonly ["bg", "fg", "padding", "borderRadius", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "textTransform", "textDecoration", "fontVariant"]>>, {}, "">;
10
10
  type TabItem = ReturnType<typeof TabItem>;
11
11
  export default TabItem;
@@ -1,12 +1,28 @@
1
- <script lang="ts">import { injectVars } from "../util";
2
- let { checked = $bindable(false), name = "", onLabel, offLabel, children, ...restProps } = $props();
3
- const style = $derived(injectVars(restProps, "toggle", ["bg", "fg", "padding", "width", "height"]));
1
+ <script lang="ts">import { splitProps } from "../util";
2
+ import { COLOR_VARS, TYPOGRAPHY_VARS, } from "../styleProps";
3
+ let { checked = $bindable(false), name = "", onLabel, offLabel, children, class: className, ...restProps } = $props();
4
+ /* Variables and the caller's `style` go on the wrapper label, which is what
5
+ `.toggle`'s CSS targets; the attributes go on the input, which is what
6
+ `aria-*`, `required` and `data-*` are about. */
7
+ /* The shorthands toggle's own CSS backs, one group per mixin it
8
+ includes. The Props type is derived from this same array, so what the
9
+ component accepts and what it emits cannot drift apart. */
10
+ const TOGGLE_VARS = [
11
+ ...COLOR_VARS,
12
+ ...TYPOGRAPHY_VARS,
13
+ ];
14
+ const el = $derived(splitProps(restProps, "toggle", [
15
+ ...TOGGLE_VARS,
16
+ "padding",
17
+ "width",
18
+ "height",
19
+ ]));
4
20
  const hasOffLabel = $derived(Boolean(offLabel));
5
21
  const hasOnLabel = $derived(Boolean(onLabel || children));
6
22
  const effectiveOnLabel = $derived(onLabel || children);
7
23
  </script>
8
24
 
9
- <label class="toggle" {style}>
25
+ <label class={["toggle", className]} style={el.style}>
10
26
  {#if hasOffLabel}
11
27
  <span class="toggle-label toggle-label-off">{@render offLabel?.()}</span>
12
28
  {/if}
@@ -16,7 +32,7 @@ const effectiveOnLabel = $derived(onLabel || children);
16
32
  name={name || undefined}
17
33
  type="checkbox"
18
34
  bind:checked
19
- {...restProps}
35
+ {...el.attrs}
20
36
  />
21
37
  <span class="toggle-track" aria-hidden="true">
22
38
  <span class="toggle-thumb"></span>