fuma 0.5.0 → 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 (125) 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/dist/validation/zod.d.ts +1 -1
  118. package/dist/validation/zod.js +1 -1
  119. package/package.json +32 -33
  120. package/dist/ui/slot/Slot.svelte +0 -35
  121. package/dist/ui/slot/Slot.svelte.d.ts +0 -22
  122. package/dist/ui/slot/Span.svelte +0 -4
  123. package/dist/ui/slot/Span.svelte.d.ts +0 -16
  124. package/dist/ui/slot/index.d.ts +0 -1
  125. package/dist/ui/slot/index.js +0 -1
@@ -25,6 +25,22 @@ declare const __propDef: {
25
25
  invalidateAll?: boolean | undefined;
26
26
  state?: App.PageState | undefined;
27
27
  } | undefined) => Promise<void>) | undefined;
28
+ children?: import("svelte").Snippet<[{
29
+ open: (value?: number, options?: {
30
+ replaceState?: boolean | undefined;
31
+ noScroll?: boolean | undefined;
32
+ keepFocus?: boolean | undefined;
33
+ invalidateAll?: boolean | undefined;
34
+ state?: App.PageState | undefined;
35
+ } | undefined) => Promise<void>;
36
+ close: (options?: {
37
+ replaceState?: boolean | undefined;
38
+ noScroll?: boolean | undefined;
39
+ keepFocus?: boolean | undefined;
40
+ invalidateAll?: boolean | undefined;
41
+ state?: App.PageState | undefined;
42
+ } | undefined) => Promise<void>;
43
+ }]> | undefined;
28
44
  };
