kosui 0.1.2 → 0.4.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 (238) hide show
  1. package/README.md +34 -3
  2. package/dist/alert/alert.svelte +16 -157
  3. package/dist/alert/alert.svelte.d.ts +3 -26
  4. package/dist/alert/index.d.ts +1 -1
  5. package/dist/alert/index.js +1 -1
  6. package/dist/autocomplete/autocomplete.svelte +126 -12
  7. package/dist/autocomplete/autocomplete.svelte.d.ts +30 -6
  8. package/dist/autocomplete/index.d.ts +1 -5
  9. package/dist/autocomplete/index.js +1 -5
  10. package/dist/avatar/avatar.svelte +16 -10
  11. package/dist/badge/badge.svelte +31 -20
  12. package/dist/badge/badge.svelte.d.ts +8 -4
  13. package/dist/badge/index.d.ts +1 -1
  14. package/dist/base.d.ts +4 -8
  15. package/dist/base.js +14 -28
  16. package/dist/box/box.svelte +2 -14
  17. package/dist/box/box.svelte.d.ts +0 -2
  18. package/dist/breadcrumbs/breadcrumbs.svelte +38 -19
  19. package/dist/breadcrumbs/breadcrumbs.svelte.d.ts +6 -4
  20. package/dist/breadcrumbs/index.d.ts +1 -1
  21. package/dist/breadcrumbs/index.js +1 -1
  22. package/dist/button/button.svelte +96 -31
  23. package/dist/button/button.svelte.d.ts +11 -5
  24. package/dist/button/index.d.ts +1 -1
  25. package/dist/button/index.js +1 -1
  26. package/dist/chip/chip.svelte +62 -14
  27. package/dist/chip/chip.svelte.d.ts +2 -1
  28. package/dist/command/action.svelte.js +13 -18
  29. package/dist/command/command-palette.svelte +163 -0
  30. package/dist/command/command-palette.svelte.d.ts +11 -0
  31. package/dist/command/index.d.ts +1 -8
  32. package/dist/command/index.js +1 -8
  33. package/dist/common/divider.svelte +10 -5
  34. package/dist/common/divider.svelte.d.ts +3 -3
  35. package/dist/common/index.d.ts +0 -2
  36. package/dist/common/index.js +0 -2
  37. package/dist/dialog/dialog-provider.svelte +70 -0
  38. package/dist/dialog/dialog-provider.svelte.d.ts +7 -0
  39. package/dist/dialog/dialog.svelte +33 -35
  40. package/dist/dialog/dialog.svelte.d.ts +4 -8
  41. package/dist/dialog/dialogs.svelte.d.ts +49 -0
  42. package/dist/dialog/dialogs.svelte.js +73 -0
  43. package/dist/dialog/index.d.ts +2 -3
  44. package/dist/dialog/index.js +2 -3
  45. package/dist/fab/fab.svelte +30 -10
  46. package/dist/fab/fab.svelte.d.ts +3 -2
  47. package/dist/index.d.ts +0 -1
  48. package/dist/index.js +0 -1
  49. package/dist/input/field.d.ts +8 -0
  50. package/dist/input/field.js +7 -0
  51. package/dist/input/index.d.ts +2 -1
  52. package/dist/input/index.js +2 -1
  53. package/dist/input/input.svelte +21 -66
  54. package/dist/input/input.svelte.d.ts +6 -16
  55. package/dist/link/link.svelte +33 -42
  56. package/dist/link/link.svelte.d.ts +4 -3
  57. package/dist/markdown/index.d.ts +2 -25
  58. package/dist/markdown/index.js +0 -24
  59. package/dist/markdown/markdown-tokens.svelte +166 -6
  60. package/dist/markdown/markdown-tokens.svelte.d.ts +2 -0
  61. package/dist/markdown/markdown.svelte +62 -173
  62. package/dist/markdown/markdown.svelte.d.ts +7 -27
  63. package/dist/markdown/parse.d.ts +5 -0
  64. package/dist/markdown/parse.js +30 -0
  65. package/dist/markdown/types.d.ts +28 -0
  66. package/dist/markdown/types.js +1 -0
  67. package/dist/menu/index.d.ts +3 -6
  68. package/dist/menu/index.js +3 -6
  69. package/dist/menu/menu-actions.svelte +44 -38
  70. package/dist/menu/menu-context.d.ts +4 -0
  71. package/dist/menu/menu-context.js +2 -0
  72. package/dist/menu/menu-group.svelte +40 -0
  73. package/dist/menu/menu-group.svelte.d.ts +11 -0
  74. package/dist/menu/menu-item.svelte +31 -54
  75. package/dist/menu/menu-item.svelte.d.ts +7 -5
  76. package/dist/menu/menu.svelte +160 -15
  77. package/dist/menu/menu.svelte.d.ts +15 -4
  78. package/dist/merge-props.d.ts +1 -1
  79. package/dist/merge-props.js +10 -5
  80. package/dist/modal/modal.svelte +60 -83
  81. package/dist/modal/modal.svelte.d.ts +5 -4
  82. package/dist/popover/index.d.ts +1 -1
  83. package/dist/popover/index.js +1 -1
  84. package/dist/popover/popover.svelte +58 -111
  85. package/dist/popover/popover.svelte.d.ts +6 -8
  86. package/dist/progress/circular-progress.svelte +64 -30
  87. package/dist/progress/circular-progress.svelte.d.ts +7 -8
  88. package/dist/shortcut/index.d.ts +2 -2
  89. package/dist/shortcut/index.js +1 -1
  90. package/dist/shortcut/shortcut-hint.svelte +36 -0
  91. package/dist/shortcut/shortcut-hint.svelte.d.ts +9 -0
  92. package/dist/shortcut/shortcut.d.ts +19 -14
  93. package/dist/shortcut/shortcut.js +105 -52
  94. package/dist/skeleton/skeleton.svelte +13 -8
  95. package/dist/skeleton/skeleton.svelte.d.ts +2 -5
  96. package/dist/slider/index.d.ts +1 -8
  97. package/dist/slider/index.js +1 -8
  98. package/dist/slider/slider.svelte +180 -211
  99. package/dist/slider/slider.svelte.d.ts +11 -32
  100. package/dist/switch/index.d.ts +1 -2
  101. package/dist/switch/index.js +1 -2
  102. package/dist/switch/switch.svelte +36 -60
  103. package/dist/switch/switch.svelte.d.ts +6 -17
  104. package/dist/textarea/index.d.ts +1 -1
  105. package/dist/textarea/index.js +1 -1
  106. package/dist/textarea/textarea.svelte +23 -63
  107. package/dist/textarea/textarea.svelte.d.ts +8 -18
  108. package/dist/theme.css +191 -0
  109. package/dist/toggle/index.d.ts +0 -1
  110. package/dist/toggle/index.js +0 -1
  111. package/dist/toggle/toggle-button.svelte +72 -38
  112. package/dist/toggle/toggle-button.svelte.d.ts +4 -4
  113. package/dist/toggle/toggle-context.d.ts +10 -0
  114. package/dist/toggle/toggle-context.js +2 -0
  115. package/dist/toggle/toggle-group.svelte +41 -22
  116. package/dist/toggle/toggle-group.svelte.d.ts +7 -4
  117. package/dist/tooltip/tooltip.svelte +67 -26
  118. package/dist/tooltip/tooltip.svelte.d.ts +10 -4
  119. package/dist/utils.d.ts +9 -3
  120. package/dist/utils.js +10 -0
  121. package/package.json +21 -13
  122. package/dist/autocomplete/autocomplete-content.svelte +0 -47
  123. package/dist/autocomplete/autocomplete-content.svelte.d.ts +0 -10
  124. package/dist/autocomplete/autocomplete-context.svelte.d.ts +0 -12
  125. package/dist/autocomplete/autocomplete-context.svelte.js +0 -34
  126. package/dist/autocomplete/autocomplete-input.svelte +0 -36
  127. package/dist/autocomplete/autocomplete-input.svelte.d.ts +0 -5
  128. package/dist/autocomplete/autocomplete-item.svelte +0 -68
  129. package/dist/autocomplete/autocomplete-item.svelte.d.ts +0 -11
  130. package/dist/base.css +0 -71
  131. package/dist/bindable.svelte.d.ts +0 -7
  132. package/dist/bindable.svelte.js +0 -25
  133. package/dist/command/command-content.svelte +0 -15
  134. package/dist/command/command-content.svelte.d.ts +0 -8
  135. package/dist/command/command-context.svelte.d.ts +0 -5
  136. package/dist/command/command-context.svelte.js +0 -13
  137. package/dist/command/command-input.svelte +0 -44
  138. package/dist/command/command-input.svelte.d.ts +0 -7
  139. package/dist/command/command-item.svelte +0 -66
  140. package/dist/command/command-item.svelte.d.ts +0 -11
  141. package/dist/command/command-search.svelte +0 -28
  142. package/dist/command/command-search.svelte.d.ts +0 -5
  143. package/dist/command/command.svelte +0 -19
  144. package/dist/command/command.svelte.d.ts +0 -8
  145. package/dist/command/commander.svelte +0 -107
  146. package/dist/command/commander.svelte.d.ts +0 -9
  147. package/dist/common/header.svelte +0 -35
  148. package/dist/common/header.svelte.d.ts +0 -10
  149. package/dist/common/item-context.svelte.d.ts +0 -12
  150. package/dist/common/item-context.svelte.js +0 -77
  151. package/dist/dialog/dialog-button.svelte +0 -25
  152. package/dist/dialog/dialog-button.svelte.d.ts +0 -32
  153. package/dist/dialog/dialoguer-context.svelte.d.ts +0 -53
  154. package/dist/dialog/dialoguer-context.svelte.js +0 -85
  155. package/dist/dialog/dialoguer.svelte +0 -65
  156. package/dist/dialog/dialoguer.svelte.d.ts +0 -7
  157. package/dist/markdown/markdown-blockquote.svelte +0 -14
  158. package/dist/markdown/markdown-blockquote.svelte.d.ts +0 -7
  159. package/dist/markdown/markdown-br.svelte +0 -12
  160. package/dist/markdown/markdown-br.svelte.d.ts +0 -7
  161. package/dist/markdown/markdown-code.svelte +0 -14
  162. package/dist/markdown/markdown-code.svelte.d.ts +0 -7
  163. package/dist/markdown/markdown-codespan.svelte +0 -15
  164. package/dist/markdown/markdown-codespan.svelte.d.ts +0 -7
  165. package/dist/markdown/markdown-context.svelte.d.ts +0 -26
  166. package/dist/markdown/markdown-context.svelte.js +0 -30
  167. package/dist/markdown/markdown-def.svelte +0 -15
  168. package/dist/markdown/markdown-def.svelte.d.ts +0 -7
  169. package/dist/markdown/markdown-del.svelte +0 -14
  170. package/dist/markdown/markdown-del.svelte.d.ts +0 -7
  171. package/dist/markdown/markdown-em.svelte +0 -14
  172. package/dist/markdown/markdown-em.svelte.d.ts +0 -7
  173. package/dist/markdown/markdown-escape.svelte +0 -8
  174. package/dist/markdown/markdown-escape.svelte.d.ts +0 -5
  175. package/dist/markdown/markdown-heading.svelte +0 -16
  176. package/dist/markdown/markdown-heading.svelte.d.ts +0 -7
  177. package/dist/markdown/markdown-hr.svelte +0 -12
  178. package/dist/markdown/markdown-hr.svelte.d.ts +0 -7
  179. package/dist/markdown/markdown-html.svelte +0 -9
  180. package/dist/markdown/markdown-html.svelte.d.ts +0 -5
  181. package/dist/markdown/markdown-image.svelte +0 -12
  182. package/dist/markdown/markdown-image.svelte.d.ts +0 -7
  183. package/dist/markdown/markdown-link.svelte +0 -17
  184. package/dist/markdown/markdown-link.svelte.d.ts +0 -7
  185. package/dist/markdown/markdown-list-item.svelte +0 -14
  186. package/dist/markdown/markdown-list-item.svelte.d.ts +0 -7
  187. package/dist/markdown/markdown-list.svelte +0 -19
  188. package/dist/markdown/markdown-list.svelte.d.ts +0 -7
  189. package/dist/markdown/markdown-paragraph.svelte +0 -16
  190. package/dist/markdown/markdown-paragraph.svelte.d.ts +0 -7
  191. package/dist/markdown/markdown-space.svelte +0 -8
  192. package/dist/markdown/markdown-space.svelte.d.ts +0 -5
  193. package/dist/markdown/markdown-strong.svelte +0 -15
  194. package/dist/markdown/markdown-strong.svelte.d.ts +0 -7
  195. package/dist/markdown/markdown-table-cell.svelte +0 -16
  196. package/dist/markdown/markdown-table-cell.svelte.d.ts +0 -7
  197. package/dist/markdown/markdown-table.svelte +0 -36
  198. package/dist/markdown/markdown-table.svelte.d.ts +0 -7
  199. package/dist/markdown/markdown-text.svelte +0 -8
  200. package/dist/markdown/markdown-text.svelte.d.ts +0 -5
  201. package/dist/markdown/markdown-token.svelte +0 -25
  202. package/dist/markdown/markdown-token.svelte.d.ts +0 -7
  203. package/dist/menu/menu-content.svelte +0 -47
  204. package/dist/menu/menu-content.svelte.d.ts +0 -10
  205. package/dist/menu/menu-context.svelte.d.ts +0 -18
  206. package/dist/menu/menu-context.svelte.js +0 -118
  207. package/dist/menu/menu-trigger-button.svelte +0 -31
  208. package/dist/menu/menu-trigger-button.svelte.d.ts +0 -5
  209. package/dist/menu/menu-trigger.svelte +0 -42
  210. package/dist/menu/menu-trigger.svelte.d.ts +0 -10
  211. package/dist/ordered-html-elements.d.ts +0 -7
  212. package/dist/ordered-html-elements.js +0 -29
  213. package/dist/portal/index.d.ts +0 -2
  214. package/dist/portal/index.js +0 -2
  215. package/dist/portal/portal.svelte +0 -15
  216. package/dist/portal/portal.svelte.d.ts +0 -8
  217. package/dist/portal/proxy.svelte +0 -13
  218. package/dist/portal/proxy.svelte.d.ts +0 -7
  219. package/dist/shortcut/shortcut-badge.svelte +0 -41
  220. package/dist/shortcut/shortcut-badge.svelte.d.ts +0 -11
  221. package/dist/slider/slider-context.svelte.d.ts +0 -50
  222. package/dist/slider/slider-context.svelte.js +0 -198
  223. package/dist/slider/slider-handle-label-arrow.svelte +0 -18
  224. package/dist/slider/slider-handle-label-arrow.svelte.d.ts +0 -6
  225. package/dist/slider/slider-handle-label.svelte +0 -35
  226. package/dist/slider/slider-handle-label.svelte.d.ts +0 -6
  227. package/dist/slider/slider-handle.svelte +0 -54
  228. package/dist/slider/slider-handle.svelte.d.ts +0 -6
  229. package/dist/slider/slider-mark-dot.svelte +0 -25
  230. package/dist/slider/slider-mark-dot.svelte.d.ts +0 -6
  231. package/dist/slider/slider-mark-label.svelte +0 -37
  232. package/dist/slider/slider-mark-label.svelte.d.ts +0 -9
  233. package/dist/slider/slider-mark.svelte +0 -33
  234. package/dist/slider/slider-mark.svelte.d.ts +0 -9
  235. package/dist/switch/switch-thumb.svelte +0 -52
  236. package/dist/switch/switch-thumb.svelte.d.ts +0 -7
  237. package/dist/toggle/toggle-context.svelte.d.ts +0 -9
  238. package/dist/toggle/toggle-context.svelte.js +0 -32
