compote-ui 0.52.6 → 0.55.0
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/components/combobox/combobox.svelte +12 -3
- package/dist/components/data-table-v8/create-table.svelte.js +3 -1
- package/dist/components/data-table-v8/data-table-foot.svelte +96 -0
- package/dist/components/data-table-v8/data-table-foot.svelte.d.ts +33 -0
- package/dist/components/data-table-v8/data-table-utils.d.ts +1 -0
- package/dist/components/data-table-v8/data-table-utils.js +25 -0
- package/dist/components/data-table-v8/data-table.svelte +16 -0
- package/dist/components/data-table-v8/types.d.ts +4 -0
- package/dist/components/data-table-v8/virtual/data-table-virtualized.svelte +23 -0
- package/dist/components/date-input/date-input.svelte +15 -49
- package/dist/components/date-input/types.d.ts +2 -3
- package/dist/components/select/select.svelte +12 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" generics="T extends ListItem">
|
|
2
2
|
import { Combobox } from '@ark-ui/svelte/combobox';
|
|
3
|
-
import { Field } from '@ark-ui/svelte/field';
|
|
3
|
+
import { Field, useFieldContext } from '@ark-ui/svelte/field';
|
|
4
4
|
import { useFilter } from '@ark-ui/svelte/locale';
|
|
5
5
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
6
6
|
import { createVirtualizer } from '@tanstack/svelte-virtual';
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
placeholder,
|
|
18
18
|
layout = 'vertical',
|
|
19
19
|
name,
|
|
20
|
+
invalid,
|
|
20
21
|
readOnly,
|
|
22
|
+
disabled,
|
|
21
23
|
multiple,
|
|
22
24
|
loading = false,
|
|
23
25
|
virtualized = false,
|
|
@@ -26,6 +28,11 @@
|
|
|
26
28
|
...restProps
|
|
27
29
|
}: ComboboxProps<T> = $props();
|
|
28
30
|
|
|
31
|
+
const field = useFieldContext();
|
|
32
|
+
const isInvalid = $derived(invalid ?? field?.()?.invalid ?? false);
|
|
33
|
+
const isReadOnly = $derived(readOnly ?? field?.()?.readOnly ?? false);
|
|
34
|
+
const isDisabled = $derived(disabled ?? field?.()?.disabled ?? false);
|
|
35
|
+
|
|
29
36
|
let filterText = $state('');
|
|
30
37
|
|
|
31
38
|
const filters = useFilter({ sensitivity: 'base' });
|
|
@@ -112,7 +119,9 @@
|
|
|
112
119
|
: undefined}
|
|
113
120
|
openOnClick
|
|
114
121
|
{multiple}
|
|
115
|
-
{
|
|
122
|
+
invalid={isInvalid}
|
|
123
|
+
readOnly={isReadOnly}
|
|
124
|
+
disabled={isDisabled}
|
|
116
125
|
{...restProps}
|
|
117
126
|
class={cn(
|
|
118
127
|
layout === 'horizontal' ? 'flex items-center gap-1.5' : 'grid gap-1.5',
|
|
@@ -151,7 +160,7 @@
|
|
|
151
160
|
placeholder={placeholder ?? 'Search...'}
|
|
152
161
|
class="min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-ink-dim disabled:cursor-not-allowed disabled:opacity-50"
|
|
153
162
|
/>
|
|
154
|
-
{#if !
|
|
163
|
+
{#if !isReadOnly}
|
|
155
164
|
<Combobox.ClearTrigger class="text-ink-dim transition-colors hover:text-ink">
|
|
156
165
|
<PhX class="size-4" />
|
|
157
166
|
</Combobox.ClearTrigger>
|
|
@@ -110,7 +110,9 @@ function createColumns(columns, localeCtx) {
|
|
|
110
110
|
type: column.type,
|
|
111
111
|
formatOptions: column.formatOptions,
|
|
112
112
|
formatLocale: column.formatLocale,
|
|
113
|
-
grow: column.grow
|
|
113
|
+
grow: column.grow,
|
|
114
|
+
sum: column.sum,
|
|
115
|
+
footer: column.footer
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
118
|
if (typeof column.accessorFn === 'function') {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends RowData">
|
|
2
|
+
import type { Column, Row, RowData } from '@tanstack/table-core';
|
|
3
|
+
import { useLocaleContext } from '@ark-ui/svelte/locale';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { DataTableInstance } from './data-table-utils';
|
|
6
|
+
import {
|
|
7
|
+
alignClass,
|
|
8
|
+
formatColumnFooter,
|
|
9
|
+
getColumnMeta,
|
|
10
|
+
getPinningStyle,
|
|
11
|
+
justifyClass,
|
|
12
|
+
joinStyles,
|
|
13
|
+
virtualColumnSizeStyle,
|
|
14
|
+
virtualGrowColumnSizeStyle,
|
|
15
|
+
virtualSelectionColumnSizeStyle
|
|
16
|
+
} from './data-table-utils';
|
|
17
|
+
|
|
18
|
+
type Props = {
|
|
19
|
+
table: DataTableInstance<T>;
|
|
20
|
+
visibleLeafColumns: Column<T, unknown>[];
|
|
21
|
+
rows: Row<T>[];
|
|
22
|
+
isRowSelectionEnabled: boolean;
|
|
23
|
+
hasGrowColumn: boolean;
|
|
24
|
+
isVirtual?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
table,
|
|
29
|
+
visibleLeafColumns,
|
|
30
|
+
rows,
|
|
31
|
+
isRowSelectionEnabled,
|
|
32
|
+
hasGrowColumn,
|
|
33
|
+
isVirtual = false
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const localeCtx = useLocaleContext();
|
|
37
|
+
const locale = $derived(localeCtx().locale);
|
|
38
|
+
|
|
39
|
+
function footCellStyle(column: Column<T, unknown>) {
|
|
40
|
+
const meta = getColumnMeta(column.columnDef);
|
|
41
|
+
if (!isVirtual) return getPinningStyle(column, table, true, isRowSelectionEnabled);
|
|
42
|
+
return joinStyles(
|
|
43
|
+
meta?.grow ? virtualGrowColumnSizeStyle() : virtualColumnSizeStyle(column.getSize()),
|
|
44
|
+
getPinningStyle(column, table, true, isRowSelectionEnabled)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function selectionCellStyle() {
|
|
49
|
+
return isVirtual
|
|
50
|
+
? joinStyles(
|
|
51
|
+
virtualSelectionColumnSizeStyle(),
|
|
52
|
+
'min-width: 40px',
|
|
53
|
+
'max-width: 40px',
|
|
54
|
+
'position: sticky',
|
|
55
|
+
'left: 0',
|
|
56
|
+
'z-index: 15'
|
|
57
|
+
)
|
|
58
|
+
: 'width: 40px; min-width: 40px; max-width: 40px; position: sticky; left: 0; z-index: 15';
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<tfoot
|
|
63
|
+
class="sticky bottom-0 z-20 bg-surface-2 text-ink-dim"
|
|
64
|
+
style={isVirtual ? 'display: grid; position: sticky; bottom: 0; z-index: 20' : undefined}
|
|
65
|
+
>
|
|
66
|
+
<tr class="h-9" style={isVirtual ? 'display: flex; width: 100%' : undefined}>
|
|
67
|
+
{#if isRowSelectionEnabled}
|
|
68
|
+
<td
|
|
69
|
+
class={cn(
|
|
70
|
+
'h-9 border-t border-surface-3 bg-surface-2 px-3 py-0',
|
|
71
|
+
isVirtual && 'flex items-center'
|
|
72
|
+
)}
|
|
73
|
+
style={selectionCellStyle()}
|
|
74
|
+
></td>
|
|
75
|
+
{/if}
|
|
76
|
+
{#each visibleLeafColumns as column (column.id)}
|
|
77
|
+
{@const meta = getColumnMeta(column.columnDef)}
|
|
78
|
+
{@const values = rows.map((row) => row.getValue(column.id))}
|
|
79
|
+
{@const footerText = formatColumnFooter(meta ?? {}, values, locale)}
|
|
80
|
+
<td
|
|
81
|
+
class={cn(
|
|
82
|
+
'h-9 truncate border-t border-surface-3 bg-surface-2 px-3 py-0 align-middle text-sm font-medium',
|
|
83
|
+
alignClass(meta?.align),
|
|
84
|
+
isVirtual && 'flex items-center',
|
|
85
|
+
isVirtual && justifyClass(meta?.align)
|
|
86
|
+
)}
|
|
87
|
+
style={footCellStyle(column)}
|
|
88
|
+
>
|
|
89
|
+
{footerText ?? ''}
|
|
90
|
+
</td>
|
|
91
|
+
{/each}
|
|
92
|
+
{#if !isVirtual && !hasGrowColumn}
|
|
93
|
+
<td aria-hidden="true" class="h-9 border-t border-surface-3 bg-surface-2 p-0"></td>
|
|
94
|
+
{/if}
|
|
95
|
+
</tr>
|
|
96
|
+
</tfoot>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Column, Row, RowData } from '@tanstack/table-core';
|
|
2
|
+
import type { DataTableInstance } from './data-table-utils';
|
|
3
|
+
declare function $$render<T extends RowData>(): {
|
|
4
|
+
props: {
|
|
5
|
+
table: DataTableInstance<T>;
|
|
6
|
+
visibleLeafColumns: Column<T, unknown>[];
|
|
7
|
+
rows: Row<T>[];
|
|
8
|
+
isRowSelectionEnabled: boolean;
|
|
9
|
+
hasGrowColumn: boolean;
|
|
10
|
+
isVirtual?: boolean;
|
|
11
|
+
};
|
|
12
|
+
exports: {};
|
|
13
|
+
bindings: "";
|
|
14
|
+
slots: {};
|
|
15
|
+
events: {};
|
|
16
|
+
};
|
|
17
|
+
declare class __sveltets_Render<T extends RowData> {
|
|
18
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
19
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
20
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
21
|
+
bindings(): "";
|
|
22
|
+
exports(): {};
|
|
23
|
+
}
|
|
24
|
+
interface $$IsomorphicComponent {
|
|
25
|
+
new <T extends RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
26
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
27
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
28
|
+
<T extends RowData>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
29
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
30
|
+
}
|
|
31
|
+
declare const DataTableFoot: $$IsomorphicComponent;
|
|
32
|
+
type DataTableFoot<T extends RowData> = InstanceType<typeof DataTableFoot<T>>;
|
|
33
|
+
export default DataTableFoot;
|
|
@@ -29,3 +29,4 @@ export declare function getColumnMeta(columnDef: {
|
|
|
29
29
|
meta?: unknown;
|
|
30
30
|
}): DataTableColumnMeta | undefined;
|
|
31
31
|
export declare function joinStyles(...styles: Array<string | undefined>): string;
|
|
32
|
+
export declare function formatColumnFooter(meta: DataTableColumnMeta, values: unknown[], locale: string): string | undefined;
|
|
@@ -133,3 +133,28 @@ export function getColumnMeta(columnDef) {
|
|
|
133
133
|
export function joinStyles(...styles) {
|
|
134
134
|
return styles.filter(Boolean).join('; ');
|
|
135
135
|
}
|
|
136
|
+
const FOOTER_SUM_FORMAT_DEFAULTS = {
|
|
137
|
+
currency: { style: 'currency', currency: 'USD' },
|
|
138
|
+
percent: { style: 'percent' },
|
|
139
|
+
number: {}
|
|
140
|
+
};
|
|
141
|
+
export function formatColumnFooter(meta, values, locale) {
|
|
142
|
+
if (meta.footer) {
|
|
143
|
+
const result = meta.footer(values);
|
|
144
|
+
if (result === null || result === undefined)
|
|
145
|
+
return undefined;
|
|
146
|
+
return String(result);
|
|
147
|
+
}
|
|
148
|
+
if (meta.sum) {
|
|
149
|
+
const sum = values.reduce((acc, val) => acc + (typeof val === 'number' ? val : Number(val) || 0), 0);
|
|
150
|
+
const numDefaults = meta.type ? FOOTER_SUM_FORMAT_DEFAULTS[meta.type] : undefined;
|
|
151
|
+
if (numDefaults !== undefined) {
|
|
152
|
+
return new Intl.NumberFormat(meta.formatLocale ?? locale, {
|
|
153
|
+
...numDefaults,
|
|
154
|
+
...meta.formatOptions
|
|
155
|
+
}).format(sum);
|
|
156
|
+
}
|
|
157
|
+
return String(sum);
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { PhArrowSquareOut, PhCheck, PhX } from '../../icons';
|
|
6
6
|
import type { DataTableInstance } from './data-table-utils';
|
|
7
7
|
import DataTableHead from './data-table-head.svelte';
|
|
8
|
+
import DataTableFoot from './data-table-foot.svelte';
|
|
8
9
|
import FlexRender from './flex-render.svelte';
|
|
9
10
|
import {
|
|
10
11
|
alignClass,
|
|
@@ -105,6 +106,12 @@
|
|
|
105
106
|
return getSelectedRowCount(table);
|
|
106
107
|
});
|
|
107
108
|
const isColumnResizing = $derived(tableState.columnSizingInfo.isResizingColumn !== false);
|
|
109
|
+
const hasFooter = $derived(
|
|
110
|
+
visibleLeafColumns.some((col) => {
|
|
111
|
+
const meta = getColumnMeta(col.columnDef);
|
|
112
|
+
return !!(meta?.sum || meta?.footer);
|
|
113
|
+
})
|
|
114
|
+
);
|
|
108
115
|
</script>
|
|
109
116
|
|
|
110
117
|
<div
|
|
@@ -244,6 +251,15 @@
|
|
|
244
251
|
</tr>
|
|
245
252
|
{/each}
|
|
246
253
|
</tbody>
|
|
254
|
+
{#if hasFooter}
|
|
255
|
+
<DataTableFoot
|
|
256
|
+
{table}
|
|
257
|
+
{visibleLeafColumns}
|
|
258
|
+
rows={rowModel.rows}
|
|
259
|
+
{isRowSelectionEnabled}
|
|
260
|
+
{hasGrowColumn}
|
|
261
|
+
/>
|
|
262
|
+
{/if}
|
|
247
263
|
</table>
|
|
248
264
|
</div>
|
|
249
265
|
|
|
@@ -33,6 +33,8 @@ export type DataTableLeafColumnBase<T extends RowData> = DataTableColumnOptions<
|
|
|
33
33
|
formatLocale?: string;
|
|
34
34
|
pinned?: 'left' | 'right';
|
|
35
35
|
grow?: boolean;
|
|
36
|
+
sum?: boolean;
|
|
37
|
+
footer?: (values: unknown[]) => string | number | undefined;
|
|
36
38
|
columns?: never;
|
|
37
39
|
};
|
|
38
40
|
export type DataTableAccessorKeyColumn<T extends RowData> = DataTableLeafColumnBase<T> & {
|
|
@@ -66,4 +68,6 @@ export type DataTableColumnMeta = {
|
|
|
66
68
|
formatOptions?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
|
|
67
69
|
formatLocale?: string;
|
|
68
70
|
grow?: boolean;
|
|
71
|
+
sum?: boolean;
|
|
72
|
+
footer?: (values: unknown[]) => string | number | undefined;
|
|
69
73
|
};
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
import { cn, type ClassValue } from 'tailwind-variants';
|
|
5
5
|
import type { DataTableInstance } from '../data-table-utils';
|
|
6
6
|
import DataTableHead from '../data-table-head.svelte';
|
|
7
|
+
import DataTableFoot from '../data-table-foot.svelte';
|
|
7
8
|
import DataTableVirtualRows from './data-table-virtual-rows.svelte';
|
|
8
9
|
import {
|
|
9
10
|
getAllRowsSelectionState,
|
|
11
|
+
getColumnMeta,
|
|
10
12
|
getReactiveTableState,
|
|
11
13
|
getSelectedRowCount,
|
|
12
14
|
tableSizeStyle
|
|
@@ -69,6 +71,17 @@
|
|
|
69
71
|
return getSelectedRowCount(table);
|
|
70
72
|
});
|
|
71
73
|
const isColumnResizing = $derived(tableState.columnSizingInfo.isResizingColumn !== false);
|
|
74
|
+
const visibleLeafColumns = $derived.by(() => {
|
|
75
|
+
const { columnVisibility } = getReactiveTableState(table);
|
|
76
|
+
void columnVisibility;
|
|
77
|
+
return table.getVisibleLeafColumns();
|
|
78
|
+
});
|
|
79
|
+
const hasFooter = $derived(
|
|
80
|
+
visibleLeafColumns.some((col) => {
|
|
81
|
+
const meta = getColumnMeta(col.columnDef);
|
|
82
|
+
return !!(meta?.sum || meta?.footer);
|
|
83
|
+
})
|
|
84
|
+
);
|
|
72
85
|
</script>
|
|
73
86
|
|
|
74
87
|
<div
|
|
@@ -110,6 +123,16 @@
|
|
|
110
123
|
{onRowDoubleClick}
|
|
111
124
|
/>
|
|
112
125
|
{/if}
|
|
126
|
+
{#if hasFooter}
|
|
127
|
+
<DataTableFoot
|
|
128
|
+
{table}
|
|
129
|
+
{visibleLeafColumns}
|
|
130
|
+
rows={rowModel.rows}
|
|
131
|
+
{isRowSelectionEnabled}
|
|
132
|
+
hasGrowColumn={false}
|
|
133
|
+
isVirtual
|
|
134
|
+
/>
|
|
135
|
+
{/if}
|
|
113
136
|
</table>
|
|
114
137
|
</div>
|
|
115
138
|
|
|
@@ -1,75 +1,41 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { DateInput } from '@ark-ui/svelte/date-input';
|
|
3
|
-
import { Field } from '@ark-ui/svelte/field';
|
|
4
|
-
import {
|
|
5
|
-
fromDateToLocal,
|
|
6
|
-
getLocalTimeZone,
|
|
7
|
-
parseAbsolute,
|
|
8
|
-
parseDate,
|
|
9
|
-
parseDateTime,
|
|
10
|
-
parseZonedDateTime
|
|
11
|
-
} from '@internationalized/date';
|
|
12
|
-
import type { DateValue, DateInputProps, NativeDateInput } from './types';
|
|
3
|
+
import { Field, useFieldContext } from '@ark-ui/svelte/field';
|
|
4
|
+
import type { DateInputProps } from './types';
|
|
13
5
|
|
|
14
6
|
let {
|
|
15
7
|
value = $bindable(),
|
|
16
8
|
defaultValue,
|
|
17
9
|
label,
|
|
18
10
|
name,
|
|
19
|
-
timeZone = getLocalTimeZone(),
|
|
20
|
-
hideTimeZone,
|
|
21
11
|
onValueChange,
|
|
12
|
+
invalid,
|
|
13
|
+
readOnly,
|
|
14
|
+
disabled,
|
|
22
15
|
...restProps
|
|
23
16
|
}: DateInputProps = $props();
|
|
24
17
|
|
|
25
|
-
const
|
|
18
|
+
const field = useFieldContext();
|
|
19
|
+
const isInvalid = $derived(invalid ?? field?.()?.invalid ?? false);
|
|
20
|
+
const isReadOnly = $derived(readOnly ?? field?.()?.readOnly ?? false);
|
|
21
|
+
const isDisabled = $derived(disabled ?? field?.()?.disabled ?? false);
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function toDateValue(v: NativeDateInput): DateValue | null {
|
|
32
|
-
if (v == null) return null;
|
|
33
|
-
if (typeof v === 'string') {
|
|
34
|
-
if (!v) return null;
|
|
35
|
-
if (v.includes('T')) {
|
|
36
|
-
// ZonedDateTime.toString() format: "2024-01-15T10:30:00+02:00[Europe/Belgrade]"
|
|
37
|
-
if (v.includes('[')) return parseZonedDateTime(v);
|
|
38
|
-
if (absoluteDateTimeRe.test(v)) return parseAbsolute(v, timeZone);
|
|
39
|
-
return parseDateTime(v);
|
|
40
|
-
}
|
|
41
|
-
return parseDate(v);
|
|
42
|
-
}
|
|
43
|
-
if (v instanceof Date) return fromDateToLocal(v);
|
|
44
|
-
return v;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function fromDateValue(dv: DateValue | null, source: NativeDateInput): NativeDateInput {
|
|
48
|
-
if (dv == null) return null;
|
|
49
|
-
if (typeof source === 'string') {
|
|
50
|
-
if (absoluteDateTimeRe.test(source)) return dv.toDate(timeZone).toISOString();
|
|
51
|
-
return dv.toString();
|
|
52
|
-
}
|
|
53
|
-
if (source instanceof Date) return dv.toDate(getLocalTimeZone());
|
|
54
|
-
return dv;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const arkValue = $derived(toDateValue(value));
|
|
58
|
-
const arkDefault = $derived(toDateValue(defaultValue));
|
|
59
|
-
const shouldHideTimeZone = $derived(hideTimeZone ?? isAbsoluteDateTime(value));
|
|
23
|
+
const arkValue = $derived(value ?? null);
|
|
24
|
+
const arkDefault = $derived(defaultValue ?? null);
|
|
60
25
|
</script>
|
|
61
26
|
|
|
62
27
|
<DateInput.Root
|
|
63
28
|
{...restProps}
|
|
64
|
-
{
|
|
65
|
-
|
|
29
|
+
invalid={isInvalid}
|
|
30
|
+
readOnly={isReadOnly}
|
|
31
|
+
disabled={isDisabled}
|
|
66
32
|
value={arkValue ? [arkValue] : []}
|
|
67
33
|
defaultValue={arkDefault ? [arkDefault] : undefined}
|
|
68
34
|
onValueChange={(details) => {
|
|
69
35
|
const dv = details.value[0] ?? null;
|
|
70
36
|
// Guard: skip if Ark UI echoes back the same date (prevents reactive loop)
|
|
71
37
|
if (dv?.toString() === arkValue?.toString()) return;
|
|
72
|
-
value =
|
|
38
|
+
value = dv;
|
|
73
39
|
onValueChange?.(details);
|
|
74
40
|
}}
|
|
75
41
|
>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { DateInputRootBaseProps } from '@ark-ui/svelte/date-input';
|
|
2
2
|
import type { DateInputDateValue as DateValue } from '@ark-ui/svelte/date-input';
|
|
3
3
|
export type { DateValue };
|
|
4
|
-
export type NativeDateInput = DateValue | string | Date | null | undefined;
|
|
5
4
|
export interface DateInputProps extends Omit<DateInputRootBaseProps, 'value' | 'defaultValue'> {
|
|
6
|
-
value?:
|
|
7
|
-
defaultValue?:
|
|
5
|
+
value?: DateValue | null;
|
|
6
|
+
defaultValue?: DateValue | null;
|
|
8
7
|
label?: string;
|
|
9
8
|
name?: string;
|
|
10
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="T extends ListItem">
|
|
2
|
-
import { Field } from '@ark-ui/svelte/field';
|
|
2
|
+
import { Field, useFieldContext } from '@ark-ui/svelte/field';
|
|
3
3
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
4
4
|
import { Select } from '@ark-ui/svelte/select';
|
|
5
5
|
import type { SelectProps } from './types';
|
|
@@ -15,15 +15,26 @@
|
|
|
15
15
|
layout = 'vertical',
|
|
16
16
|
size = 'default',
|
|
17
17
|
name,
|
|
18
|
+
invalid,
|
|
19
|
+
readOnly,
|
|
20
|
+
disabled,
|
|
18
21
|
...restProps
|
|
19
22
|
}: SelectProps<T> = $props();
|
|
20
23
|
|
|
24
|
+
const field = useFieldContext();
|
|
25
|
+
const isInvalid = $derived(invalid ?? field?.()?.invalid ?? false);
|
|
26
|
+
const isReadOnly = $derived(readOnly ?? field?.()?.readOnly ?? false);
|
|
27
|
+
const isDisabled = $derived(disabled ?? field?.()?.disabled ?? false);
|
|
28
|
+
|
|
21
29
|
const collection = $derived(createListCollection(items));
|
|
22
30
|
</script>
|
|
23
31
|
|
|
24
32
|
<Select.Root
|
|
25
33
|
{collection}
|
|
26
34
|
{...restProps}
|
|
35
|
+
invalid={isInvalid}
|
|
36
|
+
readOnly={isReadOnly}
|
|
37
|
+
disabled={isDisabled}
|
|
27
38
|
deselectable
|
|
28
39
|
value={value ? [value.toString()] : []}
|
|
29
40
|
onValueChange={(valueChangeDetails) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type { DateFieldProps } from './components/date-field/types';
|
|
|
17
17
|
export { default as DateRangeField } from './components/date-range-field/date-range-field.svelte';
|
|
18
18
|
export type { DateRangeFieldProps } from './components/date-range-field/types';
|
|
19
19
|
export { default as DateInput } from './components/date-input/date-input.svelte';
|
|
20
|
-
export type { DateInputProps } from './components/date-input/types';
|
|
20
|
+
export type { DateInputProps, DateValue as DateInputDateValue } from './components/date-input/types';
|
|
21
21
|
export { default as DatePicker } from './components/date-picker/date-picker.svelte';
|
|
22
22
|
export type { DatePickerProps } from './components/date-picker/types';
|
|
23
23
|
export * as Dialog from './components/dialog';
|
|
@@ -51,6 +51,7 @@ export * as Field from './components/field';
|
|
|
51
51
|
export * as Fieldset from './components/fieldset';
|
|
52
52
|
export { default as TreeView } from './components/tree-view/tree-view.svelte';
|
|
53
53
|
export { LocaleProvider, useLocaleContext } from '@ark-ui/svelte/locale';
|
|
54
|
+
export { getLocalTimeZone, parseAbsolute, parseDateTime } from '@internationalized/date';
|
|
54
55
|
export { Portal } from '@ark-ui/svelte/portal';
|
|
55
56
|
export type { PortalProps } from '@ark-ui/svelte/portal';
|
|
56
57
|
export { createListCollection, createTreeCollection } from './utils/collections';
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export * as Field from './components/field';
|
|
|
39
39
|
export * as Fieldset from './components/fieldset';
|
|
40
40
|
export { default as TreeView } from './components/tree-view/tree-view.svelte';
|
|
41
41
|
export { LocaleProvider, useLocaleContext } from '@ark-ui/svelte/locale';
|
|
42
|
+
export { getLocalTimeZone, parseAbsolute, parseDateTime } from '@internationalized/date';
|
|
42
43
|
export { Portal } from '@ark-ui/svelte/portal';
|
|
43
44
|
export { createListCollection, createTreeCollection } from './utils/collections';
|
|
44
45
|
export { PersistedState, Debounced } from 'runed';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compote-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev --open",
|
|
@@ -56,14 +56,13 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@eslint/compat": "^2.0.5",
|
|
60
59
|
"@eslint/js": "^10.0.1",
|
|
61
60
|
"@faker-js/faker": "^10.4.0",
|
|
62
61
|
"@iconify-json/ph": "^1.2.2",
|
|
63
62
|
"@sveltejs/adapter-auto": "^7.0.0",
|
|
64
63
|
"@sveltejs/adapter-cloudflare": "^7.2.8",
|
|
65
|
-
"@sveltejs/kit": "^2.
|
|
66
|
-
"@sveltejs/package": "^2.5.
|
|
64
|
+
"@sveltejs/kit": "^2.63.0",
|
|
65
|
+
"@sveltejs/package": "^2.5.8",
|
|
67
66
|
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
68
67
|
"@tailwindcss/vite": "^4.2.4",
|
|
69
68
|
"@tanstack/svelte-virtual": "^3.13.28",
|
|
@@ -77,8 +76,8 @@
|
|
|
77
76
|
"prettier-plugin-svelte": "^4.1.0",
|
|
78
77
|
"prettier-plugin-tailwindcss": "^0.8.0",
|
|
79
78
|
"publint": "^0.3.21",
|
|
80
|
-
"svelte": "^5.56.
|
|
81
|
-
"svelte-check": "^4.
|
|
79
|
+
"svelte": "^5.56.2",
|
|
80
|
+
"svelte-check": "^4.6.0",
|
|
82
81
|
"tailwindcss": "^4.2.4",
|
|
83
82
|
"tw-animate-css": "^1.4.0",
|
|
84
83
|
"typescript": "^6.0.3",
|
|
@@ -93,6 +92,7 @@
|
|
|
93
92
|
"@ark-ui/svelte": "^5.22.0",
|
|
94
93
|
"@fontsource-variable/nunito-sans": "^5.2.7",
|
|
95
94
|
"@iconify/svelte": "^5.2.1",
|
|
95
|
+
"@internationalized/date": "^3.12.2",
|
|
96
96
|
"runed": "^0.37.1",
|
|
97
97
|
"tailwind-merge": "^3.6.0",
|
|
98
98
|
"tailwind-variants": "^3.2.2"
|