@casinogate/ui 1.11.2 → 1.11.4
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.
- package/dist/assets/css/root.css +6 -0
- package/dist/components/data-table/components/data-table.cell.svelte +7 -1
- package/dist/components/data-table/components/data-table.expand-button.svelte +27 -0
- package/dist/components/data-table/components/data-table.expand-button.svelte.d.ts +9 -0
- package/dist/components/data-table/components/data-table.svelte.d.ts +6 -2
- package/dist/components/data-table/components/data-table.svelte.js +25 -5
- package/dist/components/data-table/data-table.svelte +5 -4
- package/dist/components/data-table/exports-primitive.d.ts +1 -0
- package/dist/components/data-table/exports-primitive.js +1 -0
- package/dist/components/data-table/styles.js +1 -1
- package/dist/components/data-table/types.d.ts +1 -0
- package/dist/components/data-table/utils/expanded-state.svelte.d.ts +10 -0
- package/dist/components/data-table/utils/expanded-state.svelte.js +23 -0
- package/dist/components/data-table/utils/index.d.ts +1 -0
- package/dist/components/data-table/utils/index.js +1 -0
- package/package.json +1 -1
package/dist/assets/css/root.css
CHANGED
|
@@ -463,6 +463,9 @@
|
|
|
463
463
|
.cgui\:h-\[300px\] {
|
|
464
464
|
height: 300px;
|
|
465
465
|
}
|
|
466
|
+
.cgui\:h-\[600px\] {
|
|
467
|
+
height: 600px;
|
|
468
|
+
}
|
|
466
469
|
.cgui\:h-auto {
|
|
467
470
|
height: auto;
|
|
468
471
|
}
|
|
@@ -652,6 +655,9 @@
|
|
|
652
655
|
.cgui\:basis-1\/2 {
|
|
653
656
|
flex-basis: calc(1 / 2 * 100%);
|
|
654
657
|
}
|
|
658
|
+
.cgui\:table-fixed {
|
|
659
|
+
table-layout: fixed;
|
|
660
|
+
}
|
|
655
661
|
.cgui\:origin-\(--bits-dropdown-menu-content-transform-origin\) {
|
|
656
662
|
transform-origin: var(--bits-dropdown-menu-content-transform-origin);
|
|
657
663
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
children,
|
|
14
14
|
class: className,
|
|
15
15
|
cell,
|
|
16
|
+
depth = 0,
|
|
16
17
|
...restProps
|
|
17
18
|
}: DataTableCellProps = $props();
|
|
18
19
|
|
|
@@ -30,6 +31,11 @@
|
|
|
30
31
|
const mergedProps = $derived(mergeProps(restProps, cellState.props));
|
|
31
32
|
</script>
|
|
32
33
|
|
|
33
|
-
<td
|
|
34
|
+
<td
|
|
35
|
+
style:--depth={depth}
|
|
36
|
+
style:padding-left={depth > 0 ? `calc((var(--cgui-spacing)*2) + ${depth} * 1rem)` : undefined}
|
|
37
|
+
class={cn(styles.current.cell(), className)}
|
|
38
|
+
{...mergedProps}
|
|
39
|
+
>
|
|
34
40
|
{@render children?.()}
|
|
35
41
|
</td>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '../../icons/index.js';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
canExpand,
|
|
6
|
+
isExpanded,
|
|
7
|
+
depth = 0,
|
|
8
|
+
onToggle,
|
|
9
|
+
}: {
|
|
10
|
+
canExpand: boolean;
|
|
11
|
+
isExpanded: boolean;
|
|
12
|
+
depth?: number;
|
|
13
|
+
onToggle: () => void;
|
|
14
|
+
} = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
{#if canExpand}
|
|
18
|
+
<button onclick={onToggle} class="cgui:flex cgui:items-center cgui:justify-center cgui:cursor-pointer">
|
|
19
|
+
{#if isExpanded}
|
|
20
|
+
<Icon.ChevronDown width={16} height={16} />
|
|
21
|
+
{:else}
|
|
22
|
+
<Icon.ChevronRight width={16} height={16} />
|
|
23
|
+
{/if}
|
|
24
|
+
</button>
|
|
25
|
+
{:else}
|
|
26
|
+
<span style="padding-left: {depth}rem; display: inline-block; width: 16px;"></span>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
canExpand: boolean;
|
|
3
|
+
isExpanded: boolean;
|
|
4
|
+
depth?: number;
|
|
5
|
+
onToggle: () => void;
|
|
6
|
+
};
|
|
7
|
+
declare const DataTable: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type DataTable = ReturnType<typeof DataTable>;
|
|
9
|
+
export default DataTable;
|
|
@@ -85,7 +85,9 @@ export declare class DataTableHeadState {
|
|
|
85
85
|
readonly "data-slot": "head";
|
|
86
86
|
readonly 'data-id': string;
|
|
87
87
|
readonly style: {
|
|
88
|
-
readonly width: "
|
|
88
|
+
readonly width: "undefinedpx" | `${number}px`;
|
|
89
|
+
readonly 'min-width': string | undefined;
|
|
90
|
+
readonly 'max-width': string | undefined;
|
|
89
91
|
};
|
|
90
92
|
readonly colspan: number;
|
|
91
93
|
};
|
|
@@ -104,7 +106,9 @@ export declare class DataTableCellState {
|
|
|
104
106
|
readonly id: string;
|
|
105
107
|
readonly "data-slot": "cell";
|
|
106
108
|
readonly style: {
|
|
107
|
-
readonly width: "
|
|
109
|
+
readonly width: "undefinedpx" | `${number}px`;
|
|
110
|
+
readonly 'min-width': string | undefined;
|
|
111
|
+
readonly 'max-width': string | undefined;
|
|
108
112
|
};
|
|
109
113
|
};
|
|
110
114
|
}
|
|
@@ -117,8 +117,8 @@ export class DataTableBodyState {
|
|
|
117
117
|
this.rootState = root;
|
|
118
118
|
this.attachment = attachRef(opts.ref);
|
|
119
119
|
const { stop } = useMutationObserver(() => opts.ref.current, (mutations) => {
|
|
120
|
-
const target = mutations[mutations.length - 1]
|
|
121
|
-
this.#lastRow = target
|
|
120
|
+
const target = mutations[mutations.length - 1]?.target;
|
|
121
|
+
this.#lastRow = target?.lastElementChild;
|
|
122
122
|
}, { childList: true, subtree: true });
|
|
123
123
|
let observer = null;
|
|
124
124
|
watch.pre(() => this.#lastRow, () => {
|
|
@@ -138,7 +138,7 @@ export class DataTableBodyState {
|
|
|
138
138
|
#rowObserver = () => {
|
|
139
139
|
const observer = new IntersectionObserver((entries) => {
|
|
140
140
|
const entry = entries[0];
|
|
141
|
-
if (entry
|
|
141
|
+
if (entry?.isIntersecting) {
|
|
142
142
|
this.rootState.opts.table.current?.features?.onLastRowReached?.();
|
|
143
143
|
if (this.#lastRow) {
|
|
144
144
|
observer.unobserve(this.#lastRow);
|
|
@@ -173,12 +173,22 @@ export class DataTableHeadState {
|
|
|
173
173
|
this.attachment = attachRef(opts.ref);
|
|
174
174
|
}
|
|
175
175
|
#width = $derived.by(() => this.rootState.columnSizingVars[`--header-${this.opts.header.current.id}-size`]);
|
|
176
|
+
#minSize = $derived.by(() => {
|
|
177
|
+
const min = this.opts.header.current.column.columnDef.minSize;
|
|
178
|
+
return min !== undefined ? `${min}px` : undefined;
|
|
179
|
+
});
|
|
180
|
+
#maxSize = $derived.by(() => {
|
|
181
|
+
const max = this.opts.header.current.column.columnDef.maxSize;
|
|
182
|
+
return max !== undefined && max !== Number.MAX_SAFE_INTEGER ? `${max}px` : undefined;
|
|
183
|
+
});
|
|
176
184
|
props = $derived.by(() => ({
|
|
177
185
|
id: this.opts.id.current,
|
|
178
186
|
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.head,
|
|
179
187
|
'data-id': this.opts.header.current.id,
|
|
180
188
|
style: {
|
|
181
|
-
width:
|
|
189
|
+
width: `${this.#width}px`,
|
|
190
|
+
'min-width': this.#minSize,
|
|
191
|
+
'max-width': this.#maxSize,
|
|
182
192
|
},
|
|
183
193
|
colspan: this.opts.header.current.colSpan,
|
|
184
194
|
...this.attachment,
|
|
@@ -197,11 +207,21 @@ export class DataTableCellState {
|
|
|
197
207
|
this.attachment = attachRef(opts.ref);
|
|
198
208
|
}
|
|
199
209
|
#width = $derived.by(() => this.rootState.columnSizingVars[`--col-${this.opts.cell.current?.column.id}-size`]);
|
|
210
|
+
#minSize = $derived.by(() => {
|
|
211
|
+
const min = this.opts.cell.current?.column.columnDef.minSize;
|
|
212
|
+
return min !== undefined ? `${min}px` : undefined;
|
|
213
|
+
});
|
|
214
|
+
#maxSize = $derived.by(() => {
|
|
215
|
+
const max = this.opts.cell.current?.column.columnDef.maxSize;
|
|
216
|
+
return max !== undefined && max !== Number.MAX_SAFE_INTEGER ? `${max}px` : undefined;
|
|
217
|
+
});
|
|
200
218
|
props = $derived.by(() => ({
|
|
201
219
|
id: this.opts.id.current,
|
|
202
220
|
[SLOT_ATTR_NAME]: SLOT_ATTR_VALUES.cell,
|
|
203
221
|
style: {
|
|
204
|
-
width:
|
|
222
|
+
width: `${this.#width}px`,
|
|
223
|
+
'min-width': this.#minSize,
|
|
224
|
+
'max-width': this.#maxSize,
|
|
205
225
|
},
|
|
206
226
|
...this.attachment,
|
|
207
227
|
}));
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import FlexRender from './components/flex-render.svelte';
|
|
16
16
|
import { type DataTableProps, type RowData } from './types.js';
|
|
17
17
|
|
|
18
|
-
let { ref = $bindable(null), table, empty, ...restProps }: DataTableProps<TData> = $props();
|
|
18
|
+
let { ref = $bindable(null), table, empty, class: className, ...restProps }: DataTableProps<TData> = $props();
|
|
19
19
|
|
|
20
20
|
let isFirstLoaded = $state(false);
|
|
21
21
|
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
);
|
|
38
38
|
</script>
|
|
39
39
|
|
|
40
|
-
<DataTableRoot bind:ref {table} {...restProps}>
|
|
41
|
-
<DataTableTable>
|
|
40
|
+
<DataTableRoot bind:ref {table} class={cn(className, { 'cgui:h-full': isEmpty })} {...restProps}>
|
|
41
|
+
<DataTableTable class={cn({ 'cgui:h-full': isEmpty })}>
|
|
42
42
|
<DataTableHeader>
|
|
43
43
|
{#each table.getHeaderGroups() as headerGroup (headerGroup.id)}
|
|
44
44
|
<DataTableRow>
|
|
@@ -96,7 +96,8 @@
|
|
|
96
96
|
{/if}
|
|
97
97
|
<DataTableRow>
|
|
98
98
|
{#each row.getVisibleCells() as cell (cell.id)}
|
|
99
|
-
|
|
99
|
+
{console.log(row.depth)}
|
|
100
|
+
<DataTableCell {cell} depth={row.depth}>
|
|
100
101
|
<FlexRender content={cell.column.columnDef.cell} context={cell.getContext()} />
|
|
101
102
|
</DataTableCell>
|
|
102
103
|
{/each}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Body } from './components/data-table.body.svelte';
|
|
2
2
|
export { default as Cell } from './components/data-table.cell.svelte';
|
|
3
|
+
export { default as ExpandButton } from './components/data-table.expand-button.svelte';
|
|
3
4
|
export { default as Head } from './components/data-table.head.svelte';
|
|
4
5
|
export { default as Header } from './components/data-table.header.svelte';
|
|
5
6
|
export { default as ResizeHandler } from './components/data-table.resize-handler.svelte';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Body } from './components/data-table.body.svelte';
|
|
2
2
|
export { default as Cell } from './components/data-table.cell.svelte';
|
|
3
|
+
export { default as ExpandButton } from './components/data-table.expand-button.svelte';
|
|
3
4
|
export { default as Head } from './components/data-table.head.svelte';
|
|
4
5
|
export { default as Header } from './components/data-table.header.svelte';
|
|
5
6
|
export { default as ResizeHandler } from './components/data-table.resize-handler.svelte';
|
|
@@ -9,7 +9,7 @@ export const dataTableVariants = tv({
|
|
|
9
9
|
'cgui:border cgui:border-stroke-divider',
|
|
10
10
|
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
11
11
|
],
|
|
12
|
-
table: ['cgui:w-full'],
|
|
12
|
+
table: ['cgui:w-full', 'cgui:table-fixed'],
|
|
13
13
|
header: ['cgui:font-medium cgui:text-body-2 cgui:text-fg-darkest cgui:sticky cgui:z-1 cgui:top-0'],
|
|
14
14
|
body: [
|
|
15
15
|
'cgui:relative',
|
|
@@ -14,6 +14,7 @@ type DataTableBodyPropsWithoutHTML = WithElementRef<WithChildren<{}>>;
|
|
|
14
14
|
export type DataTableBodyProps = DataTableBodyPropsWithoutHTML & Without<PrimitiveDivAttributes, DataTableBodyPropsWithoutHTML>;
|
|
15
15
|
type DataTableCellPropsWithoutHTML = WithElementRef<WithChildren<{
|
|
16
16
|
cell: Cell<any, unknown> | null;
|
|
17
|
+
depth?: number;
|
|
17
18
|
}>>;
|
|
18
19
|
export type DataTableCellProps = DataTableCellPropsWithoutHTML & Without<PrimitiveTdAttributes, DataTableCellPropsWithoutHTML>;
|
|
19
20
|
type DataTableHeadPropsWithoutHTML = WithElementRef<WithChildren<{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExpandedState as ExpandedStateValue, Updater } from '@tanstack/table-core';
|
|
2
|
+
type ExpandedStateOpts = {
|
|
3
|
+
defaultValue?: ExpandedStateValue;
|
|
4
|
+
onValueChange?: (value: ExpandedStateValue) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const useExpandedState: (opts?: ExpandedStateOpts) => {
|
|
7
|
+
value: ExpandedStateValue;
|
|
8
|
+
updater: (updater: Updater<ExpandedStateValue>) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const useExpandedState = (opts) => {
|
|
2
|
+
let value = $state(opts?.defaultValue ?? {});
|
|
3
|
+
return {
|
|
4
|
+
get value() {
|
|
5
|
+
return value;
|
|
6
|
+
},
|
|
7
|
+
set value(v) {
|
|
8
|
+
value = v;
|
|
9
|
+
opts?.onValueChange?.(v);
|
|
10
|
+
},
|
|
11
|
+
updater: (updater) => {
|
|
12
|
+
let newExpandedState;
|
|
13
|
+
if (updater instanceof Function) {
|
|
14
|
+
newExpandedState = updater(value);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
newExpandedState = updater;
|
|
18
|
+
}
|
|
19
|
+
value = newExpandedState;
|
|
20
|
+
opts?.onValueChange?.(newExpandedState);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|