@consta/header 0.1.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Badges/Badges.js +1 -1
- package/Badges/Badges.js.map +1 -1
- package/ButtonMenu/ButtonMenu.css +1 -0
- package/ButtonMenu/ButtonMenu.d.ts +5 -0
- package/ButtonMenu/ButtonMenu.js +2 -0
- package/ButtonMenu/ButtonMenu.js.map +1 -0
- package/ButtonMenu/helpers.d.ts +43 -0
- package/ButtonMenu/helpers.js +2 -0
- package/ButtonMenu/helpers.js.map +1 -0
- package/ButtonMenu/index.d.ts +1 -0
- package/ButtonMenu/index.js +2 -0
- package/ButtonMenu/index.js.map +1 -0
- package/ButtonMenu/types.d.ts +38 -0
- package/ButtonMenu/types.js +2 -0
- package/ButtonMenu/types.js.map +1 -0
- package/Header/Header.css +1 -1
- package/Header/Header.js +1 -1
- package/Header/Header.js.map +1 -1
- package/Header/HeaderSearch/HeaderSearch.css +1 -0
- package/Header/HeaderSearch/HeaderSearch.d.ts +15 -0
- package/Header/HeaderSearch/HeaderSearch.js +2 -0
- package/Header/HeaderSearch/HeaderSearch.js.map +1 -0
- package/Header/HeaderSearch/index.d.ts +1 -0
- package/Header/HeaderSearch/index.js +2 -0
- package/Header/HeaderSearch/index.js.map +1 -0
- package/Header/helpers.d.ts +9 -0
- package/Header/helpers.js +2 -0
- package/Header/helpers.js.map +1 -0
- package/Header/types.d.ts +99 -13
- package/Languages/Languages.d.ts +3 -0
- package/Languages/Languages.js +2 -0
- package/Languages/Languages.js.map +1 -0
- package/Languages/helpers.d.ts +20 -0
- package/Languages/helpers.js +2 -0
- package/Languages/helpers.js.map +1 -0
- package/Languages/index.d.ts +1 -0
- package/Languages/index.js +2 -0
- package/Languages/index.js.map +1 -0
- package/Languages/types.d.ts +23 -0
- package/Languages/types.js +2 -0
- package/Languages/types.js.map +1 -0
- package/Layout/Layout.js +1 -1
- package/Layout/Layout.js.map +1 -1
- package/Menu/Menu.js +1 -1
- package/Menu/Menu.js.map +1 -1
- package/Menu/helpers.d.ts +29 -16
- package/Menu/helpers.js +1 -1
- package/Menu/helpers.js.map +1 -1
- package/Menu/types.d.ts +5 -5
- package/MobileMenu/MobileMenu.js +1 -1
- package/MobileMenu/MobileMenu.js.map +1 -1
- package/MobileMenu/types.d.ts +5 -2
- package/MobileMenu/types.js +1 -1
- package/MobileMenu/types.js.map +1 -1
- package/Notifications/Notifications.js +1 -1
- package/Notifications/Notifications.js.map +1 -1
- package/Notifications/types.d.ts +3 -3
- package/NotificationsList/helpers.d.ts +15 -15
- package/NotificationsList/helpers.js.map +1 -1
- package/NotificationsList/types.d.ts +11 -11
- package/SelectMenu/SelectMenu.css +1 -0
- package/SelectMenu/SelectMenu.d.ts +5 -0
- package/SelectMenu/SelectMenu.js +2 -0
- package/SelectMenu/SelectMenu.js.map +1 -0
- package/SelectMenu/helpers.d.ts +40 -0
- package/SelectMenu/helpers.js +2 -0
- package/SelectMenu/helpers.js.map +1 -0
- package/SelectMenu/index.d.ts +1 -0
- package/SelectMenu/index.js +2 -0
- package/SelectMenu/index.js.map +1 -0
- package/SelectMenu/types.d.ts +33 -0
- package/SelectMenu/types.js +2 -0
- package/SelectMenu/types.js.map +1 -0
- package/TileMenu/TileMenu.js +1 -1
- package/TileMenu/TileMenu.js.map +1 -1
- package/TileMenu/TileMenuList/TileMenuList.js +1 -1
- package/TileMenu/TileMenuList/TileMenuList.js.map +1 -1
- package/TileMenu/helpers.d.ts +11 -11
- package/TileMenu/helpers.js +1 -1
- package/TileMenu/helpers.js.map +1 -1
- package/TileMenu/types.d.ts +10 -10
- package/TileMenu/types.js.map +1 -1
- package/VerticalMenu/VerticalMenu.js +1 -1
- package/VerticalMenu/VerticalMenu.js.map +1 -1
- package/VerticalMenu/VerticalMenuItem/VerticalMenuItem.js +1 -1
- package/VerticalMenu/VerticalMenuItem/VerticalMenuItem.js.map +1 -1
- package/VerticalMenu/VerticalMenuLevel/VerticalMenuLevel.css +1 -1
- package/VerticalMenu/VerticalMenuLevel/VerticalMenuLevel.js +1 -1
- package/VerticalMenu/VerticalMenuLevel/VerticalMenuLevel.js.map +1 -1
- package/VerticalMenu/helpers.d.ts +6 -3
- package/VerticalMenu/helpers.js +1 -1
- package/VerticalMenu/helpers.js.map +1 -1
- package/VerticalMenu/types.d.ts +8 -0
- package/__private__/AnimatedContextMenu/AnimatedContextMenu.css +1 -1
- package/__private__/AnimatedContextMenu/AnimatedContextMenu.js +1 -1
- package/__private__/AnimatedContextMenu/AnimatedContextMenu.js.map +1 -1
- package/__private__/helpers/getItemClick.d.ts +7 -0
- package/__private__/helpers/getItemClick.js +2 -0
- package/__private__/helpers/getItemClick.js.map +1 -0
- package/package.json +2 -2
- package/__private__/hooks/useHideElementsLine.d.ts +0 -8
- package/__private__/hooks/useHideElementsLine.js +0 -2
- package/__private__/hooks/useHideElementsLine.js.map +0 -1
- package/__private__/mixs/MixPopoverAnimate/MixPopoverAnimate.css +0 -1
- package/__private__/mixs/MixPopoverAnimate/MixPopoverAnimate.d.ts +0 -4
- package/__private__/mixs/MixPopoverAnimate/MixPopoverAnimate.js +0 -2
- package/__private__/mixs/MixPopoverAnimate/MixPopoverAnimate.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React,{forwardRef,useRef,useState
|
|
1
|
+
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React,{forwardRef,useRef,useState}from"react";import{Transition}from"react-transition-group";import{cn}from"../__private__/utils/bem";import{NotificationsList}from"../NotificationsList";import{Sidebar}from"../__private__/components/Sidebar";import{Button}from"@consta/uikit/Button";import{Popover}from"@consta/uikit/Popover";import{useForkRef}from"@consta/uikit/useForkRef";import{IconRing}from"@consta/uikit/IconRing";import{useFlag}from"@consta/uikit/useFlag";import{cnMixPopoverArrow}from"../__private__/mixs/MixPopoverArrow/MixPopoverArrow";import{cnMixPopoverAnimate,animateTimeout}from"@consta/uikit/MixPopoverAnimate";import"./Notifications.css";const ARROW_SIZE=6,ARROW_OFFSET=10;export const cnNotifications=cn("Notifications");const NotificationsRender=(a,b)=>{var c;const{className:d,items:e,groupByDay:f,groups:g,groupLabelFormat:h,itemDateFormat:i,title:j,actions:k,getActionIcon:l,getActionLabel:m,getActionOnClick:n,getGroupId:o,getGroupLabel:p,getItemActions:q,getItemBadges:r,getItemDate:s,getItemDescription:t,getItemGroup:u,getItemImage:v,getItemLabel:w,getItemRead:x,getItemView:y,listClassName:z,isMobile:A}=a,B=_objectWithoutProperties(a,["className","items","groupByDay","groups","groupLabelFormat","itemDateFormat","title","actions","getActionIcon","getActionLabel","getActionOnClick","getGroupId","getGroupLabel","getItemActions","getItemBadges","getItemDate","getItemDescription","getItemGroup","getItemImage","getItemLabel","getItemRead","getItemView","listClassName","isMobile"]),C=useRef(null),[D,E]=useState(void 0),[F,{toogle:G,off:H}]=useFlag(),I={className:cnNotifications("List",[z]),items:e,groupByDay:f,groups:g,groupLabelFormat:h,title:j,actions:k,getActionIcon:l,getActionLabel:m,getActionOnClick:n,getGroupId:o,getGroupLabel:p,getItemActions:q,getItemBadges:r,getItemDate:s,getItemDescription:t,getItemGroup:u,getItemImage:v,getItemLabel:w,getItemRead:x,getItemView:y},J="number"==typeof(null===(c=a.style)||void 0===c?void 0:c.zIndex)?a.style.zIndex+1:void 0;return React.createElement(React.Fragment,null,React.createElement(Button,Object.assign({},B,{size:"s",view:"clear",className:cnNotifications(null,[d]),iconLeft:IconRing,ref:useForkRef([b,C]),onClick:G})),A?_jsx(Sidebar,{isOpen:F,onClickOutside:H,style:{zIndex:J}},void 0,React.createElement(NotificationsList,Object.assign({},I,{onClose:H,style:{zIndex:J}}))):_jsx(Transition,{timeout:animateTimeout,unmountOnExit:!0,in:F},void 0,a=>_jsx(Popover,{className:cnNotifications("Popover",[cnMixPopoverAnimate({animate:a,direction:D})]),anchorRef:C,arrowOffset:ARROW_OFFSET+ARROW_SIZE,offset:10,onSetDirection:E,style:{"--popover-arrow-size":`${ARROW_SIZE}px`,"--popover-arrow-offset":`${ARROW_OFFSET}px`,zIndex:J},onClickOutside:H},void 0,_jsx("div",{className:cnMixPopoverArrow({direction:D})}),React.createElement(NotificationsList,Object.assign({},I,{style:{zIndex:J}})))))};export const Notifications=forwardRef(NotificationsRender);
|
|
2
2
|
//# sourceMappingURL=Notifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Notifications/Notifications.tsx"],"names":["React","forwardRef","useRef","useState","
|
|
1
|
+
{"version":3,"sources":["../../src/Notifications/Notifications.tsx"],"names":["React","forwardRef","useRef","useState","Transition","cn","NotificationsList","Sidebar","Button","Popover","useForkRef","IconRing","useFlag","cnMixPopoverArrow","cnMixPopoverAnimate","animateTimeout","ARROW_SIZE","ARROW_OFFSET","cnNotifications","NotificationsRender","props","ref","className","items","groupByDay","groups","groupLabelFormat","itemDateFormat","title","actions","getActionIcon","getActionLabel","getActionOnClick","getGroupId","getGroupLabel","getItemActions","getItemBadges","getItemDate","getItemDescription","getItemGroup","getItemImage","getItemLabel","getItemRead","getItemView","listClassName","isMobile","otherProps","buttonRef","direction","setDirection","visibleMenu","toogle","off","listProps","elementZIndex","style","zIndex","animate","Notifications"],"mappings":"kIAAA,MAAOA,CAAAA,KAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,CAAoCC,QAApC,KAAoD,OAApD,CAEA,OAASC,UAAT,KAA2B,wBAA3B,CACA,OAASC,EAAT,gCAIA,OAASC,iBAAT,4BACA,OAASC,OAAT,yCAEA,OAASC,MAAT,KAAuB,sBAAvB,CAEA,OAASC,OAAT,KAAmC,uBAAnC,CACA,OAASC,UAAT,KAA2B,0BAA3B,CACA,OAASC,QAAT,KAAyB,wBAAzB,CACA,OAASC,OAAT,KAAwB,uBAAxB,CACA,OAASC,iBAAT,2DAEA,OAASC,mB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CAAvB,EAAkC,OAAO,CAAED,CAA3C,CAAgD,KAAK,CAAE,CAAEI,MAAM,CAAEF,CAAV,CAAvD,GADF,CADO,CAKP,KAAC,UAAD,EAAY,OAAO,CAAEvC,cAArB,CAAqC,aAAa,GAAlD,CAAmD,EAAE,CAAEmC,CAAvD,SACGO,CAAO,EACN,KAAC,OAAD,EACE,SAAS,CAAEvC,eAAe,CAAC,SAAD,CAAY,CAACJ,mBAAmB,CAAC,CAAE2C,OAAO,CAAPA,CAAF,CAAWT,SAAS,CAATA,CAAX,CAAD,CAApB,CAAZ,CAD5B,CAEE,SAAS,CAAED,CAFb,CAGE,WAAW,CAAE9B,YAAY,CAAGD,UAH9B,CAIE,MAAM,GAJR,CAKE,cAAc,CAAEiC,CALlB,CAME,KAAK,CAAE,CACL,uBAAqC,GAAEjC,UAAW,IAD7C,CAEL,yBAAuC,GAAEC,YAAa,IAFjD,CAGLuC,MAAM,CAAEF,CAHH,CANT,CAWE,cAAc,CAAEF,CAXlB,SAaE,YAAK,SAAS,CAAEvC,iBAAiB,CAAC,CAAEmC,SAAS,CAATA,CAAF,CAAD,CAAjC,EAbF,CAcE,oBAAC,iBAAD,kBAAuBK,CAAvB,EAAkC,KAAK,CAAE,CAAEG,MAAM,CAAEF,CAAV,CAAzC,GAdF,CAFJ,CAfJ,CAsCH,CAnGD,CAqGA,MAAO,MAAMI,CAAAA,aAAa,CAAGzD,UAAU,CAACkB,mBAAD,CAAhC","sourcesContent":["import React, { forwardRef, useRef, useState } from 'react'\n\nimport { Transition } from 'react-transition-group'\nimport { cn } from '@/__private__/utils/bem'\n\nimport { NotificationsProps, NotificationsComponent } from './types'\n\nimport { NotificationsList } from '@/NotificationsList'\nimport { Sidebar } from '@/__private__/components/Sidebar'\n\nimport { Button } from '@consta/uikit/Button'\n\nimport { Popover, Direction } from '@consta/uikit/Popover'\nimport { useForkRef } from '@consta/uikit/useForkRef'\nimport { IconRing } from '@consta/uikit/IconRing'\nimport { useFlag } from '@consta/uikit/useFlag'\nimport { cnMixPopoverArrow } from '@/__private__/mixs/MixPopoverArrow/MixPopoverArrow'\n\nimport { cnMixPopoverAnimate, animateTimeout } from '@consta/uikit/MixPopoverAnimate'\n\nimport './Notifications.css'\n\nconst ARROW_SIZE = 6\nconst ARROW_OFFSET = 10\n\nexport const cnNotifications = cn('Notifications')\n\nconst NotificationsRender = (props: NotificationsProps, ref: React.Ref<HTMLButtonElement>) => {\n const {\n className,\n items,\n groupByDay,\n groups,\n groupLabelFormat,\n itemDateFormat,\n title,\n actions,\n getActionIcon,\n getActionLabel,\n getActionOnClick,\n getGroupId,\n getGroupLabel,\n getItemActions,\n getItemBadges,\n getItemDate,\n getItemDescription,\n getItemGroup,\n getItemImage,\n getItemLabel,\n getItemRead,\n getItemView,\n listClassName,\n isMobile,\n ...otherProps\n } = props\n\n const buttonRef = useRef<HTMLButtonElement>(null)\n const [direction, setDirection] = useState<Direction | undefined>(undefined)\n\n const [visibleMenu, { toogle, off }] = useFlag()\n\n const listProps = {\n className: cnNotifications('List', [listClassName]),\n items,\n groupByDay,\n groups,\n groupLabelFormat,\n title,\n actions,\n getActionIcon,\n getActionLabel,\n getActionOnClick,\n getGroupId,\n getGroupLabel,\n getItemActions,\n getItemBadges,\n getItemDate,\n getItemDescription,\n getItemGroup,\n getItemImage,\n getItemLabel,\n getItemRead,\n getItemView,\n }\n\n const elementZIndex = typeof props.style?.zIndex === 'number' ? props.style.zIndex + 1 : undefined\n\n return (\n <>\n <Button\n {...otherProps}\n size=\"s\"\n view=\"clear\"\n className={cnNotifications(null, [className])}\n iconLeft={IconRing}\n ref={useForkRef([ref, buttonRef])}\n onClick={toogle}\n />\n {isMobile ? (\n <Sidebar isOpen={visibleMenu} onClickOutside={off} style={{ zIndex: elementZIndex }}>\n <NotificationsList {...listProps} onClose={off} style={{ zIndex: elementZIndex }} />\n </Sidebar>\n ) : (\n <Transition timeout={animateTimeout} unmountOnExit in={visibleMenu}>\n {animate => (\n <Popover\n className={cnNotifications('Popover', [cnMixPopoverAnimate({ animate, direction })])}\n anchorRef={buttonRef}\n arrowOffset={ARROW_OFFSET + ARROW_SIZE}\n offset={ARROW_SIZE + 4}\n onSetDirection={setDirection}\n style={{\n ['--popover-arrow-size' as string]: `${ARROW_SIZE}px`,\n ['--popover-arrow-offset' as string]: `${ARROW_OFFSET}px`,\n zIndex: elementZIndex,\n }}\n onClickOutside={off}\n >\n <div className={cnMixPopoverArrow({ direction })} />\n <NotificationsList {...listProps} style={{ zIndex: elementZIndex }} />\n </Popover>\n )}\n </Transition>\n )}\n </>\n )\n}\n\nexport const Notifications = forwardRef(NotificationsRender) as NotificationsComponent\n"],"file":"Notifications.js"}
|
package/Notifications/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Props,
|
|
2
|
+
import { Props, NotificationsDefaultAction, NotificationsDefaultItem, NotificationsDefaultGroup } from "../NotificationsList/index";
|
|
3
3
|
import { PropsWithHTMLAttributesAndRef } from "../__private__/utils/types/PropsWithHTMLAttributes";
|
|
4
|
-
export declare type NotificationsProps<ITEM =
|
|
4
|
+
export declare type NotificationsProps<ITEM = NotificationsDefaultItem, GROUP = NotificationsDefaultGroup, ACTION = NotificationsDefaultAction, GROUP_BY_DAY extends boolean = false> = PropsWithHTMLAttributesAndRef<Omit<Props<ITEM, GROUP, ACTION, GROUP_BY_DAY>, 'onClose'> & {
|
|
5
5
|
listClassName?: string;
|
|
6
6
|
isMobile?: boolean;
|
|
7
7
|
}, HTMLButtonElement>;
|
|
8
|
-
export declare type NotificationsComponent = <ITEM =
|
|
8
|
+
export declare type NotificationsComponent = <ITEM = NotificationsDefaultItem, GROUP = NotificationsDefaultGroup, ACTION = NotificationsDefaultAction, GROUP_BY_DAY extends boolean = false>(props: NotificationsProps<ITEM, GROUP, ACTION, GROUP_BY_DAY>) => React.ReactElement | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { NotificationsListPropGetActionIcon, NotificationsListPropGetActionLabel, NotificationsListPropGetActionOnClick, NotificationsListPropGetGroupId, NotificationsListPropGetGroupLabel, NotificationsListPropGetItemActions, NotificationsListPropGetItemBadges, NotificationsListPropGetItemDate, NotificationsListPropGetItemDescription, NotificationsListPropGetItemGroup, NotificationsListPropGetItemImage, NotificationsListPropGetItemLabel, NotificationsListPropGetItemRead, NotificationsListPropGetItemView,
|
|
2
|
+
import { NotificationsListPropGetActionIcon, NotificationsListPropGetActionLabel, NotificationsListPropGetActionOnClick, NotificationsListPropGetGroupId, NotificationsListPropGetGroupLabel, NotificationsListPropGetItemActions, NotificationsListPropGetItemBadges, NotificationsListPropGetItemDate, NotificationsListPropGetItemDescription, NotificationsListPropGetItemGroup, NotificationsListPropGetItemImage, NotificationsListPropGetItemLabel, NotificationsListPropGetItemRead, NotificationsListPropGetItemView, NotificationsDefaultAction, NotificationsDefaultGroup, NotificationsDefaultItem, NotificationsListProps, NotificationsListPropGroupLabelFormat } from "./types";
|
|
3
3
|
export declare function withDefaultGetters<ITEM, GROUP, ACTION>(props: NotificationsListProps<ITEM, GROUP, ACTION>): {
|
|
4
4
|
children?: undefined;
|
|
5
5
|
items: ITEM[];
|
|
@@ -4121,20 +4121,20 @@ export declare function withDefaultGetters<ITEM, GROUP, ACTION>(props: Notificat
|
|
|
4121
4121
|
} ? {} : {
|
|
4122
4122
|
getItemLabel: NotificationsListPropGetItemLabel<ITEM>;
|
|
4123
4123
|
})>> & {
|
|
4124
|
-
getActionIcon: NotificationsListPropGetActionIcon<
|
|
4125
|
-
getActionLabel: NotificationsListPropGetActionLabel<
|
|
4126
|
-
getActionOnClick: NotificationsListPropGetActionOnClick<
|
|
4127
|
-
getGroupId: NotificationsListPropGetGroupId<
|
|
4128
|
-
getGroupLabel: NotificationsListPropGetGroupLabel<
|
|
4129
|
-
getItemActions: NotificationsListPropGetItemActions<
|
|
4130
|
-
getItemBadges: NotificationsListPropGetItemBadges<
|
|
4131
|
-
getItemDate: NotificationsListPropGetItemDate<
|
|
4132
|
-
getItemDescription: NotificationsListPropGetItemDescription<
|
|
4133
|
-
getItemGroup: NotificationsListPropGetItemGroup<
|
|
4134
|
-
getItemImage: NotificationsListPropGetItemImage<
|
|
4135
|
-
getItemLabel: NotificationsListPropGetItemLabel<
|
|
4136
|
-
getItemRead: NotificationsListPropGetItemRead<
|
|
4137
|
-
getItemView: NotificationsListPropGetItemView<
|
|
4124
|
+
getActionIcon: NotificationsListPropGetActionIcon<NotificationsDefaultAction> | NotificationsListPropGetActionIcon<ACTION>;
|
|
4125
|
+
getActionLabel: NotificationsListPropGetActionLabel<NotificationsDefaultAction> | NotificationsListPropGetActionLabel<ACTION>;
|
|
4126
|
+
getActionOnClick: NotificationsListPropGetActionOnClick<NotificationsDefaultAction> | NotificationsListPropGetActionOnClick<ACTION>;
|
|
4127
|
+
getGroupId: NotificationsListPropGetGroupId<NotificationsDefaultGroup> | NotificationsListPropGetGroupId<GROUP>;
|
|
4128
|
+
getGroupLabel: NotificationsListPropGetGroupLabel<NotificationsDefaultGroup> | NotificationsListPropGetGroupLabel<GROUP>;
|
|
4129
|
+
getItemActions: NotificationsListPropGetItemActions<NotificationsDefaultItem> | NotificationsListPropGetItemActions<ITEM>;
|
|
4130
|
+
getItemBadges: NotificationsListPropGetItemBadges<NotificationsDefaultItem> | NotificationsListPropGetItemBadges<ITEM>;
|
|
4131
|
+
getItemDate: NotificationsListPropGetItemDate<NotificationsDefaultItem> | NotificationsListPropGetItemDate<ITEM>;
|
|
4132
|
+
getItemDescription: NotificationsListPropGetItemDescription<NotificationsDefaultItem> | NotificationsListPropGetItemDescription<ITEM>;
|
|
4133
|
+
getItemGroup: NotificationsListPropGetItemGroup<NotificationsDefaultItem> | NotificationsListPropGetItemGroup<ITEM>;
|
|
4134
|
+
getItemImage: NotificationsListPropGetItemImage<NotificationsDefaultItem> | NotificationsListPropGetItemImage<ITEM>;
|
|
4135
|
+
getItemLabel: NotificationsListPropGetItemLabel<NotificationsDefaultItem> | NotificationsListPropGetItemLabel<ITEM>;
|
|
4136
|
+
getItemRead: NotificationsListPropGetItemRead<NotificationsDefaultItem> | NotificationsListPropGetItemRead<ITEM>;
|
|
4137
|
+
getItemView: NotificationsListPropGetItemView<NotificationsDefaultItem> | NotificationsListPropGetItemView<ITEM>;
|
|
4138
4138
|
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4139
4139
|
key?: string | number | undefined;
|
|
4140
4140
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/NotificationsList/helpers.ts"],"names":["getGroups","constaGetGroups","format","isToday","isYesterday","startOfDay","defaultGetActionIcon","action","icon","defaultGetActionLabel","label","defaultGetActionOnClick","onClick","defaultGetGroupId","group","id","defaultGetGroupLabel","defaultGetItemActions","item","actions","defaultGetItemBadges","badges","defaultGetItemDate","date","defaultGetItemDescription","description","defaultGetItemGroup","defaultGetItemImage","image","defaultGetItemLabel","defaultGetItemRead","read","defaultGetItemView","view","withDefaultGetters","props","getActionIcon","getActionLabel","getActionOnClick","getGroupId","getGroupLabel","getItemActions","getItemBadges","getItemDate","getItemDescription","getItemGroup","getItemImage","getItemLabel","getItemRead","getItemView","noGroupKey","defaultGroupLabelFormat","timestamp","sortGroup","a","b","key","items","groups","groupByDay","getTime"],"mappings":"+DAsBA,OAASA,SAAS,GAAIC,CAAAA,eAAtB,KAA6C,gDAA7C,CACA,OAASC,MAAT,CAAiBC,OAAjB,CAA0BC,WAA1B,CAAuCC,UAAvC,KAAyD,UAAzD,C,KAEMC,CAAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/NotificationsList/helpers.ts"],"names":["getGroups","constaGetGroups","format","isToday","isYesterday","startOfDay","defaultGetActionIcon","action","icon","defaultGetActionLabel","label","defaultGetActionOnClick","onClick","defaultGetGroupId","group","id","defaultGetGroupLabel","defaultGetItemActions","item","actions","defaultGetItemBadges","badges","defaultGetItemDate","date","defaultGetItemDescription","description","defaultGetItemGroup","defaultGetItemImage","image","defaultGetItemLabel","defaultGetItemRead","read","defaultGetItemView","view","withDefaultGetters","props","getActionIcon","getActionLabel","getActionOnClick","getGroupId","getGroupLabel","getItemActions","getItemBadges","getItemDate","getItemDescription","getItemGroup","getItemImage","getItemLabel","getItemRead","getItemView","noGroupKey","defaultGroupLabelFormat","timestamp","sortGroup","a","b","key","items","groups","groupByDay","getTime"],"mappings":"+DAsBA,OAASA,SAAS,GAAIC,CAAAA,eAAtB,KAA6C,gDAA7C,CACA,OAASC,MAAT,CAAiBC,OAAjB,CAA0BC,WAA1B,CAAuCC,UAAvC,KAAyD,UAAzD,C,KAEMC,CAAAA,oBAAoF,CAAGC,CAAM,EACjGA,CAAM,CAACC,I,CACHC,qBAAsF,CAAGF,CAAM,EACnGA,CAAM,CAACG,K,CACHC,uBAA0F,CAAGJ,CAAM,EACvGA,CAAM,CAACK,O,CACHC,iBAA6E,CAAGC,CAAK,EACzFA,CAAK,CAACC,E,CACFC,oBAAmF,CAAGF,CAAK,EAC/FA,CAAK,CAACJ,K,CACFO,qBAAoF,CAAGC,CAAI,EAC/FA,CAAI,CAACC,O,CACDC,oBAAkF,CAAGF,CAAI,EAC7FA,CAAI,CAACG,M,CACDC,kBAA8E,CAAGJ,CAAI,EACzFA,CAAI,CAACK,I,CACDC,yBAA4F,CAAGN,CAAI,EACvGA,CAAI,CAACO,W,CACDC,mBAAgF,CAAGR,CAAI,EAC3FA,CAAI,CAACJ,K,CACDa,mBAAgF,CAAGT,CAAI,EAC3FA,CAAI,CAACU,K,CACDC,mBAAgF,CAAGX,CAAI,EAC3FA,CAAI,CAACR,K,CACDoB,kBAA8E,CAAGZ,CAAI,EACzFA,CAAI,CAACa,I,CACDC,kBAA8E,CAAGd,CAAI,EACzFA,CAAI,CAACe,I,CAEP,MAAO,SAASC,CAAAA,kBAAT,CACLC,CADK,CAEL,CACA,wBACKA,CADL,EAEEC,aAAa,CAAED,CAAK,CAACC,aAAN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,MAAMxD,CAAAA,SAAS,CAAG,CACvByD,CADuB,CAEvBC,CAFuB,CAGvBC,CAHuB,CAIvBd,CAJuB,CAKvBF,CALuB,CAMvBJ,CANuB,GAOe,CACtC,GAAIoB,CAAJ,CAAgB,CAMd,MAAO1D,CAAAA,eAAe,CACpBwD,CADoB,CALMvC,CAAD,EAAgB,CACzC,KAAMK,CAAAA,CAAI,CAAGoB,CAAW,CAACzB,CAAD,CAAxB,CACA,MAAOK,CAAAA,CAAI,CAAGlB,UAAU,CAACkB,CAAD,CAAV,CAAiBqC,OAAjB,EAAH,OACZ,CAEqB,eAKpBP,SALoB,CAMpBH,UANoB,CAQvB,CACD,MAAOjD,CAAAA,eAAe,CAACwD,CAAD,CAAQZ,CAAR,CAAsBa,CAAtB,CAA8BnB,CAA9B,QAAqDW,UAArD,CACvB,CAxBM","sourcesContent":["import {\n NotificationsListPropGetActionIcon,\n NotificationsListPropGetActionLabel,\n NotificationsListPropGetActionOnClick,\n NotificationsListPropGetGroupId,\n NotificationsListPropGetGroupLabel,\n NotificationsListPropGetItemActions,\n NotificationsListPropGetItemBadges,\n NotificationsListPropGetItemDate,\n NotificationsListPropGetItemDescription,\n NotificationsListPropGetItemGroup,\n NotificationsListPropGetItemImage,\n NotificationsListPropGetItemLabel,\n NotificationsListPropGetItemRead,\n NotificationsListPropGetItemView,\n NotificationsDefaultAction,\n NotificationsDefaultGroup,\n NotificationsDefaultItem,\n NotificationsListProps,\n NotificationsListPropGroupLabelFormat,\n} from './types'\n\nimport { getGroups as constaGetGroups } from '@consta/uikit/__internal__/src/utils/getGroups'\nimport { format, isToday, isYesterday, startOfDay } from 'date-fns'\n\nconst defaultGetActionIcon: NotificationsListPropGetActionIcon<NotificationsDefaultAction> = action =>\n action.icon\nconst defaultGetActionLabel: NotificationsListPropGetActionLabel<NotificationsDefaultAction> = action =>\n action.label\nconst defaultGetActionOnClick: NotificationsListPropGetActionOnClick<NotificationsDefaultAction> = action =>\n action.onClick\nconst defaultGetGroupId: NotificationsListPropGetGroupId<NotificationsDefaultGroup> = group =>\n group.id\nconst defaultGetGroupLabel: NotificationsListPropGetGroupLabel<NotificationsDefaultGroup> = group =>\n group.label\nconst defaultGetItemActions: NotificationsListPropGetItemActions<NotificationsDefaultItem> = item =>\n item.actions\nconst defaultGetItemBadges: NotificationsListPropGetItemBadges<NotificationsDefaultItem> = item =>\n item.badges\nconst defaultGetItemDate: NotificationsListPropGetItemDate<NotificationsDefaultItem> = item =>\n item.date\nconst defaultGetItemDescription: NotificationsListPropGetItemDescription<NotificationsDefaultItem> = item =>\n item.description\nconst defaultGetItemGroup: NotificationsListPropGetItemGroup<NotificationsDefaultItem> = item =>\n item.group\nconst defaultGetItemImage: NotificationsListPropGetItemImage<NotificationsDefaultItem> = item =>\n item.image\nconst defaultGetItemLabel: NotificationsListPropGetItemLabel<NotificationsDefaultItem> = item =>\n item.label\nconst defaultGetItemRead: NotificationsListPropGetItemRead<NotificationsDefaultItem> = item =>\n item.read\nconst defaultGetItemView: NotificationsListPropGetItemView<NotificationsDefaultItem> = item =>\n item.view\n\nexport function withDefaultGetters<ITEM, GROUP, ACTION>(\n props: NotificationsListProps<ITEM, GROUP, ACTION>\n) {\n return {\n ...props,\n getActionIcon: props.getActionIcon || defaultGetActionIcon,\n getActionLabel: props.getActionLabel || defaultGetActionLabel,\n getActionOnClick: props.getActionOnClick || defaultGetActionOnClick,\n getGroupId: props.getGroupId || defaultGetGroupId,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getItemActions: props.getItemActions || defaultGetItemActions,\n getItemBadges: props.getItemBadges || defaultGetItemBadges,\n getItemDate: props.getItemDate || defaultGetItemDate,\n getItemDescription: props.getItemDescription || defaultGetItemDescription,\n getItemGroup: props.getItemGroup || defaultGetItemGroup,\n getItemImage: props.getItemImage || defaultGetItemImage,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemRead: props.getItemRead || defaultGetItemRead,\n getItemView: props.getItemView || defaultGetItemView,\n }\n}\n\ntype ReturnedGroup<ITEM, GROUP> = {\n items: ITEM[]\n key: string | number\n group?: GROUP\n groupIndex: number\n}\n\nexport const noGroupKey = 'no-group'\n\nexport const defaultGroupLabelFormat: NotificationsListPropGroupLabelFormat<true> = timestamp => {\n if (isToday(timestamp)) {\n return 'Сегодня'\n }\n if (isYesterday(timestamp)) {\n return 'Вчера'\n }\n return format(timestamp, 'dd.MM.yyyy')\n}\n\nconst sortGroup = (a: { key: string | number }, b: { key: string | number }) => {\n if (a.key < b.key) {\n return 1\n }\n if (a.key > b.key) {\n return -1\n }\n return 0\n}\n\nexport const getGroups = <ITEM, GROUP>(\n items: ITEM[],\n groups: GROUP[] | undefined,\n groupByDay: boolean,\n getItemGroup: NotificationsListPropGetItemGroup<ITEM>,\n getItemDate: NotificationsListPropGetItemDate<ITEM>,\n getGroupId: NotificationsListPropGetGroupId<GROUP>\n): Array<ReturnedGroup<ITEM, GROUP>> => {\n if (groupByDay) {\n const getItemGroupByDate = (item: ITEM) => {\n const date = getItemDate(item)\n return date ? startOfDay(date).getTime() : undefined\n }\n\n return constaGetGroups<ITEM, GROUP>(\n items,\n getItemGroupByDate,\n undefined,\n undefined,\n sortGroup,\n noGroupKey\n )\n }\n return constaGetGroups(items, getItemGroup, groups, getGroupId, undefined, noGroupKey)\n}\n"],"file":"helpers.js"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { BadgePropStatus } from '@consta/uikit/Badge';
|
|
3
3
|
import { IconProps } from '@consta/uikit/Icon';
|
|
4
4
|
import { PropsWithHTMLAttributesAndRef } from "../__private__/utils/types/PropsWithHTMLAttributes";
|
|
5
|
-
export declare type
|
|
5
|
+
export declare type NotificationsDefaultAction = {
|
|
6
6
|
label: string;
|
|
7
7
|
onClick?: React.EventHandler<React.MouseEvent>;
|
|
8
8
|
icon?: React.FC<IconProps>;
|
|
@@ -11,18 +11,18 @@ export declare type Badge = {
|
|
|
11
11
|
label: string;
|
|
12
12
|
status?: BadgePropStatus;
|
|
13
13
|
};
|
|
14
|
-
export declare type
|
|
14
|
+
export declare type NotificationsDefaultGroup = {
|
|
15
15
|
label: string;
|
|
16
16
|
id: string;
|
|
17
17
|
};
|
|
18
|
-
export declare type
|
|
18
|
+
export declare type NotificationsDefaultItem = {
|
|
19
19
|
label: string;
|
|
20
20
|
description?: string;
|
|
21
21
|
image?: string;
|
|
22
22
|
read?: boolean;
|
|
23
23
|
date?: Date;
|
|
24
24
|
badges?: Badge[];
|
|
25
|
-
actions?:
|
|
25
|
+
actions?: NotificationsDefaultAction[];
|
|
26
26
|
onClick?: React.EventHandler<React.MouseEvent>;
|
|
27
27
|
group?: string;
|
|
28
28
|
view?: 'default' | 'user';
|
|
@@ -33,7 +33,7 @@ export declare type NotificationsListPropGetItemImage<ITEM> = (item: ITEM) => st
|
|
|
33
33
|
export declare type NotificationsListPropGetItemRead<ITEM> = (item: ITEM) => boolean | undefined;
|
|
34
34
|
export declare type NotificationsListPropGetItemDate<ITEM> = (item: ITEM) => Date | undefined;
|
|
35
35
|
export declare type NotificationsListPropGetItemBadges<ITEM> = (item: ITEM) => Badge[] | undefined;
|
|
36
|
-
export declare type NotificationsListPropGetItemActions<ITEM> = (item: ITEM) =>
|
|
36
|
+
export declare type NotificationsListPropGetItemActions<ITEM> = (item: ITEM) => NotificationsDefaultAction[] | undefined;
|
|
37
37
|
export declare type NotificationsListPropGetItemGroup<ITEM> = (item: ITEM) => string | undefined;
|
|
38
38
|
export declare type NotificationsListPropGetItemView<ITEM> = (item: ITEM) => 'default' | 'user' | undefined;
|
|
39
39
|
export declare type NotificationsListPropItemDateFormat = (date: Date) => string;
|
|
@@ -68,21 +68,21 @@ export declare type Props<ITEM, GROUP, ACTION, GROUP_BY_DAY extends boolean> = {
|
|
|
68
68
|
groups?: GROUP_BY_DAY extends true ? never : GROUP[];
|
|
69
69
|
onClose?: React.EventHandler<React.MouseEvent>;
|
|
70
70
|
} & (ACTION extends {
|
|
71
|
-
label:
|
|
71
|
+
label: NotificationsDefaultAction['label'];
|
|
72
72
|
} ? {} : {
|
|
73
73
|
getActionLabel: NotificationsListPropGetItemActions<ACTION>;
|
|
74
74
|
}) & (GROUP extends {
|
|
75
|
-
label:
|
|
75
|
+
label: NotificationsDefaultGroup['label'];
|
|
76
76
|
} ? {} : {
|
|
77
77
|
getGroupLabel: NotificationsListPropGetGroupLabel<GROUP>;
|
|
78
78
|
}) & (GROUP extends {
|
|
79
|
-
id:
|
|
79
|
+
id: NotificationsDefaultGroup['id'];
|
|
80
80
|
} ? {} : {
|
|
81
81
|
getGroupId: NotificationsListPropGetGroupId<GROUP>;
|
|
82
82
|
}) & (ITEM extends {
|
|
83
|
-
label:
|
|
83
|
+
label: NotificationsDefaultItem['label'];
|
|
84
84
|
} ? {} : {
|
|
85
85
|
getItemLabel: NotificationsListPropGetItemLabel<ITEM>;
|
|
86
86
|
});
|
|
87
|
-
export declare type NotificationsListProps<ITEM =
|
|
88
|
-
export declare type NotificationsListComponent = <ITEM =
|
|
87
|
+
export declare type NotificationsListProps<ITEM = NotificationsDefaultItem, GROUP = NotificationsDefaultGroup, ACTION = NotificationsDefaultAction, GROUP_BY_DAY extends boolean = false> = PropsWithHTMLAttributesAndRef<Props<ITEM, GROUP, ACTION, GROUP_BY_DAY>, HTMLDivElement>;
|
|
88
|
+
export declare type NotificationsListComponent = <ITEM = NotificationsDefaultItem, GROUP = NotificationsDefaultGroup, ACTION = NotificationsDefaultAction, GROUP_BY_DAY extends boolean = false>(props: NotificationsListProps<ITEM, GROUP, ACTION, GROUP_BY_DAY>) => React.ReactElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.che--SelectMenu{display:inline-flex;align-items:center;cursor:pointer}.che--SelectMenu-Label{flex:1}.che--SelectMenu-ArrowBox{display:flex;align-items:center;flex:none;justify-content:center;width:var(--space-2xl);height:var(--space-2xl);color:var(--color-control-typo-placeholder)}.che--SelectMenu-ArrowBox_open{transform:rotate(180deg)}.che--SelectMenu-Menu{overflow:auto;max-height:360px}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import _jsx from"@babel/runtime/helpers/jsx";import _objectSpread from"@babel/runtime/helpers/objectSpread";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React,{useRef,useCallback,forwardRef}from"react";import{cn}from"../__private__/utils/bem";import{withDefaultGetters}from"./helpers";import"./SelectMenu.css";import{Text}from"@consta/uikit/Text";import{IconSelect}from"@consta/uikit/IconSelect";import{useFlag}from"@consta/uikit/useFlag";import{useMutableRef}from"@consta/uikit/useMutableRef";import{useForkRef}from"@consta/uikit/useForkRef";import{AnimatedContextMenu}from"../__private__/AnimatedContextMenu/AnimatedContextMenu";export const cnSelectMenu=cn("SelectMenu");var _ref=_jsx(IconSelect,{size:"xs"});const SelectMenuRender=(a,b)=>{const c=withDefaultGetters(a),{items:d,className:e,getItemHref:f,getItemLabel:g,getItemOnClick:h,getItemTarget:i,onItemClick:j,label:k,onClick:l,getItemSubMenu:m,style:n}=c,o=_objectWithoutProperties(c,["items","className","getItemHref","getItemLabel","getItemOnClick","getItemTarget","onItemClick","label","onClick","getItemSubMenu","style"]),[p,q]=useFlag(),r=useRef(null),s=useMutableRef(f),t=useMutableRef(i),u=useMutableRef(l),v=useCallback(a=>s.current(a)?"a":"span",[]),w=useCallback(a=>{const b=s.current(a),c=t.current(a);return _objectSpread({},b&&{href:s.current(a)},c&&{href:t.current(a)})},[]),x=useCallback(a=>{var b;null===(b=u.current)||void 0===b?void 0:b.call(u,a),q.toogle()},[]);return React.createElement(React.Fragment,null,React.createElement("div",Object.assign({},o,{className:cnSelectMenu(null,[e]),ref:useForkRef([r,b]),onClick:x,style:n}),_jsx(Text,{className:cnSelectMenu("Label"),size:"s"},void 0,k),_jsx("span",{className:cnSelectMenu("ArrowBox",{open:p})},void 0,_ref)),d&&_jsx(AnimatedContextMenu,{className:cnSelectMenu("Menu"),anchorRef:r,isOpen:p,items:d,getLabel:g,getItemOnClick:h,getItemAs:v,getItemHTMLAttributes:w,onClickOutside:q.off,onItemClick:j,direction:"rightStartDown",possibleDirections:["downStartLeft","upStartLeft","downStartRight","upStartRight"],getSubItems:m,style:{zIndex:"number"==typeof(null===n||void 0===n?void 0:n.zIndex)?n.zIndex+1:"auto"}}))};export const SelectMenu=forwardRef(SelectMenuRender);export*from"./types";
|
|
2
|
+
//# sourceMappingURL=SelectMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SelectMenu/SelectMenu.tsx"],"names":["React","useRef","useCallback","forwardRef","cn","withDefaultGetters","Text","IconSelect","useFlag","useMutableRef","useForkRef","AnimatedContextMenu","cnSelectMenu","SelectMenuRender","props","componentRef","items","className","getItemHref","getItemLabel","getItemOnClick","getItemTarget","onItemClick","label","onClick","onClickProp","getItemSubMenu","style","otherProps","open","setOpen","ref","getItemHrefRef","getItemTargetRef","onClickRef","getItemAs","item","current","getItemHTMLAttributes","href","target","e","toogle","off","zIndex","SelectMenu"],"mappings":"iMAAA,MAAOA,CAAAA,KAAP,EAAgBC,MAAhB,CAAwBC,WAAxB,CAAqCC,UAArC,KAAuD,OAAvD,CAEA,OAASC,EAAT,gCAEA,OAASC,kBAAT,iBAEA,yBACA,OAASC,IAAT,KAAqB,oBAArB,CACA,OAASC,UAAT,KAA2B,0BAA3B,CACA,OAASC,OAAT,KAAwB,uBAAxB,CACA,OAASC,aAAT,KAA8B,6BAA9B,CACA,OAASC,UAAT,KAA2B,0BAA3B,CACA,OAASC,mBAAT,8DAEA,MAAO,MAAMC,CAAAA,YAAY,CAAGR,EAAE,CAAC,YAAD,CAAvB,C,SA6DG,KAAC,UAAD,EAAY,IAAI,CAAC,IAAjB,E,CA3DV,KAAMS,CAAAA,gBAAgB,CAAG,CAACC,CAAD,CAAyBC,CAAzB,GAAqE,SAcxFV,kBAAkB,CAACS,CAAD,CAdsE,CACtF,CACJE,KAAK,CAALA,CADI,CAEJC,SAAS,CAATA,CAFI,CAGJC,WAAW,CAAXA,CAHI,CAIJC,YAAY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EAEE,SAAS,CAAEhB,YAAY,CAAC,IAAD,CAAO,CAACK,CAAD,CAAP,CAFzB,CAGE,GAAG,CAAEP,UAAU,CAAC,CAACqB,CAAD,CAAMhB,CAAN,CAAD,CAHjB,CAIE,OAAO,CAAES,CAJX,CAKE,KAAK,CAAEG,CALT,GAOE,KAAC,IAAD,EAAM,SAAS,CAAEf,YAAY,CAAC,OAAD,CAA7B,CAAwC,IAAI,CAAC,GAA7C,SACGW,CADH,CAPF,CAUE,aAAM,SAAS,CAAEX,YAAY,CAAC,UAAD,CAAa,CAAEiB,IAAI,CAAJA,CAAF,CAAb,CAA7B,cAVF,CADF,CAeGb,CAAK,EACJ,KAAC,mBAAD,EACE,SAAS,CAAEJ,YAAY,CAAC,MAAD,CADzB,CAEE,SAAS,CAAEmB,CAFb,CAGE,MAAM,CAAEF,CAHV,CAIE,KAAK,CAAEb,CAJT,CAKE,QAAQ,CAAEG,CALZ,CAME,cAAc,CAAEC,CANlB,CAOE,SAAS,CAAEe,CAPb,CAQE,qBAAqB,CAAEG,CARzB,CASE,cAAc,CAAER,CAAO,CAACa,GAT1B,CAUE,WAAW,CAAErB,CAVf,CAWE,SAAS,CAAC,gBAXZ,CAYE,kBAAkB,CAAE,CAAC,eAAD,CAAkB,aAAlB,CAAiC,gBAAjC,CAAmD,cAAnD,CAZtB,CAaE,WAAW,CAAEI,CAbf,CAcE,KAAK,CAAE,CAAEkB,MAAM,CAA2B,QAAzB,gBAAOjB,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAEiB,MAAd,EAAoCjB,CAAK,CAACiB,MAAN,CAAe,CAAnD,CAAuD,MAAjE,CAdT,EAhBJ,CAmCH,CAlFD,CAoFA,MAAO,MAAMC,CAAAA,UAAU,CAAG1C,UAAU,CAACU,gBAAD,CAA7B,CAEP","sourcesContent":["import React, { useRef, useCallback, forwardRef } from 'react'\n\nimport { cn } from '@/__private__/utils/bem'\n\nimport { withDefaultGetters } from './helpers'\nimport { SelectMenuComponent, SelectMenuProps, SelectMenuDefaultItem } from './types'\nimport './SelectMenu.css'\nimport { Text } from '@consta/uikit/Text'\nimport { IconSelect } from '@consta/uikit/IconSelect'\nimport { useFlag } from '@consta/uikit/useFlag'\nimport { useMutableRef } from '@consta/uikit/useMutableRef'\nimport { useForkRef } from '@consta/uikit/useForkRef'\nimport { AnimatedContextMenu } from '@/__private__/AnimatedContextMenu/AnimatedContextMenu'\n\nexport const cnSelectMenu = cn('SelectMenu')\n\nconst SelectMenuRender = (props: SelectMenuProps, componentRef: React.Ref<HTMLDivElement>) => {\n const {\n items,\n className,\n getItemHref,\n getItemLabel,\n getItemOnClick,\n getItemTarget,\n onItemClick,\n label,\n onClick: onClickProp,\n getItemSubMenu,\n style,\n ...otherProps\n } = withDefaultGetters(props)\n\n const [open, setOpen] = useFlag()\n\n const ref = useRef<HTMLDivElement>(null)\n\n const getItemHrefRef = useMutableRef(getItemHref)\n const getItemTargetRef = useMutableRef(getItemTarget)\n const onClickRef = useMutableRef(onClickProp)\n\n const getItemAs = useCallback((item: SelectMenuDefaultItem) => {\n if (!!getItemHrefRef.current(item)) {\n return 'a'\n }\n return 'span'\n }, [])\n\n const getItemHTMLAttributes = useCallback((item: SelectMenuDefaultItem) => {\n const href = getItemHrefRef.current(item)\n const target = getItemTargetRef.current(item)\n\n return {\n ...(href && { href: getItemHrefRef.current(item) }),\n ...(target && { href: getItemTargetRef.current(item) }),\n }\n }, [])\n\n const onClick = useCallback((e: React.MouseEvent<HTMLDivElement>) => {\n onClickRef.current?.(e)\n setOpen.toogle()\n }, [])\n\n return (\n <>\n <div\n {...otherProps}\n className={cnSelectMenu(null, [className])}\n ref={useForkRef([ref, componentRef])}\n onClick={onClick}\n style={style}\n >\n <Text className={cnSelectMenu('Label')} size=\"s\">\n {label}\n </Text>\n <span className={cnSelectMenu('ArrowBox', { open })}>\n <IconSelect size=\"xs\" />\n </span>\n </div>\n {items && (\n <AnimatedContextMenu\n className={cnSelectMenu('Menu')}\n anchorRef={ref}\n isOpen={open}\n items={items}\n getLabel={getItemLabel}\n getItemOnClick={getItemOnClick}\n getItemAs={getItemAs}\n getItemHTMLAttributes={getItemHTMLAttributes}\n onClickOutside={setOpen.off}\n onItemClick={onItemClick}\n direction=\"rightStartDown\"\n possibleDirections={['downStartLeft', 'upStartLeft', 'downStartRight', 'upStartRight']}\n getSubItems={getItemSubMenu}\n style={{ zIndex: typeof style?.zIndex === 'number' ? style.zIndex + 1 : 'auto' }}\n />\n )}\n </>\n )\n}\n\nexport const SelectMenu = forwardRef(SelectMenuRender) as SelectMenuComponent\n\nexport * from './types'\n"],"file":"SelectMenu.js"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SelectMenuDefaultItem, SelectMenuProps, SelectMenuPropGetItemHref, SelectMenuPropGetItemLabel, SelectMenuPropGetItemOnClick, SelectMenuPropGetItemTarget, SelectMenuPropGetItemSubMenu } from "./types";
|
|
3
|
+
export declare const defaultGetItemLabel: SelectMenuPropGetItemLabel<SelectMenuDefaultItem>;
|
|
4
|
+
export declare const defaultGetItemHref: SelectMenuPropGetItemHref<SelectMenuDefaultItem>;
|
|
5
|
+
export declare const defaultGetItemOnClick: SelectMenuPropGetItemOnClick<SelectMenuDefaultItem>;
|
|
6
|
+
export declare const defaultGetItemTarget: SelectMenuPropGetItemTarget<SelectMenuDefaultItem>;
|
|
7
|
+
export declare const defaultGetItemSubMenu: SelectMenuPropGetItemSubMenu<SelectMenuDefaultItem>;
|
|
8
|
+
export declare const getGetters: <ITEM>(props: {
|
|
9
|
+
getItemLabel?: SelectMenuPropGetItemLabel<ITEM> | undefined;
|
|
10
|
+
getItemHref?: SelectMenuPropGetItemHref<ITEM> | undefined;
|
|
11
|
+
getItemOnClick?: SelectMenuPropGetItemOnClick<ITEM> | undefined;
|
|
12
|
+
getItemTarget?: SelectMenuPropGetItemTarget<ITEM> | undefined;
|
|
13
|
+
getItemSubMenu?: SelectMenuPropGetItemSubMenu<ITEM> | undefined;
|
|
14
|
+
}) => {
|
|
15
|
+
getItemLabel: SelectMenuPropGetItemLabel<SelectMenuDefaultItem> | SelectMenuPropGetItemLabel<ITEM>;
|
|
16
|
+
getItemHref: SelectMenuPropGetItemHref<SelectMenuDefaultItem> | SelectMenuPropGetItemHref<ITEM>;
|
|
17
|
+
getItemOnClick: SelectMenuPropGetItemOnClick<SelectMenuDefaultItem> | SelectMenuPropGetItemOnClick<ITEM>;
|
|
18
|
+
getItemTarget: SelectMenuPropGetItemTarget<SelectMenuDefaultItem> | SelectMenuPropGetItemTarget<ITEM>;
|
|
19
|
+
getItemSubMenu: SelectMenuPropGetItemSubMenu<SelectMenuDefaultItem> | SelectMenuPropGetItemSubMenu<ITEM>;
|
|
20
|
+
};
|
|
21
|
+
export declare function withDefaultGetters<ITEM>(props: SelectMenuProps<ITEM>): {
|
|
22
|
+
items: ITEM[];
|
|
23
|
+
onItemClick?: import("./types").SelectMenuPropOnItemClick<ITEM> | undefined;
|
|
24
|
+
getItemHref?: SelectMenuPropGetItemHref<ITEM> | undefined;
|
|
25
|
+
getItemLabel?: SelectMenuPropGetItemLabel<ITEM> | undefined;
|
|
26
|
+
getItemTarget?: SelectMenuPropGetItemTarget<ITEM> | undefined;
|
|
27
|
+
getItemOnClick?: SelectMenuPropGetItemOnClick<ITEM> | undefined;
|
|
28
|
+
getItemSubMenu?: SelectMenuPropGetItemSubMenu<ITEM> | undefined;
|
|
29
|
+
label: string;
|
|
30
|
+
} & Pick<import("react").HTMLAttributes<HTMLDivElement>, "hidden" | "dir" | "slot" | "style" | "title" | "color" | "children" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "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" | "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"> & import("react").RefAttributes<HTMLDivElement> & (ITEM extends {
|
|
31
|
+
label: string;
|
|
32
|
+
} ? {} : {
|
|
33
|
+
getItemLabel: SelectMenuPropGetItemLabel<ITEM>;
|
|
34
|
+
}) & {
|
|
35
|
+
getItemLabel: SelectMenuPropGetItemLabel<SelectMenuDefaultItem> | SelectMenuPropGetItemLabel<ITEM>;
|
|
36
|
+
getItemHref: SelectMenuPropGetItemHref<SelectMenuDefaultItem> | SelectMenuPropGetItemHref<ITEM>;
|
|
37
|
+
getItemOnClick: SelectMenuPropGetItemOnClick<SelectMenuDefaultItem> | SelectMenuPropGetItemOnClick<ITEM>;
|
|
38
|
+
getItemTarget: SelectMenuPropGetItemTarget<SelectMenuDefaultItem> | SelectMenuPropGetItemTarget<ITEM>;
|
|
39
|
+
getItemSubMenu: SelectMenuPropGetItemSubMenu<SelectMenuDefaultItem> | SelectMenuPropGetItemSubMenu<ITEM>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import _objectSpread from"@babel/runtime/helpers/objectSpread";export const defaultGetItemLabel=a=>a.label;export const defaultGetItemHref=a=>a.href;export const defaultGetItemOnClick=a=>a.onClick;export const defaultGetItemTarget=a=>a.target;export const defaultGetItemSubMenu=a=>a.subMenu;export const getGetters=a=>({getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemHref:a.getItemHref||defaultGetItemHref,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick,getItemTarget:a.getItemTarget||defaultGetItemTarget,getItemSubMenu:a.getItemSubMenu||defaultGetItemSubMenu});export function withDefaultGetters(a){return _objectSpread({},a,getGetters(a))}
|
|
2
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SelectMenu/helpers.ts"],"names":["defaultGetItemLabel","item","label","defaultGetItemHref","href","defaultGetItemOnClick","onClick","defaultGetItemTarget","target","defaultGetItemSubMenu","subMenu","getGetters","props","getItemLabel","getItemHref","getItemOnClick","getItemTarget","getItemSubMenu","withDefaultGetters"],"mappings":"+DAUA,MAAO,MAAMA,CAAAA,mBAAsE,CAAGC,CAAI,EACxFA,CAAI,CAACC,KADA,CAEP,MAAO,MAAMC,CAAAA,kBAAoE,CAAGF,CAAI,EACtFA,CAAI,CAACG,IADA,CAEP,MAAO,MAAMC,CAAAA,qBAA0E,CAAGJ,CAAI,EAC5FA,CAAI,CAACK,OADA,CAEP,MAAO,MAAMC,CAAAA,oBAAwE,CAAGN,CAAI,EAC1FA,CAAI,CAACO,MADA,CAEP,MAAO,MAAMC,CAAAA,qBAA0E,CAAGR,CAAI,EAC5FA,CAAI,CAACS,OADA,CAGP,MAAO,MAAMC,CAAAA,UAAU,CAAUC,CAAP,GAOjB,CACLC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBb,mBAD/B,CAELc,WAAW,CAAEF,CAAK,CAACE,WAAN,EAAqBX,kBAF7B,CAGLY,cAAc,CAAEH,CAAK,CAACG,cAAN,EAAwBV,qBAHnC,CAILW,aAAa,CAAEJ,CAAK,CAACI,aAAN,EAAuBT,oBAJjC,CAKLU,cAAc,CAAEL,CAAK,CAACK,cAAN,EAAwBR,qBALnC,CAPiB,CAAnB,CAgBP,MAAO,SAASS,CAAAA,kBAAT,CAAkCN,CAAlC,CAAgE,CACrE,wBACKA,CADL,CAEKD,UAAU,CAACC,CAAD,CAFf,CAID","sourcesContent":["import {\n SelectMenuDefaultItem,\n SelectMenuProps,\n SelectMenuPropGetItemHref,\n SelectMenuPropGetItemLabel,\n SelectMenuPropGetItemOnClick,\n SelectMenuPropGetItemTarget,\n SelectMenuPropGetItemSubMenu,\n} from './types'\n\nexport const defaultGetItemLabel: SelectMenuPropGetItemLabel<SelectMenuDefaultItem> = item =>\n item.label\nexport const defaultGetItemHref: SelectMenuPropGetItemHref<SelectMenuDefaultItem> = item =>\n item.href\nexport const defaultGetItemOnClick: SelectMenuPropGetItemOnClick<SelectMenuDefaultItem> = item =>\n item.onClick\nexport const defaultGetItemTarget: SelectMenuPropGetItemTarget<SelectMenuDefaultItem> = item =>\n item.target\nexport const defaultGetItemSubMenu: SelectMenuPropGetItemSubMenu<SelectMenuDefaultItem> = item =>\n item.subMenu\n\nexport const getGetters = <ITEM>(props: {\n getItemLabel?: SelectMenuPropGetItemLabel<ITEM>\n getItemHref?: SelectMenuPropGetItemHref<ITEM>\n getItemOnClick?: SelectMenuPropGetItemOnClick<ITEM>\n getItemTarget?: SelectMenuPropGetItemTarget<ITEM>\n getItemSubMenu?: SelectMenuPropGetItemSubMenu<ITEM>\n}) => {\n return {\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemHref: props.getItemHref || defaultGetItemHref,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n getItemTarget: props.getItemTarget || defaultGetItemTarget,\n getItemSubMenu: props.getItemSubMenu || defaultGetItemSubMenu,\n }\n}\n\nexport function withDefaultGetters<ITEM>(props: SelectMenuProps<ITEM>) {\n return {\n ...props,\n ...getGetters(props),\n }\n}\n"],"file":"helpers.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SelectMenu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/SelectMenu/index.ts"],"names":[],"mappings":"AAAA","sourcesContent":["export * from './SelectMenu'\n"],"file":"index.js"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PropsWithHTMLAttributesAndRef } from "../__private__/utils/types/PropsWithHTMLAttributes";
|
|
3
|
+
export declare type SelectMenuDefaultItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
target?: string;
|
|
7
|
+
onClick?: React.EventHandler<React.MouseEvent>;
|
|
8
|
+
subMenu?: SelectMenuDefaultItem[];
|
|
9
|
+
};
|
|
10
|
+
export declare type SelectMenuPropGetItemLabel<ITEM> = (item: ITEM) => string;
|
|
11
|
+
export declare type SelectMenuPropGetItemHref<ITEM> = (item: ITEM) => string | undefined;
|
|
12
|
+
export declare type SelectMenuPropGetItemTarget<ITEM> = (item: ITEM) => string | undefined;
|
|
13
|
+
export declare type SelectMenuPropGetItemOnClick<ITEM> = (item: ITEM) => React.EventHandler<React.MouseEvent> | undefined;
|
|
14
|
+
export declare type SelectMenuPropOnItemClick<ITEM> = (props: {
|
|
15
|
+
e: React.MouseEvent;
|
|
16
|
+
item: ITEM;
|
|
17
|
+
}) => void;
|
|
18
|
+
export declare type SelectMenuPropGetItemSubMenu<ITEM> = (item: ITEM) => ITEM[] | undefined;
|
|
19
|
+
export declare type SelectMenuProps<ITEM = SelectMenuDefaultItem> = PropsWithHTMLAttributesAndRef<{
|
|
20
|
+
items: ITEM[];
|
|
21
|
+
onItemClick?: SelectMenuPropOnItemClick<ITEM>;
|
|
22
|
+
getItemHref?: SelectMenuPropGetItemHref<ITEM>;
|
|
23
|
+
getItemLabel?: SelectMenuPropGetItemLabel<ITEM>;
|
|
24
|
+
getItemTarget?: SelectMenuPropGetItemTarget<ITEM>;
|
|
25
|
+
getItemOnClick?: SelectMenuPropGetItemOnClick<ITEM>;
|
|
26
|
+
getItemSubMenu?: SelectMenuPropGetItemSubMenu<ITEM>;
|
|
27
|
+
label: string;
|
|
28
|
+
}, HTMLDivElement> & (ITEM extends {
|
|
29
|
+
label: SelectMenuDefaultItem['label'];
|
|
30
|
+
} ? {} : {
|
|
31
|
+
getItemLabel: SelectMenuPropGetItemLabel<ITEM>;
|
|
32
|
+
});
|
|
33
|
+
export declare type SelectMenuComponent = <ITEM = SelectMenuDefaultItem>(props: SelectMenuProps<ITEM>) => React.ReactElement | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
|
package/TileMenu/TileMenu.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React,{forwardRef,useRef,useState
|
|
1
|
+
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React,{forwardRef,useRef,useState}from"react";import{cn}from"../__private__/utils/bem";import{IconBento}from"@consta/uikit/IconBento";import{Button}from"@consta/uikit/Button";import{Transition}from"react-transition-group";import{useFlag}from"@consta/uikit/useFlag";import{useForkRef}from"@consta/uikit/useForkRef";import{Popover}from"@consta/uikit/Popover";import{cnMixPopoverArrow}from"../__private__/mixs/MixPopoverArrow/MixPopoverArrow";import{Sidebar}from"../__private__/components/Sidebar";import{tileMenuPropViewDefault}from"./types";import{cnMixPopoverAnimate,animateTimeout}from"@consta/uikit/MixPopoverAnimate";import{TileMenuList}from"./TileMenuList/TileMenuList";import"./TileMenu.css";export const cnTileMenu=cn("TileMenu");const ARROW_SIZE=6,ARROW_OFFSET=10;function TileMenuRender(a,b){var c;const{view:p=tileMenuPropViewDefault,items:d,isMobile:e,className:f,children:g,listClassName:h,getItemDescription:i,getItemHref:j,getItemImage:k,getItemOnClick:l,getItemLabel:m,title:n,onItemClick:o}=a,q=_objectWithoutProperties(a,["view","items","isMobile","className","children","listClassName","getItemDescription","getItemHref","getItemImage","getItemOnClick","getItemLabel","title","onItemClick"]),r=useRef(null),[s,t]=useState(void 0),[u,{toogle:v,off:w}]=useFlag(),x={className:h,getItemDescription:i,getItemHref:j,getItemImage:k,getItemOnClick:l,getItemLabel:m,items:d,view:p,onItemClick:o},y="number"==typeof(null===(c=a.style)||void 0===c?void 0:c.zIndex)?a.style.zIndex+1:void 0;return React.createElement(React.Fragment,null,React.createElement(Button,Object.assign({},q,{size:"s",view:"clear",className:cnTileMenu(null,[f]),iconLeft:IconBento,ref:useForkRef([b,r]),onClick:v})),e?_jsx(Sidebar,{isOpen:u,onClickOutside:w,onClose:w,title:n,style:{zIndex:y}},void 0,React.createElement(TileMenuList,x)):_jsx(Transition,{timeout:animateTimeout,unmountOnExit:!0,in:u},void 0,a=>_jsx(Popover,{className:cnTileMenu("Popover",{view:p},[cnMixPopoverAnimate({animate:a,direction:s})]),anchorRef:r,arrowOffset:ARROW_OFFSET+ARROW_SIZE,offset:10,onSetDirection:t,style:{"--popover-arrow-size":`${ARROW_SIZE}px`,"--popover-arrow-offset":`${ARROW_OFFSET}px`,zIndex:y},onClickOutside:w},void 0,_jsx("div",{className:cnMixPopoverArrow({direction:s})}),_jsx("div",{className:cnTileMenu("ListWrapper")},void 0,React.createElement(TileMenuList,x)))))}export const TileMenu=forwardRef(TileMenuRender);export*from"./types";
|
|
2
2
|
//# sourceMappingURL=TileMenu.js.map
|
package/TileMenu/TileMenu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TileMenu/TileMenu.tsx"],"names":["React","forwardRef","useRef","useState","
|
|
1
|
+
{"version":3,"sources":["../../src/TileMenu/TileMenu.tsx"],"names":["React","forwardRef","useRef","useState","cn","IconBento","Button","Transition","useFlag","useForkRef","Popover","cnMixPopoverArrow","Sidebar","tileMenuPropViewDefault","cnMixPopoverAnimate","animateTimeout","TileMenuList","cnTileMenu","ARROW_SIZE","ARROW_OFFSET","TileMenuRender","props","ref","view","items","isMobile","className","children","listClassName","getItemDescription","getItemHref","getItemImage","getItemOnClick","getItemLabel","title","onItemClick","otherProps","buttonRef","direction","setDirection","visibleMenu","toogle","off","listProps","elementZIndex","style","zIndex","animate","TileMenu"],"mappings":"kIAAA,MAAOA,CAAAA,KAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,CAAoCC,QAApC,KAAoD,OAApD,CAEA,OAASC,EAAT,gCACA,OAASC,SAAT,KAA0B,yBAA1B,CACA,OAASC,MAAT,KAAuB,sBAAvB,CACA,OAASC,UAAT,KAA2B,wBAA3B,CACA,OAASC,OAAT,KAAwB,uBAAx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AM,CAAEF,CAHH,CART,CAaE,cAAc,CAAEF,CAblB,SAeE,YAAK,SAAS,CAAE/B,iBAAiB,CAAC,CAAE2B,SAAS,CAATA,CAAF,CAAD,CAAjC,EAfF,CAgBE,YAAK,SAAS,CAAErB,UAAU,CAAC,aAAD,CAA1B,SACE,oBAAC,YAAD,CAAkB0B,CAAlB,CADF,CAhBF,CAFJ,CArBJ,CAgDH,CAED,MAAO,MAAMK,CAAAA,QAAQ,CAAG/C,UAAU,CAACmB,cAAD,CAA3B,CAEP","sourcesContent":["import React, { forwardRef, useRef, useState } from 'react'\n\nimport { cn } from '@/__private__/utils/bem'\nimport { IconBento } from '@consta/uikit/IconBento'\nimport { Button } from '@consta/uikit/Button'\nimport { Transition } from 'react-transition-group'\nimport { useFlag } from '@consta/uikit/useFlag'\nimport { useForkRef } from '@consta/uikit/useForkRef'\nimport { Popover, Direction } from '@consta/uikit/Popover'\nimport { cnMixPopoverArrow } from '@/__private__/mixs/MixPopoverArrow/MixPopoverArrow'\nimport { Sidebar } from '@/__private__/components/Sidebar'\nimport { TileMenuProps, tileMenuPropViewDefault, TileMenuComponent } from './types'\nimport { cnMixPopoverAnimate, animateTimeout } from '@consta/uikit/MixPopoverAnimate'\n\nimport { TileMenuList } from './TileMenuList/TileMenuList'\n\nimport './TileMenu.css'\n\nexport const cnTileMenu = cn('TileMenu')\n\nconst ARROW_SIZE = 6\nconst ARROW_OFFSET = 10\n\nfunction TileMenuRender(props: TileMenuProps, ref: React.Ref<HTMLButtonElement>) {\n const {\n view = tileMenuPropViewDefault,\n items,\n isMobile,\n className,\n children,\n listClassName,\n getItemDescription,\n getItemHref,\n getItemImage,\n getItemOnClick,\n getItemLabel,\n title,\n onItemClick,\n ...otherProps\n } = props\n\n const buttonRef = useRef<HTMLButtonElement>(null)\n\n const [direction, setDirection] = useState<Direction | undefined>(undefined)\n\n const [visibleMenu, { toogle, off }] = useFlag()\n\n const listProps = {\n className: listClassName,\n getItemDescription,\n getItemHref,\n getItemImage,\n getItemOnClick,\n getItemLabel,\n items,\n view,\n onItemClick,\n }\n\n const elementZIndex = typeof props.style?.zIndex === 'number' ? props.style.zIndex + 1 : undefined\n\n return (\n <>\n <Button\n {...otherProps}\n size=\"s\"\n view=\"clear\"\n className={cnTileMenu(null, [className])}\n iconLeft={IconBento}\n ref={useForkRef([ref, buttonRef])}\n onClick={toogle}\n />\n {isMobile ? (\n <Sidebar\n isOpen={visibleMenu}\n onClickOutside={off}\n onClose={off}\n title={title}\n style={{ zIndex: elementZIndex }}\n >\n <TileMenuList {...listProps} />\n </Sidebar>\n ) : (\n <Transition timeout={animateTimeout} unmountOnExit in={visibleMenu}>\n {animate => (\n <Popover\n className={cnTileMenu('Popover', { view }, [\n cnMixPopoverAnimate({ animate, direction }),\n ])}\n anchorRef={buttonRef}\n arrowOffset={ARROW_OFFSET + ARROW_SIZE}\n offset={ARROW_SIZE + 4}\n onSetDirection={setDirection}\n style={{\n ['--popover-arrow-size' as string]: `${ARROW_SIZE}px`,\n ['--popover-arrow-offset' as string]: `${ARROW_OFFSET}px`,\n zIndex: elementZIndex,\n }}\n onClickOutside={off}\n >\n <div className={cnMixPopoverArrow({ direction })} />\n <div className={cnTileMenu('ListWrapper')}>\n <TileMenuList {...listProps} />\n </div>\n </Popover>\n )}\n </Transition>\n )}\n </>\n )\n}\n\nexport const TileMenu = forwardRef(TileMenuRender) as TileMenuComponent\n\nexport * from './types'\n"],"file":"TileMenu.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React from"react";import{cn}from"../../__private__/utils/bem";import{withDefaultGetters}from"../helpers";import{TileMenuItem}from"../TileMenuItem/TileMenuItem";import{getByMap}from"@consta/uikit/__internal__/src/utils/getByMap";import{cnMixSpace}from"@consta/uikit/MixSpace";import"./TileMenuList.css";export const cnTileMenuList=cn("TileMenuList");const itemViewMap={lines:"line",twoLines:"line",cards:"card"};export const TileMenuList=a=>{const b=withDefaultGetters(a),{items:c,view:l="lines",className:d,children:e,getItemDescription:f,getItemImage:g,
|
|
1
|
+
import _jsx from"@babel/runtime/helpers/jsx";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import React from"react";import{cn}from"../../__private__/utils/bem";import{withDefaultGetters}from"../helpers";import{TileMenuItem}from"../TileMenuItem/TileMenuItem";import{getByMap}from"@consta/uikit/__internal__/src/utils/getByMap";import{cnMixSpace}from"@consta/uikit/MixSpace";import"./TileMenuList.css";export const cnTileMenuList=cn("TileMenuList");const itemViewMap={lines:"line",twoLines:"line",cards:"card"};export const TileMenuList=a=>{const b=withDefaultGetters(a),{items:c,view:l="lines",className:d,children:e,getItemDescription:f,getItemImage:g,getItemLabel:h,getItemHref:i,getItemOnClick:j,onItemClick:k}=b,m=_objectWithoutProperties(b,["items","view","className","children","getItemDescription","getItemImage","getItemLabel","getItemHref","getItemOnClick","onItemClick"]);return React.createElement("div",Object.assign({},m,{className:cnTileMenuList({view:l},[cnMixSpace({p:"xl"}),d])}),c.map((a,b)=>_jsx(TileMenuItem,{className:cnTileMenuList("Item"),view:getByMap(itemViewMap,l),image:g(a),title:h(a),description:f(a),href:i(a),onClick:b=>{var c;null===k||void 0===k?void 0:k({item:a,e:b}),null===(c=j(a))||void 0===c?void 0:c(b)},as:"a"},cnTileMenuList("Item",{index:b}))))};
|
|
2
2
|
//# sourceMappingURL=TileMenuList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/TileMenu/TileMenuList/TileMenuList.tsx"],"names":["React","cn","withDefaultGetters","TileMenuItem","getByMap","cnMixSpace","cnTileMenuList","itemViewMap","lines","twoLines","cards","TileMenuList","props","items","view","className","children","getItemDescription","getItemImage","
|
|
1
|
+
{"version":3,"sources":["../../../src/TileMenu/TileMenuList/TileMenuList.tsx"],"names":["React","cn","withDefaultGetters","TileMenuItem","getByMap","cnMixSpace","cnTileMenuList","itemViewMap","lines","twoLines","cards","TileMenuList","props","items","view","className","children","getItemDescription","getItemImage","getItemLabel","getItemHref","getItemOnClick","onItemClick","otherProps","p","map","item","index","e"],"mappings":"kIAAA,MAAOA,CAAAA,KAAP,KAAkB,OAAlB,CAEA,OAASC,EAAT,mCAEA,OAASC,kBAAT,kBAEA,OAASC,YAAT,oCACA,OAASC,QAAT,KAAyB,+CAAzB,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,2BAEA,MAAO,MAAMC,CAAAA,cAAc,CAAGL,EAAE,CAAC,cAAD,CAAzB,CAEP,KAAMM,CAAAA,WAAW,CAAG,CAClBC,KAAK,CAAE,MADW,CAElBC,QAAQ,CAAE,MAFQ,CAGlBC,KAAK,CAAE,MAHW,CAApB,CAMA,MAAO,MAAMC,CAAAA,YAAY,CAAKC,CAAD,EAA8B,CACzD,QAYIV,kBAAkB,CAACU,CAAD,CAZtB,CAAM,CACJC,KAAK,CAALA,CADI,CAEJC,IAAI,CAAJA,CAAI,CAAG,OAFH,CAGJC,SAAS,CAATA,CAHI,CAIJC,QAAQ,CAARA,CAJI,CAKJC,kBAAkB,CAAlBA,CALI,CAMJC,YAAY,CAAZA,CANI,CAOJC,YAAY,CAAZA,CAPI,CAQJC,WAAW,CAAXA,CARI,CASJC,cAAc,CAAdA,CATI,CAUJC,WAAW,CAAXA,CAVI,CAAN,GAWKC,CAXL,qKAcA,MACE,4CAASA,CAAT,EAAqB,SAAS,CAAEjB,cAAc,CAAC,CAAEQ,IAAI,CAAJA,CAAF,CAAD,CAAW,CAACT,UAAU,CAAC,CAAEmB,CAAC,CAAE,IAAL,CAAD,CAAX,CAA0BT,CAA1B,CAAX,CAA9C,GACGF,CAAK,CAACY,GAAN,CAAU,CAACC,CAAD,CAAOC,CAAP,GAEP,KAAC,YAAD,EACE,SAAS,CAAErB,cAAc,CAAC,MAAD,CAD3B,CAGE,IAAI,CAAEF,QAAQ,CAACG,WAAD,CAAcO,CAAd,CAHhB,CAIE,KAAK,CAAEI,CAAY,CAACQ,CAAD,CAJrB,CAKE,KAAK,CAAEP,CAAY,CAACO,CAAD,CALrB,CAME,WAAW,CAAET,CAAkB,CAACS,CAAD,CANjC,CAOE,IAAI,CAAEN,CAAW,CAACM,CAAD,CAPnB,CAQE,OAAO,CAAEE,CAAC,EAAI,cACZN,CADY,WACZA,CADY,QACZA,CAAW,CAAG,CAAEI,IAAI,CAAJA,CAAF,CAAQE,CAAC,CAADA,CAAR,CAAH,CADC,WAEZP,CAAc,CAACK,CAAD,CAFF,qBAEZ,EAAuBE,CAAvB,CACD,CAXH,CAYE,EAAE,CAAC,GAZL,EAEOtB,cAAc,CAAC,MAAD,CAAS,CAAEqB,KAAK,CAALA,CAAF,CAAT,CAFrB,CAFH,CADH,CAqBH,CArCM","sourcesContent":["import React from 'react'\n\nimport { cn } from '@/__private__/utils/bem'\nimport { TileMenuListComponent, TileMenuListProps } from '../types'\nimport { withDefaultGetters } from '../helpers'\n\nimport { TileMenuItem } from '../TileMenuItem/TileMenuItem'\nimport { getByMap } from '@consta/uikit/__internal__/src/utils/getByMap'\nimport { cnMixSpace } from '@consta/uikit/MixSpace'\n\nimport './TileMenuList.css'\n\nexport const cnTileMenuList = cn('TileMenuList')\n\nconst itemViewMap = {\n lines: 'line',\n twoLines: 'line',\n cards: 'card',\n} as const\n\nexport const TileMenuList = ((props: TileMenuListProps) => {\n const {\n items,\n view = 'lines',\n className,\n children,\n getItemDescription,\n getItemImage,\n getItemLabel,\n getItemHref,\n getItemOnClick,\n onItemClick,\n ...otherProps\n } = withDefaultGetters(props)\n\n return (\n <div {...otherProps} className={cnTileMenuList({ view }, [cnMixSpace({ p: 'xl' }), className])}>\n {items.map((item, index) => {\n return (\n <TileMenuItem\n className={cnTileMenuList('Item')}\n key={cnTileMenuList('Item', { index })}\n view={getByMap(itemViewMap, view)}\n image={getItemImage(item)}\n title={getItemLabel(item)}\n description={getItemDescription(item)}\n href={getItemHref(item)}\n onClick={e => {\n onItemClick?.({ item, e })\n getItemOnClick(item)?.(e)\n }}\n as=\"a\"\n />\n )\n })}\n </div>\n )\n}) as TileMenuListComponent\n"],"file":"TileMenuList.js"}
|
package/TileMenu/helpers.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TileMenuPropGetItemDescription, TileMenuPropGetItemImage,
|
|
3
|
-
export declare const defaultGetItemImage: TileMenuPropGetItemImage<
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const defaultGetItemHref: TileMenuPropGetItemHref<
|
|
6
|
-
export declare const defaultGetItemOnClick: TileMenuPropGetItemOnClick<
|
|
7
|
-
export declare const defaultGetItemDescription: TileMenuPropGetItemDescription<
|
|
2
|
+
import { TileMenuPropGetItemDescription, TileMenuPropGetItemImage, TileMenuPropGetItemLabel, TileMenuDefaultItem, TileMenuListProps, TileMenuPropGetItemHref, TileMenuPropGetItemOnClick } from "./types";
|
|
3
|
+
export declare const defaultGetItemImage: TileMenuPropGetItemImage<TileMenuDefaultItem>;
|
|
4
|
+
export declare const defaultGetItemLabel: TileMenuPropGetItemLabel<TileMenuDefaultItem>;
|
|
5
|
+
export declare const defaultGetItemHref: TileMenuPropGetItemHref<TileMenuDefaultItem>;
|
|
6
|
+
export declare const defaultGetItemOnClick: TileMenuPropGetItemOnClick<TileMenuDefaultItem>;
|
|
7
|
+
export declare const defaultGetItemDescription: TileMenuPropGetItemDescription<TileMenuDefaultItem>;
|
|
8
8
|
export declare function withDefaultGetters<ITEM>(props: TileMenuListProps<ITEM>): {
|
|
9
|
-
getItemDescription: TileMenuPropGetItemDescription<
|
|
10
|
-
|
|
11
|
-
getItemImage: TileMenuPropGetItemImage<
|
|
12
|
-
getItemHref: TileMenuPropGetItemHref<
|
|
13
|
-
getItemOnClick: TileMenuPropGetItemOnClick<
|
|
9
|
+
getItemDescription: TileMenuPropGetItemDescription<TileMenuDefaultItem> | TileMenuPropGetItemDescription<ITEM>;
|
|
10
|
+
getItemLabel: TileMenuPropGetItemLabel<TileMenuDefaultItem> | TileMenuPropGetItemLabel<ITEM>;
|
|
11
|
+
getItemImage: TileMenuPropGetItemImage<TileMenuDefaultItem> | TileMenuPropGetItemImage<ITEM>;
|
|
12
|
+
getItemHref: TileMenuPropGetItemHref<TileMenuDefaultItem> | TileMenuPropGetItemHref<ITEM>;
|
|
13
|
+
getItemOnClick: TileMenuPropGetItemOnClick<TileMenuDefaultItem> | TileMenuPropGetItemOnClick<ITEM>;
|
|
14
14
|
view?: "lines" | "twoLines" | "cards" | undefined;
|
|
15
15
|
items: ITEM[];
|
|
16
16
|
isMobile?: boolean | undefined;
|
package/TileMenu/helpers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectSpread from"@babel/runtime/helpers/objectSpread";export const defaultGetItemImage=a=>a.image;export const
|
|
1
|
+
import _objectSpread from"@babel/runtime/helpers/objectSpread";export const defaultGetItemImage=a=>a.image;export const defaultGetItemLabel=a=>a.label;export const defaultGetItemHref=a=>a.href;export const defaultGetItemOnClick=a=>a.onClick;export const defaultGetItemDescription=a=>a.description;export function withDefaultGetters(a){return _objectSpread({},a,{getItemDescription:a.getItemDescription||defaultGetItemDescription,getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemImage:a.getItemImage||defaultGetItemImage,getItemHref:a.getItemHref||defaultGetItemHref,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick})}
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
package/TileMenu/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TileMenu/helpers.ts"],"names":["defaultGetItemImage","item","image","
|
|
1
|
+
{"version":3,"sources":["../../src/TileMenu/helpers.ts"],"names":["defaultGetItemImage","item","image","defaultGetItemLabel","label","defaultGetItemHref","href","defaultGetItemOnClick","onClick","defaultGetItemDescription","description","withDefaultGetters","props","getItemDescription","getItemLabel","getItemImage","getItemHref","getItemOnClick"],"mappings":"+DAUA,MAAO,MAAMA,CAAAA,mBAAkE,CAAGC,CAAI,EAAIA,CAAI,CAACC,KAAxF,CACP,MAAO,MAAMC,CAAAA,mBAAkE,CAAGF,CAAI,EAAIA,CAAI,CAACG,KAAxF,CACP,MAAO,MAAMC,CAAAA,kBAAgE,CAAGJ,CAAI,EAAIA,CAAI,CAACK,IAAtF,CACP,MAAO,MAAMC,CAAAA,qBAAsE,CAAGN,CAAI,EACxFA,CAAI,CAACO,OADA,CAEP,MAAO,MAAMC,CAAAA,yBAA8E,CAAGR,CAAI,EAChGA,CAAI,CAACS,WADA,CAGP,MAAO,SAASC,CAAAA,kBAAT,CAAkCC,CAAlC,CAAkE,CACvE,wBACKA,CADL,EAEEC,kBAAkB,CAAED,CAAK,CAACC,kBAAN,EAA4BJ,yBAFlD,CAGEK,YAAY,CAAEF,CAAK,CAACE,YAAN,EAAsBX,mBAHtC,CAIEY,YAAY,CAAEH,CAAK,CAACG,YAAN,EAAsBf,mBAJtC,CAKEgB,WAAW,CAAEJ,CAAK,CAACI,WAAN,EAAqBX,kBALpC,CAMEY,cAAc,CAAEL,CAAK,CAACK,cAAN,EAAwBV,qBAN1C,EAQD","sourcesContent":["import {\n TileMenuPropGetItemDescription,\n TileMenuPropGetItemImage,\n TileMenuPropGetItemLabel,\n TileMenuDefaultItem,\n TileMenuListProps,\n TileMenuPropGetItemHref,\n TileMenuPropGetItemOnClick,\n} from './types'\n\nexport const defaultGetItemImage: TileMenuPropGetItemImage<TileMenuDefaultItem> = item => item.image\nexport const defaultGetItemLabel: TileMenuPropGetItemLabel<TileMenuDefaultItem> = item => item.label\nexport const defaultGetItemHref: TileMenuPropGetItemHref<TileMenuDefaultItem> = item => item.href\nexport const defaultGetItemOnClick: TileMenuPropGetItemOnClick<TileMenuDefaultItem> = item =>\n item.onClick\nexport const defaultGetItemDescription: TileMenuPropGetItemDescription<TileMenuDefaultItem> = item =>\n item.description\n\nexport function withDefaultGetters<ITEM>(props: TileMenuListProps<ITEM>) {\n return {\n ...props,\n getItemDescription: props.getItemDescription || defaultGetItemDescription,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemImage: props.getItemImage || defaultGetItemImage,\n getItemHref: props.getItemHref || defaultGetItemHref,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n }\n}\n"],"file":"helpers.js"}
|