svelte-multistyle-ui 0.0.15-alpha → 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 (174) hide show
  1. package/README.md +55 -3
  2. package/cli/bin.js +94 -92
  3. package/cli/emit.js +242 -225
  4. package/cli/fixtures/sample.expected.svelte +2 -1
  5. package/cli/generate.js +507 -499
  6. package/cli/registry.js +105 -100
  7. package/cli/schema.js +16 -0
  8. package/dist/actions/dialog.d.ts +11 -0
  9. package/dist/actions/dialog.js +118 -0
  10. package/dist/components/Accordion.svelte +11 -5
  11. package/dist/components/Accordion.svelte.d.ts +8 -12
  12. package/dist/components/Alert.svelte +11 -5
  13. package/dist/components/Alert.svelte.d.ts +8 -16
  14. package/dist/components/Avatar.svelte +13 -3
  15. package/dist/components/Avatar.svelte.d.ts +8 -14
  16. package/dist/components/Breadcrumb.svelte +9 -3
  17. package/dist/components/Breadcrumb.svelte.d.ts +8 -8
  18. package/dist/components/Button.svelte +11 -3
  19. package/dist/components/Button.svelte.d.ts +8 -20
  20. package/dist/components/ButtonGroup.svelte +10 -4
  21. package/dist/components/ButtonGroup.svelte.d.ts +8 -16
  22. package/dist/components/Card.svelte +9 -3
  23. package/dist/components/Card.svelte.d.ts +8 -12
  24. package/dist/components/Carousel.svelte +17 -9
  25. package/dist/components/Carousel.svelte.d.ts +8 -16
  26. package/dist/components/Checkbox.svelte +10 -4
  27. package/dist/components/Checkbox.svelte.d.ts +8 -14
  28. package/dist/components/Chip.svelte +10 -4
  29. package/dist/components/Chip.svelte.d.ts +8 -20
  30. package/dist/components/CodeEditor.svelte +139 -129
  31. package/dist/components/CodeEditor.svelte.d.ts +8 -16
  32. package/dist/components/Column.svelte +48 -38
  33. package/dist/components/Column.svelte.d.ts +8 -12
  34. package/dist/components/CommandPalette.svelte +14 -5
  35. package/dist/components/CommandPalette.svelte.d.ts +8 -12
  36. package/dist/components/CrudView.svelte +1604 -0
  37. package/dist/components/CrudView.svelte.d.ts +17 -0
  38. package/dist/components/DatePicker.svelte +42 -10
  39. package/dist/components/DatePicker.svelte.d.ts +8 -24
  40. package/dist/components/Divider.svelte +9 -3
  41. package/dist/components/Divider.svelte.d.ts +8 -10
  42. package/dist/components/Drawer.svelte +19 -3
  43. package/dist/components/Drawer.svelte.d.ts +8 -14
  44. package/dist/components/DropdownMenu.svelte +32 -5
  45. package/dist/components/DropdownMenu.svelte.d.ts +8 -18
  46. package/dist/components/FAB.svelte +10 -4
  47. package/dist/components/FAB.svelte.d.ts +8 -14
  48. package/dist/components/FileUpload.svelte +47 -8
  49. package/dist/components/FileUpload.svelte.d.ts +8 -14
  50. package/dist/components/FilterBar.svelte +768 -0
  51. package/dist/components/FilterBar.svelte.d.ts +17 -0
  52. package/dist/components/GraphEditor.svelte +725 -723
  53. package/dist/components/GraphEditor.svelte.d.ts +8 -8
  54. package/dist/components/Grid.svelte +61 -51
  55. package/dist/components/Grid.svelte.d.ts +8 -18
  56. package/dist/components/IconButton.svelte +12 -4
  57. package/dist/components/IconButton.svelte.d.ts +8 -22
  58. package/dist/components/InlineEdit.svelte +6 -3
  59. package/dist/components/InlineEdit.svelte.d.ts +10 -10
  60. package/dist/components/Input.svelte +18 -4
  61. package/dist/components/Input.svelte.d.ts +8 -62
  62. package/dist/components/Modal.svelte +14 -5
  63. package/dist/components/Modal.svelte.d.ts +8 -16
  64. package/dist/components/MultiSelect.svelte +22 -204
  65. package/dist/components/MultiSelect.svelte.d.ts +8 -16
  66. package/dist/components/Pagination.svelte +19 -4
  67. package/dist/components/Pagination.svelte.d.ts +8 -12
  68. package/dist/components/Popover.svelte +15 -4
  69. package/dist/components/Popover.svelte.d.ts +8 -16
  70. package/dist/components/ProgressBar.svelte +79 -73
  71. package/dist/components/ProgressBar.svelte.d.ts +8 -14
  72. package/dist/components/Radio.svelte +10 -4
  73. package/dist/components/Radio.svelte.d.ts +8 -14
  74. package/dist/components/Rating.svelte +30 -6
  75. package/dist/components/Rating.svelte.d.ts +8 -18
  76. package/dist/components/Row.svelte +49 -39
  77. package/dist/components/Row.svelte.d.ts +8 -14
  78. package/dist/components/Select.svelte +252 -32
  79. package/dist/components/Select.svelte.d.ts +8 -16
  80. package/dist/components/Skeleton.svelte +9 -3
  81. package/dist/components/Skeleton.svelte.d.ts +8 -12
  82. package/dist/components/Slider.svelte +14 -6
  83. package/dist/components/Slider.svelte.d.ts +8 -18
  84. package/dist/components/SortableList.svelte +136 -130
  85. package/dist/components/SortableList.svelte.d.ts +6 -14
  86. package/dist/components/Spinner.svelte +9 -3
  87. package/dist/components/Spinner.svelte.d.ts +8 -8
  88. package/dist/components/Stepper.svelte +101 -93
  89. package/dist/components/Stepper.svelte.d.ts +8 -10
  90. package/dist/components/Table.svelte +9 -3
  91. package/dist/components/Table.svelte.d.ts +8 -12
  92. package/dist/components/Tabs.svelte +29 -5
  93. package/dist/components/Tabs.svelte.d.ts +8 -10
  94. package/dist/components/TextEditor.svelte +191 -182
  95. package/dist/components/TextEditor.svelte.d.ts +8 -18
  96. package/dist/components/Textarea.svelte +24 -7
  97. package/dist/components/Textarea.svelte.d.ts +8 -24
  98. package/dist/components/Toast.svelte +52 -16
  99. package/dist/components/Toast.svelte.d.ts +8 -12
  100. package/dist/components/Toggle.svelte +10 -4
  101. package/dist/components/Toggle.svelte.d.ts +8 -14
  102. package/dist/components/Tooltip.svelte +14 -4
  103. package/dist/components/Tooltip.svelte.d.ts +8 -12
  104. package/dist/components/charts/BarChart.svelte +7 -5
  105. package/dist/components/charts/BarChart.svelte.d.ts +8 -22
  106. package/dist/components/charts/BubbleChart.svelte +7 -5
  107. package/dist/components/charts/BubbleChart.svelte.d.ts +8 -22
  108. package/dist/components/charts/Chart.svelte +273 -248
  109. package/dist/components/charts/Chart.svelte.d.ts +8 -30
  110. package/dist/components/charts/ComboChart.svelte +7 -5
  111. package/dist/components/charts/ComboChart.svelte.d.ts +8 -22
  112. package/dist/components/charts/DoughnutChart.svelte +7 -5
  113. package/dist/components/charts/DoughnutChart.svelte.d.ts +8 -22
  114. package/dist/components/charts/LineChart.svelte +7 -5
  115. package/dist/components/charts/LineChart.svelte.d.ts +8 -22
  116. package/dist/components/charts/MermaidChart.svelte +106 -0
  117. package/dist/components/charts/MermaidChart.svelte.d.ts +20 -0
  118. package/dist/components/charts/PieChart.svelte +7 -5
  119. package/dist/components/charts/PieChart.svelte.d.ts +8 -22
  120. package/dist/components/charts/PolarAreaChart.svelte +7 -5
  121. package/dist/components/charts/PolarAreaChart.svelte.d.ts +8 -22
  122. package/dist/components/charts/RadarChart.svelte +7 -5
  123. package/dist/components/charts/RadarChart.svelte.d.ts +8 -22
  124. package/dist/components/charts/ScatterChart.svelte +7 -5
  125. package/dist/components/charts/ScatterChart.svelte.d.ts +8 -22
  126. package/dist/components/charts/StackedBarChart.svelte +20 -18
  127. package/dist/components/charts/StackedBarChart.svelte.d.ts +8 -22
  128. package/dist/components/charts/StackedLineChart.svelte +23 -21
  129. package/dist/components/charts/StackedLineChart.svelte.d.ts +8 -22
  130. package/dist/components/charts/chart-config.d.ts +5 -5
  131. package/dist/components/charts/chart-config.js +722 -733
  132. package/dist/components/charts/index.d.ts +12 -0
  133. package/dist/components/charts/index.js +12 -0
  134. package/dist/components/charts/mermaid-chart-styles.css +27 -0
  135. package/dist/components/checkbox-styles.css +122 -117
  136. package/dist/components/crudview-styles.css +1057 -0
  137. package/dist/components/fileupload-styles.css +121 -117
  138. package/dist/components/filterbar-styles.css +655 -0
  139. package/dist/components/graph/FlowNode.svelte +82 -79
  140. package/dist/components/graph/FlowNode.svelte.d.ts +8 -28
  141. package/dist/components/graph/GraphNode.svelte +72 -69
  142. package/dist/components/graph/GraphNode.svelte.d.ts +8 -22
  143. package/dist/components/prism-manual.d.ts +0 -0
  144. package/dist/components/prism-manual.js +4 -0
  145. package/dist/components/radio-styles.css +118 -113
  146. package/dist/components/rating-styles.css +70 -65
  147. package/dist/components/select-styles.css +239 -11
  148. package/dist/components/slider-styles.css +85 -81
  149. package/dist/components/text-editor-core/dom-utils.d.ts +1 -1
  150. package/dist/components/text-editor-core/editor-core.d.ts +9 -9
  151. package/dist/components/text-editor-core/editor-core.js +854 -808
  152. package/dist/components/text-editor-core/sanitizer.d.ts +4 -1
  153. package/dist/components/text-editor-core/sanitizer.js +236 -161
  154. package/dist/components/text-editor-core/selection-engine.d.ts +3 -3
  155. package/dist/components/theme.css +59 -49
  156. package/dist/components/toast-styles.css +8 -8
  157. package/dist/components/toggle-styles.css +126 -121
  158. package/dist/config.d.ts +1 -1
  159. package/dist/config.js +1 -1
  160. package/dist/config.svelte.d.ts +5 -4
  161. package/dist/config.svelte.js +124 -81
  162. package/dist/graph/geometry.d.ts +1 -1
  163. package/dist/graph/node-types.d.ts +1 -1
  164. package/dist/index.d.ts +4 -11
  165. package/dist/index.js +9 -12
  166. package/dist/themes/generator.js +175 -173
  167. package/dist/themes/presets.d.ts +21 -21
  168. package/dist/themes/presets.js +6 -6
  169. package/dist/utils/dbmr.d.ts +27 -0
  170. package/dist/utils/dbmr.js +381 -0
  171. package/dist/utils/filter.d.ts +103 -0
  172. package/dist/utils/filter.js +621 -0
  173. package/package.json +114 -85
  174. package/dist/components/multiselect-styles.css +0 -364
