@janbox/storefront-ui 4.0.1 → 4.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.
package/README.md CHANGED
@@ -478,7 +478,7 @@ Mọi component đều có README riêng với API reference, examples, và usag
478
478
  - [Drawer](./dist/lib/drawer/README.md)
479
479
  - [FilterPanel](./dist/lib/filter-panel/README.md)
480
480
  - [Flag](./dist/lib/flag/README.md)
481
- - [Flexbox](./dist/lib/flexbox/README.md)
481
+ - [Flexbox](./dist/lib/flexbox/flexbox/README.md)
482
482
  - [Floating](./dist/lib/floating/README.md)
483
483
  - [FormHelperText](./dist/lib/form-helper-text/README.md)
484
484
  - [FormLabel](./dist/lib/form-label/README.md)
@@ -11,7 +11,11 @@ import { Box } from '@janbox/storefront-ui';
11
11
  ## Props
12
12
 
13
13
  | Prop | Type | Default | Description |
14
- |------|------|---------|-------------|
14
+ | ------ | ------ | ------- | ----------- |
15
+ | `hidden` | `boolean` | - | Ẩn Box (`display: none`) hoặc hiển thị (`display: block`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
16
+ | `sm` | `BoxResponsiveProps` | - | Override responsive props tại breakpoint `sm` (768px). |
17
+ | `md` | `BoxResponsiveProps` | - | Override responsive props tại breakpoint `md` (1280px). |
18
+ | `lg` | `BoxResponsiveProps` | - | Override responsive props tại breakpoint `lg` (1680px). |
15
19
  | `sx` | `ToResponsiveProps<StyledCSS>` | - | Responsive Emotion CSS overrides. Accepts a base StyledCSS object plus optional `sm`, `md`, and `lg` breakpoint keys for responsive styles. |
16
20
  | `as` | `HTMLElementType` | "div" | Override the rendered HTML element (polymorphic). Defaults to `div`. |
17
21
  | `children` | `React.ReactNode` | - | Content rendered inside the Box. |
@@ -44,6 +48,15 @@ import { Box } from '@janbox/storefront-ui';
44
48
  </Box>
45
49
  ```
46
50
 
51
+ ### Responsive hidden
52
+
53
+ ```tsx
54
+ {/* Ẩn trên mobile, hiện từ md trở lên */}
55
+ <Box hidden md={{ hidden: false }}>
56
+ Desktop only content
57
+ </Box>
58
+ ```
59
+
47
60
  ## Related Components
48
61
 
49
62
  - [Primitive](../primitive/README.md)
@@ -2,22 +2,26 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { getBoxProps } from "./helpers.js";
3
3
  import { Primitive } from "../primitive/primitive.js";
4
4
  const Box = ({ children, ref, ..._props }) => {
5
- const { sx = {}, ...rest } = getBoxProps(_props);
5
+ const { hidden, sm, md, lg, sx = {}, ...rest } = getBoxProps(_props);
6
6
  return /* @__PURE__ */ jsx(
7
7
  Primitive,
8
8
  {
9
9
  ...rest,
10
10
  sx: {
11
+ ...createStyle({ hidden }),
11
12
  ...sx,
12
- sm: { ...sx.sm },
13
- md: { ...sx.md },
14
- lg: { ...sx.lg }
13
+ sm: { ...createStyle(sm), ...sx.sm },
14
+ md: { ...createStyle(md), ...sx.md },
15
+ lg: { ...createStyle(lg), ...sx.lg }
15
16
  },
16
17
  ref,
17
18
  children
18
19
  }
19
20
  );
20
21
  };
22
+ const createStyle = ({ hidden } = {}) => ({
23
+ display: hidden ? "none" : "block"
24
+ });
21
25
  export {
22
26
  Box
23
27
  };
@@ -1,3 +1,9 @@
1
1
  import { JSX } from 'react';
2
2
  import { PrimitiveProps } from '../primitive';
3
- export type BoxProps = PrimitiveProps<JSX.IntrinsicElements['div']>;
3
+ import { ShallowMerge, ToResponsiveProps } from '../../types';
4
+ export interface BoxResponsiveProps {
5
+ hidden?: boolean;
6
+ }
7
+ type BoxExtendedProps = ToResponsiveProps<BoxResponsiveProps>;
8
+ export type BoxProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], BoxExtendedProps>, 'div'>;
9
+ export {};
@@ -11,7 +11,11 @@ import { Container } from '@janbox/storefront-ui';
11
11
  ## Props
12
12
 
13
13
  | Prop | Type | Default | Description |
14
- |------|------|---------|-------------|
14
+ | ------ | ------ | ------- | ----------- |
15
+ | `hidden` | `boolean` | - | Ẩn Container (`display: none`) hoặc hiển thị (`display: block`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
16
+ | `sm` | `ContainerResponsiveProps` | - | Override responsive props tại breakpoint `sm` (768px). |
17
+ | `md` | `ContainerResponsiveProps` | - | Override responsive props tại breakpoint `md` (1280px). |
18
+ | `lg` | `ContainerResponsiveProps` | - | Override responsive props tại breakpoint `lg` (1680px). |
15
19
  | `sx` | `ToResponsiveProps<StyledCSS>` | - | Custom Emotion CSS. Hỗ trợ responsive keys (`sm`, `md`, `lg`). **Không nên override** `width`, `max-width`, `margin-left`, `margin-right`, `padding-left`, `padding-right` — các thuộc tính này do Container quản lý nội bộ. |
16
20
  | `children` | `React.ReactNode` | - | Nội dung render bên trong container. |
17
21
  | `...rest` | `JSX.IntrinsicElements['div']` | - | Tất cả HTML div attributes tiêu chuẩn (`className`, `style`, `onClick`, v.v.). |
@@ -34,6 +38,15 @@ import { Container } from '@janbox/storefront-ui';
34
38
  </Container>
35
39
  ```
36
40
 
41
+ ### Responsive hidden
42
+
43
+ ```tsx
44
+ {/* Ẩn trên mobile, hiện từ md trở lên */}
45
+ <Container hidden md={{ hidden: false }}>
46
+ Desktop only section
47
+ </Container>
48
+ ```
49
+
37
50
  > Không dùng `sx` để override layout core của Container như `width`, `max-width`, `margin-left`, `margin-right`, `padding-left`, `padding-right`. Nếu cần layout khác, dùng wrapper component riêng thay vì thay đổi contract của Container.
38
51
 
39
52
  ## Dependencies
@@ -2,9 +2,26 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { getContainerProps } from "./helpers.js";
3
3
  import { Primitive } from "../primitive/primitive.js";
4
4
  const Container = ({ children, ref, ..._props }) => {
5
- const props = getContainerProps(_props);
6
- return /* @__PURE__ */ jsx(Primitive, { ...props, ref, children });
5
+ const { hidden, sm, md, lg, sx = {}, ...rest } = getContainerProps(_props);
6
+ return /* @__PURE__ */ jsx(
7
+ Primitive,
8
+ {
9
+ ...rest,
10
+ sx: {
11
+ ...createStyle({ hidden }),
12
+ ...sx,
13
+ sm: { ...createStyle(sm), ...sx.sm },
14
+ md: { ...createStyle(md), ...sx.md },
15
+ lg: { ...createStyle(lg), ...sx.lg }
16
+ },
17
+ ref,
18
+ children
19
+ }
20
+ );
7
21
  };
22
+ const createStyle = ({ hidden } = {}) => ({
23
+ display: hidden ? "none" : "block"
24
+ });
8
25
  export {
9
26
  Container
10
27
  };
@@ -1,3 +1,9 @@
1
1
  import { JSX } from 'react';
2
2
  import { PrimitiveProps } from '../primitive';
3
- export type ContainerProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
3
+ import { ShallowMerge, ToResponsiveProps } from '../../types';
4
+ export interface ContainerResponsiveProps {
5
+ hidden?: boolean;
6
+ }
7
+ type ContainerExtendedProps = ToResponsiveProps<ContainerResponsiveProps>;
8
+ export type ContainerProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], ContainerExtendedProps>, 'div'>;
9
+ export {};
@@ -0,0 +1,53 @@
1
+ # FlexItem
2
+
3
+ A flex child component intended to be used inside Flexbox. Constrains content to `max-width: 100%` by default and supports `hidden` for responsive visibility control.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { FlexItem } from '@janbox/storefront-ui';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ | ------ | ------ | ------- | ----------- |
15
+ | `hidden` | `boolean` | - | Ẩn FlexItem (`display: none`) hoặc hiển thị (`display: block`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
16
+ | `sm` | `FlexItemResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ hidden?: boolean }`. |
17
+ | `md` | `FlexItemResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ hidden?: boolean }`. |
18
+ | `lg` | `FlexItemResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ hidden?: boolean }`. |
19
+ | `sx` | `ToResponsiveProps<StyledCSS>` | - | Custom Emotion CSS. Hỗ trợ responsive keys (`sm`, `md`, `lg`). |
20
+ | `children` | `React.ReactNode` | - | Nội dung render bên trong flex item. |
21
+ | `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying div element. |
22
+ | `...rest` | `JSX.IntrinsicElements['div']` | - | Tất cả HTML div attributes tiêu chuẩn. |
23
+
24
+ ## Examples
25
+
26
+ ### Basic FlexItem
27
+
28
+ ```tsx
29
+ <Flexbox sx={{ gap: 8 }}>
30
+ <FlexItem>Item 1</FlexItem>
31
+ <FlexItem>Item 2</FlexItem>
32
+ </Flexbox>
33
+ ```
34
+
35
+ ### Responsive hidden
36
+
37
+ ```tsx
38
+ {/* Ẩn trên mobile, hiện từ md trở lên */}
39
+ <Flexbox sx={{ gap: 8 }}>
40
+ <FlexItem>Always visible</FlexItem>
41
+ <FlexItem hidden md={{ hidden: false }}>Desktop only</FlexItem>
42
+ </Flexbox>
43
+ ```
44
+
45
+ ## Related Components
46
+
47
+ - [Flexbox](../flexbox/README.md)
48
+ - [Primitive](../../primitive/README.md)
49
+
50
+ ## See Also
51
+
52
+ - [Component Source](./flex-item.tsx)
53
+ - [Main README](../../../README.md)
@@ -2,13 +2,17 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { getFlexItemProps } from "./helpers.js";
3
3
  import { Primitive } from "../../primitive/primitive.js";
4
4
  const FlexItem = ({ children, ref, ...rest }) => {
5
- const { sx, ...props } = getFlexItemProps(rest);
5
+ const { hidden, sm, md, lg, sx, ...props } = getFlexItemProps(rest);
6
6
  return /* @__PURE__ */ jsx(
7
7
  Primitive,
8
8
  {
9
9
  sx: {
10
10
  maxWidth: "100%",
11
- ...sx
11
+ ...createStyle({ hidden }),
12
+ ...sx,
13
+ sm: { ...createStyle(sm), ...sx == null ? void 0 : sx.sm },
14
+ md: { ...createStyle(md), ...sx == null ? void 0 : sx.md },
15
+ lg: { ...createStyle(lg), ...sx == null ? void 0 : sx.lg }
12
16
  },
13
17
  ...props,
14
18
  ref,
@@ -16,6 +20,9 @@ const FlexItem = ({ children, ref, ...rest }) => {
16
20
  }
17
21
  );
18
22
  };
23
+ const createStyle = ({ hidden } = {}) => ({
24
+ display: hidden ? "none" : "block"
25
+ });
19
26
  export {
20
27
  FlexItem
21
28
  };
@@ -1,3 +1,9 @@
1
1
  import { JSX } from 'react';
2
2
  import { PrimitiveProps } from '../../primitive';
3
- export type FlexItemProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
3
+ import { ShallowMerge, ToResponsiveProps } from '../../../types';
4
+ export interface FlexItemResponsiveProps {
5
+ hidden?: boolean;
6
+ }
7
+ type FlexItemExtendedProps = ToResponsiveProps<FlexItemResponsiveProps>;
8
+ export type FlexItemProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], FlexItemExtendedProps>, 'div'>;
9
+ export {};
@@ -11,7 +11,11 @@ import { Flexbox } from '@janbox/storefront-ui';
11
11
  ## Props
12
12
 
13
13
  | Prop | Type | Default | Description |
14
- |------|------|---------|-------------|
14
+ | ------ | ------ | ------- | ----------- |
15
+ | `hidden` | `boolean` | - | Ẩn Flexbox (`display: none`) hoặc hiển thị (`display: flex`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
16
+ | `sm` | `FlexboxResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ hidden?: boolean }`. |
17
+ | `md` | `FlexboxResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ hidden?: boolean }`. |
18
+ | `lg` | `FlexboxResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ hidden?: boolean }`. |
15
19
  | `sx` | `ToResponsiveProps<StyledCSS>` | { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'flex-start' } | Responsive style overrides via the Emotion-powered sx prop. Supports base styles plus `sm`, `md`, and `lg` breakpoint keys. Merged on top of the component defaults (`flexDirection: 'row'`, `alignItems: 'flex-start'`, `justifyContent: 'flex-start'`). |
16
20
  | `children` | `React.ReactNode` | - | Child elements rendered inside the flex container — typically `FlexItem` components. |
17
21
  | `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying `div` element. |
