fuma 1.0.21 → 2.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 (195) hide show
  1. package/README.md +1 -1
  2. package/dist/action/list/handlers.d.ts +2 -2
  3. package/dist/action/list/index.d.ts +2 -0
  4. package/dist/action/list/index.js +1 -0
  5. package/dist/action/list/trigger.d.ts +7 -1
  6. package/dist/action/list/trigger.js +2 -2
  7. package/dist/private/Meta.svelte +32 -27
  8. package/dist/private/Meta.svelte.d.ts +29 -17
  9. package/dist/private/api.d.ts +1 -1
  10. package/dist/private/store.d.ts +0 -1
  11. package/dist/server/parseFormData.d.ts +1 -1
  12. package/dist/server/parseQuery.d.ts +1 -1
  13. package/dist/server/sse.d.ts +0 -1
  14. package/dist/store/isSmallScreen.d.ts +0 -1
  15. package/dist/store/param.d.ts +0 -2
  16. package/dist/store/session.d.ts +0 -1
  17. package/dist/ui/badge/Badge.svelte +4 -3
  18. package/dist/ui/badge/Badge.svelte.d.ts +19 -15
  19. package/dist/ui/button/ButtonCopy.svelte +35 -32
  20. package/dist/ui/button/ButtonCopy.svelte.d.ts +23 -21
  21. package/dist/ui/button/ButtonDelete.svelte +23 -21
  22. package/dist/ui/button/ButtonDelete.svelte.d.ts +32 -20
  23. package/dist/ui/card/Card.svelte +13 -10
  24. package/dist/ui/card/Card.svelte.d.ts +39 -24
  25. package/dist/ui/card/CardBasic.svelte +5 -4
  26. package/dist/ui/card/CardBasic.svelte.d.ts +29 -18
  27. package/dist/ui/card/CardCollapse.svelte +35 -31
  28. package/dist/ui/card/CardCollapse.svelte.d.ts +37 -23
  29. package/dist/ui/card/CardFullScreen.svelte +8 -6
  30. package/dist/ui/card/CardFullScreen.svelte.d.ts +35 -20
  31. package/dist/ui/card/CardLink.svelte +5 -4
  32. package/dist/ui/card/CardLink.svelte.d.ts +29 -18
  33. package/dist/ui/dialog/Dialog.svelte +41 -34
  34. package/dist/ui/dialog/Dialog.svelte.d.ts +36 -23
  35. package/dist/ui/dialog/DialogConfirm.svelte +6 -4
  36. package/dist/ui/dialog/DialogConfirm.svelte.d.ts +33 -19
  37. package/dist/ui/drawer/Drawer.svelte +47 -38
  38. package/dist/ui/drawer/Drawer.svelte.d.ts +81 -46
  39. package/dist/ui/drawer/drawerFly.d.ts +0 -1
  40. package/dist/ui/drawer/layers.d.ts +0 -1
  41. package/dist/ui/form/Form.svelte +106 -87
  42. package/dist/ui/form/Form.svelte.d.ts +29 -16
  43. package/dist/ui/form/FormInput.svelte +12 -6
  44. package/dist/ui/form/FormSection.svelte +24 -17
  45. package/dist/ui/form/FormSection.svelte.d.ts +37 -25
  46. package/dist/ui/icon/Icon.svelte +35 -32
  47. package/dist/ui/icon/Icon.svelte.d.ts +25 -21
  48. package/dist/ui/index.d.ts +0 -1
  49. package/dist/ui/index.js +0 -1
  50. package/dist/ui/input/FormControl.svelte +48 -36
  51. package/dist/ui/input/FormControl.svelte.d.ts +32 -30
  52. package/dist/ui/input/InputBoolean.svelte +29 -22
  53. package/dist/ui/input/InputBoolean.svelte.d.ts +43 -35
  54. package/dist/ui/input/InputCheckboxs.svelte +37 -34
  55. package/dist/ui/input/InputCheckboxs.svelte.d.ts +54 -39
  56. package/dist/ui/input/InputCheckboxsMenu.svelte +64 -47
  57. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +56 -41
  58. package/dist/ui/input/InputCheckboxsTree.svelte +9 -6
  59. package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +22 -18
  60. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +36 -28
  61. package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +20 -16
  62. package/dist/ui/input/InputCombo.svelte +76 -65
  63. package/dist/ui/input/InputCombo.svelte.d.ts +55 -39
  64. package/dist/ui/input/InputDate.svelte +36 -29
  65. package/dist/ui/input/InputDate.svelte.d.ts +20 -16
  66. package/dist/ui/input/InputDateTime.svelte +37 -30
  67. package/dist/ui/input/InputDateTime.svelte.d.ts +20 -16
  68. package/dist/ui/input/InputImage.svelte +52 -45
  69. package/dist/ui/input/InputImage.svelte.d.ts +40 -27
  70. package/dist/ui/input/InputImagePreview.svelte +24 -20
  71. package/dist/ui/input/InputImagePreview.svelte.d.ts +25 -21
  72. package/dist/ui/input/InputNumber.svelte +28 -22
  73. package/dist/ui/input/InputNumber.svelte.d.ts +20 -20
  74. package/dist/ui/input/InputOptionInParam.svelte +12 -10
  75. package/dist/ui/input/InputOptionInParam.svelte.d.ts +21 -17
  76. package/dist/ui/input/InputOptions.svelte +40 -34
  77. package/dist/ui/input/InputOptions.svelte.d.ts +19 -15
  78. package/dist/ui/input/InputPassword.svelte +22 -18
  79. package/dist/ui/input/InputPassword.svelte.d.ts +43 -35
  80. package/dist/ui/input/InputRadio.svelte +51 -46
  81. package/dist/ui/input/InputRadio.svelte.d.ts +53 -38
  82. package/dist/ui/input/InputRelation.svelte +129 -112
  83. package/dist/ui/input/InputRelation.svelte.d.ts +39 -53
  84. package/dist/ui/input/InputRelations.svelte +96 -90
  85. package/dist/ui/input/InputRelations.svelte.d.ts +35 -37
  86. package/dist/ui/input/InputSearch.svelte +14 -11
  87. package/dist/ui/input/InputSearch.svelte.d.ts +25 -21
  88. package/dist/ui/input/InputSelect.svelte +59 -46
  89. package/dist/ui/input/InputSelect.svelte.d.ts +23 -19
  90. package/dist/ui/input/InputText.svelte +29 -28
  91. package/dist/ui/input/InputText.svelte.d.ts +41 -28
  92. package/dist/ui/input/InputTextarea.svelte +20 -19
  93. package/dist/ui/input/InputTextarea.svelte.d.ts +20 -20
  94. package/dist/ui/input/InputTime.svelte +43 -36
  95. package/dist/ui/input/InputTime.svelte.d.ts +21 -36
  96. package/dist/ui/input/RelationAfter.svelte +13 -9
  97. package/dist/ui/input/RelationAfter.svelte.d.ts +24 -20
  98. package/dist/ui/input/SelectorList.svelte +16 -12
  99. package/dist/ui/input/SelectorList.svelte.d.ts +29 -20
  100. package/dist/ui/input/textRich/InputTextRich.svelte +63 -59
  101. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +36 -38
  102. package/dist/ui/input/textRich/SuggesionList.svelte +13 -9
  103. package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +19 -15
  104. package/dist/ui/input/textRich/ToolMark.svelte +12 -9
  105. package/dist/ui/input/textRich/ToolMark.svelte.d.ts +22 -18
  106. package/dist/ui/input/textRich/ToolMarkColor.svelte +16 -12
  107. package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +21 -17
  108. package/dist/ui/input/textRich/ToolMarkLink.svelte +46 -38
  109. package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +18 -14
  110. package/dist/ui/input/textRich/ToolMenu.svelte +34 -19
  111. package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +30 -26
  112. package/dist/ui/input/textRich/ToolMenuAlign.svelte +13 -9
  113. package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +18 -14
  114. package/dist/ui/input/textRich/ToolMenuInsert.svelte +12 -7
  115. package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +20 -16
  116. package/dist/ui/input/textRich/ToolMenuNode.svelte +14 -10
  117. package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +18 -14
  118. package/dist/ui/input/textRich/ToolsBar.svelte +21 -14
  119. package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +19 -17
  120. package/dist/ui/input/textRich/suggestion.d.ts +0 -1
  121. package/dist/ui/login/Login.svelte +37 -31
  122. package/dist/ui/login/Login.svelte.d.ts +18 -14
  123. package/dist/ui/menu/ContextMenu.svelte +37 -31
  124. package/dist/ui/menu/ContextMenu.svelte.d.ts +38 -25
  125. package/dist/ui/menu/DropDown.svelte +92 -83
  126. package/dist/ui/menu/DropDown.svelte.d.ts +46 -33
  127. package/dist/ui/menu/DropDownMenu.svelte +25 -18
  128. package/dist/ui/menu/DropDownMenu.svelte.d.ts +30 -19
  129. package/dist/ui/mode/ToggleMode.svelte +28 -16
  130. package/dist/ui/mode/ToggleMode.svelte.d.ts +34 -17
  131. package/dist/ui/pagination/Pagination.svelte +9 -8
  132. package/dist/ui/pagination/Pagination.svelte.d.ts +18 -14
  133. package/dist/ui/placeholder/Placeholder.svelte +4 -3
  134. package/dist/ui/placeholder/Placeholder.svelte.d.ts +28 -17
  135. package/dist/ui/placeholder/PlaceholderImage.svelte +6 -4
  136. package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +28 -17
  137. package/dist/ui/range/RangePicker.svelte +76 -63
  138. package/dist/ui/range/RangePicker.svelte.d.ts +29 -24
  139. package/dist/ui/range/RangePickerButton.svelte +45 -40
  140. package/dist/ui/range/RangePickerButton.svelte.d.ts +21 -19
  141. package/dist/ui/table/Table.svelte +35 -28
  142. package/dist/ui/table/Table.svelte.d.ts +24 -19
  143. package/dist/ui/table/TableBody.svelte +18 -12
  144. package/dist/ui/table/TableBody.svelte.d.ts +20 -15
  145. package/dist/ui/table/TableCell.svelte +13 -10
  146. package/dist/ui/table/TableCell.svelte.d.ts +19 -14
  147. package/dist/ui/table/TableFieldsEdition.svelte +58 -52
  148. package/dist/ui/table/TableFieldsEdition.svelte.d.ts +20 -15
  149. package/dist/ui/table/TableHead.svelte +20 -21
  150. package/dist/ui/table/TableHead.svelte.d.ts +19 -14
  151. package/dist/ui/table/TableViewSelect.svelte +50 -37
  152. package/dist/ui/table/TableViewSelect.svelte.d.ts +27 -23
  153. package/dist/ui/table/cell/TableCellArray.svelte +5 -3
  154. package/dist/ui/table/cell/TableCellArray.svelte.d.ts +18 -14
  155. package/dist/ui/table/cell/TableCellBoolean.svelte +4 -3
  156. package/dist/ui/table/cell/TableCellBoolean.svelte.d.ts +18 -14
  157. package/dist/ui/table/cell/TableCellNumber.svelte +2 -1
  158. package/dist/ui/table/cell/TableCellNumber.svelte.d.ts +18 -14
  159. package/dist/ui/table/cell/TableCellString.svelte +5 -2
  160. package/dist/ui/table/cell/TableCellString.svelte.d.ts +19 -25
  161. package/dist/ui/table/field.d.ts +32 -40
  162. package/dist/ui/table/field.js +1 -1
  163. package/dist/ui/table/head/TableHeadBoolean.svelte +6 -3
  164. package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +18 -24
  165. package/dist/ui/table/head/TableHeadDate.svelte +61 -113
  166. package/dist/ui/table/head/TableHeadDate.svelte.d.ts +18 -24
  167. package/dist/ui/table/head/TableHeadDefault.svelte +5 -2
  168. package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +18 -24
  169. package/dist/ui/table/head/TableHeadNumber.svelte +67 -76
  170. package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +18 -24
  171. package/dist/ui/table/head/TableHeadSelect.svelte +47 -41
  172. package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +21 -27
  173. package/dist/ui/table/head/TableHeadString.svelte +14 -8
  174. package/dist/ui/table/head/TableHeadString.svelte.d.ts +18 -24
  175. package/dist/ui/tabs/Tabs.svelte +8 -5
  176. package/dist/ui/tabs/Tabs.svelte.d.ts +19 -15
  177. package/dist/ui/tabs/TabsIcon.svelte +31 -28
  178. package/dist/ui/tabs/TabsIcon.svelte.d.ts +21 -17
  179. package/dist/utils/eventEmitter.d.ts +4 -4
  180. package/dist/utils/tippy.d.ts +1 -1
  181. package/dist/validation/form.d.ts +0 -1
  182. package/dist/validation/zod.d.ts +96 -162
  183. package/dist/validation/zod.js +2 -4
  184. package/package.json +134 -138
  185. package/dist/ui/form/FormInput.svelte.d.ts +0 -152
  186. package/dist/ui/form/formInput.d.ts +0 -90
  187. package/dist/ui/slot/Slot.svelte +0 -35
  188. package/dist/ui/slot/Slot.svelte.d.ts +0 -22
  189. package/dist/ui/slot/Span.svelte +0 -4
  190. package/dist/ui/slot/Span.svelte.d.ts +0 -16
  191. package/dist/ui/slot/index.d.ts +0 -1
  192. package/dist/ui/slot/index.js +0 -1
  193. package/dist/ui/table/head/OrderButtons.svelte +0 -37
  194. package/dist/ui/table/head/OrderButtons.svelte.d.ts +0 -20
  195. package/dist/ui/table/head/index.d.ts +0 -19
