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,41 +1,49 @@
1
- <script>import { mdiLinkVariant } from "@mdi/js";
2
- import { Dialog } from "../../dialog/index.js";
3
- import { InputText } from "../index.js";
4
- import { z } from "../../../validation/zod.js";
5
- import ToolMark from "./ToolMark.svelte";
6
- export let editor;
7
- let dialogLink;
8
- let linkHref = "";
9
- let linkError = "";
10
- async function handleNewLink() {
11
- if (!linkHref) {
12
- linkError = "URL requis";
13
- return;
14
- }
15
- const isEmail = z.string().email().safeParse(linkHref);
16
- if (isEmail.success)
17
- linkHref = "mailto:" + linkHref;
18
- else if (!linkHref.match(/^http(s)?:\/\//)) {
19
- linkHref = "https://" + linkHref;
20
- }
21
- const isUrl = z.string().url().safeParse(linkHref);
22
- if (!isUrl.success) {
23
- linkError = "URL invalide";
24
- return;
25
- }
26
- editor.chain().focus().setLink({ href: linkHref }).run();
27
- dialogLink.close();
28
- }
29
- function handleRemoveLink() {
30
- editor.chain().focus().unsetLink().run();
31
- dialogLink.close();
32
- }
33
- function handleKeyDown(event) {
34
- if (event.key !== "Enter")
35
- return;
36
- event.preventDefault();
37
- handleNewLink();
38
- }
1
+ <script lang="ts">
2
+ import type { Editor } from '@tiptap/core'
3
+ import { mdiLinkVariant } from '@mdi/js'
4
+
5
+ import { Dialog } from '../../dialog/index.js'
6
+ import { InputText } from '../index.js'
7
+ import { z } from '../../../validation/zod.js'
8
+ import ToolMark from './ToolMark.svelte'
9
+
10
+ export let editor: Editor
11
+ let dialogLink: HTMLDialogElement
12
+ let linkHref = ''
13
+ let linkError = ''
14
+
15
+ async function handleNewLink() {
16
+ if (!linkHref) {
17
+ linkError = 'URL requis'
18
+ return
19
+ }
20
+
21
+ const isEmail = z.string().email().safeParse(linkHref)
22
+ if (isEmail.success) linkHref = 'mailto:' + linkHref
23
+ else if (!linkHref.match(/^http(s)?:\/\//)) {
24
+ linkHref = 'https://' + linkHref
25
+ }
26
+
27
+ const isUrl = z.string().url().safeParse(linkHref)
28
+ if (!isUrl.success) {
29
+ linkError = 'URL invalide'
30
+ return
31
+ }
32
+
33
+ editor.chain().focus().setLink({ href: linkHref }).run()
34
+ dialogLink.close()
35
+ }
36
+
37
+ function handleRemoveLink() {
38
+ editor.chain().focus().unsetLink().run()
39
+ dialogLink.close()
40
+ }
41
+
42
+ function handleKeyDown(event: KeyboardEvent) {
43
+ if (event.key !== 'Enter') return
44
+ event.preventDefault()
45
+ handleNewLink()
46
+ }
39
47
  </script>
40
48
 
41
49
  <ToolMark
@@ -1,22 +1,37 @@
1
- <script>import { mdiChevronDown } from "@mdi/js";
2
- import { Icon } from "../../icon/index.js";
3
- import { DropDown } from "../../menu/index.js";
4
- export let editor;
5
- export let tools;
6
- export let hideLabel = false;
7
- let dropdown;
8
- function handleClick(tool) {
9
- tool.action();
10
- dropdown.hide();
11
- }
12
- $:
13
- toolSelected = tools.find((t) => {
14
- if (t.key)
15
- return editor.isActive(t.key, t.attributes);
16
- if (t.attributes)
17
- return editor.isActive(t.attributes);
18
- return false;
19
- }) || tools[0];
1
+ <script lang="ts">
2
+ import type { Editor } from '@tiptap/core'
3
+ import { mdiChevronDown } from '@mdi/js'
4
+
5
+ import { Icon } from '../../icon/index.js'
6
+ import { DropDown } from '../../menu/index.js'
7
+
8
+ type Tool = {
9
+ key?: string
10
+ attributes?: {}
11
+ label: string
12
+ icon: string
13
+ action: () => unknown
14
+ newSection?: true
15
+ disable?: boolean
16
+ }
17
+
18
+ export let editor: Editor
19
+ export let tools: Tool[]
20
+ export let hideLabel = false
21
+
22
+ let dropdown: DropDown
23
+
24
+ function handleClick(tool: Tool) {
25
+ tool.action()
26
+ dropdown.hide()
27
+ }
28
+
29
+ $: toolSelected =
30
+ tools.find((t) => {
31
+ if (t.key) return editor.isActive(t.key, t.attributes)
32
+ if (t.attributes) return editor.isActive(t.attributes)
33
+ return false
34
+ }) || tools[0]
20
35
  </script>
21
36
 
22
37
  <DropDown hideOnBlur bind:this={dropdown}>
@@ -1,12 +1,16 @@
1
- <script>import {
2
- mdiAlignHorizontalLeft,
3
- mdiAlignHorizontalCenter,
4
- mdiAlignHorizontalRight,
5
- mdiFormatIndentIncrease,
6
- mdiFormatIndentDecrease
7
- } from "@mdi/js";
8
- import ToolMenu from "./ToolMenu.svelte";
9
- export let editor;
1
+ <script lang="ts">
2
+ import type { Editor } from '@tiptap/core'
3
+ import {
4
+ mdiAlignHorizontalLeft,
5
+ mdiAlignHorizontalCenter,
6
+ mdiAlignHorizontalRight,
7
+ mdiFormatIndentIncrease,
8
+ mdiFormatIndentDecrease,
9
+ } from '@mdi/js'
10
+
11
+ import ToolMenu from './ToolMenu.svelte'
12
+
13
+ export let editor: Editor
10
14
  </script>
11
15
 
12
16
  <ToolMenu
@@ -1,10 +1,15 @@
1
- <script>import { createEventDispatcher } from "svelte";
2
- import { mdiPlus, mdiMinus, mdiImageOutline, mdiYoutube, mdiAt } from "@mdi/js";
3
- import { Icon } from "../../icon/index.js";
4
- import ToolMenu from "./ToolMenu.svelte";
5
- import { suggestionItems } from "./suggestion.js";
6
- export let editor;
7
- const dispatch = createEventDispatcher();
1
+ <script lang="ts">
2
+ import { createEventDispatcher } from 'svelte'
3
+ import type { Editor } from '@tiptap/core'
4
+ import { mdiPlus, mdiMinus, mdiImageOutline, mdiYoutube, mdiAt } from '@mdi/js'
5
+
6
+ import { Icon } from '../../icon/index.js'
7
+ import ToolMenu from './ToolMenu.svelte'
8
+ import { suggestionItems } from './suggestion.js'
9
+
10
+ export let editor: Editor
11
+
12
+ const dispatch = createEventDispatcher<{ insertMedia: void }>()
8
13
  </script>
9
14
 
10
15
  <ToolMenu
@@ -1,13 +1,17 @@
1
- <script>import {
2
- mdiText,
3
- mdiFormatListBulleted,
4
- mdiFormatListNumbered,
5
- mdiFormatHeader1,
6
- mdiFormatHeader3,
7
- mdiFormatHeader2
8
- } from "@mdi/js";
9
- import ToolMenu from "./ToolMenu.svelte";
10
- export let editor;
1
+ <script lang="ts">
2
+ import type { Editor } from '@tiptap/core'
3
+ import {
4
+ mdiText,
5
+ mdiFormatListBulleted,
6
+ mdiFormatListNumbered,
7
+ mdiFormatHeader1,
8
+ mdiFormatHeader3,
9
+ mdiFormatHeader2,
10
+ } from '@mdi/js'
11
+
12
+ import ToolMenu from './ToolMenu.svelte'
13
+
14
+ export let editor: Editor
11
15
  </script>
12
16
 
13
17
  <ToolMenu
@@ -1,14 +1,18 @@
1
- <script>import { mdiFormatBold, mdiFormatColorFill, mdiFormatColorText, mdiFormatItalic } from "@mdi/js";
2
- import { toast } from "svelte-sonner";
3
- import ToolMenuNode from "./ToolMenuNode.svelte";
4
- import ToolMark from "./ToolMark.svelte";
5
- import ToolMarkColor from "./ToolMarkColor.svelte";
6
- import ToolMarkLink from "./ToolMarkLink.svelte";
7
- import ToolMenuAlign from "./ToolMenuAlign.svelte";
8
- import ToolMenuInsert from "./ToolMenuInsert.svelte";
9
- export let editor;
10
- let klass = "";
11
- export { klass as class };
1
+ <script lang="ts">
2
+ import type { Editor } from '@tiptap/core'
3
+ import { mdiFormatBold, mdiFormatColorFill, mdiFormatColorText, mdiFormatItalic } from '@mdi/js'
4
+ import { toast } from 'svelte-sonner'
5
+
6
+ import ToolMenuNode from './ToolMenuNode.svelte'
7
+ import ToolMark from './ToolMark.svelte'
8
+ import ToolMarkColor from './ToolMarkColor.svelte'
9
+ import ToolMarkLink from './ToolMarkLink.svelte'
10
+ import ToolMenuAlign from './ToolMenuAlign.svelte'
11
+ import ToolMenuInsert from './ToolMenuInsert.svelte'
12
+
13
+ export let editor: Editor
14
+ let klass = ''
15
+ export { klass as class }
12
16
  </script>
13
17
 
14
18
  <div
@@ -20,7 +24,7 @@ export { klass as class };
20
24
  <div class="flex overflow-x-auto p-2">
21
25
  <ToolMenuNode {editor} />
22
26
  <ToolMenuAlign {editor} />
23
- <div class="mx-1 my-auto h-6 border border-y-0 border-l-0" />
27
+ <div class="mx-1 my-auto h-6 border border-y-0 border-l-0"></div>
24
28
 
25
29
  <ToolMark
26
30
  {editor}
@@ -50,7 +54,7 @@ export { klass as class };
50
54
  setColor={(color) => editor.commands.setHighlight({ color })}
51
55
  />
52
56
 
53
- <div class="mx-1 my-auto h-6 border border-y-0 border-l-0" />
57
+ <div class="mx-1 my-auto h-6 border border-y-0 border-l-0"></div>
54
58
 
55
59
  <ToolMenuInsert
56
60
  {editor}
@@ -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,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}
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  class?: string | undefined;
7
7
  show?: ((event: MouseEvent) => void) | undefined;
8
8
  hide?: (() => void) | undefined;
9
+ children?: import("svelte").Snippet<[]> | undefined;
9
10
  };
10
11
  events: {
11
12
  show: CustomEvent<void>;
@@ -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}
@@ -18,6 +18,7 @@ declare const __propDef: {
18
18
  hide?: (() => void) | undefined;
19
19
  show?: (() => void) | undefined;
20
20
  setTippyProps?: ((props: Partial<TippyProps>) => void) | undefined;
21
+ children?: import("svelte").Snippet<[]> | undefined;
21
22
  };
22
23
  events: {
23
24
  [evt: string]: CustomEvent<any>;