@@ -47,12 +51,22 @@ import { Flexbox } from '@janbox/storefront-ui';
47
51
  </Flexbox>
48
52
  ```
49
53
 
54
+ ### Responsive hidden
55
+
56
+ ```tsx
57
+ {/* Ẩn trên mobile, hiện từ md trở lên */}
58
+ <Flexbox hidden md={{ hidden: false }} sx={{ gap: 16 }}>
59
+ <FlexItem>Desktop only</FlexItem>
60
+ </Flexbox>
61
+ ```
62
+
50
63
  ## Related Components
51
64
 
52
- - [Primitive](../primitive/README.md)
65
+ - [FlexItem](../flex-item/README.md)
66
+ - [Primitive](../../primitive/README.md)
53
67
 
54
68
  ## See Also
55
69
 
56
70
  - [Component Source](./index.ts)
57
- - [Storybook Stories](./flexbox.stories.tsx)
58
- - [Main README](../../README.md)
71
+ - [Storybook Stories](../flexbox.stories.tsx)
72
+ - [Main README](../../../README.md)
@@ -2,23 +2,27 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { getFlexboxProps } from "./helpers.js";
3
3
  import { Primitive } from "../../primitive/primitive.js";
4
4
  const Flexbox = ({ children, ref, ..._props }) => {
5
- const { sx = {}, ...rest } = getFlexboxProps(_props);
5
+ var _a, _b, _c;
6
+ const { hidden, sm, md, lg, ...rest } = getFlexboxProps(_props);
6
7
  return /* @__PURE__ */ jsx(
7
8
  Primitive,
8
9
  {
9
10
  ...rest,
10
11
  sx: {
11
- display: "flex",
12
- ...sx,
13
- sm: { ...sx.sm },
14
- md: { ...sx.md },
15
- lg: { ...sx.lg }
12
+ ...createStyle({ hidden }),
13
+ ...rest.sx,
14
+ sm: { ...createStyle(sm), ...(_a = rest.sx) == null ? void 0 : _a.sm },
15
+ md: { ...createStyle(md), ...(_b = rest.sx) == null ? void 0 : _b.md },
16
+ lg: { ...createStyle(lg), ...(_c = rest.sx) == null ? void 0 : _c.lg }
16
17
  },
17
18
  ref,
18
19
  children
19
20
  }
20
21
  );
21
22
  };
23
+ const createStyle = ({ hidden } = {}) => ({
24
+ display: hidden ? "none" : "flex"
25
+ });
22
26
  export {
23
27
  Flexbox
24
28
  };
@@ -1,3 +1,9 @@
1
1
  import { JSX } from 'react';
2
2
  import { PrimitiveProps } from '../../primitive';
3
- export type FlexboxProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
3
+ import { ShallowMerge, ToResponsiveProps } from '../../../types';
4
+ export interface FlexboxResponsiveProps {
5
+ hidden?: boolean;
6
+ }
7
+ type FlexboxExtendedProps = ToResponsiveProps<FlexboxResponsiveProps>;
8
+ export type FlexboxProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], FlexboxExtendedProps>, 'div'>;
9
+ export {};
@@ -11,11 +11,12 @@ import { Cell } from '@janbox/storefront-ui';
11
11
  ## Props
12
12
 
13
13
  | Prop | Type | Default | Description |
14
- |------|------|---------|-------------|
14
+ | ------ | ------ | ------- | ----------- |
15
15
  | `colSpan` | `number` | - | Number of grid columns the cell should span. Generates `grid-column: span colSpan`. Supports responsive variants via sm/md/lg. |
16
- | `sm` | `CellResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ colSpan?: number }`. |
17
- | `md` | `CellResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ colSpan?: number }`. |
18
- | `lg` | `CellResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ colSpan?: number }`. |
16
+ | `hidden` | `boolean` | - | Ẩn Cell (`display: none`) hoặc hiển thị (`display: block`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
17
+ | `sm` | `CellResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ colSpan?: number, hidden?: boolean }`. |
18
+ | `md` | `CellResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ colSpan?: number, hidden?: boolean }`. |
19
+ | `lg` | `CellResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ colSpan?: number, hidden?: boolean }`. |
19
20
  | `sx` | `ToResponsiveProps<StyledCSS>` | - | Escape-hatch for inline Emotion styles. Supports responsive keys (sm, md, lg) alongside base styles. |
20
21
  | `children` | `React.ReactNode` | - | Cell content. |
21
22
  | `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying div element. |
@@ -50,6 +51,18 @@ import { Cell } from '@janbox/storefront-ui';
50
51
  </Cell>
51
52
  ```
52
53
 
54
+ ### Responsive hidden
55
+
56
+ ```tsx
57
+ {/* Ẩn trên mobile, hiện từ sm trở lên */}
58
+ <Grid cols={3}>
59
+ <Cell hidden sm={{ hidden: false }}>
60
+ Desktop only cell
61
+ </Cell>
62
+ <Cell>Always visible</Cell>
63
+ </Grid>
64
+ ```
65
+
53
66
  ## Related Components
54
67
 
55
68
  - [Grid](../grid/README.md)
@@ -4,13 +4,13 @@ import { getCellProps } from "./helpers.js";
4
4
  import { Primitive } from "../../primitive/primitive.js";
5
5
  const Cell = ({ children, ref, ..._props }) => {
6
6
  var _a, _b, _c;
7
- const { colSpan, sm, md, lg, ...rest } = getCellProps(_props);
7
+ const { colSpan, hidden, sm, md, lg, ...rest } = getCellProps(_props);
8
8
  return /* @__PURE__ */ jsx(
9
9
  Primitive,
10
10
  {
11
11
  ...rest,
12
12
  sx: {
13
- ...createStyle({ colSpan }),
13
+ ...createStyle({ colSpan, hidden }),
14
14
  ...rest.sx,
15
15
  sm: {
16
16
  ...createStyle(sm),
@@ -30,8 +30,9 @@ const Cell = ({ children, ref, ..._props }) => {
30
30
  }
31
31
  );
32
32
  };
33
- const createStyle = ({ colSpan } = {}) => {
33
+ const createStyle = ({ colSpan, hidden } = {}) => {
34
34
  return {
35
+ display: hidden ? "none" : "block",
35
36
  gridColumn: isNumber(colSpan) ? `span ${colSpan}` : colSpan
36
37
  };
37
38
  };
@@ -3,5 +3,6 @@ import { ToResponsiveProps } from '../../../types';
3
3
  import { PrimitiveProps } from '../../primitive';
4
4
  export interface CellResponsiveProps {
5
5
  colSpan?: number;
6
+ hidden?: boolean;
6
7
  }
7
8
  export type CellProps = PrimitiveProps<JSX.IntrinsicElements['div'] & ToResponsiveProps<CellResponsiveProps>>;
@@ -11,11 +11,12 @@ import { Grid } from '@janbox/storefront-ui';
11
11
  ## Props
12
12
 
13
13
  | Prop | Type | Default | Description |
14
- |------|------|---------|-------------|
14
+ | ------ | ------ | ------- | ----------- |
15
15
  | `cols` | `number` | 1 | Number of equal-width columns in the grid. Generates `grid-template-columns: repeat(cols, minmax(0, 1fr))`. Supports responsive variants via sm/md/lg. |
16
- | `sm` | `GridResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ cols?: number }`. |
17
- | `md` | `GridResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ cols?: number }`. |
18
- | `lg` | `GridResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ cols?: number }`. |
16
+ | `hidden` | `boolean` | - | Ẩn Grid (`display: none`) hoặc hiển thị (`display: grid`). Hỗ trợ responsive qua `sm`, `md`, `lg`. |
17
+ | `sm` | `GridResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ cols?: number, hidden?: boolean }`. |
18
+ | `md` | `GridResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ cols?: number, hidden?: boolean }`. |
19
+ | `lg` | `GridResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ cols?: number, hidden?: boolean }`. |
19
20
  | `sx` | `ToResponsiveProps<StyledCSS>` | - | Escape-hatch for inline Emotion styles. Supports responsive keys (sm, md, lg) alongside base styles. |
20
21
  | `children` | `React.ReactNode` | - | Grid children, typically Cell components. |
21
22
  | `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying div element. |
