@janbox/storefront-ui 4.0.10 → 4.0.12
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/components/scroll-view.js +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/accordion/accordion-content/accordion-content.js +1 -1
- package/dist/lib/count-up/count-up.js +1 -1
- package/dist/lib/drawer/drawer/drawer.js +1 -1
- package/dist/lib/floating/floating-content/floating-content.js +1 -1
- package/dist/lib/lightbox/lightbox.js +1 -1
- package/dist/lib/loading/image-skeleton/image-skeleton.js +1 -1
- package/dist/lib/notifications/notifications.js +1 -1
- package/dist/lib/pagination/helpers.js +1 -1
- package/dist/lib/star-rating/README.md +14 -8
- package/dist/lib/star-rating/helpers.d.ts +2 -0
- package/dist/lib/star-rating/helpers.js +14 -0
- package/dist/lib/star-rating/index.d.ts +3 -2
- package/dist/lib/star-rating/star-rating.d.ts +1 -1
- package/dist/lib/star-rating/star-rating.js +9 -17
- package/dist/lib/star-rating/types.d.ts +2 -2
- package/dist/lib/swiper/swiper-dots-paging/swiper-dots-paging.js +1 -1
- package/dist/lib/tabs/tab-indicator/tab-indicator.js +1 -1
- package/package.json +1 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Stylesheet } from "../lib/stylesheet/stylesheet.js";
|
|
3
2
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
|
|
3
|
+
import { Stylesheet } from "../lib/stylesheet/stylesheet.js";
|
|
4
4
|
const ScrollView = ({ children, options, sx, ...props }) => {
|
|
5
5
|
return /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(
|
|
6
6
|
OverlayScrollbarsComponent,
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,7 @@ import { getMultipleSelectProps } from "./lib/multiple-select/helpers.js";
|
|
|
133
133
|
import { getPageRange, getPaginationProps } from "./lib/pagination/helpers.js";
|
|
134
134
|
import { getPriceLabelProps } from "./lib/price-label/helpers.js";
|
|
135
135
|
import { getRadioButtonProps } from "./lib/radio-button/helpers.js";
|
|
136
|
+
import { getStarRatingProps } from "./lib/star-rating/helpers.js";
|
|
136
137
|
import { getSwiperProps } from "./lib/swiper/swiper/helpers.js";
|
|
137
138
|
import { getTabListProps } from "./lib/tabs/tab-list/helpers.js";
|
|
138
139
|
import { getTabPanelProps } from "./lib/tabs/tab-panel/helpers.js";
|
|
@@ -290,6 +291,7 @@ export {
|
|
|
290
291
|
getPaginationProps,
|
|
291
292
|
getPriceLabelProps,
|
|
292
293
|
getRadioButtonProps,
|
|
294
|
+
getStarRatingProps,
|
|
293
295
|
getSwiperProps,
|
|
294
296
|
getTabListProps,
|
|
295
297
|
getTabPanelProps,
|
|
@@ -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 { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
7
6
|
import { useAccordionGroupContext } from "../accordion-group/helpers.js";
|
|
7
|
+
import { Stylesheet } from "../../stylesheet/stylesheet.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";
|
|
11
10
|
import { getCountUpProps } from "./helpers.js";
|
|
12
11
|
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,
|
|
@@ -2,10 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { motion } from "motion/react";
|
|
4
4
|
import { FLOATING_Z_INDEX } from "../../../theme/index.js";
|
|
5
|
-
import { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
6
5
|
import { Floating } from "../../floating/floating/floating.js";
|
|
7
6
|
import { FloatingContent } from "../../floating/floating-content/floating-content.js";
|
|
8
7
|
import { Primitive } from "../../primitive/primitive.js";
|
|
8
|
+
import { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
9
9
|
const Drawer = ({ children, placement = "left", ...props }) => {
|
|
10
10
|
const initial = useMemo(() => {
|
|
11
11
|
switch (placement) {
|
|
@@ -4,8 +4,8 @@ import { AnimatePresence, motion } 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 { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
8
7
|
import { usePortalContainer } from "../../../theme/provider.js";
|
|
8
|
+
import { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
9
9
|
const FloatingContent = ({
|
|
10
10
|
style,
|
|
11
11
|
floatingPortalProps,
|
|
@@ -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";
|
|
14
13
|
import { Swiper } from "../swiper/swiper/swiper.js";
|
|
15
14
|
import { SwiperSlide } from "../swiper/swiper-slide/swiper-slide.js";
|
|
16
15
|
import { Floating } from "../floating/floating/floating.js";
|
|
17
16
|
import { FloatingContent } from "../floating/floating-content/floating-content.js";
|
|
18
17
|
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";
|
|
4
3
|
import "lodash-es";
|
|
5
4
|
import { getColorVar } from "../../../theme/palette.js";
|
|
6
5
|
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";
|
|
11
10
|
import { usePortalContainer } from "../../theme/provider.js";
|
|
12
11
|
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 = () => {
|
|
@@ -12,10 +12,10 @@ import { StarRating } from '@janbox/storefront-ui';
|
|
|
12
12
|
|
|
13
13
|
| Prop | Type | Default | Description |
|
|
14
14
|
|------|------|---------|-------------|
|
|
15
|
-
| `rating*` | `number` | - | Giá trị rating hiện tại. Kiểm soát mức độ tô màu ngôi sao qua clip-path. Hỗ trợ giá trị thập phân (VD: 2.5). |
|
|
16
|
-
| `maxRating` | `number` | 5 | Giá trị rating tối đa. Dùng để tính phần trăm tô màu của ngôi sao. |
|
|
17
|
-
| `size` | `number` | 24 | Chiều rộng và chiều cao của SVG tính bằng pixel. ViewBox nội bộ luôn là 24x24 nên giá trị này scale output. Hỗ trợ responsive qua `sm`, `md`, `lg` (VD: `md={{ size: 32 }}`). |
|
|
18
|
-
| `color` | `
|
|
15
|
+
| `rating*` | `number` | - | Giá trị rating hiện tại (bắt buộc). Kiểm soát mức độ tô màu ngôi sao qua clip-path. Hỗ trợ giá trị thập phân (VD: 2.5). |
|
|
16
|
+
| `maxRating` | `number` | `5` | Giá trị rating tối đa. Dùng để tính phần trăm tô màu của ngôi sao. |
|
|
17
|
+
| `size` | `number` | `24` | Chiều rộng và chiều cao của SVG tính bằng pixel. ViewBox nội bộ luôn là 24x24 nên giá trị này scale output. Hỗ trợ responsive qua `sm`, `md`, `lg` (VD: `md={{ size: 32 }}`). |
|
|
18
|
+
| `color` | `string` | `var(--color-orange-600)` | Giá trị màu CSS bất kỳ dùng cho cả stroke và fill của ngôi sao. Nhận mọi CSS color (hex, rgb, `var(...)`, ...). Dùng `getColorVar('orange.600')` cho giá trị mặc định. |
|
|
19
19
|
| `sx` | `ToResponsiveProps<StyledCSS>` | - | Custom style responsive (hỗ trợ `sm`, `md`, `lg`) áp dụng lên root SVG element. |
|
|
20
20
|
| `ref` | `React.Ref<SVGSVGElement>` | - | Ref tới phần tử SVG bên dưới. |
|
|
21
21
|
|
|
@@ -42,10 +42,15 @@ import { StarRating } from '@janbox/storefront-ui';
|
|
|
42
42
|
<StarRating rating={4} size={24} md={{ size: 32 }} lg={{ size: 40 }} />
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
### Max rating tùy chỉnh và color
|
|
45
|
+
### Max rating tùy chỉnh và color tùy chỉnh
|
|
46
46
|
|
|
47
47
|
```tsx
|
|
48
|
-
|
|
48
|
+
import { getColorVar } from '@janbox/storefront-ui/theme';
|
|
49
|
+
|
|
50
|
+
<StarRating rating={7} maxRating={10} color={getColorVar('primary.600')} />
|
|
51
|
+
|
|
52
|
+
{/* Hoặc dùng CSS color trực tiếp */}
|
|
53
|
+
<StarRating rating={7} maxRating={10} color="#f59e0b" />
|
|
49
54
|
```
|
|
50
55
|
|
|
51
56
|
### Custom style responsive với `sx`
|
|
@@ -71,8 +76,9 @@ import { StarRating } from '@janbox/storefront-ui';
|
|
|
71
76
|
## Dependencies
|
|
72
77
|
|
|
73
78
|
- react (useId)
|
|
74
|
-
- @/utils (
|
|
75
|
-
- @/
|
|
79
|
+
- @/utils (mergeComponentProps)
|
|
80
|
+
- @/theme (getColorVar)
|
|
81
|
+
- @/types (PropsWithSx, ToResponsiveProps, StyledCSS)
|
|
76
82
|
- Stylesheet (../stylesheet)
|
|
77
83
|
|
|
78
84
|
## See Also
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "lodash-es";
|
|
2
|
+
import { getColorVar } from "../../theme/palette.js";
|
|
3
|
+
import { mergeComponentProps } from "../../utils/index.js";
|
|
4
|
+
const defaultProps = {
|
|
5
|
+
color: getColorVar("orange.600"),
|
|
6
|
+
size: 24,
|
|
7
|
+
maxRating: 5
|
|
8
|
+
};
|
|
9
|
+
const getStarRatingProps = (extended) => {
|
|
10
|
+
return mergeComponentProps(defaultProps, extended);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
getStarRatingProps
|
|
14
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { StarRating } from './star-rating';
|
|
2
|
+
export type { StarRatingProps, StarRatingResponsiveProps } from './types';
|
|
3
|
+
export { getStarRatingProps } from './helpers';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { StarRatingProps } from './types';
|
|
2
|
-
export declare const StarRating: (
|
|
2
|
+
export declare const StarRating: (_props: StarRatingProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { getStarRatingProps } from "./helpers.js";
|
|
4
4
|
import { Stylesheet } from "../stylesheet/stylesheet.js";
|
|
5
|
-
const StarRating = ({
|
|
6
|
-
rating,
|
|
7
|
-
maxRating = 5,
|
|
8
|
-
size = 24,
|
|
9
|
-
sm,
|
|
10
|
-
md,
|
|
11
|
-
lg,
|
|
12
|
-
ref,
|
|
13
|
-
color = "orange",
|
|
14
|
-
sx
|
|
15
|
-
}) => {
|
|
5
|
+
const StarRating = (_props) => {
|
|
6
|
+
const { rating, maxRating, size, sm, md, lg, ref, color, sx } = getStarRatingProps(_props);
|
|
16
7
|
const id = useId();
|
|
17
|
-
const percent =
|
|
18
|
-
|
|
8
|
+
const percent = (() => {
|
|
9
|
+
return maxRating ? rating / maxRating * 24 : 0;
|
|
10
|
+
})();
|
|
19
11
|
return /* @__PURE__ */ jsx(Stylesheet, { children: ({ css, cx }) => /* @__PURE__ */ jsxs(
|
|
20
12
|
"svg",
|
|
21
13
|
{
|
|
@@ -38,7 +30,7 @@ const StarRating = ({
|
|
|
38
30
|
{
|
|
39
31
|
d: "M12 2.89648L14.935 8.88948L21.5 9.85648L16.75 14.5185L17.871 21.1045L12 17.9935L6.129 21.1045L7.25 14.5185L2.5 9.85648L9.064 8.88948L12 2.89648Z",
|
|
40
32
|
fill: "white",
|
|
41
|
-
stroke:
|
|
33
|
+
stroke: color,
|
|
42
34
|
strokeWidth: "1.5",
|
|
43
35
|
strokeLinecap: "round",
|
|
44
36
|
strokeLinejoin: "round"
|
|
@@ -48,12 +40,12 @@ const StarRating = ({
|
|
|
48
40
|
"path",
|
|
49
41
|
{
|
|
50
42
|
d: "M12 2.89648L14.935 8.88948L21.5 9.85648L16.75 14.5185L17.871 21.1045L12 17.9935L6.129 21.1045L7.25 14.5185L2.5 9.85648L9.064 8.88948L12 2.89648Z",
|
|
51
|
-
fill:
|
|
43
|
+
fill: color,
|
|
52
44
|
clipPath: `url(#${id})`,
|
|
53
45
|
strokeLinecap: "round",
|
|
54
46
|
strokeLinejoin: "round",
|
|
55
47
|
strokeWidth: "1.5",
|
|
56
|
-
stroke:
|
|
48
|
+
stroke: color
|
|
57
49
|
}
|
|
58
50
|
)
|
|
59
51
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithSx, ToResponsiveProps } from '../../types';
|
|
2
2
|
import { Ref } from 'react';
|
|
3
3
|
export type StarRatingResponsiveProps = {
|
|
4
4
|
size?: number;
|
|
@@ -6,6 +6,6 @@ export type StarRatingResponsiveProps = {
|
|
|
6
6
|
export type StarRatingProps = PropsWithSx<ToResponsiveProps<StarRatingResponsiveProps> & {
|
|
7
7
|
rating: number;
|
|
8
8
|
maxRating?: number;
|
|
9
|
-
color?:
|
|
9
|
+
color?: string;
|
|
10
10
|
ref?: Ref<SVGSVGElement>;
|
|
11
11
|
}>;
|
|
@@ -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 { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
10
9
|
import { Primitive } from "../../primitive/primitive.js";
|
|
10
|
+
import { Stylesheet } from "../../stylesheet/stylesheet.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 { Stylesheet } from "../../stylesheet/stylesheet.js";
|
|
5
4
|
import { useTabsContext } from "../tabs/helpers.js";
|
|
5
|
+
import { Stylesheet } from "../../stylesheet/stylesheet.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.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"description": "Storefront UI component library for Janbox",
|
|
5
5
|
"author": "Janbox",
|
|
6
6
|
"keywords": [
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
103
103
|
"globals": "^17.4.0",
|
|
104
104
|
"prettier": "^3.8.1",
|
|
105
|
-
"sass-embedded": "^1.97.3",
|
|
106
105
|
"storybook": "^10.2.14",
|
|
107
106
|
"type-fest": "^5.2.0",
|
|
108
107
|
"typescript": "5.5.4",
|