@caseparts-org/caseblocks 0.0.113 → 0.0.115
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,15 +1,10 @@
|
|
|
1
|
+
import { PopoverAPI } from './usePopover';
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
type PositionKeyword = "top" | "right" | "bottom" | "left";
|
|
3
4
|
type Position = "top left" | "top center" | "top right" | "right top" | "right center" | "right bottom" | "bottom left" | "bottom center" | "bottom right" | "left top" | "left center" | "left bottom" | PositionKeyword;
|
|
4
|
-
type PopoverAPI = {
|
|
5
|
-
close: () => void;
|
|
6
|
-
open: () => void;
|
|
7
|
-
toggle: () => void;
|
|
8
|
-
};
|
|
9
|
-
export declare function usePopover(): PopoverAPI;
|
|
10
5
|
export type PopoverProps = {
|
|
11
6
|
trigger: React.ReactElement;
|
|
12
|
-
children: React.ReactNode | ((
|
|
7
|
+
children: React.ReactNode | ((_api: PopoverAPI) => React.ReactNode);
|
|
13
8
|
position?: Position;
|
|
14
9
|
popoverClassName?: string;
|
|
15
10
|
contentClassName?: string;
|
|
@@ -1,85 +1,80 @@
|
|
|
1
1
|
import { jsxs as H, jsx as k } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
2
|
+
import * as f from "react";
|
|
3
3
|
import { r as N } from "../../index-B4KbmMH3.js";
|
|
4
4
|
import { c as z } from "../../clsx-OuTLNxxd.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error("usePopover must be used within a Popover");
|
|
13
|
-
return o;
|
|
14
|
-
}
|
|
15
|
-
function D(o) {
|
|
16
|
-
return o ? o.includes(" ") ? o : `${o} center` : "top center";
|
|
5
|
+
import { PopoverContext as W } from "./usePopover.js";
|
|
6
|
+
import '../../assets/Popover.css';const q = "_popover_vlr81_1", C = "_content_vlr81_7", M = {
|
|
7
|
+
popover: q,
|
|
8
|
+
content: C
|
|
9
|
+
};
|
|
10
|
+
function D(r) {
|
|
11
|
+
return r ? r.includes(" ") ? r : `${r} center` : "top center";
|
|
17
12
|
}
|
|
18
|
-
function F(
|
|
19
|
-
const
|
|
20
|
-
return { side: ["top", "right", "bottom", "left"].includes(
|
|
13
|
+
function F(r) {
|
|
14
|
+
const d = D(r).toLowerCase(), [s, c] = d.split(" ");
|
|
15
|
+
return { side: ["top", "right", "bottom", "left"].includes(s) ? s : "top", align: c === "left" || c === "top" ? "start" : c === "right" || c === "bottom" ? "end" : "center" };
|
|
21
16
|
}
|
|
22
|
-
function U(
|
|
23
|
-
const
|
|
24
|
-
let a = 0,
|
|
25
|
-
|
|
17
|
+
function U(r, d, s, c, p = 8) {
|
|
18
|
+
const o = r.getBoundingClientRect(), l = d.getBoundingClientRect();
|
|
19
|
+
let a = 0, u = 0;
|
|
20
|
+
s === "top" ? a = o.top - l.height - p : s === "bottom" ? a = o.bottom + p : s === "left" ? u = o.left - l.width - p : s === "right" && (u = o.right + p), s === "top" || s === "bottom" ? c === "start" ? u = o.left : c === "end" ? u = o.right - l.width : u = o.left + o.width / 2 - l.width / 2 : c === "start" ? a = o.top : c === "end" ? a = o.bottom - l.height : a = o.top + o.height / 2 - l.height / 2;
|
|
26
21
|
const w = window.innerWidth, h = window.innerHeight;
|
|
27
|
-
return a = Math.max(4, Math.min(h -
|
|
22
|
+
return a = Math.max(4, Math.min(h - l.height - 4, a)), u = Math.max(4, Math.min(w - l.width - 4, u)), { top: a, left: u };
|
|
28
23
|
}
|
|
29
24
|
const Q = ({
|
|
30
|
-
trigger:
|
|
31
|
-
children:
|
|
32
|
-
position:
|
|
33
|
-
popoverClassName:
|
|
34
|
-
contentClassName:
|
|
35
|
-
disabled:
|
|
36
|
-
closeOnOutsideClick:
|
|
25
|
+
trigger: r,
|
|
26
|
+
children: d,
|
|
27
|
+
position: s,
|
|
28
|
+
popoverClassName: c,
|
|
29
|
+
contentClassName: p,
|
|
30
|
+
disabled: o,
|
|
31
|
+
closeOnOutsideClick: l = !0,
|
|
37
32
|
closeOnInsideClickAttr: a = !0,
|
|
38
|
-
open:
|
|
33
|
+
open: u,
|
|
39
34
|
onOpenChange: w
|
|
40
35
|
}) => {
|
|
41
|
-
const { side: h, align: y } = F(
|
|
42
|
-
const e = typeof t == "function" ? t(
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
}, E = () =>
|
|
36
|
+
const { side: h, align: y } = F(s), [S, j] = f.useState(!1), R = typeof u == "boolean", n = R ? u : S, [m, P] = f.useState(null), b = f.useRef(null), v = f.useRef(null), L = (t) => {
|
|
37
|
+
const e = typeof t == "function" ? t(n) : t;
|
|
38
|
+
R ? w == null || w(e) : j(e);
|
|
39
|
+
}, x = () => {
|
|
40
|
+
o || L((t) => !t);
|
|
41
|
+
}, E = () => L(!1), _ = () => L(!0), B = f.cloneElement(r, {
|
|
47
42
|
ref: (t) => {
|
|
48
|
-
const { ref: e } =
|
|
43
|
+
const { ref: e } = r;
|
|
49
44
|
typeof e == "function" ? e(t) : e && (e.current = t), b.current = t;
|
|
50
45
|
},
|
|
51
46
|
onClick: (t) => {
|
|
52
47
|
var e, i;
|
|
53
|
-
(i = (e =
|
|
48
|
+
(i = (e = r.props).onClick) == null || i.call(e, t), x();
|
|
54
49
|
},
|
|
55
50
|
"aria-haspopup": "dialog",
|
|
56
|
-
"aria-expanded":
|
|
57
|
-
"aria-controls":
|
|
58
|
-
style: { ...
|
|
51
|
+
"aria-expanded": n || void 0,
|
|
52
|
+
"aria-controls": n ? "popover-panel" : void 0,
|
|
53
|
+
style: { ...r.props.style || {}, outline: "none" }
|
|
59
54
|
});
|
|
60
|
-
return
|
|
61
|
-
if (!
|
|
62
|
-
|
|
55
|
+
return f.useLayoutEffect(() => {
|
|
56
|
+
if (!n) {
|
|
57
|
+
P(null);
|
|
63
58
|
return;
|
|
64
59
|
}
|
|
65
|
-
const t = b.current, e =
|
|
60
|
+
const t = b.current, e = v.current;
|
|
66
61
|
if (!t || !e) return;
|
|
67
62
|
const i = () => {
|
|
68
|
-
|
|
63
|
+
P(U(t, e, h, y, 8));
|
|
69
64
|
};
|
|
70
65
|
return i(), window.addEventListener("resize", i), window.addEventListener("scroll", i, !0), () => {
|
|
71
66
|
window.removeEventListener("resize", i), window.removeEventListener("scroll", i, !0);
|
|
72
67
|
};
|
|
73
|
-
}, [
|
|
74
|
-
if (!
|
|
68
|
+
}, [n, h, y, d]), f.useEffect(() => {
|
|
69
|
+
if (!n || !l) return;
|
|
75
70
|
const t = (e) => {
|
|
76
|
-
const i =
|
|
71
|
+
const i = v.current, g = b.current;
|
|
77
72
|
!i || !g || i.contains(e.target) || g.contains(e.target) || E();
|
|
78
73
|
};
|
|
79
74
|
return window.addEventListener("mousedown", t), () => window.removeEventListener("mousedown", t);
|
|
80
|
-
}, [
|
|
81
|
-
if (!
|
|
82
|
-
const t =
|
|
75
|
+
}, [n, l]), f.useEffect(() => {
|
|
76
|
+
if (!n || !a) return;
|
|
77
|
+
const t = v.current;
|
|
83
78
|
if (!t) return;
|
|
84
79
|
const e = (i) => {
|
|
85
80
|
const g = i.target;
|
|
@@ -87,40 +82,40 @@ const Q = ({
|
|
|
87
82
|
g.closest('[data-popover-close="true"]') && E();
|
|
88
83
|
};
|
|
89
84
|
return t.addEventListener("click", e), () => t.removeEventListener("click", e);
|
|
90
|
-
}, [
|
|
91
|
-
if (!
|
|
85
|
+
}, [n, a]), f.useEffect(() => {
|
|
86
|
+
if (!n) return;
|
|
92
87
|
const t = (e) => {
|
|
93
88
|
e.key === "Escape" && E();
|
|
94
89
|
};
|
|
95
90
|
return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
|
|
96
|
-
}, [
|
|
97
|
-
if (
|
|
98
|
-
const t =
|
|
91
|
+
}, [n]), f.useEffect(() => {
|
|
92
|
+
if (n && v.current) {
|
|
93
|
+
const t = v.current.querySelector(
|
|
99
94
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
100
95
|
);
|
|
101
96
|
t == null || t.focus();
|
|
102
97
|
}
|
|
103
|
-
}, [
|
|
98
|
+
}, [n]), /* @__PURE__ */ H(W.Provider, { value: { close: E, open: _, toggle: x }, children: [
|
|
104
99
|
B,
|
|
105
|
-
|
|
100
|
+
n && typeof document < "u" && N.createPortal(
|
|
106
101
|
/* @__PURE__ */ k(
|
|
107
102
|
"div",
|
|
108
103
|
{
|
|
109
104
|
id: "popover-panel",
|
|
110
|
-
ref:
|
|
105
|
+
ref: v,
|
|
111
106
|
role: "dialog",
|
|
112
107
|
"aria-modal": "false",
|
|
113
|
-
className: z(M.popover,
|
|
108
|
+
className: z(M.popover, c),
|
|
114
109
|
"data-side": h,
|
|
115
110
|
"data-align": y,
|
|
116
111
|
style: {
|
|
117
112
|
position: "absolute",
|
|
118
|
-
top: (
|
|
119
|
-
left: (
|
|
120
|
-
visibility:
|
|
113
|
+
top: (m == null ? void 0 : m.top) ?? 0,
|
|
114
|
+
left: (m == null ? void 0 : m.left) ?? 0,
|
|
115
|
+
visibility: m ? "visible" : "hidden",
|
|
121
116
|
zIndex: 20
|
|
122
117
|
},
|
|
123
|
-
children: /* @__PURE__ */ k("div", { className: z(M.content,
|
|
118
|
+
children: /* @__PURE__ */ k("div", { className: z(M.content, p), children: typeof d == "function" ? d({ close: E, open: _, toggle: x }) : d })
|
|
124
119
|
}
|
|
125
120
|
),
|
|
126
121
|
document.body
|
|
@@ -128,6 +123,5 @@ const Q = ({
|
|
|
128
123
|
] });
|
|
129
124
|
};
|
|
130
125
|
export {
|
|
131
|
-
Q as Popover
|
|
132
|
-
K as usePopover
|
|
126
|
+
Q as Popover
|
|
133
127
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
const t = e.createContext(null);
|
|
3
|
+
function r() {
|
|
4
|
+
const o = e.useContext(t);
|
|
5
|
+
if (!o)
|
|
6
|
+
throw new Error("usePopover must be used within a Popover");
|
|
7
|
+
return o;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
t as PopoverContext,
|
|
11
|
+
r as usePopover
|
|
12
|
+
};
|
package/dist/main-client.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type { SlideInPanelProps } from './atoms/SlideInPanel/SlideInPanel';
|
|
|
6
6
|
export { Tooltip } from './atoms/Tooltip/Tooltip';
|
|
7
7
|
export { Popover } from './atoms/Popover/Popover';
|
|
8
8
|
export type { PopoverProps } from './atoms/Popover/Popover';
|
|
9
|
+
export { usePopover } from './atoms/Popover/usePopover';
|
|
10
|
+
export type { PopoverAPI } from './atoms/Popover/usePopover';
|
|
9
11
|
export { Account } from './molecules/Account/Account';
|
|
10
12
|
export type { AccountProps } from './molecules/Account/Account';
|
|
11
13
|
export { Chip } from './molecules/Chip/Chip';
|
|
@@ -22,6 +24,8 @@ export { AnimatedCheckMark } from './molecules/StatefulButton/AnimatedCheckmark'
|
|
|
22
24
|
export type { AddToCartProps } from './molecules/AddToCart/AddToCart';
|
|
23
25
|
export { AddToCart } from './molecules/AddToCart/AddToCart';
|
|
24
26
|
export type { CategoryWithChildren as MainCategory, Category } from './molecules/CategoryNav/CategoryNav';
|
|
27
|
+
export { Modal } from './molecules/Modal/Modal';
|
|
28
|
+
export type { ModalProps } from './molecules/Modal/Modal';
|
|
25
29
|
export { MainNav } from './organisms/MainNav/MainNav';
|
|
26
30
|
export type { MainNavProps } from './organisms/MainNav/MainNav';
|
|
27
31
|
export { ChipSelector } from './organisms/ChipSelector/ChipSelector';
|
package/dist/main-client.js
CHANGED
|
@@ -6,13 +6,13 @@ 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
|
|
10
|
-
import { Link as
|
|
11
|
-
import { linkClassName as
|
|
12
|
-
import { configureLink as
|
|
9
|
+
import { Input as v } from "./atoms/Input/Input.js";
|
|
10
|
+
import { Link as I } from "./atoms/Link/Link.js";
|
|
11
|
+
import { linkClassName as s } from "./atoms/Link/linkClassName.js";
|
|
12
|
+
import { configureLink as L, routerOverride as h } from "./atoms/Link/configureLink.js";
|
|
13
13
|
import { LinkButton as F } from "./atoms/LinkButton/LinkButton.js";
|
|
14
|
-
import { configureImage as
|
|
15
|
-
import { Logo as
|
|
14
|
+
import { configureImage as N } from "./atoms/Image/configureImage.js";
|
|
15
|
+
import { Logo as y } from "./molecules/Logo/Logo.js";
|
|
16
16
|
import { SearchBox as w } from "./molecules/SearchBox/SearchBox.js";
|
|
17
17
|
import { QuantityInput as G } from "./molecules/QuantityInput/QuantityInput.js";
|
|
18
18
|
import { Pricing as Q } from "./molecules/Pricing/Pricing.js";
|
|
@@ -26,59 +26,63 @@ import { HorizontalScroll as _ } from "./atoms/HorizontalScroll/HorizontalScroll
|
|
|
26
26
|
import { SlideInPanel as oo } from "./atoms/SlideInPanel/SlideInPanel.js";
|
|
27
27
|
import { Tooltip as eo } from "./atoms/Tooltip/Tooltip.js";
|
|
28
28
|
import { Popover as po } from "./atoms/Popover/Popover.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
29
|
+
import { usePopover as fo } from "./atoms/Popover/usePopover.js";
|
|
30
|
+
import { Account as ao } from "./molecules/Account/Account.js";
|
|
31
|
+
import { Chip as io } from "./molecules/Chip/Chip.js";
|
|
32
|
+
import { ToggleView as uo } from "./molecules/ToggleView/ToggleView.js";
|
|
33
|
+
import { CartSlideInPanel as Co } from "./molecules/Cart/CartSlideInPanel.js";
|
|
34
|
+
import { StatefulButton as ko } from "./molecules/StatefulButton/StatefulButton.js";
|
|
35
|
+
import { AnimatedCheckMark as vo } from "./molecules/StatefulButton/AnimatedCheckmark.js";
|
|
36
|
+
import { AddToCart as Io } from "./molecules/AddToCart/AddToCart.js";
|
|
37
|
+
import { Modal as so } from "./molecules/Modal/Modal.js";
|
|
38
|
+
import { MainNav as Lo } 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 Ho } from "./organisms/Footer/Footer.js";
|
|
41
43
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
ao as Account,
|
|
45
|
+
Io as AddToCart,
|
|
46
|
+
vo as AnimatedCheckMark,
|
|
45
47
|
V as Availability,
|
|
46
48
|
q as Avatar,
|
|
47
49
|
E as BannerCard,
|
|
48
50
|
W as Breadcrumbs,
|
|
49
51
|
e as Button,
|
|
50
52
|
K as CardLink,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
bo as Carousel,
|
|
54
|
+
Co as CartSlideInPanel,
|
|
55
|
+
io as Chip,
|
|
56
|
+
To as ChipSelector,
|
|
55
57
|
f as Column,
|
|
56
58
|
p as Flex,
|
|
57
|
-
|
|
59
|
+
Ho as Footer,
|
|
58
60
|
x as Grid,
|
|
59
61
|
n as Head,
|
|
60
62
|
_ as HorizontalScroll,
|
|
61
63
|
l as Icon,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
v as Input,
|
|
65
|
+
I as Link,
|
|
64
66
|
F as LinkButton,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
y as Logo,
|
|
68
|
+
Lo as MainNav,
|
|
69
|
+
so as Modal,
|
|
67
70
|
Y as NotFound,
|
|
68
71
|
po as Popover,
|
|
69
72
|
Q as Pricing,
|
|
70
|
-
|
|
73
|
+
Mo as Product,
|
|
71
74
|
G as QuantityInput,
|
|
72
75
|
d as Root,
|
|
73
76
|
w as SearchBox,
|
|
74
77
|
C as Separator,
|
|
75
78
|
oo as SlideInPanel,
|
|
76
|
-
|
|
79
|
+
ko as StatefulButton,
|
|
77
80
|
k as Text,
|
|
78
|
-
|
|
81
|
+
uo as ToggleView,
|
|
79
82
|
eo as Tooltip,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
N as configureImage,
|
|
84
|
+
L as configureLink,
|
|
85
|
+
s as linkClassName,
|
|
86
|
+
h as routerOverride,
|
|
87
|
+
fo as usePopover
|
|
84
88
|
};
|