@chotot/clad-ui 1.2.5 → 1.3.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.
Files changed (224) hide show
  1. package/README.md +3 -3
  2. package/components/Announcer/Announcer.d.ts +9 -4
  3. package/components/Announcer/Announcer.stories.d.ts +142 -0
  4. package/components/Announcer/{Announcer.stories.js → Announcer.stories.tsx} +36 -31
  5. package/components/Announcer/Announcer.styles.d.ts +24 -12
  6. package/components/Announcer/{Announcer.styles.js → Announcer.styles.ts} +43 -18
  7. package/components/Announcer/Announcer.tsx +62 -47
  8. package/components/Badge/Badge.d.ts +4 -2
  9. package/components/Badge/Badge.stories.d.ts +61 -0
  10. package/components/Badge/{Badge.stories.js → Badge.stories.tsx} +5 -5
  11. package/components/Badge/Badge.styles.d.ts +20 -5
  12. package/components/Badge/{Badge.styles.js → Badge.styles.ts} +14 -1
  13. package/components/Badge/Badge.tsx +8 -4
  14. package/components/Box/Box.d.ts +3 -3
  15. package/components/Box/Box.stories.d.ts +240 -0
  16. package/components/Box/{Box.stories.js → Box.stories.tsx} +2 -2
  17. package/components/Box/Box.styles.d.ts +19 -4
  18. package/components/Box/{Box.styles.js → Box.styles.ts} +17 -4
  19. package/components/Box/Box.tsx +4 -4
  20. package/components/Breadcrumbs/Breadcrumbs.d.ts +2 -2
  21. package/components/Breadcrumbs/Breadcrumbs.stories.d.ts +52 -0
  22. package/components/Breadcrumbs/{Breadcrumbs.stories.js → Breadcrumbs.stories.tsx} +17 -15
  23. package/components/Breadcrumbs/Breadcrumbs.styles.d.ts +5 -4
  24. package/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
  25. package/components/Button/Button.d.ts +21 -6
  26. package/components/Button/Button.stories.d.ts +103 -0
  27. package/components/Button/{Button.stories.js → Button.stories.tsx} +5 -1
  28. package/components/Button/Button.styles.d.ts +1 -1
  29. package/components/Button/{Button.styles.js → Button.styles.ts} +100 -6
  30. package/components/Button/Button.tsx +51 -18
  31. package/components/Button/ButtonLink.d.ts +4 -4
  32. package/components/Button/ButtonLink.stories.d.ts +30 -0
  33. package/components/Button/ButtonLink.styles.d.ts +1 -1
  34. package/components/Button/ButtonLink.tsx +5 -5
  35. package/components/Button/IconButton.d.ts +3 -29
  36. package/components/Button/IconButton.stories.d.ts +60 -0
  37. package/components/Button/{IconButton.stories.js → IconButton.stories.tsx} +27 -0
  38. package/components/Button/IconButton.tsx +2 -42
  39. package/components/Checkbox/Checkbox.d.ts +3 -3
  40. package/components/Checkbox/Checkbox.stories.d.ts +88 -0
  41. package/components/Checkbox/Checkbox.styles.d.ts +2 -2
  42. package/components/Checkbox/Checkbox.tsx +3 -6
  43. package/components/Chip/Chip.d.ts +5 -4
  44. package/components/Chip/Chip.stories.d.ts +153 -0
  45. package/components/Chip/{Chip.stories.js → Chip.stories.tsx} +4 -5
  46. package/components/Chip/Chip.styles.d.ts +11 -8
  47. package/components/Chip/{Chip.styles.js → Chip.styles.ts} +4 -4
  48. package/components/Chip/Chip.tsx +19 -12
  49. package/components/CurrencyInput/CurrencyInput.d.ts +3 -56
  50. package/components/CurrencyInput/CurrencyInput.stories.d.ts +104 -0
  51. package/components/CurrencyInput/{CurrencyInput.stories.js → CurrencyInput.stories.tsx} +2 -2
  52. package/components/CurrencyInput/CurrencyInput.styles.d.ts +16 -10
  53. package/components/CurrencyInput/{CurrencyInput.styles.js → CurrencyInput.styles.ts} +23 -9
  54. package/components/CurrencyInput/CurrencyInput.tsx +7 -61
  55. package/components/Dropdown/Dropdown.d.ts +22 -7
  56. package/components/Dropdown/Dropdown.stories.d.ts +148 -0
  57. package/components/Dropdown/{Dropdown.stories.js → Dropdown.stories.tsx} +115 -1
  58. package/components/Dropdown/Dropdown.styles.d.ts +10 -0
  59. package/components/Dropdown/Dropdown.styles.ts +42 -0
  60. package/components/Dropdown/Dropdown.tsx +120 -24
  61. package/components/Grid/Col.d.ts +2 -2
  62. package/components/Grid/Col.tsx +6 -3
  63. package/components/Grid/Grid.styles.d.ts +25 -5
  64. package/components/Grid/{Grid.styles.js → Grid.styles.ts} +16 -3
  65. package/components/Grid/aGrid.stories.d.ts +127 -0
  66. package/components/Grid/bCol.stories.d.ts +74 -0
  67. package/components/Input/Input.d.ts +14 -10
  68. package/components/Input/Input.stories.d.ts +226 -0
  69. package/components/Input/{Input.stories.js → Input.stories.tsx} +20 -16
  70. package/components/Input/Input.styles.d.ts +22 -11
  71. package/components/Input/{Input.styles.js → Input.styles.ts} +29 -7
  72. package/components/Input/Input.tsx +22 -20
  73. package/components/Popover/Popover.d.ts +44 -0
  74. package/components/Popover/Popover.stories.d.ts +53 -0
  75. package/components/Popover/Popover.stories.tsx +133 -0
  76. package/components/Popover/Popover.tsx +121 -0
  77. package/components/RadioButton/RadioButton.d.ts +5 -6
  78. package/components/RadioButton/RadioButton.stories.d.ts +94 -0
  79. package/components/RadioButton/RadioButton.styles.d.ts +7 -3
  80. package/components/RadioButton/{RadioButton.styles.js → RadioButton.styles.ts} +1 -1
  81. package/components/RadioButton/RadioButton.tsx +5 -11
  82. package/components/RowItem/RowItem.d.ts +27 -9
  83. package/components/RowItem/RowItem.stories.d.ts +131 -0
  84. package/components/RowItem/RowItem.stories.tsx +710 -0
  85. package/components/RowItem/RowItem.styles.d.ts +31 -10
  86. package/components/RowItem/{RowItem.styles.js → RowItem.styles.ts} +41 -13
  87. package/components/RowItem/RowItem.tsx +106 -42
  88. package/components/ShapeIcon/ShapeIcon.d.ts +23 -16
  89. package/components/ShapeIcon/ShapeIcon.stories.d.ts +91 -0
  90. package/components/ShapeIcon/{ShapeIcon.stories.js → ShapeIcon.stories.tsx} +21 -8
  91. package/components/ShapeIcon/ShapeIcon.styles.d.ts +8 -3
  92. package/components/ShapeIcon/{ShapeIcon.styles.js → ShapeIcon.styles.ts} +6 -3
  93. package/components/ShapeIcon/ShapeIcon.tsx +25 -21
  94. package/components/Slider/Slider.d.ts +9 -7
  95. package/components/Slider/Slider.stories.d.ts +81 -0
  96. package/components/Slider/{Slider.stories.js → Slider.stories.tsx} +7 -7
  97. package/components/Slider/Slider.styles.d.ts +15 -11
  98. package/components/Slider/{Slider.styles.js → Slider.styles.ts} +1 -1
  99. package/components/Slider/Slider.tsx +21 -16
  100. package/components/Snack/Snack.d.ts +4 -5
  101. package/components/Snack/Snack.stories.d.ts +87 -0
  102. package/components/Snack/Snack.styles.d.ts +9 -8
  103. package/components/Snack/{Snack.styles.js → Snack.styles.ts} +4 -4
  104. package/components/Snack/Snack.tsx +14 -11
  105. package/components/Tabs/Tab.d.ts +6 -6
  106. package/components/Tabs/Tab.tsx +6 -7
  107. package/components/Tabs/Tabs.d.ts +7 -4
  108. package/components/Tabs/Tabs.stories.d.ts +64 -0
  109. package/components/Tabs/{Tabs.stories.js → Tabs.stories.tsx} +2 -2
  110. package/components/Tabs/Tabs.styles.d.ts +30 -12
  111. package/components/Tabs/{Tabs.styles.js → Tabs.styles.ts} +4 -4
  112. package/components/Tabs/Tabs.tsx +11 -7
  113. package/components/TextArea/TextArea.d.ts +24 -11
  114. package/components/TextArea/TextArea.stories.d.ts +151 -0
  115. package/components/TextArea/{TextArea.stories.js → TextArea.stories.tsx} +5 -96
  116. package/components/TextArea/TextArea.styles.d.ts +18 -16
  117. package/components/TextArea/{TextArea.styles.js → TextArea.styles.ts} +39 -19
  118. package/components/TextArea/TextArea.tsx +85 -31
  119. package/components/TextLabel/TextLabel.d.ts +35 -0
  120. package/components/TextLabel/TextLabel.stories.d.ts +40 -0
  121. package/components/TextLabel/TextLabel.stories.tsx +177 -0
  122. package/components/TextLabel/TextLabel.styles.d.ts +9 -0
  123. package/components/TextLabel/TextLabel.styles.ts +24 -0
  124. package/components/TextLabel/TextLabel.tsx +112 -0
  125. package/components/ToggleSwitch/ToggleSwitch.d.ts +2 -2
  126. package/components/ToggleSwitch/ToggleSwitch.stories.d.ts +38 -0
  127. package/components/ToggleSwitch/ToggleSwitch.styles.d.ts +21 -14
  128. package/components/ToggleSwitch/{ToggleSwitch.styles.js → ToggleSwitch.styles.ts} +8 -12
  129. package/components/ToggleSwitch/ToggleSwitch.tsx +12 -6
  130. package/components/Tooltip/Tooltip.d.ts +9 -3
  131. package/components/Tooltip/Tooltip.spec.js +5 -3
  132. package/components/Tooltip/Tooltip.styles.d.ts +7 -8
  133. package/components/Tooltip/Tooltip.tsx +10 -3
  134. package/components/index.d.ts +2 -0
  135. package/components/index.ts +2 -0
  136. package/icons/PrivateSellerAvatar.d.ts +3 -0
  137. package/icons/PrivateSellerAvatar.js +3 -0
  138. package/icons/Sda.d.ts +5 -2
  139. package/icons/Sda.js +7 -7
  140. package/icons/VerifiedShop.d.ts +3 -0
  141. package/icons/VerifiedShop.js +3 -0
  142. package/package.json +6 -6
  143. package/patterns/Drawer/Drawer.d.ts +13 -13
  144. package/patterns/Drawer/Drawer.stories.d.ts +90 -0
  145. package/patterns/Drawer/{Drawer.stories.js → Drawer.stories.tsx} +25 -0
  146. package/patterns/Drawer/Drawer.styles.d.ts +30 -26
  147. package/patterns/Drawer/{Drawer.styles.js → Drawer.styles.ts} +2 -5
  148. package/patterns/Drawer/Drawer.tsx +20 -41
  149. package/patterns/EmptyState/EmptyState.d.ts +5 -4
  150. package/patterns/EmptyState/EmptyState.stories.d.ts +40 -0
  151. package/patterns/EmptyState/EmptyState.styles.d.ts +10 -10
  152. package/patterns/EmptyState/{EmptyState.styles.js → EmptyState.styles.ts} +5 -4
  153. package/patterns/EmptyState/EmptyState.tsx +14 -12
  154. package/patterns/InputGroup/InputGroup.d.ts +4 -0
  155. package/patterns/InputGroup/InputGroup.styles.d.ts +5 -4
  156. package/patterns/InputGroup/InputGroup.tsx +11 -5
  157. package/patterns/LegacyDialog/DialogMainIcon.d.ts +1 -0
  158. package/patterns/LegacyDialog/DialogMainIcon.js +51 -0
  159. package/patterns/LegacyDialog/LegacyDialog.d.ts +3 -3
  160. package/patterns/LegacyDialog/LegacyDialog.styles.d.ts +8 -10
  161. package/patterns/LegacyDialog/LegacyDialog.styles.js +1 -46
  162. package/patterns/LegacyDialog/LegacyDialog.tsx +5 -11
  163. package/patterns/LegacyPopup/LegacyPopup.d.ts +4 -4
  164. package/patterns/LegacyPopup/LegacyPopup.styles.d.ts +18 -13
  165. package/patterns/LegacyPopup/{LegacyPopup.styles.js → LegacyPopup.styles.ts} +3 -1
  166. package/patterns/LegacyPopup/LegacyPopup.tsx +4 -6
  167. package/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts +20 -17
  168. package/patterns/MultiSearchDropdown/MultiSearchDropdown.stories.d.ts +125 -0
  169. package/patterns/MultiSearchDropdown/{MultiSearchDropdown.stories.js → MultiSearchDropdown.stories.tsx} +31 -30
  170. package/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts +22 -21
  171. package/patterns/MultiSearchDropdown/{MultiSearchDropdown.styles.js → MultiSearchDropdown.styles.ts} +1 -7
  172. package/patterns/MultiSearchDropdown/MultiSearchDropdown.tsx +33 -32
  173. package/patterns/Popup/Popup.d.ts +8 -7
  174. package/patterns/Popup/Popup.stories.d.ts +102 -0
  175. package/patterns/Popup/Popup.styles.d.ts +41 -30
  176. package/patterns/Popup/{Popup.styles.js → Popup.styles.ts} +26 -33
  177. package/patterns/Popup/Popup.tsx +14 -33
  178. package/patterns/SearchInput/SearchInput.d.ts +38 -21
  179. package/patterns/SearchInput/SearchInput.stories.d.ts +186 -0
  180. package/patterns/SearchInput/{SearchInput.stories.js → SearchInput.stories.tsx} +78 -45
  181. package/patterns/SearchInput/SearchInput.styles.d.ts +6 -5
  182. package/patterns/SearchInput/{SearchInput.styles.js → SearchInput.styles.ts} +7 -4
  183. package/patterns/SearchInput/SearchInput.tsx +53 -34
  184. package/patterns/TagCloud/TagCloud.d.ts +19 -6
  185. package/patterns/TagCloud/TagCloud.stories.d.ts +159 -0
  186. package/patterns/TagCloud/{TagCloud.stories.js → TagCloud.stories.tsx} +59 -14
  187. package/patterns/TagCloud/TagCloud.styles.d.ts +12 -8
  188. package/patterns/TagCloud/{TagCloud.styles.js → TagCloud.styles.ts} +6 -7
  189. package/patterns/TagCloud/TagCloud.tsx +24 -8
  190. package/patterns/TagCloud/TagCloudMultiActive.d.ts +6 -4
  191. package/patterns/TagCloud/TagCloudMultiActive.tsx +5 -5
  192. package/patterns/TagCloud/TagCloudSingleActive.d.ts +5 -2
  193. package/patterns/TagCloud/TagCloudSingleActive.tsx +18 -5
  194. package/patterns/patterns-index.spec.js +1 -1
  195. package/storybook/GuideImage.d.ts +2 -2
  196. package/storybook/Swatch.d.ts +2 -2
  197. package/theme/__snapshots__/chotot.spec.js.snap +2 -2
  198. package/theme/chotot-color1.d.ts +7 -14
  199. package/theme/chotot.d.ts +32 -32
  200. package/theme/chotot.js +4 -4
  201. package/theme/ct-job.d.ts +6 -14
  202. package/theme/ct-pty.d.ts +6 -8
  203. package/theme/mudah.d.ts +14 -13
  204. package/types.d.ts +0 -9
  205. package/utils/_simulateChangeEvent.d.ts +18 -3
  206. package/utils/_simulateChangeEvent.js +13 -6
  207. package/utils/_simulateChangeEvent.spec.js +1 -1
  208. package/utils/cx.d.ts +8 -4
  209. package/utils/cx.js +8 -4
  210. package/utils/sx.d.ts +12 -4192
  211. package/components/RowItem/RowItem.stories.js +0 -560
  212. /package/components/Breadcrumbs/{Breadcrumbs.styles.js → Breadcrumbs.styles.ts} +0 -0
  213. /package/components/Button/{ButtonLink.stories.js → ButtonLink.stories.tsx} +0 -0
  214. /package/components/Button/{ButtonLink.styles.js → ButtonLink.styles.ts} +0 -0
  215. /package/components/Checkbox/{Checkbox.stories.js → Checkbox.stories.tsx} +0 -0
  216. /package/components/Checkbox/{Checkbox.styles.js → Checkbox.styles.ts} +0 -0
  217. /package/components/Grid/{aGrid.stories.js → aGrid.stories.tsx} +0 -0
  218. /package/components/Grid/{bCol.stories.js → bCol.stories.tsx} +0 -0
  219. /package/components/RadioButton/{RadioButton.stories.js → RadioButton.stories.tsx} +0 -0
  220. /package/components/Snack/{Snack.stories.js → Snack.stories.tsx} +0 -0
  221. /package/components/ToggleSwitch/{ToggleSwitch.stories.js → ToggleSwitch.stories.tsx} +0 -0
  222. /package/patterns/EmptyState/{EmptyState.stories.js → EmptyState.stories.tsx} +0 -0
  223. /package/patterns/InputGroup/{InputGroup.styles.js → InputGroup.styles.ts} +0 -0
  224. /package/patterns/Popup/{Popup.stories.js → Popup.stories.tsx} +0 -0
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <!-- badges -->
2
2
 
