fuma 1.0.21 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/action/list/handlers.d.ts +2 -2
- package/dist/action/list/index.d.ts +2 -0
- package/dist/action/list/index.js +1 -0
- package/dist/action/list/trigger.d.ts +7 -1
- package/dist/action/list/trigger.js +2 -2
- package/dist/private/Meta.svelte +32 -27
- package/dist/private/Meta.svelte.d.ts +29 -17
- package/dist/private/api.d.ts +1 -1
- package/dist/private/store.d.ts +0 -1
- package/dist/server/parseFormData.d.ts +1 -1
- package/dist/server/parseQuery.d.ts +1 -1
- package/dist/server/sse.d.ts +0 -1
- package/dist/store/isSmallScreen.d.ts +0 -1
- package/dist/store/param.d.ts +0 -2
- package/dist/store/session.d.ts +0 -1
- package/dist/ui/badge/Badge.svelte +4 -3
- package/dist/ui/badge/Badge.svelte.d.ts +19 -15
- package/dist/ui/button/ButtonCopy.svelte +35 -32
- package/dist/ui/button/ButtonCopy.svelte.d.ts +23 -21
- package/dist/ui/button/ButtonDelete.svelte +23 -21
- package/dist/ui/button/ButtonDelete.svelte.d.ts +32 -20
- package/dist/ui/card/Card.svelte +13 -10
- package/dist/ui/card/Card.svelte.d.ts +39 -24
- package/dist/ui/card/CardBasic.svelte +5 -4
- package/dist/ui/card/CardBasic.svelte.d.ts +29 -18
- package/dist/ui/card/CardCollapse.svelte +35 -31
- package/dist/ui/card/CardCollapse.svelte.d.ts +37 -23
- package/dist/ui/card/CardFullScreen.svelte +8 -6
- package/dist/ui/card/CardFullScreen.svelte.d.ts +35 -20
- package/dist/ui/card/CardLink.svelte +5 -4
- package/dist/ui/card/CardLink.svelte.d.ts +29 -18
- package/dist/ui/dialog/Dialog.svelte +41 -34
- package/dist/ui/dialog/Dialog.svelte.d.ts +36 -23
- package/dist/ui/dialog/DialogConfirm.svelte +6 -4
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +33 -19
- package/dist/ui/drawer/Drawer.svelte +47 -38
- package/dist/ui/drawer/Drawer.svelte.d.ts +81 -46
- package/dist/ui/drawer/drawerFly.d.ts +0 -1
- package/dist/ui/drawer/layers.d.ts +0 -1
- package/dist/ui/form/Form.svelte +106 -87
- package/dist/ui/form/Form.svelte.d.ts +29 -16
- package/dist/ui/form/FormInput.svelte +12 -6
- package/dist/ui/form/FormSection.svelte +24 -17
- package/dist/ui/form/FormSection.svelte.d.ts +37 -25
- package/dist/ui/icon/Icon.svelte +35 -32
- package/dist/ui/icon/Icon.svelte.d.ts +25 -21
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js +0 -1
- package/dist/ui/input/FormControl.svelte +48 -36
- package/dist/ui/input/FormControl.svelte.d.ts +32 -30
- package/dist/ui/input/InputBoolean.svelte +29 -22
- package/dist/ui/input/InputBoolean.svelte.d.ts +43 -35
- package/dist/ui/input/InputCheckboxs.svelte +37 -34
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +54 -39
- package/dist/ui/input/InputCheckboxsMenu.svelte +64 -47
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +56 -41
- package/dist/ui/input/InputCheckboxsTree.svelte +9 -6
- package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +22 -18
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +36 -28
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +20 -16
- package/dist/ui/input/InputCombo.svelte +76 -65
- package/dist/ui/input/InputCombo.svelte.d.ts +55 -39
- package/dist/ui/input/InputDate.svelte +36 -29
- package/dist/ui/input/InputDate.svelte.d.ts +20 -16
- package/dist/ui/input/InputDateTime.svelte +37 -30
- package/dist/ui/input/InputDateTime.svelte.d.ts +20 -16
- package/dist/ui/input/InputImage.svelte +52 -45
- package/dist/ui/input/InputImage.svelte.d.ts +40 -27
- package/dist/ui/input/InputImagePreview.svelte +24 -20
- package/dist/ui/input/InputImagePreview.svelte.d.ts +25 -21
- package/dist/ui/input/InputNumber.svelte +28 -22
- package/dist/ui/input/InputNumber.svelte.d.ts +20 -20
- package/dist/ui/input/InputOptionInParam.svelte +12 -10
- package/dist/ui/input/InputOptionInParam.svelte.d.ts +21 -17
- package/dist/ui/input/InputOptions.svelte +40 -34
- package/dist/ui/input/InputOptions.svelte.d.ts +19 -15
- package/dist/ui/input/InputPassword.svelte +22 -18
- package/dist/ui/input/InputPassword.svelte.d.ts +43 -35
- package/dist/ui/input/InputRadio.svelte +51 -46
- package/dist/ui/input/InputRadio.svelte.d.ts +53 -38
- package/dist/ui/input/InputRelation.svelte +129 -112
- package/dist/ui/input/InputRelation.svelte.d.ts +39 -53
- package/dist/ui/input/InputRelations.svelte +96 -90
- package/dist/ui/input/InputRelations.svelte.d.ts +35 -37
- package/dist/ui/input/InputSearch.svelte +14 -11
- package/dist/ui/input/InputSearch.svelte.d.ts +25 -21
- package/dist/ui/input/InputSelect.svelte +59 -46
- package/dist/ui/input/InputSelect.svelte.d.ts +23 -19
- package/dist/ui/input/InputText.svelte +29 -28
- package/dist/ui/input/InputText.svelte.d.ts +41 -28
- package/dist/ui/input/InputTextarea.svelte +20 -19
- package/dist/ui/input/InputTextarea.svelte.d.ts +20 -20
- package/dist/ui/input/InputTime.svelte +43 -36
- package/dist/ui/input/InputTime.svelte.d.ts +21 -36
- package/dist/ui/input/RelationAfter.svelte +13 -9
- package/dist/ui/input/RelationAfter.svelte.d.ts +24 -20
- package/dist/ui/input/SelectorList.svelte +16 -12
- package/dist/ui/input/SelectorList.svelte.d.ts +29 -20
- package/dist/ui/input/textRich/InputTextRich.svelte +63 -59
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +36 -38
- package/dist/ui/input/textRich/SuggesionList.svelte +13 -9
- package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +19 -15
- package/dist/ui/input/textRich/ToolMark.svelte +12 -9
- package/dist/ui/input/textRich/ToolMark.svelte.d.ts +22 -18
- package/dist/ui/input/textRich/ToolMarkColor.svelte +16 -12
- package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +21 -17
- package/dist/ui/input/textRich/ToolMarkLink.svelte +46 -38
- package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +18 -14
- package/dist/ui/input/textRich/ToolMenu.svelte +34 -19
- package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +30 -26
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +13 -9
- package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +18 -14
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +12 -7
- package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +20 -16
- package/dist/ui/input/textRich/ToolMenuNode.svelte +14 -10
- package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +18 -14
- package/dist/ui/input/textRich/ToolsBar.svelte +21 -14
- package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +19 -17
- package/dist/ui/input/textRich/suggestion.d.ts +0 -1
- package/dist/ui/login/Login.svelte +37 -31
- package/dist/ui/login/Login.svelte.d.ts +18 -14
- package/dist/ui/menu/ContextMenu.svelte +37 -31
- package/dist/ui/menu/ContextMenu.svelte.d.ts +38 -25
- package/dist/ui/menu/DropDown.svelte +92 -83
- package/dist/ui/menu/DropDown.svelte.d.ts +46 -33
- package/dist/ui/menu/DropDownMenu.svelte +25 -18
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +30 -19
- package/dist/ui/mode/ToggleMode.svelte +28 -16
- package/dist/ui/mode/ToggleMode.svelte.d.ts +34 -17
- package/dist/ui/pagination/Pagination.svelte +9 -8
- package/dist/ui/pagination/Pagination.svelte.d.ts +18 -14
- package/dist/ui/placeholder/Placeholder.svelte +4 -3
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +28 -17
- package/dist/ui/placeholder/PlaceholderImage.svelte +6 -4
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +28 -17
- package/dist/ui/range/RangePicker.svelte +76 -63
- package/dist/ui/range/RangePicker.svelte.d.ts +29 -24
- package/dist/ui/range/RangePickerButton.svelte +45 -40
- package/dist/ui/range/RangePickerButton.svelte.d.ts +21 -19
- package/dist/ui/table/Table.svelte +35 -28
- package/dist/ui/table/Table.svelte.d.ts +24 -19
- package/dist/ui/table/TableBody.svelte +18 -12
- package/dist/ui/table/TableBody.svelte.d.ts +20 -15
- package/dist/ui/table/TableCell.svelte +13 -10
- package/dist/ui/table/TableCell.svelte.d.ts +19 -14
- package/dist/ui/table/TableFieldsEdition.svelte +58 -52
- package/dist/ui/table/TableFieldsEdition.svelte.d.ts +20 -15
- package/dist/ui/table/TableHead.svelte +20 -21
- package/dist/ui/table/TableHead.svelte.d.ts +19 -14
- package/dist/ui/table/TableViewSelect.svelte +50 -37
- package/dist/ui/table/TableViewSelect.svelte.d.ts +27 -23
- package/dist/ui/table/cell/TableCellArray.svelte +5 -3
- package/dist/ui/table/cell/TableCellArray.svelte.d.ts +18 -14
- package/dist/ui/table/cell/TableCellBoolean.svelte +4 -3
- package/dist/ui/table/cell/TableCellBoolean.svelte.d.ts +18 -14
- package/dist/ui/table/cell/TableCellNumber.svelte +2 -1
- package/dist/ui/table/cell/TableCellNumber.svelte.d.ts +18 -14
- package/dist/ui/table/cell/TableCellString.svelte +5 -2
- package/dist/ui/table/cell/TableCellString.svelte.d.ts +19 -25
- package/dist/ui/table/field.d.ts +32 -40
- package/dist/ui/table/field.js +1 -1
- package/dist/ui/table/head/TableHeadBoolean.svelte +6 -3
- package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +18 -24
- package/dist/ui/table/head/TableHeadDate.svelte +61 -113
- package/dist/ui/table/head/TableHeadDate.svelte.d.ts +18 -24
- package/dist/ui/table/head/TableHeadDefault.svelte +5 -2
- package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +18 -24
- package/dist/ui/table/head/TableHeadNumber.svelte +67 -76
- package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +18 -24
- package/dist/ui/table/head/TableHeadSelect.svelte +47 -41
- package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +21 -27
- package/dist/ui/table/head/TableHeadString.svelte +14 -8
- package/dist/ui/table/head/TableHeadString.svelte.d.ts +18 -24
- package/dist/ui/tabs/Tabs.svelte +8 -5
- package/dist/ui/tabs/Tabs.svelte.d.ts +19 -15
- package/dist/ui/tabs/TabsIcon.svelte +31 -28
- package/dist/ui/tabs/TabsIcon.svelte.d.ts +21 -17
- package/dist/utils/eventEmitter.d.ts +4 -4
- package/dist/utils/tippy.d.ts +1 -1
- package/dist/validation/form.d.ts +0 -1
- package/dist/validation/zod.d.ts +96 -162
- package/dist/validation/zod.js +2 -4
- package/package.json +134 -138
- package/dist/ui/form/FormInput.svelte.d.ts +0 -152
- package/dist/ui/form/formInput.d.ts +0 -90
- package/dist/ui/slot/Slot.svelte +0 -35
- package/dist/ui/slot/Slot.svelte.d.ts +0 -22
- package/dist/ui/slot/Span.svelte +0 -4
- package/dist/ui/slot/Span.svelte.d.ts +0 -16
- package/dist/ui/slot/index.d.ts +0 -1
- package/dist/ui/slot/index.js +0 -1
- package/dist/ui/table/head/OrderButtons.svelte +0 -37
- package/dist/ui/table/head/OrderButtons.svelte.d.ts +0 -20
- package/dist/ui/table/head/index.d.ts +0 -19
|
@@ -1,70 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
+
default: any;
|
|
16
|
+
} ? Props extends Record<string, never> ? any : {
|
|
17
|
+
children?: any;
|
|
18
|
+
} : {});
|
|
19
|
+
declare const Drawer: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
title?: string;
|
|
21
|
+
/** Key used in url query params */ key: string;
|
|
22
|
+
class?: string;
|
|
23
|
+
maxWidth?: string;
|
|
24
|
+
classHeader?: string;
|
|
25
|
+
classBody?: string;
|
|
26
|
+
duration?: number;
|
|
27
|
+
noOverlay?: boolean;
|
|
28
|
+
transitionX?: number;
|
|
29
|
+
zIndex?: number;
|
|
30
|
+
open?: (value?: number, options?: {
|
|
31
|
+
replaceState?: boolean | undefined;
|
|
32
|
+
noScroll?: boolean | undefined;
|
|
33
|
+
keepFocus?: boolean | undefined;
|
|
34
|
+
invalidateAll?: boolean | undefined;
|
|
35
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
36
|
+
state?: App.PageState | undefined;
|
|
37
|
+
} | undefined) => Promise<void>;
|
|
38
|
+
close?: (options?: {
|
|
39
|
+
replaceState?: boolean | undefined;
|
|
40
|
+
noScroll?: boolean | undefined;
|
|
41
|
+
keepFocus?: boolean | undefined;
|
|
42
|
+
invalidateAll?: boolean | undefined;
|
|
43
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
44
|
+
state?: App.PageState | undefined;
|
|
45
|
+
} | undefined) => Promise<void>;
|
|
46
|
+
}, {
|
|
47
|
+
default: {
|
|
48
|
+
open: (value?: number, options?: {
|
|
15
49
|
replaceState?: boolean | undefined;
|
|
16
50
|
noScroll?: boolean | undefined;
|
|
17
51
|
keepFocus?: boolean | undefined;
|
|
18
52
|
invalidateAll?: boolean | undefined;
|
|
53
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
19
54
|
state?: App.PageState | undefined;
|
|
20
|
-
} | undefined) => Promise<void
|
|
21
|
-
close
|
|
55
|
+
} | undefined) => Promise<void>;
|
|
56
|
+
close: (options?: {
|
|
22
57
|
replaceState?: boolean | undefined;
|
|
23
58
|
noScroll?: boolean | undefined;
|
|
24
59
|
keepFocus?: boolean | undefined;
|
|
25
60
|
invalidateAll?: boolean | undefined;
|
|
61
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
26
62
|
state?: App.PageState | undefined;
|
|
27
|
-
} | undefined) => Promise<void
|
|
28
|
-
};
|
|
29
|
-
events: {
|
|
30
|
-
[evt: string]: CustomEvent<any>;
|
|
63
|
+
} | undefined) => Promise<void>;
|
|
31
64
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
}>, {
|
|
66
|
+
[evt: string]: CustomEvent<any>;
|
|
67
|
+
}, {
|
|
68
|
+
default: {
|
|
69
|
+
open: (value?: number, options?: {
|
|
70
|
+
replaceState?: boolean | undefined;
|
|
71
|
+
noScroll?: boolean | undefined;
|
|
72
|
+
keepFocus?: boolean | undefined;
|
|
73
|
+
invalidateAll?: boolean | undefined;
|
|
74
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
75
|
+
state?: App.PageState | undefined;
|
|
76
|
+
} | undefined) => Promise<void>;
|
|
77
|
+
close: (options?: {
|
|
78
|
+
replaceState?: boolean | undefined;
|
|
79
|
+
noScroll?: boolean | undefined;
|
|
80
|
+
keepFocus?: boolean | undefined;
|
|
81
|
+
invalidateAll?: boolean | undefined;
|
|
82
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
83
|
+
state?: App.PageState | undefined;
|
|
84
|
+
} | undefined) => Promise<void>;
|
|
49
85
|
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type DrawerEvents = typeof __propDef.events;
|
|
53
|
-
export type DrawerSlots = typeof __propDef.slots;
|
|
54
|
-
export default class Drawer extends SvelteComponent<DrawerProps, DrawerEvents, DrawerSlots> {
|
|
55
|
-
get open(): (value?: number, options?: {
|
|
86
|
+
}, {
|
|
87
|
+
open: (value?: number, options?: {
|
|
56
88
|
replaceState?: boolean | undefined;
|
|
57
89
|
noScroll?: boolean | undefined;
|
|
58
90
|
keepFocus?: boolean | undefined;
|
|
59
91
|
invalidateAll?: boolean | undefined;
|
|
92
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
60
93
|
state?: App.PageState | undefined;
|
|
61
94
|
} | undefined) => Promise<void>;
|
|
62
|
-
|
|
95
|
+
close: (options?: {
|
|
63
96
|
replaceState?: boolean | undefined;
|
|
64
97
|
noScroll?: boolean | undefined;
|
|
65
98
|
keepFocus?: boolean | undefined;
|
|
66
99
|
invalidateAll?: boolean | undefined;
|
|
100
|
+
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
67
101
|
state?: App.PageState | undefined;
|
|
68
102
|
} | undefined) => Promise<void>;
|
|
69
|
-
}
|
|
70
|
-
|
|
103
|
+
}, string>;
|
|
104
|
+
type Drawer = InstanceType<typeof Drawer>;
|
|
105
|
+
export default Drawer;
|
package/dist/ui/form/Form.svelte
CHANGED
|
@@ -1,92 +1,111 @@
|
|
|
1
|
-
<script context="module"
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
import type { z } from 'zod'
|
|
3
|
+
import type { FormDataInput } from './form.js'
|
|
4
|
+
</script>
|
|
2
5
|
|
|
3
6
|
<script
|
|
4
|
-
|
|
7
|
+
lang="ts"
|
|
5
8
|
generics="
|
|
6
9
|
Shape extends z.ZodRawShape,
|
|
7
10
|
ReturnData extends Record<string, unknown> = FormDataInput<Shape>,
|
|
8
11
|
Data extends FormDataInput<Shape> = FormDataInput<Shape>
|
|
9
12
|
"
|
|
10
|
-
>
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
export let
|
|
33
|
-
export let
|
|
34
|
-
export let
|
|
35
|
-
export let
|
|
36
|
-
let
|
|
37
|
-
export
|
|
38
|
-
let
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
13
|
+
>
|
|
14
|
+
import { createEventDispatcher, onMount } from 'svelte'
|
|
15
|
+
import { fade } from 'svelte/transition'
|
|
16
|
+
import { page } from '$app/stores'
|
|
17
|
+
import { contextContainer } from '../context.js'
|
|
18
|
+
import {
|
|
19
|
+
initData,
|
|
20
|
+
type FormField,
|
|
21
|
+
type FormSectionProps,
|
|
22
|
+
type BoolOrFunction,
|
|
23
|
+
type Nullable,
|
|
24
|
+
getFieldType,
|
|
25
|
+
useHandleInput
|
|
26
|
+
} from './form.js'
|
|
27
|
+
import ButtonDelete from '../button/ButtonDelete.svelte'
|
|
28
|
+
|
|
29
|
+
import { useForm, type UseFormOptions } from '../../validation/form.js'
|
|
30
|
+
import FormInput from './FormInput.svelte'
|
|
31
|
+
import FormSection from './FormSection.svelte'
|
|
32
|
+
|
|
33
|
+
let klass = ''
|
|
34
|
+
export { klass as class }
|
|
35
|
+
export let classSection = ''
|
|
36
|
+
export let classAction = ''
|
|
37
|
+
export let model: Shape | undefined = undefined
|
|
38
|
+
export let fields: FormField<Shape>[][] = []
|
|
39
|
+
export let sections: FormSectionProps<Shape>[] = [{}]
|
|
40
|
+
export let action = ''
|
|
41
|
+
export let actionCreate = '_create'
|
|
42
|
+
export let actionDelete = '_delete'
|
|
43
|
+
export let actionUpdate = '_update'
|
|
44
|
+
export let disabled = false
|
|
45
|
+
|
|
46
|
+
/** Ignore actionCreate, actionDelete and actionUpdate */
|
|
47
|
+
export let simpleAction = false
|
|
48
|
+
|
|
49
|
+
export let options: UseFormOptions<ReturnData> = {}
|
|
50
|
+
let dataInput: Nullable<Data> = initData<Shape, Data>(fields)
|
|
51
|
+
export { dataInput as data }
|
|
52
|
+
|
|
53
|
+
let data = dataInput
|
|
54
|
+
|
|
55
|
+
export function set<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) {
|
|
56
|
+
isDirty.set(true)
|
|
57
|
+
data[key] = value
|
|
58
|
+
}
|
|
59
|
+
export function update(updater: (currentData: Nullable<Data>) => Nullable<Data>) {
|
|
60
|
+
isDirty.set(true)
|
|
61
|
+
data = updater(data)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const dispatch = createEventDispatcher<{
|
|
65
|
+
success: { action: URL; data?: ReturnData }
|
|
66
|
+
created: ReturnData
|
|
67
|
+
updated: ReturnData
|
|
68
|
+
deleted: void
|
|
69
|
+
}>()
|
|
70
|
+
|
|
71
|
+
const { enhance, setError } = useForm<ReturnData>({
|
|
72
|
+
...options,
|
|
73
|
+
async onSuccess(url, data) {
|
|
74
|
+
if (options.onSuccess) await options.onSuccess(url, data)
|
|
75
|
+
dispatch('success', { action: url, data })
|
|
76
|
+
const actionPath = url.pathname + url.search
|
|
77
|
+
if (actionPath.includes(action + actionDelete)) dispatch('deleted')
|
|
78
|
+
if (!data) return
|
|
79
|
+
if (actionPath.includes(action + actionCreate)) dispatch('created', data)
|
|
80
|
+
if (actionPath.includes(action + actionUpdate)) dispatch('updated', data)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
const { handleInput, isDirty } = useHandleInput({ model, setError })
|
|
84
|
+
|
|
85
|
+
onMount(lookupValueFromParams)
|
|
86
|
+
$: $isDirty ? (dataInput = data) : (data = dataInput)
|
|
87
|
+
|
|
88
|
+
function lookupValueFromParams() {
|
|
89
|
+
fields.flat().forEach(({ key }) => {
|
|
90
|
+
if (data[key]) return
|
|
91
|
+
const value = $page.url.searchParams.get(key)
|
|
92
|
+
// TODO: fix data[key] type
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
if (value && key in data) data[key] = value
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const actionPadding = getActionPadding()
|
|
99
|
+
function getActionPadding(): string {
|
|
100
|
+
const container = contextContainer.get()
|
|
101
|
+
if (container === 'drawer') return 'bottom-0 -ml-8 -mr-4 pl-8 pr-4'
|
|
102
|
+
if (container === 'card') return 'bottom-0 -mx-2 sm:-mx-8 px-2 sm:px-8'
|
|
103
|
+
if (container === 'dialog') return '-bottom-4 -mx-4 px-4'
|
|
104
|
+
return 'bottom-0'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const getBoolean = (bool?: BoolOrFunction<Shape>) => (_data: Nullable<Data>) =>
|
|
108
|
+
typeof bool === 'boolean' || bool === undefined ? !!bool : !!bool(_data)
|
|
90
109
|
</script>
|
|
91
110
|
|
|
92
111
|
<form
|
|
@@ -97,12 +116,12 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
|
|
|
97
116
|
use:enhance
|
|
98
117
|
on:input={handleInput}
|
|
99
118
|
>
|
|
119
|
+
<slot />
|
|
120
|
+
|
|
100
121
|
{#if data?.id}
|
|
101
122
|
<input type="hidden" name="id" value={data.id} />
|
|
102
123
|
{/if}
|
|
103
124
|
|
|
104
|
-
<slot />
|
|
105
|
-
|
|
106
125
|
{#each fields as groupFields, groupIndex}
|
|
107
126
|
{@const section = sections[groupIndex] || {}}
|
|
108
127
|
{#if !getBoolean(section?.hide)(data)}
|
|
@@ -137,12 +156,12 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
|
|
|
137
156
|
sticky col-span-full mt-2 flex flex-row-reverse gap-2 border-t py-4 backdrop-blur-sm
|
|
138
157
|
"
|
|
139
158
|
>
|
|
140
|
-
<button class="btn btn-primary"> Valider </button>
|
|
141
|
-
<div class="grow"
|
|
159
|
+
<button class="btn btn-primary" {disabled}> Valider </button>
|
|
160
|
+
<div class="grow"></div>
|
|
142
161
|
{#if !simpleAction && data.id && actionDelete}
|
|
143
162
|
{@const formaction = `${action}${actionDelete}`}
|
|
144
163
|
<slot name="delete" {formaction}>
|
|
145
|
-
<ButtonDelete {formaction}>Supprimer</ButtonDelete>
|
|
164
|
+
<ButtonDelete {formaction} {disabled}>Supprimer</ButtonDelete>
|
|
146
165
|
</slot>
|
|
147
166
|
{/if}
|
|
148
167
|
</div>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { z } from 'zod';
|
|
3
2
|
import type { FormDataInput } from './form.js';
|
|
4
3
|
import { type FormField, type FormSectionProps, type Nullable } from './form.js';
|
|
5
4
|
import { type UseFormOptions } from '../../validation/form.js';
|
|
6
5
|
declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> {
|
|
7
6
|
props(): {
|
|
8
|
-
class?: string
|
|
9
|
-
classSection?: string
|
|
10
|
-
classAction?: string
|
|
7
|
+
class?: string;
|
|
8
|
+
classSection?: string;
|
|
9
|
+
classAction?: string;
|
|
11
10
|
model?: Shape | undefined;
|
|
12
11
|
fields?: FormField<Shape>[][] | undefined;
|
|
13
12
|
sections?: FormSectionProps<Shape>[] | undefined;
|
|
14
|
-
action?: string
|
|
15
|
-
actionCreate?: string
|
|
16
|
-
actionDelete?: string
|
|
17
|
-
actionUpdate?: string
|
|
18
|
-
|
|
13
|
+
action?: string;
|
|
14
|
+
actionCreate?: string;
|
|
15
|
+
actionDelete?: string;
|
|
16
|
+
actionUpdate?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Ignore actionCreate, actionDelete and actionUpdate */ simpleAction?: boolean;
|
|
19
19
|
options?: UseFormOptions<ReturnData> | undefined;
|
|
20
20
|
data?: Nullable<Data> | undefined;
|
|
21
21
|
set?: (<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void) | undefined;
|
|
@@ -38,12 +38,25 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends
|
|
|
38
38
|
formaction: any;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
bindings(): string;
|
|
42
|
+
exports(): {
|
|
43
|
+
set: <K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void;
|
|
44
|
+
update: (updater: (currentData: Nullable<Data>) => Nullable<Data>) => void;
|
|
45
|
+
};
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
interface $$IsomorphicComponent {
|
|
48
|
+
new <Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Shape, ReturnData, Data>['props']> & {
|
|
49
|
+
children?: any;
|
|
50
|
+
}>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Shape, ReturnData, Data>['props']>, ReturnType<__sveltets_Render<Shape, ReturnData, Data>['events']>, ReturnType<__sveltets_Render<Shape, ReturnData, Data>['slots']>> & {
|
|
51
|
+
$$bindings?: ReturnType<__sveltets_Render<Shape, ReturnData, Data>['bindings']>;
|
|
52
|
+
} & ReturnType<__sveltets_Render<Shape, ReturnData, Data>['exports']>;
|
|
53
|
+
<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>>(internal: unknown, props: ReturnType<__sveltets_Render<Shape, ReturnData, Data>['props']> & {
|
|
54
|
+
$$events?: ReturnType<__sveltets_Render<Shape, ReturnData, Data>['events']>;
|
|
55
|
+
$$slots?: ReturnType<__sveltets_Render<Shape, ReturnData, Data>['slots']>;
|
|
56
|
+
children?: any;
|
|
57
|
+
}): ReturnType<__sveltets_Render<Shape, ReturnData, Data>['exports']>;
|
|
58
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
|
|
48
59
|
}
|
|
49
|
-
|
|
60
|
+
declare const Form: $$IsomorphicComponent;
|
|
61
|
+
type Form<Shape extends z.ZodRawShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = InstanceType<typeof Form<Shape, ReturnData, Data>>;
|
|
62
|
+
export default Form;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
<script generics="InputType extends FormInputsType">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts" generics="InputType extends FormInputsType">
|
|
2
|
+
import { formInputs, type FormInputProps, type FormInputsType } from './formInput.js'
|
|
3
|
+
|
|
4
|
+
type $$Props = FormInputProps<InputType> & {
|
|
5
|
+
type: InputType
|
|
6
|
+
value: FormInputProps<InputType>['value']
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let inputType: InputType
|
|
10
|
+
export { inputType as type }
|
|
11
|
+
export let value: FormInputProps<InputType>['value']
|
|
12
|
+
$: component = formInputs[inputType] as any
|
|
7
13
|
</script>
|
|
8
14
|
|
|
9
15
|
<svelte:component this={component} bind:value {...$$restProps} />
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { slide } from 'svelte/transition'
|
|
3
|
+
import { mdiChevronRight } from '@mdi/js'
|
|
4
|
+
import { Icon } from '../icon/index.js'
|
|
5
|
+
type Props = { isActive?: boolean; class?: string; contentClass?: string }
|
|
6
|
+
type $$Props = Props &
|
|
7
|
+
({ isReducible: true; title: string } | { isReducible?: false; title?: string })
|
|
8
|
+
|
|
9
|
+
export let title = ''
|
|
10
|
+
export let isActive = false
|
|
11
|
+
export let isReducible = false
|
|
12
|
+
|
|
13
|
+
let klass = ''
|
|
14
|
+
export { klass as class }
|
|
15
|
+
export let contentClass = ''
|
|
16
|
+
|
|
17
|
+
function open() {
|
|
18
|
+
isActive = true
|
|
19
|
+
}
|
|
20
|
+
function toggle(event: Event) {
|
|
21
|
+
event.stopPropagation()
|
|
22
|
+
isActive = !isActive
|
|
23
|
+
}
|
|
17
24
|
</script>
|
|
18
25
|
|
|
19
26
|
<div>
|
|
@@ -44,7 +51,7 @@ function toggle(event) {
|
|
|
44
51
|
{/if}
|
|
45
52
|
</slot>
|
|
46
53
|
{#if isReducible}
|
|
47
|
-
<div class="grow"
|
|
54
|
+
<div class="grow"></div>
|
|
48
55
|
<button
|
|
49
56
|
type="button"
|
|
50
57
|
on:click={toggle}
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isReducible?: false | undefined;
|
|
12
|
-
title?: string | undefined;
|
|
13
|
-
});
|
|
14
|
-
events: {
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
16
11
|
};
|
|
17
|
-
|
|
18
|
-
title: {};
|
|
19
|
-
default: {};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type FormSectionProps = typeof __propDef.props;
|
|
23
|
-
export type FormSectionEvents = typeof __propDef.events;
|
|
24
|
-
export type FormSectionSlots = typeof __propDef.slots;
|
|
25
|
-
export default class FormSection extends SvelteComponent<FormSectionProps, FormSectionEvents, FormSectionSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
26
13
|
}
|
|
27
|
-
|
|
14
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
+
default: any;
|
|
16
|
+
} ? Props extends Record<string, never> ? any : {
|
|
17
|
+
children?: any;
|
|
18
|
+
} : {});
|
|
19
|
+
declare const FormSection: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
isActive?: boolean;
|
|
21
|
+
class?: string;
|
|
22
|
+
contentClass?: string;
|
|
23
|
+
} & ({
|
|
24
|
+
isReducible: true;
|
|
25
|
+
title: string;
|
|
26
|
+
} | {
|
|
27
|
+
isReducible?: false;
|
|
28
|
+
title?: string;
|
|
29
|
+
}), {
|
|
30
|
+
title: {};
|
|
31
|
+
default: {};
|
|
32
|
+
}>, {
|
|
33
|
+
[evt: string]: CustomEvent<any>;
|
|
34
|
+
}, {
|
|
35
|
+
title: {};
|
|
36
|
+
default: {};
|
|
37
|
+
}, {}, string>;
|
|
38
|
+
type FormSection = InstanceType<typeof FormSection>;
|
|
39
|
+
export default FormSection;
|