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,56 @@
1
+ <script>import { InputImage } from "./index.js";
2
+ import { PlaceholderImage } from "../index.js";
3
+ export let key = "";
4
+ export let src = "";
5
+ export let alt = "";
6
+ let klass = "";
7
+ export { klass as class };
8
+ export let title = "Image";
9
+ export let x;
10
+ export let y;
11
+ export let aspect = x / y;
12
+ let crop = null;
13
+ let image = "";
14
+ let scale = 0;
15
+ let preview;
16
+ async function handleSubmit(detail) {
17
+ crop = detail.crop;
18
+ image = detail.image;
19
+ scale = x / crop.width;
20
+ }
21
+ </script>
22
+
23
+ <InputImage {key} {title} {aspect} on:submit={({ detail }) => handleSubmit(detail)}>
24
+ {#if crop && image}
25
+ <div
26
+ class="relative overflow-hidden rounded-lg border"
27
+ style:width="{x}px"
28
+ style:height="{y}px"
29
+ >
30
+ <img
31
+ src={image}
32
+ alt="preview"
33
+ bind:this={preview}
34
+ class="absolute max-w-none"
35
+ style:margin="-{scale * crop.y}px 0 0 -{scale * crop.x}px"
36
+ style:width="{scale * preview?.naturalWidth}px"
37
+ style:height="{scale * preview?.naturalHeight}px"
38
+ />
39
+ </div>
40
+ {:else if src}
41
+ <div class="group relative">
42
+ <span
43
+ class="
44
+ absolute inset-[1px] grid
45
+ place-content-center rounded-lg bg-base-300/30
46
+ font-medium opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100
47
+ "
48
+ >
49
+ {title}
50
+ </span>
51
+ <img class="{klass} rounded-lg border" {src} {alt} width={x} height={y} />
52
+ </div>
53
+ {:else}
54
+ <PlaceholderImage {x} {y}>{title}</PlaceholderImage>
55
+ {/if}
56
+ </InputImage>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ key?: string | undefined;
5
+ src?: string | undefined;
6
+ alt?: string | undefined;
7
+ class?: string | undefined;
8
+ title?: string | undefined;
9
+ x: number;
10
+ y: number;
11
+ aspect?: number | undefined;
12
+ };
13
+ events: {
14
+ [evt: string]: CustomEvent<any>;
15
+ };
16
+ slots: {};
17
+ };
18
+ export type InputImagePreviewProps = typeof __propDef.props;
19
+ export type InputImagePreviewEvents = typeof __propDef.events;
20
+ export type InputImagePreviewSlots = typeof __propDef.slots;
21
+ export default class InputImagePreview extends SvelteComponent<InputImagePreviewProps, InputImagePreviewEvents, InputImagePreviewSlots> {
22
+ }
23
+ export {};
@@ -0,0 +1,22 @@
1
+ <script>import { FormControl } from "./index.js";
2
+ $:
3
+ ({ input, value: _value, ...props } = $$props);
4
+ export let value = _value;
5
+ </script>
6
+
7
+ <FormControl {...props} let:key>
8
+ <slot name="label_append" slot="label_append" />
9
+ <input
10
+ bind:value
11
+ bind:this={props.inputElement}
12
+ on:input
13
+ on:focus
14
+ on:blur
15
+ type="number"
16
+ name={key}
17
+ id={key}
18
+ class="input input-bordered"
19
+ inputmode="numeric"
20
+ {...input}
21
+ />
22
+ </FormControl>
@@ -0,0 +1,23 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type InputProps } from './index.js';
3
+ declare const __propDef: {
4
+ props: InputProps;
5
+ events: {
6
+ input: Event;
7
+ focus: FocusEvent;
8
+ blur: FocusEvent;
9
+ } & {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {
13
+ label_append: {
14
+ slot: string;
15
+ };
16
+ };
17
+ };
18
+ export type InputNumberProps = typeof __propDef.props;
19
+ export type InputNumberEvents = typeof __propDef.events;
20
+ export type InputNumberSlots = typeof __propDef.slots;
21
+ export default class InputNumber extends SvelteComponent<InputNumberProps, InputNumberEvents, InputNumberSlots> {
22
+ }
23
+ export {};
@@ -0,0 +1,34 @@
1
+ <script>import { Icon } from "../index.js";
2
+ import { parseOptions } from "../../utils/options.js";
3
+ import { urlParam } from "../../store/param.js";
4
+ let klass = "";
5
+ export { klass as class };
6
+ export let key;
7
+ export let options;
8
+ export let removeKeys = [];
9
+ $:
10
+ _options = parseOptions(options);
11
+ </script>
12
+
13
+ <div class="join {klass}">
14
+ {#each _options as opt}
15
+ {@const active = $urlParam.hasValue(key, opt.value)}
16
+ <a
17
+ href={$urlParam.toggle({ [key]: opt.value }, ...removeKeys)}
18
+ class="btn join-item btn-sm"
19
+ class:btn-primary={active}
20
+ class:w-9={opt.icon}
21
+ >
22
+ {#if opt.icon}
23
+ <Icon
24
+ path={opt.icon}
25
+ title={opt.label}
26
+ class={active ? 'fill-primary-content' : 'opacity-70'}
27
+ size={20}
28
+ />
29
+ {:else}
30
+ {opt.label}
31
+ {/if}
32
+ </a>
33
+ {/each}
34
+ </div>
@@ -0,0 +1,20 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Options } from '../../utils/options.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ class?: string | undefined;
6
+ key: string;
7
+ options: Options;
8
+ removeKeys?: string[] | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type InputOptionInParamProps = typeof __propDef.props;
16
+ export type InputOptionInParamEvents = typeof __propDef.events;
17
+ export type InputOptionInParamSlots = typeof __propDef.slots;
18
+ export default class InputOptionInParam extends SvelteComponent<InputOptionInParamProps, InputOptionInParamEvents, InputOptionInParamSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,79 @@
1
+ <script>import { slide } from "svelte/transition";
2
+ import { mdiPlus, mdiTrashCanOutline } from "@mdi/js";
3
+ import { toast } from "svelte-sonner";
4
+ import { Icon } from "../index.js";
5
+ import { listEditable } from "../../action/list/index.js";
6
+ export let key;
7
+ export let value = "[]";
8
+ let options = JSON.parse(value);
9
+ let newOption = "";
10
+ let optionInput;
11
+ function handleKeyDown(e) {
12
+ if (e.key === "Enter") {
13
+ e.preventDefault();
14
+ createOption();
15
+ }
16
+ }
17
+ function createOption() {
18
+ if (!newOption)
19
+ return;
20
+ if (options.includes(newOption))
21
+ return toast.warning("Cette option \xE9xiste d\xE9j\xE0 !");
22
+ options = [...options, newOption];
23
+ newOption = "";
24
+ value = JSON.stringify(options);
25
+ optionInput.focus();
26
+ }
27
+ function removeOption(index) {
28
+ options = [...options.slice(0, index), ...options.slice(index + 1)];
29
+ value = JSON.stringify(options);
30
+ }
31
+ function onChange(newOrder) {
32
+ options = newOrder;
33
+ value = JSON.stringify(options);
34
+ }
35
+ </script>
36
+
37
+ <input type="hidden" name={key} {value} />
38
+
39
+ <div class="label">
40
+ <span class="label-text">Options</span>
41
+ </div>
42
+
43
+ <div class="bordered rounded-box border p-2">
44
+ <div use:listEditable={{ items: options, onChange }}>
45
+ {#each options as option, index (option)}
46
+ <div class="flex items-center gap-2" transition:slide={{ duration: 200 }}>
47
+ <div class="grow pl-4">
48
+ {option}
49
+ </div>
50
+ <button
51
+ type="button"
52
+ class="btn btn-square btn-ghost btn-sm"
53
+ on:click={() => removeOption(index)}
54
+ >
55
+ <Icon path={mdiTrashCanOutline} size={20} class="fill-error" />
56
+ </button>
57
+ </div>
58
+ {/each}
59
+ </div>
60
+
61
+ <div class="join flex pt-2">
62
+ <input
63
+ bind:this={optionInput}
64
+ type="text"
65
+ placeholder="Nouvelle option"
66
+ class="input join-item input-bordered grow"
67
+ bind:value={newOption}
68
+ on:keydown={handleKeyDown}
69
+ />
70
+ <button
71
+ type="button"
72
+ class="btn btn-square join-item"
73
+ disabled={!newOption}
74
+ on:click={createOption}
75
+ >
76
+ <Icon path={mdiPlus} title="Ajouter" />
77
+ </button>
78
+ </div>
79
+ </div>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ key: string;
5
+ value?: string | undefined;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type InputOptionsProps = typeof __propDef.props;
13
+ export type InputOptionsEvents = typeof __propDef.events;
14
+ export type InputOptionsSlots = typeof __propDef.slots;
15
+ export default class InputOptions extends SvelteComponent<InputOptionsProps, InputOptionsEvents, InputOptionsSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,21 @@
1
+ <script>import { FormControl } from "./index.js";
2
+ $:
3
+ ({ input, value: _value, ...props } = $$props);
4
+ export let value = _value;
5
+ export let autocomplete = "current-password";
6
+ </script>
7
+
8
+ <FormControl {...props} let:key>
9
+ <input
10
+ bind:value
11
+ on:input
12
+ on:focus
13
+ on:blur
14
+ type="password"
15
+ name={key}
16
+ id={key}
17
+ class="input input-bordered"
18
+ {autocomplete}
19
+ {...input}
20
+ />
21
+ </FormControl>
@@ -0,0 +1,36 @@
1
+ import { SvelteComponent } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ class?: string | undefined;
5
+ classLabel?: string | undefined;
6
+ key?: string | undefined;
7
+ label?: string | undefined;
8
+ error?: string | undefined;
9
+ hint?: string | undefined;
10
+ prefix?: string | number | undefined;
11
+ prefixFor?: string | number | undefined;
12
+ enhanceDisabled?: boolean | undefined;
13
+ } & {
14
+ input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
15
+ inputElement?: HTMLInputElement | undefined;
16
+ wrapperClass?: string | undefined;
17
+ value?: string | undefined;
18
+ bindWithParams?: boolean | undefined;
19
+ } & {
20
+ autocomplete?: string | undefined;
21
+ };
22
+ events: {
23
+ input: Event;
24
+ focus: FocusEvent;
25
+ blur: FocusEvent;
26
+ } & {
27
+ [evt: string]: CustomEvent<any>;
28
+ };
29
+ slots: {};
30
+ };
31
+ export type InputPasswordProps = typeof __propDef.props;
32
+ export type InputPasswordEvents = typeof __propDef.events;
33
+ export type InputPasswordSlots = typeof __propDef.slots;
34
+ export default class InputPassword extends SvelteComponent<InputPasswordProps, InputPasswordEvents, InputPasswordSlots> {
35
+ }
36
+ export {};
@@ -0,0 +1,79 @@
1
+ <script>import { onMount } from "svelte";
2
+ import { slide } from "svelte/transition";
3
+ import { parseOptions } from "../../utils/options.js";
4
+ import { formContext } from "../../validation/form.js";
5
+ import { FormControl, bindValueWithParams } from "./index.js";
6
+ $:
7
+ ({
8
+ input,
9
+ value: _value,
10
+ error: _error,
11
+ options,
12
+ optionsClass = "",
13
+ hint,
14
+ class: klass,
15
+ ...props
16
+ } = $$props);
17
+ export let value = _value;
18
+ export let error = _error;
19
+ $:
20
+ _options = parseOptions(options);
21
+ let formControl;
22
+ const { setError } = formContext.get();
23
+ onMount(() => {
24
+ if (props.key)
25
+ setError[props.key] = (err) => error = err;
26
+ const inputs = formControl.querySelectorAll("input");
27
+ const handleInput = () => error = "";
28
+ inputs.forEach((input2) => input2.addEventListener("input", handleInput));
29
+ return () => {
30
+ inputs.forEach((input2) => input2.removeEventListener("input", handleInput));
31
+ };
32
+ });
33
+ </script>
34
+
35
+ <div class={klass} bind:this={formControl}>
36
+ {#if props.label}
37
+ <div class="label">
38
+ <span class="label-text">{props.label}</span>
39
+ <slot name="label_append" />
40
+ </div>
41
+ {/if}
42
+
43
+ <div class={optionsClass}>
44
+ {#each _options as option}
45
+ <FormControl
46
+ {...props}
47
+ let:key
48
+ enhanceDisabled
49
+ label={option.label}
50
+ prefixFor={option.value}
51
+ class="flex-row-reverse items-center justify-end gap-2"
52
+ >
53
+ <input
54
+ use:bindValueWithParams={{ bindEnable: props.bindWithParams }}
55
+ bind:group={value}
56
+ on:input
57
+ on:focus
58
+ on:blur
59
+ value={option.value}
60
+ type="radio"
61
+ name={key}
62
+ id="{option.value}{key}"
63
+ class="radio"
64
+ {...input}
65
+ />
66
+ </FormControl>
67
+ {/each}
68
+ </div>
69
+
70
+ {#if error}
71
+ <div class="label" transition:slide>
72
+ <span class="label-text-alt text-warning">{error}</span>
73
+ </div>
74
+ {:else if hint}
75
+ <div class="label" transition:slide>
76
+ <span class="label-text-alt text-info">{hint}</span>
77
+ </div>
78
+ {/if}
79
+ </div>
@@ -0,0 +1,40 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Options } from '../../utils/options.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ class?: string | undefined;
6
+ classLabel?: string | undefined;
7
+ key?: string | undefined;
8
+ label?: string | undefined;
9
+ error?: string | undefined;
10
+ hint?: string | undefined;
11
+ prefix?: string | number | undefined;
12
+ prefixFor?: string | number | undefined;
13
+ enhanceDisabled?: boolean | undefined;
14
+ } & {
15
+ input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
16
+ inputElement?: HTMLInputElement | undefined;
17
+ wrapperClass?: string | undefined;
18
+ value?: string | undefined;
19
+ bindWithParams?: boolean | undefined;
20
+ } & {
21
+ options: Options;
22
+ optionsClass?: string | undefined;
23
+ };
24
+ events: {
25
+ input: Event;
26
+ focus: FocusEvent;
27
+ blur: FocusEvent;
28
+ } & {
29
+ [evt: string]: CustomEvent<any>;
30
+ };
31
+ slots: {
32
+ label_append: {};
33
+ };
34
+ };
35
+ export type InputRadioProps = typeof __propDef.props;
36
+ export type InputRadioEvents = typeof __propDef.events;
37
+ export type InputRadioSlots = typeof __propDef.slots;
38
+ export default class InputRadio extends SvelteComponent<InputRadioProps, InputRadioEvents, InputRadioSlots> {
39
+ }
40
+ export {};
@@ -0,0 +1,114 @@
1
+ <script>import { createEventDispatcher, tick } from "svelte";
2
+ import debounce from "debounce";
3
+ import { toast } from "svelte-sonner";
4
+ import { mdiClose } from "@mdi/js";
5
+ import { FormControl, DropDown, Icon, SelectorList } from "../index.js";
6
+ import RelationAfter from "./RelationAfter.svelte";
7
+ export let key = "";
8
+ export let label = "";
9
+ export let search;
10
+ export let createUrl = "";
11
+ export let createTitle = "";
12
+ export let item = null;
13
+ export let error = "";
14
+ export let placeholder = "";
15
+ export let tippyProps = {};
16
+ export let flatMode = false;
17
+ let klass = "";
18
+ export { klass as class };
19
+ export let classList = "";
20
+ let inputElement;
21
+ let proposedItems = [];
22
+ let isLoading = false;
23
+ let isError = false;
24
+ let focusIndex = 0;
25
+ let searchValue = "";
26
+ const dispatch = createEventDispatcher();
27
+ export async function clear() {
28
+ searchValue = "";
29
+ item = null;
30
+ await tick();
31
+ inputElement.focus();
32
+ }
33
+ async function select(index = focusIndex) {
34
+ item = proposedItems[index];
35
+ dispatch("input", { value: item });
36
+ }
37
+ async function searchItems(searchValue2 = "") {
38
+ try {
39
+ isLoading = true;
40
+ isError = false;
41
+ focusIndex = 0;
42
+ proposedItems = await search(searchValue2);
43
+ } catch (error2) {
44
+ toast.error("Erreur");
45
+ isError = true;
46
+ console.error(error2);
47
+ } finally {
48
+ isLoading = false;
49
+ }
50
+ }
51
+ const searchItemsDebounce = debounce(searchItems, 150);
52
+ function handleFocus() {
53
+ searchItems();
54
+ }
55
+ async function handleBlur() {
56
+ searchValue = "";
57
+ }
58
+ </script>
59
+
60
+ <DropDown {tippyProps} disable={flatMode}>
61
+ <div class="contents" slot="activator">
62
+ <FormControl {key} {label} {error} class={klass} let:key>
63
+ <div class="flex grow gap-2" class:hidden={item}>
64
+ <div class="relative flex grow items-center gap-2">
65
+ <input
66
+ type="text"
67
+ id={key}
68
+ name={key}
69
+ bind:this={inputElement}
70
+ bind:value={searchValue}
71
+ on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
72
+ on:focus={handleFocus}
73
+ on:blur={handleBlur}
74
+ autocomplete="off"
75
+ {placeholder}
76
+ class="input input-bordered grow"
77
+ />
78
+
79
+ <RelationAfter {isLoading} {createUrl} {createTitle} />
80
+ </div>
81
+ <slot name="append" />
82
+ </div>
83
+
84
+ {#if item}
85
+ <div class="flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2">
86
+ <div class="grow">
87
+ <slot name="item" {item}>
88
+ {item.id}
89
+ </slot>
90
+ </div>
91
+ <button type="button" on:click={() => clear()} class="btn btn-square btn-sm">
92
+ <Icon path={mdiClose} />
93
+ </button>
94
+ </div>
95
+ <input type="hidden" name={key} value={item.id} />
96
+ {/if}
97
+ </FormControl>
98
+ </div>
99
+
100
+ <SelectorList
101
+ items={proposedItems}
102
+ trigger={inputElement}
103
+ {isError}
104
+ {isLoading}
105
+ {focusIndex}
106
+ let:index
107
+ class="w-full {classList}"
108
+ on:select={({ detail }) => select(detail)}
109
+ >
110
+ <slot name="listItem" item={proposedItems[index]}>
111
+ {proposedItems[index].id}
112
+ </slot>
113
+ </SelectorList>
114
+ </DropDown>
@@ -0,0 +1,52 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { TippyProps } from '../../utils/tippy.js';
3
+ declare class __sveltets_Render<RelationItem extends {
4
+ id: string;
5
+ }> {
6
+ props(): {
7
+ key?: string | undefined;
8
+ label?: string | undefined;
9
+ search: (q: string) => Promise<RelationItem[]>;
10
+ createUrl?: string | undefined;
11
+ createTitle?: string | undefined;
12
+ item?: RelationItem | null | undefined;
13
+ error?: string | undefined;
14
+ placeholder?: string | undefined;
15
+ tippyProps?: Partial<TippyProps> | undefined;
16
+ flatMode?: boolean | undefined;
17
+ class?: string | undefined;
18
+ classList?: string | undefined;
19
+ clear?: (() => Promise<void>) | undefined;
20
+ };
21
+ events(): {
22
+ input: CustomEvent<{
23
+ value: RelationItem;
24
+ }>;
25
+ } & {
26
+ [evt: string]: CustomEvent<any>;
27
+ };
28
+ slots(): {
29
+ append: {};
30
+ item: {
31
+ item: RelationItem | null;
32
+ };
33
+ listItem: {
34
+ item: RelationItem;
35
+ };
36
+ };
37
+ }
38
+ export type InputRelationProps<RelationItem extends {
39
+ id: string;
40
+ }> = ReturnType<__sveltets_Render<RelationItem>['props']>;
41
+ export type InputRelationEvents<RelationItem extends {
42
+ id: string;
43
+ }> = ReturnType<__sveltets_Render<RelationItem>['events']>;
44
+ export type InputRelationSlots<RelationItem extends {
45
+ id: string;
46
+ }> = ReturnType<__sveltets_Render<RelationItem>['slots']>;
47
+ export default class InputRelation<RelationItem extends {
48
+ id: string;
49
+ }> extends SvelteComponent<InputRelationProps<RelationItem>, InputRelationEvents<RelationItem>, InputRelationSlots<RelationItem>> {
50
+ get clear(): () => Promise<void>;
51
+ }
52
+ export {};