@janbox/storefront-ui 3.0.1 → 3.0.3

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.
Files changed (47) hide show
  1. package/dist/components/svg-loader.d.ts +4 -3
  2. package/dist/components/svg-loader.js +12 -7
  3. package/dist/hooks/use-formatter/index.d.ts +5 -3
  4. package/dist/hooks/use-formatter/index.js +20 -6
  5. package/dist/index.js +2 -0
  6. package/dist/lib/accordion/accordion-content/accordion-content.d.ts +1 -1
  7. package/dist/lib/accordion/accordion-content/accordion-content.js +24 -13
  8. package/dist/lib/count-up/README.md +1 -1
  9. package/dist/lib/count-up/count-up.js +1 -1
  10. package/dist/lib/filter-panel/checkbox-filter-panel.js +3 -2
  11. package/dist/lib/filter-panel/price-range-filter-panel.d.ts +1 -1
  12. package/dist/lib/filter-panel/price-range-filter-panel.js +4 -3
  13. package/dist/lib/filter-panel/radio-filter-panel.js +2 -1
  14. package/dist/lib/flexbox/flex-item/flex-item.d.ts +1 -1
  15. package/dist/lib/flexbox/flex-item/flex-item.js +13 -8
  16. package/dist/lib/flexbox/flex-item/types.d.ts +2 -2
  17. package/dist/lib/icon/icon.d.ts +1 -1
  18. package/dist/lib/icon/icon.js +23 -21
  19. package/dist/lib/icon-button/icon-button.js +5 -3
  20. package/dist/lib/index.d.ts +1 -0
  21. package/dist/lib/lightbox/lightbox.js +2 -1
  22. package/dist/lib/pagination/pagination.js +1 -1
  23. package/dist/lib/popover/popover-content/popover-content.d.ts +1 -1
  24. package/dist/lib/popover/popover-content/popover-content.js +6 -5
  25. package/dist/lib/primitive/primitive.js +3 -4
  26. package/dist/lib/select/select.js +4 -4
  27. package/dist/lib/stepper/stepper.js +2 -1
  28. package/dist/lib/stylesheet/index.d.ts +2 -0
  29. package/dist/lib/stylesheet/stylesheet.d.ts +2 -0
  30. package/dist/lib/stylesheet/stylesheet.js +23 -0
  31. package/dist/lib/stylesheet/types.d.ts +9 -0
  32. package/dist/lib/table/table-body/table-body.d.ts +1 -1
  33. package/dist/lib/table/table-body/table-body.js +21 -22
  34. package/dist/lib/table/table-body/types.d.ts +2 -2
  35. package/dist/lib/table/table-head/table-head.d.ts +1 -1
  36. package/dist/lib/table/table-head/table-head.js +19 -20
  37. package/dist/lib/table/table-head/types.d.ts +2 -2
  38. package/dist/lib/tabs/tab-indicator/tab-indicator.d.ts +1 -1
  39. package/dist/lib/tabs/tab-indicator/tab-indicator.js +12 -14
  40. package/dist/lib/tabs/tabs/tabs.js +2 -3
  41. package/dist/lib/time-picker/time-picker.js +15 -11
  42. package/dist/lib/video/video.d.ts +1 -1
  43. package/dist/lib/video/video.js +3 -3
  44. package/dist/utils/common.d.ts +2 -2
  45. package/dist/utils/index.d.ts +26 -6
  46. package/dist/utils/index.js +26 -6
  47. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { JSX } from 'react';
2
- export type SvgLoaderProps = JSX.IntrinsicElements['svg'] & {
2
+ import { PropsWithSx } from '../types';
3
+ export type SvgLoaderProps = PropsWithSx<JSX.IntrinsicElements['svg'] & {
3
4
  source: string;
4
- };
5
- export declare const SvgLoader: import('react').ForwardRefExoticComponent<Omit<SvgLoaderProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
5
+ }>;
6
+ export declare const SvgLoader: ({ sx, source, ref, ...props }: SvgLoaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,19 @@
1
1
  import { jsx, Fragment } from "react/jsx-runtime";
2
- import { forwardRef, useId, useMemo, cloneElement } from "react";
2
+ import { useId, useMemo, cloneElement } from "react";
3
3
  import { parseSvgString } from "../utils/common.js";
4
- const SvgLoader = forwardRef(({ source, ...props }, ref) => {
4
+ import { Stylesheet } from "../lib/stylesheet/stylesheet.js";
5
+ const SvgLoader = ({ sx, source, ref, ...props }) => {
5
6
  const uniqueId = useId();
6
7
  const jsxSvg = useMemo(() => parseSvgString(source, uniqueId), [source, uniqueId]);
7
- return /* @__PURE__ */ jsx(Fragment, { children: !!jsxSvg && cloneElement(jsxSvg, {
8
- ...props,
9
- ref
10
- }) });
11
- });
8
+ return /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => {
9
+ if (!jsxSvg) return /* @__PURE__ */ jsx(Fragment, {});
10
+ return cloneElement(jsxSvg, {
11
+ ...props,
12
+ className: cx(css(sx), props.className),
13
+ ref
14
+ });
15
+ } });
16
+ };
12
17
  export {
13
18
  SvgLoader
14
19
  };
@@ -1,7 +1,9 @@
1
- import { FormatPriceOptions, FormatDateTimeOptions, FormatNumberOptions } from '../../utils';
1
+ import { FormatPriceOptions, FormatDateTimeOptions, FormatNumberOptions, GetCurrencyDisplayNameOptions, GetLanguageDisplayNameOptions } from '../../utils';
2
2
  import { SetOptional } from 'type-fest';
3
3
  export declare const useFormatter: () => {
4
4
  formatNumber: (value: number, options?: Partial<FormatNumberOptions>) => string;
5
- formatDateTime: (value: Date | string | number, options: SetOptional<FormatDateTimeOptions, "lng">) => string;
6
- formatPrice: (value: number, options: SetOptional<FormatPriceOptions, "lng">) => string;
5
+ formatDateTime: (value: Date | string | number, options: SetOptional<FormatDateTimeOptions, "locale">) => string;
6
+ formatPrice: (value: number, options: SetOptional<FormatPriceOptions, "locale">) => string;
7
+ getLanguageDisplayName: (code: string, options?: GetLanguageDisplayNameOptions) => string;
8
+ getCurrencyDisplayName: (code: string, options?: SetOptional<GetCurrencyDisplayNameOptions, "locale">) => string;
7
9
  };
@@ -1,11 +1,11 @@
1
- import { formatNumber, formatDateTime, formatPrice } from "../../utils/index.js";
1
+ import { formatNumber, formatDateTime, formatPrice, getLanguageDisplayName, getCurrencyDisplayName } from "../../utils/index.js";
2
2
  import { useCallback, useMemo } from "react";
3
3
  import { useTranslation } from "../../i18n/index.js";
4
4
  const useFormatter = () => {
5
5
  const { locale } = useTranslation();
6
6
  const formatNumberFn = useCallback(
7
7
  (value, options) => {
8
- return formatNumber(value, { lng: locale, ...options });
8
+ return formatNumber(value, { ...options, locale: (options == null ? void 0 : options.locale) ?? locale });
9
9
  },
10
10
  [locale]
11
11
  );
@@ -16,14 +16,26 @@ const useFormatter = () => {
16
16
  return formatDateTime(value, {
17
17
  ...defaults,
18
18
  ...options,
19
- lng: options.lng ?? locale
19
+ locale: options.locale ?? locale
20
20
  });
21
21
  },
22
22
  [locale]
23
23
  );
24
24
  const formatPriceFn = useCallback(
25
25
  (value, options) => {
26
- return formatPrice(value, { ...options, lng: options.lng ?? locale });
26
+ return formatPrice(value, { ...options, locale: options.locale ?? locale });
27
+ },
28
+ [locale]
29
+ );
30
+ const getLanguageDisplayNameFn = useCallback(
31
+ (code, options) => {
32
+ return getLanguageDisplayName(code, { ...options, locale: (options == null ? void 0 : options.locale) ?? locale });
33
+ },
34
+ [locale]
35
+ );
36
+ const getCurrencyDisplayNameFn = useCallback(
37
+ (code, options) => {
38
+ return getCurrencyDisplayName(code, { ...options, locale: (options == null ? void 0 : options.locale) ?? locale });
27
39
  },
28
40
  [locale]
29
41
  );
@@ -31,9 +43,11 @@ const useFormatter = () => {
31
43
  () => ({
32
44
  formatNumber: formatNumberFn,
33
45
  formatDateTime: formatDateTimeFn,
34
- formatPrice: formatPriceFn
46
+ formatPrice: formatPriceFn,
47
+ getLanguageDisplayName: getLanguageDisplayNameFn,
48
+ getCurrencyDisplayName: getCurrencyDisplayNameFn
35
49
  }),
36
- [formatNumberFn, formatDateTimeFn, formatPriceFn]
50
+ [formatNumberFn, formatDateTimeFn, formatPriceFn, getLanguageDisplayNameFn, getCurrencyDisplayNameFn]
37
51
  );
38
52
  };
