@qoretechnologies/reqore 0.36.0 → 0.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/__tests__/collection.test.tsx +1 -22
  2. package/__tests__/table.test.tsx +1 -1
  3. package/__tests__/tree.test.tsx +0 -18
  4. package/dist/components/Breadcrumbs/index.js +1 -1
  5. package/dist/components/Breadcrumbs/index.js.map +1 -1
  6. package/dist/components/Button/index.d.ts +1 -4
  7. package/dist/components/Button/index.d.ts.map +1 -1
  8. package/dist/components/Button/index.js +11 -26
  9. package/dist/components/Button/index.js.map +1 -1
  10. package/dist/components/Collection/index.d.ts +2 -2
  11. package/dist/components/Collection/index.d.ts.map +1 -1
  12. package/dist/components/Collection/index.js +10 -10
  13. package/dist/components/Collection/index.js.map +1 -1
  14. package/dist/components/Collection/item.d.ts +3 -3
  15. package/dist/components/Collection/item.d.ts.map +1 -1
  16. package/dist/components/Collection/item.js.map +1 -1
  17. package/dist/components/Columns/index.d.ts +1 -1
  18. package/dist/components/Columns/index.d.ts.map +1 -1
  19. package/dist/components/Comment/index.d.ts +1 -1
  20. package/dist/components/Comment/index.d.ts.map +1 -1
  21. package/dist/components/CommentFeed/index.d.ts +1 -1
  22. package/dist/components/CommentFeed/index.d.ts.map +1 -1
  23. package/dist/components/ControlGroup/index.d.ts +1 -1
  24. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  25. package/dist/components/Dropdown/index.d.ts +1 -1
  26. package/dist/components/Dropdown/index.d.ts.map +1 -1
  27. package/dist/components/Dropdown/item.d.ts +2 -2
  28. package/dist/components/Dropdown/item.d.ts.map +1 -1
  29. package/dist/components/Dropdown/list.d.ts +1 -1
  30. package/dist/components/Dropdown/list.d.ts.map +1 -1
  31. package/dist/components/Effect/index.d.ts +2 -2
  32. package/dist/components/Effect/index.d.ts.map +1 -1
  33. package/dist/components/ExportModal/index.d.ts +11 -0
  34. package/dist/components/ExportModal/index.d.ts.map +1 -0
  35. package/dist/components/ExportModal/index.js +91 -0
  36. package/dist/components/ExportModal/index.js.map +1 -0
  37. package/dist/components/Header/index.d.ts +7 -7
  38. package/dist/components/Header/index.d.ts.map +1 -1
  39. package/dist/components/InputClearButton/index.d.ts +1 -0
  40. package/dist/components/InputClearButton/index.d.ts.map +1 -1
  41. package/dist/components/InternalPopover/index.js +2 -2
  42. package/dist/components/InternalPopover/index.js.map +1 -1
  43. package/dist/components/KeyValueTable/index.d.ts +7 -4
  44. package/dist/components/KeyValueTable/index.d.ts.map +1 -1
  45. package/dist/components/KeyValueTable/index.js +32 -2
  46. package/dist/components/KeyValueTable/index.js.map +1 -1
  47. package/dist/components/Layout/content.d.ts +1 -1
  48. package/dist/components/Layout/content.d.ts.map +1 -1
  49. package/dist/components/Layout/index.d.ts +1 -1
  50. package/dist/components/Layout/index.d.ts.map +1 -1
  51. package/dist/components/Menu/item.d.ts +1 -1
  52. package/dist/components/Menu/item.d.ts.map +1 -1
  53. package/dist/components/Menu/item.js +3 -3
  54. package/dist/components/Menu/item.js.map +1 -1
  55. package/dist/components/Message/index.d.ts +1 -0
  56. package/dist/components/Message/index.d.ts.map +1 -1
  57. package/dist/components/Message/index.js.map +1 -1
  58. package/dist/components/Modal/index.d.ts +1 -1
  59. package/dist/components/Modal/index.d.ts.map +1 -1
  60. package/dist/components/MultiSelect/index.d.ts +2 -2
  61. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  62. package/dist/components/Notifications/notification.d.ts +1 -0
  63. package/dist/components/Notifications/notification.d.ts.map +1 -1
  64. package/dist/components/Notifications/notification.js +23 -16
  65. package/dist/components/Notifications/notification.js.map +1 -1
  66. package/dist/components/Paging/index.d.ts +1 -1
  67. package/dist/components/Paging/index.d.ts.map +1 -1
  68. package/dist/components/Panel/NonResponsiveActions.d.ts +1 -1
  69. package/dist/components/Panel/NonResponsiveActions.d.ts.map +1 -1
  70. package/dist/components/Panel/index.js +1 -1
  71. package/dist/components/Panel/index.js.map +1 -1
  72. package/dist/components/Panel/panel.screenshot.d.ts +1 -1
  73. package/dist/components/Panel/panel.screenshot.d.ts.map +1 -1
  74. package/dist/components/Paragraph/index.d.ts +1 -1
  75. package/dist/components/Paragraph/index.d.ts.map +1 -1
  76. package/dist/components/Popover/index.d.ts +1 -1
  77. package/dist/components/Popover/index.d.ts.map +1 -1
  78. package/dist/components/Popover/index.js +2 -0
  79. package/dist/components/Popover/index.js.map +1 -1
  80. package/dist/components/RadioGroup/index.d.ts +1 -1
  81. package/dist/components/RadioGroup/index.d.ts.map +1 -1
  82. package/dist/components/Sidebar/item.d.ts +1 -1
  83. package/dist/components/Sidebar/item.d.ts.map +1 -1
  84. package/dist/components/Spacer/index.d.ts +3 -3
  85. package/dist/components/Spacer/index.d.ts.map +1 -1
  86. package/dist/components/Spinner/index.d.ts +1 -1
  87. package/dist/components/Spinner/index.d.ts.map +1 -1
  88. package/dist/components/Table/body.d.ts +1 -1
  89. package/dist/components/Table/body.d.ts.map +1 -1
  90. package/dist/components/Table/body.js +26 -21
  91. package/dist/components/Table/body.js.map +1 -1
  92. package/dist/components/Table/cell.d.ts +3 -2
  93. package/dist/components/Table/cell.d.ts.map +1 -1
  94. package/dist/components/Table/cell.js +8 -4
  95. package/dist/components/Table/cell.js.map +1 -1
  96. package/dist/components/Table/headerCell.d.ts +1 -1
  97. package/dist/components/Table/headerCell.d.ts.map +1 -1
  98. package/dist/components/Table/helpers.d.ts +8 -6
  99. package/dist/components/Table/helpers.d.ts.map +1 -1
  100. package/dist/components/Table/helpers.js +49 -16
  101. package/dist/components/Table/helpers.js.map +1 -1
  102. package/dist/components/Table/index.d.ts +5 -4
  103. package/dist/components/Table/index.d.ts.map +1 -1
  104. package/dist/components/Table/index.js +47 -38
  105. package/dist/components/Table/index.js.map +1 -1
  106. package/dist/components/Table/row.d.ts +7 -5
  107. package/dist/components/Table/row.d.ts.map +1 -1
  108. package/dist/components/Table/row.js +38 -36
  109. package/dist/components/Table/row.js.map +1 -1
  110. package/dist/components/Table/value.d.ts +1 -1
  111. package/dist/components/Table/value.d.ts.map +1 -1
  112. package/dist/components/Tabs/content.d.ts +1 -1
  113. package/dist/components/Tabs/content.d.ts.map +1 -1
  114. package/dist/components/Tabs/index.d.ts +1 -1
  115. package/dist/components/Tabs/index.d.ts.map +1 -1
  116. package/dist/components/Tabs/list.d.ts +1 -1
  117. package/dist/components/Tabs/list.d.ts.map +1 -1
  118. package/dist/components/Tabs/list.js +1 -1
  119. package/dist/components/Tabs/list.js.map +1 -1
  120. package/dist/components/Tag/group.d.ts +1 -1
  121. package/dist/components/Tag/group.d.ts.map +1 -1
  122. package/dist/components/Tree/index.d.ts +2 -1
  123. package/dist/components/Tree/index.d.ts.map +1 -1
  124. package/dist/components/Tree/index.js +35 -31
  125. package/dist/components/Tree/index.js.map +1 -1
  126. package/dist/constants/sizes.js +5 -5
  127. package/dist/containers/Paging.d.ts +1 -1
  128. package/dist/containers/Paging.d.ts.map +1 -1
  129. package/dist/containers/ThemeProvider.d.ts +1 -1
  130. package/dist/containers/ThemeProvider.d.ts.map +1 -1
  131. package/dist/helpers/utils.d.ts +2 -1
  132. package/dist/helpers/utils.d.ts.map +1 -1
  133. package/dist/helpers/utils.js +20 -2
  134. package/dist/helpers/utils.js.map +1 -1
  135. package/dist/hooks/useAutoFocus.d.ts +1 -1
  136. package/dist/hooks/useAutoFocus.d.ts.map +1 -1
  137. package/dist/hooks/usePopover.d.ts +1 -0
  138. package/dist/hooks/usePopover.d.ts.map +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js.map +1 -1
  142. package/dist/styles.d.ts +3 -0
  143. package/dist/styles.d.ts.map +1 -1
  144. package/dist/styles.js +49 -11
  145. package/dist/styles.js.map +1 -1
  146. package/migration-storybook.log +88 -0
  147. package/package.json +26 -20
  148. package/src/components/Breadcrumbs/index.tsx +1 -1
  149. package/src/components/Button/index.tsx +3 -54
  150. package/src/components/Collection/index.tsx +18 -15
  151. package/src/components/Collection/item.tsx +2 -1
  152. package/src/components/ExportModal/index.tsx +98 -0
  153. package/src/components/InternalPopover/index.tsx +2 -2
  154. package/src/components/KeyValueTable/index.tsx +59 -11
  155. package/src/components/Menu/item.tsx +4 -4
  156. package/src/components/Message/index.tsx +1 -0
  157. package/src/components/Notifications/notification.tsx +14 -3
  158. package/src/components/Panel/index.tsx +2 -2
  159. package/src/components/Popover/index.tsx +3 -0
  160. package/src/components/Table/body.tsx +26 -20
  161. package/src/components/Table/cell.tsx +15 -4
  162. package/src/components/Table/helpers.ts +52 -21
  163. package/src/components/Table/index.tsx +119 -75
  164. package/src/components/Table/row.tsx +47 -46
  165. package/src/components/Tabs/list.tsx +1 -1
  166. package/src/components/Tree/index.tsx +82 -75
  167. package/src/constants/sizes.ts +5 -5
  168. package/src/helpers/utils.ts +10 -2
  169. package/src/hooks/useAutoFocus.ts +1 -1
  170. package/src/index.tsx +1 -1
  171. package/src/mock/tableData.ts +12 -0
  172. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +11 -23
  173. package/src/stories/Button/Button.stories.tsx +83 -47
  174. package/src/stories/Checkbox/Checkbox.stories.tsx +19 -9
  175. package/src/stories/Collection/Collection.stories.tsx +195 -171
  176. package/src/stories/Columns/Columns.stories.tsx +38 -24
  177. package/src/stories/Comment/Comment.stories.tsx +15 -6
  178. package/src/stories/ControlGroup/ControlGroup.stories.tsx +102 -48
  179. package/src/stories/Drawer/Drawer.stories.tsx +52 -17
  180. package/src/stories/Dropdown/Dropdown.stories.tsx +184 -152
  181. package/src/stories/ExportModal/ExportModal.stories.tsx +18 -0
  182. package/src/stories/Header/Header.stories.tsx +65 -31
  183. package/src/stories/Icon/Icon.stories.tsx +139 -133
  184. package/src/stories/Input/Input.stories.tsx +68 -31
  185. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +183 -117
  186. package/src/stories/Menu/Menu.stories.tsx +56 -20
  187. package/src/stories/Message/Message.stories.tsx +96 -37
  188. package/src/stories/Modal/Modal.stories.tsx +28 -8
  189. package/src/stories/MultiSelect/MultiSelect.stories.tsx +66 -35
  190. package/src/stories/Navbar/Navbar.stories.tsx +15 -5
  191. package/src/stories/Notifications/Interactive.stories.tsx +40 -28
  192. package/src/stories/Notifications/Notification.stories.tsx +55 -41
  193. package/src/stories/Notifications/Notifications.stories.tsx +45 -29
  194. package/src/stories/Paging/Paging.stories.tsx +206 -177
  195. package/src/stories/Panel/Panel.stories.tsx +238 -168
  196. package/src/stories/Paragraph/Paragraph.stories.tsx +66 -31
  197. package/src/stories/Popover/Popover.stories.tsx +62 -40
  198. package/src/stories/RadioGroup/RadioGroup.stories.tsx +41 -19
  199. package/src/stories/Sidebar/Sidebar.stories.tsx +29 -10
  200. package/src/stories/Spacer/Spacer.stories.tsx +13 -5
  201. package/src/stories/Spinner/Spinner.stories.tsx +26 -12
  202. package/src/stories/Table/Table.stories.tsx +200 -144
  203. package/src/stories/Table/Tests.stories.tsx +9 -0
  204. package/src/stories/Tabs/Tabs.stories.tsx +82 -46
  205. package/src/stories/Tag/Tag.stories.tsx +56 -37
  206. package/src/stories/Tag/TagGroup.stories.tsx +297 -0
  207. package/src/stories/TextArea/TextArea.stories.tsx +82 -40
  208. package/src/stories/Tree/Tree.stories.tsx +84 -22
  209. package/src/stories/utils.ts +22 -1
  210. package/src/styles.ts +55 -2
  211. package/tests.json +1 -1
@@ -1,14 +1,15 @@
1
1
  import { cloneDeep, size as lodashSize } from 'lodash';
2
- import { useState } from 'react';
2
+ import { useMemo, useState } from 'react';
3
3
  import styled from 'styled-components';
4
- import { ReqoreMessage, ReqorePanel, ReqoreTextarea, useReqoreProperty } from '../..';
4
+ import { ReqoreMessage, ReqorePanel, useReqoreProperty } from '../..';
5
5
  import { IReqoreTheme } from '../../constants/theme';
6
6
  import { getTypeFromValue } from '../../helpers/utils';
7
7
  import { IWithReqoreSize } from '../../types/global';
8
8
  import ReqoreButton from '../Button';
9
9
  import ReqoreControlGroup from '../ControlGroup';
10
- import { IReqorePanelProps } from '../Panel';
11
- import { getZoomActions, sizeToZoom, zoomToSize } from '../Table/helpers';
10
+ import { ReqoreExportModal } from '../ExportModal';
11
+ import { IReqorePanelAction, IReqorePanelProps } from '../Panel';
12
+ import { getExportActions, getZoomActions, sizeToZoom, zoomToSize } from '../Table/helpers';
12
13
  import ReqoreTag from '../Tag';
13
14
 
14
15
  export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
@@ -20,6 +21,7 @@ export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
20
21
  withLabelCopy?: boolean;
