@nqmcreative/ui 0.2.3 → 0.3.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 (170) hide show
  1. package/README.md +15 -15
  2. package/cli/index.mjs +81 -42
  3. package/dist/core/toast.svelte.d.ts +3 -0
  4. package/dist/styles/matte/AccordionItem.svelte +5 -0
  5. package/dist/styles/matte/AccordionItem.svelte.d.ts +2 -0
  6. package/dist/styles/matte/Avatar.svelte +15 -0
  7. package/dist/styles/matte/Avatar.svelte.d.ts +3 -0
  8. package/dist/styles/matte/Badge.svelte +5 -0
  9. package/dist/styles/matte/Badge.svelte.d.ts +2 -0
  10. package/dist/styles/matte/Breadcrumb.svelte +11 -4
  11. package/dist/styles/matte/Breadcrumb.svelte.d.ts +3 -0
  12. package/dist/styles/matte/Button.svelte +58 -7
  13. package/dist/styles/matte/Button.svelte.d.ts +14 -2
  14. package/dist/styles/matte/Card.svelte +6 -1
  15. package/dist/styles/matte/Card.svelte.d.ts +2 -0
  16. package/dist/styles/matte/CheckboxGroup.svelte +6 -0
  17. package/dist/styles/matte/CheckboxGroup.svelte.d.ts +2 -0
  18. package/dist/styles/matte/Combobox.svelte +5 -0
  19. package/dist/styles/matte/Combobox.svelte.d.ts +3 -0
  20. package/dist/styles/matte/CommandPalette.svelte +6 -0
  21. package/dist/styles/matte/CommandPalette.svelte.d.ts +3 -0
  22. package/dist/styles/matte/Drawer.svelte +5 -0
  23. package/dist/styles/matte/Drawer.svelte.d.ts +2 -0
  24. package/dist/styles/matte/Footer.svelte +6 -2
  25. package/dist/styles/matte/Footer.svelte.d.ts +2 -0
  26. package/dist/styles/matte/Link.svelte +9 -0
  27. package/dist/styles/matte/Link.svelte.d.ts +4 -0
  28. package/dist/styles/matte/MenuItem.svelte +2 -1
  29. package/dist/styles/matte/Modal.svelte +5 -0
  30. package/dist/styles/matte/Modal.svelte.d.ts +2 -0
  31. package/dist/styles/matte/MultiSelect.svelte +7 -1
  32. package/dist/styles/matte/MultiSelect.svelte.d.ts +3 -0
  33. package/dist/styles/matte/Navbar.svelte +18 -4
  34. package/dist/styles/matte/Navbar.svelte.d.ts +2 -0
  35. package/dist/styles/matte/PricingCard.svelte +16 -8
  36. package/dist/styles/matte/PricingCard.svelte.d.ts +2 -0
  37. package/dist/styles/matte/RadioGroup.svelte +6 -0
  38. package/dist/styles/matte/RadioGroup.svelte.d.ts +2 -0
  39. package/dist/styles/matte/SegmentedControl.svelte +16 -2
  40. package/dist/styles/matte/SegmentedControl.svelte.d.ts +5 -0
  41. package/dist/styles/matte/Sidebar.svelte +2 -1
  42. package/dist/styles/matte/Stat.svelte +8 -1
  43. package/dist/styles/matte/Stat.svelte.d.ts +3 -0
  44. package/dist/styles/matte/Steps.svelte +7 -0
  45. package/dist/styles/matte/Steps.svelte.d.ts +3 -0
  46. package/dist/styles/matte/Table.svelte +153 -97
  47. package/dist/styles/matte/Table.svelte.d.ts +12 -0
  48. package/dist/styles/matte/Tabs.svelte +5 -0
  49. package/dist/styles/matte/Tabs.svelte.d.ts +3 -0
  50. package/dist/styles/matte/Toaster.svelte +3 -0
  51. package/dist/styles/matte/icon.d.ts +21 -0
  52. package/dist/styles/matte/icon.js +21 -0
  53. package/dist/styles/matte/index.d.ts +0 -2
  54. package/dist/styles/matte/index.js +0 -2
  55. package/dist/styles/paper/AccordionItem.svelte +5 -0
  56. package/dist/styles/paper/AccordionItem.svelte.d.ts +2 -0
  57. package/dist/styles/paper/Avatar.svelte +15 -0
  58. package/dist/styles/paper/Avatar.svelte.d.ts +3 -0
  59. package/dist/styles/paper/Badge.svelte +5 -0
  60. package/dist/styles/paper/Badge.svelte.d.ts +2 -0
  61. package/dist/styles/paper/Breadcrumb.svelte +8 -4
  62. package/dist/styles/paper/Breadcrumb.svelte.d.ts +3 -0
  63. package/dist/styles/paper/Button.svelte +58 -7
  64. package/dist/styles/paper/Button.svelte.d.ts +14 -2
  65. package/dist/styles/paper/Card.svelte +6 -1
  66. package/dist/styles/paper/Card.svelte.d.ts +2 -0
  67. package/dist/styles/paper/CheckboxGroup.svelte +6 -0
  68. package/dist/styles/paper/CheckboxGroup.svelte.d.ts +2 -0
  69. package/dist/styles/paper/Combobox.svelte +5 -0
  70. package/dist/styles/paper/Combobox.svelte.d.ts +3 -0
  71. package/dist/styles/paper/CommandPalette.svelte +6 -0
  72. package/dist/styles/paper/CommandPalette.svelte.d.ts +3 -0
  73. package/dist/styles/paper/Drawer.svelte +5 -0
  74. package/dist/styles/paper/Drawer.svelte.d.ts +2 -0
  75. package/dist/styles/paper/Footer.svelte +6 -2
  76. package/dist/styles/paper/Footer.svelte.d.ts +2 -0
  77. package/dist/styles/paper/Link.svelte +9 -0
  78. package/dist/styles/paper/Link.svelte.d.ts +4 -0
  79. package/dist/styles/paper/MenuItem.svelte +2 -1
  80. package/dist/styles/paper/Modal.svelte +5 -0
  81. package/dist/styles/paper/Modal.svelte.d.ts +2 -0
  82. package/dist/styles/paper/MultiSelect.svelte +7 -1
  83. package/dist/styles/paper/MultiSelect.svelte.d.ts +3 -0
  84. package/dist/styles/paper/Navbar.svelte +18 -4
  85. package/dist/styles/paper/Navbar.svelte.d.ts +2 -0
  86. package/dist/styles/paper/PricingCard.svelte +23 -15
  87. package/dist/styles/paper/PricingCard.svelte.d.ts +2 -0
  88. package/dist/styles/paper/RadioGroup.svelte +6 -0
  89. package/dist/styles/paper/RadioGroup.svelte.d.ts +2 -0
  90. package/dist/styles/paper/SegmentedControl.svelte +16 -2
  91. package/dist/styles/paper/SegmentedControl.svelte.d.ts +5 -0
  92. package/dist/styles/paper/Sidebar.svelte +2 -1
  93. package/dist/styles/paper/Stat.svelte +8 -1
  94. package/dist/styles/paper/Stat.svelte.d.ts +3 -0
  95. package/dist/styles/paper/Steps.svelte +7 -0
  96. package/dist/styles/paper/Steps.svelte.d.ts +3 -0
  97. package/dist/styles/paper/Table.svelte +153 -97
  98. package/dist/styles/paper/Table.svelte.d.ts +12 -0
  99. package/dist/styles/paper/Tabs.svelte +5 -0
  100. package/dist/styles/paper/Tabs.svelte.d.ts +3 -0
  101. package/dist/styles/paper/Toaster.svelte +3 -0
  102. package/dist/styles/paper/icon.d.ts +21 -0
  103. package/dist/styles/paper/icon.js +21 -0
  104. package/dist/styles/paper/index.d.ts +0 -2
  105. package/dist/styles/paper/index.js +0 -2
  106. package/dist/styles/sprout/AccordionItem.svelte +5 -0
  107. package/dist/styles/sprout/AccordionItem.svelte.d.ts +2 -0
  108. package/dist/styles/sprout/Avatar.svelte +15 -0
  109. package/dist/styles/sprout/Avatar.svelte.d.ts +3 -0
  110. package/dist/styles/sprout/Badge.svelte +5 -0
  111. package/dist/styles/sprout/Badge.svelte.d.ts +2 -0
  112. package/dist/styles/sprout/Breadcrumb.svelte +8 -4
  113. package/dist/styles/sprout/Breadcrumb.svelte.d.ts +3 -0
  114. package/dist/styles/sprout/Button.svelte +58 -7
  115. package/dist/styles/sprout/Button.svelte.d.ts +14 -2
  116. package/dist/styles/sprout/Card.svelte +6 -1
  117. package/dist/styles/sprout/Card.svelte.d.ts +2 -0
  118. package/dist/styles/sprout/CheckboxGroup.svelte +6 -0
  119. package/dist/styles/sprout/CheckboxGroup.svelte.d.ts +2 -0
  120. package/dist/styles/sprout/Combobox.svelte +5 -0
  121. package/dist/styles/sprout/Combobox.svelte.d.ts +3 -0
  122. package/dist/styles/sprout/CommandPalette.svelte +6 -0
  123. package/dist/styles/sprout/CommandPalette.svelte.d.ts +3 -0
  124. package/dist/styles/sprout/Drawer.svelte +5 -0
  125. package/dist/styles/sprout/Drawer.svelte.d.ts +2 -0
  126. package/dist/styles/sprout/Footer.svelte +6 -2
  127. package/dist/styles/sprout/Footer.svelte.d.ts +2 -0
  128. package/dist/styles/sprout/Link.svelte +9 -0
  129. package/dist/styles/sprout/Link.svelte.d.ts +4 -0
  130. package/dist/styles/sprout/MenuItem.svelte +2 -1
  131. package/dist/styles/sprout/Modal.svelte +5 -0
  132. package/dist/styles/sprout/Modal.svelte.d.ts +2 -0
  133. package/dist/styles/sprout/MultiSelect.svelte +7 -1
  134. package/dist/styles/sprout/MultiSelect.svelte.d.ts +3 -0
  135. package/dist/styles/sprout/Navbar.svelte +18 -4
  136. package/dist/styles/sprout/Navbar.svelte.d.ts +2 -0
  137. package/dist/styles/sprout/PricingCard.svelte +23 -15
  138. package/dist/styles/sprout/PricingCard.svelte.d.ts +2 -0
  139. package/dist/styles/sprout/RadioGroup.svelte +6 -0
  140. package/dist/styles/sprout/RadioGroup.svelte.d.ts +2 -0
  141. package/dist/styles/sprout/SegmentedControl.svelte +16 -2
  142. package/dist/styles/sprout/SegmentedControl.svelte.d.ts +5 -0
  143. package/dist/styles/sprout/Sidebar.svelte +2 -1
  144. package/dist/styles/sprout/Stat.svelte +8 -1
  145. package/dist/styles/sprout/Stat.svelte.d.ts +3 -0
  146. package/dist/styles/sprout/Steps.svelte +7 -0
  147. package/dist/styles/sprout/Steps.svelte.d.ts +3 -0
  148. package/dist/styles/sprout/Table.svelte +153 -97
  149. package/dist/styles/sprout/Table.svelte.d.ts +12 -0
  150. package/dist/styles/sprout/Tabs.svelte +5 -0
  151. package/dist/styles/sprout/Tabs.svelte.d.ts +3 -0
  152. package/dist/styles/sprout/Toaster.svelte +3 -0
  153. package/dist/styles/sprout/icon.d.ts +21 -0
  154. package/dist/styles/sprout/icon.js +21 -0
  155. package/dist/styles/sprout/index.d.ts +0 -2
  156. package/dist/styles/sprout/index.js +0 -2
  157. package/package.json +2 -26
  158. package/registry.json +1 -35
  159. package/dist/styles/matte/NumberInput.svelte +0 -96
  160. package/dist/styles/matte/NumberInput.svelte.d.ts +0 -15
  161. package/dist/styles/matte/PasswordInput.svelte +0 -95
  162. package/dist/styles/matte/PasswordInput.svelte.d.ts +0 -12
  163. package/dist/styles/paper/NumberInput.svelte +0 -96
  164. package/dist/styles/paper/NumberInput.svelte.d.ts +0 -15
  165. package/dist/styles/paper/PasswordInput.svelte +0 -100
  166. package/dist/styles/paper/PasswordInput.svelte.d.ts +0 -12
  167. package/dist/styles/sprout/NumberInput.svelte +0 -97
  168. package/dist/styles/sprout/NumberInput.svelte.d.ts +0 -15
  169. package/dist/styles/sprout/PasswordInput.svelte +0 -101
  170. package/dist/styles/sprout/PasswordInput.svelte.d.ts +0 -12
@@ -2,6 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { toneBorder, toneSoft, toneSolid, type Tone } from '../../core/tones.js';
5
+ import { iconMd } from './icon.js';
5
6
 
6
7
  interface Props extends HTMLAttributes<HTMLDivElement> {
7
8
  name: string;
@@ -12,6 +13,8 @@
12
13
  description?: string;
13
14
  /** One line each. Rendered with a tick. */
14
15
  features?: string[];
16
+ /** Replaces the tick beside every feature. */
17
+ featureIcon?: Snippet;
15
18
  /** Pill in the top corner, e.g. "Most popular". */
16
19
  badge?: string;
17
20
  /** Ring, lift and a tinted header — for the plan you want chosen. */
@@ -29,6 +32,7 @@
29
32
  period,
30
33
  description,
31
34
  features = [],
35
+ featureIcon,
32
36
  badge,
33
37
  featured = false,
34
38
  tone = 'brand',
@@ -77,21 +81,25 @@
77
81
  <ul class="flex flex-1 flex-col gap-3 border-t border-hairline p-6">
78
82
  {#each features as feature (feature)}
79
83
  <li class="flex items-start gap-3 font-sans text-sm text-text-secondary">
80
- <span
81
- class="mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full {toneSoft[
82
- tone
83
- ]}"
84
- >
85
- <svg class="size-2.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
86
- <path
87
- d="m3 8 3.2 3.2L13 4.4"
88
- stroke="currentColor"
89
- stroke-width="2.4"
90
- stroke-linecap="round"
91
- stroke-linejoin="round"
92
- />
93
- </svg>
94
- </span>
84
+ {#if featureIcon}
85
+ <span class="mt-0.5 {iconMd}">{@render featureIcon()}</span>
86
+ {:else}
87
+ <span
88
+ class="mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full {toneSoft[
89
+ tone
90
+ ]}"
91
+ >
92
+ <svg class="size-2.5" viewBox="0 0 16 16" fill="none" aria-hidden="true">
93
+ <path
94
+ d="m3 8 3.2 3.2L13 4.4"
95
+ stroke="currentColor"
96
+ stroke-width="2.4"
97
+ stroke-linecap="round"
98
+ stroke-linejoin="round"
99
+ />
100
+ </svg>
101
+ </span>
102
+ {/if}
95
103
  <span class="leading-snug">{feature}</span>
96
104
  </li>
97
105
  {/each}
@@ -10,6 +10,8 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
10
10
  description?: string;
11
11
  /** One line each. Rendered with a tick. */
12
12
  features?: string[];
13
+ /** Replaces the tick beside every feature. */
14
+ featureIcon?: Snippet;
13
15
  /** Pill in the top corner, e.g. "Most popular". */
14
16
  badge?: string;
15
17
  /** Ring, lift and a tinted header — for the plan you want chosen. */
@@ -3,10 +3,13 @@
3
3
  import type { HTMLFieldsetAttributes } from 'svelte/elements';
4
4
  import Radio from './Radio.svelte';
5
5
  import { toneBorder, toneSurface, type Tone } from '../../core/tones.js';
6
+ import { iconLg } from './icon.js';
6
7
 
7
8
  export interface RadioOption {
8
9
  value: string;
9
10
  label: string;
11
+ /** Leading icon, 20px. Drawn in `boxed` mode only. */
12
+ icon?: Snippet;
10
13
  description?: string;
11
14
  disabled?: boolean;
12
15
  }
@@ -62,6 +65,9 @@
62
65
  : 'border-hairline bg-bg hover:border-hairline-strong'}
63
66
  {option.disabled ? 'pointer-events-none opacity-50' : ''}"
64
67
  >
68
+ {#if option.icon}
69
+ <span class={iconLg}>{@render option.icon()}</span>
70
+ {/if}
65
71
  <Radio
66
72
  bind:group={value}
67
73
  value={option.value}
@@ -4,6 +4,8 @@ import { type Tone } from '../../core/tones.js';
4
4
  export interface RadioOption {
5
5
  value: string;
6
6
  label: string;
7
+ /** Leading icon, 20px. Drawn in `boxed` mode only. */
8
+ icon?: Snippet;
7
9
  description?: string;
8
10
  disabled?: boolean;
9
11
  }
@@ -1,10 +1,14 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte';
2
3
  import type { HTMLAttributes } from 'svelte/elements';
3
4
  import { focusRing, toneRing, type Tone } from '../../core/tones.js';
5
+ import { iconMd } from './icon.js';
4
6
 
5
7
  export interface SegmentOption {
6
8
  value: string;
7
9
  label: string;
10
+ /** Leading icon, 16px. */
11
+ icon?: Snippet;
8
12
  disabled?: boolean;
9
13
  }
10
14
 
@@ -20,6 +24,8 @@
20
24
  tone?: Tone;
21
25
  /** Spread the segments evenly across the full width. */
22
26
  fullWidth?: boolean;
27
+ /** Icons only — each option's `label` becomes its accessible name. */
28
+ iconOnly?: boolean;
23
29
  label?: string;
24
30
  disabled?: boolean;
25
31
  onchange?: (value: string) => void;
@@ -32,6 +38,7 @@
32
38
  size = 'md',
33
39
  tone = 'brand',
34
40
  fullWidth = false,
41
+ iconOnly = false,
35
42
  label,
36
43
  disabled = false,
37
44
  class: className = '',
@@ -44,6 +51,11 @@
44
51
  md: 'h-8 px-3.5 text-sm'
45
52
  };
46
53
 
54
+ const squares: Record<SegmentedSize, string> = {
55
+ sm: 'size-7 text-[13px]',
56
+ md: 'size-8 text-sm'
57
+ };
58
+
47
59
  function select(option: SegmentOption) {
48
60
  if (option.disabled || disabled) return;
49
61
  value = option.value;
@@ -74,14 +86,16 @@
74
86
  type="button"
75
87
  role="radio"
76
88
  aria-checked={value === option.value}
89
+ aria-label={iconOnly ? option.label : undefined}
77
90
  disabled={option.disabled || disabled}
78
91
  tabindex={value === option.value ? 0 : -1}
79
92
  onclick={() => select(option)}
80
93
  class="inline-flex items-center justify-center rounded-md font-sans font-medium whitespace-nowrap transition-all duration-150 ease-brand-out disabled:pointer-events-none disabled:opacity-40
81
- {sizes[size]} {focusRing} {toneRing[tone]}
94
+ {iconOnly ? squares[size] : sizes[size]} {focusRing} {toneRing[tone]}
82
95
  {value === option.value ? 'bg-bg text-text shadow-xs' : 'text-text-muted hover:text-text'}"
83
96
  >
84
- {option.label}
97
+ {#if option.icon}<span class={iconMd}>{@render option.icon()}</span>{/if}
98
+ {#if !iconOnly}{option.label}{/if}
85
99
  </button>
86
100
  {/each}
87
101
  {#if name}<input type="hidden" {name} {value} />{/if}
@@ -1,8 +1,11 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { HTMLAttributes } from 'svelte/elements';
2
3
  import { type Tone } from '../../core/tones.js';
3
4
  export interface SegmentOption {
4
5
  value: string;
5
6
  label: string;
7
+ /** Leading icon, 16px. */
8
+ icon?: Snippet;
6
9
  disabled?: boolean;
7
10
  }
8
11
  export type SegmentedSize = 'sm' | 'md';
@@ -16,6 +19,8 @@ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
16
19
  tone?: Tone;
17
20
  /** Spread the segments evenly across the full width. */
18
21
  fullWidth?: boolean;
22
+ /** Icons only — each option's `label` becomes its accessible name. */
23
+ iconOnly?: boolean;
19
24
  label?: string;
20
25
  disabled?: boolean;
21
26
  onchange?: (value: string) => void;
@@ -36,6 +36,7 @@
36
36
 
37
37
  <script lang="ts">
38
38
  import { useLocale } from '../../core/locale.svelte.js';
39
+ import { iconMd } from './icon.js';
39
40
  import { focusRing, toneRing, toneSoft, type Tone } from '../../core/tones.js';
40
41
 
41
42
  interface Props {
@@ -126,7 +127,7 @@
126
127
  <!-- One box for every glyph, so rows line up whether or not an item has one. -->
127
128
  {#snippet glyph(item: SidebarItem)}
128
129
  {#if item.icon}
129
- <span class="grid size-4 shrink-0 place-items-center *:size-4">{@render item.icon()}</span>
130
+ <span class={iconMd}>{@render item.icon()}</span>
130
131
  {/if}
131
132
  {/snippet}
132
133
 
@@ -1,6 +1,8 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte';
2
3
  import type { HTMLAttributes } from 'svelte/elements';
3
4
  import { toneText, type Tone } from '../../core/tones.js';
5
+ import { iconMd } from './icon.js';
4
6
 
5
7
  export type StatTrend = 'up' | 'down' | 'flat';
6
8
 
@@ -11,6 +13,8 @@
11
13
  delta?: string;
12
14
  trend?: StatTrend;
13
15
  hint?: string;
16
+ /** Leading icon on the label row. */
17
+ icon?: Snippet;
14
18
  /** Colour of the value itself. Leave unset for plain `text`. */
15
19
  tone?: Tone;
16
20
  }
@@ -21,6 +25,7 @@
21
25
  delta,
22
26
  trend = 'flat',
23
27
  hint,
28
+ icon,
24
29
  tone,
25
30
  class: className = '',
26
31
  ...rest
@@ -31,7 +36,9 @@
31
36
  </script>
32
37
 
33
38
  <div class="flex flex-col gap-1 font-sans {className}" {...rest}>
34
- <span class="text-sm font-medium text-text-muted">{label}</span>
39
+ <span class="flex items-center gap-2 text-sm font-medium text-text-muted"
40
+ >{#if icon}<span class={iconMd}>{@render icon()}</span>{/if}{label}</span
41
+ >
35
42
  <div class="flex items-baseline gap-2">
36
43
  <span
37
44
  class="font-heading text-3xl font-semibold tracking-tight tabular-nums {tone
@@ -1,3 +1,4 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { HTMLAttributes } from 'svelte/elements';
2
3
  import { type Tone } from '../../core/tones.js';
3
4
  export type StatTrend = 'up' | 'down' | 'flat';
@@ -8,6 +9,8 @@ interface Props extends HTMLAttributes<HTMLDivElement> {
8
9
  delta?: string;
9
10
  trend?: StatTrend;
10
11
  hint?: string;
12
+ /** Leading icon on the label row. */
13
+ icon?: Snippet;
11
14
  /** Colour of the value itself. Leave unset for plain `text`. */
12
15
  tone?: Tone;
13
16
  }
@@ -1,7 +1,11 @@
1
1
  <script module lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
2
4
  export interface StepItem {
3
5
  label: string;
4
6
  description?: string;
7
+ /** Replaces the step number. A finished step still shows its check. */
8
+ icon?: Snippet;
5
9
  /** Marks the step as failed — shown in `danger` regardless of position. */
6
10
  error?: boolean;
7
11
  disabled?: boolean;
@@ -10,6 +14,7 @@
10
14
 
11
15
  <script lang="ts">
12
16
  import type { HTMLAttributes } from 'svelte/elements';
17
+ import { iconMd } from './icon.js';
13
18
  import { focusRing, toneFill, toneRing, toneText, type Tone } from '../../core/tones.js';
14
19
 
15
20
  interface Props extends Omit<HTMLAttributes<HTMLElement>, 'onchange'> {
@@ -73,6 +78,8 @@
73
78
  stroke-linejoin="round"
74
79
  />
75
80
  </svg>
81
+ {:else if item.icon}
82
+ <span class={iconMd}>{@render item.icon()}</span>
76
83
  {:else}
77
84
  {index + 1}
78
85
  {/if}
@@ -1,6 +1,9 @@
1
+ import type { Snippet } from 'svelte';
1
2
  export interface StepItem {
2
3
  label: string;
3
4
  description?: string;
5
+ /** Replaces the step number. A finished step still shows its check. */
6
+ icon?: Snippet;
4
7
  /** Marks the step as failed — shown in `danger` regardless of position. */
5
8
  error?: boolean;
6
9
  disabled?: boolean;
@@ -32,6 +32,16 @@
32
32
  /** Header stays put while the body scrolls — pair with a `max-h-*` class. */
33
33
  stickyHeader?: boolean;
34
34
 
35
+ /** Bar above the table — a title, a search field, a filter row. */
36
+ header?: Snippet;
37
+ /** Bar below the table — pagination, a total, a summary line. */
38
+ footer?: Snippet;
39
+ /**
40
+ * Shown in place of `header` while rows are ticked, after the count and the
41
+ * clear button. Passing it is what turns the bulk bar on.
42
+ */
43
+ bulkActions?: Snippet<[{ selected: string[]; clear: () => void }]>;
44
+
35
45
  /** Bindable. Set it to sort; leave `sortable` columns to drive it. */
36
46
  sort?: TableSort | null;
37
47
  /** Sort the rows here rather than refetching them server-side. Default true. */
@@ -57,6 +67,9 @@
57
67
  hoverable = true,
58
68
  compact = false,
59
69
  stickyHeader = false,
70
+ header,
71
+ footer,
72
+ bulkActions,
60
73
  sort = $bindable(null),
61
74
  sortLocally = true,
62
75
  onsort,
@@ -106,112 +119,155 @@
106
119
  selected = toggleKey(selected, keyOf(row));
107
120
  onselect?.(selected);
108
121
  }
122
+
123
+ function clearSelection() {
124
+ selected = [];
125
+ onselect?.(selected);
126
+ }
127
+
128
+ /** The bulk bar takes the header's place, so only one of the two is up. */
129
+ const bulkBar = $derived(selectable && bulkActions !== undefined && selected.length > 0);
109
130
  </script>
110
131
 
111
132
  <div
112
- class="w-full overflow-auto rounded-lg border border-hairline bg-bg shadow-xs {className}"
133
+ class="flex w-full flex-col overflow-hidden rounded-lg border border-hairline bg-bg shadow-xs {className}"
113
134
  {...rest}
114
135
  >
115
- <table class="w-full border-collapse font-sans text-sm">
116
- {#if caption}
117
- <caption
118
- class="border-b border-hairline px-4 py-3 text-left font-sans text-[13px] text-text-muted"
136
+ {#if bulkBar}
137
+ <div
138
+ class="flex flex-wrap items-center gap-3 border-b border-hairline bg-brand-light px-4 py-3"
139
+ >
140
+ <span class="font-sans text-[13px] font-semibold text-text">
141
+ {selected.length}
142
+ {t.current.selected}
143
+ </span>
144
+ <button
145
+ type="button"
146
+ onclick={clearSelection}
147
+ class="rounded font-sans text-[13px] font-medium text-text-muted transition-colors duration-150 hover:text-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
119
148
  >
120
- {caption}
121
- </caption>
122
- {/if}
123
- <thead class={stickyHeader ? 'sticky top-0 z-10' : ''}>
124
- <tr class="border-b border-hairline bg-bg-alt">
125
- {#if selectable}
126
- <th scope="col" class="w-10 {pad}">
127
- <Checkbox
128
- checked={allSelected}
129
- indeterminate={someSelected}
130
- {tone}
131
- aria-label={t.current.selectAllRows}
132
- onchange={toggleAll}
133
- />
134
- </th>
135
- {/if}
136
- {#each columns as column (column.key)}
137
- <th
138
- scope="col"
139
- aria-sort={sort?.key === column.key
140
- ? sort.direction === 'asc'
141
- ? 'ascending'
142
- : 'descending'
143
- : undefined}
144
- class="text-[13px] font-semibold text-text-muted {pad} {aligns[
145
- column.align ?? 'left'
146
- ]} {column.class ?? ''}"
147
- >
148
- {#if column.sortable}
149
- <button
150
- type="button"
151
- onclick={() => toggleSort(column)}
152
- class="inline-flex items-center gap-1.5 rounded transition-colors duration-150 hover:text-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current
149
+ {t.current.clear}
150
+ </button>
151
+ <div class="ml-auto flex flex-wrap items-center gap-2">
152
+ {@render bulkActions?.({ selected, clear: clearSelection })}
153
+ </div>
154
+ </div>
155
+ {:else if header}
156
+ <div
157
+ class="flex flex-wrap items-center gap-3 border-b border-hairline px-4 py-3 font-sans text-[13px] text-text-secondary"
158
+ >
159
+ {@render header()}
160
+ </div>
161
+ {/if}
162
+ <div class="min-h-0 w-full flex-1 overflow-auto">
163
+ <table class="w-full border-collapse font-sans text-sm">
164
+ {#if caption}
165
+ <caption
166
+ class="border-b border-hairline px-4 py-3 text-left font-sans text-[13px] text-text-muted"
167
+ >
168
+ {caption}
169
+ </caption>
170
+ {/if}
171
+ <thead class={stickyHeader ? 'sticky top-0 z-10' : ''}>
172
+ <tr class="border-b border-hairline bg-bg-alt">
173
+ {#if selectable}
174
+ <th scope="col" class="w-10 {pad}">
175
+ <Checkbox
176
+ checked={allSelected}
177
+ indeterminate={someSelected}
178
+ {tone}
179
+ aria-label={t.current.selectAllRows}
180
+ onchange={toggleAll}
181
+ />
182
+ </th>
183
+ {/if}
184
+ {#each columns as column (column.key)}
185
+ <th
186
+ scope="col"
187
+ aria-sort={sort?.key === column.key
188
+ ? sort.direction === 'asc'
189
+ ? 'ascending'
190
+ : 'descending'
191
+ : undefined}
192
+ class="text-[13px] font-semibold text-text-muted {pad} {aligns[
193
+ column.align ?? 'left'
194
+ ]} {column.class ?? ''}"
195
+ >
196
+ {#if column.sortable}
197
+ <button
198
+ type="button"
199
+ onclick={() => toggleSort(column)}
200
+ class="inline-flex items-center gap-1.5 rounded transition-colors duration-150 hover:text-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current
153
201
  {sort?.key === column.key ? 'text-text' : ''}"
154
- >
202
+ >
203
+ {column.label}
204
+ <span class="text-[9px] leading-none" aria-hidden="true">
205
+ {#if sort?.key === column.key}
206
+ {sort.direction === 'asc' ? '▲' : '▼'}
207
+ {:else}
208
+
209
+ {/if}
210
+ </span>
211
+ </button>
212
+ {:else}
155
213
  {column.label}
156
- <span class="text-[9px] leading-none" aria-hidden="true">
157
- {#if sort?.key === column.key}
158
- {sort.direction === 'asc' ? '▲' : '▼'}
159
- {:else}
160
-
161
- {/if}
162
- </span>
163
- </button>
164
- {:else}
165
- {column.label}
166
- {/if}
167
- </th>
168
- {/each}
169
- </tr>
170
- </thead>
171
- <tbody>
172
- {#if sorted.length === 0}
173
- <tr>
174
- <td
175
- colspan={columns.length + (selectable ? 1 : 0)}
176
- class="px-4 py-10 text-center text-sm text-text-muted"
177
- >
178
- {#if empty}{@render empty()}{:else}{t.current.noData}{/if}
179
- </td>
214
+ {/if}
215
+ </th>
216
+ {/each}
180
217
  </tr>
181
- {:else}
182
- {#each sorted as row, i (selectable ? keyOf(row) : i)}
183
- {@const isSelected = selectable && selected.includes(keyOf(row))}
184
- <tr
185
- aria-selected={selectable ? isSelected : undefined}
186
- class="border-b border-hairline last:border-b-0
218
+ </thead>
219
+ <tbody>
220
+ {#if sorted.length === 0}
221
+ <tr>
222
+ <td
223
+ colspan={columns.length + (selectable ? 1 : 0)}
224
+ class="px-4 py-10 text-center text-sm text-text-muted"
225
+ >
226
+ {#if empty}{@render empty()}{:else}{t.current.noData}{/if}
227
+ </td>
228
+ </tr>
229
+ {:else}
230
+ {#each sorted as row, i (selectable ? keyOf(row) : i)}
231
+ {@const isSelected = selectable && selected.includes(keyOf(row))}
232
+ <tr
233
+ aria-selected={selectable ? isSelected : undefined}
234
+ class="border-b border-hairline last:border-b-0
187
235
  {isSelected ? 'bg-brand-light' : striped && i % 2 === 1 ? 'bg-bg-alt' : ''}
188
236
  {hoverable ? 'transition-colors duration-150 hover:bg-bg-alt' : ''}"
189
- >
190
- {#if selectable}
191
- <td class={pad}>
192
- <Checkbox
193
- checked={isSelected}
194
- {tone}
195
- aria-label={t.current.selectRow}
196
- onchange={() => toggleRow(row)}
197
- />
198
- </td>
199
- {/if}
200
- {#each columns as column (column.key)}
201
- <td
202
- class="text-text-secondary {pad} {aligns[column.align ?? 'left']} {column.class ??
203
- ''}"
204
- >
205
- {#if cell}
206
- {@render cell({ row, column, value: row[column.key] })}
207
- {:else}
208
- {row[column.key] ?? ''}
209
- {/if}
210
- </td>
211
- {/each}
212
- </tr>
213
- {/each}
214
- {/if}
215
- </tbody>
216
- </table>
237
+ >
238
+ {#if selectable}
239
+ <td class={pad}>
240
+ <Checkbox
241
+ checked={isSelected}
242
+ {tone}
243
+ aria-label={t.current.selectRow}
244
+ onchange={() => toggleRow(row)}
245
+ />
246
+ </td>
247
+ {/if}
248
+ {#each columns as column (column.key)}
249
+ <td
250
+ class="text-text-secondary {pad} {aligns[column.align ?? 'left']} {column.class ??
251
+ ''}"
252
+ >
253
+ {#if cell}
254
+ {@render cell({ row, column, value: row[column.key] })}
255
+ {:else}
256
+ {row[column.key] ?? ''}
257
+ {/if}
258
+ </td>
259
+ {/each}
260
+ </tr>
261
+ {/each}
262
+ {/if}
263
+ </tbody>
264
+ </table>
265
+ </div>
266
+ {#if footer}
267
+ <div
268
+ class="flex flex-wrap items-center gap-3 border-t border-hairline px-4 py-3 font-sans text-[13px] text-text-secondary"
269
+ >
270
+ {@render footer()}
271
+ </div>
272
+ {/if}
217
273
  </div>
@@ -29,6 +29,18 @@ declare function $$render<T extends Record<string, unknown>>(): {
29
29
  compact?: boolean;
30
30
  /** Header stays put while the body scrolls — pair with a `max-h-*` class. */
31
31
  stickyHeader?: boolean;
32
+ /** Bar above the table — a title, a search field, a filter row. */
33
+ header?: Snippet;
34
+ /** Bar below the table — pagination, a total, a summary line. */
35
+ footer?: Snippet;
36
+ /**
37
+ * Shown in place of `header` while rows are ticked, after the count and the
38
+ * clear button. Passing it is what turns the bulk bar on.
39
+ */
40
+ bulkActions?: Snippet<[{
41
+ selected: string[];
42
+ clear: () => void;
43
+ }]>;
32
44
  /** Bindable. Set it to sort; leave `sortable` columns to drive it. */
33
45
  sort?: TableSort | null;
34
46
  /** Sort the rows here rather than refetching them server-side. Default true. */
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte';
2
3
  import type { HTMLAttributes } from 'svelte/elements';
3
4
  import {
4
5
  focusRing,
@@ -8,10 +9,13 @@
8
9
  toneText,
9
10
  type Tone
10
11
  } from '../../core/tones.js';
12
+ import { iconMd } from './icon.js';
11
13
 
12
14
  export interface TabItem {
13
15
  value: string;
14
16
  label: string;
17
+ /** Leading icon, 16px. */
18
+ icon?: Snippet;
15
19
  disabled?: boolean;
16
20
  /** Small count/label rendered after the tab title. */
17
21
  badge?: string | number;
@@ -89,6 +93,7 @@
89
93
  onclick={() => select(item)}
90
94
  class={tabClass(value === item.value)}
91
95
  >
96
+ {#if item.icon}<span class={iconMd}>{@render item.icon()}</span>{/if}
92
97
  {item.label}
93
98
  {#if item.badge !== undefined}
94
99
  <span
@@ -1,8 +1,11 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { HTMLAttributes } from 'svelte/elements';
2
3
  import { type Tone } from '../../core/tones.js';
3
4
  export interface TabItem {
4
5
  value: string;
5
6
  label: string;
7
+ /** Leading icon, 16px. */
8
+ icon?: Snippet;
6
9
  disabled?: boolean;
7
10
  /** Small count/label rendered after the tab title. */
8
11
  badge?: string | number;
@@ -4,6 +4,7 @@
4
4
  import { portal } from '../../core/actions/dismissable.js';
5
5
  import { toast } from '../../core/toast.svelte.js';
6
6
  import { toneText } from '../../core/tones.js';
7
+ import { iconMd } from './icon.js';
7
8
  import Spinner from './Spinner.svelte';
8
9
  import { useLocale } from '../../core/locale.svelte.js';
9
10
 
@@ -61,6 +62,8 @@
61
62
  <span class="mt-0.5 shrink-0 {toneText[item.tone]}">
62
63
  {#if item.loading}
63
64
  <Spinner size="sm" label="" />
65
+ {:else if item.icon}
66
+ <span class={iconMd}>{@render item.icon()}</span>
64
67
  {:else if item.tone === 'success'}
65
68
  <svg class="size-4" viewBox="0 0 16 16" fill="none" aria-hidden="true">
66
69
  <circle cx="8" cy="8" r="6.5" stroke="currentColor" stroke-width="1.5" />