@janbox/storefront-ui 5.0.1 → 5.0.2

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,10 +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 { Stylesheet } from "../../stylesheet/stylesheet.js";
4
5
  import { Floating } from "../../floating/floating/floating.js";
5
6
  import { FloatingContent } from "../../floating/floating-content/floating-content.js";
6
7
  import { Primitive } from "../../primitive/primitive.js";
7
- import { Stylesheet } from "../../stylesheet/stylesheet.js";
8
8
  const Drawer = ({ children, placement = "left", ...props }) => {
9
9
  const initial = useMemo(() => {
10
10
  switch (placement) {
@@ -4,8 +4,8 @@ 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";
8
+ import { usePortalContainer } from "../../../theme/provider.js";
9
9
  const FloatingContent = ({ preserveTabOrder, focus, overlay, sx, ref, ...props }) => {
10
10
  const { getFloatingProps, context } = useFloatingContext();
11
11
  const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);
@@ -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";
@@ -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";
@@ -31,7 +31,9 @@ Truyền `indicator={false}` để không render indicator.
31
31
  - Tab đang active được tìm bằng `parentElement.children.item(activeIndex)` — tức là **theo thứ tự DOM**, không qua index từ context. Vì vậy đừng chèn element không phải `Tab` vào giữa các `Tab`, nếu không indicator sẽ trỏ sai.
32
32
  - Vị trí (`left`, `top`, `width`) được tính từ `getBoundingClientRect()` của tab active so với container, có bù `scrollLeft`/`scrollTop` để đúng khi tab bar scroll ngang.
33
33
  - Một `MutationObserver` theo dõi `childList` của `TabList` để cập nhật khi số lượng `Tab` thay đổi (thêm/bớt tab động).
34
- - Một `ResizeObserver` observe cả tab active **và** container: resize container không đổi kích thước từng tab nhưng có thể làm tab xuống dòng khác khi `overflowBehavior="wrap"`, nên phải theo dõi cả hai để cập nhật vị trí dòng.
34
+ - Một `ResizeObserver` observe tab active, container **và** chính indicator:
35
+ - Container: resize container không đổi kích thước từng tab nhưng có thể làm tab xuống dòng khác khi `overflowBehavior="wrap"`, nên phải theo dõi để cập nhật vị trí dòng.
36
+ - Chính indicator: `top` phụ thuộc `offsetHeight` của nó, nên khi `size` đổi (qua prop hoặc breakpoint) vị trí phải được tính lại. Indicator là `position: absolute` nên đổi height không làm tab/container resize.
35
37
  - `top` được tính là mép dưới của tab trừ đi chiều cao indicator, nên indicator luôn nằm sát đáy tab active — kể cả khi tab wrap sang dòng thứ hai.
36
38
 
37
39
  ## Examples
@@ -1 +1,2 @@
1
- export * from './tab-indicator';
1
+ export { TabIndicator } from './tab-indicator';
2
+ export { type TabIndicatorProps } from './types';
@@ -1,11 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRef, useState, useEffect, useCallback } from "react";
3
3
  import { motion } from "motion/react";
4
+ import { Stylesheet } from "../../stylesheet/stylesheet.js";
4
5
  import "lodash-es";
5
6
  import "../../../theme/palette.js";
6
7
  import { isNumber } from "../../../utils/common.js";
7
8
  import { useTabsContext } from "../tabs/helpers.js";
8
- import { Stylesheet } from "../../stylesheet/stylesheet.js";
9
9
  const INDICATOR_SIZE_VAR_NAME = "--indicator-size";
10
10
  const TabIndicator = ({ size, sm, md, lg, ...props }) => {
11
11
  const { activeIndex } = useTabsContext();
@@ -51,15 +51,18 @@ const TabIndicator = ({ size, sm, md, lg, ...props }) => {
51
51
  });
52
52
  }, [activeTabElement]);
53
53
  useEffect(() => {
54
- var _a;
55
54
  const resizeObserver = new ResizeObserver(syncIndicatorRect);
56
- const parentElement = (_a = indicatorEl.current) == null ? void 0 : _a.parentElement;
55
+ const indicator = indicatorEl.current;
56
+ const parentElement = indicator == null ? void 0 : indicator.parentElement;
57
57
  if (activeTabElement) {
58
58
  resizeObserver.observe(activeTabElement);
59
59
  }
60
60
  if (parentElement) {
61
61
  resizeObserver.observe(parentElement);
62
62
  }
63
+ if (indicator) {
64
+ resizeObserver.observe(indicator);
65
+ }
63
66
  return () => {
64
67
  resizeObserver.disconnect();
65
68
  };
@@ -1,5 +1,5 @@
1
1
  import { flatten } from "flat";
2
- import { isNil, trim, isString, isNumber, isDate, isBoolean, isArray, isPlainObject } from "lodash-es";
2
+ import { isNil, isString, isNumber, isDate, isBoolean, isArray, isPlainObject } from "lodash-es";
3
3
  import { getEnumValues } from "./common.js";
4
4
  class QueryParamParser {
5
5
  constructor(value) {
@@ -55,7 +55,7 @@ class ArrayParamParser extends QueryParamParser {
55
55
  if (isNil(value)) {
56
56
  return void 0;
57
57
  }
58
- const parsedValue = value.split(",").map(trim).filter(Boolean);
58
+ const parsedValue = value.split(",").map((part) => part.trim()).filter(Boolean);
59
59
  return parsedValue.length ? parsedValue : void 0;
60
60
  }
61
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [