@sepale/components 0.0.0-stage → 0.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 (261) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -3
  3. package/dist/components/Accordion.svelte +48 -0
  4. package/dist/components/Accordion.svelte.d.ts +24 -0
  5. package/dist/components/Alert.svelte +107 -0
  6. package/dist/components/Alert.svelte.d.ts +40 -0
  7. package/dist/components/Avatar.svelte +75 -0
  8. package/dist/components/Avatar.svelte.d.ts +37 -0
  9. package/dist/components/Badge.svelte +46 -0
  10. package/dist/components/Badge.svelte.d.ts +22 -0
  11. package/dist/components/Breadcrumbs.svelte +36 -0
  12. package/dist/components/Breadcrumbs.svelte.d.ts +18 -0
  13. package/dist/components/Bubble.svelte +43 -0
  14. package/dist/components/Bubble.svelte.d.ts +23 -0
  15. package/dist/components/Button.svelte +132 -0
  16. package/dist/components/Button.svelte.d.ts +40 -0
  17. package/dist/components/Calendar.svelte +193 -0
  18. package/dist/components/Calendar.svelte.d.ts +60 -0
  19. package/dist/components/Card.svelte +69 -0
  20. package/dist/components/Card.svelte.d.ts +37 -0
  21. package/dist/components/Carousel.svelte +550 -0
  22. package/dist/components/Carousel.svelte.d.ts +124 -0
  23. package/dist/components/Checkbox.svelte +48 -0
  24. package/dist/components/Checkbox.svelte.d.ts +26 -0
  25. package/dist/components/Chip.svelte +60 -0
  26. package/dist/components/Chip.svelte.d.ts +26 -0
  27. package/dist/components/ChipsInput.svelte +158 -0
  28. package/dist/components/ChipsInput.svelte.d.ts +64 -0
  29. package/dist/components/Collapse.svelte +101 -0
  30. package/dist/components/Collapse.svelte.d.ts +46 -0
  31. package/dist/components/ColorPicker.svelte +135 -0
  32. package/dist/components/ColorPicker.svelte.d.ts +44 -0
  33. package/dist/components/Combobox.svelte +496 -0
  34. package/dist/components/Combobox.svelte.d.ts +96 -0
  35. package/dist/components/DataControl.svelte +754 -0
  36. package/dist/components/DataControl.svelte.d.ts +143 -0
  37. package/dist/components/DataHandler.svelte +67 -0
  38. package/dist/components/DataHandler.svelte.d.ts +44 -0
  39. package/dist/components/DatePicker.svelte +185 -0
  40. package/dist/components/DatePicker.svelte.d.ts +56 -0
  41. package/dist/components/Dialog.svelte +194 -0
  42. package/dist/components/Dialog.svelte.d.ts +51 -0
  43. package/dist/components/Divider.svelte +54 -0
  44. package/dist/components/Divider.svelte.d.ts +27 -0
  45. package/dist/components/Dock.svelte +34 -0
  46. package/dist/components/Dock.svelte.d.ts +18 -0
  47. package/dist/components/Drawer.svelte +174 -0
  48. package/dist/components/Drawer.svelte.d.ts +51 -0
  49. package/dist/components/Dropdown.svelte +183 -0
  50. package/dist/components/Dropdown.svelte.d.ts +52 -0
  51. package/dist/components/Editable.svelte +292 -0
  52. package/dist/components/Editable.svelte.d.ts +113 -0
  53. package/dist/components/EmptyState.svelte +64 -0
  54. package/dist/components/EmptyState.svelte.d.ts +29 -0
  55. package/dist/components/Fieldset.svelte +42 -0
  56. package/dist/components/Fieldset.svelte.d.ts +20 -0
  57. package/dist/components/FileDropzone.svelte +154 -0
  58. package/dist/components/FileDropzone.svelte.d.ts +45 -0
  59. package/dist/components/FileExplorer.svelte +643 -0
  60. package/dist/components/FileExplorer.svelte.d.ts +114 -0
  61. package/dist/components/FileInput.svelte +125 -0
  62. package/dist/components/FileInput.svelte.d.ts +51 -0
  63. package/dist/components/FloatingLabel.svelte +38 -0
  64. package/dist/components/FloatingLabel.svelte.d.ts +24 -0
  65. package/dist/components/Footer.svelte +68 -0
  66. package/dist/components/Footer.svelte.d.ts +37 -0
  67. package/dist/components/Grid.svelte +122 -0
  68. package/dist/components/Grid.svelte.d.ts +72 -0
  69. package/dist/components/Hero.svelte +62 -0
  70. package/dist/components/Hero.svelte.d.ts +33 -0
  71. package/dist/components/Input.svelte +184 -0
  72. package/dist/components/Input.svelte.d.ts +65 -0
  73. package/dist/components/Join.svelte +38 -0
  74. package/dist/components/Join.svelte.d.ts +21 -0
  75. package/dist/components/Kanban.svelte +284 -0
  76. package/dist/components/Kanban.svelte.d.ts +93 -0
  77. package/dist/components/Label.svelte +32 -0
  78. package/dist/components/Label.svelte.d.ts +21 -0
  79. package/dist/components/LaptopFrame.svelte +44 -0
  80. package/dist/components/LaptopFrame.svelte.d.ts +21 -0
  81. package/dist/components/List.svelte +95 -0
  82. package/dist/components/List.svelte.d.ts +69 -0
  83. package/dist/components/Loading.svelte +37 -0
  84. package/dist/components/Loading.svelte.d.ts +17 -0
  85. package/dist/components/Menu.svelte +144 -0
  86. package/dist/components/Menu.svelte.d.ts +53 -0
  87. package/dist/components/MobileFrame.svelte +41 -0
  88. package/dist/components/MobileFrame.svelte.d.ts +21 -0
  89. package/dist/components/Navbar.svelte +49 -0
  90. package/dist/components/Navbar.svelte.d.ts +25 -0
  91. package/dist/components/NumberInput.svelte +255 -0
  92. package/dist/components/NumberInput.svelte.d.ts +68 -0
  93. package/dist/components/Pagination.svelte +169 -0
  94. package/dist/components/Pagination.svelte.d.ts +50 -0
  95. package/dist/components/Progress.svelte +65 -0
  96. package/dist/components/Progress.svelte.d.ts +28 -0
  97. package/dist/components/RadialProgress.svelte +48 -0
  98. package/dist/components/RadialProgress.svelte.d.ts +20 -0
  99. package/dist/components/Radio.svelte +50 -0
  100. package/dist/components/Radio.svelte.d.ts +28 -0
  101. package/dist/components/Range.svelte +53 -0
  102. package/dist/components/Range.svelte.d.ts +26 -0
  103. package/dist/components/Rating.svelte +90 -0
  104. package/dist/components/Rating.svelte.d.ts +41 -0
  105. package/dist/components/Select.svelte +338 -0
  106. package/dist/components/Select.svelte.d.ts +74 -0
  107. package/dist/components/Sidebar.svelte +100 -0
  108. package/dist/components/Sidebar.svelte.d.ts +54 -0
  109. package/dist/components/Skeleton.svelte +40 -0
  110. package/dist/components/Skeleton.svelte.d.ts +18 -0
  111. package/dist/components/Stat.svelte +71 -0
  112. package/dist/components/Stat.svelte.d.ts +35 -0
  113. package/dist/components/Stats.svelte +38 -0
  114. package/dist/components/Stats.svelte.d.ts +22 -0
  115. package/dist/components/Steps.svelte +204 -0
  116. package/dist/components/Steps.svelte.d.ts +66 -0
  117. package/dist/components/Subtitle.svelte +44 -0
  118. package/dist/components/Subtitle.svelte.d.ts +26 -0
  119. package/dist/components/Swatch.svelte +61 -0
  120. package/dist/components/Swatch.svelte.d.ts +27 -0
  121. package/dist/components/Switch.svelte +105 -0
  122. package/dist/components/Switch.svelte.d.ts +44 -0
  123. package/dist/components/Table.svelte +243 -0
  124. package/dist/components/Table.svelte.d.ts +121 -0
  125. package/dist/components/Tabs.svelte +142 -0
  126. package/dist/components/Tabs.svelte.d.ts +80 -0
  127. package/dist/components/Text.svelte +43 -0
  128. package/dist/components/Text.svelte.d.ts +25 -0
  129. package/dist/components/Textarea.svelte +76 -0
  130. package/dist/components/Textarea.svelte.d.ts +39 -0
  131. package/dist/components/Title.svelte +46 -0
  132. package/dist/components/Title.svelte.d.ts +29 -0
  133. package/dist/components/Toast.svelte +154 -0
  134. package/dist/components/Toast.svelte.d.ts +49 -0
  135. package/dist/components/Toggle.svelte +48 -0
  136. package/dist/components/Toggle.svelte.d.ts +25 -0
  137. package/dist/components/Tooltip.svelte +70 -0
  138. package/dist/components/Tooltip.svelte.d.ts +34 -0
  139. package/dist/components/WindowFrame.svelte +53 -0
  140. package/dist/components/WindowFrame.svelte.d.ts +24 -0
  141. package/dist/components/accordion-context.d.ts +8 -0
  142. package/dist/components/accordion-context.js +25 -0
  143. package/dist/components/color.d.ts +39 -0
  144. package/dist/components/color.js +92 -0
  145. package/dist/components/data-handler.svelte.d.ts +362 -0
  146. package/dist/components/data-handler.svelte.js +690 -0
  147. package/dist/components/file-icons.d.ts +25 -0
  148. package/dist/components/file-icons.js +46 -0
  149. package/dist/family-types.d.ts +45 -0
  150. package/dist/family-types.js +73 -0
  151. package/dist/generated/classes.d.ts +17 -0
  152. package/dist/generated/classes.js +2511 -0
  153. package/dist/generated/components.d.ts +39 -0
  154. package/dist/generated/components.js +28666 -0
  155. package/dist/generated/registry.d.ts +35 -0
  156. package/dist/generated/registry.js +2658 -0
  157. package/dist/index.d.ts +73 -0
  158. package/dist/index.js +99 -0
  159. package/dist/sepale-types.d.ts +8 -0
  160. package/dist/sepale-types.js +200 -0
  161. package/dist/theme.d.ts +123 -0
  162. package/dist/theme.js +226 -0
  163. package/dist/variants.d.ts +124 -0
  164. package/dist/variants.js +70 -0
  165. package/dist/vendor/air-datepicker/LICENSE.md +21 -0
  166. package/dist/vendor/air-datepicker/README.md +19 -0
  167. package/dist/vendor/air-datepicker/buttonPresets.d.ts +13 -0
  168. package/dist/vendor/air-datepicker/buttonPresets.js +12 -0
  169. package/dist/vendor/air-datepicker/consts.d.ts +18 -0
  170. package/dist/vendor/air-datepicker/consts.js +35 -0
  171. package/dist/vendor/air-datepicker/datepicker.d.ts +289 -0
  172. package/dist/vendor/air-datepicker/datepicker.js +1435 -0
  173. package/dist/vendor/air-datepicker/datepickerBody.d.ts +46 -0
  174. package/dist/vendor/air-datepicker/datepickerBody.js +386 -0
  175. package/dist/vendor/air-datepicker/datepickerButtons.d.ts +25 -0
  176. package/dist/vendor/air-datepicker/datepickerButtons.js +85 -0
  177. package/dist/vendor/air-datepicker/datepickerCell.d.ts +35 -0
  178. package/dist/vendor/air-datepicker/datepickerCell.js +297 -0
  179. package/dist/vendor/air-datepicker/datepickerKeyboard.d.ts +26 -0
  180. package/dist/vendor/air-datepicker/datepickerKeyboard.js +207 -0
  181. package/dist/vendor/air-datepicker/datepickerNav.d.ts +31 -0
  182. package/dist/vendor/air-datepicker/datepickerNav.js +200 -0
  183. package/dist/vendor/air-datepicker/datepickerTime.d.ts +60 -0
  184. package/dist/vendor/air-datepicker/datepickerTime.js +276 -0
  185. package/dist/vendor/air-datepicker/defaults.d.ts +65 -0
  186. package/dist/vendor/air-datepicker/defaults.js +79 -0
  187. package/dist/vendor/air-datepicker/index.d.ts +168 -0
  188. package/dist/vendor/air-datepicker/index.js +3 -0
  189. package/dist/vendor/air-datepicker/locale/ar.d.ts +4 -0
  190. package/dist/vendor/air-datepicker/locale/ar.js +14 -0
  191. package/dist/vendor/air-datepicker/locale/bg.d.ts +4 -0
  192. package/dist/vendor/air-datepicker/locale/bg.js +14 -0
  193. package/dist/vendor/air-datepicker/locale/ca.d.ts +4 -0
  194. package/dist/vendor/air-datepicker/locale/ca.js +14 -0
  195. package/dist/vendor/air-datepicker/locale/cs.d.ts +4 -0
  196. package/dist/vendor/air-datepicker/locale/cs.js +14 -0
  197. package/dist/vendor/air-datepicker/locale/da.d.ts +4 -0
  198. package/dist/vendor/air-datepicker/locale/da.js +14 -0
  199. package/dist/vendor/air-datepicker/locale/de.d.ts +4 -0
  200. package/dist/vendor/air-datepicker/locale/de.js +14 -0
  201. package/dist/vendor/air-datepicker/locale/el.d.ts +4 -0
  202. package/dist/vendor/air-datepicker/locale/el.js +14 -0
  203. package/dist/vendor/air-datepicker/locale/en.d.ts +4 -0
  204. package/dist/vendor/air-datepicker/locale/en.js +14 -0
  205. package/dist/vendor/air-datepicker/locale/es.d.ts +4 -0
  206. package/dist/vendor/air-datepicker/locale/es.js +14 -0
  207. package/dist/vendor/air-datepicker/locale/eu.d.ts +4 -0
  208. package/dist/vendor/air-datepicker/locale/eu.js +14 -0
  209. package/dist/vendor/air-datepicker/locale/fi.d.ts +4 -0
  210. package/dist/vendor/air-datepicker/locale/fi.js +14 -0
  211. package/dist/vendor/air-datepicker/locale/fr.d.ts +4 -0
  212. package/dist/vendor/air-datepicker/locale/fr.js +14 -0
  213. package/dist/vendor/air-datepicker/locale/hr.d.ts +4 -0
  214. package/dist/vendor/air-datepicker/locale/hr.js +14 -0
  215. package/dist/vendor/air-datepicker/locale/hu.d.ts +4 -0
  216. package/dist/vendor/air-datepicker/locale/hu.js +14 -0
  217. package/dist/vendor/air-datepicker/locale/id.d.ts +4 -0
  218. package/dist/vendor/air-datepicker/locale/id.js +14 -0
  219. package/dist/vendor/air-datepicker/locale/it.d.ts +4 -0
  220. package/dist/vendor/air-datepicker/locale/it.js +14 -0
  221. package/dist/vendor/air-datepicker/locale/ja.d.ts +4 -0
  222. package/dist/vendor/air-datepicker/locale/ja.js +14 -0
  223. package/dist/vendor/air-datepicker/locale/ko.d.ts +4 -0
  224. package/dist/vendor/air-datepicker/locale/ko.js +14 -0
  225. package/dist/vendor/air-datepicker/locale/nb.d.ts +4 -0
  226. package/dist/vendor/air-datepicker/locale/nb.js +14 -0
  227. package/dist/vendor/air-datepicker/locale/nl.d.ts +4 -0
  228. package/dist/vendor/air-datepicker/locale/nl.js +14 -0
  229. package/dist/vendor/air-datepicker/locale/pl.d.ts +4 -0
  230. package/dist/vendor/air-datepicker/locale/pl.js +14 -0
  231. package/dist/vendor/air-datepicker/locale/pt-BR.d.ts +4 -0
  232. package/dist/vendor/air-datepicker/locale/pt-BR.js +14 -0
  233. package/dist/vendor/air-datepicker/locale/pt.d.ts +4 -0
  234. package/dist/vendor/air-datepicker/locale/pt.js +14 -0
  235. package/dist/vendor/air-datepicker/locale/ro.d.ts +4 -0
  236. package/dist/vendor/air-datepicker/locale/ro.js +14 -0
  237. package/dist/vendor/air-datepicker/locale/ru.d.ts +4 -0
  238. package/dist/vendor/air-datepicker/locale/ru.js +14 -0
  239. package/dist/vendor/air-datepicker/locale/si.d.ts +4 -0
  240. package/dist/vendor/air-datepicker/locale/si.js +14 -0
  241. package/dist/vendor/air-datepicker/locale/sk.d.ts +4 -0
  242. package/dist/vendor/air-datepicker/locale/sk.js +14 -0
  243. package/dist/vendor/air-datepicker/locale/sl.d.ts +4 -0
  244. package/dist/vendor/air-datepicker/locale/sl.js +14 -0
  245. package/dist/vendor/air-datepicker/locale/sv.d.ts +4 -0
  246. package/dist/vendor/air-datepicker/locale/sv.js +14 -0
  247. package/dist/vendor/air-datepicker/locale/th.d.ts +4 -0
  248. package/dist/vendor/air-datepicker/locale/th.js +14 -0
  249. package/dist/vendor/air-datepicker/locale/tr.d.ts +4 -0
  250. package/dist/vendor/air-datepicker/locale/tr.js +16 -0
  251. package/dist/vendor/air-datepicker/locale/uk.d.ts +4 -0
  252. package/dist/vendor/air-datepicker/locale/uk.js +14 -0
  253. package/dist/vendor/air-datepicker/locale/zh.d.ts +4 -0
  254. package/dist/vendor/air-datepicker/locale/zh.js +14 -0
  255. package/dist/vendor/air-datepicker/typedefs.d.ts +3 -0
  256. package/dist/vendor/air-datepicker/typedefs.js +15 -0
  257. package/dist/vendor/air-datepicker/utils.d.ts +155 -0
  258. package/dist/vendor/air-datepicker/utils.js +395 -0
  259. package/dist/vendor/air-datepicker/withEvents.d.ts +1 -0
  260. package/dist/vendor/air-datepicker/withEvents.js +39 -0
  261. package/package.json +44 -3
