@qoretechnologies/reqore 0.32.3 → 0.34.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 (109) hide show
  1. package/__tests__/collection.test.tsx +144 -5
  2. package/__tests__/containers/paging.test.tsx +106 -0
  3. package/__tests__/hooks/useLatestZIndex.test.tsx +10 -0
  4. package/__tests__/hooks/useReqorePaging.test.tsx +255 -0
  5. package/__tests__/hooks/useTheme.test.tsx +31 -0
  6. package/__tests__/pagination.test.tsx +305 -0
  7. package/__tests__/popover.test.tsx +20 -6
  8. package/__tests__/setup.js +8 -0
  9. package/__tests__/tree.test.tsx +0 -1
  10. package/dist/components/Button/index.d.ts +1 -0
  11. package/dist/components/Button/index.d.ts.map +1 -1
  12. package/dist/components/Button/index.js +11 -7
  13. package/dist/components/Button/index.js.map +1 -1
  14. package/dist/components/Collection/index.d.ts +4 -3
  15. package/dist/components/Collection/index.d.ts.map +1 -1
  16. package/dist/components/Collection/index.js +31 -13
  17. package/dist/components/Collection/index.js.map +1 -1
  18. package/dist/components/Dropdown/index.d.ts +9 -2
  19. package/dist/components/Dropdown/index.d.ts.map +1 -1
  20. package/dist/components/Dropdown/index.js +2 -2
  21. package/dist/components/Dropdown/index.js.map +1 -1
  22. package/dist/components/Dropdown/list.d.ts +6 -1
  23. package/dist/components/Dropdown/list.d.ts.map +1 -1
  24. package/dist/components/Dropdown/list.js +13 -5
  25. package/dist/components/Dropdown/list.js.map +1 -1
  26. package/dist/components/Menu/index.d.ts +1 -0
  27. package/dist/components/Menu/index.d.ts.map +1 -1
  28. package/dist/components/Menu/index.js +4 -1
  29. package/dist/components/Menu/index.js.map +1 -1
  30. package/dist/components/Menu/item.d.ts +1 -0
  31. package/dist/components/Menu/item.d.ts.map +1 -1
  32. package/dist/components/Menu/item.js +14 -2
  33. package/dist/components/Menu/item.js.map +1 -1
  34. package/dist/components/MultiSelect/index.d.ts +1 -1
  35. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  36. package/dist/components/Paging/index.d.ts +32 -0
  37. package/dist/components/Paging/index.d.ts.map +1 -0
  38. package/dist/components/Paging/index.js +127 -0
  39. package/dist/components/Paging/index.js.map +1 -0
  40. package/dist/components/Panel/index.d.ts +1 -0
  41. package/dist/components/Panel/index.d.ts.map +1 -1
  42. package/dist/components/Panel/index.js +2 -2
  43. package/dist/components/Panel/index.js.map +1 -1
  44. package/dist/components/Tag/index.d.ts +3 -2
  45. package/dist/components/Tag/index.d.ts.map +1 -1
  46. package/dist/components/Tag/index.js +10 -7
  47. package/dist/components/Tag/index.js.map +1 -1
  48. package/dist/constants/colors.d.ts +2 -9
  49. package/dist/constants/colors.d.ts.map +1 -1
  50. package/dist/constants/colors.js +3 -1
  51. package/dist/constants/colors.js.map +1 -1
  52. package/dist/constants/paging.d.ts +17 -0
  53. package/dist/constants/paging.d.ts.map +1 -0
  54. package/dist/constants/paging.js +45 -0
  55. package/dist/constants/paging.js.map +1 -0
  56. package/dist/constants/theme.d.ts.map +1 -1
  57. package/dist/constants/theme.js +8 -7
  58. package/dist/constants/theme.js.map +1 -1
  59. package/dist/containers/Paging.d.ts +15 -0
  60. package/dist/containers/Paging.d.ts.map +1 -0
  61. package/dist/containers/Paging.js +51 -0
  62. package/dist/containers/Paging.js.map +1 -0
  63. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  64. package/dist/containers/ReqoreProvider.js +2 -2
  65. package/dist/containers/ReqoreProvider.js.map +1 -1
  66. package/dist/containers/UIProvider.d.ts.map +1 -1
  67. package/dist/containers/UIProvider.js +9 -3
  68. package/dist/containers/UIProvider.js.map +1 -1
  69. package/dist/hooks/useCombinedRefs.d.ts +2 -2
  70. package/dist/hooks/useCombinedRefs.d.ts.map +1 -1
  71. package/dist/hooks/useCombinedRefs.js.map +1 -1
  72. package/dist/hooks/usePaging.d.ts +28 -0
  73. package/dist/hooks/usePaging.d.ts.map +1 -0
  74. package/dist/hooks/usePaging.js +85 -0
  75. package/dist/hooks/usePaging.js.map +1 -0
  76. package/dist/index.d.ts +3 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +8 -2
  79. package/dist/index.js.map +1 -1
  80. package/package.json +6 -4
  81. package/src/components/Button/index.tsx +18 -10
  82. package/src/components/Collection/index.tsx +78 -49
  83. package/src/components/ControlGroup/index.tsx +1 -1
  84. package/src/components/Dropdown/index.tsx +27 -12
  85. package/src/components/Dropdown/list.tsx +49 -24
  86. package/src/components/Menu/index.tsx +3 -2
  87. package/src/components/Menu/item.tsx +16 -2
  88. package/src/components/MultiSelect/index.tsx +1 -1
  89. package/src/components/Paging/index.tsx +260 -0
  90. package/src/components/Panel/index.tsx +4 -1
  91. package/src/components/Tag/index.tsx +9 -7
  92. package/src/constants/colors.ts +5 -1
  93. package/src/constants/paging.ts +67 -0
  94. package/src/constants/theme.ts +8 -7
  95. package/src/containers/Paging.tsx +90 -0
  96. package/src/containers/ReqoreProvider.tsx +3 -3
  97. package/src/containers/UIProvider.tsx +17 -4
  98. package/src/hooks/useCombinedRefs.ts +2 -2
  99. package/src/hooks/usePaging.ts +114 -0
  100. package/src/index.tsx +3 -0
  101. package/src/mock/collectionData.tsx +19 -0
  102. package/src/mock/tableData.ts +1 -0
  103. package/src/stories/Button/Button.stories.tsx +25 -8
  104. package/src/stories/Collection/Collection.stories.tsx +51 -42
  105. package/src/stories/Dropdown/Dropdown.stories.tsx +71 -29
  106. package/src/stories/Menu/Menu.stories.tsx +4 -0
  107. package/src/stories/Paging/Paging.stories.tsx +202 -0
  108. package/src/stories/Tag/Tag.stories.tsx +50 -0
  109. package/tests.json +1 -1
@@ -0,0 +1,202 @@
1
+ import { Story, StoryObj } from '@storybook/react/types-6-0';
2
+ import { useState } from 'react';
3
+ import { useMount } from 'react-use';
4
+ import { IReqorePaginationProps, ReqorePagination } from '../../components/Paging';
5
+ import { IReqorePagingOptions } from '../../hooks/usePaging';
6
+ import { ReqoreControlGroup, ReqoreTag, useReqorePaging } from '../../index';
7
+ import { tableData } from '../../mock/tableData';
8
+
9
+ export default {
10
+ title: 'Components/Paging',
11
+ } as StoryObj<typeof ReqorePagination>;
12
+
13
+ const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }> =
14
+ (args) => {
15
+ const [scrollContainer, setScrollContainer] = useState<any>(undefined);
16
+ const paging = useReqorePaging<any>({ items: tableData, ...args.pagingOptions });
17
+
18
+ useMount(() => {
19
+ setScrollContainer(document.querySelector('.reqore-content')!);
20
+ });
21
+
22
+ return (
23
+ <ReqoreControlGroup vertical fluid>
24
+ {paging.items.map((item) => (
25
+ <ReqoreTag fixed='key' labelKey={item.id} label={`${item.firstName} ${item.lastName}`} />
26
+ ))}
27
+ <ReqorePagination<any> {...paging} {...args} scrollContainer={scrollContainer} />
28
+ </ReqoreControlGroup>
29
+ );
30
+ };
31
+
32
+ export const Basic = Template.bind({});
33
+ export const NoPageButtons = Template.bind({});
34
+ NoPageButtons.args = {
35
+ showPages: false,
36
+ };
37
+
38
+ export const NoControlButtons = Template.bind({});
39
+ NoControlButtons.args = {
40
+ showControls: false,
41
+ };
42
+
43
+ export const ShowSomePages = Template.bind({});
44
+ ShowSomePages.args = {
45
+ pagingOptions: {
46
+ pagesToShow: 4,
47
+ } as IReqorePagingOptions<any>,
48
+ };
49
+ export const AsList = Template.bind({});
50
+ AsList.args = {
51
+ showPagesAs: 'list',
52
+ pagingOptions: {
53
+ pagesToShow: 5,
54
+ } as IReqorePagingOptions<any>,
55
+ };
56
+
57
+ export const WithStyling: Story<
58
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
59
+ > = Template.bind({});
60
+ WithStyling.args = {
61
+ showPagesAs: 'buttons',
62
+ activePageButtonProps: {
63
+ effect: {
64
+ gradient: {
65
+ colors: 'info',
66
+ },
67
+ },
68
+ },
69
+ pageButtonProps: {
70
+ effect: {
71
+ gradient: {
72
+ colors: 'warning',
73
+ },
74
+ },
75
+ },
76
+ controlPageButtonProps: {
77
+ effect: {
78
+ gradient: {
79
+ colors: 'success',
80
+ },
81
+ },
82
+ },
83
+ pagingOptions: {
84
+ pagesToShow: 15,
85
+ } as IReqorePagingOptions<any>,
86
+ };
87
+
88
+ export const ListWithStyling: Story<
89
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
90
+ > = Template.bind({});
91
+ ListWithStyling.args = {
92
+ showPagesAs: 'list',
93
+ activePageButtonProps: {
94
+ effect: {
95
+ gradient: {
96
+ colors: 'info',
97
+ },
98
+ },
99
+ },
100
+ pageButtonProps: {
101
+ effect: {
102
+ gradient: {
103
+ colors: 'warning',
104
+ },
105
+ },
106
+ },
107
+ listPageButtonProps: {
108
+ isDefaultOpen: true,
109
+ effect: {
110
+ gradient: {
111
+ colors: 'info',
112
+ },
113
+ },
114
+ },
115
+ controlPageButtonProps: {
116
+ effect: {
117
+ gradient: {
118
+ colors: 'success',
119
+ },
120
+ },
121
+ },
122
+ pagingOptions: {
123
+ pagesToShow: 15,
124
+ } as IReqorePagingOptions<any>,
125
+ };
126
+
127
+ export const WithLabels: Story<
128
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
129
+ > = Template.bind({});
130
+ WithLabels.args = {
131
+ showPagesAs: 'list',
132
+ showLabels: true,
133
+ listPageButtonProps: {
134
+ isDefaultOpen: true,
135
+ },
136
+ pagingOptions: {
137
+ pagesToShow: 15,
138
+ } as IReqorePagingOptions<any>,
139
+ };
140
+
141
+ export const ScrollToTop: Story<
142
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
143
+ > = Template.bind({});
144
+ ScrollToTop.args = {
145
+ scrollToTopOnPageChange: true,
146
+ pagingOptions: {
147
+ pagesToShow: 5,
148
+ itemsPerPage: 100,
149
+ } as IReqorePagingOptions<any>,
150
+ };
151
+
152
+ export const Infinite: Story<
153
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
154
+ > = Template.bind({});
155
+ Infinite.args = {
156
+ showLabels: true,
157
+ fluid: true,
158
+ loadMoreButtonProps: {
159
+ textAlign: 'center',
160
+ },
161
+ loadMoreLabel: 'Load 10 more',
162
+ pagingOptions: {
163
+ infinite: true,
164
+ } as IReqorePagingOptions<any>,
165
+ };
166
+
167
+ export const InfiniteWithAutoScroll: Story<
168
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
169
+ > = Template.bind({});
170
+ InfiniteWithAutoScroll.args = {
171
+ showLabels: true,
172
+ fluid: true,
173
+ scrollOnLoadMore: true,
174
+ loadMoreButtonProps: {
175
+ textAlign: 'center',
176
+ size: 'big',
177
+ },
178
+ loadMoreLabel: 'Load 100 more',
179
+ pagingOptions: {
180
+ infinite: true,
181
+ itemsPerPage: 100,
182
+ } as IReqorePagingOptions<any>,
183
+ };
184
+
185
+ export const InfiniteWithAutoLoad: Story<
186
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
187
+ > = Template.bind({});
188
+ InfiniteWithAutoLoad.args = {
189
+ showLabels: true,
190
+ fluid: true,
191
+ autoLoadMore: true,
192
+ scrollOnLoadMore: true,
193
+ loadMoreButtonProps: {
194
+ textAlign: 'center',
195
+ icon: 'Loader5Line',
196
+ },
197
+ loadMoreLabel: 'Scroll to load 20 more',
198
+ pagingOptions: {
199
+ infinite: true,
200
+ itemsPerPage: 20,
201
+ } as IReqorePagingOptions<any>,
202
+ };
@@ -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
  };