@invopop/popui 0.1.35 → 0.1.40

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 (119) hide show
  1. package/dist/BaseButton.svelte +4 -0
  2. package/dist/BaseDropdown.svelte +42 -3
  3. package/dist/BaseDropdown.svelte.d.ts +1 -0
  4. package/dist/BaseTableHeaderOrderBy.svelte +35 -12
  5. package/dist/ButtonSearch.svelte +82 -0
  6. package/dist/ButtonSearch.svelte.d.ts +4 -0
  7. package/dist/ButtonUuidCopy.svelte +1 -0
  8. package/dist/DatePicker.svelte +96 -27
  9. package/dist/DatePicker.svelte.d.ts +5 -1
  10. package/dist/DrawerContext.svelte +443 -34
  11. package/dist/DrawerContextItem.svelte +36 -29
  12. package/dist/DropdownSelect.svelte +68 -18
  13. package/dist/DropdownSelect.svelte.d.ts +4 -1
  14. package/dist/DropdownSelectGroup.svelte +15 -0
  15. package/dist/DropdownSelectGroup.svelte.d.ts +7 -0
  16. package/dist/EmptyState.svelte +6 -2
  17. package/dist/InputSearch.svelte +45 -5
  18. package/dist/InputSelect.svelte +12 -3
  19. package/dist/InputText.svelte +25 -8
  20. package/dist/InputToggle.svelte +23 -6
  21. package/dist/StepIcon.svelte +35 -0
  22. package/dist/StepIcon.svelte.d.ts +4 -0
  23. package/dist/StepIconList.svelte +24 -31
  24. package/dist/TagStatus.svelte +1 -1
  25. package/dist/button/button.svelte +34 -3
  26. package/dist/button/button.svelte.d.ts +29 -0
  27. package/dist/clickOutside.d.ts +5 -2
  28. package/dist/clickOutside.js +9 -3
  29. package/dist/data-table/cells/boolean-cell.svelte +29 -0
  30. package/dist/data-table/cells/boolean-cell.svelte.d.ts +8 -0
  31. package/dist/data-table/cells/cell-skeleton.svelte +35 -0
  32. package/dist/data-table/cells/cell-skeleton.svelte.d.ts +4 -0
  33. package/dist/data-table/cells/currency-cell.svelte +10 -0
  34. package/dist/data-table/cells/currency-cell.svelte.d.ts +8 -0
  35. package/dist/data-table/cells/date-cell.svelte +10 -0
  36. package/dist/data-table/cells/date-cell.svelte.d.ts +8 -0
  37. package/dist/data-table/cells/tag-cell.svelte +12 -0
  38. package/dist/data-table/cells/tag-cell.svelte.d.ts +8 -0
  39. package/dist/data-table/cells/text-cell.svelte +10 -0
  40. package/dist/data-table/cells/text-cell.svelte.d.ts +8 -0
  41. package/dist/data-table/cells/uuid-cell.svelte +17 -0
  42. package/dist/data-table/cells/uuid-cell.svelte.d.ts +8 -0
  43. package/dist/data-table/column-definitions.d.ts +12 -0
  44. package/dist/data-table/column-definitions.js +42 -0
  45. package/dist/data-table/column-sizing-helpers.d.ts +6 -0
  46. package/dist/data-table/column-sizing-helpers.js +24 -0
  47. package/dist/data-table/create-columns.d.ts +3 -0
  48. package/dist/data-table/create-columns.js +67 -0
  49. package/dist/data-table/data-table-cell.svelte +94 -0
  50. package/dist/data-table/data-table-cell.svelte.d.ts +25 -0
  51. package/dist/data-table/data-table-header-cell.svelte +188 -0
  52. package/dist/data-table/data-table-header-cell.svelte.d.ts +25 -0
  53. package/dist/data-table/data-table-helpers.d.ts +10 -0
  54. package/dist/data-table/data-table-helpers.js +124 -0
  55. package/dist/data-table/data-table-pagination.svelte +214 -0
  56. package/dist/data-table/data-table-pagination.svelte.d.ts +4 -0
  57. package/dist/data-table/data-table-row.svelte +57 -0
  58. package/dist/data-table/data-table-row.svelte.d.ts +25 -0
  59. package/dist/data-table/data-table-svelte.svelte.d.ts +40 -0
  60. package/dist/data-table/data-table-svelte.svelte.js +115 -0
  61. package/dist/data-table/data-table-toolbar.svelte +19 -0
  62. package/dist/data-table/data-table-toolbar.svelte.d.ts +32 -0
  63. package/dist/data-table/data-table-types.d.ts +194 -0
  64. package/dist/data-table/data-table-types.js +1 -0
  65. package/dist/data-table/data-table-view-options.svelte +126 -0
  66. package/dist/data-table/data-table-view-options.svelte.d.ts +29 -0
  67. package/dist/data-table/data-table.svelte +428 -0
  68. package/dist/data-table/data-table.svelte.d.ts +25 -0
  69. package/dist/data-table/flex-render.svelte +40 -0
  70. package/dist/data-table/flex-render.svelte.d.ts +33 -0
  71. package/dist/data-table/index.d.ts +13 -0
  72. package/dist/data-table/index.js +13 -0
  73. package/dist/data-table/render-helpers.d.ts +90 -0
  74. package/dist/data-table/render-helpers.js +99 -0
  75. package/dist/data-table/table-setup.d.ts +39 -0
  76. package/dist/data-table/table-setup.js +151 -0
  77. package/dist/data-table/table-styles.d.ts +17 -0
  78. package/dist/data-table/table-styles.js +70 -0
  79. package/dist/drawer-dnd-helpers.d.ts +30 -0
  80. package/dist/drawer-dnd-helpers.js +72 -0
  81. package/dist/helpers.d.ts +1 -0
  82. package/dist/helpers.js +3 -0
  83. package/dist/index.d.ts +15 -3
  84. package/dist/index.js +28 -5
  85. package/dist/skeleton/index.d.ts +5 -0
  86. package/dist/skeleton/index.js +7 -0
  87. package/dist/skeleton/skeleton-avatar.svelte +14 -0
  88. package/dist/skeleton/skeleton-avatar.svelte.d.ts +7 -0
  89. package/dist/skeleton/skeleton-card.svelte +22 -0
  90. package/dist/skeleton/skeleton-card.svelte.d.ts +9 -0
  91. package/dist/skeleton/skeleton-list.svelte +25 -0
  92. package/dist/skeleton/skeleton-list.svelte.d.ts +8 -0
  93. package/dist/skeleton/skeleton.svelte +17 -0
  94. package/dist/skeleton/skeleton.svelte.d.ts +5 -0
  95. package/dist/svg/IconDelivery.svelte +1 -1
  96. package/dist/svg/IconOrder.svelte +1 -1
  97. package/dist/svg/IconPayment.svelte +1 -1
  98. package/dist/table/table-cell.svelte +4 -2
  99. package/dist/table/table-head.svelte +4 -2
  100. package/dist/table/table-header.svelte +1 -1
  101. package/dist/table/table-row.svelte +4 -2
  102. package/dist/table/table.svelte +2 -2
  103. package/dist/tailwind.theme.css +30 -6
  104. package/dist/tooltip/index.d.ts +2 -1
  105. package/dist/tooltip/index.js +3 -2
  106. package/dist/tooltip/tooltip-auto-hide.svelte +31 -0
  107. package/dist/tooltip/tooltip-auto-hide.svelte.d.ts +7 -0
  108. package/dist/types.d.ts +51 -73
  109. package/package.json +14 -8
  110. package/dist/BaseTable.svelte +0 -391
  111. package/dist/BaseTable.svelte.d.ts +0 -4
  112. package/dist/BaseTableCellContent.svelte +0 -58
  113. package/dist/BaseTableCellContent.svelte.d.ts +0 -4
  114. package/dist/BaseTableCheckbox.svelte +0 -33
  115. package/dist/BaseTableCheckbox.svelte.d.ts +0 -4
  116. package/dist/BaseTableHeaderContent.svelte +0 -67
  117. package/dist/BaseTableHeaderContent.svelte.d.ts +0 -4
  118. package/dist/BaseTableRow.svelte +0 -127
  119. package/dist/BaseTableRow.svelte.d.ts +0 -4
