@caseparts-org/caseblocks 0.0.84 → 0.0.85

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 @@
1
+ ._container_aum2v_1{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;overflow-x:auto;width:100%;-webkit-overflow-scrolling:touch;cursor:grab;-webkit-user-select:none;user-select:none;overscroll-behavior:contain;touch-action:pan-x}._dragging_aum2v_14{cursor:grabbing}._scrollVisibility--false_aum2v_19{scrollbar-width:none;-ms-overflow-style:none}._scrollVisibility--false_aum2v_19::-webkit-scrollbar{display:none}
@@ -0,0 +1,6 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export interface HorizontalScrollProps extends PropsWithChildren {
3
+ className?: string;
4
+ showScrollbar?: boolean;
5
+ }
6
+ export declare function HorizontalScroll({ className, showScrollbar, children }: HorizontalScrollProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { useRef as a, useState as v } from "react";
3
+ import { c as x } from "../../clsx-OuTLNxxd.js";
4
+ import '../../assets/HorizontalScroll.css';const h = "_container_aum2v_1", b = "_dragging_aum2v_14", l = {
5
+ container: h,
6
+ dragging: b,
7
+ "scrollVisibility--false": "_scrollVisibility--false_aum2v_19"
8
+ };
9
+ function S({
10
+ className: u,
11
+ showScrollbar: f = !1,
12
+ children: g
13
+ }) {
14
+ const r = a(null), [o, c] = v(!1), e = a({ x: 0, scroll: 0 }), d = (t) => {
15
+ r.current && (c(!0), e.current.x = t.clientX, e.current.scroll = r.current.scrollLeft);
16
+ }, m = (t) => {
17
+ if (!o || !r.current) return;
18
+ const n = t.clientX - e.current.x;
19
+ r.current.scrollLeft = e.current.scroll - n;
20
+ }, s = () => {
21
+ r.current && c(!1);
22
+ }, _ = (t) => {
23
+ const n = r.current;
24
+ if (!n || !(n.scrollWidth > n.clientWidth)) return;
25
+ const i = Math.abs(t.deltaY) >= Math.abs(t.deltaX) && t.deltaY !== 0 ? t.deltaY : t.deltaX;
26
+ i !== 0 ? (t.preventDefault(), n.scrollLeft += i) : t.preventDefault();
27
+ };
28
+ return /* @__PURE__ */ p(
29
+ "div",
30
+ {
31
+ ref: r,
32
+ className: x(
33
+ u,
34
+ l.container,
35
+ l[`scrollVisibility--${f}`],
36
+ o ? l.dragging : ""
37
+ ),
38
+ onPointerDown: d,
39
+ onPointerMove: m,
40
+ onPointerLeave: s,
41
+ onPointerUp: s,
42
+ onWheel: _,
43
+ children: g
44
+ }
45
+ );
46
+ }
47
+ export {
48
+ S as HorizontalScroll
49
+ };
@@ -0,0 +1,18 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ interface DemoArgs {
3
+ showScrollbar: boolean;
4
+ itemCount: number;
5
+ itemWidth: number;
6
+ itemHeight: number;
7
+ gap: number;
8
+ rounded: boolean;
9
+ gradient: boolean;
10
+ }
11
+ type StoryArgs = DemoArgs;
12
+ declare const meta: Meta<StoryArgs>;
13
+ export default meta;
14
+ type Story = StoryObj<StoryArgs>;
15
+ export declare const Playground: Story;
16
+ export declare const WithScrollbar: Story;
17
+ export declare const DenseSmallItems: Story;
18
+ export declare const LargeCards: Story;
@@ -0,0 +1,135 @@
1
+ import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
+ import { HorizontalScroll as t } from "./HorizontalScroll.js";
3
+ const b = {
4
+ title: "Case Parts/Atoms/HorizontalScroll",
5
+ component: t,
6
+ tags: ["autodocs"],
7
+ parameters: {
8
+ layout: "fullscreen",
9
+ docs: {
10
+ description: {
11
+ component: `
12
+ A drag + wheel enabled horizontal scrolling container.
13
+
14
+ Features:
15
+ - Pointer drag (mouse / touch) horizontal scrolling.
16
+ - Converts vertical mouse wheel motion to horizontal scrolling.
17
+ - Optional native scrollbar visibility via showScrollbar.
18
+
19
+ Use for carousels, chip lists, card rails, horizontally overflowing panels.
20
+ `.trim()
21
+ }
22
+ }
23
+ },
24
+ argTypes: {
25
+ showScrollbar: {
26
+ control: { type: "boolean" },
27
+ description: "Show native scrollbar when overflow exists."
28
+ },
29
+ itemCount: {
30
+ control: { type: "range", min: 3, max: 60, step: 1 },
31
+ description: "Number of demo items rendered."
32
+ },
33
+ itemWidth: {
34
+ control: { type: "number", min: 40, max: 320, step: 10 },
35
+ description: "Width of each item (px)."
36
+ },
37
+ itemHeight: {
38
+ control: { type: "number", min: 30, max: 240, step: 5 },
39
+ description: "Height of each item (px)."
40
+ },
41
+ gap: {
42
+ control: { type: "number", min: 0, max: 48, step: 2 },
43
+ description: "Gap between items (px)."
44
+ },
45
+ rounded: {
46
+ control: { type: "boolean" },
47
+ description: "Apply border radius to items."
48
+ },
49
+ gradient: {
50
+ control: { type: "boolean" },
51
+ description: "Use gradient background instead of solid."
52
+ }
53
+ },
54
+ args: {
55
+ showScrollbar: !1,
56
+ itemCount: 20,
57
+ itemWidth: 120,
58
+ itemHeight: 80,
59
+ gap: 12,
60
+ rounded: !0,
61
+ gradient: !0
62
+ }
63
+ }, i = (e) => {
64
+ const { itemCount: a, itemWidth: s, itemHeight: n, gap: d, rounded: c, gradient: h } = e;
65
+ return Array.from({ length: a }, (p, m) => {
66
+ const l = m + 1;
67
+ return /* @__PURE__ */ r(
68
+ "div",
69
+ {
70
+ style: {
71
+ flex: "0 0 auto",
72
+ width: s,
73
+ height: n,
74
+ marginRight: d,
75
+ borderRadius: c ? 8 : 0,
76
+ background: h ? "linear-gradient(135deg,#4F46E5,#6366F1)" : "#4F46E5",
77
+ color: "#fff",
78
+ display: "flex",
79
+ alignItems: "center",
80
+ justifyContent: "center",
81
+ fontSize: Math.max(12, Math.min(24, n / 3)),
82
+ fontWeight: 600,
83
+ userSelect: "none",
84
+ boxShadow: "0 2px 6px rgba(0,0,0,0.25)"
85
+ },
86
+ children: l
87
+ },
88
+ l
89
+ );
90
+ });
91
+ }, y = {
92
+ name: "Playground",
93
+ render: (e) => /* @__PURE__ */ o("div", { style: { padding: 24 }, children: [
94
+ /* @__PURE__ */ r("h3", { style: { margin: "0 0 12px" }, children: "HorizontalScroll Playground" }),
95
+ /* @__PURE__ */ r("p", { style: { margin: "0 0 16px", fontSize: 14, color: "#555" }, children: "Drag horizontally or use the mouse wheel. Tweak values in Controls." }),
96
+ /* @__PURE__ */ r(t, { showScrollbar: e.showScrollbar, children: i(e) })
97
+ ] })
98
+ }, f = {
99
+ args: { showScrollbar: !0 },
100
+ render: (e) => /* @__PURE__ */ o("div", { style: { padding: 24 }, children: [
101
+ /* @__PURE__ */ r("h3", { style: { margin: "0 0 12px" }, children: "Scrollbar Visible" }),
102
+ /* @__PURE__ */ r(t, { showScrollbar: !0, children: i(e) })
103
+ ] })
104
+ }, S = {
105
+ args: {
106
+ itemCount: 40,
107
+ itemWidth: 90,
108
+ itemHeight: 60,
109
+ gap: 8,
110
+ showScrollbar: !1
111
+ },
112
+ render: (e) => /* @__PURE__ */ o("div", { style: { padding: 24 }, children: [
113
+ /* @__PURE__ */ r("h3", { style: { margin: "0 0 12px" }, children: "Dense Small Items" }),
114
+ /* @__PURE__ */ r(t, { showScrollbar: e.showScrollbar, children: i(e) })
115
+ ] })
116
+ }, w = {
117
+ args: {
118
+ itemCount: 12,
119
+ itemWidth: 260,
120
+ itemHeight: 160,
121
+ gap: 16,
122
+ gradient: !1
123
+ },
124
+ render: (e) => /* @__PURE__ */ o("div", { style: { padding: 24 }, children: [
125
+ /* @__PURE__ */ r("h3", { style: { margin: "0 0 12px" }, children: "Large Cards" }),
126
+ /* @__PURE__ */ r(t, { showScrollbar: e.showScrollbar, children: i(e) })
127
+ ] })
128
+ };
129
+ export {
130
+ S as DenseSmallItems,
131
+ w as LargeCards,
132
+ y as Playground,
133
+ f as WithScrollbar,
134
+ b as default
135
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.84",
4
+ "version": "0.0.85",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",