fuma 0.5.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/private/Meta.svelte +32 -27
  2. package/dist/private/Meta.svelte.d.ts +1 -0
  3. package/dist/private/api.d.ts +1 -1
  4. package/dist/ui/badge/Badge.svelte +4 -3
  5. package/dist/ui/button/ButtonCopy.svelte +32 -26
  6. package/dist/ui/button/ButtonDelete.svelte +23 -21
  7. package/dist/ui/button/ButtonDelete.svelte.d.ts +1 -0
  8. package/dist/ui/card/Card.svelte +13 -10
  9. package/dist/ui/card/Card.svelte.d.ts +1 -0
  10. package/dist/ui/card/CardBasic.svelte +5 -4
  11. package/dist/ui/card/CardBasic.svelte.d.ts +1 -0
  12. package/dist/ui/card/CardCollapse.svelte +35 -31
  13. package/dist/ui/card/CardCollapse.svelte.d.ts +1 -0
  14. package/dist/ui/card/CardFullScreen.svelte +8 -6
  15. package/dist/ui/card/CardFullScreen.svelte.d.ts +3 -0
  16. package/dist/ui/card/CardLink.svelte +5 -4
  17. package/dist/ui/card/CardLink.svelte.d.ts +1 -0
  18. package/dist/ui/dialog/Dialog.svelte +41 -34
  19. package/dist/ui/dialog/Dialog.svelte.d.ts +1 -0
  20. package/dist/ui/dialog/DialogConfirm.svelte +6 -4
  21. package/dist/ui/dialog/DialogConfirm.svelte.d.ts +1 -0
  22. package/dist/ui/drawer/Drawer.svelte +47 -38
  23. package/dist/ui/drawer/Drawer.svelte.d.ts +16 -0
  24. package/dist/ui/form/Form.svelte +101 -83
  25. package/dist/ui/form/Form.svelte.d.ts +1 -0
  26. package/dist/ui/form/FormInput.svelte +12 -6
  27. package/dist/ui/form/FormInput.svelte.d.ts +30 -8
  28. package/dist/ui/form/FormSection.svelte +24 -17
  29. package/dist/ui/form/formInput.d.ts +7 -4
  30. package/dist/ui/icon/Icon.svelte +35 -32
  31. package/dist/ui/index.d.ts +0 -1
  32. package/dist/ui/index.js +0 -1
  33. package/dist/ui/input/FormControl.svelte +48 -36
  34. package/dist/ui/input/FormControl.svelte.d.ts +7 -9
  35. package/dist/ui/input/InputBoolean.svelte +29 -22
  36. package/dist/ui/input/InputBoolean.svelte.d.ts +5 -1
  37. package/dist/ui/input/InputCheckboxs.svelte +37 -34
  38. package/dist/ui/input/InputCheckboxs.svelte.d.ts +5 -1
  39. package/dist/ui/input/InputCheckboxsMenu.svelte +64 -47
  40. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +5 -1
  41. package/dist/ui/input/InputCheckboxsTree.svelte +9 -6
  42. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +36 -28
  43. package/dist/ui/input/InputCombo.svelte +76 -65
  44. package/dist/ui/input/InputCombo.svelte.d.ts +5 -1
  45. package/dist/ui/input/InputDate.svelte +36 -29
  46. package/dist/ui/input/InputDateTime.svelte +37 -30
  47. package/dist/ui/input/InputImage.svelte +52 -45
  48. package/dist/ui/input/InputImage.svelte.d.ts +1 -0
  49. package/dist/ui/input/InputImagePreview.svelte +24 -20
  50. package/dist/ui/input/InputNumber.svelte +28 -22
  51. package/dist/ui/input/InputNumber.svelte.d.ts +1 -5
  52. package/dist/ui/input/InputOptionInParam.svelte +12 -10
  53. package/dist/ui/input/InputOptions.svelte +40 -34
  54. package/dist/ui/input/InputPassword.svelte +22 -18
  55. package/dist/ui/input/InputPassword.svelte.d.ts +5 -1
  56. package/dist/ui/input/InputRadio.svelte +51 -46
  57. package/dist/ui/input/InputRadio.svelte.d.ts +5 -1
  58. package/dist/ui/input/InputRelation.svelte +119 -111
  59. package/dist/ui/input/InputRelation.svelte.d.ts +6 -12
  60. package/dist/ui/input/InputRelations.svelte +94 -90
  61. package/dist/ui/input/InputRelations.svelte.d.ts +5 -12
  62. package/dist/ui/input/InputSearch.svelte +13 -10
  63. package/dist/ui/input/InputSelect.svelte +59 -46
  64. package/dist/ui/input/InputText.svelte +29 -28
  65. package/dist/ui/input/InputText.svelte.d.ts +0 -3
  66. package/dist/ui/input/InputTextarea.svelte +20 -19
  67. package/dist/ui/input/InputTextarea.svelte.d.ts +1 -5
  68. package/dist/ui/input/InputTime.svelte +43 -35
  69. package/dist/ui/input/RelationAfter.svelte +13 -9
  70. package/dist/ui/input/SelectorList.svelte +16 -12
  71. package/dist/ui/input/SelectorList.svelte.d.ts +4 -0
  72. package/dist/ui/input/textRich/InputTextRich.svelte +63 -54
  73. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +5 -1
  74. package/dist/ui/input/textRich/SuggesionList.svelte +13 -9
  75. package/dist/ui/input/textRich/ToolMark.svelte +12 -9
  76. package/dist/ui/input/textRich/ToolMarkColor.svelte +16 -12
  77. package/dist/ui/input/textRich/ToolMarkLink.svelte +46 -38
  78. package/dist/ui/input/textRich/ToolMenu.svelte +34 -19
  79. package/dist/ui/input/textRich/ToolMenuAlign.svelte +13 -9
  80. package/dist/ui/input/textRich/ToolMenuInsert.svelte +12 -7
  81. package/dist/ui/input/textRich/ToolMenuNode.svelte +14 -10
  82. package/dist/ui/input/textRich/ToolsBar.svelte +17 -13
  83. package/dist/ui/login/Login.svelte +37 -31
  84. package/dist/ui/menu/ContextMenu.svelte +37 -31
  85. package/dist/ui/menu/ContextMenu.svelte.d.ts +1 -0
  86. package/dist/ui/menu/DropDown.svelte +92 -83
  87. package/dist/ui/menu/DropDown.svelte.d.ts +1 -0
  88. package/dist/ui/menu/DropDownMenu.svelte +25 -18
  89. package/dist/ui/menu/DropDownMenu.svelte.d.ts +1 -0
  90. package/dist/ui/mode/ToggleMode.svelte +15 -14
  91. package/dist/ui/mode/ToggleMode.svelte.d.ts +6 -1
  92. package/dist/ui/pagination/Pagination.svelte +9 -8
  93. package/dist/ui/placeholder/Placeholder.svelte +4 -3
  94. package/dist/ui/placeholder/Placeholder.svelte.d.ts +1 -0
  95. package/dist/ui/placeholder/PlaceholderImage.svelte +6 -4
  96. package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +1 -0
  97. package/dist/ui/range/RangePicker.svelte +76 -63
  98. package/dist/ui/range/RangePickerButton.svelte +43 -35
  99. package/dist/ui/table/Table.svelte +35 -28
  100. package/dist/ui/table/TableBody.svelte +18 -12
  101. package/dist/ui/table/TableCell.svelte +13 -10
  102. package/dist/ui/table/TableFieldsEdition.svelte +57 -51
  103. package/dist/ui/table/TableHead.svelte +19 -20
  104. package/dist/ui/table/TableViewSelect.svelte +50 -37
  105. package/dist/ui/table/cell/TableCellArray.svelte +5 -3
  106. package/dist/ui/table/cell/TableCellBoolean.svelte +4 -3
  107. package/dist/ui/table/cell/TableCellNumber.svelte +2 -1
  108. package/dist/ui/table/cell/TableCellString.svelte +5 -2
  109. package/dist/ui/table/head/TableHeadBoolean.svelte +6 -3
  110. package/dist/ui/table/head/TableHeadDate.svelte +54 -47
  111. package/dist/ui/table/head/TableHeadDefault.svelte +5 -2
  112. package/dist/ui/table/head/TableHeadNumber.svelte +65 -53
  113. package/dist/ui/table/head/TableHeadSelect.svelte +47 -41
  114. package/dist/ui/table/head/TableHeadString.svelte +14 -8
  115. package/dist/ui/tabs/Tabs.svelte +8 -5
  116. package/dist/ui/tabs/TabsIcon.svelte +31 -28
  117. package/package.json +32 -33
  118. package/dist/ui/slot/Slot.svelte +0 -35
  119. package/dist/ui/slot/Slot.svelte.d.ts +0 -22
  120. package/dist/ui/slot/Span.svelte +0 -4
  121. package/dist/ui/slot/Span.svelte.d.ts +0 -16
  122. package/dist/ui/slot/index.d.ts +0 -1
  123. package/dist/ui/slot/index.js +0 -1
@@ -1,28 +1,26 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type ComponentType } from 'svelte';
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 | ComponentType | ComponentAndProps | undefined;
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>import { createEventDispatcher } from "svelte";
2
- import { FormControl, bindCheckedWithParams } from "./index.js";
3
- import { USE_COERCE_BOOLEAN } from "../../utils/constant.js";
4
- export let value = false;
5
- export let input = {};
6
- export let inputElement = void 0;
7
- export let bindWithParams = false;
8
- const dispatch = createEventDispatcher();
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} let:key class="">
12
- <input
13
- bind:this={inputElement}
14
- bind:checked={value}
15
- use:bindCheckedWithParams={{ bindEnable: bindWithParams }}
16
- on:input={({ currentTarget: { checked } }) => dispatch('change', checked)}
17
- on:focus
18
- on:blur
19
- type="checkbox"
20
- id={key}
21
- class="checkbox ml-1"
22
- {...input}
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
- <input type="hidden" name={key} value="{USE_COERCE_BOOLEAN}{value}" />
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").ComponentType | import("../../index.js").ComponentAndProps | undefined;
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>import { slide } from "svelte/transition";
2
- import { FormControl } from "./index.js";
3
- import { parseOptions } from "../../utils/options.js";
4
- $:
5
- ({
6
- input,
7
- value: _value,
8
- options: _1,
9
- class: klass,
10
- checkboxesClass,
11
- hint,
12
- error,
13
- ...props
14
- } = $$props);
15
- export let value = _value || [];
16
- export let options;
17
- if (!value)
18
- value = [];
19
- $:
20
- _options = parseOptions(options);
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
- <input
41
- bind:group={value}
42
- on:change
43
- on:input
44
- on:focus
45
- on:blur
46
- value={option.value}
47
- type="checkbox"
48
- name={key}
49
- id="{index}{key}"
50
- class="checkbox"
51
- {...input}
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").ComponentType | import("../../index.js").ComponentAndProps | undefined;
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>import { goto } from "$app/navigation";
2
- import { page } from "$app/stores";
3
- import { mdiClose } from "@mdi/js";
4
- import { urlParam } from "../../store/index.js";
5
- import { jsonParse, parseOptions } from "../../utils/index.js";
6
- import { Icon } from "../icon/index.js";
7
- import { DropDown } from "../menu/index.js";
8
- import { FormControl } from "./index.js";
9
- $:
10
- ({
11
- input,
12
- value: _value,
13
- options: _1,
14
- class: klass,
15
- label,
16
- right,
17
- btnClass,
18
- badgePrimary,
19
- ...props
20
- } = $$props);
21
- export let key;
22
- export let options;
23
- export let value = _value || jsonParse($page.url.searchParams.get(key), []);
24
- let dropdown;
25
- $:
26
- _options = parseOptions(options);
27
- async function writeUrl() {
28
- const url = value?.length ? $urlParam.with({ [key]: JSON.stringify(value) }) : $urlParam.without(key);
29
- return goto(url, { replaceState: true, noScroll: true });
30
- }
31
- function handleReset() {
32
- dropdown.hide();
33
- value = [];
34
- goto($urlParam.without(key), { replaceState: true });
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
- <input
74
- bind:group={value}
75
- on:input
76
- on:focus
77
- on:blur
78
- value={option.value}
79
- type="checkbox"
80
- id="{index}{key}"
81
- class="checkbox"
82
- {...input}
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").ComponentType | import("../../utils/index.js").ComponentAndProps | undefined;
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>import InputCheckboxsTreeNodes, {
2
- } from "./InputCheckboxsTreeNodes.svelte";
3
- export let label;
4
- export let options;
5
- let klass = "";
6
- export { klass as class };
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"></script>
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
- <script>import { createEventDispatcher } from "svelte";
4
- import { InputBoolean } from "./index.js";
5
- export let options;
6
- const dispatch = createEventDispatcher();
7
- function handleChange(newValue, option) {
8
- if (newValue === true)
9
- dispatch("setTrue");
10
- else if (option.options) {
11
- option.options = setFalse(option.options);
12
- }
13
- }
14
- function setFalse(_options) {
15
- if (!_options)
16
- return void 0;
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>import { createEventDispatcher, tick } from "svelte";
2
- import { parseOptions } from "../../utils/options.js";
3
- import { FormControl, SelectorList } from "./index.js";
4
- import { DropDown } from "../menu/index.js";
5
- import { Icon } from "../icon/index.js";
6
- $:
7
- ({ input, value: _value, options, tippyProps, ...props } = $$props);
8
- $:
9
- ({ class: inputClass, ...inputProps } = input || {});
10
- export let value = _value;
11
- export let inputElement = void 0;
12
- let focusIndex = 0;
13
- let searchValue = "";
14
- const dispatch = createEventDispatcher();
15
- let filteredOptions = [];
16
- $:
17
- _options = parseOptions(options);
18
- $:
19
- selectedOption = _options.find((opt) => opt.value === value);
20
- function filterOptions(value2) {
21
- const reg = new RegExp(value2, "i");
22
- filteredOptions = _options.filter((opt) => opt.label.match(reg) || opt.value.match(reg)).map((opt) => ({ id: opt.value, ...opt }));
23
- }
24
- export async function clear() {
25
- searchValue = "";
26
- value = "";
27
- filterOptions("");
28
- await tick();
29
- inputElement?.focus();
30
- }
31
- async function select(index = focusIndex) {
32
- value = _options[index].value;
33
- dispatch("input", value);
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} let:key>
40
- <div class="flex grow gap-2" class:hidden={selectedOption}>
41
- <div class="relative flex grow items-center gap-2">
42
- <input
43
- type="text"
44
- id={key}
45
- bind:this={inputElement}
46
- bind:value={searchValue}
47
- on:focus={() => filterOptions('')}
48
- on:blur={() => (searchValue = '')}
49
- on:input={(e) => filterOptions(e.currentTarget.value)}
50
- autocomplete="off"
51
- class="input input-bordered grow {inputClass || {}}"
52
- {...inputProps}
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
- {#if selectedOption}
59
- <button
60
- type="button"
61
- class="flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2"
62
- on:click={clear}
63
- on:focus={clear}
64
- >
65
- {#if selectedOption.icon}
66
- <Icon path={selectedOption.icon} size={21} class="opacity-70" />
67
- {/if}
68
- <span>{selectedOption.label}</span>
69
- </button>
70
- <input type="hidden" name={key} value={selectedOption.value} />
71
- {/if}
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").ComponentType | import("../..").ComponentAndProps | undefined;
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;