@caseparts-org/caseblocks 0.0.8 → 0.0.10

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 +1 @@
1
- ._chipSelector_1k7dl_1{column-gap:var(--spacing-1);row-gap:var(--spacing-0-75);flex-wrap:wrap}
1
+ ._chipSelector_butnu_1{column-gap:var(--spacing-0-5);row-gap:var(--spacing-0-5);flex-wrap:wrap}
@@ -1 +1 @@
1
- ._toggleView_1qbhe_1{flex-wrap:wrap}._toggleOption_1qbhe_5{border:none;padding:var(--spacing-0-25) var(--spacing-1);gap:var(--spacing-0-125);cursor:pointer;border:1px solid var(--border-border-primary)}._toggleOption_1qbhe_5._selected_1qbhe_13{color:var(--text-text-invert);border:1px solid var(--color-brand-primary-primary-teal-blue);background-color:var(--color-brand-primary-primary-teal-blue)}._toggleOption_1qbhe_5._selected_1qbhe_13 path{fill:var(--icons-icon-invert)}
1
+ ._toggleView_1voum_1{flex-wrap:wrap}._toggleOption_1voum_5{border:none;padding:var(--spacing-0-125) var(--spacing-0-5);gap:var(--spacing-0-125);cursor:pointer;border-top:1px solid var(--border-border-primary);border-bottom:1px solid var(--border-border-primary)}._toggleOption_1voum_5._selected_1voum_15{color:var(--text-text-invert);border-color:var(--color-brand-primary-primary-teal-blue);background-color:var(--color-brand-primary-primary-teal-blue)}._toggleOption_1voum_5._selected_1voum_15 path{fill:var(--icons-icon-invert)}._toggleOption_1voum_5:first-child{border-left:1px solid var(--border-border-primary);border-radius:2px 0 0 2px}._toggleOption_1voum_5:last-child{border-right:1px solid var(--border-border-primary);border-radius:0 2px 2px 0}._toggleOption_1voum_5:not(:last-child){border-right:1px solid var(--border-border-primary)}._toggleOption_1voum_5._selected_1voum_15+._toggleOption_1voum_5{border-left:none}
@@ -2,18 +2,18 @@ import { jsx as e, jsxs as d } from "react/jsx-runtime";
2
2
  import g from "react";
3
3
  import { Flex as f } from "../../atoms/Flex/Flex.js";
4
4
  import { Icon as l } from "../../atoms/Icon/Icon.js";
5
- import { Text as b } from "../../atoms/Text/Text.js";
6
- import { getHideAtStyles as x } from "../../atoms/HideAt.js";
5
+ import { Text as x } from "../../atoms/Text/Text.js";
6
+ import { getHideAtStyles as O } from "../../atoms/HideAt.js";
7
7
  import { c as p } from "../../clsx-OuTLNxxd.js";
