compote-ui 0.15.0 → 0.16.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.
@@ -12,6 +12,7 @@
12
12
  import { Button, Field } from '../..';
13
13
  import { SvelteSet } from 'svelte/reactivity';
14
14
  import PhMagnifyingGlass from '../../icons/PhMagnifyingGlass.svelte';
15
+ import Icon from '@iconify/svelte';
15
16
 
16
17
  let {
17
18
  items = [],
@@ -171,10 +172,11 @@
171
172
  {@render nodeCheckbox()}
172
173
  {/if}
173
174
  <TreeView.BranchIndicator
174
- class="text-muted-foreground inline-flex items-center justify-center transition-transform duration-150 data-[state=open]:rotate-90"
175
+ class="text-muted-foreground inline-flex w-(--tree-icon) shrink-0 items-center justify-center transition-transform duration-150 data-[state=open]:rotate-90"
175
176
  >
176
177
  <PhCaretRight class="size-3.5" />
177
178
  </TreeView.BranchIndicator>
179
+ {#if node.icon}<Icon icon={node.icon} class="size-4 shrink-0" />{/if}
178
180
  <TreeView.BranchText class="flex-1 truncate">
179
181
  {node.label}
180
182
  </TreeView.BranchText>
@@ -194,6 +196,7 @@
194
196
  {#if selectionMode === 'multiple'}
195
197
  {@render nodeCheckbox()}
196
198
  {/if}
199
+ {#if node.icon}<Icon icon={node.icon} class="size-4 shrink-0" />{/if}
197
200
  <TreeView.ItemText class="flex-1 truncate">
198
201
  {node.label}
199
202
  </TreeView.ItemText>
@@ -9,6 +9,7 @@ export interface TreeItem {
9
9
  value: number | string;
10
10
  label: string;
11
11
  disabled?: boolean;
12
+ icon?: string;
12
13
  children?: TreeItem[];
13
14
  }
14
15
  export declare function createListCollection<T extends ListItem>(items: T[]): ListCollection<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -67,6 +67,7 @@
67
67
  "dependencies": {
68
68
  "@ark-ui/svelte": "^5.20.0",
69
69
  "@fontsource-variable/wix-madefor-text": "^5.2.8",
70
+ "@iconify/svelte": "^5.2.1",
70
71
  "runed": "^0.37.1",
71
72
  "tailwind-merge": "^3.5.0",
72
73
  "tailwind-variants": "^3.2.2"
@@ -1,120 +0,0 @@
1
- <script lang="ts">
2
- import PhArrowLeft from '../../icons/PhArrowLeft.svelte';
3
- import PhArrowRight from '../../icons/PhArrowRight.svelte';
4
- import PhCheck from '../../icons/PhCheck.svelte';
5
- import PhImage from '../../icons/PhImage.svelte';
6
- import PhStar from '../../icons/PhStar.svelte';
7
- import { Carousel } from '@ark-ui/svelte/carousel';
8
- import type { CarouselRootProps } from '@ark-ui/svelte/carousel';
9
-
10
- interface ImageItem {
11
- id?: string | number;
12
- src: string;
13
- alt?: string;
14
- is_primary?: boolean;
15
- position?: number;
16
- }
17
-
18
- interface Props extends Omit<CarouselRootProps, 'slideCount'> {
19
- images: ImageItem[];
20
- indicator?: boolean;
21
- selectable?: boolean;
22
- selectedIds?: (string | number)[];
23
- onSetStar?: (id: string | number) => void;
24
- }
25
-
26
- let {
27
- images,
28
- indicator = false,
29
- selectable = false,
30
- selectedIds = $bindable([]),
31
- onSetStar,
32
- ...rootProps
33
- }: Props = $props();
34
-
35
- function toggleSelect(id: string | number) {
36
- if (selectedIds.includes(id)) {
37
- selectedIds = selectedIds.filter((i) => i !== id);
38
- } else {
39
- selectedIds = [...selectedIds, id];
40
- }
41
- }
42
- </script>
43
-
44
- {#if images.length === 0}
45
- <div
46
- class="flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed py-12 text-center text-ink-dim"
47
- >
48
- <PhImage class="size-10 opacity-40" />
49
- <p class="text-sm">No images yet.</p>
50
- </div>
51
- {:else}
52
- <Carousel.Root slideCount={images.length} {...rootProps}>
53
- <Carousel.Control class="flex items-center gap-2">
54
- <Carousel.PrevTrigger
55
- class="inline-flex size-9 items-center justify-center rounded-md border bg-surface-1 shadow-sm hover:bg-surface-2 active:bg-surface-3 disabled:opacity-50"
56
- >
57
- <PhArrowLeft class="size-4" />
58
- </Carousel.PrevTrigger>
59
- <Carousel.ItemGroup class="flex flex-1 overflow-hidden rounded-lg">
60
- {#each images as image, index (image.id ?? index)}
61
- {@const key = image.id ?? index}
62
- {@const isSelected = selectable && selectedIds.includes(key)}
63
- <Carousel.Item {index} class="min-w-0 flex-[0_0_100%]">
64
- <div class="group/slide relative">
65
- <img
66
- src={image.src}
67
- alt={image.alt ?? ''}
68
- class="aspect-square w-full rounded-lg bg-surface-2 object-contain"
69
- />
70
- {#if onSetStar && image.id != null}
71
- <button
72
- class="absolute top-2 left-2 z-10 transition-opacity {image.is_primary
73
- ? 'opacity-100'
74
- : 'opacity-0 group-hover/slide:opacity-100'}"
75
- title={image.is_primary ? 'Primary image' : 'Set as primary'}
76
- onclick={() => onSetStar(image.id!)}
77
- >
78
- <PhStar
79
- class="size-5 drop-shadow {image.is_primary
80
- ? 'fill-yellow-400 text-yellow-400'
81
- : 'text-white/70 hover:text-yellow-300'}"
82
- />
83
- </button>
84
- {/if}
85
- {#if selectable}
86
- <button
87
- class="absolute top-2 right-2 z-10 flex size-6 items-center justify-center rounded-full border-2 transition-all {isSelected
88
- ? 'border-primary bg-primary text-white opacity-100'
89
- : 'border-white/80 bg-black/40 opacity-0 group-hover/slide:opacity-100'}"
90
- onclick={() => toggleSelect(key)}
91
- >
92
- {#if isSelected}
93
- <PhCheck class="size-3.5" />
94
- {/if}
95
- </button>
96
- {/if}
97
- </div>
98
- </Carousel.Item>
99
- {/each}
100
- </Carousel.ItemGroup>
101
- <Carousel.NextTrigger
102
- class="inline-flex size-9 items-center justify-center rounded-md border bg-surface-1 shadow-sm hover:bg-surface-2 active:bg-surface-3 disabled:opacity-50"
103
- >
104
- <PhArrowRight class="size-4" />
105
- </Carousel.NextTrigger>
106
- </Carousel.Control>
107
- {#if indicator}
108
- <Carousel.IndicatorGroup class="mt-2 flex justify-center gap-2">
109
- {#each images as image, index (index)}
110
- <Carousel.Indicator
111
- {index}
112
- class="h-15 w-15 cursor-pointer overflow-hidden rounded-sm border-2 border-transparent opacity-60 transition-all data-current:border-primary data-current:opacity-100"
113
- >
114
- <img src={image.src} alt={image.alt ?? ''} class="h-full w-full object-cover" />
115
- </Carousel.Indicator>
116
- {/each}
117
- </Carousel.IndicatorGroup>
118
- {/if}
119
- </Carousel.Root>
120
- {/if}
@@ -1,18 +0,0 @@
1
- import type { CarouselRootProps } from '@ark-ui/svelte/carousel';
2
- interface ImageItem {
3
- id?: string | number;
4
- src: string;
5
- alt?: string;
6
- is_primary?: boolean;
7
- position?: number;
8
- }
9
- interface Props extends Omit<CarouselRootProps, 'slideCount'> {
10
- images: ImageItem[];
11
- indicator?: boolean;
12
- selectable?: boolean;
13
- selectedIds?: (string | number)[];
14
- onSetStar?: (id: string | number) => void;
15
- }
16
- declare const Carouselbackup: import("svelte").Component<Props, {}, "selectedIds">;
17
- type Carouselbackup = ReturnType<typeof Carouselbackup>;
18
- export default Carouselbackup;