@consta/uikit 4.7.0 → 4.8.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 (152) hide show
  1. package/ListCanary/index.d.ts +1 -0
  2. package/ListCanary/index.js +1 -0
  3. package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.d.ts +1 -6
  4. package/__internal__/src/components/Breadcrumbs/useElements.d.ts +6 -6
  5. package/__internal__/src/components/Breadcrumbs/useElements.js +1 -1
  6. package/__internal__/src/components/Breadcrumbs/useElements.js.map +1 -1
  7. package/__internal__/src/components/ContextMenu/ContextMenu.d.ts +0 -1
  8. package/__internal__/src/components/ContextMenu/ContextMenu.js +1 -1
  9. package/__internal__/src/components/ContextMenu/ContextMenu.js.map +1 -1
  10. package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.css +1 -1
  11. package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js +1 -1
  12. package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js.map +1 -1
  13. package/__internal__/src/components/ContextMenu/ContextMenuLevel/index.d.ts +1 -0
  14. package/__internal__/src/components/ContextMenu/ContextMenuLevel/index.js +2 -0
  15. package/__internal__/src/components/ContextMenu/ContextMenuLevel/index.js.map +1 -0
  16. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.css +1 -0
  17. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.d.ts +4 -0
  18. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js +2 -0
  19. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js.map +1 -0
  20. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.d.ts +1 -0
  21. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.js +2 -0
  22. package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.js.map +1 -0
  23. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.d.ts +2 -2
  24. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js +1 -1
  25. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js.map +1 -1
  26. package/__internal__/src/components/ContextMenu/ContextMenuLevels/index.d.ts +1 -0
  27. package/__internal__/src/components/ContextMenu/ContextMenuLevels/index.js +2 -0
  28. package/__internal__/src/components/ContextMenu/ContextMenuLevels/index.js.map +1 -0
  29. package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.d.ts +2 -0
  30. package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.js +2 -0
  31. package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.js.map +1 -0
  32. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.css +1 -0
  33. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.d.ts +3 -0
  34. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js +2 -0
  35. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js.map +1 -0
  36. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.d.ts +1 -0
  37. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.js +2 -0
  38. package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.js.map +1 -0
  39. package/__internal__/src/components/ContextMenu/helpers.d.ts +16 -15
  40. package/__internal__/src/components/ContextMenu/helpers.js +1 -1
  41. package/__internal__/src/components/ContextMenu/helpers.js.map +1 -1
  42. package/__internal__/src/components/ContextMenu/types.d.ts +57 -3
  43. package/__internal__/src/components/ContextMenu/types.js +1 -1
  44. package/__internal__/src/components/ContextMenu/types.js.map +1 -1
  45. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.css +1 -1
  46. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.js +1 -1
  47. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.js.map +1 -1
  48. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.css +1 -1
  49. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.js +1 -1
  50. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.js.map +1 -1
  51. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.css +1 -1
  52. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js +1 -1
  53. package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js.map +1 -1
  54. package/__internal__/src/components/ListCanary/ListAddItem/ListAddItem.d.ts +1 -2
  55. package/__internal__/src/components/ListCanary/ListAddItem/ListAddItem.js +1 -1
  56. package/__internal__/src/components/ListCanary/ListAddItem/ListAddItem.js.map +1 -1
  57. package/__internal__/src/components/ListCanary/ListAddItem/index.js.map +1 -1
  58. package/__internal__/src/components/ListCanary/ListBox/ListBox.css +1 -0
  59. package/__internal__/src/components/ListCanary/ListBox/ListBox.d.ts +3 -0
  60. package/__internal__/src/components/ListCanary/ListBox/ListBox.js +2 -0
  61. package/__internal__/src/components/ListCanary/ListBox/ListBox.js.map +1 -0
  62. package/__internal__/src/components/ListCanary/ListBox/cnListBox.d.ts +2 -0
  63. package/__internal__/src/components/ListCanary/ListBox/cnListBox.js +2 -0
  64. package/__internal__/src/components/ListCanary/ListBox/cnListBox.js.map +1 -0
  65. package/__internal__/src/components/ListCanary/ListBox/index.d.ts +3 -0
  66. package/__internal__/src/components/ListCanary/ListBox/index.js +2 -0
  67. package/__internal__/src/components/ListCanary/ListBox/index.js.map +1 -0
  68. package/__internal__/src/components/ListCanary/ListBox/mapVerticalSpase.d.ts +3 -0
  69. package/__internal__/src/components/ListCanary/ListBox/mapVerticalSpase.js +2 -0
  70. package/__internal__/src/components/ListCanary/ListBox/mapVerticalSpase.js.map +1 -0
  71. package/__internal__/src/components/ListCanary/ListCanary.d.ts +0 -1
  72. package/__internal__/src/components/ListCanary/ListCanary.js +1 -1
  73. package/__internal__/src/components/ListCanary/ListCanary.js.map +1 -1
  74. package/__internal__/src/components/ListCanary/ListDivider/ListDivider.css +1 -0
  75. package/__internal__/src/components/ListCanary/ListDivider/ListDivider.d.ts +5 -0
  76. package/__internal__/src/components/ListCanary/ListDivider/ListDivider.js +2 -0
  77. package/__internal__/src/components/ListCanary/ListDivider/ListDivider.js.map +1 -0
  78. package/__internal__/src/components/ListCanary/ListDivider/index.d.ts +1 -0
  79. package/__internal__/src/components/ListCanary/ListDivider/index.js +2 -0
  80. package/__internal__/src/components/ListCanary/ListDivider/index.js.map +1 -0
  81. package/__internal__/src/components/ListCanary/ListGroupLabel/ListGroupLabel.css +1 -1
  82. package/__internal__/src/components/ListCanary/ListGroupLabel/ListGroupLabel.d.ts +2 -1
  83. package/__internal__/src/components/ListCanary/ListGroupLabel/ListGroupLabel.js +1 -1
  84. package/__internal__/src/components/ListCanary/ListGroupLabel/ListGroupLabel.js.map +1 -1
  85. package/__internal__/src/components/ListCanary/ListGroupLabel/index.js.map +1 -1
  86. package/__internal__/src/components/ListCanary/ListItem/ListItem.css +1 -1
  87. package/__internal__/src/components/ListCanary/ListItem/ListItem.js +1 -1
  88. package/__internal__/src/components/ListCanary/ListItem/ListItem.js.map +1 -1
  89. package/__internal__/src/components/ListCanary/ListItem/index.js.map +1 -1
  90. package/__internal__/src/components/ListCanary/ListItemGrid/ListItemGrid.js +1 -1
  91. package/__internal__/src/components/ListCanary/ListItemGrid/ListItemGrid.js.map +1 -1
  92. package/__internal__/src/components/ListCanary/ListLoader/ListLoader.css +1 -1
  93. package/__internal__/src/components/ListCanary/ListLoader/ListLoader.d.ts +7 -3
  94. package/__internal__/src/components/ListCanary/ListLoader/ListLoader.js +1 -1
  95. package/__internal__/src/components/ListCanary/ListLoader/ListLoader.js.map +1 -1
  96. package/__internal__/src/components/ListCanary/ListLoader/index.js.map +1 -1
  97. package/__internal__/src/components/ListCanary/helper.d.ts +17 -19
  98. package/__internal__/src/components/ListCanary/helper.js +1 -1
  99. package/__internal__/src/components/ListCanary/helper.js.map +1 -1
  100. package/__internal__/src/components/ListCanary/index.d.ts +4 -0
  101. package/__internal__/src/components/ListCanary/index.js +1 -1
  102. package/__internal__/src/components/ListCanary/index.js.map +1 -1
  103. package/__internal__/src/components/ListCanary/maps.d.ts +9 -0
  104. package/__internal__/src/components/ListCanary/maps.js +2 -0
  105. package/__internal__/src/components/ListCanary/maps.js.map +1 -0
  106. package/__internal__/src/components/ListCanary/types.d.ts +55 -31
  107. package/__internal__/src/components/ListCanary/types.js +1 -1
  108. package/__internal__/src/components/ListCanary/types.js.map +1 -1
  109. package/__internal__/src/components/Popover/helpers.d.ts +1 -1
  110. package/__internal__/src/components/Popover/helpers.js.map +1 -1
  111. package/__internal__/src/components/SelectComponents/SelectCreateButton/SelectCreateButton.css +1 -1
  112. package/__internal__/src/components/SelectComponents/SelectCreateButton/SelectCreateButton.d.ts +1 -1
  113. package/__internal__/src/components/SelectComponents/SelectCreateButton/SelectCreateButton.js +1 -1
  114. package/__internal__/src/components/SelectComponents/SelectCreateButton/SelectCreateButton.js.map +1 -1
  115. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.css +1 -1
  116. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js +1 -1
  117. package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js.map +1 -1
  118. package/__internal__/src/components/SelectComponents/SelectGroupLabel/SelectGroupLabel.d.ts +1 -3
  119. package/__internal__/src/components/SelectComponents/SelectGroupLabel/SelectGroupLabel.js +1 -1
  120. package/__internal__/src/components/SelectComponents/SelectGroupLabel/SelectGroupLabel.js.map +1 -1
  121. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.css +1 -1
  122. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js +1 -1
  123. package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js.map +1 -1
  124. package/__internal__/src/components/SelectComponents/helpers.d.ts +1 -1
  125. package/__internal__/src/components/SelectComponents/helpers.js +1 -1
  126. package/__internal__/src/components/SelectComponents/helpers.js.map +1 -1
  127. package/__internal__/src/components/TagBase/TagBase.d.ts +1 -1
  128. package/__internal__/src/components/UserSelect/UserSelectItem/UserSelectItem.css +1 -1
  129. package/__internal__/src/components/UserSelect/UserSelectItem/UserSelectItem.d.ts +1 -1
  130. package/__internal__/src/components/UserSelect/UserSelectItem/UserSelectItem.js +1 -1
  131. package/__internal__/src/components/UserSelect/UserSelectItem/UserSelectItem.js.map +1 -1
  132. package/__internal__/src/hooks/useComponentSize/useComponentSize.d.ts +2 -2
  133. package/__internal__/src/hooks/useComponentSize/useComponentSize.js +1 -1
  134. package/__internal__/src/hooks/useComponentSize/useComponentSize.js.map +1 -1
  135. package/__internal__/src/hooks/useRefs/useRefs.d.ts +3 -1
  136. package/__internal__/src/hooks/useRefs/useRefs.js +1 -1
  137. package/__internal__/src/hooks/useRefs/useRefs.js.map +1 -1
  138. package/__internal__/src/hooks/useSelect/useSelect.d.ts +1 -6
  139. package/__internal__/src/mixs/MixPopoverAnimate/MixPopoverAnimate.css +1 -1
  140. package/__internal__/src/mixs/MixSpace/MixSpace.d.ts +17 -17
  141. package/__internal__/src/mixs/MixSpace/MixSpace.js.map +1 -1
  142. package/__internal__/src/utils/getGroups.d.ts +1 -1
  143. package/__internal__/src/utils/getGroups.js.map +1 -1
  144. package/package.json +2 -2
  145. package/__internal__/src/components/ContextMenu/ContextMenu.css +0 -1
  146. package/__internal__/src/components/ContextMenu/ContextMenuItem/ContextMenuItem.css +0 -1
  147. package/__internal__/src/components/ContextMenu/ContextMenuItem/ContextMenuItem.d.ts +0 -4
  148. package/__internal__/src/components/ContextMenu/ContextMenuItem/ContextMenuItem.js +0 -2
  149. package/__internal__/src/components/ContextMenu/ContextMenuItem/ContextMenuItem.js.map +0 -1
  150. package/__internal__/src/components/ListCanary/List.css +0 -1
  151. package/__internal__/src/components/ListCanary/ListAddItem/ListAddItem.css +0 -1
  152. package/__internal__/src/components/SelectComponents/SelectGroupLabel/SelectGroupLabel.css +0 -1
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/components/ListCanary";
@@ -0,0 +1 @@
1
+ export * from "../__internal__/src/components/ListCanary";
@@ -34,12 +34,7 @@ declare type GetOptionPropsResult = {
34
34
  };
