fuma 2.0.49 → 2.1.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/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/input/type.js +1 -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 +18 -0
- package/dist/state/param.svelte.js +66 -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 +15 -21
- package/dist/ui/table/Table.svelte.d.ts +1 -1
- 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 +69 -69
- package/dist/ui/table/TableViewSelect.svelte.d.ts +10 -23
- package/dist/ui/table/cell/TableCellArray.svelte +1 -1
- 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/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 +41 -53
- 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 +94 -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 +111 -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/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
|
@@ -1,21 +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
|
-
declare const InputOptions: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
key: string;
|
|
16
|
-
value?: string | undefined | null;
|
|
17
|
-
}, {
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
}, {}, {}, string>;
|
|
20
|
-
type InputOptions = InstanceType<typeof InputOptions>;
|
|
21
|
-
export default InputOptions;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { FormControl, type InputProps } from './index.js'
|
|
3
|
-
|
|
4
|
-
type $$Props = InputProps & { autocomplete?: string }
|
|
5
|
-
$: ({ input, value: _value, ...props } = $$props as $$Props)
|
|
6
|
-
export let value = _value
|
|
7
|
-
export let autocomplete = 'current-password'
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<FormControl {...props}>
|
|
11
|
-
{#snippet children({ key })}
|
|
12
|
-
<input
|
|
13
|
-
bind:value
|
|
14
|
-
on:input
|
|
15
|
-
on:focus
|
|
16
|
-
on:blur
|
|
17
|
-
type="password"
|
|
18
|
-
name={key}
|
|
19
|
-
id={key}
|
|
20
|
-
class="input input-bordered"
|
|
21
|
-
{autocomplete}
|
|
22
|
-
{...input}
|
|
23
|
-
/>
|
|
24
|
-
{/snippet}
|
|
25
|
-
</FormControl>
|
|
@@ -1,45 +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
|
-
declare const InputPassword: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
class?: string;
|
|
16
|
-
classLabel?: string;
|
|
17
|
-
key?: string;
|
|
18
|
-
label?: import("svelte").Snippet | string;
|
|
19
|
-
labelAppend?: import("svelte").Snippet | null;
|
|
20
|
-
error?: string;
|
|
21
|
-
hint?: string;
|
|
22
|
-
prefix?: string | number;
|
|
23
|
-
prefixFor?: string | number;
|
|
24
|
-
enhanceDisabled?: boolean;
|
|
25
|
-
labelPosition?: "top" | "left" | "right";
|
|
26
|
-
children?: import("svelte").Snippet<[{
|
|
27
|
-
key: string;
|
|
28
|
-
}]> | undefined;
|
|
29
|
-
} & {
|
|
30
|
-
input?: import("svelte/elements").HTMLInputAttributes;
|
|
31
|
-
inputElement?: HTMLInputElement;
|
|
32
|
-
classWrapper?: string;
|
|
33
|
-
value?: string | null | undefined;
|
|
34
|
-
bindWithParams?: boolean;
|
|
35
|
-
} & {
|
|
36
|
-
autocomplete?: string;
|
|
37
|
-
}, {
|
|
38
|
-
input: Event;
|
|
39
|
-
focus: FocusEvent;
|
|
40
|
-
blur: FocusEvent;
|
|
41
|
-
} & {
|
|
42
|
-
[evt: string]: CustomEvent<any>;
|
|
43
|
-
}, {}, {}, string>;
|
|
44
|
-
type InputPassword = InstanceType<typeof InputPassword>;
|
|
45
|
-
export default InputPassword;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from 'svelte'
|
|
3
|
-
import { slide } from 'svelte/transition'
|
|
4
|
-
|
|
5
|
-
import { type Options, parseOptions } from '../../utils/options.js'
|
|
6
|
-
import { formContext } from '../../validation/form.js'
|
|
7
|
-
import { FormControl, bindValueWithParams, type InputProps } from './index.js'
|
|
8
|
-
|
|
9
|
-
type $$Props = InputProps & { options: Options; optionsClass?: string }
|
|
10
|
-
$: ({
|
|
11
|
-
input,
|
|
12
|
-
value: _value,
|
|
13
|
-
error: _error,
|
|
14
|
-
options,
|
|
15
|
-
optionsClass = '',
|
|
16
|
-
hint,
|
|
17
|
-
class: klass,
|
|
18
|
-
...props
|
|
19
|
-
} = $$props as $$Props)
|
|
20
|
-
export let value = _value
|
|
21
|
-
export let error = _error
|
|
22
|
-
|
|
23
|
-
$: _options = parseOptions(options)
|
|
24
|
-
|
|
25
|
-
let formControl: HTMLDivElement
|
|
26
|
-
const { setError } = formContext.get()
|
|
27
|
-
onMount(() => {
|
|
28
|
-
if (props.key) setError[props.key] = (err) => (error = err)
|
|
29
|
-
|
|
30
|
-
const inputs = formControl.querySelectorAll('input')
|
|
31
|
-
const handleInput = () => (error = '')
|
|
32
|
-
inputs.forEach((input) => input.addEventListener('input', handleInput))
|
|
33
|
-
return () => {
|
|
34
|
-
inputs.forEach((input) => input.removeEventListener('input', handleInput))
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<div class={klass} bind:this={formControl}>
|
|
40
|
-
{#if props.label}
|
|
41
|
-
<div class="label">
|
|
42
|
-
<span class="label-text">{props.label}</span>
|
|
43
|
-
<slot name="label_append" />
|
|
44
|
-
</div>
|
|
45
|
-
{/if}
|
|
46
|
-
|
|
47
|
-
<div class={optionsClass}>
|
|
48
|
-
{#each _options as option}
|
|
49
|
-
<FormControl
|
|
50
|
-
{...props}
|
|
51
|
-
enhanceDisabled
|
|
52
|
-
label={option.label}
|
|
53
|
-
prefixFor={option.value}
|
|
54
|
-
class="flex-row-reverse items-center justify-end gap-2"
|
|
55
|
-
>
|
|
56
|
-
{#snippet children({ key })}
|
|
57
|
-
<input
|
|
58
|
-
use:bindValueWithParams={{ bindEnable: props.bindWithParams }}
|
|
59
|
-
bind:group={value}
|
|
60
|
-
on:input
|
|
61
|
-
on:focus
|
|
62
|
-
on:blur
|
|
63
|
-
value={option.value}
|
|
64
|
-
type="radio"
|
|
65
|
-
name={key}
|
|
66
|
-
id="{option.value}{key}"
|
|
67
|
-
class="radio"
|
|
68
|
-
{...input}
|
|
69
|
-
/>
|
|
70
|
-
{/snippet}
|
|
71
|
-
</FormControl>
|
|
72
|
-
{/each}
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
{#if error}
|
|
76
|
-
<div class="label" transition:slide>
|
|
77
|
-
<span class="label-text-alt text-warning">{error}</span>
|
|
78
|
-
</div>
|
|
79
|
-
{:else if hint}
|
|
80
|
-
<div class="label" transition:slide>
|
|
81
|
-
<span class="label-text-alt text-info">{hint}</span>
|
|
82
|
-
</div>
|
|
83
|
-
{/if}
|
|
84
|
-
</div>
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Options } from '../../utils/options.js';
|
|
2
|
-
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> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
16
|
-
default: any;
|
|
17
|
-
} ? Props extends Record<string, never> ? any : {
|
|
18
|
-
children?: any;
|
|
19
|
-
} : {});
|
|
20
|
-
declare const InputRadio: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
21
|
-
class?: string;
|
|
22
|
-
classLabel?: string;
|
|
23
|
-
key?: string;
|
|
24
|
-
label?: import("svelte").Snippet | string;
|
|
25
|
-
labelAppend?: import("svelte").Snippet | null;
|
|
26
|
-
error?: string;
|
|
27
|
-
hint?: string;
|
|
28
|
-
prefix?: string | number;
|
|
29
|
-
prefixFor?: string | number;
|
|
30
|
-
enhanceDisabled?: boolean;
|
|
31
|
-
labelPosition?: "top" | "left" | "right";
|
|
32
|
-
children?: import("svelte").Snippet<[{
|
|
33
|
-
key: string;
|
|
34
|
-
}]> | undefined;
|
|
35
|
-
} & {
|
|
36
|
-
input?: import("svelte/elements").HTMLInputAttributes;
|
|
37
|
-
inputElement?: HTMLInputElement;
|
|
38
|
-
classWrapper?: string;
|
|
39
|
-
value?: string | null | undefined;
|
|
40
|
-
bindWithParams?: boolean;
|
|
41
|
-
} & {
|
|
42
|
-
options: Options;
|
|
43
|
-
optionsClass?: string;
|
|
44
|
-
}, {
|
|
45
|
-
label_append: {};
|
|
46
|
-
}>, {
|
|
47
|
-
input: Event;
|
|
48
|
-
focus: FocusEvent;
|
|
49
|
-
blur: FocusEvent;
|
|
50
|
-
} & {
|
|
51
|
-
[evt: string]: CustomEvent<any>;
|
|
52
|
-
}, {
|
|
53
|
-
label_append: {};
|
|
54
|
-
}, {}, string>;
|
|
55
|
-
type InputRadio = InstanceType<typeof InputRadio>;
|
|
56
|
-
export default InputRadio;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="RelationItem extends {id: string | number}">
|
|
2
|
-
import {
|
|
3
|
-
createEventDispatcher,
|
|
4
|
-
tick,
|
|
5
|
-
type Component,
|
|
6
|
-
type ComponentProps,
|
|
7
|
-
type Snippet
|
|
8
|
-
} from 'svelte'
|
|
9
|
-
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
10
|
-
import debounce from 'debounce'
|
|
11
|
-
import { toast } from 'svelte-sonner'
|
|
12
|
-
|
|
13
|
-
import { USE_COERCE_JSON } from '../../utils/constant.js'
|
|
14
|
-
import { DropDown } from '../menu/index.js'
|
|
15
|
-
import { FormControl, SelectorList } from './index.js'
|
|
16
|
-
import type { TippyProps } from '../../utils/tippy.js'
|
|
17
|
-
import RelationAfter from './RelationAfter.svelte'
|
|
18
|
-
import type { SnippetLike } from '../table/type.js'
|
|
19
|
-
|
|
20
|
-
export let key = Math.random().toString()
|
|
21
|
-
export let label = ''
|
|
22
|
-
export let search: (q: string) => Promise<RelationItem[]>
|
|
23
|
-
export let createUrl = ''
|
|
24
|
-
export let createTitle = 'Nouveau'
|
|
25
|
-
export let createIcon: string | undefined = undefined
|
|
26
|
-
let item: RelationItem | null = null
|
|
27
|
-
export { item as value }
|
|
28
|
-
export let error = ''
|
|
29
|
-
export let placeholder = ''
|
|
30
|
-
export let tippyProps: Partial<TippyProps> = {}
|
|
31
|
-
export let dropdownProps: ComponentProps<DropDown> = {}
|
|
32
|
-
export let flatMode = false
|
|
33
|
-
export let noSlotItemWrapper = false
|
|
34
|
-
export let slotItem: SnippetLike<[RelationItem]>
|
|
35
|
-
export let slotSuggestion: SnippetLike<[RelationItem]> = slotItem
|
|
36
|
-
export let input: HTMLInputAttributes | undefined = undefined
|
|
37
|
-
export let append: Snippet | undefined = undefined
|
|
38
|
-
export let disabled = false
|
|
39
|
-
export let shortcutKey = ''
|
|
40
|
-
export let Icon: Component<{ class: string }> | undefined = undefined
|
|
41
|
-
export let debounceMs = 150
|
|
42
|
-
|
|
43
|
-
let klass = ''
|
|
44
|
-
export { klass as class }
|
|
45
|
-
export let classList = ''
|
|
46
|
-
export let inputElement: HTMLInputElement | undefined = undefined
|
|
47
|
-
export let dropdown: DropDown | undefined = undefined
|
|
48
|
-
|
|
49
|
-
let proposedItems: RelationItem[] = []
|
|
50
|
-
|
|
51
|
-
let isLoading = false
|
|
52
|
-
let isError = false
|
|
53
|
-
let isFocus = false
|
|
54
|
-
let focusIndex = 0
|
|
55
|
-
let searchValue = ''
|
|
56
|
-
|
|
57
|
-
const dispatch = createEventDispatcher<{
|
|
58
|
-
input: { value: RelationItem | null }
|
|
59
|
-
blur: void
|
|
60
|
-
}>()
|
|
61
|
-
|
|
62
|
-
export async function clear() {
|
|
63
|
-
searchValue = ''
|
|
64
|
-
item = null
|
|
65
|
-
dispatch('input', { value: item })
|
|
66
|
-
await tick()
|
|
67
|
-
inputElement?.focus()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export async function select(index = focusIndex) {
|
|
71
|
-
item = proposedItems[index]
|
|
72
|
-
dispatch('input', { value: item })
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function focus() {
|
|
76
|
-
inputElement?.focus()
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function searchItems(searchValue = '') {
|
|
80
|
-
try {
|
|
81
|
-
isLoading = true
|
|
82
|
-
isError = false
|
|
83
|
-
focusIndex = 0
|
|
84
|
-
proposedItems = await search(searchValue)
|
|
85
|
-
} catch (error) {
|
|
86
|
-
toast.error('Erreur')
|
|
87
|
-
isError = true
|
|
88
|
-
console.error(error)
|
|
89
|
-
} finally {
|
|
90
|
-
isLoading = false
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const searchItemsDebounce = debounce(searchItems, debounceMs)
|
|
95
|
-
|
|
96
|
-
function handleFocus() {
|
|
97
|
-
isFocus = true
|
|
98
|
-
searchItems()
|
|
99
|
-
}
|
|
100
|
-
async function handleBlur() {
|
|
101
|
-
isFocus = false
|
|
102
|
-
searchValue = ''
|
|
103
|
-
dispatch('blur')
|
|
104
|
-
}
|
|
105
|
-
</script>
|
|
106
|
-
|
|
107
|
-
<DropDown bind:this={dropdown} {tippyProps} disable={flatMode} {...dropdownProps}>
|
|
108
|
-
<div class="contents" slot="activator">
|
|
109
|
-
<FormControl {key} {label} {error} class={klass}>
|
|
110
|
-
{#snippet children({ key })}
|
|
111
|
-
<label class="input w-full" class:hidden={item}>
|
|
112
|
-
<svelte:component this={Icon} class="h-5 w-5 shrink-0 opacity-70" />
|
|
113
|
-
<input
|
|
114
|
-
type="text"
|
|
115
|
-
id={key}
|
|
116
|
-
bind:this={inputElement}
|
|
117
|
-
bind:value={searchValue}
|
|
118
|
-
on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
|
|
119
|
-
on:focus={handleFocus}
|
|
120
|
-
on:blur={handleBlur}
|
|
121
|
-
autocomplete="off"
|
|
122
|
-
{placeholder}
|
|
123
|
-
class="grow"
|
|
124
|
-
size={8}
|
|
125
|
-
{...input}
|
|
126
|
-
/>
|
|
127
|
-
<RelationAfter {isLoading} {createUrl} {createTitle} {createIcon} />
|
|
128
|
-
{#if shortcutKey && !isFocus}
|
|
129
|
-
<kbd class="kbd kbd-xs text-base-content/50 shrink-0">
|
|
130
|
-
{shortcutKey}
|
|
131
|
-
</kbd>
|
|
132
|
-
{/if}
|
|
133
|
-
</label>
|
|
134
|
-
{@render append?.()}
|
|
135
|
-
|
|
136
|
-
{#if item}
|
|
137
|
-
{#if noSlotItemWrapper}
|
|
138
|
-
{@render slotItem(item)}
|
|
139
|
-
{:else}
|
|
140
|
-
<button
|
|
141
|
-
type="button"
|
|
142
|
-
{disabled}
|
|
143
|
-
on:click|stopPropagation={() => clear()}
|
|
144
|
-
class="input h-auto min-h-10 w-full grow items-start pt-2 pr-2"
|
|
145
|
-
>
|
|
146
|
-
{@render slotItem(item)}
|
|
147
|
-
</button>
|
|
148
|
-
{/if}
|
|
149
|
-
<input
|
|
150
|
-
type="hidden"
|
|
151
|
-
name={key}
|
|
152
|
-
value="{USE_COERCE_JSON}{JSON.stringify({ id: item.id })}"
|
|
153
|
-
/>
|
|
154
|
-
{/if}
|
|
155
|
-
{/snippet}
|
|
156
|
-
</FormControl>
|
|
157
|
-
</div>
|
|
158
|
-
|
|
159
|
-
<SelectorList
|
|
160
|
-
items={proposedItems}
|
|
161
|
-
trigger={inputElement}
|
|
162
|
-
{isError}
|
|
163
|
-
{isLoading}
|
|
164
|
-
bind:focusIndex
|
|
165
|
-
let:index
|
|
166
|
-
class="w-full min-w-40 {classList}"
|
|
167
|
-
on:select={({ detail }) => select(detail)}
|
|
168
|
-
>
|
|
169
|
-
{@render slotSuggestion(proposedItems[index])}
|
|
170
|
-
</SelectorList>
|
|
171
|
-
</DropDown>
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { type Component, type ComponentProps, type Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
-
import { DropDown } from '../menu/index.js';
|
|
4
|
-
import type { TippyProps } from '../../utils/tippy.js';
|
|
5
|
-
import type { SnippetLike } from '../table/type.js';
|
|
6
|
-
declare class __sveltets_Render<RelationItem extends {
|
|
7
|
-
id: string | number;
|
|
8
|
-
}> {
|
|
9
|
-
props(): {
|
|
10
|
-
key?: string;
|
|
11
|
-
label?: string;
|
|
12
|
-
search: (q: string) => Promise<RelationItem[]>;
|
|
13
|
-
createUrl?: string;
|
|
14
|
-
createTitle?: string;
|
|
15
|
-
createIcon?: string | undefined;
|
|
16
|
-
value?: RelationItem | null | undefined;
|
|
17
|
-
error?: string;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
tippyProps?: Partial<TippyProps>;
|
|
20
|
-
dropdownProps?: ComponentProps<DropDown>;
|
|
21
|
-
flatMode?: boolean;
|
|
22
|
-
noSlotItemWrapper?: boolean;
|
|
23
|
-
slotItem: SnippetLike<[RelationItem]>;
|
|
24
|
-
slotSuggestion?: SnippetLike<[RelationItem]> | undefined;
|
|
25
|
-
input?: HTMLInputAttributes | undefined;
|
|
26
|
-
append?: Snippet | undefined;
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
shortcutKey?: string;
|
|
29
|
-
Icon?: Component<{
|
|
30
|
-
class: string;
|
|
31
|
-
}, {}, string> | undefined;
|
|
32
|
-
debounceMs?: number;
|
|
33
|
-
class?: string;
|
|
34
|
-
classList?: string;
|
|
35
|
-
inputElement?: HTMLInputElement | undefined;
|
|
36
|
-
dropdown?: DropDown | undefined;
|
|
37
|
-
clear?: (() => Promise<void>) | undefined;
|
|
38
|
-
select?: ((index?: number) => Promise<void>) | undefined;
|
|
39
|
-
focus?: (() => void) | undefined;
|
|
40
|
-
searchItems?: ((searchValue?: string) => Promise<void>) | undefined;
|
|
41
|
-
};
|
|
42
|
-
events(): {
|
|
43
|
-
input: CustomEvent<{
|
|
44
|
-
value: RelationItem | null;
|
|
45
|
-
}>;
|
|
46
|
-
blur: CustomEvent<void>;
|
|
47
|
-
} & {
|
|
48
|
-
[evt: string]: CustomEvent<any>;
|
|
49
|
-
};
|
|
50
|
-
slots(): {};
|
|
51
|
-
bindings(): string;
|
|
52
|
-
exports(): {
|
|
53
|
-
clear: () => Promise<void>;
|
|
54
|
-
select: (index?: number) => Promise<void>;
|
|
55
|
-
focus: () => void;
|
|
56
|
-
searchItems: (searchValue?: string) => Promise<void>;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
interface $$IsomorphicComponent {
|
|
60
|
-
new <RelationItem extends {
|
|
61
|
-
id: string | number;
|
|
62
|
-
}>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<RelationItem>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<RelationItem>['props']>, ReturnType<__sveltets_Render<RelationItem>['events']>, ReturnType<__sveltets_Render<RelationItem>['slots']>> & {
|
|
63
|
-
$$bindings?: ReturnType<__sveltets_Render<RelationItem>['bindings']>;
|
|
64
|
-
} & ReturnType<__sveltets_Render<RelationItem>['exports']>;
|
|
65
|
-
<RelationItem extends {
|
|
66
|
-
id: string | number;
|
|
67
|
-
}>(internal: unknown, props: ReturnType<__sveltets_Render<RelationItem>['props']> & {
|
|
68
|
-
$$events?: ReturnType<__sveltets_Render<RelationItem>['events']>;
|
|
69
|
-
}): ReturnType<__sveltets_Render<RelationItem>['exports']>;
|
|
70
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
71
|
-
}
|
|
72
|
-
declare const InputRelation: $$IsomorphicComponent;
|
|
73
|
-
type InputRelation<RelationItem extends {
|
|
74
|
-
id: string | number;
|
|
75
|
-
}> = InstanceType<typeof InputRelation<RelationItem>>;
|
|
76
|
-
export default InputRelation;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="RelationItem extends {id: string | number}">
|
|
2
|
-
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
3
|
-
|
|
4
|
-
import { createEventDispatcher, tick, type Snippet } from 'svelte'
|
|
5
|
-
import { slide } from 'svelte/transition'
|
|
6
|
-
import { toast } from 'svelte-sonner'
|
|
7
|
-
import { mdiClose } from '@mdi/js'
|
|
8
|
-
import debounce from 'debounce'
|
|
9
|
-
|
|
10
|
-
import { USE_COERCE_JSON } from '../../utils/constant.js'
|
|
11
|
-
import { Icon } from '../icon/index.js'
|
|
12
|
-
import { FormControl, SelectorList } from './index.js'
|
|
13
|
-
import { DropDown } from '../menu/index.js'
|
|
14
|
-
import RelationAfter from './RelationAfter.svelte'
|
|
15
|
-
import type { SnippetLike } from '../table/type.js'
|
|
16
|
-
|
|
17
|
-
export let key = ''
|
|
18
|
-
export let label = ''
|
|
19
|
-
export let search: (q: string) => Promise<RelationItem[]>
|
|
20
|
-
export let createUrl = ''
|
|
21
|
-
export let createTitle = ''
|
|
22
|
-
export let createIcon: string | undefined = undefined
|
|
23
|
-
export let error = ''
|
|
24
|
-
export let placeholder = ''
|
|
25
|
-
export let flatMode = false
|
|
26
|
-
export let slotItem: SnippetLike<[RelationItem]>
|
|
27
|
-
export let slotSuggestion: SnippetLike<[RelationItem]> = slotItem
|
|
28
|
-
export let input: HTMLInputAttributes | undefined = undefined
|
|
29
|
-
export let append: Snippet | undefined = undefined
|
|
30
|
-
export let debounceMs = 150
|
|
31
|
-
|
|
32
|
-
let klass = ''
|
|
33
|
-
export { klass as class }
|
|
34
|
-
export let classList = ''
|
|
35
|
-
|
|
36
|
-
let proposedItems: RelationItem[] = []
|
|
37
|
-
let items: RelationItem[] | null = null
|
|
38
|
-
export { items as value }
|
|
39
|
-
|
|
40
|
-
let isLoading = false
|
|
41
|
-
let isError = false
|
|
42
|
-
let focusIndex = 0
|
|
43
|
-
let searchValue = ''
|
|
44
|
-
|
|
45
|
-
let dropdown: DropDown
|
|
46
|
-
const dispatch = createEventDispatcher<{
|
|
47
|
-
input: { value: (string | number)[]; items: RelationItem[] }
|
|
48
|
-
}>()
|
|
49
|
-
let inputSearch: HTMLInputElement
|
|
50
|
-
|
|
51
|
-
async function select(index = focusIndex) {
|
|
52
|
-
const proposedItem = proposedItems[index]
|
|
53
|
-
if (!proposedItem) return
|
|
54
|
-
if (!items) items = [proposedItem]
|
|
55
|
-
else items = [...items, proposedItem]
|
|
56
|
-
dropdown.hide()
|
|
57
|
-
inputSearch.select()
|
|
58
|
-
proposedItems = [...proposedItems.slice(0, index), ...proposedItems.slice(index + 1)]
|
|
59
|
-
dispatch('input', { value: items.map(({ id }) => id), items })
|
|
60
|
-
await tick()
|
|
61
|
-
setTimeout(() => dropdown.show(), 200)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function remove(index: number) {
|
|
65
|
-
if (!items?.length) return
|
|
66
|
-
items = [...items.slice(0, index), ...items.slice(index + 1)]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function searchItems(searchValue = '') {
|
|
70
|
-
try {
|
|
71
|
-
isLoading = true
|
|
72
|
-
isError = false
|
|
73
|
-
focusIndex = 0
|
|
74
|
-
const res = await search(searchValue)
|
|
75
|
-
const currentIds = items?.map(({ id }) => id) || []
|
|
76
|
-
proposedItems = res.filter(({ id }) => !currentIds.includes(id))
|
|
77
|
-
} catch (error) {
|
|
78
|
-
toast.error('Erreur')
|
|
79
|
-
isError = true
|
|
80
|
-
console.error(error)
|
|
81
|
-
} finally {
|
|
82
|
-
isLoading = false
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const searchItemsDebounce = debounce(searchItems, debounceMs)
|
|
87
|
-
|
|
88
|
-
function handleFocus() {
|
|
89
|
-
searchItems()
|
|
90
|
-
// dropdown.show()
|
|
91
|
-
}
|
|
92
|
-
async function handleBlur() {
|
|
93
|
-
// dropdown.hide()
|
|
94
|
-
searchValue = ''
|
|
95
|
-
}
|
|
96
|
-
</script>
|
|
97
|
-
|
|
98
|
-
<DropDown bind:this={dropdown} disable={flatMode}>
|
|
99
|
-
<div slot="activator">
|
|
100
|
-
<FormControl {key} {label} {error} class={klass}>
|
|
101
|
-
<div class="flex flex-col gap-2">
|
|
102
|
-
{#if items && items.length}
|
|
103
|
-
<div class="flex flex-wrap gap-2">
|
|
104
|
-
{#each items || [] as item, index (item.id)}
|
|
105
|
-
<div
|
|
106
|
-
transition:slide|local={{ axis: 'x', duration: 200 }}
|
|
107
|
-
class="badge badge-outline badge-lg items-center pr-0 text-right whitespace-nowrap"
|
|
108
|
-
>
|
|
109
|
-
{@render slotItem(item)}
|
|
110
|
-
<div
|
|
111
|
-
class="btn btn-circle btn-ghost btn-xs mr-[2px] ml-1 h-[18px] min-h-[18px] w-[18px]"
|
|
112
|
-
role="button"
|
|
113
|
-
tabindex="0"
|
|
114
|
-
on:click={() => remove(index)}
|
|
115
|
-
on:keyup={(event) => event.key === 'Enter' && remove(index)}
|
|
116
|
-
>
|
|
117
|
-
<Icon path={mdiClose} size={16} />
|
|
118
|
-
</div>
|
|
119
|
-
</div>
|
|
120
|
-
{/each}
|
|
121
|
-
</div>
|
|
122
|
-
{/if}
|
|
123
|
-
<div class="flex grow gap-2">
|
|
124
|
-
<div class="input input-bordered flex grow items-center pr-2">
|
|
125
|
-
<input
|
|
126
|
-
type="text"
|
|
127
|
-
id={key}
|
|
128
|
-
bind:this={inputSearch}
|
|
129
|
-
bind:value={searchValue}
|
|
130
|
-
on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
|
|
131
|
-
on:focus={handleFocus}
|
|
132
|
-
on:blur={handleBlur}
|
|
133
|
-
autocomplete="off"
|
|
134
|
-
{placeholder}
|
|
135
|
-
class="grow"
|
|
136
|
-
size={8}
|
|
137
|
-
{...input}
|
|
138
|
-
/>
|
|
139
|
-
|
|
140
|
-
<RelationAfter {isLoading} {createUrl} {createTitle} {createIcon} />
|
|
141
|
-
</div>
|
|
142
|
-
{@render append?.()}
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<input
|
|
147
|
-
type="hidden"
|
|
148
|
-
name={key}
|
|
149
|
-
value="{USE_COERCE_JSON}{JSON.stringify(items?.map(({ id }) => ({ id })) || [])}"
|
|
150
|
-
/>
|
|
151
|
-
</FormControl>
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
<SelectorList
|
|
155
|
-
trigger={inputSearch}
|
|
156
|
-
items={proposedItems}
|
|
157
|
-
{isError}
|
|
158
|
-
{isLoading}
|
|
159
|
-
bind:focusIndex
|
|
160
|
-
let:index
|
|
161
|
-
class="w-full min-w-40 {classList}"
|
|
162
|
-
on:select={({ detail }) => select(detail)}
|
|
163
|
-
>
|
|
164
|
-
{@render slotSuggestion(proposedItems[index])}
|
|
165
|
-
</SelectorList>
|
|
166
|
-
</DropDown>
|