@@ -0,0 +1,17 @@
1
+ export default CrudView;
2
+ type CrudView = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const CrudView: import("svelte").Component<{
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
10
+ class?: string;
11
+ }, {}, "mode" | "items" | "data" | "search" | "selected" | "conjunction" | "filters" | "views" | "activeView" | "perPage" | "currentPage" | "sortKey" | "sortDirection" | "activeItem" | "breadcrumbs" | "activeTab">;
12
+ type $$ComponentProps = {
13
+ style?: string;
14
+ theme?: string;
15
+ class?: string;
16
+ [key: string]: any;
17
+ };
@@ -1,12 +1,16 @@
1
1
  <script>
2
2
  import "./datepicker-styles.css";
3
- import { defaults, iconClass } from "../config.js";
3
+ import { getMultistyleDefaults, iconClass } from "../config.js";
4
4
  import { portal } from "../actions/portal.js";
5
+ import { dialog } from "../actions/dialog.js";
5
6
  import { cn } from "../utils/cn.js";
6
7
  import dayjs from "dayjs";
7
8
  import customParseFormat from "dayjs/plugin/customParseFormat";
8
9
  dayjs.extend(customParseFormat);
9
10
 
11
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
12
+
13
+
10
14
  let {
11
15
  style: styleProp,
12
16
  theme: themeProp,
@@ -23,11 +27,14 @@
23
27
  ...rest
24
28
  } = $props();