@@ -1,14 +1,20 @@
1
1
  <script lang="ts" module>
2
+ import { mergeProps } from "../merge-props.js";
2
3
  import { Popover, type PopoverProps } from "../popover/index.js";
3
- import type { ClassName } from "../utils.js";
4
+ import { cn, type ClassName } from "../utils.js";
4
5
  import type { Snippet } from "svelte";
5
- import { twMerge } from "tailwind-merge";
6
+ import { createAttachmentKey, type Attachment } from "svelte/attachments";
6
7
 
7
8
  export type TooltipTriggerProps = {
8
- ref: (el: HTMLElement) => void;
9
+ [attachment: symbol]: Attachment<HTMLElement>;
10
+ "aria-describedby"?: string;
11
+ "aria-expanded"?: boolean;
12
+ "aria-controls"?: string;
9
13
  onclick?: () => void;
10
- onmouseenter?: () => void;
11
- onmouseleave?: () => void;
14
+ onpointerenter?: (event: PointerEvent) => void;
15
+ onpointerleave?: (event: PointerEvent) => void;
16
+ onfocus?: (event: FocusEvent) => void;
17
+ onblur?: () => void;
12
18
  ontouchstart?: () => void;
13
19
  ontouchend?: () => void;
14
20
  };
@@ -21,28 +27,36 @@
21
27
  trigger?: Snippet<[TooltipTriggerProps]>;
