@janbox/storefront-ui 4.0.12 → 4.0.14

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,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
3
2
  import { Stylesheet } from "../lib/stylesheet/stylesheet.js";
3
+ import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
4
4
  const ScrollView = ({ children, options, sx, ...props }) => {
5
5
  return /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(
6
6
  OverlayScrollbarsComponent,
@@ -3,8 +3,8 @@ import { useRef } from "react";
3
3
  import { motion } from "motion/react";
4
4
  import { getAccordionContentProps } from "./helpers.js";
5
5
  import { useAccordionContext } from "../accordion/helpers.js";
6
- import { useAccordionGroupContext } from "../accordion-group/helpers.js";
7
6
  import { Stylesheet } from "../../stylesheet/stylesheet.js";
7
+ import { useAccordionGroupContext } from "../accordion-group/helpers.js";
8
8
  import { Primitive } from "../../primitive/primitive.js";
9
9
  const AccordionContent = ({ children, ref, ..._props }) => {
10
10
  const { accordionContentProps: accordionContentPropsByGroup = {} } = useAccordionGroupContext();
@@ -7,9 +7,9 @@ import { useTranslation } from "../../i18n/index.js";
7
7
  import "lodash-es";
8
8
  import "../../theme/palette.js";
9
9
  import { getTypographyVar } from "../../theme/typography.js";
10
+ import { Stylesheet } from "../stylesheet/stylesheet.js";
10
11
  import { getCountUpProps } from "./helpers.js";
11
12
  import { getDecimalDigits } from "../../utils/common.js";
12
- import { Stylesheet } from "../stylesheet/stylesheet.js";
13
13
  const CountUp = ({ ref, ..._props }) => {
14
14
  const {
15
15
  from = 0,
@@ -1,11 +1,9 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getDialogProps, getDialogSizeInNumber } from "./helpers.js";
3
- import { FLOATING_Z_INDEX } from "../../../theme/index.js";
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__ */ jsxs(
16
+ children: /* @__PURE__ */ jsx(
19
17
  FloatingContent,
20
18
  {
21
- floatingOverlayProps: {
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
- zIndex: FLOATING_Z_INDEX
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
- maxHeight: "100%",
37
- maxWidth: "100%",
29
+ width: getDialogSizeInNumber(size),
30
+ backgroundColor: getColorVar("surface.default"),
31
+ maxWidth: `calc(100dvw - ${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(100dvw - ${breakpoint.sm.padding * 2}px)`
40
+ },
41
+ md: {
42
+ width: getDialogSizeInNumber(md == null ? void 0 : md.size),
43
+ maxWidth: `calc(100dvw - ${breakpoint.md.padding * 2}px)`
44
+ },
45
+ lg: {
46
+ width: getDialogSizeInNumber(lg == null ? void 0 : lg.size),
47
+ maxWidth: `calc(100dvw - ${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,11 +1,10 @@
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";
4
+ import { Stylesheet } from "../../stylesheet/stylesheet.js";
5
5
  import { Floating } from "../../floating/floating/floating.js";
6
6
  import { FloatingContent } from "../../floating/floating-content/floating-content.js";
7
7
  import { Primitive } from "../../primitive/primitive.js";
8
- import { Stylesheet } from "../../stylesheet/stylesheet.js";
9
8
  const Drawer = ({ children, placement = "left", ...props }) => {
10
9
  const initial = useMemo(() => {
11
10
  switch (placement) {
@@ -39,12 +38,8 @@ const Drawer = ({ children, placement = "left", ...props }) => {
39
38
  children: /* @__PURE__ */ jsxs(
40
39
  FloatingContent,
41
40
  {
42
- floatingOverlayProps: {
43
- disabled: false,
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: ({ style, floatingPortalProps, floatingFocusManagerProps, floatingOverlayProps, sx, ref, ...props }: FloatingContentProps) => import("react/jsx-runtime").JSX.Element;
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, FloatingFocusManager } from "@floating-ui/react";
3
- import { AnimatePresence, motion } from "motion/react";
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
- import { usePortalContainer } from "../../../theme/provider.js";
8
7
  import { Stylesheet } from "../../stylesheet/stylesheet.js";
9
- const FloatingContent = ({
10
- style,
11
- floatingPortalProps,
12
- floatingFocusManagerProps,
13
- floatingOverlayProps,
14
- sx,
15
- ref,
16
- ...props
17
- }) => {
8
+ import { usePortalContainer } from "../../../theme/provider.js";
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 { root = portalRoot, ...portalProps } = floatingPortalProps ?? {};
23
- const resolvedRoot = root || void 0;
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
- ...floatingOverlayProps,
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
- display: (floatingOverlayProps == null ? void 0 : floatingOverlayProps.disabled) ?? true ? "contents" : void 0,
30
- ...floatingOverlayProps == null ? void 0 : floatingOverlayProps.style
25
+ ...context.elements.reference ? context.floatingStyles : {},
26
+ ...props.style,
27
+ zIndex: FLOATING_Z_INDEX
31
28
  },
32
- children: /* @__PURE__ */ jsx(FloatingFocusManager, { disabled: true, context, ...floatingFocusManagerProps, children: /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(
33
- motion.div,
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 { Interpolation } from '@emotion/react';
3
- import { FloatingFocusManager, FloatingOverlay, FloatingPortal } from '@floating-ui/react';
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
- floatingOverlayProps?: Partial<ShallowMerge<ComponentProps<typeof FloatingOverlay>, {
8
- disabled: boolean;
9
- css?: Interpolation;
10
- }>>;
11
- floatingFocusManagerProps?: Partial<ComponentProps<typeof FloatingFocusManager>>;
12
- }>;
6
+ focus?: Partial<ComponentProps<typeof FloatingFocusManager>>;
7
+ overlay?: Partial<ComponentProps<typeof FloatingOverlay>>;
8
+ } & Pick<FloatingPortalProps, 'preserveTabOrder'>>;
@@ -10,12 +10,12 @@ import ZoomPlusIcon from "../../assets/svg/search-add-plus-middle.svg.js";
10
10
  import ZoomMinusIcon from "../../assets/svg/search-minus.svg.js";
11
11
  import CloseIcon from "../../assets/svg/times-close-delete.svg.js";
12
12
  import { FLOATING_Z_INDEX } from "../../theme/index.js";
13
+ import { Stylesheet } from "../stylesheet/stylesheet.js";
13
14
  import { Swiper } from "../swiper/swiper/swiper.js";
14
15
  import { SwiperSlide } from "../swiper/swiper-slide/swiper-slide.js";
15
16
  import { Floating } from "../floating/floating/floating.js";
16
17
  import { FloatingContent } from "../floating/floating-content/floating-content.js";
17
18
  import { Primitive } from "../primitive/primitive.js";
18
- import { Stylesheet } from "../stylesheet/stylesheet.js";
19
19
  import { Image } from "../image/image.js";
20
20
  import { FloatingClose } from "../floating/floating-close/floating-close.js";
21
21
  import { IconButton } from "../icon-button/icon-button.js";
@@ -269,16 +269,11 @@ const Lightbox = ({ slides, defaultActiveIndex, ...props }) => {
269
269
  children: /* @__PURE__ */ jsx(
270
270
  FloatingContent,
271
271
  {
272
- floatingOverlayProps: {
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
  }
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { animatePulseStyle } from "../../../constants/emotion.js";
3
+ import { Stylesheet } from "../../stylesheet/stylesheet.js";
3
4
  import "lodash-es";
4
5
  import { getColorVar } from "../../../theme/palette.js";
5
6
  import { Primitive } from "../../primitive/primitive.js";
6
- import { Stylesheet } from "../../stylesheet/stylesheet.js";
7
7
  const ImageSkeleton = (props) => {
8
8
  return /* @__PURE__ */ jsx(
9
9
  Primitive,
@@ -7,9 +7,9 @@ import { notificationStore } from "./helpers.js";
7
7
  import { getColorShadesByVariant } from "../../utils/index.js";
8
8
  import { FLOATING_Z_INDEX } from "../../theme/index.js";
9
9
  import CloseIcon from "../../assets/svg/times-close-delete.svg.js";
10
+ import { Stylesheet } from "../stylesheet/stylesheet.js";
10
11
  import { usePortalContainer } from "../../theme/provider.js";
11
12
  import { Primitive } from "../primitive/primitive.js";
12
- import { Stylesheet } from "../stylesheet/stylesheet.js";
13
13
  import { getTypographyVar } from "../../theme/typography.js";
14
14
  import { IconButton } from "../icon-button/icon-button.js";
15
15
  const Notifications = () => {
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
- import { getStarRatingProps } from "./helpers.js";
4
3
  import { Stylesheet } from "../stylesheet/stylesheet.js";
4
+ import { getStarRatingProps } from "./helpers.js";
5
5
  const StarRating = (_props) => {
6
6
  const { rating, maxRating, size, sm, md, lg, ref, color, sx } = getStarRatingProps(_props);
7
7
  const id = useId();
@@ -6,8 +6,8 @@ import { motion } from "motion/react";
6
6
  import { getColorVar } from "../../../theme/palette.js";
7
7
  import { usePortalContainer } from "../../../theme/provider.js";
8
8
  import { useIsHydrated } from "../../../hooks/use-is-hydrated/index.js";
9
- import { Primitive } from "../../primitive/primitive.js";
10
9
  import { Stylesheet } from "../../stylesheet/stylesheet.js";
10
+ import { Primitive } from "../../primitive/primitive.js";
11
11
  const SWIPER_DOTS_SIZE_VAR = "--swiper-dots-size";
12
12
  const SWIPER_DOTS_OFFSET_VAR = "--swiper-dots-offset";
13
13
  const SWIPER_DOTS_SPACING_VAR = "--swiper-dots-spacing";
@@ -1,8 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRef, useState, useEffect } from "react";
3
3
  import { motion } from "motion/react";
4
- import { useTabsContext } from "../tabs/helpers.js";
5
4
  import { Stylesheet } from "../../stylesheet/stylesheet.js";
5
+ import { useTabsContext } from "../tabs/helpers.js";
6
6
  const TabIndicator = () => {
7
7
  const { activeIndex, tabIndicatorProps } = useTabsContext();
8
8
  const indicatorEl = useRef(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "4.0.12",
3
+ "version": "4.0.14",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [