@qoretechnologies/reqore 0.39.0 → 0.40.1

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 (50) hide show
  1. package/dist/components/Button/index.d.ts.map +1 -1
  2. package/dist/components/Button/index.js +1 -1
  3. package/dist/components/Button/index.js.map +1 -1
  4. package/dist/components/ControlGroup/index.d.ts +4 -2
  5. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  6. package/dist/components/ControlGroup/index.js +13 -33
  7. package/dist/components/ControlGroup/index.js.map +1 -1
  8. package/dist/components/Menu/index.d.ts +2 -0
  9. package/dist/components/Menu/index.d.ts.map +1 -1
  10. package/dist/components/Menu/index.js +17 -16
  11. package/dist/components/Menu/index.js.map +1 -1
  12. package/dist/components/Menu/section.d.ts +12 -0
  13. package/dist/components/Menu/section.d.ts.map +1 -0
  14. package/dist/components/Menu/section.js +64 -0
  15. package/dist/components/Menu/section.js.map +1 -0
  16. package/dist/hooks/useCloneThroughFragments.d.ts +5 -0
  17. package/dist/hooks/useCloneThroughFragments.d.ts.map +1 -0
  18. package/dist/hooks/useCloneThroughFragments.js +53 -0
  19. package/dist/hooks/useCloneThroughFragments.js.map +1 -0
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +6 -4
  23. package/dist/index.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/Button/index.tsx +8 -1
  26. package/src/components/ControlGroup/index.tsx +59 -80
  27. package/src/components/Menu/index.tsx +15 -16
  28. package/src/components/Menu/section.tsx +81 -0
  29. package/src/hooks/useCloneThroughFragments.ts +39 -0
  30. package/src/index.tsx +2 -1
  31. package/src/mock/menu.ts +46 -48
  32. package/src/stories/Menu/Menu.stories.tsx +171 -108
  33. package/tests.json +1 -1
  34. package/__tests__/sidebar.test.tsx +0 -225
  35. package/dist/components/Sidebar/index.d.ts +0 -60
  36. package/dist/components/Sidebar/index.d.ts.map +0 -1
  37. package/dist/components/Sidebar/index.js +0 -266
  38. package/dist/components/Sidebar/index.js.map +0 -1
  39. package/dist/components/Sidebar/item.d.ts +0 -35
  40. package/dist/components/Sidebar/item.d.ts.map +0 -1
  41. package/dist/components/Sidebar/item.js +0 -98
  42. package/dist/components/Sidebar/item.js.map +0 -1
  43. package/dist/helpers/sidebar.d.ts +0 -5
  44. package/dist/helpers/sidebar.d.ts.map +0 -1
  45. package/dist/helpers/sidebar.js +0 -92
  46. package/dist/helpers/sidebar.js.map +0 -1
  47. package/src/components/Sidebar/index.tsx +0 -536
  48. package/src/components/Sidebar/item.tsx +0 -264
  49. package/src/helpers/sidebar.ts +0 -89
  50. package/src/stories/Sidebar/Sidebar.stories.tsx +0 -97
@@ -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,162 @@ 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
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
100
103
  </ReqoreMenuItem>
