@caseparts-org/caseblocks 0.0.96 → 0.0.97

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.
@@ -1,49 +1,55 @@
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,
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import { useRef as c, useState as D, useEffect as L } from "react";
3
+ import { c as b } from "../../clsx-OuTLNxxd.js";
4
+ import '../../assets/HorizontalScroll.css';const P = "_container_aum2v_1", S = "_dragging_aum2v_14", s = {
5
+ container: P,
6
+ dragging: S,
7
7
  "scrollVisibility--false": "_scrollVisibility--false_aum2v_19"
8
8
  };
9
- function S({
10
- className: u,
11
- showScrollbar: f = !1,
12
- children: g
9
+ function M({
10
+ className: d,
11
+ showScrollbar: g = !1,
12
+ children: p
13
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);
14
+ const r = c(null), [a, i] = D(!1), n = c({ x: 0, scroll: 0 }), l = c(!1), v = 5, m = (t) => {
15
+ r.current && (i(!0), n.current.x = t.clientX, n.current.scroll = r.current.scrollLeft, l.current = !1);
16
+ }, h = (t) => {
17
+ if (!a || !r.current) return;
18
+ const o = t.clientX - n.current.x;
19
+ r.current.scrollLeft = n.current.scroll - o, Math.abs(t.clientX - n.current.x) > v && (l.current = !0);
20
+ }, u = () => {
21
+ r.current && i(!1);
22
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();
23
+ l.current && (t.preventDefault(), t.stopPropagation(), l.current = !1);
27
24
  };
28
- return /* @__PURE__ */ p(
25
+ return L(() => {
26
+ const t = r.current;
27
+ if (!t) return;
28
+ const o = (e) => {
29
+ if (!(t.scrollWidth > t.clientWidth)) return;
30
+ const f = Math.abs(e.deltaY) >= Math.abs(e.deltaX) && e.deltaY !== 0 ? e.deltaY : e.deltaX;
31
+ f !== 0 ? (e.preventDefault(), t.scrollLeft += f) : e.preventDefault();
32
+ };
33
+ return t.addEventListener("wheel", o, { passive: !1 }), () => t.removeEventListener("wheel", o);
34
+ }, []), /* @__PURE__ */ x(
29
35
  "div",
30
36
  {
31
37
  ref: r,
32
- className: x(
33
- u,
34
- l.container,
35
- l[`scrollVisibility--${f}`],
36
- o ? l.dragging : ""
38
+ className: b(
39
+ d,
40
+ s.container,
41
+ s[`scrollVisibility--${g}`],
42
+ a ? s.dragging : ""
37
43
  ),
38
- onPointerDown: d,
39
- onPointerMove: m,
40
- onPointerLeave: s,
41
- onPointerUp: s,
42
- onWheel: _,
43
- children: g
44
+ onPointerDown: m,
45
+ onPointerMove: h,
46
+ onPointerLeave: u,
47
+ onPointerUp: u,
48
+ onClickCapture: _,
49
+ children: p
44
50
  }
45
51
  );
46
52
  }
47
53
  export {
48
- S as HorizontalScroll
54
+ M as HorizontalScroll
49
55
  };
@@ -1,8 +1,8 @@
1
- import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
- import { HorizontalScroll as t } from "./HorizontalScroll.js";
3
- const b = {
1
+ import { jsxs as t, jsx as o } from "react/jsx-runtime";
2
+ import { HorizontalScroll as r } from "./HorizontalScroll.js";
3
+ const S = {
4
4
  title: "Case Parts/Atoms/HorizontalScroll",
5
- component: t,
5
+ component: r,
6
6
  tags: ["autodocs"],
7
7
  parameters: {
8
8
  layout: "fullscreen",
@@ -60,48 +60,59 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
60
60
  rounded: !0,
61
61
  gradient: !0
62
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",
63
+ }, l = /* @__PURE__ */ o("style", { children: `
64
+ .horizontalDemoScroll {
65
+ touch-action: none; /* ensure pointer events for horizontal drag */
66
+ }
67
+ .horizontalDemoScroll a {
68
+ -webkit-user-drag: none; /* Safari/Chrome: prevent ghost dragging of link */
69
+ }
70
+ ` }), n = (e) => {
71
+ const { itemCount: s, itemWidth: c, itemHeight: i, gap: d, rounded: h, gradient: m } = e;
72
+ return Array.from({ length: s }, (p, g) => {
73
+ const a = g + 1;
74
+ return /* @__PURE__ */ o(
75
+ "a",
69
76
  {
77
+ href: "/",
78
+ draggable: !1,
70
79
  style: {
71
80
  flex: "0 0 auto",
72
- width: s,
73
- height: n,
81
+ width: c,
82
+ height: i,
74
83
  marginRight: d,
75
- borderRadius: c ? 8 : 0,
76
- background: h ? "linear-gradient(135deg,#4F46E5,#6366F1)" : "#4F46E5",
84
+ borderRadius: h ? 8 : 0,
85
+ background: m ? "linear-gradient(135deg,#4F46E5,#6366F1)" : "#4F46E5",
77
86
  color: "#fff",
78
87
  display: "flex",
79
88
  alignItems: "center",
80
89
  justifyContent: "center",
81
- fontSize: Math.max(12, Math.min(24, n / 3)),
90
+ fontSize: Math.max(12, Math.min(24, i / 3)),
82
91
  fontWeight: 600,
83
92
  userSelect: "none",
84
93
  boxShadow: "0 2px 6px rgba(0,0,0,0.25)"
85
94
  },
86
- children: l
95
+ children: a
87
96
  },
88
- l
97
+ a
89
98
  );
90
99
  });
91
100
  }, y = {
92
101
  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) })
102
+ render: (e) => /* @__PURE__ */ t("div", { style: { padding: 24 }, children: [
103
+ l,
104
+ /* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "HorizontalScroll Playground" }),
105
+ /* @__PURE__ */ o("p", { style: { margin: "0 0 16px", fontSize: 14, color: "#555" }, children: "Drag horizontally or use the mouse wheel. Tweak values in Controls." }),
106
+ /* @__PURE__ */ o(r, { className: "horizontalDemoScroll", showScrollbar: e.showScrollbar, children: n(e) })
97
107
  ] })
98
108
  }, f = {
99
109
  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) })
110
+ render: (e) => /* @__PURE__ */ t("div", { style: { padding: 24 }, children: [
111
+ l,
112
+ /* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Scrollbar Visible" }),
113
+ /* @__PURE__ */ o(r, { className: "horizontalDemoScroll", showScrollbar: !0, children: n(e) })
103
114
  ] })
104
- }, S = {
115
+ }, w = {
105
116
  args: {
106
117
  itemCount: 40,
107
118
  itemWidth: 90,
@@ -109,11 +120,12 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
109
120
  gap: 8,
110
121
  showScrollbar: !1
111
122
  },
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) })
123
+ render: (e) => /* @__PURE__ */ t("div", { style: { padding: 24 }, children: [
124
+ l,
125
+ /* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Dense Small Items" }),
126
+ /* @__PURE__ */ o(r, { className: "horizontalDemoScroll", showScrollbar: e.showScrollbar, children: n(e) })
115
127
  ] })
116
- }, w = {
128
+ }, x = {
117
129
  args: {
118
130
  itemCount: 12,
119
131
  itemWidth: 260,
@@ -121,15 +133,16 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
121
133
  gap: 16,
122
134
  gradient: !1
123
135
  },
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) })
136
+ render: (e) => /* @__PURE__ */ t("div", { style: { padding: 24 }, children: [
137
+ l,
138
+ /* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Large Cards" }),
139
+ /* @__PURE__ */ o(r, { className: "horizontalDemoScroll", showScrollbar: e.showScrollbar, children: n(e) })
127
140
  ] })
128
141
  };
129
142
  export {
130
- S as DenseSmallItems,
131
- w as LargeCards,
143
+ w as DenseSmallItems,
144
+ x as LargeCards,
132
145
  y as Playground,
133
146
  f as WithScrollbar,
134
- b as default
147
+ S as default
135
148
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.96",
4
+ "version": "0.0.97",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",