compote-ui 0.48.0 → 0.49.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/dialog/dialog-close-trigger.svelte +29 -7
- package/dist/components/dialog/dialog-close-trigger.svelte.d.ts +4 -1
- package/dist/components/drawer/drawer-footer.svelte +6 -1
- package/dist/components/json-tree-view/json-tree-view.svelte +150 -0
- package/dist/components/json-tree-view/json-tree-view.svelte.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -2,20 +2,42 @@
|
|
|
2
2
|
import { Dialog } from '@ark-ui/svelte/dialog';
|
|
3
3
|
import type { DialogCloseTriggerBaseProps } from '@ark-ui/svelte/dialog';
|
|
4
4
|
import { PhX } from '../../icons';
|
|
5
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
button,
|
|
7
|
+
type ButtonVariant,
|
|
8
|
+
type ButtonSize
|
|
9
|
+
} from '../button/button.variants';
|
|
10
|
+
import type { ClassValue } from 'tailwind-variants';
|
|
6
11
|
|
|
7
12
|
interface Props extends DialogCloseTriggerBaseProps {
|
|
13
|
+
variant?: ButtonVariant;
|
|
14
|
+
size?: ButtonSize;
|
|
8
15
|
class?: ClassValue;
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
let { class: className, children, ...rest }: Props = $props();
|
|
18
|
+
let { class: className, variant, size, children, ...rest }: Props = $props();
|
|
19
|
+
|
|
20
|
+
const isIconMode = $derived(!children);
|
|
21
|
+
|
|
22
|
+
const classes = $derived(
|
|
23
|
+
isIconMode
|
|
24
|
+
? button({
|
|
25
|
+
variant: variant ?? 'ghost',
|
|
26
|
+
size: size ?? 'icon-sm',
|
|
27
|
+
class: [
|
|
28
|
+
'absolute top-3 right-3 opacity-70 hover:opacity-100 active:opacity-50',
|
|
29
|
+
className
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
: button({
|
|
33
|
+
variant: variant ?? 'outline',
|
|
34
|
+
size: size ?? 'default',
|
|
35
|
+
class: className
|
|
36
|
+
})
|
|
37
|
+
);
|
|
12
38
|
</script>
|
|
13
39
|
|
|
14
|
-
<Dialog.CloseTrigger
|
|
15
|
-
{...rest}
|
|
16
|
-
class={className ??
|
|
17
|
-
'absolute top-3 right-3 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none active:opacity-50'}
|
|
18
|
-
>
|
|
40
|
+
<Dialog.CloseTrigger {...rest} class={classes}>
|
|
19
41
|
{#if children}
|
|
20
42
|
{@render children()}
|
|
21
43
|
{:else}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { DialogCloseTriggerBaseProps } from '@ark-ui/svelte/dialog';
|
|
2
|
-
import type
|
|
2
|
+
import { type ButtonVariant, type ButtonSize } from '../button/button.variants';
|
|
3
|
+
import type { ClassValue } from 'tailwind-variants';
|
|
3
4
|
interface Props extends DialogCloseTriggerBaseProps {
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: ButtonSize;
|
|
4
7
|
class?: ClassValue;
|
|
5
8
|
}
|
|
6
9
|
declare const DialogCloseTrigger: import("svelte").Component<Props, {}, "">;
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
let { class: className, children }: Props = $props();
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
class={cn(
|
|
16
|
+
'mt-auto flex flex-row items-center justify-end gap-2 border-t border-border p-4',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
>
|
|
15
20
|
{@render children()}
|
|
16
21
|
</div>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { JsonTreeView } from '@ark-ui/svelte/json-tree-view';
|
|
3
|
+
import type {
|
|
4
|
+
JsonTreeViewRootBaseProps,
|
|
5
|
+
JsonTreeViewTreeBaseProps
|
|
6
|
+
} from '@ark-ui/svelte/json-tree-view';
|
|
7
|
+
import type { ClassValue } from 'svelte/elements';
|
|
8
|
+
import { cn } from 'tailwind-variants';
|
|
9
|
+
import { PhCaretRight } from '../../icons';
|
|
10
|
+
|
|
11
|
+
interface Props extends JsonTreeViewRootBaseProps {
|
|
12
|
+
class?: ClassValue;
|
|
13
|
+
treeClass?: ClassValue;
|
|
14
|
+
indentGuide?: JsonTreeViewTreeBaseProps['indentGuide'];
|
|
15
|
+
renderValue?: JsonTreeViewTreeBaseProps['renderValue'];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
class: className,
|
|
20
|
+
treeClass,
|
|
21
|
+
defaultExpandedDepth = 1,
|
|
22
|
+
indentGuide = true,
|
|
23
|
+
renderValue,
|
|
24
|
+
...rootProps
|
|
25
|
+
}: Props = $props();
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<JsonTreeView.Root
|
|
29
|
+
{defaultExpandedDepth}
|
|
30
|
+
class={cn(
|
|
31
|
+
'w-full overflow-auto font-mono text-xs text-ink',
|
|
32
|
+
'**:data-[part=branch-content]:relative',
|
|
33
|
+
'**:data-[part=branch-control]:flex **:data-[part=branch-control]:min-w-0 **:data-[part=branch-control]:cursor-pointer **:data-[part=branch-control]:items-baseline **:data-[part=branch-control]:rounded-sm **:data-[part=branch-control]:py-0.5 **:data-[part=branch-control]:pe-2 **:data-[part=branch-control]:outline-none **:data-[part=branch-control]:select-none',
|
|
34
|
+
'[&_[data-part=branch-control]:focus-visible]:ring-2 [&_[data-part=branch-control]:focus-visible]:ring-ring [&_[data-part=branch-control]:focus-visible]:ring-offset-1 [&_[data-part=branch-control]:focus-visible]:ring-offset-surface-1 [&_[data-part=branch-control]:hover]:bg-surface-2 [&_[data-part=branch-control][data-highlighted]]:bg-surface-2 [&_[data-part=branch-control][data-selected]]:bg-surface-2',
|
|
35
|
+
'**:data-[part=branch-indicator]:me-1 **:data-[part=branch-indicator]:inline-flex **:data-[part=branch-indicator]:size-3 **:data-[part=branch-indicator]:shrink-0 **:data-[part=branch-indicator]:origin-center **:data-[part=branch-indicator]:items-center **:data-[part=branch-indicator]:justify-center **:data-[part=branch-indicator]:text-ink-dim **:data-[part=branch-indicator]:transition-transform **:data-[part=branch-indicator]:duration-150',
|
|
36
|
+
'[&_[data-part=branch-indicator][data-state=open]]:rotate-90',
|
|
37
|
+
'**:data-[part=item]:relative **:data-[part=item]:flex **:data-[part=item]:min-w-0 **:data-[part=item]:rounded-sm **:data-[part=item]:py-0.5 **:data-[part=item]:pe-2 **:data-[part=item]:outline-none',
|
|
38
|
+
'[&_[data-part=item]:focus-visible]:ring-2 [&_[data-part=item]:focus-visible]:ring-ring [&_[data-part=item]:focus-visible]:ring-offset-1 [&_[data-part=item]:focus-visible]:ring-offset-surface-1 [&_[data-part=item]:hover]:bg-surface-2 [&_[data-part=item][data-highlighted]]:bg-surface-2 [&_[data-part=item][data-selected]]:bg-surface-2',
|
|
39
|
+
'**:data-[part=item-text]:flex **:data-[part=item-text]:min-w-0 **:data-[part=item-text]:flex-wrap **:data-[part=item-text]:items-baseline **:data-[part=item-text]:wrap-break-word',
|
|
40
|
+
'**:data-[part=branch-text]:flex **:data-[part=branch-text]:min-w-0 **:data-[part=branch-text]:flex-wrap **:data-[part=branch-text]:items-baseline **:data-[part=branch-text]:wrap-break-word',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...rootProps}
|
|
44
|
+
>
|
|
45
|
+
<JsonTreeView.Tree
|
|
46
|
+
class={cn('flex flex-col leading-[1.8] [&_svg]:size-3', treeClass)}
|
|
47
|
+
{indentGuide}
|
|
48
|
+
{renderValue}
|
|
49
|
+
>
|
|
50
|
+
{#snippet arrow()}
|
|
51
|
+
<PhCaretRight class="size-3" />
|
|
52
|
+
{/snippet}
|
|
53
|
+
</JsonTreeView.Tree>
|
|
54
|
+
</JsonTreeView.Root>
|
|
55
|
+
|
|
56
|
+
<style>
|
|
57
|
+
/* depth-based indentation requires calc(var(--depth)...) — not expressible in Tailwind */
|
|
58
|
+
:global([data-scope='json-tree-view'] [data-part='branch-indent-guide']) {
|
|
59
|
+
position: absolute;
|
|
60
|
+
height: 100%;
|
|
61
|
+
width: 1px;
|
|
62
|
+
background: var(--compote-border);
|
|
63
|
+
inset-inline-start: calc((var(--depth) - 1) * 1rem + 0.75rem);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:global([data-scope='json-tree-view'] [data-part='branch-indent-guide'][data-depth='1']) {
|
|
67
|
+
inset-inline-start: 0.75rem;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:global([data-scope='json-tree-view'] [data-part='branch-control']) {
|
|
71
|
+
padding-inline-start: calc((var(--depth) - 1) * 0.75rem);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:global([data-scope='json-tree-view'] [data-part='branch-control'][data-depth='1']) {
|
|
75
|
+
padding-inline-start: 0.25rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:global([data-scope='json-tree-view'] [data-part='item']) {
|
|
79
|
+
padding-inline-start: calc(((var(--depth) - 1) * 0.75rem) + 0.75rem);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:global([data-scope='json-tree-view'] [data-part='item'][data-depth='1']) {
|
|
83
|
+
padding-inline-start: 1.5rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Value types — light-dark() for dark mode, not expressible in Tailwind */
|
|
87
|
+
:global([data-scope='json-tree-view'] [data-type='string']) {
|
|
88
|
+
color: light-dark(#16a34a, #4ade80);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:global([data-scope='json-tree-view'] [data-type='number']) {
|
|
92
|
+
color: light-dark(#2563eb, #60a5fa);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:global([data-scope='json-tree-view'] [data-type='boolean']) {
|
|
96
|
+
color: light-dark(#d97706, #fbbf24);
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:global([data-scope='json-tree-view'] [data-type='null']),
|
|
101
|
+
:global([data-scope='json-tree-view'] [data-type='undefined']) {
|
|
102
|
+
color: var(--compote-ink-dim);
|
|
103
|
+
font-style: italic;
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:global([data-scope='json-tree-view'] [data-type='function']) {
|
|
108
|
+
color: light-dark(#9333ea, #c084fc);
|
|
109
|
+
font-style: italic;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:global([data-scope='json-tree-view'] [data-type='date']) {
|
|
113
|
+
color: light-dark(#0891b2, #22d3ee);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:global([data-scope='json-tree-view'] [data-type='error']) {
|
|
117
|
+
color: light-dark(#dc2626, #f87171);
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:global([data-scope='json-tree-view'] [data-type='regex']) {
|
|
122
|
+
color: light-dark(#7c3aed, #a78bfa);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Syntax elements */
|
|
126
|
+
:global([data-scope='json-tree-view'] [data-kind='brace']) {
|
|
127
|
+
color: var(--compote-ink);
|
|
128
|
+
font-weight: 700;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:global([data-scope='json-tree-view'] [data-kind='key']) {
|
|
132
|
+
color: var(--compote-primary);
|
|
133
|
+
font-weight: 500;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:global([data-scope='json-tree-view'] [data-kind='colon']) {
|
|
137
|
+
color: var(--compote-ink-dim);
|
|
138
|
+
margin-inline: 0.25rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:global([data-scope='json-tree-view'] [data-kind='preview-text']) {
|
|
142
|
+
color: var(--compote-ink-dim);
|
|
143
|
+
font-style: italic;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:global([data-scope='json-tree-view'] [data-kind='constructor']) {
|
|
147
|
+
color: var(--compote-primary);
|
|
148
|
+
font-weight: 500;
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonTreeView } from '@ark-ui/svelte/json-tree-view';
|
|
2
|
+
import type { JsonTreeViewRootBaseProps, JsonTreeViewTreeBaseProps } from '@ark-ui/svelte/json-tree-view';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
4
|
+
interface Props extends JsonTreeViewRootBaseProps {
|
|
5
|
+
class?: ClassValue;
|
|
6
|
+
treeClass?: ClassValue;
|
|
7
|
+
indentGuide?: JsonTreeViewTreeBaseProps['indentGuide'];
|
|
8
|
+
renderValue?: JsonTreeViewTreeBaseProps['renderValue'];
|
|
9
|
+
}
|
|
10
|
+
declare const JsonTreeView: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type JsonTreeView = ReturnType<typeof JsonTreeView>;
|
|
12
|
+
export default JsonTreeView;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { default as ImageCropper } from './components/image-cropper/image-croppe
|
|
|
23
23
|
export type { ImageCropperProps, ImageCropperCropData } from './components/image-cropper/types';
|
|
24
24
|
export { default as ImageCropDialog } from './components/image-crop-dialog/image-crop-dialog.svelte';
|
|
25
25
|
export type { ImageCropDialogProps } from './components/image-crop-dialog/types';
|
|
26
|
+
export { default as JsonTreeView } from './components/json-tree-view/json-tree-view.svelte';
|
|
26
27
|
export * as Listbox from './components/listbox';
|
|
27
28
|
export { default as NumberInput } from './components/number-input/number-input.svelte';
|
|
28
29
|
export type { NumberInputProps } from './components/number-input/types';
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { default as FileUploadDropzone } from './components/file-upload/file-upl
|
|
|
18
18
|
export { default as FileUpload } from './components/file-upload/file-upload.svelte';
|
|
19
19
|
export { default as ImageCropper } from './components/image-cropper/image-cropper.svelte';
|
|
20
20
|
export { default as ImageCropDialog } from './components/image-crop-dialog/image-crop-dialog.svelte';
|
|
21
|
+
export { default as JsonTreeView } from './components/json-tree-view/json-tree-view.svelte';
|
|
21
22
|
export * as Listbox from './components/listbox';
|
|
22
23
|
export { default as NumberInput } from './components/number-input/number-input.svelte';
|
|
23
24
|
export * as Popover from './components/popover';
|