@@ -55,6 +56,17 @@ import { Grid } from '@janbox/storefront-ui';
55
56
  </Grid>
56
57
  ```
57
58
 
59
+ ### Responsive hidden
60
+
61
+ ```tsx
62
+ {/* Ẩn trên mobile, hiện từ md trở lên */}
63
+ <Grid cols={3} hidden md={{ hidden: false }}>
64
+ <Cell>Item 1</Cell>
65
+ <Cell>Item 2</Cell>
66
+ <Cell>Item 3</Cell>
67
+ </Grid>
68
+ ```
69
+
58
70
  ## Related Components
59
71
 
60
72
  - [Cell](../cell/README.md)
@@ -5,25 +5,26 @@ import { Primitive } from "../../primitive/primitive.js";
5
5
  const GRID_MINIMUM_COLS = 1;
6
6
  const GRID_MAXIMUM_COLS = 24;
7
7
  const Grid = ({ children, ref, ..._props }) => {
8
- const { cols, sm, md, lg, sx = {}, ...rest } = getGridProps(_props);
8
+ var _a, _b, _c;
9
+ const { cols, hidden, sm, md, lg, ...rest } = getGridProps(_props);
9
10
  return /* @__PURE__ */ jsx(
10
11
  Primitive,
11
12
  {
13
+ ...rest,
12
14
  sx: {
13
- display: "grid",
14
- ...createStyle({ cols }),
15
- ...sx,
16
- sm: { ...createStyle(sm), ...sx.sm },
17
- md: { ...createStyle(md), ...sx.md },
18
- lg: { ...createStyle(lg), ...sx.lg }
15
+ ...createStyle({ cols, hidden }),
16
+ ...rest.sx,
17
+ sm: { ...createStyle(sm), ...(_a = rest.sx) == null ? void 0 : _a.sm },
18
+ md: { ...createStyle(md), ...(_b = rest.sx) == null ? void 0 : _b.md },
19
+ lg: { ...createStyle(lg), ...(_c = rest.sx) == null ? void 0 : _c.lg }
19
20
  },
20
- ...rest,
21
21
  ref,
22
22
  children
23
23
  }
24
24
  );
25
25
  };
26
- const createStyle = ({ cols } = {}) => ({
26
+ const createStyle = ({ cols, hidden } = {}) => ({
27
+ display: hidden ? "none" : "grid",
27
28
  gridTemplateColumns: isNil(cols) ? void 0 : `repeat(${cols}, minmax(0, 1fr))`
28
29
  });
29
30
  export {
@@ -3,6 +3,7 @@ import { ShallowMerge, ToResponsiveProps } from '../../../types';
3
3
  import { PrimitiveProps } from '../../primitive';
4
4
  export interface GridResponsiveProps {
5
5
  cols?: number;
6
+ hidden?: boolean;
6
7
  }
7
8
  type GridExtendedProps = ToResponsiveProps<GridResponsiveProps>;
8
9
  export type GridProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], GridExtendedProps>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janbox/storefront-ui",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Storefront UI component library for Janbox",
5
5
  "author": "Janbox",
6
6
  "keywords": [