compote-ui 0.53.0 → 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/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>
|
|
@@ -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"
|