@ims360/svelte-ivory 0.0.42 → 0.0.45

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 (78) hide show
  1. package/dist/components/ai/Chat.svelte +12 -12
  2. package/dist/components/ai/Chat.svelte.d.ts +3 -1
  3. package/dist/components/ai/Chat.svelte.d.ts.map +1 -1
  4. package/dist/components/ai/UserMessage.svelte +1 -1
  5. package/dist/components/basic/checkbox/Checkbox.svelte +0 -1
  6. package/dist/components/basic/checkbox/Checkbox.svelte.d.ts.map +1 -1
  7. package/dist/components/layout/drawer/Drawer.svelte +13 -9
  8. package/dist/components/layout/drawer/Drawer.svelte.d.ts +4 -4
  9. package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
  10. package/dist/components/layout/modal/Modal.svelte +12 -9
  11. package/dist/components/layout/modal/Modal.svelte.d.ts +6 -5
  12. package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
  13. package/dist/components/layout/popover/Popover.svelte +1 -0
  14. package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
  15. package/dist/components/layout/tooltip/Tooltip.svelte +5 -5
  16. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts +5 -3
  17. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
  18. package/dist/components/table/Column.svelte +2 -2
  19. package/dist/components/table/ColumnHead.svelte +4 -4
  20. package/dist/components/table/ColumnHead.svelte.d.ts +3 -3
  21. package/dist/components/table/ColumnHead.svelte.d.ts.map +1 -1
  22. package/dist/components/table/Row.svelte +0 -1
  23. package/dist/components/table/Row.svelte.d.ts.map +1 -1
  24. package/dist/components/table/Table.svelte +56 -24
  25. package/dist/components/table/Table.svelte.d.ts +12 -9
  26. package/dist/components/table/Table.svelte.d.ts.map +1 -1
  27. package/dist/components/table/VirtualList.svelte +3 -3
  28. package/dist/components/table/columnController.svelte.d.ts +1 -1
  29. package/dist/components/table/columnController.svelte.d.ts.map +1 -1
  30. package/dist/components/table/columnController.svelte.js +1 -1
  31. package/dist/components/table/controller.d.ts +23 -0
  32. package/dist/components/table/controller.d.ts.map +1 -0
  33. package/dist/components/table/controller.js +52 -0
  34. package/dist/components/table/index.d.ts +2 -2
  35. package/dist/components/table/index.d.ts.map +1 -1
  36. package/dist/components/table/index.js +2 -2
  37. package/dist/components/table/plugins/search.svelte.d.ts +3 -2
  38. package/dist/components/table/plugins/search.svelte.d.ts.map +1 -1
  39. package/dist/components/table/plugins/search.svelte.js +3 -4
  40. package/dist/components/toast/Toast.svelte +0 -2
  41. package/dist/components/toast/Toast.svelte.d.ts.map +1 -1
  42. package/dist/utils/functions/cookie.js +1 -1
  43. package/package.json +1 -1
  44. package/src/lib/components/ai/Chat.svelte +12 -12
  45. package/src/lib/components/ai/UserMessage.svelte +1 -1
  46. package/src/lib/components/basic/checkbox/Checkbox.svelte +0 -1
  47. package/src/lib/components/layout/drawer/Drawer.svelte +13 -9
  48. package/src/lib/components/layout/modal/Modal.svelte +12 -9
  49. package/src/lib/components/layout/popover/Popover.svelte +1 -0
  50. package/src/lib/components/layout/tabs/index.ts +0 -1
  51. package/src/lib/components/layout/tooltip/Tooltip.svelte +5 -5
  52. package/src/lib/components/table/Column.svelte +2 -2
  53. package/src/lib/components/table/ColumnHead.svelte +4 -4
  54. package/src/lib/components/table/Row.svelte +0 -1
  55. package/src/lib/components/table/Table.svelte +56 -24
  56. package/src/lib/components/table/VirtualList.svelte +3 -3
  57. package/src/lib/components/table/columnController.svelte.ts +1 -1
  58. package/src/lib/components/table/controller.ts +75 -0
  59. package/src/lib/components/table/index.ts +2 -9
  60. package/src/lib/components/table/plugins/search.svelte.ts +3 -12
  61. package/src/lib/components/toast/Toast.svelte +0 -2
  62. package/src/lib/utils/functions/cookie.ts +1 -1
  63. package/dist/components/layout/modal/ModalTest.svelte +0 -9
  64. package/dist/components/layout/modal/ModalTest.svelte.d.ts +0 -8
  65. package/dist/components/layout/modal/ModalTest.svelte.d.ts.map +0 -1
  66. package/dist/components/table/controller.svelte.d.ts +0 -37
  67. package/dist/components/table/controller.svelte.d.ts.map +0 -1
  68. package/dist/components/table/controller.svelte.js +0 -160
  69. package/dist/components/table/plugins/expandAll.svelte.d.ts +0 -7
  70. package/dist/components/table/plugins/expandAll.svelte.d.ts.map +0 -1
  71. package/dist/components/table/plugins/expandAll.svelte.js +0 -24
  72. package/dist/utils/functions/transitionProps.d.ts +0 -1
  73. package/dist/utils/functions/transitionProps.d.ts.map +0 -1
  74. package/dist/utils/functions/transitionProps.js +0 -1
  75. package/src/lib/components/layout/modal/ModalTest.svelte +0 -9
  76. package/src/lib/components/table/controller.svelte.ts +0 -203
  77. package/src/lib/components/table/plugins/expandAll.svelte.ts +0 -34
  78. package/src/lib/utils/functions/transitionProps.ts +0 -1
