@caseparts-org/caseblocks 0.0.57 → 0.0.59

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,17 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { CarouselProps } from './Carousel';
3
+ type ExtraArgs = {
4
+ slidesCount: number;
5
+ slideHeight: number;
6
+ colorful?: boolean;
7
+ };
8
+ type AllArgs = CarouselProps & ExtraArgs;
9
+ declare const meta: Meta<AllArgs>;
10
+ export default meta;
11
+ type Story = StoryObj<AllArgs>;
12
+ export declare const Basic: Story;
13
+ export declare const FastAutoplay: Story;
14
+ export declare const ManySlides: Story;
15
+ export declare const TallSlides: Story;
16
+ export declare const InteractionStopsAutoplay: Story;
17
+ export declare const ContinuousAutoplay: Story;
@@ -0,0 +1,171 @@
1
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
+ import { Carousel as s } from "./Carousel.js";
3
+ const p = (t, e, a = !0) => Array.from({ length: t }, (l, o) => {
4
+ const n = o * 60 % 360;
5
+ return /* @__PURE__ */ i(
6
+ "div",
7
+ {
8
+ style: {
9
+ height: e,
10
+ display: "flex",
11
+ alignItems: "center",
12
+ justifyContent: "center",
13
+ fontSize: 24,
14
+ fontWeight: 600,
15
+ background: a ? `hsl(${n} 70% 55%)` : "var(--color-neutrals-neutral-5,#888)",
16
+ color: "#fff",
17
+ borderRadius: 8,
18
+ margin: 8,
19
+ boxShadow: "0 2px 6px rgba(0,0,0,.2)"
20
+ },
21
+ children: [
22
+ "Slide ",
23
+ o + 1
24
+ ]
25
+ },
26
+ o
27
+ );
28
+ }), y = {
29
+ title: "Case Parts/Organisms/Carousel",
30
+ component: s,
31
+ tags: ["autodocs"],
32
+ render: (t) => {
33
+ const { slidesCount: e, slideHeight: a, colorful: l, ...o } = t;
34
+ return /* @__PURE__ */ r(
35
+ s,
36
+ {
37
+ ...o,
38
+ slides: p(e, a, l)
39
+ }
40
+ );
41
+ },
42
+ args: {
43
+ slidesCount: 5,
44
+ slideHeight: 160,
45
+ colorful: !0,
46
+ loop: !0,
47
+ autoplay: !0,
48
+ autoplayDelay: 4e3,
49
+ autoplayStopOnInteraction: !0
50
+ },
51
+ argTypes: {
52
+ slides: {
53
+ table: { disable: !0 },
54
+ description: "Generated internally from slidesCount."
55
+ },
56
+ slidesCount: {
57
+ name: "slidesCount",
58
+ control: { type: "number", min: 1, max: 20, step: 1 },
59
+ description: "Number of slides to generate dynamically."
60
+ },
61
+ slideHeight: {
62
+ control: { type: "number", min: 80, max: 600, step: 10 },
63
+ description: "Height (px) for each slide."
64
+ },
65
+ colorful: {
66
+ control: "boolean",
67
+ description: "Toggle colorful backgrounds."
68
+ },
69
+ loop: {
70
+ control: "boolean",
71
+ description: "Enable infinite looping."
72
+ },
73
+ autoplay: {
74
+ control: "boolean",
75
+ description: "Enable autoplay (uses embla-carousel-autoplay)."
76
+ },
77
+ autoplayDelay: {
78
+ control: { type: "number", min: 500, max: 1e4, step: 100 },
79
+ if: { arg: "autoplay" },
80
+ description: "Delay between automatic advances (ms)."
81
+ },
82
+ autoplayStopOnInteraction: {
83
+ control: "boolean",
84
+ if: { arg: "autoplay" },
85
+ description: "Whether user interaction stops autoplay."
86
+ },
87
+ className: { control: "text" },
88
+ hideAt: {
89
+ control: "object",
90
+ description: "Forwarded to HideAt (shape depends on your implementation)."
91
+ }
92
+ },
93
+ parameters: {
94
+ docs: {
95
+ description: {
96
+ component: `
97
+ A flexible Embla-based carousel.
98
+
99
+ Key props:
100
+ - slides: React.ReactNode[]
101
+ - loop: infinite wrap
102
+ - autoplay & autoplayDelay: timing via Autoplay plugin (loop only controls wrap)
103
+ - autoplayStopOnInteraction: stop autoplay after user navigation
104
+
105
+ Use the Playground story to experiment.`
106
+ }
107
+ }
108
+ }
109
+ }, d = {
110
+ name: "Basic (No Loop / No Autoplay)",
111
+ args: {
112
+ loop: !1,
113
+ autoplay: !1
114
+ }
115
+ }, m = {
116
+ name: "Fast Autoplay",
117
+ args: {
118
+ autoplay: !0,
119
+ autoplayDelay: 1200
120
+ }
121
+ }, g = {
122
+ name: "Many Slides",
123
+ args: {
124
+ slidesCount: 12,
125
+ autoplay: !1,
126
+ loop: !0
127
+ }
128
+ }, f = {
129
+ name: "Tall Slides",
130
+ args: {
131
+ slideHeight: 300,
132
+ autoplay: !1
133
+ }
134
+ }, b = {
135
+ name: "Interaction Stops Autoplay",
136
+ args: {
137
+ autoplay: !0,
138
+ autoplayDelay: 2500,
139
+ autoplayStopOnInteraction: !0
140
+ },
141
+ parameters: {
142
+ docs: {
143
+ description: {
144
+ story: "Shows how autoplay halts after user presses arrows or dots."
145
+ }
146
+ }
147
+ }
148
+ }, h = {
149
+ name: "Autoplay Ignores Interaction",
150
+ args: {
151
+ autoplay: !0,
152
+ autoplayStopOnInteraction: !1,
153
+ autoplayDelay: 2500
154
+ },
155
+ parameters: {
156
+ docs: {
157
+ description: {
158
+ story: "User interaction will not stop autoplay."
159
+ }
160
+ }
161
+ }
162
+ };
163
+ export {
164
+ d as Basic,
165
+ h as ContinuousAutoplay,
166
+ m as FastAutoplay,
167
+ b as InteractionStopsAutoplay,
168
+ g as ManySlides,
169
+ f as TallSlides,
170
+ y as default
171
+ };
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ export declare const PrevButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
3
+ export declare const NextButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
@@ -0,0 +1,8 @@
1
+ import "react/jsx-runtime";
2
+ import "../../atoms/Icon/Icon.js";
3
+ import { N as e, P as i } from "../../CarouselArrowButtons-DMKru3f7.js";
4
+ import "../../clsx-OuTLNxxd.js";
5
+ export {
6
+ e as NextButton,
7
+ i as PrevButton
8
+ };
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { EmblaCarouselType } from 'embla-carousel';
3
+ export interface UseDotButtonReturn {
4
+ selectedIndex: number;
5
+ scrollSnaps: number[];
6
+ onDotButtonClick: (_index: number) => void;
7
+ }
8
+ export declare const useDotButton: (emblaApi: EmblaCarouselType | undefined) => UseDotButtonReturn;
9
+ export interface DotButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
+ children?: React.ReactNode;
11
+ }
12
+ export declare const DotButton: React.FC<DotButtonProps>;
@@ -0,0 +1,25 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useState as r, useCallback as e, useEffect as I } from "react";
3
+ const D = (t) => {
4
+ const [s, u] = r(0), [S, l] = r([]), d = e(
5
+ (o) => {
6
+ t == null || t.scrollTo(o);
7
+ },
8
+ [t]
9
+ ), c = e((o) => {
10
+ l(o.scrollSnapList());
11
+ }, []), n = e((o) => {
12
+ u(o.selectedScrollSnap());
13
+ }, []);
14
+ return I(() => {
15
+ t && (c(t), n(t), t.on("reInit", c).on("reInit", n).on("select", n));
16
+ }, [t, c, n]), {
17
+ selectedIndex: s,
18
+ scrollSnaps: S,
19
+ onDotButtonClick: d
20
+ };
21
+ }, k = ({ children: t, ...s }) => /* @__PURE__ */ f("button", { type: "button", ...s, children: t });
22
+ export {
23
+ k as DotButton,
24
+ D as useDotButton
25
+ };
@@ -0,0 +1,8 @@
1
+ import { EmblaCarouselType } from 'embla-carousel';
2
+ export interface UsePrevNextButtonsReturn {
3
+ prevBtnDisabled: boolean;
4
+ nextBtnDisabled: boolean;
5
+ onPrevButtonClick: () => void;
6
+ onNextButtonClick: () => void;
7
+ }
8
+ export declare const usePrevNextButtons: (emblaApi: EmblaCarouselType | undefined) => UsePrevNextButtonsReturn;
@@ -0,0 +1,21 @@
1
+ import { useState as s, useCallback as o, useEffect as N } from "react";
2
+ const d = (t) => {
3
+ const [e, c] = s(!0), [u, x] = s(!0), B = o(() => {
4
+ t == null || t.scrollPrev();
5
+ }, [t]), v = o(() => {
6
+ t == null || t.scrollNext();
7
+ }, [t]), n = o((r) => {
8
+ c(!r.canScrollPrev()), x(!r.canScrollNext());
9
+ }, []);
10
+ return N(() => {
11
+ t && (n(t), t.on("reInit", n).on("select", n));
12
+ }, [t, n]), {
13
+ prevBtnDisabled: e,
14
+ nextBtnDisabled: u,
15
+ onPrevButtonClick: B,
16
+ onNextButtonClick: v
17
+ };
18
+ };
19
+ export {
20
+ d as usePrevNextButtons
21
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.57",
4
+ "version": "0.0.59",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -40,7 +40,9 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=18.3.1 <20.0.0",
43
- "react-dom": ">=18.3.1 <20.0.0"
43
+ "react-dom": ">=18.3.1 <20.0.0",
44
+ "embla-carousel-autoplay": "^8.0.0",
45
+ "embla-carousel-react": "^8.0.0"
44
46
  },
45
47
  "devDependencies": {
46
48
  "@chromatic-com/storybook": "^4.0.1",
@@ -52,6 +54,8 @@
52
54
  "@types/react": "^18.3.12",
53
55
  "@types/react-dom": "^18.3.1",
54
56
  "@vitejs/plugin-react-swc": "^3.5.0",
57
+ "embla-carousel-autoplay": "^8.6.0",
58
+ "embla-carousel-react": "^8.6.0",
55
59
  "eslint": "^9.13.0",
56
60
  "eslint-config-prettier": "^9.1.0",
57
61
  "eslint-plugin-react-hooks": "^5.0.0",