@caseparts-org/caseblocks 0.0.119 → 0.0.120
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.
- package/dist/main-client.d.ts +2 -0
- package/dist/main-client.js +26 -24
- package/dist/molecules/Account/Account.js +16 -19
- package/dist/molecules/ImageViewer/ImageViewer.d.ts +8 -0
- package/dist/molecules/ImageViewer/ImageViewer.js +123 -0
- package/dist/molecules/ImageViewer/ImageViewer.stories.d.ts +6 -0
- package/dist/molecules/ImageViewer/ImageViewer.stories.js +30 -0
- package/package.json +1 -1
package/dist/main-client.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export { AddToCart } from './molecules/AddToCart/AddToCart';
|
|
|
24
24
|
export type { CategoryWithChildren as MainCategory, Category } from './molecules/CategoryNav/CategoryNav';
|
|
25
25
|
export { Modal } from './molecules/Modal/Modal';
|
|
26
26
|
export type { ModalProps } from './molecules/Modal/Modal';
|
|
27
|
+
export { ImageViewer } from './molecules/ImageViewer/ImageViewer';
|
|
28
|
+
export type { ImageViewerProps } from './molecules/ImageViewer/ImageViewer';
|
|
27
29
|
export { MainNav } from './organisms/MainNav/MainNav';
|
|
28
30
|
export type { MainNavProps } from './organisms/MainNav/MainNav';
|
|
29
31
|
export { ChipSelector } from './organisms/ChipSelector/ChipSelector';
|
package/dist/main-client.js
CHANGED
|
@@ -6,17 +6,17 @@ import { Icon as l } from "./atoms/Icon/Icon.js";
|
|
|
6
6
|
import { Root as d } from "./atoms/Root/Root.js";
|
|
7
7
|
import { Separator as C } from "./atoms/Separator/Separator.js";
|
|
8
8
|
import { Text as k } from "./atoms/Text/Text.js";
|
|
9
|
-
import { Input as
|
|
9
|
+
import { Input as S } from "./atoms/Input/Input.js";
|
|
10
10
|
import { Link as v } from "./atoms/Link/Link.js";
|
|
11
11
|
import { linkClassName as L } from "./atoms/Link/linkClassName.js";
|
|
12
12
|
import { configureLink as h, routerOverride as s } from "./atoms/Link/configureLink.js";
|
|
13
13
|
import { LinkButton as F } from "./atoms/LinkButton/LinkButton.js";
|
|
14
14
|
import { configureImage as N } from "./atoms/Image/configureImage.js";
|
|
15
|
-
import { Logo as
|
|
16
|
-
import { SearchBox as
|
|
17
|
-
import { QuantityInput as
|
|
18
|
-
import { Pricing as
|
|
19
|
-
import { Availability as
|
|
15
|
+
import { Logo as w } from "./molecules/Logo/Logo.js";
|
|
16
|
+
import { SearchBox as H } from "./molecules/SearchBox/SearchBox.js";
|
|
17
|
+
import { QuantityInput as z } from "./molecules/QuantityInput/QuantityInput.js";
|
|
18
|
+
import { Pricing as O } from "./molecules/Pricing/Pricing.js";
|
|
19
|
+
import { Availability as R } from "./molecules/Availability/Availability.js";
|
|
20
20
|
import { Avatar as q } from "./molecules/Avatar/Avatar.js";
|
|
21
21
|
import { BannerCard as E } from "./molecules/BannerCard/BannerCard.js";
|
|
22
22
|
import { CardLink as K } from "./molecules/CardLink/CardLink.js";
|
|
@@ -32,47 +32,49 @@ import { ToggleView as io } from "./molecules/ToggleView/ToggleView.js";
|
|
|
32
32
|
import { CartSlideInPanel as uo } from "./molecules/Cart/CartSlideInPanel.js";
|
|
33
33
|
import { StatefulButton as Co } from "./molecules/StatefulButton/StatefulButton.js";
|
|
34
34
|
import { AnimatedCheckMark as ko } from "./molecules/StatefulButton/AnimatedCheckmark.js";
|
|
35
|
-
import { AddToCart as
|
|
35
|
+
import { AddToCart as So } from "./molecules/AddToCart/AddToCart.js";
|
|
36
36
|
import { Modal as vo } from "./molecules/Modal/Modal.js";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
37
|
+
import { ImageViewer as Lo } from "./molecules/ImageViewer/ImageViewer.js";
|
|
38
|
+
import { MainNav as ho } from "./organisms/MainNav/MainNav.js";
|
|
39
|
+
import { ChipSelector as To } from "./organisms/ChipSelector/ChipSelector.js";
|
|
40
|
+
import { Product as Mo } from "./organisms/Product/Product.js";
|
|
41
|
+
import { Carousel as bo } from "./organisms/Carousel/Carousel.js";
|
|
42
|
+
import { Footer as yo } from "./organisms/Footer/Footer.js";
|
|
42
43
|
export {
|
|
43
44
|
fo as Account,
|
|
44
|
-
|
|
45
|
+
So as AddToCart,
|
|
45
46
|
ko as AnimatedCheckMark,
|
|
46
|
-
|
|
47
|
+
R as Availability,
|
|
47
48
|
q as Avatar,
|
|
48
49
|
E as BannerCard,
|
|
49
50
|
W as Breadcrumbs,
|
|
50
51
|
e as Button,
|
|
51
52
|
K as CardLink,
|
|
52
|
-
|
|
53
|
+
bo as Carousel,
|
|
53
54
|
uo as CartSlideInPanel,
|
|
54
55
|
ao as Chip,
|
|
55
|
-
|
|
56
|
+
To as ChipSelector,
|
|
56
57
|
f as Column,
|
|
57
58
|
p as Flex,
|
|
58
|
-
|
|
59
|
+
yo as Footer,
|
|
59
60
|
x as Grid,
|
|
60
61
|
n as Head,
|
|
61
62
|
_ as HorizontalScroll,
|
|
62
63
|
l as Icon,
|
|
63
|
-
|
|
64
|
+
Lo as ImageViewer,
|
|
65
|
+
S as Input,
|
|
64
66
|
v as Link,
|
|
65
67
|
F as LinkButton,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
w as Logo,
|
|
69
|
+
ho as MainNav,
|
|
68
70
|
vo as Modal,
|
|
69
71
|
Y as NotFound,
|
|
70
72
|
po as Popover,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
O as Pricing,
|
|
74
|
+
Mo as Product,
|
|
75
|
+
z as QuantityInput,
|
|
74
76
|
d as Root,
|
|
75
|
-
|
|
77
|
+
H as SearchBox,
|
|
76
78
|
C as Separator,
|
|
77
79
|
oo as SlideInPanel,
|
|
78
80
|
Co as StatefulButton,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as n, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { getHideAtStyles as m } from "../../atoms/HideAt.js";
|
|
3
3
|
import { Icon as f } from "../../atoms/Icon/Icon.js";
|
|
4
4
|
import { Text as c } from "../../atoms/Text/Text.js";
|
|
@@ -16,7 +16,7 @@ function y(i) {
|
|
|
16
16
|
return i.account !== void 0;
|
|
17
17
|
}
|
|
18
18
|
function j(i) {
|
|
19
|
-
return i.isAccountLoading ? /* @__PURE__ */
|
|
19
|
+
return i.isAccountLoading ? /* @__PURE__ */ n("div", { className: o.placeholder }) : y(i) ? /* @__PURE__ */ n(_, { ...i }) : /* @__PURE__ */ n(N, { ...i });
|
|
20
20
|
}
|
|
21
21
|
function _(i) {
|
|
22
22
|
const {
|
|
@@ -27,17 +27,17 @@ function _(i) {
|
|
|
27
27
|
isAccountLoading: h,
|
|
28
28
|
...l
|
|
29
29
|
} = i;
|
|
30
|
-
return a ? /* @__PURE__ */
|
|
30
|
+
return a ? /* @__PURE__ */ n(
|
|
31
31
|
A,
|
|
32
32
|
{
|
|
33
33
|
position: "bottom right",
|
|
34
|
-
trigger: /* @__PURE__ */
|
|
34
|
+
trigger: /* @__PURE__ */ t(
|
|
35
35
|
"div",
|
|
36
36
|
{
|
|
37
37
|
className: g(o.loggedIn, m(s), r),
|
|
38
38
|
...l,
|
|
39
39
|
children: [
|
|
40
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ t(
|
|
41
41
|
d,
|
|
42
42
|
{
|
|
43
43
|
flexDirection: "column",
|
|
@@ -45,30 +45,30 @@ function _(i) {
|
|
|
45
45
|
hideAt: ["sm", "md"],
|
|
46
46
|
className: o.customer,
|
|
47
47
|
children: [
|
|
48
|
-
/* @__PURE__ */
|
|
48
|
+
/* @__PURE__ */ t(c, { size: "xxs", children: [
|
|
49
49
|
"Acct: ",
|
|
50
50
|
e == null ? void 0 : e.number
|
|
51
51
|
] }),
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ t(c, { size: "sm", variant: "display", colorToken: "links", children: [
|
|
53
53
|
"Hello ",
|
|
54
54
|
e == null ? void 0 : e.name
|
|
55
55
|
] })
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
),
|
|
59
|
-
e.avatar ?? (e.initials ? /* @__PURE__ */
|
|
59
|
+
e.avatar ?? (e.initials ? /* @__PURE__ */ n(u, { initials: e.initials }) : null)
|
|
60
60
|
]
|
|
61
61
|
}
|
|
62
62
|
),
|
|
63
63
|
children: a
|
|
64
64
|
}
|
|
65
|
-
) : /* @__PURE__ */
|
|
65
|
+
) : /* @__PURE__ */ t(
|
|
66
66
|
"div",
|
|
67
67
|
{
|
|
68
68
|
className: g(o.loggedIn, m(s), r),
|
|
69
69
|
...l,
|
|
70
70
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ t(
|
|
72
72
|
d,
|
|
73
73
|
{
|
|
74
74
|
flexDirection: "column",
|
|
@@ -76,18 +76,15 @@ function _(i) {
|
|
|
76
76
|
hideAt: ["sm", "md"],
|
|
77
77
|
className: o.customer,
|
|
78
78
|
children: [
|
|
79
|
-
/* @__PURE__ */ n(c, { size: "xxs", children:
|
|
80
|
-
|
|
81
|
-
e == null ? void 0 : e.number
|
|
82
|
-
] }),
|
|
83
|
-
/* @__PURE__ */ n(c, { size: "sm", variant: "display", colorToken: "links", children: [
|
|
79
|
+
/* @__PURE__ */ n(c, { size: "xxs", children: e == null ? void 0 : e.number }),
|
|
80
|
+
/* @__PURE__ */ t(c, { size: "sm", variant: "display", colorToken: "links", children: [
|
|
84
81
|
"Hello ",
|
|
85
82
|
e == null ? void 0 : e.name
|
|
86
83
|
] })
|
|
87
84
|
]
|
|
88
85
|
}
|
|
89
86
|
),
|
|
90
|
-
e.avatar ?? (e.initials ? /* @__PURE__ */
|
|
87
|
+
e.avatar ?? (e.initials ? /* @__PURE__ */ n(u, { initials: e.initials }) : null)
|
|
91
88
|
]
|
|
92
89
|
}
|
|
93
90
|
);
|
|
@@ -101,7 +98,7 @@ function N(i) {
|
|
|
101
98
|
isAccountLoading: h,
|
|
102
99
|
...l
|
|
103
100
|
} = i;
|
|
104
|
-
return /* @__PURE__ */
|
|
101
|
+
return /* @__PURE__ */ t(
|
|
105
102
|
d,
|
|
106
103
|
{
|
|
107
104
|
flexDirection: "row",
|
|
@@ -113,7 +110,7 @@ function N(i) {
|
|
|
113
110
|
r
|
|
114
111
|
),
|
|
115
112
|
children: [
|
|
116
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ n(
|
|
117
114
|
p,
|
|
118
115
|
{
|
|
119
116
|
onClick: e,
|
|
@@ -123,7 +120,7 @@ function N(i) {
|
|
|
123
120
|
children: "Sign In / Register"
|
|
124
121
|
}
|
|
125
122
|
),
|
|
126
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ n(f, { iconKey: "fa-kit fa-user-anon", size: "lg", hideAt: "lg" })
|
|
127
124
|
]
|
|
128
125
|
}
|
|
129
126
|
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ImageViewerProps {
|
|
2
|
+
imgSrc: string;
|
|
3
|
+
zoomFactor?: number;
|
|
4
|
+
minZoomScale?: number;
|
|
5
|
+
maxZoomScale?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function ImageViewer({ imgSrc, zoomFactor, // Default 10% per wheel notch
|
|
8
|
+
minZoomScale, maxZoomScale, }: ImageViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as U } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as o, useEffect as Q } from "react";
|
|
3
|
+
function Z({
|
|
4
|
+
imgSrc: j,
|
|
5
|
+
zoomFactor: O = 1.1,
|
|
6
|
+
// Default 10% per wheel notch
|
|
7
|
+
minZoomScale: x = 1,
|
|
8
|
+
maxZoomScale: z = 5
|
|
9
|
+
// 500%
|
|
10
|
+
}) {
|
|
11
|
+
const D = o(null), a = o(null), d = o(null), h = o(1), g = o(0), p = o(0), P = o(null), y = o(!1), A = o(0), b = o(0), W = o(0), B = o(0), R = o(!1), u = o(/* @__PURE__ */ new Map()), T = o(0), q = o(1), L = o({ x: 0, y: 0 });
|
|
12
|
+
Q(() => {
|
|
13
|
+
const t = a.current, n = D.current;
|
|
14
|
+
if (!t || !n) return;
|
|
15
|
+
const s = () => {
|
|
16
|
+
const e = n.getBoundingClientRect();
|
|
17
|
+
t.height = e.height, t.width = e.width;
|
|
18
|
+
const c = t.getContext("2d");
|
|
19
|
+
c && (c.setTransform(1, 0, 0, 1, 0, 0), d.current = c, k());
|
|
20
|
+
};
|
|
21
|
+
s();
|
|
22
|
+
const r = new ResizeObserver(s);
|
|
23
|
+
return r.observe(n), s(), () => r.disconnect();
|
|
24
|
+
}, []);
|
|
25
|
+
const k = () => {
|
|
26
|
+
const t = a.current;
|
|
27
|
+
if (!d.current || !t) return;
|
|
28
|
+
d.current.clearRect(0, 0, t.width, t.height);
|
|
29
|
+
const n = new Image();
|
|
30
|
+
n.crossOrigin = "anonymous", n.src = j, n.onload = () => {
|
|
31
|
+
P.current = n, Y();
|
|
32
|
+
};
|
|
33
|
+
}, Y = () => {
|
|
34
|
+
const t = a.current, n = P.current;
|
|
35
|
+
if (!d.current || !t || !n) return;
|
|
36
|
+
const s = n.width / 2, r = n.height / 2, e = t.width / 2, c = t.height / 2, i = e - s, f = c - r;
|
|
37
|
+
h.current = 1, g.current = i, p.current = f, v();
|
|
38
|
+
}, E = (t) => {
|
|
39
|
+
const n = a.current;
|
|
40
|
+
if (!d.current || !n) return;
|
|
41
|
+
const s = t.deltaY < 0 ? O : 1 / O, r = h.current;
|
|
42
|
+
let e = r * s;
|
|
43
|
+
if (e = Math.max(x, Math.min(z, e)), h.current = e, e === x) {
|
|
44
|
+
Y();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const { x: c, y: i } = X(t, n), f = (c - g.current) / r, w = (i - p.current) / r, m = c - f * e, l = i - w * e;
|
|
48
|
+
g.current = m, p.current = l, v();
|
|
49
|
+
}, H = (t) => {
|
|
50
|
+
var r;
|
|
51
|
+
const n = a.current;
|
|
52
|
+
if (!d.current || !n) return;
|
|
53
|
+
(r = a.current) == null || r.setPointerCapture(t.pointerId);
|
|
54
|
+
const s = X(t, n);
|
|
55
|
+
if (u.current.set(t.pointerId, s), u.current.size === 2) {
|
|
56
|
+
R.current = !0, y.current = !1;
|
|
57
|
+
const [e, c] = Array.from(u.current.values()), i = e.x - c.x, f = e.y - c.y, w = Math.sqrt(i * i + f * f);
|
|
58
|
+
T.current = w, q.current = h.current;
|
|
59
|
+
const m = (e.x + c.x) / 2, l = (e.y + c.y) / 2, M = (m - g.current) / h.current, C = (l - p.current) / h.current;
|
|
60
|
+
L.current = { x: M, y: C }, R.current = !0;
|
|
61
|
+
} else if (u.current.size === 1) {
|
|
62
|
+
const [e] = Array.from(u.current.values());
|
|
63
|
+
A.current = e.x, b.current = e.y, W.current = g.current, B.current = p.current, y.current = !0;
|
|
64
|
+
}
|
|
65
|
+
}, S = (t) => {
|
|
66
|
+
const n = a.current;
|
|
67
|
+
if (!d.current || !n) return;
|
|
68
|
+
const s = X(t, n);
|
|
69
|
+
if (u.current.has(t.pointerId)) {
|
|
70
|
+
if (u.current.set(t.pointerId, s), R.current && u.current.size === 2) {
|
|
71
|
+
const [r, e] = Array.from(u.current.values()), c = r.x - e.x, i = r.y - e.y, f = Math.sqrt(c * c + i * i), w = T.current;
|
|
72
|
+
if (w === 0) return;
|
|
73
|
+
const m = f / w;
|
|
74
|
+
let l = q.current * m;
|
|
75
|
+
if (l = Math.max(x, Math.min(z, l)), l === x) {
|
|
76
|
+
Y();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const M = (r.x + e.x) / 2, C = (r.y + e.y) / 2, { x: G, y: J } = L.current, K = M - G * l, N = C - J * l;
|
|
80
|
+
h.current = l, g.current = K, p.current = N, v();
|
|
81
|
+
} else if (y.current && u.current.size === 1) {
|
|
82
|
+
const r = n.getBoundingClientRect(), e = t.clientX - r.left, c = t.clientY - r.top, i = e - A.current, f = c - b.current;
|
|
83
|
+
g.current = W.current + i, p.current = B.current + f, v();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, I = (t) => {
|
|
87
|
+
u.current.delete(t.pointerId), u.current.size < 2 && (R.current = !1), u.current.size === 0 && (y.current = !1);
|
|
88
|
+
const n = a.current;
|
|
89
|
+
!d.current || !n || n.releasePointerCapture(t.pointerId);
|
|
90
|
+
}, V = I, F = I, X = (t, n) => {
|
|
91
|
+
const s = n.getBoundingClientRect();
|
|
92
|
+
return {
|
|
93
|
+
x: t.clientX - s.left,
|
|
94
|
+
y: t.clientY - s.top
|
|
95
|
+
};
|
|
96
|
+
}, v = () => {
|
|
97
|
+
const t = a.current, n = d.current, s = P.current;
|
|
98
|
+
!t || !n || !s || (n.setTransform(1, 0, 0, 1, 0, 0), n.clearRect(0, 0, t.width, t.height), n.setTransform(
|
|
99
|
+
h.current,
|
|
100
|
+
0,
|
|
101
|
+
0,
|
|
102
|
+
h.current,
|
|
103
|
+
g.current,
|
|
104
|
+
p.current
|
|
105
|
+
), n.drawImage(s, 0, 0));
|
|
106
|
+
};
|
|
107
|
+
return /* @__PURE__ */ U("div", { ref: D, style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ U(
|
|
108
|
+
"canvas",
|
|
109
|
+
{
|
|
110
|
+
ref: a,
|
|
111
|
+
style: { width: "100%", height: "100%", display: "block", touchAction: "none" },
|
|
112
|
+
onWheel: E,
|
|
113
|
+
onPointerDown: H,
|
|
114
|
+
onPointerMove: S,
|
|
115
|
+
onPointerUp: I,
|
|
116
|
+
onPointerLeave: V,
|
|
117
|
+
onPointerCancel: F
|
|
118
|
+
}
|
|
119
|
+
) });
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
Z as ImageViewer
|
|
123
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { ImageViewer as o } from "./ImageViewer.js";
|
|
3
|
+
const r = {
|
|
4
|
+
title: "Case Parts/Molecules/ImageViewer",
|
|
5
|
+
component: o,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: "fullscreen"
|
|
8
|
+
},
|
|
9
|
+
argTypes: {
|
|
10
|
+
imgSrc: { control: "text" },
|
|
11
|
+
zoomFactor: { control: { type: "number", min: 1, max: 2, step: 0.01 } },
|
|
12
|
+
minZoomScale: { control: { type: "number", min: 0.1, max: 2, step: 0.1 } },
|
|
13
|
+
maxZoomScale: { control: { type: "number", min: 2, max: 10, step: 0.5 } }
|
|
14
|
+
},
|
|
15
|
+
decorators: [
|
|
16
|
+
(t) => /* @__PURE__ */ e("div", { style: { height: "90dvh", width: "100%" }, children: /* @__PURE__ */ e(t, {}) })
|
|
17
|
+
]
|
|
18
|
+
}, c = {
|
|
19
|
+
name: "Default",
|
|
20
|
+
args: {
|
|
21
|
+
imgSrc: "https://cdnimg.webstaurantstore.com/images/products/large/573147/2989461.jpg",
|
|
22
|
+
zoomFactor: 1.1,
|
|
23
|
+
minZoomScale: 1,
|
|
24
|
+
maxZoomScale: 5
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
c as Default,
|
|
29
|
+
r as default
|
|
30
|
+
};
|