39
53
  export {
package/dist/index.js CHANGED
@@ -82,6 +82,7 @@ import { Select } from "./lib/select/select.js";
82
82
  import { StarRating } from "./lib/star-rating/star-rating.js";
83
83
  import { Step } from "./lib/stepper/step.js";
84
84
  import { Stepper } from "./lib/stepper/stepper.js";
85
+ import { Stylesheet } from "./lib/stylesheet/stylesheet.js";
85
86
  import { SuspenseQuery } from "./lib/suspense-query/suspense-query.js";
86
87
  import { Swiper } from "./lib/swiper/swiper/swiper.js";
87
88
  import { SwiperSlide } from "./lib/swiper/swiper-slide/swiper-slide.js";
@@ -229,6 +230,7 @@ export {
229
230
  StarRating,
230
231
  Step,
231
232
  Stepper,
233
+ Stylesheet,
232
234
  SuspenseQuery,
233
235
  Swiper,
234
236
  SwiperSlide,
@@ -1,2 +1,2 @@
1
1
  import { AccordionContentProps } from './types';
2
- export declare const AccordionContent: ({ children, ref, ..._props }: AccordionContentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const AccordionContent: ({ children, ref, ..._props }: AccordionContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,34 +1,45 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  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 { createSxInterpolation } from "../../../utils/stylesheet.js";
6
+ import { Stylesheet } from "../../stylesheet/stylesheet.js";
7
7
  import { useAccordionGroupContext } from "../accordion-group/helpers.js";
8
+ import { Primitive } from "../../primitive/primitive.js";
8
9
  const AccordionContent = ({ children, ref, ..._props }) => {
9
10
  const { accordionContentProps: accordionContentPropsByGroup = {} } = useAccordionGroupContext();
10
- const { sx, containerProps, ...props } = getAccordionContentProps(accordionContentPropsByGroup, _props);
11
+ const { containerProps, ...props } = getAccordionContentProps(accordionContentPropsByGroup, _props);
11
12
  const { open } = useAccordionContext();
12
13
  const defaultOpenRef = useRef(open);
13
- const css = [
14
- {
15
- width: "100%"
16
- },
17
- createSxInterpolation(sx)
18
- ];
19
14
  const initial = defaultOpenRef.current ? { height: "auto", opacity: 1 } : { height: 0, opacity: 0 };
20
- return /* @__PURE__ */ jsx(
15
+ return /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(
21
16
  motion.div,
22
17
  {
23
18
  initial,
24
19
  animate: open ? { height: "auto", opacity: 1 } : { height: 0, opacity: 0 },
25
20
  transition: { duration: 0.3 },
26
- css: { overflow: "hidden", width: "100%" },
27
21
  ...containerProps,
22
+ className: cx(
23
+ css({
24
+ overflow: "hidden",
25
+ width: "100%"
26
+ }),
27
+ containerProps == null ? void 0 : containerProps.className
28
+ ),
28
29
  ref,
29
- children: /* @__PURE__ */ jsx("div", { ...props, css, children })
30
+ children: /* @__PURE__ */ jsx(
31
+ Primitive,
32
+ {
33
+ ...props,
34
+ sx: {
35
+ width: "100%",
36
+ ...props.sx
37
+ },
38
+ children
39
+ }
40
+ )
30
41
  }
31
- );
42
+ ) });
32
43
  };
33
44
  export {
34
45
  AccordionContent
@@ -15,7 +15,7 @@ import { CountUp } from '@janbox/storefront-ui';
15
15
  | `to*` | `number` | - | Số đích cần đếm tới |
16
16
  | `from` | `number` | 0 | Số bắt đầu đếm |
17
17
  | `duration` | `number` | 2 | Thời gian animation tính bằng giây |
18
- | `formatNumberOptions` | `FormatNumberOptions` | - | Tùy chọn format số (mở rộng từ `Intl.NumberFormatOptions` với thuộc tính `lng`). Kiểm soát số chữ số thập phân, format tiền tệ và các tùy chọn hiển thị số theo locale |
18
+ | `formatNumberOptions` | `FormatNumberOptions` | - | Tùy chọn format số (mở rộng từ `Intl.NumberFormatOptions` với thuộc tính `locale`). Kiểm soát số chữ số thập phân, format tiền tệ và các tùy chọn hiển thị số theo locale |
19
19
  | `ref` | `React.Ref<HTMLSpanElement>` | - | Ref tới phần tử span bên dưới |
20
20
 
21
21
  *Prop bắt buộc
@@ -15,7 +15,7 @@ const CountUp = ({ from = 0, to, duration = 2, formatNumberOptions, ref, ...prop
15
15
  const rounded = useTransform(
16
16
  count,
17
17
  (latest) => formatNumber(latest, {
18
- lng: locale,
18
+ locale,
19
19
  ...formatNumberOptions,
20
20
  maximumFractionDigits
21
21
  })
@@ -7,6 +7,7 @@ import "../../theme/palette.js";
7
7
  import { matchSearch } from "../../utils/common.js";
8
8
  import { ArrayParamParser } from "../../utils/query-params.js";
9
9
  import { Checkbox } from "../checkbox/checkbox.js";
10
+ import { Primitive } from "../primitive/primitive.js";
10
11
  import { Input } from "../input/input.js";
11
12
  const ROW_HEIGHT = 32;
12
13
  const DISPLAY_ROW_COUNT = 5;
@@ -65,7 +66,7 @@ const CheckboxFilterPanel = ({
65
66
  }
66
67
  onChange == null ? void 0 : onChange(e);
67
68
  };
68
- return /* @__PURE__ */ jsx("div", { css: { paddingTop: 4, paddingBottom: 4 }, children: /* @__PURE__ */ jsx(
69
+ return /* @__PURE__ */ jsx(Primitive, { sx: { paddingTop: 4, paddingBottom: 4 }, children: /* @__PURE__ */ jsx(
69
70
  Checkbox,
70
71
  {
71
72
  containerProps: {
@@ -82,7 +83,7 @@ const CheckboxFilterPanel = ({
82
83
  ) });
83
84
  };
84
85
  return /* @__PURE__ */ jsxs("div", { children: [
85
- searchEnabled && /* @__PURE__ */ jsx("div", { css: { marginBottom: 8 }, children: /* @__PURE__ */ jsx(Input, { value: inputValue, ...inputSearchProps, onChange: onSearchChange }) }),
86
+ searchEnabled && /* @__PURE__ */ jsx(Primitive, { sx: { marginBottom: 8 }, children: /* @__PURE__ */ jsx(Input, { value: inputValue, ...inputSearchProps, onChange: onSearchChange }) }),
86
87
  /* @__PURE__ */ jsx(
87
88
  VirtualizedList,
88
89
  {
@@ -1,2 +1,2 @@
1
1
  import { InputRangeFilterPanelProps } from './types';
2
- export declare const PriceRangeFilterPanel: ({ value, queryParam, placeholder, priceTypes, onPriceChange, onPriceTypeChange, }: InputRangeFilterPanelProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const PriceRangeFilterPanel: ({ value, queryParam, placeholder, priceTypes, onPriceChange, onPriceTypeChange, }: InputRangeFilterPanelProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { TYPING_DEBOUNCE } from "../../constants/index.js";
3
3
  import { useQueryParams } from "../../hooks/use-query-params.js";
4
4
  import { useId } from "react";
@@ -7,6 +7,7 @@ import "../../theme/palette.js";
7
7
  import { StringParamParser, NumberParamParser } from "../../utils/query-params.js";
8
8
  import { RadioButton } from "../radio-button/radio-button.js";
9
9
  import { InputRange } from "../input-range/input-range.js";
10
+ import { Primitive } from "../primitive/primitive.js";
10
11
  const PriceRangeFilterPanel = ({
11
12
  value,
12
13
  queryParam,
@@ -86,8 +87,8 @@ const PriceRangeFilterPanel = ({
86
87
  }
87
88
  onPriceTypeChange == null ? void 0 : onPriceTypeChange(event);
88
89
  };
89
- return /* @__PURE__ */ jsxs("div", { css: { display: "flex", flexDirection: "column", gap: 8 }, children: [
90
- /* @__PURE__ */ jsx("div", { css: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: priceTypes.map((priceType) => {
90
+ return /* @__PURE__ */ jsxs(Primitive, { sx: { display: "flex", flexDirection: "column", gap: 8 }, children: [
91
+ /* @__PURE__ */ jsx(Primitive, { sx: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: priceTypes.map((priceType) => {
91
92
  var _a2;
92
93
  return /* @__PURE__ */ jsx(
93
94
  RadioButton,
@@ -6,6 +6,7 @@ import { useQueryParams } from "../../hooks/use-query-params.js";
6
6
  import "../../theme/palette.js";
7
7
  import { matchSearch } from "../../utils/common.js";
8
8
  import { StringParamParser } from "../../utils/query-params.js";
9
+ import { Primitive } from "../primitive/primitive.js";
9
10
  import { Input } from "../input/input.js";
10
11
  import { RadioButton } from "../radio-button/radio-button.js";
11
12
  const ROW_HEIGHT = 32;
@@ -72,7 +73,7 @@ const RadioFilterPanel = ({
72
73
  ) });
73
74
  };
74
75
  return /* @__PURE__ */ jsxs("div", { children: [
75
- searchEnabled && /* @__PURE__ */ jsx("div", { css: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsx(Input, { value: inputValue, ...inputSearchProps, onChange: onInputChange }) }),
76
+ searchEnabled && /* @__PURE__ */ jsx(Primitive, { sx: { marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsx(Input, { value: inputValue, ...inputSearchProps, onChange: onInputChange }) }),
76
77
  /* @__PURE__ */ jsx(
77
78
  VirtualizedList,
78
79
  {
@@ -1,2 +1,2 @@
1
1
  import { FlexItemProps } from './types';
2
- export declare const FlexItem: ({ children, ref, ...rest }: FlexItemProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const FlexItem: ({ children, ref, ...rest }: FlexItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,20 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getFlexItemProps } from "./helpers.js";
3
- import { createSxInterpolation } from "../../../utils/stylesheet.js";
3
+ import { Primitive } from "../../primitive/primitive.js";
4
4
  const FlexItem = ({ children, ref, ...rest }) => {
5
5
  const { sx, ...props } = getFlexItemProps(rest);
6
- const css = [
6
+ return /* @__PURE__ */ jsx(
7
+ Primitive,
7
8
  {
8
- maxWidth: "100%"
9
- },
10
- createSxInterpolation(sx)
11
- ];
12
- return /* @__PURE__ */ jsx("div", { css, ...props, ref, children });
9
+ sx: {
10
+ maxWidth: "100%",
11
+ ...sx
12
+ },
13
+ ...props,
14
+ ref,
15
+ children
16
+ }
17
+ );
13
18
  };
14
19
  export {
15
20
  FlexItem
@@ -1,3 +1,3 @@
1
1
  import { JSX } from 'react';
2
- import { PropsWithSx } from '../../../types';
3
- export type FlexItemProps = PropsWithSx<JSX.IntrinsicElements['div']>;
2
+ import { PrimitiveProps } from '../../primitive';
3
+ export type FlexItemProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
@@ -1,2 +1,2 @@
1
1
  import { IconProps } from './types';
2
- export declare const Icon: ({ children: _children, ref, ..._props }: IconProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const Icon: ({ children: _children, ref, ..._props }: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,38 +1,40 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getIconProps } from "./helpers.js";
3
3
  import { SvgLoader } from "../../components/svg-loader.js";
4
- import { mediaQuery } from "../../theme/screens.js";
5
- import "../../theme/palette.js";
6
- import { createSxInterpolation } from "../../utils/stylesheet.js";
7
4
  const Icon = ({ children: _children, ref, ..._props }) => {
8
- const { source, sx, size, md, sm, lg, ...props } = getIconProps(_props);
5
+ var _a, _b, _c;
6
+ const { size, md, sm, lg, ...props } = getIconProps(_props);
9
7
  return /* @__PURE__ */ jsx(
10
8
  SvgLoader,
11
9
  {
12
- source,
13
10
  ...props,
14
- css: [
15
- createStyle({ size }),
16
- {
17
- [mediaQuery("sm")]: createStyle(sm),
18
- [mediaQuery("md")]: createStyle(md),
19
- [mediaQuery("lg")]: createStyle(lg)
20
- },
21
- createSxInterpolation(sx)
22
- ],
23
11
  width: void 0,
24
12
  height: void 0,
13
+ sx: {
14
+ ...createStyle({ size }),
15
+ ...props.sx,
16
+ sm: {
17
+ ...createStyle(sm),
18
+ ...(_a = props.sx) == null ? void 0 : _a.sm
19
+ },
20
+ md: {
21
+ ...createStyle(md),
22
+ ...(_b = props.sx) == null ? void 0 : _b.md
23
+ },
24
+ lg: {
25
+ ...createStyle(lg),
26
+ ...(_c = props.sx) == null ? void 0 : _c.lg
27
+ }
28
+ },
25
29
  ref
26
30
  }
27
31
  );
28
32
  };
29
33
  const createStyle = ({ size } = {}) => {
30
- return [
31
- {
32
- width: size,
33
- height: size
34
- }
35
- ];
34
+ return {
35
+ width: size,
36
+ height: size
37
+ };
36
38
  };
37
39
  export {
38
40
  Icon
@@ -8,6 +8,7 @@ import { getColorShadesByVariant, getSizeVariantState } from "../../utils/index.
8
8
  import { animateSpinStyle } from "../../constants/emotion.js";
9
9
  import { ensureBoolean } from "../../utils/common.js";
10
10
  import { Icon } from "../icon/icon.js";
11
+ import { Primitive } from "../primitive/primitive.js";
11
12
  import { RippleEffect } from "../ripple-effect/ripple-effect.js";
12
13
  const IconButton = ({ children, ref, ..._props }) => {
13
14
  const { size, color, variant, icon, isLoading, sx, sm, md, lg, ...rest } = getIconButtonProps(_props);
@@ -119,11 +120,12 @@ const IconButton = ({ children, ref, ..._props }) => {
119
120
  ),
120
121
  children,
121
122
  isLoading && /* @__PURE__ */ jsx(
122
- "span",
123
+ Primitive,
123
124
  {
124
125
  "data-loading": true,
125
- css: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" },
126
- children: /* @__PURE__ */ jsx(Icon, { css: animateSpinStyle, source: LoadingIcon })
126
+ sx: { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center" },
127
+ as: "span",
128
+ children: /* @__PURE__ */ jsx(Icon, { sx: animateSpinStyle, source: LoadingIcon })
127
129
  }
128
130
  ),
129
131
  /* @__PURE__ */ jsx(RippleEffect, {})
@@ -57,6 +57,7 @@ export * from './video';
57
57
  export * from './lightbox';
58
58
  export * from './cascader';
59
59
  export * from './primitive';
60
+ export * from './stylesheet';
60
61
  export * from './price-label';
61
62
  export * from './avatar';
62
63
  export * from './suspense-query';
@@ -14,6 +14,7 @@ import { Swiper } from "../swiper/swiper/swiper.js";
14
14
  import { SwiperSlide } from "../swiper/swiper-slide/swiper-slide.js";
15
15
  import { Floating } from "../floating/floating/floating.js";
16
16
  import { FloatingContent } from "../floating/floating-content/floating-content.js";
17
+ import { Primitive } from "../primitive/primitive.js";
17
18
  import { Image } from "../image/image.js";
18
19
  import { mediaQuery } from "../../theme/screens.js";
19
20
  import { FloatingClose } from "../floating/floating-close/floating-close.js";
@@ -57,7 +58,7 @@ const LightboxContent = ({ slides, defaultActiveIndex = 0 }) => {
57
58
  mainApi == null ? void 0 : mainApi.off("select", onSelect);
58
59
  };
59
60
  }, [mainApi]);
60
- return /* @__PURE__ */ jsx("div", { css: { width: "100%", height: "100%", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ jsx(
61
+ return /* @__PURE__ */ jsx(Primitive, { sx: { width: "100%", height: "100%", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ jsx(
61
62
  "div",
62
63
  {
63
64
  css: {
@@ -94,7 +94,7 @@ const Pagination = ({ ref, ..._props }) => {
94
94
  );
95
95
  };
96
96
  return /* @__PURE__ */ jsxs("div", { css, ...rest, ref, children: [
97
- showFirstPageButton && /* @__PURE__ */ jsx(PaginationButton, { "aria-disabled": page <= 1, color: (_a = states == null ? void 0 : states.normal) == null ? void 0 : _a.color, onClick: handleFirstClick, children: /* @__PURE__ */ jsx(PaginationIcon, { css: { transform: "rotate(180deg)" }, source: ArrowForwardIcon }) }),
97
+ showFirstPageButton && /* @__PURE__ */ jsx(PaginationButton, { "aria-disabled": page <= 1, color: (_a = states == null ? void 0 : states.normal) == null ? void 0 : _a.color, onClick: handleFirstClick, children: /* @__PURE__ */ jsx(PaginationIcon, { sx: { transform: "rotate(180deg)" }, source: ArrowForwardIcon }) }),
98
98
  showPrevPageButton && /* @__PURE__ */ jsx(PaginationButton, { "aria-disabled": page <= 1, color: (_b = states == null ? void 0 : states.normal) == null ? void 0 : _b.color, onClick: handlePrevClick, children: /* @__PURE__ */ jsx(PaginationIcon, { source: ArrowLeftIcon }) }),
99
99
  pageRange.map((pageItem, index) => {
100
100
  var _a2, _b2, _c2, _d2, _e;
@@ -1,2 +1,2 @@
1
1
  import { PopoverContentProps } from './types';
2
- export declare const PopoverContent: (props: PopoverContentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const PopoverContent: (props: PopoverContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import "lodash-es";
3
3
  import { getColorVar } from "../../../theme/palette.js";
4
4
  import { FloatingContent } from "../../floating/floating-content/floating-content.js";
@@ -6,16 +6,17 @@ const PopoverContent = (props) => {
6
6
  return /* @__PURE__ */ jsx(
7
7
  FloatingContent,
8
8
  {
9
- css: {
9
+ ...props,
10
+ sx: {
10
11
  backgroundColor: getColorVar("surface.default"),
11
12
  padding: "0.75rem",
12
13
  borderRadius: "0.75rem",
13
14
  borderWidth: "1px",
14
15
  borderStyle: "solid",
15
16
  borderColor: getColorVar("neutral.100"),
16
- boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)"
17
- },
18
- ...props
17
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
18
+ ...props.sx
19
+ }
19
20
  }
20
21
  );
21
22
  };
@@ -1,12 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { createElement } from "react";
3
- import { ClassNames } from "@emotion/react";
4
- import { createSxInterpolation } from "../../utils/stylesheet.js";
3
+ import { Stylesheet } from "../stylesheet/stylesheet.js";
5
4
  const Primitive = ({ as = "div", sx, ...rest }) => {
6
- return /* @__PURE__ */ jsx(ClassNames, { children: ({ css, cx }) => {
5
+ return /* @__PURE__ */ jsx(Stylesheet, { children: ({ css, cx }) => {
7
6
  return createElement(as, {
8
7
  ...rest,
9
- className: cx(css(createSxInterpolation(sx)), rest.className)
8
+ className: cx(css(sx), rest.className)
10
9
  });
11
10
  } });
12
11
  };
@@ -277,15 +277,15 @@ const Select = ({
277
277
  { flex: 1, textAlign: "left", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
278
278
  getTextCss(rest == null ? void 0 : rest.size)
279
279
  ],
280
- children: selectedOption ? /* @__PURE__ */ jsx(Fragment, { children: selectedRenderer ? selectedRenderer(selectedOption) : getOptionLabel(selectedOption) }) : /* @__PURE__ */ jsx("span", { css: { color: getColorVar("neutral.400"), display: "block" }, children: placeholder })
280
+ children: selectedOption ? /* @__PURE__ */ jsx(Fragment, { children: selectedRenderer ? selectedRenderer(selectedOption) : getOptionLabel(selectedOption) }) : /* @__PURE__ */ jsx(Primitive, { css: { color: getColorVar("neutral.400"), display: "block" }, as: "span", children: placeholder })
281
281
  }
282
282
  )
283
283
  }
284
284
  ) }),
285
285
  /* @__PURE__ */ jsx(FloatingContent, { children: /* @__PURE__ */ jsxs(
286
- "div",
286
+ Primitive,
287
287
  {
288
- css: {
288
+ sx: {
289
289
  paddingTop: 8,
290
290
  paddingBottom: 8,
291
291
  border: "1px solid",
@@ -297,7 +297,7 @@ const Select = ({
297
297
  backgroundColor: getColorVar("surface.default")
298
298
  },
299
299
  children: [
300
- searchable && /* @__PURE__ */ jsx("div", { css: { paddingLeft: 8, paddingRight: 8, paddingBottom: 12, position: "relative" }, children: /* @__PURE__ */ jsx(
300
+ searchable && /* @__PURE__ */ jsx(Primitive, { sx: { paddingLeft: 8, paddingRight: 8, paddingBottom: 12, position: "relative" }, children: /* @__PURE__ */ jsx(
301
301
  Input,
302
302
  {
303
303
  size: rest.size,
@@ -2,6 +2,7 @@ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Step } from "./step.js";
4
4
  import { Progress } from "../progress/progress.js";
5
+ import { Primitive } from "../primitive/primitive.js";
5
6
  const maxPercent = 100;
6
7
  const Stepper = forwardRef((props, ref) => {
7
8
  const { direction = "horizontal", items, activeIndex = 0, circleSize = 32, ...rest } = props;
@@ -49,7 +50,7 @@ const Stepper = forwardRef((props, ref) => {
49
50
  );
50
51
  });
51
52
  };
52
- return /* @__PURE__ */ jsxs("div", { css: { position: "relative" }, children: [
53
+ return /* @__PURE__ */ jsxs(Primitive, { sx: { position: "relative" }, children: [
53
54
  /* @__PURE__ */ jsx(
54
55
  Progress,
55
56
  {
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './stylesheet';
@@ -0,0 +1,2 @@
1
+ import { StylesheetProps } from './types';
2
+ export declare const Stylesheet: ({ children }: StylesheetProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ClassNames } from "@emotion/react";
3
+ import { mediaQuery } from "../../theme/screens.js";
4
+ import "../../theme/palette.js";
5
+ const Stylesheet = ({ children }) => {
6
+ return /* @__PURE__ */ jsx(ClassNames, { children: ({ css, cx }) => {
7
+ return children({
8
+ css: (sx = {}) => {
9
+ const { sm, md, lg, ...xs } = sx;
10
+ return css({
11
+ ...xs,
12
+ [mediaQuery("sm")]: sm,
13
+ [mediaQuery("md")]: md,
14
+ [mediaQuery("lg")]: lg
15
+ });
16
+ },
17
+ cx
18
+ });
19
+ } });
20
+ };
21
+ export {
22
+ Stylesheet
23
+ };
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { PropsWithSx } from '../../types';
3
+ export type StylesheetChildrenProps = {
4
+ css: (sx?: PropsWithSx['sx']) => string;
5
+ cx: (...classNames: Array<string | undefined | null | false>) => string;
6
+ };
7
+ export type StylesheetProps = {
8
+ children: (props: StylesheetChildrenProps) => ReactNode;
9
+ };
@@ -1,2 +1,2 @@
1
1
  import { TableBodyProps } from './types';
2
- export declare const TableBody: ({ sx, children, ref, ...props }: TableBodyProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const TableBody: ({ children, ref, ...props }: TableBodyProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,30 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import "lodash-es";
3
3
  import { getColorVar } from "../../../theme/palette.js";
4
- import { createSxInterpolation } from "../../../utils/stylesheet.js";
5
- const TableBody = ({ sx, children, ref, ...props }) => {
4
+ import { Primitive } from "../../primitive/primitive.js";
5
+ const TableBody = ({ children, ref, ...props }) => {
6
6
  return /* @__PURE__ */ jsx(
7
- "tbody",
7
+ Primitive,
8
8
  {
9
- css: [
10
- {
11
- "& > tr": {
12
- position: "relative",
13
- "&::after": {
14
- content: '""',
15
- position: "absolute",
16
- bottom: 0,
17
- left: 0,
18
- right: 0,
19
- borderBottomWidth: 1,
20
- borderBottomStyle: "solid",
21
- borderBottomColor: getColorVar("neutral.100")
22
- }
23
- }
24
- },
25
- createSxInterpolation(sx)
26
- ],
27
9
  ...props,
28
10
  ref,
11
+ sx: {
12
+ "& > tr": {
13
+ position: "relative",
14
+ "&::after": {
15
+ content: '""',
16
+ position: "absolute",
17
+ bottom: 0,
18
+ left: 0,
19
+ right: 0,
20
+ borderBottomWidth: 1,
21
+ borderBottomStyle: "solid",
22
+ borderBottomColor: getColorVar("neutral.100")
23
+ }
24
+ },
25
+ ...props.sx
26
+ },
27
+ as: "tbody",
29
28
  children
30
29
  }
31
30
  );
@@ -1,3 +1,3 @@
1
- import { PropsWithSx } from '../../../types';
1
+ import { PrimitiveProps } from '../../primitive';
2
2
  import { JSX } from 'react';
3
- export type TableBodyProps = PropsWithSx<JSX.IntrinsicElements['tbody']>;
3
+ export type TableBodyProps = PrimitiveProps<JSX.IntrinsicElements['tbody'], 'tbody'>;
@@ -1,2 +1,2 @@
1
1
  import { TableHeadProps } from './types';
2
- export declare const TableHead: ({ sx, children, ...props }: TableHeadProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const TableHead: ({ sx, children, ...props }: TableHeadProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,29 +1,28 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import "lodash-es";
3
3
  import { getColorVar } from "../../../theme/palette.js";
4
- import { createSxInterpolation } from "../../../utils/stylesheet.js";
4
+ import { Primitive } from "../../primitive/primitive.js";
5
5
  const TableHead = ({ sx, children, ...props }) => {
6
6
  return /* @__PURE__ */ jsx(
7
- "thead",
7
+ Primitive,
8
8
  {
9
- css: [
10
- {
11
- position: "relative",
12
- fontWeight: 500,
13
- "&::after": {
14
- content: '""',
15
- position: "absolute",
16
- bottom: 0,
17
- left: 0,
18
- right: 0,
19
- borderTopWidth: 1,
20
- borderTopStyle: "solid",
21
- borderTopColor: getColorVar("neutral.200")
22
- }
23
- },
24
- createSxInterpolation(sx)
25
- ],
26
9
  ...props,
10
+ sx: {
11
+ position: "relative",
12
+ fontWeight: 500,
13
+ ":after": {
14
+ content: '""',
15
+ position: "absolute",
16
+ bottom: 0,
17
+ left: 0,
18
+ right: 0,
19
+ borderTopWidth: 1,
20
+ borderTopStyle: "solid",
21
+ borderTopColor: getColorVar("neutral.200")
22
+ },
23
+ ...sx
24
+ },
25
+ as: "thead",
27
26
  children
28
27
  }
29
28
  );
@@ -1,3 +1,3 @@
1
- import { PropsWithSx } from '../../../types';
1
+ import { PrimitiveProps } from '../../primitive';
2
2
  import { JSX } from 'react';
3
- export type TableHeadProps = PropsWithSx<JSX.IntrinsicElements['thead']>;
3
+ export type TableHeadProps = PrimitiveProps<JSX.IntrinsicElements['thead'], 'thead'>;
@@ -1 +1 @@
1
- export declare const TabIndicator: () => import("@emotion/react/jsx-runtime").JSX.Element;
1
+ export declare const TabIndicator: () => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { useRef, useState, useEffect } from "react";
3
3
  import { motion } from "motion/react";
4
- import { createSxInterpolation } from "../../../utils/stylesheet.js";
4
+ import { Stylesheet } from "../../stylesheet/stylesheet.js";
5
5
  import { useTabsContext } from "../tabs/helpers.js";
6
6
  const TabIndicator = () => {
7
7
  const { activeIndex, tabIndicatorProps } = useTabsContext();
@@ -53,7 +53,7 @@ const TabIndicator = () => {
53
53
  resizeObserver.disconnect();
54
54
  };
55
55
  }, [activeTabElement]);
56
- return /* @__PURE__ */ jsx(
56
+ return /* @__PURE__ */ jsx(Stylesheet, { children: ({ css }) => /* @__PURE__ */ jsx(
57
57
  motion.div,
58
58
  {
59
59
  initial: {
@@ -65,18 +65,16 @@ const TabIndicator = () => {
65
65
  transform: `translateX(${indicatorRect.left}px)`
66
66
  },
67
67
  ref: indicatorEl,
68
- css: [
69
- {
70
- position: "absolute",
71
- bottom: 0,
72
- left: 0,
73
- backgroundColor: "currentcolor",
74
- borderRadius: 8
75
- },
76
- createSxInterpolation(tabIndicatorProps == null ? void 0 : tabIndicatorProps.sx)
77
- ]
68
+ className: css({
69
+ position: "absolute",
70
+ bottom: 0,
71
+ left: 0,
72
+ backgroundColor: "currentcolor",
73
+ borderRadius: 8,
74
+ ...tabIndicatorProps == null ? void 0 : tabIndicatorProps.sx
75
+ })
78
76
  }
79
- );
77
+ ) });
80
78
  };
81
79
  export {
82
80
  TabIndicator
@@ -2,11 +2,10 @@ import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import { useRef, useMemo } from "react";
3
3
  import { getTabsProps, TabsContext } from "./helpers.js";
4
4
  import { useControllableState } from "../../../hooks/use-controllable-state.js";
5
- import { createSxInterpolation } from "../../../utils/stylesheet.js";
5
+ import { Primitive } from "../../primitive/primitive.js";
6
6
  const Tabs = ({ ref, children, ..._props }) => {
7
7
  const {
8
8
  defaultActiveIndex,
9
- sx,
10
9
  activeIndex,
11
10
  onTabChange,
12
11
  tabProps,
@@ -35,7 +34,7 @@ const Tabs = ({ ref, children, ..._props }) => {
35
34
  preventActiveTabChange
36
35
  };
37
36
  }, [activeTabIndex, tabProps, tabIndicatorProps, tabPanelProps, preventActiveTabChange, setActiveTabIndex]);
38
- return /* @__PURE__ */ jsx(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { css: createSxInterpolation(sx), ...rest, ref, children }) });
37
+ return /* @__PURE__ */ jsx(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(Primitive, { ...rest, ref, children }) });
39
38
  };
40
39
  export {
41
40
  Tabs
@@ -4,13 +4,13 @@ import dayjs from "dayjs";
4
4
  import { isNil, uniqueId } from "lodash-es";
5
5
  import { useWindowScreen } from "../../hooks/use-window-screen/index.js";
6
6
  import { useControllableState } from "../../hooks/use-controllable-state.js";
7
- import { getResponsiveProp, getSizeVariantState } from "../../utils/index.js";
7
+ import { getResponsiveProp, getSizeVariantState, getColorShadesByVariant } from "../../utils/index.js";
8
8
  import { VirtualizedList } from "../../components/virtualized-list.js";
9
9
  import CloseIcon from "../../assets/svg/times-close-delete.svg.js";
10
10
  import ClockIcon from "../../assets/svg/clock-time.svg.js";
11
11
  import { getColorVar } from "../../theme/palette.js";
12
12
  import { getTypographyVar } from "../../theme/typography.js";
13
- import { createSxInterpolation } from "../../utils/stylesheet.js";
13
+ import { Primitive } from "../primitive/primitive.js";
14
14
  import { Floating } from "../floating/floating/floating.js";
15
15
  import { FloatingTrigger } from "../floating/floating-trigger/floating-trigger.js";
16
16
  import { FloatingContent } from "../floating/floating-content/floating-content.js";
@@ -223,12 +223,16 @@ const TimePicker = ({
223
223
  }
224
224
  );
225
225
  };
226
- const { sx: containerSx, ...restContainerProps } = containerProps ?? {};
227
226
  return /* @__PURE__ */ jsx(
228
- "div",
227
+ Primitive,
229
228
  {
230
- ...restContainerProps,
231
- css: [{ display: "flex", flexDirection: "column", width: "100%" }, createSxInterpolation(containerSx)],
229
+ ...containerProps,
230
+ sx: {
231
+ display: "flex",
232
+ flexDirection: "column",
233
+ width: "100%",
234
+ ...containerProps == null ? void 0 : containerProps.sx
235
+ },
232
236
  children: /* @__PURE__ */ jsxs(
233
237
  Floating,
234
238
  {
@@ -244,15 +248,15 @@ const TimePicker = ({
244
248
  onOpenChange: prehandleOpenChange,
245
249
  ref: floatingRef,
246
250
  children: [
247
- /* @__PURE__ */ jsx(FloatingTrigger, { children: /* @__PURE__ */ jsxs("div", { css: createSxInterpolation(sx), children: [
248
- !selectedDate && !!placeholder && /* @__PURE__ */ jsx("span", { css: { color: "var(--ic-ink-4s)" }, children: placeholder }),
251
+ /* @__PURE__ */ jsx(FloatingTrigger, { children: /* @__PURE__ */ jsxs(Primitive, { sx, children: [
252
+ !selectedDate && !!placeholder && /* @__PURE__ */ jsx(Primitive, { sx: { color: getColorShadesByVariant("neutral").placeholder }, as: "span", children: placeholder }),
249
253
  !!selectedDate && /* @__PURE__ */ jsx("span", { children: dayjs(selectedDate).format(TIME_FORMAT) }),
250
254
  getIcon()
251
255
  ] }) }),
252
256
  /* @__PURE__ */ jsx(FloatingContent, { children: /* @__PURE__ */ jsx(
253
- "div",
257
+ Primitive,
254
258
  {
255
- css: {
259
+ sx: {
256
260
  paddingTop: "0.5rem",
257
261
  paddingBottom: "0.5rem",
258
262
  borderWidth: 1,
@@ -261,7 +265,7 @@ const TimePicker = ({
261
265
  boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
262
266
  fontSize: getTypographyVar("sm").fontSize,
263
267
  lineHeight: getTypographyVar("sm").lineHeight,
264
- backgroundColor: "var(--color-surface-default)"
268
+ backgroundColor: getColorVar("surface.default")
265
269
  },
266
270
  children: portalContentRenderer()
267
271
  }
@@ -1,2 +1,2 @@
1
1
  import { VideoProps } from './types';
2
- export declare const Video: ({ ref, ..._props }: VideoProps) => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export declare const Video: ({ ref, ..._props }: VideoProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
- import { jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import ReactPlayer from "react-player";
3
3
  import { getVideoProps } from "./helpers.js";
4
- import { createSxInterpolation } from "../../utils/stylesheet.js";
4
+ import { Stylesheet } from "../stylesheet/stylesheet.js";
5
5
  const Video = ({ ref, ..._props }) => {
6
6
  const { sx, ...rest } = getVideoProps(_props);
7
- return /* @__PURE__ */ jsx(ReactPlayer, { css: createSxInterpolation(sx), width: "", height: "", ref, ...rest });
7
+ return /* @__PURE__ */ jsx(Stylesheet, { children: ({ cx, css }) => /* @__PURE__ */ jsx(ReactPlayer, { width: "", height: "", ref, ...rest, className: cx(css(sx), rest.className) }) });
8
8
  };
9
9
  export {
10
10
  Video
@@ -8,9 +8,9 @@ export declare const normalizeSearchText: (str?: string, options?: {
8
8
  }) => string;
9
9
  export declare const matchSearch: (text: string | string[], searchText: string, options?: Parameters<typeof normalizeSearchText>[1]) => boolean;
10
10
  export type FormatNumberOptions = Intl.NumberFormatOptions & {
11
- lng: string;
11
+ locale: string;
12
12
  };
13
- export declare const formatNumber: (value: number, { lng, ...options }: FormatNumberOptions) => string;
13
+ export declare const formatNumber: (value: number, { locale, ...options }: FormatNumberOptions) => string;
14
14
  export declare const getDecimalDigits: (value: number) => number;
15
15
  export declare const parseNumber: (text?: string | number, type?: "int" | "float", separator?: string) => number | undefined;
16
16
  export declare function omitEmpty<T extends object>(obj?: T): T;
@@ -39,14 +39,34 @@ export declare const getResponsiveProp: <O extends object, P extends Paths<O>, R
39
39
  condition?: (value?: R) => boolean;
40
40
  }) => R;
41
41
  export type FormatNumberOptions = Intl.NumberFormatOptions & {
42
- lng: string;
42
+ locale: string;
43
43
  };
44
- export declare const formatNumber: (value: number, { lng, ...options }: FormatNumberOptions) => string;
44
+ export declare const formatNumber: (value: number, { locale, ...options }: FormatNumberOptions) => string;
45
45
  export type FormatPriceOptions = SetRequired<Intl.NumberFormatOptions, 'currency'> & {
46
- lng: string;
46
+ locale: string;
47
47
  };
48
- export declare const formatPrice: (value: number, { lng, ...options }: FormatPriceOptions) => string;
48
+ export declare const formatPrice: (value: number, { locale, ...options }: FormatPriceOptions) => string;
49
49
  export type FormatDateTimeOptions = Intl.DateTimeFormatOptions & {
50
- lng: string;
50
+ locale: string;
51
51
  };
52
- export declare const formatDateTime: (value: Date | string | number, { lng, ...options }: FormatDateTimeOptions) => string;
52
+ export type GetLanguageDisplayNameOptions = Omit<Intl.DisplayNamesOptions, 'type'> & {
53
+ /** Ngôn ngữ hiển thị tên, mặc định là chính code đó (self-naming) */
54
+ locale?: string;
55
+ };
56
+ /**
57
+ * Trả về tên đầy đủ của ngôn ngữ dựa trên language code.
58
+ * VD: getLanguageDisplayName('vi') → 'Tiếng Việt'
59
+ * getLanguageDisplayName('en', { locale: 'vi' }) → 'Tiếng Anh'
60
+ */
61
+ export declare const getLanguageDisplayName: (code: string, options?: GetLanguageDisplayNameOptions) => string;
62
+ /**
63
+ * Trả về tên đầy đủ của tiền tệ dựa trên currency code.
64
+ * VD: getCurrencyDisplayName('VND', { locale: 'vi' }) → 'Đồng Việt Nam'
65
+ * getCurrencyDisplayName('USD', { locale: 'en' }) → 'US Dollar'
66
+ */
67
+ export type GetCurrencyDisplayNameOptions = Omit<Intl.DisplayNamesOptions, 'type'> & {
68
+ /** Ngôn ngữ hiển thị tên */
69
+ locale: string;
70
+ };
71
+ export declare const getCurrencyDisplayName: (code: string, options: GetCurrencyDisplayNameOptions) => string;
72
+ export declare const formatDateTime: (value: Date | string | number, { locale, ...options }: FormatDateTimeOptions) => string;
@@ -167,9 +167,9 @@ const getResponsiveProp = (record, field, screen, options) => {
167
167
  });
168
168
  return getByScreen(smallerScreen ?? screen);
169
169
  };
170
- const formatNumber = (value, { lng, ...options }) => {
170
+ const formatNumber = (value, { locale, ...options }) => {
171
171
  try {
172
- return new Intl.NumberFormat(lng, {
172
+ return new Intl.NumberFormat(locale, {
173
173
  minimumFractionDigits: 0,
174
174
  ...options
175
175
  }).format(value);
@@ -177,9 +177,9 @@ const formatNumber = (value, { lng, ...options }) => {
177
177
  return value.toString();
178
178
  }
179
179
  };
180
- const formatPrice = (value, { lng, ...options }) => {
180
+ const formatPrice = (value, { locale, ...options }) => {
181
181
  try {
182
- return new Intl.NumberFormat(lng, {
182
+ return new Intl.NumberFormat(locale, {
183
183
  style: "currency",
184
184
  minimumFractionDigits: 0,
185
185
  currencyDisplay: "narrowSymbol",
@@ -189,7 +189,25 @@ const formatPrice = (value, { lng, ...options }) => {
189
189
  return [value, options.currency].filter(Boolean).join(" ");
190
190
  }
191
191
  };
192
- const formatDateTime = (value, { lng, ...options }) => {
192
+ const getLanguageDisplayName = (code, options) => {
193
+ const { locale, ...rest } = options ?? {};
194
+ try {
195
+ const displayNames = new Intl.DisplayNames([locale ?? code], { ...rest, type: "language" });
196
+ return displayNames.of(code) ?? code;
197
+ } catch {
198
+ return code;
199
+ }
200
+ };
201
+ const getCurrencyDisplayName = (code, options) => {
202
+ const { locale, ...rest } = options;
203
+ try {
204
+ const displayNames = new Intl.DisplayNames([locale], { ...rest, type: "currency" });
205
+ return displayNames.of(code.toUpperCase()) ?? code;
206
+ } catch {
207
+ return code;
208
+ }
209
+ };
210
+ const formatDateTime = (value, { locale, ...options }) => {
193
211
  const dateObject = (() => {
194
212
  if (isString(value)) {
195
213
  const hasTimezone = /([zZ]|[+-]\d{2}:\d{2})$/.test(value);
@@ -201,7 +219,7 @@ const formatDateTime = (value, { lng, ...options }) => {
201
219
  return value;
202
220
  })();
203
221
  try {
204
- return new Intl.DateTimeFormat(lng, {
222
+ return new Intl.DateTimeFormat(locale, {
205
223
  day: "2-digit",
206
224
  month: "2-digit",
207
225
  year: "numeric",
@@ -229,8 +247,10 @@ export {
229
247
  formatNumber,
230
248
  formatPrice,
231
249
  getColorShadesByVariant,
250
+ getCurrencyDisplayName,
232
251
  getDecimalDigits,
233
252
  getEnumValues,
253
+ getLanguageDisplayName,
234
254
  getResponsiveProp,
235
255
  getSizeVariantState,
236
256
  matchSearch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [