@casinogate/ui 1.11.1 → 1.11.3
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 +4 -1
- package/dist/components/data-table/components/data-table.expand-button.svelte +31 -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/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/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/dist/components/textarea/styles.js +1 -1
- package/package.json +1 -1
package/dist/assets/css/root.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! tailwindcss v4.2.
|
|
1
|
+
/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer properties;
|
|
3
3
|
@layer theme, base, components, utilities;
|
|
4
4
|
@layer theme {
|
|
@@ -652,6 +652,9 @@
|
|
|
652
652
|
.cgui\:basis-1\/2 {
|
|
653
653
|
flex-basis: calc(1 / 2 * 100%);
|
|
654
654
|
}
|
|
655
|
+
.cgui\:table-fixed {
|
|
656
|
+
table-layout: fixed;
|
|
657
|
+
}
|
|
655
658
|
.cgui\:origin-\(--bits-dropdown-menu-content-transform-origin\) {
|
|
656
659
|
transform-origin: var(--bits-dropdown-menu-content-transform-origin);
|
|
657
660
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
|
19
|
+
onclick={onToggle}
|
|
20
|
+
class="cgui:flex cgui:items-center cgui:justify-center cgui:cursor-pointer"
|
|
21
|
+
style="padding-left: {depth}rem"
|
|
22
|
+
>
|
|
23
|
+
{#if isExpanded}
|
|
24
|
+
<Icon.ChevronDown width={16} height={16} />
|
|
25
|
+
{:else}
|
|
26
|
+
<Icon.ChevronRight width={16} height={16} />
|
|
27
|
+
{/if}
|
|
28
|
+
</button>
|
|
29
|
+
{:else}
|
|
30
|
+
<span style="padding-left: {depth}rem; display: inline-block; width: 16px;"></span>
|
|
31
|
+
{/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
|
}));
|
|
@@ -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',
|
|
@@ -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
|
+
};
|
|
@@ -12,7 +12,7 @@ export const textareaVariants = tv({
|
|
|
12
12
|
variant: {
|
|
13
13
|
primary: [
|
|
14
14
|
'cgui:border cgui:border-stroke-default',
|
|
15
|
-
'cgui:bg-surface-lightest cgui:placeholder:text-fg-regular/70 cgui:shadow-none',
|
|
15
|
+
'cgui:bg-surface-lightest cgui:placeholder:text-fg-regular/70 cgui:text-fg-dark cgui:shadow-none',
|
|
16
16
|
'cgui:focus:ring-stroke-default cgui:focus-visible:border-stroke-focus',
|
|
17
17
|
'cgui:aria-invalid:ring-stroke-error cgui:aria-invalid:border-stroke-error',
|
|
18
18
|
],
|