3
- [<img src="https://img.shields.io/badge/clad--ui-1.2.5-FFBA00" alt="clad-ui npm version" />](http://npmjs.cmco.io/-/web/detail/clad-ui)
3
+ [<img src="https://img.shields.io/badge/clad--ui-1.3.1-FFBA00" alt="clad-ui npm version" />](http://npmjs.cmco.io/-/web/detail/clad-ui)
4
4
  [<img src="https://img.shields.io/badge/@clad--ui/charts-1.0.2-FFBA00" alt="@clad-ui/charts npm version" />](http://npmjs.cmco.io/-/web/detail/clad-ui)
5
5
  [<img src="https://img.shields.io/badge/react-%3E=16.8-0088CC" alt="React dependency version" />](https://github.com/facebook/react/)
6
- [<img src="https://img.shields.io/badge/linaria-4.2.10-DE2D68" alt="Linaria dependency version" />](https://github.com/callstack/linaria)
7
- [<img src="https://img.shields.io/badge/storybook-7.5.1-FF4785" alt="Storybook dependency version" />](https://storybook.js.org/)
6
+ [<img src="https://img.shields.io/badge/linaria-^4.2.10-DE2D68" alt="Linaria dependency version" />](https://github.com/callstack/linaria)
7
+ [<img src="https://img.shields.io/badge/storybook-7.6.20-FF4785" alt="Storybook dependency version" />](https://storybook.js.org/)
8
8
  [<img src="https://github.com/carousell/clad-ui/actions/workflows/publish.yml/badge.svg" alt="Pipeline Status" />](https://github.com/carousell/clad-ui/actions/workflows/publish.yml)
9
9
  [<img src="https://sonar.chotot.org/api/project_badges/measure?project=web-clad-ui&metric=coverage" alt="Coverage" />](https://sonar.chotot.org/dashboard?id=web-clad-ui)
10
10
 
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  * `✅ Stable`
6
6
  *
7
7
  */
8
- export type AnnouncerProps = {
8
+ export interface AnnouncerProps {
9
9
  open?: boolean;
10
10
  /**
11
11
  * Callback when close icon is clicked. Normally, it is used to update `open` prop to close the Announcer.
@@ -15,7 +15,7 @@ export type AnnouncerProps = {
15
15
  /**
16
16
  * Callback when Announcer action button is clicked
17
17
  */
18
- onButtonClick?: () => void;
18
+ onButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
19
19
  /**
20
20
  * Announcer title
21
21
  */
@@ -26,8 +26,9 @@ export type AnnouncerProps = {
26
26
  children?: React.ReactNode;
27
27
  /**
28
28
  * Announcer type
29
+ * @default 'info'
29
30
  */
30
- type?: 'error' | 'gift' | 'info' | 'neutral' | 'success' | 'time' | 'warning';
31
+ type?: 'info' | 'warning' | 'success' | 'error' | 'neutral';
31
32
  /**
32
33
  * Turn Announcer to single line. Useful for short announcement. `compact` does not have effect on Announcer with type=`neutral`.
33
34
  */
@@ -44,6 +45,10 @@ export type AnnouncerProps = {
44
45
  * Custom icon
45
46
  */
46
47
  icon?: React.ReactElement;
47
- };
48
+ /**
49
+ * Displays a skeleton loader
50
+ */
51
+ isLoading?: boolean;
52
+ }
48
53
  declare const Announcer: React.FC<AnnouncerProps>;
49
54
  export default Announcer;
@@ -0,0 +1,142 @@
1
+ import React from 'react';
2
+ declare const announcerStories: {
3
+ title: string;
4
+ component: React.FC<import("./Announcer").AnnouncerProps>;
5
+ tags: string[];
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: string;
10
+ };
11
+ };
12
+ };
13
+ argTypes: {
14
+ title: string;
15
+ children: {
16
+ control: {
17
+ type: string;
18
+ };
19
+ };
20
+ type: {};
21
+ compact: {};
22
+ onClose: {
23
+ control: null;
24
+ };
25
+ onButtonClick: {
26
+ control: null;
27
+ };
28
+ dangerousHtml: {
29
+ control: null;
30
+ };
31
+ };
32
+ args: {
33
+ title: string;
34
+ children: string;
35
+ btnLabel: string;
36
+ open: boolean;
37
+ onClose: null;
38
+ onButtonClick: null;
39
+ dangerousHtml: null;
40
+ };
41
+ };
42
+ export default announcerStories;
43
+ export declare const Overview: {
44
+ render: (args: any) => JSX.Element;
45
+ };
46
+ export declare const WithoutTitle: {
47
+ render: () => JSX.Element;
48
+ name: string;
49
+ parameters: {
50
+ docs: {
51
+ description: {
52
+ story: string;
53
+ };
54
+ };
55
+ };
56
+ };
57
+ export declare const WithoutButton: {
58
+ render: () => JSX.Element;
59
+ name: string;
60
+ parameters: {
61
+ docs: {
62
+ description: {
63
+ story: string;
64
+ };
65
+ };
66
+ };
67
+ };
68
+ export declare const WithoutCloseButton: {
69
+ render: () => JSX.Element;
70
+ name: string;
71
+ parameters: {
72
+ docs: {
73
+ description: {
74
+ story: string;
75
+ };
76
+ };
77
+ };
78
+ };
79
+ export declare const WithType: {
80
+ render: () => JSX.Element;
81
+ name: string;
82
+ parameters: {
83
+ docs: {
84
+ description: {
85
+ story: string;
86
+ };
87
+ };
88
+ };
89
+ };
90
+ export declare const CustomIcon: {
91
+ render: () => JSX.Element;
92
+ name: string;
93
+ parameters: {
94
+ docs: {
95
+ description: {
96
+ story: string;
97
+ };
98
+ };
99
+ };
100
+ };
101
+ export declare const WithCompact: {
102
+ render: () => JSX.Element;
103
+ name: string;
104
+ parameters: {
105
+ docs: {
106
+ description: {
107
+ story: string;
108
+ };
109
+ };
110
+ };
111
+ };
112
+ export declare const LoadingState: {
113
+ render: () => JSX.Element;
114
+ parameters: {
115
+ docs: {
116
+ description: {
117
+ story: string;
118
+ };
119
+ };
120
+ };
121
+ };
122
+ export declare const HtmlContentExample: {
123
+ render: () => JSX.Element;
124
+ name: string;
125
+ parameters: {
126
+ docs: {
127
+ description: {
128
+ story: string;
129
+ };
130
+ };
131
+ };
132
+ };
133
+ export declare const UsageGuide: {
134
+ render: () => JSX.Element;
135
+ parameters: {
136
+ docs: {
137
+ source: {
138
+ code: never[];
139
+ };
140
+ };
141
+ };
142
+ };
@@ -204,28 +204,7 @@ export const WithType = {
204
204
  đến quản lý và hiển thị tin đăng, chúng tôi sẽ cập nhật thông tin ngay khi hoàn thành. Xin
205
205
  lỗi Quý khách vì sự bất tiện này!
206
206
  </Announcer>
207
- <br />
208
- <p>type=&quot;time&quot;</p>
209
- <Announcer
210
- type="time"
211
- title="Tin của bạn đang được duyệt"
212
- open
213
- onButtonClick={onActionBtnClick}
214
- >
215
- Bạn có thể cập nhật thông báo tình trạng tin đăng tại mục Quản lý tin đăng
216
- </Announcer>
217
- <br />
218
- <p>type=&quot;gift&quot;</p>
219
- <Announcer
220
- type="gift"
221
- title="Chương trình giảm giá đặc biệt"
222
- btnLabel="Mua dịch vụ"
223
- open
224
- onButtonClick={onActionBtnClick}
225
- >
226
- Bán nhanh hơn với dịch vụ đẩy tin của Chợ Tốt. Chương trình khuyến mãi chỉ dành cho người
227
- dùng nhận được thông báo này.
228
- </Announcer>
207
+
229
208
  <br />
230
209
  <p>type=&quot;warning&quot;</p>
231
210
  <Announcer
@@ -265,7 +244,13 @@ export const WithType = {
265
244
  </Announcer>
266
245
  <br />
267
246
  <p>type=&quot;neutral&quot;</p>
268
- <Announcer type="neutral" open>
247
+ <Announcer
248
+ type="neutral"
249
+ title="Cửa hàng điện tử đã hết hạn"
250
+ btnLabel="Gia hạn cửa hàng"
251
+ open
252
+ onButtonClick={onActionBtnClick}
253
+ >
269
254
  Cửa hàng Điện tử của bạn đã hết hạn. Để tiếp tục việc kinh doanh, gia hạn Cửa hàng ngay bạn
270
255
  nhé.
271
256
  </Announcer>
@@ -315,14 +300,6 @@ export const WithCompact = {
315
300
  Info
316
301
  </Announcer>
317
302
  <br />
318
- <Announcer type="time" compact open>
319
- Time
320
- </Announcer>
321
- <br />
322
- <Announcer type="gift" compact open>
323
- Gift
324
- </Announcer>
325
- <br />
326
303
  <Announcer type="warning" compact open>
327
304
  Warning
328
305
  </Announcer>
@@ -334,6 +311,10 @@ export const WithCompact = {
334
311
  <Announcer type="error" compact open>
335
312
  Error
336
313
  </Announcer>
314
+ <br />
315
+ <Announcer type="neutral" compact open>
316
+ Neutral
317
+ </Announcer>
337
318
  </>
338
319
  ),
339
320
 
@@ -349,6 +330,30 @@ export const WithCompact = {
349
330
  },
350
331
  };
351
332
 
333
+ export const LoadingState = {
334
+ render: (/* args */) => (
335
+ <div>
336
+ <Announcer
337
+ type="error"
338
+ title="Cửa hàng điện tử đã hết hạn"
339
+ btnLabel="Gia hạn cửa hàng"
340
+ open
341
+ isLoading
342
+ >
343
+ Loading
344
+ </Announcer>
345
+ </div>
346
+ ),
347
+
348
+ parameters: {
349
+ docs: {
350
+ description: {
351
+ story: 'Use `isLoading` prop to show skeleton loader',
352
+ },
353
+ },
354
+ },
355
+ };
356
+
352
357
  export const HtmlContentExample = {
353
358
  render: () => (
354
359
  <>
@@ -1,17 +1,29 @@
1
- export const typeIconClass: import("@linaria/core").LinariaClassName;
2
- export const StyledAnnouncer: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
3
- as?: import("react").ElementType<any> | undefined;
1
+ declare const typeIconClass: import("@linaria/core").LinariaClassName;
2
+ declare const lineLimitClass: import("@linaria/core").LinariaClassName;
3
+ declare const ChildrenWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
4
+ as?: import("react").ElementType;
4
5
  }>;
5
- export const lineLimitClass: import("@linaria/core").LinariaClassName;
6
- export const ExpandButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
7
- as?: import("react").ElementType<any> | undefined;
6
+ declare const StyledAnnouncer: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
7
+ as?: import("react").ElementType;
8
8
  }>;
9
- export const ActionButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
10
- as?: import("react").ElementType<any> | undefined;
9
+ declare const ExpandButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
10
+ as?: import("react").ElementType;
11
11
  }>;
12
- export const CloseButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
13
- as?: import("react").ElementType<any> | undefined;
12
+ declare const ActionButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
13
+ as?: import("react").ElementType;
14
14
  }>;
15
- export const ChildrenWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
16
- as?: import("react").ElementType<any> | undefined;
15
+ declare const CloseButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
16
+ as?: import("react").ElementType;
17
17
  }>;
18
+ declare const Skeleton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
19
+ width: string;
20
+ height: string;
21
+ radius?: string;
22
+ margin?: string;
23
+ } & {
24
+ as?: import("react").ElementType;
25
+ }>;
26
+ declare const SkeletonWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
27
+ as?: import("react").ElementType;
28
+ }>;
29
+ export { typeIconClass, StyledAnnouncer, lineLimitClass, ExpandButton, ActionButton, CloseButton, ChildrenWrapper, Skeleton, SkeletonWrapper, };
@@ -22,6 +22,18 @@ const typeIconClass = css`
22
22
  &.error {
23
23
  color: ${colors.iconError};
24
24
  }
25
+
26
+ &.neutral {
27
+ color: ${colors.iconTertiary};
28
+ }
29
+
30
+ &.info {
31
+ color: ${colors.iconInfo};
32
+ }
33
+
34
+ @media ${mediaQueries.tablet} {
35
+ left: 20px;
36
+ }
25
37
  `;
26
38
 
27
39
  /* limit description to 2 lines */
@@ -52,7 +64,7 @@ const ChildrenWrapper = styled.div`
52
64
 
53
65
  const StyledAnnouncer = styled.div`
54
66
  position: relative;
55
- padding: ${space.md} ${space.md} ${space.md} ${space.xxl};
67
+ padding: ${space.sm} ${space.xxl} ${space.sm} 44px;
56
68
  border-radius: ${radii.sm};
57
69
  text-align: right;
58
70
  background-color: ${colors.backgroundInfoLight};
@@ -69,6 +81,10 @@ const StyledAnnouncer = styled.div`
69
81
  background-color: ${colors.backgroundErrorLight};
70
82
  }
71
83
 
84
+ &.neutral {
85
+ background-color: ${colors.backgroundSecondary};
86
+ }
87
+
72
88
  & > * {
73
89
  text-align: left;
74
90
  }
@@ -102,21 +118,8 @@ const StyledAnnouncer = styled.div`
102
118
  margin-bottom: 0;
103
119
  }
104
120
 
105
- &.neutral {
106
- background-color: ${colors.backgroundSecondary};
107
- color: ${colors.textTertiary};
108
-
109
- svg {
110
- color: ${colors.iconTertiary};
111
- }
112
-
113
- h6 {
114
- color: ${colors.textTertiary};
115
- }
116
- }
117
-
118
121
  @media ${mediaQueries.tablet} {
119
- padding-right: ${space.xl};
122
+ padding: ${space.md} ${space.xxl} ${space.md} ${space.xxl};
120
123
 
121
124
  & > h6 {
122
125
  margin-right: 0;
@@ -163,7 +166,6 @@ const ActionButton = styled.button`
163
166
  font-weight: bold;
164
167
  font-size: ${fontSizes.xs};
165
168
  line-height: 16px;
166
- text-transform: uppercase;
167
169
  color: ${colors.textInfo};
168
170
 
169
171
  &.warning {
@@ -181,8 +183,8 @@ const ActionButton = styled.button`
181
183
 
182
184
  const CloseButton = styled.button`
183
185
  position: absolute;
184
- top: ${space.sm};
185
- right: ${space.sm};
186
+ top: ${space.md};
187
+ right: ${space.md};
186
188
  /* increase hit box */
187
189
  padding: ${space.xs};
188
190
  margin: -${space.xs};
@@ -195,6 +197,27 @@ const CloseButton = styled.button`
195
197
  }
196
198
  `;
197
199
 
200
+ const Skeleton = styled.div<{ width: string; height: string; radius?: string; margin?: string }>`
201
+ width: ${({ width }) => width};
202
+ height: ${({ height }) => height};
203
+ border-radius: ${({ radius }) => radius || radii.sm};
204
+ background-color: ${colors.gray75};
205
+ content: '';
206
+ margin: ${({ margin }) => margin || 0};
207
+ `;
208
+
209
+ const SkeletonWrapper = styled.div`
210
+ content: '';
211
+ background-color: ${colors.gray50};
212
+ display: flex;
213
+ flex-direction: row;
214
+ gap: ${space.xs};
215
+ justify-content: space-between;
216
+ padding: ${space.md};
217
+ border-radius: ${radii.md};
218
+ min-height: 108px;
219
+ `;
220
+
198
221
  export {
199
222
  typeIconClass,
200
223
  StyledAnnouncer,
@@ -203,4 +226,6 @@ export {
203
226
  ActionButton,
204
227
  CloseButton,
205
228
  ChildrenWrapper,
229
+ Skeleton,
230
+ SkeletonWrapper,
206
231
  };
@@ -1,13 +1,5 @@
1
1
  import * as React from 'react';
2
- import {
3
- BellFilled,
4
- CircleCheckFilled,
5
- InfoFilled,
6
- WarningFilled,
7
- GiftFilled,
8
- Close,
9
- Info,
10
- } from '../../icons';
2
+ import { CircleCheckFilled, InfoFilled, WarningFilled, Close } from '../../icons';
11
3
  import {
12
4
  typeIconClass,
13
5
  StyledAnnouncer,
@@ -16,6 +8,8 @@ import {
16
8
  ActionButton,
17
9
  CloseButton,
18
10
  ChildrenWrapper,
11
+ SkeletonWrapper,
12
+ Skeleton,
19
13
  } from './Announcer.styles';
20
14
  import { cleanHtml, cx, noop } from '../../utils';
21
15
 
@@ -25,7 +19,7 @@ import { cleanHtml, cx, noop } from '../../utils';
25
19
  * `✅ Stable`
26
20
  *
27
21
  */
28
- export type AnnouncerProps = {
22
+ export interface AnnouncerProps {
29
23
  open?: boolean;
30
24
  /**
31
25
  * Callback when close icon is clicked. Normally, it is used to update `open` prop to close the Announcer.
@@ -35,7 +29,7 @@ export type AnnouncerProps = {
35
29
  /**
36
30
  * Callback when Announcer action button is clicked
37
31
  */
38
- onButtonClick?: () => void;
32
+ onButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
39
33
  /**
40
34
  * Announcer title
41
35
  */
@@ -46,8 +40,9 @@ export type AnnouncerProps = {
46
40
  children?: React.ReactNode;
47
41
  /**
48
42
  * Announcer type
43
+ * @default 'info'
49
44
  */
50
- type?: 'error' | 'gift' | 'info' | 'neutral' | 'success' | 'time' | 'warning';
45
+ type?: 'info' | 'warning' | 'success' | 'error' | 'neutral';
51
46
  /**
52
47
  * Turn Announcer to single line. Useful for short announcement. `compact` does not have effect on Announcer with type=`neutral`.
53
48
  */
@@ -64,7 +59,11 @@ export type AnnouncerProps = {
64
59
  * Custom icon
65
60
  */
66
61
  icon?: React.ReactElement;
67
- };
62
+ /**
63
+ * Displays a skeleton loader
64
+ */
65
+ isLoading?: boolean;
66
+ }
68
67
 
69
68
  const Announcer: React.FC<AnnouncerProps> = ({
70
69
  open = false,
@@ -77,6 +76,7 @@ const Announcer: React.FC<AnnouncerProps> = ({
77
76
  compact = false,
78
77
  dangerousHtml,
79
78
  icon,
79
+ isLoading = false,
80
80
  }) => {
81
81
  const { useState, useEffect, useRef } = React;
82
82
  const ref = useRef<HTMLDivElement>(null);
@@ -95,12 +95,13 @@ const Announcer: React.FC<AnnouncerProps> = ({
95
95
  const iconClass = cx(typeIconClass, type);
96
96
  const announcerIcon =
97
97
  (type === 'info' && <InfoFilled className={iconClass} />) ||
98
- (type === 'time' && <BellFilled className={iconClass} />) ||
99
- (type === 'gift' && <GiftFilled className={iconClass} />) ||
98
+ (type === 'neutral' && <InfoFilled className={iconClass} />) ||
99
+ // (type === 'time' && <BellFilled className={iconClass} />) ||
100
+ // (type === 'gift' && <GiftFilled className={iconClass} />) ||
100
101
  (type === 'warning' && <WarningFilled className={iconClass} />) ||
101
102
  (type === 'success' && <CircleCheckFilled className={iconClass} />) ||
102
- (type === 'error' && <WarningFilled className={iconClass} />) ||
103
- (type === 'neutral' && <Info className={iconClass} />);
103
+ (type === 'error' && <WarningFilled className={iconClass} />);
104
+ // || (type === 'neutral' && <Info className={iconClass} />
104
105
 
105
106
  let announcerHtml;
106
107
  if (typeof dangerousHtml === 'string' && dangerousHtml.trim()) {
@@ -114,37 +115,51 @@ const Announcer: React.FC<AnnouncerProps> = ({
114
115
  }
115
116
  const iconWithClassName = icon ? React.cloneElement(icon, { className: iconClass }) : null;
116
117
 
117
- return (
118
- <StyledAnnouncer className={cx(type, compact && 'compact', !withButton && 'no-button')}>
119
- {iconWithClassName ? iconWithClassName : announcerIcon}
120
- {!compact && !!withTitle && <h6>{title}</h6>}
121
- <ChildrenWrapper
122
- className={limit ? lineLimitClass : ''}
123
- ref={ref}
124
- dangerouslySetInnerHTML={announcerHtml}
125
- >
126
- {!announcerHtml ? children : null}
127
- </ChildrenWrapper>
128
- {!!limit && (
129
- <ExpandButton
130
- onClick={() => {
131
- setLimit(false);
132
- }}
118
+ if (!isLoading) {
119
+ return (
120
+ <StyledAnnouncer className={cx(type, compact && 'compact', !withButton && 'no-button')}>
121
+ {iconWithClassName ? iconWithClassName : announcerIcon}
122
+ {!compact && !!withTitle && <h6>{title}</h6>}
123
+ <ChildrenWrapper
124
+ className={limit ? lineLimitClass : ''}
125
+ ref={ref}
126
+ dangerouslySetInnerHTML={announcerHtml}
133
127
  >
134
- Xem thêm
135
- </ExpandButton>
136
- )}
137
- {typeof onClose === 'function' && (
138
- <CloseButton type="button" onClick={onClose}>
139
- <Close width="24px" height="24px" />
140
- </CloseButton>
141
- )}
142
- {!compact && !!withButton && (
143
- <ActionButton type="button" className={type} onClick={onButtonClick}>
144
- {btnLabel}
145
- </ActionButton>
146
- )}
147
- </StyledAnnouncer>
128
+ {!announcerHtml ? children : null}
129
+ </ChildrenWrapper>
130
+ {!!limit && (
131
+ <ExpandButton
132
+ onClick={() => {
133
+ setLimit(false);
134
+ }}
135
+ >
136
+ Xem thêm
137
+ </ExpandButton>
138
+ )}
139
+ {typeof onClose === 'function' && (
140
+ <CloseButton type="button" onClick={onClose}>
141
+ <Close width="24px" height="24px" />
142
+ </CloseButton>
143
+ )}
144
+ {!compact && !!withButton && (
145
+ <ActionButton type="button" className={type} onClick={onButtonClick}>
146
+ {btnLabel}
147
+ </ActionButton>
148
+ )}
149
+ </StyledAnnouncer>
150
+ );
151
+ }
152
+ return (
153
+ <SkeletonWrapper>
154
+ <Skeleton width="20px" height="20px" radius="100%" />
155
+ <div style={{ width: '70%' }}>
156
+ <Skeleton width="100%" height="20px" margin="0 0 4px 0" />
157
+ <Skeleton width="70%" height="20px" />
158
+ </div>
159
+ <div style={{ width: '25%', display: 'flex', alignItems: 'flex-end' }}>
160
+ <Skeleton width="100%" height="20px" />
161
+ </div>
162
+ </SkeletonWrapper>
148
163
  );
149
164
  };
150
165
 
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export type BadgeProps = {
2
+ export interface BadgeProps {
3
3
  /**
4
4
  * Size of Badge
5
5
  */
@@ -28,8 +28,10 @@ export type BadgeProps = {
28
28
  * z-index
29
29
  */
30
30
  zIndex?: number;
31
- };
31
+ }
32
32
  /**
33
+ * Badge Component for menus and notifications
34
+ *
33
35
  * `✅ Stable`
34
36
  */
35
37
  declare const Badge: React.FC<BadgeProps>;