29
45
  events: {
30
46
  [evt: string]: CustomEvent<any>;
@@ -1,92 +1,110 @@
1
- <script context="module"></script>
1
+ <script lang="ts" context="module">
2
+ import type { z } from 'zod'
3
+ import type { FormDataInput } from './form.js'
4
+ </script>
2
5
 
3
6
  <script
4
-
7
+ lang="ts"
5
8
  generics="
6
9
  Shape extends z.ZodRawShape,
7
10
  ReturnData extends Record<string, unknown> = FormDataInput<Shape>,
8
11
  Data extends FormDataInput<Shape> = FormDataInput<Shape>
9
12
  "
10
- >import { createEventDispatcher, onMount } from "svelte";
11
- import { fade } from "svelte/transition";
12
- import { page } from "$app/stores";
13
- import { contextContainer } from "../context.js";
14
- import {
15
- initData,
16
- getFieldType,
17
- useHandleInput
18
- } from "./form.js";
19
- import ButtonDelete from "../button/ButtonDelete.svelte";
20
- import { useForm } from "../../validation/form.js";
21
- import FormInput from "./FormInput.svelte";
22
- import FormSection from "./FormSection.svelte";
23
- let klass = "";
24
- export { klass as class };
25
- export let classSection = "";
26
- export let classAction = "";
27
- export let model = void 0;
28
- export let fields = [];
29
- export let sections = [{}];
30
- export let action = "";
31
- export let actionCreate = "_create";
32
- export let actionDelete = "_delete";
33
- export let actionUpdate = "_update";
34
- export let simpleAction = false;
35
- export let options = {};
36
- let dataInput = initData(fields);
37
- export { dataInput as data };
38
- let data = dataInput;
39
- export function set(key, value) {
40
- isDirty.set(true);
41
- data[key] = value;
42
- }
43
- export function update(updater) {
44
- isDirty.set(true);
45
- data = updater(data);
46
- }
47
- const dispatch = createEventDispatcher();
48
- const { enhance, setError } = useForm({
49
- ...options,
50
- async onSuccess(url, data2) {
51
- if (options.onSuccess)
52
- await options.onSuccess(url, data2);
53
- dispatch("success", { action: url, data: data2 });
54
- const actionPath = url.pathname + url.search;
55
- if (actionPath.includes(action + actionDelete))
56
- dispatch("deleted");
57
- if (!data2)
58
- return;
59
- if (actionPath.includes(action + actionCreate))
60
- dispatch("created", data2);
61
- if (actionPath.includes(action + actionUpdate))
62
- dispatch("updated", data2);
63
- }
64
- });
65
- const { handleInput, isDirty } = useHandleInput({ model, setError });
66
- onMount(lookupValueFromParams);
67
- $:
68
- $isDirty ? dataInput = data : data = dataInput;
69
- function lookupValueFromParams() {
70
- fields.flat().forEach(({ key }) => {
71
- if (data[key])
72
- return;
73
- const value = $page.url.searchParams.get(key);
74
- if (value && key in data)
75
- data[key] = value;
76
- });
77
- }
78
- const actionPadding = getActionPadding();
79
- function getActionPadding() {
80
- const container = contextContainer.get();
81
- if (container === "drawer")
82
- return "bottom-0 -ml-8 -mr-4 pl-8 pr-4";
83
- if (container === "card")
84
- return "bottom-0 -mx-2 sm:-mx-8 px-2 sm:px-8";
85
- if (container === "dialog")
86
- return "-bottom-4 -mx-4 px-4";
87
- return "bottom-0";
88
- }
89
- const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === void 0 ? !!bool : !!bool(_data);
13
+ >
14
+ import { createEventDispatcher, onMount } from 'svelte'
15
+ import { fade } from 'svelte/transition'
16
+ import { page } from '$app/stores'
17
+ import { contextContainer } from '../context.js'
18
+ import {
19
+ initData,
20
+ type FormField,
21
+ type FormSectionProps,
22
+ type BoolOrFunction,
23
+ type Nullable,
24
+ getFieldType,
25
+ useHandleInput
26
+ } from './form.js'
27
+ import ButtonDelete from '../button/ButtonDelete.svelte'
28
+
29
+ import { useForm, type UseFormOptions } from '../../validation/form.js'
30
+ import FormInput from './FormInput.svelte'
31
+ import FormSection from './FormSection.svelte'
32
+
33
+ let klass = ''
34
+ export { klass as class }
35
+ export let classSection = ''
36
+ export let classAction = ''
37
+ export let model: Shape | undefined = undefined
38
+ export let fields: FormField<Shape>[][] = []
39
+ export let sections: FormSectionProps<Shape>[] = [{}]
40
+ export let action = ''
41
+ export let actionCreate = '_create'
42
+ export let actionDelete = '_delete'
43
+ export let actionUpdate = '_update'
44
+
45
+ /** Ignore actionCreate, actionDelete and actionUpdate */
46
+ export let simpleAction = false
47
+
48
+ export let options: UseFormOptions<ReturnData> = {}
49
+ let dataInput: Nullable<Data> = initData<Shape, Data>(fields)
50
+ export { dataInput as data }
51
+
52
+ let data = dataInput
53
+
54
+ export function set<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) {
55
+ isDirty.set(true)
56
+ data[key] = value
57
+ }
58
+ export function update(updater: (currentData: Nullable<Data>) => Nullable<Data>) {
59
+ isDirty.set(true)
60
+ data = updater(data)
61
+ }
62
+
63
+ const dispatch = createEventDispatcher<{
64
+ success: { action: URL; data?: ReturnData }
65
+ created: ReturnData
66
+ updated: ReturnData
67
+ deleted: void
68
+ }>()
69
+
70
+ const { enhance, setError } = useForm<ReturnData>({
71
+ ...options,
72
+ async onSuccess(url, data) {
73
+ if (options.onSuccess) await options.onSuccess(url, data)
74
+ dispatch('success', { action: url, data })
75
+ const actionPath = url.pathname + url.search
76
+ if (actionPath.includes(action + actionDelete)) dispatch('deleted')
77
+ if (!data) return
78
+ if (actionPath.includes(action + actionCreate)) dispatch('created', data)
79
+ if (actionPath.includes(action + actionUpdate)) dispatch('updated', data)
80
+ }
81
+ })
82
+ const { handleInput, isDirty } = useHandleInput({ model, setError })
83
+
84
+ onMount(lookupValueFromParams)
85
+ $: $isDirty ? (dataInput = data) : (data = dataInput)
86
+
87
+ function lookupValueFromParams() {
88
+ fields.flat().forEach(({ key }) => {
89
+ if (data[key]) return
90
+ const value = $page.url.searchParams.get(key)
91
+ // TODO: fix data[key] type
92
+ // @ts-ignore
93
+ if (value && key in data) data[key] = value
94
+ })
95
+ }
96
+
97
+ const actionPadding = getActionPadding()
98
+ function getActionPadding(): string {
99
+ const container = contextContainer.get()
100
+ if (container === 'drawer') return 'bottom-0 -ml-8 -mr-4 pl-8 pr-4'
101
+ if (container === 'card') return 'bottom-0 -mx-2 sm:-mx-8 px-2 sm:px-8'
102
+ if (container === 'dialog') return '-bottom-4 -mx-4 px-4'
103
+ return 'bottom-0'
104
+ }
105
+
106
+ const getBoolean = (bool?: BoolOrFunction<Shape>) => (_data: Nullable<Data>) =>
107
+ typeof bool === 'boolean' || bool === undefined ? !!bool : !!bool(_data)
90
108
  </script>
