@caseparts-org/caseblocks 0.0.9 → 0.0.11

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
+ ._input-container_1fwgs_1{display:flex;flex-direction:column;align-items:flex-start;width:100%;box-sizing:border-box}._input-container_1fwgs_1>label{font-family:var(--font-family-label);font-size:var(--font-size-xs)}._input_1fwgs_1{height:32px;border-radius:var(--radius-radius-minimal, 2px);border:1px solid var(--border-border-primary, #dfdfdf);background:var(--surface-surface-secondary, #f6f6f6);padding:0px var(--spacing-spacing-1xs, 12px);outline:none;font-size:var(--font-size-sm);width:100%}._input_1fwgs_1:focus{border:1px solid var(--border-border-primary-btn, #1380b1);box-shadow:0 0 2px 1px var(--border-border-primary-btn)}
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { HideAtProps } from '../HideAt';
3
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>, HideAtProps {
4
+ label: string | null;
5
+ }
6
+ export declare function Input({ label, hideAt, className, ...otherProps }: InputProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsxs as p, jsx as i } from "react/jsx-runtime";
2
+ import { c as m } from "../../clsx-OuTLNxxd.js";
3
+ import { getHideAtStyles as r } from "../HideAt.js";
4
+ import '../../assets/Input.css';const u = "_input_1fwgs_1", e = {
5
+ "input-container": "_input-container_1fwgs_1",
6
+ input: u
7
+ };
8
+ function f({ label: n, hideAt: s, className: c, ...t }) {
9
+ return /* @__PURE__ */ p("div", { className: e["input-container"], children: [
10
+ n && /* @__PURE__ */ i("label", { htmlFor: t.name, children: n }),
11
+ /* @__PURE__ */ i(
12
+ "input",
13
+ {
14
+ id: t.name,
15
+ type: "text",
16
+ className: m(e.input, r(s), c),
17
+ ...t
18
+ }
19
+ )
20
+ ] });
21
+ }
22
+ export {
23
+ f as Input
24
+ };
@@ -0,0 +1,14 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { Input } from './Input';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Input;
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ tags: string[];
10
+ };
11
+ export default meta;
12
+ type Story = StoryObj<typeof meta>;
13
+ export declare const Default: Story;
14
+ export declare const WithHideAt: Story;
@@ -0,0 +1,27 @@
1
+ import { Input as e } from "./Input.js";
2
+ const a = {
3
+ title: "Case Parts/Atoms/Input",
4
+ component: e,
5
+ parameters: {
6
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
7
+ layout: "centered"
8
+ },
9
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
10
+ tags: ["autodocs"]
11
+ }, l = {
12
+ args: {
13
+ label: "Label",
14
+ placeholder: "Type here..."
15
+ }
16
+ }, o = {
17
+ args: {
18
+ label: "Label",
19
+ placeholder: "Hidden at md",
20
+ hideAt: "md"
21
+ }
22
+ };
23
+ export {
24
+ l as Default,
25
+ o as WithHideAt,
26
+ a as default
27
+ };
package/dist/main.d.ts CHANGED
@@ -13,6 +13,8 @@ export { Separator } from './atoms/Separator/Separator';
13
13
  export type { SeparatorProps } from './atoms/Separator/Separator';
14
14
  export { Text } from './atoms/Text/Text';
15
15
  export type { TextProps } from './atoms/Text/Text';
16
+ export { Input } from './atoms/Input/Input';
17
+ export type { InputProps } from './atoms/Input/Input';
16
18
  export { Account } from './molecules/Account/Account';
17
19
  export type { AccountProps } from './molecules/Account/Account';
18
20
  export { Avatar } from './molecules/Avatar/Avatar';
package/dist/main.js CHANGED
@@ -1,37 +1,39 @@
1
1
  import { Button as e } from "./atoms/Button/Button.js";
2
2
  import { Flex as p } from "./atoms/Flex/Flex.js";
3
3
  import { Column as m, Grid as f } from "./atoms/Grid/Grid.js";
4
- import { Head as i } from "./atoms/Root/Head.js";
4
+ import { Head as n } from "./atoms/Root/Head.js";
5
5
  import { Icon as c } from "./atoms/Icon/Icon.js";
6
- import { Link as g } from "./atoms/Link/Link.js";
7
- import { Root as u } from "./atoms/Root/Root.js";
6
+ import { Link as u } from "./atoms/Link/Link.js";
7
+ import { Root as h } from "./atoms/Root/Root.js";
8
8
  import { Separator as S } from "./atoms/Separator/Separator.js";
9
9
  import { Text as v } from "./atoms/Text/Text.js";
10
- import { Account as B } from "./molecules/Account/Account.js";
11
- import { Avatar as T } from "./molecules/Avatar/Avatar.js";
12
- import { Chip as w } from "./molecules/Chip/Chip.js";
13
- import { Logo as G } from "./molecules/Logo/Logo.js";
14
- import { SearchBox as I } from "./molecules/SearchBox/SearchBox.js";
15
- import { ToggleView as N } from "./molecules/ToggleView/ToggleView.js";
16
- import { MainNav as V } from "./organisms/MainNav/MainNav.js";
17
- import { ChipSelector as j } from "./organisms/ChipSelector/ChipSelector.js";
10
+ import { Input as B } from "./atoms/Input/Input.js";
11
+ import { Account as L } from "./molecules/Account/Account.js";
12
+ import { Avatar as k } from "./molecules/Avatar/Avatar.js";
13
+ import { Chip as F } from "./molecules/Chip/Chip.js";
14
+ import { Logo as H } from "./molecules/Logo/Logo.js";
15
+ import { SearchBox as N } from "./molecules/SearchBox/SearchBox.js";
16
+ import { ToggleView as V } from "./molecules/ToggleView/ToggleView.js";
17
+ import { MainNav as j } from "./organisms/MainNav/MainNav.js";
18
+ import { ChipSelector as s } from "./organisms/ChipSelector/ChipSelector.js";
18
19
  export {
19
- B as Account,
20
- T as Avatar,
20
+ L as Account,
21
+ k as Avatar,
21
22
  e as Button,
22
- w as Chip,
23
- j as ChipSelector,
23
+ F as Chip,
24
+ s as ChipSelector,
24
25
  m as Column,
25
26
  p as Flex,
26
27
  f as Grid,
27
- i as Head,
28
+ n as Head,
28
29
  c as Icon,
29
- g as Link,
30
- G as Logo,
31
- V as MainNav,
32
- u as Root,
33
- I as SearchBox,
30
+ B as Input,
31
+ u as Link,
32
+ H as Logo,
33
+ j as MainNav,
34
+ h as Root,
35
+ N as SearchBox,
34
36
  S as Separator,
35
37
  v as Text,
36
- N as ToggleView
38
+ V as ToggleView
37
39
  };
@@ -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.9",
4
+ "version": "0.0.11",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",