@@ -0,0 +1,132 @@
1
+ <script module lang="ts">
2
+ /**
3
+ * What .btn is made of, classified. The props follow the families the
4
+ * project registers: a family's `.css.d.ts` narrows them to what it ships
5
+ * (variants.ts, ADR 0015).
6
+ *
7
+ * AXES are mutually exclusive and named after what they impact. FLAGS are
8
+ * independent booleans. PARTS are class names the component renders itself
9
+ * and never exposes. The build fails if a .btn-* class in a family's CSS
10
+ * appears in none of the three.
11
+ */
12
+ export const PREFIX = 'btn';
13
+
14
+ export const AXES = {
15
+ color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error'],
16
+ size: ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl'],
17
+ shape: ['square', 'circle'],
18
+ width: ['wide', 'block'],
19
+ /* The fill/border/text treatments. daisyUI ships them as flat
20
+ combinations rather than as orthogonal axes — `dash` is `outline`
21
+ plus a dashed border — so they are one axis, and `variant` is the
22
+ name we keep for an exclusive group with no better one. */
23
+ variant: ['outline', 'dash', 'soft', 'ghost', 'link', 'classic', 'surface'],
24
+ /* sunflower only: the hard shadow is the family, so moving or removing
25
+ it is its own axis and combines with everything above. */
26
+ shadow: ['none', 'reverse']
27
+ } as const;
28
+
29
+ export const FLAGS = {
30
+ active: 'Draw the button as if it were the current choice.'
31
+ } as const;
32
+ /* `ripple` is a part for now, not a flag: its prop carries behaviour (the
33
+ waves), so it is written by hand below, and offered whether or not the
34
+ family ships .btn-ripple. It leaves Button for an
35
+ attachment later. */
36
+ export const PARTS = ['ripple', 'ripple-wave', 'disabled'] as const;
37
+ </script>
38
+
39
+ <script lang="ts">
40
+ import type { Snippet } from 'svelte';
41
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
42
+ import { applyAxes, cx, type AxisProps } from '../variants.js';
43
+
44
+ // `size` is ours — the HTML attribute of the same name is a character
45
+ // count our CSS overrides anyway. Any axis whose name collides with an
46
+ // attribute of the element we render must be Omitted like this, or renamed.
47
+ interface Props
48
+ extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>,
49
+ Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'size' | 'color' | 'onpointerdown'> {
50
+ /** Expanding wave from the pointer on press. */
51
+ ripple?: boolean;
52
+ /** Renders an <a> instead of a <button>. */
53
+ href?: string;
54
+ class?: string;
55
+ children?: Snippet;
56
+ /* Ours, because the ripple rides on it: the element may be a <button>
57
+ or an <a>, so the inherited overloaded signature cannot type it. */
58
+ onpointerdown?: (event: PointerEvent & { currentTarget: EventTarget & HTMLElement }) => void;
59
+ }
60
+
61
+ // The axes are deliberately NOT destructured: they travel in `axes` and are
62
+ // resolved by name against the AXES block. That is what keeps this half of
63
+ // the file free of any axis by name — drop an axis up there and
64
+ // nothing down here has to know.
65
+ let {
66
+ ripple = false,
67
+ disabled = false,
68
+ href,
69
+ onpointerdown,
70
+ class: klass = '',
71
+ children,
72
+ ...axes
73
+ }: Props = $props();
74
+
75
+ let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
76
+
77
+ let classes = $derived(
78
+ cx(
79
+ PREFIX,
80
+ applied.classes,
81
+ ripple && `${PREFIX}-ripple`,
82
+ // An <a> cannot be disabled, so the class carries what the attribute
83
+ // would have: it is the only way the two states cannot drift apart.
84
+ href && disabled && `${PREFIX}-disabled`,
85
+ klass
86
+ )
87
+ );
88
+
89
+ // Live ripple waves; each renders a .btn-ripple-wave positioned at the
90
+ // press point and removed when its animation ends.
91
+ let waves = $state<{ id: number; x: number; y: number; size: number }[]>([]);
92
+ let waveId = 0;
93
+
94
+ function press(e: PointerEvent & { currentTarget: EventTarget & HTMLElement }) {
95
+ if (ripple) {
96
+ const rect = e.currentTarget.getBoundingClientRect();
97
+ const x = e.clientX - rect.left;
98
+ const y = e.clientY - rect.top;
99
+ // Radius reaching the farthest corner, so the wave always covers it.
100
+ const r = 2 * Math.hypot(Math.max(x, rect.width - x), Math.max(y, rect.height - y));
101
+ waves.push({ id: waveId++, x, y, size: r });
102
+ }
103
+ onpointerdown?.(e);
104
+ }
105
+ </script>
106
+
107
+ {#snippet body()}
108
+ {@render children?.()}
109
+ {#each waves as wave (wave.id)}
110
+ <span
111
+ class={`${PREFIX}-ripple-wave`}
112
+ style="--ripple-x:{wave.x}px;--ripple-y:{wave.y}px;--ripple-size:{wave.size}px"
113
+ onanimationend={() => (waves = waves.filter((w) => w.id !== wave.id))}
114
+ ></span>
115
+ {/each}
116
+ {/snippet}
117
+
118
+ {#if href}
119
+ <a
120
+ {...applied.rest}
121
+ href={disabled ? undefined : href}
122
+ class={classes}
123
+ aria-disabled={disabled ? 'true' : undefined}
124
+ onpointerdown={press}
125
+ >
126
+ {@render body()}
127
+ </a>
128
+ {:else}
129
+ <button {...applied.rest} class={classes} {disabled} onpointerdown={press}>
130
+ {@render body()}
131
+ </button>
132
+ {/if}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * What .btn is made of, classified. The props follow the families the
3
+ * project registers: a family's `.css.d.ts` narrows them to what it ships
4
+ * (variants.ts, ADR 0015).
5
+ *
6
+ * AXES are mutually exclusive and named after what they impact. FLAGS are
7
+ * independent booleans. PARTS are class names the component renders itself
8
+ * and never exposes. The build fails if a .btn-* class in a family's CSS
9
+ * appears in none of the three.
10
+ */
11
+ export declare const PREFIX = "btn";
12
+ export declare const AXES: {
13
+ readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
14
+ readonly size: readonly ["xxs", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"];
15
+ readonly shape: readonly ["square", "circle"];
16
+ readonly width: readonly ["wide", "block"];
17
+ readonly variant: readonly ["outline", "dash", "soft", "ghost", "link", "classic", "surface"];
18
+ readonly shadow: readonly ["none", "reverse"];
19
+ };
20
+ export declare const FLAGS: {
21
+ readonly active: "Draw the button as if it were the current choice.";
22
+ };
23
+ export declare const PARTS: readonly ["ripple", "ripple-wave", "disabled"];
24
+ import type { Snippet } from 'svelte';
25
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
26
+ import { type AxisProps } from '../variants.js';
27
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'size' | 'color' | 'onpointerdown'> {
28
+ /** Expanding wave from the pointer on press. */
29
+ ripple?: boolean;
30
+ /** Renders an <a> instead of a <button>. */
31
+ href?: string;
32
+ class?: string;
33
+ children?: Snippet;
34
+ onpointerdown?: (event: PointerEvent & {
35
+ currentTarget: EventTarget & HTMLElement;
36
+ }) => void;
37
+ }
38
+ declare const Button: import("svelte").Component<Props, {}, "">;
39
+ type Button = ReturnType<typeof Button>;
40
+ export default Button;
@@ -0,0 +1,193 @@
1
+ <script module lang="ts">
2
+ /** What .calendar is made of, classified. The props follow the
3
+ families the project registers (variants.ts, ADR 0015).
4
+
5
+ `.calendar` is the only class we own. The calendar inside is drawn by
6
+ air-datepicker (vendored, src/lib/vendor/air-datepicker), whose class
7
+ names — `.air-datepicker-cell`, `.-selected-`… — are its own: a family
8
+ styles them from under `.calendar`, it does not own them. */
9
+ export const PREFIX = 'calendar';
10
+
11
+ export const AXES = {
12
+ /* The selected day and the range. */
13
+ color: ['primary', 'secondary', 'accent', 'neutral', 'info', 'success', 'warning', 'error'],
14
+ size: ['xs', 'sm', 'md', 'lg', 'xl']
15
+ } as const;
16
+
17
+ export const FLAGS = {} as const;
18
+ export const PARTS = [] as const;
19
+ </script>
20
+
21
+ <script lang="ts">
22
+ /**
23
+ * A date picker, drawn by air-datepicker (https://air-datepicker.com).
24
+ *
25
+ * Inline by default: the calendar sits in the page. With `inline={false}`
26
+ * it is a field (`.input`) that opens the calendar under it; the calendar
27
+ * is then appended to this component's own `.calendar` element rather
28
+ * than to <body>, so it stays under the class every family styles.
29
+ *
30
+ * `value` is a Date (or null) — an array of Dates with `range` or
31
+ * `multiple`. Anything air-datepicker can do that has no prop here goes
32
+ * through `options`, applied last.
33
+ */
34
+ import { untrack } from 'svelte';
35
+ import type { HTMLAttributes } from 'svelte/elements';
36
+ import AirDatepicker from '../vendor/air-datepicker/index.js';
37
+ import type {
38
+ AirDatepickerLocale,
39
+ AirDatepickerOptions,
40
+ AirDatepickerViews,
41
+ AirDatepickerViewsSingle,
42
+ AirDatepickerButtonPresets
43
+ } from '../vendor/air-datepicker/index.js';
44
+ import { applyAxes, cx, type AxisProps } from '../variants.js';
45
+
46
+ type Value = Date | Date[] | null;
47
+
48
+ // `color` is ours — the HTML attribute of the same name is long obsolete.
49
+ interface Props
50
+ extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>,
51
+ Omit<HTMLAttributes<HTMLDivElement>, 'color'> {
52
+ /** The picked date, or dates with `range` / `multiple`. Bindable. */
53
+ value?: Value;
54
+ /** Pick a start and an end. */
55
+ range?: boolean;
56
+ /** Pick several dates — at most this many when a number. */
57
+ multiple?: boolean | number;
58
+ /** In the page (default), or as a field that opens it. */
59
+ inline?: boolean;
60
+ /** The field's placeholder and name, when not inline. */
61
+ placeholder?: string;
62
+ name?: string;
63
+ /** The field cannot be opened, when not inline. */
64
+ disabled?: boolean;
65
+ /** Bounds: dates outside cannot be picked. */
66
+ min?: Date;
67
+ max?: Date;
68
+ /** Month and day names. English unless given (see vendor/air-datepicker/locale). */
69
+ locale?: AirDatepickerLocale;
70
+ /** First day of the week: 0 Sunday … 6 Saturday. Defaults to the locale's. */
71
+ firstDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
72
+ /** The view it opens on, and the finest one a pick can be made in. */
73
+ view?: AirDatepickerViews;
74
+ minView?: AirDatepickerViews;
75
+ /** Hours and minutes too. */
76
+ timepicker?: boolean;
77
+ /** Buttons under the calendar. */
78
+ buttons?: AirDatepickerButtonPresets[];
79
+ /** How a date is written in the field (air-datepicker tokens). */
80
+ dateFormat?: string;
81
+ /** Anything else air-datepicker accepts. Applied last. */
82
+ options?: AirDatepickerOptions<HTMLElement>;
83
+ /** Called with the new value after every pick. */
84
+ onChange?: (value: Value) => void;
85
+ /** The air-datepicker instance, for what no prop covers. Bindable. */
86
+ picker?: AirDatepicker<HTMLElement>;
87
+ class?: string;
88
+ }
89
+
90
+ // The axes are deliberately NOT destructured: they travel in `axes` and are
91
+ // resolved by name, so an axis a family drops changes nothing down here.
92
+ let {
93
+ value = $bindable(null),
94
+ range = false,
95
+ multiple = false,
96
+ inline = true,
97
+ placeholder,
98
+ name,
99
+ disabled = false,
100
+ min,
101
+ max,
102
+ locale,
103
+ firstDay,
104
+ view = 'days',
105
+ minView = 'days',
106
+ timepicker = false,
107
+ buttons,
108
+ dateFormat,
109
+ options,
110
+ onChange,
111
+ picker = $bindable(),
112
+ class: klass = '',
113
+ ...axes
114
+ }: Props = $props();
115
+
116
+ let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
117
+ let classes = $derived(cx(PREFIX, applied.classes, klass));
118
+
119
+ let host: HTMLDivElement | undefined = $state();
120
+ let field: HTMLInputElement | undefined = $state();
121
+
122
+ const asList = (v: Value): Date[] => (v == null ? [] : Array.isArray(v) ? v : [v]);
123
+ const same = (a: Date[], b: Date[]) =>
124
+ a.length === b.length && a.every((d, i) => d.getTime() === b[i]!.getTime());
125
+
126
+ /** Everything air-datepicker is told, but the dates and the callback. */
127
+ let settings = $derived<AirDatepickerOptions<HTMLElement>>({
128
+ range,
129
+ multipleDates: multiple,
130
+ minDate: min,
131
+ maxDate: max,
132
+ ...(locale ? { locale } : {}),
133
+ ...(firstDay !== undefined ? { firstDay } : {}),
134
+ view,
135
+ minView,
136
+ timepicker,
137
+ ...(buttons ? { buttons } : {}),
138
+ ...(dateFormat ? { dateFormat } : {}),
139
+ // A popup closes on a pick when one date is all there is to pick.
140
+ autoClose: !range && !multiple && !timepicker,
141
+ position: 'bottom left',
142
+ ...options
143
+ });
144
+
145
+ function picked({ date }: { date: Date | Date[] }) {
146
+ const next: Value = range || multiple ? asList(date as Value) : ((date as Date | undefined) ?? null);
147
+ if (same(asList(next), asList(value))) return;
148
+ value = next;
149
+ onChange?.(next);
150
+ }
151
+
152
+ // One instance per element: built when the element is there, rebuilt only
153
+ // when switching between inline and field.
154
+ $effect(() => {
155
+ const el = inline ? host : field;
156
+ if (!el || !host) return;
157
+ const instance = new AirDatepicker<HTMLElement>(el, {
158
+ ...untrack(() => settings),
159
+ inline,
160
+ // The popup is placed against, and appended to, our own element.
161
+ container: inline ? undefined : host,
162
+ selectedDates: untrack(() => asList(value)),
163
+ onSelect: picked
164
+ });
165
+ picker = instance;
166
+ return () => {
167
+ instance.destroy();
168
+ picker = undefined;
169
+ };
170
+ });
171
+
172
+ // Settings changed: the instance takes them as they are.
173
+ $effect(() => {
174
+ const next = settings;
175
+ untrack(() => picker?.update(next, { silent: true }));
176
+ });
177
+
178
+ // The value changed from outside: select it, without echoing it back.
179
+ $effect(() => {
180
+ const wanted = asList(value);
181
+ untrack(() => {
182
+ if (!picker || same(wanted, picker.selectedDates)) return;
183
+ picker.clear({ silent: true });
184
+ if (wanted.length) picker.selectDate(wanted, { silent: true });
185
+ });
186
+ });
187
+ </script>
188
+
189
+ <div {...applied.rest} bind:this={host} class={classes}>
190
+ {#if !inline}
191
+ <input bind:this={field} class="input" {placeholder} {name} {disabled} readonly />
192
+ {/if}
193
+ </div>
@@ -0,0 +1,60 @@
1
+ /** What .calendar is made of, classified. The props follow the
2
+ families the project registers (variants.ts, ADR 0015).
3
+
4
+ `.calendar` is the only class we own. The calendar inside is drawn by
5
+ air-datepicker (vendored, src/lib/vendor/air-datepicker), whose class
6
+ names — `.air-datepicker-cell`, `.-selected-`… — are its own: a family
7
+ styles them from under `.calendar`, it does not own them. */
8
+ export declare const PREFIX = "calendar";
9
+ export declare const AXES: {
10
+ readonly color: readonly ["primary", "secondary", "accent", "neutral", "info", "success", "warning", "error"];
11
+ readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
12
+ };
13
+ export declare const FLAGS: {};
14
+ export declare const PARTS: readonly [];
15
+ import type { HTMLAttributes } from 'svelte/elements';
16
+ import AirDatepicker from '../vendor/air-datepicker/index.js';
17
+ import type { AirDatepickerLocale, AirDatepickerOptions, AirDatepickerViews, AirDatepickerButtonPresets } from '../vendor/air-datepicker/index.js';
18
+ import { type AxisProps } from '../variants.js';
19
+ type Value = Date | Date[] | null;
20
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLDivElement>, 'color'> {
21
+ /** The picked date, or dates with `range` / `multiple`. Bindable. */
22
+ value?: Value;
23
+ /** Pick a start and an end. */
24
+ range?: boolean;
25
+ /** Pick several dates — at most this many when a number. */
26
+ multiple?: boolean | number;
27
+ /** In the page (default), or as a field that opens it. */
28
+ inline?: boolean;
29
+ /** The field's placeholder and name, when not inline. */
30
+ placeholder?: string;
31
+ name?: string;
32
+ /** The field cannot be opened, when not inline. */
33
+ disabled?: boolean;
34
+ /** Bounds: dates outside cannot be picked. */
35
+ min?: Date;
36
+ max?: Date;
37
+ /** Month and day names. English unless given (see vendor/air-datepicker/locale). */
38
+ locale?: AirDatepickerLocale;
39
+ /** First day of the week: 0 Sunday … 6 Saturday. Defaults to the locale's. */
40
+ firstDay?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
41
+ /** The view it opens on, and the finest one a pick can be made in. */
42
+ view?: AirDatepickerViews;
43
+ minView?: AirDatepickerViews;
44
+ /** Hours and minutes too. */
45
+ timepicker?: boolean;
46
+ /** Buttons under the calendar. */
47
+ buttons?: AirDatepickerButtonPresets[];
48
+ /** How a date is written in the field (air-datepicker tokens). */
49
+ dateFormat?: string;
50
+ /** Anything else air-datepicker accepts. Applied last. */
51
+ options?: AirDatepickerOptions<HTMLElement>;
52
+ /** Called with the new value after every pick. */
53
+ onChange?: (value: Value) => void;
54
+ /** The air-datepicker instance, for what no prop covers. Bindable. */
55
+ picker?: AirDatepicker<HTMLElement>;
56
+ class?: string;
57
+ }
58
+ declare const Calendar: import("svelte").Component<Props, {}, "value" | "picker">;
59
+ type Calendar = ReturnType<typeof Calendar>;
60
+ export default Calendar;
@@ -0,0 +1,69 @@
1
+ <script module lang="ts">
2
+ /** What .card is made of, classified. */
3
+ export const PREFIX = 'card';
4
+
5
+ export const AXES = {
6
+ size: ['xs', 'sm', 'md', 'lg', 'xl']
7
+ } as const;
8
+
9
+ /** `border` and `dash` are exclusive in practice but not by construction:
10
+ a card with both simply takes the last rule, and neither is a look you
11
+ reach for by accident. */
12
+ export const FLAGS = {
13
+ border: 'Draw an edge the family does not draw by default.',
14
+ dash: 'Draw that edge dashed.',
15
+ side: 'Put the figure beside the body instead of above it.',
16
+ 'image-full': 'Let the figure fill the card, with the body laid over it.'
17
+ } as const;
18
+ export const PARTS = ['title', 'body', 'actions'] as const;
19
+ </script>
20
+
21
+ <script lang="ts">
22
+ /**
23
+ * A box with, optionally, a title, a body and a row of actions.
24
+ *
25
+ * Every part is optional. A card with nothing but children is a card, and
26
+ * that is the common case — which is why `body` wraps the children rather
27
+ * than being a snippet you have to remember to pass.
28
+ */
29
+ import type { Snippet } from 'svelte';
30
+ import type { HTMLAttributes } from 'svelte/elements';
31
+ import { applyAxes, cx, type AxisProps } from '../variants.js';
32
+
33
+ /* `title` is an HTML attribute too, and a tooltip is not a heading — so
34
+ the DOM one is dropped rather than shadowed silently. */
35
+ interface Props
36
+ extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>,
37
+ Omit<HTMLAttributes<HTMLElement>, 'title'> {
38
+ title?: Snippet;
39
+ /** A row of buttons, at the end of the body. */
40
+ actions?: Snippet;
41
+ /** An image or anything else that spans the card, above the body. */
42
+ figure?: Snippet;
43
+ class?: string;
44
+ children?: Snippet;
45
+ }
46
+
47
+ let {
48
+ title,
49
+ actions,
50
+ figure,
51
+ class: klass = '',
52
+ children,
53
+ ...axes
54
+ }: Props = $props();
55
+
56
+ let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
57
+ let classes = $derived(cx(PREFIX, applied.classes, klass));
58
+ </script>
59
+
60
+ <div class={classes} {...applied.rest}>
61
+ {#if figure}
62
+ <figure>{@render figure()}</figure>
63
+ {/if}
64
+ <div class="card-body">
65
+ {#if title}<h2 class="card-title">{@render title()}</h2>{/if}
66
+ {@render children?.()}
67
+ {#if actions}<div class="card-actions">{@render actions()}</div>{/if}
68
+ </div>
69
+ </div>
@@ -0,0 +1,37 @@
1
+ /** What .card is made of, classified. */
2
+ export declare const PREFIX = "card";
3
+ export declare const AXES: {
4
+ readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
5
+ };
6
+ /** `border` and `dash` are exclusive in practice but not by construction:
7
+ a card with both simply takes the last rule, and neither is a look you
8
+ reach for by accident. */
9
+ export declare const FLAGS: {
10
+ readonly border: "Draw an edge the family does not draw by default.";
11
+ readonly dash: "Draw that edge dashed.";
12
+ readonly side: "Put the figure beside the body instead of above it.";
13
+ readonly 'image-full': "Let the figure fill the card, with the body laid over it.";
14
+ };
15
+ export declare const PARTS: readonly ["title", "body", "actions"];
16
+ /**
17
+ * A box with, optionally, a title, a body and a row of actions.
18
+ *
19
+ * Every part is optional. A card with nothing but children is a card, and
20
+ * that is the common case — which is why `body` wraps the children rather
21
+ * than being a snippet you have to remember to pass.
22
+ */
23
+ import type { Snippet } from 'svelte';
24
+ import type { HTMLAttributes } from 'svelte/elements';
25
+ import { type AxisProps } from '../variants.js';
26
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLElement>, 'title'> {
27
+ title?: Snippet;
28
+ /** A row of buttons, at the end of the body. */
29
+ actions?: Snippet;
30
+ /** An image or anything else that spans the card, above the body. */
31
+ figure?: Snippet;
32
+ class?: string;
33
+ children?: Snippet;
34
+ }
35
+ declare const Card: import("svelte").Component<Props, {}, "">;
36
+ type Card = ReturnType<typeof Card>;
37
+ export default Card;