@qoretechnologies/reqore 0.32.3 → 0.33.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.
Files changed (92) hide show
  1. package/__tests__/collection.test.tsx +123 -5
  2. package/__tests__/hooks/useLatestZIndex.test.tsx +10 -0
  3. package/__tests__/hooks/useReqorePaging.test.tsx +251 -0
  4. package/__tests__/hooks/useTheme.test.tsx +31 -0
  5. package/__tests__/pagination.test.tsx +301 -0
  6. package/__tests__/popover.test.tsx +20 -6
  7. package/__tests__/setup.js +8 -0
  8. package/__tests__/tree.test.tsx +0 -1
  9. package/dist/components/Button/index.d.ts +1 -0
  10. package/dist/components/Button/index.d.ts.map +1 -1
  11. package/dist/components/Button/index.js +11 -7
  12. package/dist/components/Button/index.js.map +1 -1
  13. package/dist/components/Collection/index.d.ts +9 -3
  14. package/dist/components/Collection/index.d.ts.map +1 -1
  15. package/dist/components/Collection/index.js +34 -8
  16. package/dist/components/Collection/index.js.map +1 -1
  17. package/dist/components/Dropdown/index.d.ts +5 -2
  18. package/dist/components/Dropdown/index.d.ts.map +1 -1
  19. package/dist/components/Dropdown/index.js +2 -2
  20. package/dist/components/Dropdown/index.js.map +1 -1
  21. package/dist/components/Dropdown/list.d.ts +4 -1
  22. package/dist/components/Dropdown/list.d.ts.map +1 -1
  23. package/dist/components/Dropdown/list.js +3 -3
  24. package/dist/components/Dropdown/list.js.map +1 -1
  25. package/dist/components/Menu/item.d.ts +1 -0
  26. package/dist/components/Menu/item.d.ts.map +1 -1
  27. package/dist/components/Menu/item.js +14 -2
  28. package/dist/components/Menu/item.js.map +1 -1
  29. package/dist/components/MultiSelect/index.d.ts +1 -1
  30. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  31. package/dist/components/Paging/index.d.ts +30 -0
  32. package/dist/components/Paging/index.d.ts.map +1 -0
  33. package/dist/components/Paging/index.js +106 -0
  34. package/dist/components/Paging/index.js.map +1 -0
  35. package/dist/components/Tag/index.d.ts +3 -2
  36. package/dist/components/Tag/index.d.ts.map +1 -1
  37. package/dist/components/Tag/index.js +10 -7
  38. package/dist/components/Tag/index.js.map +1 -1
  39. package/dist/constants/colors.d.ts +2 -9
  40. package/dist/constants/colors.d.ts.map +1 -1
  41. package/dist/constants/colors.js +3 -1
  42. package/dist/constants/colors.js.map +1 -1
  43. package/dist/constants/paging.d.ts +10 -0
  44. package/dist/constants/paging.d.ts.map +1 -0
  45. package/dist/constants/paging.js +41 -0
  46. package/dist/constants/paging.js.map +1 -0
  47. package/dist/constants/theme.d.ts.map +1 -1
  48. package/dist/constants/theme.js +8 -7
  49. package/dist/constants/theme.js.map +1 -1
  50. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  51. package/dist/containers/ReqoreProvider.js +2 -2
  52. package/dist/containers/ReqoreProvider.js.map +1 -1
  53. package/dist/containers/UIProvider.d.ts.map +1 -1
  54. package/dist/containers/UIProvider.js +9 -3
  55. package/dist/containers/UIProvider.js.map +1 -1
  56. package/dist/hooks/useCombinedRefs.d.ts +2 -2
  57. package/dist/hooks/useCombinedRefs.d.ts.map +1 -1
  58. package/dist/hooks/useCombinedRefs.js.map +1 -1
  59. package/dist/hooks/usePaging.d.ts +27 -0
  60. package/dist/hooks/usePaging.d.ts.map +1 -0
  61. package/dist/hooks/usePaging.js +83 -0
  62. package/dist/hooks/usePaging.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +6 -2
  66. package/dist/index.js.map +1 -1
  67. package/package.json +6 -4
  68. package/src/components/Button/index.tsx +18 -10
  69. package/src/components/Collection/index.tsx +96 -44
  70. package/src/components/ControlGroup/index.tsx +1 -1
  71. package/src/components/Dropdown/index.tsx +8 -2
  72. package/src/components/Dropdown/list.tsx +7 -1
  73. package/src/components/Menu/item.tsx +16 -2
  74. package/src/components/MultiSelect/index.tsx +1 -1
  75. package/src/components/Paging/index.tsx +232 -0
  76. package/src/components/Tag/index.tsx +9 -7
  77. package/src/constants/colors.ts +5 -1
  78. package/src/constants/paging.ts +48 -0
  79. package/src/constants/theme.ts +8 -7
  80. package/src/containers/ReqoreProvider.tsx +3 -3
  81. package/src/containers/UIProvider.tsx +17 -4
  82. package/src/hooks/useCombinedRefs.ts +2 -2
  83. package/src/hooks/usePaging.ts +110 -0
  84. package/src/index.tsx +2 -0
  85. package/src/mock/collectionData.tsx +19 -0
  86. package/src/mock/tableData.ts +1 -0
  87. package/src/stories/Button/Button.stories.tsx +25 -8
  88. package/src/stories/Collection/Collection.stories.tsx +32 -42
  89. package/src/stories/Dropdown/Dropdown.stories.tsx +24 -1
  90. package/src/stories/Paging/Paging.stories.tsx +184 -0
  91. package/src/stories/Tag/Tag.stories.tsx +50 -0
  92. package/tests.json +1 -1