91
109
 
92
110
  <form
@@ -138,7 +156,7 @@ const getBoolean = (bool) => (_data) => typeof bool === "boolean" || bool === vo
138
156
  "
139
157
  >
140
158
  <button class="btn btn-primary"> Valider </button>
141
- <div class="grow" />
159
+ <div class="grow"></div>
142
160
  {#if !simpleAction && data.id && actionDelete}
143
161
  {@const formaction = `${action}${actionDelete}`}
144
162
  <slot name="delete" {formaction}>
@@ -20,6 +20,7 @@ declare class __sveltets_Render<Shape extends z.ZodRawShape, ReturnData extends
20
20
  data?: Nullable<Data> | undefined;
21
21
  set?: (<K extends keyof Shape>(key: K, value: Nullable<Data>[K]) => void) | undefined;
22
22
  update?: ((updater: (currentData: Nullable<Data>) => Nullable<Data>) => void) | undefined;
23
+ children?: import("svelte").Snippet<[]> | undefined;
23
24
  };
24
25
  events(): {
25
26
  success: CustomEvent<{
@@ -1,9 +1,15 @@
1
- <script generics="InputType extends FormInputsType">import { formInputs } from "./formInput.js";
2
- let inputType;
3
- export { inputType as type };
4
- export let value;
5
- $:
6
- component = formInputs[inputType];
1
+ <script lang="ts" generics="InputType extends FormInputsType">
2
+ import { formInputs, type FormInputProps, type FormInputsType } from './formInput.js'
3
+
4
+ type $$Props = FormInputProps<InputType> & {
5
+ type: InputType
6
+ value: FormInputProps<InputType>['value']
7
+ }
8
+
9
+ let inputType: InputType
10
+ export { inputType as type }
11
+ export let value: FormInputProps<InputType>['value']
12
+ $: component = formInputs[inputType] as any
7
13
  </script>
8
14
 
9
15
  <svelte:component this={component} bind:value {...$$restProps} />
@@ -39,15 +39,21 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
39
39
  hide?: (() => void) | undefined;
40
40
  show?: (() => void) | undefined;
41
41
  setTippyProps?: ((props: Partial<import("tippy.js").Props>) => void) | undefined;
42
+ children?: import("svelte").Snippet<[]> | undefined;
42
43
  } | undefined;
43
44
  flatMode?: boolean | undefined;
44
- slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
45
- slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
45
+ slotItem: import("svelte").Snippet<[any]>;
46
+ slotSuggestion?: import("svelte").Snippet<[any]> | undefined;
46
47
  input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
48
+ append?: import("svelte").Snippet<[]> | undefined;
47
49
  class?: string | undefined;
48
50
  classList?: string | undefined;
49
51
  clear?: (() => Promise<void>) | undefined;
50
52
  }>): import("../index.js").InputRelation<any>;
53
+ element?: {
54
+ new (): HTMLElement;
55
+ prototype: HTMLElement;
56
+ } | undefined;
51
57
  };
52
58
  readonly relations: {
53
59
  new (options: import("svelte").ComponentConstructorOptions<{
@@ -60,13 +66,18 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
60
66
  error?: string | undefined;
61
67
  placeholder?: string | undefined;
62
68
  flatMode?: boolean | undefined;
63
- slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
64
- slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
69
+ slotItem: import("svelte").Snippet<[any]>;
70
+ slotSuggestion?: import("svelte").Snippet<[any]> | undefined;
65
71
  input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
72
+ append?: import("svelte").Snippet<[]> | undefined;
66
73
  class?: string | undefined;
67
74
  classList?: string | undefined;
68
75
  value?: any[] | null | undefined;
69
76
  }>): import("../index.js").InputRelations<any>;
77
+ element?: {
78
+ new (): HTMLElement;
79
+ prototype: HTMLElement;
80
+ } | undefined;
70
81
  };
71
82
  }[InputType]>> & {
72
83
  type: InputType;
@@ -108,15 +119,21 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
108
119
  hide?: (() => void) | undefined;
109
120
  show?: (() => void) | undefined;
110
121
  setTippyProps?: ((props: Partial<import("tippy.js").Props>) => void) | undefined;
122
+ children?: import("svelte").Snippet<[]> | undefined;
111
123
  } | undefined;
112
124
  flatMode?: boolean | undefined;
113
- slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
114
- slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
125
+ slotItem: import("svelte").Snippet<[any]>;
126
+ slotSuggestion?: import("svelte").Snippet<[any]> | undefined;
115
127
  input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
128
+ append?: import("svelte").Snippet<[]> | undefined;
116
129
  class?: string | undefined;
117
130
  classList?: string | undefined;
118
131
  clear?: (() => Promise<void>) | undefined;
119
132
  }>): import("../index.js").InputRelation<any>;
133
+ element?: {
134
+ new (): HTMLElement;
135
+ prototype: HTMLElement;
136
+ } | undefined;
120
137
  };
121
138
  readonly relations: {
122
139
  new (options: import("svelte").ComponentConstructorOptions<{
@@ -129,13 +146,18 @@ declare class __sveltets_Render<InputType extends FormInputsType> {
129
146
  error?: string | undefined;
130
147
  placeholder?: string | undefined;
131
148
  flatMode?: boolean | undefined;
132
- slotItem?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
133
- slotSuggestion?: ((item: any) => string | import("../../index.js").ComponentAndProps) | null | undefined;
149
+ slotItem: import("svelte").Snippet<[any]>;
150
+ slotSuggestion?: import("svelte").Snippet<[any]> | undefined;
134
151
  input?: import("svelte/elements.js").HTMLInputAttributes | undefined;
152
+ append?: import("svelte").Snippet<[]> | undefined;
135
153
  class?: string | undefined;
136
154
  classList?: string | undefined;
137
155
  value?: any[] | null | undefined;
138
156
  }>): import("../index.js").InputRelations<any>;
157
+ element?: {
158
+ new (): HTMLElement;
159
+ prototype: HTMLElement;
160
+ } | undefined;
139
161
  };
140
162
  }[InputType]>>["value"];
141
163
  };
@@ -1,19 +1,26 @@
1
- <script>import { slide } from "svelte/transition";
2
- import { mdiChevronRight } from "@mdi/js";
3
- import { Icon } from "../icon/index.js";
4
- export let title = "";
5
- export let isActive = false;
6
- export let isReducible = false;
7
- let klass = "";
8
- export { klass as class };
9
- export let contentClass = "";
10
- function open() {
11
- isActive = true;
12
- }
13
- function toggle(event) {
14
- event.stopPropagation();
15
- isActive = !isActive;
16
- }
1
+ <script lang="ts">
2
+ import { slide } from 'svelte/transition'
3
+ import { mdiChevronRight } from '@mdi/js'
4
+ import { Icon } from '../icon/index.js'
5
+ type Props = { isActive?: boolean; class?: string; contentClass?: string }
6
+ type $$Props = Props &
7
+ ({ isReducible: true; title: string } | { isReducible?: false; title?: string })
8
+
9
+ export let title = ''
10
+ export let isActive = false
11
+ export let isReducible = false
12
+
13
+ let klass = ''
14
+ export { klass as class }
15
+ export let contentClass = ''
16
+
17
+ function open() {
18
+ isActive = true
19
+ }
20
+ function toggle(event: Event) {
21
+ event.stopPropagation()
22
+ isActive = !isActive
23
+ }
17
24
  </script>
18
25
 
19
26
  <div>
@@ -44,7 +51,7 @@ function toggle(event) {
44
51
  {/if}
45
52
  </slot>
46
53
  {#if isReducible}
47
- <div class="grow" />
54
+ <div class="grow"></div>
48
55
  <button
49
56
  type="button"
50
57
  on:click={toggle}
@@ -60,11 +60,13 @@ export declare function relationProps<Item extends {
60
60
  hide?: (() => void) | undefined;
61
61
  show?: (() => void) | undefined;
62
62
  setTippyProps?: ((props: Partial<import("tippy.js").Props>) => void) | undefined;
63
+ children?: import("svelte").Snippet<[]> | undefined;
63
64
  } | undefined;
64
65
  flatMode?: boolean | undefined;
65
- slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
66
- slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
66
+ slotItem: import("svelte").Snippet<[Item]>;
67
+ slotSuggestion?: import("svelte").Snippet<[Item]> | undefined;
67
68
  input?: import("svelte/elements").HTMLInputAttributes | undefined;
69
+ append?: import("svelte").Snippet<[]> | undefined;
68
70
  class?: string | undefined;
69
71
  classList?: string | undefined;
70
72
  clear?: (() => Promise<void>) | undefined;
@@ -81,9 +83,10 @@ export declare function relationsProps<Item extends {
81
83
  error?: string | undefined;
82
84
  placeholder?: string | undefined;
83
85
  flatMode?: boolean | undefined;
84
- slotItem?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
85
- slotSuggestion?: ((item: Item) => string | import("../..").ComponentAndProps) | null | undefined;
86
+ slotItem: import("svelte").Snippet<[Item]>;
87
+ slotSuggestion?: import("svelte").Snippet<[Item]> | undefined;
86
88
  input?: import("svelte/elements").HTMLInputAttributes | undefined;
89
+ append?: import("svelte").Snippet<[]> | undefined;
87
90
  class?: string | undefined;
88
91
  classList?: string | undefined;
89
92
  value?: Item[] | null | undefined;
@@ -1,35 +1,38 @@
1
- <script>import { tippy } from "../../utils/tippy.js";
2
- import { onMount } from "svelte";
3
- export let path;
4
- export let title = "";
5
- export let size = 22;
6
- let klass = "";
7
- export { klass as class };
8
- export let style = "";
9
- export let classSVG = "";
10
- export let tippyProps = {};
11
- export let disableTitlePropagation = false;
12
- const viewWidth = 24;
13
- const viewHeight = 24;
14
- let icon;
15
- let tip = null;
16
- $:
17
- tip?.setContent(title);
18
- onMount(() => {
19
- if (!title)
20
- return;
21
- const parent = icon.parentElement;
22
- const isButton = parent?.tagName === "BUTTON" || parent?.tagName === "A";
23
- const target = parent && isButton && !disableTitlePropagation ? parent : icon;
24
- tip = tippy(target || icon, {
25
- content: title,
26
- trigger: "mouseenter",
27
- ...tippyProps
28
- });
29
- return () => {
30
- tip?.destroy();
31
- };
32
- });
1
+ <script lang="ts">
2
+ import { tippy, type TippyProps, type TippyInstance } from '../../utils/tippy.js'
3
+ import { onMount } from 'svelte'
4
+
5
+ export let path: string
6
+ export let title = ''
7
+ export let size = 22
8
+ let klass = ''
9
+ export { klass as class }
10
+ export let style = ''
11
+ export let classSVG = ''
12
+ export let tippyProps: Partial<TippyProps> = {}
13
+ export let disableTitlePropagation = false
14
+ const viewWidth = 24
15
+ const viewHeight = 24
16
+
17
+ let icon: HTMLElement
18
+
19
+ let tip: TippyInstance | null = null
20
+ $: tip?.setContent(title)
21
+
22
+ onMount(() => {
23
+ if (!title) return
24
+ const parent = icon.parentElement
25
+ const isButton = parent?.tagName === 'BUTTON' || parent?.tagName === 'A'
26
+ const target = parent && isButton && !disableTitlePropagation ? parent : icon
27
+ tip = tippy(target || icon, {
28
+ content: title,
29
+ trigger: 'mouseenter',
30
+ ...tippyProps
31
+ })
32
+ return () => {
33
+ tip?.destroy()
34
+ }
35
+ })
33
36
  </script>
34
37
 
35
38
  <i bind:this={icon} class="grid place-content-center fill-base-content {klass}" {style}>
@@ -11,7 +11,6 @@ export * from './dialog/index.js';
11
11
  export * from './placeholder/index.js';
12
12
  export * from './icon/index.js';
13
13
  export * from './login/index.js';
14
- export * from './slot/index.js';
15
14
  export * from './pagination/index.js';
16
15
  export * from './mode/index.js';
17
16
  export * from './badge/index.js';
package/dist/ui/index.js CHANGED
@@ -11,7 +11,6 @@ export * from './dialog/index.js';
11
11
  export * from './placeholder/index.js';
12
12
  export * from './icon/index.js';
13
13
  export * from './login/index.js';
14
- export * from './slot/index.js';
15
14
  export * from './pagination/index.js';
16
15
  export * from './mode/index.js';
17
16
  export * from './badge/index.js';
@@ -1,35 +1,41 @@
1
- <script>import { slide } from "svelte/transition";
2
- import { onMount } from "svelte";
3
- import { formContext } from "../../validation/form.js";
4
- import { Slot } from "../index.js";
5
- let klass = "";
6
- export { klass as class };
7
- export let classLabel = "";
8
- export let key = "";
9
- export let label = "";
10
- export let error = "";
11
- export let hint = "";
12
- export let prefix = "";
13
- export let prefixFor = "";
14
- export let enhanceDisabled = false;
15
- export let labelPosition = "top";
16
- $:
17
- _key = prefix && key ? `${prefix}_${key}` : key || "";
18
- if (!enhanceDisabled) {
19
- const { setError } = formContext.get();
20
- setError[key] = (err) => error = err;
21
- }
22
- let formControl;
23
- onMount(() => {
24
- const input = formControl.querySelector("input, textarea");
25
- if (!input)
26
- return;
27
- const handleInput = () => error = "";
28
- input.addEventListener("input", handleInput);
29
- return () => {
30
- input.removeEventListener("input", handleInput);
31
- };
32
- });
1
+ <script lang="ts">
2
+ import { slide } from 'svelte/transition'
3
+ import { onMount, type Snippet } from 'svelte'
4
+ import { formContext } from '../../validation/form.js'
5
+
6
+ let klass = ''
7
+ export { klass as class }
8
+ export let classLabel = ''
9
+ export let key = ''
10
+ export let label: Snippet | string = ''
11
+ export let labelAppend: Snippet | null = null
12
+ export let error = ''
13
+ export let hint = ''
14
+ export let prefix: string | number = ''
15
+ export let prefixFor: string | number = ''
16
+ export let enhanceDisabled = false
17
+ export let labelPosition: LabelPosition = 'top'
18
+ export let children: Snippet<[{ key: string }]> | undefined = undefined
19
+
20
+ type LabelPosition = 'top' | 'left' | 'right'
21
+
22
+ $: _key = prefix && key ? `${prefix}_${key}` : key || ''
23
+
24
+ if (!enhanceDisabled) {
25
+ const { setError } = formContext.get()
26
+ setError[key] = (err) => (error = err)
27
+ }
28
+
29
+ let formControl: HTMLDivElement
30
+ onMount(() => {
31
+ const input = formControl.querySelector('input, textarea')
32
+ if (!input) return
33
+ const handleInput = () => (error = '')
34
+ input.addEventListener('input', handleInput)
35
+ return () => {
36
+ input.removeEventListener('input', handleInput)
37
+ }
38
+ })
33
39
  </script>
34
40
 
35
41
  <div class="form-control {klass}" bind:this={formControl}>
@@ -44,15 +50,21 @@ onMount(() => {
44
50
  {#if label}
45
51
  <label for="{prefixFor}{_key}" class="label cursor-pointer {classLabel}">
46
52
  <span class="label-text">
47
- <Slot slot={label} />
53
+ {#if typeof label === 'string'}
54
+ {label}
55
+ {:else}
56
+ {@render label()}
57
+ {/if}
48
58
  </span>
49
- <slot name="label_append" />
59
+ {#if labelAppend}
60
+ {@render labelAppend()}
61
+ {/if}
50
62
  </label>
51
63
  {/if}
52
-
53
- <slot key={_key} />
54
64
  </div>
55
65
 
66
+ {@render children?.({ key: _key })}
67
+
56
68
  {#if error}
57
69
  <label for="{prefixFor}{_key}" class="label" transition:slide>
58
70
  <span class="label-text-alt text-warning">{error}</span>