35
35
  export declare function useAutoComplete<ITEM, GROUP>(params: UseAutoCompleteProps<ITEM, GROUP>): {
36
36
  isOpen: boolean;
37
- visibleItems: {
38
- items: ITEM[];
39
- key: string | number;
40
- group?: GROUP | undefined;
41
- groupIndex: number;
42
- }[];
37
+ visibleItems: import("../../utils/getGroups").Group<ITEM, GROUP>[];
43
38
  getOptionProps: ({ index, item, }: OptionProps<ITEM>) => GetOptionPropsResult;
44
39
  handleInputFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
45
40
  handleInputBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
@@ -1,15 +1,15 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  export declare const useElements: <ITEM>(items: ITEM[]) => {
3
3
  visibleItems: ITEM[];
4
4
  hiddenItems: ITEM[];
5
- itemsRefs: React.RefObject<HTMLLIElement>[];
6
- wrapperRef: React.RefObject<HTMLUListElement>;
7
- moreRef: React.RefObject<HTMLLIElement> | undefined;
5
+ itemsRefs: import("react").RefObject<HTMLLIElement>[];
6
+ wrapperRef: import("react").RefObject<HTMLUListElement>;
7
+ moreRef: import("react").RefObject<HTMLLIElement> | undefined;
8
8
  firstItem: ITEM | undefined;
9
9
  lastItem: ITEM | undefined;
10
10
  readyToHideItems: ITEM[];
11
- firstItemRef: React.RefObject<HTMLLIElement>;
12
- lastItemRef: React.RefObject<HTMLLIElement>;
11
+ firstItemRef: import("react").RefObject<HTMLLIElement>;
12
+ lastItemRef: import("react").RefObject<HTMLLIElement>;
13
13
  lastWidth: string;
14
14
  compression: string;
15
15
  elementsSizeSum: number;
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _excluded=["itemsDimensions","wrapperWidth"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{useMemo}from"react";import{useHideElementsInLine}from"../../hooks/useHideElementsInLine/useHideElementsInLine";import{useRefs}from"../../hooks/useRefs/useRefs";import{useResizeObserved}from"../../hooks/useResizeObserved/useResizeObserved";var useReadyToHideItems=function(a){return useMemo(function(){console.log(a);var b=_toConsumableArray(a),c=b.shift(),d=b.pop();return[c,b,d]},[a])},getLastWidth=function(a,b,c,d){var e=b+c.reduce(function(a,b,c){return a+(d[c]?0:b)},0);return"".concat(a-e,"px")},getCompression=function(a){return 380>=a?"s":900>=a?"m":1200>=a?"l":"xl"};export var useElements=function(a){var b=useReadyToHideItems(a),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];console.log(e);var g=useRefs(2),h=useResizeObserved(g,function(a){return a?parseInt(getComputedStyle(a).marginRight,10)+parseInt(getComputedStyle(a).marginLeft,10)+a.offsetWidth:0}),i=h.reduce(function(a,b){return a+b},0),j=useHideElementsInLine(e,i,!0),k=j.itemsDimensions,l=j.wrapperWidth,m=_objectWithoutProperties(j,_excluded),n=i+k.reduce(function(a,b){return a+b},0),o=getLastWidth(l,h[0],k,m.hiddenItems),p=getCompression(l);return _objectSpread({firstItem:d,lastItem:f,readyToHideItems:e,firstItemRef:g[0],lastItemRef:g[1],lastWidth:o,compression:p,elementsSizeSum:n},m)};
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";var _excluded=["itemsDimensions","wrapperWidth"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{useMemo}from"react";import{useHideElementsInLine}from"../../hooks/useHideElementsInLine/useHideElementsInLine";import{useRefs}from"../../hooks/useRefs/useRefs";import{useResizeObserved}from"../../hooks/useResizeObserved/useResizeObserved";var useReadyToHideItems=function(a){return useMemo(function(){var b=_toConsumableArray(a),c=b.shift(),d=b.pop();return[c,b,d]},[a])},getLastWidth=function(a,b,c,d){var e=b+c.reduce(function(a,b,c){return a+(d[c]?0:b)},0);return"".concat(a-e,"px")},getCompression=function(a){return 380>=a?"s":900>=a?"m":1200>=a?"l":"xl"};export var useElements=function(a){var b=useReadyToHideItems(a),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2],g=useRefs(2),h=useResizeObserved(g,function(a){return a?parseInt(getComputedStyle(a).marginRight,10)+parseInt(getComputedStyle(a).marginLeft,10)+a.offsetWidth:0}),i=h.reduce(function(a,b){return a+b},0),j=useHideElementsInLine(e,i,!0),k=j.itemsDimensions,l=j.wrapperWidth,m=_objectWithoutProperties(j,_excluded),n=i+k.reduce(function(a,b){return a+b},0),o=getLastWidth(l,h[0],k,m.hiddenItems),p=getCompression(l);return _objectSpread({firstItem:d,lastItem:f,readyToHideItems:e,firstItemRef:g[0],lastItemRef:g[1],lastWidth:o,compression:p,elementsSizeSum:n},m)};
2
2
  //# sourceMappingURL=useElements.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useElements.js","names":["useMemo","useHideElementsInLine","useRefs","useResizeObserved","useReadyToHideItems","items","console","log","returnedItems","first","shift","last","pop","getLastWidth","wrapperWidth","fistWidth","itemsDimensions","hiddenItems","widthExceptLast","reduce","previous","current","currentIndex","getCompression","componentWidth","useElements","firstItem","readyToHideItems","lastItem","noHideElementsRef","noHideElementsSize","el","parseInt","getComputedStyle","marginRight","marginLeft","offsetWidth","noHideElementsSizeSum","hideElementsInLineResult","elementsSizeSum","lastWidth","compression","firstItemRef","lastItemRef"],"sources":["../../../../../src/components/Breadcrumbs/useElements.ts"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport { useHideElementsInLine } from '../../hooks/useHideElementsInLine/useHideElementsInLine';\nimport { useRefs } from '../../hooks/useRefs/useRefs';\nimport { useResizeObserved } from '../../hooks/useResizeObserved/useResizeObserved';\n\nconst useReadyToHideItems = <ITEM>(items: ITEM[]) =>\n useMemo(() => {\n console.log(items);\n const returnedItems = [...items];\n const first = returnedItems.shift();\n const last = returnedItems.pop();\n return [first, returnedItems, last] as const;\n }, [items]);\n\nconst getLastWidth = (\n wrapperWidth: number,\n fistWidth: number,\n itemsDimensions: number[],\n hiddenItems: unknown[],\n) => {\n const widthExceptLast =\n fistWidth +\n itemsDimensions.reduce(\n (previous, current, currentIndex) =>\n previous + (hiddenItems[currentIndex] ? 0 : current),\n 0,\n );\n\n const lastWidthCalculate = wrapperWidth - widthExceptLast;\n\n return `${lastWidthCalculate}px`;\n};\n\nconst getCompression = (componentWidth: number) => {\n if (componentWidth <= 380) {\n return 's';\n }\n if (componentWidth <= 900) {\n return 'm';\n }\n if (componentWidth <= 1200) {\n return 'l';\n }\n return 'xl';\n};\n\nexport const useElements = <ITEM>(items: ITEM[]) => {\n const [firstItem, readyToHideItems, lastItem] = useReadyToHideItems(items);\n\n console.log(readyToHideItems);\n\n const noHideElementsRef = useRefs(2) as [\n React.RefObject<HTMLLIElement>,\n React.RefObject<HTMLLIElement>,\n ];\n\n const noHideElementsSize = useResizeObserved(noHideElementsRef, (el) =>\n el\n ? parseInt(getComputedStyle(el).marginRight, 10) +\n parseInt(getComputedStyle(el).marginLeft, 10) +\n el.offsetWidth\n : 0,\n );\n\n const noHideElementsSizeSum = noHideElementsSize.reduce(\n (previous, current) => previous + current,\n 0,\n );\n\n const { itemsDimensions, wrapperWidth, ...hideElementsInLineResult } =\n useHideElementsInLine<ITEM, HTMLLIElement, HTMLUListElement>(\n readyToHideItems,\n noHideElementsSizeSum,\n true,\n );\n\n const elementsSizeSum =\n noHideElementsSizeSum +\n itemsDimensions.reduce((previous, current) => previous + current, 0);\n\n const lastWidth = getLastWidth(\n wrapperWidth,\n noHideElementsSize[0],\n itemsDimensions,\n hideElementsInLineResult.hiddenItems,\n );\n\n const compression = getCompression(wrapperWidth);\n\n return {\n firstItem,\n lastItem,\n readyToHideItems,\n firstItemRef: noHideElementsRef[0],\n lastItemRef: noHideElementsRef[1],\n lastWidth,\n compression,\n elementsSizeSum,\n ...hideElementsInLineResult,\n };\n};\n"],"mappings":"q7BAAA,OAAgBA,OAAhB,KAA+B,OAA/B,CAEA,OAASC,qBAAT,+DACA,OAASC,OAAT,mCACA,OAASC,iBAAT,uD,GAEMC,oBAAmB,CAAG,SAAOC,CAAP,QAC1BL,QAAO,CAAC,UAAM,CACZM,OAAO,CAACC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,CAEAJ,CAAE,CAACK,WAHL,CAIE,CAL0D,CAApB,CAVM,CAkB5CC,CAAqB,CAAGP,CAAkB,CAACX,MAAnB,CAC5B,SAACC,CAAD,CAAWC,CAAX,QAAuBD,EAAQ,CAAGC,CAAlC,CAD4B,CAE5B,CAF4B,CAlBoB,GAwBhDpB,qBAAqB,CACnB0B,CADmB,CAEnBU,CAFmB,IAxB2B,CAuB1CrB,CAvB0C,GAuB1CA,eAvB0C,CAuBzBF,CAvByB,GAuBzBA,YAvByB,CAuBRwB,CAvBQ,uCA8B5CC,CAAe,CACnBF,CAAqB,CACrBrB,CAAe,CAACG,MAAhB,CAAuB,SAACC,CAAD,CAAWC,CAAX,QAAuBD,EAAQ,CAAGC,CAAlC,CAAvB,CAAkE,CAAlE,CAhCgD,CAkC5CmB,CAAS,CAAG3B,YAAY,CAC5BC,CAD4B,CAE5BgB,CAAkB,CAAC,CAAD,CAFU,CAG5Bd,CAH4B,CAI5BsB,CAAwB,CAACrB,WAJG,CAlCoB,CAyC5CwB,CAAW,CAAGlB,cAAc,CAACT,CAAD,CAzCgB,CA2ClD,sBACEY,SAAS,CAATA,CADF,CAEEE,QAAQ,CAARA,CAFF,CAGED,gBAAgB,CAAhBA,CAHF,CAIEe,YAAY,CAAEb,CAAiB,CAAC,CAAD,CAJjC,CAKEc,WAAW,CAAEd,CAAiB,CAAC,CAAD,CALhC,CAMEW,SAAS,CAATA,CANF,CAOEC,WAAW,CAAXA,CAPF,CAQEF,eAAe,CAAfA,CARF,EASKD,CATL,CAWD,CAtDM"}
1
+ {"version":3,"file":"useElements.js","names":["useMemo","useHideElementsInLine","useRefs","useResizeObserved","useReadyToHideItems","items","returnedItems","first","shift","last","pop","getLastWidth","wrapperWidth","fistWidth","itemsDimensions","hiddenItems","widthExceptLast","reduce","previous","current","currentIndex","getCompression","componentWidth","useElements","firstItem","readyToHideItems","lastItem","noHideElementsRef","noHideElementsSize","el","parseInt","getComputedStyle","marginRight","marginLeft","offsetWidth","noHideElementsSizeSum","hideElementsInLineResult","elementsSizeSum","lastWidth","compression","firstItemRef","lastItemRef"],"sources":["../../../../../src/components/Breadcrumbs/useElements.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { useHideElementsInLine } from '../../hooks/useHideElementsInLine/useHideElementsInLine';\nimport { useRefs } from '../../hooks/useRefs/useRefs';\nimport { useResizeObserved } from '../../hooks/useResizeObserved/useResizeObserved';\n\nconst useReadyToHideItems = <ITEM>(items: ITEM[]) =>\n useMemo(() => {\n const returnedItems = [...items];\n const first = returnedItems.shift();\n const last = returnedItems.pop();\n return [first, returnedItems, last] as const;\n }, [items]);\n\nconst getLastWidth = (\n wrapperWidth: number,\n fistWidth: number,\n itemsDimensions: number[],\n hiddenItems: unknown[],\n) => {\n const widthExceptLast =\n fistWidth +\n itemsDimensions.reduce(\n (previous, current, currentIndex) =>\n previous + (hiddenItems[currentIndex] ? 0 : current),\n 0,\n );\n\n const lastWidthCalculate = wrapperWidth - widthExceptLast;\n\n return `${lastWidthCalculate}px`;\n};\n\nconst getCompression = (componentWidth: number) => {\n if (componentWidth <= 380) {\n return 's';\n }\n if (componentWidth <= 900) {\n return 'm';\n }\n if (componentWidth <= 1200) {\n return 'l';\n }\n return 'xl';\n};\n\nexport const useElements = <ITEM>(items: ITEM[]) => {\n const [firstItem, readyToHideItems, lastItem] = useReadyToHideItems(items);\n\n const noHideElementsRef = useRefs<HTMLLIElement>(2);\n\n const noHideElementsSize = useResizeObserved(noHideElementsRef, (el) =>\n el\n ? parseInt(getComputedStyle(el).marginRight, 10) +\n parseInt(getComputedStyle(el).marginLeft, 10) +\n el.offsetWidth\n : 0,\n );\n\n const noHideElementsSizeSum = noHideElementsSize.reduce(\n (previous, current) => previous + current,\n 0,\n );\n\n const { itemsDimensions, wrapperWidth, ...hideElementsInLineResult } =\n useHideElementsInLine<ITEM, HTMLLIElement, HTMLUListElement>(\n readyToHideItems,\n noHideElementsSizeSum,\n true,\n );\n\n const elementsSizeSum =\n noHideElementsSizeSum +\n itemsDimensions.reduce((previous, current) => previous + current, 0);\n\n const lastWidth = getLastWidth(\n wrapperWidth,\n noHideElementsSize[0],\n itemsDimensions,\n hideElementsInLineResult.hiddenItems,\n );\n\n const compression = getCompression(wrapperWidth);\n\n return {\n firstItem,\n lastItem,\n readyToHideItems,\n firstItemRef: noHideElementsRef[0],\n lastItemRef: noHideElementsRef[1],\n lastWidth,\n compression,\n elementsSizeSum,\n ...hideElementsInLineResult,\n };\n};\n"],"mappings":"q7BAAA,OAASA,OAAT,KAAwB,OAAxB,CAEA,OAASC,qBAAT,+DACA,OAASC,OAAT,mCACA,OAASC,iBAAT,uD,GAEMC,oBAAmB,CAAG,SAAOC,CAAP,QAC1BL,QAAO,CAAC,UAAM,IACNM,EAAa,oBAAOD,CAAP,CADP,CAENE,CAAK,CAAGD,CAAa,CAACE,KAAd,EAFF,CAGNC,CAAI,CAAGH,CAAa,CAACI,GAAd,EAHD,CAIZ,MAAO,CAACH,CAAD,CAAQD,CAAR,CAAuBG,CAAvB,CACR,CALM,CAKJ,CAACJ,CAAD,CALI,CADmB,C,CAQtBM,YAAY,CAAG,SACnBC,CADmB,CAEnBC,CAFmB,CAGnBC,CAHmB,CAInBC,CAJmB,CAKhB,IACGC,EAAe,CACnBH,CAAS,CACTC,CAAe,CAACG,MAAhB,CACE,SAACC,CAAD,CAAWC,CAAX,CAAoBC,CAApB,QACEF,EAAQ,EAAIH,CAAW,CAACK,CAAD,CAAX,CAA4B,CAA5B,CAAgCD,CAApC,CADV,CADF,CAGE,CAHF,CAHC,CAWH,gBAF2BP,CAAY,CAAGI,CAE1C,MACD,C,CAEKK,cAAc,CAAG,SAACC,CAAD,CAA4B,OAC3B,IAAlB,EAAAA,CAD6C,CAExC,GAFwC,CAI3B,GAAlB,EAAAA,CAJ6C,CAKxC,GALwC,CAO3B,IAAlB,EAAAA,CAP6C,CAQxC,GARwC,CAU1C,IACR,C,CAED,MAAO,IAAMC,YAAW,CAAG,SAAOlB,CAAP,CAA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SAAS,CAATA,CANF,CAOEC,WAAW,CAAXA,CAPF,CAQEF,eAAe,CAAfA,CARF,EASKD,CATL,CAWD,CAjDM"}
@@ -1,4 +1,3 @@
1
- import './ContextMenu.css';
2
1
  import { ContextMenuComponent } from './types';
3
2
  export declare const COMPONENT_NAME: "ContextMenu";
4
3
  export declare const ContextMenu: ContextMenuComponent;
@@ -1,2 +1,2 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isOpen","className","onSetDirection"];import"./ContextMenu.css";import React,{useRef,useState}from"react";import{Transition}from"react-transition-group";import{useFlag}from"../../hooks/useFlag/useFlag";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{animateTimeout,cnMixPopoverAnimate}from"../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cn}from"../../utils/bem";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{ContextMenuLevels}from"./ContextMenuLevels/ContextMenuLevels";var cnContextMenu=cn("ContextMenuCanary");export var COMPONENT_NAME="ContextMenu";var ContextMenuRender=function(a,b){var c=useRef(null),d=useForkRef([b,c]),e=usePropsHandler(COMPONENT_NAME,a,d),f=e.isOpen,g=e.className,h=e.onSetDirection,i=_objectWithoutProperties(e,_excluded),j=useFlag(),k=_slicedToArray(j,2),l=k[0],m=k[1],n=useFlag(!0),o=_slicedToArray(n,2),p=o[0],q=o[1],r=useState(a.direction),s=_slicedToArray(r,2),t=s[0],u=s[1],v=function(a){u(a),null===h||void 0===h?void 0:h(a)};return React.createElement(Transition,{in:f,unmountOnExit:!0,timeout:animateTimeout,onEntered:q.off,onEnter:m.off,onExit:function onExit(){m.on(),q.on()},nodeRef:c},function(a){return React.createElement(ContextMenuLevels,Object.assign({},i,{ref:d,onSetDirection:v,className:cnContextMenu("Level",{playAnimation:l,eventsNone:p},[g,cnMixPopoverAnimate({animate:a,direction:t})])}))})};export var ContextMenu=React.forwardRef(ContextMenuRender);export*from"./types";
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{useState}from"react";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{useDebounce}from"../../hooks/useDebounce";import{useFlag}from"../../hooks/useFlag";import{animateTimeout}from"../../mixs/MixPopoverAnimate";import{ContextMenuLevels}from"./ContextMenuLevels";import{ContextMenuWrapper}from"./ContextMenuWrapper";export var COMPONENT_NAME="ContextMenu";var ContextMenuRender=function(a,b){var c=usePropsHandler(COMPONENT_NAME,a,b),d=useState({width:240,height:100}),e=_slicedToArray(d,2),f=e[0],g=e[1],h=useFlag(),i=_slicedToArray(h,2),j=i[0],k=i[1],l=useDebounce(k.off,animateTimeout);return React.createElement(ContextMenuWrapper,Object.assign({},c,{animationBack:j,style:_objectSpread(_objectSpread({},null===c||void 0===c?void 0:c.style),f)}),React.createElement(ContextMenuLevels,Object.assign({},c,{setComponentSize:g,ref:b,enableAnimationBack:k.on,disableAnimationBack:l})))};export var ContextMenu=React.forwardRef(ContextMenuRender);export*from"./types";
2
2
  //# sourceMappingURL=ContextMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","names":["React","useRef","useState","Transition","useFlag","useForkRef","animateTimeout","cnMixPopoverAnimate","cn","usePropsHandler","ContextMenuLevels","cnContextMenu","COMPONENT_NAME","ContextMenuRender","props","ref","nodeRef","levelRef","isOpen","className","onSetDirection","otherProps","playAnimation","setPlayAnimation","eventsNone","setEventsNone","direction","setDirection","handleSetDirection","d","off","on","animate","ContextMenu","forwardRef"],"sources":["../../../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import './ContextMenu.css';\n\nimport React, { useRef, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { useFlag } from '../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../hooks/useForkRef/useForkRef';\nimport {\n animateTimeout,\n cnMixPopoverAnimate,\n} from '../../mixs/MixPopoverAnimate/MixPopoverAnimate';\nimport { cn } from '../../utils/bem';\nimport { usePropsHandler } from '../EventInterceptor/usePropsHandler';\nimport { Direction } from '../Popover/Popover';\nimport { ContextMenuLevels } from './ContextMenuLevels/ContextMenuLevels';\nimport { ContextMenuComponent, ContextMenuProps } from './types';\n\nconst cnContextMenu = cn('ContextMenuCanary');\n\nexport const COMPONENT_NAME = 'ContextMenu' as const;\n\nconst ContextMenuRender = (\n props: ContextMenuProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const nodeRef = useRef<HTMLDivElement>(null);\n const levelRef = useForkRef([ref, nodeRef]);\n\n const { isOpen, className, onSetDirection, ...otherProps } = usePropsHandler(\n COMPONENT_NAME,\n props,\n levelRef,\n );\n const [playAnimation, setPlayAnimation] = useFlag();\n const [eventsNone, setEventsNone] = useFlag(true);\n const [direction, setDirection] = useState<Direction | undefined>(\n props.direction,\n );\n\n const handleSetDirection = (d: Direction) => {\n setDirection(d);\n onSetDirection?.(d);\n };\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n timeout={animateTimeout}\n onEntered={setEventsNone.off}\n onEnter={setPlayAnimation.off}\n onExit={() => {\n setPlayAnimation.on();\n setEventsNone.on();\n }}\n nodeRef={nodeRef}\n >\n {(animate) => (\n <ContextMenuLevels\n {...otherProps}\n ref={levelRef}\n onSetDirection={handleSetDirection}\n className={cnContextMenu('Level', { playAnimation, eventsNone }, [\n className,\n cnMixPopoverAnimate({ animate, direction }),\n ])}\n />\n )}\n </Transition>\n );\n};\n\nexport const ContextMenu = React.forwardRef(\n ContextMenuRender,\n) as ContextMenuComponent;\n\nexport * from './types';\n"],"mappings":"4MAAA,0BAEA,MAAOA,MAAP,EAAgBC,MAAhB,CAAwBC,QAAxB,KAAwC,OAAxC,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OAASC,OAAT,mCACA,OAASC,UAAT,yCACA,OACEC,cADF,CAEEC,mBAFF,sDAIA,OAASC,EAAT,uBACA,OAASC,eAAT,2CAEA,OAASC,iBAAT,6CAGA,GAAMC,cAAa,CAAGH,EAAE,CAAC,mBAAD,CAAxB,CAEA,MAAO,IAAMI,eAAc,CAAG,aAAvB,CAEP,GAAMC,kBAAiB,CAAG,SACxBC,CADwB,CAExBC,CAFwB,CAGrB,IACGC,EAAO,CAAGf,MAAM,CAAiB,IAAjB,CADnB,CAEGgB,CAAQ,CAAGZ,UAAU,CAAC,CAACU,CAAD,CAAMC,CAAN,CAAD,CAFxB,GAI0DP,eAAe,CAC1EG,cAD0E,CAE1EE,CAF0E,CAG1EG,CAH0E,CAJzE,CAIKC,CAJL,GAIKA,MAJL,CAIaC,CAJb,GAIaA,SAJb,CAIwBC,CAJxB,GAIwBA,cAJxB,CAI2CC,CAJ3C,yCASuCjB,OAAO,EAT9C,uBASIkB,CATJ,MASmBC,CATnB,QAUiCnB,OAAO,IAVxC,uBAUIoB,CAVJ,MAUgBC,CAVhB,QAW+BvB,QAAQ,CACxCY,CAAK,CAACY,SADkC,CAXvC,uBAWIA,CAXJ,MAWeC,CAXf,MAeGC,CAAkB,CAAG,SAACC,CAAD,CAAkB,CAC3CF,CAAY,CAACE,CAAD,CAD+B,QAE3CT,CAF2C,WAE3CA,CAF2C,QAE3CA,CAAc,CAAGS,CAAH,CACf,CAlBE,CAoBH,MACE,qBAAC,UAAD,EACE,GAAIX,CADN,CAEE,aAAa,GAFf,CAGE,OAAO,CAAEZ,cAHX,CAIE,SAAS,CAAEmB,CAAa,CAACK,GAJ3B,CAKE,OAAO,CAAEP,CAAgB,CAACO,GAL5B,CAME,MAAM,CAAE,iBAAM,CACZP,CAAgB,CAACQ,EAAjB,EADY,CAEZN,CAAa,CAACM,EAAd,EACD,CATH,CAUE,OAAO,CAAEf,CAVX,EAYG,SAACgB,CAAD,QACC,qBAAC,iBAAD,kBACMX,CADN,EAEE,GAAG,CAAEJ,CAFP,CAGE,cAAc,CAAEW,CAHlB,CAIE,SAAS,CAAEjB,aAAa,CAAC,OAAD,CAAU,CAAEW,aAAa,CAAbA,CAAF,CAAiBE,UAAU,CAAVA,CAAjB,CAAV,CAAyC,CAC/DL,CAD+D,CAE/DZ,mBAAmB,CAAC,CAAEyB,OAAO,CAAPA,CAAF,CAAWN,SAAS,CAATA,CAAX,CAAD,CAF4C,CAAzC,CAJ1B,GADD,CAZH,CAyBH,CAjDD,CAmDA,MAAO,IAAMO,YAAW,CAAGjC,KAAK,CAACkC,UAAN,CACzBrB,iBADyB,CAApB,CAIP"}
1
+ {"version":3,"file":"ContextMenu.js","names":["React","useState","usePropsHandler","useDebounce","useFlag","animateTimeout","ContextMenuLevels","ContextMenuWrapper","COMPONENT_NAME","ContextMenuRender","props","ref","rest","width","height","componentSize","setComponentSize","animationBack","setAnimationBack","disableAnimationBack","off","style","on","ContextMenu","forwardRef"],"sources":["../../../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { ComponentSize } from '##/hooks/useComponentSize';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { useFlag } from '##/hooks/useFlag';\nimport { animateTimeout } from '##/mixs/MixPopoverAnimate';\n\nimport { ContextMenuLevels } from './ContextMenuLevels';\nimport { ContextMenuWrapper } from './ContextMenuWrapper';\nimport { ContextMenuComponent, ContextMenuProps } from './types';\n\nexport const COMPONENT_NAME = 'ContextMenu' as const;\n\nconst ContextMenuRender = (\n props: ContextMenuProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const rest = usePropsHandler(COMPONENT_NAME, props, ref);\n\n const [componentSize, setComponentSize] = useState<ComponentSize>({\n width: 240,\n height: 100,\n });\n\n const [animationBack, setAnimationBack] = useFlag();\n const disableAnimationBack = useDebounce(\n setAnimationBack.off,\n animateTimeout,\n );\n\n return (\n <ContextMenuWrapper\n {...rest}\n animationBack={animationBack}\n style={{ ...rest?.style, ...componentSize }}\n >\n <ContextMenuLevels\n {...rest}\n setComponentSize={setComponentSize}\n ref={ref}\n enableAnimationBack={setAnimationBack.on}\n disableAnimationBack={disableAnimationBack}\n />\n </ContextMenuWrapper>\n );\n};\n\nexport const ContextMenu = React.forwardRef(\n ContextMenuRender,\n) as ContextMenuComponent;\n\nexport * from './types';\n"],"mappings":"suBAAA,MAAOA,MAAP,EAAgBC,QAAhB,KAAgC,OAAhC,CAEA,OAASC,eAAT,2CAEA,OAASC,WAAT,+BACA,OAASC,OAAT,2BACA,OAASC,cAAT,oCAEA,OAASC,iBAAT,2BACA,OAASC,kBAAT,4BAGA,MAAO,IAAMC,eAAc,CAAG,aAAvB,CAEP,GAAMC,kBAAiB,CAAG,SACxBC,CADwB,CAExBC,CAFwB,CAGrB,IACGC,EAAI,CAAGV,eAAe,CAACM,cAAD,CAAiBE,CAAjB,CAAwBC,CAAxB,CADzB,GAGuCV,QAAQ,CAAgB,CAChEY,KAAK,CAAE,GADyD,CAEhEC,MAAM,CAAE,GAFwD,CAAhB,CAH/C,uBAGIC,CAHJ,MAGmBC,CAHnB,QAQuCZ,OAAO,EAR9C,uBAQIa,CARJ,MAQmBC,CARnB,MASGC,CAAoB,CAAGhB,WAAW,CACtCe,CAAgB,CAACE,GADqB,CAEtCf,cAFsC,CATrC,CAcH,MACE,qBAAC,kBAAD,kBACMO,CADN,EAEE,aAAa,CAAEK,CAFjB,CAGE,KAAK,uCAAOL,CAAP,WAAOA,CAAP,QAAOA,CAAI,CAAES,KAAb,EAAuBN,CAAvB,CAHP,GAKE,oBAAC,iBAAD,kBACMH,CADN,EAEE,gBAAgB,CAAEI,CAFpB,CAGE,GAAG,CAAEL,CAHP,CAIE,mBAAmB,CAAEO,CAAgB,CAACI,EAJxC,CAKE,oBAAoB,CAAEH,CALxB,GALF,CAcH,CAhCD,CAkCA,MAAO,IAAMI,YAAW,CAAGvB,KAAK,CAACwB,UAAN,CACzBf,iBADyB,CAApB,CAIP"}
@@ -1 +1 @@
1
- .ContextMenuLevelCanary{background:var(--color-bg-default);border:var(--control-border-width) solid var(--color-control-bg-border-default);border-radius:var(--control-radius);box-shadow:var(--shadow-layer);box-sizing:border-box;padding:var(--space-xs) 0;width:240px}.ContextMenuLevelCanary:not(.ContextMenuLevelCanary_firstLevel).ContextMenuLevelCanary_direction_leftStartUp,.ContextMenuLevelCanary:not(.ContextMenuLevelCanary_firstLevel).ContextMenuLevelCanary_direction_rightStartUp{transform:translateY(calc((var(--space-xs) + 1px)*-1))}.ContextMenuLevelCanary:not(.ContextMenuLevelCanary_firstLevel).ContextMenuLevelCanary_direction_leftStartDown,.ContextMenuLevelCanary:not(.ContextMenuLevelCanary_firstLevel).ContextMenuLevelCanary_direction_rightStartDown{transform:translateY(calc(var(--space-xs) + 1px))}.ContextMenuLevelCanary-Divider{--vertical-space:0;background:var(--color-control-bg-border-default);height:var(--control-border-width);margin:var(--vertical-space) var(--space-s)}.ContextMenuLevelCanary-Divider_size_l{--vertical-space:var(--space-xs)}.ContextMenuLevelCanary-Divider_size_m,.ContextMenuLevelCanary-Divider_size_s,.ContextMenuLevelCanary-Divider_size_xs{--vertical-space:var(--space-2xs)}.ContextMenuLevelCanary-Group_size_xs>.ContextMenuLevel-Item:not(:last-child){margin-bottom:var(--space-2xs)}.ContextMenuLevelCanary-Header{--top-space:0;--bottom-space:0;border-bottom:solid var(--control-border-width) var(--color-control-bg-border-default);letter-spacing:.05em;margin:0 var(--space-s);padding:var(--top-space) 0 var(--bottom-space) 0}.ContextMenuLevelCanary-Header_size_s,.ContextMenuLevelCanary-Header_size_xs{--top-space:var(--space-xs);--bottom-space:var(--space-2xs)}.ContextMenuLevelCanary-Header_size_m{--top-space:var(--space-s);--bottom-space:var(--space-xs)}.ContextMenuLevelCanary-Header_size_l{--top-space:var(--space-s);--bottom-space:var(--space-s)}.ContextMenuLevelCanary-Header_first{padding:calc(var(--top-space) - var(--space-xs)) 0 var(--bottom-space) 0}
1
+ .Popover.ContextMenuLevel-Desktop{visibility:hidden;width:240px}.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entered.Popover_direction_leftStartUp,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entered.Popover_direction_rightStartUp,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entering.Popover_direction_leftStartUp,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entering.Popover_direction_rightStartUp{transform:translateY(calc((var(--space-xs) + 1px)*-1))}.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entered.Popover_direction_leftStartDown,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entered.Popover_direction_rightStartDown,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entering.Popover_direction_leftStartDown,.Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_firstLevel).Popover.ContextMenuLevel-Desktop:not(.Popover.ContextMenuLevel-Desktop_isMobile).MixPopoverAnimate_animate_entering.Popover_direction_rightStartDown{transform:translateY(calc(var(--space-xs) + 1px))}.Popover.ContextMenuLevel-Desktop_visible{visibility:visible}.ContextMenuLevel-Mobile{bottom:0;left:0;position:absolute;right:0;top:0;width:240px}.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_entered,.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_entering,.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_exited,.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_exiting{pointer-events:none;transition:transform .2s,opacity .2s}.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_entered{pointer-events:all}.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_entered,.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_entering{opacity:1;transform:translate(0)}.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_exited{opacity:0;transform:translate(100%)}.ContextMenuWrapper_innerAnimation .ContextMenuLevel-Mobile_animate_exiting{opacity:0;transform:translate(-100%)}.ContextMenuWrapper_innerAnimation.ContextMenuWrapper_animationBack .ContextMenuLevel-Mobile_animate_exited{transform:translate(-100%)}.ContextMenuWrapper_innerAnimation.ContextMenuWrapper_animationBack .ContextMenuLevel-Mobile_animate_exiting{transform:translate(100%)}
@@ -1,2 +1,2 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","items","groups","className","levelDepth","activeItem","addLevel","deleteLevel","setHoveredParenLevel","hoveredParenLevel","sortGroup","onItemClick","direction","possibleDirections","offset","onSetDirection","spareDirection","anchorRef","getItemLabel","getItemRightSide","getItemLeftSide","getItemSubMenu","getItemStatus","getItemDisabled","getItemKey","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getItemLeftIcon","getItemRightIcon","getGroupLabel","getGroupId"];function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import"./ContextMenuLevel.css";import React,{createRef,forwardRef,useEffect,useMemo}from"react";import{useFlag}from"../../../hooks/useFlag/useFlag";import{cn}from"../../../utils/bem";import{getByMap}from"../../../utils/getByMap";import{getGroups}from"../../../utils/getGroups";import{Popover}from"../../Popover/Popover";import{Text}from"../../Text/Text";import{ContextMenuItem}from"../ContextMenuItem/ContextMenuItem";import{getItemIndex,sizeMapHeader}from"../helpers";import{contextMenuDefaultSize}from"../types";export var cnContextMenuLevel=cn("ContextMenuLevelCanary");var renderHeader=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:contextMenuDefaultSize;return a?React.createElement(Text,{view:"secondary",transform:"uppercase",className:cnContextMenuLevel("Header",{size:c,first:b}),size:getByMap(sizeMapHeader,c)},a):b?null:React.createElement("div",{className:cnContextMenuLevel("Divider",{size:c})})},timers=[];export function clearTimers(){var a,b=_createForOfIteratorHelper(timers);try{for(b.s();!(a=b.n()).done;){var c=a.value;clearTimeout(c)}}catch(a){b.e(a)}finally{b.f()}timers=[]}var closeDelay=300,ContextMenuLevelRender=function(a,b){var c=a.size,d=void 0===c?contextMenuDefaultSize:c,e=a.items,f=a.groups,g=a.className,h=a.levelDepth,i=a.activeItem,j=a.addLevel,k=a.deleteLevel,l=a.setHoveredParenLevel,m=a.hoveredParenLevel,n=a.sortGroup,o=a.onItemClick,p=a.direction,q=a.possibleDirections,r=a.offset,s=a.onSetDirection,t=a.spareDirection,u=a.anchorRef,v=a.getItemLabel,w=a.getItemRightSide,x=a.getItemLeftSide,y=a.getItemSubMenu,z=a.getItemStatus,A=a.getItemDisabled,B=a.getItemKey,C=a.getItemOnClick,D=a.getItemAs,E=a.getItemAttributes,F=a.getItemGroupId,G=a.getItemLeftIcon,H=a.getItemRightIcon,I=a.getGroupLabel,J=a.getGroupId,K=_objectWithoutProperties(a,_excluded),L=useFlag(!1),M=_slicedToArray(L,2),N=M[0],O=M[1],P=getGroups(e,F,f,J,n&&function(c,a){return n(c.key,a.key)}),Q=useMemo(function constructItemRefs(){var a,b={},c=_createForOfIteratorHelper(P);try{for(c.s();!(a=c.n()).done;)for(var d=a.value,f=0;f<e.length;f++)b[getItemIndex(d.key,f)]=createRef()}catch(a){c.e(a)}finally{c.f()}return b},[e,f]);useEffect(function(){return 0!==h&&!N&&m<h&&(clearTimeout(timers[h]),timers[h]=setTimeout(function(){return k(h)},closeDelay)),function(){return clearTimeout(timers[h])}},[N,m]);var R=function onMouseEnter(a,b){var c=y(a),d=A(a);Array.isArray(c)&&!d?(j({level:h+1,items:c,anchorRef:Q[b],activeItem:b}),l(h+1)):l(h)};return React.createElement(Popover,Object.assign({anchorRef:u,className:cnContextMenuLevel({firstLevel:0===h,direction:p},[g]),possibleDirections:q,spareDirection:t,direction:p,offset:r,onSetDirection:s,onMouseEnter:O.on,onMouseLeave:O.off,ref:b},K),P.map(function(a,b){return React.createElement("div",{className:cnContextMenuLevel("Group",{size:d}),key:a.key},renderHeader(a.group&&I(a.group),0===b,d),a.items.map(function(c,e){var f,g=getItemIndex(a.key,e);return React.createElement(ContextMenuItem,Object.assign({label:v(c),rightSide:w(c),rightIcon:H(c),leftSide:x(c),leftIcon:G(c),status:z(c),key:cnContextMenuLevel("Item",{groupIndex:b,index:e}),disabled:A(c),onClick:function onClick(a){if(!A(c)){if("function"==typeof C(c)){var b;null===(b=C(c))||void 0===b?void 0:b({e:a,item:c})}"function"==typeof o&&(null===o||void 0===o?void 0:o({e:a,item:c}))}},as:D(c)},null!==(f=E(c))&&void 0!==f?f:{},{ref:Q[g],className:cnContextMenuLevel("Item"),onMouseEnter:function onMouseEnter(){return R(c,g)},active:i===g,size:d,withSubMenu:!!y(c)}))}))}))};export var ContextMenuLevel=forwardRef(ContextMenuLevelRender);
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","items","groups","className","form","animate","levelDepth","activeItem","addLevel","deleteLevel","setHoveredParenLevel","hoveredParenLevel","sortGroup","onItemClick","isOpen","parent","isMobile","direction","possibleDirections","offset","onSetDirection","spareDirection","anchorRef","getItemLabel","getItemRightSide","getItemLeftSide","getItemSubMenu","getItemStatus","getItemDisabled","getItemKey","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getItemLeftIcon","getItemRightIcon","getGroupLabel","getGroupId"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}import"./ContextMenuLevel.css";import{IconArrowLeft}from"@consta/icons/IconArrowLeft";import{IconArrowRight}from"@consta/icons/IconArrowRight";import React,{forwardRef,useEffect}from"react";import{cnListBox,List,ListDivider,ListItem,mapIconSize,mapVerticalSpase}from"../../ListCanary";import{useDebounce}from"../../../hooks/useDebounce";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useRefs}from"../../../hooks/useRefs/useRefs";import{cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate";import{cnMixSpace}from"../../../mixs/MixSpace";import{cn}from"../../../utils/bem";import{ContextMenuLevelWrapper}from"../ContextMenuLevelWrapper";import{contextMenuDefaultSize}from"../types";export var cnContextMenuLevel=cn("ContextMenuLevel");var timers=[];export function clearTimers(){var a,b=_createForOfIteratorHelper(timers);try{for(b.s();!(a=b.n()).done;){var c=a.value;clearTimeout(c)}}catch(a){b.e(a)}finally{b.f()}timers=[]}var closeDelay=300,ContextMenuLevelRender=function(a,b){var c=a.size,d=void 0===c?contextMenuDefaultSize:c,e=a.items,f=a.groups,g=a.className,h=a.form,i=void 0===h?"default":h,j=a.animate,k=a.levelDepth,l=a.activeItem,m=a.addLevel,n=a.deleteLevel,o=a.setHoveredParenLevel,p=a.hoveredParenLevel,q=a.sortGroup,r=a.onItemClick,s=a.isOpen,t=a.parent,u=a.isMobile,v=a.direction,w=a.possibleDirections,x=a.offset,y=a.onSetDirection,z=a.spareDirection,A=a.anchorRef,B=a.getItemLabel,C=a.getItemRightSide,D=a.getItemLeftSide,E=a.getItemSubMenu,F=a.getItemStatus,G=a.getItemDisabled,H=a.getItemKey,I=a.getItemOnClick,J=a.getItemAs,K=a.getItemAttributes,L=a.getItemGroupId,M=a.getItemLeftIcon,N=a.getItemRightIcon,O=a.getGroupLabel,P=a.getGroupId,Q=_objectWithoutProperties(a,_excluded),R=useFlag(!1),S=_slicedToArray(R,2),T=S[0],U=S[1],V=useFlag(!1),W=_slicedToArray(V,2),X=W[0],Y=W[1],Z=useDebounce(Y.on,20),$=function(a){return(H(a)||B(a)).toString()},_=useRefs(e.map(function(a){return $(a)}),[f]);useEffect(function(){return 0!==k&&!T&&p<k&&(clearTimeout(timers[k]),timers[k]=setTimeout(function(){return n(k)},closeDelay)),function(){return clearTimeout(timers[k])}},[T,p]),useEffect(function(){s||clearTimeout(timers[k])},[s]);var aa=function(a){var b=E(a),c=G(a);if(Array.isArray(b)&&!c){var d=$(a);m({level:k+1,items:b,anchorRef:_[d],activeItem:d,parent:a}),o(k+1)}else o(k)},ba=u?void 0:function(a){return function(b){var c;aa(a);var d=null===(c=K(a))||void 0===c?void 0:c.onMouseEnter;null===d||void 0===d?void 0:d(b)}},ca=0===k;return React.createElement(ContextMenuLevelWrapper,Object.assign({anchorRef:A,className:u?cnContextMenuLevel("Mobile",{animate:j},[g]):cnContextMenuLevel("Desktop",{firstLevel:ca,visible:X},[cnListBox({size:d,form:i,border:!0,shadow:!0}),cnMixSpace({pV:mapVerticalSpase[d]}),cnMixPopoverAnimate({animate:j}),ca?g:void 0]),possibleDirections:w,spareDirection:z,direction:v,offset:x,onSetDirection:function onSetDirection(a){Z(),null===y||void 0===y?void 0:y(a)},onMouseEnter:U.on,onMouseLeave:U.off,ref:b,isMobile:u},Q),t&&React.createElement(React.Fragment,null,React.createElement(ListItem,{label:B(t),size:d,leftIcon:IconArrowLeft,onClick:function onClick(){return n(k)}}),React.createElement(ListDivider,{size:d,space:{mV:mapVerticalSpase[d]}})),React.createElement(List,{size:d,items:e,getItemLabel:B,onItemClick:function onItemClick(a,b){var c=b.e;u&&aa(a),null===r||void 0===r?void 0:r({item:a,e:c})},sortGroup:q?function(c,a){return q(c.key,a.key)}:void 0,getItemOnClick:I?function(a){return function(b){var c;return null===(c=I(a))||void 0===c?void 0:c({e:b,item:a})}}:void 0,getItemAs:J,getItemAttributes:ba?function(a){return _objectSpread(_objectSpread({},K(a)),{},{onMouseEnter:ba(a)})}:K,getItemGroupKey:L,getItemLeftIcon:M,getItemRightIcon:N,getItemLeftSide:D,getItemRightSide:function getItemRightSide(a){var b=C(a);if(!E(a))return b;var c=Array.isArray(b)?b:[b];return c.push(React.createElement(IconArrowRight,{size:mapIconSize[d]})),c},getGroupKey:P,getGroupLabel:O,getItemDisabled:G,getItemStatus:F,getItemRef:function getItemRef(a){return _[$(a)]},groups:f,getItemActive:function getItemActive(a){return $(a)===l},innerOffset:"round"===i?"increased":"normal"}))};export var ContextMenuLevel=forwardRef(ContextMenuLevelRender);
2
2
  //# sourceMappingURL=ContextMenuLevel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuLevel.js","names":["React","createRef","forwardRef","useEffect","useMemo","useFlag","cn","getByMap","getGroups","Popover","Text","ContextMenuItem","getItemIndex","sizeMapHeader","contextMenuDefaultSize","cnContextMenuLevel","renderHeader","groupLabel","first","size","timers","clearTimers","timer","clearTimeout","closeDelay","ContextMenuLevelRender","props","ref","items","groupsProp","groups","className","levelDepth","activeItem","addLevel","deleteLevel","setHoveredParenLevel","hoveredParenLevel","sortGroup","onItemClick","direction","possibleDirections","offset","onSetDirection","spareDirection","anchorRef","getItemLabel","getItemRightSide","getItemLeftSide","getItemSubMenu","getItemStatus","getItemDisabled","getItemKey","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getItemLeftIcon","getItemRightIcon","getGroupLabel","getGroupId","otherProps","hovered","setHovered","a","b","key","itemsRefs","constructItemRefs","refs","group","i","length","setTimeout","onMouseEnter","item","itemIndex","subMenu","disabled","Array","isArray","level","firstLevel","on","off","map","groupIndex","index","onClick","e","ContextMenuLevel"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.tsx"],"sourcesContent":["import './ContextMenuLevel.css';\n\nimport React, { createRef, forwardRef, useEffect, useMemo } from 'react';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { cn } from '../../../utils/bem';\nimport { getByMap } from '../../../utils/getByMap';\nimport { getGroups } from '../../../utils/getGroups';\nimport { Popover } from '../../Popover/Popover';\nimport { Text } from '../../Text/Text';\nimport { ContextMenuItem } from '../ContextMenuItem/ContextMenuItem';\nimport { getItemIndex, sizeMapHeader } from '../helpers';\nimport {\n contextMenuDefaultSize,\n ContextMenuLevelComponent,\n ContextMenuLevelProps,\n ContextMenuPropSize,\n} from '../types';\n\nexport const cnContextMenuLevel = cn('ContextMenuLevelCanary');\n\nconst renderHeader = (\n groupLabel: string | number | undefined,\n first: boolean,\n size: ContextMenuPropSize = contextMenuDefaultSize,\n): React.ReactNode | null => {\n if (!groupLabel) {\n if (first) {\n return null;\n }\n return <div className={cnContextMenuLevel('Divider', { size })} />;\n }\n return (\n <Text\n view=\"secondary\"\n transform=\"uppercase\"\n className={cnContextMenuLevel('Header', { size, first })}\n size={getByMap(sizeMapHeader, size)}\n >\n {groupLabel}\n </Text>\n );\n};\n\nlet timers: ReturnType<typeof setTimeout>[] = [];\nexport function clearTimers() {\n for (const timer of timers) {\n clearTimeout(timer);\n }\n timers = [];\n}\nconst closeDelay = 300;\n\nconst ContextMenuLevelRender = <ITEM, GROUP>(\n props: ContextMenuLevelProps<ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n size = contextMenuDefaultSize,\n items,\n groups: groupsProp,\n className,\n // Свойства относящиеся к меню\n levelDepth,\n activeItem,\n addLevel,\n deleteLevel,\n setHoveredParenLevel,\n hoveredParenLevel,\n sortGroup,\n onItemClick,\n // Свойства для поповера\n direction,\n possibleDirections,\n offset,\n onSetDirection,\n spareDirection,\n anchorRef,\n // Геттеры для ITEM\n getItemLabel,\n getItemRightSide,\n getItemLeftSide,\n getItemSubMenu,\n getItemStatus,\n getItemDisabled,\n getItemKey,\n getItemOnClick,\n getItemAs,\n getItemAttributes,\n getItemGroupId,\n getItemLeftIcon,\n getItemRightIcon,\n // Геттеры для GROUP\n getGroupLabel,\n getGroupId,\n ...otherProps\n } = props;\n\n const [hovered, setHovered] = useFlag(false);\n\n const groups = getGroups<ITEM, GROUP>(\n items,\n getItemGroupId,\n groupsProp,\n getGroupId,\n sortGroup && ((a, b) => sortGroup(a.key, b.key)),\n );\n\n const constructItemRefs: () => Record<\n string,\n React.RefObject<HTMLDivElement>\n > = () => {\n const refs: Record<string, React.RefObject<HTMLDivElement>> = {};\n\n for (const group of groups) {\n for (let i = 0; i < items.length; i++) {\n refs[getItemIndex(group.key, i)] = createRef<HTMLDivElement>();\n }\n }\n return refs;\n };\n\n const itemsRefs = useMemo(constructItemRefs, [items, groupsProp]);\n\n useEffect(() => {\n if (levelDepth !== 0 && !hovered && hoveredParenLevel < levelDepth) {\n clearTimeout(timers[levelDepth]);\n timers[levelDepth] = setTimeout(\n () => deleteLevel(levelDepth),\n closeDelay,\n );\n }\n return () => clearTimeout(timers[levelDepth]);\n }, [hovered, hoveredParenLevel]);\n\n const onMouseEnter = (item: ITEM, itemIndex: string) => {\n const subMenu = getItemSubMenu(item);\n const disabled = getItemDisabled(item);\n if (Array.isArray(subMenu) && !disabled) {\n addLevel({\n level: levelDepth + 1,\n items: subMenu,\n anchorRef: itemsRefs[itemIndex],\n activeItem: itemIndex,\n });\n setHoveredParenLevel(levelDepth + 1);\n } else {\n setHoveredParenLevel(levelDepth);\n }\n };\n\n return (\n <Popover\n anchorRef={anchorRef}\n className={cnContextMenuLevel(\n { firstLevel: levelDepth === 0, direction },\n [className],\n )}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n direction={direction}\n offset={offset}\n onSetDirection={onSetDirection}\n onMouseEnter={setHovered.on}\n onMouseLeave={setHovered.off}\n ref={ref}\n {...otherProps}\n >\n {groups.map((group, groupIndex) => {\n return (\n <div\n className={cnContextMenuLevel('Group', { size })}\n key={group.key}\n >\n {renderHeader(\n group.group && getGroupLabel(group.group),\n groupIndex === 0,\n size,\n )}\n {group.items.map((item, index) => {\n const itemIndex = getItemIndex(group.key, index);\n const onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n if (!getItemDisabled(item)) {\n if (typeof getItemOnClick(item) === 'function') {\n getItemOnClick(item)?.({ e, item });\n }\n if (typeof onItemClick === 'function') {\n onItemClick?.({ e, item });\n }\n }\n };\n return (\n <ContextMenuItem\n label={getItemLabel(item)}\n rightSide={getItemRightSide(item)}\n rightIcon={getItemRightIcon(item)}\n leftSide={getItemLeftSide(item)}\n leftIcon={getItemLeftIcon(item)}\n status={getItemStatus(item)}\n key={cnContextMenuLevel('Item', { groupIndex, index })}\n disabled={getItemDisabled(item)}\n onClick={onClick}\n as={getItemAs(item)}\n {...(getItemAttributes(item) ?? {})}\n ref={itemsRefs[itemIndex]}\n className={cnContextMenuLevel('Item')}\n onMouseEnter={() => onMouseEnter(item, itemIndex)}\n active={activeItem === itemIndex}\n size={size}\n withSubMenu={!!getItemSubMenu(item)}\n />\n );\n })}\n </div>\n );\n })}\n </Popover>\n );\n};\n\nexport const ContextMenuLevel = forwardRef(\n ContextMenuLevelRender,\n) as ContextMenuLevelComponent;\n"],"mappings":"uyDAAA,+BAEA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,UAA3B,CAAuCC,SAAvC,CAAkDC,OAAlD,KAAiE,OAAjE,CAEA,OAASC,OAAT,sCACA,OAASC,EAAT,0BACA,OAASC,QAAT,+BACA,OAASC,SAAT,gCACA,OAASC,OAAT,6BACA,OAASC,IAAT,uBACA,OAASC,eAAT,0CACA,OAASC,YAAT,CAAuBC,aAAvB,kBACA,OACEC,sBADF,gBAOA,MAAO,IAAMC,mBAAkB,CAAGT,EAAE,CAAC,wBAAD,CAA7B,C,GAEDU,aAAY,CAAG,SACnBC,CADmB,CAEnBC,CAFmB,CAIQ,IAD3BC,EAC2B,wDADCL,sBACD,OACtBG,EADsB,CAQzB,oBAAC,IAAD,EACE,IAAI,CAAC,WADP,CAEE,SAAS,CAAC,WAFZ,CAGE,SAAS,CAAEF,kBAAkB,CAAC,QAAD,CAAW,CAAEI,IAAI,CAAJA,CAAF,CAAQD,KAAK,CAALA,CAAR,CAAX,CAH/B,CAIE,IAAI,CAAEX,QAAQ,CAACM,aAAD,CAAgBM,CAAhB,CAJhB,EAMGF,CANH,CARyB,CAErBC,CAFqB,CAGhB,IAHgB,CAKlB,2BAAK,SAAS,CAAEH,kBA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,CAAyC,CACvD,GAAI,CAACtC,CAAe,CAACwB,CAAD,CAApB,CAA4B,CAC1B,GAAoC,UAAhC,QAAOtB,EAAc,CAACsB,CAAD,CAAzB,CAAgD,iBAC9CtB,CAAc,CAACsB,CAAD,CADgC,qBAC9C,EAAuB,CAAEc,CAAC,CAADA,CAAF,CAAKd,IAAI,CAAJA,CAAL,CAAvB,CACD,CAC0B,UAAvB,QAAOpC,EAJe,UAKxBA,CALwB,WAKxBA,CALwB,QAKxBA,CAAW,CAAG,CAAEkD,CAAC,CAADA,CAAF,CAAKd,IAAI,CAAJA,CAAL,CAAH,CALa,CAO3B,CACF,CAEC,CAUE,EAAE,CAAErB,CAAS,CAACqB,CAAD,CAVf,YAWOpB,CAAiB,CAACoB,CAAD,CAXxB,gBAWkC,EAXlC,EAYE,GAAG,CAAER,CAAS,CAACS,CAAD,CAZhB,CAaE,SAAS,CAAE7D,kBAAkB,CAAC,MAAD,CAb/B,CAcE,YAAY,CAAE,8BAAM2D,EAAY,CAACC,CAAD,CAAOC,CAAP,CAAlB,CAdhB,CAeE,MAAM,CAAE3C,CAAU,GAAK2C,CAfzB,CAgBE,IAAI,CAAEzD,CAhBR,CAiBE,WAAW,CAAE,CAAC,CAAC8B,CAAc,CAAC0B,CAAD,CAjB/B,GAoBH,CAjCA,CATH,CA6CH,CA/CA,CAhBH,CAkEH,C,CAED,MAAO,IAAMe,iBAAgB,CAAGxF,UAAU,CACxCuB,sBADwC,CAAnC"}