101
- <ReqoreMenuItem icon='Save3Fill' badge={10}>
102
- Save
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, 20]}>
141
+ Save this item
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
+ <>
158
+ <ReqoreMenuItem
159
+ icon='BluetoothConnectLine'
160
+ rightIcon='EditLine'
161
+ onRightIconClick={() => alert('Icon clicked')}
162
+ description='Button with right icon and description'
163
+ customTheme={{
164
+ main: 'info:darken:1:0.3',
165
+ }}
166
+ >
167
+ Some button
168
+ </ReqoreMenuItem>
169
+ </>
170
+
171
+ <ReqoreMenuItem icon='Lock2Fill' description='I also have a description'>
172
+ This is a really long item that should wrap
173
+ </ReqoreMenuItem>
174
+ <ReqoreMenuItem icon='Lock2Fill' disabled>
175
+ Disabled
176
+ </ReqoreMenuItem>
177
+ <ReqoreMenuItem icon='Lock2Fill' disabled intent='warning'>
178
+ Disabled intent
179
+ </ReqoreMenuItem>
180
+ <ReqoreMenuDivider label='Divider' />
181
+ <ReqorePopover
182
+ component={ReqoreMenuItem}
183
+ flat={args.flat}
184
+ componentProps={
185
+ {
186
+ icon: 'EmotionUnhappyLine',
187
+ rightIcon: 'Scissors2Fill',
188
+ leftIconColor: 'danger:lighten',
189
+ wrap: args.wrapText,
190
+ flat: args.flat,
191
+ } as IReqoreMenuItemProps
192
+ }
193
+ openOnMount
194
+ content={
195
+ <ReqoreMenu {...args}>
196
+ <ReqoreMenuItem icon='ZhihuFill'>Item 1</ReqoreMenuItem>
197
+ <ReqoreMenuItem
198
+ icon='AccountCircleFill'
199
+ description='Would you look at that beautiful description'
200
+ intent='warning'
201
+ >
202
+ Item 2
203
+ </ReqoreMenuItem>
204
+ <ReqoreMenuItem icon='AnticlockwiseFill' disabled>
205
+ Item 3
206
+ </ReqoreMenuItem>
207
+ <ReqoreMenuItem
208
+ icon='ArchiveFill'
209
+ badge={{
210
+ label: '10',
211
+ effect: { gradient: { colors: { 0: '#00e3e8', 100: '#eb0e8c' } } },
212
+ }}
213
+ >
214
+ Item 4
215
+ </ReqoreMenuItem>
216
+ </ReqoreMenu>
217
+ }
218
+ isReqoreComponent
219
+ noWrapper
220
+ handler='click'
221
+ placement='right'
222
+ >
223
+ I have a submenu on click
224
+ </ReqorePopover>
225
+ <ReqoreMenuDivider
226
+ label='Fancy divider'
227
+ effect={{ gradient: { colors: { 0: '#0d5ba5', 100: '#ff5dfd' } } }}
228
+ align='left'
229
+ padded='none'
230
+ margin='none'
231
+ />
232
+ <ReqoreMenuItem icon='DualSim1Line' rightIcon='MoneyEuroBoxLine' selected>
233
+ I am selected!
234
+ </ReqoreMenuItem>
235
+ <ReqoreMenuItem
236
+ icon='FireLine'
237
+ rightIcon='ArrowRightDownLine'
238
+ effect={{
239
+ gradient: {
240
+ colors: {
241
+ 0: '#000000',
242
+ 100: 'transparent',
243
+ },
200
244
  },
201
- },
202
- }}
203
- description='I also have a description'
204
- badge={10}
205
- >
206
- Fancy
207
- </ReqoreMenuItem>
208
- </ReqoreMenu>
245
+ }}
246
+ description='I also have a description'
247
+ badge={10}
248
+ >
249
+ Fancy
250
+ </ReqoreMenuItem>
251
+ </ReqoreMenu>
252
+ <MenuWithSubmenus {...args} />
253
+ </ReqoreControlGroup>
209
254
  );
210
255
  };
211
256
 
@@ -252,3 +297,21 @@ export const Transparent: Story = {
252
297
  transparent: true,
253
298
  },
254
299
  };
300
+
301
+ export const BigGapSize: Story = {
302
+ render: Template,
303
+
304
+ args: {
305
+ itemGap: 'big',
306
+ },
307
+ };
308
+
309
+ export const SubmenuCanBeToggled: Story = {
310
+ render: (args) => <MenuWithSubmenus {...args} />,
311
+ play: async ({ canvasElement, ...rest }) => {
312
+ const canvas = within(canvasElement);
313
+
314
+ await fireEvent.click(canvas.queryAllByText('Submenu 2 active')[0]);
315
+ await fireEvent.click(canvas.queryAllByText('Collapsed submenu')[0]);
316
+ },
317
+ };