@@ -19,7 +19,7 @@ export default {
19
19
 
20
20
  const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
21
21
  return (
22
- <>
22
+ <ReqoreControlGroup vertical gapSize='big'>
23
23
  <ReqoreControlGroup size={buttonProps.size} wrap>
24
24
  <ReqoreButton {...buttonProps} icon='BankFill' rightIcon={null} />
25
25
  <ReqoreButton {...buttonProps} />
@@ -27,7 +27,7 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
27
27
  {...buttonProps}
28
28
  icon='BankFill'
29
29
  rightIcon={null}
30
- textAlign='center'
30
+ iconsAlign='center'
31
31
  style={{ width: '100px' }}
32
32
  />
33
33
  <ReqoreButton {...buttonProps}>Default</ReqoreButton>
@@ -47,7 +47,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
47
47
  Read only
48
48
  </ReqoreButton>
49
49
  </ReqoreControlGroup>
50
- <br />
51
50
  <ReqoreControlGroup size={buttonProps.size} wrap>
52
51
  <ReqoreButton {...buttonProps} active flat={false} tooltip='hello'>
53
52
  Active Not Flat
@@ -72,13 +71,33 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
72
71
  Disabled not flat
73
72
  </ReqoreButton>
74
73
  </ReqoreControlGroup>
75
- <br />
76
74
  <ReqoreControlGroup fluid wrap>
77
75
  <ReqoreButton {...buttonProps} fluid>
78
76
  Fluid button
79
77
  </ReqoreButton>
80
78
  </ReqoreControlGroup>
81
- <br />
79
+ <ReqoreControlGroup fluid wrap>
80
+ <ReqoreButton {...buttonProps} fluid textAlign='center'>
81
+ Fluid button with centered text
82
+ </ReqoreButton>
83
+ </ReqoreControlGroup>
84
+ <ReqoreControlGroup fluid wrap>
85
+ <ReqoreButton {...buttonProps} fluid textAlign='center' iconsAlign='center'>
86
+ Fluid button with centered text & icons
87
+ </ReqoreButton>
88
+ <ReqoreButton
89
+ {...buttonProps}
90
+ rightIcon={null}
91
+ fluid
92
+ textAlign='center'
93
+ iconsAlign='center'
94
+ >
95
+ Fluid button with centered text & icons
96
+ </ReqoreButton>
97
+ <ReqoreButton {...buttonProps} icon={null} fluid textAlign='center' iconsAlign='center'>
98
+ Fluid button with centered text & icons
99
+ </ReqoreButton>
100
+ </ReqoreControlGroup>
82
101
  <ReqoreControlGroup fluid wrap>
83
102
  <ReqoreButton {...buttonProps}>Left text</ReqoreButton>
84
103
  <ReqoreButton
@@ -112,7 +131,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
112
131
  Right text
113
132
  </ReqoreButton>
114
133
  </ReqoreControlGroup>
115
- <br />
116
134
  <ReqoreControlGroup wrap>
117
135
  <ReqoreButton
118
136
  {...buttonProps}
@@ -171,7 +189,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
171
189
  wrap
172
190
  />
173
191
  </ReqoreControlGroup>
174
- <br />
175
192
  <ReqoreControlGroup wrap>
176
193
  <ReqoreButton {...buttonProps} readOnly badge={10} onClick={alert}>
177
194
  Read only with badge
@@ -225,7 +242,7 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
225
242
  With modified Badge
226
243
  </ReqoreButton>
227
244
  </ReqoreControlGroup>
228
- </>
245
+ </ReqoreControlGroup>
229
246
  );
230
247
  };