1
+ {"version":3,"file":"ContextMenuLevel.js","names":["IconArrowLeft","IconArrowRight","React","forwardRef","useEffect","cnListBox","List","ListDivider","ListItem","mapIconSize","mapVerticalSpase","useDebounce","useFlag","useRefs","cnMixPopoverAnimate","cnMixSpace","cn","ContextMenuLevelWrapper","contextMenuDefaultSize","cnContextMenuLevel","timers","clearTimers","timer","clearTimeout","closeDelay","ContextMenuLevelRender","props","ref","size","items","groupsProp","groups","className","form","animate","levelDepth","activeItem","addLevel","deleteLevel","setHoveredParenLevel","hoveredParenLevel","sortGroup","onItemClick","isOpen","parent","isMobile","direction","possibleDirections","offset","onSetDirection","spareDirection","anchorRef","getItemLabel","getItemRightSide","getItemLeftSide","getItemSubMenu","getItemStatus","getItemDisabled","getItemKey","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getItemLeftIcon","getItemRightIcon","getGroupLabel","getGroupId","otherProps","hovered","setHovered","visible","setVisible","setVisibleTrue","on","getKey","item","toString","itemsRefs","map","setTimeout","addCurrentLevel","subMenu","disabled","Array","isArray","key","level","onMouseEnter","e","firstLevel","border","shadow","pV","off","mV","a","b","side","sides","push","ContextMenuLevel"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.tsx"],"sourcesContent":["import './ContextMenuLevel.css';\n\nimport { IconArrowLeft } from '@consta/icons/IconArrowLeft';\nimport { IconArrowRight } from '@consta/icons/IconArrowRight';\nimport React, { forwardRef, useEffect } from 'react';\n\nimport {\n cnListBox,\n List,\n ListDivider,\n ListItem,\n mapIconSize,\n mapVerticalSpase,\n} from '##/components/ListCanary';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { useFlag } from '##/hooks/useFlag/useFlag';\nimport { useRefs } from '##/hooks/useRefs/useRefs';\nimport { cnMixPopoverAnimate } from '##/mixs/MixPopoverAnimate';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cn } from '##/utils/bem';\n\nimport { ContextMenuLevelWrapper } from '../ContextMenuLevelWrapper';\nimport {\n contextMenuDefaultSize,\n ContextMenuItemDefault,\n ContextMenuLevelComponent,\n ContextMenuLevelProps,\n} from '../types';\n\nexport const cnContextMenuLevel = cn('ContextMenuLevel');\n\nlet timers: ReturnType<typeof setTimeout>[] = [];\nexport function clearTimers() {\n for (const timer of timers) {\n clearTimeout(timer);\n }\n timers = [];\n}\n\nconst closeDelay = 300;\n\nconst ContextMenuLevelRender = (\n props: ContextMenuLevelProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const {\n size = contextMenuDefaultSize,\n items,\n groups: groupsProp,\n className,\n form = 'default',\n animate,\n // Свойства относящиеся к меню\n levelDepth,\n activeItem,\n addLevel,\n deleteLevel,\n setHoveredParenLevel,\n hoveredParenLevel,\n sortGroup,\n onItemClick,\n isOpen,\n parent,\n isMobile,\n\n // Свойства для поповера\n direction,\n possibleDirections,\n offset,\n onSetDirection,\n spareDirection,\n anchorRef,\n // Геттеры для ITEM\n getItemLabel,\n getItemRightSide,\n getItemLeftSide,\n getItemSubMenu,\n getItemStatus,\n getItemDisabled,\n getItemKey,\n getItemOnClick,\n getItemAs,\n getItemAttributes,\n getItemGroupId,\n getItemLeftIcon,\n getItemRightIcon,\n // Геттеры для GROUP\n getGroupLabel,\n getGroupId,\n ...otherProps\n } = props;\n\n const [hovered, setHovered] = useFlag(false);\n\n const [visible, setVisible] = useFlag(false);\n const setVisibleTrue = useDebounce(setVisible.on, 20);\n\n const getKey = (item: ContextMenuItemDefault) =>\n (getItemKey(item) || getItemLabel(item)).toString();\n\n const itemsRefs = useRefs<HTMLDivElement, string[]>(\n items.map((item) => getKey(item)),\n [groupsProp],\n );\n\n useEffect(() => {\n if (levelDepth !== 0 && !hovered && hoveredParenLevel < levelDepth) {\n clearTimeout(timers[levelDepth]);\n timers[levelDepth] = setTimeout(\n () => deleteLevel(levelDepth),\n closeDelay,\n );\n }\n return () => clearTimeout(timers[levelDepth]);\n }, [hovered, hoveredParenLevel]);\n\n useEffect(() => {\n if (!isOpen) {\n clearTimeout(timers[levelDepth]);\n }\n }, [isOpen]);\n\n const addCurrentLevel = (item: ContextMenuItemDefault) => {\n const subMenu = getItemSubMenu(item);\n const disabled = getItemDisabled(item);\n\n if (Array.isArray(subMenu) && !disabled) {\n const key = getKey(item);\n addLevel({\n level: levelDepth + 1,\n items: subMenu,\n anchorRef: itemsRefs[key],\n activeItem: key,\n parent: item,\n });\n setHoveredParenLevel(levelDepth + 1);\n } else {\n setHoveredParenLevel(levelDepth);\n }\n };\n\n const onMouseEnter = isMobile\n ? undefined\n : (\n item: ContextMenuItemDefault,\n ): JSX.IntrinsicElements['div']['onMouseEnter'] =>\n (e) => {\n addCurrentLevel(item);\n const onMouseEnter = getItemAttributes(item)\n ?.onMouseEnter as JSX.IntrinsicElements['div']['onMouseEnter'];\n\n onMouseEnter?.(e);\n };\n\n const firstLevel = levelDepth === 0;\n\n return (\n <ContextMenuLevelWrapper\n anchorRef={anchorRef}\n className={\n isMobile\n ? cnContextMenuLevel('Mobile', { animate }, [className])\n : cnContextMenuLevel('Desktop', { firstLevel, visible }, [\n cnListBox({ size, form, border: true, shadow: true }),\n cnMixSpace({\n pV: mapVerticalSpase[size],\n }),\n cnMixPopoverAnimate({ animate }),\n firstLevel ? className : undefined,\n ])\n }\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n direction={direction}\n offset={offset}\n onSetDirection={(item) => {\n // скрываем блок пока не найдем точную позицию для оображения\n setVisibleTrue();\n onSetDirection?.(item);\n }}\n onMouseEnter={setHovered.on}\n onMouseLeave={setHovered.off}\n ref={ref}\n isMobile={isMobile}\n {...otherProps}\n >\n {parent && (\n <>\n <ListItem\n label={getItemLabel(parent)}\n size={size}\n leftIcon={IconArrowLeft}\n onClick={() => deleteLevel(levelDepth)}\n />\n <ListDivider size={size} space={{ mV: mapVerticalSpase[size] }} />\n </>\n )}\n <List\n size={size}\n items={items}\n getItemLabel={getItemLabel}\n onItemClick={(item, { e }) => {\n isMobile && addCurrentLevel(item);\n onItemClick?.({\n item,\n e: e as React.MouseEvent<HTMLDivElement>,\n });\n }}\n sortGroup={sortGroup ? (a, b) => sortGroup(a.key, b.key) : undefined}\n getItemOnClick={\n getItemOnClick\n ? (item) => (e) =>\n getItemOnClick(item)?.({\n e: e as React.MouseEvent<HTMLDivElement>,\n item,\n })\n : undefined\n }\n getItemAs={getItemAs}\n getItemAttributes={\n onMouseEnter\n ? (item) =>\n ({\n ...getItemAttributes(item),\n onMouseEnter: onMouseEnter(item),\n } as JSX.IntrinsicElements[keyof JSX.IntrinsicElements])\n : getItemAttributes\n }\n getItemGroupKey={getItemGroupId}\n getItemLeftIcon={getItemLeftIcon}\n getItemRightIcon={getItemRightIcon}\n getItemLeftSide={getItemLeftSide}\n getItemRightSide={(item) => {\n const side = getItemRightSide(item);\n if (!getItemSubMenu(item)) {\n return side;\n }\n\n const sides: React.ReactNode[] = Array.isArray(side) ? side : [side];\n sides.push(<IconArrowRight size={mapIconSize[size]} />);\n return sides;\n }}\n getGroupKey={getGroupId}\n getGroupLabel={getGroupLabel}\n getItemDisabled={getItemDisabled}\n getItemStatus={getItemStatus}\n getItemRef={(item) => itemsRefs[getKey(item)]}\n groups={groupsProp}\n getItemActive={(item) => getKey(item) === activeItem}\n innerOffset={form === 'round' ? 'increased' : 'normal'}\n />\n </ContextMenuLevelWrapper>\n );\n};\n\nexport const ContextMenuLevel = forwardRef(\n ContextMenuLevelRender,\n) as ContextMenuLevelComponent;\n"],"mappings":"0/EAAA,+BAEA,OAASA,aAAT,KAA8B,6BAA9B,CACA,OAASC,cAAT,KAA+B,8BAA/B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,KAA6C,OAA7C,CAEA,OACEC,SADF,CAEEC,IAFF,CAGEC,WAHF,CAIEC,QAJF,CAKEC,WALF,CAMEC,gBANF,wBAQA,OAASC,WAAT,kCACA,OAASC,OAAT,sCACA,OAASC,OAAT,sCACA,OAASC,mBAAT,uCACA,OAASC,UAAT,8BACA,OAASC,EAAT,0BAEA,OAASC,uBAAT,kCACA,OACEC,sBADF,gBAOA,MAAO,IAAMC,mBAAkB,CAAGH,EAAE,CAAC,kBAAD,CAA7B,CAEP,GAAII,OAAuC,CAAG,EAA9C,CACA,MAAO,SAASC,YAAT,EAAuB,oCACRD,MADQ,MAC5B,2BAA4B,IAAjBE,EAAiB,SAC1BC,YAAY,CAACD,CAAD,CACb,CAH2B,+BAI5BF,MAAM,CAAG,EACV,C,GAEKI,WAAU,CAAG,G,CAEbC,sBAAsB,CAAG,SAC7BC,CA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AAc,CAACoB,CAAD,CAAnB,CACE,MAAOsB,EAAP,CAGF,GAAMC,EAAwB,CAAGf,KAAK,CAACC,OAAN,CAAca,CAAd,EAAsBA,CAAtB,CAA6B,CAACA,CAAD,CAA9D,CAEA,MADAC,EAAK,CAACC,IAAN,CAAW,oBAAC,cAAD,EAAgB,IAAI,CAAE1F,WAAW,CAACmB,CAAD,CAAjC,EAAX,CACA,CAAOsE,CACR,CA5CH,CA6CE,WAAW,CAAEhC,CA7Cf,CA8CE,aAAa,CAAED,CA9CjB,CA+CE,eAAe,CAAER,CA/CnB,CAgDE,aAAa,CAAED,CAhDjB,CAiDE,UAAU,CAAE,oBAACmB,CAAD,QAAUE,EAAS,CAACH,CAAM,CAACC,CAAD,CAAP,CAAnB,CAjDd,CAkDE,MAAM,CAAE7C,CAlDV,CAmDE,aAAa,CAAE,uBAAC6C,CAAD,QAAUD,EAAM,CAACC,CAAD,CAAN,GAAiBvC,CAA3B,CAnDjB,CAoDE,WAAW,CAAW,OAAT,GAAAH,CAAI,CAAe,WAAf,CAA6B,QApDhD,EAxCF,CAgGH,C,CAED,MAAO,IAAMmE,iBAAgB,CAAGjG,UAAU,CACxCsB,sBADwC,CAAnC"}
@@ -0,0 +1 @@
1
+ export * from './ContextMenuLevel';
@@ -0,0 +1,2 @@
1
+ export*from"./ContextMenuLevel";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevel/index.ts"],"sourcesContent":["export * from './ContextMenuLevel';\n"],"mappings":"AAAA"}
@@ -0,0 +1 @@
1
+ .ContextMenuLevelWrapper-Mobile{position:relative;width:240px}
@@ -0,0 +1,4 @@
1
+ import './ContextMenuLevelWrapper.css';
2
+ import React from 'react';
3
+ import { ContextMenuLevelWrapperProps } from '../types';
4
+ export declare const ContextMenuLevelWrapper: React.ForwardRefExoticComponent<Pick<ContextMenuLevelWrapperProps, "form" | "slot" | "style" | "title" | "className" | "color" | "id" | "lang" | "role" | "tabIndex" | "direction" | "offset" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "size" | "position" | "isOpen" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "isMobile" | "classname"> & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,2 @@
1
+ import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["isMobile","children","className","size"];import"./ContextMenuLevelWrapper.css";import React,{forwardRef}from"react";import{mapVerticalSpase}from"../../ListCanary";import{Popover}from"../../Popover";import{cnMixSpace}from"../../../mixs/MixSpace";import{cn}from"../../../utils/bem";import{contextMenuDefaultSize}from"../types";var cnContextMenuLevelWrapper=cn("ContextMenuLevelWrapper");export var ContextMenuLevelWrapper=forwardRef(function(a,b){var c=a.isMobile,d=a.children,e=a.className,f=a.size,g=void 0===f?contextMenuDefaultSize:f,h=_objectWithoutProperties(a,_excluded);return c?React.createElement("div",{className:e},React.createElement("div",{className:cnContextMenuLevelWrapper("Mobile",[cnMixSpace({pV:mapVerticalSpase[g]})]),ref:b},d)):React.createElement(Popover,Object.assign({},h,{ref:b,className:e}),d)});
2
+ //# sourceMappingURL=ContextMenuLevelWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenuLevelWrapper.js","names":["React","forwardRef","mapVerticalSpase","Popover","cnMixSpace","cn","contextMenuDefaultSize","cnContextMenuLevelWrapper","ContextMenuLevelWrapper","props","ref","isMobile","children","className","size","otherProps","pV"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.tsx"],"sourcesContent":["import './ContextMenuLevelWrapper.css';\n\nimport React, { forwardRef } from 'react';\n\nimport { mapVerticalSpase } from '##/components/ListCanary';\nimport { Popover } from '##/components/Popover';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cn } from '##/utils/bem';\n\nimport { contextMenuDefaultSize, ContextMenuLevelWrapperProps } from '../types';\n\nconst cnContextMenuLevelWrapper = cn('ContextMenuLevelWrapper');\n\nexport const ContextMenuLevelWrapper = forwardRef(\n (props: ContextMenuLevelWrapperProps, ref: React.Ref<HTMLDivElement>) => {\n const {\n isMobile,\n children,\n className,\n size = contextMenuDefaultSize,\n ...otherProps\n } = props;\n\n if (isMobile) {\n return (\n <div className={className}>\n <div\n className={cnContextMenuLevelWrapper('Mobile', [\n cnMixSpace({\n pV: mapVerticalSpase[size],\n }),\n ])}\n ref={ref}\n >\n {children}\n </div>\n </div>\n );\n }\n\n return (\n <Popover {...otherProps} ref={ref} className={className}>\n {children}\n </Popover>\n );\n },\n);\n"],"mappings":"8IAAA,sCAEA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,gBAAT,wBACA,OAASC,OAAT,qBACA,OAASC,UAAT,8BACA,OAASC,EAAT,0BAEA,OAASC,sBAAT,gBAEA,GAAMC,0BAAyB,CAAGF,EAAE,CAAC,yBAAD,CAApC,CAEA,MAAO,IAAMG,wBAAuB,CAAGP,UAAU,CAC/C,SAACQ,CAAD,CAAsCC,CAAtC,CAAyE,CACvE,GACEC,EADF,CAMIF,CANJ,CACEE,QADF,CAEEC,CAFF,CAMIH,CANJ,CAEEG,QAFF,CAGEC,CAHF,CAMIJ,CANJ,CAGEI,SAHF,GAMIJ,CANJ,CAIEK,IAJF,CAIEA,CAJF,YAISR,sBAJT,GAKKS,CALL,0BAMIN,CANJ,YADuE,MASnEE,EATmE,CAWnE,2BAAK,SAAS,CAAEE,CAAhB,EACE,2BACE,SAAS,CAAEN,yBAAyB,CAAC,QAAD,CAAW,CAC7CH,UAAU,CAAC,CACTY,EAAE,CAAEd,gBAAgB,CAACY,CAAD,CADX,CAAD,CADmC,CAAX,CADtC,CAME,GAAG,CAAEJ,CANP,EAQGE,CARH,CADF,CAXmE,CA2BrE,oBAAC,OAAD,kBAAaG,CAAb,EAAyB,GAAG,CAAEL,CAA9B,CAAmC,SAAS,CAAEG,CAA9C,GACGD,CADH,CAIH,CAhC8C,CAA1C"}
@@ -0,0 +1 @@
1
+ export * from './ContextMenuLevelWrapper';
@@ -0,0 +1,2 @@
1
+ export*from"./ContextMenuLevelWrapper";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevelWrapper/index.ts"],"sourcesContent":["export * from './ContextMenuLevelWrapper';\n"],"mappings":"AAAA"}
@@ -1,2 +1,2 @@
1
- import { ContextMenuComponent } from '../types';
2
- export declare const ContextMenuLevels: ContextMenuComponent;
1
+ import { ContextMenuLevelsComponent } from '../types';
2
+ export declare const ContextMenuLevels: ContextMenuLevelsComponent;
@@ -1,2 +1,2 @@
1
- import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{useEffect,useState}from"react";import{useClickOutside}from"../../../hooks/useClickOutside/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{useRefs}from"../../../hooks/useRefs/useRefs";import{directions}from"../../Popover/Popover";import{clearTimers,ContextMenuLevel}from"../ContextMenuLevel/ContextMenuLevel";import{getLevels,withDefaultGetters}from"../helpers";import{contextMenuPropDefaultSubMenuDirection,contextMenuPropSubMenuDirections}from"../types";var ContextMenuLevelsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.anchorRef,f=c.position,g=c.direction,h=c.possibleDirections,i=void 0===h?directions:h,j=c.offset,k=c.onClickOutside,l=c.getItemKey,m=c.getItemLabel,n=c.getItemSubMenu,o=c.style,p=c.spareDirection,q=c.subMenuDirection,r=void 0===q?contextMenuPropDefaultSubMenuDirection:q,s=_objectWithoutProperties(c,_excluded),t=[{items:d,anchorRef:e,position:f,direction:g,possibleDirections:i,offset:j}],u=useState(t),v=_slicedToArray(u,2),w=v[0],x=v[1],y=useState(r),z=_slicedToArray(y,2),A=z[0],B=z[1],C=useState(-1),D=_slicedToArray(C,2),E=D[0],F=D[1],G=useRefs(w.length),H=function(a){var b=a.level,c=a.items,d=a.anchorRef,e=a.activeItem,f=_toConsumableArray(w),g=f[b]&&1<f.length-b?f[b].direction:void 0;f[b]&&1<f.length-b&&g&&B(g),f[b-1].activeItem=e,f.splice(b),f.push({items:c,anchorRef:d,direction:g||A,possibleDirections:contextMenuPropSubMenuDirections,position:void 0}),x(f)},I=function(a){var b=_toConsumableArray(w);b.splice(a),b[a-1]=_objectSpread(_objectSpread({},b[a-1]),{},{activeItem:void 0}),x(b)};useClickOutside({isActive:!!k,ignoreClicksInsideRefs:[].concat(_toConsumableArray(G),[e||{current:null}]),handler:function handler(a){return null===k||void 0===k?void 0:k(a)}}),useEffect(function(){return clearTimers(),x(getLevels({levels:w,items:d,getItemKey:l,getItemSubMenu:n})),function(){return clearTimers()}},[d]);var J=useForkRef([G[0],b]);return useEffect(function(){x(t)},[f]),React.createElement(React.Fragment,null,w.map(function(a,b){return React.createElement(ContextMenuLevel,Object.assign({},s,a,{key:"ContextMenu-".concat(b),style:_objectSpread(_objectSpread({},o),{zIndex:"number"==typeof(null===o||void 0===o?void 0:o.zIndex)?o.zIndex+1:void 0}),levelDepth:b,getItemLabel:m,addLevel:H,deleteLevel:I,onSetDirection:0<b?B:c.onSetDirection,hoveredParenLevel:E,setHoveredParenLevel:F,getItemSubMenu:n,getItemKey:l,ref:0===b?J:G[b],spareDirection:0===b?p:"rightStartUp"}))}))};export var ContextMenuLevels=React.forwardRef(ContextMenuLevelsRender);
1
+ import _defineProperty from"@babel/runtime/helpers/defineProperty";import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection","isMobile","isOpen","setComponentSize","enableAnimationBack","disableAnimationBack"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import React,{Fragment,useEffect,useState}from"react";import{Transition,TransitionGroup}from"react-transition-group";import{useClickOutside}from"../../../hooks/useClickOutside";import{useForkRef}from"../../../hooks/useForkRef";import{useMutableRef}from"../../../hooks/useMutableRef";import{useRefs}from"../../../hooks/useRefs";import{animateTimeout}from"../../../mixs/MixPopoverAnimate";import{clearTimers,ContextMenuLevel}from"../ContextMenuLevel";import{getLevels,withDefaultGetters}from"../helpers";import{contextMenuPropDefaultSubMenuDirection,contextMenuPropSubMenuDirections}from"../types";import{useSize}from"./useSize";var ContextMenuLevelsRender=function(a,b){var c=withDefaultGetters(a),d=c.items,e=c.anchorRef,f=c.position,g=c.direction,h=c.possibleDirections,i=c.offset,j=c.onClickOutside,k=c.getItemKey,l=c.getItemLabel,m=c.getItemSubMenu,n=c.style,o=c.spareDirection,p=c.subMenuDirection,q=void 0===p?contextMenuPropDefaultSubMenuDirection:p,r=c.isMobile,s=c.isOpen,t=c.setComponentSize,u=c.enableAnimationBack,v=c.disableAnimationBack,w=_objectWithoutProperties(c,_excluded),x=useMutableRef(s),y=[{items:d,anchorRef:e,position:f,direction:g,possibleDirections:h,offset:i}],z=useState(r?y:[]),A=_slicedToArray(z,2),B=A[0],C=A[1],D=useState(q),E=_slicedToArray(D,2),F=E[0],G=E[1],H=useState(-1),I=_slicedToArray(H,2),J=I[0],K=I[1],L=useRefs(B.length),M=function(a){var b=a.level,d=a.items,e=a.anchorRef,f=a.activeItem,g=a.parent,h=_toConsumableArray(B),i=h[b]&&1<h.length-b?h[b].direction:void 0;h[b]&&1<h.length-b&&i&&G(i),h[b-1].activeItem=f,h.splice(b),h.push({items:d,anchorRef:r?c.anchorRef:e,direction:r?c.direction:i||F,possibleDirections:r?c.possibleDirections:contextMenuPropSubMenuDirections,position:r?c.position:void 0,offset:r?c.offset:void 0,parent:g}),x.current?C(h):C([])},N=function(a){u();var b=_toConsumableArray(B);b.splice(a),b[a-1]=_objectSpread(_objectSpread({},b[a-1]),{},{activeItem:void 0}),C(b),v()};useClickOutside({isActive:!!j,ignoreClicksInsideRefs:[].concat(_toConsumableArray(L),[e||{current:null}]),handler:function handler(a){return null===j||void 0===j?void 0:j(a)}}),useEffect(function(){return clearTimers(),C(getLevels({levels:B,items:d,getItemKey:k,getItemSubMenu:m})),function(){return clearTimers()}},[d]);var O=useForkRef([L[0],b]);return useEffect(function(){C(y)},[f]),useEffect(function(){C(s?y:[])},[s]),useSize(L,t,r),React.createElement(TransitionGroup,{component:Fragment},B.map(function(a,b){var d="".concat(b,"-").concat(a.parent?k(a.parent):""),e=b!==B.length-1;return r&&e?React.createElement(Fragment,{key:b}):React.createElement(Transition,{key:d,timeout:animateTimeout,nodeRef:L[b]},function(d){return React.createElement(ContextMenuLevel,Object.assign({},w,a,{key:"".concat(b,"-").concat(a.parent?k(a.parent):""),isMobile:r,isOpen:s,style:_objectSpread(_objectSpread({},n),{zIndex:"number"==typeof(null===n||void 0===n?void 0:n.zIndex)?n.zIndex+1:void 0}),levelDepth:b,getItemLabel:l,addLevel:M,deleteLevel:N,onSetDirection:0<b?G:c.onSetDirection,hoveredParenLevel:J,setHoveredParenLevel:K,getItemSubMenu:m,getItemKey:k,ref:0===b?O:L[b],spareDirection:0===b?o:"rightStartUp",parent:r?a.parent:void 0,animate:d}))})}))};export var ContextMenuLevels=React.forwardRef(ContextMenuLevelsRender);
2
2
  //# sourceMappingURL=ContextMenuLevels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuLevels.js","names":["React","useEffect","useState","useClickOutside","useForkRef","useRefs","directions","clearTimers","ContextMenuLevel","getLevels","withDefaultGetters","contextMenuPropDefaultSubMenuDirection","contextMenuPropSubMenuDirections","ContextMenuLevelsRender","propsComponent","ref","props","items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection","subMenuDirectionProp","otherProps","defaultLevels","levels","setLevels","setSubMenuDirection","hoveredParenLevel","setHoveredParenLevel","levelsRefs","length","addLevel","level","activeItem","newLevels","oldDirection","splice","push","deleteLevel","isActive","ignoreClicksInsideRefs","current","handler","e","firstLevelRef","map","index","zIndex","onSetDirection","ContextMenuLevels","forwardRef"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { useClickOutside } from '../../../hooks/useClickOutside/useClickOutside';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { useRefs } from '../../../hooks/useRefs/useRefs';\nimport { Direction, directions } from '../../Popover/Popover';\nimport {\n clearTimers,\n ContextMenuLevel,\n} from '../ContextMenuLevel/ContextMenuLevel';\nimport { getLevels, withDefaultGetters } from '../helpers';\nimport {\n AddLevel,\n ContextMenuComponent,\n contextMenuPropDefaultSubMenuDirection,\n ContextMenuProps,\n contextMenuPropSubMenuDirections,\n Level,\n} from '../types';\n\nconst ContextMenuLevelsRender = (\n propsComponent: ContextMenuProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const props = withDefaultGetters(propsComponent);\n const {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections = directions,\n offset,\n onClickOutside,\n getItemKey,\n getItemLabel,\n getItemSubMenu,\n style,\n spareDirection,\n subMenuDirection:\n subMenuDirectionProp = contextMenuPropDefaultSubMenuDirection,\n ...otherProps\n } = props;\n\n type Item = typeof items[number];\n\n const defaultLevels: Level<Item>[] = [\n {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections,\n offset,\n } as Level<Item>,\n ];\n\n const [levels, setLevels] = useState<Level<Item>[]>(defaultLevels);\n const [subMenuDirection, setSubMenuDirection] =\n useState<Direction>(subMenuDirectionProp);\n const [hoveredParenLevel, setHoveredParenLevel] = useState<number>(-1);\n\n const levelsRefs = useRefs<HTMLDivElement>(levels.length);\n\n const addLevel: AddLevel<Item> = ({\n level,\n items,\n anchorRef,\n activeItem,\n }) => {\n const newLevels = [...levels];\n const oldDirection =\n newLevels[level] && newLevels.length - level > 1\n ? newLevels[level].direction\n : undefined;\n\n if (newLevels[level] && newLevels.length - level > 1 && oldDirection) {\n setSubMenuDirection(oldDirection);\n }\n\n newLevels[level - 1].activeItem = activeItem;\n newLevels.splice(level);\n newLevels.push({\n items,\n anchorRef,\n direction: oldDirection || subMenuDirection,\n possibleDirections: contextMenuPropSubMenuDirections,\n position: undefined,\n });\n setLevels(newLevels);\n };\n\n const deleteLevel = (level: number) => {\n const newLevels = [...levels];\n newLevels.splice(level);\n newLevels[level - 1] = { ...newLevels[level - 1], activeItem: undefined };\n setLevels(newLevels);\n };\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [...levelsRefs, anchorRef || { current: null }],\n handler: (e) => onClickOutside?.(e),\n });\n\n useEffect(() => {\n clearTimers();\n setLevels(\n getLevels({\n levels,\n items,\n getItemKey,\n getItemSubMenu,\n }),\n );\n return () => clearTimers();\n }, [items]);\n\n const firstLevelRef = useForkRef([levelsRefs[0], ref]);\n\n useEffect(() => {\n setLevels(defaultLevels);\n }, [position]);\n\n return (\n <>\n {levels.map((level, index) => (\n <ContextMenuLevel\n {...otherProps}\n {...level}\n key={`ContextMenu-${index}`}\n style={{\n ...style,\n ...{\n zIndex:\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined,\n },\n }}\n levelDepth={index}\n getItemLabel={getItemLabel}\n addLevel={addLevel}\n deleteLevel={deleteLevel}\n onSetDirection={\n index > 0 ? setSubMenuDirection : props.onSetDirection\n }\n hoveredParenLevel={hoveredParenLevel}\n setHoveredParenLevel={setHoveredParenLevel}\n getItemSubMenu={getItemSubMenu}\n getItemKey={getItemKey}\n ref={index === 0 ? firstLevelRef : levelsRefs[index]}\n spareDirection={index === 0 ? spareDirection : 'rightStartUp'}\n />\n ))}\n </>\n );\n};\n\nexport const ContextMenuLevels = React.forwardRef(\n ContextMenuLevelsRender,\n) as ContextMenuComponent;\n"],"mappings":"ukCAAA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,QAA3B,KAA2C,OA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,CAAP,CAA6BnB,CAAK,CAACyC,cAlB5C,CAoBE,iBAAiB,CAAErB,CApBrB,CAqBE,oBAAoB,CAAEC,CArBxB,CAsBE,cAAc,CAAEX,CAtBlB,CAuBE,UAAU,CAAEF,CAvBd,CAwBE,GAAG,CAAY,CAAV,GAAA+B,CAAK,CAASF,CAAT,CAAyBf,CAAU,CAACiB,CAAD,CAxB/C,CAyBE,cAAc,CAAY,CAAV,GAAAA,CAAK,CAAS3B,CAAT,CAA0B,cAzBjD,GADU,CAAX,CADH,CAgCH,CAxID,CA0IA,MAAO,IAAM8B,kBAAiB,CAAG1D,KAAK,CAAC2D,UAAN,CAC/B9C,uBAD+B,CAA1B"}
1
+ {"version":3,"file":"ContextMenuLevels.js","names":["React","Fragment","useEffect","useState","Transition","TransitionGroup","useClickOutside","useForkRef","useMutableRef","useRefs","animateTimeout","clearTimers","ContextMenuLevel","getLevels","withDefaultGetters","contextMenuPropDefaultSubMenuDirection","contextMenuPropSubMenuDirections","useSize","ContextMenuLevelsRender","propsComponent","ref","props","items","anchorRef","position","direction","possibleDirections","offset","onClickOutside","getItemKey","getItemLabel","getItemSubMenu","style","spareDirection","subMenuDirection","subMenuDirectionProp","isMobile","isOpen","setComponentSize","enableAnimationBack","disableAnimationBack","otherProps","isOpenRef","defaultLevels","levels","setLevels","setSubMenuDirection","hoveredParenLevel","setHoveredParenLevel","levelsRefs","length","addLevel","level","activeItem","parent","newLevels","oldDirection","splice","push","current","deleteLevel","isActive","ignoreClicksInsideRefs","handler","e","firstLevelRef","map","index","key","last","animate","zIndex","onSetDirection","ContextMenuLevels","forwardRef"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useState } from 'react';\nimport { Transition, TransitionGroup } from 'react-transition-group';\n\nimport { Direction } from '##/components/Popover';\nimport { useClickOutside } from '##/hooks/useClickOutside';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { useRefs } from '##/hooks/useRefs';\nimport { animateTimeout } from '##/mixs/MixPopoverAnimate';\n\nimport { clearTimers, ContextMenuLevel } from '../ContextMenuLevel';\nimport { getLevels, withDefaultGetters } from '../helpers';\nimport {\n AddLevel,\n ContextMenuItemDefault,\n ContextMenuLevelsComponent,\n ContextMenuLevelsProps,\n contextMenuPropDefaultSubMenuDirection,\n contextMenuPropSubMenuDirections,\n Level,\n} from '../types';\nimport { useSize } from './useSize';\n\nconst ContextMenuLevelsRender = (\n propsComponent: ContextMenuLevelsProps,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const props = withDefaultGetters(propsComponent);\n const {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections,\n offset,\n onClickOutside,\n getItemKey,\n getItemLabel,\n getItemSubMenu,\n style,\n spareDirection,\n subMenuDirection:\n subMenuDirectionProp = contextMenuPropDefaultSubMenuDirection,\n isMobile,\n isOpen,\n setComponentSize,\n enableAnimationBack,\n disableAnimationBack,\n ...otherProps\n } = props;\n\n const isOpenRef = useMutableRef(isOpen);\n\n type Item = typeof items[number];\n\n const defaultLevels: Level<ContextMenuItemDefault>[] = [\n {\n items,\n anchorRef,\n position,\n direction,\n possibleDirections,\n offset,\n },\n ];\n\n const [levels, setLevels] = useState<\n Level<ContextMenuItemDefault & { isParent?: boolean }>[]\n >(isMobile ? defaultLevels : []);\n const [subMenuDirection, setSubMenuDirection] =\n useState<Direction>(subMenuDirectionProp);\n const [hoveredParenLevel, setHoveredParenLevel] = useState<number>(-1);\n\n const levelsRefs = useRefs<HTMLDivElement>(levels.length);\n\n const addLevel: AddLevel<Item> = ({\n level,\n items,\n anchorRef,\n activeItem,\n parent,\n }) => {\n const newLevels: Level<ContextMenuItemDefault & { isParent?: boolean }>[] =\n [...levels];\n const oldDirection =\n newLevels[level] && newLevels.length - level > 1\n ? newLevels[level].direction\n : undefined;\n\n if (newLevels[level] && newLevels.length - level > 1 && oldDirection) {\n setSubMenuDirection(oldDirection);\n }\n\n newLevels[level - 1].activeItem = activeItem;\n newLevels.splice(level);\n newLevels.push({\n items,\n anchorRef: isMobile ? props.anchorRef : anchorRef,\n direction: isMobile ? props.direction : oldDirection || subMenuDirection,\n possibleDirections: isMobile\n ? props.possibleDirections\n : contextMenuPropSubMenuDirections,\n position: isMobile ? props.position : undefined,\n offset: isMobile ? props.offset : undefined,\n parent,\n });\n\n isOpenRef.current ? setLevels(newLevels) : setLevels([]);\n };\n\n const deleteLevel = (level: number) => {\n enableAnimationBack();\n const newLevels = [...levels];\n newLevels.splice(level);\n newLevels[level - 1] = { ...newLevels[level - 1], activeItem: undefined };\n setLevels(newLevels);\n disableAnimationBack();\n };\n\n useClickOutside({\n isActive: !!onClickOutside,\n ignoreClicksInsideRefs: [...levelsRefs, anchorRef || { current: null }],\n handler: (e) => onClickOutside?.(e),\n });\n\n useEffect(() => {\n clearTimers();\n setLevels(\n getLevels({\n levels,\n items,\n getItemKey,\n getItemSubMenu,\n }),\n );\n return () => clearTimers();\n }, [items]);\n\n const firstLevelRef = useForkRef([levelsRefs[0], ref]);\n\n useEffect(() => {\n setLevels(defaultLevels);\n }, [position]);\n\n useEffect(() => {\n setLevels(isOpen ? defaultLevels : []);\n }, [isOpen]);\n\n useSize(levelsRefs, setComponentSize, isMobile);\n\n return (\n <TransitionGroup component={Fragment}>\n {levels.map((level, index) => {\n const key = `${index}-${level.parent ? getItemKey(level.parent) : ''}`;\n\n const last = index !== levels.length - 1;\n\n if (isMobile && last) {\n return <Fragment key={index} />;\n }\n\n return (\n <Transition\n key={key}\n timeout={animateTimeout}\n nodeRef={levelsRefs[index]}\n >\n {(animate) => (\n <ContextMenuLevel\n {...otherProps}\n {...level}\n key={`${index}-${level.parent ? getItemKey(level.parent) : ''}`}\n isMobile={isMobile}\n isOpen={isOpen}\n style={{\n ...style,\n ...{\n zIndex:\n typeof style?.zIndex === 'number'\n ? style.zIndex + 1\n : undefined,\n },\n }}\n levelDepth={index}\n getItemLabel={getItemLabel}\n addLevel={addLevel}\n deleteLevel={deleteLevel}\n onSetDirection={\n index > 0 ? setSubMenuDirection : props.onSetDirection\n }\n hoveredParenLevel={hoveredParenLevel}\n setHoveredParenLevel={setHoveredParenLevel}\n getItemSubMenu={getItemSubMenu}\n getItemKey={getItemKey}\n ref={index === 0 ? firstLevelRef : levelsRefs[index]}\n spareDirection={index === 0 ? spareDirection : 'rightStartUp'}\n parent={isMobile ? level.parent : undefined}\n animate={animate}\n />\n )}\n </Transition>\n );\n })}\n </TransitionGroup>\n );\n};\n\nexport const ContextMenuLevels = React.forwardRef(\n ContextMenuLevelsRender,\n) as ContextMenuLevelsComponent;\n"],"mappings":"2pCAAA,MAAOA,MAAP,EAAgBC,QAAhB,CAA0BC,SAA1B,CAAqCC,QAArC,KAAqD,OAArD,CACA,OAASC,UAAT,CAAqBC,eAArB,KAA4C,wBAA5C,CAGA,OAASC,eAAT,sCACA,OAASC,UAAT,iCACA,OAASC,aAAT,oCACA,OAASC,OAAT,8BACA,OAASC,cAAT,uCAEA,OAASC,WAAT,CAAsBC,gBAAtB,2BACA,OAASC,SAAT,CAAoBC,kBAApB,kBACA,OAKEC,sCALF,CAMEC,gCANF,gBASA,OAASC,OAAT,iBAEA,GAAMC,wBAAuB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAG3B,IACGC,EAAK,CAAGP,kBAAkB,CAACK,CAAD,CAD7B,CAGDG,CAHC,CAuBCD,CAvBD,CAGDC,KAHC,CAIDC,CAJC,CAuBCF,CAvBD,CAIDE,SAJC,CAKDC,CALC,CAuBCH,CAvBD,CAKDG,QALC,CAMDC,CANC,CAuBCJ,CAvBD,CAMDI,SANC,CAODC,CAPC,CAuBCL,CAvBD,CAODK,kBAPC,CAQDC,CARC,CAuBCN,CAvBD,CAQDM,MARC,CASDC,CATC,CAuBCP,CAvBD,CASDO,cATC,CAUDC,CAVC,CAuBCR,CAvBD,CAUDQ,UAVC,CAWDC,CAXC,CAuBCT,CAvBD,CAWDS,YAXC,CA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CAtLD,CAwLA,MAAO,IAAMG,kBAAiB,CAAGzE,KAAK,CAAC0E,UAAN,CAC/BxD,uBAD+B,CAA1B"}
@@ -0,0 +1 @@
1
+ export * from './ContextMenuLevels';
@@ -0,0 +1,2 @@
1
+ export*from"./ContextMenuLevels";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/index.ts"],"sourcesContent":["export * from './ContextMenuLevels';\n"],"mappings":"AAAA"}
@@ -0,0 +1,2 @@
1
+ import { ComponentSize } from "../../../hooks/useComponentSize";
2
+ export declare const useSize: (refs: React.RefObject<HTMLDivElement>[], setFn: React.Dispatch<React.SetStateAction<ComponentSize>>, isActive?: boolean) => void;
@@ -0,0 +1,2 @@
1
+ import{useEffect,useLayoutEffect}from"react";import{getElementSize}from"../../../hooks/useComponentSize";import{useMutableRef}from"../../../hooks/useMutableRef";export var useSize=function(a,b,c){var d=useMutableRef(function(a){c&&b(function(b){return a.height&&a.width&&(b.height!==a.height||b.width!==a.width)?a:b})}),e=null===a||void 0===a?void 0:a[a.length-1];useLayoutEffect(function(){d.current(getElementSize(null===e||void 0===e?void 0:e.current))},[e]),useEffect(function(){var a=null===e||void 0===e?void 0:e.current,b=new ResizeObserver(function(a){d.current(getElementSize(a[0].target))});return a&&b.observe(a),function(){b.disconnect()}},[e])};
2
+ //# sourceMappingURL=useSize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSize.js","names":["useEffect","useLayoutEffect","getElementSize","useMutableRef","useSize","refs","setFn","isActive","setRef","newState","oldState","height","width","elementRef","length","current","element","resizeObserver","ResizeObserver","res","target","observe","disconnect"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevels/useSize.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nimport { ComponentSize, getElementSize } from '##/hooks/useComponentSize';\nimport { useMutableRef } from '##/hooks/useMutableRef';\n\nexport const useSize = (\n refs: React.RefObject<HTMLDivElement>[],\n setFn: React.Dispatch<React.SetStateAction<ComponentSize>>,\n isActive?: boolean,\n) => {\n const setRef = useMutableRef((newState: ComponentSize) => {\n if (!isActive) {\n return;\n }\n\n setFn((oldState) => {\n if (\n newState.height &&\n newState.width &&\n (oldState.height !== newState.height ||\n oldState.width !== newState.width)\n ) {\n return newState;\n }\n return oldState;\n });\n });\n\n const elementRef = refs?.[refs.length - 1];\n\n useLayoutEffect(() => {\n setRef.current(getElementSize(elementRef?.current));\n }, [elementRef]);\n\n useEffect(() => {\n const element = elementRef?.current;\n\n const resizeObserver = new ResizeObserver((res) => {\n setRef.current(getElementSize(res[0].target as HTMLElement));\n });\n\n element && resizeObserver.observe(element);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [elementRef]);\n};\n"],"mappings":"AAAA,OAASA,SAAT,CAAoBC,eAApB,KAA2C,OAA3C,CAEA,OAAwBC,cAAxB,uCACA,OAASC,aAAT,oCAEA,MAAO,IAAMC,QAAO,CAAG,SACrBC,CADqB,CAErBC,CAFqB,CAGrBC,CAHqB,CAIlB,IACGC,EAAM,CAAGL,aAAa,CAAC,SAACM,CAAD,CAA6B,CACnDF,CADmD,EAKxDD,CAAK,CAAC,SAACI,CAAD,CAAc,OAEhBD,EAAQ,CAACE,MAAT,EACAF,CAAQ,CAACG,KADT,GAECF,CAAQ,CAACC,MAAT,GAAoBF,CAAQ,CAACE,MAA7B,EACCD,CAAQ,CAACE,KAAT,GAAmBH,CAAQ,CAACG,KAH9B,CAFgB,CAOTH,CAPS,CASXC,CACR,CAVI,CAWN,CAhB2B,CADzB,CAmBGG,CAAU,QAAGR,CAAH,WAAGA,CAAH,QAAGA,CAAI,CAAGA,CAAI,CAACS,MAAL,CAAc,CAAjB,CAnBpB,CAqBHb,eAAe,CAAC,UAAM,CACpBO,CAAM,CAACO,OAAP,CAAeb,cAAc,QAACW,CAAD,WAACA,CAAD,QAACA,CAAU,CAAEE,OAAb,CAA7B,CACD,CAFc,CAEZ,CAACF,CAAD,CAFY,CArBZ,CAyBHb,SAAS,CAAC,UAAM,IACRgB,EAAO,QAAGH,CAAH,WAAGA,CAAH,QAAGA,CAAU,CAAEE,OADd,CAGRE,CAAc,CAAG,GAAIC,eAAJ,CAAmB,SAACC,CAAD,CAAS,CACjDX,CAAM,CAACO,OAAP,CAAeb,cAAc,CAACiB,CAAG,CAAC,CAAD,CAAH,CAAOC,MAAR,CAA7B,CACD,CAFsB,CAHT,CASd,MAFAJ,EAAO,EAAIC,CAAc,CAACI,OAAf,CAAuBL,CAAvB,CAEX,CAAO,UAAM,CACXC,CAAc,CAACK,UAAf,EACD,CACF,CAZQ,CAYN,CAACT,CAAD,CAZM,CAaV,CA1CM"}
@@ -0,0 +1 @@
1
+ .ContextMenuWrapper{overflow:hidden;width:240px}.MixPopoverAnimate.ContextMenuWrapper{--mix-dropdown-animate-trasition:opacity var(--mix-dropdown-animate-timeout),transform var(--mix-dropdown-animate-timeout),height var(--mix-dropdown-animate-timeout)}
@@ -0,0 +1,3 @@
1
+ import './ContextMenuWrapper.css';
2
+ import { ContextMenuWrapperProps } from '../types';
3
+ export declare const ContextMenuWrapper: (props: ContextMenuWrapperProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"./ContextMenuWrapper.css";import React,{Fragment,useCallback,useState}from"react";import{Transition}from"react-transition-group";import{cnListBox,mapVerticalSpase}from"../../ListCanary";import{Popover}from"../../Popover";import{useFlag}from"../../../hooks/useFlag";import{useMutableRef}from"../../../hooks/useMutableRef";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate";import{cnMixSpace}from"../../../mixs/MixSpace";import{cn}from"../../../utils/bem";import{contextMenuDefaultSize,defaultContextMenuForm}from"../types";var cnContextMenuWrapper=cn("ContextMenuWrapper");export var ContextMenuWrapper=function(a){var b=a.isMobile,c=a.children,d=a.form,e=void 0===d?defaultContextMenuForm:d,f=a.isOpen,g=a.size,h=void 0===g?contextMenuDefaultSize:g,i=a.anchorRef,j=a.possibleDirections,k=a.position,l=a.direction,m=a.spareDirection,n=a.onClickOutside,o=a.offset,p=a.onSetDirection,q=a.className,r=a.animationBack,s=a.style,t=useFlag(b),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useState(l),y=_slicedToArray(x,2),z=y[0],A=y[1],B=useMutableRef(p),C=useCallback(function(a){var b;A(a),null===(b=B.current)||void 0===b?void 0:b.call(B,a)},[]);return b?React.createElement(Transition,{timeout:animateTimeout,in:f,unmountOnExit:!0,onEntered:w.on,onExit:w.off},function(a){return React.createElement(Popover,{className:cnContextMenuWrapper({animationBack:r,innerAnimation:v},[cnListBox({size:h,form:e,border:!0,shadow:!0}),cnMixSpace({pV:mapVerticalSpase[h]}),cnMixPopoverAnimate({animate:a}),q]),anchorRef:i,possibleDirections:j,position:k,direction:z,spareDirection:m,onClickOutside:n,offset:o,onSetDirection:C,style:s},c)}):React.createElement(Fragment,{key:ContextMenuWrapper.name},c)};
2
+ //# sourceMappingURL=ContextMenuWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenuWrapper.js","names":["React","Fragment","useCallback","useState","Transition","cnListBox","mapVerticalSpase","Popover","useFlag","useMutableRef","animateTimeout","cnMixPopoverAnimate","cnMixSpace","cn","contextMenuDefaultSize","defaultContextMenuForm","cnContextMenuWrapper","ContextMenuWrapper","props","isMobile","children","form","isOpen","size","anchorRef","possibleDirections","position","directionProp","direction","spareDirection","onClickOutside","offset","onSetDirectionProp","onSetDirection","className","animationBack","style","innerAnimation","setInnerAnimation","setSirection","onSetDirectionRef","current","on","off","animate","border","shadow","pV","name"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.tsx"],"sourcesContent":["import './ContextMenuWrapper.css';\n\nimport React, { Fragment, useCallback, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { cnListBox, mapVerticalSpase } from '##/components/ListCanary';\nimport { Direction, Popover } from '##/components/Popover';\nimport { useFlag } from '##/hooks/useFlag';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { animateTimeout, cnMixPopoverAnimate } from '##/mixs/MixPopoverAnimate';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cn } from '##/utils/bem';\n\nimport {\n contextMenuDefaultSize,\n ContextMenuWrapperProps,\n defaultContextMenuForm,\n} from '../types';\n\nconst cnContextMenuWrapper = cn('ContextMenuWrapper');\n\nexport const ContextMenuWrapper = (props: ContextMenuWrapperProps) => {\n const {\n isMobile,\n children,\n form = defaultContextMenuForm,\n isOpen,\n size = contextMenuDefaultSize,\n anchorRef,\n possibleDirections,\n position,\n direction: directionProp,\n spareDirection,\n onClickOutside,\n offset,\n onSetDirection: onSetDirectionProp,\n className,\n animationBack,\n style,\n } = props;\n\n const [innerAnimation, setInnerAnimation] = useFlag(isMobile);\n // запоминаем позицию посднего удовлетворяющего разворота,\n // для того чтоб следующий экран разворачивался в эту же строну.\n const [direction, setSirection] = useState(directionProp);\n\n const onSetDirectionRef = useMutableRef(onSetDirectionProp);\n\n const onSetDirection = useCallback((direction: Direction) => {\n setSirection(direction);\n onSetDirectionRef.current?.(direction);\n }, []);\n\n if (isMobile) {\n return (\n <Transition\n timeout={animateTimeout}\n in={isOpen}\n unmountOnExit\n onEntered={setInnerAnimation.on}\n onExit={setInnerAnimation.off}\n >\n {(animate) => (\n <Popover\n className={cnContextMenuWrapper({ animationBack, innerAnimation }, [\n cnListBox({ size, form, border: true, shadow: true }),\n cnMixSpace({\n pV: mapVerticalSpase[size],\n }),\n cnMixPopoverAnimate({ animate }),\n className,\n ])}\n anchorRef={anchorRef}\n possibleDirections={possibleDirections}\n position={position}\n direction={direction}\n spareDirection={spareDirection}\n onClickOutside={onClickOutside}\n offset={offset}\n onSetDirection={onSetDirection}\n style={style}\n >\n {children}\n </Popover>\n )}\n </Transition>\n );\n }\n\n return <Fragment key={ContextMenuWrapper.name}>{children}</Fragment>;\n};\n"],"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AAEE,CAhBlB,CAiBE,KAAK,CAAEG,CAjBT,EAmBGhB,CAnBH,CADD,CAPH,CAlCgE,CAoE7D,oBAAC,QAAD,EAAU,GAAG,CAAEH,kBAAkB,CAAC+B,IAAlC,EAAyC5B,CAAzC,CACR,CArEM"}
@@ -0,0 +1 @@
1
+ export * from './ContextMenuWrapper';
@@ -0,0 +1,2 @@
1
+ export*from"./ContextMenuWrapper";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/components/ContextMenu/ContextMenuWrapper/index.ts"],"sourcesContent":["export * from './ContextMenuWrapper';\n"],"mappings":"AAAA"}