@@ -1,33 +1,39 @@
1
- <script>import { slide } from "svelte/transition";
2
- import { page } from "$app/stores";
3
- import { InputText, InputPassword } from "../input/index.js";
4
- import { useForm } from "../../validation/form.js";
5
- export let onSuccess = void 0;
6
- const { enhance } = useForm({
7
- onSuccess,
8
- successMessage(action) {
9
- if (action.search === "?/reset_password") {
10
- recorverDialog.close();
11
- state = "login";
12
- return "Un lien de r\xE9cup\xE9ration t'a \xE9t\xE9 envoy\xE9 par email";
13
- }
14
- return "Bienvenue";
15
- },
16
- onError(err) {
17
- if (err === "This account already exists") {
18
- state = "login";
19
- return;
20
- }
21
- if (err === "This account already created from an invitation") {
22
- recorverDialog.showModal();
23
- return;
24
- }
25
- }
26
- });
27
- let state = "login";
28
- $:
29
- redirectTo = $page.url.searchParams.get("redirectTo");
30
- let recorverDialog;
1
+ <script lang="ts">
2
+ import { slide } from 'svelte/transition'
3
+ import { page } from '$app/stores'
4
+ import { InputText, InputPassword } from '../input/index.js'
5
+ import { useForm } from '../../validation/form.js'
6
+
7
+ export let onSuccess:
8
+ | ((action: URL, data?: Record<string, unknown> | undefined) => any)
9
+ | undefined = undefined
10
+
11
+ const { enhance } = useForm({
12
+ onSuccess,
13
+ successMessage(action) {
14
+ if (action.search === '?/reset_password') {
15
+ recorverDialog.close()
16
+ state = 'login'
17
+ return "Un lien de récupération t'a été envoyé par email"
18
+ }
19
+ return 'Bienvenue'
20
+ },
21
+ onError(err) {
22
+ if (err === 'This account already exists') {
23
+ state = 'login'
24
+ return
25
+ }
26
+ if (err === 'This account already created from an invitation') {
27
+ recorverDialog.showModal()
28
+ return
29
+ }
30
+ }
31
+ })
32
+ let state: 'login' | 'register' = 'login'
33
+
34
+ $: redirectTo = $page.url.searchParams.get('redirectTo')
35
+
36
+ let recorverDialog: HTMLDialogElement
31
37
  </script>