231
248
 
@@ -1,10 +1,11 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
- import { ReqoreButton, ReqoreControlGroup } from '../..';
2
+ import { ReqoreButton, ReqoreControlGroup, ReqoreVerticalSpacer } from '../..';
3
3
  import { IReqoreCollectionProps, ReqoreCollection } from '../../components/Collection';
4
4
  import { IReqoreColumnsProps } from '../../components/Columns';
5
- import items from '../../mock/collectionData';
6
- import data from '../../mock/data.json';
7
- import { IntentArg, SizeArg, argManager } from '../utils/args';
5
+ import { PADDING_FROM_SIZE } from '../../constants/sizes';
6
+ import items, { bigCollection } from '../../mock/collectionData';
7
+
8
+ import { argManager, IntentArg, SizeArg } from '../utils/args';
8
9
 
9
10
  export interface IColumnsStoryArgs extends IReqoreColumnsProps {
10
11
  multipleColumns?: boolean;
@@ -143,34 +144,38 @@ export const ChildrenBeforeAndAfter = Template.bind({});
143
144
  ChildrenBeforeAndAfter.args = {
144
145
  label: 'Collection of items',
145
146
  items,
146
- childrenBefore: (
147
- <ReqoreControlGroup horizontalAlign='center' fluid>
148
- <ReqoreButton fluid> I could be a filter of some kind</ReqoreButton>
149
- </ReqoreControlGroup>
150
- ),
151
- childrenAfter: (
152
- <ReqoreControlGroup horizontalAlign='center' fluid>
153
- <ReqoreControlGroup fluid={false} fixed>
154
- <ReqoreButton fixed textAlign='center'>
155
- 1
156
- </ReqoreButton>
157
- <ReqoreButton fixed textAlign='center'>
158
- 2
159
- </ReqoreButton>
160
- <ReqoreButton fixed textAlign='center'>
161
- 3
162
- </ReqoreButton>
163
- <ReqoreButton fixed textAlign='center'>
164
- 4
165
- </ReqoreButton>
147
+ contentRenderer: (children) => (
148
+ <>
149
+ <ReqoreControlGroup horizontalAlign='center' fluid>
150
+ <ReqoreButton fluid> I could be a filter of some kind</ReqoreButton>
151
+ </ReqoreControlGroup>
152
+ <ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
153
+ {children}
154
+ <ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
155
+ <ReqoreControlGroup horizontalAlign='center' fluid>
156
+ <ReqoreControlGroup fluid={false} fixed>
157
+ <ReqoreButton fixed textAlign='center'>
158
+ 1
159
+ </ReqoreButton>
160
+ <ReqoreButton fixed textAlign='center'>
161
+ 2
162
+ </ReqoreButton>
163
+ <ReqoreButton fixed textAlign='center'>
164
+ 3
165
+ </ReqoreButton>
166
+ <ReqoreButton fixed textAlign='center'>
167
+ 4
168
+ </ReqoreButton>
169
+ </ReqoreControlGroup>
166
170
  </ReqoreControlGroup>
167
- </ReqoreControlGroup>
171
+ </>
168
172
  ),
169
173
  };
170
174
 
171
175
  export const FilteringSearchingPaging = Template.bind({});
172
176
  FilteringSearchingPaging.args = {
173
177
  inputProps: {
178
+ fluid: true,
174
179
  focusRules: {
175
180
  type: 'keypress',
176
181
  shortcut: 'letters',
@@ -183,24 +188,9 @@ FilteringSearchingPaging.args = {
183
188
  sortButtonProps: {
184
189
  fixed: false,
185
190
  },
191
+ paging: true,
186
192
  size: 'big',
187
193
  padded: false,
188
194
  fill: true,
189
- items: data.slice(0, 100).map((datum) => ({
190
- label: `${datum.firstName} ${datum.lastName}`,
191
- badge: datum.id,
192
- size: 'small',
193
- expandable: true,
194
- content: datum.address,
195
- tags: [
196
- {
197
- labelKey: 'Age',
198
- label: datum.age,
199
- },
200
- {
201
- labelKey: 'Occupation',
202
- label: datum.occupation,
203
- },
204
- ],
205
- })),
195
+ items: bigCollection,
206
196
  } as IReqoreCollectionProps;
@@ -11,7 +11,7 @@ export default {
11
11
  title: 'Components/Dropdown',
12
12
  parameters: {
13
13
  chromatic: {
14
- delay: 500,
14
+ delay: 1500,
15
15
  },
16
16
  },
17
17
  argTypes: {
@@ -132,6 +132,25 @@ export default {
132
132
  const Template: Story<IReqoreDropdownProps> = (args: IReqoreDropdownProps) => {
133
133
  const [selected, setSelected] = useState<(string | number)[]>(['Item 3', 'Item 6']);
134
134
 
135
+ if (args.scrollToSelected) {
136
+ return (
137
+ <ReqoreControlGroup>
138
+ <ReqoreDropdown
139
+ label='Scrolling to selected'
140
+ isDefaultOpen
141
+ scrollToSelected
142
+ items={Array(130)
143
+ .fill(null)
144
+ .map((_, i) => ({
145
+ label: `Item ${i}`,
146
+ value: `item-${i}`,
147
+ selected: i === 55,
148
+ }))}
149
+ />
150
+ </ReqoreControlGroup>
151
+ );
152
+ }
153
+
135
154
  if (args.multiSelect) {
136
155
  return (
137
156
  <>
@@ -226,6 +245,10 @@ CustomComponent.args = {
226
245
  component: ReqoreInput,
227
246
  placeholder: 'Custom component',
228
247
  };
248
+ export const ScrollToSelectedItem = Template.bind({});
249
+ ScrollToSelectedItem.args = {
250
+ scrollToSelected: true,
251
+ };
229
252
  export const MultiSelect = Template.bind({});
230
253
  MultiSelect.args = {
231
254
  multiSelect: true,
@@ -0,0 +1,184 @@
1
+ import { Story, StoryObj } from '@storybook/react/types-6-0';
2
+ import { IReqorePaginationProps, ReqorePagination } from '../../components/Paging';
3
+ import { IReqorePagingOptions } from '../../hooks/usePaging';
4
+ import { ReqoreControlGroup, ReqoreTag, useReqorePaging } from '../../index';
5
+ import { tableData } from '../../mock/tableData';
6
+
7
+ export default {
8
+ title: 'Components/Paging',
9
+ } as StoryObj<typeof ReqorePagination>;
10
+
11
+ const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }> =
12
+ (args) => {
13
+ const paging = useReqorePaging<any>({ items: tableData, ...args.pagingOptions });
14
+
15
+ return (
16
+ <ReqoreControlGroup vertical fluid>
17
+ {paging.items.map((item) => (
18
+ <ReqoreTag fixed='key' labelKey={item.id} label={`${item.firstName} ${item.lastName}`} />
19
+ ))}
20
+ <ReqorePagination<any> {...paging} {...args} />
21
+ </ReqoreControlGroup>
22
+ );
23
+ };
24
+
25
+ export const Basic = Template.bind({});
26
+ export const NoPageButtons = Template.bind({});
27
+ NoPageButtons.args = {
28
+ showPages: false,
29
+ };
30
+
31
+ export const NoControlButtons = Template.bind({});
32
+ NoControlButtons.args = {
33
+ showControls: false,
34
+ };
35
+
36
+ export const ShowSomePages = Template.bind({});
37
+ ShowSomePages.args = {
38
+ pagingOptions: {
39
+ pagesToShow: 4,
40
+ } as IReqorePagingOptions<any>,
41
+ };
42
+ export const AsList = Template.bind({});
43
+ AsList.args = {
44
+ showPagesAs: 'list',
45
+ pagingOptions: {
46
+ pagesToShow: 5,
47
+ } as IReqorePagingOptions<any>,
48
+ };
49
+
50
+ export const WithStyling: Story<
51
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
52
+ > = Template.bind({});
53
+ WithStyling.args = {
54
+ showPagesAs: 'buttons',
55
+ activePageButtonProps: {
56
+ effect: {
57
+ gradient: {
58
+ colors: 'info',
59
+ },
60
+ },
61
+ },
62
+ pageButtonProps: {
63
+ effect: {
64
+ gradient: {
65
+ colors: 'warning',
66
+ },
67
+ },
68
+ },
69
+ controlPageButtonProps: {
70
+ effect: {
71
+ gradient: {
72
+ colors: 'success',
73
+ },
74
+ },
75
+ },
76
+ pagingOptions: {
77
+ pagesToShow: 15,
78
+ } as IReqorePagingOptions<any>,
79
+ };
80
+
81
+ export const ListWithStyling: Story<
82
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
83
+ > = Template.bind({});
84
+ ListWithStyling.args = {
85
+ showPagesAs: 'list',
86
+ activePageButtonProps: {
87
+ effect: {
88
+ gradient: {
89
+ colors: 'info',
90
+ },
91
+ },
92
+ },
93
+ pageButtonProps: {
94
+ effect: {
95
+ gradient: {
96
+ colors: 'warning',
97
+ },
98
+ },
99
+ },
100
+ listPageButtonProps: {
101
+ isDefaultOpen: true,
102
+ effect: {
103
+ gradient: {
104
+ colors: 'info',
105
+ },
106
+ },
107
+ },
108
+ controlPageButtonProps: {
109
+ effect: {
110
+ gradient: {
111
+ colors: 'success',
112
+ },
113
+ },
114
+ },
115
+ pagingOptions: {
116
+ pagesToShow: 15,
117
+ } as IReqorePagingOptions<any>,
118
+ };
119
+
120
+ export const WithLabels: Story<
121
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
122
+ > = Template.bind({});
123
+ WithLabels.args = {
124
+ showPagesAs: 'list',
125
+ showLabels: true,
126
+ listPageButtonProps: {
127
+ isDefaultOpen: true,
128
+ },
129
+ pagingOptions: {
130
+ pagesToShow: 15,
131
+ } as IReqorePagingOptions<any>,
132
+ };
133
+
134
+ export const Infinite: Story<
135
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
136
+ > = Template.bind({});
137
+ Infinite.args = {
138
+ showLabels: true,
139
+ fluid: true,
140
+ loadMoreButtonProps: {
141
+ textAlign: 'center',
142
+ },
143
+ loadMoreLabel: 'Load 10 more',
144
+ pagingOptions: {
145
+ infinite: true,
146
+ } as IReqorePagingOptions<any>,
147
+ };
148
+
149
+ export const InfiniteWithAutoScroll: Story<
150
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
151
+ > = Template.bind({});
152
+ InfiniteWithAutoScroll.args = {
153
+ showLabels: true,
154
+ fluid: true,
155
+ scrollOnLoadMore: true,
156
+ loadMoreButtonProps: {
157
+ textAlign: 'center',
158
+ size: 'big',
159
+ },
160
+ loadMoreLabel: 'Load 100 more',
161
+ pagingOptions: {
162
+ infinite: true,
163
+ itemsPerPage: 100,
164
+ } as IReqorePagingOptions<any>,
165
+ };
166
+
167
+ export const InfiniteWithAutoLoad: Story<
168
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
169
+ > = Template.bind({});
170
+ InfiniteWithAutoLoad.args = {
171
+ showLabels: true,
172
+ fluid: true,
173
+ autoLoadMore: true,
174
+ scrollOnLoadMore: true,
175
+ loadMoreButtonProps: {
176
+ textAlign: 'center',
177
+ icon: 'Loader5Line',
178
+ },
179
+ loadMoreLabel: 'Scroll to load 20 more',
180
+ pagingOptions: {
181
+ infinite: true,
182
+ itemsPerPage: 20,
183
+ } as IReqorePagingOptions<any>,
184
+ };
@@ -267,6 +267,56 @@ const Template: Story<IReqoreTagGroup & IReqoreTagProps> = ({ columns, ...args }
267
267
  },
268
268
  ]}
269
269
  />
270
+ <ReqoreTag
271
+ {...args}
272
+ labelKey='Fixed'
273
+ fixed='key'
274
+ label='Wrapped tag with some long text and NO width specified, AND wrap specified, with fixed key'
275
+ icon='DriveLine'
276
+ rightIcon={args.rightIcon}
277
+ wrap
278
+ onRemoveClick={null}
279
+ actions={[
280
+ {
281
+ icon: '24HoursFill',
282
+ onClick: noop,
283
+ disabled: true,
284
+ intent: 'info',
285
+ tooltip: { content: 'I am a tooltip' },
286
+ },
287
+ {
288
+ icon: 'SpyFill',
289
+ onClick: noop,
290
+ intent: 'success',
291
+ tooltip: { content: 'Hm, another tooltip', openOnMount: true },
292
+ },
293
+ ]}
294
+ />
295
+ <ReqoreTag
296
+ {...args}
297
+ labelKey='Wrapped tag with some long text and NO width specified, AND wrap specified, with fixed label, Wrapped tag with some long text and NO width specified, AND wrap specified, with fixed label'
298
+ fixed='label'
299
+ label='Fixed'
300
+ icon='DriveLine'
301
+ rightIcon={args.rightIcon}
302
+ wrap
303
+ onRemoveClick={null}
304
+ actions={[
305
+ {
306
+ icon: '24HoursFill',
307
+ onClick: noop,
308
+ disabled: true,
309
+ intent: 'info',
310
+ tooltip: { content: 'I am a tooltip' },
311
+ },
312
+ {
313
+ icon: 'SpyFill',
314
+ onClick: noop,
315
+ intent: 'success',
316
+ tooltip: { content: 'Hm, another tooltip', openOnMount: true },
317
+ },
318
+ ]}
319
+ />
270
320
  </ReqoreTagGroup>
271
321
  );
272
322
  };