compote-ui 0.14.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.
- package/dist/components/card/card-header.svelte +1 -1
- package/dist/components/card/card-title.svelte +1 -1
- package/dist/components/carousel/carousel-control.svelte +22 -0
- package/dist/components/carousel/carousel-control.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-indicator-group.svelte +19 -0
- package/dist/components/carousel/carousel-indicator-group.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-indicator.svelte +25 -0
- package/dist/components/carousel/carousel-indicator.svelte.d.ts +9 -0
- package/dist/components/carousel/carousel-item-group.svelte +22 -0
- package/dist/components/carousel/carousel-item-group.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-item.svelte +16 -0
- package/dist/components/carousel/carousel-item.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-next-trigger.svelte +27 -0
- package/dist/components/carousel/carousel-next-trigger.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-prev-trigger.svelte +27 -0
- package/dist/components/carousel/carousel-prev-trigger.svelte.d.ts +8 -0
- package/dist/components/carousel/carousel-root.svelte +19 -0
- package/dist/components/carousel/carousel-root.svelte.d.ts +8 -0
- package/dist/components/carousel/index.d.ts +8 -0
- package/dist/components/carousel/index.js +8 -0
- package/dist/components/tree-view/tree-view.svelte +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/collections.d.ts +1 -0
- package/package.json +7 -6
- package/dist/components/carousel/carousel.svelte +0 -120
- package/dist/components/carousel/carousel.svelte.d.ts +0 -19
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
let { class: className, children, ...rest }: HTMLAttributes<HTMLDivElement> = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<div class={cn('flex flex-col gap-1.5
|
|
8
|
+
<div class={cn('flex flex-col gap-1.5 pb-4', className)} {...rest}>
|
|
9
9
|
{@render children?.()}
|
|
10
10
|
</div>
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
let { class: className, children, ...rest }: HTMLAttributes<HTMLHeadingElement> = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<h3 class={cn('text-
|
|
8
|
+
<h3 class={cn('text-lg font-semibold', className)} {...rest}>
|
|
9
9
|
{@render children?.()}
|
|
10
10
|
</h3>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselControlProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}: CarouselControlProps & { children?: Snippet } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Carousel.Control
|
|
15
|
+
class={cn(
|
|
16
|
+
'flex items-center gap-2 data-[justify=center]:justify-center data-[orientation=vertical]:flex-col',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...rest}
|
|
20
|
+
>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</Carousel.Control>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselControlProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselControlProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselControl: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselControl = ReturnType<typeof CarouselControl>;
|
|
8
|
+
export default CarouselControl;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselIndicatorGroupProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}: CarouselIndicatorGroupProps & { children?: Snippet } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Carousel.IndicatorGroup
|
|
15
|
+
class={cn('flex justify-center gap-2 data-[orientation=vertical]:flex-col', className)}
|
|
16
|
+
{...rest}
|
|
17
|
+
>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</Carousel.IndicatorGroup>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselIndicatorGroupProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselIndicatorGroupProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselIndicatorGroup: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselIndicatorGroup = ReturnType<typeof CarouselIndicatorGroup>;
|
|
8
|
+
export default CarouselIndicatorGroup;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselIndicatorProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
thumbnail = false,
|
|
11
|
+
...rest
|
|
12
|
+
}: CarouselIndicatorProps & { children?: Snippet; thumbnail?: boolean } = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Carousel.Indicator
|
|
16
|
+
class={cn(
|
|
17
|
+
thumbnail
|
|
18
|
+
? 'h-14 w-14 cursor-pointer overflow-hidden rounded-sm border-2 border-transparent opacity-60 transition-all data-current:border-primary data-current:opacity-100 [&_img]:h-full [&_img]:w-full [&_img]:object-cover'
|
|
19
|
+
: 'size-2 cursor-pointer rounded-full border-0 bg-surface-3 p-0 data-current:bg-primary',
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{@render children?.()}
|
|
25
|
+
</Carousel.Indicator>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CarouselIndicatorProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselIndicatorProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
thumbnail?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const CarouselIndicator: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type CarouselIndicator = ReturnType<typeof CarouselIndicator>;
|
|
9
|
+
export default CarouselIndicator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselItemGroupProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}: CarouselItemGroupProps & { children?: Snippet } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Carousel.ItemGroup
|
|
15
|
+
class={cn(
|
|
16
|
+
'flex min-w-0 flex-1 overflow-hidden rounded-lg [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...rest}
|
|
20
|
+
>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</Carousel.ItemGroup>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselItemGroupProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselItemGroupProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselItemGroup: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselItemGroup = ReturnType<typeof CarouselItemGroup>;
|
|
8
|
+
export default CarouselItemGroup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselItemProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}: CarouselItemProps & { children?: Snippet } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Carousel.Item class={cn('min-w-0 flex-[0_0_100%]', className)} {...rest}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</Carousel.Item>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselItemProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselItemProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselItem: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselItem = ReturnType<typeof CarouselItem>;
|
|
8
|
+
export default CarouselItem;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import PhArrowRight from '../../icons/PhArrowRight.svelte';
|
|
3
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import type { CarouselNextTriggerProps } from '@ark-ui/svelte/carousel';
|
|
5
|
+
import { cn } from 'tailwind-variants';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
...rest
|
|
12
|
+
}: CarouselNextTriggerProps & { children?: Snippet } = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Carousel.NextTrigger
|
|
16
|
+
class={cn(
|
|
17
|
+
'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',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{#if children}
|
|
23
|
+
{@render children()}
|
|
24
|
+
{:else}
|
|
25
|
+
<PhArrowRight class="size-4" />
|
|
26
|
+
{/if}
|
|
27
|
+
</Carousel.NextTrigger>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselNextTriggerProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselNextTriggerProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselNextTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselNextTrigger = ReturnType<typeof CarouselNextTrigger>;
|
|
8
|
+
export default CarouselNextTrigger;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import PhArrowLeft from '../../icons/PhArrowLeft.svelte';
|
|
3
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import type { CarouselPrevTriggerProps } from '@ark-ui/svelte/carousel';
|
|
5
|
+
import { cn } from 'tailwind-variants';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
...rest
|
|
12
|
+
}: CarouselPrevTriggerProps & { children?: Snippet } = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Carousel.PrevTrigger
|
|
16
|
+
class={cn(
|
|
17
|
+
'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',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{#if children}
|
|
23
|
+
{@render children()}
|
|
24
|
+
{:else}
|
|
25
|
+
<PhArrowLeft class="size-4" />
|
|
26
|
+
{/if}
|
|
27
|
+
</Carousel.PrevTrigger>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselPrevTriggerProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselPrevTriggerProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselPrevTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselPrevTrigger = ReturnType<typeof CarouselPrevTrigger>;
|
|
8
|
+
export default CarouselPrevTrigger;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
3
|
+
import type { CarouselRootProps } from '@ark-ui/svelte/carousel';
|
|
4
|
+
import { cn } from 'tailwind-variants';
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}: CarouselRootProps & { children?: Snippet } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Carousel.Root
|
|
15
|
+
class={cn('flex flex-col gap-2 data-[orientation=vertical]:flex-row', className)}
|
|
16
|
+
{...rest}
|
|
17
|
+
>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</Carousel.Root>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CarouselRootProps } from '@ark-ui/svelte/carousel';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type $$ComponentProps = CarouselRootProps & {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const CarouselRoot: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CarouselRoot = ReturnType<typeof CarouselRoot>;
|
|
8
|
+
export default CarouselRoot;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Root } from './carousel-root.svelte';
|
|
2
|
+
export { default as Control } from './carousel-control.svelte';
|
|
3
|
+
export { default as PrevTrigger } from './carousel-prev-trigger.svelte';
|
|
4
|
+
export { default as NextTrigger } from './carousel-next-trigger.svelte';
|
|
5
|
+
export { default as ItemGroup } from './carousel-item-group.svelte';
|
|
6
|
+
export { default as Item } from './carousel-item.svelte';
|
|
7
|
+
export { default as IndicatorGroup } from './carousel-indicator-group.svelte';
|
|
8
|
+
export { default as Indicator } from './carousel-indicator.svelte';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Root } from './carousel-root.svelte';
|
|
2
|
+
export { default as Control } from './carousel-control.svelte';
|
|
3
|
+
export { default as PrevTrigger } from './carousel-prev-trigger.svelte';
|
|
4
|
+
export { default as NextTrigger } from './carousel-next-trigger.svelte';
|
|
5
|
+
export { default as ItemGroup } from './carousel-item-group.svelte';
|
|
6
|
+
export { default as Item } from './carousel-item.svelte';
|
|
7
|
+
export { default as IndicatorGroup } from './carousel-indicator-group.svelte';
|
|
8
|
+
export { default as Indicator } from './carousel-indicator.svelte';
|
|
@@ -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>
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { default as LinkButton } from './components/button/link-button.svelte';
|
|
|
3
3
|
export * as Card from './components/card';
|
|
4
4
|
export { loadImage, fileToDataUrl, cropImage, processImage } from './utils/image-processing';
|
|
5
5
|
export type { ProcessImageOptions, CropRegion } from './utils/image-processing';
|
|
6
|
-
export
|
|
6
|
+
export * as Carousel from './components/carousel';
|
|
7
7
|
export { default as Checkbox } from './components/checkbox/checkbox.svelte';
|
|
8
8
|
export { default as CheckboxGroup } from './components/checkbox/checkbox-group.svelte';
|
|
9
9
|
export { default as Combobox } from './components/combobox/combobox.svelte';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { default as Button } from './components/button/button.svelte';
|
|
|
3
3
|
export { default as LinkButton } from './components/button/link-button.svelte';
|
|
4
4
|
export * as Card from './components/card';
|
|
5
5
|
export { loadImage, fileToDataUrl, cropImage, processImage } from './utils/image-processing';
|
|
6
|
-
export
|
|
6
|
+
export * as Carousel from './components/carousel';
|
|
7
7
|
export { default as Checkbox } from './components/checkbox/checkbox.svelte';
|
|
8
8
|
export { default as CheckboxGroup } from './components/checkbox/checkbox-group.svelte';
|
|
9
9
|
export { default as Combobox } from './components/combobox/combobox.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compote-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"svelte": "^5.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@eslint/compat": "^2.0.
|
|
38
|
+
"@eslint/compat": "^2.0.4",
|
|
39
39
|
"@eslint/js": "^10.0.1",
|
|
40
40
|
"@iconify-json/ph": "^1.2.2",
|
|
41
41
|
"@sveltejs/adapter-auto": "^7.0.0",
|
|
42
|
-
"@sveltejs/kit": "^2.
|
|
42
|
+
"@sveltejs/kit": "^2.56.1",
|
|
43
43
|
"@sveltejs/package": "^2.5.7",
|
|
44
|
-
"@sveltejs/vite-plugin-svelte": "
|
|
44
|
+
"@sveltejs/vite-plugin-svelte": "6.2.4",
|
|
45
45
|
"@tailwindcss/vite": "^4.1.18",
|
|
46
46
|
"@types/node": "^22",
|
|
47
|
-
"eslint": "^10.0
|
|
47
|
+
"eslint": "^10.2.0",
|
|
48
48
|
"eslint-config-prettier": "^10.1.8",
|
|
49
|
-
"eslint-plugin-svelte": "^3.
|
|
49
|
+
"eslint-plugin-svelte": "^3.17.0",
|
|
50
50
|
"globals": "^17.4.0",
|
|
51
51
|
"prettier": "^3.8.1",
|
|
52
52
|
"prettier-plugin-svelte": "^3.4.1",
|
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
import { Carousel } from '@ark-ui/svelte/carousel';
|
|
2
|
-
import type { CarouselRootProps } from '@ark-ui/svelte/carousel';
|
|
3
|
-
interface ImageItem {
|
|
4
|
-
id?: string | number;
|
|
5
|
-
src: string;
|
|
6
|
-
alt?: string;
|
|
7
|
-
is_primary?: boolean;
|
|
8
|
-
position?: number;
|
|
9
|
-
}
|
|
10
|
-
interface Props extends Omit<CarouselRootProps, 'slideCount'> {
|
|
11
|
-
images: ImageItem[];
|
|
12
|
-
indicator?: boolean;
|
|
13
|
-
selectable?: boolean;
|
|
14
|
-
selectedIds?: (string | number)[];
|
|
15
|
-
onSetStar?: (id: string | number) => void;
|
|
16
|
-
}
|
|
17
|
-
declare const Carousel: import("svelte").Component<Props, {}, "selectedIds">;
|
|
18
|
-
type Carousel = ReturnType<typeof Carousel>;
|
|
19
|
-
export default Carousel;
|