@stubber/ui 1.8.2 → 1.9.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.
@@ -0,0 +1,29 @@
1
+ <script>import emblaCarouselSvelte from "embla-carousel-svelte";
2
+ import { getEmblaContext } from "./context.js";
3
+ import { cn } from "../../utils/shadcn-utils.js";
4
+ let className = void 0;
5
+ export { className as class };
6
+ const { orientation, options, plugins, onInit } = getEmblaContext("<Carousel.Content/>");
7
+ </script>
8
+
9
+ <div
10
+ class="overflow-hidden"
11
+ use:emblaCarouselSvelte={{
12
+ options: {
13
+ container: "[data-embla-container]",
14
+ slides: "[data-embla-slide]",
15
+ ...$options,
16
+ axis: $orientation === "horizontal" ? "x" : "y",
17
+ },
18
+ plugins: $plugins,
19
+ }}
20
+ on:emblaInit={onInit}
21
+ >
22
+ <div
23
+ class={cn("flex", $orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className)}
24
+ data-embla-container=""
25
+ {...$$restProps}
26
+ >
27
+ <slot />
28
+ </div>
29
+ </div>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ declare const __propDef: {
4
+ props: HTMLAttributes<HTMLDivElement>;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {
9
+ default: {};
10
+ };
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
13
+ };
14
+ export type CarouselContentProps = typeof __propDef.props;
15
+ export type CarouselContentEvents = typeof __propDef.events;
16
+ export type CarouselContentSlots = typeof __propDef.slots;
17
+ export default class CarouselContent extends SvelteComponent<CarouselContentProps, CarouselContentEvents, CarouselContentSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,20 @@
1
+ <script>import { getEmblaContext } from "./context.js";
2
+ import { cn } from "../../utils/shadcn-utils.js";
3
+ let className = void 0;
4
+ export { className as class };
5
+ const { orientation } = getEmblaContext("<Carousel.Item/>");
6
+ </script>
7
+
8
+ <div
9
+ role="group"
10
+ aria-roledescription="slide"
11
+ class={cn(
12
+ "min-w-0 shrink-0 grow-0 basis-full",
13
+ $orientation === "horizontal" ? "pl-4" : "pt-4",
14
+ className
15
+ )}
16
+ data-embla-slide=""
17
+ {...$$restProps}
18
+ >
19
+ <slot />
20
+ </div>
@@ -0,0 +1,19 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ declare const __propDef: {
4
+ props: HTMLAttributes<HTMLDivElement>;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {
9
+ default: {};
10
+ };
11
+ exports?: {} | undefined;
12
+ bindings?: string | undefined;
13
+ };
14
+ export type CarouselItemProps = typeof __propDef.props;
15
+ export type CarouselItemEvents = typeof __propDef.events;
16
+ export type CarouselItemSlots = typeof __propDef.slots;
17
+ export default class CarouselItem extends SvelteComponent<CarouselItemProps, CarouselItemEvents, CarouselItemSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,28 @@
1
+ <script>import { getEmblaContext } from "./context.js";
2
+ import { cn } from "../../utils/shadcn-utils.js";
3
+ import { Button } from "../button/index.js";
4
+ let className = void 0;
5
+ export { className as class };
6
+ export let variant = "outline";
7
+ export let size = "icon";
8
+ const { orientation, canScrollNext, scrollNext, handleKeyDown } = getEmblaContext("<Carousel.Next/>");
9
+ </script>
10
+
11
+ <Button
12
+ {variant}
13
+ {size}
14
+ class={cn(
15
+ "absolute h-8 w-8 touch-manipulation rounded-full",
16
+ $orientation === "horizontal"
17
+ ? "-right-12 top-1/2 -translate-y-1/2"
18
+ : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
19
+ className
20
+ )}
21
+ disabled={!$canScrollNext}
22
+ on:click={scrollNext}
23
+ on:keydown={handleKeyDown}
24
+ {...$$restProps}
25
+ >
26
+ <i class="far fa-arrow-right h-4 w-4" />
27
+ <span class="sr-only">Next slide</span>
28
+ </Button>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Props } from "../button/index.js";
3
+ declare const __propDef: {
4
+ props: Props;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ exports?: {} | undefined;
10
+ bindings?: string | undefined;
11
+ };
12
+ export type CarouselNextProps = typeof __propDef.props;
13
+ export type CarouselNextEvents = typeof __propDef.events;
14
+ export type CarouselNextSlots = typeof __propDef.slots;
15
+ export default class CarouselNext extends SvelteComponent<CarouselNextProps, CarouselNextEvents, CarouselNextSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,28 @@
1
+ <script>import { getEmblaContext } from "./context.js";
2
+ import { cn } from "../../utils/shadcn-utils.js";
3
+ import { Button } from "../button/index.js";
4
+ let className = void 0;
5
+ export { className as class };
6
+ export let variant = "outline";
7
+ export let size = "icon";
8
+ const { orientation, canScrollPrev, scrollPrev, handleKeyDown } = getEmblaContext("<Carousel.Previous/>");
9
+ </script>
10
+
11
+ <Button
12
+ {variant}
13
+ {size}
14
+ class={cn(
15
+ "absolute h-8 w-8 touch-manipulation rounded-full",
16
+ $orientation === "horizontal"
17
+ ? "-left-12 top-1/2 -translate-y-1/2"
18
+ : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
19
+ className
20
+ )}
21
+ disabled={!$canScrollPrev}
22
+ on:click={scrollPrev}
23
+ on:keydown={handleKeyDown}
24
+ {...$$restProps}
25
+ >
26
+ <i class="far fa-arrow-left h-4 w-4" />
27
+ <span class="sr-only">Previous slide</span>
28
+ </Button>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type Props } from "../button/index.js";
3
+ declare const __propDef: {
4
+ props: Props;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ exports?: {} | undefined;
10
+ bindings?: string | undefined;
11
+ };
12
+ export type CarouselPreviousProps = typeof __propDef.props;
13
+ export type CarouselPreviousEvents = typeof __propDef.events;
14
+ export type CarouselPreviousSlots = typeof __propDef.slots;
15
+ export default class CarouselPrevious extends SvelteComponent<CarouselPreviousProps, CarouselPreviousEvents, CarouselPreviousSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,85 @@
1
+ <script>import { writable } from "svelte/store";
2
+ import { onDestroy } from "svelte";
3
+ import { setEmblaContext } from "./context.js";
4
+ import { cn } from "../../utils/shadcn-utils.js";
5
+ export let opts = {};
6
+ export let plugins = [];
7
+ export let api = void 0;
8
+ export let orientation = "horizontal";
9
+ let className = void 0;
10
+ export { className as class };
11
+ const apiStore = writable(void 0);
12
+ const orientationStore = writable(orientation);
13
+ const canScrollPrev = writable(false);
14
+ const canScrollNext = writable(false);
15
+ const optionsStore = writable(opts);
16
+ const pluginStore = writable(plugins);
17
+ const scrollSnapsStore = writable([]);
18
+ const selectedIndexStore = writable(0);
19
+ $: orientationStore.set(orientation);
20
+ $: pluginStore.set(plugins);
21
+ $: optionsStore.set(opts);
22
+ function scrollPrev() {
23
+ api?.scrollPrev();
24
+ }
25
+ function scrollNext() {
26
+ api?.scrollNext();
27
+ }
28
+ function scrollTo(index, jump) {
29
+ api?.scrollTo(index, jump);
30
+ }
31
+ function onSelect(api2) {
32
+ if (!api2) return;
33
+ canScrollPrev.set(api2.canScrollPrev());
34
+ canScrollNext.set(api2.canScrollNext());
35
+ selectedIndexStore.set(api2.selectedScrollSnap());
36
+ }
37
+ $: if (api) {
38
+ onSelect(api);
39
+ api.on("select", onSelect);
40
+ api.on("reInit", onSelect);
41
+ }
42
+ function handleKeyDown(e) {
43
+ if (e.key === "ArrowLeft") {
44
+ e.preventDefault();
45
+ scrollPrev();
46
+ } else if (e.key === "ArrowRight") {
47
+ e.preventDefault();
48
+ scrollNext();
49
+ }
50
+ }
51
+ setEmblaContext({
52
+ api: apiStore,
53
+ scrollPrev,
54
+ scrollNext,
55
+ orientation: orientationStore,
56
+ canScrollNext,
57
+ canScrollPrev,
58
+ handleKeyDown,
59
+ options: optionsStore,
60
+ plugins: pluginStore,
61
+ onInit,
62
+ scrollSnaps: scrollSnapsStore,
63
+ selectedIndex: selectedIndexStore,
64
+ scrollTo
65
+ });
66
+ function onInit(event) {
67
+ api = event.detail;
68
+ apiStore.set(api);
69
+ scrollSnapsStore.set(api.scrollSnapList());
70
+ }
71
+ onDestroy(() => {
72
+ api?.off("select", onSelect);
73
+ });
74
+ </script>
75
+
76
+ <div
77
+ class={cn("relative", className)}
78
+ on:mouseenter
79
+ on:mouseleave
80
+ role="region"
81
+ aria-roledescription="carousel"
82
+ {...$$restProps}
83
+ >
84
+ <slot />
85
+ </div>
@@ -0,0 +1,22 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type CarouselProps } from "./context.js";
3
+ declare const __propDef: {
4
+ props: CarouselProps;
5
+ events: {
6
+ mouseenter: MouseEvent;
7
+ mouseleave: MouseEvent;
8
+ } & {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ exports?: {} | undefined;
15
+ bindings?: string | undefined;
16
+ };
17
+ type CarouselProps_ = typeof __propDef.props;
18
+ export { CarouselProps_ as CarouselProps };
19
+ export type CarouselEvents = typeof __propDef.events;
20
+ export type CarouselSlots = typeof __propDef.slots;
21
+ export default class Carousel extends SvelteComponent<CarouselProps_, CarouselEvents, CarouselSlots> {
22
+ }
@@ -0,0 +1,32 @@
1
+ import type { EmblaCarouselSvelteType } from "embla-carousel-svelte";
2
+ import type emblaCarouselSvelte from "embla-carousel-svelte";
3
+ import type { HTMLAttributes } from "svelte/elements";
4
+ import type { Readable, Writable } from "svelte/store";
5
+ export type CarouselAPI = NonNullable<NonNullable<EmblaCarouselSvelteType["$$_attributes"]>["on:emblaInit"]> extends (evt: CustomEvent<infer CarouselAPI>) => void ? CarouselAPI : never;
6
+ type EmblaCarouselConfig = NonNullable<Parameters<typeof emblaCarouselSvelte>[1]>;
7
+ export type CarouselOptions = EmblaCarouselConfig["options"];
8
+ export type CarouselPlugins = EmblaCarouselConfig["plugins"];
9
+ export type CarouselProps = {
10
+ opts?: CarouselOptions;
11
+ plugins?: CarouselPlugins;
12
+ api?: CarouselAPI;
13
+ orientation?: "horizontal" | "vertical";
14
+ } & HTMLAttributes<HTMLDivElement>;
15
+ type EmblaContext = {
16
+ api: Writable<CarouselAPI | undefined>;
17
+ orientation: Writable<"horizontal" | "vertical">;
18
+ scrollNext: () => void;
19
+ scrollPrev: () => void;
20
+ canScrollNext: Readable<boolean>;
21
+ canScrollPrev: Readable<boolean>;
22
+ handleKeyDown: (e: KeyboardEvent) => void;
23
+ options: Writable<CarouselOptions>;
24
+ plugins: Writable<CarouselPlugins>;
25
+ onInit: (e: CustomEvent<CarouselAPI>) => void;
26
+ scrollTo: (index: number, jump?: boolean) => void;
27
+ scrollSnaps: Readable<number[]>;
28
+ selectedIndex: Readable<number>;
29
+ };
30
+ export declare function setEmblaContext(config: EmblaContext): EmblaContext;
31
+ export declare function getEmblaContext(name?: string): EmblaContext;
32
+ export {};
@@ -0,0 +1,12 @@
1
+ import { getContext, hasContext, setContext } from "svelte";
2
+ const EMBLA_CAROUSEL_CONTEXT = Symbol("EMBLA_CAROUSEL_CONTEXT");
3
+ export function setEmblaContext(config) {
4
+ setContext(EMBLA_CAROUSEL_CONTEXT, config);
5
+ return config;
6
+ }
7
+ export function getEmblaContext(name = "This component") {
8
+ if (!hasContext(EMBLA_CAROUSEL_CONTEXT)) {
9
+ throw new Error(`${name} must be used within a <Carousel.Root> component`);
10
+ }
11
+ return getContext(EMBLA_CAROUSEL_CONTEXT);
12
+ }
@@ -0,0 +1,5 @@
1
+ export { default as Root } from "./carousel.svelte";
2
+ export { default as Content } from "./carousel-content.svelte";
3
+ export { default as Item } from "./carousel-item.svelte";
4
+ export { default as Previous } from "./carousel-previous.svelte";
5
+ export { default as Next } from "./carousel-next.svelte";
@@ -0,0 +1,5 @@
1
+ export { default as Root } from "./carousel.svelte";
2
+ export { default as Content } from "./carousel-content.svelte";
3
+ export { default as Item } from "./carousel-item.svelte";
4
+ export { default as Previous } from "./carousel-previous.svelte";
5
+ export { default as Next } from "./carousel-next.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stubber/ui",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && pnpm run package && node ./fix_dts_imports.js",
@@ -68,6 +68,7 @@
68
68
  "bits-ui": "^0.22.0",
69
69
  "clsx": "^2.1.1",
70
70
  "cmdk-sv": "^0.0.18",
71
+ "embla-carousel-svelte": "^8.6.0",
71
72
  "svelte-popperjs": "^1.3.2",
72
73
  "svelte-select": "^5.6.0",
73
74
  "svelte-sonner": "^0.3.28",