@janbox/storefront-ui 4.0.12 → 4.0.13
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/lib/dialog/dialog/dialog.js +28 -60
- package/dist/lib/drawer/drawer/drawer.js +2 -7
- package/dist/lib/floating/floating/floating.js +3 -1
- package/dist/lib/floating/floating/types.d.ts +2 -1
- package/dist/lib/floating/floating-content/floating-content.d.ts +1 -1
- package/dist/lib/floating/floating-content/floating-content.js +28 -37
- package/dist/lib/floating/floating-content/types.d.ts +5 -9
- package/dist/lib/lightbox/lightbox.js +2 -7
- package/package.json +1 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getDialogProps, getDialogSizeInNumber } from "./helpers.js";
|
|
3
|
-
import {
|
|
3
|
+
import { breakpoint } from "../../../theme/screens.js";
|
|
4
|
+
import { getColorVar } from "../../../theme/palette.js";
|
|
4
5
|
import { Floating } from "../../floating/floating/floating.js";
|
|
5
6
|
import { FloatingContent } from "../../floating/floating-content/floating-content.js";
|
|
6
|
-
import { Primitive } from "../../primitive/primitive.js";
|
|
7
|
-
import { getColorVar } from "../../../theme/palette.js";
|
|
8
|
-
import { mediaQuery } from "../../../theme/screens.js";
|
|
9
7
|
const Dialog = (_props) => {
|
|
10
8
|
const { size, sm, md, lg, children, ...props } = getDialogProps(_props);
|
|
11
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -15,71 +13,41 @@ const Dialog = (_props) => {
|
|
|
15
13
|
enabled: true
|
|
16
14
|
},
|
|
17
15
|
...props,
|
|
18
|
-
children: /* @__PURE__ */
|
|
16
|
+
children: /* @__PURE__ */ jsx(
|
|
19
17
|
FloatingContent,
|
|
20
18
|
{
|
|
21
|
-
|
|
22
|
-
disabled: false,
|
|
23
|
-
css: {
|
|
24
|
-
display: "grid",
|
|
25
|
-
placeItems: "center",
|
|
26
|
-
padding: "1rem",
|
|
27
|
-
[mediaQuery("sm")]: { padding: "1.25rem" },
|
|
28
|
-
[mediaQuery("md")]: { padding: "1.5rem" }
|
|
29
|
-
},
|
|
19
|
+
overlay: {
|
|
30
20
|
lockScroll: true,
|
|
31
21
|
style: {
|
|
32
|
-
|
|
22
|
+
display: "grid",
|
|
23
|
+
placeItems: "center",
|
|
24
|
+
backgroundColor: "rgba(0, 0, 0, 0.4)",
|
|
25
|
+
backdropFilter: "blur(2px)"
|
|
33
26
|
}
|
|
34
27
|
},
|
|
35
28
|
sx: {
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
width: getDialogSizeInNumber(size),
|
|
30
|
+
backgroundColor: getColorVar("surface.default"),
|
|
31
|
+
maxWidth: `calc(100% - ${breakpoint.xs.padding * 2}px)`,
|
|
38
32
|
overflow: "hidden",
|
|
39
33
|
display: "flex",
|
|
40
|
-
flexDirection: "column"
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
borderRadius: 8,
|
|
36
|
+
paddingBlock: 8,
|
|
37
|
+
sm: {
|
|
38
|
+
width: getDialogSizeInNumber(sm == null ? void 0 : sm.size),
|
|
39
|
+
maxWidth: `calc(100% - ${breakpoint.sm.padding * 2}px)`
|
|
40
|
+
},
|
|
41
|
+
md: {
|
|
42
|
+
width: getDialogSizeInNumber(md == null ? void 0 : md.size),
|
|
43
|
+
maxWidth: `calc(100% - ${breakpoint.md.padding * 2}px)`
|
|
44
|
+
},
|
|
45
|
+
lg: {
|
|
46
|
+
width: getDialogSizeInNumber(lg == null ? void 0 : lg.size),
|
|
47
|
+
maxWidth: `calc(100% - ${breakpoint.lg.padding * 2}px)`
|
|
48
|
+
}
|
|
41
49
|
},
|
|
42
|
-
children
|
|
43
|
-
/* @__PURE__ */ jsx(
|
|
44
|
-
Primitive,
|
|
45
|
-
{
|
|
46
|
-
sx: {
|
|
47
|
-
backdropFilter: "blur(2px)",
|
|
48
|
-
position: "fixed",
|
|
49
|
-
inset: 0,
|
|
50
|
-
backgroundColor: "rgba(0, 0, 0, 0.4)",
|
|
51
|
-
pointerEvents: "none"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
),
|
|
55
|
-
/* @__PURE__ */ jsx(
|
|
56
|
-
Primitive,
|
|
57
|
-
{
|
|
58
|
-
sx: {
|
|
59
|
-
width: getDialogSizeInNumber(size),
|
|
60
|
-
backgroundColor: getColorVar("surface.default"),
|
|
61
|
-
maxWidth: "100%",
|
|
62
|
-
overflow: "hidden",
|
|
63
|
-
display: "flex",
|
|
64
|
-
flexDirection: "column",
|
|
65
|
-
borderRadius: "0.5rem",
|
|
66
|
-
paddingTop: "0.5rem",
|
|
67
|
-
paddingBottom: "0.5rem",
|
|
68
|
-
position: "relative",
|
|
69
|
-
sm: {
|
|
70
|
-
width: getDialogSizeInNumber(sm == null ? void 0 : sm.size)
|
|
71
|
-
},
|
|
72
|
-
md: {
|
|
73
|
-
width: getDialogSizeInNumber(md == null ? void 0 : md.size)
|
|
74
|
-
},
|
|
75
|
-
lg: {
|
|
76
|
-
width: getDialogSizeInNumber(lg == null ? void 0 : lg.size)
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
children
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
]
|
|
50
|
+
children
|
|
83
51
|
}
|
|
84
52
|
)
|
|
85
53
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { motion } from "motion/react";
|
|
4
|
-
import { FLOATING_Z_INDEX } from "../../../theme/index.js";
|
|
5
4
|
import { Floating } from "../../floating/floating/floating.js";
|
|
6
5
|
import { FloatingContent } from "../../floating/floating-content/floating-content.js";
|
|
7
6
|
import { Primitive } from "../../primitive/primitive.js";
|
|
@@ -39,12 +38,8 @@ const Drawer = ({ children, placement = "left", ...props }) => {
|
|
|
39
38
|
children: /* @__PURE__ */ jsxs(
|
|
40
39
|
FloatingContent,
|
|
41
40
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
lockScroll: true,
|
|
45
|
-
style: {
|
|
46
|
-
zIndex: FLOATING_Z_INDEX
|
|
47
|
-
}
|
|
41
|
+
overlay: {
|
|
42
|
+
lockScroll: true
|
|
48
43
|
},
|
|
49
44
|
sx: {
|
|
50
45
|
maxHeight: "100%",
|
|
@@ -30,6 +30,7 @@ const FloatingCore = ({
|
|
|
30
30
|
offsetOptions = 4,
|
|
31
31
|
sizeOptions,
|
|
32
32
|
autoUpdateOptions,
|
|
33
|
+
strategy,
|
|
33
34
|
ref
|
|
34
35
|
}) => {
|
|
35
36
|
const floating = useFloating({
|
|
@@ -72,7 +73,8 @@ const FloatingCore = ({
|
|
|
72
73
|
whileElementsMounted: (...args) => {
|
|
73
74
|
return autoUpdate(...args, autoUpdateOptions);
|
|
74
75
|
},
|
|
75
|
-
elements
|
|
76
|
+
elements,
|
|
77
|
+
strategy
|
|
76
78
|
});
|
|
77
79
|
useImperativeHandle(ref, () => floating, [floating]);
|
|
78
80
|
const { context } = floating;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { AutoUpdateOptions, OffsetOptions, Placement, SizeOptions, UseClickProps, UseDismissProps, UseFloatingOptions, UseFloatingReturn, UseFocusProps, UseHoverProps } from '@floating-ui/react';
|
|
2
|
+
import { AutoUpdateOptions, OffsetOptions, Placement, SizeOptions, Strategy, UseClickProps, UseDismissProps, UseFloatingOptions, UseFloatingReturn, UseFocusProps, UseHoverProps } from '@floating-ui/react';
|
|
3
3
|
export type FloatingProps = PropsWithChildren<{
|
|
4
4
|
placement?: Placement;
|
|
5
5
|
onOpenChange?: UseFloatingOptions['onOpenChange'];
|
|
@@ -13,5 +13,6 @@ export type FloatingProps = PropsWithChildren<{
|
|
|
13
13
|
sizeOptions?: SizeOptions;
|
|
14
14
|
autoUpdateOptions?: AutoUpdateOptions;
|
|
15
15
|
ref?: React.Ref<FloatingRef>;
|
|
16
|
+
strategy?: Strategy;
|
|
16
17
|
}>;
|
|
17
18
|
export type FloatingRef = UseFloatingReturn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FloatingContentProps } from './types';
|
|
2
|
-
export declare const FloatingContent: ({
|
|
2
|
+
export declare const FloatingContent: ({ preserveTabOrder, focus, overlay, sx, ref, ...props }: FloatingContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,55 +1,46 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMergeRefs, FloatingPortal, FloatingOverlay
|
|
3
|
-
import {
|
|
2
|
+
import { useMergeRefs, FloatingFocusManager, FloatingPortal, FloatingOverlay } from "@floating-ui/react";
|
|
3
|
+
import { motion, AnimatePresence } from "motion/react";
|
|
4
4
|
import { useFloatingContext } from "../floating/helpers.js";
|
|
5
5
|
import { FLOATING_Z_INDEX } from "../../../theme/index.js";
|
|
6
6
|
import { useIsHydrated } from "../../../hooks/use-is-hydrated/index.js";
|
|
7
7
|
import { usePortalContainer } from "../../../theme/provider.js";
|
|
8
8
|
import { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
9
|
-
const FloatingContent = ({
|
|
10
|
-
style,
|
|
11
|
-
floatingPortalProps,
|
|
12
|
-
floatingFocusManagerProps,
|
|
13
|
-
floatingOverlayProps,
|
|
14
|
-
sx,
|
|
15
|
-
ref,
|
|
16
|
-
...props
|
|
17
|
-
}) => {
|
|
9
|
+
const FloatingContent = ({ preserveTabOrder, focus, overlay, sx, ref, ...props }) => {
|
|
18
10
|
const { getFloatingProps, context } = useFloatingContext();
|
|
19
11
|
const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);
|
|
20
12
|
const isHydrated = useIsHydrated();
|
|
21
13
|
const portalRoot = usePortalContainer();
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
return /* @__PURE__ */ jsx(AnimatePresence, { children: context.open && isHydrated && /* @__PURE__ */ jsx(FloatingPortal, { root: resolvedRoot, ...portalProps, children: /* @__PURE__ */ jsx(
|
|
25
|
-
FloatingOverlay,
|
|
14
|
+
const mainContent = /* @__PURE__ */ jsx(FloatingFocusManager, { initialFocus: -1, context, ...focus, children: /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(
|
|
15
|
+
motion.div,
|
|
26
16
|
{
|
|
27
|
-
|
|
17
|
+
initial: { opacity: 0 },
|
|
18
|
+
animate: { opacity: 1 },
|
|
19
|
+
exit: { opacity: 0 },
|
|
20
|
+
...getFloatingProps({
|
|
21
|
+
...props,
|
|
22
|
+
className: cx(css(sx), props.className)
|
|
23
|
+
}),
|
|
28
24
|
style: {
|
|
29
|
-
|
|
30
|
-
...
|
|
25
|
+
...context.elements.reference ? context.floatingStyles : {},
|
|
26
|
+
...props.style,
|
|
27
|
+
zIndex: FLOATING_Z_INDEX
|
|
31
28
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
initial: { opacity: 0 },
|
|
36
|
-
animate: { opacity: 1 },
|
|
37
|
-
exit: { opacity: 0 },
|
|
38
|
-
style: {
|
|
39
|
-
...context.elements.reference ? context.floatingStyles : {},
|
|
40
|
-
...style,
|
|
41
|
-
zIndex: FLOATING_Z_INDEX
|
|
42
|
-
},
|
|
43
|
-
...getFloatingProps({
|
|
44
|
-
...props,
|
|
45
|
-
className: cx(css(sx), props.className)
|
|
46
|
-
}),
|
|
47
|
-
ref: mergedRefs,
|
|
48
|
-
children: props.children
|
|
49
|
-
}
|
|
50
|
-
) }) })
|
|
29
|
+
ref: mergedRefs,
|
|
30
|
+
children: props.children
|
|
51
31
|
}
|
|
52
32
|
) }) });
|
|
33
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: context.open && isHydrated && /* @__PURE__ */ jsx(FloatingPortal, { root: portalRoot ?? void 0, preserveTabOrder, children: overlay ? /* @__PURE__ */ jsx(
|
|
34
|
+
FloatingOverlay,
|
|
35
|
+
{
|
|
36
|
+
...overlay,
|
|
37
|
+
style: {
|
|
38
|
+
zIndex: FLOATING_Z_INDEX,
|
|
39
|
+
...overlay.style
|
|
40
|
+
},
|
|
41
|
+
children: mainContent
|
|
42
|
+
}
|
|
43
|
+
) : mainContent }) });
|
|
53
44
|
};
|
|
54
45
|
export {
|
|
55
46
|
FloatingContent
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { ComponentProps, HTMLProps } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { PropsWithSx, ShallowMerge } from '../../../types';
|
|
2
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, FloatingPortalProps } from '@floating-ui/react';
|
|
3
|
+
import { PropsWithSx } from '../../../types';
|
|
5
4
|
export type FloatingContentProps = PropsWithSx<HTMLProps<HTMLDivElement> & {
|
|
6
5
|
floatingPortalProps?: Partial<ComponentProps<typeof FloatingPortal>>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}>>;
|
|
11
|
-
floatingFocusManagerProps?: Partial<ComponentProps<typeof FloatingFocusManager>>;
|
|
12
|
-
}>;
|
|
6
|
+
focus?: Partial<ComponentProps<typeof FloatingFocusManager>>;
|
|
7
|
+
overlay?: Partial<ComponentProps<typeof FloatingOverlay>>;
|
|
8
|
+
} & Pick<FloatingPortalProps, 'preserveTabOrder'>>;
|
|
@@ -269,16 +269,11 @@ const Lightbox = ({ slides, defaultActiveIndex, ...props }) => {
|
|
|
269
269
|
children: /* @__PURE__ */ jsx(
|
|
270
270
|
FloatingContent,
|
|
271
271
|
{
|
|
272
|
-
|
|
273
|
-
disabled: false,
|
|
272
|
+
overlay: {
|
|
274
273
|
lockScroll: true,
|
|
275
274
|
style: {
|
|
276
275
|
zIndex: FLOATING_Z_INDEX,
|
|
277
|
-
backdropFilter: "blur(4px)"
|
|
278
|
-
},
|
|
279
|
-
css: {
|
|
280
|
-
position: "fixed",
|
|
281
|
-
inset: 0,
|
|
276
|
+
backdropFilter: "blur(4px)",
|
|
282
277
|
backgroundColor: "rgba(0, 0, 0, 0.9)",
|
|
283
278
|
color: "white"
|
|
284
279
|
}
|