22
28
  } & ClassName &
23
29
  PopoverProps;
30
+
31
+ const GRACE = 100;
24
32
  </script>
25
33
 
26
34
  <script lang="ts">
35
+ const generatedId = $props.id();
36
+
27
37
  let {
38
+ id: providedId,
28
39
  delay = 500,
29
40
  open = $bindable(false),
30
41
  click = false,
31
42
  rich = false,
32
- arrow,
33
43
  trigger,
34
44
  anchorEl,
35
45
  class: className,
36
46
  ...restProps
37
47
  }: TooltipProps = $props();
38
48
 
39
- function isTouchDevice() {
40
- return "ontouchstart" in window || navigator.maxTouchPoints > 0;
41
- }
49
+ let id = $derived(providedId ?? generatedId);
50
+
51
+ const anchor = createAttachmentKey();
52
+ const attachAnchor: Attachment<HTMLElement> = (node) => {
53
+ anchorEl = node;
54
+ };
42
55
 
43
56
  let timeout: number;
44
57
 
45
58
  export function show(after?: number) {
59
+ cancel();
46
60
  timeout = window.setTimeout(
47
61
  () => (open = true),
48
62
  after === undefined ? delay : after,
@@ -58,40 +72,67 @@
58
72
  open = false;
59
73
  }
60
74
 
75
+ function hideSoon() {
76
+ cancel();
77
+ timeout = window.setTimeout(() => (open = false), GRACE);
78
+ }
79
+
80
+ const notTouch =
81
+ (handler: () => void) =>
82
+ ({ pointerType }: PointerEvent) => {
83
+ if (pointerType !== "touch") handler();
84
+ };
85
+
61
86
  const triggerProps: TooltipTriggerProps = $derived(
62
87
  click
63
88
  ? {
64
- ref: (ref) => (anchorEl = ref),
65
- onclick: () => (open = true),
89
+ [anchor]: attachAnchor,
90
+ "aria-expanded": open,
91
+ "aria-controls": open ? id : undefined,
92
+ onclick: () => (open = !open),
66
93
  }
67
94
  : {
68
- ref: (ref) => (anchorEl = ref),
69
- onmouseenter: () => !isTouchDevice() && show(),
70
- onmouseleave: () => hide(),
95
+ [anchor]: attachAnchor,
96
+ "aria-describedby": open ? id : undefined,
97
+ onpointerenter: notTouch(() => show()),
98
+ onpointerleave: notTouch(hideSoon),
99
+ onfocus: (event) => {
100
+ if (
101
+ event.target instanceof HTMLElement &&
102
+ event.target.matches(":focus-visible")
103
+ ) {
104
+ cancel();
105
+ open = true;
106
+ }
107
+ },
108
+ onblur: () => hide(),
71
109
  ontouchstart: () => show(delay),
72
110
  ontouchend: () => cancel(),
73
111
  },
74
112
  );
113
+
114
+ const popupProps: Omit<PopoverProps, "children"> = $derived(
115
+ click
116
+ ? {}
117
+ : {
118
+ role: "tooltip",
119
+ onpointerenter: notTouch(cancel),
120
+ onpointerleave: notTouch(hideSoon),
121
+ },
122
+ );
75
123
  </script>
76
124
 
125
+ {@render trigger?.(triggerProps)}
126
+
77
127
  <Popover
78
128
  bind:open
79
- role="tooltip"
129
+ {id}
80
130
  {anchorEl}
81
- {arrow}
82
- class={twMerge(
83
- arrow && "overflow-visible",
131
+ class={cn(
84
132
  rich
85
133
  ? "rounded-md border bg-m3-surface-container p-2 text-sm shadow shadow-m3-shadow/20"
86
134
  : "rounded-sm bg-m3-inverse-surface px-2 py-1 text-xs text-m3-inverse-on-surface",
87
135
  className,
88
136
  )}
89
- arrowClass={twMerge(
90
- rich
91
- ? "bg-m3-surface-container border-r border-b"
92
- : "bg-m3-inverse-surface",
93
- )}
94
- {...restProps}
137
+ {...mergeProps(popupProps, restProps)}
95
138
  />
96
-
97
- {@render trigger?.(triggerProps)}
@@ -1,11 +1,17 @@
1
1
  import { type PopoverProps } from "../popover/index.js";
2
- import type { ClassName } from "../utils.js";
2
+ import { type ClassName } from "../utils.js";
3
3
  import type { Snippet } from "svelte";
4
+ import { type Attachment } from "svelte/attachments";
4
5
  export type TooltipTriggerProps = {
5
- ref: (el: HTMLElement) => void;
6
+ [attachment: symbol]: Attachment<HTMLElement>;
7
+ "aria-describedby"?: string;
8
+ "aria-expanded"?: boolean;
9
+ "aria-controls"?: string;
6
10
  onclick?: () => void;
7
- onmouseenter?: () => void;
8
- onmouseleave?: () => void;
11
+ onpointerenter?: (event: PointerEvent) => void;
12
+ onpointerleave?: (event: PointerEvent) => void;
13
+ onfocus?: (event: FocusEvent) => void;
14
+ onblur?: () => void;
9
15
  ontouchstart?: () => void;
10
16
  ontouchend?: () => void;
11
17
  };
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,18 @@
1
- import type { ClassNameValue } from "tailwind-merge";
1
+ import { type ClassValue as ClassInput } from "clsx";
2
+ import type { ClassValue } from "svelte/elements";
2
3
  export declare function noop(): void;
3
4
  export type ElementRef = {
4
5
  el?: HTMLElement;
5
- ref?: (el: HTMLElement) => void;
6
6
  };
7
7
  export type ClassName = {
8
- class?: ClassNameValue;
8
+ class?: ClassValue;
9
9
  };
10
+ /**
11
+ * Resolves class values the way Svelte's `class` attribute does (strings,
12
+ * arrays and objects), then merges conflicting Tailwind classes so later
13
+ * values win.
14
+ */
15
+ export declare function cn(...values: ClassInput[]): string;
10
16
  export type ToggleEventWithTarget<T extends HTMLElement> = ToggleEvent & {
11
17
  currentTarget: EventTarget & T;
12
18
  };
package/dist/utils.js CHANGED
@@ -1,4 +1,14 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
1
3
  export function noop() { }
4
+ /**
5
+ * Resolves class values the way Svelte's `class` attribute does (strings,
6
+ * arrays and objects), then merges conflicting Tailwind classes so later
7
+ * values win.
8
+ */
9
+ export function cn(...values) {
10
+ return twMerge(clsx(values));
11
+ }
2
12
  export function uid({ prefix = "", separator = "-" } = {}) {
3
13
  const parts = [];
4
14
  if (prefix) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kosui",
3
- "version": "0.1.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,36 +24,39 @@
24
24
  ".": {
25
25
  "types": "./dist/index.d.ts",
26
26
  "svelte": "./dist/index.js"
27
- }
27
+ },
28
+ "./theme.css": "./dist/theme.css"
28
29
  },
29
30
  "dependencies": {
30
- "@floating-ui/dom": "^1.7.4",
31
31
  "@lucide/svelte": "^1.1.0",
32
- "marked": "^18.0.0"
32
+ "clsx": "^2.1.1",
33
+ "marked": "^18.0.0",
34
+ "tailwind-merge": "^3.7.0"
33
35
  },
34
36
  "peerDependencies": {
35
37
  "svelte": "^5.0.0"
36
38
  },
37
39
  "devDependencies": {
38
- "@changesets/cli": "2.31.1",
40
+ "@changesets/cli": "3.0.3",
39
41
  "@eslint/compat": "2.1.1",
40
42
  "@eslint/js": "10.0.1",
41
43
  "@playwright/test": "1.64.1",
42
- "@sveltejs/adapter-static": "3.0.10",
43
- "@sveltejs/kit": "2.70.3",
44
- "@sveltejs/package": "2.5.8",
44
+ "@sveltejs/adapter-static": "4.0.1",
45
+ "@sveltejs/kit": "3.1.1",
46
+ "@sveltejs/load-config": "0.2.3",
47
+ "@sveltejs/package": "3.0.2",
45
48
  "@sveltejs/vite-plugin-svelte": "7.3.1",
46
49
  "@tailwindcss/forms": "0.5.11",
47
50
  "@tailwindcss/postcss": "4.3.3",
48
51
  "@tailwindcss/vite": "4.3.3",
49
- "@types/node": "25.9.9",
52
+ "@types/node": "26.6.6",
50
53
  "eslint": "10.14.0",
51
54
  "eslint-config-prettier": "10.1.8",
52
55
  "eslint-plugin-svelte": "3.23.1",
53
56
  "globals": "17.14.0",
54
57
  "highlight.js": "11.12.0",
55
58
  "highlight.svelte": "0.1.3",
56
- "jsdom": "29.1.1",
59
+ "jsdom": "30.1.3",
57
60
  "postcss": "8.5.32",
58
61
  "prettier": "3.9.10",
59
62
  "prettier-plugin-svelte": "4.1.1",
@@ -61,21 +64,26 @@
61
64
  "publint": "0.3.25",
62
65
  "svelte": "^5.57.3",
63
66
  "svelte-check": "4.7.8",
64
- "tailwind-merge": "3.7.0",
65
67
  "tailwindcss": "4.3.3",
66
68
  "typescript": "6.0.3",
67
69
  "typescript-eslint": "8.72.1",
68
70
  "vite": "8.3.5",
69
- "vitest": "4.1.12"
71
+ "vitest": "5.0.5"
70
72
  },
71
73
  "keywords": [
72
74
  "svelte"
73
75
  ],
76
+ "imports": {
77
+ "#lib": "./src/lib/index.js",
78
+ "#lib/*": "./src/lib/*",
79
+ "#ui": "./src/ui/index.js",
80
+ "#ui/*": "./src/ui/*"
81
+ },
74
82
  "scripts": {
75
83
  "dev": "vite dev",
76
84
  "build": "vite build && pnpm prepack",
77
85
  "preview": "vite preview",
78
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
86
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --fail-on-warnings",
79
87
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
80
88
  "format": "prettier --write .",
81
89
  "lint": "prettier --check . && eslint .",
@@ -1,47 +0,0 @@
1
- <script module lang="ts">
2
- import { getAutocompleteContext } from "./index.js";
3
- import { baseClasses, type Variants } from "../base.js";
4
- import { Popover, type PopoverProps } from "../popover/index.js";
5
- import type { ClassName } from "../utils.js";
6
- import type { Snippet } from "svelte";
7
- import { twMerge } from "tailwind-merge";
8
-
9
- export type AutocompleteProps = {
10
- children: Snippet;
11
- } & ClassName &
12
- Variants &
13
- Omit<PopoverProps, "children">;
14
- </script>
15
-
16
- <script lang="ts">
17
- let {
18
- open = $bindable(false),
19
- children,
20
- class: className,
21
- variant = "elevated",
22
- color = "primary",
23
- shape = "rounded",
24
- ...restProps
25
- }: AutocompleteProps = $props();
26
-
27
- const ctx = getAutocompleteContext();
28
- ctx.bindOpen(
29
- () => open,
30
- (newval) => (open = newval),
31
- );
32
- </script>
33
-
34
- <Popover
35
- bind:open={ctx.open}
36
- role="menu"
37
- class={twMerge(
38
- baseClasses({ variant, color, shape }),
39
- "max-h-[40%] border bg-m3-surface-container-highest p-1 shadow",
40
- className,
41
- )}
42
- anchorEl={ctx.anchorEl}
43
- placement="bottom"
44
- {...restProps}
45
- >
46
- {@render children()}
47
- </Popover>
@@ -1,10 +0,0 @@
1
- import { type Variants } from "../base.js";
2
- import { type PopoverProps } from "../popover/index.js";
3
- import type { ClassName } from "../utils.js";
4
- import type { Snippet } from "svelte";
5
- export type AutocompleteProps = {
6
- children: Snippet;
7
- } & ClassName & Variants & Omit<PopoverProps, "children">;
8
- declare const AutocompleteContent: import("svelte").Component<AutocompleteProps, {}, "open">;
9
- type AutocompleteContent = ReturnType<typeof AutocompleteContent>;
10
- export default AutocompleteContent;
@@ -1,12 +0,0 @@
1
- import { ItemContext } from "../common/index.js";
2
- export declare class AutocompleteContext extends ItemContext {
3
- #private;
4
- get open(): boolean;
5
- set open(value: boolean);
6
- bindOpen(getOpen: () => boolean, setOpen: (val: boolean) => void): void;
7
- get anchorEl(): HTMLElement | undefined;
8
- set anchorEl(value: HTMLElement | undefined);
9
- bindAnchorEl(getAnchorEl: () => HTMLElement | undefined, setAnchorEl: (val: HTMLElement | undefined) => void): void;
10
- }
11
- export declare function setAutocompleteContext(state: AutocompleteContext): AutocompleteContext;
12
- export declare function getAutocompleteContext(): AutocompleteContext;
@@ -1,34 +0,0 @@
1
- import { Bindable } from "../bindable.svelte.js";
2
- import { ItemContext } from "../common/index.js";
3
- import { getContext, setContext } from "svelte";
4
- export class AutocompleteContext extends ItemContext {
5
- #open = new Bindable(false);
6
- #anchorEl = new Bindable(undefined);
7
- get open() {
8
- return this.#open.value;
9
- }
10
- set open(value) {
11
- this.#open.value = value;
12
- }
13
- bindOpen(getOpen, setOpen) {
14
- this.#open.bind(getOpen, setOpen);
15
- }
16
- get anchorEl() {
17
- return this.#anchorEl.value;
18
- }
19
- set anchorEl(value) {
20
- this.#anchorEl.value = value;
21
- }
22
- bindAnchorEl(getAnchorEl, setAnchorEl) {
23
- this.#anchorEl.bind(getAnchorEl, setAnchorEl);
24
- }
25
- }
26
- export function setAutocompleteContext(state) {
27
- return setContext(AutocompleteContext, state);
28
- }
29
- export function getAutocompleteContext() {
30
- const ctx = getContext(AutocompleteContext);
31
- if (!ctx)
32
- throw new Error("AutocompleteContext is undefined");
33
- return ctx;
34
- }
@@ -1,36 +0,0 @@
1
- <script module lang="ts">
2
- import { getAutocompleteContext } from "./index.js";
3
- import { Input, type InputProps } from "../input/index.js";
4
- import { mergeComponentProps } from "../merge-props.js";
5
-
6
- export type AutocompleteInputProps = InputProps;
7
- </script>
8
-
9
- <script lang="ts">
10
- let {
11
- el = $bindable(),
12
- value = $bindable(""),
13
- ...restProps
14
- }: AutocompleteInputProps = $props();
15
-
16
- const ctx = getAutocompleteContext();
17
- ctx.bindInput(
18
- () => value,
19
- (newval) => (value = newval),
20
- );
21
- ctx.bindAnchorEl(
22
- () => el,
23
- (newval) => (el = newval),
24
- );
25
-
26
- function handleKeyDown(event: KeyboardEvent) {
27
- ctx.handleKeyDown(event);
28
- }
29
- </script>
30
-
31
- <Input
32
- bind:el={ctx.anchorEl}
33
- bind:value={ctx.input}
34
- autocomplete="off"
35
- {...mergeComponentProps(Input, { onkeydown: handleKeyDown }, restProps)}
36
- />
@@ -1,5 +0,0 @@
1
- import { type InputProps } from "../input/index.js";
2
- export type AutocompleteInputProps = InputProps;
3
- declare const AutocompleteInput: import("svelte").Component<InputProps, {}, "el" | "value">;
4
- type AutocompleteInput = ReturnType<typeof AutocompleteInput>;
5
- export default AutocompleteInput;
@@ -1,68 +0,0 @@
1
- <script module lang="ts">
2
- import { getAutocompleteContext } from "./index.js";
3
- import { baseClasses, type Variants } from "../base.js";
4
- import { mergeProps } from "../merge-props.js";
5
- import type { ClassName, ElementRef } from "../utils.js";
6
- import type { Snippet } from "svelte";
7
- import type { HTMLAttributes } from "svelte/elements";
8
- import { twMerge } from "tailwind-merge";
9
-
10
- export type AutocompleteItemProps = {
11
- onSelect?: (el: HTMLElement) => void;
12
- children: Snippet;
13
- } & ElementRef &
14
- ClassName &
15
- Variants &
16
- HTMLAttributes<HTMLDivElement>;
17
- </script>
18
-
19
- <script lang="ts">
20
- let {
21
- onSelect,
22
- children,
23
- el = $bindable(),
24
- class: className,
25
- variant = "plain",
26
- color = "secondary",
27
- shape = "rounded",
28
- ...restProps
29
- }: AutocompleteItemProps = $props();
30
-
31
- const ctx = getAutocompleteContext();
32
-
33
- function handleClick() {
34
- if (el) {
35
- onSelect?.(el);
36
- }
37
- }
38
-
39
- function handleMouseEnter() {
40
- ctx.focused = el;
41
- }
42
-
43
- $effect(() => {
44
- if (el) {
45
- return ctx.add(el);
46
- }
47
- });
48
- </script>
49
-
50
- <div
51
- bind:this={el}
52
- role="option"
53
- aria-selected={ctx.focused === el}
54
- class={twMerge(
55
- baseClasses({ variant, color, shape }),
56
- "flex w-full cursor-pointer items-center gap-1 px-2 py-1 text-left text-sm focus:ring-0 disabled:bg-transparent aria-selected:bg-m3-secondary/15",
57
- className,
58
- )}
59
- {...mergeProps(
60
- {
61
- onclick: handleClick,
62
- onmouseenter: handleMouseEnter,
63
- },
64
- restProps,
65
- )}
66
- >
67
- {@render children()}
68
- </div>
@@ -1,11 +0,0 @@
1
- import { type Variants } from "../base.js";
2
- import type { ClassName, ElementRef } from "../utils.js";
3
- import type { Snippet } from "svelte";
4
- import type { HTMLAttributes } from "svelte/elements";
5
- export type AutocompleteItemProps = {
6
- onSelect?: (el: HTMLElement) => void;
7
- children: Snippet;
8
- } & ElementRef & ClassName & Variants & HTMLAttributes<HTMLDivElement>;
9
- declare const AutocompleteItem: import("svelte").Component<AutocompleteItemProps, {}, "el">;
10
- type AutocompleteItem = ReturnType<typeof AutocompleteItem>;
11
- export default AutocompleteItem;
package/dist/base.css DELETED
@@ -1,71 +0,0 @@
1
- .radius-none {
2
- --radius: none;
3
- }
4
-
5
- .radius-xs {
6
- --radius: 0.125rem;
7
- }
8
-
9
- .radius-sm {
10
- --radius: 0.25rem;
11
- }
12
-
13
- .radius-md {
14
- --radius: 0.375rem;
15
- }
16
-
17
- .radius-lg {
18
- --radius: 0.5rem;
19
- }
20
-
21
- .radius-xl {
22
- --radius: 0.75rem;
23
- }
24
-
25
- .radius-2xl {
26
- --radius: 1rem;
27
- }
28
-
29
- .radius-3xl {
30
- --radius: 1.5rem;
31
- }
32
-
33
- .radius-4xl {
34
- --radius: 2rem;
35
- }
36
-
37
- .radius-full {
38
- --radius: calc(infinity * 1px);
39
- }
40
-
41
- .color-primary {
42
- --color-main: var(--md-sys-color-primary);
43
- --color-on-main: var(--md-sys-color-on-primary);
44
- --color-tonal: var(--md-sys-color-primary-container);
45
- --color-on-tonal: var(--md-sys-color-on-primary-container);
46
- --color-shadow: var(--md-sys-color-shadow);
47
- }
48
-
49
- .color-secondary {
50
- --color-main: var(--md-sys-color-secondary);
51
- --color-on-main: var(--md-sys-color-on-secondary);
52
- --color-tonal: var(--md-sys-color-secondary-container);
53
- --color-on-tonal: var(--md-sys-color-on-secondary-container);
54
- --color-shadow: var(--md-sys-color-shadow);
55
- }
56
-
57
- .color-tertiary {
58
- --color-main: var(--md-sys-color-tertiary);
59
- --color-on-main: var(--md-sys-color-on-tertiary);
60
- --color-tonal: var(--md-sys-color-tertiary-container);
61
- --color-on-tonal: var(--md-sys-color-on-tertiary-container);
62
- --color-shadow: var(--md-sys-color-shadow);
63
- }
64
-
65
- .color-error {
66
- --color-main: var(--md-sys-color-error);
67
- --color-on-main: var(--md-sys-color-on-error);
68
- --color-tonal: var(--md-sys-color-error-container);
69
- --color-on-tonal: var(--md-sys-color-on-error-container);
70
- --color-shadow: var(--md-sys-color-shadow);
71
- }
@@ -1,7 +0,0 @@
1
- export declare class Bindable<T> {
2
- #private;
3
- constructor(value: T);
4
- bind(getValue: () => T, setValue: (value: T) => void): void;
5
- get value(): T;
6
- set value(value: T);
7
- }
@@ -1,25 +0,0 @@
1
- export class Bindable {
2
- #value = $state();
3
- #setValue;
4
- constructor(value) {
5
- this.#value = value;
6
- }
7
- bind(getValue, setValue) {
8
- this.#value = getValue();
9
- this.#setValue = setValue;
10
- $effect(() => {
11
- if (this.#value !== getValue()) {
12
- this.#value = getValue();
13
- }
14
- });
15
- }
16
- get value() {
17
- return this.#value;
18
- }
19
- set value(value) {
20
- if (this.#value !== value) {
21
- this.#value = value;
22
- this.#setValue?.(value);
23
- }
24
- }
25
- }
@@ -1,15 +0,0 @@
1
- <script module lang="ts">
2
- import type { ClassName } from "../utils.js";
3
- import type { Snippet } from "svelte";
4
- import { twMerge } from "tailwind-merge";
5
-
6
- export type CommandContentProps = { children: Snippet } & ClassName;
7
- </script>
8
-
9
- <script lang="ts">
10
- let { class: className, children }: CommandContentProps = $props();
11
- </script>
12
-
13
- <div class={twMerge("h-full overflow-scroll", className)}>
14
- {@render children()}
15
- </div>
@@ -1,8 +0,0 @@
1
- import type { ClassName } from "../utils.js";
2
- import type { Snippet } from "svelte";
3
- export type CommandContentProps = {
4
- children: Snippet;
5
- } & ClassName;
6
- declare const CommandContent: import("svelte").Component<CommandContentProps, {}, "">;
7
- type CommandContent = ReturnType<typeof CommandContent>;
8
- export default CommandContent;
@@ -1,5 +0,0 @@
1
- import { ItemContext } from "../common/index.js";
2
- export declare class CommandContext extends ItemContext {
3
- }
4
- export declare function setCommandContext(state: CommandContext): CommandContext;
5
- export declare function getCommandContext(): CommandContext;