@qoretechnologies/reqore 0.34.3 → 0.34.5

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 (69) hide show
  1. package/__tests__/button.test.tsx +30 -1
  2. package/__tests__/collection.test.tsx +30 -0
  3. package/__tests__/drawer.test.tsx +1 -1
  4. package/__tests__/dropdown.test.tsx +5 -2
  5. package/__tests__/heading.test.tsx +58 -0
  6. package/__tests__/hooks/useReqorePaging.test.tsx +16 -0
  7. package/__tests__/pagination.test.tsx +104 -3
  8. package/__tests__/panel.test.tsx +23 -2
  9. package/__tests__/stories/Collection.stories.tsx +0 -0
  10. package/dist/components/Button/index.d.ts +3 -1
  11. package/dist/components/Button/index.d.ts.map +1 -1
  12. package/dist/components/Button/index.js +9 -7
  13. package/dist/components/Button/index.js.map +1 -1
  14. package/dist/components/Collection/index.d.ts.map +1 -1
  15. package/dist/components/Collection/index.js +1 -1
  16. package/dist/components/Collection/index.js.map +1 -1
  17. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  18. package/dist/components/ControlGroup/index.js +4 -4
  19. package/dist/components/ControlGroup/index.js.map +1 -1
  20. package/dist/components/Drawer/index.d.ts.map +1 -1
  21. package/dist/components/Drawer/index.js +3 -10
  22. package/dist/components/Drawer/index.js.map +1 -1
  23. package/dist/components/Dropdown/index.d.ts.map +1 -1
  24. package/dist/components/Dropdown/index.js +5 -1
  25. package/dist/components/Dropdown/index.js.map +1 -1
  26. package/dist/components/Header/index.d.ts +3 -3
  27. package/dist/components/Header/index.d.ts.map +1 -1
  28. package/dist/components/Header/index.js +5 -2
  29. package/dist/components/Header/index.js.map +1 -1
  30. package/dist/components/Paging/index.d.ts +2 -1
  31. package/dist/components/Paging/index.d.ts.map +1 -1
  32. package/dist/components/Paging/index.js +31 -1
  33. package/dist/components/Paging/index.js.map +1 -1
  34. package/dist/components/Panel/NonResponsiveActions.d.ts +18 -0
  35. package/dist/components/Panel/NonResponsiveActions.d.ts.map +1 -0
  36. package/dist/components/Panel/NonResponsiveActions.js +47 -0
  37. package/dist/components/Panel/NonResponsiveActions.js.map +1 -0
  38. package/dist/components/Panel/index.d.ts +5 -1
  39. package/dist/components/Panel/index.d.ts.map +1 -1
  40. package/dist/components/Panel/index.js +36 -20
  41. package/dist/components/Panel/index.js.map +1 -1
  42. package/dist/components/Tag/group.js +4 -1
  43. package/dist/components/Tag/group.js.map +1 -1
  44. package/dist/containers/Paging.d.ts +2 -1
  45. package/dist/containers/Paging.d.ts.map +1 -1
  46. package/dist/containers/Paging.js.map +1 -1
  47. package/dist/hooks/usePaging.d.ts +5 -0
  48. package/dist/hooks/usePaging.d.ts.map +1 -1
  49. package/dist/hooks/usePaging.js +7 -1
  50. package/dist/hooks/usePaging.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/components/Button/index.tsx +19 -14
  53. package/src/components/Collection/index.tsx +1 -0
  54. package/src/components/ControlGroup/index.tsx +3 -2
  55. package/src/components/Drawer/index.tsx +4 -10
  56. package/src/components/Dropdown/index.tsx +28 -15
  57. package/src/components/Header/index.tsx +9 -3
  58. package/src/components/Paging/index.tsx +37 -1
  59. package/src/components/Panel/NonResponsiveActions.tsx +79 -0
  60. package/src/components/Panel/index.tsx +129 -76
  61. package/src/components/Tag/group.tsx +1 -1
  62. package/src/containers/Paging.tsx +7 -3
  63. package/src/hooks/usePaging.ts +14 -0
  64. package/src/stories/Drawer/Drawer.stories.tsx +6 -1
  65. package/src/stories/Dropdown/Dropdown.stories.tsx +1 -0
  66. package/src/stories/Header/Header.stories.tsx +6 -8
  67. package/src/stories/Paging/Paging.stories.tsx +17 -1
  68. package/src/stories/Panel/Panel.stories.tsx +13 -3
  69. package/tests.json +1 -1
