@ims360/svelte-ivory 0.4.11 → 0.4.12

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.
@@ -7,9 +7,7 @@
7
7
 
8
8
  <Input {...props}>
9
9
  {#snippet children({ id, class: inputClass })}
10
- <div
11
- class={merge([inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0'])}
12
- >
10
+ <div class={merge(inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0')}>
13
11
  <input
14
12
  type="text"
15
13
  bind:value={props.form.value, props.form.set}
@@ -72,12 +72,12 @@
72
72
  {@render children({ class: inputClass, id, ...inputProps })}
73
73
  {#if label}
74
74
  <label
75
- class={merge([
75
+ class={merge(
76
76
  'pointer-events-none absolute cursor-text px-1 transition-all select-none group-focus-within:top-0 group-focus-within:left-0 group-focus-within:text-sm focus:cursor-default',
77
77
  hasValue ? 'top-0 left-0 cursor-default text-sm' : 'top-10 left-3',
78
78
  hasIssues ? 'text-error-500' : 'text-surface-700-300',
79
79
  theme.current.input?.label?.class?.(hasValue, hasIssues)
80
- ])}
80
+ )}
81
81
  for={id}
82
82
  >
83
83
  {label}
@@ -2,7 +2,6 @@
2
2
  import { theme } from '../../../theme.svelte';
3
3
  import type { IvoryComponent } from '../../../types';
4
4
  import { merge } from '../../../utils/functions';
5
- import { onMount, tick } from 'svelte';
6
5
  import type { MouseEventHandler } from 'svelte/elements';
7
6
 
8
7
  export interface DialogProps extends IvoryComponent<HTMLElement> {
@@ -14,49 +13,43 @@
14
13
  <script lang="ts">
15
14
  let {
16
15
  class: clazz,
17
- onclose: close, // This is the prop from the parent
16
+ onclose: onclose, // This is the prop from the parent
18
17
  children,
19
18
  ...rest
20
19
  }: DialogProps = $props();
21
20
 
22
21
  let dialog = $state<HTMLDialogElement>();
23
22
 
24
- /**
25
- * This function "requests" a close.
26
- * It tries to stop the native close and lets the parent decide.
27
- */
28
- async function requestClose(event: Event) {
29
- event.preventDefault(); // Stop the native close
30
- event.stopPropagation();
31
- close?.(); // Ask the parent to close
32
- await tick();
33
- await tick();
23
+ let currentlyOpen = $state(false);
24
+
25
+ export const open = () => {
34
26
  dialog?.showModal();
35
- }
27
+ currentlyOpen = true;
28
+ };
29
+
30
+ export const isOpen = () => currentlyOpen;
36
31
 
37
- onMount(() => {
38
- if (dialog && !dialog.open) {
39
- dialog.showModal();
40
- }
41
- return () => {
42
- if (dialog && dialog.open) {
43
- dialog.close();
44
- }
45
- };
46
- });
32
+ export const close = () => {
33
+ dialog?.close();
34
+ currentlyOpen = false;
35
+ };
47
36
 
48
37
  const handleBackdropClick: MouseEventHandler<HTMLElement> = (event) => {
49
- if (event.target === dialog) {
50
- requestClose(event);
51
- }
38
+ if (event.target !== dialog) return;
39
+ onclose?.();
40
+ };
41
+
42
+ const handleClose = () => {
43
+ onclose?.();
44
+ currentlyOpen = false;
52
45
  };
53
46
  </script>
54
47
 
55
48
  <dialog
56
49
  bind:this={dialog}
57
50
  onclick={handleBackdropClick}
58
- oncancel={requestClose}
59
- onclose={close}
51
+ oncancel={handleClose}
52
+ onclose={handleClose}
60
53
  class={merge(
61
54
  'backdrop:bg-surface-800-200/30 h-full max-h-none w-screen max-w-full overflow-hidden bg-transparent',
62
55
  theme.current.dialog?.class,
@@ -68,12 +61,7 @@
68
61
  </dialog>
69
62
 
70
63
  <style>
71
- dialog::backdrop {
72
- animation: fade-in 200ms ease-out;
73
- }
74
- @keyframes fade-in {
75
- from {
76
- opacity: 0;
77
- }
64
+ dialog:not([open]):not(:popover-open) {
65
+ display: none !important;
78
66
  }
79
67
  </style>
@@ -3,7 +3,11 @@ export interface DialogProps extends IvoryComponent<HTMLElement> {
3
3
  /** Gets called when the dialog requests to close (Escape, backdrop click) */
4
4
  onclose?: () => void;
5
5
  }
6
- declare const Dialog: import("svelte").Component<DialogProps, {}, "">;
6
+ declare const Dialog: import("svelte").Component<DialogProps, {
7
+ open: () => void;
8
+ isOpen: () => boolean;
9
+ close: () => void;
10
+ }, "">;
7
11
  type Dialog = ReturnType<typeof Dialog>;
8
12
  export default Dialog;
9
13
  //# sourceMappingURL=Dialog.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/dialog/Dialog.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC5D,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAyDL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Dialog.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/dialog/Dialog.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC5D,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAmDL,QAAA,MAAM,MAAM;;;;MAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -35,40 +35,33 @@
35
35
  ...rest
36
36
  }: DrawerProps = $props();
37
37
 
38
- let currentlyOpen = $state(false);
39
- export function close() {
40
- currentlyOpen = false;
41
- }
38
+ let dialog = $state<Dialog>();
42
39
 
43
- export function open() {
44
- currentlyOpen = true;
45
- }
40
+ export const close = () => dialog?.close();
46
41
 
47
- export function toggle() {
48
- currentlyOpen = !currentlyOpen;
49
- }
42
+ export const open = () => dialog?.open();
50
43
 
51
- export function isOpen() {
52
- return currentlyOpen;
53
- }
44
+ export const isOpen = () => dialog?.isOpen();
45
+
46
+ export const toggle = () => {
47
+ if (isOpen()) close();
48
+ else open();
49
+ };
54
50
  </script>
55
51
 
56
- {#if currentlyOpen}
57
- <Dialog
58
- onclose={() => {
59
- if (closeOnOutsideClick) close();
60
- }}
61
- class={[
62
- 'flex flex-row justify-start overflow-visible',
63
- placement === 'left' && '',
64
- placement === 'right' && 'justify-end'
65
- ]}
66
- >
52
+ <Dialog
53
+ bind:this={dialog}
54
+ onclose={() => {
55
+ if (closeOnOutsideClick) close();
56
+ }}
57
+ class={['flex flex-row justify-start overflow-visible', placement === 'right' && 'justify-end']}
58
+ >
59
+ {#if dialog?.isOpen()}
67
60
  <div
68
- class={merge(['bg-surface-50-950 flex h-full flex-col gap-4 p-4', clazz])}
61
+ class={merge('bg-surface-50-950 flex h-full flex-col gap-4 p-4', clazz)}
69
62
  onclick={(e) => e.stopPropagation()}
70
- in:inTransition|global
71
- out:outTransition|global
63
+ in:inTransition
64
+ out:outTransition
72
65
  {...rest}
73
66
  >
74
67
  {#if inner}
@@ -91,5 +84,5 @@
91
84
  {@render children()}
92
85
  {/if}
93
86
  </div>
94
- </Dialog>
95
- {/if}
87
+ {/if}
88
+ </Dialog>
@@ -11,10 +11,10 @@ export type DrawerProps = TransitionProps & {
11
11
  inner?: Snippet;
12
12
  };
13
13
  declare const Drawer: import("svelte").Component<DrawerProps, {
14
- close: () => void;
15
- open: () => void;
14
+ close: () => void | undefined;
15
+ open: () => void | undefined;
16
+ isOpen: () => boolean | undefined;
16
17
  toggle: () => void;
17
- isOpen: () => boolean;
18
18
  }, "">;
19
19
  type Drawer = ReturnType<typeof Drawer>;
20
20
  export default Drawer;
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/drawer/Drawer.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKtC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAuEN,QAAA,MAAM,MAAM;;;;;MAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/drawer/Drawer.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKtC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AA+DN,QAAA,MAAM,MAAM;;;;;MAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -54,23 +54,18 @@
54
54
  ...rest
55
55
  }: Props = $props();
56
56
 
57
- let currentlyOpen = $state(false);
57
+ let dialog = $state<Dialog>();
58
58
 
59
- export function close() {
60
- currentlyOpen = false;
61
- }
59
+ export const close = () => dialog?.close();
62
60
 
63
- export function open() {
64
- currentlyOpen = true;
65
- }
61
+ export const open = () => dialog?.open();
66
62
 
67
- export function toggle() {
68
- currentlyOpen = !currentlyOpen;
69
- }
63
+ export const isOpen = () => dialog?.isOpen();
70
64
 
71
- export function isOpen() {
72
- return currentlyOpen;
73
- }
65
+ export const toggle = () => {
66
+ if (isOpen()) close();
67
+ else open();
68
+ };
74
69
 
75
70
  const onclick: MouseEventHandler<HTMLDivElement> = (e) => {
76
71
  e.stopPropagation();
@@ -82,31 +77,29 @@
82
77
  @component
83
78
  A modal, comes with a title, close button and different variants per default.
84
79
  -->
85
- {#if currentlyOpen}
86
- <Dialog
87
- onclose={() => {
88
- if (closeOnOutsideClick) close();
89
- }}
90
- class={merge(
91
- 'flex h-full w-full flex-col items-center justify-center p-8 lg:p-12 xl:p-16',
92
- theme.current.modal?.dialog?.class
93
- )}
94
- >
80
+ <Dialog
81
+ bind:this={dialog}
82
+ onclose={() => {
83
+ if (closeOnOutsideClick) close();
84
+ }}
85
+ class={merge('flex h-full w-full flex-col items-center justify-center p-8 lg:p-12 xl:p-16')}
86
+ >
87
+ {#if dialog?.isOpen()}
95
88
  {#if modal}
96
89
  <div {...rest} {onclick}>
97
90
  {@render modal()}
98
91
  </div>
99
92
  {:else}
100
93
  <div
101
- class={merge([
94
+ class={merge(
102
95
  'bg-surface-50-950 flex max-h-full max-w-full flex-col overflow-hidden rounded',
103
96
  theme.current.modal?.class,
104
97
  clazz
105
- ])}
98
+ )}
106
99
  {...rest}
107
100
  {onclick}
108
- in:inTransition|global
109
- out:outTransition|global
101
+ in:inTransition
102
+ out:outTransition
110
103
  >
111
104
  <div
112
105
  class={[
@@ -145,5 +138,5 @@
145
138
  </div>
146
139
  </div>
147
140
  {/if}
148
- </Dialog>
149
- {/if}
141
+ {/if}
142
+ </Dialog>
@@ -27,10 +27,10 @@ interface Props extends ModalProps {
27
27
  }
28
28
  /** A modal, comes with a title, close button and different variants per default. */
29
29
  declare const Modal: import("svelte").Component<Props, {
30
- close: () => void;
31
- open: () => void;
30
+ close: () => void | undefined;
31
+ open: () => void | undefined;
32
+ isOpen: () => boolean | undefined;
32
33
  toggle: () => void;
33
- isOpen: () => boolean;
34
34
  }, "">;
35
35
  type Modal = ReturnType<typeof Modal>;
36
36
  export default Modal;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/modal/Modal.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKrE,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACvC,iEAAiE;IACjE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;SAIK;IACL,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAC/C,CAAC;AAEF,UAAU,KAAM,SAAQ,UAAU;IAC9B,sGAAsG;IACtG,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAuGL,oFAAoF;AACpF,QAAA,MAAM,KAAK;;;;;MAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Modal.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/modal/Modal.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKrE,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACvC,iEAAiE;IACjE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;SAIK;IACL,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAC/C,CAAC;AAEF,UAAU,KAAM,SAAQ,UAAU;IAC9B,sGAAsG;IACtG,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AA+FL,oFAAoF;AACpF,QAAA,MAAM,KAAK;;;;;MAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
@@ -73,10 +73,10 @@
73
73
  onclick={finalOnClick}
74
74
  href={finalHref}
75
75
  style={ignoreWidth ? '' : `width: ${widthStyle}`}
76
- class={merge([
76
+ class={merge(
77
77
  'box-border flex h-full shrink-0 flex-row items-center justify-start gap-1 truncate',
78
78
  column.width !== 0 && 'border-r-[calc(var(--spacing)*2)] border-transparent',
79
79
  theme.current.table?.column?.class,
80
80
  clazz
81
- ])}
81
+ )}
82
82
  />
@@ -200,11 +200,11 @@
200
200
  bind:this={list}
201
201
  bind:b_scrollTop
202
202
  data={results.entries}
203
- class={merge([
203
+ class={merge(
204
204
  'flex flex-col overflow-hidden border-transparent',
205
205
  theme.current.table?.class,
206
206
  clazz
207
- ])}
207
+ )}
208
208
  rowClass={merge('pl-2 pr-4', theme.current.table?.row?.class, rowClass)}
209
209
  {rowHeight}
210
210
  >
@@ -26,7 +26,7 @@
26
26
  }: Props<T> = $props();
27
27
 
28
28
  const finalRowClass = $derived(
29
- merge(['flex w-full shrink-0 grow flex-row items-center overflow-hidden', rowClass])
29
+ merge('flex w-full shrink-0 grow flex-row items-center overflow-hidden', rowClass)
30
30
  );
31
31
 
32
32
  let viewportReactivity = $state(0);
@@ -92,7 +92,7 @@
92
92
  });
93
93
  </script>
94
94
 
95
- <div class={merge(['scroll relative flex grow flex-col overflow-hidden border-inherit', clazz])}>
95
+ <div class={merge('scroll relative flex grow flex-col overflow-hidden border-inherit', clazz)}>
96
96
  {#if header}
97
97
  <div class="h-fit w-full border-inherit">
98
98
  <div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ims360/svelte-ivory",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],
@@ -7,9 +7,7 @@
7
7
 
8
8
  <Input {...props}>
9
9
  {#snippet children({ id, class: inputClass })}
10
- <div
11
- class={merge([inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0'])}
12
- >
10
+ <div class={merge(inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0')}>
13
11
  <input
14
12
  type="text"
15
13
  bind:value={props.form.value, props.form.set}
@@ -72,12 +72,12 @@
72
72
  {@render children({ class: inputClass, id, ...inputProps })}
73
73
  {#if label}
74
74
  <label
75
- class={merge([
75
+ class={merge(
76
76
  'pointer-events-none absolute cursor-text px-1 transition-all select-none group-focus-within:top-0 group-focus-within:left-0 group-focus-within:text-sm focus:cursor-default',
77
77
  hasValue ? 'top-0 left-0 cursor-default text-sm' : 'top-10 left-3',
78
78
  hasIssues ? 'text-error-500' : 'text-surface-700-300',
79
79
  theme.current.input?.label?.class?.(hasValue, hasIssues)
80
- ])}
80
+ )}
81
81
  for={id}
82
82
  >
83
83
  {label}
@@ -2,7 +2,6 @@
2
2
  import { theme } from '$lib/theme.svelte';
3
3
  import type { IvoryComponent } from '$lib/types';
4
4
  import { merge } from '$lib/utils/functions';
5
- import { onMount, tick } from 'svelte';
6
5
  import type { MouseEventHandler } from 'svelte/elements';
7
6
 
8
7
  export interface DialogProps extends IvoryComponent<HTMLElement> {
@@ -14,49 +13,43 @@
14
13
  <script lang="ts">
15
14
  let {
16
15
  class: clazz,
17
- onclose: close, // This is the prop from the parent
16
+ onclose: onclose, // This is the prop from the parent
18
17
  children,
19
18
  ...rest
20
19
  }: DialogProps = $props();
21
20
 
22
21
  let dialog = $state<HTMLDialogElement>();
23
22
 
24
- /**
25
- * This function "requests" a close.
26
- * It tries to stop the native close and lets the parent decide.
27
- */
28
- async function requestClose(event: Event) {
29
- event.preventDefault(); // Stop the native close
30
- event.stopPropagation();
31
- close?.(); // Ask the parent to close
32
- await tick();
33
- await tick();
23
+ let currentlyOpen = $state(false);
24
+
25
+ export const open = () => {
34
26
  dialog?.showModal();
35
- }
27
+ currentlyOpen = true;
28
+ };
29
+
30
+ export const isOpen = () => currentlyOpen;
36
31
 
37
- onMount(() => {
38
- if (dialog && !dialog.open) {
39
- dialog.showModal();
40
- }
41
- return () => {
42
- if (dialog && dialog.open) {
43
- dialog.close();
44
- }
45
- };
46
- });
32
+ export const close = () => {
33
+ dialog?.close();
34
+ currentlyOpen = false;
35
+ };
47
36
 
48
37
  const handleBackdropClick: MouseEventHandler<HTMLElement> = (event) => {
49
- if (event.target === dialog) {
50
- requestClose(event);
51
- }
38
+ if (event.target !== dialog) return;
39
+ onclose?.();
40
+ };
41
+
42
+ const handleClose = () => {
43
+ onclose?.();
44
+ currentlyOpen = false;
52
45
  };
53
46
  </script>
54
47
 
55
48
  <dialog
56
49
  bind:this={dialog}
57
50
  onclick={handleBackdropClick}
58
- oncancel={requestClose}
59
- onclose={close}
51
+ oncancel={handleClose}
52
+ onclose={handleClose}
60
53
  class={merge(
61
54
  'backdrop:bg-surface-800-200/30 h-full max-h-none w-screen max-w-full overflow-hidden bg-transparent',
62
55
  theme.current.dialog?.class,
@@ -68,12 +61,7 @@
68
61
  </dialog>
69
62
 
70
63
  <style>
71
- dialog::backdrop {
72
- animation: fade-in 200ms ease-out;
73
- }
74
- @keyframes fade-in {
75
- from {
76
- opacity: 0;
77
- }
64
+ dialog:not([open]):not(:popover-open) {
65
+ display: none !important;
78
66
  }
79
67
  </style>
@@ -35,40 +35,33 @@
35
35
  ...rest
36
36
  }: DrawerProps = $props();
37
37
 
38
- let currentlyOpen = $state(false);
39
- export function close() {
40
- currentlyOpen = false;
41
- }
38
+ let dialog = $state<Dialog>();
42
39
 
43
- export function open() {
44
- currentlyOpen = true;
45
- }
40
+ export const close = () => dialog?.close();
46
41
 
47
- export function toggle() {
48
- currentlyOpen = !currentlyOpen;
49
- }
42
+ export const open = () => dialog?.open();
50
43
 
51
- export function isOpen() {
52
- return currentlyOpen;
53
- }
44
+ export const isOpen = () => dialog?.isOpen();
45
+
46
+ export const toggle = () => {
47
+ if (isOpen()) close();
48
+ else open();
49
+ };
54
50
  </script>
55
51
 
56
- {#if currentlyOpen}
57
- <Dialog
58
- onclose={() => {
59
- if (closeOnOutsideClick) close();
60
- }}
61
- class={[
62
- 'flex flex-row justify-start overflow-visible',
63
- placement === 'left' && '',
64
- placement === 'right' && 'justify-end'
65
- ]}
66
- >
52
+ <Dialog
53
+ bind:this={dialog}
54
+ onclose={() => {
55
+ if (closeOnOutsideClick) close();
56
+ }}
57
+ class={['flex flex-row justify-start overflow-visible', placement === 'right' && 'justify-end']}
58
+ >
59
+ {#if dialog?.isOpen()}
67
60
  <div
68
- class={merge(['bg-surface-50-950 flex h-full flex-col gap-4 p-4', clazz])}
61
+ class={merge('bg-surface-50-950 flex h-full flex-col gap-4 p-4', clazz)}
69
62
  onclick={(e) => e.stopPropagation()}
70
- in:inTransition|global
71
- out:outTransition|global
63
+ in:inTransition
64
+ out:outTransition
72
65
  {...rest}
73
66
  >
74
67
  {#if inner}
@@ -91,5 +84,5 @@
91
84
  {@render children()}
92
85
  {/if}
93
86
  </div>
94
- </Dialog>
95
- {/if}
87
+ {/if}
88
+ </Dialog>
@@ -54,23 +54,18 @@
54
54
  ...rest
55
55
  }: Props = $props();
56
56
 
57
- let currentlyOpen = $state(false);
57
+ let dialog = $state<Dialog>();
58
58
 
59
- export function close() {
60
- currentlyOpen = false;
61
- }
59
+ export const close = () => dialog?.close();
62
60
 
63
- export function open() {
64
- currentlyOpen = true;
65
- }
61
+ export const open = () => dialog?.open();
66
62
 
67
- export function toggle() {
68
- currentlyOpen = !currentlyOpen;
69
- }
63
+ export const isOpen = () => dialog?.isOpen();
70
64
 
71
- export function isOpen() {
72
- return currentlyOpen;
73
- }
65
+ export const toggle = () => {
66
+ if (isOpen()) close();
67
+ else open();
68
+ };
74
69
 
75
70
  const onclick: MouseEventHandler<HTMLDivElement> = (e) => {
76
71
  e.stopPropagation();
@@ -82,31 +77,29 @@
82
77
  @component
83
78
  A modal, comes with a title, close button and different variants per default.
84
79
  -->
85
- {#if currentlyOpen}
86
- <Dialog
87
- onclose={() => {
88
- if (closeOnOutsideClick) close();
89
- }}
90
- class={merge(
91
- 'flex h-full w-full flex-col items-center justify-center p-8 lg:p-12 xl:p-16',
92
- theme.current.modal?.dialog?.class
93
- )}
94
- >
80
+ <Dialog
81
+ bind:this={dialog}
82
+ onclose={() => {
83
+ if (closeOnOutsideClick) close();
84
+ }}
85
+ class={merge('flex h-full w-full flex-col items-center justify-center p-8 lg:p-12 xl:p-16')}
86
+ >
87
+ {#if dialog?.isOpen()}
95
88
  {#if modal}
96
89
  <div {...rest} {onclick}>
97
90
  {@render modal()}
98
91
  </div>
99
92
  {:else}
100
93
  <div
101
- class={merge([
94
+ class={merge(
102
95
  'bg-surface-50-950 flex max-h-full max-w-full flex-col overflow-hidden rounded',
103
96
  theme.current.modal?.class,
104
97
  clazz
105
- ])}
98
+ )}
106
99
  {...rest}
107
100
  {onclick}
108
- in:inTransition|global
109
- out:outTransition|global
101
+ in:inTransition
102
+ out:outTransition
110
103
  >
111
104
  <div
112
105
  class={[
@@ -145,5 +138,5 @@
145
138
  </div>
146
139
  </div>
147
140
  {/if}
148
- </Dialog>
149
- {/if}
141
+ {/if}
142
+ </Dialog>
@@ -73,10 +73,10 @@
73
73
  onclick={finalOnClick}
74
74
  href={finalHref}
75
75
  style={ignoreWidth ? '' : `width: ${widthStyle}`}
76
- class={merge([
76
+ class={merge(
77
77
  'box-border flex h-full shrink-0 flex-row items-center justify-start gap-1 truncate',
78
78
  column.width !== 0 && 'border-r-[calc(var(--spacing)*2)] border-transparent',
79
79
  theme.current.table?.column?.class,
80
80
  clazz
81
- ])}
81
+ )}
82
82
  />
@@ -200,11 +200,11 @@
200
200
  bind:this={list}
201
201
  bind:b_scrollTop
202
202
  data={results.entries}
203
- class={merge([
203
+ class={merge(
204
204
  'flex flex-col overflow-hidden border-transparent',
205
205
  theme.current.table?.class,
206
206
  clazz
207
- ])}
207
+ )}
208
208
  rowClass={merge('pl-2 pr-4', theme.current.table?.row?.class, rowClass)}
209
209
  {rowHeight}
210
210
  >
@@ -26,7 +26,7 @@
26
26
  }: Props<T> = $props();
27
27
 
28
28
  const finalRowClass = $derived(
29
- merge(['flex w-full shrink-0 grow flex-row items-center overflow-hidden', rowClass])
29
+ merge('flex w-full shrink-0 grow flex-row items-center overflow-hidden', rowClass)
30
30
  );
31
31
 
32
32
  let viewportReactivity = $state(0);
@@ -92,7 +92,7 @@
92
92
  });
93
93
  </script>
94
94
 
95
- <div class={merge(['scroll relative flex grow flex-col overflow-hidden border-inherit', clazz])}>
95
+ <div class={merge('scroll relative flex grow flex-col overflow-hidden border-inherit', clazz)}>
96
96
  {#if header}
97
97
  <div class="h-fit w-full border-inherit">
98
98
  <div