@ims360/svelte-ivory 0.0.56 → 0.0.60

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 (26) hide show
  1. package/dist/components/layout/drawer/Drawer.svelte +25 -8
  2. package/dist/components/layout/drawer/Drawer.svelte.d.ts +7 -2
  3. package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
  4. package/dist/components/layout/modal/Modal.svelte +25 -11
  5. package/dist/components/layout/modal/Modal.svelte.d.ts +12 -5
  6. package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
  7. package/dist/components/layout/popover/Popover.svelte +41 -27
  8. package/dist/components/layout/popover/Popover.svelte.d.ts +6 -3
  9. package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
  10. package/dist/components/layout/tabs/Tabs.svelte +16 -13
  11. package/dist/components/layout/tabs/Tabs.svelte.d.ts +3 -2
  12. package/dist/components/layout/tabs/Tabs.svelte.d.ts.map +1 -1
  13. package/dist/components/layout/tabs/index.d.ts +2 -1
  14. package/dist/components/layout/tabs/index.d.ts.map +1 -1
  15. package/dist/components/layout/tooltip/Tooltip.svelte +22 -26
  16. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
  17. package/dist/components/table/Table.svelte +32 -32
  18. package/dist/components/table/Table.svelte.d.ts +2 -0
  19. package/dist/components/table/Table.svelte.d.ts.map +1 -1
  20. package/package.json +26 -26
  21. package/src/lib/components/layout/drawer/Drawer.svelte +25 -8
  22. package/src/lib/components/layout/modal/Modal.svelte +25 -11
  23. package/src/lib/components/layout/popover/Popover.svelte +41 -27
  24. package/src/lib/components/layout/tabs/Tabs.svelte +16 -13
  25. package/src/lib/components/layout/tooltip/Tooltip.svelte +22 -26
  26. package/src/lib/components/table/Table.svelte +32 -32
@@ -13,20 +13,20 @@
13
13
 
14
14
  export type DrawerProps = TransitionProps & {
15
15
  class?: string;
16
- b_open: boolean;
17
16
  title?: string | Snippet;
18
17
  children: Snippet;
19
18
  placement?: DrawerPlacement;
19
+ closeOnOutsideClick?: boolean;
20
20
  };
21
21
  </script>
22
22
 
23
23
  <script lang="ts">
24
24
  let {
25
25
  class: clazz,
26
- b_open = $bindable(false),
27
26
  children,
28
27
  title,
29
28
  placement = 'right',
29
+ closeOnOutsideClick = true,
30
30
  inTransition = (e) =>
31
31
  fly(e, { x: placement === 'right' ? '100%' : '-100%', duration: 200 }),
32
32
  outTransition = (e) =>
@@ -34,14 +34,31 @@
34
34
  ...rest
35
35
  }: DrawerProps = $props();
36
36
 
37
- const onclose = () => {
38
- b_open = false;
39
- };
37
+ let currentlyOpen = $state(false);
38
+ export function close() {
39
+ currentlyOpen = false;
40
+ }
41
+
42
+ export function open() {
43
+ currentlyOpen = true;
44
+ }
45
+
46
+ export function toggle() {
47
+ currentlyOpen = !currentlyOpen;
48
+ }
49
+
50
+ export function isOpen() {
51
+ return currentlyOpen;
52
+ }
40
53
  </script>
41
54
 
