@consta/uikit 4.7.1 → 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.
- package/__internal__/src/components/ContextMenu/ContextMenu.d.ts +0 -1
- package/__internal__/src/components/ContextMenu/ContextMenu.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenu.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.css +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.css +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.d.ts +4 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js.map +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.d.ts +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.js +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/index.js.map +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.d.ts +2 -2
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.d.ts +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.js +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/useSize.js.map +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.css +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.d.ts +3 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js.map +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.d.ts +1 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.js +2 -0
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/index.js.map +1 -0
- package/__internal__/src/components/ContextMenu/helpers.d.ts +14 -15
- package/__internal__/src/components/ContextMenu/helpers.js +1 -1
- package/__internal__/src/components/ContextMenu/helpers.js.map +1 -1
- package/__internal__/src/components/ContextMenu/types.d.ts +52 -3
- package/__internal__/src/components/ContextMenu/types.js.map +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.css +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.js +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.js.map +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.css +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.js +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.js.map +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.css +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js +1 -1
- package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js.map +1 -1
- package/__internal__/src/components/ListCanary/ListItem/ListItem.css +1 -1
- package/__internal__/src/hooks/useComponentSize/useComponentSize.d.ts +2 -2
- package/__internal__/src/hooks/useComponentSize/useComponentSize.js +1 -1
- package/__internal__/src/hooks/useComponentSize/useComponentSize.js.map +1 -1
- package/__internal__/src/mixs/MixPopoverAnimate/MixPopoverAnimate.css +1 -1
- package/package.json +2 -2
- package/__internal__/src/components/ContextMenu/ContextMenu.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
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","
|
|
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
|
-
.
|
|
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 _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","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 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{IconArrowRight}from"@consta/icons/IconArrowRight";import React,{forwardRef,useEffect}from"react";import{cnListBox,List,mapIconSize}from"../../ListCanary";import{
|
|
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":["IconArrowRight","React","forwardRef","useEffect","cnListBox","List","mapIconSize","Popover","useDebounce","useFlag","useRefs","cn","contextMenuDefaultSize","cnContextMenuLevel","timers","clearTimers","timer","clearTimeout","closeDelay","ContextMenuLevelRender","props","ref","size","items","groupsProp","groups","className","form","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","visible","setVisible","setVisibleTrue","on","getKey","item","toString","itemsRefs","map","setTimeout","onMouseEnter","e","subMenu","disabled","Array","isArray","key","level","firstLevel","border","shadow","off","a","b","side","sides","push","ContextMenuLevel"],"sources":["../../../../../../src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.tsx"],"sourcesContent":["import './ContextMenuLevel.css';\n\nimport { IconArrowRight } from '@consta/icons/IconArrowRight';\nimport React, { forwardRef, useEffect } from 'react';\n\nimport { cnListBox, List, mapIconSize } from '##/components/ListCanary';\nimport { Popover } from '##/components/Popover';\nimport { useDebounce } from '##/hooks/useDebounce';\nimport { useFlag } from '##/hooks/useFlag/useFlag';\nimport { useRefs } from '##/hooks/useRefs/useRefs';\nimport { cn } from '##/utils/bem';\n\nimport {\n contextMenuDefaultSize,\n ContextMenuItemDefault,\n ContextMenuLevelComponent,\n ContextMenuLevelProps,\n} from '../types';\n\nexport const cnContextMenuLevel = cn('ContextMenuLevelCanary');\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 // Свойства относящиеся к меню\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\n ...otherProps\n } = props;\n\n const [hovered, setHovered] = useFlag(false);\n // скрываем блок пока не найдем тоную позицию для оображения\n const [visible, setVisible] = useFlag(false);\n\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 const onMouseEnter =\n (\n item: ContextMenuItemDefault,\n ): JSX.IntrinsicElements['div']['onMouseEnter'] =>\n (e) => {\n const subMenu = getItemSubMenu(item);\n const disabled = getItemDisabled(item);\n const onMouseEnter = getItemAttributes(item)\n ?.onMouseEnter as JSX.IntrinsicElements['div']['onMouseEnter'];\n\n onMouseEnter?.(e);\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 });\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, visible },\n [cnListBox({ size, form, border: true, shadow: true }), className],\n )}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n direction={direction}\n offset={offset}\n onSetDirection={(item) => {\n setVisibleTrue();\n onSetDirection?.(item);\n }}\n onMouseEnter={setHovered.on}\n onMouseLeave={setHovered.off}\n ref={ref}\n {...otherProps}\n >\n <List\n size={size}\n items={items}\n getItemLabel={getItemLabel}\n onItemClick={\n onItemClick\n ? (item, { e }) =>\n onItemClick({ item, e: e as React.MouseEvent<HTMLDivElement> })\n : undefined\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={(item) =>\n ({\n ...getItemAttributes(item),\n onMouseEnter: onMouseEnter(item),\n } as JSX.IntrinsicElements[keyof JSX.IntrinsicElements])\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 </Popover>\n );\n};\n\nexport const ContextMenuLevel = forwardRef(\n ContextMenuLevelRender,\n) as ContextMenuLevelComponent;\n"],"mappings":"m9EAAA,+BAEA,OAASA,cAAT,KAA+B,8BAA/B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,KAA6C,OAA7C,CAEA,OAASC,SAAT,CAAoBC,IAApB,CAA0BC,WAA1B,wBACA,OAASC,OAAT,qBACA,OAASC,WAAT,kCACA,OAASC,OAAT,sCACA,OAASC,OAAT,sCACA,OAASC,EAAT,0BAEA,OACEC,sBADF,gBAOA,MAAO,IAAMC,mBAAkB,CAAGF,EAAE,CAAC,wBAAD,CAA7B,CAEP,GAAIG,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,CAD6B,CAE7BC,CAF6B,CAG1B,OA0CCD,CA1CD,CAEDE,IAFC,CAEDA,CAFC,YAEMV,sBAFN,GAGDW,CAHC,CA0CCH,CA1CD,CAGDG,KAHC,CAIOC,CAJP,CA0CCJ,CA1CD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,IAAN,CAAW,oBAAC,cAAD,EAAgB,IAAI,CAAEhF,WAAW,CAACgB,CAAD,CAAjC,EAAX,CACA,CAAO+D,CACR,CAxCH,CAyCE,WAAW,CAAE7B,CAzCf,CA0CE,aAAa,CAAED,CA1CjB,CA2CE,eAAe,CAAER,CA3CnB,CA4CE,aAAa,CAAED,CA5CjB,CA6CE,UAAU,CAAE,oBAACmB,CAAD,QAAUE,EAAS,CAACH,CAAM,CAACC,CAAD,CAAP,CAAnB,CA7Cd,CA8CE,MAAM,CAAEzC,CA9CV,CA+CE,aAAa,CAAE,uBAACyC,CAAD,QAAUD,EAAM,CAACC,CAAD,CAAN,GAAiBpC,CAA3B,CA/CjB,CAgDE,WAAW,CAAW,OAAT,GAAAF,CAAI,CAAe,WAAf,CAA6B,QAhDhD,EAnBF,CAuEH,C,CAED,MAAO,IAAM4D,iBAAgB,CAAGrF,UAAU,CACxCiB,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,CAD6B,CAE7BC,CAF6B,CAG1B,OA8CCD,CA9CD,CAEDE,IAFC,CAEDA,CAFC,YAEMV,sBAFN,GAGDW,CAHC,CA8CCH,CA9CD,CAGDG,KAHC,CAIOC,CAJP,CA8CCJ,CA9CD,CAIDK,MAJC,CAKDC,CALC,CA8CCN,CA9CD,CAKDM,SALC,GA8CCN,CA9CD,CAMDO,IANC,CAMDA,CANC,YAMM,SANN,GAODC,CAPC,CA8CCR,CA9CD,CAODQ,OAPC,CASDC,CATC,CA8CCT,CA9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A9CjB,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"}
|
package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ContextMenuLevelWrapper-Mobile{position:relative;width:240px}
|
package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.d.ts
ADDED
|
@@ -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>>;
|
package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js
ADDED
|
@@ -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 @@
|
|
|
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 {
|
|
2
|
-
export declare const ContextMenuLevels:
|
|
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{
|
|
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","directions","useClickOutside","useForkRef","useRefs","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 { Direction, directions } from '##/components/Popover';\nimport { useClickOutside } from '##/hooks/useClickOutside';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useRefs } from '##/hooks/useRefs';\n\nimport { clearTimers, ContextMenuLevel } from '../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,OAA3C,CAEA,OAAoBC,UAApB,qBACA,OAASC,eAAT,sCACA,OAASC,UAAT,iCACA,OAASC,OAAT,8BAEA,OAASC,WAAT,CAAsBC,gBAAtB,2BACA,OAASC,SAAT,CAAoBC,kBAApB,kBACA,OAGEC,sCAHF,CAKEC,gCALF,gBASA,GAAMC,wBAAuB,CAAG,SAC9BC,CAD8B,CAE9BC,CAF8B,CAG3B,IACGC,EAAK,CAAGN,kBAAkB,CAACI,CAAD,CAD7B,CAGDG,CAHC,CAkBCD,CAlBD,CAGDC,KAHC,CAIDC,CAJC,CAkBCF,CAlBD,CAIDE,SAJC,CAKDC,CALC,CAkBCH,CAlBD,CAKDG,QALC,CAMDC,CANC,CAkBCJ,CAlBD,CAMDI,SANC,GAkBCJ,CAlBD,CAODK,kBAPC,CAODA,CAPC,YAOoBlB,UAPpB,GAQDmB,CARC,CAkBCN,CAlBD,CAQDM,MARC,CASDC,CATC,CAkBCP,CAlBD,CASDO,cATC,CAUDC,CAVC,CAkBCR,CAlBD,CAUDQ,UAVC,CAWDC,CAXC,CAkBCT,CAlBD,CAWDS,YAXC,CAYD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CAAC,UAAM,CACdiC,CAAS,CAACF,CAAD,CACV,CAFQ,CAEN,CAACb,CAAD,CAFM,CAIT,CACE,wCACGc,CAAM,CAACqB,GAAP,CAAW,SAACb,CAAD,CAAQc,CAAR,QACV,qBAAC,gBAAD,kBACMxB,CADN,CAEMU,CAFN,EAGE,GAAG,uBAAiBc,CAAjB,CAHL,CAIE,KAAK,gCACA5B,CADA,EAEA,CACD6B,MAAM,CACqB,QAAzB,gBAAO7B,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAE6B,MAAd,EACI7B,CAAK,CAAC6B,MAAN,CAAe,CADnB,OAFD,CAFA,CAJP,CAaE,UAAU,CAAED,CAbd,CAcE,YAAY,CAAE9B,CAdhB,CAeE,QAAQ,CAAEe,CAfZ,CAgBE,WAAW,CAAEO,CAhBf,CAiBE,cAAc,CACJ,CAAR,CAAAQ,CAAK,CAAOpB,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,S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,CAhBhB,CAiBE,QAAQ,CAAEqB,CAjBZ,CAkBE,WAAW,CAAES,CAlBf,CAmBE,cAAc,CACJ,CAAR,CAAAO,CAAK,CAAOrB,CAAP,CAA6BzB,CAAK,CAACmD,cApB5C,CAsBE,iBAAiB,CAAEzB,CAtBrB,CAuBE,oBAAoB,CAAEC,CAvBxB,CAwBE,cAAc,CAAEjB,CAxBlB,CAyBE,UAAU,CAAEF,CAzBd,CA0BE,GAAG,CAAY,CAAV,GAAAsC,CAAK,CAASF,CAAT,CAAyBhB,CAAU,CAACkB,CAAD,CA1B/C,CA2BE,cAAc,CAAY,CAAV,GAAAA,CAAK,CAASlC,CAAT,CAA0B,cA3BjD,CA4BE,MAAM,CAAEG,CAAQ,CAAGgB,CAAK,CAACE,MAAT,OA5BlB,CA6BE,OAAO,CAAEgB,CA7BX,GADD,CALH,CAwCH,CAlDA,CADH,CAsDH,CAtLD,CAwLA,MAAO,IAAMG,kBAAiB,CAAGzE,KAAK,CAAC0E,UAAN,CAC/BxD,uBAD+B,CAA1B"}
|
|
@@ -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,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"],"mappings":"iEAAA,iCAEA,MAAOA,MAAP,EAAgBC,QAAhB,CAA0BC,WAA1B,CAAuCC,QAAvC,KAAuD,OAAvD,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OAASC,SAAT,CAAoBC,gBAApB,wBACA,OAAoBC,OAApB,qBACA,OAASC,OAAT,8BACA,OAASC,aAAT,oCACA,OAASC,cAAT,CAAyBC,mBAAzB,uCACA,OAASC,UAAT,8BACA,OAASC,EAAT,0BAEA,OACEC,sBADF,CAGEC,sBAHF,gBAMA,GAAMC,qBAAoB,CAAGH,EAAE,CAAC,oBAAD,CAA/B,CAEA,MAAO,IAAMI,mBAAkB,CAAG,SAACC,CAAD,CAAoC,IAElEC,EAFkE,CAkBhED,CAlBgE,CAElEC,QAFkE,CAGlEC,CAHkE,CAkBhEF,CAlBgE,CAGlEE,QAHkE,GAkBhEF,CAlBgE,CAIlEG,IAJkE,CAIlEA,CAJkE,YAI3DN,sBAJ2D,GAKlEO,CALkE,CAkBhEJ,CAlBgE,CAKlEI,MALkE,GAkBhEJ,CAlBgE,CAMlEK,IANkE,CAMlEA,CANkE,YAM3DT,sBAN2D,GAOlEU,CAPkE,CAkBhEN,CAlBgE,CAOlEM,SAPkE,CAQlEC,CARkE,CAkBhEP,CAlBgE,CAQlEO,kBARkE,CASlEC,CATkE,CAkBhER,CAlBgE,CASlEQ,QATkE,CAUvDC,CAVuD,CAkBhET,CAlBgE,CAUlEU,SAVkE,CAWlEC,CAXkE,CAkBhEX,CAlBgE,CAWlEW,cAXkE,CAYlEC,CAZkE,CAkBhEZ,CAlBgE,CAYlEY,cAZkE,CAalEC,CAbkE,CAkBhEb,CAlBgE,CAalEa,MAbkE,CAclDC,CAdkD,CAkBhEd,CAlBgE,CAclEe,cAdkE,CAelEC,CAfkE,CAk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AXZ,CAYE,SAAS,CAAEE,CAZb,CAaE,cAAc,CAAEC,CAblB,CAcE,cAAc,CAAEC,CAdlB,CAeE,MAAM,CAAEC,CAfV,CAgBE,cAAc,CAAEE,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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/components/ContextMenu/ContextMenuWrapper/index.ts"],"sourcesContent":["export * from './ContextMenuWrapper';\n"],"mappings":"AAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { ContextMenuGroupDefault, ContextMenuItemDefault, ContextMenuPropGetGroupId, ContextMenuPropGetGroupLabel, ContextMenuPropGetItemAs, ContextMenuPropGetItemAttributes, ContextMenuPropGetItemDisabled, ContextMenuPropGetItemGroupId, ContextMenuPropGetItemKey, ContextMenuPropGetItemLabel, ContextMenuPropGetItemLeftIcon, ContextMenuPropGetItemLeftSide, ContextMenuPropGetItemOnClick, ContextMenuPropGetItemRightIcon, ContextMenuPropGetItemRightSide, ContextMenuPropGetItemStatus, ContextMenuPropGetItemSubMenu, ContextMenuProps, ContextMenuPropSize, GetLevelsParams, Level, MappersGroup } from './types';
|
|
5
|
-
export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<ITEM, GROUP>): ({
|
|
2
|
+
import { ContextMenuGroupDefault, ContextMenuItemDefault, ContextMenuLevelsProps, ContextMenuPropGetGroupId, ContextMenuPropGetGroupLabel, ContextMenuPropGetItemAs, ContextMenuPropGetItemAttributes, ContextMenuPropGetItemDisabled, ContextMenuPropGetItemGroupId, ContextMenuPropGetItemKey, ContextMenuPropGetItemLabel, ContextMenuPropGetItemLeftIcon, ContextMenuPropGetItemLeftSide, ContextMenuPropGetItemOnClick, ContextMenuPropGetItemRightIcon, ContextMenuPropGetItemRightSide, ContextMenuPropGetItemStatus, ContextMenuPropGetItemSubMenu, GetLevelsParams, Level } from './types';
|
|
3
|
+
export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuLevelsProps<ITEM, GROUP>): ({
|
|
6
4
|
items: ITEM[];
|
|
7
5
|
size?: "s" | "m" | "xs" | "l" | undefined;
|
|
8
6
|
direction?: "downCenter" | "upCenter" | "downRight" | "downLeft" | "upRight" | "upLeft" | "leftUp" | "leftCenter" | "leftDown" | "rightUp" | "rightCenter" | "rightDown" | "downStartLeft" | "upStartLeft" | "downStartRight" | "upStartRight" | "leftStartUp" | "leftStartDown" | "rightStartUp" | "rightStartDown" | undefined;
|
|
@@ -17,10 +15,11 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
|
|
|
17
15
|
onClickOutside?: import("../../hooks/useClickOutside").ClickOutsideHandler | undefined;
|
|
18
16
|
isOpen?: boolean | undefined;
|
|
19
17
|
form?: "default" | "round" | "brick" | undefined;
|
|
20
|
-
|
|
18
|
+
isMobile?: boolean | undefined;
|
|
19
|
+
} & import("./types").MappersItem<ITEM> & import("./types").MappersGroup<GROUP> & {
|
|
21
20
|
anchorRef: import("react").RefObject<HTMLElement>;
|
|
22
21
|
position?: undefined;
|
|
23
|
-
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "form" | "direction" | "offset" | "size" | "css" | "items" | "groups" | "position" | "isOpen" | "onItemClick" | "sortGroup" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "subMenuDirection" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
|
|
22
|
+
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "form" | "direction" | "offset" | "size" | "css" | "items" | "groups" | "position" | "isOpen" | "onItemClick" | "sortGroup" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "subMenuDirection" | "isMobile" | keyof import("./types").MappersItem<ITEM_1> | keyof import("./types").MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
|
|
24
23
|
id: unknown;
|
|
25
24
|
} ? {} : {
|
|
26
25
|
getGroupId: ContextMenuPropGetGroupId<GROUP>;
|
|
@@ -44,6 +43,9 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
|
|
|
44
43
|
getItemGroupId: ContextMenuPropGetItemGroupId<ContextMenuItemDefault> | ContextMenuPropGetItemGroupId<ITEM>;
|
|
45
44
|
getGroupId: ContextMenuPropGetGroupId<ContextMenuGroupDefault> | ContextMenuPropGetGroupId<GROUP>;
|
|
46
45
|
getGroupLabel: ContextMenuPropGetGroupLabel<ContextMenuGroupDefault> | ContextMenuPropGetGroupLabel<GROUP>;
|
|
46
|
+
setComponentSize: import("react").Dispatch<import("react").SetStateAction<import("../../hooks/useComponentSize").ComponentSize>>;
|
|
47
|
+
disableAnimationBack: () => void;
|
|
48
|
+
enableAnimationBack: () => void;
|
|
47
49
|
}) | ({
|
|
48
50
|
items: ITEM[];
|
|
49
51
|
size?: "s" | "m" | "xs" | "l" | undefined;
|
|
@@ -59,10 +61,11 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
|
|
|
59
61
|
onClickOutside?: import("../../hooks/useClickOutside").ClickOutsideHandler | undefined;
|
|
60
62
|
isOpen?: boolean | undefined;
|
|
61
63
|
form?: "default" | "round" | "brick" | undefined;
|
|
62
|
-
|
|
64
|
+
isMobile?: boolean | undefined;
|
|
65
|
+
} & import("./types").MappersItem<ITEM> & import("./types").MappersGroup<GROUP> & {
|
|
63
66
|
anchorRef?: undefined;
|
|
64
67
|
position: import("../Popover").Position;
|
|
65
|
-
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "form" | "direction" | "offset" | "size" | "css" | "items" | "groups" | "position" | "isOpen" | "onItemClick" | "sortGroup" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "subMenuDirection" | keyof import("./types").MappersItem<ITEM_1> | keyof MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
|
|
68
|
+
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "form" | "direction" | "offset" | "size" | "css" | "items" | "groups" | "position" | "isOpen" | "onItemClick" | "sortGroup" | "possibleDirections" | "spareDirection" | "onClickOutside" | "onSetDirection" | "anchorRef" | "subMenuDirection" | "isMobile" | keyof import("./types").MappersItem<ITEM_1> | keyof import("./types").MappersGroup<GROUP_1>> & import("react").RefAttributes<HTMLDivElement> & (GROUP extends {
|
|
66
69
|
id: unknown;
|
|
67
70
|
} ? {} : {
|
|
68
71
|
getGroupId: ContextMenuPropGetGroupId<GROUP>;
|
|
@@ -86,12 +89,8 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: ContextMenuProps<
|
|
|
86
89
|
getItemGroupId: ContextMenuPropGetItemGroupId<ContextMenuItemDefault> | ContextMenuPropGetItemGroupId<ITEM>;
|
|
87
90
|
getGroupId: ContextMenuPropGetGroupId<ContextMenuGroupDefault> | ContextMenuPropGetGroupId<GROUP>;
|
|
88
91
|
getGroupLabel: ContextMenuPropGetGroupLabel<ContextMenuGroupDefault> | ContextMenuPropGetGroupLabel<GROUP>;
|
|
92
|
+
setComponentSize: import("react").Dispatch<import("react").SetStateAction<import("../../hooks/useComponentSize").ComponentSize>>;
|
|
93
|
+
disableAnimationBack: () => void;
|
|
94
|
+
enableAnimationBack: () => void;
|
|
89
95
|
});
|
|
90
|
-
export declare const getGroup: <GROUP>(group: GROUP, props: Required<MappersGroup<GROUP>>) => {
|
|
91
|
-
id: number;
|
|
92
|
-
name: string | undefined;
|
|
93
|
-
};
|
|
94
96
|
export declare const getLevels: <ITEM>(params: GetLevelsParams<ITEM>) => Level<ITEM>[];
|
|
95
|
-
export declare const getItemIndex: (groupId: number | string, itemIndex: number) => string;
|
|
96
|
-
export declare const sizeMapHeader: Record<ContextMenuPropSize, TextPropSize>;
|
|
97
|
-
export declare const sizeMapIcon: Record<ContextMenuPropSize, IconPropSize>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";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}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{isNotNil}from"../../utils/type-guards";var defaultGetItemKey=function(a){return a.key||a.label},defaultGetItemRightSide=function(a){return a.rightSide},defaultGetItemLeftSide=function(a){return a.leftSide},defaultGetItemRightIcon=function(a){return a.rightIcon},defaultGetItemLeftIcon=function(a){return a.leftIcon},defaultGetItemStatus=function(a){return a.status},defaultGetItemDisabled=function(a){return a.disabled},defaultGetItemLabel=function(a){return a.label},defaultGetItemOnClick=function(a){return a.onClick},defaultGetItemSubMenu=function(a){return a.subMenu},defaultGetItemAs=function(a){return a.as},defaultGetItemAttributes=function(a){return a.attributes},defaultGetItemGroupId=function(a){return a.groupId},defaultGetGroupId=function(a){return a.id},defaultGetGroupLabel=function(a){return a.label};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemKey:a.getItemKey||defaultGetItemKey,getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemRightSide:a.getItemRightSide||defaultGetItemRightSide,getItemLeftSide:a.getItemLeftSide||defaultGetItemLeftSide,getItemRightIcon:a.getItemRightIcon||defaultGetItemRightIcon,getItemLeftIcon:a.getItemLeftIcon||defaultGetItemLeftIcon,getItemSubMenu:a.getItemSubMenu||defaultGetItemSubMenu,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemDisabled:a.getItemDisabled||defaultGetItemDisabled,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick,getItemAs:a.getItemAs||defaultGetItemAs,getItemAttributes:a.getItemAttributes||defaultGetItemAttributes,getItemGroupId:a.getItemGroupId||defaultGetItemGroupId,getGroupId:a.getGroupId||defaultGetGroupId,getGroupLabel:a.getGroupLabel||defaultGetGroupLabel})}
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";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}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{isNotNil}from"../../utils/type-guards";var defaultGetItemKey=function(a){return a.key||a.label},defaultGetItemRightSide=function(a){return a.rightSide},defaultGetItemLeftSide=function(a){return a.leftSide},defaultGetItemRightIcon=function(a){return a.rightIcon},defaultGetItemLeftIcon=function(a){return a.leftIcon},defaultGetItemStatus=function(a){return a.status},defaultGetItemDisabled=function(a){return a.disabled},defaultGetItemLabel=function(a){return a.label},defaultGetItemOnClick=function(a){return a.onClick},defaultGetItemSubMenu=function(a){return a.subMenu},defaultGetItemAs=function(a){return a.as},defaultGetItemAttributes=function(a){return a.attributes},defaultGetItemGroupId=function(a){return a.groupId},defaultGetGroupId=function(a){return a.id},defaultGetGroupLabel=function(a){return a.label};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemKey:a.getItemKey||defaultGetItemKey,getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemRightSide:a.getItemRightSide||defaultGetItemRightSide,getItemLeftSide:a.getItemLeftSide||defaultGetItemLeftSide,getItemRightIcon:a.getItemRightIcon||defaultGetItemRightIcon,getItemLeftIcon:a.getItemLeftIcon||defaultGetItemLeftIcon,getItemSubMenu:a.getItemSubMenu||defaultGetItemSubMenu,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemDisabled:a.getItemDisabled||defaultGetItemDisabled,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick,getItemAs:a.getItemAs||defaultGetItemAs,getItemAttributes:a.getItemAttributes||defaultGetItemAttributes,getItemGroupId:a.getItemGroupId||defaultGetItemGroupId,getGroupId:a.getGroupId||defaultGetGroupId,getGroupLabel:a.getGroupLabel||defaultGetGroupLabel})}var findItem=function(a){var b,c=a.items,d=a.getItemKey,e=a.getItemSubMenu,f=a.key,g=_createForOfIteratorHelper(c);try{for(g.s();!(b=g.n()).done;){var h=b.value;if(d(h)===f)return h;var i="function"==typeof e&&e(h);if(i){var j=findItem({items:i,key:f,getItemKey:d,getItemSubMenu:e});if(j)return j}}}catch(a){g.e(a)}finally{g.f()}};export var getLevels=function(a){var b=a.levels,c=a.items,d=a.getItemKey,e=a.getItemSubMenu;return b.map(function(a){return _objectSpread(_objectSpread({},a),{},{items:a.items.map(function(a){return findItem({items:c,getItemSubMenu:e,getItemKey:d,key:d(a)})}).filter(isNotNil)})})};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["isNotNil","defaultGetItemKey","item","key","label","defaultGetItemRightSide","rightSide","defaultGetItemLeftSide","leftSide","defaultGetItemRightIcon","rightIcon","defaultGetItemLeftIcon","leftIcon","defaultGetItemStatus","status","defaultGetItemDisabled","disabled","defaultGetItemLabel","defaultGetItemOnClick","onClick","defaultGetItemSubMenu","subMenu","defaultGetItemAs","as","defaultGetItemAttributes","attributes","defaultGetItemGroupId","groupId","defaultGetGroupId","group","id","defaultGetGroupLabel","withDefaultGetters","props","getItemKey","getItemLabel","getItemRightSide","getItemLeftSide","getItemRightIcon","getItemLeftIcon","getItemSubMenu","getItemStatus","getItemDisabled","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getGroupId","getGroupLabel","
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["isNotNil","defaultGetItemKey","item","key","label","defaultGetItemRightSide","rightSide","defaultGetItemLeftSide","leftSide","defaultGetItemRightIcon","rightIcon","defaultGetItemLeftIcon","leftIcon","defaultGetItemStatus","status","defaultGetItemDisabled","disabled","defaultGetItemLabel","defaultGetItemOnClick","onClick","defaultGetItemSubMenu","subMenu","defaultGetItemAs","as","defaultGetItemAttributes","attributes","defaultGetItemGroupId","groupId","defaultGetGroupId","group","id","defaultGetGroupLabel","withDefaultGetters","props","getItemKey","getItemLabel","getItemRightSide","getItemLeftSide","getItemRightIcon","getItemLeftIcon","getItemSubMenu","getItemStatus","getItemDisabled","getItemOnClick","getItemAs","getItemAttributes","getItemGroupId","getGroupId","getGroupLabel","findItem","params","items","subItems","subItem","getLevels","levels","map","level","filter"],"sources":["../../../../../src/components/ContextMenu/helpers.ts"],"sourcesContent":["import { isNotNil } from '../../utils/type-guards';\nimport {\n ContextMenuGroupDefault,\n ContextMenuItemDefault,\n ContextMenuLevelsProps,\n ContextMenuPropGetGroupId,\n ContextMenuPropGetGroupLabel,\n ContextMenuPropGetItemAs,\n ContextMenuPropGetItemAttributes,\n ContextMenuPropGetItemDisabled,\n ContextMenuPropGetItemGroupId,\n ContextMenuPropGetItemKey,\n ContextMenuPropGetItemLabel,\n ContextMenuPropGetItemLeftIcon,\n ContextMenuPropGetItemLeftSide,\n ContextMenuPropGetItemOnClick,\n ContextMenuPropGetItemRightIcon,\n ContextMenuPropGetItemRightSide,\n ContextMenuPropGetItemStatus,\n ContextMenuPropGetItemSubMenu,\n GetLevelsParams,\n Level,\n} from './types';\n\nconst defaultGetItemKey: ContextMenuPropGetItemKey<ContextMenuItemDefault> = (\n item,\n) => item.key || item.label;\nconst defaultGetItemRightSide: ContextMenuPropGetItemRightSide<\n ContextMenuItemDefault\n> = (item) => item.rightSide;\nconst defaultGetItemLeftSide: ContextMenuPropGetItemLeftSide<\n ContextMenuItemDefault\n> = (item) => item.leftSide;\nconst defaultGetItemRightIcon: ContextMenuPropGetItemRightIcon<\n ContextMenuItemDefault\n> = (item) => item.rightIcon;\nconst defaultGetItemLeftIcon: ContextMenuPropGetItemLeftIcon<\n ContextMenuItemDefault\n> = (item) => item.leftIcon;\nconst defaultGetItemStatus: ContextMenuPropGetItemStatus<\n ContextMenuItemDefault\n> = (item) => item.status;\nconst defaultGetItemDisabled: ContextMenuPropGetItemDisabled<\n ContextMenuItemDefault\n> = (item) => item.disabled;\nconst defaultGetItemLabel: ContextMenuPropGetItemLabel<\n ContextMenuItemDefault\n> = (item) => item.label;\nconst defaultGetItemOnClick: ContextMenuPropGetItemOnClick<\n ContextMenuItemDefault\n> = (item) => item.onClick;\nconst defaultGetItemSubMenu: ContextMenuPropGetItemSubMenu<\n ContextMenuItemDefault\n> = (item) => item.subMenu;\nconst defaultGetItemAs: ContextMenuPropGetItemAs<ContextMenuItemDefault> = (\n item,\n) => item.as;\nconst defaultGetItemAttributes: ContextMenuPropGetItemAttributes<\n ContextMenuItemDefault\n> = (item) => item.attributes;\nconst defaultGetItemGroupId: ContextMenuPropGetItemGroupId<\n ContextMenuItemDefault\n> = (item) => item.groupId;\n\nconst defaultGetGroupId: ContextMenuPropGetGroupId<ContextMenuGroupDefault> = (\n group,\n) => group.id;\nconst defaultGetGroupLabel: ContextMenuPropGetGroupLabel<\n ContextMenuGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<ITEM, GROUP>(\n props: ContextMenuLevelsProps<ITEM, GROUP>,\n) {\n return {\n ...props,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemRightSide: props.getItemRightSide || defaultGetItemRightSide,\n getItemLeftSide: props.getItemLeftSide || defaultGetItemLeftSide,\n getItemRightIcon: props.getItemRightIcon || defaultGetItemRightIcon,\n getItemLeftIcon: props.getItemLeftIcon || defaultGetItemLeftIcon,\n getItemSubMenu: props.getItemSubMenu || defaultGetItemSubMenu,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n getItemAs: props.getItemAs || defaultGetItemAs,\n getItemAttributes: props.getItemAttributes || defaultGetItemAttributes,\n getItemGroupId: props.getItemGroupId || defaultGetItemGroupId,\n getGroupId: props.getGroupId || defaultGetGroupId,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n };\n}\n\nconst findItem = <ITEM>(\n params: Omit<GetLevelsParams<ITEM>, 'levels'> & {\n key: ContextMenuItemDefault['key'];\n },\n): ITEM | undefined => {\n const { items, getItemKey, getItemSubMenu, key } = params;\n for (const item of items) {\n if (getItemKey(item) === key) {\n return item;\n }\n const subItems =\n typeof getItemSubMenu === 'function' && getItemSubMenu(item);\n if (subItems) {\n const subItem = findItem({\n items: subItems,\n key,\n getItemKey,\n getItemSubMenu,\n });\n if (subItem) {\n return subItem;\n }\n }\n }\n return undefined;\n};\n\nexport const getLevels = <ITEM>(\n params: GetLevelsParams<ITEM>,\n): Level<ITEM>[] => {\n const { levels, items, getItemKey, getItemSubMenu } = params;\n\n return levels.map((level) => ({\n ...level,\n items: level.items\n .map((item) =>\n findItem({\n items,\n getItemSubMenu,\n getItemKey,\n key: getItemKey(item),\n }),\n )\n .filter(isNotNil),\n }));\n};\n"],"mappings":"0zDAAA,OAASA,QAAT,+B,GAwBMC,kBAAoE,CAAG,SAC3EC,CAD2E,QAExEA,EAAI,CAACC,GAAL,EAAYD,CAAI,CAACE,KAFuD,C,CAGvEC,uBAEL,CAAG,SAACH,CAAD,QAAUA,EAAI,CAACI,SAAf,C,CACEC,sBAEL,CAAG,SAACL,CAAD,QAAUA,EAAI,CAACM,QAAf,C,CACEC,uBAEL,CAAG,SAACP,CAAD,QAAUA,EAAI,CAACQ,SAAf,C,CACEC,sBAEL,CAAG,SAACT,CAAD,QAAUA,EAAI,CAACU,QAAf,C,CACEC,oBAEL,CAAG,SAACX,CAAD,QAAUA,EAAI,CAACY,MAAf,C,CACEC,sBAEL,CAAG,SAACb,CAAD,QAAUA,EAAI,CAACc,QAAf,C,CACEC,mBAEL,CAAG,SAACf,CAAD,QAAUA,EAAI,CAACE,KAAf,C,CACEc,qBAEL,CAAG,SAAChB,CAAD,QAAUA,EAAI,CAACiB,OAAf,C,CACEC,qBAEL,CAAG,SAAClB,CAAD,QAAUA,EAAI,CAACmB,OAAf,C,CACEC,gBAAkE,CAAG,SACzEpB,CADyE,QAEtEA,EAAI,CAACqB,EAFiE,C,CAGrEC,wBAEL,CAAG,SAACtB,CAAD,QAAUA,EAAI,CAACuB,UAAf,C,CACEC,qBAEL,CAAG,SAACxB,CAAD,QAAUA,EAAI,CAACyB,OAAf,C,CAEEC,iBAAqE,CAAG,SAC5EC,CAD4E,QAEzEA,EAAK,CAACC,EAFmE,C,CAGxEC,oBAEL,CAAG,SAACF,CAAD,QAAWA,EAAK,CAACzB,KAAjB,C,CAEJ,MAAO,SAAS4B,mBAAT,CACLC,CADK,CAEL,CACA,sCACKA,CAD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,UAA1B,QAAOZ,EAAP,EAAwCA,CAAc,CAACtC,CAAD,CADxD,CAEA,GAAIkD,CAAJ,CAAc,CACZ,GAAMC,EAAO,CAAGJ,QAAQ,CAAC,CACvBE,KAAK,CAAEC,CADgB,CAEvBjD,GAAG,CAAHA,CAFuB,CAGvB+B,UAAU,CAAVA,CAHuB,CAIvBM,cAAc,CAAdA,CAJuB,CAAD,CAAxB,CAMA,GAAIa,CAAJ,CACE,MAAOA,EAEV,CACF,CAnBoB,+BAqBtB,CAzBD,CA2BA,MAAO,IAAMC,UAAS,CAAG,SACvBJ,CADuB,CAEL,CAClB,GAAQK,EAAR,CAAsDL,CAAtD,CAAQK,MAAR,CAAgBJ,CAAhB,CAAsDD,CAAtD,CAAgBC,KAAhB,CAAuBjB,CAAvB,CAAsDgB,CAAtD,CAAuBhB,UAAvB,CAAmCM,CAAnC,CAAsDU,CAAtD,CAAmCV,cAAnC,CAEA,MAAOe,EAAM,CAACC,GAAP,CAAW,SAACC,CAAD,wCACbA,CADa,MAEhBN,KAAK,CAAEM,CAAK,CAACN,KAAN,CACJK,GADI,CACA,SAACtD,CAAD,QACH+C,SAAQ,CAAC,CACPE,KAAK,CAALA,CADO,CAEPX,cAAc,CAAdA,CAFO,CAGPN,UAAU,CAAVA,CAHO,CAIP/B,GAAG,CAAE+B,CAAU,CAAChC,CAAD,CAJR,CAAD,CADL,CADA,EASJwD,MATI,CASG1D,QATH,CAFS,GAAX,CAaR,CAlBM"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconComponent } from '@consta/icons/Icon';
|
|
3
3
|
import { ListPropForm } from "../ListCanary";
|
|
4
|
+
import { ComponentSize } from "../../hooks/useComponentSize";
|
|
5
|
+
import { Animate } from "../../mixs/MixPopoverAnimate";
|
|
4
6
|
import { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';
|
|
5
7
|
import { PropsWithAsAttributes } from '../../utils/types/PropsWithAsAttributes';
|
|
6
|
-
import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';
|
|
8
|
+
import { PropsWithHTMLAttributes, PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';
|
|
7
9
|
import { Direction, PopoverPropOffset, Position } from '../Popover/Popover';
|
|
8
10
|
export declare const contextMenuSizes: readonly ["m", "xs", "s", "l"];
|
|
9
11
|
export declare type ContextMenuPropSize = typeof contextMenuSizes[number];
|
|
@@ -88,11 +90,16 @@ export declare type Level<ITEM> = {
|
|
|
88
90
|
direction?: Direction;
|
|
89
91
|
possibleDirections?: readonly Direction[];
|
|
90
92
|
offset?: PopoverPropOffset;
|
|
91
|
-
|
|
93
|
+
parent?: ITEM;
|
|
94
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
95
|
+
position?: Position;
|
|
96
|
+
};
|
|
92
97
|
export declare type AddLevel<ITEM> = (params: {
|
|
93
98
|
level: number;
|
|
94
99
|
items: ITEM[];
|
|
100
|
+
parent?: ITEM;
|
|
95
101
|
anchorRef?: React.RefObject<HTMLElement>;
|
|
102
|
+
position?: Position;
|
|
96
103
|
activeItem: string;
|
|
97
104
|
}) => void;
|
|
98
105
|
export declare type ContextMenuProps<ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault> = PropsWithHTMLAttributesAndRef<{
|
|
@@ -110,6 +117,7 @@ export declare type ContextMenuProps<ITEM = ContextMenuItemDefault, GROUP = Cont
|
|
|
110
117
|
onClickOutside?: ClickOutsideHandler;
|
|
111
118
|
isOpen?: boolean;
|
|
112
119
|
form?: ContextMenuForm;
|
|
120
|
+
isMobile?: boolean;
|
|
113
121
|
} & MappersItem<ITEM> & MappersGroup<GROUP> & PositioningProps, HTMLDivElement> & (GROUP extends {
|
|
114
122
|
id: ContextMenuGroupDefault['id'] | unknown;
|
|
115
123
|
} ? {} : {
|
|
@@ -119,8 +127,15 @@ export declare type ContextMenuProps<ITEM = ContextMenuItemDefault, GROUP = Cont
|
|
|
119
127
|
} ? {} : {
|
|
120
128
|
getItemLabel: ContextMenuPropGetItemLabel<ITEM>;
|
|
121
129
|
});
|
|
130
|
+
export declare type ContextMenuLevelsProps<ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault> = ContextMenuProps<ITEM, GROUP> & {
|
|
131
|
+
setComponentSize: React.Dispatch<React.SetStateAction<ComponentSize>>;
|
|
132
|
+
disableAnimationBack: () => void;
|
|
133
|
+
enableAnimationBack: () => void;
|
|
134
|
+
};
|
|
135
|
+
export declare type ContextMenuLevelsComponent = <ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault>(props: ContextMenuLevelsProps<ITEM, GROUP>) => React.ReactElement | null;
|
|
122
136
|
export declare type ContextMenuComponent = <ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault>(props: ContextMenuProps<ITEM, GROUP>) => React.ReactElement | null;
|
|
123
|
-
export declare type ContextMenuLevelProps<ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault> = Omit<ContextMenuProps<ITEM, GROUP>, 'subMenuDirection' | 'onClickOutside' | keyof MappersItem<ITEM> | keyof MappersGroup<GROUP>> & {
|
|
137
|
+
export declare type ContextMenuLevelProps<ITEM = ContextMenuItemDefault, GROUP = ContextMenuGroupDefault> = Omit<ContextMenuProps<ITEM, GROUP>, 'subMenuDirection' | 'onClickOutside' | 'setComponentSize' | 'animationBack' | 'disableAnimationBack' | 'enableAnimationBack' | keyof MappersItem<ITEM> | keyof MappersGroup<GROUP>> & {
|
|
138
|
+
parent?: ITEM;
|
|
124
139
|
levelDepth: number;
|
|
125
140
|
addLevel: AddLevel<ITEM>;
|
|
126
141
|
deleteLevel: (level: number) => void;
|
|
@@ -128,6 +143,7 @@ export declare type ContextMenuLevelProps<ITEM = ContextMenuItemDefault, GROUP =
|
|
|
128
143
|
onSetDirection?: (direction: Direction) => void;
|
|
129
144
|
hoveredParenLevel: number;
|
|
130
145
|
setHoveredParenLevel: (level: number) => void;
|
|
146
|
+
animate: Animate;
|
|
131
147
|
} & Required<MappersItem<ITEM>> & Required<MappersGroup<GROUP>>;
|
|
132
148
|
export declare type ContextMenuLevelComponent = <ITEM, GROUP>(props: ContextMenuLevelProps<ITEM, GROUP>, ref: React.Ref<HTMLElement>) => React.ReactElement | null;
|
|
133
149
|
export declare type ContextMenuItemProps<AS extends keyof JSX.IntrinsicElements = 'div'> = PropsWithAsAttributes<Omit<ContextMenuItemDefault, 'onClick' | 'attributes' | 'key'> & {
|
|
@@ -142,4 +158,37 @@ export declare type GetLevelsParams<ITEM> = {
|
|
|
142
158
|
getItemSubMenu: ContextMenuPropGetItemSubMenu<ITEM>;
|
|
143
159
|
getItemKey: ContextMenuPropGetItemKey<ITEM>;
|
|
144
160
|
};
|
|
161
|
+
export declare type ContextMenuWrapperProps = PropsWithHTMLAttributes<{
|
|
162
|
+
children: React.ReactNode;
|
|
163
|
+
isOpen?: boolean;
|
|
164
|
+
isMobile?: boolean;
|
|
165
|
+
form?: ContextMenuForm;
|
|
166
|
+
onClickOutside?: ClickOutsideHandler;
|
|
167
|
+
spareDirection?: Direction;
|
|
168
|
+
possibleDirections?: readonly Direction[];
|
|
169
|
+
size?: ContextMenuPropSize;
|
|
170
|
+
direction?: Direction;
|
|
171
|
+
offset?: PopoverPropOffset;
|
|
172
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
173
|
+
position?: Position;
|
|
174
|
+
onSetDirection?: (direction: Direction) => void;
|
|
175
|
+
className?: string;
|
|
176
|
+
animationBack?: boolean;
|
|
177
|
+
}, HTMLDivElement>;
|
|
178
|
+
export declare type ContextMenuLevelWrapperProps = PropsWithHTMLAttributesAndRef<{
|
|
179
|
+
children: React.ReactNode;
|
|
180
|
+
isOpen?: boolean;
|
|
181
|
+
isMobile?: boolean;
|
|
182
|
+
form?: ContextMenuForm;
|
|
183
|
+
onClickOutside?: ClickOutsideHandler;
|
|
184
|
+
spareDirection?: Direction;
|
|
185
|
+
possibleDirections?: readonly Direction[];
|
|
186
|
+
size?: ContextMenuPropSize;
|
|
187
|
+
direction?: Direction;
|
|
188
|
+
offset?: PopoverPropOffset;
|
|
189
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
190
|
+
position?: Position;
|
|
191
|
+
onSetDirection?: (direction: Direction) => void;
|
|
192
|
+
classname?: string;
|
|
193
|
+
}, HTMLDivElement>;
|
|
145
194
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["defaultListPropForm","listPropForm","contextMenuSizes","contextMenuDefaultSize","contextMenuStatus","contextMenuDefaultStatus","contextMenuForm","defaultContextMenuForm","contextMenuPropSubMenuDirections","contextMenuPropDefaultSubMenuDirection"],"sources":["../../../../../src/components/ContextMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport {\n defaultListPropForm,\n ListPropForm,\n listPropForm,\n} from '##/components/ListCanary';\n\nimport { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { PropsWithAsAttributes } from '../../utils/types/PropsWithAsAttributes';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport { Direction, PopoverPropOffset, Position } from '../Popover/Popover';\n\nexport const contextMenuSizes = ['m', 'xs', 's', 'l'] as const;\nexport type ContextMenuPropSize = typeof contextMenuSizes[number];\nexport const contextMenuDefaultSize: ContextMenuPropSize = contextMenuSizes[0];\n\nexport const contextMenuStatus = ['alert', 'success', 'warning'] as const;\nexport type ContextMenuStatus = typeof contextMenuStatus[number];\nexport const contextMenuDefaultStatus: ContextMenuStatus = contextMenuStatus[0];\n\nexport const contextMenuForm = listPropForm;\nexport type ContextMenuForm = ListPropForm;\nexport const defaultContextMenuForm = defaultListPropForm;\n\nexport const contextMenuPropSubMenuDirections = [\n 'rightStartUp',\n 'rightStartDown',\n 'leftStartUp',\n 'leftStartDown',\n] as const;\nexport type ContextMenuPropSubMenuDirection =\n typeof contextMenuPropSubMenuDirections[number];\nexport const contextMenuPropDefaultSubMenuDirection: ContextMenuPropSubMenuDirection =\n contextMenuPropSubMenuDirections[0];\n\nexport type ContextMenuPropOnClick<ITEM> = (params: {\n e: React.MouseEvent<HTMLDivElement>;\n item: ITEM;\n}) => void;\n\nexport type ContextMenuGroupDefault = {\n label?: string;\n id: number;\n};\n\nexport type ContextMenuItemDefault = {\n label: string | number;\n key?: string | number;\n rightSide?: React.ReactNode;\n rightIcon?: IconComponent;\n leftSide?: React.ReactNode;\n leftIcon?: IconComponent;\n subMenu?: ContextMenuItemDefault[];\n status?: ContextMenuStatus;\n disabled?: boolean;\n groupId?: number;\n onClick?: ContextMenuPropOnClick<ContextMenuItemDefault>;\n as?: keyof JSX.IntrinsicElements;\n attributes?: JSX.IntrinsicElements[keyof JSX.IntrinsicElements];\n};\n\nexport type ContextMenuPropSortGroup = (\n a: string | number,\n b: string | number,\n) => number;\n\nexport type ContextMenuPropGetItemLabel<ITEM> = (item: ITEM) => string | number;\n\nexport type ContextMenuPropGetItemRightSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\n\nexport type ContextMenuPropGetItemLeftSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\n\nexport type ContextMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\n\nexport type ContextMenuPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ContextMenuStatus | undefined;\n\nexport type ContextMenuPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type ContextMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => ContextMenuPropOnClick<ITEM> | undefined;\n\nexport type ContextMenuPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\n\nexport type ContextMenuPropGetItemAs<ITEM> = (\n item: ITEM,\n) => keyof JSX.IntrinsicElements | undefined;\n\nexport type ContextMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => JSX.IntrinsicElements[keyof JSX.IntrinsicElements] | undefined;\n\nexport type ContextMenuPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\n\nexport type ContextMenuPropGetItemRightIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetItemLeftIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetGroupLabel<GROUP> = (\n group: GROUP,\n) => string | undefined;\nexport type ContextMenuPropGetGroupId<GROUP> = (group: GROUP) => number;\n\ntype PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n position?: never;\n }\n | {\n anchorRef?: never;\n position: Position;\n };\n\nexport type MappersItem<ITEM> = {\n getItemLabel?: ContextMenuPropGetItemLabel<ITEM>;\n getItemRightSide?: ContextMenuPropGetItemRightSide<ITEM>;\n getItemLeftSide?: ContextMenuPropGetItemLeftSide<ITEM>;\n getItemSubMenu?: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemStatus?: ContextMenuPropGetItemStatus<ITEM>;\n getItemDisabled?: ContextMenuPropGetItemDisabled<ITEM>;\n getItemKey?: ContextMenuPropGetItemKey<ITEM>;\n getItemOnClick?: ContextMenuPropGetItemOnClick<ITEM>;\n getItemAs?: ContextMenuPropGetItemAs<ITEM>;\n getItemAttributes?: ContextMenuPropGetItemAttributes<ITEM>;\n getItemGroupId?: ContextMenuPropGetItemGroupId<ITEM>;\n getItemLeftIcon?: ContextMenuPropGetItemLeftIcon<ITEM>;\n getItemRightIcon?: ContextMenuPropGetItemRightIcon<ITEM>;\n};\n\nexport type MappersGroup<GROUP> = {\n getGroupLabel?: ContextMenuPropGetGroupLabel<GROUP>;\n getGroupId?: ContextMenuPropGetGroupId<GROUP>;\n};\n\nexport type Level<ITEM> = {\n items: ITEM[];\n activeItem?: string;\n direction?: Direction;\n possibleDirections?: readonly Direction[];\n offset?: PopoverPropOffset;\n} & PositioningProps;\n\nexport type AddLevel<ITEM> = (params: {\n level: number;\n items: ITEM[];\n anchorRef?: React.RefObject<HTMLElement>;\n activeItem: string;\n}) => void;\n\nexport type ContextMenuProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n groups?: GROUP[];\n sortGroup?: ContextMenuPropSortGroup;\n onItemClick?: ContextMenuPropOnClick<ITEM>;\n possibleDirections?: readonly Direction[];\n subMenuDirection?: ContextMenuPropSubMenuDirection;\n spareDirection?: Direction;\n onSetDirection?: (direction: Direction) => void;\n onClickOutside?: ClickOutsideHandler;\n isOpen?: boolean;\n form?: ContextMenuForm;\n } & MappersItem<ITEM> &\n MappersGroup<GROUP> &\n PositioningProps,\n HTMLDivElement\n> &\n (GROUP extends { id: ContextMenuGroupDefault['id'] | unknown }\n ? {}\n : { getGroupId: ContextMenuPropGetGroupId<GROUP> }) &\n (ITEM extends { label: ContextMenuItemDefault['label'] }\n ? {}\n : { getItemLabel: ContextMenuPropGetItemLabel<ITEM> });\n\nexport type ContextMenuComponent = <\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n>(\n props: ContextMenuProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport type ContextMenuLevelProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = Omit<\n ContextMenuProps<ITEM, GROUP>,\n | 'subMenuDirection'\n | 'onClickOutside'\n | keyof MappersItem<ITEM>\n | keyof MappersGroup<GROUP>\n> & {\n levelDepth: number;\n addLevel: AddLevel<ITEM>;\n deleteLevel: (level: number) => void;\n activeItem?: string;\n onSetDirection?: (direction: Direction) => void;\n hoveredParenLevel: number;\n setHoveredParenLevel: (level: number) => void;\n} & Required<MappersItem<ITEM>> &\n Required<MappersGroup<GROUP>>;\n\nexport type ContextMenuLevelComponent = <ITEM, GROUP>(\n props: ContextMenuLevelProps<ITEM, GROUP>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type ContextMenuItemProps<\n AS extends keyof JSX.IntrinsicElements = 'div',\n> = PropsWithAsAttributes<\n Omit<ContextMenuItemDefault, 'onClick' | 'attributes' | 'key'> & {\n size?: ContextMenuPropSize;\n active: boolean;\n withSubMenu: boolean;\n },\n AS\n> &\n React.RefAttributes<HTMLDivElement>;\n\nexport type ContextMenuItemComponent = <\n AS extends keyof JSX.IntrinsicElements = 'div',\n>(\n props: ContextMenuItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type GetLevelsParams<ITEM> = {\n levels: Level<ITEM>[];\n items: ITEM[];\n getItemSubMenu: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemKey: ContextMenuPropGetItemKey<ITEM>;\n};\n"],"mappings":"AAEA,OACEA,mBADF,CAGEC,YAHF,qBAWA,MAAO,IAAMC,iBAAgB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAzB,CAEP,MAAO,IAAMC,uBAA2C,CAAGD,gBAAgB,CAAC,CAAD,CAApE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,gBAAe,CAAGL,YAAxB,CAEP,MAAO,IAAMM,uBAAsB,CAAGP,mBAA/B,CAEP,MAAO,IAAMQ,iCAAgC,CAAG,CAC9C,cAD8C,CAE9C,gBAF8C,CAG9C,aAH8C,CAI9C,eAJ8C,CAAzC,CAQP,MAAO,IAAMC,uCAAuE,CAClFD,gCAAgC,CAAC,CAAD,CAD3B"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["defaultListPropForm","listPropForm","contextMenuSizes","contextMenuDefaultSize","contextMenuStatus","contextMenuDefaultStatus","contextMenuForm","defaultContextMenuForm","contextMenuPropSubMenuDirections","contextMenuPropDefaultSubMenuDirection"],"sources":["../../../../../src/components/ContextMenu/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport {\n defaultListPropForm,\n ListPropForm,\n listPropForm,\n} from '##/components/ListCanary';\nimport { ComponentSize } from '##/hooks/useComponentSize';\nimport { Animate } from '##/mixs/MixPopoverAnimate';\n\nimport { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { PropsWithAsAttributes } from '../../utils/types/PropsWithAsAttributes';\nimport {\n PropsWithHTMLAttributes,\n PropsWithHTMLAttributesAndRef,\n} from '../../utils/types/PropsWithHTMLAttributes';\nimport { Direction, PopoverPropOffset, Position } from '../Popover/Popover';\n\nexport const contextMenuSizes = ['m', 'xs', 's', 'l'] as const;\nexport type ContextMenuPropSize = typeof contextMenuSizes[number];\nexport const contextMenuDefaultSize: ContextMenuPropSize = contextMenuSizes[0];\n\nexport const contextMenuStatus = ['alert', 'success', 'warning'] as const;\nexport type ContextMenuStatus = typeof contextMenuStatus[number];\nexport const contextMenuDefaultStatus: ContextMenuStatus = contextMenuStatus[0];\n\nexport const contextMenuForm = listPropForm;\nexport type ContextMenuForm = ListPropForm;\nexport const defaultContextMenuForm = defaultListPropForm;\n\nexport const contextMenuPropSubMenuDirections = [\n 'rightStartUp',\n 'rightStartDown',\n 'leftStartUp',\n 'leftStartDown',\n] as const;\nexport type ContextMenuPropSubMenuDirection =\n typeof contextMenuPropSubMenuDirections[number];\nexport const contextMenuPropDefaultSubMenuDirection: ContextMenuPropSubMenuDirection =\n contextMenuPropSubMenuDirections[0];\n\nexport type ContextMenuPropOnClick<ITEM> = (params: {\n e: React.MouseEvent<HTMLDivElement>;\n item: ITEM;\n}) => void;\n\nexport type ContextMenuGroupDefault = {\n label?: string;\n id: number;\n};\n\nexport type ContextMenuItemDefault = {\n label: string | number;\n key?: string | number;\n rightSide?: React.ReactNode;\n rightIcon?: IconComponent;\n leftSide?: React.ReactNode;\n leftIcon?: IconComponent;\n subMenu?: ContextMenuItemDefault[];\n status?: ContextMenuStatus;\n disabled?: boolean;\n groupId?: number;\n onClick?: ContextMenuPropOnClick<ContextMenuItemDefault>;\n as?: keyof JSX.IntrinsicElements;\n attributes?: JSX.IntrinsicElements[keyof JSX.IntrinsicElements];\n};\n\nexport type ContextMenuPropSortGroup = (\n a: string | number,\n b: string | number,\n) => number;\n\nexport type ContextMenuPropGetItemLabel<ITEM> = (item: ITEM) => string | number;\n\nexport type ContextMenuPropGetItemRightSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\n\nexport type ContextMenuPropGetItemLeftSide<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\n\nexport type ContextMenuPropGetItemSubMenu<ITEM> = (\n item: ITEM,\n) => ITEM[] | undefined;\n\nexport type ContextMenuPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ContextMenuStatus | undefined;\n\nexport type ContextMenuPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\n\nexport type ContextMenuPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => ContextMenuPropOnClick<ITEM> | undefined;\n\nexport type ContextMenuPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\n\nexport type ContextMenuPropGetItemAs<ITEM> = (\n item: ITEM,\n) => keyof JSX.IntrinsicElements | undefined;\n\nexport type ContextMenuPropGetItemAttributes<ITEM> = (\n item: ITEM,\n) => JSX.IntrinsicElements[keyof JSX.IntrinsicElements] | undefined;\n\nexport type ContextMenuPropGetItemGroupId<ITEM> = (\n item: ITEM,\n) => number | undefined;\n\nexport type ContextMenuPropGetItemRightIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetItemLeftIcon<ITEM> = (\n item: ITEM,\n) => IconComponent | undefined;\n\nexport type ContextMenuPropGetGroupLabel<GROUP> = (\n group: GROUP,\n) => string | undefined;\nexport type ContextMenuPropGetGroupId<GROUP> = (group: GROUP) => number;\n\ntype PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n position?: never;\n }\n | {\n anchorRef?: never;\n position: Position;\n };\n\nexport type MappersItem<ITEM> = {\n getItemLabel?: ContextMenuPropGetItemLabel<ITEM>;\n getItemRightSide?: ContextMenuPropGetItemRightSide<ITEM>;\n getItemLeftSide?: ContextMenuPropGetItemLeftSide<ITEM>;\n getItemSubMenu?: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemStatus?: ContextMenuPropGetItemStatus<ITEM>;\n getItemDisabled?: ContextMenuPropGetItemDisabled<ITEM>;\n getItemKey?: ContextMenuPropGetItemKey<ITEM>;\n getItemOnClick?: ContextMenuPropGetItemOnClick<ITEM>;\n getItemAs?: ContextMenuPropGetItemAs<ITEM>;\n getItemAttributes?: ContextMenuPropGetItemAttributes<ITEM>;\n getItemGroupId?: ContextMenuPropGetItemGroupId<ITEM>;\n getItemLeftIcon?: ContextMenuPropGetItemLeftIcon<ITEM>;\n getItemRightIcon?: ContextMenuPropGetItemRightIcon<ITEM>;\n};\n\nexport type MappersGroup<GROUP> = {\n getGroupLabel?: ContextMenuPropGetGroupLabel<GROUP>;\n getGroupId?: ContextMenuPropGetGroupId<GROUP>;\n};\n\nexport type Level<ITEM> = {\n items: ITEM[];\n activeItem?: string;\n direction?: Direction;\n possibleDirections?: readonly Direction[];\n offset?: PopoverPropOffset;\n parent?: ITEM;\n anchorRef?: React.RefObject<HTMLElement>;\n position?: Position;\n};\n\nexport type AddLevel<ITEM> = (params: {\n level: number;\n items: ITEM[];\n parent?: ITEM;\n anchorRef?: React.RefObject<HTMLElement>;\n position?: Position;\n activeItem: string;\n}) => void;\n\nexport type ContextMenuProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n groups?: GROUP[];\n sortGroup?: ContextMenuPropSortGroup;\n onItemClick?: ContextMenuPropOnClick<ITEM>;\n possibleDirections?: readonly Direction[];\n subMenuDirection?: ContextMenuPropSubMenuDirection;\n spareDirection?: Direction;\n onSetDirection?: (direction: Direction) => void;\n onClickOutside?: ClickOutsideHandler;\n isOpen?: boolean;\n form?: ContextMenuForm;\n isMobile?: boolean;\n } & MappersItem<ITEM> &\n MappersGroup<GROUP> &\n PositioningProps,\n HTMLDivElement\n> &\n (GROUP extends { id: ContextMenuGroupDefault['id'] | unknown }\n ? {}\n : { getGroupId: ContextMenuPropGetGroupId<GROUP> }) &\n (ITEM extends { label: ContextMenuItemDefault['label'] }\n ? {}\n : { getItemLabel: ContextMenuPropGetItemLabel<ITEM> });\n\nexport type ContextMenuLevelsProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = ContextMenuProps<ITEM, GROUP> & {\n setComponentSize: React.Dispatch<React.SetStateAction<ComponentSize>>;\n disableAnimationBack: () => void;\n enableAnimationBack: () => void;\n};\n\nexport type ContextMenuLevelsComponent = <\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n>(\n props: ContextMenuLevelsProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport type ContextMenuComponent = <\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n>(\n props: ContextMenuProps<ITEM, GROUP>,\n) => React.ReactElement | null;\n\nexport type ContextMenuLevelProps<\n ITEM = ContextMenuItemDefault,\n GROUP = ContextMenuGroupDefault,\n> = Omit<\n ContextMenuProps<ITEM, GROUP>,\n | 'subMenuDirection'\n | 'onClickOutside'\n | 'setComponentSize'\n | 'animationBack'\n | 'disableAnimationBack'\n | 'enableAnimationBack'\n | keyof MappersItem<ITEM>\n | keyof MappersGroup<GROUP>\n> & {\n parent?: ITEM;\n levelDepth: number;\n addLevel: AddLevel<ITEM>;\n deleteLevel: (level: number) => void;\n activeItem?: string;\n onSetDirection?: (direction: Direction) => void;\n hoveredParenLevel: number;\n setHoveredParenLevel: (level: number) => void;\n animate: Animate;\n} & Required<MappersItem<ITEM>> &\n Required<MappersGroup<GROUP>>;\n\nexport type ContextMenuLevelComponent = <ITEM, GROUP>(\n props: ContextMenuLevelProps<ITEM, GROUP>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type ContextMenuItemProps<\n AS extends keyof JSX.IntrinsicElements = 'div',\n> = PropsWithAsAttributes<\n Omit<ContextMenuItemDefault, 'onClick' | 'attributes' | 'key'> & {\n size?: ContextMenuPropSize;\n active: boolean;\n withSubMenu: boolean;\n },\n AS\n> &\n React.RefAttributes<HTMLDivElement>;\n\nexport type ContextMenuItemComponent = <\n AS extends keyof JSX.IntrinsicElements = 'div',\n>(\n props: ContextMenuItemProps<AS>,\n ref: React.Ref<HTMLElement>,\n) => React.ReactElement | null;\n\nexport type GetLevelsParams<ITEM> = {\n levels: Level<ITEM>[];\n items: ITEM[];\n getItemSubMenu: ContextMenuPropGetItemSubMenu<ITEM>;\n getItemKey: ContextMenuPropGetItemKey<ITEM>;\n};\n\nexport type ContextMenuWrapperProps = PropsWithHTMLAttributes<\n {\n children: React.ReactNode;\n isOpen?: boolean;\n isMobile?: boolean;\n form?: ContextMenuForm;\n onClickOutside?: ClickOutsideHandler;\n spareDirection?: Direction;\n possibleDirections?: readonly Direction[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n anchorRef?: React.RefObject<HTMLElement>;\n position?: Position;\n onSetDirection?: (direction: Direction) => void;\n className?: string;\n animationBack?: boolean;\n },\n HTMLDivElement\n>;\n\nexport type ContextMenuLevelWrapperProps = PropsWithHTMLAttributesAndRef<\n {\n children: React.ReactNode;\n isOpen?: boolean;\n isMobile?: boolean;\n form?: ContextMenuForm;\n onClickOutside?: ClickOutsideHandler;\n spareDirection?: Direction;\n possibleDirections?: readonly Direction[];\n size?: ContextMenuPropSize;\n direction?: Direction;\n offset?: PopoverPropOffset;\n anchorRef?: React.RefObject<HTMLElement>;\n position?: Position;\n onSetDirection?: (direction: Direction) => void;\n classname?: string;\n },\n HTMLDivElement\n>;\n"],"mappings":"AAEA,OACEA,mBADF,CAGEC,YAHF,qBAgBA,MAAO,IAAMC,iBAAgB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAiB,GAAjB,CAAzB,CAEP,MAAO,IAAMC,uBAA2C,CAAGD,gBAAgB,CAAC,CAAD,CAApE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAAC,OAAD,CAAU,SAAV,CAAqB,SAArB,CAA1B,CAEP,MAAO,IAAMC,yBAA2C,CAAGD,iBAAiB,CAAC,CAAD,CAArE,CAEP,MAAO,IAAME,gBAAe,CAAGL,YAAxB,CAEP,MAAO,IAAMM,uBAAsB,CAAGP,mBAA/B,CAEP,MAAO,IAAMQ,iCAAgC,CAAG,CAC9C,cAD8C,CAE9C,gBAF8C,CAG9C,aAH8C,CAI9C,eAJ8C,CAAzC,CAQP,MAAO,IAAMC,uCAAuE,CAClFD,gCAAgC,CAAC,CAAD,CAD3B"}
|
package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.ContextMenuDividerDeprecated{--vertical-space:0;background:var(--color-control-bg-border-default);height:var(--control-border-width);margin:var(--vertical-space) var(--space-s)}.ContextMenuDividerDeprecated_size_l{--vertical-space:var(--space-xs)}.ContextMenuDividerDeprecated_size_m,.ContextMenuDividerDeprecated_size_s{--vertical-space:var(--space-2xs)}
|
package/__internal__/src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./ContextMenuDivider.css";import React from"react";import{cn}from"../../../utils/bem";import{contextMenuDefaultSize}from"../helpers";var cnContextMenuDivider=cn("
|
|
1
|
+
import"./ContextMenuDivider.css";import React from"react";import{cn}from"../../../utils/bem";import{contextMenuDefaultSize}from"../helpers";var cnContextMenuDivider=cn("ContextMenuDividerDeprecated");export var ContextMenuDivider=function(a){var b=a.size,c=void 0===b?contextMenuDefaultSize:b;return React.createElement("div",{className:cnContextMenuDivider({size:c})})};
|
|
2
2
|
//# sourceMappingURL=ContextMenuDivider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuDivider.js","names":["React","cn","contextMenuDefaultSize","cnContextMenuDivider","ContextMenuDivider","props","size"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.tsx"],"sourcesContent":["import './ContextMenuDivider.css';\n\nimport React from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { contextMenuDefaultSize, ContextMenuPropSize } from '../helpers';\n\nconst cnContextMenuDivider = cn('
|
|
1
|
+
{"version":3,"file":"ContextMenuDivider.js","names":["React","cn","contextMenuDefaultSize","cnContextMenuDivider","ContextMenuDivider","props","size"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuDivider/ContextMenuDivider.tsx"],"sourcesContent":["import './ContextMenuDivider.css';\n\nimport React from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { contextMenuDefaultSize, ContextMenuPropSize } from '../helpers';\n\nconst cnContextMenuDivider = cn('ContextMenuDividerDeprecated');\n\nexport const ContextMenuDivider: React.FC<{\n size?: ContextMenuPropSize;\n children?: never;\n}> = (props) => {\n const { size = contextMenuDefaultSize } = props;\n return <div className={cnContextMenuDivider({ size })} />;\n};\n"],"mappings":"AAAA,iCAEA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,EAAT,0BACA,OAASC,sBAAT,kBAEA,GAAMC,qBAAoB,CAAGF,EAAE,CAAC,8BAAD,CAA/B,CAEA,MAAO,IAAMG,mBAGX,CAAG,SAACC,CAAD,CAAW,CACd,MAA0CA,CAA1C,CAAQC,IAAR,CAAQA,CAAR,YAAeJ,sBAAf,GACA,MAAO,4BAAK,SAAS,CAAEC,oBAAoB,CAAC,CAAEG,IAAI,CAAJA,CAAF,CAAD,CAApC,EACR,CANM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.ContextMenuGroupHeaderDeprecated{--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}.ContextMenuGroupHeaderDeprecated_size_s{--top-space:var(--space-xs);--bottom-space:var(--space-2xs)}.ContextMenuGroupHeaderDeprecated_size_m{--top-space:var(--space-s);--bottom-space:var(--space-xs)}.ContextMenuGroupHeaderDeprecated_size_l{--top-space:var(--space-s);--bottom-space:var(--space-s)}.ContextMenuGroupHeaderDeprecated_first{padding:calc(var(--top-space) - var(--space-xs)) 0 var(--bottom-space) 0}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./ContextMenuGroupHeader.css";import React from"react";import{cn}from"../../../utils/bem";import{getByMap}from"../../../utils/getByMap";import{Text}from"../../Text/Text";import{contextMenuDefaultSize}from"../helpers";export var cnContextMenuGroupHeader=cn("
|
|
1
|
+
import"./ContextMenuGroupHeader.css";import React from"react";import{cn}from"../../../utils/bem";import{getByMap}from"../../../utils/getByMap";import{Text}from"../../Text/Text";import{contextMenuDefaultSize}from"../helpers";export var cnContextMenuGroupHeader=cn("ContextMenuGroupHeaderDeprecated");var sizeMap={s:"2xs",m:"xs",l:"s"};export var ContextMenuGroupHeader=function(a){var b=a.label,c=a.size,d=void 0===c?contextMenuDefaultSize:c,e=a.first;return React.createElement(Text,{view:"secondary",transform:"uppercase",className:cnContextMenuGroupHeader({size:d,first:e}),size:getByMap(sizeMap,d)},b)};
|
|
2
2
|
//# sourceMappingURL=ContextMenuGroupHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuGroupHeader.js","names":["React","cn","getByMap","Text","contextMenuDefaultSize","cnContextMenuGroupHeader","sizeMap","s","m","l","ContextMenuGroupHeader","label","size","first"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.tsx"],"sourcesContent":["import './ContextMenuGroupHeader.css';\n\nimport React from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { getByMap } from '../../../utils/getByMap';\nimport { Text, TextPropSize } from '../../Text/Text';\nimport { contextMenuDefaultSize, ContextMenuPropSize } from '../helpers';\n\nexport const cnContextMenuGroupHeader = cn('
|
|
1
|
+
{"version":3,"file":"ContextMenuGroupHeader.js","names":["React","cn","getByMap","Text","contextMenuDefaultSize","cnContextMenuGroupHeader","sizeMap","s","m","l","ContextMenuGroupHeader","label","size","first"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuGroupHeader/ContextMenuGroupHeader.tsx"],"sourcesContent":["import './ContextMenuGroupHeader.css';\n\nimport React from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { getByMap } from '../../../utils/getByMap';\nimport { Text, TextPropSize } from '../../Text/Text';\nimport { contextMenuDefaultSize, ContextMenuPropSize } from '../helpers';\n\nexport const cnContextMenuGroupHeader = cn('ContextMenuGroupHeaderDeprecated');\n\nconst sizeMap: Record<ContextMenuPropSize, TextPropSize> = {\n s: '2xs',\n m: 'xs',\n l: 's',\n};\n\nexport const ContextMenuGroupHeader: React.FC<{\n label: string | number;\n size?: ContextMenuPropSize;\n children?: never;\n first: boolean;\n}> = ({ label, size = contextMenuDefaultSize, first }) => (\n <Text\n view=\"secondary\"\n transform=\"uppercase\"\n className={cnContextMenuGroupHeader({ size, first })}\n size={getByMap(sizeMap, size)}\n >\n {label}\n </Text>\n);\n"],"mappings":"AAAA,qCAEA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,EAAT,0BACA,OAASC,QAAT,+BACA,OAASC,IAAT,uBACA,OAASC,sBAAT,kBAEA,MAAO,IAAMC,yBAAwB,CAAGJ,EAAE,CAAC,kCAAD,CAAnC,CAEP,GAAMK,QAAkD,CAAG,CACzDC,CAAC,CAAE,KADsD,CAEzDC,CAAC,CAAE,IAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAA3D,CAMA,MAAO,IAAMC,uBAKX,CAAG,eAAGC,EAAH,GAAGA,KAAH,KAAUC,IAAV,CAAUA,CAAV,YAAiBR,sBAAjB,GAAyCS,CAAzC,GAAyCA,KAAzC,OACH,qBAAC,IAAD,EACE,IAAI,CAAC,WADP,CAEE,SAAS,CAAC,WAFZ,CAGE,SAAS,CAAER,wBAAwB,CAAC,CAAEO,IAAI,CAAJA,CAAF,CAAQC,KAAK,CAALA,CAAR,CAAD,CAHrC,CAIE,IAAI,CAAEX,QAAQ,CAACI,OAAD,CAAUM,CAAV,CAJhB,EAMGD,CANH,CADG,CALE"}
|
package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.ContextMenuLevelDeprecated{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;z-index:9999}.ContextMenuLevelDeprecated:not(.ContextMenuLevelDeprecated_firstLevel).ContextMenuLevelDeprecated_direction_leftStartUp,.ContextMenuLevelDeprecated:not(.ContextMenuLevelDeprecated_firstLevel).ContextMenuLevelDeprecated_direction_rightStartUp{transform:translateY(calc((var(--space-xs) + 1px)*-1))}.ContextMenuLevelDeprecated:not(.ContextMenuLevelDeprecated_firstLevel).ContextMenuLevelDeprecated_direction_leftStartDown,.ContextMenuLevelDeprecated:not(.ContextMenuLevelDeprecated_firstLevel).ContextMenuLevelDeprecated_direction_rightStartDown{transform:translateY(calc(var(--space-xs) + 1px))}
|
package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","level","activeItem","addLevel","className","deleteLevel","items","setHoveredParenLevel","getLabel","getRightSideBar","getLeftSideBar","getSubItems","getGroupId","getAccent","getDisabled","getOnClick","getItemOnClick","onItemClick","getItemHTMLAttributes","getItemAs","sortGroup","getGroupLabel","direction","possibleDirections","offset","onSetDirection","hoveredParenLevel","spareDirection","anchorRef"];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,useEffect,useMemo,useState}from"react";import{cn}from"../../../utils/bem";import{getGroups}from"../../../utils/getGroups";import{Popover}from"../../Popover/Popover";import{ContextMenuDivider}from"../ContextMenuDivider/ContextMenuDivider";import{ContextMenuGroupHeader}from"../ContextMenuGroupHeader/ContextMenuGroupHeader";import{ContextMenuItem}from"../ContextMenuItem/ContextMenuItem";import{contextMenuDefaultSize}from"../helpers";export var cnContextMenuLevel=cn("
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","level","activeItem","addLevel","className","deleteLevel","items","setHoveredParenLevel","getLabel","getRightSideBar","getLeftSideBar","getSubItems","getGroupId","getAccent","getDisabled","getOnClick","getItemOnClick","onItemClick","getItemHTMLAttributes","getItemAs","sortGroup","getGroupLabel","direction","possibleDirections","offset","onSetDirection","hoveredParenLevel","spareDirection","anchorRef"];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,useEffect,useMemo,useState}from"react";import{cn}from"../../../utils/bem";import{getGroups}from"../../../utils/getGroups";import{Popover}from"../../Popover/Popover";import{ContextMenuDivider}from"../ContextMenuDivider/ContextMenuDivider";import{ContextMenuGroupHeader}from"../ContextMenuGroupHeader/ContextMenuGroupHeader";import{ContextMenuItem}from"../ContextMenuItem/ContextMenuItem";import{contextMenuDefaultSize}from"../helpers";export var cnContextMenuLevel=cn("ContextMenuLevelDeprecated");function renderHeader(a,b,c,d){return a?React.createElement(ContextMenuGroupHeader,{label:a,first:b,size:d}):b?null:React.createElement(ContextMenuDivider,{size:d})}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;export var ContextMenuLevel=React.forwardRef(function(a,b){var c=a.size,d=void 0===c?contextMenuDefaultSize:c,e=a.level,f=a.activeItem,g=a.addLevel,h=a.className,i=a.deleteLevel,j=a.items,k=a.setHoveredParenLevel,l=a.getLabel,m=a.getRightSideBar,n=a.getLeftSideBar,o=a.getSubItems,p=a.getGroupId,q=a.getAccent,r=a.getDisabled,s=a.getOnClick,t=a.getItemOnClick,u=a.onItemClick,v=a.getItemHTMLAttributes,w=a.getItemAs,x=a.sortGroup,y=a.getGroupLabel,z=a.direction,A=a.possibleDirections,B=a.offset,C=a.onSetDirection,D=a.hoveredParenLevel,E=a.spareDirection,F=a.anchorRef,G=_objectWithoutProperties(a,_excluded),H=useState(!1),I=_slicedToArray(H,2),J=I[0],K=I[1],L=getGroups(j,p,void 0,void 0,x&&function(c,a){return x(c.key,a.key)}),M=function(a,b){return"".concat(a,"-").concat(b)},N=useMemo(function constructItemRefs(){var a,b={},c=_createForOfIteratorHelper(L);try{for(c.s();!(a=c.n()).done;)for(var d=a.value,e=0;e<j.length;e++)b[M(d.key,e)]=createRef()}catch(a){c.e(a)}finally{c.f()}return b},[j]);return useEffect(function(){return 0!==e&&!J&&D<e&&(clearTimeout(timers[e]),timers[e]=setTimeout(function(){return i(e)},closeDelay)),function(){clearTimeout(timers[e])}},[J,D]),React.createElement(Popover,Object.assign({},G,{anchorRef:F,className:cnContextMenuLevel({firstLevel:0===e,direction:z},[h]),possibleDirections:A,spareDirection:E,direction:z,offset:B,onSetDirection:C,onMouseEnter:function onMouseEnter(){return K(!0)},onMouseLeave:function onMouseLeave(){return K(!1)},ref:b}),L.map(function(a,b){var c="function"==typeof y?y(a.key):void 0;return React.createElement("div",{className:cnContextMenuLevel("Group"),key:a.key},renderHeader(c,0===b,L.length,d),a.items.map(function(b,c){var h=M(a.key,c),i=N[h],j="function"==typeof r&&r(b),p=l(b),x="function"==typeof n?n(b):void 0,y="function"==typeof m?m(b):void 0,z="function"==typeof o?o(b):void 0,A=z&&!j?function(){g(e+1,z,i,h),k(e+1)}:function(){k(e)},B="function"==typeof q?q(b):void 0,C="function"==typeof v?v(b):{},D="function"==typeof w?w(b):void 0;return React.createElement(ContextMenuItem,Object.assign({},C,{ref:i,label:p,leftSide:x,rightSide:y,size:d,key:h,onMouseEnter:A,onClick:function onClick(a){if(!j){if("function"==typeof t){var c;null===(c=t(b))||void 0===c?void 0:c(a)}if("function"==typeof s){var d;null===(d=s(b))||void 0===d?void 0:d(a)}"function"==typeof u&&(null===u||void 0===u?void 0:u({e:a,item:b}))}},active:f===h,withSubMenu:!!z,accent:B,disabled:j,as:D}))}))}))});
|
|
2
2
|
//# sourceMappingURL=ContextMenuLevel.js.map
|
package/__internal__/src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuLevel.js","names":["React","createRef","useEffect","useMemo","useState","cn","getGroups","Popover","ContextMenuDivider","ContextMenuGroupHeader","ContextMenuItem","contextMenuDefaultSize","cnContextMenuLevel","renderHeader","groupLabel","first","length","size","timers","clearTimers","timer","clearTimeout","closeDelay","ContextMenuLevel","forwardRef","props","ref","level","activeItem","addLevel","className","deleteLevel","items","setHoveredParenLevel","getLabel","getRightSideBar","getLeftSideBar","getSubItems","getGroupId","getAccent","getDisabled","getOnClick","getItemOnClick","onItemClick","getItemHTMLAttributes","getItemAs","sortGroup","getGroupLabel","direction","possibleDirections","offset","onSetDirection","hoveredParenLevel","spareDirection","anchorRef","otherProps","hovered","setHovered","groups","a","b","key","getItemIndex","groupId","itemIndex","itemsRefs","constructItemRefs","refs","group","i","setTimeout","firstLevel","map","groupIndex","item","index","disabled","label","leftSide","rightSide","subItems","onMouseEnter","accent","atributes","as","onClick","e"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.tsx"],"sourcesContent":["import './ContextMenuLevel.css';\n\nimport React, { createRef, useEffect, useMemo, useState } from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { getGroups } from '../../../utils/getGroups';\nimport { Popover } from '../../Popover/Popover';\nimport { ContextMenuDivider } from '../ContextMenuDivider/ContextMenuDivider';\nimport { ContextMenuGroupHeader } from '../ContextMenuGroupHeader/ContextMenuGroupHeader';\nimport { ContextMenuItem } from '../ContextMenuItem/ContextMenuItem';\nimport {\n contextMenuDefaultSize,\n ContextMenuLevelType,\n ContextMenuPropSize,\n} from '../helpers';\n\nexport const cnContextMenuLevel = cn('ContextMenuLevel');\n\nfunction renderHeader(\n groupLabel: string | number | undefined,\n first: boolean,\n length: number,\n size?: ContextMenuPropSize,\n): React.ReactNode | null {\n if (!groupLabel) {\n if (first) {\n return null;\n }\n return <ContextMenuDivider size={size} />;\n }\n return (\n <ContextMenuGroupHeader label={groupLabel} first={first} size={size} />\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\nexport const ContextMenuLevel: ContextMenuLevelType = React.forwardRef(\n (props, ref: React.Ref<HTMLDivElement>) => {\n const {\n // props относящиеся к уровню меню\n size = contextMenuDefaultSize,\n level,\n activeItem,\n addLevel,\n className,\n deleteLevel,\n items,\n setHoveredParenLevel,\n\n // props относящиеся к пунктам меню\n getLabel,\n getRightSideBar,\n getLeftSideBar,\n getSubItems,\n getGroupId,\n getAccent,\n getDisabled,\n getOnClick,\n getItemOnClick,\n onItemClick,\n getItemHTMLAttributes,\n getItemAs,\n\n // props относящиеся к группам меню\n sortGroup,\n getGroupLabel,\n\n // props относящиеся к поповеру\n direction,\n possibleDirections,\n offset,\n onSetDirection,\n hoveredParenLevel,\n spareDirection,\n anchorRef,\n ...otherProps\n } = props;\n\n const [hovered, setHovered] = useState<boolean>(false);\n\n const groups = getGroups(\n items,\n getGroupId,\n undefined,\n undefined,\n sortGroup && ((a, b) => sortGroup(a.key, b.key)),\n );\n\n const getItemIndex = (groupId: number | string, itemIndex: number) =>\n `${groupId}-${itemIndex}`;\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]);\n\n useEffect(() => {\n if (level !== 0 && !hovered && hoveredParenLevel < level) {\n clearTimeout(timers[level]);\n timers[level] = setTimeout(() => deleteLevel(level), closeDelay);\n }\n return () => {\n clearTimeout(timers[level]);\n };\n }, [hovered, hoveredParenLevel]);\n\n return (\n <Popover\n {...otherProps}\n anchorRef={anchorRef}\n className={cnContextMenuLevel({ firstLevel: level === 0, direction }, [\n className,\n ])}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n direction={direction}\n offset={offset}\n onSetDirection={onSetDirection}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={ref}\n >\n {groups.map((group, groupIndex) => {\n const groupLabel =\n typeof getGroupLabel === 'function'\n ? getGroupLabel(group.key)\n : undefined;\n return (\n <div className={cnContextMenuLevel('Group')} key={group.key}>\n {renderHeader(groupLabel, groupIndex === 0, groups.length, size)}\n {group.items.map((item, index) => {\n const itemIndex = getItemIndex(group.key, index);\n const ref = itemsRefs[itemIndex];\n const disabled =\n typeof getDisabled === 'function' ? getDisabled(item) : false;\n const label = getLabel(item);\n const leftSide =\n typeof getLeftSideBar === 'function'\n ? getLeftSideBar(item)\n : undefined;\n const rightSide =\n typeof getRightSideBar === 'function'\n ? getRightSideBar(item)\n : undefined;\n const subItems =\n typeof getSubItems === 'function'\n ? getSubItems(item)\n : undefined;\n const onClick = (\n e: React.MouseEvent<HTMLDivElement, MouseEvent>,\n ) => {\n if (!disabled) {\n if (typeof getItemOnClick === 'function') {\n getItemOnClick(item)?.(e);\n }\n if (typeof getOnClick === 'function') {\n getOnClick(item)?.(e);\n }\n if (typeof onItemClick === 'function') {\n onItemClick?.({ e, item });\n }\n }\n };\n const onMouseEnter =\n subItems && !disabled\n ? () => {\n addLevel(level + 1, subItems, ref, itemIndex);\n setHoveredParenLevel(level + 1);\n }\n : () => {\n setHoveredParenLevel(level);\n };\n const accent =\n typeof getAccent === 'function' ? getAccent(item) : undefined;\n const atributes =\n typeof getItemHTMLAttributes === 'function'\n ? getItemHTMLAttributes(item)\n : {};\n const as =\n typeof getItemAs === 'function' ? getItemAs(item) : undefined;\n\n return (\n <ContextMenuItem\n {...atributes}\n ref={ref}\n label={label}\n leftSide={leftSide}\n rightSide={rightSide}\n size={size}\n key={itemIndex}\n onMouseEnter={onMouseEnter}\n onClick={onClick}\n active={activeItem === itemIndex}\n withSubMenu={Boolean(subItems)}\n accent={accent}\n disabled={disabled}\n as={as}\n />\n );\n })}\n </div>\n );\n })}\n </Popover>\n );\n },\n);\n"],"mappings":"stDAAA,+BAEA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,SAA3B,CAAsCC,OAAtC,CAA+CC,QAA/C,KAA+D,OAA/D,CAEA,OAASC,EAAT,0BACA,OAASC,SAAT,gCACA,OAASC,OAAT,6BACA,OAASC,kBAAT,gDACA,OAASC,sBAAT,wDACA,OAASC,eAAT,0CACA,OACEC,sBADF,kBAMA,MAAO,IAAMC,mBAAkB,CAAGP,EAAE,CAAC,kBAAD,CAA7B,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M,CACW,UAArB,QAAO3C,EAAP,CAAkCA,CAAS,CAACmC,CAAD,CAA3C,OA3C8B,CA4C1BS,CAAS,CACoB,UAAjC,QAAOvC,EAAP,CACIA,CAAqB,CAAC8B,CAAD,CADzB,CAEI,EA/C0B,CAgD1BU,CAAE,CACe,UAArB,QAAOvC,EAAP,CAAkCA,CAAS,CAAC6B,CAAD,CAA3C,OAjD8B,CAmDhC,MACE,qBAAC,eAAD,kBACMS,CADN,EAEE,GAAG,CAAEzD,CAFP,CAGE,KAAK,CAAEmD,CAHT,CAIE,QAAQ,CAAEC,CAJZ,CAKE,SAAS,CAAEC,CALb,CAME,IAAI,CAAE9D,CANR,CAOE,GAAG,CAAE+C,CAPP,CAQE,YAAY,CAAEiB,CARhB,CASE,OAAO,CA3CK,QAAVI,QAAU,CACdC,CADc,CAEX,CACH,GAAI,CAACV,CAAL,CAAe,CACb,GAA8B,UAA1B,QAAOlC,EAAX,CAA0C,iBACxCA,CAAc,CAACgC,CAAD,CAD0B,qBACxC,EAAuBY,CAAvB,CACD,CACD,GAA0B,UAAtB,QAAO7C,EAAX,CAAsC,iBACpCA,CAAU,CAACiC,CAAD,CAD0B,qBACpC,EAAmBY,CAAnB,CACD,CAC0B,UAAvB,QAAO3C,EAPE,UAQXA,CARW,WAQXA,CARW,QAQXA,CAAW,CAAG,CAAE2C,CAAC,CAADA,CAAF,CAAKZ,IAAI,CAAJA,CAAL,CAAH,CARA,CAUd,CACF,CAoBC,CAUE,MAAM,CAAE9C,CAAU,GAAKoC,CAVzB,CAWE,WAAW,GAAUgB,CAXvB,CAYE,MAAM,CAAEE,CAZV,CAaE,QAAQ,CAAEN,CAbZ,CAcE,EAAE,CAAEQ,CAdN,GAiBH,CArEA,CAFH,CA0EH,CAhFA,CAfH,CAkGH,CApLmD,CAA/C"}
|
|
1
|
+
{"version":3,"file":"ContextMenuLevel.js","names":["React","createRef","useEffect","useMemo","useState","cn","getGroups","Popover","ContextMenuDivider","ContextMenuGroupHeader","ContextMenuItem","contextMenuDefaultSize","cnContextMenuLevel","renderHeader","groupLabel","first","length","size","timers","clearTimers","timer","clearTimeout","closeDelay","ContextMenuLevel","forwardRef","props","ref","level","activeItem","addLevel","className","deleteLevel","items","setHoveredParenLevel","getLabel","getRightSideBar","getLeftSideBar","getSubItems","getGroupId","getAccent","getDisabled","getOnClick","getItemOnClick","onItemClick","getItemHTMLAttributes","getItemAs","sortGroup","getGroupLabel","direction","possibleDirections","offset","onSetDirection","hoveredParenLevel","spareDirection","anchorRef","otherProps","hovered","setHovered","groups","a","b","key","getItemIndex","groupId","itemIndex","itemsRefs","constructItemRefs","refs","group","i","setTimeout","firstLevel","map","groupIndex","item","index","disabled","label","leftSide","rightSide","subItems","onMouseEnter","accent","atributes","as","onClick","e"],"sources":["../../../../../../src/components/ContextMenuDeprecated/ContextMenuLevel/ContextMenuLevel.tsx"],"sourcesContent":["import './ContextMenuLevel.css';\n\nimport React, { createRef, useEffect, useMemo, useState } from 'react';\n\nimport { cn } from '../../../utils/bem';\nimport { getGroups } from '../../../utils/getGroups';\nimport { Popover } from '../../Popover/Popover';\nimport { ContextMenuDivider } from '../ContextMenuDivider/ContextMenuDivider';\nimport { ContextMenuGroupHeader } from '../ContextMenuGroupHeader/ContextMenuGroupHeader';\nimport { ContextMenuItem } from '../ContextMenuItem/ContextMenuItem';\nimport {\n contextMenuDefaultSize,\n ContextMenuLevelType,\n ContextMenuPropSize,\n} from '../helpers';\n\nexport const cnContextMenuLevel = cn('ContextMenuLevelDeprecated');\n\nfunction renderHeader(\n groupLabel: string | number | undefined,\n first: boolean,\n length: number,\n size?: ContextMenuPropSize,\n): React.ReactNode | null {\n if (!groupLabel) {\n if (first) {\n return null;\n }\n return <ContextMenuDivider size={size} />;\n }\n return (\n <ContextMenuGroupHeader label={groupLabel} first={first} size={size} />\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\nexport const ContextMenuLevel: ContextMenuLevelType = React.forwardRef(\n (props, ref: React.Ref<HTMLDivElement>) => {\n const {\n // props относящиеся к уровню меню\n size = contextMenuDefaultSize,\n level,\n activeItem,\n addLevel,\n className,\n deleteLevel,\n items,\n setHoveredParenLevel,\n\n // props относящиеся к пунктам меню\n getLabel,\n getRightSideBar,\n getLeftSideBar,\n getSubItems,\n getGroupId,\n getAccent,\n getDisabled,\n getOnClick,\n getItemOnClick,\n onItemClick,\n getItemHTMLAttributes,\n getItemAs,\n\n // props относящиеся к группам меню\n sortGroup,\n getGroupLabel,\n\n // props относящиеся к поповеру\n direction,\n possibleDirections,\n offset,\n onSetDirection,\n hoveredParenLevel,\n spareDirection,\n anchorRef,\n ...otherProps\n } = props;\n\n const [hovered, setHovered] = useState<boolean>(false);\n\n const groups = getGroups(\n items,\n getGroupId,\n undefined,\n undefined,\n sortGroup && ((a, b) => sortGroup(a.key, b.key)),\n );\n\n const getItemIndex = (groupId: number | string, itemIndex: number) =>\n `${groupId}-${itemIndex}`;\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]);\n\n useEffect(() => {\n if (level !== 0 && !hovered && hoveredParenLevel < level) {\n clearTimeout(timers[level]);\n timers[level] = setTimeout(() => deleteLevel(level), closeDelay);\n }\n return () => {\n clearTimeout(timers[level]);\n };\n }, [hovered, hoveredParenLevel]);\n\n return (\n <Popover\n {...otherProps}\n anchorRef={anchorRef}\n className={cnContextMenuLevel({ firstLevel: level === 0, direction }, [\n className,\n ])}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n direction={direction}\n offset={offset}\n onSetDirection={onSetDirection}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n ref={ref}\n >\n {groups.map((group, groupIndex) => {\n const groupLabel =\n typeof getGroupLabel === 'function'\n ? getGroupLabel(group.key)\n : undefined;\n return (\n <div className={cnContextMenuLevel('Group')} key={group.key}>\n {renderHeader(groupLabel, groupIndex === 0, groups.length, size)}\n {group.items.map((item, index) => {\n const itemIndex = getItemIndex(group.key, index);\n const ref = itemsRefs[itemIndex];\n const disabled =\n typeof getDisabled === 'function' ? getDisabled(item) : false;\n const label = getLabel(item);\n const leftSide =\n typeof getLeftSideBar === 'function'\n ? getLeftSideBar(item)\n : undefined;\n const rightSide =\n typeof getRightSideBar === 'function'\n ? getRightSideBar(item)\n : undefined;\n const subItems =\n typeof getSubItems === 'function'\n ? getSubItems(item)\n : undefined;\n const onClick = (\n e: React.MouseEvent<HTMLDivElement, MouseEvent>,\n ) => {\n if (!disabled) {\n if (typeof getItemOnClick === 'function') {\n getItemOnClick(item)?.(e);\n }\n if (typeof getOnClick === 'function') {\n getOnClick(item)?.(e);\n }\n if (typeof onItemClick === 'function') {\n onItemClick?.({ e, item });\n }\n }\n };\n const onMouseEnter =\n subItems && !disabled\n ? () => {\n addLevel(level + 1, subItems, ref, itemIndex);\n setHoveredParenLevel(level + 1);\n }\n : () => {\n setHoveredParenLevel(level);\n };\n const accent =\n typeof getAccent === 'function' ? getAccent(item) : undefined;\n const atributes =\n typeof getItemHTMLAttributes === 'function'\n ? getItemHTMLAttributes(item)\n : {};\n const as =\n typeof getItemAs === 'function' ? getItemAs(item) : undefined;\n\n return (\n <ContextMenuItem\n {...atributes}\n ref={ref}\n label={label}\n leftSide={leftSide}\n rightSide={rightSide}\n size={size}\n key={itemIndex}\n onMouseEnter={onMouseEnter}\n onClick={onClick}\n active={activeItem === itemIndex}\n withSubMenu={Boolean(subItems)}\n accent={accent}\n disabled={disabled}\n as={as}\n />\n );\n })}\n </div>\n );\n })}\n </Popover>\n );\n },\n);\n"],"mappings":"stDAAA,+BAEA,MAAOA,MAAP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AAUgB,CAXvB,CAYE,MAAM,CAAEE,CAZV,CAaE,QAAQ,CAAEN,CAbZ,CAcE,EAAE,CAAEQ,CAdN,GAiBH,CArEA,CAFH,CA0EH,CAhFA,CAfH,CAkGH,CApLmD,CAA/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ListItem{--list-item-color:var(--color-typo-primary);background:var(--color-control-bg-clear);position:relative;transition:color .3s}.ListItem.Text{color:var(--list-item-color)}.ListItem_interactive{cursor:pointer}.ListItem_active,.ListItem_interactive:hover{background:var(--color-control-bg-clear-hover)}.ListItem:before{background-color:var(--color-control-typo-secondary);bottom:0;content:"";left:0;opacity:0;position:absolute;top:0;transition:opacity .2s;width:var(--space-3xs)}.ListItem_checked{--list-item-color:var(--color-control-typo-secondary)}.ListItem_checked:before{opacity:1}.ListItem_disabled{--list-item-color:var(--color-control-typo-disable);cursor:auto}
|
|
1
|
+
.ListItem{--list-item-color:var(--color-typo-primary);background:var(--color-control-bg-clear);position:relative;text-decoration:none;transition:color .3s}.ListItem.Text{color:var(--list-item-color)}.ListItem_interactive{cursor:pointer}.ListItem_active,.ListItem_interactive:hover{background:var(--color-control-bg-clear-hover)}.ListItem:before{background-color:var(--color-control-typo-secondary);bottom:0;content:"";left:0;opacity:0;position:absolute;top:0;transition:opacity .2s;width:var(--space-3xs)}.ListItem_checked{--list-item-color:var(--color-control-typo-secondary)}.ListItem_checked:before{opacity:1}.ListItem_disabled{--list-item-color:var(--color-control-typo-disable);cursor:auto}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type ComponentSize = {
|
|
2
|
+
export declare type ComponentSize = {
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
};
|
|
6
|
+
export declare const getElementSize: (el: HTMLElement | SVGGraphicsElement | null) => ComponentSize;
|
|
6
7
|
export declare function useComponentSize(ref: React.RefObject<HTMLElement | SVGGraphicsElement>): ComponentSize;
|
|
7
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useMemo}from"react";import{useResizeObserved}from"../useResizeObserved/useResizeObserved";var getElementSize=function(a){if(!a)return{width:0,height:0};var b=a.getBoundingClientRect(),c=b.width,d=b.height;return{width:Math.floor(c),height:Math.floor(d)}};export function useComponentSize(a){var b=useMemo(function(){return[a]},[a.current]),c=useResizeObserved(b,getElementSize),d=_slicedToArray(c,1),e=d[0];return e}
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useMemo}from"react";import{useResizeObserved}from"../useResizeObserved/useResizeObserved";export var getElementSize=function(a){if(!a)return{width:0,height:0};var b=a.getBoundingClientRect(),c=b.width,d=b.height;return{width:Math.floor(c),height:Math.floor(d)}};export function useComponentSize(a){var b=useMemo(function(){return[a]},[a.current]),c=useResizeObserved(b,getElementSize),d=_slicedToArray(c,1),e=d[0];return e}
|
|
2
2
|
//# sourceMappingURL=useComponentSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComponentSize.js","names":["useMemo","useResizeObserved","getElementSize","el","width","height","getBoundingClientRect","Math","floor","useComponentSize","ref","refs","current","componentSize"],"sources":["../../../../../src/hooks/useComponentSize/useComponentSize.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { useResizeObserved } from '../useResizeObserved/useResizeObserved';\n\
|
|
1
|
+
{"version":3,"file":"useComponentSize.js","names":["useMemo","useResizeObserved","getElementSize","el","width","height","getBoundingClientRect","Math","floor","useComponentSize","ref","refs","current","componentSize"],"sources":["../../../../../src/hooks/useComponentSize/useComponentSize.tsx"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { useResizeObserved } from '../useResizeObserved/useResizeObserved';\n\nexport type ComponentSize = {\n width: number;\n height: number;\n};\n\nexport const getElementSize = (\n el: HTMLElement | SVGGraphicsElement | null,\n): ComponentSize => {\n if (!el) {\n return { width: 0, height: 0 };\n }\n\n const { width, height } = el.getBoundingClientRect();\n\n return {\n width: Math.floor(width),\n height: Math.floor(height),\n };\n};\n\nexport function useComponentSize(\n ref: React.RefObject<HTMLElement | SVGGraphicsElement>,\n): ComponentSize {\n const refs = useMemo(\n () => [ref],\n // Если реф начал указывать на другой элемент, нужно обновить подписки\n [ref.current],\n );\n const [componentSize] = useResizeObserved(refs, getElementSize);\n return componentSize;\n}\n"],"mappings":"iEAAA,OAASA,OAAT,KAAwB,OAAxB,CAEA,OAASC,iBAAT,8CAOA,MAAO,IAAMC,eAAc,CAAG,SAC5BC,CAD4B,CAEV,CAClB,GAAI,CAACA,CAAL,CACE,MAAO,CAAEC,KAAK,CAAE,CAAT,CAAYC,MAAM,CAAE,CAApB,CAAP,CAGF,MAA0BF,CAAE,CAACG,qBAAH,EAA1B,CAAQF,CAAR,GAAQA,KAAR,CAAeC,CAAf,GAAeA,MAAf,CAEA,MAAO,CACLD,KAAK,CAAEG,IAAI,CAACC,KAAL,CAAWJ,CAAX,CADF,CAELC,MAAM,CAAEE,IAAI,CAACC,KAAL,CAAWH,CAAX,CAFH,CAIR,CAbM,CAeP,MAAO,SAASI,iBAAT,CACLC,CADK,CAEU,IACTC,EAAI,CAAGX,OAAO,CAClB,iBAAM,CAACU,CAAD,CAAN,CADkB,CAGlB,CAACA,CAAG,CAACE,OAAL,CAHkB,CADL,GAMSX,iBAAiB,CAACU,CAAD,CAAOT,cAAP,CAN1B,uBAMRW,CANQ,MAOf,MAAOA,EACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.MixPopoverAnimate{--mix-dropdown-animate-space:var(--space-s);--mix-dropdown-animate-transform:translateY(var(--mix-dropdown-animate-space))}.MixPopoverAnimate_animate_exit{opacity:1;transform:translate(0)}.MixPopoverAnimate_animate_enter,.MixPopoverAnimate_animate_exitActive,.MixPopoverAnimate_animate_exitDone,.MixPopoverAnimate_animate_exited,.MixPopoverAnimate_animate_exiting,.MixPopoverAnimate_animate_unmounted{opacity:0;pointer-events:none;transform:var(--mix-dropdown-animate-transform)}.MixPopoverAnimate_animate_enterActive,.MixPopoverAnimate_animate_enterDone,.MixPopoverAnimate_animate_entered,.MixPopoverAnimate_animate_entering{opacity:1;transform:translate(0)}.MixPopoverAnimate_animate_enterActive,.MixPopoverAnimate_animate_enterDone,.MixPopoverAnimate_animate_entered,.MixPopoverAnimate_animate_entering,.MixPopoverAnimate_animate_exitActive,.MixPopoverAnimate_animate_exitDone,.MixPopoverAnimate_animate_exiting{transition:
|
|
1
|
+
.MixPopoverAnimate{--mix-dropdown-animate-space:var(--space-s);--mix-dropdown-animate-transform:translateY(var(--mix-dropdown-animate-space));--mix-dropdown-animate-timeout:0.2s;--mix-dropdown-animate-trasition:opacity var(--mix-dropdown-animate-timeout),transform var(--mix-dropdown-animate-timeout)}.MixPopoverAnimate_animate_exit{opacity:1;pointer-events:none;transform:translate(0)}.MixPopoverAnimate_animate_enter,.MixPopoverAnimate_animate_exitActive,.MixPopoverAnimate_animate_exitDone,.MixPopoverAnimate_animate_exited,.MixPopoverAnimate_animate_exiting,.MixPopoverAnimate_animate_unmounted{opacity:0;pointer-events:none;transform:var(--mix-dropdown-animate-transform)}.MixPopoverAnimate_animate_enterActive,.MixPopoverAnimate_animate_enterDone,.MixPopoverAnimate_animate_entered,.MixPopoverAnimate_animate_entering{opacity:1;transform:translate(0)}.MixPopoverAnimate_animate_enterActive,.MixPopoverAnimate_animate_enterDone,.MixPopoverAnimate_animate_entered,.MixPopoverAnimate_animate_entering,.MixPopoverAnimate_animate_exitActive,.MixPopoverAnimate_animate_exitDone,.MixPopoverAnimate_animate_exiting{transition:var(--mix-dropdown-animate-trasition)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@consta/uikit",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"ui-kit",
|
|
6
6
|
"design-system",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@bem-react/classname": "^1.5.12",
|
|
18
18
|
"@bem-react/classnames": "^1.3.10",
|
|
19
|
-
"@consta/icons": "^0.
|
|
19
|
+
"@consta/icons": "^0.1.1",
|
|
20
20
|
"compute-scroll-into-view": "^1.0.17",
|
|
21
21
|
"date-fns": "^2.29.1",
|
|
22
22
|
"focus-trap-react": "8.7.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.ContextMenuCanary-Level{pointer-events:none}.ContextMenuCanary-Level.MixPopoverAnimate_animate_entered{pointer-events:auto}.ContextMenuCanary-Level_playAnimation.MixPopoverAnimate{opacity:0!important;transform:var(--mix-dropdown-animate-transform)!important;transition:opacity .2s,transform .2s!important}.ContextMenuCanary-Level_eventsNone.MixPopoverAnimate{pointer-events:none}
|