compote-ui 0.2.0 → 0.5.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/button/button.svelte +16 -0
- package/dist/components/button/{Button.svelte.d.ts → button.svelte.d.ts} +3 -2
- package/dist/components/button/button.variants.d.ts +46 -0
- package/dist/components/button/button.variants.js +20 -0
- package/dist/components/carousel/carousel.svelte +120 -0
- package/dist/components/carousel/carousel.svelte.d.ts +19 -0
- package/dist/components/checkbox/{Checkbox-group.svelte → checkbox-group.svelte} +1 -1
- package/dist/components/checkbox/{Checkbox.svelte → checkbox.svelte} +6 -2
- package/dist/components/combobox/{Combobox.svelte → combobox.svelte} +22 -25
- package/dist/components/combobox/types.d.ts +1 -1
- package/dist/components/dialog/alert-dialog.svelte +73 -0
- package/dist/components/dialog/alert-dialog.svelte.d.ts +13 -0
- package/dist/components/dialog/dialog.svelte +68 -0
- package/dist/components/dialog/dialog.svelte.d.ts +14 -0
- package/dist/components/field/field-error-text.svelte +11 -0
- package/dist/components/field/field-error-text.svelte.d.ts +4 -0
- package/dist/components/field/field-helper-text.svelte +11 -0
- package/dist/components/field/field-helper-text.svelte.d.ts +4 -0
- package/dist/components/field/field-input.svelte +38 -0
- package/dist/components/field/field-input.svelte.d.ts +4 -0
- package/dist/components/field/field-label.svelte +18 -0
- package/dist/components/field/field-label.svelte.d.ts +4 -0
- package/dist/components/field/field-textarea.svelte +16 -0
- package/dist/components/field/field-textarea.svelte.d.ts +4 -0
- package/dist/components/field/field.svelte +11 -0
- package/dist/components/field/field.svelte.d.ts +5 -0
- package/dist/components/field/index.d.ts +7 -0
- package/dist/components/field/index.js +6 -0
- package/dist/components/field/types.d.ts +22 -0
- package/dist/components/field/types.js +1 -0
- package/dist/components/file-upload/basic-document.svelte +89 -0
- package/dist/components/file-upload/basic-document.svelte.d.ts +4 -0
- package/dist/components/file-upload/basic.svelte +50 -0
- package/dist/components/file-upload/basic.svelte.d.ts +18 -0
- package/dist/components/file-upload/dropzone.svelte +26 -0
- package/dist/components/file-upload/dropzone.svelte.d.ts +4 -0
- package/dist/components/file-upload/files-list.svelte +97 -0
- package/dist/components/file-upload/files-list.svelte.d.ts +18 -0
- package/dist/components/file-upload/icons.d.ts +3 -0
- package/dist/components/file-upload/icons.js +39 -0
- package/dist/components/file-upload/types.d.ts +6 -0
- package/dist/components/file-upload/types.js +1 -0
- package/dist/components/file-upload/utils.d.ts +13 -0
- package/dist/components/file-upload/utils.js +18 -0
- package/dist/components/image-cropper/image-cropper.svelte +109 -0
- package/dist/components/image-cropper/image-cropper.svelte.d.ts +5 -0
- package/dist/components/image-cropper/types.d.ts +16 -0
- package/dist/components/image-cropper/types.js +1 -0
- package/dist/components/listbox/listbox.svelte +116 -0
- package/dist/components/listbox/listbox.svelte.d.ts +27 -0
- package/dist/components/listbox/types.d.ts +16 -0
- package/dist/components/listbox/types.js +1 -0
- package/dist/components/menu/index.d.ts +14 -0
- package/dist/components/menu/index.js +14 -0
- package/dist/components/menu/menu-checkbox-item.svelte +31 -0
- package/dist/components/menu/menu-checkbox-item.svelte.d.ts +12 -0
- package/dist/components/menu/menu-content.svelte +23 -0
- package/dist/components/menu/menu-content.svelte.d.ts +8 -0
- package/dist/components/menu/menu-context-trigger.svelte +20 -0
- package/dist/components/menu/menu-context-trigger.svelte.d.ts +8 -0
- package/dist/components/menu/menu-indicator.svelte +19 -0
- package/dist/components/menu/menu-indicator.svelte.d.ts +9 -0
- package/dist/components/menu/menu-item-group-label.svelte +17 -0
- package/dist/components/menu/menu-item-group-label.svelte.d.ts +9 -0
- package/dist/components/menu/menu-item-group.svelte +14 -0
- package/dist/components/menu/menu-item-group.svelte.d.ts +9 -0
- package/dist/components/menu/menu-item-indicator.svelte +14 -0
- package/dist/components/menu/menu-item-indicator.svelte.d.ts +9 -0
- package/dist/components/menu/menu-item.svelte +20 -0
- package/dist/components/menu/menu-item.svelte.d.ts +9 -0
- package/dist/components/menu/menu-radio-item-group.svelte +14 -0
- package/dist/components/menu/menu-radio-item-group.svelte.d.ts +9 -0
- package/dist/components/menu/menu-radio-item.svelte +28 -0
- package/dist/components/menu/menu-radio-item.svelte.d.ts +10 -0
- package/dist/components/menu/menu-separator.svelte +11 -0
- package/dist/components/menu/menu-separator.svelte.d.ts +7 -0
- package/dist/components/menu/menu-trigger-item.svelte +20 -0
- package/dist/components/menu/menu-trigger-item.svelte.d.ts +9 -0
- package/dist/components/menu/menu-trigger.svelte +19 -0
- package/dist/components/menu/menu-trigger.svelte.d.ts +12 -0
- package/dist/components/menu/menu.svelte +12 -0
- package/dist/components/menu/menu.svelte.d.ts +4 -0
- package/dist/components/number-input/number-input.svelte +67 -0
- package/dist/components/number-input/number-input.svelte.d.ts +5 -0
- package/dist/components/number-input/types.d.ts +7 -0
- package/dist/components/number-input/types.js +1 -0
- package/dist/components/select/select.svelte +93 -0
- package/dist/components/select/select.svelte.d.ts +26 -0
- package/dist/components/select/types.d.ts +13 -0
- package/dist/components/select/types.js +1 -0
- package/dist/components/splitter/splitter.svelte +60 -0
- package/dist/components/splitter/splitter.svelte.d.ts +5 -0
- package/dist/components/splitter/types.d.ts +9 -0
- package/dist/components/splitter/types.js +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/switch/switch.svelte +40 -0
- package/dist/components/switch/switch.svelte.d.ts +8 -0
- package/dist/components/switch/types.d.ts +5 -0
- package/dist/components/switch/types.js +1 -0
- package/dist/components/tabs/index.d.ts +4 -0
- package/dist/components/tabs/index.js +3 -0
- package/dist/components/tabs/tab-content.svelte +18 -0
- package/dist/components/tabs/tab-content.svelte.d.ts +7 -0
- package/dist/components/tabs/tab-trigger.svelte +18 -0
- package/dist/components/tabs/tab-trigger.svelte.d.ts +7 -0
- package/dist/components/tabs/tabs.svelte +39 -0
- package/dist/components/tabs/tabs.svelte.d.ts +5 -0
- package/dist/components/tabs/types.d.ts +8 -0
- package/dist/components/tabs/types.js +1 -0
- package/dist/components/tree-view/tree-view.svelte +210 -0
- package/dist/components/tree-view/tree-view.svelte.d.ts +26 -0
- package/dist/components/tree-view/types.d.ts +12 -0
- package/dist/components/tree-view/types.js +1 -0
- package/dist/icons/PhArrowLeft.svelte +18 -0
- package/dist/icons/PhArrowLeft.svelte.d.ts +5 -0
- package/dist/icons/PhArrowRight.svelte +18 -0
- package/dist/icons/PhArrowRight.svelte.d.ts +5 -0
- package/dist/icons/PhArrowsInSimple.svelte +17 -0
- package/dist/icons/PhArrowsInSimple.svelte.d.ts +5 -0
- package/dist/icons/PhCaretDown.svelte +2 -1
- package/dist/icons/PhCaretRight.svelte +17 -0
- package/dist/icons/PhCaretRight.svelte.d.ts +5 -0
- package/dist/icons/PhCaretUp.svelte +18 -0
- package/dist/icons/PhCaretUp.svelte.d.ts +5 -0
- package/dist/icons/PhCheck.svelte +2 -1
- package/dist/icons/PhFile.svelte +19 -0
- package/dist/icons/PhFile.svelte.d.ts +5 -0
- package/dist/icons/PhFileArchive.svelte +18 -0
- package/dist/icons/PhFileArchive.svelte.d.ts +5 -0
- package/dist/icons/PhFileText.svelte +18 -0
- package/dist/icons/PhFileText.svelte.d.ts +5 -0
- package/dist/icons/PhHeadphones.svelte +17 -0
- package/dist/icons/PhHeadphones.svelte.d.ts +5 -0
- package/dist/icons/PhImage.svelte +18 -0
- package/dist/icons/PhImage.svelte.d.ts +5 -0
- package/dist/icons/PhListMagnifyingGlass.svelte +17 -0
- package/dist/icons/PhListMagnifyingGlass.svelte.d.ts +5 -0
- package/dist/icons/PhMagnifyingGlass.svelte +17 -0
- package/dist/icons/PhMagnifyingGlass.svelte.d.ts +5 -0
- package/dist/icons/PhMicrosoftExcelLogo.svelte +17 -0
- package/dist/icons/PhMicrosoftExcelLogo.svelte.d.ts +5 -0
- package/dist/icons/PhStar.svelte +18 -0
- package/dist/icons/PhStar.svelte.d.ts +5 -0
- package/dist/icons/PhUploadSimple.svelte +18 -0
- package/dist/icons/PhUploadSimple.svelte.d.ts +5 -0
- package/dist/icons/PhUser.svelte +18 -0
- package/dist/icons/PhUser.svelte.d.ts +5 -0
- package/dist/icons/PhVideoCamera.svelte +17 -0
- package/dist/icons/PhVideoCamera.svelte.d.ts +5 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +17 -4
- package/dist/open-props/props.colors-oklch-hues.css +14 -0
- package/dist/open-props/props.colors-oklch.css +19 -0
- package/dist/open-props/props.gray-oklch.css +18 -0
- package/dist/theme.css +19 -5
- package/package.json +4 -3
- package/dist/components/button/Button.svelte +0 -33
- package/dist/gray-oklch.min.css +0 -1
- package/dist/green-hsl.min.css +0 -1
- package/dist/props.colors-oklch-hues.css +0 -14
- package/dist/props.colors-oklch.css +0 -19
- package/dist/props.gray-oklch.css +0 -18
- /package/dist/components/checkbox/{Checkbox-group.svelte.d.ts → checkbox-group.svelte.d.ts} +0 -0
- /package/dist/components/checkbox/{Checkbox.svelte.d.ts → checkbox.svelte.d.ts} +0 -0
- /package/dist/components/combobox/{Combobox.svelte.d.ts → combobox.svelte.d.ts} +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Field } from '@ark-ui/svelte/field';
|
|
3
|
+
import { NumberInput } from '@ark-ui/svelte/number-input';
|
|
4
|
+
import type { NumberInputProps } from './types';
|
|
5
|
+
import PhCaretDown from '../../icons/PhCaretDown.svelte';
|
|
6
|
+
import PhCaretUp from '../../icons/PhCaretUp.svelte';
|
|
7
|
+
import { useLocaleContext } from '@ark-ui/svelte/locale';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
readonly,
|
|
12
|
+
label,
|
|
13
|
+
layout = 'vertical',
|
|
14
|
+
name,
|
|
15
|
+
...restProps
|
|
16
|
+
}: NumberInputProps = $props();
|
|
17
|
+
const locale = useLocaleContext();
|
|
18
|
+
const rootClass = $derived(
|
|
19
|
+
layout === 'horizontal'
|
|
20
|
+
? 'flex items-center gap-1.5 w-full max-w-48 data-disabled:opacity-50 data-disabled:grayscale'
|
|
21
|
+
: 'flex flex-col gap-1.5 w-full max-w-48 data-disabled:opacity-50 data-disabled:grayscale'
|
|
22
|
+
);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<input type="hidden" {name} value={Number.isNaN(value) ? undefined : value?.toString()} />
|
|
26
|
+
|
|
27
|
+
<NumberInput.Root
|
|
28
|
+
{...restProps}
|
|
29
|
+
allowMouseWheel
|
|
30
|
+
locale={locale().locale}
|
|
31
|
+
value={value?.toString()}
|
|
32
|
+
readOnly={readonly}
|
|
33
|
+
onValueChange={(valueChangeDetails) => {
|
|
34
|
+
console.log(valueChangeDetails);
|
|
35
|
+
if (isNaN(valueChangeDetails.valueAsNumber)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
value = valueChangeDetails.valueAsNumber;
|
|
39
|
+
}}
|
|
40
|
+
class={rootClass}
|
|
41
|
+
>
|
|
42
|
+
{#if label}
|
|
43
|
+
<NumberInput.Label>
|
|
44
|
+
{label}
|
|
45
|
+
<Field.RequiredIndicator />
|
|
46
|
+
</NumberInput.Label>
|
|
47
|
+
{/if}
|
|
48
|
+
<NumberInput.Control class="relative isolate">
|
|
49
|
+
<NumberInput.Input
|
|
50
|
+
class="h-9 w-full rounded-md border bg-surface-1 px-3 pr-8 text-right text-sm font-medium tabular-nums shadow-sm focus-visible:ring-1 focus-visible:ring-primary focus-visible:outline-none data-invalid:border-danger data-invalid:focus-visible:ring-danger"
|
|
51
|
+
/>
|
|
52
|
+
<div
|
|
53
|
+
class="absolute top-px right-px bottom-px z-10 flex w-6 flex-col overflow-hidden rounded-r border-l"
|
|
54
|
+
>
|
|
55
|
+
<NumberInput.IncrementTrigger
|
|
56
|
+
class="inline-flex flex-1 cursor-pointer items-center justify-center border-none text-ink-dim hover:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary active:bg-surface-2 disabled:cursor-not-allowed disabled:text-ink-dim"
|
|
57
|
+
>
|
|
58
|
+
<PhCaretUp class="h-4 w-4 shrink-0" />
|
|
59
|
+
</NumberInput.IncrementTrigger>
|
|
60
|
+
<NumberInput.DecrementTrigger
|
|
61
|
+
class="inline-flex flex-1 cursor-pointer items-center justify-center border-t text-ink-dim hover:bg-surface-2 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary active:bg-surface-2 disabled:cursor-not-allowed disabled:text-ink-dim"
|
|
62
|
+
>
|
|
63
|
+
<PhCaretDown class="h-4 w-4 shrink-0" />
|
|
64
|
+
</NumberInput.DecrementTrigger>
|
|
65
|
+
</div>
|
|
66
|
+
</NumberInput.Control>
|
|
67
|
+
</NumberInput.Root>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NumberInput } from '@ark-ui/svelte/number-input';
|
|
2
|
+
import type { NumberInputProps } from './types';
|
|
3
|
+
declare const NumberInput: import("svelte").Component<NumberInputProps, {}, "value">;
|
|
4
|
+
type NumberInput = ReturnType<typeof NumberInput>;
|
|
5
|
+
export default NumberInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NumberInputRootBaseProps } from '@ark-ui/svelte/number-input';
|
|
2
|
+
export interface NumberInputProps extends Omit<NumberInputRootBaseProps, 'value' | 'readOnly'> {
|
|
3
|
+
value?: number | null;
|
|
4
|
+
readonly?: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
layout?: 'vertical' | 'horizontal';
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends SelectItem">
|
|
2
|
+
import { Field } from '@ark-ui/svelte/field';
|
|
3
|
+
import { Portal } from '@ark-ui/svelte/portal';
|
|
4
|
+
import { Select, createListCollection } from '@ark-ui/svelte/select';
|
|
5
|
+
import type { SelectItem, SelectProps } from './types';
|
|
6
|
+
import { cn } from 'tailwind-variants';
|
|
7
|
+
import PhCaretDown from '../../icons/PhCaretDown.svelte';
|
|
8
|
+
import PhCheck from '../../icons/PhCheck.svelte';
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
value = $bindable(),
|
|
12
|
+
items = [],
|
|
13
|
+
label,
|
|
14
|
+
placeholder,
|
|
15
|
+
layout = 'vertical',
|
|
16
|
+
name,
|
|
17
|
+
...restProps
|
|
18
|
+
}: SelectProps<T> = $props();
|
|
19
|
+
const rootClass = $derived(
|
|
20
|
+
layout === 'horizontal' ? 'flex items-center gap-1.5' : 'grid gap-1.5'
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const collection = $derived(
|
|
24
|
+
createListCollection<T>({
|
|
25
|
+
items: items,
|
|
26
|
+
itemToValue: (item) => item.value.toString(),
|
|
27
|
+
isItemDisabled: (item) => item.disabled === true
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<Select.Root
|
|
33
|
+
{collection}
|
|
34
|
+
{...restProps}
|
|
35
|
+
deselectable
|
|
36
|
+
value={value ? [value.toString()] : []}
|
|
37
|
+
onValueChange={(valueChangeDetails) => {
|
|
38
|
+
if (valueChangeDetails.items.length === 0 || valueChangeDetails.items == null) {
|
|
39
|
+
value = null;
|
|
40
|
+
} else {
|
|
41
|
+
value = valueChangeDetails.items[0].value;
|
|
42
|
+
}
|
|
43
|
+
if (restProps.onValueChange) {
|
|
44
|
+
restProps.onValueChange(valueChangeDetails);
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
class={rootClass}
|
|
48
|
+
>
|
|
49
|
+
{#if label}
|
|
50
|
+
<Select.Label>
|
|
51
|
+
{label}
|
|
52
|
+
<Field.RequiredIndicator />
|
|
53
|
+
</Select.Label>
|
|
54
|
+
{/if}
|
|
55
|
+
<Select.Control>
|
|
56
|
+
<Select.Trigger
|
|
57
|
+
class="flex h-9 w-full cursor-pointer items-center justify-between rounded-md border bg-surface-1 px-3 text-sm shadow-sm focus-visible:ring-1 focus-visible:ring-primary focus-visible:outline-none active:bg-surface-2 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-invalid:border-danger data-invalid:focus-visible:ring-danger"
|
|
58
|
+
>
|
|
59
|
+
<div class="flex items-center gap-2">
|
|
60
|
+
<Select.ValueText
|
|
61
|
+
placeholder={placeholder ?? 'Select a item'}
|
|
62
|
+
class={cn('text-nowrap', value ? '' : 'text-ink-dim')}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
<Select.Indicator>
|
|
66
|
+
<PhCaretDown class="h-4 w-4 opacity-50" />
|
|
67
|
+
</Select.Indicator>
|
|
68
|
+
</Select.Trigger>
|
|
69
|
+
</Select.Control>
|
|
70
|
+
<Portal>
|
|
71
|
+
<Select.Positioner>
|
|
72
|
+
<Select.Content
|
|
73
|
+
class="data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 z-50 max-h-60 min-w-(--reference-width) overflow-auto rounded-md border bg-surface-1 p-1 text-ink shadow-md"
|
|
74
|
+
>
|
|
75
|
+
<Select.ItemGroup>
|
|
76
|
+
{#each items as item (item.value)}
|
|
77
|
+
<Select.Item
|
|
78
|
+
{item}
|
|
79
|
+
class="relative flex cursor-default items-center rounded-sm py-1.5 pr-8 pl-2 text-sm text-ink select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-surface-2 data-[state=checked]:bg-surface-2"
|
|
80
|
+
>
|
|
81
|
+
<Select.ItemText>{item.label}</Select.ItemText>
|
|
82
|
+
<Select.ItemIndicator class="absolute right-2 items-center justify-center">
|
|
83
|
+
<PhCheck class="size-3.5" />
|
|
84
|
+
</Select.ItemIndicator>
|
|
85
|
+
</Select.Item>
|
|
86
|
+
{/each}
|
|
87
|
+
</Select.ItemGroup>
|
|
88
|
+
</Select.Content>
|
|
89
|
+
</Select.Positioner>
|
|
90
|
+
</Portal>
|
|
91
|
+
<input type="hidden" {name} value={value ?? ''} />
|
|
92
|
+
<Select.HiddenSelect />
|
|
93
|
+
</Select.Root>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Select } from '@ark-ui/svelte/select';
|
|
2
|
+
import type { SelectItem, SelectProps } from './types';
|
|
3
|
+
declare function $$render<T extends SelectItem>(): {
|
|
4
|
+
props: SelectProps<T>;
|
|
5
|
+
exports: {};
|
|
6
|
+
bindings: "value";
|
|
7
|
+
slots: {};
|
|
8
|
+
events: {};
|
|
9
|
+
};
|
|
10
|
+
declare class __sveltets_Render<T extends SelectItem> {
|
|
11
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
14
|
+
bindings(): "value";
|
|
15
|
+
exports(): {};
|
|
16
|
+
}
|
|
17
|
+
interface $$IsomorphicComponent {
|
|
18
|
+
new <T extends SelectItem>(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']>> & {
|
|
19
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
20
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
+
<T extends SelectItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
22
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
|
+
}
|
|
24
|
+
declare const Select: $$IsomorphicComponent;
|
|
25
|
+
type Select<T extends SelectItem> = InstanceType<typeof Select<T>>;
|
|
26
|
+
export default Select;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SelectRootBaseProps } from '@ark-ui/svelte/select';
|
|
2
|
+
export interface SelectItem<T = number | string> {
|
|
3
|
+
value: T;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SelectProps<T extends SelectItem> extends Omit<SelectRootBaseProps<T>, 'value' | 'collection'> {
|
|
8
|
+
value?: number | string | null;
|
|
9
|
+
items: T[];
|
|
10
|
+
label?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
layout?: 'vertical' | 'horizontal';
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Splitter } from '@ark-ui/svelte/splitter';
|
|
3
|
+
import { cn } from 'tailwind-variants';
|
|
4
|
+
import type { SplitterProps } from './types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
panels,
|
|
8
|
+
class: className,
|
|
9
|
+
orientation = 'horizontal',
|
|
10
|
+
...restProps
|
|
11
|
+
}: SplitterProps = $props();
|
|
12
|
+
|
|
13
|
+
const isHorizontal = $derived(orientation === 'horizontal');
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
+
const arkPanels = $derived(panels.map(({ content: _content, ...rest }) => rest));
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Splitter.Root
|
|
19
|
+
{orientation}
|
|
20
|
+
panels={arkPanels}
|
|
21
|
+
{...restProps}
|
|
22
|
+
class={cn('flex h-full w-full', !isHorizontal && 'flex-col', className)}
|
|
23
|
+
>
|
|
24
|
+
{#each panels as panelConfig, i (panelConfig.id)}
|
|
25
|
+
<Splitter.Panel
|
|
26
|
+
id={panelConfig.id}
|
|
27
|
+
class={cn('overflow-auto p-2', isHorizontal ? 'min-w-0' : 'min-h-0')}
|
|
28
|
+
>
|
|
29
|
+
{@render panelConfig.content()}
|
|
30
|
+
</Splitter.Panel>
|
|
31
|
+
|
|
32
|
+
{#if i < panels.length - 1}
|
|
33
|
+
<Splitter.ResizeTrigger
|
|
34
|
+
id={`${panelConfig.id}:${panels[i + 1].id}`}
|
|
35
|
+
aria-label={`Resize ${panelConfig.id} and ${panels[i + 1].id}`}
|
|
36
|
+
class={cn(
|
|
37
|
+
'group relative flex shrink-0 items-center justify-center border-none bg-transparent p-0 outline-none',
|
|
38
|
+
isHorizontal ? 'w-1.5 cursor-col-resize' : 'h-1.5 cursor-row-resize'
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<!-- Divider line -->
|
|
42
|
+
<div
|
|
43
|
+
class={cn(
|
|
44
|
+
'absolute bg-surface-3 transition-colors group-focus-within:bg-primary group-hover:bg-primary/40 group-data-dragging:bg-primary',
|
|
45
|
+
isHorizontal
|
|
46
|
+
? 'inset-y-0 left-1/2 w-px -translate-x-1/2'
|
|
47
|
+
: 'inset-x-0 top-1/2 h-px -translate-y-1/2'
|
|
48
|
+
)}
|
|
49
|
+
></div>
|
|
50
|
+
<!-- Handle pill -->
|
|
51
|
+
<div
|
|
52
|
+
class={cn(
|
|
53
|
+
'relative z-10 rounded-full bg-surface-3 shadow-sm transition-colors group-hover:bg-primary/40 group-data-dragging:bg-primary',
|
|
54
|
+
isHorizontal ? 'h-6 w-1' : 'h-1 w-6'
|
|
55
|
+
)}
|
|
56
|
+
></div>
|
|
57
|
+
</Splitter.ResizeTrigger>
|
|
58
|
+
{/if}
|
|
59
|
+
{/each}
|
|
60
|
+
</Splitter.Root>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SplitterRootBaseProps, SplitterPanelData } from '@ark-ui/svelte/splitter';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface SplitterPanelConfig extends SplitterPanelData {
|
|
4
|
+
content: Snippet;
|
|
5
|
+
}
|
|
6
|
+
export interface SplitterProps extends Omit<SplitterRootBaseProps, 'panels'> {
|
|
7
|
+
panels: SplitterPanelConfig[];
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Switch } from './switch.svelte';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Switch, type SwitchRootBaseProps } from '@ark-ui/svelte/switch';
|
|
3
|
+
|
|
4
|
+
interface Props extends SwitchRootBaseProps {
|
|
5
|
+
labelSpacer?: boolean;
|
|
6
|
+
layout?: 'vertical' | 'horizontal';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
checked = $bindable(),
|
|
11
|
+
label,
|
|
12
|
+
labelSpacer = false,
|
|
13
|
+
layout = 'horizontal',
|
|
14
|
+
...rootProps
|
|
15
|
+
}: Props = $props();
|
|
16
|
+
const rootClass = $derived(
|
|
17
|
+
layout === 'vertical'
|
|
18
|
+
? 'flex flex-col items-start gap-1 data-disabled:cursor-not-allowed data-disabled:opacity-50'
|
|
19
|
+
: 'inline-flex cursor-pointer items-center gap-2 data-disabled:cursor-not-allowed data-disabled:opacity-50'
|
|
20
|
+
);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if labelSpacer}
|
|
24
|
+
<div style="height: calc(var(--ark-label-height) + var(--ark-field-gap))"></div>
|
|
25
|
+
{/if}
|
|
26
|
+
<Switch.Root {...rootProps} bind:checked class={rootClass}>
|
|
27
|
+
<Switch.Control
|
|
28
|
+
class="relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border-2 border-transparent bg-surface-3 transition-colors duration-150 hover:opacity-90 focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:outline-hidden data-invalid:ring-2 data-invalid:ring-danger data-invalid:ring-offset-2 data-[state=checked]:bg-primary"
|
|
29
|
+
>
|
|
30
|
+
<Switch.Thumb
|
|
31
|
+
class="pointer-events-none block size-5 rounded-full bg-white shadow-sm ring-0 transition-transform duration-150 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
32
|
+
/>
|
|
33
|
+
</Switch.Control>
|
|
34
|
+
{#if label}
|
|
35
|
+
<Switch.Label class="cursor-pointer text-sm font-medium text-ink select-none">
|
|
36
|
+
{label}
|
|
37
|
+
</Switch.Label>
|
|
38
|
+
{/if}
|
|
39
|
+
<Switch.HiddenInput />
|
|
40
|
+
</Switch.Root>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Switch, type SwitchRootBaseProps } from '@ark-ui/svelte/switch';
|
|
2
|
+
interface Props extends SwitchRootBaseProps {
|
|
3
|
+
labelSpacer?: boolean;
|
|
4
|
+
layout?: 'vertical' | 'horizontal';
|
|
5
|
+
}
|
|
6
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
7
|
+
type Switch = ReturnType<typeof Switch>;
|
|
8
|
+
export default Switch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Tabs } from '@ark-ui/svelte/tabs';
|
|
3
|
+
import type { TabContentBaseProps } from '@ark-ui/svelte/tabs';
|
|
4
|
+
|
|
5
|
+
interface Props extends TabContentBaseProps {
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let { class: className, children, ...rest }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Tabs.Content
|
|
13
|
+
{...rest}
|
|
14
|
+
class={className ??
|
|
15
|
+
'flex-1 pt-4 outline-none data-[orientation=vertical]:pt-0 data-[orientation=vertical]:pl-4'}
|
|
16
|
+
>
|
|
17
|
+
{@render children?.()}
|
|
18
|
+
</Tabs.Content>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TabContentBaseProps } from '@ark-ui/svelte/tabs';
|
|
2
|
+
interface Props extends TabContentBaseProps {
|
|
3
|
+
class?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const TabContent: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type TabContent = ReturnType<typeof TabContent>;
|
|
7
|
+
export default TabContent;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Tabs } from '@ark-ui/svelte/tabs';
|
|
3
|
+
import type { TabTriggerBaseProps } from '@ark-ui/svelte/tabs';
|
|
4
|
+
|
|
5
|
+
interface Props extends TabTriggerBaseProps {
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let { class: className, children, ...rest }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Tabs.Trigger
|
|
13
|
+
{...rest}
|
|
14
|
+
class={className ??
|
|
15
|
+
'inline-flex h-8 items-center justify-center gap-2 rounded-md bg-transparent px-3 text-sm whitespace-nowrap text-ink-dim transition-colors outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 data-selected:font-medium data-selected:text-ink data-[orientation=vertical]:w-full data-[orientation=vertical]:justify-start data-[orientation=vertical]:py-2'}
|
|
16
|
+
>
|
|
17
|
+
{@render children?.()}
|
|
18
|
+
</Tabs.Trigger>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TabTriggerBaseProps } from '@ark-ui/svelte/tabs';
|
|
2
|
+
interface Props extends TabTriggerBaseProps {
|
|
3
|
+
class?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const TabTrigger: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type TabTrigger = ReturnType<typeof TabTrigger>;
|
|
7
|
+
export default TabTrigger;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Tabs } from '@ark-ui/svelte/tabs';
|
|
3
|
+
import { ClientOnly } from '@ark-ui/svelte/client-only';
|
|
4
|
+
import type { TabsProps } from './types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
indicator = false,
|
|
8
|
+
value = $bindable(),
|
|
9
|
+
defaultValue,
|
|
10
|
+
orientation = 'horizontal',
|
|
11
|
+
triggers,
|
|
12
|
+
children,
|
|
13
|
+
...rootProps
|
|
14
|
+
}: TabsProps = $props();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<ClientOnly>
|
|
18
|
+
<Tabs.Root
|
|
19
|
+
{...rootProps}
|
|
20
|
+
bind:value
|
|
21
|
+
{defaultValue}
|
|
22
|
+
{orientation}
|
|
23
|
+
class="flex data-[orientation='horizontal']:flex-col data-[orientation='vertical']:flex-row"
|
|
24
|
+
>
|
|
25
|
+
<Tabs.List
|
|
26
|
+
class="relative isolate inline-flex gap-1 data-[orientation='horizontal']:flex-row data-[orientation='vertical']:flex-col"
|
|
27
|
+
>
|
|
28
|
+
{#if triggers}
|
|
29
|
+
{@render triggers()}
|
|
30
|
+
{/if}
|
|
31
|
+
{#if indicator}
|
|
32
|
+
<Tabs.Indicator
|
|
33
|
+
class="absolute -z-10 rounded-md bg-surface-2 transition-[width,height,left,top] duration-200 ease-out data-[orientation='horizontal']:h-8 data-[orientation='horizontal']:w-(--width) data-[orientation='vertical']:h-(--height) data-[orientation='vertical']:w-full"
|
|
34
|
+
/>
|
|
35
|
+
{/if}
|
|
36
|
+
</Tabs.List>
|
|
37
|
+
{@render children?.()}
|
|
38
|
+
</Tabs.Root>
|
|
39
|
+
</ClientOnly>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TabsRootBaseProps } from '@ark-ui/svelte/tabs';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface TabsProps extends TabsRootBaseProps {
|
|
4
|
+
/** Whether to show the animated indicator behind the active tab */
|
|
5
|
+
indicator?: boolean;
|
|
6
|
+
/** Snippet for rendering tab triggers inside the list */
|
|
7
|
+
triggers?: Snippet;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|