8
- import '../../assets/ToggleView.css';const O = "_toggleView_1qbhe_1", y = "_toggleOption_1qbhe_5", I = "_selected_1qbhe_13", m = {
9
- toggleView: O,
10
- toggleOption: y,
11
- selected: I
12
- }, _ = {
8
+ import '../../assets/ToggleView.css';const y = "_toggleView_1voum_1", I = "_toggleOption_1voum_5", _ = "_selected_1voum_15", m = {
9
+ toggleView: y,
10
+ toggleOption: I,
11
+ selected: _
12
+ }, T = {
13
13
  grid: "GRID",
14
14
  list: "LIST",
15
15
  table: "TABLE"
16
- }, T = {
16
+ }, b = {
17
17
  grid: /* @__PURE__ */ e(l, { iconKey: "fa-regular fa-grid-2", size: "sm" }),
18
18
  list: /* @__PURE__ */ e(l, { iconKey: "fa-regular fa-list-ul", size: "sm" }),
19
19
  table: /* @__PURE__ */ e(l, { iconKey: "fa-regular fa-table-cells", size: "sm" })
@@ -31,7 +31,7 @@ function s({
31
31
  {
32
32
  flexDirection: "row",
33
33
  alignItems: "center",
34
- className: p(m.toggleView, x(a), n),
34
+ className: p(m.toggleView, O(a), n),
35
35
  ...r,
36
36
  children: g.Children.map(o, (i) => g.isValidElement(i) ? g.cloneElement(i, {
37
37
  isSelected: i.props.id === c,
@@ -53,8 +53,8 @@ function w({
53
53
  u,
54
54
  {
55
55
  id: c,
56
- label: _[t],
57
- icon: T[t],
56
+ label: T[t],
57
+ icon: b[t],
58
58
  isSelected: n,
59
59
  onClick: o,
60
60
  ...r
@@ -87,7 +87,7 @@ function u({
87
87
  ...i,
88
88
  children: [
89
89
  n,
90
- /* @__PURE__ */ e(b, { size: "xxs", children: t })
90
+ /* @__PURE__ */ e(x, { size: "xxs", children: t })
91
91
  ]
92
92
  }
93
93
  );
@@ -9,7 +9,7 @@ const l = {
9
9
  tags: ["autodocs"]
10
10
  }, r = {
11
11
  args: {
12
- selectedId: "table",
12
+ selectedId: "grid",
13
13
  onToggle: (o) => console.log(`Option ${o} selected`),
14
14
  children: [
15
15
  /* @__PURE__ */ e(t.Option, { id: "grid", variant: "grid" }, "grid"),
@@ -1,27 +1,27 @@
1
- import { jsx as l } from "react/jsx-runtime";
1
+ import { jsx as o } from "react/jsx-runtime";
2
2
  import { c as m } from "../../clsx-OuTLNxxd.js";
3
3
  import { getHideAtStyles as n } from "../../atoms/HideAt.js";
4
4
  import { Flex as s } from "../../atoms/Flex/Flex.js";
5
5
  import { Chip as f } from "../../molecules/Chip/Chip.js";
6
- import '../../assets/ChipSelector.css';const x = "_chipSelector_1k7dl_1", i = {
6
+ import '../../assets/ChipSelector.css';const x = "_chipSelector_butnu_1", u = {
7
7
  chipSelector: x
8
8
  };
9
9
  function g({
10
- chips: o,
10
+ chips: l,
11
11
  onChipSelect: e,
12
12
  onChipDismiss: r,
13
13
  className: a,
14
- hideAt: d,
15
- ...c
14
+ hideAt: c,
15
+ ...d
16
16
  }) {
17
- return /* @__PURE__ */ l(
17
+ return /* @__PURE__ */ o(
18
18
  s,
19
19
  {
20
20
  flexDirection: "row",
21
21
  alignItems: "center",
22
- className: m(i.chipSelector, n(d), a),
23
- ...c,
24
- children: o.map((t) => /* @__PURE__ */ l(
22
+ className: m(u.chipSelector, n(c), a),
23
+ ...d,
24
+ children: l.map((t) => /* @__PURE__ */ o(
25
25
  f,
26
26
  {
27
27
  text: t.text,
@@ -1,6 +1,6 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import { ChipSelector as t } from "./ChipSelector.js";
3
- const a = {
3
+ const s = {
4
4
  title: "Case Parts/Organisms/ChipSelector",
5
5
  component: t,
6
6
  parameters: {
@@ -9,17 +9,34 @@ const a = {
9
9
  },
10
10
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
11
11
  tags: ["autodocs"]
12
- }, o = {
12
+ }, c = {
13
13
  args: {
14
14
  chips: [
15
15
  { id: 1, text: "Chip 1", variant: "selectable", selected: !0 },
16
16
  { id: 2, text: "Chip 2", variant: "selectable", selected: !0 },
17
- { id: 3, text: "Chip 3", variant: "selectable", selected: !0 }
17
+ { id: 3, text: "Chip 3", variant: "selectable", selected: !0 },
18
+ { id: 4, text: "Chip 4", variant: "selectable", selected: !0 },
19
+ { id: 5, text: "Chip 5", variant: "selectable", selected: !0 },
20
+ { id: 6, text: "Chip 6", variant: "selectable", selected: !0 },
21
+ { id: 7, text: "Chip 7", variant: "selectable", selected: !0 },
22
+ { id: 8, text: "Chip 8", variant: "selectable", selected: !0 },
23
+ { id: 9, text: "Chip 9", variant: "selectable", selected: !0 },
24
+ { id: 10, text: "Chip 10", variant: "selectable", selected: !0 },
25
+ { id: 11, text: "Chip 11", variant: "selectable", selected: !0 },
26
+ { id: 12, text: "Chip 12", variant: "selectable", selected: !0 },
27
+ { id: 13, text: "Chip 13", variant: "selectable", selected: !1 },
28
+ { id: 14, text: "Chip 14", variant: "selectable", selected: !1 },
29
+ { id: 15, text: "Chip 15", variant: "selectable", selected: !1 },
30
+ { id: 16, text: "Chip 16", variant: "selectable", selected: !1 },
31
+ { id: 17, text: "Chip 17", variant: "selectable", selected: !0 },
32
+ { id: 18, text: "Chip 18", variant: "selectable", selected: !0 },
33
+ { id: 19, text: "Chip 19", variant: "selectable", selected: !1 },
34
+ { id: 20, text: "Chip 20", variant: "selectable", selected: !1 }
18
35
  ],
19
36
  onChipSelect: (e) => console.log(`Chip ${e} selected`),
20
37
  onChipDismiss: (e) => console.log(`Chip ${e} dismissed`)
21
38
  }
22
- }, c = {
39
+ }, d = {
23
40
  render: () => /* @__PURE__ */ i(
24
41
  t,
25
42
  {
@@ -45,7 +62,7 @@ const a = {
45
62
  )
46
63
  };
47
64
  export {
48
- o as AllProps,
49
- c as Variants,
50
- a as default
65
+ c as AllProps,
66
+ d as Variants,
67
+ s as default
51
68
  };
@@ -0,0 +1,20 @@
1
+ import { default as React, CSSProperties, ComponentType } from 'react';
2
+ type SpinZoom360Props = {
3
+ images: string[];
4
+ defaultIndex?: number;
5
+ disableSpin?: boolean;
6
+ disableZoom?: boolean;
7
+ clickZoomFactor?: number;
8
+ scrollZoomFactor?: number;
9
+ maxZoomLevel?: number;
10
+ spinOverlayComponent?: ComponentType<{
11
+ style?: CSSProperties;
12
+ }>;
13
+ rotationSpeedThreshold?: number;
14
+ onImageChange?: (_info: {
15
+ index: number;
16
+ src: string;
17
+ }) => void;
18
+ };
19
+ declare const SpinZoomViewer: React.FC<SpinZoom360Props>;
20
+ export default SpinZoomViewer;
@@ -0,0 +1,292 @@
1
+ import { jsxs as rt, jsx as k } from "react/jsx-runtime";
2
+ import { useState as f, useRef as x, useEffect as G } from "react";
3
+ import { Text as lt } from "../../atoms/Text/Text.js";
4
+ const ut = 4, dt = ({
5
+ images: Y,
6
+ defaultIndex: M = 0,
7
+ disableSpin: w = !1,
8
+ disableZoom: P = !1,
9
+ clickZoomFactor: D = 1.5,
10
+ scrollZoomFactor: B = 1.1,
11
+ maxZoomLevel: m = 5,
12
+ spinOverlayComponent: U,
13
+ rotationSpeedThreshold: O = 15,
14
+ onImageChange: H = () => {
15
+ }
16
+ }) => {
17
+ const [J, tt] = f(!1), [X, N] = f(M), [S, L] = f(!1), [Q, R] = f(!1), [Z, T] = f(!1), [c, h] = f(!1), [l, p] = f(1), [d, a] = f({
18
+ top: 0,
19
+ left: 0
20
+ }), [C, et] = f(!1), u = x(null), q = x(0), b = x({ x: 0, y: 0 }), V = x({
21
+ initialPosition: 0,
22
+ centerX: 0,
23
+ centerY: 0
24
+ }), y = x({
25
+ x: 0,
26
+ y: 0,
27
+ isZoomIn: !1
28
+ }), W = x({ x: 0, y: 0 });
29
+ G(() => {
30
+ const t = u.current;
31
+ return t && t.addEventListener("wheel", A, {
32
+ passive: !1
33
+ }), () => {
34
+ t && t.removeEventListener(
35
+ "wheel",
36
+ A,
37
+ { passive: !1 }
38
+ );
39
+ };
40
+ }, []), G(() => {
41
+ H == null || H({ index: X, src: Y[X] });
42
+ }, [X]);
43
+ function K(t) {
44
+ if (!P && "touches" in t && t.touches && t.touches.length > 1) {
45
+ T(!0), h(!0), R(!1), L(!1);
46
+ const o = t.touches[0].clientX - t.touches[1].clientX, i = t.touches[0].clientY - t.touches[1].clientY;
47
+ V.current.initialPosition = Math.sqrt(o * o + i * i);
48
+ } else c ? R(!0) : w || L(!0);
49
+ const e = "type" in t && t.type === "mousedown" ? t.clientX : t.touches[0].clientX, n = "type" in t && t.type === "mousedown" ? t.clientY : t.touches[0].clientY;
50
+ q.current = e, b.current = { x: e, y: n }, W.current = { x: e, y: n };
51
+ }
52
+ function F(t) {
53
+ if (!P && "touches" in t && t.touches && t.touches.length > 1) {
54
+ const o = t.touches[0].clientX - t.touches[1].clientX, i = t.touches[0].clientY - t.touches[1].clientY, r = Math.sqrt(o * o + i * i), I = r / V.current.initialPosition;
55
+ let s = l * I;
56
+ if (p((g) => (s = g * I, s < 1.001 ? (h(!1), a({ top: 0, left: 0 }), 1) : s >= m ? g : s)), s < m) {
57
+ const g = (t.touches[0].clientX + t.touches[1].clientX) / 2, E = (t.touches[0].clientY + t.touches[1].clientY) / 2, v = u.current.getBoundingClientRect();
58
+ a((_) => {
59
+ const { relX: st, relY: ct } = z(
60
+ g,
61
+ E,
62
+ v.left,
63
+ v.top
64
+ );
65
+ return j(
66
+ !0,
67
+ st,
68
+ ct,
69
+ _.left,
70
+ _.top,
71
+ I
72
+ );
73
+ });
74
+ }
75
+ V.current.initialPosition = r;
76
+ }
77
+ const e = "type" in t && t.type === "mousemove" ? t.clientX : t.touches[0].clientX, n = "type" in t && t.type === "mousemove" ? t.clientY : t.touches[0].clientY;
78
+ if (S) {
79
+ et(!0);
80
+ const o = e - q.current;
81
+ Math.abs(o) > O && (o > 0 ? N(
82
+ (i) => (i - 1 + Y.length) % Y.length
83
+ ) : N((i) => (i + 1) % Y.length), q.current = e);
84
+ }
85
+ if (Q) {
86
+ const o = e - b.current.x, i = n - b.current.y;
87
+ a({
88
+ top: d.top + i,
89
+ left: d.left + o
90
+ }), b.current = { x: e, y: n };
91
+ }
92
+ }
93
+ function $(t) {
94
+ L(!1), T(!1);
95
+ let e, n, o = 0;
96
+ if ("type" in t && (t.type === "mouseup" || t.type === "mouseleave"))
97
+ e = t.clientX, n = t.clientY, o = t.button;
98
+ else {
99
+ const s = t.changedTouches[0];
100
+ e = s.clientX, n = s.clientY;
101
+ }
102
+ const i = e - W.current.x, r = n - W.current.y, I = Math.hypot(i, r);
103
+ if (!P && Math.abs(I) < ut) {
104
+ if (o === 0)
105
+ if (l >= m)
106
+ h(!1), p(1), a({ top: 0, left: 0 });
107
+ else {
108
+ const s = u.current.getBoundingClientRect(), { relX: g, relY: E } = z(
109
+ e,
110
+ n,
111
+ s.left,
112
+ s.top
113
+ ), v = j(
114
+ !0,
115
+ g,
116
+ E,
117
+ d.left,
118
+ d.top,
119
+ D
120
+ );
121
+ a(v), p(l * D), h(!0);
122
+ }
123
+ else if (o === 1)
124
+ if (l / D <= 1)
125
+ h(!1), p(1), a({ top: 0, left: 0 });
126
+ else {
127
+ const s = u.current.getBoundingClientRect(), { relX: g, relY: E } = z(
128
+ e,
129
+ n,
130
+ s.left,
131
+ s.top
132
+ ), v = j(
133
+ !1,
134
+ g,
135
+ E,
136
+ d.left,
137
+ d.top,
138
+ D
139
+ );
140
+ a(v), p(l / D), h(!0);
141
+ }
142
+ }
143
+ R(!1);
144
+ }
145
+ function A(t) {
146
+ if (P)
147
+ return;
148
+ t.preventDefault(), h(!0);
149
+ const e = t.deltaY < 0;
150
+ p(e ? (n) => {
151
+ const o = n * B;
152
+ return o >= m ? m : o;
153
+ } : (n) => {
154
+ const o = n / B;
155
+ return o <= 1 ? (h(!1), p(1), a({ top: 0, left: 0 }), 1) : o;
156
+ }), y.current = {
157
+ x: t.clientX,
158
+ y: t.clientY,
159
+ isZoomIn: e,
160
+ isScrolling: !0
161
+ };
162
+ }
163
+ G(() => {
164
+ var e;
165
+ const t = (e = u.current) == null ? void 0 : e.getBoundingClientRect();
166
+ l !== 1 && l !== m && y.current.isScrolling && t && (y.current = {
167
+ ...y.current,
168
+ isScrolling: !1
169
+ }, a((n) => {
170
+ const { relX: o, relY: i } = z(
171
+ y.current.x,
172
+ y.current.y,
173
+ t.left,
174
+ t.top
175
+ );
176
+ return j(
177
+ y.current.isZoomIn,
178
+ o,
179
+ i,
180
+ n.left,
181
+ n.top,
182
+ B
183
+ );
184
+ }));
185
+ }, [l]);
186
+ function nt(t) {
187
+ t.preventDefault();
188
+ }
189
+ function z(t, e, n, o) {
190
+ const i = t - n, r = e - o;
191
+ return { relX: i, relY: r };
192
+ }
193
+ function j(t, e, n, o, i, r) {
194
+ return t ? {
195
+ top: n - (n - i) * r,
196
+ left: e - (e - o) * r
197
+ } : {
198
+ top: n - (n - i) / r,
199
+ left: e - (e - o) / r
200
+ };
201
+ }
202
+ function ot() {
203
+ return w && P ? "default" : c && l >= m ? "zoom-out" : S ? "grabbing" : Q ? "move" : c || w ? "zoom-in" : "grab";
204
+ }
205
+ const it = {
206
+ height: c && u.current ? u.current.offsetHeight * l + "px" : "100%",
207
+ width: c && u.current ? u.current.offsetWidth * l + "px" : "100%",
208
+ position: c ? "absolute" : "static",
209
+ top: c ? `${d.top}px` : "0",
210
+ left: c ? `${d.left}px` : "0",
211
+ objectFit: "contain",
212
+ touchAction: c || Z ? "none" : "auto"
213
+ };
214
+ return /* @__PURE__ */ rt(
215
+ "div",
216
+ {
217
+ onTouchStart: K,
218
+ onTouchMove: F,
219
+ onTouchEnd: $,
220
+ onMouseDown: K,
221
+ onMouseMove: F,
222
+ onMouseUp: $,
223
+ onMouseLeave: $,
224
+ onDragStart: nt,
225
+ onContextMenu: (t) => t.preventDefault(),
226
+ ref: u,
227
+ style: {
228
+ cursor: ot(),
229
+ width: "100%",
230
+ height: "100%",
231
+ position: "relative",
232
+ overflow: "hidden",
233
+ touchAction: c || Z ? "none" : "auto"
234
+ },
235
+ children: [
236
+ Y.map((t, e) => /* @__PURE__ */ k(
237
+ "img",
238
+ {
239
+ style: {
240
+ display: e === X ? "block" : "none",
241
+ ...e === X ? it : {}
242
+ },
243
+ src: t,
244
+ alt: "",
245
+ onContextMenu: (n) => n.preventDefault(),
246
+ onLoad: e === M ? () => tt(!0) : void 0
247
+ },
248
+ t
249
+ )),
250
+ U ? /* @__PURE__ */ k(
251
+ U,
252
+ {
253
+ style: {
254
+ position: "absolute",
255
+ opacity: S || c || C || !J || w ? "0" : ".7",
256
+ transition: "opacity .3s ease-in",
257
+ pointerEvents: "none",
258
+ left: "50%",
259
+ top: "50%",
260
+ transform: "translate(-50%, -50%)"
261
+ }
262
+ }
263
+ ) : /* @__PURE__ */ k(
264
+ "div",
265
+ {
266
+ style: {
267
+ backgroundColor: "#393939",
268
+ color: "white",
269
+ display: "flex",
270
+ flexDirection: "row",
271
+ alignItems: "center",
272
+ justifyContent: "center",
273
+ height: "max-content",
274
+ width: "max-content",
275
+ padding: "8px 16px",
276
+ left: "50%",
277
+ top: "50%",
278
+ transform: "translate(-50%, -50%)",
279
+ position: "absolute",
280
+ transition: "opacity .3s ease-in",
281
+ opacity: S || c || C || !J || w ? "0" : "0.7"
282
+ },
283
+ children: /* @__PURE__ */ k(lt, { size: "sm", children: "Drag to spin" })
284
+ }
285
+ )
286
+ ]
287
+ }
288
+ );
289
+ };
290
+ export {
291
+ dt as default
292
+ };
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { default as SpinZoomViewer } from './SpinZoomViewer';
3
+ declare const meta: Meta<typeof SpinZoomViewer>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof SpinZoomViewer>;
6
+ export declare const Default: Story;
@@ -0,0 +1,24 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import r from "./SpinZoomViewer.js";
3
+ const o = "1092-01", a = `https://dev.caseparts.com/graphics/ortery/web%20spin/${o}/${o}/images/lv1/`, s = [];
4
+ for (let e = 0; e < 20; e++)
5
+ s.push(`${a}img${(e + 1).toString().padStart(2, "0")}.webp`);
6
+ const n = {
7
+ title: "Case Parts/Organisms/SpinZoomViewer",
8
+ component: r,
9
+ tags: ["autodocs"],
10
+ parameters: {
11
+ layout: "centered"
12
+ }
13
+ }, p = {
14
+ render: (e) => /* @__PURE__ */ t("div", { style: { height: "500px", width: "500px" }, children: /* @__PURE__ */ t(r, { ...e }) }),
15
+ args: {
16
+ defaultIndex: 3,
17
+ images: s,
18
+ maxZoomLevel: 5
19
+ }
20
+ };
21
+ export {
22
+ p as Default,
23
+ n as default
24
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",