@qoretechnologies/reqore 0.38.8 → 0.40.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 (64) hide show
  1. package/dist/components/Collection/index.d.ts +4 -1
  2. package/dist/components/Collection/index.d.ts.map +1 -1
  3. package/dist/components/Collection/index.js +32 -14
  4. package/dist/components/Collection/index.js.map +1 -1
  5. package/dist/components/Collection/item.d.ts +1 -0
  6. package/dist/components/Collection/item.d.ts.map +1 -1
  7. package/dist/components/Collection/item.js.map +1 -1
  8. package/dist/components/ControlGroup/index.d.ts +4 -2
  9. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  10. package/dist/components/ControlGroup/index.js.map +1 -1
  11. package/dist/components/Dropdown/list.d.ts +1 -0
  12. package/dist/components/Dropdown/list.d.ts.map +1 -1
  13. package/dist/components/Dropdown/list.js +2 -2
  14. package/dist/components/Dropdown/list.js.map +1 -1
  15. package/dist/components/Menu/divider.d.ts +1 -0
  16. package/dist/components/Menu/divider.d.ts.map +1 -1
  17. package/dist/components/Menu/divider.js +8 -5
  18. package/dist/components/Menu/divider.js.map +1 -1
  19. package/dist/components/Menu/section.d.ts +12 -0
  20. package/dist/components/Menu/section.d.ts.map +1 -0
  21. package/dist/components/Menu/section.js +87 -0
  22. package/dist/components/Menu/section.js.map +1 -0
  23. package/dist/components/Table/helpers.d.ts +1 -1
  24. package/dist/components/Table/helpers.d.ts.map +1 -1
  25. package/dist/components/Table/helpers.js +4 -1
  26. package/dist/components/Table/helpers.js.map +1 -1
  27. package/dist/components/Table/index.d.ts +1 -1
  28. package/dist/components/Table/index.d.ts.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +3 -3
  32. package/dist/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/components/Collection/index.tsx +64 -18
  35. package/src/components/Collection/item.tsx +2 -0
  36. package/src/components/ControlGroup/index.tsx +8 -4
  37. package/src/components/Dropdown/list.tsx +6 -1
  38. package/src/components/Menu/divider.tsx +8 -1
  39. package/src/components/Menu/section.tsx +82 -0
  40. package/src/components/Table/helpers.ts +2 -0
  41. package/src/components/Table/index.tsx +1 -1
  42. package/src/index.tsx +1 -1
  43. package/src/mock/collectionData.tsx +36 -0
  44. package/src/mock/menu.ts +46 -48
  45. package/src/stories/Collection/Collection.stories.tsx +32 -0
  46. package/src/stories/Menu/Menu.stories.tsx +161 -108
  47. package/tests.json +1 -1
  48. package/__tests__/sidebar.test.tsx +0 -225
  49. package/dist/components/Sidebar/index.d.ts +0 -60
  50. package/dist/components/Sidebar/index.d.ts.map +0 -1
  51. package/dist/components/Sidebar/index.js +0 -266
  52. package/dist/components/Sidebar/index.js.map +0 -1
  53. package/dist/components/Sidebar/item.d.ts +0 -35
  54. package/dist/components/Sidebar/item.d.ts.map +0 -1
  55. package/dist/components/Sidebar/item.js +0 -98
  56. package/dist/components/Sidebar/item.js.map +0 -1
  57. package/dist/helpers/sidebar.d.ts +0 -5
  58. package/dist/helpers/sidebar.d.ts.map +0 -1
  59. package/dist/helpers/sidebar.js +0 -92
  60. package/dist/helpers/sidebar.js.map +0 -1
  61. package/src/components/Sidebar/index.tsx +0 -536
  62. package/src/components/Sidebar/item.tsx +0 -264
  63. package/src/helpers/sidebar.ts +0 -89
  64. package/src/stories/Sidebar/Sidebar.stories.tsx +0 -97