32
38
 
33
39
  <div class="grid place-content-center p-10">
@@ -82,7 +88,7 @@ let recorverDialog;
82
88
  <button class="btn" formaction="/auth?/{state}">
83
89
  {state === 'login' ? 'Connexion' : 'Valider'}
84
90
  </button>
85
- <div class="grow" />
91
+ <div class="grow"></div>
86
92
 
87
93
  <button class="link-hover link" formaction="/auth?/reset_password">
88
94
  Mot de passe oublié
@@ -1,16 +1,20 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- onSuccess?: ((action: URL, data?: Record<string, unknown> | undefined) => any) | undefined;
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;
5
11
  };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
10
- };
11
- export type LoginProps = typeof __propDef.props;
12
- export type LoginEvents = typeof __propDef.events;
13
- export type LoginSlots = typeof __propDef.slots;
14
- export default class Login extends SvelteComponent<LoginProps, LoginEvents, LoginSlots> {
12
+ z_$$bindings?: Bindings;
15
13
  }
16
- export {};
14
+ declare const Login: $$__sveltets_2_IsomorphicComponent<{
15
+ onSuccess?: ((action: URL, data?: Record<string, unknown> | undefined) => any) | undefined;
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type Login = InstanceType<typeof Login>;
20
+ export default Login;
@@ -1,34 +1,40 @@
1
- <script>import { createEventDispatcher } from "svelte";
2
- import { Dialog } from "../dialog/index.js";
3
- import { DropDown } from "./index.js";
4
- import { isSmallScreen } from "../../store/index.js";
5
- export let tippyProps = {};
6
- let klass = "";
7
- export { klass as class };
8
- const dispatch = createEventDispatcher();
9
- let dropdown;
10
- let dialog;
11
- export function show(event) {
12
- if ($isSmallScreen) {
13
- dialog?.showModal();
14
- } else {
15
- const target = event.target;
16
- if (!target || !(target instanceof HTMLElement))
17
- return;
18
- dropdown?.setTippyProps({
19
- getReferenceClientRect: () => new DOMRect(event.clientX, event.clientY)
20
- });
21
- dropdown?.show();
22
- }
23
- dispatch("show");
24
- }
25
- export function hide() {
26
- if ($isSmallScreen)
27
- dialog?.close();
28
- else
29
- dropdown?.hide();
30
- dispatch("hide");
31
- }
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from 'svelte'
3
+ import type { TippyProps } from '../../utils/tippy.js'
4
+
5
+ import { Dialog } from '../dialog/index.js'
6
+ import { DropDown } from './index.js'
7
+ import { isSmallScreen } from '../../store/index.js'
8
+
9
+ export let tippyProps: Partial<TippyProps> = {}
10
+ let klass = ''
11
+ export { klass as class }
12
+
13
+ const dispatch = createEventDispatcher<{ show: void; hide: void }>()
14
+
15
+ let dropdown: DropDown
16
+ let dialog: HTMLDialogElement
17
+
18
+ export function show(event: MouseEvent) {
19
+ if ($isSmallScreen) {
20
+ dialog?.showModal()
21
+ } else {
22
+ const target = event.target as HTMLElement
23
+ if (!target || !(target instanceof HTMLElement)) return
24
+ dropdown?.setTippyProps({
25
+ getReferenceClientRect: () => new DOMRect(event.clientX, event.clientY)
26
+ })
27
+ dropdown?.show()
28
+ }
29
+
30
+ dispatch('show')
31
+ }
32
+
33
+ export function hide() {
34
+ if ($isSmallScreen) dialog?.close()
35
+ else dropdown?.hide()
36
+ dispatch('hide')
37
+ }
32
38
  </script>
33
39
 
34
40
  {#if $isSmallScreen}
@@ -1,28 +1,41 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { TippyProps } from '../../utils/tippy.js';
3
- declare const __propDef: {
4
- props: {
5
- tippyProps?: Partial<TippyProps> | undefined;
6
- class?: string | undefined;
7
- show?: ((event: MouseEvent) => void) | undefined;
8
- hide?: (() => void) | undefined;
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;
9
12
  };
10
- events: {
11
- show: CustomEvent<void>;
12
- hide: CustomEvent<void>;
13
- } & {
14
- [evt: string]: CustomEvent<any>;
15
- };
16
- slots: {
17
- header: {};
18
- default: {};
19
- };
20
- };
21
- export type ContextMenuProps = typeof __propDef.props;
22
- export type ContextMenuEvents = typeof __propDef.events;
23
- export type ContextMenuSlots = typeof __propDef.slots;
24
- export default class ContextMenu extends SvelteComponent<ContextMenuProps, ContextMenuEvents, ContextMenuSlots> {
25
- get show(): (event: MouseEvent) => void;
26
- get hide(): () => void;
13
+ z_$$bindings?: Bindings;
27
14
  }
28
- export {};
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 ContextMenu: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
21
+ tippyProps?: Partial<TippyProps>;
22
+ class?: string;
23
+ show?: (event: MouseEvent) => void;
24
+ hide?: () => void;
25
+ }, {
26
+ header: {};
27
+ default: {};
28
+ }>, {
29
+ show: CustomEvent<void>;
30
+ hide: CustomEvent<void>;
31
+ } & {
32
+ [evt: string]: CustomEvent<any>;
33
+ }, {
34
+ header: {};
35
+ default: {};
36
+ }, {
37
+ show: (event: MouseEvent) => void;
38
+ hide: () => void;
39
+ }, string>;
40
+ type ContextMenu = InstanceType<typeof ContextMenu>;
41
+ export default ContextMenu;
@@ -1,88 +1,97 @@
1
- <script context="module">import { createSingleton } from "../../utils/tippy.js";
2
- const sigleton = browser ? createSingleton([], {
3
- theme: "dropdown",
4
- arrow: false,
5
- moveTransition: "transform 0.1s ease-out",
6
- interactive: true,
7
- interactiveDebounce: 50
8
- }) : null;
9
- const tips = [];
1
+ <script lang="ts" context="module">
2
+ import { createSingleton, type TippyInstance } from '../../utils/tippy.js'
3
+
4
+ const sigleton = browser
5
+ ? createSingleton([], {
6
+ theme: 'dropdown',
7
+ arrow: false,
8
+ moveTransition: 'transform 0.1s ease-out',
9
+ interactive: true,
10
+ interactiveDebounce: 50
11
+ })
12
+ : null
13
+
14
+ const tips: TippyInstance[] = []
10
15
  </script>
11
16
 
12
- <script>import { tippy } from "../../utils/tippy.js";
13
- import { onMount } from "svelte";
14
- import { browser } from "$app/environment";
15
- import { beforeNavigate } from "$app/navigation";
16
- import "./dropdown.css";
17
- export let tippyProps = {};
18
- let klass = "";
19
- export { klass as class };
20
- export let classWrapper = "";
21
- export let classActivator = "";
22
- export let useSingleton = false;
23
- export let autofocus = false;
24
- export let hideOnBlur = false;
25
- export let hideOnNav = true;
26
- export let tip = void 0;
27
- export let disable = false;
28
- export let content = void 0;
29
- let activator;
30
- beforeNavigate(() => hideOnNav && hide());
31
- onMount(() => {
32
- if (disable)
33
- return;
34
- const triggerTarget = activator.querySelector("button, input") || activator;
35
- const focusables = Array.from(
36
- content.querySelectorAll(
37
- "a[href], button, input, textarea, select, details, [tabindex]"
38
- )
39
- );
40
- tip = tippy(activator, {
41
- content,
42
- placement: "bottom-start",
43
- theme: "dropdown",
44
- arrow: false,
45
- triggerTarget,
46
- trigger: "click focus",
47
- interactive: true,
48
- interactiveDebounce: 50,
49
- appendTo: "parent",
50
- onShown() {
51
- if (autofocus)
52
- focusables[0]?.select();
53
- },
54
- ...tippyProps
55
- });
56
- if (useSingleton && tip) {
57
- tips.push(tip);
58
- sigleton?.setInstances(tips);
59
- }
60
- const lastFocusable = focusables.at(-1);
61
- if (hideOnBlur)
62
- lastFocusable?.addEventListener("blur", hide);
63
- return () => {
64
- if (hideOnBlur)
65
- lastFocusable?.removeEventListener("blur", hide);
66
- if (useSingleton && tip) {
67
- tips.splice(tips.indexOf(tip), 1);
68
- tip.destroy();
69
- }
70
- };
71
- });
72
- export function hide() {
73
- if (!tip)
74
- return;
75
- if (useSingleton)
76
- sigleton?.hide();
77
- else
78
- tip.hide();
79
- }
80
- export function show() {
81
- tip?.show();
82
- }
83
- export function setTippyProps(props) {
84
- tip?.setProps(props);
85
- }
17
+ <script lang="ts">
18
+ import { tippy, type TippyProps } from '../../utils/tippy.js'
19
+ import { onMount } from 'svelte'
20
+ import { browser } from '$app/environment'
21
+ import { beforeNavigate } from '$app/navigation'
22
+ import './dropdown.css'
23
+
24
+ export let tippyProps: Partial<TippyProps> = {}
25
+ let klass = ''
26
+ export { klass as class }
27
+ export let classWrapper = ''
28
+ export let classActivator = ''
29
+ export let useSingleton = false
30
+ export let autofocus = false
31
+ export let hideOnBlur = false
32
+ export let hideOnNav = true
33
+ export let tip: TippyInstance | undefined = undefined
34
+ // By pass dropdown for use in flat mode
35
+ export let disable = false
36
+ export let content: HTMLDivElement | undefined = undefined
37
+ let activator: HTMLDivElement
38
+
39
+ beforeNavigate(() => hideOnNav && hide())
40
+
41
+ onMount(() => {
42
+ if (disable) return
43
+
44
+ const triggerTarget = activator.querySelector('button, input') || activator
45
+ const focusables = Array.from(
46
+ content!.querySelectorAll<HTMLInputElement>(
47
+ 'a[href], button, input, textarea, select, details, [tabindex]'
48
+ )
49
+ )
50
+ tip = tippy(activator, {
51
+ content,
52
+ placement: 'bottom-start',
53
+ theme: 'dropdown',
54
+ arrow: false,
55
+ triggerTarget,
56
+ trigger: 'click focus',
57
+ interactive: true,
58
+ interactiveDebounce: 50,
59
+ appendTo: 'parent',
60
+ onShown() {
61
+ if (autofocus) focusables[0]?.select()
62
+ },
63
+ ...tippyProps
64
+ })
65
+
66
+ if (useSingleton && tip) {
67
+ tips.push(tip)
68
+ sigleton?.setInstances(tips)
69
+ }
70
+
71
+ const lastFocusable = focusables.at(-1)
72
+ if (hideOnBlur) lastFocusable?.addEventListener('blur', hide)
73
+
74
+ return () => {
75
+ if (hideOnBlur) lastFocusable?.removeEventListener('blur', hide)
76
+ if (useSingleton && tip) {
77
+ tips.splice(tips.indexOf(tip), 1)
78
+ tip.destroy()
79
+ }
80
+ }
81
+ })
82
+
83
+ export function hide() {
84
+ if (!tip) return
85
+ if (useSingleton) sigleton?.hide()
86
+ else tip.hide()
87
+ }
88
+
89
+ export function show() {
90
+ tip?.show()
91
+ }
92
+ export function setTippyProps(props: Partial<TippyProps>) {
93
+ tip?.setProps(props)
94
+ }
86
95
  </script>
87
96
 
88
97
  {#if !disable}
@@ -1,38 +1,51 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import { type TippyInstance } from '../../utils/tippy.js';
3
2
  import { type TippyProps } from '../../utils/tippy.js';
4
3
  import './dropdown.css';
5
- declare const __propDef: {
6
- props: {
7
- tippyProps?: Partial<TippyProps> | undefined;
8
- class?: string | undefined;
9
- classWrapper?: string | undefined;
10
- classActivator?: string | undefined;
11
- useSingleton?: boolean | undefined;
12
- autofocus?: boolean | undefined;
13
- hideOnBlur?: boolean | undefined;
14
- hideOnNav?: boolean | undefined;
15
- tip?: TippyInstance | undefined;
16
- disable?: boolean | undefined;
17
- content?: HTMLDivElement | undefined;
18
- hide?: (() => void) | undefined;
19
- show?: (() => void) | undefined;
20
- setTippyProps?: ((props: Partial<TippyProps>) => void) | undefined;
4
+ 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> {
5
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: Props & {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
21
14
  };
22
- events: {
23
- [evt: string]: CustomEvent<any>;
24
- };
25
- slots: {
26
- activator: {};
27
- default: {};
28
- };
29
- };
30
- export type DropDownProps = typeof __propDef.props;
31
- export type DropDownEvents = typeof __propDef.events;
32
- export type DropDownSlots = typeof __propDef.slots;
33
- export default class DropDown extends SvelteComponent<DropDownProps, DropDownEvents, DropDownSlots> {
34
- get hide(): () => void;
35
- get show(): () => void;
36
- get setTippyProps(): (props: Partial<TippyProps>) => void;
15
+ z_$$bindings?: Bindings;
37
16
  }
38
- export {};
17
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
18
+ default: any;
19
+ } ? Props extends Record<string, never> ? any : {
20
+ children?: any;
21
+ } : {});
22
+ declare const DropDown: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
23
+ tippyProps?: Partial<TippyProps>;
24
+ class?: string;
25
+ classWrapper?: string;
26
+ classActivator?: string;
27
+ useSingleton?: boolean;
28
+ autofocus?: boolean;
29
+ hideOnBlur?: boolean;
30
+ hideOnNav?: boolean;
31
+ tip?: TippyInstance | undefined;
32
+ disable?: boolean;
33
+ content?: HTMLDivElement | undefined;
34
+ hide?: () => void;
35
+ show?: () => void;
36
+ setTippyProps?: (props: Partial<TippyProps>) => void;
37
+ }, {
38
+ activator: {};
39
+ default: {};
40
+ }>, {
41
+ [evt: string]: CustomEvent<any>;
42
+ }, {
43
+ activator: {};
44
+ default: {};
45
+ }, {
46
+ hide: () => void;
47
+ show: () => void;
48
+ setTippyProps: (props: Partial<TippyProps>) => void;
49
+ }, string>;
50
+ type DropDown = InstanceType<typeof DropDown>;
51
+ export default DropDown;
@@ -1,21 +1,28 @@
1
- <script>import { createEventDispatcher } from "svelte";
2
- import { mdiUnfoldMoreHorizontal } from "@mdi/js";
3
- import { Icon } from "../icon/index.js";
4
- import { DropDown } from "./index.js";
5
- import { SelectorList } from "../input/index.js";
6
- import { parseOptions } from "../../utils/options.js";
7
- export let options;
8
- export let tippyProps = {};
9
- $:
10
- _options = parseOptions(options);
11
- let trigger;
12
- let dropDown;
13
- const dispatch = createEventDispatcher();
14
- function onSelect(index) {
15
- const option = _options[index];
16
- dispatch("select", option.value);
17
- dropDown.hide();
18
- }
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from 'svelte'
3
+ import { mdiUnfoldMoreHorizontal } from '@mdi/js'
4
+
5
+ import { Icon } from '../icon/index.js'
6
+ import { DropDown } from './index.js'
7
+ import { SelectorList } from '../input/index.js'
8
+ import { type Options, parseOptions } from '../../utils/options.js'
9
+ import type { TippyProps } from '../../utils/tippy.js'
10
+
11
+ export let options: Options
12
+ export let tippyProps: Partial<TippyProps> = {}
13
+
14
+ $: _options = parseOptions(options)
15
+
16
+ let trigger: HTMLDivElement
17
+
18
+ let dropDown: DropDown
19
+ const dispatch = createEventDispatcher<{ select: string }>()
20
+
21
+ function onSelect(index: number) {
22
+ const option = _options[index]
23
+ dispatch('select', option.value)
24
+ dropDown.hide()
25
+ }
19
26
  </script>
20
27
 
21
28
  <DropDown bind:this={dropDown} {tippyProps}>
@@ -1,23 +1,34 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import { type Options } from '../../utils/options.js';
3
2
  import type { TippyProps } from '../../utils/tippy.js';
4
- declare const __propDef: {
5
- props: {
6
- options: Options;
7
- tippyProps?: Partial<TippyProps> | undefined;
3
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
4
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
5
+ $$bindings?: Bindings;
6
+ } & Exports;
7
+ (internal: unknown, props: Props & {
8
+ $$events?: Events;
9
+ $$slots?: Slots;
10
+ }): Exports & {
11
+ $set?: any;
12
+ $on?: any;
8
13
  };
9
- events: {
10
- select: CustomEvent<string>;
11
- } & {
12
- [evt: string]: CustomEvent<any>;
13
- };
14
- slots: {
15
- default: {};
16
- };
17
- };
18
- export type DropDownMenuProps = typeof __propDef.props;
19
- export type DropDownMenuEvents = typeof __propDef.events;
20
- export type DropDownMenuSlots = typeof __propDef.slots;
21
- export default class DropDownMenu extends SvelteComponent<DropDownMenuProps, DropDownMenuEvents, DropDownMenuSlots> {
14
+ z_$$bindings?: Bindings;
22
15
  }
23
- export {};
16
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
17
+ default: any;
18
+ } ? Props extends Record<string, never> ? any : {
19
+ children?: any;
20
+ } : {});
21
+ declare const DropDownMenu: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
22
+ options: Options;
23
+ tippyProps?: Partial<TippyProps>;
24
+ }, {
25
+ default: {};
26
+ }>, {
27
+ select: CustomEvent<string>;
28
+ } & {
29
+ [evt: string]: CustomEvent<any>;
30
+ }, {
31
+ default: {};
32
+ }, {}, string>;
33
+ type DropDownMenu = InstanceType<typeof DropDownMenu>;
34
+ export default DropDownMenu;