@janbox/storefront-ui 3.0.0 → 3.0.1
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 +72 -37
- package/dist/constants/emotion.d.ts +0 -2
- package/dist/constants/emotion.js +0 -24
- package/dist/lib/accordion/accordion-summary/accordion-summary.d.ts +1 -1
- package/dist/lib/accordion/accordion-summary/accordion-summary.js +21 -13
- package/dist/lib/accordion/accordion-summary/types.d.ts +4 -3
- package/dist/lib/box/README.md +1 -11
- package/dist/lib/box/box.js +1 -3
- package/dist/lib/box/types.d.ts +1 -5
- package/dist/lib/cascader/cascader.js +9 -12
- package/dist/lib/cascader/types.d.ts +3 -2
- package/dist/lib/chip/chip.d.ts +1 -1
- package/dist/lib/chip/chip.js +35 -31
- package/dist/lib/chip/types.d.ts +5 -4
- package/dist/lib/container/README.md +7 -18
- package/dist/lib/container/container.d.ts +1 -1
- package/dist/lib/container/container.js +4 -88
- package/dist/lib/container/helpers.js +24 -1
- package/dist/lib/container/types.d.ts +2 -8
- package/dist/lib/flexbox/README.md +1 -2
- package/dist/lib/flexbox/flexbox/flexbox.d.ts +1 -1
- package/dist/lib/flexbox/flexbox/flexbox.js +1 -3
- package/dist/lib/flexbox/flexbox/types.d.ts +2 -6
- package/dist/lib/grid/cell/README.md +66 -0
- package/dist/lib/grid/{README.md → grid/README.md} +5 -6
- package/dist/lib/grid/grid/grid.js +1 -3
- package/dist/lib/grid/grid/types.d.ts +4 -5
- package/dist/lib/table/table/table.d.ts +1 -1
- package/dist/lib/table/table/table.js +7 -6
- package/dist/lib/table/table/types.d.ts +2 -2
- package/dist/lib/table/table-footer/table-footer.d.ts +1 -1
- package/dist/lib/table/table-footer/table-footer.js +4 -4
- package/dist/lib/table/table-footer/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -250,43 +250,7 @@ const formatted = formatPrice(1000000, 'VND', 'vi-VN'); // "1.000.000 ₫"
|
|
|
250
250
|
|
|
251
251
|
### Component Categories
|
|
252
252
|
|
|
253
|
-
Thư viện cung cấp 60+ components được tổ chức theo các nhóm
|
|
254
|
-
|
|
255
|
-
#### Layout
|
|
256
|
-
|
|
257
|
-
`Box`, `Flexbox`, `Grid`, `Container`
|
|
258
|
-
|
|
259
|
-
#### Typography
|
|
260
|
-
|
|
261
|
-
`Text`, `Link`, `HighlightWords`
|
|
262
|
-
|
|
263
|
-
#### Form Controls
|
|
264
|
-
|
|
265
|
-
`Input`, `InputNumber`, `InputRange`, `InputMask`, `Textarea`, `Select`, `MultipleSelect`, `Checkbox`, `RadioButton`, `Switch`, `DatePicker`, `TimePicker`, `PhoneInput`, `OtpInput`, `Cascader`
|
|
266
|
-
|
|
267
|
-
#### Buttons
|
|
268
|
-
|
|
269
|
-
`Button`, `IconButton`, `NavLink`
|
|
270
|
-
|
|
271
|
-
#### Feedback
|
|
272
|
-
|
|
273
|
-
`Loading`, `Progress`, `LinearProgress`, `Dialog`, `Drawer`, `Tooltip`, `Popover`, `Notifications`
|
|
274
|
-
|
|
275
|
-
#### Data Display
|
|
276
|
-
|
|
277
|
-
`Badge`, `Chip`, `Avatar`, `Table`, `Pagination`, `Stepper`, `Tabs`, `Accordion`, `Collapse`, `Breadcrumbs`, `StarRating`, `PriceLabel`, `CountUp`, `CountdownTimer`, `Flag`
|
|
278
|
-
|
|
279
|
-
#### Media
|
|
280
|
-
|
|
281
|
-
`Image`, `Video`, `Icon`, `Lightbox`, `Swiper`
|
|
282
|
-
|
|
283
|
-
#### Navigation
|
|
284
|
-
|
|
285
|
-
`Menu`, `FilterPanel`
|
|
286
|
-
|
|
287
|
-
#### Utilities
|
|
288
|
-
|
|
289
|
-
`Primitive`, `RippleEffect`, `SuspenseQuery`, `Marquee`, `Floating`
|
|
253
|
+
Thư viện cung cấp 60+ components được tổ chức theo các nhóm. Xem danh sách README theo từng component tại [Component Documentation](#component-documentation).
|
|
290
254
|
|
|
291
255
|
### Export Paths
|
|
292
256
|
|
|
@@ -491,6 +455,77 @@ export const Xxx = ({ ref, ..._props }: XxxProps) => {
|
|
|
491
455
|
|
|
492
456
|
---
|
|
493
457
|
|
|
458
|
+
## Component Documentation
|
|
459
|
+
|
|
460
|
+
Mọi component đều có README riêng với API reference, examples, và usage notes.
|
|
461
|
+
|
|
462
|
+
- [Accordion](./dist/lib/accordion/README.md)
|
|
463
|
+
- [Avatar](./dist/lib/avatar/README.md)
|
|
464
|
+
- [Badge](./dist/lib/badge/README.md)
|
|
465
|
+
- [Box](./dist/lib/box/README.md)
|
|
466
|
+
- [Breadcrumbs](./dist/lib/breadcrumbs/README.md)
|
|
467
|
+
- [Button](./dist/lib/button/README.md)
|
|
468
|
+
- [Cascader](./dist/lib/cascader/README.md)
|
|
469
|
+
- [Cell](./dist/lib/grid/cell/README.md)
|
|
470
|
+
- [Checkbox](./dist/lib/checkbox/README.md)
|
|
471
|
+
- [Chip](./dist/lib/chip/README.md)
|
|
472
|
+
- [Collapse](./dist/lib/collapse/README.md)
|
|
473
|
+
- [Container](./dist/lib/container/README.md)
|
|
474
|
+
- [CountUp](./dist/lib/count-up/README.md)
|
|
475
|
+
- [CountdownTimer](./dist/lib/countdown-timer/README.md)
|
|
476
|
+
- [DatePicker](./dist/lib/date-picker/README.md)
|
|
477
|
+
- [Dialog](./dist/lib/dialog/README.md)
|
|
478
|
+
- [Drawer](./dist/lib/drawer/README.md)
|
|
479
|
+
- [FilterPanel](./dist/lib/filter-panel/README.md)
|
|
480
|
+
- [Flag](./dist/lib/flag/README.md)
|
|
481
|
+
- [Flexbox](./dist/lib/flexbox/README.md)
|
|
482
|
+
- [Floating](./dist/lib/floating/README.md)
|
|
483
|
+
- [FormHelperText](./dist/lib/form-helper-text/README.md)
|
|
484
|
+
- [FormLabel](./dist/lib/form-label/README.md)
|
|
485
|
+
- [Grid](./dist/lib/grid/grid/README.md)
|
|
486
|
+
- [HighlightWords](./dist/lib/highlight-words/README.md)
|
|
487
|
+
- [Icon](./dist/lib/icon/README.md)
|
|
488
|
+
- [IconButton](./dist/lib/icon-button/README.md)
|
|
489
|
+
- [Image](./dist/lib/image/README.md)
|
|
490
|
+
- [Input](./dist/lib/input/README.md)
|
|
491
|
+
- [InputMask](./dist/lib/input-mask/README.md)
|
|
492
|
+
- [InputNumber](./dist/lib/input-number/README.md)
|
|
493
|
+
- [InputRange](./dist/lib/input-range/README.md)
|
|
494
|
+
- [Lightbox](./dist/lib/lightbox/README.md)
|
|
495
|
+
- [LinearProgress](./dist/lib/linear-progress/README.md)
|
|
496
|
+
- [Link](./dist/lib/link/README.md)
|
|
497
|
+
- [Loading](./dist/lib/loading/README.md)
|
|
498
|
+
- [Marquee](./dist/lib/marquee/README.md)
|
|
499
|
+
- [Menu](./dist/lib/menu/README.md)
|
|
500
|
+
- [MultipleSelect](./dist/lib/multiple-select/README.md)
|
|
501
|
+
- [NavLink](./dist/lib/nav-link/README.md)
|
|
502
|
+
- [Notifications](./dist/lib/notifications/README.md)
|
|
503
|
+
- [OtpInput](./dist/lib/otp-input/README.md)
|
|
504
|
+
- [Pagination](./dist/lib/pagination/README.md)
|
|
505
|
+
- [PhoneInput](./dist/lib/phone-input/README.md)
|
|
506
|
+
- [Popover](./dist/lib/popover/README.md)
|
|
507
|
+
- [PriceLabel](./dist/lib/price-label/README.md)
|
|
508
|
+
- [Primitive](./dist/lib/primitive/README.md)
|
|
509
|
+
- [Progress](./dist/lib/progress/README.md)
|
|
510
|
+
- [RadioButton](./dist/lib/radio-button/README.md)
|
|
511
|
+
- [RippleEffect](./dist/lib/ripple-effect/README.md)
|
|
512
|
+
- [Select](./dist/lib/select/README.md)
|
|
513
|
+
- [StarRating](./dist/lib/star-rating/README.md)
|
|
514
|
+
- [Stepper](./dist/lib/stepper/README.md)
|
|
515
|
+
- [SuspenseQuery](./dist/lib/suspense-query/README.md)
|
|
516
|
+
- [Swiper](./dist/lib/swiper/README.md)
|
|
517
|
+
- [Switch](./dist/lib/switch/README.md)
|
|
518
|
+
- [Table](./dist/lib/table/README.md)
|
|
519
|
+
- [Tabs](./dist/lib/tabs/README.md)
|
|
520
|
+
- [Text](./dist/lib/text/README.md)
|
|
521
|
+
- [Textarea](./dist/lib/textarea/README.md)
|
|
522
|
+
- [TimePicker](./dist/lib/time-picker/README.md)
|
|
523
|
+
- [Tooltip](./dist/lib/tooltip/README.md)
|
|
524
|
+
- [UnorderedList](./dist/lib/unordered-list/README.md)
|
|
525
|
+
- [Video](./dist/lib/video/README.md)
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
494
529
|
## API Reference
|
|
495
530
|
|
|
496
531
|
### Documentation
|
|
@@ -3,5 +3,3 @@ export declare const scrollbarNoneStyle: StyledCSS;
|
|
|
3
3
|
export declare const animatePulseStyle: StyledCSS;
|
|
4
4
|
export declare const animateSpinStyle: StyledCSS;
|
|
5
5
|
export declare const truncateStyle: StyledCSS;
|
|
6
|
-
export declare const pointerEventsNone: StyledCSS;
|
|
7
|
-
export declare const containerStyle: StyledCSS;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { keyframes } from "@emotion/react";
|
|
2
|
-
import { breakpoint, mediaQuery } from "../theme/screens.js";
|
|
3
2
|
const scrollbarNoneStyle = {
|
|
4
3
|
scrollbarWidth: "none",
|
|
5
4
|
"&::-webkit-scrollbar": { display: "none" }
|
|
@@ -21,32 +20,9 @@ const truncateStyle = {
|
|
|
21
20
|
textOverflow: "ellipsis",
|
|
22
21
|
whiteSpace: "nowrap"
|
|
23
22
|
};
|
|
24
|
-
const containerStyle = {
|
|
25
|
-
width: "100%",
|
|
26
|
-
marginLeft: "auto",
|
|
27
|
-
marginRight: "auto",
|
|
28
|
-
paddingLeft: `${breakpoint.xs.padding}px`,
|
|
29
|
-
paddingRight: `${breakpoint.xs.padding}px`,
|
|
30
|
-
[mediaQuery("sm")]: {
|
|
31
|
-
maxWidth: `${breakpoint.sm.minWidth}px`,
|
|
32
|
-
paddingLeft: `${breakpoint.sm.padding}px`,
|
|
33
|
-
paddingRight: `${breakpoint.sm.padding}px`
|
|
34
|
-
},
|
|
35
|
-
[mediaQuery("md")]: {
|
|
36
|
-
maxWidth: `${breakpoint.md.minWidth}px`,
|
|
37
|
-
paddingLeft: `${breakpoint.md.padding}px`,
|
|
38
|
-
paddingRight: `${breakpoint.md.padding}px`
|
|
39
|
-
},
|
|
40
|
-
[mediaQuery("lg")]: {
|
|
41
|
-
maxWidth: `${breakpoint.lg.minWidth}px`,
|
|
42
|
-
paddingLeft: `${breakpoint.lg.padding}px`,
|
|
43
|
-
paddingRight: `${breakpoint.lg.padding}px`
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
23
|
export {
|
|
47
24
|
animatePulseStyle,
|
|
48
25
|
animateSpinStyle,
|
|
49
|
-
containerStyle,
|
|
50
26
|
scrollbarNoneStyle,
|
|
51
27
|
truncateStyle
|
|
52
28
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AccordionSummaryProps } from './types';
|
|
2
|
-
export declare const AccordionSummary: ({ children, ref, ..._props }: AccordionSummaryProps) => import("
|
|
2
|
+
export declare const AccordionSummary: ({ children, ref, ..._props }: AccordionSummaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs, jsx } from "
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getAccordionSummaryProps } from "./helpers.js";
|
|
3
3
|
import { useAccordionContext } from "../accordion/helpers.js";
|
|
4
4
|
import { Booleanish } from "../../../constants/index.js";
|
|
5
|
-
import { createSxInterpolation } from "../../../utils/stylesheet.js";
|
|
6
5
|
import { useAccordionGroupContext } from "../accordion-group/helpers.js";
|
|
6
|
+
import { Primitive } from "../../primitive/primitive.js";
|
|
7
7
|
import { Icon } from "../../icon/icon.js";
|
|
8
8
|
const AccordionSummary = ({ children, ref, ..._props }) => {
|
|
9
9
|
const { accordionSummaryProps: accordionSummaryPropsByGroup = {} } = useAccordionGroupContext();
|
|
@@ -22,18 +22,26 @@ const AccordionSummary = ({ children, ref, ..._props }) => {
|
|
|
22
22
|
toggle();
|
|
23
23
|
(_b = rest.onClick) == null ? void 0 : _b.call(rest, e);
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
return /* @__PURE__ */ jsxs(
|
|
26
|
+
Primitive,
|
|
26
27
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
as: "div",
|
|
29
|
+
sx: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
cursor: "pointer",
|
|
32
|
+
...sx
|
|
33
|
+
},
|
|
34
|
+
"aria-hidden": true,
|
|
35
|
+
...rest,
|
|
36
|
+
onClick,
|
|
37
|
+
ref,
|
|
38
|
+
children: [
|
|
39
|
+
!!expandIcon && expandIcon.position === "left" && /* @__PURE__ */ jsx(ExpandIcon, { ...expandIcon }),
|
|
40
|
+
/* @__PURE__ */ jsx(Primitive, { sx: { flex: "1 1 0%" }, children }),
|
|
41
|
+
!!expandIcon && expandIcon.position === "right" && /* @__PURE__ */ jsx(ExpandIcon, { ...expandIcon })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
37
45
|
};
|
|
38
46
|
const ExpandIcon = ({ source, position, size, sm, md, lg, sx }) => {
|
|
39
47
|
const { open } = useAccordionContext();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import { IconResponsiveProps } from '../../icon';
|
|
3
3
|
import { PropsWithSx, ShallowMerge, ToResponsiveProps } from '../../../types';
|
|
4
|
+
import { PrimitiveProps } from '../../primitive';
|
|
4
5
|
export declare enum AccordionSummaryVariant {
|
|
5
6
|
EndArrow = "end-arrow",
|
|
6
7
|
EndPlusMinus = "end-plus-minus"
|
|
@@ -20,8 +21,8 @@ export type AccordionSummaryExpandIconProps = ToResponsiveProps<IconResponsivePr
|
|
|
20
21
|
source: Record<AccordionState, string>;
|
|
21
22
|
position: 'left' | 'right';
|
|
22
23
|
} & PropsWithSx;
|
|
23
|
-
type AccordionSummaryExtendedProps =
|
|
24
|
+
type AccordionSummaryExtendedProps = {
|
|
24
25
|
expandIcon?: AccordionSummaryExpandIconProps;
|
|
25
|
-
}
|
|
26
|
-
export type AccordionSummaryProps = ShallowMerge<JSX.IntrinsicElements['div'], AccordionSummaryExtendedProps
|
|
26
|
+
};
|
|
27
|
+
export type AccordionSummaryProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], AccordionSummaryExtendedProps>>;
|
|
27
28
|
export {};
|
package/dist/lib/box/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Box
|
|
2
2
|
|
|
3
|
-
A general-purpose layout primitive that renders a `div` by default. It supports responsive `sx` styling
|
|
3
|
+
A general-purpose layout primitive that renders a `div` by default. It supports responsive `sx` styling via the Emotion-powered `sx` prop.
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
|
|
@@ -12,7 +12,6 @@ import { Box } from '@janbox/storefront-ui';
|
|
|
12
12
|
|
|
13
13
|
| Prop | Type | Default | Description |
|
|
14
14
|
|------|------|---------|-------------|
|
|
15
|
-
| `container` | `boolean` | false | When true, applies responsive container styles: full width, auto horizontal margins, and breakpoint-aware max-width and padding (xs → sm → md → lg). |
|
|
16
15
|
| `sx` | `ToResponsiveProps<StyledCSS>` | - | Responsive Emotion CSS overrides. Accepts a base StyledCSS object plus optional `sm`, `md`, and `lg` breakpoint keys for responsive styles. |
|
|
17
16
|
| `as` | `HTMLElementType` | "div" | Override the rendered HTML element (polymorphic). Defaults to `div`. |
|
|
18
17
|
| `children` | `React.ReactNode` | - | Content rendered inside the Box. |
|
|
@@ -30,15 +29,6 @@ import { Box } from '@janbox/storefront-ui';
|
|
|
30
29
|
</Box>
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
### Container Box
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
<Box container>
|
|
37
|
-
<h1>Page title</h1>
|
|
38
|
-
<p>Centered, max-width constrained content with responsive padding.</p>
|
|
39
|
-
</Box>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
32
|
### Responsive sx styling
|
|
43
33
|
|
|
44
34
|
```tsx
|
package/dist/lib/box/box.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getBoxProps } from "./helpers.js";
|
|
3
|
-
import { containerStyle } from "../../constants/emotion.js";
|
|
4
3
|
import { Primitive } from "../primitive/primitive.js";
|
|
5
4
|
const Box = ({ children, ref, ..._props }) => {
|
|
6
|
-
const { sx = {},
|
|
5
|
+
const { sx = {}, ...rest } = getBoxProps(_props);
|
|
7
6
|
return /* @__PURE__ */ jsx(
|
|
8
7
|
Primitive,
|
|
9
8
|
{
|
|
10
9
|
...rest,
|
|
11
10
|
sx: {
|
|
12
|
-
...container ? containerStyle : {},
|
|
13
11
|
...sx,
|
|
14
12
|
sm: { ...sx.sm },
|
|
15
13
|
md: { ...sx.md },
|
package/dist/lib/box/types.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
2
|
import { PrimitiveProps } from '../primitive';
|
|
3
|
-
type
|
|
4
|
-
container?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type BoxProps = PrimitiveProps<JSX.IntrinsicElements['div']> & BoxExtendedProps;
|
|
7
|
-
export {};
|
|
3
|
+
export type BoxProps = PrimitiveProps<JSX.IntrinsicElements['div']>;
|
|
@@ -10,7 +10,7 @@ import { truncateStyle } from "../../constants/emotion.js";
|
|
|
10
10
|
import { getSizeVariantState } from "../../utils/index.js";
|
|
11
11
|
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
12
12
|
import { SvgLoader } from "../../components/svg-loader.js";
|
|
13
|
-
import {
|
|
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 { InputMask as ForwardRefInputMask } from "../input-mask/input-mask.js";
|
|
@@ -73,19 +73,16 @@ const Cascader = ({ ref, ..._props }) => {
|
|
|
73
73
|
if (isNil(textVariant)) return {};
|
|
74
74
|
return getTypographyVar(textVariant);
|
|
75
75
|
};
|
|
76
|
-
const { sx: containerSx, ...restContainerProps } = containerProps ?? {};
|
|
77
76
|
return /* @__PURE__ */ jsxs(
|
|
78
|
-
|
|
77
|
+
Primitive,
|
|
79
78
|
{
|
|
80
|
-
...
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
createSxInterpolation(containerSx)
|
|
88
|
-
],
|
|
79
|
+
...containerProps,
|
|
80
|
+
sx: {
|
|
81
|
+
display: "flex",
|
|
82
|
+
flexDirection: "column",
|
|
83
|
+
...fullWidth ? { width: "100%" } : {},
|
|
84
|
+
...containerProps == null ? void 0 : containerProps.sx
|
|
85
|
+
},
|
|
89
86
|
children: [
|
|
90
87
|
/* @__PURE__ */ jsxs(
|
|
91
88
|
Floating,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { HTMLAttributes, JSX, ReactNode } from 'react';
|
|
2
2
|
import { Placement, UseFloatingOptions } from '@floating-ui/react';
|
|
3
|
-
import {
|
|
3
|
+
import { ShallowMerge, ToResponsiveProps } from '../../types';
|
|
4
4
|
import { InputProps } from '../input';
|
|
5
5
|
import { InputMaskProps, InputMaskResponsiveProps } from '../input-mask';
|
|
6
|
+
import { PrimitiveProps } from '../primitive';
|
|
6
7
|
export type CascaderResponsiveProps = InputMaskResponsiveProps;
|
|
7
8
|
export type CascaderOptionValue = string | number;
|
|
8
9
|
export interface CascaderOption {
|
|
@@ -47,7 +48,7 @@ interface CascaderExtendedProps extends ToResponsiveProps<CascaderResponsiveProp
|
|
|
47
48
|
/** Helper text below the input */
|
|
48
49
|
helperText?: string;
|
|
49
50
|
/** Props for the container div */
|
|
50
|
-
containerProps?:
|
|
51
|
+
containerProps?: PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
|
|
51
52
|
/** Props for the search input */
|
|
52
53
|
inputProps?: InputProps;
|
|
53
54
|
/** Whether component takes full width */
|
package/dist/lib/chip/chip.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChipProps } from './types';
|
|
2
|
-
export declare const Chip: ({ children, ..._props }: ChipProps) => import("
|
|
2
|
+
export declare const Chip: ({ children, ..._props }: ChipProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/lib/chip/chip.js
CHANGED
|
@@ -1,52 +1,56 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getChipProps, getChipSizeState } from "./helpers.js";
|
|
3
3
|
import { getColorShadesByVariant } from "../../utils/index.js";
|
|
4
|
-
import
|
|
4
|
+
import "lodash-es";
|
|
5
5
|
import "../../theme/palette.js";
|
|
6
6
|
import { getTypographyVar } from "../../theme/typography.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Primitive } from "../primitive/primitive.js";
|
|
8
8
|
const Chip = ({ children, ..._props }) => {
|
|
9
9
|
const { sx, size, sm, md, lg, color = "green", ...rest } = getChipProps(_props);
|
|
10
10
|
const { light, main } = getColorShadesByVariant(color);
|
|
11
11
|
return /* @__PURE__ */ jsx(
|
|
12
|
-
|
|
12
|
+
Primitive,
|
|
13
13
|
{
|
|
14
|
+
as: "div",
|
|
14
15
|
...rest,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
sx: {
|
|
17
|
+
width: "fit-content",
|
|
18
|
+
maxWidth: "100%",
|
|
19
|
+
display: "flex",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
backgroundColor: light,
|
|
22
|
+
borderWidth: 1,
|
|
23
|
+
borderColor: main,
|
|
24
|
+
color: main,
|
|
25
|
+
...createStyle({ size }),
|
|
26
|
+
...sx,
|
|
27
|
+
sm: {
|
|
28
|
+
...createStyle(sm),
|
|
29
|
+
...sx == null ? void 0 : sx.sm
|
|
25
30
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[mediaQuery("md")]: createStyle(md),
|
|
30
|
-
[mediaQuery("lg")]: createStyle(lg)
|
|
31
|
+
md: {
|
|
32
|
+
...createStyle(md),
|
|
33
|
+
...sx == null ? void 0 : sx.md
|
|
31
34
|
},
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
lg: {
|
|
36
|
+
...createStyle(lg),
|
|
37
|
+
...sx == null ? void 0 : sx.lg
|
|
38
|
+
}
|
|
39
|
+
},
|
|
34
40
|
children
|
|
35
41
|
}
|
|
36
42
|
);
|
|
37
43
|
};
|
|
38
44
|
const createStyle = ({ size } = {}) => {
|
|
39
45
|
const { inputSize, inputPaddingX, textVariant, rounded } = getChipSizeState(size);
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
];
|
|
46
|
+
return {
|
|
47
|
+
paddingLeft: inputPaddingX,
|
|
48
|
+
paddingRight: inputPaddingX,
|
|
49
|
+
minHeight: inputSize,
|
|
50
|
+
fontSize: textVariant ? getTypographyVar(textVariant).fontSize : void 0,
|
|
51
|
+
lineHeight: textVariant ? getTypographyVar(textVariant).lineHeight : void 0,
|
|
52
|
+
borderRadius: rounded
|
|
53
|
+
};
|
|
50
54
|
};
|
|
51
55
|
export {
|
|
52
56
|
Chip
|
package/dist/lib/chip/types.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import { ColorVariant,
|
|
2
|
+
import { ColorVariant, ShallowMerge, SizeVariant, ToResponsiveProps } from '../../types';
|
|
3
|
+
import { PrimitiveProps } from '../primitive';
|
|
3
4
|
export interface ChipResponsiveProps {
|
|
4
5
|
size?: SizeVariant;
|
|
5
6
|
}
|
|
6
|
-
type ChipExtendedProps =
|
|
7
|
+
type ChipExtendedProps = ToResponsiveProps<ChipResponsiveProps> & {
|
|
7
8
|
color?: ColorVariant;
|
|
8
|
-
}
|
|
9
|
-
export type ChipProps = ShallowMerge<JSX.IntrinsicElements['div'], ChipExtendedProps
|
|
9
|
+
};
|
|
10
|
+
export type ChipProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], ChipExtendedProps>>;
|
|
10
11
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Container
|
|
2
2
|
|
|
3
|
-
Wrapper layout responsive giúp giới hạn chiều rộng nội dung theo breakpoint và tự động xử lý padding ngang. Component căn giữa nội dung trong viewport
|
|
3
|
+
Wrapper layout responsive giúp giới hạn chiều rộng nội dung theo breakpoint và tự động xử lý padding ngang. Component căn giữa nội dung trong viewport theo cấu hình layout nội bộ của design system.
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
|
|
@@ -12,13 +12,9 @@ import { Container } from '@janbox/storefront-ui';
|
|
|
12
12
|
|
|
13
13
|
| Prop | Type | Default | Description |
|
|
14
14
|
|------|------|---------|-------------|
|
|
15
|
-
| `
|
|
16
|
-
| `sm` | `{ position?: ContainerPosition }` | - | Responsive override tại breakpoint `sm` (min-width: 768px). Nhận giá trị `position` để thay đổi căn chỉnh ở màn hình tablet. |
|
|
17
|
-
| `md` | `{ position?: ContainerPosition }` | - | Responsive override tại breakpoint `md` (min-width: 1280px). Nhận giá trị `position` để thay đổi căn chỉnh ở màn hình desktop. |
|
|
18
|
-
| `lg` | `{ position?: ContainerPosition }` | - | Responsive override tại breakpoint `lg` (min-width: 1680px). Nhận giá trị `position` để thay đổi căn chỉnh ở màn hình large desktop. |
|
|
19
|
-
| `sx` | `ToResponsiveProps<StyledCSS>` | - | Escape hatch để truyền custom Emotion CSS vào wrapper div ngoài cùng. Hỗ trợ responsive keys (`sm`, `md`, `lg`). |
|
|
15
|
+
| `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ộ. |
|
|
20
16
|
| `children` | `React.ReactNode` | - | Nội dung render bên trong container. |
|
|
21
|
-
| `...rest` | `JSX.IntrinsicElements['div']` | - | Tất cả HTML div attributes tiêu chuẩn (`className`, `style`, `onClick`, v.v.)
|
|
17
|
+
| `...rest` | `JSX.IntrinsicElements['div']` | - | Tất cả HTML div attributes tiêu chuẩn (`className`, `style`, `onClick`, v.v.). |
|
|
22
18
|
|
|
23
19
|
## Examples
|
|
24
20
|
|
|
@@ -30,22 +26,15 @@ import { Container } from '@janbox/storefront-ui';
|
|
|
30
26
|
</Container>
|
|
31
27
|
```
|
|
32
28
|
|
|
33
|
-
###
|
|
29
|
+
### Custom style qua sx prop
|
|
34
30
|
|
|
35
31
|
```tsx
|
|
36
|
-
<Container
|
|
37
|
-
|
|
38
|
-
<HeroImage />
|
|
32
|
+
<Container sx={{ backgroundColor: '#f0f0f0', minHeight: 100 }}>
|
|
33
|
+
Page content with custom visual styles
|
|
39
34
|
</Container>
|
|
40
35
|
```
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
<Container position="center" md={{ position: 'start' }}>
|
|
46
|
-
<SidebarPanel />
|
|
47
|
-
</Container>
|
|
48
|
-
```
|
|
37
|
+
> 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.
|
|
49
38
|
|
|
50
39
|
## Dependencies
|
|
51
40
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ContainerProps } from './types';
|
|
2
|
-
export declare const Container: ({ children, ref, ..._props }: ContainerProps) => import("
|
|
2
|
+
export declare const Container: ({ children, ref, ..._props }: ContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,93 +1,9 @@
|
|
|
1
|
-
import { jsx } from "
|
|
2
|
-
import { isNil } from "lodash-es";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { getContainerProps } from "./helpers.js";
|
|
4
|
-
import {
|
|
5
|
-
import "../../theme/palette.js";
|
|
6
|
-
import { createSxInterpolation } from "../../utils/stylesheet.js";
|
|
7
|
-
const CONTAINER_PADDING_VAR_NAME = "--container-padding";
|
|
8
|
-
const CONTAINER_PADDING_VAR = `var(${CONTAINER_PADDING_VAR_NAME})`;
|
|
9
|
-
const getContainerPaddingCSS = (position) => {
|
|
10
|
-
return isNil(position) ? {} : {
|
|
11
|
-
paddingLeft: position === "start" ? 0 : CONTAINER_PADDING_VAR,
|
|
12
|
-
paddingRight: position === "end" ? 0 : CONTAINER_PADDING_VAR
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const CONTAINER_CONTENT_PADDING_VAR_NAME = "--container-content-padding";
|
|
16
|
-
const CONTAINER_CONTENT_PADDING_VAR = `var(${CONTAINER_CONTENT_PADDING_VAR_NAME}, 0)`;
|
|
17
|
-
const getContainerContentPaddingCSS = (position) => {
|
|
18
|
-
return isNil(position) ? {} : {
|
|
19
|
-
paddingLeft: position === "start" ? 0 : CONTAINER_CONTENT_PADDING_VAR,
|
|
20
|
-
paddingRight: position === "end" ? 0 : CONTAINER_CONTENT_PADDING_VAR
|
|
21
|
-
};
|
|
22
|
-
};
|
|
3
|
+
import { Primitive } from "../primitive/primitive.js";
|
|
23
4
|
const Container = ({ children, ref, ..._props }) => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
width: "100%"
|
|
28
|
-
},
|
|
29
|
-
createSxInterpolation(sx)
|
|
30
|
-
];
|
|
31
|
-
return /* @__PURE__ */ jsx("div", { css, ...rest, ref, children: /* @__PURE__ */ jsx(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
css: [
|
|
35
|
-
{
|
|
36
|
-
width: "100%",
|
|
37
|
-
[CONTAINER_PADDING_VAR_NAME]: "0px",
|
|
38
|
-
...getContainerPaddingCSS(position)
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
[mediaQuery("sm")]: {
|
|
42
|
-
width: "100%",
|
|
43
|
-
[CONTAINER_PADDING_VAR_NAME]: `calc((100% - ${breakpoint.sm.minWidth}px) / 2)`,
|
|
44
|
-
...getContainerPaddingCSS(sm == null ? void 0 : sm.position)
|
|
45
|
-
},
|
|
46
|
-
[mediaQuery("md")]: {
|
|
47
|
-
[CONTAINER_PADDING_VAR_NAME]: `calc((100% - ${breakpoint.md.minWidth}px) / 2)`,
|
|
48
|
-
...getContainerPaddingCSS(md == null ? void 0 : md.position)
|
|
49
|
-
},
|
|
50
|
-
[mediaQuery("lg")]: {
|
|
51
|
-
[CONTAINER_PADDING_VAR_NAME]: `calc((100% - ${breakpoint.lg.minWidth}px) / 2)`,
|
|
52
|
-
...getContainerPaddingCSS(lg == null ? void 0 : lg.position)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
children: /* @__PURE__ */ jsx(
|
|
57
|
-
"div",
|
|
58
|
-
{
|
|
59
|
-
css: [
|
|
60
|
-
{
|
|
61
|
-
width: "100%",
|
|
62
|
-
[CONTAINER_CONTENT_PADDING_VAR_NAME]: `${breakpoint.xs.padding}px`,
|
|
63
|
-
...getContainerContentPaddingCSS(position)
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
[mediaQuery("sm")]: [
|
|
67
|
-
{
|
|
68
|
-
[CONTAINER_CONTENT_PADDING_VAR_NAME]: `${breakpoint.sm.padding}px`,
|
|
69
|
-
...getContainerContentPaddingCSS(sm == null ? void 0 : sm.position)
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
[mediaQuery("md")]: [
|
|
73
|
-
{
|
|
74
|
-
[CONTAINER_CONTENT_PADDING_VAR_NAME]: `${breakpoint.md.padding}px`,
|
|
75
|
-
...getContainerContentPaddingCSS(md == null ? void 0 : md.position)
|
|
76
|
-
}
|
|
77
|
-
],
|
|
78
|
-
[mediaQuery("lg")]: [
|
|
79
|
-
{
|
|
80
|
-
[CONTAINER_CONTENT_PADDING_VAR_NAME]: `${breakpoint.lg.padding}px`,
|
|
81
|
-
...getContainerContentPaddingCSS(lg == null ? void 0 : lg.position)
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
children
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
) });
|
|
5
|
+
const props = getContainerProps(_props);
|
|
6
|
+
return /* @__PURE__ */ jsx(Primitive, { ...props, ref, children });
|
|
91
7
|
};
|
|
92
8
|
export {
|
|
93
9
|
Container
|
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
import { breakpoint } from "../../theme/screens.js";
|
|
2
|
+
import "../../theme/palette.js";
|
|
1
3
|
import { mergeComponentProps } from "../../utils/index.js";
|
|
2
4
|
const defaultProps = {
|
|
3
|
-
|
|
5
|
+
sx: {
|
|
6
|
+
width: "100%",
|
|
7
|
+
marginLeft: "auto",
|
|
8
|
+
marginRight: "auto",
|
|
9
|
+
paddingLeft: breakpoint.xs.padding,
|
|
10
|
+
paddingRight: breakpoint.xs.padding,
|
|
11
|
+
sm: {
|
|
12
|
+
maxWidth: breakpoint.sm.minWidth,
|
|
13
|
+
paddingLeft: breakpoint.sm.padding,
|
|
14
|
+
paddingRight: breakpoint.sm.padding
|
|
15
|
+
},
|
|
16
|
+
md: {
|
|
17
|
+
maxWidth: breakpoint.md.minWidth,
|
|
18
|
+
paddingLeft: breakpoint.md.padding,
|
|
19
|
+
paddingRight: breakpoint.md.padding
|
|
20
|
+
},
|
|
21
|
+
lg: {
|
|
22
|
+
maxWidth: breakpoint.lg.minWidth,
|
|
23
|
+
paddingLeft: breakpoint.lg.padding,
|
|
24
|
+
paddingRight: breakpoint.lg.padding
|
|
25
|
+
}
|
|
26
|
+
}
|
|
4
27
|
};
|
|
5
28
|
const getContainerProps = (extended) => {
|
|
6
29
|
return mergeComponentProps(defaultProps, extended);
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export type
|
|
4
|
-
export type ContainerResponsiveProps = {
|
|
5
|
-
position?: ContainerPosition;
|
|
6
|
-
};
|
|
7
|
-
type ContainerExtendedProps = PropsWithSx<ToResponsiveProps<ContainerResponsiveProps>>;
|
|
8
|
-
export type ContainerProps = ShallowMerge<JSX.IntrinsicElements['div'], ContainerExtendedProps>;
|
|
9
|
-
export {};
|
|
2
|
+
import { PrimitiveProps } from '../primitive';
|
|
3
|
+
export type ContainerProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Flexbox
|
|
2
2
|
|
|
3
|
-
A layout component that renders a `div` with `display: flex` applied by default. It supports responsive `sx` prop overrides
|
|
3
|
+
A layout component that renders a `div` with `display: flex` applied by default. It supports responsive `sx` prop overrides.
|
|
4
4
|
|
|
5
5
|
## Import
|
|
6
6
|
|
|
@@ -12,7 +12,6 @@ import { Flexbox } from '@janbox/storefront-ui';
|
|
|
12
12
|
|
|
13
13
|
| Prop | Type | Default | Description |
|
|
14
14
|
|------|------|---------|-------------|
|
|
15
|
-
| `container` | `boolean` | undefined (false) | When true, applies the global `containerStyle` (responsive padding and max-width) on top of the flex display — useful for page-level section wrappers. |
|
|
16
15
|
| `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'`). |
|
|
17
16
|
| `children` | `React.ReactNode` | - | Child elements rendered inside the flex container — typically `FlexItem` components. |
|
|
18
17
|
| `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying `div` element. |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FlexboxProps } from './types';
|
|
2
|
-
export declare const Flexbox: ({ children,
|
|
2
|
+
export declare const Flexbox: ({ children, ref, ..._props }: FlexboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getFlexboxProps } from "./helpers.js";
|
|
3
|
-
import { containerStyle } from "../../../constants/emotion.js";
|
|
4
3
|
import { Primitive } from "../../primitive/primitive.js";
|
|
5
|
-
const Flexbox = ({ children,
|
|
4
|
+
const Flexbox = ({ children, ref, ..._props }) => {
|
|
6
5
|
const { sx = {}, ...rest } = getFlexboxProps(_props);
|
|
7
6
|
return /* @__PURE__ */ jsx(
|
|
8
7
|
Primitive,
|
|
@@ -10,7 +9,6 @@ const Flexbox = ({ children, container, ref, ..._props }) => {
|
|
|
10
9
|
...rest,
|
|
11
10
|
sx: {
|
|
12
11
|
display: "flex",
|
|
13
|
-
...container ? containerStyle : {},
|
|
14
12
|
...sx,
|
|
15
13
|
sm: { ...sx.sm },
|
|
16
14
|
md: { ...sx.md },
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
container?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export type FlexboxProps = ShallowMerge<JSX.IntrinsicElements['div'], PropsWithSx<FlexboxExtendedProps>>;
|
|
7
|
-
export {};
|
|
2
|
+
import { PrimitiveProps } from '../../primitive';
|
|
3
|
+
export type FlexboxProps = PrimitiveProps<JSX.IntrinsicElements['div'], 'div'>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Cell
|
|
2
|
+
|
|
3
|
+
A CSS Grid child component that supports configurable column spans. It is intended to be used inside Grid.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Cell } from '@janbox/storefront-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
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 }`. |
|
|
19
|
+
| `sx` | `ToResponsiveProps<StyledCSS>` | - | Escape-hatch for inline Emotion styles. Supports responsive keys (sm, md, lg) alongside base styles. |
|
|
20
|
+
| `children` | `React.ReactNode` | - | Cell content. |
|
|
21
|
+
| `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying div element. |
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
### Span two columns
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<Grid cols={3}>
|
|
29
|
+
<Cell colSpan={2}>Span 2 columns</Cell>
|
|
30
|
+
<Cell>Cell 2</Cell>
|
|
31
|
+
<Cell>Cell 3</Cell>
|
|
32
|
+
</Grid>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Responsive spans
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Grid cols={4}>
|
|
39
|
+
<Cell colSpan={4} sm={{ colSpan: 2 }} md={{ colSpan: 1 }}>
|
|
40
|
+
Responsive item
|
|
41
|
+
</Cell>
|
|
42
|
+
</Grid>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Custom styles
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<Cell colSpan={2} sx={{ padding: 12, backgroundColor: 'var(--color-neutral-100)' }}>
|
|
49
|
+
Styled cell
|
|
50
|
+
</Cell>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Related Components
|
|
54
|
+
|
|
55
|
+
- [Grid](../grid/README.md)
|
|
56
|
+
- [Primitive](../../primitive/README.md)
|
|
57
|
+
|
|
58
|
+
## Dependencies
|
|
59
|
+
|
|
60
|
+
- lodash-es
|
|
61
|
+
|
|
62
|
+
## See Also
|
|
63
|
+
|
|
64
|
+
- [Component Source](./cell.tsx)
|
|
65
|
+
- [Storybook Stories](./cell.stories.tsx)
|
|
66
|
+
- [Main README](../../../README.md)
|
|
@@ -16,7 +16,6 @@ import { Grid } from '@janbox/storefront-ui';
|
|
|
16
16
|
| `sm` | `GridResponsiveProps` | - | Responsive overrides applied at the sm breakpoint (≥768px). Accepts `{ cols?: number }`. |
|
|
17
17
|
| `md` | `GridResponsiveProps` | - | Responsive overrides applied at the md breakpoint (≥1280px). Accepts `{ cols?: number }`. |
|
|
18
18
|
| `lg` | `GridResponsiveProps` | - | Responsive overrides applied at the lg breakpoint (≥1680px). Accepts `{ cols?: number }`. |
|
|
19
|
-
| `container` | `boolean` | false | When true, applies the shared responsive container styles (padding and max-width) from `containerStyle`. |
|
|
20
19
|
| `sx` | `ToResponsiveProps<StyledCSS>` | - | Escape-hatch for inline Emotion styles. Supports responsive keys (sm, md, lg) alongside base styles. |
|
|
21
20
|
| `children` | `React.ReactNode` | - | Grid children, typically Cell components. |
|
|
22
21
|
| `ref` | `React.Ref<HTMLDivElement>` | - | Forwarded ref to the underlying div element. |
|
|
@@ -48,7 +47,7 @@ import { Grid } from '@janbox/storefront-ui';
|
|
|
48
47
|
### Responsive columns (1 on mobile, 2 on tablet, 4 on desktop)
|
|
49
48
|
|
|
50
49
|
```tsx
|
|
51
|
-
<Grid cols={1} sm={{ cols: 2 }} md={{ cols: 4 }}
|
|
50
|
+
<Grid cols={1} sm={{ cols: 2 }} md={{ cols: 4 }}>
|
|
52
51
|
<Cell>Item 1</Cell>
|
|
53
52
|
<Cell>Item 2</Cell>
|
|
54
53
|
<Cell>Item 3</Cell>
|
|
@@ -58,8 +57,8 @@ import { Grid } from '@janbox/storefront-ui';
|
|
|
58
57
|
|
|
59
58
|
## Related Components
|
|
60
59
|
|
|
61
|
-
- [Cell](
|
|
62
|
-
- [Primitive](
|
|
60
|
+
- [Cell](../cell/README.md)
|
|
61
|
+
- [Primitive](../../primitive/README.md)
|
|
63
62
|
|
|
64
63
|
## Dependencies
|
|
65
64
|
|
|
@@ -67,6 +66,6 @@ import { Grid } from '@janbox/storefront-ui';
|
|
|
67
66
|
|
|
68
67
|
## See Also
|
|
69
68
|
|
|
70
|
-
- [Component Source](./
|
|
69
|
+
- [Component Source](./grid.tsx)
|
|
71
70
|
- [Storybook Stories](./grid.stories.tsx)
|
|
72
|
-
- [Main README](
|
|
71
|
+
- [Main README](../../../README.md)
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { isNil } from "lodash-es";
|
|
3
3
|
import { getGridProps } from "./helpers.js";
|
|
4
|
-
import { containerStyle } from "../../../constants/emotion.js";
|
|
5
4
|
import { Primitive } from "../../primitive/primitive.js";
|
|
6
5
|
const GRID_MINIMUM_COLS = 1;
|
|
7
6
|
const GRID_MAXIMUM_COLS = 24;
|
|
8
7
|
const Grid = ({ children, ref, ..._props }) => {
|
|
9
|
-
const { cols, sm, md, lg,
|
|
8
|
+
const { cols, sm, md, lg, sx = {}, ...rest } = getGridProps(_props);
|
|
10
9
|
return /* @__PURE__ */ jsx(
|
|
11
10
|
Primitive,
|
|
12
11
|
{
|
|
13
12
|
sx: {
|
|
14
13
|
display: "grid",
|
|
15
|
-
...container ? containerStyle : {},
|
|
16
14
|
...createStyle({ cols }),
|
|
17
15
|
...sx,
|
|
18
16
|
sm: { ...createStyle(sm), ...sx.sm },
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ShallowMerge, ToResponsiveProps } from '../../../types';
|
|
3
|
+
import { PrimitiveProps } from '../../primitive';
|
|
3
4
|
export interface GridResponsiveProps {
|
|
4
5
|
cols?: number;
|
|
5
6
|
}
|
|
6
|
-
type GridExtendedProps =
|
|
7
|
-
|
|
8
|
-
}>;
|
|
9
|
-
export type GridProps = ShallowMerge<JSX.IntrinsicElements['div'], GridExtendedProps>;
|
|
7
|
+
type GridExtendedProps = ToResponsiveProps<GridResponsiveProps>;
|
|
8
|
+
export type GridProps = PrimitiveProps<ShallowMerge<JSX.IntrinsicElements['div'], GridExtendedProps>>;
|
|
10
9
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TableProps } from './types';
|
|
2
|
-
export declare const Table: ({ children, sx, ...props }: TableProps) => import("
|
|
2
|
+
export declare const Table: ({ children, sx, ...props }: TableProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "lodash-es";
|
|
3
3
|
import { getColorVar } from "../../../theme/palette.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Primitive } from "../../primitive/primitive.js";
|
|
5
5
|
const Table = ({ children, sx, ...props }) => {
|
|
6
6
|
return /* @__PURE__ */ jsx(
|
|
7
|
-
|
|
7
|
+
Primitive,
|
|
8
8
|
{
|
|
9
|
-
|
|
9
|
+
...props,
|
|
10
|
+
sx: {
|
|
10
11
|
width: "100%",
|
|
11
12
|
borderTopLeftRadius: "0.5rem",
|
|
12
13
|
borderTopRightRadius: "0.5rem",
|
|
13
14
|
overflow: "hidden",
|
|
14
15
|
backgroundColor: getColorVar("surface.default"),
|
|
15
16
|
...sx
|
|
16
|
-
}
|
|
17
|
-
|
|
17
|
+
},
|
|
18
|
+
as: "table",
|
|
18
19
|
children
|
|
19
20
|
}
|
|
20
21
|
);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export type TableProps =
|
|
2
|
+
import { PrimitiveProps } from '../../primitive';
|
|
3
|
+
export type TableProps = PrimitiveProps<JSX.IntrinsicElements['table'], 'table'>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { TableFooterProps } from './types';
|
|
2
|
-
export declare const TableFooter: ({
|
|
2
|
+
export declare const TableFooter: ({ children, ...props }: TableFooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx } from "
|
|
2
|
-
import {
|
|
3
|
-
const TableFooter = ({
|
|
4
|
-
return /* @__PURE__ */ jsx(
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Primitive } from "../../primitive/primitive.js";
|
|
3
|
+
const TableFooter = ({ children, ...props }) => {
|
|
4
|
+
return /* @__PURE__ */ jsx(Primitive, { ...props, as: "tfoot", children });
|
|
5
5
|
};
|
|
6
6
|
export {
|
|
7
7
|
TableFooter
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { JSX } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export type TableFooterProps =
|
|
2
|
+
import { PrimitiveProps } from '../../primitive';
|
|
3
|
+
export type TableFooterProps = PrimitiveProps<JSX.IntrinsicElements['tfoot'], 'tfoot'>;
|