@consta/uikit 4.13.0 → 4.14.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/Breadcrumbs/BreadcrumbsItem/BreadcrumbsItem.js +1 -1
- package/__internal__/src/components/Breadcrumbs/BreadcrumbsItem/BreadcrumbsItem.js.map +1 -1
- package/__internal__/src/components/Breadcrumbs/BreadcrumbsMore/BreadcrumbsMore.js +1 -1
- package/__internal__/src/components/Breadcrumbs/BreadcrumbsMore/BreadcrumbsMore.js.map +1 -1
- package/__internal__/src/components/BreadcrumbsDeprecated/BreadcrumbsDeprecated.js +1 -1
- package/__internal__/src/components/BreadcrumbsDeprecated/BreadcrumbsDeprecated.js.map +1 -1
- package/__internal__/src/components/CalendarDeprecated/CalendarMonthToggler/CalendarMonthToggler.js +1 -1
- package/__internal__/src/components/CalendarDeprecated/CalendarMonthToggler/CalendarMonthToggler.js.map +1 -1
- package/__internal__/src/components/CalendarDeprecated/CalendarSlider/CalendarSlider.js +1 -1
- package/__internal__/src/components/CalendarDeprecated/CalendarSlider/CalendarSlider.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeSlider/DateTimeSlider.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeSlider/DateTimeSlider.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeToggler/DateTimeToggler.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeToggler/DateTimeToggler.js.map +1 -1
- package/__internal__/src/components/Pagination/Pagination.js +1 -1
- package/__internal__/src/components/Pagination/Pagination.js.map +1 -1
- package/__internal__/src/components/ProgressStepBar/ProgressStepBar.js +1 -1
- package/__internal__/src/components/ProgressStepBar/ProgressStepBar.js.map +1 -1
- package/__internal__/src/components/Responses403/Responses403.js +1 -1
- package/__internal__/src/components/Responses403/Responses403.js.map +1 -1
- package/__internal__/src/components/Responses404/Responses404.js +1 -1
- package/__internal__/src/components/Responses404/Responses404.js.map +1 -1
- package/__internal__/src/components/ResponsesDeleted/ResponsesDeleted.js +1 -1
- package/__internal__/src/components/ResponsesDeleted/ResponsesDeleted.js.map +1 -1
- package/__internal__/src/components/ResponsesEmptyBox/ResponsesEmptyBox.js +1 -1
- package/__internal__/src/components/ResponsesEmptyBox/ResponsesEmptyBox.js.map +1 -1
- package/__internal__/src/components/ResponsesEmptyPockets/ResponsesEmptyPockets.js +1 -1
- package/__internal__/src/components/ResponsesEmptyPockets/ResponsesEmptyPockets.js.map +1 -1
- package/__internal__/src/components/ResponsesExit/ResponsesExit.js +1 -1
- package/__internal__/src/components/ResponsesExit/ResponsesExit.js.map +1 -1
- package/__internal__/src/components/ResponsesNothingFound/ResponsesNothingFound.js +1 -1
- package/__internal__/src/components/ResponsesNothingFound/ResponsesNothingFound.js.map +1 -1
- package/__internal__/src/components/SnackBar/SnackBarActionButton/SnackBarActionButton.js +1 -1
- package/__internal__/src/components/SnackBar/SnackBarActionButton/SnackBarActionButton.js.map +1 -1
- package/__internal__/src/components/SnackBar/SnackBarItem/SnackBarItem.js +1 -1
- package/__internal__/src/components/SnackBar/SnackBarItem/SnackBarItem.js.map +1 -1
- package/__internal__/src/components/Steps/Steps.js +1 -1
- package/__internal__/src/components/Steps/Steps.js.map +1 -1
- package/__internal__/src/components/Table/FilterContainer/TableFilterContainer.js +1 -1
- package/__internal__/src/components/Table/FilterContainer/TableFilterContainer.js.map +1 -1
- package/__internal__/src/components/Table/FilterTooltip/TableFilterTooltip.js +1 -1
- package/__internal__/src/components/Table/FilterTooltip/TableFilterTooltip.js.map +1 -1
- package/__internal__/src/components/Table/Header/TableHeader.js +1 -1
- package/__internal__/src/components/Table/Header/TableHeader.js.map +1 -1
- package/__internal__/src/components/Table/RowsCollapse/TableRowsCollapse.js +1 -1
- package/__internal__/src/components/Table/RowsCollapse/TableRowsCollapse.js.map +1 -1
- package/__internal__/src/components/Table/TextFilter/TableTextFilter.js +1 -1
- package/__internal__/src/components/Table/TextFilter/TableTextFilter.js.map +1 -1
- package/__internal__/src/components/Tabs/FitModeScrollWrapper/TabsFitModeScrollWrapper.js +1 -1
- package/__internal__/src/components/Tabs/FitModeScrollWrapper/TabsFitModeScrollWrapper.js.map +1 -1
- package/__internal__/src/components/Tabs/MoreItems/TabsMoreItems.js +1 -1
- package/__internal__/src/components/Tabs/MoreItems/TabsMoreItems.js.map +1 -1
- package/__internal__/src/components/TabsDeprecated/FitModeScrollWrapper/TabsFitModeScrollWrapper.js +1 -1
- package/__internal__/src/components/TabsDeprecated/FitModeScrollWrapper/TabsFitModeScrollWrapper.js.map +1 -1
- package/__internal__/src/components/TabsDeprecated/MoreItems/TabsMoreItems.js +1 -1
- package/__internal__/src/components/TabsDeprecated/MoreItems/TabsMoreItems.js.map +1 -1
- package/__internal__/src/components/ThemeToggler/ThemeToggler.js +1 -1
- package/__internal__/src/components/ThemeToggler/ThemeToggler.js.map +1 -1
- package/__internal__/src/components/ThemeToggler/helpers.d.ts +1 -0
- package/__internal__/src/components/ThemeToggler/types.d.ts +4 -2
- package/__internal__/src/components/ThemeToggler/types.js.map +1 -1
- package/__internal__/src/components/User/User.js +1 -1
- package/__internal__/src/components/User/User.js.map +1 -1
- package/package.json +1 -1
- package/__internal__/src/components/DatePicker/useDropdownVisible.d.ts +0 -24
- package/__internal__/src/components/DatePicker/useDropdownVisible.js +0 -2
- package/__internal__/src/components/DatePicker/useDropdownVisible.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"./TabsMoreItems.css";import{IconMeatball}from"@consta/icons/IconMeatball";import FocusTrap from"focus-trap-react";import React,{useEffect,useRef,useState}from"react";import{Transition}from"react-transition-group";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";import{Popover}from"../../Popover/Popover";var cnTabsMoreItems=cn("TabsMoreItems");export var TabsMoreItems=React.forwardRef(function(a,b){var c=a.items,d=a.renderItem,e=a.getLabel,f=a.getChecked,g=a.height,h=useFlag(!1),i=_slicedToArray(h,2),j=i[0],k=i[1],l=k.off,m=k.toggle,n=useRef(null),o=useRef(null),p=useState("downStartLeft"),q=_slicedToArray(p,2),r=q[0],s=q[1];return useEffect(function(){0===c.length&&l()},[c]),React.createElement(React.Fragment,null,React.createElement("div",{ref:useForkRef([b,n]),className:cnTabsMoreItems("Button"),style:{height:g}},React.createElement(Button,{size:"xs",view:"ghost",onlyIcon:!0,iconLeft:IconMeatball,onClick:m})),React.createElement(Transition,{in:j,unmountOnExit:!0,nodeRef:o,timeout:animateTimeout},function(a){var b;return React.createElement(Popover,{anchorRef:n,offset:-1,ref:o,direction:"downStartRight",spareDirection:"downStartLeft",className:cnTabsMoreItems("Popover",[cnMixPopoverAnimate({animate:a,direction:r})]),onSetDirection:s,possibleDirections:["downStartRight","downStartLeft","upStartRight","upStartLeft","downCenter","upCenter"]},React.createElement(FocusTrap,{focusTrapOptions:{fallbackFocus:null!==(b=n.current)&&void 0!==b?b:void 0,clickOutsideDeactivates:function clickOutsideDeactivates(a){var b,c=null===(b=n.current)||void 0===b?void 0:b.contains(a.target);return!c},allowOutsideClick:!0,onDeactivate:l}},React.createElement("div",{className:cnTabsMoreItems("Content")},c.map(function(a){return React.createElement("div",{key:e(a),className:cnTabsMoreItems("Item",{active:f(a)})},d(a,l))}))))}))});
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"./TabsMoreItems.css";import{IconMeatball}from"@consta/icons/IconMeatball";import FocusTrap from"focus-trap-react";import React,{useEffect,useRef,useState}from"react";import{Transition}from"react-transition-group";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{animateTimeout,cnMixPopoverAnimate}from"../../../mixs/MixPopoverAnimate/MixPopoverAnimate";import{cn}from"../../../utils/bem";import{Button}from"../../Button/Button";import{Popover}from"../../Popover/Popover";var cnTabsMoreItems=cn("TabsMoreItems");export var TabsMoreItems=React.forwardRef(function(a,b){var c=a.items,d=a.renderItem,e=a.getLabel,f=a.getChecked,g=a.height,h=useFlag(!1),i=_slicedToArray(h,2),j=i[0],k=i[1],l=k.off,m=k.toggle,n=useRef(null),o=useRef(null),p=useState("downStartLeft"),q=_slicedToArray(p,2),r=q[0],s=q[1];return useEffect(function(){0===c.length&&l()},[c]),React.createElement(React.Fragment,null,React.createElement("div",{ref:useForkRef([b,n]),className:cnTabsMoreItems("Button"),style:{height:g}},React.createElement(Button,{size:"xs",type:"button",view:"ghost",onlyIcon:!0,iconLeft:IconMeatball,onClick:m})),React.createElement(Transition,{in:j,unmountOnExit:!0,nodeRef:o,timeout:animateTimeout},function(a){var b;return React.createElement(Popover,{anchorRef:n,offset:-1,ref:o,direction:"downStartRight",spareDirection:"downStartLeft",className:cnTabsMoreItems("Popover",[cnMixPopoverAnimate({animate:a,direction:r})]),onSetDirection:s,possibleDirections:["downStartRight","downStartLeft","upStartRight","upStartLeft","downCenter","upCenter"]},React.createElement(FocusTrap,{focusTrapOptions:{fallbackFocus:null!==(b=n.current)&&void 0!==b?b:void 0,clickOutsideDeactivates:function clickOutsideDeactivates(a){var b,c=null===(b=n.current)||void 0===b?void 0:b.contains(a.target);return!c},allowOutsideClick:!0,onDeactivate:l}},React.createElement("div",{className:cnTabsMoreItems("Content")},c.map(function(a){return React.createElement("div",{key:e(a),className:cnTabsMoreItems("Item",{active:f(a)})},d(a,l))}))))}))});
|
|
2
2
|
//# sourceMappingURL=TabsMoreItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsMoreItems.js","names":["IconMeatball","FocusTrap","React","useEffect","useRef","useState","Transition","useFlag","useForkRef","animateTimeout","cnMixPopoverAnimate","cn","Button","Popover","cnTabsMoreItems","TabsMoreItems","forwardRef","ref","items","renderItem","getLabel","getChecked","height","isOpen","off","toggle","buttonRef","popoverRef","direction","setDirection","length","animate","fallbackFocus","current","clickOutsideDeactivates","e","isClickInsideButton","contains","target","allowOutsideClick","onDeactivate","map","item","active"],"sources":["../../../../../../src/components/TabsDeprecated/MoreItems/TabsMoreItems.tsx"],"sourcesContent":["import './TabsMoreItems.css';\n\nimport { IconMeatball } from '@consta/icons/IconMeatball';\nimport FocusTrap from 'focus-trap-react';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport {\n animateTimeout,\n cnMixPopoverAnimate,\n} from '../../../mixs/MixPopoverAnimate/MixPopoverAnimate';\nimport { cn } from '../../../utils/bem';\nimport { Button } from '../../Button/Button';\nimport { Direction, Popover } from '../../Popover/Popover';\nimport { TabsPropGetLabel } from '../TabsDeprecated';\n\nconst cnTabsMoreItems = cn('TabsMoreItems');\n\ntype TabsMoreItems = <ITEM>(\n props: {\n items: ITEM[];\n renderItem: (item: ITEM, onClick: () => void) => React.ReactNode;\n getLabel: TabsPropGetLabel<ITEM>;\n getChecked: (item: ITEM) => boolean;\n height: number;\n } & React.RefAttributes<HTMLDivElement>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport const TabsMoreItems: TabsMoreItems = React.forwardRef(\n ({ items, renderItem, getLabel, getChecked, height }, ref) => {\n const [isOpen, { off, toggle }] = useFlag(false);\n const buttonRef = useRef<HTMLDivElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const [direction, setDirection] = useState<Direction>('downStartLeft');\n\n useEffect(() => {\n items.length === 0 && off();\n }, [items]);\n\n return (\n <>\n <div\n ref={useForkRef([ref, buttonRef])}\n className={cnTabsMoreItems('Button')}\n style={{ height }}\n >\n <Button\n size=\"xs\"\n view=\"ghost\"\n onlyIcon\n iconLeft={IconMeatball}\n onClick={toggle}\n />\n </div>\n <Transition\n in={isOpen}\n unmountOnExit\n nodeRef={popoverRef}\n timeout={animateTimeout}\n >\n {(animate) => (\n <Popover\n anchorRef={buttonRef}\n offset={-1}\n ref={popoverRef}\n direction=\"downStartRight\"\n spareDirection=\"downStartLeft\"\n className={cnTabsMoreItems('Popover', [\n cnMixPopoverAnimate({ animate, direction }),\n ])}\n onSetDirection={setDirection}\n possibleDirections={[\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n 'upStartLeft',\n 'downCenter',\n 'upCenter',\n ]}\n >\n <FocusTrap\n focusTrapOptions={{\n fallbackFocus: buttonRef.current ?? undefined,\n clickOutsideDeactivates: (e) => {\n const isClickInsideButton = buttonRef.current?.contains(\n e.target as Node,\n );\n return !isClickInsideButton;\n },\n allowOutsideClick: true,\n onDeactivate: off,\n }}\n >\n <div className={cnTabsMoreItems('Content')}>\n {items.map((item) => (\n <div\n key={getLabel(item)}\n className={cnTabsMoreItems('Item', {\n active: getChecked(item),\n })}\n >\n {renderItem(item, off)}\n </div>\n ))}\n </div>\n </FocusTrap>\n </Popover>\n )}\n </Transition>\n </>\n );\n },\n);\n"],"mappings":"iEAAA,4BAEA,OAASA,YAAT,KAA6B,4BAA7B,CACA,MAAOC,UAAP,KAAsB,kBAAtB,CACA,MAAOC,MAAP,EAAgBC,SAAhB,CAA2BC,MAA3B,CAAmCC,QAAnC,KAAmD,OAAnD,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OAASC,OAAT,sCACA,OAASC,UAAT,4CACA,OACEC,cADF,CAEEC,mBAFF,yDAIA,OAASC,EAAT,0BACA,OAASC,MAAT,2BACA,OAAoBC,OAApB,6BAGA,GAAMC,gBAAe,CAAGH,EAAE,CAAC,eAAD,CAA1B,CAaA,MAAO,IAAMI,cAA4B,CAAGb,KAAK,CAACc,UAAN,CAC1C,WAAsDC,CAAtD,CAA8D,IAA3DC,EAA2D,GAA3DA,KAA2D,CAApDC,CAAoD,GAApDA,UAAoD,CAAxCC,CAAwC,GAAxCA,QAAwC,CAA9BC,CAA8B,GAA9BA,UAA8B,CAAlBC,CAAkB,GAAlBA,MAAkB,GAC1Bf,OAAO,IADmB,uBACrDgB,CADqD,aAC3CC,CAD2C,GAC3CA,GAD2C,CACtCC,CADsC,GACtCA,MADsC,CAEtDC,CAAS,CAAGtB,MAAM,CAAiB,IAAjB,CAFoC,CAGtDuB,CAAU,CAAGvB,MAAM,CAAiB,IAAjB,CAHmC,GAI1BC,QAAQ,CAAY,eAAZ,CAJkB,uBAIrDuB,CAJqD,MAI1CC,CAJ0C,MAU5D,MAJA1B,UAAS,CAAC,UAAM,CACG,CAAjB,GAAAe,CAAK,CAACY,MAAN,EAAsBN,CAAG,EAC1B,CAFQ,CAEN,CAACN,CAAD,CAFM,CAIT,CACE,wCACE,2BACE,GAAG,CAAEV,UAAU,CAAC,CAACS,CAAD,CAAMS,CAAN,CAAD,CADjB,CAEE,SAAS,CAAEZ,eAAe,CAAC,QAAD,CAF5B,CAGE,KAAK,CAAE,CAAEQ,MAAM,CAANA,CAAF,CAHT,EAKE,oBAAC,MAAD,EACE,IAAI,CAAC,IADP,CAEE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"TabsMoreItems.js","names":["IconMeatball","FocusTrap","React","useEffect","useRef","useState","Transition","useFlag","useForkRef","animateTimeout","cnMixPopoverAnimate","cn","Button","Popover","cnTabsMoreItems","TabsMoreItems","forwardRef","ref","items","renderItem","getLabel","getChecked","height","isOpen","off","toggle","buttonRef","popoverRef","direction","setDirection","length","animate","fallbackFocus","current","clickOutsideDeactivates","e","isClickInsideButton","contains","target","allowOutsideClick","onDeactivate","map","item","active"],"sources":["../../../../../../src/components/TabsDeprecated/MoreItems/TabsMoreItems.tsx"],"sourcesContent":["import './TabsMoreItems.css';\n\nimport { IconMeatball } from '@consta/icons/IconMeatball';\nimport FocusTrap from 'focus-trap-react';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport {\n animateTimeout,\n cnMixPopoverAnimate,\n} from '../../../mixs/MixPopoverAnimate/MixPopoverAnimate';\nimport { cn } from '../../../utils/bem';\nimport { Button } from '../../Button/Button';\nimport { Direction, Popover } from '../../Popover/Popover';\nimport { TabsPropGetLabel } from '../TabsDeprecated';\n\nconst cnTabsMoreItems = cn('TabsMoreItems');\n\ntype TabsMoreItems = <ITEM>(\n props: {\n items: ITEM[];\n renderItem: (item: ITEM, onClick: () => void) => React.ReactNode;\n getLabel: TabsPropGetLabel<ITEM>;\n getChecked: (item: ITEM) => boolean;\n height: number;\n } & React.RefAttributes<HTMLDivElement>,\n ref: React.Ref<HTMLDivElement>,\n) => React.ReactElement | null;\n\nexport const TabsMoreItems: TabsMoreItems = React.forwardRef(\n ({ items, renderItem, getLabel, getChecked, height }, ref) => {\n const [isOpen, { off, toggle }] = useFlag(false);\n const buttonRef = useRef<HTMLDivElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n const [direction, setDirection] = useState<Direction>('downStartLeft');\n\n useEffect(() => {\n items.length === 0 && off();\n }, [items]);\n\n return (\n <>\n <div\n ref={useForkRef([ref, buttonRef])}\n className={cnTabsMoreItems('Button')}\n style={{ height }}\n >\n <Button\n size=\"xs\"\n type=\"button\"\n view=\"ghost\"\n onlyIcon\n iconLeft={IconMeatball}\n onClick={toggle}\n />\n </div>\n <Transition\n in={isOpen}\n unmountOnExit\n nodeRef={popoverRef}\n timeout={animateTimeout}\n >\n {(animate) => (\n <Popover\n anchorRef={buttonRef}\n offset={-1}\n ref={popoverRef}\n direction=\"downStartRight\"\n spareDirection=\"downStartLeft\"\n className={cnTabsMoreItems('Popover', [\n cnMixPopoverAnimate({ animate, direction }),\n ])}\n onSetDirection={setDirection}\n possibleDirections={[\n 'downStartRight',\n 'downStartLeft',\n 'upStartRight',\n 'upStartLeft',\n 'downCenter',\n 'upCenter',\n ]}\n >\n <FocusTrap\n focusTrapOptions={{\n fallbackFocus: buttonRef.current ?? undefined,\n clickOutsideDeactivates: (e) => {\n const isClickInsideButton = buttonRef.current?.contains(\n e.target as Node,\n );\n return !isClickInsideButton;\n },\n allowOutsideClick: true,\n onDeactivate: off,\n }}\n >\n <div className={cnTabsMoreItems('Content')}>\n {items.map((item) => (\n <div\n key={getLabel(item)}\n className={cnTabsMoreItems('Item', {\n active: getChecked(item),\n })}\n >\n {renderItem(item, off)}\n </div>\n ))}\n </div>\n </FocusTrap>\n </Popover>\n )}\n </Transition>\n </>\n );\n },\n);\n"],"mappings":"iEAAA,4BAEA,OAASA,YAAT,KAA6B,4BAA7B,CACA,MAAOC,UAAP,KAAsB,kBAAtB,CACA,MAAOC,MAAP,EAAgBC,SAAhB,CAA2BC,MAA3B,CAAmCC,QAAnC,KAAmD,OAAnD,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OAASC,OAAT,sCACA,OAASC,UAAT,4CACA,OACEC,cADF,CAEEC,mBAFF,yDAIA,OAASC,EAAT,0BACA,OAASC,MAAT,2BACA,OAAoBC,OAApB,6BAGA,GAAMC,gBAAe,CAAGH,EAAE,CAAC,eAAD,CAA1B,CAaA,MAAO,IAAMI,cAA4B,CAAGb,KAAK,CAACc,UAAN,CAC1C,WAAsDC,CAAtD,CAA8D,IAA3DC,EAA2D,GAA3DA,KAA2D,CAApDC,CAAoD,GAApDA,UAAoD,CAAxCC,CAAwC,GAAxCA,QAAwC,CAA9BC,CAA8B,GAA9BA,UAA8B,CAAlBC,CAAkB,GAAlBA,MAAkB,GAC1Bf,OAAO,IADmB,uBACrDgB,CADqD,aAC3CC,CAD2C,GAC3CA,GAD2C,CACtCC,CADsC,GACtCA,MADsC,CAEtDC,CAAS,CAAGtB,MAAM,CAAiB,IAAjB,CAFoC,CAGtDuB,CAAU,CAAGvB,MAAM,CAAiB,IAAjB,CAHmC,GAI1BC,QAAQ,CAAY,eAAZ,CAJkB,uBAIrDuB,CAJqD,MAI1CC,CAJ0C,MAU5D,MAJA1B,UAAS,CAAC,UAAM,CACG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CAPe,CAQhBG,iBAAiB,GARD,CAShBC,YAAY,CAAEhB,CATE,CADpB,EAaE,2BAAK,SAAS,CAAEV,eAAe,CAAC,SAAD,CAA/B,EACGI,CAAK,CAACuB,GAAN,CAAU,SAACC,CAAD,QACT,4BACE,GAAG,CAAEtB,CAAQ,CAACsB,CAAD,CADf,CAEE,SAAS,CAAE5B,eAAe,CAAC,MAAD,CAAS,CACjC6B,MAAM,CAAEtB,CAAU,CAACqB,CAAD,CADe,CAAT,CAF5B,EAMGvB,CAAU,CAACuB,CAAD,CAAOlB,CAAP,CANb,CADS,CAAV,CADH,CAbF,CAnBF,CADD,CANH,CAfF,CAwEH,CApFyC,CAArC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","items","value","onChange","getItemKey","getItemLabel","getItemIcon","direction","possibleDirections","style"];import{IconCheck}from"@consta/icons/IconCheck";import React,{forwardRef,useRef}from"react";import{
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["size","items","value","onChange","getItemKey","getItemLabel","getItemIcon","direction","possibleDirections","style","view"];import{IconCheck}from"@consta/icons/IconCheck";import React,{forwardRef,useRef}from"react";import{Button}from"../Button";import{ContextMenu}from"../ContextMenu";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{useChoiceGroup}from"../../hooks/useChoiceGroup";import{useFlag}from"../../hooks/useFlag";import{useForkRef}from"../../hooks/useForkRef";import{contextMenuSizeMap,iconSizeMap,withDefaultGetters}from"./helpers";import{themeTogglerPropSizeDefault}from"./types";export var COMPONENT_NAME="ThemeToggler";var ThemeTogglerRender=function(a,b){var c=useRef(null),d=useForkRef([c,b]),e=usePropsHandler(COMPONENT_NAME,withDefaultGetters(a),d),f=e.size,g=void 0===f?themeTogglerPropSizeDefault:f,h=e.items,i=e.value,j=e.onChange,k=e.getItemKey,l=e.getItemLabel,m=e.getItemIcon,n=e.direction,o=e.possibleDirections,p=e.style,q=e.view,r=void 0===q?"clear":q,s=_objectWithoutProperties(e,_excluded),t=useFlag(!1),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useChoiceGroup({value:i,getKey:k||l,callBack:j,multiple:!1}),y=x.getOnChange,z=x.getChecked,A=iconSizeMap[g],B=contextMenuSizeMap[g];return 1>=h.length?null:React.createElement(React.Fragment,null,React.createElement(Button,Object.assign({},s,{ref:d,iconLeft:function getButtonIcon(){var a;return m(null!==(a=h.find(function(a){return z(a)}))&&void 0!==a?a:h[0])}(),onClick:function onButtonClick(a){2<h.length?w.toggle():y(h[z(h[0])?1:0])(a)},onlyIcon:!0,size:g,view:r,style:p})),2<h.length&&React.createElement(ContextMenu,{isOpen:v,offset:"s",items:h,getItemLabel:l,getItemKey:k||l,anchorRef:c,direction:n,possibleDirections:o,getItemLeftSide:function renderIcons(a){var b=m(a);if(b)return React.createElement(b,{size:A})},getItemRightSide:function renderChecks(a){if(z(a))return React.createElement(IconCheck,{size:A})},onClickOutside:w.off,onItemClick:function onItemClick(a){return y(a.item)(a.e)},size:B,style:"number"==typeof(null===p||void 0===p?void 0:p.zIndex)?{zIndex:p.zIndex+1}:void 0}))};export var ThemeToggler=forwardRef(ThemeTogglerRender);export*from"./types";
|
|
2
2
|
//# sourceMappingURL=ThemeToggler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeToggler.js","names":["IconCheck","React","forwardRef","useRef","
|
|
1
|
+
{"version":3,"file":"ThemeToggler.js","names":["IconCheck","React","forwardRef","useRef","Button","ContextMenu","usePropsHandler","useChoiceGroup","useFlag","useForkRef","contextMenuSizeMap","iconSizeMap","withDefaultGetters","themeTogglerPropSizeDefault","COMPONENT_NAME","ThemeTogglerRender","props","ref","anchorRef","buttonRef","size","items","value","onChange","getItemKey","getItemLabel","getItemIcon","direction","possibleDirections","style","view","otherProps","isOpen","setIsOpen","getKey","callBack","multiple","getOnChange","getChecked","iconSize","contextMenuSize","length","getButtonIcon","find","theme","onButtonClick","e","toggle","renderIcons","item","Icon","renderChecks","off","params","zIndex","ThemeToggler"],"sources":["../../../../../src/components/ThemeToggler/ThemeToggler.tsx"],"sourcesContent":["import { IconCheck } from '@consta/icons/IconCheck';\nimport React, { forwardRef, useRef } from 'react';\n\nimport { Button } from '##/components/Button';\nimport { ContextMenu } from '##/components/ContextMenu';\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { useChoiceGroup } from '##/hooks/useChoiceGroup';\nimport { useFlag } from '##/hooks/useFlag';\nimport { useForkRef } from '##/hooks/useForkRef';\n\nimport { contextMenuSizeMap, iconSizeMap, withDefaultGetters } from './helpers';\nimport {\n ThemeTogglerComponent,\n ThemeTogglerProps,\n themeTogglerPropSizeDefault,\n} from './types';\n\nexport const COMPONENT_NAME = 'ThemeToggler' as const;\n\nconst ThemeTogglerRender = (\n props: ThemeTogglerProps,\n ref: React.Ref<HTMLButtonElement>,\n) => {\n const anchorRef = useRef<HTMLButtonElement>(null);\n const buttonRef = useForkRef([anchorRef, ref]);\n\n const {\n size = themeTogglerPropSizeDefault,\n items,\n value,\n onChange,\n getItemKey,\n getItemLabel,\n getItemIcon,\n direction,\n possibleDirections,\n style,\n view = 'clear',\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, withDefaultGetters(props), buttonRef);\n\n const [isOpen, setIsOpen] = useFlag(false);\n\n const { getOnChange, getChecked } = useChoiceGroup({\n value,\n getKey: getItemKey || getItemLabel,\n callBack: onChange,\n multiple: false,\n });\n\n type Item = typeof items[number];\n\n const iconSize = iconSizeMap[size];\n const contextMenuSize = contextMenuSizeMap[size];\n\n const getButtonIcon = () =>\n getItemIcon(items.find((theme) => getChecked(theme)) ?? items[0]);\n\n const onButtonClick = (e: React.MouseEvent<Element, MouseEvent>) => {\n if (items.length > 2) {\n setIsOpen.toggle();\n } else {\n getOnChange(items[getChecked(items[0]) ? 1 : 0])(e);\n }\n };\n\n const renderIcons = (item: Item) => {\n const Icon = getItemIcon(item);\n\n if (Icon) {\n return <Icon size={iconSize} />;\n }\n };\n\n const renderChecks = (item: Item) => {\n if (getChecked(item)) {\n return <IconCheck size={iconSize} />;\n }\n };\n\n if (items.length <= 1) {\n return null;\n }\n\n return (\n <>\n <Button\n {...otherProps}\n ref={buttonRef}\n iconLeft={getButtonIcon()}\n onClick={onButtonClick}\n onlyIcon\n size={size}\n view={view}\n style={style}\n />\n {items.length > 2 && (\n <ContextMenu\n isOpen={isOpen}\n offset=\"s\"\n items={items}\n getItemLabel={getItemLabel}\n getItemKey={getItemKey || getItemLabel}\n anchorRef={anchorRef}\n direction={direction}\n possibleDirections={possibleDirections}\n getItemLeftSide={renderIcons}\n getItemRightSide={renderChecks}\n onClickOutside={setIsOpen.off}\n onItemClick={(params) => getOnChange(params.item)(params.e)}\n size={contextMenuSize}\n style={\n typeof style?.zIndex === 'number'\n ? { zIndex: style.zIndex + 1 }\n : undefined\n }\n />\n )}\n </>\n );\n};\n\nexport const ThemeToggler = forwardRef(\n ThemeTogglerRender,\n) as ThemeTogglerComponent;\n\nexport * from './types';\n"],"mappings":"kSAAA,OAASA,SAAT,KAA0B,yBAA1B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,KAA0C,OAA1C,CAEA,OAASC,MAAT,iBACA,OAASC,WAAT,sBACA,OAASC,eAAT,2CACA,OAASC,cAAT,kCACA,OAASC,OAAT,2BACA,OAASC,UAAT,8BAEA,OAASC,kBAAT,CAA6BC,WAA7B,CAA0CC,kBAA1C,iBACA,OAGEC,2BAHF,eAMA,MAAO,IAAMC,eAAc,CAAG,cAAvB,CAEP,GAAMC,mBAAkB,CAAG,SACzBC,CADyB,CAEzBC,CAFyB,CAGtB,IACGC,EAAS,CAAGf,MAAM,CAAoB,IAApB,CADrB,CAEGgB,CAAS,CAAGV,UAAU,CAAC,CAACS,CAAD,C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,CAmCH,CArGD,CAuGA,MAAO,IAAMC,aAAY,CAAGrD,UAAU,CACpCa,kBADoC,CAA/B,CAIP"}
|
|
@@ -14,6 +14,7 @@ export declare function withDefaultGetters(props: ThemeTogglerProps): {
|
|
|
14
14
|
direction?: "downCenter" | "upCenter" | "downRight" | "downLeft" | "upRight" | "upLeft" | "leftUp" | "leftCenter" | "leftDown" | "rightUp" | "rightCenter" | "rightDown" | "downStartLeft" | "upStartLeft" | "downStartRight" | "upStartRight" | "leftStartUp" | "leftStartDown" | "rightStartUp" | "rightStartDown" | undefined;
|
|
15
15
|
possibleDirections?: readonly ("downCenter" | "upCenter" | "downRight" | "downLeft" | "upRight" | "upLeft" | "leftUp" | "leftCenter" | "leftDown" | "rightUp" | "rightCenter" | "rightDown" | "downStartLeft" | "upStartLeft" | "downStartRight" | "upStartRight" | "leftStartUp" | "leftStartDown" | "rightStartUp" | "rightStartDown")[] | undefined;
|
|
16
16
|
children?: undefined;
|
|
17
|
+
view?: "primary" | "ghost" | "clear" | "secondary" | undefined;
|
|
17
18
|
defaultChecked?: boolean | undefined;
|
|
18
19
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
19
20
|
suppressContentEditableWarning?: boolean | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconComponent } from '@consta/icons/Icon';
|
|
3
|
-
import {
|
|
4
|
-
import { Direction } from
|
|
3
|
+
import { ButtonPropView } from "../Button";
|
|
4
|
+
import { Direction } from "../Popover";
|
|
5
|
+
import { PropsWithHTMLAttributesAndRef } from "../../utils/types/PropsWithHTMLAttributes";
|
|
5
6
|
export declare const themeTogglerPropSize: readonly ["m", "l", "s", "xs"];
|
|
6
7
|
export declare type ThemeTogglerPropSize = typeof themeTogglerPropSize[number];
|
|
7
8
|
export declare const themeTogglerPropSizeDefault: ThemeTogglerPropSize;
|
|
@@ -29,6 +30,7 @@ export declare type ThemeTogglerProps<ITEM = ThemeTogglerItemDefault> = PropsWit
|
|
|
29
30
|
direction?: Direction;
|
|
30
31
|
possibleDirections?: readonly Direction[];
|
|
31
32
|
children?: never;
|
|
33
|
+
view?: ButtonPropView;
|
|
32
34
|
}, HTMLButtonElement> & (ITEM extends {
|
|
33
35
|
key: ThemeTogglerItemDefault['key'];
|
|
34
36
|
} ? {} : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["themeTogglerPropSize","themeTogglerPropSizeDefault"],"sources":["../../../../../src/components/ThemeToggler/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","names":["themeTogglerPropSize","themeTogglerPropSizeDefault"],"sources":["../../../../../src/components/ThemeToggler/types.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\n\nimport { ButtonPropView } from '##/components/Button';\nimport { Direction } from '##/components/Popover';\nimport { PropsWithHTMLAttributesAndRef } from '##/utils/types/PropsWithHTMLAttributes';\n\nexport const themeTogglerPropSize = ['m', 'l', 's', 'xs'] as const;\nexport type ThemeTogglerPropSize = typeof themeTogglerPropSize[number];\nexport const themeTogglerPropSizeDefault: ThemeTogglerPropSize =\n themeTogglerPropSize[0];\n\nexport type ThemeTogglerPropSetValue<ITEM> = (props: {\n e: React.MouseEvent;\n value: ITEM;\n}) => void;\nexport type ThemeTogglerPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type ThemeTogglerPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type ThemeTogglerPropGetItemIcon<ITEM> = (item: ITEM) => IconComponent;\n\nexport type ThemeTogglerItemDefault = {\n key: string;\n label: string;\n icon: IconComponent;\n};\n\nexport type ThemeTogglerProps<ITEM = ThemeTogglerItemDefault> =\n PropsWithHTMLAttributesAndRef<\n {\n size?: ThemeTogglerPropSize;\n className?: string;\n items: ITEM[];\n value: ITEM;\n onChange: ThemeTogglerPropSetValue<ITEM>;\n getItemKey?: ThemeTogglerPropGetItemKey<ITEM>;\n getItemLabel?: ThemeTogglerPropGetItemLabel<ITEM>;\n getItemIcon?: ThemeTogglerPropGetItemIcon<ITEM>;\n direction?: Direction;\n possibleDirections?: readonly Direction[];\n children?: never;\n view?: ButtonPropView;\n },\n HTMLButtonElement\n > &\n (ITEM extends { key: ThemeTogglerItemDefault['key'] }\n ? {}\n : { getItemKey: ThemeTogglerPropGetItemLabel<ITEM> }) &\n (ITEM extends { label: ThemeTogglerItemDefault['label'] }\n ? {}\n : { getItemLabel: ThemeTogglerPropGetItemLabel<ITEM> }) &\n (ITEM extends { icon: ThemeTogglerItemDefault['icon'] }\n ? {}\n : { getItemIcon: ThemeTogglerPropGetItemIcon<ITEM> });\n\nexport type ThemeTogglerComponent = <ITEM>(\n props: ThemeTogglerProps<ITEM>,\n) => React.ReactElement | null;\n"],"mappings":"AAMA,MAAO,IAAMA,qBAAoB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAgB,IAAhB,CAA7B,CAEP,MAAO,IAAMC,4BAAiD,CAC5DD,oBAAoB,CAAC,CAAD,CADf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","className","size","avatarUrl","name","view","width","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status"];import"./User.css";import{IconSelect}from"@consta/icons/IconSelect";import React from"react";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{forwardRefWithAs}from"../../utils/types/PropsWithAsAttributes";import{Avatar}from"../Avatar/Avatar";import{Button}from"../Button/Button";import{Text}from"../Text/Text";export var userPropSize=["m","s","l"];export var userPropSizeDefault=userPropSize[0];export var userPropView=["clear","ghost"];export var userPropViewDefault=userPropView[0];export var userPropWidth=["default","full"];export var userPropWidthDefault=userPropWidth[0];export var userPropStatus=["available","remote","out"];export var cnUser=cn("User");var infoSizeMap={s:"2xs",m:"2xs",l:"xs"},iconSizeMap={s:"xs",m:"xs",l:"s"},avatarSizeMap={s:"xs",m:"s",l:"m"},buttonSizeMap={s:"xs",m:"xs",l:"s"};export var User=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"div":c,e=a.className,f=a.size,g=void 0===f?userPropSizeDefault:f,h=a.avatarUrl,i=a.name,j=a.view,k=void 0===j?userPropViewDefault:j,l=a.width,m=void 0===l?userPropWidthDefault:l,n=a.onlyAvatar,o=a.withArrow,p=a.iconRight,q=a.onIconRightClick,r=a.info,s=a.status,t=_objectWithoutProperties(a,_excluded),u=n||!i&&!r,v=p;return React.createElement(d,Object.assign({},t,{className:cnUser({size:g,view:k,width:m,withArrow:o,minified:u},[e]),ref:b}),React.createElement("div",{className:cnUser("AvatarWrapper",{status:s})},React.createElement(Avatar,{size:getByMap(avatarSizeMap,g),url:h,name:i})),!u&&(i||r)&&React.createElement("div",{className:cnUser("Block")},i&&React.createElement(Text,{className:cnUser("Name"),size:g,view:"primary",lineHeight:"2xs"},i),r&&"s"!==g&&React.createElement(Text,{className:cnUser("Info"),size:getByMap(infoSizeMap,g),view:"secondary",lineHeight:"2xs"},r)),o&&React.createElement(IconSelect,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&!q&&React.createElement(v,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&q&&React.createElement(Button,{className:cnUser("IconRightButton"),onClick:q,iconRight:v,onlyIcon:!0,view:"clear",size:getByMap(buttonSizeMap,g),form:"round"}))});
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["as","className","size","avatarUrl","name","view","width","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status"];import"./User.css";import{IconSelect}from"@consta/icons/IconSelect";import React from"react";import{cn}from"../../utils/bem";import{getByMap}from"../../utils/getByMap";import{forwardRefWithAs}from"../../utils/types/PropsWithAsAttributes";import{Avatar}from"../Avatar/Avatar";import{Button}from"../Button/Button";import{Text}from"../Text/Text";export var userPropSize=["m","s","l"];export var userPropSizeDefault=userPropSize[0];export var userPropView=["clear","ghost"];export var userPropViewDefault=userPropView[0];export var userPropWidth=["default","full"];export var userPropWidthDefault=userPropWidth[0];export var userPropStatus=["available","remote","out"];export var cnUser=cn("User");var infoSizeMap={s:"2xs",m:"2xs",l:"xs"},iconSizeMap={s:"xs",m:"xs",l:"s"},avatarSizeMap={s:"xs",m:"s",l:"m"},buttonSizeMap={s:"xs",m:"xs",l:"s"};export var User=forwardRefWithAs(function(a,b){var c=a.as,d=void 0===c?"div":c,e=a.className,f=a.size,g=void 0===f?userPropSizeDefault:f,h=a.avatarUrl,i=a.name,j=a.view,k=void 0===j?userPropViewDefault:j,l=a.width,m=void 0===l?userPropWidthDefault:l,n=a.onlyAvatar,o=a.withArrow,p=a.iconRight,q=a.onIconRightClick,r=a.info,s=a.status,t=_objectWithoutProperties(a,_excluded),u=n||!i&&!r,v=p;return React.createElement(d,Object.assign({},t,{className:cnUser({size:g,view:k,width:m,withArrow:o,minified:u},[e]),ref:b}),React.createElement("div",{className:cnUser("AvatarWrapper",{status:s})},React.createElement(Avatar,{size:getByMap(avatarSizeMap,g),url:h,name:i})),!u&&(i||r)&&React.createElement("div",{className:cnUser("Block")},i&&React.createElement(Text,{className:cnUser("Name"),size:g,view:"primary",lineHeight:"2xs"},i),r&&"s"!==g&&React.createElement(Text,{className:cnUser("Info"),size:getByMap(infoSizeMap,g),view:"secondary",lineHeight:"2xs"},r)),o&&React.createElement(IconSelect,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&!q&&React.createElement(v,{className:cnUser("Icon"),size:getByMap(iconSizeMap,g),view:"secondary"}),v&&q&&React.createElement(Button,{className:cnUser("IconRightButton"),onClick:q,iconRight:v,onlyIcon:!0,type:"button",view:"clear",size:getByMap(buttonSizeMap,g),form:"round"}))});
|
|
2
2
|
//# sourceMappingURL=User.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","names":["IconSelect","React","cn","getByMap","forwardRefWithAs","Avatar","Button","Text","userPropSize","userPropSizeDefault","userPropView","userPropViewDefault","userPropWidth","userPropWidthDefault","userPropStatus","cnUser","infoSizeMap","s","m","l","iconSizeMap","avatarSizeMap","buttonSizeMap","User","props","ref","as","className","size","avatarUrl","name","view","width","propOnlyAvatar","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status","otherProps","IconRight","minified"],"sources":["../../../../../src/components/User/User.tsx"],"sourcesContent":["import './User.css';\n\nimport { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';\nimport { Avatar } from '../Avatar/Avatar';\nimport { Button, ButtonPropSize } from '../Button/Button';\nimport { Text, TextPropSize } from '../Text/Text';\n\nexport const userPropSize = ['m', 's', 'l'] as const;\nexport type UserPropSize = typeof userPropSize[number];\nexport const userPropSizeDefault: UserPropSize = userPropSize[0];\n\nexport const userPropView = ['clear', 'ghost'] as const;\nexport type UserPropView = typeof userPropView[number];\nexport const userPropViewDefault: UserPropView = userPropView[0];\n\nexport const userPropWidth = ['default', 'full'] as const;\nexport type UserPropWidth = typeof userPropWidth[number];\nexport const userPropWidthDefault: UserPropWidth = userPropWidth[0];\n\nexport const userPropStatus = ['available', 'remote', 'out'] as const;\nexport type UserPropStatus = typeof userPropStatus[number];\n\ntype Props = {\n avatarUrl?: string;\n name?: string;\n size?: UserPropSize;\n view?: UserPropView;\n width?: UserPropWidth;\n status?: UserPropStatus;\n onlyAvatar?: boolean;\n info?: string;\n children?: never;\n} & (\n | {\n withArrow?: boolean;\n iconRight?: never;\n onIconRightClick?: never;\n }\n | {\n withArrow?: never;\n iconRight?: IconComponent;\n onIconRightClick?: (e: React.SyntheticEvent) => void;\n }\n);\n\nexport const cnUser = cn('User');\n\nconst infoSizeMap: Record<UserPropSize, TextPropSize> = {\n s: '2xs',\n m: '2xs',\n l: 'xs',\n};\n\nconst iconSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nconst avatarSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nconst buttonSizeMap: Record<UserPropSize, ButtonPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nexport const User = forwardRefWithAs<Props>((props, ref) => {\n const {\n as = 'div',\n className,\n size = userPropSizeDefault,\n avatarUrl,\n name,\n view = userPropViewDefault,\n width = userPropWidthDefault,\n onlyAvatar: propOnlyAvatar,\n withArrow,\n iconRight,\n onIconRightClick,\n info,\n status,\n ...otherProps\n } = props;\n const Tag = as as string;\n const onlyAvatar = propOnlyAvatar || (!name && !info);\n const IconRight = iconRight;\n\n return (\n <Tag\n {...otherProps}\n className={cnUser(\n { size, view, width, withArrow, minified: onlyAvatar },\n [className],\n )}\n ref={ref}\n >\n <div className={cnUser('AvatarWrapper', { status })}>\n <Avatar\n size={getByMap(avatarSizeMap, size)}\n url={avatarUrl}\n name={name}\n />\n </div>\n {!onlyAvatar && (name || info) && (\n <div className={cnUser('Block')}>\n {name && (\n <Text\n className={cnUser('Name')}\n size={size}\n view=\"primary\"\n lineHeight=\"2xs\"\n >\n {name}\n </Text>\n )}\n {info && size !== 's' && (\n <Text\n className={cnUser('Info')}\n size={getByMap(infoSizeMap, size)}\n view=\"secondary\"\n lineHeight=\"2xs\"\n >\n {info}\n </Text>\n )}\n </div>\n )}\n {withArrow && (\n <IconSelect\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && !onIconRightClick && (\n <IconRight\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && onIconRightClick && (\n <Button\n className={cnUser('IconRightButton')}\n onClick={onIconRightClick}\n iconRight={IconRight}\n onlyIcon\n view=\"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cn","getByMap","forwardRefWithAs","Avatar","Button","Text","userPropSize","userPropSizeDefault","userPropView","userPropViewDefault","userPropWidth","userPropWidthDefault","userPropStatus","cnUser","infoSizeMap","s","m","l","iconSizeMap","avatarSizeMap","buttonSizeMap","User","props","ref","as","className","size","avatarUrl","name","view","width","propOnlyAvatar","onlyAvatar","withArrow","iconRight","onIconRightClick","info","status","otherProps","IconRight","minified"],"sources":["../../../../../src/components/User/User.tsx"],"sourcesContent":["import './User.css';\n\nimport { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { getByMap } from '../../utils/getByMap';\nimport { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';\nimport { Avatar } from '../Avatar/Avatar';\nimport { Button, ButtonPropSize } from '../Button/Button';\nimport { Text, TextPropSize } from '../Text/Text';\n\nexport const userPropSize = ['m', 's', 'l'] as const;\nexport type UserPropSize = typeof userPropSize[number];\nexport const userPropSizeDefault: UserPropSize = userPropSize[0];\n\nexport const userPropView = ['clear', 'ghost'] as const;\nexport type UserPropView = typeof userPropView[number];\nexport const userPropViewDefault: UserPropView = userPropView[0];\n\nexport const userPropWidth = ['default', 'full'] as const;\nexport type UserPropWidth = typeof userPropWidth[number];\nexport const userPropWidthDefault: UserPropWidth = userPropWidth[0];\n\nexport const userPropStatus = ['available', 'remote', 'out'] as const;\nexport type UserPropStatus = typeof userPropStatus[number];\n\ntype Props = {\n avatarUrl?: string;\n name?: string;\n size?: UserPropSize;\n view?: UserPropView;\n width?: UserPropWidth;\n status?: UserPropStatus;\n onlyAvatar?: boolean;\n info?: string;\n children?: never;\n} & (\n | {\n withArrow?: boolean;\n iconRight?: never;\n onIconRightClick?: never;\n }\n | {\n withArrow?: never;\n iconRight?: IconComponent;\n onIconRightClick?: (e: React.SyntheticEvent) => void;\n }\n);\n\nexport const cnUser = cn('User');\n\nconst infoSizeMap: Record<UserPropSize, TextPropSize> = {\n s: '2xs',\n m: '2xs',\n l: 'xs',\n};\n\nconst iconSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nconst avatarSizeMap: Record<UserPropSize, IconPropSize> = {\n s: 'xs',\n m: 's',\n l: 'm',\n};\n\nconst buttonSizeMap: Record<UserPropSize, ButtonPropSize> = {\n s: 'xs',\n m: 'xs',\n l: 's',\n};\n\nexport const User = forwardRefWithAs<Props>((props, ref) => {\n const {\n as = 'div',\n className,\n size = userPropSizeDefault,\n avatarUrl,\n name,\n view = userPropViewDefault,\n width = userPropWidthDefault,\n onlyAvatar: propOnlyAvatar,\n withArrow,\n iconRight,\n onIconRightClick,\n info,\n status,\n ...otherProps\n } = props;\n const Tag = as as string;\n const onlyAvatar = propOnlyAvatar || (!name && !info);\n const IconRight = iconRight;\n\n return (\n <Tag\n {...otherProps}\n className={cnUser(\n { size, view, width, withArrow, minified: onlyAvatar },\n [className],\n )}\n ref={ref}\n >\n <div className={cnUser('AvatarWrapper', { status })}>\n <Avatar\n size={getByMap(avatarSizeMap, size)}\n url={avatarUrl}\n name={name}\n />\n </div>\n {!onlyAvatar && (name || info) && (\n <div className={cnUser('Block')}>\n {name && (\n <Text\n className={cnUser('Name')}\n size={size}\n view=\"primary\"\n lineHeight=\"2xs\"\n >\n {name}\n </Text>\n )}\n {info && size !== 's' && (\n <Text\n className={cnUser('Info')}\n size={getByMap(infoSizeMap, size)}\n view=\"secondary\"\n lineHeight=\"2xs\"\n >\n {info}\n </Text>\n )}\n </div>\n )}\n {withArrow && (\n <IconSelect\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && !onIconRightClick && (\n <IconRight\n className={cnUser('Icon')}\n size={getByMap(iconSizeMap, size)}\n view=\"secondary\"\n />\n )}\n {IconRight && onIconRightClick && (\n <Button\n className={cnUser('IconRightButton')}\n onClick={onIconRightClick}\n iconRight={IconRight}\n onlyIcon\n type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OE,IAAI,CAAEtC,QAAQ,CAACmB,aAAD,CAAgBM,CAAhB,CAPhB,CAQE,IAAI,CAAC,OARP,EAtDJ,CAmEH,CAzFmC,CAA7B"}
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare type UseDropdownVisiblePropOnFocus = [
|
|
3
|
-
React.FocusEventHandler<HTMLElement>?,
|
|
4
|
-
React.FocusEventHandler<HTMLElement>?
|
|
5
|
-
] | React.FocusEventHandler<HTMLElement>;
|
|
6
|
-
declare type FieldType = 'start' | 'end' | undefined;
|
|
7
|
-
declare type FieldResult = {
|
|
8
|
-
flag: boolean;
|
|
9
|
-
onFocus: React.FocusEventHandler<HTMLElement>;
|
|
10
|
-
onBlur: React.FocusEventHandler<HTMLElement>;
|
|
11
|
-
};
|
|
12
|
-
declare type UseDropdownVisibleResult = {
|
|
13
|
-
calendarVisible: boolean;
|
|
14
|
-
blocks: {
|
|
15
|
-
start: FieldResult;
|
|
16
|
-
end: FieldResult;
|
|
17
|
-
dropdown: FieldResult;
|
|
18
|
-
};
|
|
19
|
-
close: () => void;
|
|
20
|
-
fieldType: FieldType;
|
|
21
|
-
};
|
|
22
|
-
declare type UseDropdownVisible = (onFocus: UseDropdownVisiblePropOnFocus | undefined, onBlur?: UseDropdownVisiblePropOnFocus) => UseDropdownVisibleResult;
|
|
23
|
-
export declare const useDropdownVisible: UseDropdownVisible;
|
|
24
|
-
export {};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useEffect,useState}from"react";import{useFlag}from"../../hooks/useFlag";export var useDropdownVisible=function(a,b){var c=useFlag(),d=_slicedToArray(c,2),e=d[0],f=d[1],g=useState(),h=_slicedToArray(g,2),i=h[0],j=h[1],k=useFlag(!1),l=_slicedToArray(k,2),m=l[0],n=l[1],o=useFlag(),p=_slicedToArray(o,2),q=p[0],r=p[1];useEffect(function(){m||e?r.on():r.off()},[e,m]);return{calendarVisible:q,close:function close(){r.off(),f.off(),n.off()},blocks:{start:{flag:e,onFocus:function onStartFocus(b){var c;j("start"),f.on(),Array.isArray(a)?null===(c=a[0])||void 0===c?void 0:c.call(a,b):null===a||void 0===a?void 0:a(b)},onBlur:function onStartBlur(a){var c;Array.isArray(b)?null===(c=b[0])||void 0===c?void 0:c.call(b,a):null===b||void 0===b?void 0:b(a),f.off()}},end:{flag:e,onFocus:function onEndFocus(b){var c;j("end"),f.on(),Array.isArray(a)?null===(c=a[1])||void 0===c?void 0:c.call(a,b):null===a||void 0===a?void 0:a(b)},onBlur:function onEndBlur(a){var c;Array.isArray(b)?null===(c=b[1])||void 0===c?void 0:c.call(b,a):null===b||void 0===b?void 0:b(a),f.off()}},dropdown:{flag:m,onFocus:function(){return n.on()},onBlur:function(){return n.off()}}},fieldType:i}};
|
|
2
|
-
//# sourceMappingURL=useDropdownVisible.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdownVisible.js","names":["useEffect","useState","useFlag","useDropdownVisible","onFocus","onBlur","fieldFocused","setFieldFocused","fieldType","setFieldType","dropdownFocused","setDropdownFocused","calendarVisible","setCalendarVisible","on","off","close","blocks","start","flag","onStartFocus","e","Array","isArray","onStartBlur","end","onEndFocus","onEndBlur","dropdown"],"sources":["../../../../../src/components/DatePicker/useDropdownVisible.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { useFlag } from '##/hooks/useFlag';\n\ntype UseDropdownVisiblePropOnFocus =\n | [\n React.FocusEventHandler<HTMLElement>?,\n React.FocusEventHandler<HTMLElement>?,\n ]\n | React.FocusEventHandler<HTMLElement>;\n\ntype FieldType = 'start' | 'end' | undefined;\n\ntype FieldResult = {\n flag: boolean;\n onFocus: React.FocusEventHandler<HTMLElement>;\n onBlur: React.FocusEventHandler<HTMLElement>;\n};\n\ntype UseDropdownVisibleResult = {\n calendarVisible: boolean;\n blocks: {\n start: FieldResult;\n end: FieldResult;\n dropdown: FieldResult;\n };\n close: () => void;\n fieldType: FieldType;\n};\n\ntype UseDropdownVisible = (\n onFocus: UseDropdownVisiblePropOnFocus | undefined,\n onBlur?: UseDropdownVisiblePropOnFocus,\n) => UseDropdownVisibleResult;\n\nexport const useDropdownVisible: UseDropdownVisible = (onFocus, onBlur) => {\n const [fieldFocused, setFieldFocused] = useFlag();\n const [fieldType, setFieldType] = useState<FieldType>();\n const [dropdownFocused, setDropdownFocused] = useFlag(false);\n\n const [calendarVisible, setCalendarVisible] = useFlag();\n\n useEffect(() => {\n if (dropdownFocused || fieldFocused) {\n setCalendarVisible.on();\n } else {\n setCalendarVisible.off();\n }\n }, [fieldFocused, dropdownFocused]);\n\n const onStartFocus = (e: React.FocusEvent<HTMLElement>) => {\n setFieldType('start');\n setFieldFocused.on();\n Array.isArray(onFocus) ? onFocus[0]?.(e) : onFocus?.(e);\n };\n\n const onEndFocus = (e: React.FocusEvent<HTMLElement>) => {\n setFieldType('end');\n setFieldFocused.on();\n Array.isArray(onFocus) ? onFocus[1]?.(e) : onFocus?.(e);\n };\n\n const onStartBlur = (e: React.FocusEvent<HTMLElement>) => {\n Array.isArray(onBlur) ? onBlur[0]?.(e) : onBlur?.(e);\n setFieldFocused.off();\n };\n\n const onEndBlur = (e: React.FocusEvent<HTMLElement>) => {\n Array.isArray(onBlur) ? onBlur[1]?.(e) : onBlur?.(e);\n setFieldFocused.off();\n };\n\n const close = () => {\n setCalendarVisible.off();\n setFieldFocused.off();\n setDropdownFocused.off();\n };\n\n return {\n calendarVisible,\n close,\n blocks: {\n start: {\n flag: fieldFocused,\n onFocus: onStartFocus,\n onBlur: onStartBlur,\n },\n end: {\n flag: fieldFocused,\n onFocus: onEndFocus,\n onBlur: onEndBlur,\n },\n dropdown: {\n flag: dropdownFocused,\n onFocus: () => setDropdownFocused.on(),\n onBlur: () => setDropdownFocused.off(),\n },\n },\n fieldType,\n };\n};\n"],"mappings":"iEAAA,OAASA,SAAT,CAAoBC,QAApB,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