@janbox/storefront-ui 2.0.32 → 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 +125 -99
- 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/avatar/avatar.js +2 -2
- 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/button/button.js +2 -2
- 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/date-picker/date-picker.js +1 -1
- 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/icon-button/icon-button.js +2 -2
- package/dist/lib/stepper/step.js +6 -6
- package/dist/lib/swiper/swiper-dots-paging/swiper-dots-paging.js +1 -1
- package/dist/lib/swiper/swiper-side-arrows-paging/swiper-side-arrows-paging.js +1 -1
- 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/dist/theme/palette.d.ts +7 -6
- package/dist/theme/palette.js +41 -24
- package/dist/utils/index.d.ts +2 -4
- package/dist/utils/index.js +14 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,11 +59,7 @@ pnpm add react-router
|
|
|
59
59
|
import { ThemeProvider } from '@janbox/storefront-ui/theme';
|
|
60
60
|
|
|
61
61
|
function App() {
|
|
62
|
-
return
|
|
63
|
-
<ThemeProvider>
|
|
64
|
-
{/* Your app */}
|
|
65
|
-
</ThemeProvider>
|
|
66
|
-
);
|
|
62
|
+
return <ThemeProvider>{/* Your app */}</ThemeProvider>;
|
|
67
63
|
}
|
|
68
64
|
```
|
|
69
65
|
|
|
@@ -75,28 +71,15 @@ import { Button, Input, Box, Text } from '@janbox/storefront-ui';
|
|
|
75
71
|
function LoginForm() {
|
|
76
72
|
return (
|
|
77
73
|
<Box sx={{ md: { maxWidth: 400 } }}>
|
|
78
|
-
<Text size="2xl" sx={{ marginBottom: 16 }}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<Input
|
|
88
|
-
type="password"
|
|
89
|
-
placeholder="Mật khẩu"
|
|
90
|
-
size="md"
|
|
91
|
-
sx={{ marginBottom: 16 }}
|
|
92
|
-
/>
|
|
93
|
-
|
|
94
|
-
<Button
|
|
95
|
-
variant="contained"
|
|
96
|
-
color="primary"
|
|
97
|
-
size="lg"
|
|
98
|
-
fullWidth
|
|
99
|
-
>
|
|
74
|
+
<Text size="2xl" sx={{ marginBottom: 16 }}>
|
|
75
|
+
Đăng nhập
|
|
76
|
+
</Text>
|
|
77
|
+
|
|
78
|
+
<Input type="email" placeholder="Email" size="md" sx={{ marginBottom: 12 }} />
|
|
79
|
+
|
|
80
|
+
<Input type="password" placeholder="Mật khẩu" size="md" sx={{ marginBottom: 16 }} />
|
|
81
|
+
|
|
82
|
+
<Button variant="contained" color="primary" size="lg" fullWidth>
|
|
100
83
|
Đăng nhập
|
|
101
84
|
</Button>
|
|
102
85
|
</Box>
|
|
@@ -122,18 +105,10 @@ import { Flexbox, Box, Button } from '@janbox/storefront-ui';
|
|
|
122
105
|
|
|
123
106
|
function ResponsiveLayout() {
|
|
124
107
|
return (
|
|
125
|
-
<Flexbox
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
>
|
|
130
|
-
<Box sx={{ sm: { flex: 1 } }}>
|
|
131
|
-
Nội dung chính
|
|
132
|
-
</Box>
|
|
133
|
-
|
|
134
|
-
<Box sx={{ sm: { width: 300 } }}>
|
|
135
|
-
Sidebar
|
|
136
|
-
</Box>
|
|
108
|
+
<Flexbox direction="column" md={{ direction: 'row' }} gap={16}>
|
|
109
|
+
<Box sx={{ sm: { flex: 1 } }}>Nội dung chính</Box>
|
|
110
|
+
|
|
111
|
+
<Box sx={{ sm: { width: 300 } }}>Sidebar</Box>
|
|
137
112
|
</Flexbox>
|
|
138
113
|
);
|
|
139
114
|
}
|
|
@@ -163,7 +138,7 @@ src/lib/<component>/
|
|
|
163
138
|
export const Button = ({ ref, ..._props }: ButtonProps) => {
|
|
164
139
|
// 1. Merge với default props qua helper
|
|
165
140
|
const { size, variant, color, children, ...rest } = getButtonProps(_props);
|
|
166
|
-
|
|
141
|
+
|
|
167
142
|
// 2. Build CSS từ helpers
|
|
168
143
|
const css = [
|
|
169
144
|
getButtonCssBySize(size),
|
|
@@ -171,9 +146,13 @@ export const Button = ({ ref, ..._props }: ButtonProps) => {
|
|
|
171
146
|
getButtonCssByColor(color),
|
|
172
147
|
createSxInterpolation(sx),
|
|
173
148
|
];
|
|
174
|
-
|
|
149
|
+
|
|
175
150
|
// 3. Render với Primitive hoặc native element
|
|
176
|
-
return
|
|
151
|
+
return (
|
|
152
|
+
<button css={css} ref={ref} {...rest}>
|
|
153
|
+
{children}
|
|
154
|
+
</button>
|
|
155
|
+
);
|
|
177
156
|
};
|
|
178
157
|
```
|
|
179
158
|
|
|
@@ -195,12 +174,12 @@ import { Box } from '@janbox/storefront-ui';
|
|
|
195
174
|
|
|
196
175
|
**Breakpoints:**
|
|
197
176
|
|
|
198
|
-
| Screen | Min-width
|
|
199
|
-
|
|
200
|
-
| `xs`
|
|
201
|
-
| `sm`
|
|
202
|
-
| `md`
|
|
203
|
-
| `lg`
|
|
177
|
+
| Screen | Min-width |
|
|
178
|
+
| ------ | --------------------------------- |
|
|
179
|
+
| `xs` | 0px (default, không cần khai báo) |
|
|
180
|
+
| `sm` | 768px (tablet) |
|
|
181
|
+
| `md` | 1280px (desktop) |
|
|
182
|
+
| `lg` | 1680px (large desktop) |
|
|
204
183
|
|
|
205
184
|
### 3. Polymorphic Components
|
|
206
185
|
|
|
@@ -246,20 +225,20 @@ const responsiveStyle = {
|
|
|
246
225
|
|
|
247
226
|
```tsx
|
|
248
227
|
import {
|
|
249
|
-
cn,
|
|
250
|
-
mergeComponentProps,
|
|
251
|
-
getColorShadesByVariant,
|
|
252
|
-
getSizeVariantState,
|
|
253
|
-
formatNumber,
|
|
254
|
-
formatPrice,
|
|
255
|
-
formatDateTime,
|
|
228
|
+
cn, // Class names combiner
|
|
229
|
+
mergeComponentProps, // Deep merge props
|
|
230
|
+
getColorShadesByVariant, // Color utilities
|
|
231
|
+
getSizeVariantState, // Size utilities
|
|
232
|
+
formatNumber, // Number formatter
|
|
233
|
+
formatPrice, // Price formatter
|
|
234
|
+
formatDateTime, // DateTime formatter
|
|
256
235
|
} from '@janbox/storefront-ui/utils';
|
|
257
236
|
|
|
258
237
|
// Example: merge props
|
|
259
238
|
const props = mergeComponentProps(defaultProps, userProps);
|
|
260
239
|
|
|
261
240
|
// Example: get color shades
|
|
262
|
-
const { main, dark, light,
|
|
241
|
+
const { main, dark, light, contrast } = getColorShadesByVariant('primary');
|
|
263
242
|
|
|
264
243
|
// Example: format price
|
|
265
244
|
const formatted = formatPrice(1000000, 'VND', 'vi-VN'); // "1.000.000 ₫"
|
|
@@ -271,34 +250,7 @@ const formatted = formatPrice(1000000, 'VND', 'vi-VN'); // "1.000.000 ₫"
|
|
|
271
250
|
|
|
272
251
|
### Component Categories
|
|
273
252
|
|
|
274
|
-
Thư viện cung cấp 60+ components được tổ chức theo các nhóm
|
|
275
|
-
|
|
276
|
-
#### Layout
|
|
277
|
-
`Box`, `Flexbox`, `Grid`, `Container`
|
|
278
|
-
|
|
279
|
-
#### Typography
|
|
280
|
-
`Text`, `Link`, `HighlightWords`
|
|
281
|
-
|
|
282
|
-
#### Form Controls
|
|
283
|
-
`Input`, `InputNumber`, `InputRange`, `InputMask`, `Textarea`, `Select`, `MultipleSelect`, `Checkbox`, `RadioButton`, `Switch`, `DatePicker`, `TimePicker`, `PhoneInput`, `OtpInput`, `Cascader`
|
|
284
|
-
|
|
285
|
-
#### Buttons
|
|
286
|
-
`Button`, `IconButton`, `NavLink`
|
|
287
|
-
|
|
288
|
-
#### Feedback
|
|
289
|
-
`Loading`, `Progress`, `LinearProgress`, `Dialog`, `Drawer`, `Tooltip`, `Popover`, `Notifications`
|
|
290
|
-
|
|
291
|
-
#### Data Display
|
|
292
|
-
`Badge`, `Chip`, `Avatar`, `Table`, `Pagination`, `Stepper`, `Tabs`, `Accordion`, `Collapse`, `Breadcrumbs`, `StarRating`, `PriceLabel`, `CountUp`, `CountdownTimer`, `Flag`
|
|
293
|
-
|
|
294
|
-
#### Media
|
|
295
|
-
`Image`, `Video`, `Icon`, `Lightbox`, `Swiper`
|
|
296
|
-
|
|
297
|
-
#### Navigation
|
|
298
|
-
`Menu`, `FilterPanel`
|
|
299
|
-
|
|
300
|
-
#### Utilities
|
|
301
|
-
`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).
|
|
302
254
|
|
|
303
255
|
### Export Paths
|
|
304
256
|
|
|
@@ -320,7 +272,6 @@ import { cn, formatPrice } from '@janbox/storefront-ui/utils';
|
|
|
320
272
|
|
|
321
273
|
// Constants
|
|
322
274
|
import { HTMLDatasetAttributes } from '@janbox/storefront-ui/constants';
|
|
323
|
-
|
|
324
275
|
```
|
|
325
276
|
|
|
326
277
|
### Size Variants
|
|
@@ -337,11 +288,11 @@ Hầu hết components hỗ trợ 4 size variants:
|
|
|
337
288
|
**Size mapping:**
|
|
338
289
|
|
|
339
290
|
| size | iconSize | inputSize | inputPaddingX | textVariant |
|
|
340
|
-
|
|
341
|
-
| `xs` | 20px
|
|
342
|
-
| `sm` | 20px
|
|
343
|
-
| `md` | 24px
|
|
344
|
-
| `lg` | 24px
|
|
291
|
+
| ---- | -------- | --------- | ------------- | ----------- |
|
|
292
|
+
| `xs` | 20px | 24px | 8px | `xs` |
|
|
293
|
+
| `sm` | 20px | 32px | 12px | `sm` |
|
|
294
|
+
| `md` | 24px | 40px | 12px | `sm` |
|
|
295
|
+
| `lg` | 24px | 48px | 16px | `base` |
|
|
345
296
|
|
|
346
297
|
### Color Variants
|
|
347
298
|
|
|
@@ -453,14 +404,14 @@ Storybook sẽ chạy tại **http://localhost:6006**
|
|
|
453
404
|
|
|
454
405
|
### Development Commands
|
|
455
406
|
|
|
456
|
-
| Command
|
|
457
|
-
|
|
458
|
-
| `pnpm storybook`
|
|
459
|
-
| `pnpm build`
|
|
460
|
-
| `pnpm dev`
|
|
461
|
-
| `pnpm type-check`
|
|
462
|
-
| `pnpm lint`
|
|
463
|
-
| `pnpm build-storybook` | Build Storybook static
|
|
407
|
+
| Command | Description |
|
|
408
|
+
| ---------------------- | ------------------------ |
|
|
409
|
+
| `pnpm storybook` | Dev server (port 6006) |
|
|
410
|
+
| `pnpm build` | Build thư viện → `dist/` |
|
|
411
|
+
| `pnpm dev` | Build với watch mode |
|
|
412
|
+
| `pnpm type-check` | TypeScript type checking |
|
|
413
|
+
| `pnpm lint` | ESLint |
|
|
414
|
+
| `pnpm build-storybook` | Build Storybook static |
|
|
464
415
|
|
|
465
416
|
### Creating New Components
|
|
466
417
|
|
|
@@ -494,12 +445,87 @@ export const getXxxProps = (p: XxxProps) => mergeComponentProps(defaultProps, p)
|
|
|
494
445
|
// xxx.tsx
|
|
495
446
|
export const Xxx = ({ ref, ..._props }: XxxProps) => {
|
|
496
447
|
const { size, children, ...rest } = getXxxProps(_props);
|
|
497
|
-
return
|
|
448
|
+
return (
|
|
449
|
+
<Primitive ref={ref} {...rest}>
|
|
450
|
+
{children}
|
|
451
|
+
</Primitive>
|
|
452
|
+
);
|
|
498
453
|
};
|
|
499
454
|
```
|
|
500
455
|
|
|
501
456
|
---
|
|
502
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
|
+
|
|
503
529
|
## API Reference
|
|
504
530
|
|
|
505
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 {};
|
|
@@ -62,7 +62,7 @@ const Avatar = ({ ref, ..._props }) => {
|
|
|
62
62
|
alignItems: "center",
|
|
63
63
|
justifyContent: "center",
|
|
64
64
|
backgroundColor: getColorVar(`${color}.600`),
|
|
65
|
-
color: getColorVar("white"),
|
|
65
|
+
color: getColorVar("common.white"),
|
|
66
66
|
fontWeight: 600,
|
|
67
67
|
lineHeight: 1,
|
|
68
68
|
borderRadius: "inherit",
|
|
@@ -85,7 +85,7 @@ const Avatar = ({ ref, ..._props }) => {
|
|
|
85
85
|
borderRadius: "50%",
|
|
86
86
|
backgroundColor: getAvatarStatusColor(status),
|
|
87
87
|
borderWidth: 2,
|
|
88
|
-
borderColor: getColorVar("white"),
|
|
88
|
+
borderColor: getColorVar("common.white"),
|
|
89
89
|
...createStatusStyle({ size }),
|
|
90
90
|
sm: createStatusStyle(sm),
|
|
91
91
|
md: createStatusStyle(md),
|
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']>;
|
|
@@ -39,7 +39,7 @@ const Button = ({ children, ref, ..._props }) => {
|
|
|
39
39
|
dark,
|
|
40
40
|
light,
|
|
41
41
|
main,
|
|
42
|
-
|
|
42
|
+
contrast,
|
|
43
43
|
placeholder: placeholderColor,
|
|
44
44
|
ariaDisabledSurface,
|
|
45
45
|
ariaDisabledText
|
|
@@ -61,7 +61,7 @@ const Button = ({ children, ref, ..._props }) => {
|
|
|
61
61
|
},
|
|
62
62
|
variant === "contained" && {
|
|
63
63
|
backgroundColor: isLoading ? placeholderColor : main,
|
|
64
|
-
color:
|
|
64
|
+
color: contrast,
|
|
65
65
|
":hover": {
|
|
66
66
|
backgroundColor: dark
|
|
67
67
|
},
|
|
@@ -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;
|