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,127 @@
1
+ <script>import { onMount } from "svelte";
2
+ import { mdiChevronDown, mdiContentSaveEditOutline, mdiPlus } from "@mdi/js";
3
+ import { page } from "$app/stores";
4
+ import { enhance } from "$app/forms";
5
+ import { Dialog, DropDown, Icon, InputText } from "../index.js";
6
+ import { useForm } from "../../validation/form.js";
7
+ export let key;
8
+ export let views;
9
+ export let actionCreate = "?/create_view";
10
+ export let actionUpdate = "?/create_view";
11
+ export let actionDelete = "?/delete_view";
12
+ let dialog;
13
+ const form = useForm({
14
+ onSuccess() {
15
+ dialog.close();
16
+ }
17
+ });
18
+ let query = getQuery($page.url);
19
+ let selectedView = views.find((v) => v.query === query);
20
+ let isNewView = !!query && !selectedView;
21
+ onMount(
22
+ () => page.subscribe(({ url }) => {
23
+ query = getQuery(url);
24
+ selectedView = views.find((v) => v.query === query);
25
+ isNewView = !!query && !selectedView;
26
+ })
27
+ );
28
+ function getQuery({ searchParams }) {
29
+ const searchParam = new URLSearchParams(searchParams);
30
+ searchParam.delete("skip");
31
+ searchParam.delete("take");
32
+ return searchParam.toString();
33
+ }
34
+ </script>
35
+
36
+ <DropDown>
37
+ <button
38
+ type="button"
39
+ slot="activator"
40
+ class="menu-item bordered btn-sm gap-1 rounded-lg border font-semibold opacity-90"
41
+ >
42
+ <span>{isNewView ? 'Nouvelle vue' : selectedView?.name || 'Vue simple'}</span>
43
+ <Icon path={mdiChevronDown} size={20} class="translate-x-1 translate-y-[1px] opacity-90" />
44
+ </button>
45
+
46
+ <ul class="flex flex-col gap-1">
47
+ {#if isNewView}
48
+ <li>
49
+ <button
50
+ type="button"
51
+ class="menu-item w-full pr-[6px]"
52
+ on:click={() => {
53
+ selectedView = undefined
54
+ dialog.showModal()
55
+ }}
56
+ >
57
+ <span>Ajouter la nouvelle vue</span>
58
+ <Icon path={mdiPlus} class="ml-auto opacity-80" size={21} />
59
+ </button>
60
+ <hr class="my-1" />
61
+ </li>
62
+ {/if}
63
+
64
+ <li>
65
+ <a href={$page.url.pathname} class="menu-item" class:active={!query}>
66
+ <span class="grow">Vue simple</span>
67
+ </a>
68
+ </li>
69
+
70
+ {#each views as view (view.id)}
71
+ <li>
72
+ <a
73
+ href="{$page.url.pathname}?{view.query}"
74
+ class="menu-item group pr-1"
75
+ class:active={view.id === selectedView?.id}
76
+ >
77
+ <span class="grow">{view.name}</span>
78
+ <button
79
+ type="button"
80
+ class="btn btn-square btn-ghost btn-xs rounded"
81
+ on:click|preventDefault={() => {
82
+ selectedView = view
83
+ dialog.showModal()
84
+ }}
85
+ >
86
+ <Icon
87
+ path={mdiContentSaveEditOutline}
88
+ class="opacity-50 group-hover:opacity-80"
89
+ size={18}
90
+ title="Modifier la vue '{view.name}'"
91
+ />
92
+ </button>
93
+ </a>
94
+ </li>
95
+ {/each}
96
+ </ul>
97
+ </DropDown>
98
+
99
+ <Dialog bind:dialog>
100
+ <h2 slot="header" class="title">
101
+ {#if selectedView}
102
+ Modifier la vue
103
+ {:else}
104
+ Ajouter la nouvelle vue
105
+ {/if}
106
+ </h2>
107
+
108
+ <form action={selectedView ? actionUpdate : actionCreate} method="post" use:enhance={form.submit}>
109
+ {#if selectedView}
110
+ <input type="hidden" name="id" value={selectedView.id} />
111
+ {/if}
112
+ <input type="hidden" name="key" value={key} />
113
+ <input type="hidden" name="query" value={query} />
114
+
115
+ <InputText
116
+ key="name"
117
+ input={{ placeholder: 'Nom de la vue' }}
118
+ value={selectedView?.name || ''}
119
+ />
120
+
121
+ <div class="mt-2 flex flex-row-reverse gap-2">
122
+ <button class="btn"> Valider </button>
123
+
124
+ <button formaction={actionDelete} class="btn btn-ghost text-error"> Supprimer </button>
125
+ </div>
126
+ </form>
127
+ </Dialog>
@@ -0,0 +1,24 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ key: string;
5
+ views: {
6
+ id: string;
7
+ name: string;
8
+ query: string;
9
+ }[];
10
+ actionCreate?: string | undefined;
11
+ actionUpdate?: string | undefined;
12
+ actionDelete?: string | undefined;
13
+ };
14
+ events: {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {};
18
+ };
19
+ export type TableViewSelectProps = typeof __propDef.props;
20
+ export type TableViewSelectEvents = typeof __propDef.events;
21
+ export type TableViewSelectSlots = typeof __propDef.slots;
22
+ export default class TableViewSelect extends SvelteComponent<TableViewSelectProps, TableViewSelectEvents, TableViewSelectSlots> {
23
+ }
24
+ export {};
@@ -0,0 +1,10 @@
1
+ <script>export let value;
2
+ </script>
3
+
4
+ <td>
5
+ {#each value as v}
6
+ <span class="badge mr-1 whitespace-nowrap">
7
+ {v}
8
+ </span>
9
+ {/each}
10
+ </td>
@@ -0,0 +1,16 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value: (string | number | boolean)[];
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {};
10
+ };
11
+ export type TableCellArrayProps = typeof __propDef.props;
12
+ export type TableCellArrayEvents = typeof __propDef.events;
13
+ export type TableCellArraySlots = typeof __propDef.slots;
14
+ export default class TableCellArray extends SvelteComponent<TableCellArrayProps, TableCellArrayEvents, TableCellArraySlots> {
15
+ }
16
+ export {};
@@ -0,0 +1,12 @@
1
+ <script>import { mdiCheck, mdiClose } from "@mdi/js";
2
+ import { Icon } from "../../index.js";
3
+ export let value;
4
+ </script>
5
+
6
+ <td>
7
+ {#if value}
8
+ <Icon path={mdiCheck} class="fill-success" />
9
+ {:else}
10
+ <Icon path={mdiClose} class="fill-error" />
11
+ {/if}
12
+ </td>
@@ -0,0 +1,16 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value: boolean;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {};
10
+ };
11
+ export type TableCellBooleanProps = typeof __propDef.props;
12
+ export type TableCellBooleanEvents = typeof __propDef.events;
13
+ export type TableCellBooleanSlots = typeof __propDef.slots;
14
+ export default class TableCellBoolean extends SvelteComponent<TableCellBooleanProps, TableCellBooleanEvents, TableCellBooleanSlots> {
15
+ }
16
+ export {};
@@ -0,0 +1,6 @@
1
+ <script>export let value;
2
+ </script>
3
+
4
+ <td>
5
+ <span class="badge">{value}</span>
6
+ </td>
@@ -0,0 +1,16 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ value: number;
5
+ };
6
+ events: {
7
+ [evt: string]: CustomEvent<any>;
8
+ };
9
+ slots: {};
10
+ };
11
+ export type TableCellNumberProps = typeof __propDef.props;
12
+ export type TableCellNumberEvents = typeof __propDef.events;
13
+ export type TableCellNumberSlots = typeof __propDef.slots;
14
+ export default class TableCellNumber extends SvelteComponent<TableCellNumberProps, TableCellNumberEvents, TableCellNumberSlots> {
15
+ }
16
+ export {};
@@ -0,0 +1,7 @@
1
+ <script>export let value;
2
+ export let field;
3
+ </script>
4
+
5
+ <td data-field-key={field.key} data-field-type={field.type === 'textarea' ? 'textarea' : 'string'}>
6
+ <span>{@html value}</span>
7
+ </td>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { TableField } from '../index.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ value: string;
6
+ field: TableField;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type TableCellStringProps = typeof __propDef.props;
14
+ export type TableCellStringEvents = typeof __propDef.events;
15
+ export type TableCellStringSlots = typeof __propDef.slots;
16
+ export default class TableCellString extends SvelteComponent<TableCellStringProps, TableCellStringEvents, TableCellStringSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,4 @@
1
+ export { default as TableCellArray } from './TableCellArray.svelte';
2
+ export { default as TableCellBoolean } from './TableCellBoolean.svelte';
3
+ export { default as TableCellNumber } from './TableCellNumber.svelte';
4
+ export { default as TableCellString } from './TableCellString.svelte';
@@ -0,0 +1,4 @@
1
+ export { default as TableCellArray } from './TableCellArray.svelte';
2
+ export { default as TableCellBoolean } from './TableCellBoolean.svelte';
3
+ export { default as TableCellNumber } from './TableCellNumber.svelte';
4
+ export { default as TableCellString } from './TableCellString.svelte';
@@ -0,0 +1,14 @@
1
+ export type TableContext = {
2
+ KEY_FIELDS_VISIBLE: string;
3
+ KEY_FIELDS_HIDDEN: string;
4
+ KEY_FIELDS_ORDER: string;
5
+ };
6
+ export declare const createKeys: (key: string) => {
7
+ KEY_FIELDS_VISIBLE: string;
8
+ KEY_FIELDS_HIDDEN: string;
9
+ KEY_FIELDS_ORDER: string;
10
+ };
11
+ export declare const context: {
12
+ set: (key: any, context: TableContext) => TableContext;
13
+ get: (key: any) => TableContext;
14
+ };
@@ -0,0 +1,10 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ export const createKeys = (key) => ({
3
+ KEY_FIELDS_VISIBLE: `${key}_fields_visible`,
4
+ KEY_FIELDS_HIDDEN: `${key}_fields_hidden`,
5
+ KEY_FIELDS_ORDER: `${key}_fields_order`
6
+ });
7
+ export const context = {
8
+ set: (setContext),
9
+ get: (getContext)
10
+ };
@@ -0,0 +1,79 @@
1
+ import type { ComponentAndProps, Primitive } from '../../utils/component.js';
2
+ import type { Options } from '../../utils/options.js';
3
+ export type TableFieldType = 'string' | 'textarea' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date';
4
+ export type TableField<Item = any> = TableFieldCommon & (TableFieldUntyped<Item> | TableFieldPrimitive<Item> | TableFieldSelect<Item> | TableFieldMultiselect<Item>);
5
+ type TableFieldCommon = {
6
+ key: string;
7
+ label: string;
8
+ type?: TableFieldType;
9
+ options?: Options;
10
+ hint?: string;
11
+ locked?: boolean;
12
+ visible?: boolean;
13
+ /** Internal usage */
14
+ $visible?: boolean;
15
+ };
16
+ type TableFieldUntyped<Item = any> = {
17
+ getCell: (item: Item) => ComponentAndProps | Primitive[] | Primitive | undefined;
18
+ head?: ComponentAndProps | ((field: TableField) => ComponentAndProps);
19
+ };
20
+ type TableFieldPrimitive<Item = any> = {
21
+ type: Exclude<TableFieldType, 'select' | 'multiselect'>;
22
+ getCell: (item: Item) => ComponentAndProps | Primitive | undefined;
23
+ };
24
+ type TableFieldSelect<Item = any> = {
25
+ type: 'select';
26
+ getCell: (item: Item) => Primitive;
27
+ options: Options;
28
+ };
29
+ type TableFieldMultiselect<Item = any> = {
30
+ type: 'multiselect';
31
+ getCell: (item: Item) => Primitive[];
32
+ options: Options;
33
+ };
34
+ /**
35
+ * Initialise fields from url query
36
+ */
37
+ export declare function syncFieldsWithParams(tablekey: string, fields: TableField[]): ({
38
+ $visible: boolean;
39
+ key: string;
40
+ label: string;
41
+ type?: TableFieldType | undefined;
42
+ options?: Options | undefined;
43
+ hint?: string | undefined;
44
+ locked?: boolean | undefined;
45
+ visible?: boolean | undefined;
46
+ getCell: (item: any) => Primitive | ComponentAndProps | Primitive[] | undefined;
47
+ head?: ComponentAndProps | ((field: TableField<any>) => ComponentAndProps) | undefined;
48
+ } | {
49
+ $visible: boolean;
50
+ key: string;
51
+ label: string;
52
+ type: "string" | "number" | "boolean" | "textarea" | "date";
53
+ options?: Options | undefined;
54
+ hint?: string | undefined;
55
+ locked?: boolean | undefined;
56
+ visible?: boolean | undefined;
57
+ getCell: (item: any) => Primitive | ComponentAndProps | undefined;
58
+ } | {
59
+ $visible: boolean;
60
+ key: string;
61
+ label: string;
62
+ type: "select";
63
+ options: (Options | undefined) & Options;
64
+ hint?: string | undefined;
65
+ locked?: boolean | undefined;
66
+ visible?: boolean | undefined;
67
+ getCell: (item: any) => Primitive;
68
+ } | {
69
+ $visible: boolean;
70
+ key: string;
71
+ label: string;
72
+ type: "multiselect";
73
+ options: (Options | undefined) & Options;
74
+ hint?: string | undefined;
75
+ locked?: boolean | undefined;
76
+ visible?: boolean | undefined;
77
+ getCell: (item: any) => Primitive[];
78
+ })[];
79
+ export {};
@@ -0,0 +1,29 @@
1
+ import { page } from '$app/stores';
2
+ import { get } from 'svelte/store';
3
+ import { jsonParse } from '../../utils/jsonParse.js';
4
+ import { createKeys } from './context.js';
5
+ /**
6
+ * Initialise fields from url query
7
+ */
8
+ export function syncFieldsWithParams(tablekey, fields) {
9
+ const { KEY_FIELDS_VISIBLE, KEY_FIELDS_HIDDEN, KEY_FIELDS_ORDER } = createKeys(tablekey);
10
+ const { url: { searchParams } } = get(page);
11
+ const fieldsVisible = jsonParse(searchParams.get(KEY_FIELDS_VISIBLE), []);
12
+ const fieldsHidden = jsonParse(searchParams.get(KEY_FIELDS_HIDDEN), []);
13
+ const fieldsOrder = jsonParse(searchParams.get(KEY_FIELDS_ORDER), []);
14
+ // Init correct visible prop
15
+ const _fields = fields.map((field) => ({
16
+ ...field,
17
+ $visible: field.locked ||
18
+ (field.visible ? !fieldsHidden.includes(field.key) : fieldsVisible.includes(field.key))
19
+ }));
20
+ // Init correct order fields
21
+ if (fieldsOrder.length === fields.length) {
22
+ return _fields.map((f, index, self) => {
23
+ const key = fieldsOrder[index];
24
+ const field = self.find((_) => _.key === key);
25
+ return field ? field : f;
26
+ });
27
+ }
28
+ return _fields;
29
+ }
@@ -0,0 +1,12 @@
1
+ <script>import { mdiCheck, mdiClose } from "@mdi/js";
2
+ import TableHeadSelect from "./TableHeadSelect.svelte";
3
+ export let field;
4
+ </script>
5
+
6
+ <TableHeadSelect
7
+ {field}
8
+ options={[
9
+ { value: 'true', label: 'Oui', icon: mdiCheck },
10
+ { value: 'false', label: 'Non', icon: mdiClose }
11
+ ]}
12
+ />
@@ -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 TableHeadBooleanProps = typeof __propDef.props;
13
+ export type TableHeadBooleanEvents = typeof __propDef.events;
14
+ export type TableHeadBooleanSlots = typeof __propDef.slots;
15
+ export default class TableHeadBoolean extends SvelteComponent<TableHeadBooleanProps, TableHeadBooleanEvents, TableHeadBooleanSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,100 @@
1
+ <script>import { goto } from "$app/navigation";
2
+ import { page } from "$app/stores";
3
+ import { DropDown, InputTime } from "../../index.js";
4
+ import { formatRange } from "../../../utils/formatRange.js";
5
+ import { PeriodPicker } from "../../period/index.js";
6
+ import { urlParam } from "../../../store/param.js";
7
+ import { jsonParse } from "../../../utils/jsonParse.js";
8
+ export let field;
9
+ let dropDown;
10
+ const initialValue = jsonParse(
11
+ $page.url.searchParams.get(field.key),
12
+ {}
13
+ );
14
+ const start = initialValue.start?.split("T") || [];
15
+ const end = initialValue.end?.split("T") || [];
16
+ let period = {
17
+ start: start[0] || "",
18
+ end: end[0] || ""
19
+ };
20
+ let time = {
21
+ start: start[1] || "00:00",
22
+ end: end[1] || "23:59"
23
+ };
24
+ $:
25
+ isValidPeriod = period.start && period.end && time.start && time.start;
26
+ function getLabel(_period, _time) {
27
+ return formatRange({
28
+ start: /* @__PURE__ */ new Date(`${_period.start}T${_time.start}`),
29
+ end: /* @__PURE__ */ new Date(`${_period.end}T${_time.end}`)
30
+ });
31
+ }
32
+ function handleSubmit() {
33
+ dropDown.hide();
34
+ if (!isValidPeriod)
35
+ return;
36
+ goto(
37
+ $urlParam.with(
38
+ {
39
+ [field.key]: JSON.stringify({
40
+ start: `${period.start}T${time.start || "00:00"}`,
41
+ end: `${period.end}T${time.end || "23:59"}`
42
+ })
43
+ },
44
+ "skip",
45
+ "take"
46
+ ),
47
+ { replaceState: true, noScroll: true }
48
+ );
49
+ }
50
+ function handleReset() {
51
+ dropDown.hide();
52
+ period = { start: "", end: "" };
53
+ time = { start: "00:00", end: "23:59" };
54
+ goto($urlParam.without(field.key, "skip", "take"), { replaceState: true, noScroll: true });
55
+ }
56
+ </script>
57
+
58
+ <th class="p-1">
59
+ <DropDown
60
+ bind:this={dropDown}
61
+ on:mouseLeave={handleSubmit}
62
+ tippyProps={{ appendTo: () => document.body }}
63
+ class="max-h-none"
64
+ >
65
+ <button slot="activator" class="menu-item min-h-8 w-full flex-wrap gap-y-1">
66
+ <span>{field.label}</span>
67
+ {#if isValidPeriod}
68
+ <span class="badge badge-primary badge-xs text-[0.7rem] font-normal text-white">
69
+ {getLabel(period, time)}
70
+ </span>
71
+ {/if}
72
+ </button>
73
+
74
+ <form
75
+ class="flex flex-col font-normal"
76
+ on:submit|preventDefault={handleSubmit}
77
+ data-sveltekit-replacestate
78
+ >
79
+ <PeriodPicker numberOfMonths={1} bind:period />
80
+
81
+ <input
82
+ class="hidden"
83
+ type="text"
84
+ name="start"
85
+ value="{period.start}T{time.start || '00:00'}"
86
+ />
87
+ <input class="hidden" type="text" name="end" value="{period.end}T{time.end || '23:59'}" />
88
+
89
+ <div class="m-2 flex gap-2">
90
+ <InputTime label="A partir de" bind:value={time.start} enhanceDisabled class="grow" />
91
+ <InputTime label="Jusqu'à" bind:value={time.end} enhanceDisabled class="grow" />
92
+ </div>
93
+
94
+ <div class="m-2 flex flex-row-reverse gap-2">
95
+ <button class="btn"> Valider </button>
96
+ <button class="btn btn-ghost" type="button" on:click={handleReset}>Effacer</button>
97
+ </div>
98
+ </form>
99
+ </DropDown>
100
+ </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 TableHeadDateProps = typeof __propDef.props;
13
+ export type TableHeadDateEvents = typeof __propDef.events;
14
+ export type TableHeadDateSlots = typeof __propDef.slots;
15
+ export default class TableHeadDate extends SvelteComponent<TableHeadDateProps, TableHeadDateEvents, TableHeadDateSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,7 @@
1
+ <script>import { tip } from "../../../action/tip.js";
2
+ export let field;
3
+ </script>
4
+
5
+ <th use:tip={{ disable: !field.hint, content: field.hint }}>
6
+ {field.label}
7
+ </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 TableHeadDefaultProps = typeof __propDef.props;
13
+ export type TableHeadDefaultEvents = typeof __propDef.events;
14
+ export type TableHeadDefaultSlots = typeof __propDef.slots;
15
+ export default class TableHeadDefault extends SvelteComponent<TableHeadDefaultProps, TableHeadDefaultEvents, TableHeadDefaultSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,80 @@
1
+ <script>import { onMount } from "svelte";
2
+ import debounce from "debounce";
3
+ import { goto } from "$app/navigation";
4
+ import { page } from "$app/stores";
5
+ import { DropDown, InputNumber } from "../../index.js";
6
+ import { urlParam } from "../../../store/param.js";
7
+ import { jsonParse } from "../../../utils/jsonParse.js";
8
+ export let field;
9
+ let tip;
10
+ let { min, max } = initRange($page.url);
11
+ onMount(() => page.subscribe(({ url }) => ({ min, max } = initRange(url))));
12
+ function initRange({ searchParams }) {
13
+ return jsonParse(searchParams.get(field.key), {
14
+ min: void 0,
15
+ max: void 0
16
+ });
17
+ }
18
+ const udpateUrl = debounce(() => {
19
+ if (isDefined(min) || isDefined(max)) {
20
+ goto($urlParam.with({ [field.key]: JSON.stringify({ min, max }) }, "skip", "take"), {
21
+ noScroll: true,
22
+ keepFocus: true
23
+ });
24
+ return;
25
+ }
26
+ goto($urlParam.without(field.key, "skip", "take"), { noScroll: true, keepFocus: true });
27
+ }, 250);
28
+ function handleReset() {
29
+ min = void 0;
30
+ max = void 0;
31
+ tip.hide();
32
+ goto($urlParam.without(field.key, "skip", "take"), { noScroll: true, keepFocus: true });
33
+ }
34
+ function isDefined(v) {
35
+ return v !== void 0 && v !== null;
36
+ }
37
+ $:
38
+ isNegatifRange = isDefined(min) && isDefined(max) && max < min;
39
+ </script>
40
+
41
+ <th class="p-1">
42
+ <DropDown
43
+ bind:tip
44
+ hideOnBlur
45
+ hideOnNav={false}
46
+ autofocus
47
+ tippyProps={{ appendTo: () => document.body }}
48
+ >
49
+ <button slot="activator" class="menu-item min-h-8 w-full flex-wrap gap-y-1">
50
+ <span>{field.label}</span>
51
+
52
+ {#if isDefined(min) || isDefined(max)}
53
+ <span class="badge badge-primary badge-xs text-[0.7rem] font-normal text-white">
54
+ {#if isDefined(min)}
55
+ {min} ≤
56
+ {/if}
57
+ x
58
+ {#if isDefined(max)}
59
+ ≤ {max}
60
+ {/if}
61
+ </span>
62
+ {/if}
63
+ </button>
64
+
65
+ <form class="grid grid-cols-2 gap-2 p-1" on:submit|preventDefault={() => tip.hide()}>
66
+ <InputNumber bind:value={min} on:input={udpateUrl} input={{ placeholder: 'Min' }} />
67
+ <InputNumber
68
+ bind:value={max}
69
+ on:input={udpateUrl}
70
+ hint={isNegatifRange ? 'Doit être plus grand' : ''}
71
+ input={{ placeholder: 'Max' }}
72
+ />
73
+
74
+ <div class="col-span-full flex justify-end gap-2">
75
+ <button class="btn btn-ghost" type="button" on:click={handleReset}>Effacer</button>
76
+ <button class="btn">Ok</button>
77
+ </div>
78
+ </form>
79
+ </DropDown>
80
+ </th>