@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
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
11
11
  o[k2] = m[k];
12
12
  }));
13
13
  exports.__esModule = true;
14
- exports.ReqoreHorizontalSpacer = exports.ReqoreSidebar = exports.ReqoreRadioGroup = exports.ReqorePopover = exports.ReqoreParagraph = exports.ReqoreP = exports.ReqorePanel = exports.ReqorePagination = exports.ReqoreNotification = exports.ReqoreNotificationsWrapper = exports.ReqoreNavbarItem = exports.ReqoreNavbarGroup = exports.ReqoreNavbarDivider = exports.ReqoreHeader = exports.ReqoreFooter = exports.ReqoreMultiSelect = exports.ReqoreModal = exports.ReqoreMessage = exports.ReqoreMenuItem = exports.ReqoreMenuDivider = exports.ReqoreMenu = exports.ReqoreLayoutContent = exports.ReqoreKeyValueTable = exports.ReqoreInput = exports.ReqoreIcon = exports.ReqoreHeading = exports.ReqoreH6 = exports.ReqoreH5 = exports.ReqoreH4 = exports.ReqoreH3 = exports.ReqoreH2 = exports.ReqoreH1 = exports.ReqoreTextEffect = exports.ReqoreEffect = exports.ReqoreDropdownItem = exports.ReqoreDropdownDivider = exports.ReqoreDropdown = exports.ReqoreBackdrop = exports.ReqoreDrawer = exports.ReqoreControlGroup = exports.ReqoreContent = exports.ReqoreCommentFeed = exports.ReqoreComment = exports.ReqoreColumn = exports.ReqoreColumns = exports.ReqoreCollection = exports.ReqoreCheckbox = exports.ReqoreButton = exports.ReqoreBreadcrumbsItem = exports.ReqoreBreadcrumbs = void 0;
15
- exports.useReqoreTheme = exports.useReqoreProperty = exports.useReqore = exports.useReqorePaging = exports.useLatestZIndex = exports.ReqoreThemeContext = exports.ReqoreContext = exports.ReqoreUIProvider = exports.ReqoreNotifications = exports.ReqorePaginationContainer = exports.ReqoreIntents = exports.ReqoreSizes = exports.ReqoreColors = exports.ReqoreTree = exports.ReqoreTimeAgo = exports.ReqoreTextarea = exports.ReqoreTagGroup = exports.ReqoreTag = exports.ReqoreTabsList = exports.ReqoreTabsListItem = exports.ReqoreTabsContent = exports.ReqoreTabs = exports.ReqoreTableValue = exports.ReqoreTableRow = exports.ReqoreTableHeaderCell = exports.ReqoreTableBodyCell = exports.ReqoreTable = exports.ReqoreSpinner = exports.ReqoreVerticalSpacer = exports.ReqoreSpacer = void 0;
14
+ exports.ReqoreHorizontalSpacer = exports.ReqoreRadioGroup = exports.ReqorePopover = exports.ReqoreParagraph = exports.ReqoreP = exports.ReqorePanel = exports.ReqorePagination = exports.ReqoreNotification = exports.ReqoreNotificationsWrapper = exports.ReqoreNavbarItem = exports.ReqoreNavbarGroup = exports.ReqoreNavbarDivider = exports.ReqoreHeader = exports.ReqoreFooter = exports.ReqoreMultiSelect = exports.ReqoreModal = exports.ReqoreMessage = exports.ReqoreMenuSection = exports.ReqoreMenuItem = exports.ReqoreMenuDivider = exports.ReqoreMenu = exports.ReqoreLayoutContent = exports.ReqoreKeyValueTable = exports.ReqoreInput = exports.ReqoreIcon = exports.ReqoreHeading = exports.ReqoreH6 = exports.ReqoreH5 = exports.ReqoreH4 = exports.ReqoreH3 = exports.ReqoreH2 = exports.ReqoreH1 = exports.ReqoreTextEffect = exports.ReqoreEffect = exports.ReqoreDropdownItem = exports.ReqoreDropdownDivider = exports.ReqoreDropdown = exports.ReqoreBackdrop = exports.ReqoreDrawer = exports.ReqoreControlGroup = exports.ReqoreContent = exports.ReqoreCommentFeed = exports.ReqoreComment = exports.ReqoreColumn = exports.ReqoreColumns = exports.ReqoreCollection = exports.ReqoreCheckbox = exports.ReqoreButton = exports.ReqoreBreadcrumbsItem = exports.ReqoreBreadcrumbs = void 0;
15
+ exports.useReqoreTheme = exports.useReqoreProperty = exports.useReqore = exports.useReqorePaging = exports.useLatestZIndex = exports.useCloneThroughFragments = exports.ReqoreThemeContext = exports.ReqoreContext = exports.ReqoreUIProvider = exports.ReqoreNotifications = exports.ReqorePaginationContainer = exports.ReqoreIntents = exports.ReqoreSizes = exports.ReqoreColors = exports.ReqoreTree = exports.ReqoreTimeAgo = exports.ReqoreTextarea = exports.ReqoreTagGroup = exports.ReqoreTag = exports.ReqoreTabsList = exports.ReqoreTabsListItem = exports.ReqoreTabsContent = exports.ReqoreTabs = exports.ReqoreTableValue = exports.ReqoreTableRow = exports.ReqoreTableHeaderCell = exports.ReqoreTableBodyCell = exports.ReqoreTable = exports.ReqoreSpinner = exports.ReqoreVerticalSpacer = exports.ReqoreSpacer = void 0;
16
16
  var Breadcrumbs_1 = require("./components/Breadcrumbs");
