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
@@ -1,30 +1,35 @@
1
- <script>import {} from "svelte";
2
- import { slide } from "svelte/transition";
3
- import { mdiEyeOffOutline, mdiEyeOutline } from "@mdi/js";
4
- import { Card } from "../ui/card/index.js";
5
- import { Table } from "../ui/table/index.js";
6
- import { Icon } from "../ui/icon/index.js";
7
- export let name = "";
8
- export let description = "";
9
- export let component;
10
- let props = [];
11
- let isPropsVisible = false;
12
- $:
13
- initMeta(component);
14
- function initMeta(c) {
15
- if (!c)
16
- return;
17
- updateComponentMeta(c);
18
- component.$$.after_update.push(() => updateComponentMeta(c));
19
- }
20
- function updateComponentMeta(c) {
21
- const ctx = c.$$.ctx;
22
- const propsIndex = Object.entries(c.$$.props);
23
- props = propsIndex.map(([id, index]) => ({
24
- id,
25
- value: ctx[index]
26
- }));
27
- }
1
+ <script lang="ts">
2
+ import { type SvelteComponent } from 'svelte'
3
+ import { slide } from 'svelte/transition'
4
+ import { mdiEyeOffOutline, mdiEyeOutline } from '@mdi/js'
5
+ import { Card } from '../ui/card/index.js'
6
+ import { Table } from '../ui/table/index.js'
7
+ import { Icon } from '../ui/icon/index.js'
8
+
9
+ export let name = ''
10
+ export let description = ''
11
+ export let component: SvelteComponent
12
+
13
+ type Props = { id: string; value: string }[]
14
+ let props: Props = []
15
+ let isPropsVisible = false
16
+
17
+ $: initMeta(component)
18
+
19
+ function initMeta(c: SvelteComponent | undefined) {
20
+ if (!c) return
21
+ updateComponentMeta(c)
22
+ component.$$.after_update.push(() => updateComponentMeta(c))
23
+ }
24
+
25
+ function updateComponentMeta(c: SvelteComponent) {
26
+ const ctx = c.$$.ctx
27
+ const propsIndex = Object.entries<number>(c.$$.props)
28
+ props = propsIndex.map(([id, index]) => ({
29
+ id,
30
+ value: ctx[index] as string
31
+ }))
32
+ }
28
33
  </script>
29
34
 
30
35
  <Card class="mx-auto mb-6 max-w-4xl">
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  name?: string | undefined;
5
5
  description?: string | undefined;
6
6
  component: SvelteComponent;
7
+ children?: import("svelte").Snippet<[]> | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -29,7 +29,7 @@ export declare const apiConfig: {
29
29
  };
30
30
  };
31
31
  };