@@ -41,7 +41,7 @@
41
41
 
42
42
  let {
43
43
  class: clazz,
44
- b_chat: chat = $bindable(),
44
+ b_chat = $bindable(),
45
45
  userMessage = defaultUserMessage,
46
46
  systemMessage = defaultSystemMessage,
47
47
  placeholder,
@@ -60,7 +60,7 @@
60
60
  return remainHeight;
61
61
  }
62
62
 
63
- async function scrollToBottom() {
63
+ export async function scrollToBottom() {
64
64
  if (!chatContainer) return;
65
65
  await tick();
66
66
  await tick();
@@ -74,20 +74,20 @@
74
74
  }
75
75
 
76
76
  async function submit(message: AiChatMessage) {
77
- if (chat.loading) {
77
+ if (b_chat.loading) {
78
78
  return;
79
79
  }
80
80
 
81
- chat.messages.push({
81
+ b_chat.messages.push({
82
82
  ...message,
83
83
  from: 'user',
84
84
  time: new Date()
85
85
  });
86
86
  // prevent the user from sending another message while we are loading the ai response
87
- chat.loading = true;
87
+ b_chat.loading = true;
88
88
 
89
89
  // add an empty system message to the chat, this will indicate a loading state
90
- chat.messages.push({
90
+ b_chat.messages.push({
91
91
  from: 'system',
92
92
  message: '',
93
93
  time: new Date()
@@ -97,7 +97,7 @@
97
97
 
98
98
  await externalSubmit(message);
99
99
 
100
- chat.loading = false;
100
+ b_chat.loading = false;
101
101
  }
102
102
  </script>
103
103
 
@@ -106,11 +106,11 @@
106
106
  class="flex grow flex-col gap-4 overflow-auto pr-2 [scrollbar-gutter:stable]"
107
107
  bind:this={chatContainer}
108
108
  >
109
- {#if chat.messages.length === 0 && placeholder}
109
+ {#if b_chat.messages.length === 0 && placeholder}
110
110
  {@render placeholder()}
111
111
  {/if}
112
- {#each chat.messages as _, i}
113
- {@const message = chat.messages[i]}
112
+ {#each b_chat.messages as _, i (i)}
113
+ {@const message = b_chat.messages[i]}
114
114
  {#if message.from === 'user'}
115
115
  {@render userMessage({
116
116
  message,
@@ -120,7 +120,7 @@
120
120
  {@render systemMessage({
121
121
  message,
122
122
  i,
123
- minHeight: i === chat.messages.length - 1 ? lastMessageMinHeight : 0
123
+ minHeight: i === b_chat.messages.length - 1 ? lastMessageMinHeight : 0
124
124
  })}
125
125
  {/if}
126
126
  {/each}
@@ -136,7 +136,7 @@
136
136
  message: AiChatMessage;
137
137
  minHeight?: number;
138
138
  })}
139
- <AiMessage bind:b_message={chat.messages[i]} {minHeight} />
139
+ <AiMessage bind:b_message={b_chat.messages[i]} {minHeight} />
140
140
  {/snippet}
141
141
 
142
142
  {#snippet defaultUserMessage({
@@ -35,7 +35,9 @@ interface Props {
35
35
  * Comes with default styles for the chat messages, but can be customized with the `userMessage` and `systemMessage` props.
36
36
  * The input component has to be provided as a child component, and the `submit` function has to be provided as a callback.
37
37
  */
38
- declare const Chat: import("svelte").Component<Props, {}, "b_chat">;
38
+ declare const Chat: import("svelte").Component<Props, {
39
+ scrollToBottom: () => Promise<void>;
40
+ }, "b_chat">;
39
41
  type Chat = ReturnType<typeof Chat>;
40
42
  export default Chat;
41
43
  //# sourceMappingURL=Chat.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI,iDAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI;;YAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
@@ -28,7 +28,7 @@
28
28
  {@render messageText({ message })}
29
29
  {#if message.files}
30
30
  <div class="flex flex-row items-center gap-2">
31
- {#each message.files as file}
31
+ {#each message.files as file, i (i)}
32
32
  {@render attachedFile(file)}
33
33
  {/each}
34
34
  </div>
@@ -55,7 +55,6 @@
55
55
  });
56
56
  </script>
57
57
 
58
- <!-- svelte-ignore a11y_no_static_element_interactions-->
59
58
  <svelte:element
60
59
  this={onclick ? 'button' : 'div'}
61
60
  type="button"
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAuDL,sBAAsB;AACtB,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAsDL,sBAAsB;AACtB,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" module>
2
- import type { IvoryComponent, TransitionProps } from '../../../types';
2
+ import type { TransitionProps } from '../../../types';
3
3
  import { X } from '@lucide/svelte';
4
4
  import clsx from 'clsx';
5
5
  import type { Snippet } from 'svelte';
@@ -11,13 +11,13 @@
11
11
 
12
12
  export type DrawerPlacement = 'left' | 'right';
13
13
 
14
- export interface DrawerProps extends IvoryComponent<HTMLDivElement>, TransitionProps {
14
+ export type DrawerProps = TransitionProps & {
15
15
  class?: string;
16
16
  b_open: boolean;
17
- title?: string;
17
+ title?: string | Snippet;
18
18
  children: Snippet;
19
19
  placement?: DrawerPlacement;
20
- }
20
+ };
21
21
  </script>
22
22
 
23
23
  <script lang="ts">
@@ -42,8 +42,6 @@
42
42
  {#if b_open}
43
43
  <Portal>
44
44
  <HiddenBackground {onclose}>
45
- <!-- svelte-ignore a11y_click_events_have_key_events -->
46
- <!-- svelte-ignore a11y_no_static_element_interactions -->
47
45
  <div
48
46
  class={twMerge(
49
47
  clsx([
@@ -54,13 +52,19 @@
54
52
  ])
55
53
  )}
56
54
  onclick={(e) => e.stopPropagation()}
57
- in:inTransition
58
- out:outTransition
55
+ in:inTransition|global
56
+ out:outTransition|global
59
57
  {...rest}
60
58
  >
61
59
  <div class="flex flex-row items-center justify-between gap-8">
62
60
  {#if title}
63
- <Heading>{title}</Heading>
61
+ <Heading class="flex grow flex-row items-center gap-4">
62
+ {#if typeof title === 'function'}
63
+ {@render title()}
64
+ {:else}
65
+ {title}
66
+ {/if}
67
+ </Heading>
64
68
  {/if}
65
69
  <button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
66
70
  <X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
@@ -1,13 +1,13 @@
1
- import type { IvoryComponent, TransitionProps } from '../../../types';
1
+ import type { TransitionProps } from '../../../types';
2
2
  import type { Snippet } from 'svelte';
3
3
  export type DrawerPlacement = 'left' | 'right';
4
- export interface DrawerProps extends IvoryComponent<HTMLDivElement>, TransitionProps {
4
+ export type DrawerProps = TransitionProps & {
5
5
  class?: string;
6
6
  b_open: boolean;
7
- title?: string;
7
+ title?: string | Snippet;
8
8
  children: Snippet;
9
9
  placement?: DrawerPlacement;
10
- }
10
+ };
11
11
  declare const Drawer: import("svelte").Component<DrawerProps, {}, "b_open">;
12
12
  type Drawer = ReturnType<typeof Drawer>;
13
13
  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,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAOtC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,cAAc,CAAC,EAAE,eAAe;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B;AAoDL,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,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,5 +1,5 @@
1
1
  <script lang="ts" module>
2
- import type { IvoryComponent, TransitionProps } from '../../../types';
2
+ import type { TransitionProps } from '../../../types';
3
3
  import { X } from '@lucide/svelte';
4
4
  import clsx from 'clsx';
5
5
  import { type Snippet } from 'svelte';
@@ -9,7 +9,7 @@
9
9
  import { Heading, HiddenBackground, Portal } from '..';
10
10
 
11
11
  /** Props for the modal, expose if you overwrite the defaults in a custom component */
12
- export interface ModalProps extends IvoryComponent<HTMLDivElement>, TransitionProps {
12
+ export type ModalProps = TransitionProps & {
13
13
  /** Class of the modal itself, does not apply to the inner div */
14
14
  class?: ClassValue;
15
15
  /** Class of the div wrapping the children */
@@ -22,8 +22,9 @@
22
22
  preventClosing?: boolean;
23
23
  /** Variant of the modal, applies styling to the header */
24
24
  variant?: ModalVariant;
25
- title?: string;
26
- }
25
+ title?: string | Snippet;
26
+ onclick?: MouseEventHandler<HTMLDivElement>;
27
+ };
27
28
 
28
29
  export type ModalVariant = 'success' | 'warning' | 'error' | 'info';
29
30
  </script>
@@ -73,14 +74,10 @@
73
74
  class="flex h-full w-full flex-col items-center justify-start p-8 lg:p-12 xl:p-16"
74
75
  >
75
76
  {#if modal}
76
- <!-- svelte-ignore a11y_no_static_element_interactions -->
77
- <!-- svelte-ignore a11y_click_events_have_key_events -->
78
77
  <div {...rest} {onclick}>
79
78
  {@render modal()}
80
79
  </div>
81
80
  {:else}
82
- <!-- svelte-ignore a11y_click_events_have_key_events -->
83
- <!-- svelte-ignore a11y_no_static_element_interactions -->
84
81
  <div
85
82
  class={twMerge(
86
83
  clsx([
@@ -104,7 +101,13 @@
104
101
  ]}
105
102
  >
106
103
  {#if title}
107
- <Heading>{title}</Heading>
104
+ <Heading class="flex grow flex-row items-center gap-4">
105
+ {#if typeof title === 'function'}
106
+ {@render title()}
107
+ {:else}
108
+ {title}
109
+ {/if}
110
+ </Heading>
108
111
  {/if}
109
112
  <button
110
113
  class="group ml-auto flex justify-end"
@@ -1,8 +1,8 @@
1
- import type { IvoryComponent, TransitionProps } from '../../../types';
1
+ import type { TransitionProps } from '../../../types';
2
2
  import { type Snippet } from 'svelte';
3
- import type { ClassValue } from 'svelte/elements';
3
+ import type { ClassValue, MouseEventHandler } from 'svelte/elements';
4
4
  /** Props for the modal, expose if you overwrite the defaults in a custom component */
5
- export interface ModalProps extends IvoryComponent<HTMLDivElement>, TransitionProps {
5
+ export type ModalProps = TransitionProps & {
6
6
  /** Class of the modal itself, does not apply to the inner div */
7
7
  class?: ClassValue;
8
8
  /** Class of the div wrapping the children */
@@ -15,8 +15,9 @@ export interface ModalProps extends IvoryComponent<HTMLDivElement>, TransitionPr
15
15
  preventClosing?: boolean;
16
16
  /** Variant of the modal, applies styling to the header */
17
17
  variant?: ModalVariant;
18
- title?: string;
19
- }
18
+ title?: string | Snippet;
19
+ onclick?: MouseEventHandler<HTMLDivElement>;
20
+ };
20
21
  export type ModalVariant = 'success' | 'warning' | 'error' | 'info';
21
22
  interface Props extends ModalProps {
22
23
  /** If you don't want the title and close button to be included you can overwrite the 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,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,iBAAiB,CAAC;AAKrE,sFAAsF;AACtF,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC,EAAE,eAAe;IAC/E,iEAAiE;IACjE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,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;AAoFL,oFAAoF;AACpF,QAAA,MAAM,KAAK,iDAAwC,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,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,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,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;AAsFL,oFAAoF;AACpF,QAAA,MAAM,KAAK,iDAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
@@ -82,6 +82,7 @@
82
82
 
83
83
  // TODO: this is kinda hacky
84
84
  $effect(() => {
85
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
85
86
  [popover, target];
86
87
  postion(b_open);
87
88
  });
@@ -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;AA4DL,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;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,13 +1,15 @@
1
1
  <script lang="ts" module>
2
- import type { IvoryComponent } from '../../../types';
3
2
  import clsx from 'clsx';
4
3
  import type { Snippet } from 'svelte';
5
- import type { ClassValue } from 'svelte/elements';
4
+ import type { ClassValue, MouseEventHandler } from 'svelte/elements';
6
5
  import { twMerge } from 'tailwind-merge';
7
6
  import Popover, { type PopoverPlacement } from '../popover/Popover.svelte';
8
7
  import Portal from '../portal/Portal.svelte';
9
8
 
10
- export interface TooltipProps extends IvoryComponent<HTMLElement> {
9
+ export interface TooltipProps {
10
+ onclick?: MouseEventHandler<HTMLElement>;
11
+ class?: ClassValue;
12
+ style?: string;
11
13
  children?: Snippet;
12
14
  /** The content of the tooltip */
13
15
  tooltip: string | Snippet;
@@ -67,8 +69,6 @@
67
69
  @component
68
70
  Shows additional information when hovering over an element.
69
71
  -->
70
- <!-- Ignoring this error is fine since it's a false positive -->
71
- <!-- svelte-ignore a11y_no_static_element_interactions -->
72
72
  <svelte:element
73
73
  this={href ? 'a' : rest.onclick ? 'button' : 'div'}
74
74
  type={rest.onclick ? 'button' : undefined}
@@ -1,8 +1,10 @@
1
- import type { IvoryComponent } from '../../../types';
2
1
  import type { Snippet } from 'svelte';
3
- import type { ClassValue } from 'svelte/elements';
2
+ import type { ClassValue, MouseEventHandler } from 'svelte/elements';
4
3
  import { type PopoverPlacement } from '../popover/Popover.svelte';
5
- export interface TooltipProps extends IvoryComponent<HTMLElement> {
4
+ export interface TooltipProps {
5
+ onclick?: MouseEventHandler<HTMLElement>;
6
+ class?: ClassValue;
7
+ style?: string;
6
8
  children?: Snippet;
7
9
  /** The content of the tooltip */
8
10
  tooltip: string | Snippet;
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/tooltip/Tooltip.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG3E,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC7D,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;AA+DL,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;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;AA6DL,kEAAkE;AAClE,QAAA,MAAM,OAAO,kDAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -36,8 +36,8 @@
36
36
  }: ColumnProps = $props();
37
37
 
38
38
  // Register the new column if this is the first table row that was rendered
39
- const { table, nestingInset } = getTableContext();
40
- const column = table.registerColumn({ resizable, ...props });
39
+ const { registerColumn, nestingInset } = getTableContext();
40
+ const column = registerColumn({ resizable, ...props });
41
41
  const allowClicking = $derived(!!onclick);
42
42
 
43
43
  // passes updated props to the column
@@ -1,21 +1,21 @@
1
1
  <script lang="ts" module>
2
2
  import { getContext, setContext, type Snippet } from 'svelte';
3
3
  import { resize } from '../../utils/actions';
4
- import type { Column } from './columnController.svelte';
4
+ import type { ColumnController } from './columnController.svelte';
5
5
 
6
6
  const CONTEXT = {};
7
- function setColumnHeadContext(column: Column) {
7
+ function setColumnHeadContext(column: ColumnController) {
8
8
  setContext(CONTEXT, column);
9
9
  }
10
10
 
11
- export function getColumnHeadContext(): Column {
11
+ export function getColumnHeadContext(): ColumnController {
12
12
  return getContext(CONTEXT);
13
13
  }
14
14
  </script>
15
15
 
16
16
  <script lang="ts">
17
17
  type Props = {
18
- column: Column;
18
+ column: ColumnController;
19
19
  children: Snippet;
20
20
  };
21
21
 
@@ -1,8 +1,8 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { Column } from './columnController.svelte';
3
- export declare function getColumnHeadContext(): Column;
2
+ import type { ColumnController } from './columnController.svelte';
3
+ export declare function getColumnHeadContext(): ColumnController;
4
4
  type Props = {
5
- column: Column;
5
+ column: ColumnController;
6
6
  children: Snippet;
7
7
  };
8
8
  declare const ColumnHead: import("svelte").Component<Props, {}, "">;
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnHead.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/ColumnHead.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAOxD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AA+CN,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"ColumnHead.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/ColumnHead.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAOlE,wBAAgB,oBAAoB,IAAI,gBAAgB,CAEvD;AAED,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AA+CN,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -51,7 +51,6 @@
51
51
  });
52
52
  </script>
53
53
 
54
- <!-- svelte-ignore a11y_no_static_element_interactions -->
55
54
  <svelte:element
56
55
  this={elementProps.this}
57
56
  {...elementProps}
@@ -1 +1 @@
1
- {"version":3,"file":"Row.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Row.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,QAEvC;AAED,MAAM,WAAW,KAAK;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB;AAkDL,QAAA,MAAM,GAAG,2CAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Row.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Row.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,QAEvC;AAED,MAAM,WAAW,KAAK;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB;AAiDL,QAAA,MAAM,GAAG,2CAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
@@ -4,12 +4,14 @@
4
4
  import clsx from 'clsx';
5
5
  import { getContext, setContext, type Snippet } from 'svelte';
6
6
  import type { ClassValue } from 'svelte/elements';
7
+ import { SvelteSet } from 'svelte/reactivity';
7
8
  import { twMerge } from 'tailwind-merge';
8
- import { Column, type TableConfig, type TablePlugin, type TableRow } from '.';
9
+ import { Column as ColumnComponent, type TablePlugin, type TableRow } from '.';
9
10
  import ColumnHead from './ColumnHead.svelte';
10
11
  import Row from './Row.svelte';
11
12
  import VirtualList from './VirtualList.svelte';
12
- import { createTableConfig } from './controller.svelte';
13
+ import { ColumnController, type ColumnConfig } from './columnController.svelte';
14
+ import { treeWalker, type TableState } from './controller';
13
15
 
14
16
  export interface TableProps<T extends TableRow<T>> {
15
17
  class?: ClassValue;
@@ -24,7 +26,11 @@
24
26
  rowClass?: ClassValue;
25
27
  headerClass?: ClassValue;
26
28
  plugins?: TablePlugin<T>[];
27
- config?: TableConfig<T>;
29
+ /**
30
+ * **Bindable**
31
+ */
32
+ b_columns?: ColumnController[];
33
+ expanded?: SvelteSet<string>;
28
34
  /**
29
35
  * **Bindable**
30
36
  */
@@ -35,9 +41,11 @@
35
41
 
36
42
  const TABLE_CONTEXT = {};
37
43
  export type TableContext<T extends TableRow<T>> = {
38
- table: TableConfig<T>;
44
+ registerColumn: (config: ColumnConfig) => ColumnController;
45
+ toggleExpansion: (id: string) => void;
39
46
  nestingInset: number;
40
47
  };
48
+
41
49
  function setTableContext<T extends TableRow<T>>(context: TableContext<T>) {
42
50
  setContext(TABLE_CONTEXT, context);
43
51
  }
@@ -48,8 +56,6 @@
48
56
  </script>
49
57
 
50
58
  <script lang="ts" generics="T extends TableRow<T>">
51
- interface Props<TI extends { id: string }> extends TableProps<TI> {}
52
-
53
59
  let {
54
60
  class: clazz,
55
61
  data,
@@ -61,31 +67,57 @@
61
67
  onclick,
62
68
  href,
63
69
  plugins = [],
64
- config: table = createTableConfig<T>(),
65
- nestingInset = 4
66
- }: Props<T> = $props();
70
+ expanded: expanded = new SvelteSet<string>(),
71
+ nestingInset = 4,
72
+ b_columns: externalColumns = $bindable(),
73
+ b_scrollTop = $bindable()
74
+ }: TableProps<T> = $props();
67
75
 
68
- $effect(() => {
69
- table.data = data;
70
- table.plugins = plugins;
71
- });
76
+ let columns = $state<ColumnController[]>(externalColumns ?? []);
77
+ const results = $derived(computeResults(data, expanded, plugins));
78
+
79
+ function toggleExpansion(id: string) {
80
+ if (expanded.has(id)) expanded.delete(id);
81
+ else expanded.add(id);
82
+ }
72
83
 
73
84
  setTableContext({
74
- get table() {
75
- return table;
85
+ toggleExpansion,
86
+ registerColumn(config: ColumnConfig) {
87
+ let existingColumn: ColumnController | undefined = undefined;
88
+ for (const column of existingColumn || columns) {
89
+ if (column.id !== config.id) continue;
90
+ existingColumn = column;
91
+ break;
92
+ }
93
+ if (existingColumn) return existingColumn;
94
+ const col = new ColumnController(config);
95
+ (externalColumns || columns).push(col);
96
+ return col;
76
97
  },
77
98
  get nestingInset() {
78
99
  return nestingInset;
79
100
  }
80
101
  });
81
102
 
103
+ function computeResults(data: T[], expanded: Set<string>, plugins: TablePlugin<T>[]) {
104
+ let state: TableState<T> = {
105
+ data,
106
+ expanded
107
+ };
108
+ for (const plugin of plugins) {
109
+ state = plugin(state);
110
+ }
111
+ return treeWalker(state);
112
+ }
113
+
82
114
  const treeIndicatorId = pseudoRandomId('tree-indicator-');
83
115
  </script>
84
116
 
85
117
  <VirtualList
86
- data={table.results.entries}
118
+ data={results.entries}
87
119
  class={twMerge(clsx(['flex flex-col overflow-hidden border-transparent', clazz]))}
88
- bind:b_scrollTop={table.scrollTop}
120
+ bind:b_scrollTop
89
121
  {rowHeight}
90
122
  >
91
123
  {#snippet header()}
@@ -97,7 +129,7 @@
97
129
  )
98
130
  )}
99
131
  >
100
- {#each table.columns as column (column.id)}
132
+ {#each externalColumns || columns as column (column.id)}
101
133
  <ColumnHead {column}>
102
134
  {#if typeof column.header === 'function'}
103
135
  {@render column.header()}
@@ -119,15 +151,15 @@
119
151
  class={rowClass}
120
152
  >
121
153
  {@render firstColumn?.({ row: node })}
122
- <Column
154
+ <ColumnComponent
123
155
  id={treeIndicatorId}
124
156
  resizable={false}
125
157
  header=""
126
158
  onclick={() => {
127
- table.toggleExpansion(node.id);
159
+ toggleExpansion(node.id);
128
160
  }}
129
- ignoreWidth={table.results.someHaveChildren}
130
- width={table.results.someHaveChildren ? 24 : 0}
161
+ ignoreWidth={results.someHaveChildren}
162
+ width={results.someHaveChildren ? 24 : 0}
131
163
  minWidth={0}
132
164
  >
133
165
  <div
@@ -138,12 +170,12 @@
138
170
  <ChevronRight
139
171
  class={[
140
172
  'ml-auto aspect-square shrink-0 transition-transform duration-100',
141
- table.expanded.has(id) && 'rotate-90'
173
+ expanded.has(id) && 'rotate-90'
142
174
  ]}
143
175
  />
144
176
  {/if}
145
177
  </div>
146
- </Column>
178
+ </ColumnComponent>
147
179
  {@render passedChildren?.({ row: node, nestingLevel, index })}
148
180
  </Row>
149
181
  {/snippet}