21
22
  showControls?: boolean;
22
23
  zoomable?: boolean;
24
+ exportable?: boolean;
23
25
  defaultZoom?: 0 | 0.5 | 1 | 1.5 | 2;
24
26
  }
25
27
 
@@ -41,29 +43,23 @@ export const ReqoreTree = ({
41
43
  onItemClick,
42
44
  withLabelCopy,
43
45
  showControls = true,
46
+
47
+ exportable,
44
48
  zoomable,
45
49
  defaultZoom,
46
50
  ...rest
47
51
  }: IReqoreTreeProps) => {
48
- const [_mode, setMode] = useState<'tree' | 'copy'>(mode);
49
52
  const [items, setItems] = useState({});
50
53
  const [allExpanded, setAllExpanded] = useState(expanded || !showControls);
51
54
  const [_showTypes, setShowTypes] = useState(showTypes);
52
55
  const addNotification = useReqoreProperty('addNotification');
53
56
  const [zoom, setZoom] = useState(defaultZoom || sizeToZoom[size]);
54
-
55
- const handleCopyClick = () => {
56
- setMode('copy');
57
- };
57
+ const [showExportModal, setShowExportModal] = useState<'full' | 'current' | undefined>(undefined);
58
58
 
59
59
  const handleTypesClick = () => {
60
60
  setShowTypes(!_showTypes);
61
61
  };
62
62
 
63
- const handleTreeClick = () => {
64
- setMode('tree');
65
- };
66
-
67
63
  const handleExpandClick = () => {
68
64
  setItems({});
69
65
  setAllExpanded(true);
@@ -173,73 +169,84 @@ export const ReqoreTree = ({
173
169
  return text;
174
170
  };
175
171
 
172
+ const actions = useMemo(() => {
173
+ let _actions: IReqorePanelAction[] = [];
174
+
175
+ if (showControls) {
176
+ _actions = [
177
+ {
178
+ className: 'reqore-tree-expand-all',
179
+ icon: 'ArrowDownFill',
180
+ onClick: handleExpandClick,
181
+ show: !!(isDeep() && !allExpanded),
182
+ label: 'Expand all',
183
+ },
184
+ {
185
+ show: !!(isDeep() && (allExpanded || lodashSize(items) > 0)),
186
+ className: 'reqore-tree-collapse-all',
187
+ icon: 'ArrowUpFill',
188
+ onClick: handleCollapseClick,
189
+
190
+ label: 'Collapse all',
191
+ },
192
+ {
193
+ className: 'reqore-tree-show-types',
194
+ icon: 'CodeBoxFill',
195
+ active: _showTypes,
196
+ onClick: handleTypesClick,
197
+ label: 'Show types',
198
+ },
199
+ ];
200
+ }
201
+
202
+ if (zoomable || exportable) {
203
+ const moreActions: IReqorePanelAction = {
204
+ className: 'reqore-tree-more',
205
+ icon: 'MoreLine',
206
+ actions: [],
207
+ };
208
+
209
+ if (zoomable) {
210
+ moreActions.actions = [
211
+ ...moreActions.actions,
212
+ ...getZoomActions('reqore-tree', zoom, setZoom, true),
213
+ ];
214
+ }
215
+
216
+ if (exportable) {
217
+ moreActions.actions = [
218
+ ...moreActions.actions,
219
+ { divider: true, line: true },
220
+ ...getExportActions((type) => setShowExportModal(type)),
221
+ ];
222
+ }
223
+
224
+ _actions = [..._actions, moreActions];
225
+ }
226
+
227
+ return _actions;
228
+ }, [allExpanded, items, showControls, _showTypes, isDeep(), zoom]);
229
+
176
230
  if (!data || !Object.keys(data).length) {
177
231
  return <p>No data</p>;
178
232
  }
179
233
 
180
- const textData: string = renderText(data);
181
-
182
234
  return (
183
- <ReqorePanel
184
- className='reqore-tree'
185
- minimal
186
- flat
187
- transparent
188
- size={size}
189
- {...rest}
190
- actions={
191
- showControls
192
- ? [
193
- {
194
- fluid: false,
195
- group: getZoomActions('reqore-tree', zoom, setZoom),
196
- show: !!zoomable,
197
- },
198
- {
199
- className: 'reqore-tree-expand-all',
200
- icon: 'ArrowDownFill',
201
- onClick: handleExpandClick,
202
- show: !!(isDeep() && !allExpanded),
203
- label: 'Expand all',
204
- },
205
- {
206
- show: !!(isDeep() && (allExpanded || lodashSize(items) > 0)),
207
- className: 'reqore-tree-collapse-all',
208
- icon: 'ArrowUpFill',
209
- onClick: handleCollapseClick,
210
-
211
- label: 'Collapse all',
212
- },
213
- {
214
- className: 'reqore-tree-show-types',
215
- icon: 'CodeBoxFill',
216
- active: _showTypes,
217
- onClick: handleTypesClick,
218
- label: 'Show types',
219
- },
220
- {
221
- className: _mode === 'tree' ? 'reqore-tree-as-text' : 'reqore-tree-as-tree',
222
- onClick: _mode === 'tree' ? handleCopyClick : handleTreeClick,
223
- icon: _mode === 'tree' ? 'Menu2Fill' : 'ClipboardFill',
224
- label: _mode === 'tree' ? 'Text View' : 'Tree View',
225
- },
226
- ]
227
- : undefined
228
- }
229
- >
230
- {_mode === 'tree' && renderTree(data, true)}
231
-
232
- {_mode === 'copy' && (
233
- <ReqoreTextarea
234
- className='reqore-tree-textarea'
235
- id='tree-content'
236
- value={textData}
237
- scaleWithContent
238
- size={size}
239
- fluid
240
- readOnly
241
- />
235
+ <>
236
+ {showExportModal && (
237
+ <ReqoreExportModal data={data} onClose={() => setShowExportModal(undefined)} />
242
238
  )}
243
- </ReqorePanel>
239
+ <ReqorePanel
240
+ className='reqore-tree'
241
+ minimal
242
+ flat
243
+ transparent
244
+ size={size}
245
+ {...rest}
246
+ actions={actions}
247
+ >
248
+ {renderTree(data, true)}
249
+ </ReqorePanel>
250
+ </>
244
251
  );
245
252
  };
@@ -110,11 +110,11 @@ export const TEXT_FROM_SIZE = {
110
110
  };
111
111
 
112
112
  export const ICON_FROM_SIZE = {
113
- tiny: 11,
114
- small: 14,
115
- normal: 17,
116
- big: 20,
117
- huge: 23,
113
+ tiny: 13,
114
+ small: 17,
115
+ normal: 20,
116
+ big: 26,
117
+ huge: 33,
118
118
  };
119
119
 
120
120
  export const PADDING_FROM_SIZE = {
@@ -45,14 +45,22 @@ export const getTypeFromValue: Function = (item: any): string => {
45
45
  return 'null';
46
46
  };
47
47
 
48
- export const getLineCount = (value: string): number => {
48
+ export const getLineCount = (value: string | null): number => {
49
49
  try {
50
- return value.match(/[^\n]*\n[^\n]*/gi).length;
50
+ return value?.match(/[^\n]*\n[^\n]*/gi)?.length ?? 0;
51
51
  } catch (e) {
52
52
  return 0;
53
53
  }
54
54
  };
55
55
 
56
+ // A function that takes list of objects and transforms it
57
+ // to a CSV string
58
+ export const convertToCSV = (objArray: any[]): string => {
59
+ const header = Object.keys(objArray[0]).join(',');
60
+ const rows = objArray.map((obj) => Object.values(obj).join(','));
61
+ return [header, ...rows].join('\n');
62
+ };
63
+
56
64
  export const calculateStringSizeInPixels = (value: string = '', fontSize: number): number => {
57
65
  const widths = [
58
66
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -15,7 +15,7 @@ export interface IReqoreAutoFocusRules {
15
15
  export const useAutoFocus = (
16
16
  element: HTMLInputElement | HTMLTextAreaElement,
17
17
  rules?: IReqoreAutoFocusRules,
18
- onChange?: (e: unknown) => void
18
+ onChange?: (event: any) => void
19
19
  ) => {
20
20
  const isInViewport = useRef<boolean>(false);
21
21
  const observer = useRef<IntersectionObserver>(null);
package/src/index.tsx CHANGED
@@ -24,7 +24,7 @@ export {
24
24
  } from './components/Header';
25
25
  export { default as ReqoreIcon } from './components/Icon';
26
26
  export { default as ReqoreInput } from './components/Input';
27
- export { IReqoreKeyValueTableProps, ReqoreKeyValueTable } from './components/KeyValueTable';
27
+ export { ReqoreKeyValueTable } from './components/KeyValueTable';
28
28
  export { default as ReqoreLayoutContent } from './components/Layout/content';
29
29
  export { default as ReqoreMenu } from './components/Menu';
30
30
  export { default as ReqoreMenuDivider } from './components/Menu/divider';
@@ -1,6 +1,18 @@
1
1
  import { IReqoreTableProps } from '../components/Table';
2
2
  import data from './data.json';
3
3
 
4
+ export type TestTableItem = {
5
+ id: number;
6
+ firstName: string;
7
+ lastName: string;
8
+ address: string;
9
+ age: number;
10
+ occupation: string;
11
+ group: string;
12
+ _selectId: number;
13
+ _disabled: boolean;
14
+ };
15
+
4
16
  export const tableData = data;
5
17
  export const testColumns: IReqoreTableProps['columns'] = [
6
18
  {
@@ -1,38 +1,26 @@
1
- import { ComponentMeta, ComponentStory } from '@storybook/react';
2
- import { IReqoreBreadcrumbItem, IReqoreBreadcrumbsProps } from '../../components/Breadcrumbs';
1
+ import { StoryObj } from '@storybook/react';
3
2
  import { ReqoreBreadcrumbs } from '../../index';
4
3
  import breadcrumbs, { breadcrumbsTabs } from '../../mock/breadcrumbs';
5
- import { buildTemplate } from '../utils';
4
+ import { StoryMeta } from '../utils';
6
5
  import { SizeArg } from '../utils/args';
7
6
 
8
- export default {
7
+ const meta = {
9
8
  title: 'Navigation/Breadcrumbs/Stories',
9
+ component: ReqoreBreadcrumbs,
10
10
  argTypes: {
11
11
  withTabs: {
12
12
  name: 'With tabs',
13
- defaultValue: false,
14
13
  description: 'Whether tabs should be shown alongside the breadcrumbs',
15
14
  control: 'boolean',
16
15
  },
17
16
  ...SizeArg,
18
17
  },
19
- } as ComponentMeta<typeof ReqoreBreadcrumbs & { withTabs?: boolean }>;
18
+ args: { items: breadcrumbs },
19
+ } as StoryMeta<typeof ReqoreBreadcrumbs>;
20
20
 
21
- const Template: ComponentStory<typeof ReqoreBreadcrumbs & { withTabs?: boolean }> = (
22
- args: IReqoreBreadcrumbsProps & { withTabs?: boolean }
23
- ) => {
24
- const items = args.withTabs ? [...breadcrumbs, breadcrumbsTabs] : breadcrumbs;
25
- const customTheme = args.customTheme ? { main: args.customTheme } : undefined;
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
26
23
 
27
- return (
28
- <ReqoreBreadcrumbs
29
- {...args}
30
- items={items as IReqoreBreadcrumbItem[]}
31
- customTheme={customTheme as any}
32
- />
33
- );
34
- };
35
-
36
- export const Default = buildTemplate(Template);
37
- export const WithTabs = buildTemplate(Template, { withTabs: true });
38
- export const Flat = buildTemplate(Template, { flat: true });
24
+ export const Default: Story = {};
25
+ export const WithTabs: Story = { args: { items: [...breadcrumbs, breadcrumbsTabs] } };
26
+ export const Flat: Story = { args: { flat: true } };
@@ -1,23 +1,28 @@
1
- import { ComponentMeta, ComponentStory } from '@storybook/react';
1
+ import { StoryFn, StoryObj } from '@storybook/react';
2
2
  import { noop } from 'lodash';
3
3
  import ReqoreButton from '../../components/Button';
4
- import { IReqoreTheme } from '../../constants/theme';
5
4
  import { ReqoreControlGroup } from '../../index';
5
+ import { StoryMeta } from '../utils';
6
6
  import { IconArg, SizeArg } from '../utils/args';
7
7
 
8
- export default {
8
+ const meta = {
9
9
  title: 'Form/Button/Stories',
10
- parameters: {
11
- jest: ['button.test.tsx'],
12
- },
10
+ component: ReqoreButton,
13
11
  argTypes: {
14
12
  ...IconArg('icon', 'Icon'),
15
13
  ...IconArg('rightIcon', 'Right Icon'),
16
14
  ...SizeArg,
17
15
  },
18
- } as ComponentMeta<typeof ReqoreButton>;
16
+ args: {
17
+ icon: '24HoursFill',
18
+ rightIcon: '24HoursFill',
19
+ },
20
+ } as StoryMeta<typeof ReqoreButton>;
19
21
 
20
- const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+
25
+ const Template: StoryFn<typeof ReqoreButton> = (buttonProps) => {
21
26
  return (
22
27
  <ReqoreControlGroup vertical gapSize='big'>
23
28
  <ReqoreControlGroup size={buttonProps.size} wrap>
@@ -246,54 +251,85 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
246
251
  );
247
252
  };
248
253
 
249
- export const Default = Template.bind({});
250
- export const Info = Template.bind({});
251
- Info.args = {
252
- intent: 'info',
254
+ export const Default: Story = {
255
+ render: Template,
253
256
  };
254
- export const Success = Template.bind({});
255
- Success.args = {
256
- intent: 'success',
257
+
258
+ export const Info: Story = {
259
+ render: Template,
260
+
261
+ args: {
262
+ intent: 'info',
263
+ },
257
264
  };
258
- export const Warning = Template.bind({});
259
- Warning.args = {
260
- intent: 'warning',
265
+
266
+ export const Success: Story = {
267
+ render: Template,
268
+
269
+ args: {
270
+ intent: 'success',
271
+ },
272
+ };
273
+
274
+ export const Warning: Story = {
275
+ render: Template,
276
+
277
+ args: {
278
+ intent: 'warning',
279
+ },
261
280
  };
262
- export const Pending = Template.bind({});
263
- Pending.args = {
264
- intent: 'pending',
281
+
282
+ export const Pending: Story = {
283
+ render: Template,
284
+
285
+ args: {
286
+ intent: 'pending',
287
+ },
265
288
  };
266
- export const Danger = Template.bind({});
267
- Danger.args = {
268
- intent: 'danger',
289
+
290
+ export const Danger: Story = {
291
+ render: Template,
292
+
293
+ args: {
294
+ intent: 'danger',
295
+ },
269
296
  };
270
- export const Muted = Template.bind({});
271
- Muted.args = {
272
- intent: 'muted',
297
+
298
+ export const Muted: Story = {
299
+ render: Template,
300
+
301
+ args: {
302
+ intent: 'muted',
303
+ },
273
304
  };
274
- export const Effect: ComponentStory<typeof ReqoreButton> = Template.bind({});
275
- Effect.args = {
276
- effect: {
277
- gradient: {
278
- direction: 'to right bottom',
279
- colors: { 0: '#33023c', 100: '#0a487b' },
280
- animate: 'active',
305
+
306
+ export const Effect: Story = {
307
+ render: Template,
308
+
309
+ args: {
310
+ effect: {
311
+ gradient: {
312
+ direction: 'to right bottom',
313
+ colors: { 0: '#33023c', 100: '#0a487b' },
314
+ animate: 'active',
315
+ },
316
+ spaced: 2,
317
+ uppercase: true,
318
+ weight: 'thick',
319
+ textSize: 'small',
281
320
  },
282
- spaced: 2,
283
- uppercase: true,
284
- weight: 'thick',
285
- textSize: 'small',
286
321
  },
287
322
  };
288
323
 
289
- export const GlobalEffect: ComponentStory<
290
- typeof ReqoreButton & { otherThemeOptions?: IReqoreTheme }
291
- > = Template.bind({});
292
- GlobalEffect.args = {
293
- otherThemeOptions: {
294
- buttons: {
295
- gradient: true,
296
- animate: 'active',
324
+ export const GlobalEffect: Story = {
325
+ render: Template,
326
+
327
+ args: {
328
+ otherThemeOptions: {
329
+ buttons: {
330
+ gradient: true,
331
+ animate: 'active',
332
+ },
297
333
  },
298
334
  },
299
- } as any;
335
+ };
@@ -1,13 +1,17 @@
1
- import { ComponentMeta, ComponentStory } from '@storybook/react';
1
+ import { StoryFn, StoryObj } from '@storybook/react';
2
2
  import Checkbox from '../../components/Checkbox';
3
3
  import { ReqoreCheckbox, ReqoreControlGroup, ReqoreVerticalSpacer } from '../../index';
4
+ import { StoryMeta } from '../utils';
4
5
 
5
- export default {
6
+ const meta = {
6
7
  title: 'Form/Checkbox/Stories',
7
- parameters: ['checkbox.test.tsx'],
8
- } as ComponentMeta<typeof Checkbox>;
8
+ component: ReqoreCheckbox,
9
+ } as StoryMeta<typeof ReqoreCheckbox>;
9
10
 
10
- const Template: ComponentStory<typeof Checkbox> = (args) => {
11
+ export default meta;
12
+ type Story = StoryObj<typeof meta>;
13
+
14
+ const Template: StoryFn<typeof Checkbox> = (args) => {
11
15
  return (
12
16
  <ReqoreControlGroup vertical>
13
17
  <ReqoreControlGroup wrap>
@@ -58,8 +62,14 @@ const Template: ComponentStory<typeof Checkbox> = (args) => {
58
62
  );
59
63
  };
60
64
 
61
- export const Basic = Template.bind({});
62
- export const Switch = Template.bind({});
63
- Switch.args = {
64
- asSwitch: true,
65
+ export const Basic: Story = {
66
+ render: Template,
67
+ };
68
+
69
+ export const Switch: Story = {
70
+ render: Template,
71
+
72
+ args: {
73
+ asSwitch: true,
74
+ },
65
75
  };