@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,64 @@
1
+ <script module lang="ts">
2
+ /** What .empty-state is made of, classified. The props follow the
3
+ families the project registers (variants.ts, ADR 0015). */
4
+ export const PREFIX = 'empty-state';
5
+
6
+ export const AXES = {
7
+ size: ['xs', 'sm', 'md', 'lg', 'xl'],
8
+ /* A dashed frame, as around a drop zone. */
9
+ variant: ['dashed']
10
+ } as const;
11
+
12
+ export const FLAGS = {} as const;
13
+ export const PARTS = ['icon', 'title', 'body', 'actions'] as const;
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ /**
18
+ * What to show when there is nothing: no results, an empty folder, a list
19
+ * not started yet. Sits in the `empty` slot of Table, Grid and List.
20
+ */
21
+ import type { Snippet } from 'svelte';
22
+ import type { HTMLAttributes } from 'svelte/elements';
23
+ import { applyAxes, cx, type AxisProps } from '../variants.js';
24
+
25
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
26
+ title?: string;
27
+ /** An illustration or an icon, in a disc. Defaults to an empty tray. */
28
+ icon?: Snippet;
29
+ /** What to do about it: buttons, links. */
30
+ actions?: Snippet;
31
+ class?: string;
32
+ /** The explanation, under the title. */
33
+ children?: Snippet;
34
+ }
35
+
36
+ // The axes are deliberately NOT destructured: they travel in `axes` and are
37
+ // resolved by name, so an axis a family drops changes nothing down here.
38
+ let {
39
+ title,
40
+ icon,
41
+ actions,
42
+ class: klass = '',
43
+ children,
44
+ ...axes
45
+ }: Props = $props();
46
+
47
+ let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
48
+ let classes = $derived(cx(PREFIX, applied.classes, klass));
49
+ </script>
50
+
51
+ <div {...applied.rest} class={classes}>
52
+ <div class="empty-state-icon" aria-hidden="true">
53
+ {#if icon}
54
+ {@render icon()}
55
+ {:else}
56
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
57
+ <path d="M3 13h5l1.5 2.5h5L16 13h5" /><path d="M5.5 5h13L21 13v5a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-5z" />
58
+ </svg>
59
+ {/if}
60
+ </div>
61
+ {#if title}<p class="empty-state-title">{title}</p>{/if}
62
+ {#if children}<p class="empty-state-body">{@render children()}</p>{/if}
63
+ {#if actions}<div class="empty-state-actions">{@render actions()}</div>{/if}
64
+ </div>
@@ -0,0 +1,29 @@
1
+ /** What .empty-state is made of, classified. The props follow the
2
+ families the project registers (variants.ts, ADR 0015). */
3
+ export declare const PREFIX = "empty-state";
4
+ export declare const AXES: {
5
+ readonly size: readonly ["xs", "sm", "md", "lg", "xl"];
6
+ readonly variant: readonly ["dashed"];
7
+ };
8
+ export declare const FLAGS: {};
9
+ export declare const PARTS: readonly ["icon", "title", "body", "actions"];
10
+ /**
11
+ * What to show when there is nothing: no results, an empty folder, a list
12
+ * not started yet. Sits in the `empty` slot of Table, Grid and List.
13
+ */
14
+ import type { Snippet } from 'svelte';
15
+ import type { HTMLAttributes } from 'svelte/elements';
16
+ import { type AxisProps } from '../variants.js';
17
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
18
+ title?: string;
19
+ /** An illustration or an icon, in a disc. Defaults to an empty tray. */
20
+ icon?: Snippet;
21
+ /** What to do about it: buttons, links. */
22
+ actions?: Snippet;
23
+ class?: string;
24
+ /** The explanation, under the title. */
25
+ children?: Snippet;
26
+ }
27
+ declare const EmptyState: import("svelte").Component<Props, {}, "">;
28
+ type EmptyState = ReturnType<typeof EmptyState>;
29
+ export default EmptyState;
@@ -0,0 +1,42 @@
1
+ <script module lang="ts">
2
+ /** What .fieldset is made of, classified. The props follow the
3
+ families the project registers (variants.ts, ADR 0015). */
4
+ export const PREFIX = 'fieldset';
5
+
6
+ export const AXES = {} as const;
7
+
8
+ export const FLAGS = {} as const;
9
+ export const PARTS = ['legend', 'label'] as const;
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ import type { Snippet } from 'svelte';
14
+ import type { HTMLFieldsetAttributes } from 'svelte/elements';
15
+ import { applyAxes, cx, type AxisProps } from '../variants.js';
16
+
17
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLFieldsetAttributes {
18
+ /** The group's heading. */
19
+ legend?: string | Snippet;
20
+ /** A note under the group. */
21
+ label?: string | Snippet;
22
+ class?: string;
23
+ children?: Snippet;
24
+ }
25
+
26
+ let {
27
+ legend,
28
+ label,
29
+ class: klass = '',
30
+ children,
31
+ ...axes
32
+ }: Props = $props();
33
+
34
+ let applied = $derived(applyAxes(PREFIX, AXES, FLAGS, axes));
35
+ let classes = $derived(cx(PREFIX, applied.classes, klass));
36
+ </script>
37
+
38
+ <fieldset {...applied.rest} class={classes}>
39
+ {#if legend}<legend class="fieldset-legend">{#if typeof legend === 'function'}{@render legend()}{:else}{legend}{/if}</legend>{/if}
40
+ {@render children?.()}
41
+ {#if label}<p class="fieldset-label">{#if typeof label === 'function'}{@render label()}{:else}{label}{/if}</p>{/if}
42
+ </fieldset>
@@ -0,0 +1,20 @@
1
+ /** What .fieldset is made of, classified. The props follow the
2
+ families the project registers (variants.ts, ADR 0015). */
3
+ export declare const PREFIX = "fieldset";
4
+ export declare const AXES: {};
5
+ export declare const FLAGS: {};
6
+ export declare const PARTS: readonly ["legend", "label"];
7
+ import type { Snippet } from 'svelte';
8
+ import type { HTMLFieldsetAttributes } from 'svelte/elements';
9
+ import { type AxisProps } from '../variants.js';
10
+ interface Props extends AxisProps<typeof AXES, typeof FLAGS, typeof PREFIX>, HTMLFieldsetAttributes {
11
+ /** The group's heading. */
12
+ legend?: string | Snippet;
13
+ /** A note under the group. */
14
+ label?: string | Snippet;
15
+ class?: string;
16
+ children?: Snippet;
17
+ }
18
+ declare const Fieldset: import("svelte").Component<Props, {}, "">;
19
+ type Fieldset = ReturnType<typeof Fieldset>;
20
+ export default Fieldset;
@@ -0,0 +1,154 @@
1
+ <script lang="ts">
2
+ /**
3
+ * Its content becomes a place to drop files on. It draws nothing of its
4
+ * own — no namespace —: what is inside is the look, `over` says when
5
+ * files are dragged above it, `open()` opens the file dialog.
6
+ *
7
+ * A visually hidden `<input type="file">` holds the files: it carries
8
+ * `name`, `accept`, `multiple` and `required`, so a form submits and
9
+ * validates them, and a drop fills it as a pick does. `onFiles` gets the
10
+ * files that match `accept` (and `maxSize`), then those that do not.
11
+ */
12
+ import type { Snippet } from 'svelte';
13
+ import type { HTMLAttributes } from 'svelte/elements';
14
+
15
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
16
+ /** As on a file input: `image/*`, `.pdf`, `application/json`… */
17
+ accept?: string;
18
+ /** Several files at once. */
19
+ multiple?: boolean;
20
+ /** Neither drops nor the dialog. */
21
+ disabled?: boolean;
22
+ /** For a form: the file input's name. */
23
+ name?: string;
24
+ /** A file is needed: the file input says so to its form. */
25
+ required?: boolean;
26
+ /** On the file input. */
27
+ id?: string;
28
+ /** A click on the zone opens the dialog. Off by default: the content usually holds its own button. */
29
+ clickable?: boolean;
30
+ /** Largest file, in bytes. */
31
+ maxSize?: number;
32
+ /** Files are dragged above the zone. Bindable, for a look drawn outside it. */
33
+ over?: boolean;
34
+ /** After a drop or a pick: the files kept, then the ones refused. */
35
+ onFiles?: (accepted: File[], rejected: File[]) => void;
36
+ /** The content, given whether files are dragged above it and how to open the dialog. */
37
+ children?: Snippet<[{ over: boolean; open: () => void }]>;
38
+ class?: string;
39
+ }
40
+
41
+ let {
42
+ accept,
43
+ multiple = false,
44
+ disabled = false,
45
+ name,
46
+ required = false,
47
+ id,
48
+ clickable = false,
49
+ maxSize = Infinity,
50
+ over = $bindable(false),
51
+ onFiles,
52
+ children,
53
+ class: klass = '',
54
+ ...rest
55
+ }: Props = $props();
56
+
57
+ let input: HTMLInputElement | undefined = $state();
58
+ /** dragenter / dragleave fire for every child crossed: count them. */
59
+ let depth = 0;
60
+ function count(next: number) {
61
+ depth = Math.max(0, next);
62
+ over = depth > 0;
63
+ }
64
+
65
+ /** Open the file dialog. */
66
+ export function open() {
67
+ if (!disabled) input?.click();
68
+ }
69
+
70
+ function matches(file: File): boolean {
71
+ if (file.size > maxSize) return false;
72
+ if (!accept) return true;
73
+ const type = file.type.toLowerCase();
74
+ const fileName = file.name.toLowerCase();
75
+ return accept.split(',').some((raw) => {
76
+ const rule = raw.trim().toLowerCase();
77
+ if (!rule) return false;
78
+ if (rule.startsWith('.')) return fileName.endsWith(rule);
79
+ if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));
80
+ return type === rule;
81
+ });
82
+ }
83
+
84
+ function take(list: FileList | File[]) {
85
+ const files = multiple ? [...list] : [...list].slice(0, 1);
86
+ const accepted = files.filter(matches);
87
+ const rejected = files.filter((f) => !matches(f));
88
+ onFiles?.(accepted, rejected);
89
+ }
90
+
91
+ const carriesFiles = (e: DragEvent) => !!e.dataTransfer?.types.includes('Files');
92
+
93
+ function handleDragEnter(e: DragEvent) {
94
+ if (disabled || !carriesFiles(e)) return;
95
+ e.preventDefault();
96
+ count(depth + 1);
97
+ }
98
+
99
+ function handleDragOver(e: DragEvent) {
100
+ if (disabled || !carriesFiles(e)) return;
101
+ e.preventDefault();
102
+ if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
103
+ }
104
+
105
+ function handleDragLeave(e: DragEvent) {
106
+ if (disabled || !carriesFiles(e)) return;
107
+ count(depth - 1);
108
+ }
109
+
110
+ function handleDrop(e: DragEvent) {
111
+ count(0);
112
+ if (disabled || !e.dataTransfer?.files.length) return;
113
+ e.preventDefault();
114
+ const dropped = e.dataTransfer.files;
115
+ // The file input holds what was dropped, as if picked: a form sees it.
116
+ if (input) {
117
+ const kept = new DataTransfer();
118
+ for (const f of multiple ? [...dropped] : [...dropped].slice(0, 1)) if (matches(f)) kept.items.add(f);
119
+ input.files = kept.files;
120
+ }
121
+ take(dropped);
122
+ }
123
+ </script>
124
+
125
+ <!-- The zone itself is not a control: the content holds the button, or
126
+ `clickable` makes a click anywhere open the dialog. -->
127
+ <!-- svelte-ignore a11y_no_static_element_interactions, a11y_click_events_have_key_events -->
128
+ <div
129
+ {...rest}
130
+ class={klass}
131
+ style="position: relative;"
132
+ data-over={over || undefined}
133
+ ondragenter={handleDragEnter}
134
+ ondragover={handleDragOver}
135
+ ondragleave={handleDragLeave}
136
+ ondrop={handleDrop}
137
+ onclick={clickable ? (e) => { if (e.target !== input) open(); } : undefined}
138
+ >
139
+ {@render children?.({ over, open })}
140
+ <input
141
+ bind:this={input}
142
+ type="file"
143
+ {id}
144
+ {name}
145
+ {accept}
146
+ {multiple}
147
+ {required}
148
+ {disabled}
149
+ tabindex="-1"
150
+ aria-hidden="true"
151
+ style="position: absolute; inset-inline-start: 0; inset-block-end: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none;"
152
+ onchange={(e) => e.currentTarget.files && take(e.currentTarget.files)}
153
+ />
154
+ </div>
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Its content becomes a place to drop files on. It draws nothing of its
3
+ * own — no namespace —: what is inside is the look, `over` says when
4
+ * files are dragged above it, `open()` opens the file dialog.
5
+ *
6
+ * A visually hidden `<input type="file">` holds the files: it carries
7
+ * `name`, `accept`, `multiple` and `required`, so a form submits and
8
+ * validates them, and a drop fills it as a pick does. `onFiles` gets the
9
+ * files that match `accept` (and `maxSize`), then those that do not.
10
+ */
11
+ import type { Snippet } from 'svelte';
12
+ import type { HTMLAttributes } from 'svelte/elements';
13
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
14
+ /** As on a file input: `image/*`, `.pdf`, `application/json`… */
15
+ accept?: string;
16
+ /** Several files at once. */
17
+ multiple?: boolean;
18
+ /** Neither drops nor the dialog. */
19
+ disabled?: boolean;
20
+ /** For a form: the file input's name. */
21
+ name?: string;
22
+ /** A file is needed: the file input says so to its form. */
23
+ required?: boolean;
24
+ /** On the file input. */
25
+ id?: string;
26
+ /** A click on the zone opens the dialog. Off by default: the content usually holds its own button. */
27
+ clickable?: boolean;
28
+ /** Largest file, in bytes. */
29
+ maxSize?: number;
30
+ /** Files are dragged above the zone. Bindable, for a look drawn outside it. */
31
+ over?: boolean;
32
+ /** After a drop or a pick: the files kept, then the ones refused. */
33
+ onFiles?: (accepted: File[], rejected: File[]) => void;
34
+ /** The content, given whether files are dragged above it and how to open the dialog. */
35
+ children?: Snippet<[{
36
+ over: boolean;
37
+ open: () => void;
38
+ }]>;
39
+ class?: string;
40
+ }
41
+ declare const FileDropzone: import("svelte").Component<Props, {
42
+ open: () => void;
43
+ }, "over">;
44
+ type FileDropzone = ReturnType<typeof FileDropzone>;
45
+ export default FileDropzone;