package/src/mock/menu.ts CHANGED
@@ -1,59 +1,57 @@
1
- import { IQorusSidebarItems } from "../components/Sidebar";
2
-
3
- export const qorusSidebarItems: IQorusSidebarItems = {
1
+ export const qorusSidebarItems = {
4
2
  Menu: {
5
- title: "Menu",
3
+ title: 'Menu',
6
4
  items: [
7
5
  {
8
- name: "Menu item 1",
9
- as: "a",
6
+ name: 'Menu item 1',
7
+ as: 'a',
10
8
  props: {
11
- href: "/item-1",
9
+ href: '/item-1',
12
10
  },
13
- icon: "Home3Line",
14
- id: "menu-item-1",
11
+ icon: 'Home3Line',
12
+ id: 'menu-item-1',
15
13
  },
16
14
  {
17
- name: "Menu item 2",
18
- as: "a",
15
+ name: 'Menu item 2',
16
+ as: 'a',
19
17
  props: {
20
- href: "/item-2",
18
+ href: '/item-2',
21
19
  },
22
- icon: "Settings4Fill",
23
- id: "menu-item-2",
20
+ icon: 'Settings4Fill',
21
+ id: 'menu-item-2',
24
22
  },
25
23
  {
26
- name: "Menu item 3",
27
- icon: "File3Line",
28
- id: "menu-item-3",
29
- activePaths: ["/item-3"],
24
+ name: 'Menu item 3',
25
+ icon: 'File3Line',
26
+ id: 'menu-item-3',
27
+ activePaths: ['/item-3'],
30
28
  submenu: [
31
29
  {
32
- name: "Submenu item 1",
33
- as: "a",
30
+ name: 'Submenu item 1',
31
+ as: 'a',
34
32
  props: {
35
- href: "/item-3/item-1",
33
+ href: '/item-3/item-1',
36
34
  },
37
- icon: "NodeTree",
38
- id: "submenu-item-1",
35
+ icon: 'NodeTree',
36
+ id: 'submenu-item-1',
39
37
  },
40
38
  {
41
- name: "Submenu item 2",
42
- as: "a",
39
+ name: 'Submenu item 2',
40
+ as: 'a',
43
41
  props: {
44
- href: "/item-3/item-2",
42
+ href: '/item-3/item-2',
45
43
  },
46
- icon: "Chat3Fill",
47
- id: "submenu-item-2",
44
+ icon: 'Chat3Fill',
45
+ id: 'submenu-item-2',
48
46
  },
49
47
  {
50
- name: "Super really long Submenu item 3",
51
- as: "a",
48
+ name: 'Super really long Submenu item 3',
49
+ as: 'a',
52
50
  props: {
53
- href: "/item-3/item-3",
51
+ href: '/item-3/item-3',
54
52
  },
55
- icon: "DatabaseFill",
56
- id: "submenu-item-3",
53
+ icon: 'DatabaseFill',
54
+ id: 'submenu-item-3',
57
55
  },
58
56
  ],
59
57
  },
@@ -62,33 +60,33 @@ export const qorusSidebarItems: IQorusSidebarItems = {
62
60
  Menu2: {
63
61
  items: [
64
62
  {
65
- name: "Super Long Really Another item 1",
66
- as: "a",
63
+ name: 'Super Long Really Another item 1',
64
+ as: 'a',
67
65
  props: {
68
- href: "/another-item-1",
66
+ href: '/another-item-1',
69
67
  },
70
- icon: "Home6Line",
71
- id: "another-item-1",
68
+ icon: 'Home6Line',
69
+ id: 'another-item-1',
72
70
  },
73
71
  {
74
- name: "Another item 2",
75
- as: "a",
72
+ name: 'Another item 2',
73
+ as: 'a',
76
74
  props: {
77
- href: "/another-item-2",
75
+ href: '/another-item-2',
78
76
  },
79
- icon: "TableFill",
80
- id: "another-item-2",
77
+ icon: 'TableFill',
78
+ id: 'another-item-2',
81
79
  },
82
80
  {
83
- name: "Another item 3",
84
- as: "a",
81
+ name: 'Another item 3',
82
+ as: 'a',
85
83
  props: {
86
84
  onClick: () => {
87
- alert("Click");
85
+ alert('Click');
88
86
  },
89
87
  },
90
- icon: "BellLine",
91
- id: "another-item-3",
88
+ icon: 'BellLine',
89
+ id: 'another-item-3',
92
90
  },
93
91
  ],
94
92
  },
@@ -5,6 +5,10 @@ import { IReqoreColumnsProps } from '../../components/Columns';
5
5
  import { PADDING_FROM_SIZE } from '../../constants/sizes';
6
6
  import items, { bigCollection } from '../../mock/collectionData';
7
7
 
8
+ import { expect } from '@storybook/jest';
9
+ import { fireEvent } from '@storybook/testing-library';
10
+ import { waitFor } from '@testing-library/react';
11
+ import { sleep } from '../../helpers/utils';
8
12
  import { StoryMeta } from '../utils';
9
13
  import { argManager, IntentArg, SizeArg } from '../utils/args';
10
14
 
@@ -283,3 +287,31 @@ export const DefaultFilter: Story = {
283
287
  ],
284
288
  } as IReqoreCollectionProps,
285
289
  };
290
+
291
+ export const CustomSortKeysWithDefaultSort: Story = {
292
+ args: {
293
+ label: 'Posts',
294
+ items: items.map((item) => ({
295
+ ...item,
296
+ badge: [item.metadata.id, item.metadata.category],
297
+ })),
298
+ defaultSort: 'desc',
299
+ defaultSortBy: 'id',
300
+ sortKeys: {
301
+ id: 'ID',
302
+ category: 'Category',
303
+ },
304
+ },
305
+ play: async ({ canvasElement }) => {
306
+ await sleep(500);
307
+
308
+ await fireEvent.click(canvasElement.querySelector('.reqore-collection-sort'));
309
+
310
+ await waitFor(
311
+ () => expect(document.querySelectorAll('.reqore-popover-content')).toHaveLength(1),
312
+ {
313
+ timeout: 5000,
314
+ }
315
+ );
316
+ },
317
+ };
@@ -1,7 +1,11 @@
1
1
  import { StoryFn, StoryObj } from '@storybook/react';
2
+ import { fireEvent, within } from '@storybook/testing-library';
3
+ import { noop } from 'lodash';
2
4
  import { IReqoreMenuProps } from '../../components/Menu';
3
5
  import { IReqoreMenuItemProps } from '../../components/Menu/item';
6
+ import { ReqoreMenuSection } from '../../components/Menu/section';
4
7
  import {
8
+ ReqoreControlGroup,
5
9
  ReqoreInput,
6
10
  ReqoreMenu,
7
11
  ReqoreMenuDivider,
@@ -91,121 +95,160 @@ const meta = {
91
95
  export default meta;
92
96
  type Story = StoryObj<typeof meta>;
93
97
 
94
- const Template: StoryFn<IReqoreMenuProps> = (args) => {
95
- return (
96
- <ReqoreMenu {...args}>
97
- <ReqoreInput placeholder='Custom component' icon='Search2Fill' flat={false} />
98
- <ReqoreMenuItem icon='Save3Fill' intent='success' selected>
99
- Selected success
100
- </ReqoreMenuItem>
101
- <ReqoreMenuItem icon='Save3Fill' badge={10}>
102
- Save
98
+ const MenuWithSubmenus = (args: IReqoreMenuProps) => (
99
+ <ReqoreMenu {...args} width='300px'>
100
+ <ReqoreMenuSection label='Submenu 1' icon='Apps2Fill'>
101
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine' onRightIconClick={noop}>
102
+ Submenu Item 1
103
103
  </ReqoreMenuItem>
104
- <ReqoreMenuDivider label='BIG Divider' size='huge' />
105
104
  <ReqoreMenuItem
106
- icon='ChatPollFill'
107
- onClick={() => alert('Item clicked')}
108
- rightIcon='FahrenheitFill'
109
- onRightIconClick={() => alert('Icon clicked')}
110
- tooltip={{
111
- content: 'You sure?',
112
- }}
113
- intent='danger'
105
+ icon='DualSim1Line'
106
+ rightIcon='MoneyEuroBoxLine'
107
+ disabled
108
+ onRightIconClick={noop}
114
109
  >
115
- Delete
110
+ Submenu Item 2
116
111
  </ReqoreMenuItem>
112
+ <ReqoreMenuSection icon='PlayListLine' label='Submenu 2 active' activeIntent='info'>
113
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine'>
114
+ Submenu Item 3
115
+ </ReqoreMenuItem>
116
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine'>
117
+ Submenu Item 4
118
+ </ReqoreMenuItem>
119
+ </ReqoreMenuSection>
120
+ <ReqoreMenuSection label='Collapsed submenu' isCollapsed={true} icon='ListOrdered'>
121
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine'>
122
+ Submenu Item 5
123
+ </ReqoreMenuItem>
124
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine'>
125
+ Submenu Item 6
126
+ </ReqoreMenuItem>
127
+ </ReqoreMenuSection>
128
+ </ReqoreMenuSection>
129
+ </ReqoreMenu>
130
+ );
117
131
 
118
- <ReqoreMenuItem
119
- icon='BluetoothConnectLine'
120
- rightIcon='EditLine'
121
- onRightIconClick={() => alert('Icon clicked')}
122
- description='Button with right icon and description'
123
- customTheme={{
124
- main: 'info:darken:1:0.3',
125
- }}
126
- >
127
- Some button
128
- </ReqoreMenuItem>
132
+ const Template: StoryFn<IReqoreMenuProps> = (args) => {
133
+ return (
134
+ <ReqoreControlGroup verticalAlign='flex-start'>
135
+ <ReqoreMenu {...args}>
136
+ <ReqoreInput placeholder='Custom component' icon='Search2Fill' flat={false} />
137
+ <ReqoreMenuItem icon='Save3Fill' intent='success' selected>
138
+ Selected success
139
+ </ReqoreMenuItem>
140
+ <ReqoreMenuItem icon='Save3Fill' badge={10}>
141
+ Save
142
+ </ReqoreMenuItem>
143
+ <ReqoreMenuDivider label='BIG Divider' size='huge' />
144
+ <ReqoreMenuItem
145
+ icon='ChatPollFill'
146
+ onClick={() => alert('Item clicked')}
147
+ rightIcon='FahrenheitFill'
148
+ onRightIconClick={() => alert('Icon clicked')}
149
+ tooltip={{
150
+ content: 'You sure?',
151
+ }}
152
+ intent='danger'
153
+ >
154
+ Delete
155
+ </ReqoreMenuItem>
129
156
 
130
- <ReqoreMenuItem icon='Lock2Fill' description='I also have a description'>
131
- This is a really long item that should wrap
132
- </ReqoreMenuItem>
133
- <ReqoreMenuItem icon='Lock2Fill' disabled>
134
- Disabled
135
- </ReqoreMenuItem>
136
- <ReqoreMenuItem icon='Lock2Fill' disabled intent='warning'>
137
- Disabled intent
138
- </ReqoreMenuItem>
139
- <ReqoreMenuDivider label='Divider' />
140
- <ReqorePopover
141
- component={ReqoreMenuItem}
142
- flat={args.flat}
143
- componentProps={
144
- {
145
- icon: 'EmotionUnhappyLine',
146
- rightIcon: 'Scissors2Fill',
147
- leftIconColor: 'danger:lighten',
148
- wrap: args.wrapText,
149
- flat: args.flat,
150
- } as IReqoreMenuItemProps
151
- }
152
- openOnMount
153
- content={
154
- <ReqoreMenu {...args}>
155
- <ReqoreMenuItem icon='ZhihuFill'>Item 1</ReqoreMenuItem>
156
- <ReqoreMenuItem
157
- icon='AccountCircleFill'
158
- description='Would you look at that beautiful description'
159
- intent='warning'
160
- >
161
- Item 2
162
- </ReqoreMenuItem>
163
- <ReqoreMenuItem icon='AnticlockwiseFill' disabled>
164
- Item 3
165
- </ReqoreMenuItem>
166
- <ReqoreMenuItem
167
- icon='ArchiveFill'
168
- badge={{
169
- label: '10',
170
- effect: { gradient: { colors: { 0: '#00e3e8', 100: '#eb0e8c' } } },
171
- }}
172
- >
173
- Item 4
174
- </ReqoreMenuItem>
175
- </ReqoreMenu>
176
- }
177
- isReqoreComponent
178
- noWrapper
179
- handler='click'
180
- placement='right'
181
- >
182
- I have a submenu on click
183
- </ReqorePopover>
184
- <ReqoreMenuDivider
185
- label='Fancy divider'
186
- effect={{ gradient: { colors: { 0: '#0d5ba5', 100: '#ff5dfd' } } }}
187
- align='left'
188
- />
189
- <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine' selected>
190
- I am selected!
191
- </ReqoreMenuItem>
192
- <ReqoreMenuItem
193
- icon='FireLine'
194
- rightIcon='ArrowRightDownLine'
195
- effect={{
196
- gradient: {
197
- colors: {
198
- 0: '#000000',
199
- 100: 'transparent',
157
+ <ReqoreMenuItem
158
+ icon='BluetoothConnectLine'
159
+ rightIcon='EditLine'
160
+ onRightIconClick={() => alert('Icon clicked')}
161
+ description='Button with right icon and description'
162
+ customTheme={{
163
+ main: 'info:darken:1:0.3',
164
+ }}
165
+ >
166
+ Some button
167
+ </ReqoreMenuItem>
168
+
169
+ <ReqoreMenuItem icon='Lock2Fill' description='I also have a description'>
170
+ This is a really long item that should wrap
171
+ </ReqoreMenuItem>
172
+ <ReqoreMenuItem icon='Lock2Fill' disabled>
173
+ Disabled
174
+ </ReqoreMenuItem>
175
+ <ReqoreMenuItem icon='Lock2Fill' disabled intent='warning'>
176
+ Disabled intent
177
+ </ReqoreMenuItem>
178
+ <ReqoreMenuDivider label='Divider' />
179
+ <ReqorePopover
180
+ component={ReqoreMenuItem}
181
+ flat={args.flat}
182
+ componentProps={
183
+ {
184
+ icon: 'EmotionUnhappyLine',
185
+ rightIcon: 'Scissors2Fill',
186
+ leftIconColor: 'danger:lighten',
187
+ wrap: args.wrapText,
188
+ flat: args.flat,
189
+ } as IReqoreMenuItemProps
190
+ }
191
+ openOnMount
192
+ content={
193
+ <ReqoreMenu {...args}>
194
+ <ReqoreMenuItem icon='ZhihuFill'>Item 1</ReqoreMenuItem>
195
+ <ReqoreMenuItem
196
+ icon='AccountCircleFill'
197
+ description='Would you look at that beautiful description'
198
+ intent='warning'
199
+ >
200
+ Item 2
201
+ </ReqoreMenuItem>
202
+ <ReqoreMenuItem icon='AnticlockwiseFill' disabled>
203
+ Item 3
204
+ </ReqoreMenuItem>
205
+ <ReqoreMenuItem
206
+ icon='ArchiveFill'
207
+ badge={{
208
+ label: '10',
209
+ effect: { gradient: { colors: { 0: '#00e3e8', 100: '#eb0e8c' } } },
210
+ }}
211
+ >
212
+ Item 4
213
+ </ReqoreMenuItem>
214
+ </ReqoreMenu>
215
+ }
216
+ isReqoreComponent
217
+ noWrapper
218
+ handler='click'
219
+ placement='right'
220
+ >
221
+ I have a submenu on click
222
+ </ReqorePopover>
223
+ <ReqoreMenuDivider
224
+ label='Fancy divider'
225
+ effect={{ gradient: { colors: { 0: '#0d5ba5', 100: '#ff5dfd' } } }}
226
+ align='left'
227
+ padded='none'
228
+ margin='none'
229
+ />
230
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine' selected>
231
+ I am selected!
232
+ </ReqoreMenuItem>
233
+ <ReqoreMenuItem
234
+ icon='FireLine'
235
+ rightIcon='ArrowRightDownLine'
236
+ effect={{
237
+ gradient: {
238
+ colors: {
239
+ 0: '#000000',
240
+ 100: 'transparent',
241
+ },
200
242
  },
201
- },
202
- }}
203
- description='I also have a description'
204
- badge={10}
205
- >
206
- Fancy
207
- </ReqoreMenuItem>
208
- </ReqoreMenu>
243
+ }}
244
+ description='I also have a description'
245
+ badge={10}
246
+ >
247
+ Fancy
248
+ </ReqoreMenuItem>
249
+ </ReqoreMenu>
250
+ <MenuWithSubmenus {...args} />
251
+ </ReqoreControlGroup>
209
252
  );
210
253
  };
211
254
 
@@ -252,3 +295,13 @@ export const Transparent: Story = {
252
295
  transparent: true,
253
296
  },
254
297
  };
298
+
299
+ export const SubmenuCanBeToggled: Story = {
300
+ render: (args) => <MenuWithSubmenus {...args} />,
301
+ play: async ({ canvasElement, ...rest }) => {
302
+ const canvas = within(canvasElement);
303
+
304
+ await fireEvent.click(canvas.queryAllByText('Submenu 2 active')[0]);
305
+ await fireEvent.click(canvas.queryAllByText('Collapsed submenu')[0]);
306
+ },
307
+ };