17
17
  __createBinding(exports, Breadcrumbs_1, "default", "ReqoreBreadcrumbs");
18
18
  var item_1 = require("./components/Breadcrumbs/item");
@@ -69,6 +69,8 @@ var divider_1 = require("./components/Menu/divider");
69
69
  __createBinding(exports, divider_1, "default", "ReqoreMenuDivider");
70
70
  var item_3 = require("./components/Menu/item");
71
71
  __createBinding(exports, item_3, "default", "ReqoreMenuItem");
72
+ var section_1 = require("./components/Menu/section");
73
+ __createBinding(exports, section_1, "ReqoreMenuSection");
72
74
  var Message_1 = require("./components/Message");
73
75
  __createBinding(exports, Message_1, "default", "ReqoreMessage");
74
76
  var Modal_1 = require("./components/Modal");
@@ -99,8 +101,6 @@ var Popover_1 = require("./components/Popover");
99
101
  __createBinding(exports, Popover_1, "default", "ReqorePopover");
100
102
  var RadioGroup_1 = require("./components/RadioGroup");
101
103
  __createBinding(exports, RadioGroup_1, "default", "ReqoreRadioGroup");
102
- var Sidebar_1 = require("./components/Sidebar");
103
- __createBinding(exports, Sidebar_1, "default", "ReqoreSidebar");
104
104
  var Spacer_1 = require("./components/Spacer");
105
105
  __createBinding(exports, Spacer_1, "ReqoreHorizontalSpacer");
106
106
  __createBinding(exports, Spacer_1, "ReqoreSpacer");
@@ -151,6 +151,8 @@ var ReqoreContext_1 = require("./context/ReqoreContext");
151
151
  __createBinding(exports, ReqoreContext_1, "default", "ReqoreContext");
152
152
  var ThemeContext_1 = require("./context/ThemeContext");
153
153
  __createBinding(exports, ThemeContext_1, "default", "ReqoreThemeContext");
154
+ var useCloneThroughFragments_1 = require("./hooks/useCloneThroughFragments");
155
+ __createBinding(exports, useCloneThroughFragments_1, "useCloneThroughFragments");
154
156
  var useLatestZIndex_1 = require("./hooks/useLatestZIndex");
155
157
  __createBinding(exports, useLatestZIndex_1, "default", "useLatestZIndex");
156
158
  var usePaging_1 = require("./hooks/usePaging");
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,gDAAqD;AAA5C,qDAAa;AACtB,sDAA2D;AAAlD,mDAAY;AACrB,gDAAqD;AAA5C,qDAAa;AACtB,wDAA6D;AAApD,6DAAiB;AAC1B,gDAAgE;AAAvD,gEAAwB;AACjC,0DAA0E;AAAjE,0EAA6B;AACtC,8CAAmD;AAA1C,mDAAY;AACrB,yDAA8D;AAArD,uDAAc;AACvB,kDAAkE;AAAzD,kEAAyB;AAClC,mDAAuF;AAA9E,0DAAqB;AAAE,uDAAkB;AAClD,8CAAqE;AAA5D,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ACtB,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qoretechnologies/reqore",
3
- "version": "0.39.0",
3
+ "version": "0.40.1",
4
4
  "description": "ReQore is a highly theme-able and modular UI library for React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -475,7 +475,14 @@ const ReqoreButton = memo(
475
475
  </StyledAnimatedTextWrapper>
476
476
  )}