@@ -3,6 +3,11 @@ import { useEffect, useMemo } from 'react';
3
3
  import { useUpdateEffect } from 'react-use';
4
4
  import usePagination, { usePaginationReturn } from 'react-use-pagination-hook';
5
5
 
6
+ export interface IReqorePageChangeData {
7
+ isFirst?: boolean;
8
+ isLast?: boolean;
9
+ }
10
+
6
11
  export interface IReqorePagingOptions<T> {
7
12
  items: T[];
8
13
  startPage?: number;
@@ -10,6 +15,7 @@ export interface IReqorePagingOptions<T> {
10
15
  itemsPerPage?: number;
11
16
  infinite?: boolean;
12
17
  enabled?: boolean;
18
+ onPageChange?: (page: number, info: IReqorePageChangeData) => void;
13
19
  }
14
20
 
15
21
  export interface IReqorePagingResult<T>
@@ -46,6 +52,7 @@ export const useReqorePaging = <T>(
46
52
  pagesToShow,
47
53
  startPage,
48
54
  enabled = true,
55
+ onPageChange,
49
56
  }: IReqorePagingOptions<T> = merge({}, defaultPagingOptions, options);
50
57
  const allPageCount = useMemo(() => Math.ceil(size(items) / itemsPerPage), [items, itemsPerPage]);
51
58
  const { pagelist, currentPage, setPage, setTotalPage, goNext, goBefore } = usePagination({
@@ -57,6 +64,13 @@ export const useReqorePaging = <T>(
57
64
  setPage(startPage || 1);
58
65
  }, [startPage]);
59
66
 
67
+ useUpdateEffect(() => {
68
+ onPageChange?.(currentPage, {
69
+ isFirst: currentPage === 1,
70
+ isLast: currentPage === allPageCount,
71
+ });
72
+ }, [currentPage]);
73
+
60
74
  useUpdateEffect(() => {
61
75
  setPage(1);
62
76
  setTotalPage(Math.ceil(size(items) / itemsPerPage));
@@ -10,12 +10,17 @@ import {
10
10
  ReqoreTabsContent,
11
11
  useReqoreProperty,
12
12
  } from '../../index';
13
- import { FlatArg, IntentArg, argManager } from '../utils/args';
13
+ import { argManager, FlatArg, IntentArg } from '../utils/args';
14
14
 
15
15
  const { createArg } = argManager<IReqoreDrawerProps>();
16
16
 
17
17
  export default {
18
18
  title: 'Components/Drawer',
19
+ parameters: {
20
+ chromatic: {
21
+ viewports: [450, 600, 1440],
22
+ },
23
+ },
19
24
  argTypes: {
20
25
  ...FlatArg,
21
26
  ...createArg('floating', {
@@ -229,6 +229,7 @@ export const WithPaging: Story<IReqoreDropdownProps> = Template.bind({});
229
229
  WithPaging.args = {
230
230
  paging: {
231
231
  itemsPerPage: 50,
232
+ changePageOnScroll: 'horizontal',
232
233
  },
233
234
  label: 'Dropdown with paging',
234
235
  };
@@ -1,6 +1,6 @@
1
1
  import { Meta, Story } from '@storybook/react/types-6-0';
2
2
  import { IReqoreHeadingProps } from '../../components/Header';
3
- import { ReqoreHeading, ReqoreVerticalSpacer } from '../../index';
3
+ import { ReqoreControlGroup, ReqoreHeading } from '../../index';
4
4
  import { IntentArg } from '../utils/args';
5
5
 
6
6
  export default {
@@ -12,31 +12,29 @@ export default {
12
12
 
13
13
  const Template: Story<IReqoreHeadingProps> = (args) => {
14
14
  return (
15
- <>
15
+ <ReqoreControlGroup gapSize='big' vertical>
16
16
  <ReqoreHeading size={1} {...args}>
17
17
  This is a heading
18
18
  </ReqoreHeading>
19
- <ReqoreVerticalSpacer height={10} />
20
19
  <ReqoreHeading size={2} {...args}>
21
20
  This is a heading
22
21
  </ReqoreHeading>
23
- <ReqoreVerticalSpacer height={10} />
24
22
  <ReqoreHeading size={3} {...args}>
25
23
  This is a heading
26
24
  </ReqoreHeading>
27
- <ReqoreVerticalSpacer height={10} />
28
25
  <ReqoreHeading size={4} {...args}>
29
26
  This is a heading
30
27
  </ReqoreHeading>
31
- <ReqoreVerticalSpacer height={10} />
32
28
  <ReqoreHeading size={5} {...args}>
33
29
  This is a heading
34
30
  </ReqoreHeading>
35
- <ReqoreVerticalSpacer height={10} />
36
31
  <ReqoreHeading size={6} {...args}>
37
32
  This is a heading
38
33
  </ReqoreHeading>
39
- </>
34
+ <ReqoreHeading size={1} {...args} tooltip={{ content: 'Nice tooltip', openOnMount: true }}>
35
+ This is a heading with tooltip
36
+ </ReqoreHeading>
37
+ </ReqoreControlGroup>
40
38
  );
41
39
  };
42
40
 
@@ -27,7 +27,9 @@ const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePag
27
27
  <ReqorePagination<any>
28
28
  {...paging}
29
29
  {...args}
30
- scrollContainer={args.scrollToTopOnPageChange ? scrollContainer : undefined}
30
+ scrollContainer={
31
+ args.scrollToTopOnPageChange || !!args.changePageOnScroll ? scrollContainer : undefined
32
+ }
31
33
  />
32
34
  </ReqoreControlGroup>
33
35
  );
@@ -142,6 +144,20 @@ WithLabels.args = {
142
144
  } as IReqorePagingOptions<any>,
143
145
  };
144
146
 
147
+ export const NextPageOnVerticalScroll: Story<
148
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
149
+ > = Template.bind({});
150
+ NextPageOnVerticalScroll.args = {
151
+ changePageOnScroll: 'vertical',
152
+ };
153
+
154
+ export const NextPageOnHorizontalScroll: Story<
155
+ IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
156
+ > = Template.bind({});
157
+ NextPageOnHorizontalScroll.args = {
158
+ changePageOnScroll: 'horizontal',
159
+ };
160
+
145
161
  export const ScrollToTop: Story<
146
162
  IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
147
163
  > = Template.bind({});
@@ -3,12 +3,17 @@ import { noop } from 'lodash';
3
3
  import ReqoreInput, { IReqoreInputProps } from '../../components/Input';
4
4
  import { IReqorePanelAction, IReqorePanelProps, ReqorePanel } from '../../components/Panel';
5
5
  import { ReqoreVerticalSpacer } from '../../components/Spacer';
6
- import { FlatArg, IconArg, IntentArg, SizeArg, argManager } from '../utils/args';
6
+ import { argManager, FlatArg, IconArg, IntentArg, SizeArg } from '../utils/args';
7
7
 
8
8
  const { createArg } = argManager<IReqorePanelProps>();
9
9
 
10
10
  export default {
11
11
  title: 'Components/Panel',
12
+ parameters: {
13
+ chromatic: {
14
+ viewports: [450, 600, 1440],
15
+ },
16
+ },
12
17
  argTypes: {
13
18
  ...IntentArg,
14
19
  ...FlatArg,
@@ -373,13 +378,18 @@ NoLabel.args = {
373
378
  badge: undefined,
374
379
  };
375
380
 
376
- export const ImageAsIcon: Story<IReqorePanelProps> = Template.bind({});
377
- ImageAsIcon.args = {
381
+ export const ImageAsIconLinkAsHeader: Story<IReqorePanelProps> = Template.bind({});
382
+ ImageAsIconLinkAsHeader.args = {
378
383
  iconImage:
379
384
  'https://avatars.githubusercontent.com/u/44835090?s=400&u=371120ce0755102d2e432f11ad9aa0378c871b45&v=4',
380
385
  iconProps: {
381
386
  size: '30px',
382
387
  },
388
+ headerProps: {
389
+ as: 'a',
390
+ href: 'https://qoretechnologies.com',
391
+ target: '_blank',
392
+ } as React.HTMLAttributes<HTMLAnchorElement>,
383
393
  };
384
394
 
385
395
  export const ContentSize: Story<IReqorePanelProps> = Template.bind({});