42
- {#if b_open}
55
+ {#if currentlyOpen}
43
56
  <Portal>
44
- <HiddenBackground {onclose}>
57
+ <HiddenBackground
58
+ onclose={() => {
59
+ if (closeOnOutsideClick) close();
60
+ }}
61
+ >
45
62
  <div
46
63
  class={twMerge(
47
64
  clsx([
@@ -66,7 +83,7 @@
66
83
  {/if}
67
84
  </Heading>
68
85
  {/if}
69
- <button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
86
+ <button class="group ml-auto flex justify-end" type="button" onclick={close}>
70
87
  <X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
71
88
  </button>
72
89
  </div>
@@ -3,12 +3,17 @@ import type { Snippet } from 'svelte';
3
3
  export type DrawerPlacement = 'left' | 'right';
4
4
  export type DrawerProps = TransitionProps & {
5
5
  class?: string;
6
- b_open: boolean;
7
6
  title?: string | Snippet;
8
7
  children: Snippet;
9
8
  placement?: DrawerPlacement;
9
+ closeOnOutsideClick?: boolean;
10
10
  };
11
- declare const Drawer: import("svelte").Component<DrawerProps, {}, "b_open">;
11
+ declare const Drawer: import("svelte").Component<DrawerProps, {
12
+ close: () => void;
13
+ open: () => void;
14
+ toggle: () => void;
15
+ isOpen: () => boolean;
16
+ }, "">;
12
17
  type Drawer = ReturnType<typeof Drawer>;
13
18
  export default Drawer;
14
19
  //# sourceMappingURL=Drawer.svelte.d.ts.map
@@ -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;AAOtC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAwDN,QAAA,MAAM,MAAM,uDAAwC,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;AAOtC,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;CACjC,CAAC;AAuEN,QAAA,MAAM,MAAM;;;;;MAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -14,12 +14,14 @@
14
14
  class?: ClassValue;
15
15
  /** Class of the div wrapping the children */
16
16
  innerClass?: ClassValue;
17
- /** If `true`, the modal will be open */
18
- b_open: boolean;
19
17
  /** Content of the modal */
20
18
  children?: Snippet;
21
- /** If `true` the modal will not close when clicking outside of it */
22
- preventClosing?: boolean;
19
+ /**
20
+ * If `true` the modal will not close when clicking outside of it
21
+ *
22
+ * Defaults to `true`
23
+ * */
24
+ closeOnOutsideClick?: boolean;
23
25
  /** Variant of the modal, applies styling to the header */
24
26
  variant?: ModalVariant;
25
27
  title?: string | Snippet;
@@ -38,10 +40,9 @@
38
40
  let {
39
41
  class: clazz = 'flex flex-col',
40
42
  title,
41
- b_open = $bindable(),
42
43
  children,
43
44
  modal,
44
- preventClosing = false,
45
+ closeOnOutsideClick = true,
45
46
  variant,
46
47
  innerClass,
47
48
  inTransition = (e) =>
@@ -52,8 +53,22 @@
52
53
  ...rest
53
54
  }: Props = $props();
54
55
 
55
- function close() {
56
- b_open = false;
56
+ let currentlyOpen = $state(false);
57
+
58
+ export function close() {
59
+ currentlyOpen = false;
60
+ }
61
+
62
+ export function open() {
63
+ currentlyOpen = true;
64
+ }
65
+
66
+ export function toggle() {
67
+ currentlyOpen = !currentlyOpen;
68
+ }
69
+
70
+ export function isOpen() {
71
+ return currentlyOpen;
57
72
  }
58
73
 
59
74
  const onclick: MouseEventHandler<HTMLDivElement> = (e) => {
@@ -66,12 +81,11 @@
66
81
  @component
67
82
  A modal, comes with a title, close button and different variants per default.
68
83
  -->
69
- {#if b_open}
84
+ {#if currentlyOpen}
70
85
  <Portal>
71
86
  <HiddenBackground
72
87
  onclose={() => {
73
- if (preventClosing) return;
74
- close();
88
+ if (closeOnOutsideClick) close();
75
89
  }}
76
90
  class="flex h-full w-full flex-col items-center justify-start p-8 lg:p-12 xl:p-16"
77
91
  >
@@ -7,12 +7,14 @@ export type ModalProps = TransitionProps & {
7
7
  class?: ClassValue;
8
8
  /** Class of the div wrapping the children */
9
9
  innerClass?: ClassValue;
10
- /** If `true`, the modal will be open */
11
- b_open: boolean;
12
10
  /** Content of the modal */
13
11
  children?: Snippet;
14
- /** If `true` the modal will not close when clicking outside of it */
15
- preventClosing?: boolean;
12
+ /**
13
+ * If `true` the modal will not close when clicking outside of it
14
+ *
15
+ * Defaults to `true`
16
+ * */
17
+ closeOnOutsideClick?: boolean;
16
18
  /** Variant of the modal, applies styling to the header */
17
19
  variant?: ModalVariant;
18
20
  title?: string | Snippet;
@@ -24,7 +26,12 @@ interface Props extends ModalProps {
24
26
  modal?: Snippet;
25
27
  }
26
28
  /** A modal, comes with a title, close button and different variants per default. */
27
- declare const Modal: import("svelte").Component<Props, {}, "b_open">;
29
+ declare const Modal: import("svelte").Component<Props, {
30
+ close: () => void;
31
+ open: () => void;
32
+ toggle: () => void;
33
+ isOpen: () => boolean;
34
+ }, "">;
28
35
  type Modal = ReturnType<typeof Modal>;
29
36
  export default Modal;
30
37
  //# sourceMappingURL=Modal.svelte.d.ts.map
@@ -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,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,iEA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BAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpE,UAAU,KAAM,SAAQ,UAAU;IAC9B,sGAAsG;IACtG,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAoGL,oFAAoF;AACpF,QAAA,MAAM,KAAK;;;;;MAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
@@ -12,13 +12,12 @@
12
12
  import clsx from 'clsx';
13
13
  import { twMerge } from 'tailwind-merge';
14
14
  import { clickOutside } from '../../../utils/actions/clickOutside';
15
+ import Portal from '../portal/Portal.svelte';
15
16
 
16
17
  /** Possible placements for the popover */
17
18
  export type PopoverPlacement = ComputePositionConfig['placement'];
18
19
 
19
20
  export interface PopoverProps extends IvoryComponent<HTMLDivElement> {
20
- /** Whether the popover is open or not */
21
- b_open: boolean;
22
21
  /** The element the popover will be positioned relative to */
23
22
  target: Element | undefined;
24
23
  /**
@@ -45,13 +44,10 @@
45
44
  <script lang="ts">
46
45
  let {
47
46
  class: clazz,
48
- b_open = $bindable(false),
49
47
  style: externalStyle,
50
48
  target,
51
49
  placement = 'bottom-start',
52
- onClickOutside = () => {
53
- b_open = false;
54
- },
50
+ onClickOutside = close,
55
51
  keepMounted = false,
56
52
  children,
57
53
  autoplacement,
@@ -70,21 +66,33 @@
70
66
  style = `top: ${y}px; left: ${x}px;`;
71
67
  };
72
68
 
69
+ let currentlyOpen = $state(false);
70
+
73
71
  let cleanup: () => void = () => {};
74
- $effect(() => {
75
- if (browser && popover && target)
76
- if (b_open) {
77
- cleanup = autoUpdate(target, popover, () => postion(b_open));
78
- } else {
79
- cleanup();
80
- }
81
- });
72
+ export function close() {
73
+ currentlyOpen = false;
74
+ cleanup();
75
+ }
76
+
77
+ export function open() {
78
+ currentlyOpen = true;
79
+ if (!target || !popover) return;
80
+ cleanup = autoUpdate(target, popover, () => postion(true));
81
+ }
82
+
83
+ export function toggle() {
84
+ currentlyOpen = !currentlyOpen;
85
+ }
86
+
87
+ export function isOpen() {
88
+ return currentlyOpen;
89
+ }
82
90
 
83
91
  // TODO: this is kinda hacky
84
92
  $effect(() => {
85
93
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
86
94
  [popover, target];
87
- postion(b_open);
95
+ postion(currentlyOpen);
88
96
  });
89
97
  </script>
90
98
 
@@ -92,16 +100,22 @@
92
100
  @component
93
101
  A popover, positions itself relative to a target element.
94
102
  -->
95
- {#if b_open || keepMounted}
96
- <div
97
- class={twMerge(
98
- clsx('absolute z-30', !keepMounted && clazz, keepMounted && !b_open ? 'hidden' : clazz)
99
- )}
100
- style={style + ' ' + externalStyle}
101
- bind:this={popover}
102
- use:clickOutside={{ callback: onClickOutside, target }}
103
- {...rest}
104
- >
105
- {@render children?.()}
106
- </div>
103
+ {#if currentlyOpen || keepMounted}
104
+ <Portal>
105
+ <div
106
+ class={twMerge(
107
+ clsx(
108
+ 'absolute z-30',
109
+ !keepMounted && clazz,
110
+ keepMounted && !currentlyOpen ? 'hidden' : clazz
111
+ )
112
+ )}
113
+ style={style + ' ' + externalStyle}
114
+ bind:this={popover}
115
+ use:clickOutside={{ callback: onClickOutside, target }}
116
+ {...rest}
117
+ >
118
+ {@render children?.()}
119
+ </div>
120
+ </Portal>
107
121
  {/if}
@@ -3,8 +3,6 @@ import { type ComputePositionConfig } from '@floating-ui/dom';
3
3
  /** Possible placements for the popover */
4
4
  export type PopoverPlacement = ComputePositionConfig['placement'];
5
5
  export interface PopoverProps extends IvoryComponent<HTMLDivElement> {
6
- /** Whether the popover is open or not */
7
- b_open: boolean;
8
6
  /** The element the popover will be positioned relative to */
9
7
  target: Element | undefined;
10
8
  /**
@@ -27,7 +25,12 @@ export interface PopoverProps extends IvoryComponent<HTMLDivElement> {
27
25
  autoplacement?: boolean;
28
26
  }
29
27
  /** A popover, positions itself relative to a target element. */
30
- declare const Popover: import("svelte").Component<PopoverProps, {}, "b_open">;
28
+ declare const Popover: import("svelte").Component<PopoverProps, {
29
+ close: () => void;
30
+ open: () => void;
31
+ toggle: () => void;
32
+ isOpen: () => boolean;
33
+ }, "">;
31
34
  type Popover = ReturnType<typeof Popover>;
32
35
  export default Popover;
33
36
  //# sourceMappingURL=Popover.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/popover/Popover.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAMH,KAAK,qBAAqB,EAC7B,MAAM,kBAAkB,CAAC;AAK1B,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAElE,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,6DAA6D;IAC7D,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,8FAA8F;IAC9F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AA6DL,gEAAgE;AAChE,QAAA,MAAM,OAAO,wDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Popover.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/popover/Popover.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAMH,KAAK,qBAAqB,EAC7B,MAAM,kBAAkB,CAAC;AAM1B,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAElE,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,6DAA6D;IAC7D,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,8FAA8F;IAC9F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AA4EL,gEAAgE;AAChE,QAAA,MAAM,OAAO;;;;;MAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -3,7 +3,7 @@
3
3
  import { getContext, onDestroy, setContext } from 'svelte';
4
4
 
5
5
  export interface TabsProps extends IvoryComponent<HTMLDivElement> {
6
- b_index?: number;
6
+ initialTab?: number;
7
7
  }
8
8
 
9
9
  export interface TabContext {
@@ -24,27 +24,30 @@
24
24
  </script>
25
25
 
26
26
  <script lang="ts">
27
- let { children, b_index = $bindable(0), ...rest }: TabsProps = $props();
27
+ let { children, initialTab = 0, ...rest }: TabsProps = $props();
28
28
 
29
29
  let allTabs: string[] = $state([]);
30
30
  let panels: string[] = $state([]);
31
+ let index: number = $state(initialTab);
31
32
 
32
33
  export const forward = () => {
33
- if (b_index >= panels.length - 1) {
34
- b_index = 0;
34
+ if (index >= panels.length - 1) {
35
+ index = 0;
35
36
  } else {
36
- b_index++;
37
+ index++;
37
38
  }
38
39
  };
39
40
 
40
41
  export const back = () => {
41
- if (b_index === 0) {
42
- b_index = panels.length - 1;
42
+ if (index === 0) {
43
+ index = panels.length - 1;
43
44
  } else {
44
- b_index--;
45
+ index--;
45
46
  }
46
47
  };
47
48
 
49
+ export const currentTab = () => index;
50
+
48
51
  setTabContext({
49
52
  registerTab: (tab: string) => {
50
53
  allTabs.push(tab);
@@ -56,23 +59,23 @@
56
59
 
57
60
  registerPanel: (panel: string) => {
58
61
  panels.push(panel);
59
- b_index = b_index;
62
+ index = index;
60
63
  onDestroy(() => {
61
64
  panels.filter((p) => p !== panel);
62
65
  });
63
66
  },
64
67
 
65
68
  get selectedTab() {
66
- return allTabs[b_index];
69
+ return allTabs[index];
67
70
  },
68
71
  set selectedTab(tab: string) {
69
- b_index = allTabs.indexOf(tab);
72
+ index = allTabs.indexOf(tab);
70
73
  },
71
74
  get selectedPanel() {
72
- return panels[b_index];
75
+ return panels[index];
73
76
  },
74
77
  set selectedPanel(panel: string) {
75
- b_index = panels.indexOf(panel);
78
+ index = panels.indexOf(panel);
76
79
  },
77
80
  tabs: allTabs
78
81
  });
@@ -1,6 +1,6 @@
1
1
  import type { IvoryComponent } from '../../../types';
2
2
  export interface TabsProps extends IvoryComponent<HTMLDivElement> {
3
- b_index?: number;
3
+ initialTab?: number;
4
4
  }
5
5
  export interface TabContext {
6
6
  registerTab: (tab: string) => void;
@@ -13,7 +13,8 @@ export declare function getTabContext(): TabContext;
13
13
  declare const Tabs: import("svelte").Component<TabsProps, {
14
14
  forward: () => void;
15
15
  back: () => void;
16
- }, "b_index">;
16
+ currentTab: () => number;
17
+ }, "">;
17
18
  type Tabs = ReturnType<typeof Tabs>;
18
19
  export default Tabs;
19
20
  //# sourceMappingURL=Tabs.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tabs/Tabs.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACvB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAMD,wBAAgB,aAAa,eAE5B;AAiEL,QAAA,MAAM,IAAI;;;aAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Tabs.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tabs/Tabs.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACvB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAMD,wBAAgB,aAAa,eAE5B;AAoEL,QAAA,MAAM,IAAI;;;;MAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
@@ -2,7 +2,8 @@ import { setDefaultClass } from './Tab.svelte';
2
2
  declare const Tabs: import("svelte").Component<import("./Tabs.svelte").TabsProps, {
3
3
  forward: () => void;
4
4
  back: () => void;
5
- }, "b_index"> & {
5
+ currentTab: () => number;
6
+ }, ""> & {
6
7
  Tab: import("svelte").Component<import("./Tab.svelte").TabProps, {}, "">;
7
8
  Panel: import("svelte").Component<import("./TabPanel.svelte").TabPanelProps, {}, "">;
8
9
  setDefaultTabClass: typeof setDefaultClass;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,QAAA,MAAM,IAAI;;;;;;;CAIR,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,QAAA,MAAM,IAAI;;;;;;;;CAIR,CAAC;AAEH,eAAe,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC"}
@@ -4,7 +4,6 @@
4
4
  import type { ClassValue, MouseEventHandler } from 'svelte/elements';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import Popover, { type PopoverPlacement } from '../popover/Popover.svelte';
7
- import Portal from '../portal/Portal.svelte';
8
7
 
9
8
  export interface TooltipProps {
10
9
  onclick?: MouseEventHandler<HTMLElement>;
@@ -44,23 +43,24 @@
44
43
  }: TooltipProps = $props();
45
44
 
46
45
  let target = $state<HTMLElement>();
47
- let open = $state(false);
46
+
47
+ let popover = $state<Popover>();
48
48
 
49
49
  let currentTimeout: number;
50
50
  function onmouseenter() {
51
51
  clearTimeout(currentTimeout);
52
52
  if (timeout === 0) {
53
- open = true;
53
+ popover?.open();
54
54
  } else {
55
55
  currentTimeout = setTimeout(() => {
56
- open = true;
56
+ popover?.open();
57
57
  }, timeout) as unknown as number;
58
58
  }
59
59
  }
60
60
 
61
61
  function onmouseleave() {
62
62
  clearTimeout(currentTimeout);
63
- open = false;
63
+ popover?.close();
64
64
  }
65
65
  </script>
66
66
 
@@ -80,24 +80,20 @@
80
80
  {@render children?.()}
81
81
  </svelte:element>
82
82
 
83
- {#if open}
84
- <Portal>
85
- <Popover
86
- bind:b_open={open}
87
- {target}
88
- {placement}
89
- class={twMerge(
90
- clsx(
91
- 'bg-surface-50-950 max-w-96 -translate-y-0.5 rounded px-4 py-1 shadow-lg',
92
- tooltipClass
93
- )
94
- )}
95
- >
96
- {#if typeof tooltip === 'string'}
97
- {tooltip}
98
- {:else}
99
- {@render tooltip()}
100
- {/if}
101
- </Popover>
102
- </Portal>
103
- {/if}
83
+ <Popover
84
+ bind:this={popover}
85
+ {target}
86
+ {placement}
87
+ class={twMerge(
88
+ clsx(
89
+ 'bg-surface-50-950 max-w-96 -translate-y-0.5 rounded px-4 py-1 shadow-lg',
90
+ tooltipClass
91
+ )
92
+ )}
93
+ >
94
+ {#if typeof tooltip === 'string'}
95
+ {tooltip}
96
+ {:else}
97
+ {@render tooltip()}
98
+ {/if}
99
+ </Popover>
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tooltip/Tooltip.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG3E,MAAM,WAAW,YAAY;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iCAAiC;IACjC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,sCAAsC;IACtC,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAChC;AA4DL,kEAAkE;AAClE,QAAA,MAAM,OAAO,kDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Tooltip.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tooltip/Tooltip.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,MAAM,WAAW,YAAY;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACzC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iCAAiC;IACjC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,sCAAsC;IACtC,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAyDL,kEAAkE;AAClE,QAAA,MAAM,OAAO,kDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -84,7 +84,38 @@
84
84
  let columns = $state<ColumnController[]>(externalColumns ?? []);
85
85
  let treeIndicatorColumn = $state<ColumnController>();
86
86
 
87
- function toggleExpansion(id: string) {
87
+ setTableContext({
88
+ toggleExpansion,
89
+ registerColumn(config: ColumnConfig) {
90
+ let existingColumn: ColumnController | undefined = undefined;
91
+
92
+ if (config.id === treeIndicatorId) {
93
+ if (!treeIndicatorColumn) treeIndicatorColumn = new ColumnController(config);
94
+ return treeIndicatorColumn;
95
+ }
96
+
97
+ for (const column of existingColumn || columns) {
98
+ if (column.id !== config.id) continue;
99
+ existingColumn = column;
100
+ break;
101
+ }
102
+ if (existingColumn) return existingColumn;
103
+ const col = new ColumnController(config);
104
+ (externalColumns || columns).push(col);
105
+ return col;
106
+ },
107
+ get nestingInset() {
108
+ return nestingInset;
109
+ },
110
+ get rowHeight() {
111
+ return rowHeight;
112
+ },
113
+ scrollTo(top?: number, left?: number) {
114
+ list?.scrollTo(top, left);
115
+ }
116
+ });
117
+
118
+ export function toggleExpansion(id: string) {
88
119
  if (expanded.has(id)) expanded.delete(id);
89
120
  else expanded.add(id);
90
121
  }
@@ -151,37 +182,6 @@
151
182
  prevSearch = currentSearch;
152
183
  });
153
184
 
154
- setTableContext({
155
- toggleExpansion,
156
- registerColumn(config: ColumnConfig) {
157
- let existingColumn: ColumnController | undefined = undefined;
158
-
159
- if (config.id === treeIndicatorId) {
160
- if (!treeIndicatorColumn) treeIndicatorColumn = new ColumnController(config);
161
- return treeIndicatorColumn;
162
- }
163
-
164
- for (const column of existingColumn || columns) {
165
- if (column.id !== config.id) continue;
166
- existingColumn = column;
167
- break;
168
- }
169
- if (existingColumn) return existingColumn;
170
- const col = new ColumnController(config);
171
- (externalColumns || columns).push(col);
172
- return col;
173
- },
174
- get nestingInset() {
175
- return nestingInset;
176
- },
177
- get rowHeight() {
178
- return rowHeight;
179
- },
180
- scrollTo(top?: number, left?: number) {
181
- list?.scrollTo(top, left);
182
- }
183
- });
184
-
185
185
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
186
  let list = $state<VirtualList<any>>();
187
187
  export function scrollTo(top?: number, left?: number) {
@@ -48,6 +48,7 @@ export declare function getTableContext<T extends TableRow<T>>(): TableContext<T
48
48
  declare function $$render<T extends TableRow<T>>(): {
49
49
  props: TableProps<T>;
50
50
  exports: {
51
+ toggleExpansion: (id: string) => void;
51
52
  scrollTo: (top?: number, left?: number) => void;
52
53
  };
53
54
  bindings: "b_scrollTop" | "b_columns";
@@ -60,6 +61,7 @@ declare class __sveltets_Render<T extends TableRow<T>> {
60
61
  slots(): ReturnType<typeof $$render<T>>['slots'];
61
62
  bindings(): "b_scrollTop" | "b_columns";
62
63
  exports(): {
64
+ toggleExpansion: (id: string) => void;
63
65
  scrollTo: (top?: number, left?: number) => void;
64
66
  };
65
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Table.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Table.svelte.ts"],"names":[],"mappings":"AAKI,OAAO,EAAmC,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACvE,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te": "^0.503.0",
76
76
  "@tailwindcss/forms": "^0.5.10",
77
- "@tailwindcss/typography": "^0.5.18",
78
- "@tailwindcss/vite": "^4.1.13",
77
+ "@tailwindcss/typography": "^0.5.19",
78
+ "@tailwindcss/vite": "^4.1.16",
79
79
  "clsx": "^2.1.1",
80
- "dompurify": "^3.2.7",
80
+ "dompurify": "^3.3.0",
81
81
  "jsdom": "^26.1.0",
82
82
  "marked": "^15.0.12",
83
83
  "tailwind-merge": "^3.3.1",
84
- "tailwindcss": "^4.1.13"
84
+ "tailwindcss": "^4.1.16"
85
85
  },
86
86
  "devDependencies": {
87
- "@eslint/compat": "^1.3.2",
88
- "@eslint/js": "^9.36.0",
87
+ "@eslint/compat": "^1.4.1",
88
+ "@eslint/js": "^9.39.1",
89
89
  "@sveltejs/adapter-auto": "^4.0.0",
90
- "@sveltejs/package": "^2.5.3",
91
- "@sveltejs/vite-plugin-svelte": "^5.1.1",
92
- "@testing-library/jest-dom": "^6.8.0",
90
+ "@sveltejs/package": "^2.5.4",
91
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
92
+ "@testing-library/jest-dom": "^6.9.1",
93
93
  "@testing-library/svelte": "^5.2.8",
94
94
  "@testing-library/user-event": "^14.6.1",
95
- "@vitest/browser": "^3.2.4",
96
- "@vitest/coverage-v8": "^3.2.4",
97
- "@vitest/spy": "^3.2.4",
98
- "eslint": "^9.36.0",
95
+ "@vitest/browser": "^4.0.0",
96
+ "@vitest/coverage-v8": "^4.0.0",
97
+ "@vitest/spy": "^4.0.0",
98
+ "eslint": "^9.39.1",
99
99
  "eslint-config-prettier": "^10.1.8",
100
- "eslint-plugin-svelte": "^3.12.4",
101
- "globals": "^16.4.0",
102
- "playwright": "^1.55.0",
100
+ "eslint-plugin-svelte": "^3.13.0",
101
+ "globals": "^16.5.0",
102
+ "playwright": "^1.56.1",
103
103
  "prettier": "^3.6.2",
104
104
  "prettier-plugin-svelte": "^3.4.0",
105
- "prettier-plugin-tailwindcss": "^0.6.14",
106
- "publint": "^0.3.13",
107
- "svelte-check": "^4.3.1",
108
- "typescript": "^5.9.2",
109
- "typescript-eslint": "^8.44.0",
110
- "vite": "^6.3.6",
111
- "vitest": "^3.2.4"
105
+ "prettier-plugin-tailwindcss": "^0.7.1",
106
+ "publint": "^0.3.15",
107
+ "svelte-check": "^4.3.3",
108
+ "typescript": "^5.9.3",
109
+ "typescript-eslint": "^8.46.3",
110
+ "vite": "^7.1.1",
111
+ "vitest": "^4.0.0"
112
112
  },
113
113
  "peerDependencies": {
114
114
  "@skeletonlabs/skeleton": "^3.1.1",
115
- "@sveltejs/kit": "^2.16.0",
116
- "svelte": "^5.0.0"
115
+ "@sveltejs/kit": "^2.48.0",
116
+ "svelte": "^5.43.0"
117
117
  }
118
118
  }
@@ -13,20 +13,20 @@
13
13
 
14
14
  export type DrawerProps = TransitionProps & {
15
15
  class?: string;
16
- b_open: boolean;
17
16
  title?: string | Snippet;
18
17
  children: Snippet;
19
18
  placement?: DrawerPlacement;
19
+ closeOnOutsideClick?: boolean;
20
20
  };
21
21
  </script>
22
22
 
23
23
  <script lang="ts">
24
24
  let {
25
25
  class: clazz,
26
- b_open = $bindable(false),
27
26
  children,
28
27
  title,
29
28
  placement = 'right',
29
+ closeOnOutsideClick = true,
30
30
  inTransition = (e) =>
31
31
  fly(e, { x: placement === 'right' ? '100%' : '-100%', duration: 200 }),
32
32
  outTransition = (e) =>
@@ -34,14 +34,31 @@
34
34
  ...rest
35
35
  }: DrawerProps = $props();
36
36
 
37
- const onclose = () => {
38
- b_open = false;
39
- };
37
+ let currentlyOpen = $state(false);
38
+ export function close() {
39
+ currentlyOpen = false;
40
+ }
41
+
42
+ export function open() {
43
+ currentlyOpen = true;
44
+ }
45
+
46
+ export function toggle() {
47
+ currentlyOpen = !currentlyOpen;
48
+ }
49
+
50
+ export function isOpen() {
51
+ return currentlyOpen;
52
+ }
40
53
  </script>
41
54
 
42
- {#if b_open}
55
+ {#if currentlyOpen}
43
56
  <Portal>
44
- <HiddenBackground {onclose}>
57
+ <HiddenBackground
58
+ onclose={() => {
59
+ if (closeOnOutsideClick) close();
60
+ }}
61
+ >
45
62
  <div
46
63
  class={twMerge(
47
64
  clsx([
@@ -66,7 +83,7 @@
66
83
  {/if}
67
84
  </Heading>
68
85
  {/if}
69
- <button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
86
+ <button class="group ml-auto flex justify-end" type="button" onclick={close}>
70
87
  <X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
71
88
  </button>
72
89
  </div>
@@ -14,12 +14,14 @@
14
14
  class?: ClassValue;
15
15
  /** Class of the div wrapping the children */
16
16
  innerClass?: ClassValue;
17
- /** If `true`, the modal will be open */
18
- b_open: boolean;
19
17
  /** Content of the modal */
20
18
  children?: Snippet;
21
- /** If `true` the modal will not close when clicking outside of it */
22
- preventClosing?: boolean;
19
+ /**
20
+ * If `true` the modal will not close when clicking outside of it
21
+ *
22
+ * Defaults to `true`
23
+ * */
24
+ closeOnOutsideClick?: boolean;
23
25
  /** Variant of the modal, applies styling to the header */
24
26
  variant?: ModalVariant;
25
27
  title?: string | Snippet;
@@ -38,10 +40,9 @@
38
40
  let {
39
41
  class: clazz = 'flex flex-col',
40
42
  title,
41
- b_open = $bindable(),
42
43
  children,
43
44
  modal,
44
- preventClosing = false,
45
+ closeOnOutsideClick = true,
45
46
  variant,
46
47
  innerClass,
47
48
  inTransition = (e) =>
@@ -52,8 +53,22 @@
52
53
  ...rest
53
54
  }: Props = $props();
54
55
 
55
- function close() {
56
- b_open = false;
56
+ let currentlyOpen = $state(false);
57
+
58
+ export function close() {
59
+ currentlyOpen = false;
60
+ }
61
+
62
+ export function open() {
63
+ currentlyOpen = true;
64
+ }
65
+
66
+ export function toggle() {
67
+ currentlyOpen = !currentlyOpen;
68
+ }
69
+
70
+ export function isOpen() {
71
+ return currentlyOpen;
57
72
  }
58
73
 
59
74
  const onclick: MouseEventHandler<HTMLDivElement> = (e) => {
@@ -66,12 +81,11 @@
66
81
  @component
67
82
  A modal, comes with a title, close button and different variants per default.
68
83
  -->
69
- {#if b_open}
84
+ {#if currentlyOpen}
70
85
  <Portal>
71
86
  <HiddenBackground
72
87
  onclose={() => {
73
- if (preventClosing) return;
74
- close();
88
+ if (closeOnOutsideClick) close();
75
89
  }}
76
90
  class="flex h-full w-full flex-col items-center justify-start p-8 lg:p-12 xl:p-16"
77
91
  >
@@ -12,13 +12,12 @@
12
12
  import clsx from 'clsx';
13
13
  import { twMerge } from 'tailwind-merge';
14
14
  import { clickOutside } from '../../../utils/actions/clickOutside';
15
+ import Portal from '../portal/Portal.svelte';
15
16
 
16
17
  /** Possible placements for the popover */
17
18
  export type PopoverPlacement = ComputePositionConfig['placement'];
18
19
 
19
20
  export interface PopoverProps extends IvoryComponent<HTMLDivElement> {
20
- /** Whether the popover is open or not */
21
- b_open: boolean;
22
21
  /** The element the popover will be positioned relative to */
23
22
  target: Element | undefined;
24
23
  /**
@@ -45,13 +44,10 @@
45
44
  <script lang="ts">
46
45
  let {
47
46
  class: clazz,
48
- b_open = $bindable(false),
49
47
  style: externalStyle,
50
48
  target,
51
49
  placement = 'bottom-start',
52
- onClickOutside = () => {
53
- b_open = false;
54
- },
50
+ onClickOutside = close,
55
51
  keepMounted = false,
56
52
  children,
57
53
  autoplacement,
@@ -70,21 +66,33 @@
70
66
  style = `top: ${y}px; left: ${x}px;`;
71
67
  };
72
68
 
69
+ let currentlyOpen = $state(false);
70
+
73
71
  let cleanup: () => void = () => {};
74
- $effect(() => {
75
- if (browser && popover && target)
76
- if (b_open) {
77
- cleanup = autoUpdate(target, popover, () => postion(b_open));
78
- } else {
79
- cleanup();
80
- }
81
- });
72
+ export function close() {
73
+ currentlyOpen = false;
74
+ cleanup();
75
+ }
76
+
77
+ export function open() {
78
+ currentlyOpen = true;
79
+ if (!target || !popover) return;
80
+ cleanup = autoUpdate(target, popover, () => postion(true));
81
+ }
82
+
83
+ export function toggle() {
84
+ currentlyOpen = !currentlyOpen;
85
+ }
86
+
87
+ export function isOpen() {
88
+ return currentlyOpen;
89
+ }
82
90
 
83
91
  // TODO: this is kinda hacky
84
92
  $effect(() => {
85
93
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
86
94
  [popover, target];
87
- postion(b_open);
95
+ postion(currentlyOpen);
88
96
  });
89
97
  </script>
90
98
 
@@ -92,16 +100,22 @@
92
100
  @component
93
101
  A popover, positions itself relative to a target element.
94
102
  -->
95
- {#if b_open || keepMounted}
96
- <div
97
- class={twMerge(
98
- clsx('absolute z-30', !keepMounted && clazz, keepMounted && !b_open ? 'hidden' : clazz)
99
- )}
100
- style={style + ' ' + externalStyle}
101
- bind:this={popover}
102
- use:clickOutside={{ callback: onClickOutside, target }}
103
- {...rest}
104
- >
105
- {@render children?.()}
106
- </div>
103
+ {#if currentlyOpen || keepMounted}
104
+ <Portal>
105
+ <div
106
+ class={twMerge(
107
+ clsx(
108
+ 'absolute z-30',
109
+ !keepMounted && clazz,
110
+ keepMounted && !currentlyOpen ? 'hidden' : clazz
111
+ )
112
+ )}
113
+ style={style + ' ' + externalStyle}
114
+ bind:this={popover}
115
+ use:clickOutside={{ callback: onClickOutside, target }}
116
+ {...rest}
117
+ >
118
+ {@render children?.()}
119
+ </div>
120
+ </Portal>
107
121
  {/if}
@@ -3,7 +3,7 @@
3
3
  import { getContext, onDestroy, setContext } from 'svelte';
4
4
 
5
5
  export interface TabsProps extends IvoryComponent<HTMLDivElement> {
6
- b_index?: number;
6
+ initialTab?: number;
7
7
  }
8
8
 
9
9
  export interface TabContext {
@@ -24,27 +24,30 @@
24
24
  </script>
25
25
 
26
26
  <script lang="ts">
27
- let { children, b_index = $bindable(0), ...rest }: TabsProps = $props();
27
+ let { children, initialTab = 0, ...rest }: TabsProps = $props();
28
28
 
29
29
  let allTabs: string[] = $state([]);
30
30
  let panels: string[] = $state([]);
31
+ let index: number = $state(initialTab);
31
32
 
32
33
  export const forward = () => {
33
- if (b_index >= panels.length - 1) {
34
- b_index = 0;
34
+ if (index >= panels.length - 1) {
35
+ index = 0;
35
36
  } else {
36
- b_index++;
37
+ index++;
37
38
  }
38
39
  };
39
40
 
40
41
  export const back = () => {
41
- if (b_index === 0) {
42
- b_index = panels.length - 1;
42
+ if (index === 0) {
43
+ index = panels.length - 1;
43
44
  } else {
44
- b_index--;
45
+ index--;
45
46
  }
46
47
  };
47
48
 
49
+ export const currentTab = () => index;
50
+
48
51
  setTabContext({
49
52
  registerTab: (tab: string) => {
50
53
  allTabs.push(tab);
@@ -56,23 +59,23 @@
56
59
 
57
60
  registerPanel: (panel: string) => {
58
61
  panels.push(panel);
59
- b_index = b_index;
62
+ index = index;
60
63
  onDestroy(() => {
61
64
  panels.filter((p) => p !== panel);
62
65
  });
63
66
  },
64
67
 
65
68
  get selectedTab() {
66
- return allTabs[b_index];
69
+ return allTabs[index];
67
70
  },
68
71
  set selectedTab(tab: string) {
69
- b_index = allTabs.indexOf(tab);
72
+ index = allTabs.indexOf(tab);
70
73
  },
71
74
  get selectedPanel() {
72
- return panels[b_index];
75
+ return panels[index];
73
76
  },
74
77
  set selectedPanel(panel: string) {
75
- b_index = panels.indexOf(panel);
78
+ index = panels.indexOf(panel);
76
79
  },
77
80
  tabs: allTabs
78
81
  });
@@ -4,7 +4,6 @@
4
4
  import type { ClassValue, MouseEventHandler } from 'svelte/elements';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import Popover, { type PopoverPlacement } from '../popover/Popover.svelte';
7
- import Portal from '../portal/Portal.svelte';
8
7
 
9
8
  export interface TooltipProps {
10
9
  onclick?: MouseEventHandler<HTMLElement>;
@@ -44,23 +43,24 @@
44
43
  }: TooltipProps = $props();
45
44
 
46
45
  let target = $state<HTMLElement>();
47
- let open = $state(false);
46
+
47
+ let popover = $state<Popover>();
48
48
 
49
49
  let currentTimeout: number;
50
50
  function onmouseenter() {
51
51
  clearTimeout(currentTimeout);
52
52
  if (timeout === 0) {
53
- open = true;
53
+ popover?.open();
54
54
  } else {
55
55
  currentTimeout = setTimeout(() => {
56
- open = true;
56
+ popover?.open();
57
57
  }, timeout) as unknown as number;
58
58
  }
59
59
  }
60
60
 
61
61
  function onmouseleave() {
62
62
  clearTimeout(currentTimeout);
63
- open = false;
63
+ popover?.close();
64
64
  }
65
65
  </script>
66
66
 
@@ -80,24 +80,20 @@
80
80
  {@render children?.()}
81
81
  </svelte:element>
82
82
 
83
- {#if open}
84
- <Portal>
85
- <Popover
86
- bind:b_open={open}
87
- {target}
88
- {placement}
89
- class={twMerge(
90
- clsx(
91
- 'bg-surface-50-950 max-w-96 -translate-y-0.5 rounded px-4 py-1 shadow-lg',
92
- tooltipClass
93
- )
94
- )}
95
- >
96
- {#if typeof tooltip === 'string'}
97
- {tooltip}
98
- {:else}
99
- {@render tooltip()}
100
- {/if}
101
- </Popover>
102
- </Portal>
103
- {/if}
83
+ <Popover
84
+ bind:this={popover}
85
+ {target}
86
+ {placement}
87
+ class={twMerge(
88
+ clsx(
89
+ 'bg-surface-50-950 max-w-96 -translate-y-0.5 rounded px-4 py-1 shadow-lg',
90
+ tooltipClass
91
+ )
92
+ )}
93
+ >
94
+ {#if typeof tooltip === 'string'}
95
+ {tooltip}
96
+ {:else}
97
+ {@render tooltip()}
98
+ {/if}
99
+ </Popover>
@@ -84,7 +84,38 @@
84
84
  let columns = $state<ColumnController[]>(externalColumns ?? []);
85
85
  let treeIndicatorColumn = $state<ColumnController>();
86
86
 
87
- function toggleExpansion(id: string) {
87
+ setTableContext({
88
+ toggleExpansion,
89
+ registerColumn(config: ColumnConfig) {
90
+ let existingColumn: ColumnController | undefined = undefined;
91
+
92
+ if (config.id === treeIndicatorId) {
93
+ if (!treeIndicatorColumn) treeIndicatorColumn = new ColumnController(config);
94
+ return treeIndicatorColumn;
95
+ }
96
+
97
+ for (const column of existingColumn || columns) {
98
+ if (column.id !== config.id) continue;
99
+ existingColumn = column;
100
+ break;
101
+ }
102
+ if (existingColumn) return existingColumn;
103
+ const col = new ColumnController(config);
104
+ (externalColumns || columns).push(col);
105
+ return col;
106
+ },
107
+ get nestingInset() {
108
+ return nestingInset;
109
+ },
110
+ get rowHeight() {
111
+ return rowHeight;
112
+ },
113
+ scrollTo(top?: number, left?: number) {
114
+ list?.scrollTo(top, left);
115
+ }
116
+ });
117
+
118
+ export function toggleExpansion(id: string) {
88
119
  if (expanded.has(id)) expanded.delete(id);
89
120
  else expanded.add(id);
90
121
  }
@@ -151,37 +182,6 @@
151
182
  prevSearch = currentSearch;
152
183
  });
153
184
 
154
- setTableContext({
155
- toggleExpansion,
156
- registerColumn(config: ColumnConfig) {
157
- let existingColumn: ColumnController | undefined = undefined;
158
-
159
- if (config.id === treeIndicatorId) {
160
- if (!treeIndicatorColumn) treeIndicatorColumn = new ColumnController(config);
161
- return treeIndicatorColumn;
162
- }
163
-
164
- for (const column of existingColumn || columns) {
165
- if (column.id !== config.id) continue;
166
- existingColumn = column;
167
- break;
168
- }
169
- if (existingColumn) return existingColumn;
170
- const col = new ColumnController(config);
171
- (externalColumns || columns).push(col);
172
- return col;
173
- },
174
- get nestingInset() {
175
- return nestingInset;
176
- },
177
- get rowHeight() {
178
- return rowHeight;
179
- },
180
- scrollTo(top?: number, left?: number) {
181
- list?.scrollTo(top, left);
182
- }
183
- });
184
-
185
185
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
186
  let list = $state<VirtualList<any>>();
187
187
  export function scrollTo(top?: number, left?: number) {