25
29
 
26
- const style = $derived(styleProp ?? defaults.style);
27
- const theme = $derived(themeProp ?? defaults.theme);
30
+ const _cfg = getMultistyleDefaults();
31
+
32
+
33
+ const style = $derived(styleProp ?? _cfg.style);
34
+ const theme = $derived(themeProp ?? _cfg.theme);
28
35
  const styleClass = $derived(`s-datepicker-${style}`);
29
36
  const themeClass = $derived(`theme-${theme}`);
30
- const uid = Math.random().toString(36).slice(2, 9);
37
+ const uid = $props.id();
31
38
  const internalId = `dp-${uid}`;
32
39
  const dispFormat = $derived(displayFormat ?? format);
33
40
 
@@ -37,6 +44,16 @@
37
44
  let viewDate = $state(new Date());
38
45
  let selectedDate = $state(null);
39
46
  let isMobile = $state(false);
47
+ let skipNextFocus = false;
48
+ function closePicker() {
49
+ skipNextFocus = true;
50
+ open = false;
51
+ if (typeof requestAnimationFrame !== "undefined") {
52
+ requestAnimationFrame(() => { skipNextFocus = false; });
53
+ } else {
54
+ skipNextFocus = false;
55
+ }
56
+ }
40
57
 
41
58
  // Format helpers — uses dayjs for full format support (MMM, MMMM, etc.)
42
59
  function toDayjsFmt(f) {
@@ -48,14 +65,28 @@
48
65
  }
49
66
 
50
67
  function parseDate(str, f) {
51
- const d = dayjs(str, toDayjsFmt(f));
52
- return d.isValid() ? d.toDate() : null;
68
+ if (!str) return null;
69
+ const d = dayjs(str, toDayjsFmt(f), true);
70
+ if (d.isValid()) return d.toDate();
71
+ const loose = dayjs(str, toDayjsFmt(f));
72
+ return loose.isValid() ? loose.toDate() : null;
53
73
  }
54
74
 
75
+ // Sync internal selectedDate / viewDate when parent updates or clears `value`
76
+ $effect(() => {
77
+ const parsed = value ? parseDate(value, format) : null;
78
+ selectedDate = parsed;
79
+ if (parsed) {
80
+ viewDate = new Date(parsed);
81
+ }
82
+ });
83
+
55
84
  // Derived
56
- const displayValue = $derived(
57
- value ? fmt(parseDate(value, format) || new Date(), dispFormat) : "",
58
- );
85
+ const displayValue = $derived.by(() => {
86
+ if (!value) return "";
87
+ const parsed = parseDate(value, format);
88
+ return parsed ? fmt(parsed, dispFormat) : "";
89
+ });
59
90
  const inputPlaceholder = $derived(placeholder || dispFormat.toLowerCase());
60
91
 
61
92
  // Floating-label support — mirrors Input.svelte. Material / Material 3 float
@@ -312,7 +343,7 @@
312
343
  placeholder={useFloatingLabel ? "" : inputPlaceholder}
313
344
  {disabled}
