@qoretechnologies/reqore 0.40.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.
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +13 -33
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Menu/index.d.ts +2 -0
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +17 -16
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/section.d.ts.map +1 -1
- package/dist/components/Menu/section.js +14 -37
- package/dist/components/Menu/section.js.map +1 -1
- package/dist/hooks/useCloneThroughFragments.d.ts +5 -0
- package/dist/hooks/useCloneThroughFragments.d.ts.map +1 -0
- package/dist/hooks/useCloneThroughFragments.js +53 -0
- package/dist/hooks/useCloneThroughFragments.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +8 -1
- package/src/components/ControlGroup/index.tsx +51 -76
- package/src/components/Menu/index.tsx +15 -16
- package/src/components/Menu/section.tsx +11 -12
- package/src/hooks/useCloneThroughFragments.ts +39 -0
- package/src/index.tsx +1 -0
- package/src/stories/Menu/Menu.stories.tsx +23 -13
- package/tests.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAwE;AAA/D,wEAA4B;AACrC,sDAAiF;AAAxE,qEAAgC;AACzC,8CAA8D;AAArD,8DAAuB;AAChC,kDAAkE;AAAzD,kEAAyB;AAClC,sDAA2D;AAAlD,2DAAgB;AACzB,gDAAq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qDAAyE;AAAhE,oEAA4B;AACrC,+CAAuE;AAA9D,kEAA6B;AACtC,+CAAmE;AAA1D,8DAAyB;AAClC,wCAAwD;AAA/C,wDAAoB;AAC7B,gDAAmE;AAA1D,+DAAyB;AAClC,kDAAkE;AAAzD,kEAAyB;AAClC,gDAAgE;AAAvD,gEAAwB;AACjC,0CAA+C;AAAtC,+CAAU;AACnB,6CAA4D;AAAnD,6DAAsB;AAC/B,2CAAgD;AAAvC,iDAAW;AACpB,2CAAkD;AAAzC,mDAAa;AACtB,8CAAgE;AAAvD,gEAAyB;AAClC,8DAA6E;AAApE,6EAA8B;AACvC,sDAAsE;AAA7D,sEAA2B;AACpC,yDAAmE;AAA1D,sEAAwB;AACjC,uDAAuE;AAA9D,0EAA6B;AACtC,6EAA4E;AAAnE,iFAAwB;AACjC,2DAAqE;AAA5D,0EAA0B;AACnC,+CAAoD;AAA3C,yDAAe;AACxB,+CAA8C;AAArC,mDAAS;AAClB,6DAA6D;AAApD,kEAAiB;AAC1B,6CAAkD;AAAzC,uDAAc"}
|
package/package.json
CHANGED
|
@@ -475,7 +475,14 @@ const ReqoreButton = memo(
|
|
|
475
475
|
</StyledAnimatedTextWrapper>
|
|
476
476
|
)}
|
|
477
477
|
{(badge || badge === 0) && !wrap ? (
|
|
478
|
-
<ButtonBadge
|
|
478
|
+
<ButtonBadge
|
|
479
|
+
content={badge}
|
|
480
|
+
size={size}
|
|
481
|
+
theme={theme}
|
|
482
|
+
compact={compact}
|
|
483
|
+
wrapGroup={false}
|
|
484
|
+
wrap={false}
|
|
485
|
+
/>
|
|
479
486
|
) : null}
|
|
480
487
|
{!hasRightIcon ? (
|
|
481
488
|
_children ? (
|
|
@@ -5,6 +5,7 @@ import styled, { css } from 'styled-components';
|
|
|
5
5
|
import { ReqoreButton, ReqoreDrawer } from '../..';
|
|
6
6
|
import { GAP_FROM_SIZE, RADIUS_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
7
7
|
import { IReqoreTheme } from '../../constants/theme';
|
|
8
|
+
import { useCloneThroughFragments } from '../../hooks/useCloneThroughFragments';
|
|
8
9
|
import {
|
|
9
10
|
IReqoreIntent,
|
|
10
11
|
IWithReqoreCustomTheme,
|
|
@@ -356,81 +357,56 @@ const ReqoreControlGroup = memo(
|
|
|
356
357
|
return undefined;
|
|
357
358
|
};
|
|
358
359
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
isFirst: isChild ? getIsFirst(index) : undefined,
|
|
408
|
-
isLast: isChild ? getIsLast(index) : undefined,
|
|
409
|
-
isLastInFirstGroup: getIsLastInFirstGroup(index),
|
|
410
|
-
isLastInLastGroup: getIsLastInLastGroup(index),
|
|
411
|
-
isFirstInLastGroup: getIsFirstInLastGroup(index),
|
|
412
|
-
childrenCount: realChildCount,
|
|
413
|
-
childId: index + 1,
|
|
414
|
-
|
|
415
|
-
isFirstGroup: isChild ? isFirstGroup : index === 0,
|
|
416
|
-
isLastGroup: isChild ? isLastGroup : index === realChildCount - 1,
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/*
|
|
421
|
-
* Because of the way React.Children.map works, we have to
|
|
422
|
-
* manually decrement the index for every child that is `null`
|
|
423
|
-
* because react maps through null children and returns them in `Count`
|
|
424
|
-
* We filter these children out in the `realChildCount` variable,
|
|
425
|
-
* but the index is still incremented
|
|
426
|
-
* */
|
|
427
|
-
index = index + 1;
|
|
428
|
-
|
|
429
|
-
return React.cloneElement(child, newProps);
|
|
430
|
-
}
|
|
360
|
+
const { clone } = useCloneThroughFragments(
|
|
361
|
+
(props, _index, index) => {
|
|
362
|
+
let newProps: any = {
|
|
363
|
+
...props,
|
|
364
|
+
key: props.reactKey || _index,
|
|
365
|
+
minimal: props?.minimal || props?.minimal === false ? props.minimal : minimal,
|
|
366
|
+
size: props?.size || size,
|
|
367
|
+
flat: props?.flat || props?.flat === false ? props.flat : flat,
|
|
368
|
+
fluid: props?.fluid || props?.fluid === false ? props.fluid : fluid,
|
|
369
|
+
fixed: props?.fixed || props?.fixed === false ? props.fixed : fixed,
|
|
370
|
+
fill: props?.fill || props?.fill === false ? props.fill : fill,
|
|
371
|
+
stack: props?.stack || props?.stack === false ? props.stack : isStack,
|
|
372
|
+
intent: props?.intent || intent,
|
|
373
|
+
customTheme: props?.customTheme || customTheme,
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
if (isStack) {
|
|
377
|
+
newProps = {
|
|
378
|
+
...newProps,
|
|
379
|
+
style: {
|
|
380
|
+
borderTopLeftRadius: getBorderTopLeftRadius(index, props?.rounded),
|
|
381
|
+
borderBottomLeftRadius: getBorderBottomLeftRadius(index, props?.rounded),
|
|
382
|
+
borderTopRightRadius: getBorderTopRightRadius(index, props?.rounded),
|
|
383
|
+
borderBottomRightRadius: getBorderBottomRightRadius(index, props?.rounded),
|
|
384
|
+
...(props?.style || {}),
|
|
385
|
+
},
|
|
386
|
+
isChild: true,
|
|
387
|
+
rounded:
|
|
388
|
+
isMasterGroupRounded === false
|
|
389
|
+
? false
|
|
390
|
+
: props?.rounded || props?.rounded === false
|
|
391
|
+
? props.rounded
|
|
392
|
+
: !isStack,
|
|
393
|
+
isMasterGroupRounded: isChild ? isMasterGroupRounded : rounded,
|
|
394
|
+
isInsideStackGroup: isStack,
|
|
395
|
+
isInsideVerticalGroup: isVertical,
|
|
396
|
+
isFirst: isChild ? getIsFirst(index) : undefined,
|
|
397
|
+
isLast: isChild ? getIsLast(index) : undefined,
|
|
398
|
+
isLastInFirstGroup: getIsLastInFirstGroup(index),
|
|
399
|
+
isLastInLastGroup: getIsLastInLastGroup(index),
|
|
400
|
+
isFirstInLastGroup: getIsFirstInLastGroup(index),
|
|
401
|
+
childrenCount: realChildCount,
|
|
402
|
+
childId: index + 1,
|
|
403
|
+
|
|
404
|
+
isFirstGroup: isChild ? isFirstGroup : index === 0,
|
|
405
|
+
isLastGroup: isChild ? isLastGroup : index === realChildCount - 1,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
431
408
|
|
|
432
|
-
|
|
433
|
-
});
|
|
409
|
+
return newProps;
|
|
434
410
|
},
|
|
435
411
|
[
|
|
436
412
|
children,
|
|
@@ -440,7 +416,6 @@ const ReqoreControlGroup = memo(
|
|
|
440
416
|
isLastGroup,
|
|
441
417
|
isFirstGroup,
|
|
442
418
|
realChildCount,
|
|
443
|
-
index,
|
|
444
419
|
fluid,
|
|
445
420
|
flat,
|
|
446
421
|
minimal,
|
|
@@ -522,7 +497,7 @@ const ReqoreControlGroup = memo(
|
|
|
522
497
|
horizontalAlign={horizontalAlign}
|
|
523
498
|
className={`${className || ''} reqore-control-group`}
|
|
524
499
|
>
|
|
525
|
-
{
|
|
500
|
+
{clone(_children)}
|
|
526
501
|
</StyledReqoreControlGroup>
|
|
527
502
|
</>
|
|
528
503
|
);
|
|
@@ -4,8 +4,10 @@ import { RADIUS_FROM_SIZE } from '../../constants/sizes';
|
|
|
4
4
|
import { IReqoreCustomTheme, IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
5
5
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
6
6
|
import { changeDarkness, changeLightness, getMainBackgroundColor } from '../../helpers/colors';
|
|
7
|
+
import { useCloneThroughFragments } from '../../hooks/useCloneThroughFragments';
|
|
7
8
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
8
9
|
import { IReqoreComponent, IWithReqoreMinimal, IWithReqoreTransparent } from '../../types/global';
|
|
10
|
+
import ReqoreControlGroup, { IReqoreControlGroupProps } from '../ControlGroup';
|
|
9
11
|
|
|
10
12
|
export interface IReqoreMenuProps
|
|
11
13
|
extends IReqoreComponent,
|
|
@@ -22,6 +24,7 @@ export interface IReqoreMenuProps
|
|
|
22
24
|
flat?: boolean;
|
|
23
25
|
rounded?: boolean;
|
|
24
26
|
padded?: boolean;
|
|
27
|
+
itemGap?: IReqoreControlGroupProps['gapSize'];
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
export interface IReqoreMenuStyle extends IReqoreMenuProps {
|
|
@@ -49,10 +52,6 @@ const StyledReqoreMenu = styled.div<IReqoreMenuStyle>`
|
|
|
49
52
|
)};
|
|
50
53
|
padding-${position === 'left' ? 'right' : 'left'}: 10px;
|
|
51
54
|
`}
|
|
52
|
-
|
|
53
|
-
> *:not(:last-child) {
|
|
54
|
-
margin-bottom: 5px;
|
|
55
|
-
}
|
|
56
55
|
`;
|
|
57
56
|
|
|
58
57
|
const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
@@ -67,11 +66,20 @@ const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
|
67
66
|
wrapText,
|
|
68
67
|
flat = true,
|
|
69
68
|
minimal,
|
|
69
|
+
itemGap,
|
|
70
70
|
...rest
|
|
71
71
|
}: IReqoreMenuProps,
|
|
72
72
|
ref
|
|
73
73
|
) => {
|
|
74
74
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
75
|
+
const { clone } = useCloneThroughFragments((props) => ({
|
|
76
|
+
_insidePopover: props?._insidePopover ?? _insidePopover,
|
|
77
|
+
_popoverId: props?._popoverId ?? _popoverId,
|
|
78
|
+
customTheme: props?.customTheme || theme,
|
|
79
|
+
wrap: 'wrap' in (props || {}) ? props.wrap : wrapText,
|
|
80
|
+
flat: 'flat' in (props || {}) ? props.flat : flat,
|
|
81
|
+
minimal: 'minimal' in (props || {}) ? props.minimal : minimal,
|
|
82
|
+
}));
|
|
75
83
|
|
|
76
84
|
return (
|
|
77
85
|
<ReqoreThemeProvider theme={theme}>
|
|
@@ -82,18 +90,9 @@ const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
|
82
90
|
theme={theme}
|
|
83
91
|
className={`${rest.className || ''} reqore-menu`}
|
|
84
92
|
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_insidePopover: child.props?._insidePopover ?? _insidePopover,
|
|
89
|
-
_popoverId: child.props?._popoverId ?? _popoverId,
|
|
90
|
-
customTheme: child.props?.customTheme || theme,
|
|
91
|
-
wrap: 'wrap' in (child.props || {}) ? child.props.wrap : wrapText,
|
|
92
|
-
flat: 'flat' in (child.props || {}) ? child.props.flat : flat,
|
|
93
|
-
minimal: 'minimal' in (child.props || {}) ? child.props.minimal : minimal,
|
|
94
|
-
})
|
|
95
|
-
: null;
|
|
96
|
-
})}
|
|
93
|
+
<ReqoreControlGroup vertical gapSize={itemGap} fluid>
|
|
94
|
+
{clone(children)}
|
|
95
|
+
</ReqoreControlGroup>
|
|
97
96
|
</StyledReqoreMenu>
|
|
98
97
|
</ReqoreThemeProvider>
|
|
99
98
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { TReqoreIntent } from '../../constants/theme';
|
|
3
|
+
import { useCloneThroughFragments } from '../../hooks/useCloneThroughFragments';
|
|
3
4
|
import { IReqoreComponent } from '../../types/global';
|
|
4
5
|
import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
5
6
|
import ReqoreControlGroup from '../ControlGroup';
|
|
@@ -44,6 +45,15 @@ export const ReqoreMenuSection = ({
|
|
|
44
45
|
[_isCollapsed, onCollapseChange, collapsible, rest.onClick]
|
|
45
46
|
);
|
|
46
47
|
|
|
48
|
+
const { clone } = useCloneThroughFragments((props) => ({
|
|
49
|
+
_insidePopover: props?._insidePopover ?? _insidePopover,
|
|
50
|
+
_popoverId: props?._popoverId ?? _popoverId,
|
|
51
|
+
customTheme: props?.customTheme || customTheme,
|
|
52
|
+
wrap: 'wrap' in (props || {}) ? props.wrap : wrap,
|
|
53
|
+
flat: 'flat' in (props || {}) ? props.flat : flat,
|
|
54
|
+
minimal: 'minimal' in (props || {}) ? props.minimal : minimal,
|
|
55
|
+
}));
|
|
56
|
+
|
|
47
57
|
return (
|
|
48
58
|
<ReqoreControlGroup vertical fluid className='reqore-menu-section'>
|
|
49
59
|
<ReqoreButton
|
|
@@ -63,18 +73,7 @@ export const ReqoreMenuSection = ({
|
|
|
63
73
|
/>
|
|
64
74
|
{!_isCollapsed || !collapsible ? (
|
|
65
75
|
<ReqoreControlGroup vertical fluid style={{ paddingLeft: '10px' }}>
|
|
66
|
-
{
|
|
67
|
-
return child
|
|
68
|
-
? React.cloneElement(child, {
|
|
69
|
-
_insidePopover: child.props?._insidePopover ?? _insidePopover,
|
|
70
|
-
_popoverId: child.props?._popoverId ?? _popoverId,
|
|
71
|
-
customTheme: child.props?.customTheme || customTheme,
|
|
72
|
-
wrap: 'wrap' in (child.props || {}) ? child.props.wrap : wrap,
|
|
73
|
-
flat: 'flat' in (child.props || {}) ? child.props.flat : flat,
|
|
74
|
-
minimal: 'minimal' in (child.props || {}) ? child.props.minimal : minimal,
|
|
75
|
-
})
|
|
76
|
-
: null;
|
|
77
|
-
})}
|
|
76
|
+
{clone(children)}
|
|
78
77
|
</ReqoreControlGroup>
|
|
79
78
|
) : null}
|
|
80
79
|
</ReqoreControlGroup>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useCloneThroughFragments = (
|
|
4
|
+
propsMapper: (
|
|
5
|
+
props: Record<string | number, any>,
|
|
6
|
+
reactIndex: number,
|
|
7
|
+
realIndex: number
|
|
8
|
+
) => Record<string | number, any>,
|
|
9
|
+
deps?: any[]
|
|
10
|
+
) => {
|
|
11
|
+
let realIndex = 0;
|
|
12
|
+
|
|
13
|
+
const clone = useCallback((children: React.ReactNode): React.ReactNode => {
|
|
14
|
+
return React.Children.map(children, (child, reactIndex) => {
|
|
15
|
+
if (child && React.isValidElement(child)) {
|
|
16
|
+
if (child.type === React.Fragment) {
|
|
17
|
+
return clone(child.props.children);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const props = propsMapper(child.props, reactIndex, realIndex);
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Because of the way React.Children.map works, we have to
|
|
24
|
+
* manually decrement the index for every child that is `null`
|
|
25
|
+
* because react maps through null children and returns them in `Count`
|
|
26
|
+
* We filter these children out in the `realChildCount` variable,
|
|
27
|
+
* but the index is still incremented
|
|
28
|
+
* */
|
|
29
|
+
realIndex = realIndex + 1;
|
|
30
|
+
|
|
31
|
+
return React.cloneElement(child, props);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return child;
|
|
35
|
+
});
|
|
36
|
+
}, deps);
|
|
37
|
+
|
|
38
|
+
return { clone };
|
|
39
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -69,6 +69,7 @@ export { default as ReqoreNotifications } from './containers/ReqoreProvider';
|
|
|
69
69
|
export { default as ReqoreUIProvider } from './containers/UIProvider';
|
|
70
70
|
export { default as ReqoreContext } from './context/ReqoreContext';
|
|
71
71
|
export { default as ReqoreThemeContext } from './context/ThemeContext';
|
|
72
|
+
export { useCloneThroughFragments } from './hooks/useCloneThroughFragments';
|
|
72
73
|
export { default as useLatestZIndex } from './hooks/useLatestZIndex';
|
|
73
74
|
export { useReqorePaging } from './hooks/usePaging';
|
|
74
75
|
export { useReqore } from './hooks/useReqore';
|
|
@@ -137,8 +137,8 @@ const Template: StoryFn<IReqoreMenuProps> = (args) => {
|
|
|
137
137
|
<ReqoreMenuItem icon='Save3Fill' intent='success' selected>
|
|
138
138
|
Selected success
|
|
139
139
|
</ReqoreMenuItem>
|
|
140
|
-
<ReqoreMenuItem icon='Save3Fill' badge={10}>
|
|
141
|
-
Save
|
|
140
|
+
<ReqoreMenuItem icon='Save3Fill' badge={[10, 20]}>
|
|
141
|
+
Save this item
|
|
142
142
|
</ReqoreMenuItem>
|
|
143
143
|
<ReqoreMenuDivider label='BIG Divider' size='huge' />
|
|
144
144
|
<ReqoreMenuItem
|
|
@@ -154,17 +154,19 @@ const Template: StoryFn<IReqoreMenuProps> = (args) => {
|
|
|
154
154
|
Delete
|
|
155
155
|
</ReqoreMenuItem>
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
</>
|
|
168
170
|
|
|
169
171
|
<ReqoreMenuItem icon='Lock2Fill' description='I also have a description'>
|
|
170
172
|
This is a really long item that should wrap
|
|
@@ -296,6 +298,14 @@ export const Transparent: Story = {
|
|
|
296
298
|
},
|
|
297
299
|
};
|
|
298
300
|
|
|
301
|
+
export const BigGapSize: Story = {
|
|
302
|
+
render: Template,
|
|
303
|
+
|
|
304
|
+
args: {
|
|
305
|
+
itemGap: 'big',
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
|
|
299
309
|
export const SubmenuCanBeToggled: Story = {
|
|
300
310
|
render: (args) => <MenuWithSubmenus {...args} />,
|
|
301
311
|
play: async ({ canvasElement, ...rest }) => {
|