477
477
  {(badge || badge === 0) && !wrap ? (
478
- <ButtonBadge content={badge} size={size} theme={theme} compact={compact} />
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,
@@ -17,16 +18,14 @@ import { StyledEffect } from '../Effect';
17
18
  import { StyledHeader } from '../Header';
18
19
  import { StyledParagraph } from '../Paragraph';
19
20
 
20
- export interface IReqoreControlGroupProps
21
- extends React.HTMLAttributes<HTMLDivElement>,
22
- IWithReqoreFlat,
21
+ export interface IReqoreControlGroupComponentProps
22
+ extends IWithReqoreFlat,
23
23
  IWithReqoreSize,
24
24
  IWithReqoreMinimal,
25
25
  IReqoreIntent,
26
26
  IWithReqoreFluid,
27
27
  IWithReqoreCustomTheme {
28
28
  stack?: boolean;
29
- children: any;
30
29
  fixed?: boolean;
31
30
  rounded?: boolean;
32
31
  responsive?: boolean;
@@ -54,6 +53,12 @@ export interface IReqoreControlGroupProps
54
53
  fill?: boolean;
55
54
  }
56
55
 
56
+ export interface IReqoreControlGroupProps
57
+ extends React.HTMLAttributes<HTMLDivElement>,
58
+ IReqoreControlGroupComponentProps {
59
+ children: any;
60
+ }
61
+
57
62
  export interface IReqoreControlGroupStyle extends IReqoreControlGroupProps {
58
63
  theme: IReqoreTheme;
59
64
  }
@@ -352,81 +357,56 @@ const ReqoreControlGroup = memo(
352
357
  return undefined;
353
358
  };
354
359
 
355
- let index = 0;
356
-
357
- const cloneThroughFragments = useCallback(
358
- (children: React.ReactNode): React.ReactNode => {
359
- return React.Children.map(children, (child, _index) => {
360
- if (child && React.isValidElement(child)) {
361
- if (child.type === React.Fragment) {
362
- return cloneThroughFragments(child.props.children);
363
- }
364
-
365
- let newProps = {
366
- ...child.props,
367
- key: child.props.reactKey || _index,
368
- minimal:
369
- child.props?.minimal || child.props?.minimal === false
370
- ? child.props.minimal
371
- : minimal,
372
- size: child.props?.size || size,
373
- flat: child.props?.flat || child.props?.flat === false ? child.props.flat : flat,
374
- fluid: child.props?.fluid || child.props?.fluid === false ? child.props.fluid : fluid,
375
- fixed: child.props?.fixed || child.props?.fixed === false ? child.props.fixed : fixed,
376
- fill: child.props?.fill || child.props?.fill === false ? child.props.fill : fill,
377
- stack:
378
- child.props?.stack || child.props?.stack === false ? child.props.stack : isStack,
379
- intent: child.props?.intent || intent,
380
- customTheme: child.props?.customTheme || customTheme,
381
- };
382
-
383
- if (isStack) {
384
- newProps = {
385
- ...newProps,
386
- style: {
387
- borderTopLeftRadius: getBorderTopLeftRadius(index, child.props?.rounded),
388
- borderBottomLeftRadius: getBorderBottomLeftRadius(index, child.props?.rounded),
389
- borderTopRightRadius: getBorderTopRightRadius(index, child.props?.rounded),
390
- borderBottomRightRadius: getBorderBottomRightRadius(index, child.props?.rounded),
391
- ...(child.props?.style || {}),
392
- },
393
- isChild: true,
394
- rounded:
395
- isMasterGroupRounded === false
396
- ? false
397
- : child.props?.rounded || child.props?.rounded === false
398
- ? child.props.rounded
399
- : !isStack,
400
- isMasterGroupRounded: isChild ? isMasterGroupRounded : rounded,
401
- isInsideStackGroup: isStack,
402
- isInsideVerticalGroup: isVertical,
403
- isFirst: isChild ? getIsFirst(index) : undefined,
404
- isLast: isChild ? getIsLast(index) : undefined,
405
- isLastInFirstGroup: getIsLastInFirstGroup(index),
406
- isLastInLastGroup: getIsLastInLastGroup(index),
407
- isFirstInLastGroup: getIsFirstInLastGroup(index),
408
- childrenCount: realChildCount,
409
- childId: index + 1,
410
-
411
- isFirstGroup: isChild ? isFirstGroup : index === 0,
412
- isLastGroup: isChild ? isLastGroup : index === realChildCount - 1,
413
- };
414
- }
415
-
416
- /*
417
- * Because of the way React.Children.map works, we have to
418
- * manually decrement the index for every child that is `null`
419
- * because react maps through null children and returns them in `Count`
420
- * We filter these children out in the `realChildCount` variable,
421
- * but the index is still incremented
422
- * */
423
- index = index + 1;
424
-
425
- return React.cloneElement(child, newProps);
426
- }
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
+ }
427
408
 
428
- return child;
429
- });
409
+ return newProps;
430
410
  },
431
411
  [
432
412
  children,
@@ -436,7 +416,6 @@ const ReqoreControlGroup = memo(
436
416
  isLastGroup,
437
417
  isFirstGroup,
438
418
  realChildCount,
439
- index,
440
419
  fluid,
441
420
  flat,
442
421
  minimal,
@@ -518,7 +497,7 @@ const ReqoreControlGroup = memo(
518
497
  horizontalAlign={horizontalAlign}
519
498
  className={`${className || ''} reqore-control-group`}
520
499
  >
521
- {cloneThroughFragments(_children)}
500
+ {clone(_children)}
522
501
  </StyledReqoreControlGroup>
523
502
  </>
524
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
- {React.Children.map(children, (child) => {
86
- return child
87
- ? React.cloneElement(child, {
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
  );
@@ -0,0 +1,81 @@
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { TReqoreIntent } from '../../constants/theme';
3
+ import { useCloneThroughFragments } from '../../hooks/useCloneThroughFragments';
4
+ import { IReqoreComponent } from '../../types/global';
5
+ import ReqoreButton, { IReqoreButtonProps } from '../Button';
6
+ import ReqoreControlGroup from '../ControlGroup';
7
+
8
+ export interface IReqoreMenuSectionProps extends IReqoreComponent, IReqoreButtonProps {
9
+ children: any;
10
+ collapsible?: boolean;
11
+ isCollapsed?: boolean;
12
+ onCollapseChange?: (collapsed: boolean) => void;
13
+ activeIntent?: TReqoreIntent;
14
+ }
15
+
16
+ export const ReqoreMenuSection = ({
17
+ children,
18
+ _insidePopover,
19
+ _popoverId,
20
+ customTheme,
21
+ wrap,
22
+ flat,
23
+ minimal,
24
+ collapsible = true,
25
+ isCollapsed,
26
+ activeIntent,
27
+ onCollapseChange,
28
+ ...rest
29
+ }: IReqoreMenuSectionProps) => {
30
+ const [_isCollapsed, setIsCollapsed] = useState(isCollapsed);
31
+
32
+ useEffect(() => {
33
+ setIsCollapsed(isCollapsed);
34
+ }, [isCollapsed]);
35
+
36
+ const handleCollapseChange = useCallback(
37
+ (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
38
+ if (collapsible) {
39
+ setIsCollapsed(!_isCollapsed);
40
+ onCollapseChange?.(!_isCollapsed);
41
+ }
42
+
43
+ rest.onClick?.(event);
44
+ },
45
+ [_isCollapsed, onCollapseChange, collapsible, rest.onClick]
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
+
57
+ return (
58
+ <ReqoreControlGroup vertical fluid className='reqore-menu-section'>
59
+ <ReqoreButton
60
+ wrap={wrap}
61
+ flat={flat}
62
+ minimal={minimal}
63
+ active={collapsible && !_isCollapsed}
64
+ {...rest}
65
+ className={`${rest.className || ''} reqore-menu-section-toggle`}
66
+ intent={collapsible && !_isCollapsed ? activeIntent : rest.intent}
67
+ fluid
68
+ onClick={handleCollapseChange}
69
+ rightIcon={rest.rightIcon || (collapsible ? 'ArrowRightSLine' : 'ArrowDownSLine')}
70
+ rightIconProps={{
71
+ rotation: collapsible && !_isCollapsed ? 90 : 0,
72
+ }}
73
+ />
74
+ {!_isCollapsed || !collapsible ? (
75
+ <ReqoreControlGroup vertical fluid style={{ paddingLeft: '10px' }}>
76
+ {clone(children)}
77
+ </ReqoreControlGroup>
78
+ ) : null}
79
+ </ReqoreControlGroup>
80
+ );
81
+ };
@@ -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
@@ -30,6 +30,7 @@ export { default as ReqoreLayoutContent } from './components/Layout/content';
30
30
  export { default as ReqoreMenu } from './components/Menu';
31
31
  export { default as ReqoreMenuDivider } from './components/Menu/divider';
32
32
  export { default as ReqoreMenuItem } from './components/Menu/item';
33
+ export { ReqoreMenuSection } from './components/Menu/section';
33
34
  export { default as ReqoreMessage } from './components/Message';
34
35
  export { ReqoreModal } from './components/Modal';
35
36
  export { ReqoreMultiSelect } from './components/MultiSelect';
@@ -44,7 +45,6 @@ export { ReqorePanel } from './components/Panel';
44
45
  export { ReqoreP, ReqoreP as ReqoreParagraph } from './components/Paragraph';
45
46
  export { default as ReqorePopover } from './components/Popover';
46
47
  export { default as ReqoreRadioGroup } from './components/RadioGroup';
47
- export { default as ReqoreSidebar } from './components/Sidebar';
48
48
  export { ReqoreHorizontalSpacer, ReqoreSpacer, ReqoreVerticalSpacer } from './components/Spacer';
49
49
  export { ReqoreSpinner } from './components/Spinner';
50
50
  export { default as ReqoreTable } from './components/Table';
@@ -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';
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
  },