fuma 2.0.50 → 2.1.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.
- package/dist/action/index.d.ts +2 -5
- package/dist/action/index.js +2 -5
- package/dist/action/list/handlers.d.ts +6 -6
- package/dist/action/list/handlers.js +6 -5
- package/dist/action/list/index.d.ts +1 -1
- package/dist/action/list/index.js +11 -5
- package/dist/action/list/trigger.js +6 -2
- package/dist/action/list/utils.js +1 -1
- package/dist/action/tip.js +2 -2
- package/dist/command/command.svelte.d.ts +16 -0
- package/dist/command/command.svelte.js +68 -0
- package/dist/command/index.d.ts +1 -0
- package/dist/command/index.js +1 -0
- package/dist/data.d.ts +87 -0
- package/dist/data.js +51 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/input/InputBoolean.svelte +107 -0
- package/dist/input/InputBoolean.svelte.d.ts +12 -0
- package/dist/input/InputNumber.svelte +33 -0
- package/dist/input/InputNumber.svelte.d.ts +10 -0
- package/dist/input/InputRadio.svelte +56 -0
- package/dist/input/InputRadio.svelte.d.ts +11 -0
- package/dist/input/InputRange.svelte +30 -0
- package/dist/input/InputRange.svelte.d.ts +10 -0
- package/dist/input/InputRelation.svelte +119 -0
- package/dist/input/InputRelation.svelte.d.ts +39 -0
- package/dist/input/InputSelect.svelte +113 -0
- package/dist/input/InputSelect.svelte.d.ts +37 -0
- package/dist/input/InputSelectNative.svelte +56 -0
- package/dist/input/InputSelectNative.svelte.d.ts +12 -0
- package/dist/input/InputString.svelte +48 -0
- package/dist/input/InputString.svelte.d.ts +11 -0
- package/dist/input/InputTextarea.svelte +47 -0
- package/dist/input/InputTextarea.svelte.d.ts +11 -0
- package/dist/input/Issues.svelte +21 -0
- package/dist/input/Issues.svelte.d.ts +7 -0
- package/dist/input/index.d.ts +11 -0
- package/dist/input/index.js +10 -0
- package/dist/input/type.d.ts +5 -0
- package/dist/popover/Popover.svelte +50 -0
- package/dist/popover/index.d.ts +2 -0
- package/dist/popover/index.js +2 -0
- package/dist/popover/popover.svelte.d.ts +26 -0
- package/dist/popover/popover.svelte.js +101 -0
- package/dist/remote/useForm.d.ts +6 -0
- package/dist/remote/useForm.js +22 -0
- package/dist/search/Spans.svelte +15 -0
- package/dist/search/Spans.svelte.d.ts +7 -0
- package/dist/search/index.d.ts +2 -0
- package/dist/search/index.js +2 -0
- package/dist/search/search.js +96 -0
- package/dist/server/index.d.ts +0 -4
- package/dist/server/index.js +0 -4
- package/dist/server/parseQuery.js +1 -1
- package/dist/server/sse.js +4 -4
- package/dist/server/table.js +1 -1
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.js +1 -0
- package/dist/state/param.svelte.d.ts +17 -0
- package/dist/state/param.svelte.js +64 -0
- package/dist/ui/button/ButtonDelete.svelte +49 -28
- package/dist/ui/button/ButtonDelete.svelte.d.ts +12 -31
- package/dist/ui/button/index.d.ts +0 -1
- package/dist/ui/button/index.js +0 -1
- package/dist/ui/copy/ButtonCopy.svelte +43 -0
- package/dist/ui/copy/ButtonCopy.svelte.d.ts +17 -0
- package/dist/ui/copy/index.d.ts +2 -0
- package/dist/ui/copy/index.js +2 -0
- package/dist/ui/copy/useCopy.svelte.d.ts +10 -0
- package/dist/ui/copy/useCopy.svelte.js +36 -0
- package/dist/ui/dialog/Dialog.svelte +56 -26
- package/dist/ui/dialog/Dialog.svelte.d.ts +14 -35
- package/dist/ui/dialog/index.d.ts +0 -1
- package/dist/ui/dialog/index.js +0 -1
- package/dist/ui/drawer/Drawer.svelte +53 -45
- package/dist/ui/drawer/Drawer.svelte.d.ts +8 -63
- package/dist/ui/drawer/drawerFly.js +1 -1
- package/dist/ui/drawer/useLayer.svelte.d.ts +5 -0
- package/dist/ui/drawer/useLayer.svelte.js +33 -0
- package/dist/ui/index.d.ts +4 -12
- package/dist/ui/index.js +4 -12
- package/dist/ui/menu/ContextMenu.svelte +27 -26
- package/dist/ui/menu/ContextMenu.svelte.d.ts +9 -35
- package/dist/ui/menu/DropDown.svelte +44 -26
- package/dist/ui/menu/DropDown.svelte.d.ts +18 -43
- package/dist/ui/menu/DropDownMenu.svelte +51 -41
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +7 -29
- package/dist/ui/menu/dropdown.css +4 -4
- package/dist/ui/menu/index.d.ts +1 -1
- package/dist/ui/menu/index.js +2 -1
- package/dist/ui/mode/ToggleMode.svelte +25 -14
- package/dist/ui/mode/ToggleMode.svelte.d.ts +10 -35
- package/dist/ui/mode/index.d.ts +1 -1
- package/dist/ui/mode/index.js +1 -1
- package/dist/ui/mode/useMode.svelte.d.ts +8 -0
- package/dist/ui/mode/useMode.svelte.js +40 -0
- package/dist/ui/pagination/Pagination.svelte +18 -14
- package/dist/ui/pagination/Pagination.svelte.d.ts +4 -18
- package/dist/ui/range/RangePicker.svelte +3 -2
- package/dist/ui/range/RangePickerButton.svelte +49 -37
- package/dist/ui/range/RangePickerButton.svelte.d.ts +7 -21
- package/dist/ui/range/index.d.ts +1 -1
- package/dist/ui/range/index.js +1 -1
- package/dist/ui/table/Table.svelte +17 -24
- package/dist/ui/table/Table.svelte.d.ts +3 -3
- package/dist/ui/table/TableBody.svelte +1 -1
- package/dist/ui/table/TableBody.svelte.d.ts +1 -1
- package/dist/ui/table/TableFieldsEdition.svelte +90 -78
- package/dist/ui/table/TableFieldsEdition.svelte.d.ts +14 -13
- package/dist/ui/table/TableHead.svelte +1 -1
- package/dist/ui/table/TableViewSelect.svelte +71 -70
- package/dist/ui/table/TableViewSelect.svelte.d.ts +10 -23
- package/dist/ui/table/cell/TableCellArray.svelte +2 -2
- package/dist/ui/table/cell/TableCellBoolean.svelte +3 -4
- package/dist/ui/table/cell/index.d.ts +1 -1
- package/dist/ui/table/cell/index.js +1 -1
- package/dist/ui/table/field.d.ts +7 -7
- package/dist/ui/table/head/OrderButtons.svelte +18 -13
- package/dist/ui/table/head/OrderButtons.svelte.d.ts +11 -23
- package/dist/ui/table/head/TableHeadBoolean.svelte +3 -3
- package/dist/ui/table/head/TableHeadDate.svelte +40 -56
- package/dist/ui/table/head/TableHeadDate.svelte.d.ts +1 -1
- package/dist/ui/table/head/TableHeadDefault.svelte +2 -1
- package/dist/ui/table/head/TableHeadNumber.svelte +93 -108
- package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadSelect.svelte +55 -52
- package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +13 -10
- package/dist/ui/table/head/TableHeadString.svelte +28 -34
- package/dist/ui/table/head/index.d.ts +3 -3
- package/dist/ui/table/head/index.js +3 -3
- package/dist/ui/table/index.d.ts +5 -5
- package/dist/ui/table/index.js +4 -5
- package/dist/utils/csv.js +1 -1
- package/dist/utils/eventEmitter.d.ts +2 -2
- package/dist/utils/eventEmitter.js +18 -11
- package/dist/utils/index.d.ts +4 -6
- package/dist/utils/index.js +4 -6
- package/dist/utils/normalizePath.js +1 -1
- package/dist/utils/options.d.ts +6 -5
- package/dist/utils/options.js +3 -2
- package/dist/utils/tippy.d.ts +1 -1
- package/dist/utils/tippy.js +1 -1
- package/dist/validation/index.d.ts +0 -1
- package/dist/validation/index.js +0 -1
- package/dist/validation/zod.d.ts +12 -393
- package/dist/validation/zod.js +22 -82
- package/package.json +115 -134
- package/dist/action/heightScreen.d.ts +0 -10
- package/dist/action/heightScreen.js +0 -24
- package/dist/action/portal.d.ts +0 -3
- package/dist/action/portal.js +0 -9
- package/dist/action/selector.d.ts +0 -15
- package/dist/action/selector.js +0 -71
- package/dist/api/client.d.ts +0 -3
- package/dist/api/client.js +0 -24
- package/dist/api/config.d.ts +0 -46
- package/dist/api/config.js +0 -7
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.js +0 -3
- package/dist/api/server.d.ts +0 -11
- package/dist/api/server.js +0 -17
- package/dist/private/Meta.svelte +0 -16
- package/dist/private/Meta.svelte.d.ts +0 -30
- package/dist/private/api.d.ts +0 -61
- package/dist/private/api.js +0 -10
- package/dist/private/constant.d.ts +0 -14
- package/dist/private/constant.js +0 -6
- package/dist/private/model.d.ts +0 -70
- package/dist/private/model.js +0 -25
- package/dist/private/prisma.d.ts +0 -2
- package/dist/private/prisma.js +0 -2
- package/dist/private/store.d.ts +0 -1
- package/dist/private/store.js +0 -2
- package/dist/server/auth.d.ts +0 -12
- package/dist/server/auth.js +0 -15
- package/dist/server/formAction.d.ts +0 -13
- package/dist/server/formAction.js +0 -8
- package/dist/server/json.d.ts +0 -1
- package/dist/server/json.js +0 -16
- package/dist/server/parseFormData.d.ts +0 -10
- package/dist/server/parseFormData.js +0 -85
- package/dist/server/try.d.ts +0 -9
- package/dist/server/try.js +0 -41
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.js +0 -2
- package/dist/store/isSmallScreen.d.ts +0 -1
- package/dist/store/isSmallScreen.js +0 -14
- package/dist/store/param.d.ts +0 -22
- package/dist/store/param.js +0 -61
- package/dist/store/session.d.ts +0 -1
- package/dist/store/session.js +0 -13
- package/dist/ui/badge/Badge.svelte +0 -9
- package/dist/ui/badge/Badge.svelte.d.ts +0 -21
- package/dist/ui/badge/index.d.ts +0 -1
- package/dist/ui/badge/index.js +0 -1
- package/dist/ui/button/ButtonCopy.svelte +0 -59
- package/dist/ui/button/ButtonCopy.svelte.d.ts +0 -27
- package/dist/ui/card/Card.svelte +0 -43
- package/dist/ui/card/Card.svelte.d.ts +0 -41
- package/dist/ui/card/CardBasic.svelte +0 -15
- package/dist/ui/card/CardBasic.svelte.d.ts +0 -31
- package/dist/ui/card/CardCollapse.svelte +0 -71
- package/dist/ui/card/CardCollapse.svelte.d.ts +0 -39
- package/dist/ui/card/CardFullScreen.svelte +0 -31
- package/dist/ui/card/CardFullScreen.svelte.d.ts +0 -38
- package/dist/ui/card/CardLink.svelte +0 -22
- package/dist/ui/card/CardLink.svelte.d.ts +0 -31
- package/dist/ui/card/index.d.ts +0 -5
- package/dist/ui/card/index.js +0 -5
- package/dist/ui/context.d.ts +0 -6
- package/dist/ui/context.js +0 -12
- package/dist/ui/dialog/DialogConfirm.svelte +0 -24
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +0 -35
- package/dist/ui/drawer/layers.d.ts +0 -7
- package/dist/ui/drawer/layers.js +0 -68
- package/dist/ui/form/Form.svelte +0 -168
- package/dist/ui/form/Form.svelte.d.ts +0 -62
- package/dist/ui/form/FormInput.svelte +0 -15
- package/dist/ui/form/FormSection.svelte +0 -78
- package/dist/ui/form/FormSection.svelte.d.ts +0 -39
- package/dist/ui/form/form.d.ts +0 -37
- package/dist/ui/form/form.js +0 -57
- package/dist/ui/form/formInput.js +0 -33
- package/dist/ui/form/index.d.ts +0 -3
- package/dist/ui/form/index.js +0 -3
- package/dist/ui/icon/Icon.svelte +0 -53
- package/dist/ui/icon/Icon.svelte.d.ts +0 -29
- package/dist/ui/icon/index.d.ts +0 -1
- package/dist/ui/icon/index.js +0 -1
- package/dist/ui/input/FormControl.svelte +0 -77
- package/dist/ui/input/FormControl.svelte.d.ts +0 -34
- package/dist/ui/input/InputBoolean.svelte +0 -33
- package/dist/ui/input/InputBoolean.svelte.d.ts +0 -46
- package/dist/ui/input/InputCheckboxs.svelte +0 -71
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +0 -57
- package/dist/ui/input/InputCheckboxsMenu.svelte +0 -106
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +0 -59
- package/dist/ui/input/InputCheckboxsTree.svelte +0 -18
- package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +0 -25
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +0 -68
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +0 -27
- package/dist/ui/input/InputCombo.svelte +0 -99
- package/dist/ui/input/InputCombo.svelte.d.ts +0 -59
- package/dist/ui/input/InputDate.svelte +0 -47
- package/dist/ui/input/InputDate.svelte.d.ts +0 -46
- package/dist/ui/input/InputDateTime.svelte +0 -41
- package/dist/ui/input/InputDateTime.svelte.d.ts +0 -23
- package/dist/ui/input/InputImage.svelte +0 -116
- package/dist/ui/input/InputImage.svelte.d.ts +0 -48
- package/dist/ui/input/InputImagePreview.svelte +0 -60
- package/dist/ui/input/InputImagePreview.svelte.d.ts +0 -27
- package/dist/ui/input/InputNumber.svelte +0 -31
- package/dist/ui/input/InputNumber.svelte.d.ts +0 -23
- package/dist/ui/input/InputOptionInParam.svelte +0 -36
- package/dist/ui/input/InputOptionInParam.svelte.d.ts +0 -24
- package/dist/ui/input/InputOptions.svelte +0 -85
- package/dist/ui/input/InputOptions.svelte.d.ts +0 -21
- package/dist/ui/input/InputPassword.svelte +0 -25
- package/dist/ui/input/InputPassword.svelte.d.ts +0 -45
- package/dist/ui/input/InputRadio.svelte +0 -84
- package/dist/ui/input/InputRadio.svelte.d.ts +0 -56
- package/dist/ui/input/InputRelation.svelte +0 -171
- package/dist/ui/input/InputRelation.svelte.d.ts +0 -76
- package/dist/ui/input/InputRelations.svelte +0 -166
- package/dist/ui/input/InputRelations.svelte.d.ts +0 -55
- package/dist/ui/input/InputSearch.svelte +0 -59
- package/dist/ui/input/InputSearch.svelte.d.ts +0 -29
- package/dist/ui/input/InputSelect.svelte +0 -84
- package/dist/ui/input/InputSelect.svelte.d.ts +0 -29
- package/dist/ui/input/InputText.svelte +0 -46
- package/dist/ui/input/InputText.svelte.d.ts +0 -30
- package/dist/ui/input/InputTextarea.svelte +0 -23
- package/dist/ui/input/InputTextarea.svelte.d.ts +0 -23
- package/dist/ui/input/InputTime.svelte +0 -47
- package/dist/ui/input/InputTime.svelte.d.ts +0 -46
- package/dist/ui/input/RelationAfter.svelte +0 -34
- package/dist/ui/input/RelationAfter.svelte.d.ts +0 -26
- package/dist/ui/input/SelectorList.svelte +0 -50
- package/dist/ui/input/SelectorList.svelte.d.ts +0 -49
- package/dist/ui/input/action.d.ts +0 -13
- package/dist/ui/input/action.js +0 -56
- package/dist/ui/input/index.d.ts +0 -26
- package/dist/ui/input/index.js +0 -26
- package/dist/ui/input/textRich/InputTextRich.svelte +0 -72
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +0 -48
- package/dist/ui/input/textRich/SuggesionList.svelte +0 -25
- package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMark.svelte +0 -22
- package/dist/ui/input/textRich/ToolMark.svelte.d.ts +0 -25
- package/dist/ui/input/textRich/ToolMarkColor.svelte +0 -36
- package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMarkLink.svelte +0 -72
- package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenu.svelte +0 -66
- package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +0 -33
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +0 -50
- package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +0 -54
- package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +0 -23
- package/dist/ui/input/textRich/ToolMenuNode.svelte +0 -60
- package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +0 -21
- package/dist/ui/input/textRich/ToolsBar.svelte +0 -61
- package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +0 -24
- package/dist/ui/input/textRich/extensions.d.ts +0 -2
- package/dist/ui/input/textRich/extensions.js +0 -62
- package/dist/ui/input/textRich/indent.d.ts +0 -13
- package/dist/ui/input/textRich/indent.js +0 -112
- package/dist/ui/input/textRich/index.d.ts +0 -3
- package/dist/ui/input/textRich/index.js +0 -3
- package/dist/ui/input/textRich/suggestion.d.ts +0 -7
- package/dist/ui/input/textRich/suggestion.js +0 -55
- package/dist/ui/input/textRich/tiptapParser.d.ts +0 -4
- package/dist/ui/input/textRich/tiptapParser.js +0 -29
- package/dist/ui/input/types.d.ts +0 -15
- package/dist/ui/input/types.js +0 -1
- package/dist/ui/login/Login.svelte +0 -99
- package/dist/ui/login/Login.svelte.d.ts +0 -20
- package/dist/ui/login/index.d.ts +0 -1
- package/dist/ui/login/index.js +0 -1
- package/dist/ui/placeholder/Placeholder.svelte +0 -12
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +0 -30
- package/dist/ui/placeholder/PlaceholderImage.svelte +0 -16
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +0 -30
- package/dist/ui/placeholder/index.d.ts +0 -2
- package/dist/ui/placeholder/index.js +0 -2
- package/dist/ui/table/type.d.ts +0 -2
- package/dist/ui/tabs/Tabs.svelte +0 -32
- package/dist/ui/tabs/Tabs.svelte.d.ts +0 -22
- package/dist/ui/tabs/TabsIcon.svelte +0 -60
- package/dist/ui/tabs/TabsIcon.svelte.d.ts +0 -24
- package/dist/ui/tabs/index.d.ts +0 -8
- package/dist/ui/tabs/index.js +0 -2
- package/dist/utils/avatar.d.ts +0 -1
- package/dist/utils/avatar.js +0 -5
- package/dist/utils/component.d.ts +0 -6
- package/dist/utils/component.js +0 -3
- package/dist/validation/form.d.ts +0 -34
- package/dist/validation/form.js +0 -103
- /package/dist/{ui/table → input}/type.js +0 -0
package/dist/ui/form/Form.svelte
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
<script lang="ts" context="module">
|
|
2
|
-
import type { z } from 'zod'
|
|
3
|
-
import type { FormDataInput } from './form.js'
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
<script
|
|
7
|
-
lang="ts"
|
|
8
|
-
generics="
|
|
9
|
-
Shape extends z.core.$ZodShape,
|
|
10
|
-
ReturnData extends Record<string, unknown> = FormDataInput<Shape>,
|
|
11
|
-
Data extends FormDataInput<Shape> = FormDataInput<Shape>
|
|
12
|
-
"
|
|
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: Partial<Data> | null = initData<Shape, Data>(fields)
|
|
51
|
-
export { dataInput as data }
|
|
52
|
-
|
|
53
|
-
let data: Partial<Data> = dataInput || {}
|
|
54
|
-
|
|
55
|
-
export function set<K extends keyof Data>(key: K, value: Partial<Data>[K]) {
|
|
56
|
-
isDirty.set(true)
|
|
57
|
-
data[key] = value
|
|
58
|
-
}
|
|
59
|
-
export function update(updater: (currentData: Partial<Data>) => Partial<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)
|
|
109
|
-
</script>
|
|
110
|
-
|
|
111
|
-
<form
|
|
112
|
-
method="post"
|
|
113
|
-
action="{action}{simpleAction ? '' : data?.id ? actionUpdate : actionCreate}"
|
|
114
|
-
enctype="multipart/form-data"
|
|
115
|
-
class="{klass} flex flex-col gap-4"
|
|
116
|
-
use:enhance
|
|
117
|
-
on:input={handleInput}
|
|
118
|
-
>
|
|
119
|
-
{#if data?.id}
|
|
120
|
-
<input type="hidden" name="id" value={data.id} />
|
|
121
|
-
{/if}
|
|
122
|
-
|
|
123
|
-
<slot />
|
|
124
|
-
|
|
125
|
-
{#each fields as groupFields, groupIndex}
|
|
126
|
-
{@const section = sections[groupIndex] || {}}
|
|
127
|
-
{#if !getBoolean(section?.hide)(data)}
|
|
128
|
-
<div class="contents" in:fade|local={{ duration: 200 }}>
|
|
129
|
-
<FormSection {...section} class="{classSection} {section.class || ''} max-w-full">
|
|
130
|
-
<div class="grid grid-cols-4 gap-x-4 gap-y-2">
|
|
131
|
-
{#each groupFields as field (field.key)}
|
|
132
|
-
{#if !getBoolean(field.hide)(data)}
|
|
133
|
-
{@const inputType = getFieldType(field)}
|
|
134
|
-
<div
|
|
135
|
-
style={`grid-column: span ${field.colSpan || 2};`}
|
|
136
|
-
in:fade|local={{ duration: 200 }}
|
|
137
|
-
>
|
|
138
|
-
<FormInput
|
|
139
|
-
key={field.key}
|
|
140
|
-
type={inputType}
|
|
141
|
-
bind:value={data[field.key]}
|
|
142
|
-
{...field[inputType]}
|
|
143
|
-
/>
|
|
144
|
-
</div>
|
|
145
|
-
{/if}
|
|
146
|
-
{/each}
|
|
147
|
-
</div>
|
|
148
|
-
</FormSection>
|
|
149
|
-
</div>
|
|
150
|
-
{/if}
|
|
151
|
-
{/each}
|
|
152
|
-
|
|
153
|
-
<div
|
|
154
|
-
class="
|
|
155
|
-
{classAction} {actionPadding}
|
|
156
|
-
sticky col-span-full mt-2 flex flex-row-reverse gap-2 border-t py-4 backdrop-blur-sm
|
|
157
|
-
"
|
|
158
|
-
>
|
|
159
|
-
<button class="btn btn-primary" {disabled}> Valider </button>
|
|
160
|
-
<div class="grow"></div>
|
|
161
|
-
{#if !simpleAction && data?.id && actionDelete}
|
|
162
|
-
{@const formaction = `${action}${actionDelete}`}
|
|
163
|
-
<slot name="delete" {formaction}>
|
|
164
|
-
<ButtonDelete {formaction} {disabled}>Supprimer</ButtonDelete>
|
|
165
|
-
</slot>
|
|
166
|
-
{/if}
|
|
167
|
-
</div>
|
|
168
|
-
</form>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import type { FormDataInput } from './form.js';
|
|
3
|
-
import { type FormField, type FormSectionProps } from './form.js';
|
|
4
|
-
import { type UseFormOptions } from '../../validation/form.js';
|
|
5
|
-
declare class __sveltets_Render<Shape extends z.core.$ZodShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> {
|
|
6
|
-
props(): {
|
|
7
|
-
class?: string;
|
|
8
|
-
classSection?: string;
|
|
9
|
-
classAction?: string;
|
|
10
|
-
model?: Shape | undefined;
|
|
11
|
-
fields?: FormField<Shape>[][] | undefined;
|
|
12
|
-
sections?: FormSectionProps<Shape>[] | undefined;
|
|
13
|
-
action?: string;
|
|
14
|
-
actionCreate?: string;
|
|
15
|
-
actionDelete?: string;
|
|
16
|
-
actionUpdate?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
/** Ignore actionCreate, actionDelete and actionUpdate */ simpleAction?: boolean;
|
|
19
|
-
options?: UseFormOptions<ReturnData> | undefined;
|
|
20
|
-
data?: Partial<Data> | null | undefined;
|
|
21
|
-
set?: (<K extends keyof Data>(key: K, value: Partial<Data>[K]) => void) | undefined;
|
|
22
|
-
update?: ((updater: (currentData: Partial<Data>) => Partial<Data>) => void) | undefined;
|
|
23
|
-
};
|
|
24
|
-
events(): {
|
|
25
|
-
success: CustomEvent<{
|
|
26
|
-
action: URL;
|
|
27
|
-
data?: ReturnData | undefined;
|
|
28
|
-
}>;
|
|
29
|
-
created: CustomEvent<ReturnData>;
|
|
30
|
-
updated: CustomEvent<ReturnData>;
|
|
31
|
-
deleted: CustomEvent<void>;
|
|
32
|
-
} & {
|
|
33
|
-
[evt: string]: CustomEvent<any>;
|
|
34
|
-
};
|
|
35
|
-
slots(): {
|
|
36
|
-
default: {};
|
|
37
|
-
delete: {
|
|
38
|
-
formaction: any;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
bindings(): string;
|
|
42
|
-
exports(): {
|
|
43
|
-
set: <K extends keyof Data>(key: K, value: Partial<Data>[K]) => void;
|
|
44
|
-
update: (updater: (currentData: Partial<Data>) => Partial<Data>) => void;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
interface $$IsomorphicComponent {
|
|
48
|
-
new <Shape extends z.core.$ZodShape, 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.core.$ZodShape, 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']>;
|
|
59
|
-
}
|
|
60
|
-
declare const Form: $$IsomorphicComponent;
|
|
61
|
-
type Form<Shape extends z.core.$ZodShape, ReturnData extends Record<string, unknown> = FormDataInput<Shape>, Data extends FormDataInput<Shape> = FormDataInput<Shape>> = InstanceType<typeof Form<Shape, ReturnData, Data>>;
|
|
62
|
-
export default Form;
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<svelte:component this={component} bind:value {...$$restProps} />
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
}
|
|
24
|
-
</script>
|
|
25
|
-
|
|
26
|
-
<div>
|
|
27
|
-
{#if isReducible && isActive}
|
|
28
|
-
<div class="h-4" transition:slide></div>
|
|
29
|
-
{/if}
|
|
30
|
-
|
|
31
|
-
<section class="{klass} flex flex-col">
|
|
32
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
33
|
-
<div
|
|
34
|
-
on:click={open}
|
|
35
|
-
on:keyup={open}
|
|
36
|
-
class="flex items-center gap-2 py-2
|
|
37
|
-
{isReducible && !isActive ? 'cursor-pointer rounded-lg hover:bg-base-200/40' : ''}
|
|
38
|
-
"
|
|
39
|
-
class:rounded-lg={!isActive}
|
|
40
|
-
class:border={isReducible && !isActive}
|
|
41
|
-
>
|
|
42
|
-
<slot name="title">
|
|
43
|
-
{#if isReducible || title}
|
|
44
|
-
<h2
|
|
45
|
-
class="title-md origin-left pl-1 transition-transform"
|
|
46
|
-
class:translate-x-4={isReducible && !isActive}
|
|
47
|
-
class:scale-105={isReducible && isActive}
|
|
48
|
-
>
|
|
49
|
-
{title}
|
|
50
|
-
</h2>
|
|
51
|
-
{/if}
|
|
52
|
-
</slot>
|
|
53
|
-
{#if isReducible}
|
|
54
|
-
<div class="grow"></div>
|
|
55
|
-
<button
|
|
56
|
-
type="button"
|
|
57
|
-
on:click={toggle}
|
|
58
|
-
class="btn btn-square btn-ghost btn-sm transition-transform"
|
|
59
|
-
class:-translate-x-2={isReducible && !isActive}
|
|
60
|
-
>
|
|
61
|
-
<Icon path={mdiChevronRight} class="transition-transform {isActive ? 'rotate-90' : ''}" />
|
|
62
|
-
</button>
|
|
63
|
-
{/if}
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
{#if !isReducible || isActive}
|
|
67
|
-
<div transition:slide|local={{ duration: 200 }} class="{contentClass} grow py-4">
|
|
68
|
-
<slot />
|
|
69
|
-
</div>
|
|
70
|
-
{:else}
|
|
71
|
-
<div class="hidden"><slot /></div>
|
|
72
|
-
{/if}
|
|
73
|
-
</section>
|
|
74
|
-
|
|
75
|
-
{#if isReducible && isActive}
|
|
76
|
-
<div class="h-8" transition:slide></div>
|
|
77
|
-
{/if}
|
|
78
|
-
</div>
|
|
@@ -1,39 +0,0 @@
|
|
|
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 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;
|
package/dist/ui/form/form.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import type { ComponentProps } from 'svelte';
|
|
3
|
-
import { type Writable } from 'svelte/store';
|
|
4
|
-
import type { FormEventHandler } from 'svelte/elements';
|
|
5
|
-
import { type FormInputsProps, type FormInputsType } from './formInput.js';
|
|
6
|
-
import type FormSection from './FormSection.svelte';
|
|
7
|
-
type Shape = z.ZodRawShape;
|
|
8
|
-
type PickOne<T> = {
|
|
9
|
-
[P in keyof T]: Record<P, T[P]> & Partial<Record<Exclude<keyof T, P>, undefined>>;
|
|
10
|
-
}[keyof T];
|
|
11
|
-
export type Nullable<T> = {
|
|
12
|
-
[P in keyof T]?: T[P] | null;
|
|
13
|
-
};
|
|
14
|
-
export type BoolOrFunction<S extends Shape> = boolean | ((data: Nullable<FormDataInput<S>>) => unknown);
|
|
15
|
-
export type FormDataInput<S extends Shape> = z.input<z.core.$ZodObject<S>>;
|
|
16
|
-
export type FormField<S extends Shape> = {
|
|
17
|
-
key: string & keyof S;
|
|
18
|
-
/** number col used by field */
|
|
19
|
-
colSpan?: number;
|
|
20
|
-
/** hide field if true */
|
|
21
|
-
hide?: BoolOrFunction<S>;
|
|
22
|
-
} & PickOne<FormInputsProps>;
|
|
23
|
-
export type FormSectionProps<S extends Shape> = ComponentProps<FormSection> & {
|
|
24
|
-
/** hide group if true */
|
|
25
|
-
hide?: BoolOrFunction<S>;
|
|
26
|
-
};
|
|
27
|
-
export declare function initData<S extends Shape, Data extends FormDataInput<S> = FormDataInput<S>>(fields: FormField<S>[][]): Data;
|
|
28
|
-
export declare function getFieldType<S extends Shape>(field: FormField<S>): FormInputsType;
|
|
29
|
-
type HandleInputOptions<S extends Shape> = {
|
|
30
|
-
model?: S;
|
|
31
|
-
setError: (key: string, value: string) => void;
|
|
32
|
-
};
|
|
33
|
-
export declare function useHandleInput<S extends Shape>({ model, setError }: HandleInputOptions<S>): {
|
|
34
|
-
isDirty: Writable<boolean>;
|
|
35
|
-
handleInput: FormEventHandler<HTMLFormElement>;
|
|
36
|
-
};
|
|
37
|
-
export {};
|
package/dist/ui/form/form.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import debounce from 'debounce';
|
|
2
|
-
import { writable } from 'svelte/store';
|
|
3
|
-
import { formInputsType } from './formInput.js';
|
|
4
|
-
export function initData(fields) {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
return fields.flat().reduce((acc, cur) => {
|
|
7
|
-
const inputType = getFieldType(cur);
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
return { ...acc, [cur.key]: cur[inputType]?.value };
|
|
10
|
-
}, {});
|
|
11
|
-
}
|
|
12
|
-
export function getFieldType(field) {
|
|
13
|
-
const inputType = formInputsType.find((t) => field[t]);
|
|
14
|
-
if (!inputType)
|
|
15
|
-
return 'text';
|
|
16
|
-
return inputType;
|
|
17
|
-
}
|
|
18
|
-
export function useHandleInput({ model, setError }) {
|
|
19
|
-
const isDirty = writable(false);
|
|
20
|
-
const setErrorDebounced = debounce(setError, 1500);
|
|
21
|
-
return {
|
|
22
|
-
isDirty,
|
|
23
|
-
handleInput: ({ target }) => {
|
|
24
|
-
if (!target)
|
|
25
|
-
return;
|
|
26
|
-
if (!model)
|
|
27
|
-
return;
|
|
28
|
-
const { name } = target;
|
|
29
|
-
const value = getTypedValue(target);
|
|
30
|
-
if (value === undefined)
|
|
31
|
-
return;
|
|
32
|
-
if (name === undefined)
|
|
33
|
-
return;
|
|
34
|
-
if (!model[name])
|
|
35
|
-
return;
|
|
36
|
-
isDirty.set(true);
|
|
37
|
-
const res = model[name].safeParse(value);
|
|
38
|
-
if (res.success) {
|
|
39
|
-
setErrorDebounced.clear();
|
|
40
|
-
setError(name, '');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
setErrorDebounced(name, res.error.issues[0].message);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function getTypedValue(target) {
|
|
49
|
-
const { type, value, valueAsNumber, valueAsDate, checked } = target;
|
|
50
|
-
const typeMapValue = {
|
|
51
|
-
number: valueAsNumber,
|
|
52
|
-
date: valueAsDate,
|
|
53
|
-
text: value,
|
|
54
|
-
checkbox: checked
|
|
55
|
-
};
|
|
56
|
-
return typeMapValue[type] ?? value;
|
|
57
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import InputText from '../input/InputText.svelte';
|
|
2
|
-
import InputTextarea from '../input/InputTextarea.svelte';
|
|
3
|
-
import InputBoolean from '../input/InputBoolean.svelte';
|
|
4
|
-
import InputDate from '../input/InputDate.svelte';
|
|
5
|
-
import InputDatetime from '../input/InputDateTime.svelte';
|
|
6
|
-
import InputNumber from '../input/InputNumber.svelte';
|
|
7
|
-
import InputPassword from '../input/InputPassword.svelte';
|
|
8
|
-
import InputRadio from '../input/InputRadio.svelte';
|
|
9
|
-
import InputSelect from '../input/InputSelect.svelte';
|
|
10
|
-
import InputRelation from '../input/InputRelation.svelte';
|
|
11
|
-
import InputRelations from '../input/InputRelations.svelte';
|
|
12
|
-
import InputTextRich from '../input/textRich/InputTextRich.svelte';
|
|
13
|
-
export const formInputs = {
|
|
14
|
-
text: InputText,
|
|
15
|
-
textarea: InputTextarea,
|
|
16
|
-
textrich: InputTextRich,
|
|
17
|
-
boolean: InputBoolean,
|
|
18
|
-
date: InputDate,
|
|
19
|
-
datetime: InputDatetime,
|
|
20
|
-
number: InputNumber,
|
|
21
|
-
password: InputPassword,
|
|
22
|
-
select: InputSelect,
|
|
23
|
-
radio: InputRadio,
|
|
24
|
-
relation: InputRelation,
|
|
25
|
-
relations: InputRelations
|
|
26
|
-
};
|
|
27
|
-
export const formInputsType = Object.keys(formInputs);
|
|
28
|
-
export function relationProps(props) {
|
|
29
|
-
return props;
|
|
30
|
-
}
|
|
31
|
-
export function relationsProps(props) {
|
|
32
|
-
return props;
|
|
33
|
-
}
|
package/dist/ui/form/index.d.ts
DELETED
package/dist/ui/form/index.js
DELETED
package/dist/ui/icon/Icon.svelte
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { tippy, type TippyProps, type TippyInstance } from '../../utils/tippy.js'
|
|
3
|
-
import { onMount, type Snippet } from 'svelte'
|
|
4
|
-
|
|
5
|
-
export let path: string | Snippet
|
|
6
|
-
export let title = ''
|
|
7
|
-
export let size = 22
|
|
8
|
-
let klass = ''
|
|
9
|
-
export { klass as class }
|
|
10
|
-
export let style = ''
|
|
11
|
-
export let classSVG = ''
|
|
12
|
-
export let tippyProps: Partial<TippyProps> = {}
|
|
13
|
-
export let disableTitlePropagation = false
|
|
14
|
-
const viewWidth = 24
|
|
15
|
-
const viewHeight = 24
|
|
16
|
-
|
|
17
|
-
let icon: HTMLElement
|
|
18
|
-
|
|
19
|
-
let tip: TippyInstance | null = null
|
|
20
|
-
$: tip?.setContent(title)
|
|
21
|
-
|
|
22
|
-
onMount(() => {
|
|
23
|
-
if (!title) return
|
|
24
|
-
const parent = icon.parentElement
|
|
25
|
-
const isButton = parent?.tagName === 'BUTTON' || parent?.tagName === 'A'
|
|
26
|
-
const target = parent && isButton && !disableTitlePropagation ? parent : icon
|
|
27
|
-
tip = tippy(target || icon, {
|
|
28
|
-
content: title,
|
|
29
|
-
trigger: 'mouseenter',
|
|
30
|
-
...tippyProps
|
|
31
|
-
})
|
|
32
|
-
return () => {
|
|
33
|
-
tip?.destroy()
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
</script>
|
|
37
|
-
|
|
38
|
-
<i bind:this={icon} class="fill-base-content grid place-content-center {klass}" {style}>
|
|
39
|
-
{#if typeof path === 'string'}
|
|
40
|
-
<svg
|
|
41
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
42
|
-
width={size}
|
|
43
|
-
height={size}
|
|
44
|
-
viewBox={`0 0 ${viewWidth} ${viewHeight}`}
|
|
45
|
-
style="display: inline-block;"
|
|
46
|
-
class={classSVG}
|
|
47
|
-
>
|
|
48
|
-
<path d={path} />
|
|
49
|
-
</svg>
|
|
50
|
-
{:else}
|
|
51
|
-
{@render path()}
|
|
52
|
-
{/if}
|
|
53
|
-
</i>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type TippyProps } from '../../utils/tippy.js';
|
|
2
|
-
import { type Snippet } from 'svelte';
|
|
3
|
-
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> {
|
|
4
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
-
$$bindings?: Bindings;
|
|
6
|
-
} & Exports;
|
|
7
|
-
(internal: unknown, props: Props & {
|
|
8
|
-
$$events?: Events;
|
|
9
|
-
$$slots?: Slots;
|
|
10
|
-
}): Exports & {
|
|
11
|
-
$set?: any;
|
|
12
|
-
$on?: any;
|
|
13
|
-
};
|
|
14
|
-
z_$$bindings?: Bindings;
|
|
15
|
-
}
|
|
16
|
-
declare const Icon: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
-
path: string | Snippet;
|
|
18
|
-
title?: string;
|
|
19
|
-
size?: number;
|
|
20
|
-
class?: string;
|
|
21
|
-
style?: string;
|
|
22
|
-
classSVG?: string;
|
|
23
|
-
tippyProps?: Partial<TippyProps>;
|
|
24
|
-
disableTitlePropagation?: boolean;
|
|
25
|
-
}, {
|
|
26
|
-
[evt: string]: CustomEvent<any>;
|
|
27
|
-
}, {}, {}, string>;
|
|
28
|
-
type Icon = InstanceType<typeof Icon>;
|
|
29
|
-
export default Icon;
|
package/dist/ui/icon/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Icon } from './Icon.svelte';
|
package/dist/ui/icon/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Icon } from './Icon.svelte';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { slide } from 'svelte/transition'
|
|
3
|
-
import { onMount, type Snippet } from 'svelte'
|
|
4
|
-
import { formContext } from '../../validation/form.js'
|
|
5
|
-
|
|
6
|
-
let klass = ''
|
|
7
|
-
export { klass as class }
|
|
8
|
-
export let classLabel = ''
|
|
9
|
-
export let key = ''
|
|
10
|
-
export let label: Snippet | string = ''
|
|
11
|
-
export let labelAppend: Snippet | null = null
|
|
12
|
-
export let error = ''
|
|
13
|
-
export let hint = ''
|
|
14
|
-
export let prefix: string | number = ''
|
|
15
|
-
export let prefixFor: string | number = ''
|
|
16
|
-
export let enhanceDisabled = false
|
|
17
|
-
export let labelPosition: LabelPosition = 'top'
|
|
18
|
-
export let children: Snippet<[{ key: string }]> | undefined = undefined
|
|
19
|
-
|
|
20
|
-
type LabelPosition = 'top' | 'left' | 'right'
|
|
21
|
-
|
|
22
|
-
$: _key = prefix && key ? `${prefix}_${key}` : key || ''
|
|
23
|
-
|
|
24
|
-
if (!enhanceDisabled) {
|
|
25
|
-
const { setError } = formContext.get()
|
|
26
|
-
setError[key] = (err) => (error = err)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let formControl: HTMLDivElement
|
|
30
|
-
onMount(() => {
|
|
31
|
-
const input = formControl.querySelector('input, textarea')
|
|
32
|
-
if (!input) return
|
|
33
|
-
const handleInput = () => (error = '')
|
|
34
|
-
input.addEventListener('input', handleInput)
|
|
35
|
-
return () => {
|
|
36
|
-
input.removeEventListener('input', handleInput)
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<div class="form-control {klass}" bind:this={formControl}>
|
|
42
|
-
<div
|
|
43
|
-
class:contents={labelPosition === 'top'}
|
|
44
|
-
class:flex={labelPosition !== 'top'}
|
|
45
|
-
class:items-center={labelPosition !== 'top'}
|
|
46
|
-
class:gap-2={labelPosition !== 'top'}
|
|
47
|
-
class:flex-row-reverse={labelPosition === 'right'}
|
|
48
|
-
class:justify-end={labelPosition === 'right'}
|
|
49
|
-
>
|
|
50
|
-
{#if label}
|
|
51
|
-
<label for="{prefixFor}{_key}" class="label block cursor-pointer {classLabel}">
|
|
52
|
-
<span class="py-1.5 text-xs font-extrabold">
|
|
53
|
-
{#if typeof label === 'string'}
|
|
54
|
-
{label}
|
|
55
|
-
{:else}
|
|
56
|
-
{@render label()}
|
|
57
|
-
{/if}
|
|
58
|
-
</span>
|
|
59
|
-
{#if labelAppend}
|
|
60
|
-
{@render labelAppend()}
|
|
61
|
-
{/if}
|
|
62
|
-
</label>
|
|
63
|
-
{/if}
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
{@render children?.({ key: _key })}
|
|
67
|
-
|
|
68
|
-
{#if error}
|
|
69
|
-
<div transition:slide>
|
|
70
|
-
<span class="text-warning text-xs">{error}</span>
|
|
71
|
-
</div>
|
|
72
|
-
{:else if hint}
|
|
73
|
-
<div transition:slide>
|
|
74
|
-
<span class="text-neutral text-xs">{hint}</span>
|
|
75
|
-
</div>
|
|
76
|
-
{/if}
|
|
77
|
-
</div>
|