314
345
  onfocus={() => {
315
- if (!disabled) open = true;
346
+ if (!disabled && !skipNextFocus) open = true;
316
347
  }}
317
348
  onclick={() => {
318
349
  if (!disabled) open = true;
@@ -332,6 +363,7 @@
332
363
  class:s-datepicker-mobile={isMobile}
333
364
  bind:this={overlayEl}
334
365
  use:portal
366
+ use:dialog={{ onclose: closePicker, lockScroll: isMobile }}
335
367
  role="dialog"
336
368
  aria-modal="true"
337
369
  aria-label="Date picker"
@@ -4,30 +4,14 @@ type DatePicker = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const DatePicker: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- value?: string;
10
- format?: string;
11
- displayFormat?: any;
12
- label?: string;
13
- placeholder?: string;
14
- disabled?: boolean;
15
- min?: any;
16
- max?: any;
17
- locale?: string;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
18
10
  class?: string;
19
- } & Record<string, any>, {}, "value">;
11
+ }, {}, "value">;
20
12
  type $$ComponentProps = {
21
- style: any;
22
- theme: any;
23
- value?: string;
24
- format?: string;
25
- displayFormat?: any;
26
- label?: string;
27
- placeholder?: string;
28
- disabled?: boolean;
29
- min?: any;
30
- max?: any;
31
- locale?: string;
13
+ style?: string;
14
+ theme?: string;
32
15
  class?: string;
33
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };
@@ -1,8 +1,11 @@
1
1
  <script>
2
2
  import "./divider-styles.css";
3
- import { defaults } from "../config.js";
3
+ import { getMultistyleDefaults } from "../config.js";
4
4
  import { cn } from "../utils/cn.js";
5
5
 
6
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
7
+
8
+
6
9
  let {
7
10
  style: styleProp,
8
11
  theme: themeProp,
@@ -12,8 +15,11 @@
12
15
  ...rest
13
16
  } = $props();
14
17
 
15
- const style = $derived(styleProp ?? defaults.style);
16
- const theme = $derived(themeProp ?? defaults.theme);
18
+ const _cfg = getMultistyleDefaults();
19
+
20
+
21
+ const style = $derived(styleProp ?? _cfg.style);
22
+ const theme = $derived(themeProp ?? _cfg.theme);
17
23
 
18
24
  const styleClass = $derived(`s-divider-${style}`);
19
25
  const themeClass = $derived(`theme-${theme}`);
@@ -4,16 +4,14 @@ type Divider = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const Divider: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- orientation?: string;
10
- label?: string;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
11
10
  class?: string;
12
- } & Record<string, any>, {}, "">;
11
+ }, {}, "">;
13
12
  type $$ComponentProps = {
14
- style: any;
15
- theme: any;
16
- orientation?: string;
17
- label?: string;
13
+ style?: string;
14
+ theme?: string;
18
15
  class?: string;
19
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };
@@ -1,23 +1,32 @@
1
1
  <script>
2
2
  import "./drawer-styles.css";
3
- import { defaults } from "../config.js";
3
+ import { getMultistyleDefaults } from "../config.js";
4
4
  import { fade } from "svelte/transition";
5
5
  import { portal } from "../actions/portal.js";
6
+ import { dialog } from "../actions/dialog.js";
6
7
  import { cn } from "../utils/cn.js";
7
8
 
9
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
10
+
11
+
8
12
  let {
9
13
  style: styleProp,
10
14
  theme: themeProp,
11
15
  position = "left",
12
16
  open = $bindable(false),
17
+ title = "",
18
+ showClose = true,
13
19
  children,
14
20
  onclose,
15
21
  class: className = "",
16
22
  ...rest
17
23
  } = $props();
18
24
 
19
- const style = $derived(styleProp ?? defaults.style);
20
- const theme = $derived(themeProp ?? defaults.theme);
25
+ const _cfg = getMultistyleDefaults();
26
+
27
+
28
+ const style = $derived(styleProp ?? _cfg.style);
29
+ const theme = $derived(themeProp ?? _cfg.theme);
21
30
  const styleClass = $derived(`s-drawer-${style}`);