@@ -10,6 +10,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
10
10
  outline: string;
11
11
  ghost: string;
12
12
  secondary: string;
13
+ selected: string;
13
14
  dark: string;
14
15
  'dark-ghost': string;
15
16
  };
@@ -26,6 +27,14 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
26
27
  true: string;
27
28
  false: string;
28
29
  };
30
+ stackedLeft: {
31
+ true: string;
32
+ false: string;
33
+ };
34
+ stackedRight: {
35
+ true: string;
36
+ false: string;
37
+ };
29
38
  }, undefined, "inline-flex items-center justify-center font-medium text-base whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-selected focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-30 relative overflow-hidden box-border cursor-pointer", {
30
39
  variant: {
31
40
  primary: string;
@@ -34,6 +43,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
34
43
  outline: string;
35
44
  ghost: string;
36
45
  secondary: string;
46
+ selected: string;
37
47
  dark: string;
38
48
  'dark-ghost': string;
39
49
  };
@@ -50,6 +60,14 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
50
60
  true: string;
51
61
  false: string;
52
62
  };
63
+ stackedLeft: {
64
+ true: string;
65
+ false: string;
66
+ };
67
+ stackedRight: {
68
+ true: string;
69
+ false: string;
70
+ };
53
71
  }, undefined, import("tailwind-variants").TVReturnType<{
54
72
  variant: {
55
73
  primary: string;
@@ -58,6 +76,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
58
76
  outline: string;
59
77
  ghost: string;
60
78
  secondary: string;
79
+ selected: string;
61
80
  dark: string;
62
81
  'dark-ghost': string;
63
82
  };
@@ -74,6 +93,14 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
74
93
  true: string;
75
94
  false: string;
76
95
  };
