@chotot/clad-ui 2.1.0 → 2.3.0
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 +2 -2
- package/dist/components/Badge/Badge.d.ts +10 -2
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js +11 -6
- package/dist/components/Badge/Badge.stories.d.ts.map +1 -1
- package/dist/components/Badge/Badge.stories.js +143 -124
- package/dist/components/Badge/Badge.styles.d.ts +1 -1
- package/dist/components/Badge/Badge.styles.d.ts.map +1 -1
- package/dist/components/Badge/Badge.styles.js +67 -17
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +1 -0
- package/dist/components/Button/GhostButton.d.ts.map +1 -1
- package/dist/components/Button/GhostButton.js +1 -0
- package/dist/components/Button/IconButton.d.ts.map +1 -1
- package/dist/components/Button/IconButton.js +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -1
- package/dist/components/Chip/Chip.d.ts.map +1 -1
- package/dist/components/Chip/Chip.js +2 -2
- package/dist/components/Chip/Chip.stories.d.ts +11 -0
- package/dist/components/Chip/Chip.stories.d.ts.map +1 -1
- package/dist/components/Chip/Chip.stories.js +81 -24
- package/dist/components/Chip/Chip.styles.d.ts.map +1 -1
- package/dist/components/Chip/Chip.styles.js +56 -50
- package/dist/components/Input/Input.styles.d.ts.map +1 -1
- package/dist/components/Input/Input.styles.js +14 -0
- package/dist/components/Pagination/PageItem.d.ts.map +1 -1
- package/dist/components/Pagination/PageItem.js +1 -0
- package/dist/components/RowItem/RowItem.styles.d.ts.map +1 -1
- package/dist/components/RowItem/RowItem.styles.js +8 -0
- package/dist/components/Snack/Snack.d.ts +9 -0
- package/dist/components/Snack/Snack.d.ts.map +1 -1
- package/dist/components/Snack/Snack.js +7 -4
- package/dist/components/Snack/Snack.stories.d.ts +22 -0
- package/dist/components/Snack/Snack.stories.d.ts.map +1 -1
- package/dist/components/Snack/Snack.stories.js +137 -0
- package/dist/components/Snack/Snack.styles.d.ts +7 -1
- package/dist/components/Snack/Snack.styles.d.ts.map +1 -1
- package/dist/components/Snack/Snack.styles.js +44 -3
- package/dist/components/TextArea/TextArea.styles.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.styles.js +5 -0
- package/dist/icons/ChevronDown.d.ts.map +1 -1
- package/dist/icons/ChevronDown.js +1 -3
- package/dist/icons/ChevronLeft.d.ts.map +1 -1
- package/dist/icons/ChevronLeft.js +1 -3
- package/dist/icons/ChevronRight.d.ts.map +1 -1
- package/dist/icons/ChevronRight.js +1 -3
- package/dist/icons/ChevronUp.d.ts.map +1 -1
- package/dist/icons/ChevronUp.js +1 -3
- package/dist/patterns/Drawer/Drawer.d.ts +19 -10
- package/dist/patterns/Drawer/Drawer.d.ts.map +1 -1
- package/dist/patterns/Drawer/Drawer.js +30 -18
- package/dist/patterns/Drawer/Drawer.stories.d.ts +20 -0
- package/dist/patterns/Drawer/Drawer.stories.d.ts.map +1 -1
- package/dist/patterns/Drawer/Drawer.stories.js +329 -42
- package/dist/patterns/Drawer/Drawer.styles.d.ts +1 -1
- package/dist/patterns/Drawer/Drawer.styles.d.ts.map +1 -1
- package/dist/patterns/Drawer/Drawer.styles.js +11 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts.map +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts.map +1 -1
- package/dist/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.js +1 -5
- package/dist/storybook/Popover.js +1 -0
- package/package.json +5 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { css } from '@linaria/core';
|
|
3
3
|
import theme from '@clad-ui/theme';
|
|
4
|
+
import { CircleCheckFilled, WarningFilled, InfoFilled, BellFilled } from '../../icons';
|
|
4
5
|
import Button from '../Button/Button';
|
|
5
6
|
import Checkbox from '../Checkbox/Checkbox';
|
|
6
7
|
import Snack from './Snack';
|
|
@@ -280,3 +281,139 @@ export const WithAutoHideDuration = {
|
|
|
280
281
|
},
|
|
281
282
|
},
|
|
282
283
|
};
|
|
284
|
+
export const WithIcon = {
|
|
285
|
+
render: () => {
|
|
286
|
+
const [open1, setOpen1] = useState(false);
|
|
287
|
+
const [open2, setOpen2] = useState(false);
|
|
288
|
+
const [open3, setOpen3] = useState(false);
|
|
289
|
+
const [open4, setOpen4] = useState(false);
|
|
290
|
+
const closeAllSnack = () => {
|
|
291
|
+
setOpen1(false);
|
|
292
|
+
setOpen2(false);
|
|
293
|
+
setOpen3(false);
|
|
294
|
+
setOpen4(false);
|
|
295
|
+
};
|
|
296
|
+
const openSnackHandler1 = () => {
|
|
297
|
+
closeAllSnack();
|
|
298
|
+
setOpen1(true);
|
|
299
|
+
};
|
|
300
|
+
const closeSnackHandler1 = () => {
|
|
301
|
+
setOpen1(false);
|
|
302
|
+
};
|
|
303
|
+
const openSnackHandler2 = () => {
|
|
304
|
+
closeAllSnack();
|
|
305
|
+
setOpen2(true);
|
|
306
|
+
};
|
|
307
|
+
const closeSnackHandler2 = () => {
|
|
308
|
+
setOpen2(false);
|
|
309
|
+
};
|
|
310
|
+
const openSnackHandler3 = () => {
|
|
311
|
+
closeAllSnack();
|
|
312
|
+
setOpen3(true);
|
|
313
|
+
};
|
|
314
|
+
const closeSnackHandler3 = () => {
|
|
315
|
+
setOpen3(false);
|
|
316
|
+
};
|
|
317
|
+
const openSnackHandler4 = () => {
|
|
318
|
+
closeAllSnack();
|
|
319
|
+
setOpen4(true);
|
|
320
|
+
};
|
|
321
|
+
const closeSnackHandler4 = () => {
|
|
322
|
+
setOpen4(false);
|
|
323
|
+
};
|
|
324
|
+
return (<>
|
|
325
|
+
<p>Success message with icon</p>
|
|
326
|
+
<Button onClick={openSnackHandler1}>Show Success</Button>
|
|
327
|
+
{!!open1 && (<Snack onClose={closeSnackHandler1} icon={<CircleCheckFilled />}>
|
|
328
|
+
Cập nhật ảnh đại diện thành công
|
|
329
|
+
</Snack>)}
|
|
330
|
+
<p className={marginTopClass}>Error message with icon</p>
|
|
331
|
+
<Button onClick={openSnackHandler2}>Show Error</Button>
|
|
332
|
+
{!!open2 && (<Snack onClose={closeSnackHandler2} icon={<WarningFilled />}>
|
|
333
|
+
Đã có lỗi xảy ra.
|
|
334
|
+
</Snack>)}
|
|
335
|
+
<p className={marginTopClass}>Info message with icon</p>
|
|
336
|
+
<Button onClick={openSnackHandler3}>Show Info</Button>
|
|
337
|
+
{!!open3 && (<Snack onClose={closeSnackHandler3} icon={<InfoFilled />}>
|
|
338
|
+
Ai đang điền thông tin cho bạn...
|
|
339
|
+
</Snack>)}
|
|
340
|
+
<p className={marginTopClass}>Notification with icon and action</p>
|
|
341
|
+
<Button onClick={openSnackHandler4}>Show Notification</Button>
|
|
342
|
+
{!!open4 && (<Snack onClose={closeSnackHandler4} icon={<BellFilled />} actionLabel="Thử lại" onActionClick={() => {
|
|
343
|
+
console.log('Retry clicked');
|
|
344
|
+
}}>
|
|
345
|
+
Mất kết nối mạng.
|
|
346
|
+
</Snack>)}
|
|
347
|
+
</>);
|
|
348
|
+
},
|
|
349
|
+
name: 'With icon',
|
|
350
|
+
parameters: {
|
|
351
|
+
docs: {
|
|
352
|
+
description: {
|
|
353
|
+
story: 'Add custom icons to Snacks using the `icon` prop. The icon will always appear on the left side of the message. You can pass any React node as an icon.',
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
export const WithLayout = {
|
|
359
|
+
render: () => {
|
|
360
|
+
const [open1, setOpen1] = useState(false);
|
|
361
|
+
const [open2, setOpen2] = useState(false);
|
|
362
|
+
const [open3, setOpen3] = useState(false);
|
|
363
|
+
const closeAllSnack = () => {
|
|
364
|
+
setOpen1(false);
|
|
365
|
+
setOpen2(false);
|
|
366
|
+
setOpen3(false);
|
|
367
|
+
};
|
|
368
|
+
const openSnackHandler1 = () => {
|
|
369
|
+
closeAllSnack();
|
|
370
|
+
setOpen1(true);
|
|
371
|
+
};
|
|
372
|
+
const closeSnackHandler1 = () => {
|
|
373
|
+
setOpen1(false);
|
|
374
|
+
};
|
|
375
|
+
const openSnackHandler2 = () => {
|
|
376
|
+
closeAllSnack();
|
|
377
|
+
setOpen2(true);
|
|
378
|
+
};
|
|
379
|
+
const closeSnackHandler2 = () => {
|
|
380
|
+
setOpen2(false);
|
|
381
|
+
};
|
|
382
|
+
const openSnackHandler3 = () => {
|
|
383
|
+
closeAllSnack();
|
|
384
|
+
setOpen3(true);
|
|
385
|
+
};
|
|
386
|
+
const closeSnackHandler3 = () => {
|
|
387
|
+
setOpen3(false);
|
|
388
|
+
};
|
|
389
|
+
return (<>
|
|
390
|
+
<p>Horizontal layout (default) - Icon, text, and action button in one row</p>
|
|
391
|
+
<Button onClick={openSnackHandler1}>Show Horizontal</Button>
|
|
392
|
+
{!!open1 && (<Snack onClose={closeSnackHandler1} icon={<CircleCheckFilled />} actionLabel="Hoàn tác" layout="horizontal" desktopSize="md" autoHideDuration="xxxxl" onActionClick={() => {
|
|
393
|
+
console.log('Undo clicked');
|
|
394
|
+
}}>
|
|
395
|
+
Cập nhật ảnh đại diện không thành công, vui lòng thử lại với ảnh có kích thước nhỏ hơn
|
|
396
|
+
</Snack>)}
|
|
397
|
+
<p className={marginTopClass}>Vertical layout - Action button on second line</p>
|
|
398
|
+
<Button onClick={openSnackHandler2}>Show Vertical</Button>
|
|
399
|
+
{!!open2 && (<Snack onClose={closeSnackHandler2} icon={<CircleCheckFilled />} actionLabel="Đăng lại ảnh khác" layout="vertical" desktopSize="md" autoHideDuration="xxxxl" onActionClick={() => {
|
|
400
|
+
console.log('Re-upload clicked');
|
|
401
|
+
}}>
|
|
402
|
+
Cập nhật ảnh đại diện không thành công, vui lòng thử lại với ảnh có kích thước nhỏ hơn
|
|
403
|
+
</Snack>)}
|
|
404
|
+
<p className={marginTopClass}>Text only (centered)</p>
|
|
405
|
+
<Button onClick={openSnackHandler3}>Show Text Only</Button>
|
|
406
|
+
{!!open3 && (<Snack onClose={closeSnackHandler3}>
|
|
407
|
+
Tin đã được đưa vào danh sách theo dõi.
|
|
408
|
+
</Snack>)}
|
|
409
|
+
</>);
|
|
410
|
+
},
|
|
411
|
+
name: 'With layout',
|
|
412
|
+
parameters: {
|
|
413
|
+
docs: {
|
|
414
|
+
description: {
|
|
415
|
+
story: 'Use the `layout` prop to control the orientation of content and action button. `horizontal` (default) places everything in one row, while `vertical` stacks the action button on a second line. Text without icon and action button is centered.',
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
};
|
|
@@ -10,5 +10,11 @@ declare const CloseButton: import("@linaria/react").StyledMeta & import("react")
|
|
|
10
10
|
declare const ActionButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
|
|
11
11
|
as?: import("react").ElementType;
|
|
12
12
|
}>;
|
|
13
|
-
|
|
13
|
+
declare const IconWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
14
|
+
as?: import("react").ElementType;
|
|
15
|
+
}>;
|
|
16
|
+
declare const ContentWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
17
|
+
as?: import("react").ElementType;
|
|
18
|
+
}>;
|
|
19
|
+
export { SnackWrapper, StyledSnack, CloseButton, ActionButton, IconWrapper, ContentWrapper };
|
|
14
20
|
//# sourceMappingURL=Snack.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snack.styles.d.ts","sourceRoot":"","sources":["../../../components/Snack/Snack.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,YAAY;;EAQjB,CAAC;AAEF,QAAA,MAAM,WAAW;;
|
|
1
|
+
{"version":3,"file":"Snack.styles.d.ts","sourceRoot":"","sources":["../../../components/Snack/Snack.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,YAAY;;EAQjB,CAAC;AAEF,QAAA,MAAM,WAAW;;EAiEhB,CAAC;AAEF,QAAA,MAAM,WAAW;;EAiBhB,CAAC;AAEF,QAAA,MAAM,YAAY;;EAejB,CAAC;AAEF,QAAA,MAAM,WAAW;;EAehB,CAAC;AAEF,QAAA,MAAM,cAAc;;EAYnB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -37,6 +37,7 @@ const StyledSnack = styled.div `
|
|
|
37
37
|
display: flex;
|
|
38
38
|
align-items: center;
|
|
39
39
|
justify-content: space-between;
|
|
40
|
+
gap: 8px;
|
|
40
41
|
color: ${colors.textBlank};
|
|
41
42
|
background-color: ${colors.backgroundInverted};
|
|
42
43
|
border-radius: ${radii.lg};
|
|
@@ -53,6 +54,12 @@ const StyledSnack = styled.div `
|
|
|
53
54
|
animation-name: fadeOut;
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
&.verticalLayout {
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
align-items: flex-start;
|
|
60
|
+
gap: 2px;
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
@media ${mediaQueries.tablet} {
|
|
57
64
|
margin: 0 auto;
|
|
58
65
|
|
|
@@ -89,13 +96,47 @@ const CloseButton = styled.button `
|
|
|
89
96
|
`;
|
|
90
97
|
const ActionButton = styled.button `
|
|
91
98
|
background-color: transparent;
|
|
92
|
-
position: absolute;
|
|
93
|
-
right: ${space.sm};
|
|
94
99
|
color: ${colors.textChotot};
|
|
95
100
|
${typo.label.section}
|
|
101
|
+
padding: 0;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
flex-shrink: 0;
|
|
104
|
+
|
|
105
|
+
.verticalLayout & {
|
|
106
|
+
align-self: flex-end;
|
|
107
|
+
}
|
|
96
108
|
|
|
97
109
|
&:focus {
|
|
98
110
|
outline: none;
|
|
99
111
|
}
|
|
100
112
|
`;
|
|
101
|
-
|
|
113
|
+
const IconWrapper = styled.div `
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
margin-right: ${space.sm};
|
|
118
|
+
flex-shrink: 0;
|
|
119
|
+
line-height: 1;
|
|
120
|
+
width: ${space.mdl};
|
|
121
|
+
height: ${space.mdl};
|
|
122
|
+
|
|
123
|
+
svg {
|
|
124
|
+
width: ${space.mdl};
|
|
125
|
+
height: ${space.mdl};
|
|
126
|
+
color: ${colors.iconBlank};
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
const ContentWrapper = styled.div `
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
gap: 0;
|
|
133
|
+
flex: 1;
|
|
134
|
+
min-width: 0;
|
|
135
|
+
text-align: left;
|
|
136
|
+
|
|
137
|
+
.centerText & {
|
|
138
|
+
justify-content: center;
|
|
139
|
+
text-align: center;
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
export { SnackWrapper, StyledSnack, CloseButton, ActionButton, IconWrapper, ContentWrapper };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.styles.d.ts","sourceRoot":"","sources":["../../../components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,SAAS;oBAAgC,MAAM;;;EAOpD,CAAC;AAEF,QAAA,MAAM,eAAe;mBAA+B,MAAM;cAAY,OAAO;;;
|
|
1
|
+
{"version":3,"file":"TextArea.styles.d.ts","sourceRoot":"","sources":["../../../components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,SAAS;oBAAgC,MAAM;;;EAOpD,CAAC;AAEF,QAAA,MAAM,eAAe;mBAA+B,MAAM;cAAY,OAAO;;;EAsG5E,CAAC;AAEF,QAAA,MAAM,cAAc;;EA2CnB,CAAC;AAEF,QAAA,MAAM,SAAS;;EAQd,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -18,6 +18,11 @@ const TextAreaWrapper = styled.div `
|
|
|
18
18
|
background-color: ${colors.backgroundPrimary};
|
|
19
19
|
position: relative;
|
|
20
20
|
|
|
21
|
+
&:hover {
|
|
22
|
+
border: ${borderWidths.md} ${borderStyles.solid} ${colors.borderBlack};
|
|
23
|
+
transition: all 0.3s ease;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
/* set resize to the wrapper instead of the textarea to make sure the border move along while resizing */
|
|
22
27
|
&.resize-both {
|
|
23
28
|
resize: both;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChevronDown.d.ts","sourceRoot":"","sources":["../../icons/ChevronDown.js"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"ChevronDown.d.ts","sourceRoot":"","sources":["../../icons/ChevronDown.js"],"names":[],"mappings":";AAEA,yDAeC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const SvgChevronDown = (props) => (<svg data-type="monochrome" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" fill="none" {...props}>
|
|
3
|
-
<
|
|
4
|
-
<path d="M4.68451 8.05853C4.99693 7.74611 5.50346 7.74611 5.81588 8.05853L12.0002 14.2428L18.1845 8.05853C18.4969 7.74611 19.0035 7.74611 19.3159 8.05853C19.6283 8.37095 19.6283 8.87748 19.3159 9.1899L12.5659 15.9399C12.2535 16.2523 11.7469 16.2523 11.4345 15.9399L4.68451 9.1899C4.37209 8.87748 4.37209 8.37095 4.68451 8.05853Z"/>
|
|
5
|
-
</g>
|
|
3
|
+
<path d="M6.26267 9.32433C6.61242 8.94273 7.1903 8.89456 7.59666 9.19737L7.67576 9.2628L12 13.2237L16.3242 9.2628L16.4033 9.19737C16.8096 8.89457 17.3875 8.94271 17.7373 9.32433C18.087 9.70608 18.0842 10.2858 17.747 10.6642L17.6758 10.7374L12.6767 15.3175C12.2945 15.6677 11.7074 15.6676 11.3252 15.3175L6.3242 10.7374L6.25291 10.6651C5.9153 10.2868 5.91286 9.70628 6.26267 9.32433Z" fill="currentColor"/>
|
|
6
4
|
</svg>);
|
|
7
5
|
export default SvgChevronDown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChevronLeft.d.ts","sourceRoot":"","sources":["../../icons/ChevronLeft.js"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"ChevronLeft.d.ts","sourceRoot":"","sources":["../../icons/ChevronLeft.js"],"names":[],"mappings":";AAEA,yDAeC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const SvgChevronLeft = (props) => (<svg data-type="monochrome" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" fill="none" {...props}>
|
|
3
|
-
<
|
|
4
|
-
<path d="M15.9409 4.68353C16.2533 4.99595 16.2533 5.50248 15.9409 5.8149L9.75657 11.9992L15.9409 18.1835C16.2533 18.496 16.2533 19.0025 15.9409 19.3149C15.6285 19.6273 15.1219 19.6273 14.8095 19.3149L8.05951 12.5649C7.74709 12.2525 7.74709 11.746 8.05951 11.4335L14.8095 4.68353C15.1219 4.37111 15.6285 4.37111 15.9409 4.68353Z"/>
|
|
5
|
-
</g>
|
|
3
|
+
<path d="M8.22438 12.6309C7.90403 12.2382 7.92662 11.6592 8.29274 11.293L13.2927 6.29304L13.3689 6.22469C13.7617 5.90433 14.3407 5.92693 14.7068 6.29304C15.0729 6.65916 15.0955 7.23816 14.7752 7.63094L14.7068 7.70711L10.4138 12.0001L14.7068 16.293C15.0973 16.6836 15.0973 17.3166 14.7068 17.7071C14.3163 18.0976 13.6833 18.0976 13.2927 17.7071L8.29274 12.7071L8.22438 12.6309Z" fill="currentColor"/>
|
|
6
4
|
</svg>);
|
|
7
5
|
export default SvgChevronLeft;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChevronRight.d.ts","sourceRoot":"","sources":["../../icons/ChevronRight.js"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"ChevronRight.d.ts","sourceRoot":"","sources":["../../icons/ChevronRight.js"],"names":[],"mappings":";AAEA,0DAeC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const SvgChevronRight = (props) => (<svg data-type="monochrome" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" fill="none" {...props}>
|
|
3
|
-
<
|
|
4
|
-
<path d="M8.05951 4.68353C8.37193 4.37111 8.87846 4.37111 9.19088 4.68353L15.9409 11.4335C16.2533 11.746 16.2533 12.2525 15.9409 12.5649L9.19088 19.3149C8.87846 19.6273 8.37193 19.6273 8.05951 19.3149C7.74709 19.0025 7.74709 18.496 8.05951 18.1835L14.2438 11.9992L8.05951 5.8149C7.74709 5.50248 7.74709 4.99595 8.05951 4.68353Z"/>
|
|
5
|
-
</g>
|
|
3
|
+
<path d="M16 11.9999C16 12.2651 15.8946 12.5194 15.707 12.707L10.707 17.707L10.6309 17.7753C10.2381 18.0957 9.65908 18.0731 9.29297 17.707C8.92685 17.3408 8.90426 16.7618 9.22461 16.3691L9.29297 16.2929L13.5859 11.9999L9.29297 7.70696C8.90244 7.31643 8.90244 6.68342 9.29297 6.29289C9.68349 5.90237 10.3165 5.90237 10.707 6.29289L15.707 11.2929L15.7734 11.3661C15.9193 11.5441 16 11.7678 16 11.9999Z" fill="currentColor"/>
|
|
6
4
|
</svg>);
|
|
7
5
|
export default SvgChevronRight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChevronUp.d.ts","sourceRoot":"","sources":["../../icons/ChevronUp.js"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"ChevronUp.d.ts","sourceRoot":"","sources":["../../icons/ChevronUp.js"],"names":[],"mappings":";AAEA,uDAeC"}
|
package/dist/icons/ChevronUp.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
const SvgChevronUp = (props) => (<svg data-type="monochrome" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="1em" height="1em" fill="none" {...props}>
|
|
3
|
-
<
|
|
4
|
-
<path d="M11.4345 8.05853C11.7469 7.74611 12.2535 7.74611 12.5659 8.05853L19.3159 14.8085C19.6283 15.121 19.6283 15.6275 19.3159 15.9399C19.0035 16.2523 18.4969 16.2523 18.1845 15.9399L12.0002 9.75559L5.81588 15.9399C5.50346 16.2523 4.99693 16.2523 4.68451 15.9399C4.37209 15.6275 4.37209 15.121 4.68451 14.8085L11.4345 8.05853Z"/>
|
|
5
|
-
</g>
|
|
3
|
+
<path d="M11.3993 9.20119C11.7802 8.91389 12.3183 8.9342 12.6766 9.26271L17.6757 13.8467C18.0825 14.2198 18.11 14.8518 17.7372 15.2588C17.3639 15.6659 16.7312 15.6936 16.3241 15.3203L11.9999 11.3565L7.67565 15.3203L7.59655 15.3858C7.19021 15.6887 6.61241 15.6405 6.26257 15.2588C5.8897 14.8517 5.91729 14.2198 6.32409 13.8467L11.3251 9.26271L11.3993 9.20119Z" fill="currentColor"/>
|
|
6
4
|
</svg>);
|
|
7
5
|
export default SvgChevronUp;
|
|
@@ -14,25 +14,22 @@ export interface DrawerProps {
|
|
|
14
14
|
*/
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
/**
|
|
17
|
-
* Primary button label
|
|
18
|
-
*
|
|
19
|
-
* Leave it empty to hide button group
|
|
17
|
+
* Primary button label. Leave it empty to hide button group
|
|
18
|
+
* @deprecated Use `actions` prop for more flexibility
|
|
20
19
|
*/
|
|
21
20
|
primaryBtnLabel?: string;
|
|
22
21
|
/**
|
|
23
|
-
* Secondary button label
|
|
24
|
-
*
|
|
25
|
-
* Leave it empty to hide button group
|
|
22
|
+
* Secondary button label. Leave it empty to hide button group
|
|
23
|
+
* @deprecated Use `actions` prop for more flexibility
|
|
26
24
|
*/
|
|
27
25
|
secondaryBtnLabel?: string;
|
|
28
26
|
/**
|
|
29
|
-
* Optional button label can be icon or text
|
|
30
|
-
*
|
|
31
|
-
* Leave it empty to hide button
|
|
27
|
+
* Optional button label can be icon or text. Leave it empty to hide button
|
|
32
28
|
*/
|
|
33
29
|
optionalBtnLabel?: React.ReactNode;
|
|
34
30
|
/**
|
|
35
31
|
* Button Group Position
|
|
32
|
+
* @deprecated Use custom styling in `actions` prop instead
|
|
36
33
|
*/
|
|
37
34
|
btnRowPosition?: 'justify' | 'left' | 'right';
|
|
38
35
|
/**
|
|
@@ -49,10 +46,12 @@ export interface DrawerProps {
|
|
|
49
46
|
onClose?: React.MouseEventHandler<HTMLElement>;
|
|
50
47
|
/**
|
|
51
48
|
* Callback when main button is clicked
|
|
49
|
+
* @deprecated Use `actions` prop for more flexibility
|
|
52
50
|
*/
|
|
53
51
|
onPrimaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
54
52
|
/**
|
|
55
53
|
* Callback when secondary button is clicked
|
|
54
|
+
* @deprecated Use `actions` prop for more flexibility
|
|
56
55
|
*/
|
|
57
56
|
onSecondaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
58
57
|
/**
|
|
@@ -61,6 +60,7 @@ export interface DrawerProps {
|
|
|
61
60
|
onOptionalBtnClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
62
61
|
/**
|
|
63
62
|
* Primary Button Color
|
|
63
|
+
* @deprecated Use `actions` prop for more flexibility
|
|
64
64
|
*/
|
|
65
65
|
primaryColor?: ButtonColor;
|
|
66
66
|
/**
|
|
@@ -84,13 +84,22 @@ export interface DrawerProps {
|
|
|
84
84
|
*/
|
|
85
85
|
contentClassName?: string;
|
|
86
86
|
needBypassScrollLock?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Custom action buttons. Pass your own button components for full control. Overrides legacy button props (primaryBtnLabel, secondaryBtnLabel, etc.)
|
|
89
|
+
*/
|
|
90
|
+
actions?: React.ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* Hide scrollbar for the drawer's main content area.
|
|
93
|
+
* Useful when you want only nested scrollable elements to show scrollbars.
|
|
94
|
+
*/
|
|
95
|
+
hideScrollbar?: boolean;
|
|
87
96
|
}
|
|
88
97
|
/**
|
|
89
98
|
* Drawer is a window sitting overtop of the main content to provide information or inquire confirmation.
|
|
90
99
|
* Drawer is very intrusive toward user and should be used sparingly.
|
|
91
100
|
*
|
|
92
101
|
* Usecase:
|
|
93
|
-
* Show promotion, label explanation, information or What
|
|
102
|
+
* Show promotion, label explanation, information or What's new.
|
|
94
103
|
* Request confirmation when user perform important or destructive actions.
|
|
95
104
|
* Congrat user after completing a userflow or achieve a milestone.
|
|
96
105
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../patterns/Drawer/Drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAe,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AA+B1E,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../patterns/Drawer/Drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAe,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AA+B1E,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAC9C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC/C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAClE;;;OAGG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACpE;;OAEG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAChE;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AAEH,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA2OjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -22,16 +22,17 @@ const BTN_GROUP_POSITION = {
|
|
|
22
22
|
* Drawer is very intrusive toward user and should be used sparingly.
|
|
23
23
|
*
|
|
24
24
|
* Usecase:
|
|
25
|
-
* Show promotion, label explanation, information or What
|
|
25
|
+
* Show promotion, label explanation, information or What's new.
|
|
26
26
|
* Request confirmation when user perform important or destructive actions.
|
|
27
27
|
* Congrat user after completing a userflow or achieve a milestone.
|
|
28
28
|
*
|
|
29
29
|
* `✅ Stable`
|
|
30
30
|
*/
|
|
31
|
-
const Drawer = ({ className = '', title = '', children, primaryBtnLabel, secondaryBtnLabel, primaryColor = 'primary', optionalBtnLabel, onOptionalBtnClick, btnRowPosition = 'justify', open = false, onClose = noop, onPrimaryButtonClick = noop, onSecondaryButtonClick = null, childrenOverflowVisible = false, isEmptyDrawer = false, haveClose = true, closeIcon = <Close />, contentClassName = '', needBypassScrollLock = false, }) => {
|
|
31
|
+
const Drawer = ({ className = '', title = '', children, primaryBtnLabel, secondaryBtnLabel, primaryColor = 'primary', optionalBtnLabel, onOptionalBtnClick, btnRowPosition = 'justify', open = false, onClose = noop, onPrimaryButtonClick = noop, onSecondaryButtonClick = null, childrenOverflowVisible = false, isEmptyDrawer = false, haveClose = true, closeIcon = <Close />, contentClassName = '', needBypassScrollLock = false, actions, hideScrollbar = false, }) => {
|
|
32
32
|
const { useEffect, useRef, useState } = React;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// Determine if we should show actions (either new or legacy)
|
|
34
|
+
const hasActions = !!actions || !!primaryBtnLabel;
|
|
35
|
+
const childrenWrapperClasses = cx((typeof children === 'string' || typeof children === 'number') && 'is-single-string', !hasActions && 'no-button', childrenOverflowVisible && showChildrenOverflowClass, hideScrollbar && 'hide-scrollbar', contentClassName);
|
|
35
36
|
const [scrollTop, scrollProps] = useScrollTop();
|
|
36
37
|
const wrapperProps = { ...scrollProps };
|
|
37
38
|
// Use the new scroll lock hook with reference counting
|
|
@@ -88,6 +89,29 @@ const Drawer = ({ className = '', title = '', children, primaryBtnLabel, seconda
|
|
|
88
89
|
setShowShadowBtm(show);
|
|
89
90
|
}, [open, scrollTop, children]);
|
|
90
91
|
const closeIconClass = cx((typeof closeIcon === 'string' || typeof closeIcon === 'number') && 'is-text');
|
|
92
|
+
// Render legacy buttons or custom actions
|
|
93
|
+
const renderActions = () => {
|
|
94
|
+
// If actions prop is provided, use it (new way)
|
|
95
|
+
if (actions) {
|
|
96
|
+
return <StyledButtonGroup data-clad="Drawer">{actions}</StyledButtonGroup>;
|
|
97
|
+
}
|
|
98
|
+
// Otherwise, render legacy buttons if primaryBtnLabel exists
|
|
99
|
+
if (primaryBtnLabel) {
|
|
100
|
+
return (<StyledButtonGroup {...btnGroupProps} data-clad="Drawer">
|
|
101
|
+
{!!secondaryBtnLabel && (<Button variant="outline" color="tertiary" size="large" extraClasses={cx(
|
|
102
|
+
// Keep button width maintain on column direction
|
|
103
|
+
btnRowPosition === 'justify' && buttonClass)} onClick={onSecondaryButtonClick ? onSecondaryButtonClick : onClose}>
|
|
104
|
+
{secondaryBtnLabel}
|
|
105
|
+
</Button>)}
|
|
106
|
+
<Button color={primaryColor} size="large" extraClasses={cx(
|
|
107
|
+
// Keep button width maintain on column direction
|
|
108
|
+
btnRowPosition === 'justify' && buttonClass)} onClick={onPrimaryButtonClick}>
|
|
109
|
+
{primaryBtnLabel}
|
|
110
|
+
</Button>
|
|
111
|
+
</StyledButtonGroup>);
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
91
115
|
/* eslint-disable react/jsx-no-useless-fragment */
|
|
92
116
|
return (<>
|
|
93
117
|
{!!open &&
|
|
@@ -96,7 +120,7 @@ const Drawer = ({ className = '', title = '', children, primaryBtnLabel, seconda
|
|
|
96
120
|
<StyledPopup className={cx(className, isEmptyDrawer && noSpacingClass)}>
|
|
97
121
|
{!isEmptyDrawer ? (<>
|
|
98
122
|
{/* HEADER */}
|
|
99
|
-
<StyledHeader data-clad={!
|
|
123
|
+
<StyledHeader data-clad={!hasActions ? 'Drawer' : undefined}>
|
|
100
124
|
<HeaderTopBar>
|
|
101
125
|
{!!haveClose && (<CloseButton type="button" onClick={onClose} className={closeIconClass}>
|
|
102
126
|
{closeIcon}
|
|
@@ -122,21 +146,9 @@ const Drawer = ({ className = '', title = '', children, primaryBtnLabel, seconda
|
|
|
122
146
|
{children}
|
|
123
147
|
</ChildrenContent>
|
|
124
148
|
</ChildrenWrapper>
|
|
125
|
-
{/* BTN */}
|
|
126
149
|
{/* ------------------------------------ */}
|
|
127
150
|
{/* FOOTER */}
|
|
128
|
-
{
|
|
129
|
-
{!!secondaryBtnLabel && (<Button variant="outline" color="tertiary" size="large" extraClasses={cx(
|
|
130
|
-
// Keep button width maintain on column direction
|
|
131
|
-
btnRowPosition === 'justify' && buttonClass)} onClick={onSecondaryButtonClick ? onSecondaryButtonClick : onClose}>
|
|
132
|
-
{secondaryBtnLabel}
|
|
133
|
-
</Button>)}
|
|
134
|
-
<Button color={primaryColor} size="large" extraClasses={cx(
|
|
135
|
-
// Keep button width maintain on column direction
|
|
136
|
-
btnRowPosition === 'justify' && buttonClass)} onClick={onPrimaryButtonClick}>
|
|
137
|
-
{primaryBtnLabel}
|
|
138
|
-
</Button>
|
|
139
|
-
</StyledButtonGroup>)}
|
|
151
|
+
{renderActions()}
|
|
140
152
|
</>) : (<ChildrenWrapper className={childrenWrapperClasses} ref={childrenWrapperRef} data-clad="Drawer" {...wrapperProps}>
|
|
141
153
|
<div className="shadow-top shadow" style={{
|
|
142
154
|
opacity: +scrollTop > 0 ? '1' : '0',
|
|
@@ -105,4 +105,24 @@ export declare const ContentClassName: {
|
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
|
+
export declare const CustomActions: {
|
|
109
|
+
render: () => JSX.Element;
|
|
110
|
+
parameters: {
|
|
111
|
+
docs: {
|
|
112
|
+
description: {
|
|
113
|
+
story: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export declare const NestedScroll: {
|
|
119
|
+
render: () => JSX.Element;
|
|
120
|
+
parameters: {
|
|
121
|
+
docs: {
|
|
122
|
+
description: {
|
|
123
|
+
story: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
108
128
|
//# sourceMappingURL=Drawer.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.stories.d.ts","sourceRoot":"","sources":["../../../patterns/Drawer/Drawer.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AASzD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ClB,CAAC;AAEF,eAAe,aAAa,CAAC;AAM7B,eAAO,MAAM,QAAQ;;CAgBpB,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawer.stories.d.ts","sourceRoot":"","sources":["../../../patterns/Drawer/Drawer.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AASzD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ClB,CAAC;AAEF,eAAe,aAAa,CAAC;AAM7B,eAAO,MAAM,QAAQ;;CAgBpB,CAAC;AA4EF,eAAO,MAAM,YAAY;;;;;;;;;;CA8CxB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;CAmJ9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;CAkG3B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;CAuG3B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;CAqCvB,CAAC;AAGF,eAAO,MAAM,gBAAgB;;;;;;;;;;CA0C5B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;CAgHzB,CAAC;AAeF,eAAO,MAAM,YAAY;;;;;;;;;CAoOxB,CAAC"}
|