fuma 0.5.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/private/Meta.svelte +32 -27
- package/dist/private/Meta.svelte.d.ts +1 -0
- package/dist/private/api.d.ts +1 -1
- package/dist/ui/badge/Badge.svelte +4 -3
- package/dist/ui/button/ButtonCopy.svelte +32 -26
- package/dist/ui/button/ButtonDelete.svelte +23 -21
- package/dist/ui/button/ButtonDelete.svelte.d.ts +1 -0
- package/dist/ui/card/Card.svelte +13 -10
- package/dist/ui/card/Card.svelte.d.ts +1 -0
- package/dist/ui/card/CardBasic.svelte +5 -4
- package/dist/ui/card/CardBasic.svelte.d.ts +1 -0
- package/dist/ui/card/CardCollapse.svelte +35 -31
- package/dist/ui/card/CardCollapse.svelte.d.ts +1 -0
- package/dist/ui/card/CardFullScreen.svelte +8 -6
- package/dist/ui/card/CardFullScreen.svelte.d.ts +3 -0
- package/dist/ui/card/CardLink.svelte +5 -4
- package/dist/ui/card/CardLink.svelte.d.ts +1 -0
- package/dist/ui/dialog/Dialog.svelte +41 -34
- package/dist/ui/dialog/Dialog.svelte.d.ts +1 -0
- package/dist/ui/dialog/DialogConfirm.svelte +6 -4
- package/dist/ui/dialog/DialogConfirm.svelte.d.ts +1 -0
- package/dist/ui/drawer/Drawer.svelte +47 -38
- package/dist/ui/drawer/Drawer.svelte.d.ts +16 -0
- package/dist/ui/form/Form.svelte +101 -83
- package/dist/ui/form/Form.svelte.d.ts +1 -0
- package/dist/ui/form/FormInput.svelte +12 -6
- package/dist/ui/form/FormInput.svelte.d.ts +30 -8
- package/dist/ui/form/FormSection.svelte +24 -17
- package/dist/ui/form/formInput.d.ts +7 -4
- package/dist/ui/icon/Icon.svelte +35 -32
- 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 +7 -9
- package/dist/ui/input/InputBoolean.svelte +29 -22
- package/dist/ui/input/InputBoolean.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxs.svelte +37 -34
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxsMenu.svelte +64 -47
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +5 -1
- package/dist/ui/input/InputCheckboxsTree.svelte +9 -6
- package/dist/ui/input/InputCheckboxsTreeNodes.svelte +36 -28
- package/dist/ui/input/InputCombo.svelte +76 -65
- package/dist/ui/input/InputCombo.svelte.d.ts +5 -1
- package/dist/ui/input/InputDate.svelte +36 -29
- package/dist/ui/input/InputDateTime.svelte +37 -30
- package/dist/ui/input/InputImage.svelte +52 -45
- package/dist/ui/input/InputImage.svelte.d.ts +1 -0
- package/dist/ui/input/InputImagePreview.svelte +24 -20
- package/dist/ui/input/InputNumber.svelte +28 -22
- package/dist/ui/input/InputNumber.svelte.d.ts +1 -5
- package/dist/ui/input/InputOptionInParam.svelte +12 -10
- package/dist/ui/input/InputOptions.svelte +40 -34
- package/dist/ui/input/InputPassword.svelte +22 -18
- package/dist/ui/input/InputPassword.svelte.d.ts +5 -1
- package/dist/ui/input/InputRadio.svelte +51 -46
- package/dist/ui/input/InputRadio.svelte.d.ts +5 -1
- package/dist/ui/input/InputRelation.svelte +119 -111
- package/dist/ui/input/InputRelation.svelte.d.ts +6 -12
- package/dist/ui/input/InputRelations.svelte +94 -90
- package/dist/ui/input/InputRelations.svelte.d.ts +5 -12
- package/dist/ui/input/InputSearch.svelte +13 -10
- package/dist/ui/input/InputSelect.svelte +59 -46
- package/dist/ui/input/InputText.svelte +29 -28
- package/dist/ui/input/InputText.svelte.d.ts +0 -3
- package/dist/ui/input/InputTextarea.svelte +20 -19
- package/dist/ui/input/InputTextarea.svelte.d.ts +1 -5
- package/dist/ui/input/InputTime.svelte +43 -35
- package/dist/ui/input/RelationAfter.svelte +13 -9
- package/dist/ui/input/SelectorList.svelte +16 -12
- package/dist/ui/input/SelectorList.svelte.d.ts +4 -0
- package/dist/ui/input/textRich/InputTextRich.svelte +63 -54
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +5 -1
- package/dist/ui/input/textRich/SuggesionList.svelte +13 -9
- package/dist/ui/input/textRich/ToolMark.svelte +12 -9
- package/dist/ui/input/textRich/ToolMarkColor.svelte +16 -12
- package/dist/ui/input/textRich/ToolMarkLink.svelte +46 -38
- package/dist/ui/input/textRich/ToolMenu.svelte +34 -19
- package/dist/ui/input/textRich/ToolMenuAlign.svelte +13 -9
- package/dist/ui/input/textRich/ToolMenuInsert.svelte +12 -7
- package/dist/ui/input/textRich/ToolMenuNode.svelte +14 -10
- package/dist/ui/input/textRich/ToolsBar.svelte +17 -13
- package/dist/ui/login/Login.svelte +37 -31
- package/dist/ui/menu/ContextMenu.svelte +37 -31
- package/dist/ui/menu/ContextMenu.svelte.d.ts +1 -0
- package/dist/ui/menu/DropDown.svelte +92 -83
- package/dist/ui/menu/DropDown.svelte.d.ts +1 -0
- package/dist/ui/menu/DropDownMenu.svelte +25 -18
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +1 -0
- package/dist/ui/mode/ToggleMode.svelte +19 -15
- package/dist/ui/mode/ToggleMode.svelte.d.ts +7 -1
- package/dist/ui/pagination/Pagination.svelte +9 -8
- package/dist/ui/placeholder/Placeholder.svelte +4 -3
- package/dist/ui/placeholder/Placeholder.svelte.d.ts +1 -0
- package/dist/ui/placeholder/PlaceholderImage.svelte +6 -4
- package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +1 -0
- package/dist/ui/range/RangePicker.svelte +76 -63
- package/dist/ui/range/RangePickerButton.svelte +43 -35
- package/dist/ui/table/Table.svelte +35 -28
- package/dist/ui/table/TableBody.svelte +18 -12
- package/dist/ui/table/TableCell.svelte +13 -10
- package/dist/ui/table/TableFieldsEdition.svelte +57 -51
- package/dist/ui/table/TableHead.svelte +19 -20
- package/dist/ui/table/TableViewSelect.svelte +50 -37
- package/dist/ui/table/cell/TableCellArray.svelte +5 -3
- package/dist/ui/table/cell/TableCellBoolean.svelte +4 -3
- package/dist/ui/table/cell/TableCellNumber.svelte +2 -1
- package/dist/ui/table/cell/TableCellString.svelte +5 -2
- package/dist/ui/table/head/TableHeadBoolean.svelte +6 -3
- package/dist/ui/table/head/TableHeadDate.svelte +54 -47
- package/dist/ui/table/head/TableHeadDefault.svelte +5 -2
- package/dist/ui/table/head/TableHeadNumber.svelte +65 -53
- package/dist/ui/table/head/TableHeadSelect.svelte +47 -41
- package/dist/ui/table/head/TableHeadString.svelte +14 -8
- package/dist/ui/tabs/Tabs.svelte +8 -5
- package/dist/ui/tabs/TabsIcon.svelte +31 -28
- package/package.json +32 -33
- 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
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type
|
|
3
|
-
import type { ComponentAndProps } from '../../utils/index.js';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
4
3
|
declare const __propDef: {
|
|
5
4
|
props: {
|
|
6
5
|
class?: string | undefined;
|
|
7
6
|
classLabel?: string | undefined;
|
|
8
7
|
key?: string | undefined;
|
|
9
|
-
label?: string |
|
|
8
|
+
label?: string | Snippet<[]> | undefined;
|
|
9
|
+
labelAppend?: Snippet<[]> | null | undefined;
|
|
10
10
|
error?: string | undefined;
|
|
11
11
|
hint?: string | undefined;
|
|
12
12
|
prefix?: string | number | undefined;
|
|
13
13
|
prefixFor?: string | number | undefined;
|
|
14
14
|
enhanceDisabled?: boolean | undefined;
|
|
15
15
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
16
|
+
children?: Snippet<[{
|
|
17
|
+
key: string;
|
|
18
|
+
}]> | undefined;
|
|
16
19
|
};
|
|
17
20
|
events: {
|
|
18
21
|
[evt: string]: CustomEvent<any>;
|
|
19
22
|
};
|
|
20
|
-
slots: {
|
|
21
|
-
label_append: {};
|
|
22
|
-
default: {
|
|
23
|
-
key: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
23
|
+
slots: {};
|
|
26
24
|
};
|
|
27
25
|
export type FormControlProps = typeof __propDef.props;
|
|
28
26
|
export type FormControlEvents = typeof __propDef.events;
|
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte'
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
4
|
+
import { FormControl, type InputProps, bindCheckedWithParams } from './index.js'
|
|
5
|
+
import { USE_COERCE_BOOLEAN } from '../../utils/constant.js'
|
|
6
|
+
|
|
7
|
+
type $$Props = InputProps<boolean> & { isRow?: boolean }
|
|
8
|
+
export let value: boolean | null | undefined = false
|
|
9
|
+
export let input: HTMLInputAttributes = {}
|
|
10
|
+
export let inputElement: HTMLInputElement | undefined = undefined
|
|
11
|
+
export let bindWithParams: boolean = false
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher<{ change: boolean }>()
|
|
9
14
|
</script>
|
|
10
15
|
|
|
11
|
-
<FormControl {...$$restProps}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
<FormControl {...$$restProps} class="">
|
|
17
|
+
{#snippet children({ key })}
|
|
18
|
+
<input
|
|
19
|
+
bind:this={inputElement}
|
|
20
|
+
bind:checked={value}
|
|
21
|
+
use:bindCheckedWithParams={{ bindEnable: bindWithParams }}
|
|
22
|
+
on:input={({ currentTarget: { checked } }) => dispatch('change', checked)}
|
|
23
|
+
on:focus
|
|
24
|
+
on:blur
|
|
25
|
+
type="checkbox"
|
|
26
|
+
id={key}
|
|
27
|
+
class="checkbox ml-1"
|
|
28
|
+
{...input}
|
|
29
|
+
/>
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
<input type="hidden" name={key} value="{USE_COERCE_BOOLEAN}{value}" />
|
|
32
|
+
{/snippet}
|
|
26
33
|
</FormControl>
|
|
@@ -5,13 +5,17 @@ declare const __propDef: {
|
|
|
5
5
|
class?: string | undefined;
|
|
6
6
|
classLabel?: string | undefined;
|
|
7
7
|
key?: string | undefined;
|
|
8
|
-
label?: string | import("svelte").
|
|
8
|
+
label?: string | import("svelte").Snippet<[]> | undefined;
|
|
9
|
+
labelAppend?: import("svelte").Snippet<[]> | null | undefined;
|
|
9
10
|
error?: string | undefined;
|
|
10
11
|
hint?: string | undefined;
|
|
11
12
|
prefix?: string | number | undefined;
|
|
12
13
|
prefixFor?: string | number | undefined;
|
|
13
14
|
enhanceDisabled?: boolean | undefined;
|
|
14
15
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
16
|
+
children?: import("svelte").Snippet<[{
|
|
17
|
+
key: string;
|
|
18
|
+
}]> | undefined;
|
|
15
19
|
} & {
|
|
16
20
|
input?: HTMLInputAttributes | undefined;
|
|
17
21
|
inputElement?: HTMLInputElement | undefined;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { slide } from 'svelte/transition'
|
|
3
|
+
import { FormControl, type InputProps } from './index.js'
|
|
4
|
+
import { type Options, parseOptions } from '../../utils/options.js'
|
|
5
|
+
|
|
6
|
+
type $$Props = InputProps<string[]> & { options: Options; checkboxesClass?: string }
|
|
7
|
+
$: ({
|
|
8
|
+
input,
|
|
9
|
+
value: _value,
|
|
10
|
+
options: _1,
|
|
11
|
+
class: klass,
|
|
12
|
+
checkboxesClass,
|
|
13
|
+
hint,
|
|
14
|
+
error,
|
|
15
|
+
...props
|
|
16
|
+
} = $$props as $$Props)
|
|
17
|
+
export let value: string[] | null | undefined = _value || []
|
|
18
|
+
export let options: Options
|
|
19
|
+
|
|
20
|
+
if (!value) value = []
|
|
21
|
+
|
|
22
|
+
$: _options = parseOptions(options)
|
|
21
23
|
</script>
|
|
22
24
|
|
|
23
25
|
<div class={klass}>
|
|
@@ -32,24 +34,25 @@ $:
|
|
|
32
34
|
{#each _options as option, index}
|
|
33
35
|
<FormControl
|
|
34
36
|
{...props}
|
|
35
|
-
let:key
|
|
36
37
|
label={option.label}
|
|
37
38
|
prefixFor={index}
|
|
38
39
|
class="flex-row-reverse items-center justify-end gap-2"
|
|
39
40
|
>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
{#snippet children({ key })}
|
|
42
|
+
<input
|
|
43
|
+
bind:group={value}
|
|
44
|
+
on:change
|
|
45
|
+
on:input
|
|
46
|
+
on:focus
|
|
47
|
+
on:blur
|
|
48
|
+
value={option.value}
|
|
49
|
+
type="checkbox"
|
|
50
|
+
name={key}
|
|
51
|
+
id="{index}{key}"
|
|
52
|
+
class="checkbox"
|
|
53
|
+
{...input}
|
|
54
|
+
/>
|
|
55
|
+
{/snippet}
|
|
53
56
|
</FormControl>
|
|
54
57
|
{/each}
|
|
55
58
|
</div>
|
|
@@ -5,13 +5,17 @@ declare const __propDef: {
|
|
|
5
5
|
class?: string | undefined;
|
|
6
6
|
classLabel?: string | undefined;
|
|
7
7
|
key?: string | undefined;
|
|
8
|
-
label?: string | import("svelte").
|
|
8
|
+
label?: string | import("svelte").Snippet<[]> | undefined;
|
|
9
|
+
labelAppend?: import("svelte").Snippet<[]> | null | undefined;
|
|
9
10
|
error?: string | undefined;
|
|
10
11
|
hint?: string | undefined;
|
|
11
12
|
prefix?: string | number | undefined;
|
|
12
13
|
prefixFor?: string | number | undefined;
|
|
13
14
|
enhanceDisabled?: boolean | undefined;
|
|
14
15
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
16
|
+
children?: import("svelte").Snippet<[{
|
|
17
|
+
key: string;
|
|
18
|
+
}]> | undefined;
|
|
15
19
|
} & {
|
|
16
20
|
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
17
21
|
inputElement?: HTMLInputElement | undefined;
|
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto } from '$app/navigation'
|
|
3
|
+
import { page } from '$app/stores'
|
|
4
|
+
import { mdiClose } from '@mdi/js'
|
|
5
|
+
|
|
6
|
+
import { urlParam } from '../../store/index.js'
|
|
7
|
+
import { jsonParse, type Options, parseOptions } from '../../utils/index.js'
|
|
8
|
+
import { Icon } from '../icon/index.js'
|
|
9
|
+
import { DropDown } from '../menu/index.js'
|
|
10
|
+
import { FormControl, type InputProps } from './index.js'
|
|
11
|
+
|
|
12
|
+
type $$Props = InputProps<string[]> & {
|
|
13
|
+
key: string
|
|
14
|
+
options: Options
|
|
15
|
+
right?: boolean
|
|
16
|
+
btnClass?: string
|
|
17
|
+
badgePrimary?: boolean
|
|
18
|
+
}
|
|
19
|
+
$: ({
|
|
20
|
+
input,
|
|
21
|
+
value: _value,
|
|
22
|
+
options: _1,
|
|
23
|
+
class: klass,
|
|
24
|
+
label,
|
|
25
|
+
right,
|
|
26
|
+
btnClass,
|
|
27
|
+
badgePrimary,
|
|
28
|
+
...props
|
|
29
|
+
} = $$props as $$Props)
|
|
30
|
+
|
|
31
|
+
export let key: string
|
|
32
|
+
export let options: Options
|
|
33
|
+
export let value: string[] | null | undefined =
|
|
34
|
+
_value || jsonParse($page.url.searchParams.get(key), [])
|
|
35
|
+
|
|
36
|
+
let dropdown: DropDown
|
|
37
|
+
|
|
38
|
+
$: _options = parseOptions(options)
|
|
39
|
+
|
|
40
|
+
async function writeUrl() {
|
|
41
|
+
const url = value?.length
|
|
42
|
+
? $urlParam.with({ [key]: JSON.stringify(value) })
|
|
43
|
+
: $urlParam.without(key)
|
|
44
|
+
return goto(url, { replaceState: true, noScroll: true })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleReset() {
|
|
48
|
+
dropdown.hide()
|
|
49
|
+
value = []
|
|
50
|
+
goto($urlParam.without(key), { replaceState: true })
|
|
51
|
+
}
|
|
36
52
|
</script>
|
|
37
53
|
|
|
38
54
|
<input type="hidden" name={key} value={JSON.stringify(value)} />
|
|
@@ -65,22 +81,23 @@ function handleReset() {
|
|
|
65
81
|
{#each _options as option, index (option.value)}
|
|
66
82
|
<FormControl
|
|
67
83
|
{...props}
|
|
68
|
-
let:key
|
|
69
84
|
label={option.label}
|
|
70
85
|
prefixFor={index}
|
|
71
86
|
class="flex-row-reverse items-center justify-end gap-2 whitespace-nowrap"
|
|
72
87
|
>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
{#snippet children({ key })}
|
|
89
|
+
<input
|
|
90
|
+
bind:group={value}
|
|
91
|
+
on:input
|
|
92
|
+
on:focus
|
|
93
|
+
on:blur
|
|
94
|
+
value={option.value}
|
|
95
|
+
type="checkbox"
|
|
96
|
+
id="{index}{key}"
|
|
97
|
+
class="checkbox"
|
|
98
|
+
{...input}
|
|
99
|
+
/>
|
|
100
|
+
{/snippet}
|
|
84
101
|
</FormControl>
|
|
85
102
|
{:else}
|
|
86
103
|
<div class="px-3 py-2 rounded opacity-70">Aucun élément</div>
|
|
@@ -5,13 +5,17 @@ declare const __propDef: {
|
|
|
5
5
|
class?: string | undefined;
|
|
6
6
|
classLabel?: string | undefined;
|
|
7
7
|
key?: string | undefined;
|
|
8
|
-
label?: string | import("svelte").
|
|
8
|
+
label?: string | import("svelte").Snippet<[]> | undefined;
|
|
9
|
+
labelAppend?: import("svelte").Snippet<[]> | null | undefined;
|
|
9
10
|
error?: string | undefined;
|
|
10
11
|
hint?: string | undefined;
|
|
11
12
|
prefix?: string | number | undefined;
|
|
12
13
|
prefixFor?: string | number | undefined;
|
|
13
14
|
enhanceDisabled?: boolean | undefined;
|
|
14
15
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
16
|
+
children?: import("svelte").Snippet<[{
|
|
17
|
+
key: string;
|
|
18
|
+
}]> | undefined;
|
|
15
19
|
} & {
|
|
16
20
|
input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
|
|
17
21
|
inputElement?: HTMLInputElement | undefined;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import InputCheckboxsTreeNodes, {
|
|
3
|
+
type OptionsNode
|
|
4
|
+
} from './InputCheckboxsTreeNodes.svelte'
|
|
5
|
+
|
|
6
|
+
export let label: string
|
|
7
|
+
export let options: OptionsNode
|
|
8
|
+
let klass = ''
|
|
9
|
+
export { klass as class }
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
12
|
<div class={klass}>
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
<script context="module"
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
export type OptionsNode = Record<
|
|
3
|
+
string,
|
|
4
|
+
{ label: string; value?: boolean; options?: OptionsNode }
|
|
5
|
+
>
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { createEventDispatcher } from 'svelte'
|
|
10
|
+
import { InputBoolean } from './index.js'
|
|
11
|
+
export let options: OptionsNode
|
|
12
|
+
|
|
13
|
+
type Events = { setTrue: void }
|
|
14
|
+
const dispatch = createEventDispatcher<Events>()
|
|
15
|
+
|
|
16
|
+
function handleChange(newValue: boolean, option: OptionsNode[string]) {
|
|
17
|
+
if (newValue === true) dispatch('setTrue')
|
|
18
|
+
else if (option.options) {
|
|
19
|
+
option.options = setFalse(option.options)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
2
22
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return Object.entries(_options).reduce(
|
|
18
|
-
(acc, [key, opt]) => ({
|
|
19
|
-
...acc,
|
|
20
|
-
[key]: {
|
|
21
|
-
label: opt.label,
|
|
22
|
-
value: false,
|
|
23
|
-
options: setFalse(opt.options)
|
|
24
|
-
}
|
|
25
|
-
}),
|
|
26
|
-
{}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
23
|
+
function setFalse(_options?: OptionsNode): OptionsNode | undefined {
|
|
24
|
+
if (!_options) return undefined
|
|
25
|
+
return Object.entries(_options).reduce<OptionsNode>(
|
|
26
|
+
(acc, [key, opt]) => ({
|
|
27
|
+
...acc,
|
|
28
|
+
[key]: {
|
|
29
|
+
label: opt.label,
|
|
30
|
+
value: false,
|
|
31
|
+
options: setFalse(opt.options)
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
{}
|
|
35
|
+
)
|
|
36
|
+
}
|
|
29
37
|
</script>
|
|
30
38
|
|
|
31
39
|
{#each Object.keys(options) as key (key)}
|
|
@@ -43,7 +51,7 @@ function setFalse(_options) {
|
|
|
43
51
|
<div
|
|
44
52
|
style:height="{24 + index * 36}px"
|
|
45
53
|
class="t-0 bordered absolute w-3 rounded-bl-lg border-b-2 border-l-2"
|
|
46
|
-
|
|
54
|
+
></div>
|
|
47
55
|
{/each}
|
|
48
56
|
</div>
|
|
49
57
|
<div>
|
|
@@ -1,74 +1,85 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher, tick } from 'svelte'
|
|
3
|
+
|
|
4
|
+
import type { InputProps } from './types.js'
|
|
5
|
+
import type { TippyProps } from '../../utils/tippy.js'
|
|
6
|
+
import { type Options, type Option, parseOptions } from '../../utils/options.js'
|
|
7
|
+
import { FormControl, SelectorList } from './index.js'
|
|
8
|
+
import { DropDown } from '../menu/index.js'
|
|
9
|
+
import { Icon } from '../icon/index.js'
|
|
10
|
+
|
|
11
|
+
type $$Props = InputProps & { options: Options; tippyProps?: TippyProps }
|
|
12
|
+
$: ({ input, value: _value, options, tippyProps, ...props } = $$props as $$Props)
|
|
13
|
+
$: ({ class: inputClass, ...inputProps } = input || {})
|
|
14
|
+
export let value = _value
|
|
15
|
+
export let inputElement: HTMLInputElement | undefined = undefined
|
|
16
|
+
|
|
17
|
+
let focusIndex = 0
|
|
18
|
+
let searchValue = ''
|
|
19
|
+
|
|
20
|
+
const dispatch = createEventDispatcher<{ input: string }>()
|
|
21
|
+
let filteredOptions: (Option & { id: string })[] = []
|
|
22
|
+
$: _options = parseOptions(options)
|
|
23
|
+
$: selectedOption = _options.find((opt) => opt.value === value)
|
|
24
|
+
|
|
25
|
+
function filterOptions(value: string) {
|
|
26
|
+
const reg = new RegExp(value, 'i')
|
|
27
|
+
filteredOptions = _options
|
|
28
|
+
.filter((opt) => opt.label.match(reg) || opt.value.match(reg))
|
|
29
|
+
.map((opt) => ({ id: opt.value, ...opt }))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function clear() {
|
|
33
|
+
searchValue = ''
|
|
34
|
+
value = ''
|
|
35
|
+
filterOptions('')
|
|
36
|
+
await tick()
|
|
37
|
+
inputElement?.focus()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function select(index = focusIndex) {
|
|
41
|
+
value = _options[index].value
|
|
42
|
+
dispatch('input', value)
|
|
43
|
+
}
|
|
35
44
|
</script>
|
|
36
45
|
|
|
37
46
|
<DropDown {tippyProps}>
|
|
38
47
|
<div class="contents" slot="activator">
|
|
39
|
-
<FormControl {...props}
|
|
40
|
-
|
|
41
|
-
<div class="
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
<FormControl {...props}>
|
|
49
|
+
{#snippet children({ key })}
|
|
50
|
+
<div class="flex grow gap-2" class:hidden={selectedOption}>
|
|
51
|
+
<div class="relative flex grow items-center gap-2">
|
|
52
|
+
<input
|
|
53
|
+
type="text"
|
|
54
|
+
id={key}
|
|
55
|
+
bind:this={inputElement}
|
|
56
|
+
bind:value={searchValue}
|
|
57
|
+
on:focus={() => filterOptions('')}
|
|
58
|
+
on:blur={() => (searchValue = '')}
|
|
59
|
+
on:input={(e) => filterOptions(e.currentTarget.value)}
|
|
60
|
+
autocomplete="off"
|
|
61
|
+
class="input input-bordered grow {inputClass || {}}"
|
|
62
|
+
{...inputProps}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
<slot name="append" />
|
|
54
66
|
</div>
|
|
55
|
-
<slot name="append" />
|
|
56
|
-
</div>
|
|
57
67
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
{#if selectedOption}
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
class="flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2"
|
|
72
|
+
on:click={clear}
|
|
73
|
+
on:focus={clear}
|
|
74
|
+
>
|
|
75
|
+
{#if selectedOption.icon}
|
|
76
|
+
<Icon path={selectedOption.icon} size={21} class="opacity-70" />
|
|
77
|
+
{/if}
|
|
78
|
+
<span>{selectedOption.label}</span>
|
|
79
|
+
</button>
|
|
80
|
+
<input type="hidden" name={key} value={selectedOption.value} />
|
|
81
|
+
{/if}
|
|
82
|
+
{/snippet}
|
|
72
83
|
</FormControl>
|
|
73
84
|
</div>
|
|
74
85
|
|
|
@@ -8,13 +8,17 @@ declare const __propDef: {
|
|
|
8
8
|
class?: string | undefined;
|
|
9
9
|
classLabel?: string | undefined;
|
|
10
10
|
key?: string | undefined;
|
|
11
|
-
label?: string | import("svelte").
|
|
11
|
+
label?: string | import("svelte").Snippet<[]> | undefined;
|
|
12
|
+
labelAppend?: import("svelte").Snippet<[]> | null | undefined;
|
|
12
13
|
error?: string | undefined;
|
|
13
14
|
hint?: string | undefined;
|
|
14
15
|
prefix?: string | number | undefined;
|
|
15
16
|
prefixFor?: string | number | undefined;
|
|
16
17
|
enhanceDisabled?: boolean | undefined;
|
|
17
18
|
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
19
|
+
children?: import("svelte").Snippet<[{
|
|
20
|
+
key: string;
|
|
21
|
+
}]> | undefined;
|
|
18
22
|
} & {
|
|
19
23
|
input?: import("svelte/elements").HTMLInputAttributes | undefined;
|
|
20
24
|
inputElement?: HTMLInputElement | undefined;
|