96
+ stackedLeft: {
97
+ true: string;
98
+ false: string;
99
+ };
100
+ stackedRight: {
101
+ true: string;
102
+ false: string;
103
+ };
77
104
  }, undefined, "inline-flex items-center justify-center font-medium text-base whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-selected focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-30 relative overflow-hidden box-border cursor-pointer", unknown, unknown, undefined>>;
78
105
  export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
79
106
  export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
@@ -83,6 +110,8 @@ export type ButtonProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<
83
110
  icon?: IconSource;
84
111
  iconPosition?: 'left' | 'right';
85
112
  iconClass?: string;
113
+ stackedLeft?: boolean;
114
+ stackedRight?: boolean;
86
115
  };
87
116
  declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
88
117
  type Button = ReturnType<typeof Button>;
@@ -1,4 +1,7 @@
1
- /** Dispatch event on click outside of node */
2
- export function clickOutside(node: any): {
1
+ /**
2
+ * Dispatch event on click outside of node
3
+ * @param {HTMLElement} node
4
+ */
5
+ export function clickOutside(node: HTMLElement): {
3
6
  destroy(): void;
4
7
  };
@@ -1,8 +1,14 @@
1
- /** Dispatch event on click outside of node */
1
+ /**
2
+ * Dispatch event on click outside of node
3
+ * @param {HTMLElement} node
4
+ */
2
5
  export function clickOutside(node) {
6
+ /**
7
+ * @param {MouseEvent} event
8
+ */
3
9
  const handleClick = (event) => {
4
- if (node && !node.contains(event.target) && !event.defaultPrevented) {
5
- node.dispatchEvent(new CustomEvent('click_outside', node))
10
+ if (node && !node.contains(/** @type {Node} */ (event.target)) && !event.defaultPrevented) {
11
+ node.dispatchEvent(new CustomEvent('click_outside'))
6
12
  }
7
13
  }
8
14
 
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ import { Icon } from '@steeze-ui/svelte-icon'
3
+ import { TooltipAutoHide, TooltipContent, TooltipTrigger } from '../../tooltip'
4
+ import type { BooleanCellConfig } from '../data-table-types.js'
5
+
6
+ let { value, config }: { value: boolean; config?: BooleanCellConfig } = $props()
7
+
8
+ const showWhenTrue = $derived(config?.showWhenTrue ?? true)
9
+ const showWhenFalse = $derived(config?.showWhenFalse ?? false)
10
+ const shouldShow = $derived(value ? showWhenTrue : showWhenFalse)
11
+ const hint = $derived(value ? config?.hintWhenTrue : config?.hintWhenFalse)
12
+ </script>
13
+
14
+ {#if shouldShow && config?.icon}
15
+ <div class="flex justify-center">
16
+ {#if hint}
17
+ <TooltipAutoHide>
18
+ <TooltipTrigger>
19
+ <Icon src={config.icon} class={config.iconClass ?? 'size-4 text-icon'} />
20
+ </TooltipTrigger>
21
+ <TooltipContent>
22
+ {hint}
23
+ </TooltipContent>
24
+ </TooltipAutoHide>
25
+ {:else}
26
+ <Icon src={config.icon} class={config.iconClass ?? 'size-4 text-icon'} />
27
+ {/if}
28
+ </div>
29
+ {/if}
@@ -0,0 +1,8 @@
1
+ import type { BooleanCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: boolean;
4
+ config?: BooleanCellConfig;
5
+ };
6
+ declare const BooleanCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type BooleanCell = ReturnType<typeof BooleanCell>;
8
+ export default BooleanCell;
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import Skeleton from '../../skeleton/skeleton.svelte'
3
+ import SkeletonAvatar from '../../skeleton/skeleton-avatar.svelte'
4
+ import type { CellSkeletonProps } from '../data-table-types.js'
5
+
6
+ let {
7
+ isBoolean = false,
8
+ loadingConfig = {},
9
+ withPadding = false
10
+ }: CellSkeletonProps = $props()
11
+
12
+ const lines = $derived(loadingConfig.lines ?? 1)
13
+ const showAvatar = $derived(loadingConfig.showAvatar ?? false)
14
+ const avatarSize = $derived(loadingConfig.avatarSize ?? 32)
15
+ </script>
16
+
17
+ {#if isBoolean}
18
+ <div class={withPadding ? 'px-3' : ''}>
19
+ <Skeleton class="size-4" />
20
+ </div>
21
+ {:else}
22
+ <div class="flex items-center gap-3 w-full {withPadding ? 'px-3' : ''}">
23
+ {#if showAvatar}
24
+ <SkeletonAvatar size={avatarSize} />
25
+ {/if}
26
+ <div class="flex flex-col gap-2 flex-1">
27
+ {#each Array(lines) as _, i}
28
+ <Skeleton
29
+ class="h-4 w-full"
30
+ style="max-width: {i === lines - 1 && lines > 1 ? '80%' : '100%'}"
31
+ />
32
+ {/each}
33
+ </div>
34
+ </div>
35
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { CellSkeletonProps } from '../data-table-types.js';
2
+ declare const CellSkeleton: import("svelte").Component<CellSkeletonProps, {}, "">;
3
+ type CellSkeleton = ReturnType<typeof CellSkeleton>;
4
+ export default CellSkeleton;
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import { cn } from '../../utils.js'
3
+ import type { CurrencyCellConfig } from '../data-table-types.js'
4
+
5
+ let { value, config }: { value: any; config?: CurrencyCellConfig } = $props()
6
+ </script>
7
+
8
+ <span class={cn('font-mono text-base text-foreground text-right block', config?.className)}>
9
+ {value}
10
+ </span>
@@ -0,0 +1,8 @@
1
+ import type { CurrencyCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: any;
4
+ config?: CurrencyCellConfig;
5
+ };
6
+ declare const CurrencyCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type CurrencyCell = ReturnType<typeof CurrencyCell>;
8
+ export default CurrencyCell;
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import { cn } from '../../utils.js'
3
+ import type { DateCellConfig } from '../data-table-types.js'
4
+
5
+ let { value, config }: { value: any; config?: DateCellConfig } = $props()
6
+ </script>
7
+
8
+ <span class={cn('font-mono text-base text-foreground', config?.className)}>
9
+ {value}
10
+ </span>
@@ -0,0 +1,8 @@
1
+ import type { DateCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: any;
4
+ config?: DateCellConfig;
5
+ };
6
+ declare const DateCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type DateCell = ReturnType<typeof DateCell>;
8
+ export default DateCell;
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import TagStatus from '../../TagStatus.svelte'
3
+ import type { TagCellConfig } from '../data-table-types.js'
4
+
5
+ let { value, config }: { value: string; config: TagCellConfig } = $props()
6
+
7
+ const option = $derived(config.options.find((opt) => opt.value === value))
8
+ </script>
9
+
10
+ {#if option}
11
+ <TagStatus label={option.label} status={option.color} dot={config.showDot ?? false} />
12
+ {/if}
@@ -0,0 +1,8 @@
1
+ import type { TagCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: string;
4
+ config: TagCellConfig;
5
+ };
6
+ declare const TagCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type TagCell = ReturnType<typeof TagCell>;
8
+ export default TagCell;
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import { cn } from '../../utils.js'
3
+ import type { TextCellConfig } from '../data-table-types.js'
4
+
5
+ let { value, config }: { value: any; config?: TextCellConfig } = $props()
6
+ </script>
7
+
8
+ <div class={cn('truncate', config?.className)}>
9
+ {value}
10
+ </div>
@@ -0,0 +1,8 @@
1
+ import type { TextCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: any;
4
+ config?: TextCellConfig;
5
+ };
6
+ declare const TextCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type TextCell = ReturnType<typeof TextCell>;
8
+ export default TextCell;
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import ButtonUuidCopy from '../../ButtonUuidCopy.svelte'
3
+ import type { UuidCellConfig } from '../data-table-types.js'
4
+
5
+ let { value, config }: { value: string; config?: UuidCellConfig } = $props()
6
+ </script>
7
+
8
+ <div class="relative z-0">
9
+ <ButtonUuidCopy
10
+ uuid={value}
11
+ prefixLength={config?.prefixLength}
12
+ suffixLength={config?.suffixLength}
13
+ full={config?.full}
14
+ disabled={config?.disabled}
15
+ oncopied={config?.onCopy}
16
+ />
17
+ </div>
@@ -0,0 +1,8 @@
1
+ import type { UuidCellConfig } from '../data-table-types.js';
2
+ type $$ComponentProps = {
3
+ value: string;
4
+ config?: UuidCellConfig;
5
+ };
6
+ declare const UuidCell: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type UuidCell = ReturnType<typeof UuidCell>;
8
+ export default UuidCell;
@@ -0,0 +1,12 @@
1
+ import type { ColumnDef, Row } from '@tanstack/table-core';
2
+ import type { Snippet } from 'svelte';
3
+ /**
4
+ * Create the selection column definition for row selection
5
+ */
6
+ export declare function createSelectionColumn<TData>(): ColumnDef<TData>;
7
+ /**
8
+ * Create the actions column definition for row actions
9
+ */
10
+ export declare function createActionsColumn<TData>(rowActionsSnippet: Snippet<[{
11
+ row: Row<TData>;
12
+ }]>): ColumnDef<TData>;
@@ -0,0 +1,42 @@
1
+ import { renderComponent, renderSnippet } from './render-helpers.js';
2
+ import InputCheckbox from '../InputCheckbox.svelte';
3
+ /**
4
+ * Create the selection column definition for row selection
5
+ */
6
+ export function createSelectionColumn() {
7
+ return {
8
+ id: 'select',
9
+ header: ({ table }) => renderComponent(InputCheckbox, {
10
+ checked: table.getIsAllPageRowsSelected(),
11
+ onchange: (value) => table.toggleAllPageRowsSelected(value),
12
+ indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
13
+ 'aria-label': 'Select all',
14
+ onclick: (e) => e.stopPropagation()
15
+ }),
16
+ cell: ({ row }) => renderComponent(InputCheckbox, {
17
+ checked: row.getIsSelected(),
18
+ onchange: (value) => row.toggleSelected(value),
19
+ 'aria-label': 'Select row',
20
+ onclick: (e) => e.stopPropagation()
21
+ }),
22
+ enableSorting: false,
23
+ enableHiding: false,
24
+ enableResizing: false,
25
+ size: 40,
26
+ minSize: 40,
27
+ maxSize: 40
28
+ };
29
+ }
30
+ /**
31
+ * Create the actions column definition for row actions
32
+ */
33
+ export function createActionsColumn(rowActionsSnippet) {
34
+ return {
35
+ id: 'actions',
36
+ cell: ({ row }) => renderSnippet(rowActionsSnippet, { row }),
37
+ enableResizing: false,
38
+ size: 56,
39
+ minSize: 56,
40
+ maxSize: 56
41
+ };
42
+ }
@@ -0,0 +1,6 @@
1
+ import type { ColumnSizingState } from '@tanstack/table-core';
2
+ /**
3
+ * Calculate initial column sizes based on available container width
4
+ * Scales column sizes proportionally if container is wider than default sizes
5
+ */
6
+ export declare function calculateColumnSizing(columns: any[], containerWidth: number): ColumnSizingState | null;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Calculate initial column sizes based on available container width
3
+ * Scales column sizes proportionally if container is wider than default sizes
4
+ */
5
+ export function calculateColumnSizing(columns, containerWidth) {
6
+ // Collect all column sizes
7
+ const defaultSizes = {};
8
+ columns.forEach((col) => {
9
+ if (col.size) {
10
+ defaultSizes[col.id] = col.size;
11
+ }
12
+ });
13
+ const totalDefaultSize = Object.values(defaultSizes).reduce((sum, size) => sum + size, 0);
14
+ // If container is wider than default, scale columns proportionally
15
+ if (containerWidth > totalDefaultSize && totalDefaultSize > 0) {
16
+ const scale = containerWidth / totalDefaultSize;
17
+ const newSizing = {};
18
+ Object.entries(defaultSizes).forEach(([key, value]) => {
19
+ newSizing[key] = Math.floor(value * scale);
20
+ });
21
+ return newSizing;
22
+ }
23
+ return null;
24
+ }
@@ -0,0 +1,3 @@
1
+ import type { ColumnDef } from '@tanstack/table-core';
2
+ import type { DataTableColumn } from './data-table-types.js';
3
+ export declare function createColumns<TData>(columns: DataTableColumn<TData>[]): ColumnDef<TData>[];
@@ -0,0 +1,67 @@
1
+ import { renderComponent } from './render-helpers.js';
2
+ import TextCell from './cells/text-cell.svelte';
3
+ import BooleanCell from './cells/boolean-cell.svelte';
4
+ import TagCell from './cells/tag-cell.svelte';
5
+ import DateCell from './cells/date-cell.svelte';
6
+ import CurrencyCell from './cells/currency-cell.svelte';
7
+ import UuidCell from './cells/uuid-cell.svelte';
8
+ import { renderSnippet } from './render-helpers.js';
9
+ export function createColumns(columns) {
10
+ return columns.map((col) => {
11
+ const tanstackCol = {
12
+ id: col.id,
13
+ accessorKey: col.accessorKey,
14
+ header: col.header,
15
+ enableSorting: col.enableSorting ?? true,
16
+ enableHiding: col.enableHiding ?? true,
17
+ enableResizing: col.enableResizing ?? true,
18
+ size: col.size,
19
+ minSize: col.minSize,
20
+ maxSize: col.maxSize,
21
+ meta: {
22
+ cellType: col.cellType,
23
+ disableColumnFilter: col.disableColumnFilter ?? false,
24
+ loadingConfig: col.loadingConfig
25
+ }
26
+ };
27
+ // Cell renderer
28
+ if (col.cell) {
29
+ // Custom cell renderer - can be a Snippet or a function
30
+ const cellRenderer = col.cell;
31
+ tanstackCol.cell = ({ row }) => {
32
+ const value = col.accessorKey ? row.original[col.accessorKey] : undefined;
33
+ // Check if it's a function or a Snippet
34
+ if (typeof cellRenderer === 'function') {
35
+ return cellRenderer(value, row.original);
36
+ }
37
+ else {
38
+ // It's a Snippet, render it with the row data
39
+ return renderSnippet(cellRenderer, row.original);
40
+ }
41
+ };
42
+ }
43
+ else if (col.cellType) {
44
+ // Built-in cell renderer based on type
45
+ tanstackCol.cell = ({ row }) => {
46
+ const value = col.accessorKey ? row.original[col.accessorKey] : undefined;
47
+ switch (col.cellType) {
48
+ case 'text':
49
+ return renderComponent(TextCell, { value: value, config: col.cellConfig });
50
+ case 'boolean':
51
+ return renderComponent(BooleanCell, { value: value, config: col.cellConfig });
52
+ case 'tag':
53
+ return renderComponent(TagCell, { value: value, config: col.cellConfig });
54
+ case 'date':
55
+ return renderComponent(DateCell, { value: value, config: col.cellConfig });
56
+ case 'currency':
57
+ return renderComponent(CurrencyCell, { value: value, config: col.cellConfig });
58
+ case 'uuid':
59
+ return renderComponent(UuidCell, { value: value, config: col.cellConfig });
60
+ default:
61
+ return value;
62
+ }
63
+ };
64
+ }
65
+ return tanstackCol;
66
+ });
67
+ }
@@ -0,0 +1,94 @@
1
+ <script lang="ts" generics="TData">
2
+ import type { DataTableCellProps } from './data-table-types.js'
3
+ import * as Table from '../table/index.js'
4
+ import FlexRender from './flex-render.svelte'
5
+ import CellSkeleton from './cells/cell-skeleton.svelte'
6
+ import { calculateFrozenOffset } from './data-table-helpers.js'
7
+ import { getCellStyle, getCellClasses } from './table-styles.js'
8
+
9
+ let {
10
+ cell,
11
+ index,
12
+ visibleCells,
13
+ allCells,
14
+ frozenColumns,
15
+ loading = false,
16
+ StickyCellWrapper
17
+ }: DataTableCellProps<TData> = $props()
18
+
19
+ const isLastScrollable = $derived(index === visibleCells.length - 2)
20
+ const firstDataColumnIndex = $derived(
21
+ visibleCells.findIndex((c) => c.column.id !== 'select' && c.column.id !== 'actions')
22
+ )
23
+ const isFirstDataColumn = $derived(index === firstDataColumnIndex)
24
+ const isFirstCell = $derived(index === 0)
25
+ const isLastCell = $derived(index === visibleCells.length - 1)
26
+ const isFrozen = $derived(frozenColumns.has(cell.column.id))
27
+ const lastFrozenColumnId = $derived.by(() =>
28
+ allCells
29
+ .map((c) => c.column)
30
+ .reverse()
31
+ .find((col) => frozenColumns.has(col.id))?.id
32
+ )
33
+ const isLastFrozen = $derived(isFrozen && cell.column.id === lastFrozenColumnId)
34
+ const frozenOffset = $derived.by(() =>
35
+ isFrozen
36
+ ? calculateFrozenOffset(
37
+ cell.column.id,
38
+ allCells.map((c) => c.column),
39
+ frozenColumns
40
+ )
41
+ : 0
42
+ )
43
+ const loadingConfig = $derived(cell.column.columnDef.meta?.loadingConfig || {})
44
+ const cellType = $derived(cell.column.columnDef.meta?.cellType)
45
+ const isBoolean = $derived(cellType === 'boolean')
46
+ </script>
47
+
48
+ <Table.Cell
49
+ style={getCellStyle(cell, isLastScrollable, isFrozen, frozenOffset)}
50
+ class={getCellClasses(
51
+ cell,
52
+ isLastScrollable,
53
+ isFirstDataColumn,
54
+ isFirstCell,
55
+ isLastCell,
56
+ isFrozen
57
+ )}
58
+ >
59
+ {#if cell.column.id === 'actions'}
60
+ {@render StickyCellWrapper({
61
+ align: 'right',
62
+ children: CellContent,
63
+ isFirst: isFirstCell,
64
+ isLast: isLastCell
65
+ })}
66
+ {#snippet CellContent()}
67
+ <div class={loading ? 'opacity-30' : ''}>
68
+ <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
69
+ </div>
70
+ {/snippet}
71
+ {:else if cell.column.id === 'select' || isFrozen}
72
+ {@render StickyCellWrapper({
73
+ align: 'left',
74
+ children: CellContent,
75
+ isFirst: isFirstCell,
76
+ isLast: isLastCell,
77
+ isFrozen: isFrozen,
78
+ isLastFrozen: isLastFrozen
79
+ })}
80
+ {#snippet CellContent()}
81
+ {#if loading && cell.column.id !== 'select'}
82
+ <CellSkeleton {isBoolean} {loadingConfig} />
83
+ {:else}
84
+ <div class={cell.column.id === 'select' && loading ? 'opacity-30' : ''}>
85
+ <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
86
+ </div>
87
+ {/if}
88
+ {/snippet}
89
+ {:else if loading}
90
+ <CellSkeleton {isBoolean} {loadingConfig} withPadding />
91
+ {:else}
92
+ <FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
93
+ {/if}
94
+ </Table.Cell>
@@ -0,0 +1,25 @@
1
+ import type { DataTableCellProps } from './data-table-types.js';
2
+ declare function $$render<TData>(): {
3
+ props: DataTableCellProps<TData>;
4
+ exports: {};
5
+ bindings: "";
6
+ slots: {};
7
+ events: {};
8
+ };
9
+ declare class __sveltets_Render<TData> {
10
+ props(): ReturnType<typeof $$render<TData>>['props'];
11
+ events(): ReturnType<typeof $$render<TData>>['events'];
12
+ slots(): ReturnType<typeof $$render<TData>>['slots'];
13
+ bindings(): "";
14
+ exports(): {};
15
+ }
16
+ interface $$IsomorphicComponent {
17
+ new <TData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData>['props']>, ReturnType<__sveltets_Render<TData>['events']>, ReturnType<__sveltets_Render<TData>['slots']>> & {
18
+ $$bindings?: ReturnType<__sveltets_Render<TData>['bindings']>;
19
+ } & ReturnType<__sveltets_Render<TData>['exports']>;
20
+ <TData>(internal: unknown, props: ReturnType<__sveltets_Render<TData>['props']> & {}): ReturnType<__sveltets_Render<TData>['exports']>;
21
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
22
+ }
23
+ declare const DataTableCell: $$IsomorphicComponent;
24
+ type DataTableCell<TData> = InstanceType<typeof DataTableCell<TData>>;
25
+ export default DataTableCell;