22
31
  const themeClass = $derived(`theme-${theme}`);
23
32
 
@@ -53,6 +62,7 @@
53
62
  {#if open}
54
63
  <div
55
64
  use:portal
65
+ use:dialog={{ onclose: handleClose }}
56
66
  class={cn("s-drawer-overlay", className)}
57
67
  transition:fade={{ duration: 200 }}
58
68
  onclick={handleBackdrop}
@@ -65,6 +75,12 @@
65
75
  role="dialog"
66
76
  aria-modal="true"
67
77
  >
78
+ {#if title || showClose}
79
+ <div class="s-drawer-header" style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;">
80
+ {#if title}<h3 class="s-drawer-title" style="margin:0;font-size:16px;font-weight:600;">{title}</h3>{:else}<span></span>{/if}
81
+ {#if showClose}<button type="button" class="s-drawer-close" onclick={handleClose} aria-label="Close" style="background:none;border:none;font-size:20px;line-height:1;cursor:pointer;color:inherit;">&times;</button>{/if}
82
+ </div>
83
+ {/if}
68
84
  {@render children?.()}
69
85
  </div>
70
86
  </div>
@@ -4,20 +4,14 @@ type Drawer = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const Drawer: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- position?: string;
10
- open?: boolean;
11
- children: any;
12
- onclose: any;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
13
10
  class?: string;
14
- } & Record<string, any>, {}, "open">;
11
+ }, {}, "open">;
15
12
  type $$ComponentProps = {
16
- style: any;
17
- theme: any;
18
- position?: string;
19
- open?: boolean;
20
- children: any;
21
- onclose: any;
13
+ style?: string;
14
+ theme?: string;
22
15
  class?: string;
23
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };
@@ -1,9 +1,12 @@
1
1
  <script>
2
2
  import "./dropdown-styles.css";
3
- import { defaults } from "../config.js";
3
+ import { getMultistyleDefaults } from "../config.js";
4
4
  import { fly } from "svelte/transition";
5
5
  import { cn } from "../utils/cn.js";
6
6
 
7
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
8
+
9
+
7
10
  let {
8
11
  style: styleProp,
9
12
  theme: themeProp,
@@ -17,8 +20,11 @@
17
20
  ...rest
18
21
  } = $props();
19
22
 
20
- const style = $derived(styleProp ?? defaults.style);
21
- const theme = $derived(themeProp ?? defaults.theme);
23
+ const _cfg = getMultistyleDefaults();
24
+
25
+
26
+ const style = $derived(styleProp ?? _cfg.style);
27
+ const theme = $derived(themeProp ?? _cfg.theme);
22
28
  const styleClass = $derived(`s-dropdown-${style}`);
23
29
  const themeClass = $derived(`theme-${theme}`);
24
30
  const variantClass = $derived(`dropdown-${color}`);
@@ -40,6 +46,26 @@
40
46
  close();
41
47
  }
42
48
 
49
+ function handleMenuKeydown(e) {
50
+ if (!menuEl) return;
51
+ const btns = Array.from(menuEl.querySelectorAll('[role="menuitem"]:not([disabled])'));
52
+ if (btns.length === 0) return;
53
+ const idx = btns.indexOf(document.activeElement);
54
+ if (e.key === "ArrowDown") {
55
+ e.preventDefault();
56
+ btns[(idx + 1) % btns.length].focus();
57
+ } else if (e.key === "ArrowUp") {
58
+ e.preventDefault();
59
+ btns[(idx - 1 + btns.length) % btns.length].focus();
60
+ } else if (e.key === "Home") {
61
+ e.preventDefault();
62
+ btns[0].focus();
63
+ } else if (e.key === "End") {
64
+ e.preventDefault();
65
+ btns[btns.length - 1].focus();
66
+ }
67
+ }
68
+
43
69
  // Click outside to close
44
70
  $effect(() => {
45
71
  if (!open) return;
@@ -73,7 +99,7 @@
73
99
  role="button"
74
100
  tabindex="0"
75
101
  aria-expanded={open}
76
- onkeydown={(e) => { if (e.key === "Enter" || e.key === " ") toggle(); }}
102
+ onkeydown={(e) => { if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") { e.preventDefault(); open = true; requestAnimationFrame(() => menuEl?.querySelector('[role="menuitem"]:not([disabled])')?.focus()); } }}
77
103
  >
78
104
  {@render children?.()}
79
105
  </div>
@@ -88,12 +114,13 @@
88
114
  opacity: 0
89
115
  }}
90
116
  role="menu"
117
+ onkeydown={handleMenuKeydown}
91
118
  >
92
119
  {#each items as item}
93
120
  {#if item.divider}
94
121
  <div class="s-dropdown-divider"></div>
95
122
  {:else}
96
- <button
123
+ <button type="button"
97
124
  class="s-dropdown-item"
98
125
  class:active={item.active}
99
126
  disabled={item.disabled}
@@ -4,24 +4,14 @@ type DropdownMenu = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const DropdownMenu: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- variant?: string;
10
- color?: string;
11
- children: any;
12
- items?: any[];
13
- position?: string;
14
- align?: string;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
15
10
  class?: string;
16
- } & Record<string, any>, {}, "">;
11
+ }, {}, "">;
17
12
  type $$ComponentProps = {
18
- style: any;
19
- theme: any;
20
- variant?: string;
21
- color?: string;
22
- children: any;
23
- items?: any[];
24
- position?: string;
25
- align?: string;
13
+ style?: string;
14
+ theme?: string;
26
15
  class?: string;
27
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };
@@ -1,8 +1,11 @@
1
1
  <script>
2
2
  import "./fab-styles.css";
3
- import { defaults } from "../config.js";
3
+ import { getMultistyleDefaults } from "../config.js";
4
4
  import { cn } from "../utils/cn.js";
5
5
 
6
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
7
+
8
+
6
9
  let {
7
10
  style: styleProp,
8
11
  theme: themeProp,
@@ -14,15 +17,18 @@
14
17
  ...rest
15
18
  } = $props();
16
19
 
17
- const style = $derived(styleProp ?? defaults.style);
18
- const theme = $derived(themeProp ?? defaults.theme);
20
+ const _cfg = getMultistyleDefaults();
21
+
22
+
23
+ const style = $derived(styleProp ?? _cfg.style);
24
+ const theme = $derived(themeProp ?? _cfg.theme);
19
25
 
20
26
  const styleClass = $derived(`s-fab-${style}`);
21
27
  const themeClass = $derived(`theme-${theme}`);
22
28
  const presetClass = $derived(`fab-${preset}`);
23
29
  </script>
24
30
 
25
- <button
31
+ <button type="button"
26
32
  class={cn("s-fab", styleClass, themeClass, presetClass, `fab-${position}`, className)}
27
33
  {onclick}
28
34
  {...rest}
@@ -4,20 +4,14 @@ type FAB = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const FAB: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- preset?: string;
10
- children: any;
11
- position?: string;
12
- onclick: any;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
13
10
  class?: string;
14
- } & Record<string, any>, {}, "">;
11
+ }, {}, "">;
15
12
  type $$ComponentProps = {
16
- style: any;
17
- theme: any;
18
- preset?: string;
19
- children: any;
20
- position?: string;
21
- onclick: any;
13
+ style?: string;
14
+ theme?: string;
22
15
  class?: string;
23
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };
@@ -1,36 +1,74 @@
1
1
  <script>
2
2
  import "./fileupload-styles.css";
3
- import { defaults } from "../config.js";
3
+ import { getMultistyleDefaults } from "../config.js";
4
4
  import { cn } from "../utils/cn.js";
5
5
 
6
+ /** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
7
+
8
+
6
9
  let {
7
10
  style: styleProp,
8
11
  theme: themeProp,
12
+ files = $bindable([]),
9
13
  accept = "",
10
14
  multiple = false,
11
15
  disabled = false,
12
16
  label = "Drop files or click to upload",
17
+ onfiles,
18
+ onchange,
13
19
  class: className = "",
14
20
  ...rest
15
21
  } = $props();
16
22
 
17
- const style = $derived(styleProp ?? defaults.style);
18
- const theme = $derived(themeProp ?? defaults.theme);
23
+ const _cfg = getMultistyleDefaults();
24
+
25
+
26
+ const style = $derived(styleProp ?? _cfg.style);
27
+ const theme = $derived(themeProp ?? _cfg.theme);
19
28
 
20
29
  const styleClass = $derived(`s-fileupload-${style}`);
21
30
  const themeClass = $derived(`theme-${theme}`);
22
31
 
23
- let files = $state([]);
24
32
  let dragging = $state(false);
33
+ let inputEl = $state(null);
34
+
35
+ $effect(() => {
36
+ if (inputEl && (!files || files.length === 0)) {
37
+ inputEl.value = "";
38
+ }
39
+ });
40
+
41
+ function matchesAccept(file) {
42
+ if (!accept) return true;
43
+ const tokens = accept.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
44
+ if (tokens.length === 0) return true;
45
+ const name = (file.name || "").toLowerCase();
46
+ const mime = (file.type || "").toLowerCase();
47
+ return tokens.some((t) => {
48
+ if (t.startsWith(".")) return name.endsWith(t);
49
+ if (t.endsWith("/*")) return mime.startsWith(t.slice(0, -1));
50
+ return mime === t;
51
+ });
52
+ }
53
+
54
+ function applyFiles(rawList) {
55
+ if (disabled) return;
56
+ let next = Array.from(rawList || []).filter(matchesAccept);
57
+ if (!multiple && next.length > 1) next = [next[0]];
58
+ files = next;
59
+ onfiles?.(files);
60
+ onchange?.(files);
61
+ }
25
62
 
26
63
  function handleChange(e) {
27
- files = Array.from(e.target.files);
64
+ applyFiles(e.target.files);
28
65
  }
29
66
 
30
67
  function handleDrop(e) {
31
68
  e.preventDefault();
32
69
  dragging = false;
33
- files = Array.from(e.dataTransfer.files);
70
+ if (disabled) return;
71
+ applyFiles(e.dataTransfer?.files);
34
72
  }
35
73
  </script>
36
74
 
@@ -40,13 +78,14 @@
40
78
  class:disabled
41
79
  ondragover={(e) => {
42
80
  e.preventDefault();
43
- dragging = true;
81
+ if (!disabled) dragging = true;
44
82
  }}
45
83
  ondragleave={() => (dragging = false)}
46
84
  ondrop={handleDrop}
47
85
  {...rest}
48
86
  >
49
87
  <input
88
+ bind:this={inputEl}
50
89
  type="file"
51
90
  {accept}
52
91
  {multiple}
@@ -61,7 +100,7 @@
61
100
  height="32"
62
101
  viewBox="0 0 24 24"
63
102
  fill="none"
64
- stroke="#64748b"
103
+ stroke="currentColor"
65
104
  stroke-width="2"
66
105
  >
67
106
  <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline
@@ -4,20 +4,14 @@ type FileUpload = {
4
4
  $set?(props: Partial<$$ComponentProps>): void;
5
5
  };
6
6
  declare const FileUpload: import("svelte").Component<{
7
- style: any;
8
- theme: any;
9
- accept?: string;
10
- multiple?: boolean;
11
- disabled?: boolean;
12
- label?: string;
7
+ [key: string]: any;
8
+ style?: string;
9
+ theme?: string;
13
10
  class?: string;
14
- } & Record<string, any>, {}, "">;
11
+ }, {}, "files">;
15
12
  type $$ComponentProps = {
16
- style: any;
17
- theme: any;
18
- accept?: string;
19
- multiple?: boolean;
20
- disabled?: boolean;
21
- label?: string;
13
+ style?: string;
14
+ theme?: string;
22
15
  class?: string;
23
- } & Record<string, any>;
16
+ [key: string]: any;
17
+ };