@ims360/svelte-ivory 0.1.14 → 0.2.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 (177) hide show
  1. package/README.md +0 -5
  2. package/dist/components/ai/AiMessage.svelte +2 -3
  3. package/dist/components/ai/AiMessage.svelte.d.ts.map +1 -1
  4. package/dist/components/ai/Chat.svelte +2 -3
  5. package/dist/components/ai/Chat.svelte.d.ts.map +1 -1
  6. package/dist/components/ai/Markdown.svelte +4 -7
  7. package/dist/components/ai/Markdown.svelte.d.ts.map +1 -1
  8. package/dist/components/ai/UserMessage.svelte +2 -3
  9. package/dist/components/ai/UserMessage.svelte.d.ts.map +1 -1
  10. package/dist/components/basic/checkbox/Checkbox.svelte +13 -11
  11. package/dist/components/basic/checkbox/Checkbox.svelte.d.ts.map +1 -1
  12. package/dist/components/basic/toggle/Toggle.svelte +5 -8
  13. package/dist/components/basic/toggle/Toggle.svelte.d.ts.map +1 -1
  14. package/dist/components/inputs/CheckboxInput.svelte +39 -0
  15. package/dist/components/inputs/CheckboxInput.svelte.d.ts +12 -0
  16. package/dist/components/inputs/CheckboxInput.svelte.d.ts.map +1 -0
  17. package/dist/components/inputs/ColorInput.svelte +25 -0
  18. package/dist/components/inputs/ColorInput.svelte.d.ts +5 -0
  19. package/dist/components/inputs/ColorInput.svelte.d.ts.map +1 -0
  20. package/dist/components/inputs/DateInput.svelte +11 -0
  21. package/dist/components/inputs/DateInput.svelte.d.ts +5 -0
  22. package/dist/components/inputs/DateInput.svelte.d.ts.map +1 -0
  23. package/dist/components/inputs/EmailInput.svelte +16 -0
  24. package/dist/components/inputs/EmailInput.svelte.d.ts +5 -0
  25. package/dist/components/inputs/EmailInput.svelte.d.ts.map +1 -0
  26. package/dist/components/inputs/FileInput.svelte +131 -0
  27. package/dist/components/inputs/FileInput.svelte.d.ts +11 -0
  28. package/dist/components/inputs/FileInput.svelte.d.ts.map +1 -0
  29. package/dist/components/inputs/Input.svelte +101 -0
  30. package/dist/components/inputs/Input.svelte.d.ts +48 -0
  31. package/dist/components/inputs/Input.svelte.d.ts.map +1 -0
  32. package/dist/components/inputs/NumberInput.svelte +17 -0
  33. package/dist/components/inputs/NumberInput.svelte.d.ts +10 -0
  34. package/dist/components/inputs/NumberInput.svelte.d.ts.map +1 -0
  35. package/dist/components/inputs/PasswordCreateInput.svelte +60 -0
  36. package/dist/components/inputs/PasswordCreateInput.svelte.d.ts +12 -0
  37. package/dist/components/inputs/PasswordCreateInput.svelte.d.ts.map +1 -0
  38. package/dist/components/inputs/PasswordInput.svelte +27 -0
  39. package/dist/components/inputs/PasswordInput.svelte.d.ts +10 -0
  40. package/dist/components/inputs/PasswordInput.svelte.d.ts.map +1 -0
  41. package/dist/components/inputs/TextInput.svelte +16 -0
  42. package/dist/components/inputs/TextInput.svelte.d.ts +7 -0
  43. package/dist/components/inputs/TextInput.svelte.d.ts.map +1 -0
  44. package/dist/components/inputs/ToggleInput.svelte +24 -0
  45. package/dist/components/inputs/ToggleInput.svelte.d.ts +5 -0
  46. package/dist/components/inputs/ToggleInput.svelte.d.ts.map +1 -0
  47. package/dist/components/inputs/index.d.ts +13 -0
  48. package/dist/components/inputs/index.d.ts.map +1 -1
  49. package/dist/components/inputs/index.js +13 -0
  50. package/dist/components/inputs/issues/FormIssues.svelte +35 -0
  51. package/dist/components/inputs/issues/FormIssues.svelte.d.ts +10 -0
  52. package/dist/components/inputs/issues/FormIssues.svelte.d.ts.map +1 -0
  53. package/dist/components/inputs/select/Select.svelte +69 -0
  54. package/dist/components/inputs/select/Select.svelte.d.ts +15 -0
  55. package/dist/components/inputs/select/Select.svelte.d.ts.map +1 -0
  56. package/dist/components/inputs/select/SelectOption.svelte +34 -0
  57. package/dist/components/inputs/select/SelectOption.svelte.d.ts +11 -0
  58. package/dist/components/inputs/select/SelectOption.svelte.d.ts.map +1 -0
  59. package/dist/components/layout/Heading.svelte +5 -4
  60. package/dist/components/layout/Heading.svelte.d.ts.map +1 -1
  61. package/dist/components/layout/dialog/Dialog.svelte +5 -8
  62. package/dist/components/layout/dialog/Dialog.svelte.d.ts.map +1 -1
  63. package/dist/components/layout/drawer/Drawer.svelte +7 -10
  64. package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
  65. package/dist/components/layout/index.d.ts +1 -2
  66. package/dist/components/layout/index.d.ts.map +1 -1
  67. package/dist/components/layout/index.js +0 -1
  68. package/dist/components/layout/modal/Modal.svelte +10 -15
  69. package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
  70. package/dist/components/layout/popover/Popover.svelte +95 -89
  71. package/dist/components/layout/popover/Popover.svelte.d.ts +8 -24
  72. package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
  73. package/dist/components/layout/tabs/Tab.svelte +5 -8
  74. package/dist/components/layout/tabs/Tab.svelte.d.ts.map +1 -1
  75. package/dist/components/layout/tooltip/Tooltip.svelte +4 -7
  76. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
  77. package/dist/components/table/Column.svelte +7 -10
  78. package/dist/components/table/Column.svelte.d.ts.map +1 -1
  79. package/dist/components/table/ColumnHead.svelte +2 -2
  80. package/dist/components/table/Table.svelte +5 -8
  81. package/dist/components/table/Table.svelte.d.ts.map +1 -1
  82. package/dist/components/table/VirtualList.svelte +7 -15
  83. package/dist/components/table/VirtualList.svelte.d.ts +2 -2
  84. package/dist/components/table/VirtualList.svelte.d.ts.map +1 -1
  85. package/dist/theme.svelte.d.ts +18 -0
  86. package/dist/theme.svelte.d.ts.map +1 -1
  87. package/dist/types.d.ts.map +1 -1
  88. package/dist/utils/{actions → attachments}/clickOutside.d.ts +2 -4
  89. package/dist/utils/attachments/clickOutside.d.ts.map +1 -0
  90. package/dist/utils/{actions → attachments}/clickOutside.js +4 -7
  91. package/dist/utils/attachments/focusTrap.d.ts +3 -0
  92. package/dist/utils/attachments/focusTrap.d.ts.map +1 -0
  93. package/dist/utils/{actions → attachments}/focusTrap.js +5 -14
  94. package/dist/utils/{actions → attachments}/index.d.ts +0 -1
  95. package/dist/utils/attachments/index.d.ts.map +1 -0
  96. package/dist/utils/{actions → attachments}/index.js +0 -1
  97. package/dist/utils/attachments/resize.d.ts +6 -0
  98. package/dist/utils/attachments/resize.d.ts.map +1 -0
  99. package/dist/utils/{actions → attachments}/resize.js +3 -5
  100. package/dist/utils/attachments/shortcut.svelte.d.ts.map +1 -0
  101. package/dist/utils/attachments/visible.d.ts +6 -0
  102. package/dist/utils/attachments/visible.d.ts.map +1 -0
  103. package/dist/utils/attachments/visible.js +12 -0
  104. package/dist/utils/merge.d.ts +4 -0
  105. package/dist/utils/merge.d.ts.map +1 -0
  106. package/dist/utils/merge.js +6 -0
  107. package/package.json +7 -5
  108. package/src/lib/components/ai/AiMessage.svelte +2 -3
  109. package/src/lib/components/ai/Chat.svelte +2 -3
  110. package/src/lib/components/ai/Markdown.svelte +4 -7
  111. package/src/lib/components/ai/UserMessage.svelte +2 -3
  112. package/src/lib/components/basic/checkbox/Checkbox.svelte +13 -11
  113. package/src/lib/components/basic/toggle/Toggle.svelte +5 -8
  114. package/src/lib/components/inputs/CheckboxInput.svelte +39 -0
  115. package/src/lib/components/inputs/ColorInput.svelte +25 -0
  116. package/src/lib/components/inputs/DateInput.svelte +11 -0
  117. package/src/lib/components/inputs/EmailInput.svelte +16 -0
  118. package/src/lib/components/inputs/FileInput.svelte +131 -0
  119. package/src/lib/components/inputs/Input.svelte +101 -0
  120. package/src/lib/components/inputs/NumberInput.svelte +17 -0
  121. package/src/lib/components/inputs/PasswordCreateInput.svelte +60 -0
  122. package/src/lib/components/inputs/PasswordInput.svelte +27 -0
  123. package/src/lib/components/inputs/TextInput.svelte +16 -0
  124. package/src/lib/components/inputs/ToggleInput.svelte +24 -0
  125. package/src/lib/components/inputs/index.ts +17 -0
  126. package/src/lib/components/inputs/issues/FormIssues.svelte +35 -0
  127. package/src/lib/components/inputs/select/Select.svelte +69 -0
  128. package/src/lib/components/inputs/select/SelectOption.svelte +34 -0
  129. package/src/lib/components/layout/Heading.svelte +5 -4
  130. package/src/lib/components/layout/dialog/Dialog.svelte +5 -8
  131. package/src/lib/components/layout/drawer/Drawer.svelte +7 -10
  132. package/src/lib/components/layout/index.ts +1 -5
  133. package/src/lib/components/layout/modal/Modal.svelte +10 -15
  134. package/src/lib/components/layout/popover/Popover.svelte +95 -89
  135. package/src/lib/components/layout/tabs/Tab.svelte +5 -8
  136. package/src/lib/components/layout/tooltip/Tooltip.svelte +4 -7
  137. package/src/lib/components/table/Column.svelte +7 -10
  138. package/src/lib/components/table/ColumnHead.svelte +2 -2
  139. package/src/lib/components/table/Table.svelte +5 -8
  140. package/src/lib/components/table/VirtualList.svelte +7 -15
  141. package/src/lib/theme.svelte.ts +18 -0
  142. package/src/lib/types.ts +3 -2
  143. package/src/lib/utils/attachments/clickOutside.ts +36 -0
  144. package/src/lib/utils/attachments/focusTrap.ts +67 -0
  145. package/src/lib/utils/{actions → attachments}/index.ts +0 -1
  146. package/src/lib/utils/attachments/resize.ts +38 -0
  147. package/src/lib/utils/attachments/visible.ts +22 -0
  148. package/src/lib/utils/merge.ts +7 -0
  149. package/dist/components/layout/portal/Portal.svelte +0 -39
  150. package/dist/components/layout/portal/Portal.svelte.d.ts +0 -21
  151. package/dist/components/layout/portal/Portal.svelte.d.ts.map +0 -1
  152. package/dist/components/layout/portal/index.d.ts +0 -6
  153. package/dist/components/layout/portal/index.d.ts.map +0 -1
  154. package/dist/components/layout/portal/index.js +0 -5
  155. package/dist/utils/actions/clickOutside.d.ts.map +0 -1
  156. package/dist/utils/actions/focusTrap.d.ts +0 -5
  157. package/dist/utils/actions/focusTrap.d.ts.map +0 -1
  158. package/dist/utils/actions/index.d.ts.map +0 -1
  159. package/dist/utils/actions/portal.d.ts +0 -10
  160. package/dist/utils/actions/portal.d.ts.map +0 -1
  161. package/dist/utils/actions/portal.js +0 -39
  162. package/dist/utils/actions/resize.d.ts +0 -6
  163. package/dist/utils/actions/resize.d.ts.map +0 -1
  164. package/dist/utils/actions/shortcut.svelte.d.ts.map +0 -1
  165. package/dist/utils/actions/visible.d.ts +0 -6
  166. package/dist/utils/actions/visible.d.ts.map +0 -1
  167. package/dist/utils/actions/visible.js +0 -14
  168. package/src/lib/components/layout/portal/Portal.svelte +0 -39
  169. package/src/lib/components/layout/portal/index.ts +0 -7
  170. package/src/lib/utils/actions/clickOutside.ts +0 -38
  171. package/src/lib/utils/actions/focusTrap.ts +0 -65
  172. package/src/lib/utils/actions/portal.ts +0 -43
  173. package/src/lib/utils/actions/resize.ts +0 -35
  174. package/src/lib/utils/actions/visible.ts +0 -28
  175. /package/dist/utils/{actions → attachments}/shortcut.svelte.d.ts +0 -0
  176. /package/dist/utils/{actions → attachments}/shortcut.svelte.js +0 -0
  177. /package/src/lib/utils/{actions → attachments}/shortcut.svelte.ts +0 -0
package/README.md CHANGED
@@ -20,8 +20,3 @@ _You may need to adjust the path if your `app.css` is not located in `/src`_
20
20
  - [x] Basic layout components (modal, tabs, popover, etc.)
21
21
  - [x] Table
22
22
  - [ ] Input components
23
-
24
- ## TODOs
25
-
26
- - [ ] Bindings to exported functions
27
- - [ ] Replace `<Portal>` with `<dialog>` element in Modal, Popover and Drawer
@@ -5,11 +5,10 @@
5
5
  -->
6
6
 
7
7
  <script lang="ts">
8
+ import { merge } from '../../utils/merge';
8
9
  import { ThumbsDown, ThumbsUp } from '@lucide/svelte';
9
- import clsx from 'clsx';
10
10
  import type { Snippet } from 'svelte';
11
11
  import type { ClassValue } from 'svelte/elements';
12
- import { twMerge } from 'tailwind-merge';
13
12
  import CopyToClipboardButton from '../buttons/CopyToClipboardButton.svelte';
14
13
  import type { AiChatMessage } from './Chat.svelte';
15
14
  import Markdown from './Markdown.svelte';
@@ -48,7 +47,7 @@
48
47
  </script>
49
48
 
50
49
  <div
51
- class={twMerge(clsx('group flex w-full flex-col items-start', clazz))}
50
+ class={merge('group flex w-full flex-col items-start', clazz)}
52
51
  style={minHeight ? `min-height: ${minHeight}px;` : undefined}
53
52
  >
54
53
  {@render messageText({
@@ -1 +1 @@
1
- {"version":3,"file":"AiMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/AiMessage.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAuFL;;;GAGG;AACH,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"AiMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/AiMessage.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAsFL;;;GAGG;AACH,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -6,10 +6,9 @@
6
6
  -->
7
7
 
8
8
  <script lang="ts" module>
9
- import clsx from 'clsx';
9
+ import { merge } from '../../utils/merge';
10
10
  import { tick, type Snippet } from 'svelte';
11
11
  import type { ClassValue } from 'svelte/elements';
12
- import { twMerge } from 'tailwind-merge';
13
12
  import AiMessage from './AiMessage.svelte';
14
13
  import UserMessage from './UserMessage.svelte';
15
14
 
@@ -101,7 +100,7 @@
101
100
  }
102
101
  </script>
103
102
 
104
- <div class={twMerge(clsx('flex grow flex-col gap-2 overflow-hidden', clazz))}>
103
+ <div class={merge('flex grow flex-col gap-2 overflow-hidden', clazz)}>
105
104
  <div
106
105
  class="flex grow flex-col gap-4 overflow-auto pr-2 [scrollbar-gutter:stable]"
107
106
  bind:this={chatContainer}
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI;;YAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI;;YAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
@@ -5,11 +5,10 @@
5
5
  -->
6
6
 
7
7
  <script lang="ts">
8
- import clsx from 'clsx';
8
+ import { merge } from '../../utils/merge';
9
9
  import DomPurify from 'dompurify';
10
10
  import { marked } from 'marked';
11
11
  import type { ClassValue } from 'svelte/elements';
12
- import { twMerge } from 'tailwind-merge';
13
12
 
14
13
  interface Props {
15
14
  source: string;
@@ -44,11 +43,9 @@
44
43
  </script>
45
44
 
46
45
  <div
47
- class={twMerge(
48
- clsx(
49
- 'text-surface-950-50 prose prose-strong:text-surface-950-50 prose-p:my-1 flex flex-col items-start gap-1',
50
- clazz
51
- )
46
+ class={merge(
47
+ 'text-surface-950-50 prose prose-strong:text-surface-950-50 prose-p:my-1 flex flex-col items-start gap-1',
48
+ clazz
52
49
  )}
53
50
  >
54
51
  {#await html then html}
@@ -1 +1 @@
1
- {"version":3,"file":"Markdown.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Markdown.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI9C,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;KAC3F,CAAC;CACL;AAiDL;;;GAGG;AACH,QAAA,MAAM,QAAQ,2CAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Markdown.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Markdown.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9C,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;KAC3F,CAAC;CACL;AA8CL;;;GAGG;AACH,QAAA,MAAM,QAAQ,2CAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -1,8 +1,7 @@
1
1
  <script lang="ts">
2
- import clsx from 'clsx';
2
+ import { merge } from '../../utils/merge';
3
3
  import type { Snippet } from 'svelte';
4
4
  import type { ClassValue } from 'svelte/elements';
5
- import { twMerge } from 'tailwind-merge';
6
5
  import AttachedFile from './AttachedFile.svelte';
7
6
  import type { AiChatMessage } from './Chat.svelte';
8
7
  import Markdown from './Markdown.svelte';
@@ -24,7 +23,7 @@
24
23
  }: Props = $props();
25
24
  </script>
26
25
 
27
- <div class={twMerge(clsx('flex w-full flex-col items-end gap-1', clazz))}>
26
+ <div class={merge('flex w-full flex-col items-end gap-1', clazz)}>
28
27
  {@render messageText({ message })}
29
28
  {#if message.files}
30
29
  <div class="flex flex-row items-center gap-2">
@@ -1 +1 @@
1
- {"version":3,"file":"UserMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/UserMessage.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrC,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;CACvD;AAiDL,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"UserMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/UserMessage.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrC,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;CACvD;AAgDL,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -1,10 +1,11 @@
1
1
  <script lang="ts" module>
2
+ import { theme } from '../../../theme.svelte';
2
3
  import type { IvoryComponent } from '../../../types';
4
+ import { merge } from '../../../utils/merge';
3
5
  import { Check, type Icon as LucideIcon, Minus } from '@lucide/svelte';
4
6
  import clsx from 'clsx';
5
7
  import type { ClassValue } from 'svelte/elements';
6
8
  import { scale } from 'svelte/transition';
7
- import { twMerge } from 'tailwind-merge';
8
9
 
9
10
  export interface CheckboxProps extends IvoryComponent<HTMLElement> {
10
11
  class?: ClassValue;
@@ -40,16 +41,19 @@
40
41
  innerClass,
41
42
  style
42
43
  }: { icon?: typeof LucideIcon; innerClass?: string; style?: string } = $derived.by(() => {
43
- if (!checked && !partial) return { innerClass: 'border-surface-500' };
44
+ const overwrittenClass =
45
+ theme.current.checkbox?.class &&
46
+ clsx(theme.current.checkbox?.class?.(!!checked, !!partial));
47
+ if (!checked && !partial) return { innerClass: overwrittenClass ?? 'border-surface-500' };
44
48
  if (checked)
45
49
  return {
46
50
  icon: Check,
47
- innerClass: 'bg-primary-500 border-primary-500 text-surface-50'
51
+ innerClass: overwrittenClass ?? 'bg-primary-500 border-primary-500 text-surface-50'
48
52
  };
49
53
  if (partial)
50
54
  return {
51
55
  icon: Minus,
52
- innerClass: 'border-primary-700 text-primary-500'
56
+ innerClass: overwrittenClass ?? 'border-primary-700 text-primary-500'
53
57
  };
54
58
  return {};
55
59
  });
@@ -62,13 +66,11 @@
62
66
  {disabled}
63
67
  {style}
64
68
  {onclick}
65
- class={twMerge(
66
- clsx(
67
- 'box-border flex h-5 w-5 items-center justify-center overflow-hidden rounded border-2 transition-colors',
68
- disabled && 'cursor-not-allowed opacity-70',
69
- innerClass,
70
- clazz
71
- )
69
+ class={merge(
70
+ 'box-border flex h-5 w-5 items-center justify-center overflow-hidden rounded border-2 transition-colors',
71
+ disabled && 'cursor-not-allowed opacity-70',
72
+ innerClass,
73
+ clazz
72
74
  )}
73
75
  {...rest}
74
76
  >
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAsDL,sBAAsB;AACtB,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAuDL,sBAAsB;AACtB,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -1,9 +1,8 @@
1
1
  <script lang="ts" module>
2
2
  import type { IvoryComponent } from '../../../types';
3
- import clsx from 'clsx';
3
+ import { merge } from '../../../utils/merge';
4
4
  import type { Snippet } from 'svelte';
5
5
  import type { ClassValue } from 'svelte/elements';
6
- import { twMerge } from 'tailwind-merge';
7
6
 
8
7
  export interface ToggleProps extends IvoryComponent<HTMLElement> {
9
8
  value?: boolean;
@@ -18,12 +17,10 @@
18
17
 
19
18
  <svelte:element
20
19
  this={rest.onclick ? 'button' : 'div'}
21
- class={twMerge(
22
- clsx(
23
- 'group relative flex h-5 w-9 flex-row items-center rounded-full p-0.5 transition-colors duration-100',
24
- value ? 'bg-primary-500' : 'bg-surface-300-700',
25
- clazz
26
- )
20
+ class={merge(
21
+ 'group relative flex h-5 w-9 flex-row items-center rounded-full p-0.5 transition-colors duration-100',
22
+ value ? 'bg-primary-500' : 'bg-surface-300-700',
23
+ clazz
27
24
  )}
28
25
  type={rest.onclick ? 'button' : undefined}
29
26
  role={rest.onclick ? 'button' : undefined}
@@ -1 +1 @@
1
- {"version":3,"file":"Toggle.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/toggle/Toggle.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAgCL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Toggle.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/toggle/Toggle.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA8BL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,39 @@
1
+ <script lang="ts">
2
+ import type { ClassValue } from 'svelte/elements';
3
+ import { Checkbox } from '../basic';
4
+ import type { InputProps } from './Input.svelte';
5
+ import FormIssues from './issues/FormIssues.svelte';
6
+
7
+ interface Props extends InputProps<boolean> {
8
+ class?: ClassValue;
9
+ label: string;
10
+ description?: string;
11
+ onclick?: () => void;
12
+ }
13
+
14
+ let { class: clazz = '', label, description, onclick, disabled, form }: Props = $props();
15
+
16
+ const { set, issues, value } = $derived(form);
17
+
18
+ const checked = $derived(value());
19
+ </script>
20
+
21
+ <div class={['flex flex-col', clazz]}>
22
+ <button
23
+ type="button"
24
+ {disabled}
25
+ onclick={onclick ||
26
+ (() => {
27
+ set(!checked);
28
+ })}
29
+ class={['flex flex-row items-center gap-2', disabled && 'opacity-80']}
30
+ >
31
+ <Checkbox {checked} />
32
+ {label}
33
+ </button>
34
+ <input class="hidden" {...form.as('checkbox')} {checked} />
35
+ {#if description}
36
+ <p class="text-surface-700-300">{description}</p>
37
+ {/if}
38
+ <FormIssues issues={issues?.()} />
39
+ </div>
@@ -0,0 +1,12 @@
1
+ import type { ClassValue } from 'svelte/elements';
2
+ import type { InputProps } from './Input.svelte';
3
+ interface Props extends InputProps<boolean> {
4
+ class?: ClassValue;
5
+ label: string;
6
+ description?: string;
7
+ onclick?: () => void;
8
+ }
9
+ declare const CheckboxInput: import("svelte").Component<Props, {}, "">;
10
+ type CheckboxInput = ReturnType<typeof CheckboxInput>;
11
+ export default CheckboxInput;
12
+ //# sourceMappingURL=CheckboxInput.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/CheckboxInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI7C,UAAU,KAAM,SAAQ,UAAU,CAAC,OAAO,CAAC;IACvC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAgCL,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { merge } from '../../utils/merge';
3
+ import Input, { INPUT_UNSET_OUTLINE, type InputProps } from './Input.svelte';
4
+
5
+ let props: InputProps<string> = $props();
6
+ </script>
7
+
8
+ <Input {...props}>
9
+ {#snippet children({ id, class: inputClass })}
10
+ <div
11
+ class={merge([inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0'])}
12
+ >
13
+ <input
14
+ type="text"
15
+ bind:value={props.form.value, props.form.set}
16
+ class={['flex h-full grow items-center bg-transparent pl-2', INPUT_UNSET_OUTLINE]}
17
+ />
18
+ <input
19
+ class={['h-full rounded', INPUT_UNSET_OUTLINE]}
20
+ {id}
21
+ {...props.form.as('color')}
22
+ />
23
+ </div>
24
+ {/snippet}
25
+ </Input>
@@ -0,0 +1,5 @@
1
+ import { type InputProps } from './Input.svelte';
2
+ declare const ColorInput: import("svelte").Component<InputProps<string>, {}, "">;
3
+ type ColorInput = ReturnType<typeof ColorInput>;
4
+ export default ColorInput;
5
+ //# sourceMappingURL=ColorInput.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/ColorInput.svelte.ts"],"names":[],"mappings":"AAIA,OAAc,EAAuB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAoB7E,QAAA,MAAM,UAAU,wDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,11 @@
1
+ <script lang="ts">
2
+ import Input, { type InputProps } from './Input.svelte';
3
+
4
+ let props: InputProps<string> = $props();
5
+ </script>
6
+
7
+ <Input {...props}>
8
+ {#snippet children(inputProps)}
9
+ <input {...inputProps} {...props.form.as?.('date')} />
10
+ {/snippet}
11
+ </Input>
@@ -0,0 +1,5 @@
1
+ import { type InputProps } from './Input.svelte';
2
+ declare const DateInput: import("svelte").Component<InputProps<string>, {}, "">;
3
+ type DateInput = ReturnType<typeof DateInput>;
4
+ export default DateInput;
5
+ //# sourceMappingURL=DateInput.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/DateInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,QAAA,MAAM,SAAS,wDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import Input, { type InputProps } from './Input.svelte';
3
+
4
+ let props: InputProps<string> = $props();
5
+ </script>
6
+
7
+ <Input {...props}>
8
+ {#snippet children(inputProps)}
9
+ <input
10
+ {...inputProps}
11
+ {...props.form.as?.('email')}
12
+ autocomplete="email"
13
+ autocapitalize="off"
14
+ />
15
+ {/snippet}
16
+ </Input>
@@ -0,0 +1,5 @@
1
+ import { type InputProps } from './Input.svelte';
2
+ declare const EmailInput: import("svelte").Component<InputProps<string>, {}, "">;
3
+ type EmailInput = ReturnType<typeof EmailInput>;
4
+ export default EmailInput;
5
+ //# sourceMappingURL=EmailInput.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/EmailInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,QAAA,MAAM,UAAU,wDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,131 @@
1
+ <script lang="ts" module>
2
+ import { FileUp, X } from '@lucide/svelte';
3
+ import type { Snippet } from 'svelte';
4
+ import type { InputProps } from './Input.svelte';
5
+ import Input from './Input.svelte';
6
+
7
+ export interface FileInputProps extends InputProps<File[] | File> {
8
+ accept?: string[];
9
+ children?: Snippet;
10
+ multiple?: boolean;
11
+ }
12
+ </script>
13
+
14
+ <script lang="ts">
15
+ let { accept, children: passedChildren, multiple = false, ...rest }: FileInputProps = $props();
16
+
17
+ let hovering = $state(false);
18
+
19
+ function onDrop(
20
+ event: DragEvent & {
21
+ currentTarget: EventTarget & HTMLElement;
22
+ }
23
+ ) {
24
+ add(event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : []);
25
+ }
26
+
27
+ function add(files: File[]) {
28
+ const value = rest.form.value();
29
+ if (Array.isArray(value)) {
30
+ rest.form.set([...value.filter((f) => !files.includes(f)), ...Array.from(files || [])]);
31
+ } else {
32
+ rest.form.set((files[0] ?? undefined) as File);
33
+ }
34
+ }
35
+
36
+ function remove(file: File) {
37
+ const value = rest.form.value();
38
+ if (Array.isArray(value)) {
39
+ rest.form.set(value.filter((e) => e !== file));
40
+ } else {
41
+ rest.form.set(undefined as unknown as File);
42
+ }
43
+ }
44
+
45
+ const files = $derived.by(() => {
46
+ const value = rest.form.value();
47
+ if (Array.isArray(value)) {
48
+ return value;
49
+ } else {
50
+ return value ? [value] : [];
51
+ }
52
+ });
53
+
54
+ const formAttributes = $derived(rest.form.as(multiple ? 'file multiple' : 'file'));
55
+ </script>
56
+
57
+ <Input {...rest} fixTitle>
58
+ {#snippet children({ id })}
59
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
60
+ <div
61
+ class={[
62
+ 'group relative h-full min-h-16 w-full rounded transition-all',
63
+ hovering ? 'bg-primary-50-950' : ''
64
+ ]}
65
+ ondragover={() => {
66
+ hovering = true;
67
+ }}
68
+ ondragleave={() => {
69
+ hovering = false;
70
+ }}
71
+ ondrop={(e) => {
72
+ e.preventDefault();
73
+ e.stopPropagation();
74
+ hovering = false;
75
+ onDrop(e);
76
+ }}
77
+ >
78
+ {#if passedChildren}
79
+ {@render passedChildren()}
80
+ {:else}
81
+ <div class="flex h-full w-full flex-col items-center justify-center gap-2 p-4">
82
+ {#if files && files.length > 0}
83
+ <div class="flex flex-row items-center gap-4">
84
+ {#each files as file (file)}
85
+ {@render fileRender(file)}
86
+ {/each}
87
+ </div>
88
+ {:else}
89
+ <div
90
+ class="text-primary-200-800 group-hover:text-primary-300-700 group-hover:bg-primary-100-900 flex h-14 w-14 shrink-0 items-center justify-center rounded-full text-xl transition-colors"
91
+ >
92
+ <FileUp />
93
+ </div>
94
+ {/if}
95
+ </div>
96
+ {/if}
97
+ <input
98
+ type={formAttributes.type}
99
+ aria-invalid={formAttributes['aria-invalid']}
100
+ name={formAttributes.name}
101
+ oninput={(e) => {
102
+ e.preventDefault();
103
+ e.stopPropagation();
104
+ add(e.currentTarget.files ? Array.from(e.currentTarget.files) : []);
105
+ }}
106
+ {multiple}
107
+ title=""
108
+ accept={accept?.join(', ')}
109
+ class="absolute top-0 left-0 h-full w-full grow cursor-pointer opacity-0"
110
+ {id}
111
+ />
112
+ </div>
113
+ {/snippet}
114
+ </Input>
115
+
116
+ {#snippet fileRender(file: File)}
117
+ <div class="bg-primary-200-800 flex w-fit items-center rounded-full py-2 pr-2 pl-4">
118
+ <p>{file.name}</p>
119
+ <button
120
+ type="button"
121
+ class="btn-icon hover:text-primary-500"
122
+ onclick={(e) => {
123
+ e.preventDefault();
124
+ e.stopPropagation();
125
+ remove(file);
126
+ }}
127
+ >
128
+ <X />
129
+ </button>
130
+ </div>
131
+ {/snippet}
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { InputProps } from './Input.svelte';
3
+ export interface FileInputProps extends InputProps<File[] | File> {
4
+ accept?: string[];
5
+ children?: Snippet;
6
+ multiple?: boolean;
7
+ }
8
+ declare const FileInput: import("svelte").Component<FileInputProps, {}, "">;
9
+ type FileInput = ReturnType<typeof FileInput>;
10
+ export default FileInput;
11
+ //# sourceMappingURL=FileInput.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/FileInput.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,cAAe,SAAQ,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAwGL,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -0,0 +1,101 @@
1
+ <script lang="ts" module>
2
+ import { theme } from '../../theme.svelte';
3
+ import { pseudoRandomId } from '../../utils/functions';
4
+ import { merge } from '../../utils/merge';
5
+ import type { RemoteFormField, RemoteFormFieldValue } from '@sveltejs/kit';
6
+ import type { Snippet } from 'svelte';
7
+ import type { ClassValue } from 'svelte/elements';
8
+ import { slide } from 'svelte/transition';
9
+ import FormIssues from './issues/FormIssues.svelte';
10
+
11
+ interface CommonProps {
12
+ id?: string;
13
+ class?: ClassValue;
14
+ style?: string;
15
+ label?: string;
16
+ disabled?: boolean;
17
+ }
18
+
19
+ export interface InputProps<T extends RemoteFormFieldValue> extends CommonProps {
20
+ form: RemoteFormField<T>;
21
+ }
22
+
23
+ export const INPUT_UNSET_OUTLINE =
24
+ 'border-none outline-none ring-transparent focus:outline-none';
25
+ </script>
26
+
27
+ <script lang="ts" generics="T extends RemoteFormFieldValue">
28
+ interface Props<K extends RemoteFormFieldValue> extends CommonProps {
29
+ children: Snippet<[{ class: string; id: string; disabled?: boolean }]>;
30
+ fixTitle?: boolean;
31
+ form: Pick<RemoteFormField<K>, 'value' | 'issues'>;
32
+ }
33
+
34
+ let {
35
+ class: clazz,
36
+ style,
37
+ label,
38
+ id = pseudoRandomId(),
39
+ children,
40
+ form,
41
+ fixTitle,
42
+ ...inputProps
43
+ }: Props<T> = $props();
44
+
45
+ const inputClass = `bg-transparent grow h-14 transition-all peer m-[1px] px-4 py-3 text-lg ${INPUT_UNSET_OUTLINE}`;
46
+
47
+ const hasIssues = $derived.by(() => {
48
+ const i = form.issues?.();
49
+ return i && i.length > 0;
50
+ });
51
+
52
+ const hasValue = $derived(!!fixTitle || !!form.value?.());
53
+ </script>
54
+
55
+ <div
56
+ class={[
57
+ 'accent-primary-500 relative flex h-fit flex-col pt-5',
58
+ inputProps.disabled && 'pointer-events-none opacity-70',
59
+ theme.current.input?.outerClass,
60
+ clazz
61
+ ]}
62
+ {style}
63
+ >
64
+ <div
65
+ class={merge(
66
+ 'group flex h-full grow flex-col overflow-hidden rounded border-2',
67
+ hasIssues
68
+ ? 'bg-error-500/20 border-error-500'
69
+ : 'focus-within:border-primary-500 focus-within:hover:border-primary-500 border-surface-300-700/25 hover:border-surface-300-700/50 transition-[border-color] duration-300',
70
+ theme.current.input?.class?.(hasValue, hasIssues)
71
+ )}
72
+ >
73
+ {@render children({ class: inputClass, id, ...inputProps })}
74
+ {#if label}
75
+ <label
76
+ class={merge([
77
+ 'pointer-events-none absolute cursor-text px-1 transition-all select-none group-focus-within:top-0 group-focus-within:left-0 group-focus-within:text-sm focus:cursor-default',
78
+ hasValue ? 'top-0 left-0 cursor-default text-sm' : 'top-10 left-3',
79
+ hasIssues ? 'text-error-500' : 'text-surface-700-300',
80
+ theme.current.input?.label?.class?.(hasValue, hasIssues)
81
+ ])}
82
+ for={id}
83
+ >
84
+ {label}
85
+ </label>
86
+ {/if}
87
+ </div>
88
+ {#if form.issues?.()}
89
+ <div class="h-fit w-full">
90
+ <div
91
+ class={merge(
92
+ 'flex w-full flex-col overflow-hidden',
93
+ theme.current.input?.issues?.class
94
+ )}
95
+ transition:slide
96
+ >
97
+ <FormIssues issues={form.issues?.()} class="my-0.5 pr-2 first:mt-1 last:mb-1" />
98
+ </div>
99
+ </div>
100
+ {/if}
101
+ </div>