32
- export declare const api: import("../api/config.js").ApiClient<Prisma.TypeMap<import("@prisma/client/runtime/library").DefaultArgs>, {
32
+ export declare const api: import("../api/config.js").ApiClient<Prisma.TypeMap<import("@prisma/client/runtime/library").DefaultArgs, {}>, {
33
33
  Tag: (search: string) => {
34
34
  where: {
35
35
  name: {
@@ -1,6 +1,7 @@
1
- <script>let klass = "";
2
- export { klass as class };
3
- export let content;
1
+ <script lang="ts">
2
+ let klass = ''
3
+ export { klass as class }
4
+ export let content: string
4
5
  </script>
5
6
 
6
7
  <span class="badge mr-1 whitespace-nowrap {klass}">
@@ -1,33 +1,39 @@
1
- <script>import { mdiClipboardTextOutline } from "@mdi/js";
2
- import { toast } from "svelte-sonner";
3
- import { Icon } from "../icon/index.js";
4
- let valueOrGetValue;
5
- export { valueOrGetValue as value };
6
- export let title = "";
7
- export let icon = mdiClipboardTextOutline;
8
- export let successMessage = "Copied";
9
- let isLoading = false;
10
- async function loadValue() {
11
- if (typeof valueOrGetValue === "string")
12
- return valueOrGetValue;
13
- return valueOrGetValue();
14
- }
15
- async function handleClick() {
16
- if (isLoading)
17
- return;
18
- isLoading = true;
19
- const value = await loadValue().finally(() => isLoading = false);
20
- navigator.clipboard.writeText(value).then(() => {
21
- toast.success(successMessage);
22
- }).catch((error) => {
23
- toast.error(error);
24
- });
25
- }
1
+ <script lang="ts">
2
+ import { mdiClipboardTextOutline } from '@mdi/js'
3
+ import { toast } from 'svelte-sonner'
4
+ import { Icon } from '../icon/index.js'
5
+ let valueOrGetValue: string | (() => Promise<string>)
6
+ export { valueOrGetValue as value }
7
+ export let title = ''
8
+ export let icon = mdiClipboardTextOutline
9
+ export let successMessage = 'Copied'
10
+
11
+ let isLoading = false
12
+
13
+ async function loadValue(): Promise<string> {
14
+ if (typeof valueOrGetValue === 'string') return valueOrGetValue
15
+ return valueOrGetValue()
16
+ }
17
+
18
+ async function handleClick() {
19
+ if (isLoading) return
20
+ isLoading = true
21
+ const value = await loadValue().finally(() => (isLoading = false))
22
+
23
+ navigator.clipboard
24
+ .writeText(value)
25
+ .then(() => {
26
+ toast.success(successMessage)
27
+ })
28
+ .catch((error) => {
29
+ toast.error(error)
30
+ })
31
+ }
26
32
  </script>
27
33
 
28
34
  <div class="relative">
29
35
  {#if isLoading}
30
- <span class="loading loading-spinner absolute left-1 top-1 scale-125 opacity-25" />
36
+ <span class="loading loading-spinner absolute left-1 top-1 scale-125 opacity-25"></span>
31
37
  {/if}
32
38
  <button
33
39
  class="btn btn-square btn-sm"
@@ -1,24 +1,26 @@
1
- <script>let klass = "";
2
- export { klass as class };
3
- export let formaction;
4
- export let disabled = false;
5
- export let btn = true;
6
- let button;
7
- let width = 0;
8
- let ready = false;
9
- let timeout;
10
- function handleClick(event) {
11
- if (ready)
12
- return;
13
- width = button.offsetWidth;
14
- event.preventDefault();
15
- ready = true;
16
- timeout = setTimeout(() => ready = false, 2e3);
17
- }
18
- function handleLeave() {
19
- ready = false;
20
- clearTimeout(timeout);
21
- }
1
+ <script lang="ts">
2
+ let klass = ''
3
+ export { klass as class }
4
+ export let formaction: string
5
+ export let disabled = false
6
+ export let btn = true
7
+
8
+ let button: HTMLButtonElement
9
+ let width = 0
10
+ let ready = false
11
+ let timeout: NodeJS.Timeout
12
+ function handleClick(event: MouseEvent) {
13
+ if (ready) return
14
+ width = button.offsetWidth
15
+ event.preventDefault()
16
+ ready = true
17
+ timeout = setTimeout(() => (ready = false), 2000)
18
+ }
19
+
20
+ function handleLeave() {
21
+ ready = false
22
+ clearTimeout(timeout)
23
+ }
22
24
  </script>
23
25
 
24
26
  <button
@@ -5,6 +5,7 @@ declare const __propDef: {
5
5
  formaction: string;
6
6
  disabled?: boolean | undefined;
7
7
  btn?: boolean | undefined;
8
+ children?: import("svelte").Snippet<[]> | undefined;
8
9
  };
9
10
  events: {
10
11
  [evt: string]: CustomEvent<any>;
@@ -1,13 +1,16 @@
1
- <script>import { mdiArrowLeft } from "@mdi/js";
2
- import { Icon } from "../icon/index.js";
3
- import { contextContainer } from "../context.js";
4
- let klass = "";
5
- export { klass as class };
6
- export let bodyClass = "";
7
- export let headerClass = "";
8
- export let returnUrl = "";
9
- export let style = "";
10
- contextContainer.set("card");
1
+ <script lang="ts">
2
+ import { mdiArrowLeft } from '@mdi/js'
3
+ import { Icon } from '../icon/index.js'
4
+ import { contextContainer } from '../context.js'
5
+
6
+ let klass = ''
7
+ export { klass as class }
8
+ export let bodyClass = ''
9
+ export let headerClass = ''
10
+ export let returnUrl = ''
11
+ export let style = ''
12
+
13
+ contextContainer.set('card')
11
14
  </script>
12
15
 
13
16
  <div class="card bordered border bg-base-100 shadow-lg {klass}" {style}>
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  headerClass?: string | undefined;
7
7
  returnUrl?: string | undefined;
8
8
  style?: string | undefined;
9
+ children?: import("svelte").Snippet<[]> | undefined;
9
10
  };
10
11
  events: {
11
12
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,8 @@
1
- <script>export let title = "";
2
- let klass = "";
3
- export { klass as class };
4
- export let style = "";
1
+ <script lang="ts">
2
+ export let title = ''
3
+ let klass = ''
4
+ export { klass as class }
5
+ export let style = ''
5
6
  </script>
6
7
 
7
8
  <div class="{klass} bg-base-100 border rounded-lg p-2 sm:p-5" {style}>
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  title?: string | undefined;
5
5
  class?: string | undefined;
6
6
  style?: string | undefined;
7
+ children?: import("svelte").Snippet<[]> | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -1,34 +1,38 @@
1
- <script>import { onDestroy } from "svelte";
2
- import { slide } from "svelte/transition";
3
- import { mdiChevronRight } from "@mdi/js";
4
- import { Icon } from "../icon/index.js";
5
- import { urlParam } from "../../store/index.js";
6
- import { goto } from "$app/navigation";
7
- export let value;
8
- let klass = "";
9
- export { klass as class };
10
- export let classHeader = "";
11
- export let classBody = "";
12
- export let classTitle = "";
13
- $:
14
- isOpen = $urlParam.hasValue("section", value);
15
- let header;
16
- let timeout;
17
- async function handleClick(event) {
18
- if (isClickOnInteractiveElement(event))
19
- return;
20
- await goto($urlParam.toggle({ section: value }), { noScroll: true, keepFocus: true });
21
- }
22
- function isClickOnInteractiveElement(event) {
23
- if (!event)
24
- return false;
25
- const target = event.target;
26
- const elements = [...header.querySelectorAll("a, button")];
27
- return !!elements.filter((element) => element.contains(target)).length;
28
- }
29
- onDestroy(() => {
30
- clearTimeout(timeout);
31
- });
1
+ <script lang="ts">
2
+ import { onDestroy } from 'svelte'
3
+ import { slide } from 'svelte/transition'
4
+ import { mdiChevronRight } from '@mdi/js'
5
+
6
+ import { Icon } from '../icon/index.js'
7
+ import { urlParam } from '../../store/index.js'
8
+ import { goto } from '$app/navigation'
9
+
10
+ export let value: string
11
+ let klass = ''
12
+ export { klass as class }
13
+ export let classHeader = ''
14
+ export let classBody = ''
15
+ export let classTitle = ''
16
+
17
+ $: isOpen = $urlParam.hasValue('section', value)
18
+ let header: HTMLDivElement
19
+
20
+ let timeout: NodeJS.Timeout
21
+ async function handleClick(event: MouseEvent | null) {
22
+ if (isClickOnInteractiveElement(event)) return
23
+ await goto($urlParam.toggle({ section: value }), { noScroll: true, keepFocus: true })
24
+ }
25
+
26
+ function isClickOnInteractiveElement(event: MouseEvent | null) {
27
+ if (!event) return false
28
+ const target = event.target as HTMLElement
29
+ const elements = [...header.querySelectorAll('a, button')]
30
+ return !!elements.filter((element) => element.contains(target)).length
31
+ }
32
+
33
+ onDestroy(() => {
34
+ clearTimeout(timeout)
35
+ })
32
36
  </script>
33
37
 
34
38
  <section class="card bordered border bg-base-100 shadow-md {klass}">
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  classHeader?: string | undefined;
7
7
  classBody?: string | undefined;
8
8
  classTitle?: string | undefined;
9
+ children?: import("svelte").Snippet<[]> | undefined;
9
10
  };
10
11
  events: {
11
12
  [evt: string]: CustomEvent<any>;
@@ -1,9 +1,11 @@
1
- <script>import { mdiArrowCollapse, mdiArrowExpand } from "@mdi/js";
2
- import { Icon } from "../icon/index.js";
3
- import { Card } from "./index.js";
4
- export let isFullScreen = false;
5
- let klass = "";
6
- export { klass as class };
1
+ <script lang="ts">
2
+ import { mdiArrowCollapse, mdiArrowExpand } from '@mdi/js'
3
+ import { Icon } from '../icon/index.js'
4
+ import { Card } from './index.js'
5
+
6
+ export let isFullScreen = false
7
+ let klass = ''
8
+ export { klass as class }
7
9
  </script>
8
10
 
9
11
  <Card
@@ -3,6 +3,9 @@ declare const __propDef: {
3
3
  props: {
4
4
  isFullScreen?: boolean | undefined;
5
5
  class?: string | undefined;
6
+ children?: import("svelte").Snippet<[{
7
+ isFullScreen: boolean;
8
+ }]> | undefined;
6
9
  };
7
10
  events: {
8
11
  [evt: string]: CustomEvent<any>;
@@ -1,7 +1,8 @@
1
- <script>export let href;
2
- export let title = "";
3
- let klass = "";
4
- export { klass as class };
1
+ <script lang="ts">
2
+ export let href: string
3
+ export let title = ''
4
+ let klass = ''
5
+ export { klass as class }
5
6
  </script>
6
7
 
7
8
  <div
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  href: string;
5
5
  title?: string | undefined;
6
6
  class?: string | undefined;
7
+ children?: import("svelte").Snippet<[]> | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -1,37 +1,44 @@
1
- <script>import { createEventDispatcher, onMount } from "svelte";
2
- import { mdiClose } from "@mdi/js";
3
- import { Icon } from "../icon/index.js";
4
- import { contextContainer } from "../context.js";
5
- export let dialog;
6
- export let hideCloseButton = false;
7
- let klass = "";
8
- export { klass as class };
9
- const dispatch = createEventDispatcher();
10
- contextContainer.set("dialog");
11
- onMount(() => {
12
- const inputsSelector = 'input:not([type=hidden], [tabindex="-1"])';
13
- const inputs = dialog.querySelectorAll(inputsSelector);
14
- const buttons = dialog.querySelectorAll("button");
15
- inputs.forEach((input) => input.tabIndex = -1);
16
- buttons.forEach((button) => button.tabIndex = -1);
17
- function onDialogOpen() {
18
- dispatch("open");
19
- inputs.forEach((input) => input.tabIndex = 0);
20
- buttons.forEach((button) => button.tabIndex = 0);
21
- if (!inputs[0])
22
- return;
23
- inputs[0].focus();
24
- inputs[0].select();
25
- }
26
- function onDialogClose() {
27
- dispatch("close");
28
- inputs.forEach((input) => input.tabIndex = -1);
29
- buttons.forEach((button) => button.tabIndex = -1);
30
- }
31
- const observer = new MutationObserver(() => dialog.open ? onDialogOpen() : onDialogClose());
32
- observer.observe(dialog, { attributeFilter: ["open"] });
33
- return () => observer.disconnect();
34
- });
1
+ <script lang="ts">
2
+ import { createEventDispatcher, onMount } from 'svelte'
3
+ import { mdiClose } from '@mdi/js'
4
+ import { Icon } from '../icon/index.js'
5
+ import { contextContainer } from '../context.js'
6
+
7
+ export let dialog: HTMLDialogElement
8
+ export let hideCloseButton = false
9
+ let klass = ''
10
+ export { klass as class }
11
+
12
+ const dispatch = createEventDispatcher<{ open: void; close: void }>()
13
+ contextContainer.set('dialog')
14
+
15
+ onMount(() => {
16
+ const inputsSelector = 'input:not([type=hidden], [tabindex="-1"])'
17
+ const inputs = dialog.querySelectorAll<HTMLInputElement>(inputsSelector)
18
+ const buttons = dialog.querySelectorAll<HTMLButtonElement>('button')
19
+
20
+ inputs.forEach((input) => (input.tabIndex = -1))
21
+ buttons.forEach((button) => (button.tabIndex = -1))
22
+
23
+ function onDialogOpen() {
24
+ dispatch('open')
25
+ inputs.forEach((input) => (input.tabIndex = 0))
26
+ buttons.forEach((button) => (button.tabIndex = 0))
27
+ if (!inputs[0]) return
28
+ inputs[0].focus()
29
+ inputs[0].select()
30
+ }
31
+
32
+ function onDialogClose() {
33
+ dispatch('close')
34
+ inputs.forEach((input) => (input.tabIndex = -1))
35
+ buttons.forEach((button) => (button.tabIndex = -1))
36
+ }
37
+
38
+ const observer = new MutationObserver(() => (dialog.open ? onDialogOpen() : onDialogClose()))
39
+ observer.observe(dialog, { attributeFilter: ['open'] })
40
+ return () => observer.disconnect()
41
+ })
35
42
  </script>
36
43
 
37
44
  <dialog bind:this={dialog} class="modal" tabindex="-1">
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  dialog: HTMLDialogElement;
5
5
  hideCloseButton?: boolean | undefined;
6
6
  class?: string | undefined;
7
+ children?: import("svelte").Snippet<[]> | undefined;
7
8
  };
8
9
  events: {
9
10
  open: CustomEvent<void>;
@@ -1,7 +1,9 @@
1
- <script>import { Dialog } from "./index.js";
2
- let dialog;
3
- let klass = "";
4
- export { klass as class };
1
+ <script lang="ts">
2
+ import { Dialog } from './index.js'
3
+
4
+ let dialog: HTMLDialogElement
5
+ let klass = ''
6
+ export { klass as class }
5
7
  </script>
6
8
 
7
9
  <button type="button" on:click={() => dialog.showModal()} class="btn btn-ghost {klass}">
@@ -2,6 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  class?: string | undefined;
5
+ children?: import("svelte").Snippet<[]> | undefined;
5
6
  };
6
7
  events: {
7
8
  [evt: string]: CustomEvent<any>;
@@ -1,40 +1,49 @@
1
- <script>import { onDestroy, onMount } from "svelte";
2
- import { fade } from "svelte/transition";
3
- import { mdiClose } from "@mdi/js";
4
- import { goto } from "$app/navigation";
5
- import { urlParam } from "../../store/param.js";
6
- import { Icon } from "../icon/index.js";
7
- import { subscibeDrawerLayers } from "./layers.js";
8
- import { contextContainer } from "../context.js";
9
- import { drawerFly } from "./drawerFly.js";
10
- export let title = "";
11
- export let key;
12
- let klass = "";
13
- export { klass as class };
14
- export let maxWidth = "32rem";
15
- export let classHeader = "";
16
- export let classBody = "";
17
- export let duration = 180;
18
- export let noOverlay = false;
19
- export let transitionX = 0;
20
- export let zIndex = 50;
21
- export function open(value = 1, options = {}) {
22
- return goto($urlParam.with({ [key]: value }), {
23
- ...options,
24
- replaceState: true,
25
- noScroll: true
26
- });
27
- }
28
- export function close(options = {}) {
29
- return goto($urlParam.without(key), { ...options, replaceState: true, noScroll: true });
30
- }
31
- const { offset, index, destroy, isActive } = subscibeDrawerLayers(key);
32
- onDestroy(destroy);
33
- contextContainer.set("drawer");
34
- let clientWidth = 0;
35
- onMount(() => {
36
- transitionX = $isActive ? clientWidth : 0;
37
- });
1
+ <script lang="ts">
2
+ import { onDestroy, onMount } from 'svelte'
3
+ import { fade } from 'svelte/transition'
4
+ import { mdiClose } from '@mdi/js'
5
+
6
+ import { goto } from '$app/navigation'
7
+ import { urlParam } from '../../store/param.js'
8
+ import { Icon } from '../icon/index.js'
9
+ import { subscibeDrawerLayers } from './layers.js'
10
+ import { contextContainer } from '../context.js'
11
+ import { drawerFly } from './drawerFly.js'
12
+
13
+ export let title = ''
14
+ /** Key used in url query params */
15
+ export let key: string
16
+
17
+ let klass = ''
18
+ export { klass as class }
19
+ export let maxWidth = '32rem'
20
+ export let classHeader = ''
21
+ export let classBody = ''
22
+ export let duration = 180
23
+ export let noOverlay = false
24
+ export let transitionX = 0
25
+ export let zIndex = 50
26
+
27
+ type GotoOptions = Parameters<typeof goto>[1]
28
+ export function open(value = 1, options: GotoOptions = {}) {
29
+ return goto($urlParam.with({ [key]: value }), {
30
+ ...options,
31
+ replaceState: true,
32
+ noScroll: true
33
+ })
34
+ }
35
+ export function close(options: GotoOptions = {}) {
36
+ return goto($urlParam.without(key), { ...options, replaceState: true, noScroll: true })
37
+ }
38
+
39
+ const { offset, index, destroy, isActive } = subscibeDrawerLayers(key)
40
+ onDestroy(destroy)
41
+ contextContainer.set('drawer')
42
+ let clientWidth = 0
43
+
44
+ onMount(() => {
45
+ transitionX = $isActive ? clientWidth : 0
46
+ })
38
47
  </script>
39
48
 
40
49
  {#if !noOverlay && $isActive}
@@ -45,7 +54,7 @@ onMount(() => {
45
54
  transition:fade={{ duration }}
46
55
  style="z-index: {zIndex + $index};"
47
56
  class="fixed inset-0 bg-black/15 backdrop-blur-[1.5px] dark:bg-white/15"
48
- />
57
+ ></div>
49
58
  {/if}
50
59
 
51
60
  {#if $isActive}