fuma 0.0.1

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 (242) hide show
  1. package/README.md +58 -0
  2. package/dist/Meta.svelte +55 -0
  3. package/dist/Meta.svelte.d.ts +20 -0
  4. package/dist/action/index.d.ts +4 -0
  5. package/dist/action/index.js +4 -0
  6. package/dist/action/list/handlers.d.ts +16 -0
  7. package/dist/action/list/handlers.js +92 -0
  8. package/dist/action/list/index.css +40 -0
  9. package/dist/action/list/index.d.ts +23 -0
  10. package/dist/action/list/index.js +44 -0
  11. package/dist/action/list/store.d.ts +3 -0
  12. package/dist/action/list/store.js +1 -0
  13. package/dist/action/list/style.d.ts +2 -0
  14. package/dist/action/list/style.js +14 -0
  15. package/dist/action/list/trigger.d.ts +12 -0
  16. package/dist/action/list/trigger.js +124 -0
  17. package/dist/action/list/utils.d.ts +18 -0
  18. package/dist/action/list/utils.js +68 -0
  19. package/dist/action/portal.d.ts +3 -0
  20. package/dist/action/portal.js +9 -0
  21. package/dist/action/selector.d.ts +15 -0
  22. package/dist/action/selector.js +71 -0
  23. package/dist/action/tip.d.ts +6 -0
  24. package/dist/action/tip.js +12 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +3 -0
  27. package/dist/server/index.d.ts +5 -0
  28. package/dist/server/index.js +5 -0
  29. package/dist/server/json.d.ts +1 -0
  30. package/dist/server/json.js +16 -0
  31. package/dist/server/parseFormData.d.ts +20 -0
  32. package/dist/server/parseFormData.js +63 -0
  33. package/dist/server/parseQuery.d.ts +11 -0
  34. package/dist/server/parseQuery.js +15 -0
  35. package/dist/server/sse.d.ts +6 -0
  36. package/dist/server/sse.js +35 -0
  37. package/dist/server/try.d.ts +6 -0
  38. package/dist/server/try.js +31 -0
  39. package/dist/store/index.d.ts +2 -0
  40. package/dist/store/index.js +2 -0
  41. package/dist/store/isSmallScreen.d.ts +2 -0
  42. package/dist/store/isSmallScreen.js +14 -0
  43. package/dist/store/param.d.ts +24 -0
  44. package/dist/store/param.js +61 -0
  45. package/dist/store/session.d.ts +2 -0
  46. package/dist/store/session.js +13 -0
  47. package/dist/ui/ButtonCopy.svelte +18 -0
  48. package/dist/ui/ButtonCopy.svelte.d.ts +18 -0
  49. package/dist/ui/ButtonDelete.svelte +43 -0
  50. package/dist/ui/ButtonDelete.svelte.d.ts +22 -0
  51. package/dist/ui/Dialog.svelte +58 -0
  52. package/dist/ui/Dialog.svelte.d.ts +25 -0
  53. package/dist/ui/DialogConfirm.svelte +22 -0
  54. package/dist/ui/DialogConfirm.svelte.d.ts +21 -0
  55. package/dist/ui/Icon.svelte +46 -0
  56. package/dist/ui/Icon.svelte.d.ts +24 -0
  57. package/dist/ui/Pagination.svelte +28 -0
  58. package/dist/ui/Pagination.svelte.d.ts +16 -0
  59. package/dist/ui/Placeholder.svelte +11 -0
  60. package/dist/ui/Placeholder.svelte.d.ts +19 -0
  61. package/dist/ui/PlaceholderImage.svelte +14 -0
  62. package/dist/ui/PlaceholderImage.svelte.d.ts +19 -0
  63. package/dist/ui/card/Card.svelte +38 -0
  64. package/dist/ui/card/Card.svelte.d.ts +26 -0
  65. package/dist/ui/card/CardBasic.svelte +14 -0
  66. package/dist/ui/card/CardBasic.svelte.d.ts +20 -0
  67. package/dist/ui/card/CardCollapse.svelte +61 -0
  68. package/dist/ui/card/CardCollapse.svelte.d.ts +22 -0
  69. package/dist/ui/card/CardFullScreen.svelte +28 -0
  70. package/dist/ui/card/CardFullScreen.svelte.d.ts +23 -0
  71. package/dist/ui/card/CardLink.svelte +21 -0
  72. package/dist/ui/card/CardLink.svelte.d.ts +20 -0
  73. package/dist/ui/card/index.d.ts +5 -0
  74. package/dist/ui/card/index.js +5 -0
  75. package/dist/ui/index.d.ts +14 -0
  76. package/dist/ui/index.js +14 -0
  77. package/dist/ui/input/FormControl.svelte +53 -0
  78. package/dist/ui/input/FormControl.svelte.d.ts +30 -0
  79. package/dist/ui/input/InputBoolean.svelte +29 -0
  80. package/dist/ui/input/InputBoolean.svelte.d.ts +21 -0
  81. package/dist/ui/input/InputCheckboxs.svelte +68 -0
  82. package/dist/ui/input/InputCheckboxs.svelte.d.ts +41 -0
  83. package/dist/ui/input/InputCheckboxsMenu.svelte +93 -0
  84. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +43 -0
  85. package/dist/ui/input/InputCheckboxsTree.svelte +15 -0
  86. package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +21 -0
  87. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +60 -0
  88. package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +23 -0
  89. package/dist/ui/input/InputDate.svelte +26 -0
  90. package/dist/ui/input/InputDate.svelte.d.ts +19 -0
  91. package/dist/ui/input/InputDatetime.svelte +21 -0
  92. package/dist/ui/input/InputDatetime.svelte.d.ts +19 -0
  93. package/dist/ui/input/InputImage.svelte +107 -0
  94. package/dist/ui/input/InputImage.svelte.d.ts +35 -0
  95. package/dist/ui/input/InputImagePreview.svelte +56 -0
  96. package/dist/ui/input/InputImagePreview.svelte.d.ts +23 -0
  97. package/dist/ui/input/InputNumber.svelte +22 -0
  98. package/dist/ui/input/InputNumber.svelte.d.ts +23 -0
  99. package/dist/ui/input/InputOptionInParam.svelte +34 -0
  100. package/dist/ui/input/InputOptionInParam.svelte.d.ts +20 -0
  101. package/dist/ui/input/InputOptions.svelte +79 -0
  102. package/dist/ui/input/InputOptions.svelte.d.ts +17 -0
  103. package/dist/ui/input/InputPassword.svelte +21 -0
  104. package/dist/ui/input/InputPassword.svelte.d.ts +36 -0
  105. package/dist/ui/input/InputRadio.svelte +79 -0
  106. package/dist/ui/input/InputRadio.svelte.d.ts +40 -0
  107. package/dist/ui/input/InputRelation.svelte +114 -0
  108. package/dist/ui/input/InputRelation.svelte.d.ts +52 -0
  109. package/dist/ui/input/InputRelations.svelte +138 -0
  110. package/dist/ui/input/InputRelations.svelte.d.ts +49 -0
  111. package/dist/ui/input/InputSearch.svelte +43 -0
  112. package/dist/ui/input/InputSearch.svelte.d.ts +23 -0
  113. package/dist/ui/input/InputSelect.svelte +59 -0
  114. package/dist/ui/input/InputSelect.svelte.d.ts +26 -0
  115. package/dist/ui/input/InputText.svelte +32 -0
  116. package/dist/ui/input/InputText.svelte.d.ts +31 -0
  117. package/dist/ui/input/InputTextarea.svelte +20 -0
  118. package/dist/ui/input/InputTextarea.svelte.d.ts +23 -0
  119. package/dist/ui/input/InputTime.svelte +19 -0
  120. package/dist/ui/input/InputTime.svelte.d.ts +19 -0
  121. package/dist/ui/input/RelationAfter.svelte +42 -0
  122. package/dist/ui/input/RelationAfter.svelte.d.ts +22 -0
  123. package/dist/ui/input/SelectorList.svelte +46 -0
  124. package/dist/ui/input/SelectorList.svelte.d.ts +40 -0
  125. package/dist/ui/input/action.d.ts +13 -0
  126. package/dist/ui/input/action.js +56 -0
  127. package/dist/ui/input/index.d.ts +25 -0
  128. package/dist/ui/input/index.js +25 -0
  129. package/dist/ui/input/textRich/InputTextRich.svelte +58 -0
  130. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +20 -0
  131. package/dist/ui/input/textRich/SuggesionList.svelte +21 -0
  132. package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +19 -0
  133. package/dist/ui/input/textRich/ToolMark.svelte +19 -0
  134. package/dist/ui/input/textRich/ToolMark.svelte.d.ts +21 -0
  135. package/dist/ui/input/textRich/ToolMarkColor.svelte +32 -0
  136. package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +19 -0
  137. package/dist/ui/input/textRich/ToolMarkLink.svelte +63 -0
  138. package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +17 -0
  139. package/dist/ui/input/textRich/ToolMenu.svelte +50 -0
  140. package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +29 -0
  141. package/dist/ui/input/textRich/ToolMenuAlign.svelte +46 -0
  142. package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +17 -0
  143. package/dist/ui/input/textRich/ToolMenuInsert.svelte +49 -0
  144. package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +19 -0
  145. package/dist/ui/input/textRich/ToolMenuNode.svelte +56 -0
  146. package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +17 -0
  147. package/dist/ui/input/textRich/ToolsBar.svelte +60 -0
  148. package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +18 -0
  149. package/dist/ui/input/textRich/extensions.d.ts +2 -0
  150. package/dist/ui/input/textRich/extensions.js +62 -0
  151. package/dist/ui/input/textRich/indent.d.ts +13 -0
  152. package/dist/ui/input/textRich/indent.js +112 -0
  153. package/dist/ui/input/textRich/suggestion.d.ts +9 -0
  154. package/dist/ui/input/textRich/suggestion.js +56 -0
  155. package/dist/ui/input/types.d.ts +15 -0
  156. package/dist/ui/input/types.js +1 -0
  157. package/dist/ui/menu/ContextMenu.svelte +47 -0
  158. package/dist/ui/menu/ContextMenu.svelte.d.ts +28 -0
  159. package/dist/ui/menu/DropDown.svelte +110 -0
  160. package/dist/ui/menu/DropDown.svelte.d.ts +38 -0
  161. package/dist/ui/menu/dropdown.css +33 -0
  162. package/dist/ui/menu/index.d.ts +2 -0
  163. package/dist/ui/menu/index.js +2 -0
  164. package/dist/ui/period/PeriodPicker.svelte +53 -0
  165. package/dist/ui/period/PeriodPicker.svelte.d.ts +22 -0
  166. package/dist/ui/period/PeriodPickerButton.svelte +73 -0
  167. package/dist/ui/period/PeriodPickerButton.svelte.d.ts +14 -0
  168. package/dist/ui/period/index.d.ts +6 -0
  169. package/dist/ui/period/index.js +2 -0
  170. package/dist/ui/table/Table.svelte +42 -0
  171. package/dist/ui/table/Table.svelte.d.ts +39 -0
  172. package/dist/ui/table/TableBody.svelte +29 -0
  173. package/dist/ui/table/TableBody.svelte.d.ts +33 -0
  174. package/dist/ui/table/TableCell.svelte +27 -0
  175. package/dist/ui/table/TableCell.svelte.d.ts +28 -0
  176. package/dist/ui/table/TableFieldsEdition.svelte +122 -0
  177. package/dist/ui/table/TableFieldsEdition.svelte.d.ts +31 -0
  178. package/dist/ui/table/TableHead.svelte +31 -0
  179. package/dist/ui/table/TableHead.svelte.d.ts +29 -0
  180. package/dist/ui/table/TableViewSelect.svelte +127 -0
  181. package/dist/ui/table/TableViewSelect.svelte.d.ts +24 -0
  182. package/dist/ui/table/cell/TableCellArray.svelte +10 -0
  183. package/dist/ui/table/cell/TableCellArray.svelte.d.ts +16 -0
  184. package/dist/ui/table/cell/TableCellBoolean.svelte +12 -0
  185. package/dist/ui/table/cell/TableCellBoolean.svelte.d.ts +16 -0
  186. package/dist/ui/table/cell/TableCellNumber.svelte +6 -0
  187. package/dist/ui/table/cell/TableCellNumber.svelte.d.ts +16 -0
  188. package/dist/ui/table/cell/TableCellString.svelte +7 -0
  189. package/dist/ui/table/cell/TableCellString.svelte.d.ts +18 -0
  190. package/dist/ui/table/cell/index.d.ts +4 -0
  191. package/dist/ui/table/cell/index.js +4 -0
  192. package/dist/ui/table/context.d.ts +14 -0
  193. package/dist/ui/table/context.js +10 -0
  194. package/dist/ui/table/field.d.ts +79 -0
  195. package/dist/ui/table/field.js +29 -0
  196. package/dist/ui/table/head/TableHeadBoolean.svelte +12 -0
  197. package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +17 -0
  198. package/dist/ui/table/head/TableHeadDate.svelte +100 -0
  199. package/dist/ui/table/head/TableHeadDate.svelte.d.ts +17 -0
  200. package/dist/ui/table/head/TableHeadDefault.svelte +7 -0
  201. package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +17 -0
  202. package/dist/ui/table/head/TableHeadNumber.svelte +80 -0
  203. package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +17 -0
  204. package/dist/ui/table/head/TableHeadSelect.svelte +75 -0
  205. package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +20 -0
  206. package/dist/ui/table/head/TableHeadString.svelte +35 -0
  207. package/dist/ui/table/head/TableHeadString.svelte.d.ts +17 -0
  208. package/dist/ui/table/head/index.d.ts +19 -0
  209. package/dist/ui/table/head/index.js +22 -0
  210. package/dist/ui/table/index.d.ts +10 -0
  211. package/dist/ui/table/index.js +10 -0
  212. package/dist/ui/table/server.d.ts +1 -0
  213. package/dist/ui/table/server.js +32 -0
  214. package/dist/ui/tabs/Tabs.svelte +28 -0
  215. package/dist/ui/tabs/Tabs.svelte.d.ts +18 -0
  216. package/dist/ui/tabs/TabsIcon.svelte +56 -0
  217. package/dist/ui/tabs/TabsIcon.svelte.d.ts +20 -0
  218. package/dist/ui/tabs/index.d.ts +8 -0
  219. package/dist/ui/tabs/index.js +2 -0
  220. package/dist/utils/avatar.d.ts +1 -0
  221. package/dist/utils/avatar.js +5 -0
  222. package/dist/utils/component.d.ts +7 -0
  223. package/dist/utils/component.js +3 -0
  224. package/dist/utils/formatRange.d.ts +8 -0
  225. package/dist/utils/formatRange.js +25 -0
  226. package/dist/utils/index.d.ts +7 -0
  227. package/dist/utils/index.js +7 -0
  228. package/dist/utils/jsonParse.d.ts +1 -0
  229. package/dist/utils/jsonParse.js +10 -0
  230. package/dist/utils/normalizePath.d.ts +1 -0
  231. package/dist/utils/normalizePath.js +11 -0
  232. package/dist/utils/options.d.ts +7 -0
  233. package/dist/utils/options.js +20 -0
  234. package/dist/utils/tippy.d.ts +5 -0
  235. package/dist/utils/tippy.js +4 -0
  236. package/dist/validation/form.d.ts +31 -0
  237. package/dist/validation/form.js +94 -0
  238. package/dist/validation/index.d.ts +2 -0
  239. package/dist/validation/index.js +2 -0
  240. package/dist/validation/zod.d.ts +338 -0
  241. package/dist/validation/zod.js +100 -0
  242. package/package.json +86 -0
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { TableField } from '../field.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ field: TableField;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type TableHeadNumberProps = typeof __propDef.props;
13
+ export type TableHeadNumberEvents = typeof __propDef.events;
14
+ export type TableHeadNumberSlots = typeof __propDef.slots;
15
+ export default class TableHeadNumber extends SvelteComponent<TableHeadNumberProps, TableHeadNumberEvents, TableHeadNumberSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,75 @@
1
+ <script>import { derived } from "svelte/store";
2
+ import { page } from "$app/stores";
3
+ import { jsonParse } from "../../../utils/jsonParse.js";
4
+ import { DropDown, Icon } from "../../index.js";
5
+ import { parseOptions } from "../../../utils/options.js";
6
+ import { urlParam } from "../../../store/param.js";
7
+ export let field;
8
+ export let options;
9
+ export let multiSelect = false;
10
+ let _options = initOptions($page.url);
11
+ page.subscribe(({ url }) => _options = initOptions(url));
12
+ function initOptions({ searchParams }) {
13
+ const selection = searchParams.get(field.key);
14
+ const selections = jsonParse(searchParams.get(field.key), []);
15
+ function getActive(value) {
16
+ if (!multiSelect)
17
+ return selection === value;
18
+ return selections.includes(value);
19
+ }
20
+ return parseOptions(options).map((option) => ({
21
+ ...option,
22
+ isActive: getActive(option.value)
23
+ }));
24
+ }
25
+ const getHref = derived(urlParam, (params) => (value) => {
26
+ const selections = jsonParse(params.get(field.key), []);
27
+ if (!multiSelect)
28
+ return params.toggle({ [field.key]: value }, "skip", "take");
29
+ if (selections.includes(value)) {
30
+ const newSelections = selections.filter((v) => v !== value);
31
+ if (!newSelections.length)
32
+ return params.without(field.key);
33
+ return params.with({ [field.key]: JSON.stringify(newSelections) }, "skip", "take");
34
+ }
35
+ return params.with({ [field.key]: JSON.stringify([...selections, value]) }, "skip", "take");
36
+ });
37
+ </script>
38
+
39
+ <th class="p-1">
40
+ <DropDown hideOnBlur hideOnNav={!multiSelect} tippyProps={{ appendTo: () => document.body }}>
41
+ <button slot="activator" class="menu-item min-h-8 w-full flex-wrap gap-y-1">
42
+ <span>{field.label}</span>
43
+
44
+ {#if _options.filter((option) => option.isActive).length}
45
+ <div class="flex flex-wrap gap-1">
46
+ {#each _options.filter((option) => option.isActive) as option}
47
+ <span class="badge badge-primary badge-xs text-[0.7rem] font-normal text-white">
48
+ {#if option.icon}
49
+ <Icon path={option.icon} size={10} class="-translate-x-1 fill-white/80" />
50
+ {/if}
51
+ {option.label}
52
+ </span>
53
+ {/each}
54
+ </div>
55
+ {/if}
56
+ </button>
57
+
58
+ <div class="flex flex-col gap-1">
59
+ {#each _options as { isActive, icon, label, value }}
60
+ <a
61
+ href={$getHref(value)}
62
+ class="menu-item px-3 py-2"
63
+ class:active={isActive}
64
+ data-sveltekit-noscroll
65
+ data-sveltekit-replacestate
66
+ >
67
+ {#if icon}
68
+ <Icon path={icon} size={18} class="opacity-60" />
69
+ {/if}
70
+ <span class="whitespace-nowrap font-normal">{label}</span>
71
+ </a>
72
+ {/each}
73
+ </div>
74
+ </DropDown>
75
+ </th>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type TableField } from '../../index.js';
3
+ import { type Options } from '../../../utils/options.js';
4
+ declare const __propDef: {
5
+ props: {
6
+ field: TableField;
7
+ options: Options;
8
+ multiSelect?: boolean | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type TableHeadSelectProps = typeof __propDef.props;
16
+ export type TableHeadSelectEvents = typeof __propDef.events;
17
+ export type TableHeadSelectSlots = typeof __propDef.slots;
18
+ export default class TableHeadSelect extends SvelteComponent<TableHeadSelectProps, TableHeadSelectEvents, TableHeadSelectSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,35 @@
1
+ <script>import { mdiMagnify } from "@mdi/js";
2
+ import { page } from "$app/stores";
3
+ import { DropDown, Icon, InputSearch } from "../../index.js";
4
+ export let field;
5
+ let tip;
6
+ let searchValue = $page.url.searchParams.get(field.key) || "";
7
+ </script>
8
+
9
+ <th class="p-1">
10
+ <DropDown
11
+ bind:tip
12
+ hideOnBlur
13
+ hideOnNav={false}
14
+ autofocus
15
+ tippyProps={{ appendTo: () => document.body }}
16
+ >
17
+ <button slot="activator" class="menu-item min-h-8 w-full flex-wrap gap-y-1">
18
+ <span>{field.label}</span>
19
+
20
+ {#if searchValue}
21
+ <span class="badge badge-primary badge-xs text-[0.7rem] font-normal text-white">
22
+ <Icon path={mdiMagnify} size={10} class="-translate-x-1 fill-white/80" />
23
+ <span>{searchValue}</span>
24
+ </span>
25
+ {/if}
26
+ </button>
27
+
28
+ <InputSearch
29
+ class="m-1"
30
+ key={field.key}
31
+ bind:value={searchValue}
32
+ on:keydown={(e) => e.key === 'Enter' && tip.hide()}
33
+ />
34
+ </DropDown>
35
+ </th>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type TableField } from '../../index.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ field: TableField;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type TableHeadStringProps = typeof __propDef.props;
13
+ export type TableHeadStringEvents = typeof __propDef.events;
14
+ export type TableHeadStringSlots = typeof __propDef.slots;
15
+ export default class TableHeadString extends SvelteComponent<TableHeadStringProps, TableHeadStringEvents, TableHeadStringSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { ComponentProps } from 'svelte';
2
+ import type { ComponentAndProps } from '../../../utils/component.js';
3
+ import type { TableField, TableFieldType } from '../field.js';
4
+ import { default as TableHeadSelect } from './TableHeadSelect.svelte';
5
+ import { default as TableHeadDate } from './TableHeadDate.svelte';
6
+ import { default as TableHeadBoolean } from './TableHeadBoolean.svelte';
7
+ import { default as TableHeadNumber } from './TableHeadNumber.svelte';
8
+ import { default as TableHeadString } from './TableHeadString.svelte';
9
+ declare const tableHeadComponentRecord: {
10
+ boolean: typeof TableHeadBoolean;
11
+ string: typeof TableHeadString;
12
+ textarea: typeof TableHeadString;
13
+ number: typeof TableHeadNumber;
14
+ multiselect: typeof TableHeadSelect;
15
+ select: typeof TableHeadSelect;
16
+ date: typeof TableHeadDate;
17
+ };
18
+ export declare function tableHeadComponent<T extends TableFieldType>(type: T, props: Omit<ComponentProps<InstanceType<(typeof tableHeadComponentRecord)[T]>>, 'field'>): (field: TableField) => ComponentAndProps;
19
+ export {};
@@ -0,0 +1,22 @@
1
+ import { default as TableHeadSelect } from './TableHeadSelect.svelte';
2
+ import { default as TableHeadDate } from './TableHeadDate.svelte';
3
+ import { default as TableHeadBoolean } from './TableHeadBoolean.svelte';
4
+ import { default as TableHeadNumber } from './TableHeadNumber.svelte';
5
+ import { default as TableHeadString } from './TableHeadString.svelte';
6
+ const tableHeadComponentRecord = {
7
+ boolean: TableHeadBoolean,
8
+ string: TableHeadString,
9
+ textarea: TableHeadString,
10
+ number: TableHeadNumber,
11
+ multiselect: TableHeadSelect,
12
+ select: TableHeadSelect,
13
+ date: TableHeadDate
14
+ };
15
+ export function tableHeadComponent(type, props) {
16
+ return (field) => {
17
+ const component = tableHeadComponentRecord[type];
18
+ if (type !== 'multiselect')
19
+ return { component, props: { ...props, field } };
20
+ return { component, props: { ...props, field, multiSelect: true } };
21
+ };
22
+ }
@@ -0,0 +1,10 @@
1
+ export { type TableField } from './field.js';
2
+ export { default as Table } from './Table.svelte';
3
+ export { default as TableHead } from './TableHead.svelte';
4
+ export { default as TableBody } from './TableBody.svelte';
5
+ export { default as TableCell } from './TableCell.svelte';
6
+ export { default as TableFieldsEdition } from './TableFieldsEdition.svelte';
7
+ export { default as TableViewSelect } from './TableViewSelect.svelte';
8
+ export * from './head/index.js';
9
+ export * from './field.js';
10
+ export * from './context.js';
@@ -0,0 +1,10 @@
1
+ export {} from './field.js';
2
+ export { default as Table } from './Table.svelte';
3
+ export { default as TableHead } from './TableHead.svelte';
4
+ export { default as TableBody } from './TableBody.svelte';
5
+ export { default as TableCell } from './TableCell.svelte';
6
+ export { default as TableFieldsEdition } from './TableFieldsEdition.svelte';
7
+ export { default as TableViewSelect } from './TableViewSelect.svelte';
8
+ export * from './head/index.js';
9
+ export * from './field.js';
10
+ export * from './context.js';
@@ -0,0 +1 @@
1
+ export declare function ensureFieldsWithFilterAreVisibles(tableKey: string, url: URL, isFilterKey: (key: string) => boolean): void;
@@ -0,0 +1,32 @@
1
+ import { redirect } from '@sveltejs/kit';
2
+ import { jsonParse } from '../../utils/jsonParse.js';
3
+ import { createKeys } from './context.js';
4
+ export function ensureFieldsWithFilterAreVisibles(tableKey, url, isFilterKey) {
5
+ const { KEY_FIELDS_VISIBLE, KEY_FIELDS_HIDDEN } = createKeys(tableKey);
6
+ const fieldsVisible = jsonParse(url.searchParams.get(KEY_FIELDS_VISIBLE), []);
7
+ const fieldsHidden = jsonParse(url.searchParams.get(KEY_FIELDS_HIDDEN), []);
8
+ // Ensure all existing filter is visible
9
+ const _fieldsVisible = [...fieldsVisible];
10
+ const _fieldsHidden = [...fieldsHidden];
11
+ for (const key of url.searchParams.keys()) {
12
+ if (!isFilterKey(key))
13
+ continue;
14
+ if (!_fieldsVisible.includes(key))
15
+ _fieldsVisible.push(key);
16
+ if (_fieldsHidden.includes(key))
17
+ _fieldsHidden.splice(_fieldsHidden.indexOf(key), 1);
18
+ }
19
+ const paramsUpdated = _fieldsVisible.length !== fieldsVisible.length || _fieldsHidden.length !== fieldsHidden.length;
20
+ if (!paramsUpdated)
21
+ return;
22
+ const _url = new URL(url);
23
+ if (!_fieldsVisible.length)
24
+ _url.searchParams.delete(KEY_FIELDS_VISIBLE);
25
+ else
26
+ _url.searchParams.set(KEY_FIELDS_VISIBLE, JSON.stringify(_fieldsVisible));
27
+ if (!_fieldsHidden.length)
28
+ _url.searchParams.delete(KEY_FIELDS_HIDDEN);
29
+ else
30
+ _url.searchParams.set(KEY_FIELDS_HIDDEN, JSON.stringify(_fieldsHidden));
31
+ redirect(302, _url);
32
+ }
@@ -0,0 +1,28 @@
1
+ <script>import { page } from "$app/stores";
2
+ import { Icon } from "../../index.js";
3
+ export let tabs;
4
+ let klass = "";
5
+ export { klass as class };
6
+ </script>
7
+
8
+ <div
9
+ class="
10
+ bordered sticky top-0 z-20 flex gap-2 rounded-t-2xl border-b bg-base-100 p-2 shadow-sm
11
+ {klass}
12
+ "
13
+ >
14
+ {#each tabs as tab}
15
+ {@const active = tab.isActive ?? $page.url.pathname.startsWith(tab.href)}
16
+ <a
17
+ href={tab.href}
18
+ class="
19
+ menu-item grow flex-col justify-center gap-0 rounded-lg py-2
20
+ text-sm lg:flex-row lg:gap-3 lg:text-base
21
+ "
22
+ class:active
23
+ >
24
+ <Icon path={tab.icon} size={20} class="opacity-70" />
25
+ <span class="hidden whitespace-nowrap sm:block">{tab.label}</span>
26
+ </a>
27
+ {/each}
28
+ </div>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Tab } from './index.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ tabs: Tab[];
6
+ class?: string | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type TabsProps = typeof __propDef.props;
14
+ export type TabsEvents = typeof __propDef.events;
15
+ export type TabsSlots = typeof __propDef.slots;
16
+ export default class Tabs extends SvelteComponent<TabsProps, TabsEvents, TabsSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,56 @@
1
+ <script>import { page } from "$app/stores";
2
+ import { onMount } from "svelte";
3
+ import { urlParam } from "../../store/index.js";
4
+ import { Icon, parseOptions } from "../../index.js";
5
+ export let options;
6
+ export let showLabel = false;
7
+ export let key;
8
+ export let defaultValue = void 0;
9
+ let _options = getOptions($page.url);
10
+ onMount(
11
+ () => page.subscribe(({ url }) => {
12
+ _options = getOptions(url);
13
+ })
14
+ );
15
+ function getOptions(url) {
16
+ return parseOptions(options).map((option) => ({
17
+ ...option,
18
+ isActive: getIsActive(option, url)
19
+ }));
20
+ }
21
+ function getIsActive(option, { searchParams }) {
22
+ if (searchParams.get(key) === option.value)
23
+ return true;
24
+ if (!searchParams.has(key))
25
+ return option.value === defaultValue;
26
+ return false;
27
+ }
28
+ </script>
29
+
30
+ <div class="flex items-center gap-[3px] rounded-lg bg-base-200 p-1">
31
+ {#each _options as { value, label, icon, isActive }}
32
+ <a
33
+ href={$urlParam.with({ [key]: value })}
34
+ data-sveltekit-noscroll
35
+ data-sveltekit-replacestate
36
+ class="flex h-6 items-center justify-center gap-2 rounded p-1"
37
+ class:px-2={showLabel}
38
+ class:w-6={icon && !showLabel}
39
+ class:whitespace-nowrap={showLabel}
40
+ class:bg-base-100={isActive}
41
+ class:shadow={isActive}
42
+ >
43
+ {#if icon}
44
+ <Icon
45
+ path={icon}
46
+ title={showLabel ? '' : label}
47
+ size={18}
48
+ class={isActive ? '' : 'opacity-60'}
49
+ />
50
+ {/if}
51
+ {#if !icon || showLabel}
52
+ <span class="text-sm font-medium opacity-80">{label}</span>
53
+ {/if}
54
+ </a>
55
+ {/each}
56
+ </div>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Options } from '../../index.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ options: Options;
6
+ showLabel?: boolean | undefined;
7
+ key: string;
8
+ defaultValue?: string | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type TabsIconProps = typeof __propDef.props;
16
+ export type TabsIconEvents = typeof __propDef.events;
17
+ export type TabsIconSlots = typeof __propDef.slots;
18
+ export default class TabsIcon extends SvelteComponent<TabsIconProps, TabsIconEvents, TabsIconSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,8 @@
1
+ export { default as Tabs } from './Tabs.svelte';
2
+ export { default as TabsIcon } from './TabsIcon.svelte';
3
+ export type Tab = {
4
+ href: string;
5
+ isActive?: boolean;
6
+ label: string;
7
+ icon: string;
8
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Tabs } from './Tabs.svelte';
2
+ export { default as TabsIcon } from './TabsIcon.svelte';
@@ -0,0 +1 @@
1
+ export declare function createAvatarPlaceholder(): string;
@@ -0,0 +1,5 @@
1
+ export function createAvatarPlaceholder() {
2
+ const avatarUrl = new URL('https://api.dicebear.com/7.x/thumbs/svg');
3
+ avatarUrl.searchParams.append('seed', String(Math.random()));
4
+ return avatarUrl.toString();
5
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentProps, ComponentType } from 'svelte';
2
+ export type Primitive = string | number | boolean;
3
+ export type ComponentAndProps = {
4
+ component: ComponentType;
5
+ props: ComponentProps<InstanceType<ComponentType>>;
6
+ };
7
+ export declare function component<Component extends ComponentType>(component: Component, props: ComponentProps<InstanceType<Component>>): ComponentAndProps;
@@ -0,0 +1,3 @@
1
+ export function component(component, props) {
2
+ return { component, props };
3
+ }
@@ -0,0 +1,8 @@
1
+ type Range = {
2
+ start: Date | number;
3
+ end: Date | number;
4
+ };
5
+ export declare const formatRange: ({ start, end }: Range) => string;
6
+ export declare const formatRangeShort: ({ start, end }: Range) => string;
7
+ export declare const formatRangeHour: ({ start, end }: Range) => string;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ import dayjs from 'dayjs';
2
+ const formater = new Intl.DateTimeFormat('fr-ch', {
3
+ weekday: 'long',
4
+ day: 'numeric',
5
+ month: 'numeric',
6
+ year: '2-digit',
7
+ hour: 'numeric',
8
+ minute: 'numeric',
9
+ timeZone: 'Europe/Zurich',
10
+ });
11
+ const formaterShort = new Intl.DateTimeFormat('fr-ch', {
12
+ weekday: 'short',
13
+ hour: 'numeric',
14
+ minute: 'numeric',
15
+ timeZone: 'Europe/Zurich',
16
+ });
17
+ export const formatRange = ({ start, end }) => formater.formatRange(start, end);
18
+ export const formatRangeShort = ({ start, end }) => formaterShort.formatRange(start, end);
19
+ export const formatRangeHour = ({ start, end }) => {
20
+ const _start = dayjs(start);
21
+ const _end = dayjs(end);
22
+ if (_start.isSame(_end))
23
+ return _start.format('HH:mm');
24
+ return [_start.format('HH:mm'), _end.format('HH:mm')].join(' – ');
25
+ };
@@ -0,0 +1,7 @@
1
+ export * from './component.js';
2
+ export * from './jsonParse.js';
3
+ export * from './normalizePath.js';
4
+ export * from './formatRange.js';
5
+ export * from './options.js';
6
+ export * from './avatar.js';
7
+ export * from './tippy.js';
@@ -0,0 +1,7 @@
1
+ export * from './component.js';
2
+ export * from './jsonParse.js';
3
+ export * from './normalizePath.js';
4
+ export * from './formatRange.js';
5
+ export * from './options.js';
6
+ export * from './avatar.js';
7
+ export * from './tippy.js';
@@ -0,0 +1 @@
1
+ export declare function jsonParse<Type>(text: string | null | undefined, defaultValue: Type): Type;
@@ -0,0 +1,10 @@
1
+ export function jsonParse(text, defaultValue) {
2
+ try {
3
+ if (!text)
4
+ return defaultValue;
5
+ return JSON.parse(text);
6
+ }
7
+ catch {
8
+ return defaultValue;
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizePath(str: string | undefined): string;
@@ -0,0 +1,11 @@
1
+ export function normalizePath(str) {
2
+ if (!str)
3
+ return '';
4
+ return str
5
+ .trim()
6
+ .normalize('NFD')
7
+ .replace(/[\u0300-\u036f]/g, '')
8
+ .replaceAll(' ', '-')
9
+ .replace(/[\.\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]/g, '')
10
+ .toLowerCase();
11
+ }
@@ -0,0 +1,7 @@
1
+ export type Option = {
2
+ value: string;
3
+ label: string;
4
+ icon?: string;
5
+ };
6
+ export type Options = string | string[] | Option[] | Record<string, string> | Record<string, Omit<Option, 'value'>>;
7
+ export declare function parseOptions(options: Options): Option[];
@@ -0,0 +1,20 @@
1
+ import { jsonParse } from './jsonParse.js';
2
+ export function parseOptions(options) {
3
+ if (typeof options === 'string') {
4
+ options = jsonParse(options, []);
5
+ }
6
+ if (Array.isArray(options)) {
7
+ return options.filter(Boolean).map((opt) => {
8
+ if (typeof opt === 'string')
9
+ return { value: opt, label: opt };
10
+ return opt;
11
+ });
12
+ }
13
+ return Object.entries(options)
14
+ .filter(([value]) => !!value)
15
+ .map(([value, opt]) => {
16
+ if (typeof opt === 'string')
17
+ return { value, label: opt };
18
+ return { value, ...opt };
19
+ });
20
+ }
@@ -0,0 +1,5 @@
1
+ import 'tippy.js/dist/tippy.css';
2
+ import { type Tippy, type Props as TippyProps, type Instance as TippyInstance, hideAll, delegate, createSingleton, animateFill, followCursor, inlinePositioning, sticky, roundArrow } from 'tippy.js';
3
+ export declare const tippy: Tippy<TippyProps>;
4
+ export type { TippyProps, TippyInstance };
5
+ export { hideAll, delegate, createSingleton, animateFill, followCursor, inlinePositioning, sticky, roundArrow };
@@ -0,0 +1,4 @@
1
+ import 'tippy.js/dist/tippy.css';
2
+ import tippyBadTyped, { hideAll, delegate, createSingleton, animateFill, followCursor, inlinePositioning, sticky, roundArrow } from 'tippy.js';
3
+ export const tippy = tippyBadTyped;
4
+ export { hideAll, delegate, createSingleton, animateFill, followCursor, inlinePositioning, sticky, roundArrow };
@@ -0,0 +1,31 @@
1
+ import type { SubmitFunction } from '@sveltejs/kit';
2
+ export type SetError = {
3
+ [key: string]: (err: string) => void;
4
+ };
5
+ export type FormContext = {
6
+ setError: SetError;
7
+ };
8
+ export declare const formContext: {
9
+ get: () => FormContext;
10
+ };
11
+ type SuccessMessage = false | string | ((action: URL) => string);
12
+ type BooleanOrFunction = boolean | ((action: URL) => boolean);
13
+ type UseFormOptions<ReturnData> = {
14
+ onSubmit?: (...args: Parameters<SubmitFunction>) => any;
15
+ onSuccess?: (action: URL, data?: ReturnData) => any;
16
+ onResetError?: () => unknown;
17
+ onError?: (err: any) => unknown;
18
+ onFail?: (failure: Record<string, any> | undefined) => unknown;
19
+ successUpdate?: BooleanOrFunction;
20
+ successReset?: BooleanOrFunction;
21
+ successMessage?: SuccessMessage;
22
+ };
23
+ export declare function useForm<ReturnData extends Record<string, unknown>>({ onSubmit, onSuccess, onResetError, onError, onFail, successUpdate, successReset, successMessage }?: UseFormOptions<ReturnData>): {
24
+ enhance: (form: HTMLFormElement) => {
25
+ destroy(): void;
26
+ };
27
+ submit: SubmitFunction<ReturnData>;
28
+ resetErrors: () => void;
29
+ setError(key: string, value: string): void;
30
+ };
31
+ export {};