@consta/uikit 5.25.0 → 5.26.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/FlatSelect/index.d.ts +1 -0
- package/FlatSelect/index.js +1 -0
- package/__internal__/src/components/Combobox/Combobox.js +1 -1
- package/__internal__/src/components/Combobox/Combobox.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenu.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenu.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.d.ts +2 -2
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js.map +1 -1
- package/__internal__/src/components/ContextMenu/helpers.d.ts +2 -2
- package/__internal__/src/components/ContextMenu/types.d.ts +5 -5
- package/__internal__/src/components/ContextMenu/types.js.map +1 -1
- package/__internal__/src/components/FieldComponents/FieldButton/FieldButton.d.ts +1 -1
- package/__internal__/src/components/FieldComponents/FieldButton/FieldButton.js.map +1 -1
- package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.d.ts +1 -0
- package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.js +1 -1
- package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.js.map +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelect.css +9 -0
- package/__internal__/src/components/FlatSelect/FlatSelect.d.ts +4 -0
- package/__internal__/src/components/FlatSelect/FlatSelect.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelect.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.d.ts +16 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.d.ts +19 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.d.ts +12 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.d.ts +10 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.d.ts +17 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItem/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.d.ts +17 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.d.ts +53 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectList/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.d.ts +3 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.d.ts +24 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.css +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.d.ts +14 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.js +2 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/defaultProps.d.ts +22 -0
- package/__internal__/src/components/FlatSelect/defaultProps.js +2 -0
- package/__internal__/src/components/FlatSelect/defaultProps.js.map +1 -0
- package/__internal__/src/components/FlatSelect/index.d.ts +2 -0
- package/__internal__/src/components/FlatSelect/index.js +2 -0
- package/__internal__/src/components/FlatSelect/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/types.d.ts +133 -0
- package/__internal__/src/components/FlatSelect/types.js +2 -0
- package/__internal__/src/components/FlatSelect/types.js.map +1 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.d.ts +4 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.js +2 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.js.map +1 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/index.js +2 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.d.ts +52 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.js +2 -0
- package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.js.map +1 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/index.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/index.js +2 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/index.js.map +1 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.d.ts +10 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.js +2 -0
- package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.js.map +1 -0
- package/__internal__/src/components/ListCanary/ListBox/ListBox.js +1 -1
- package/__internal__/src/components/ListCanary/ListBox/ListBox.js.map +1 -1
- package/__internal__/src/components/ListCanary/types.d.ts +1 -0
- package/__internal__/src/components/ListCanary/types.js.map +1 -1
- package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.d.ts +1 -0
- package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.js +1 -1
- package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.js.map +1 -1
- package/__internal__/src/components/Popover/Popover.d.ts +2 -2
- package/__internal__/src/components/Popover/Popover.js.map +1 -1
- package/__internal__/src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.d.ts +1 -0
- package/__internal__/src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.js +1 -1
- package/__internal__/src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.js.map +1 -1
- package/__internal__/src/components/ProgressStepBar/helpers.d.ts +0 -1
- package/__internal__/src/components/ProgressStepBar/helpers.js +1 -1
- package/__internal__/src/components/ProgressStepBar/helpers.js.map +1 -1
- package/__internal__/src/components/SelectCanary/helpers.d.ts +1 -1
- package/__internal__/src/components/Sidebar/Sidebar.d.ts +1 -1
- package/__internal__/src/components/Sidebar/Sidebar.js.map +1 -1
- package/__internal__/src/components/ThemeToggler/helpers.d.ts +1 -1
- package/__internal__/src/components/ThemeToggler/types.d.ts +1 -1
- package/__internal__/src/components/ThemeToggler/types.js.map +1 -1
- package/__internal__/src/components/Tooltip/types.d.ts +1 -1
- package/__internal__/src/components/Tooltip/types.js.map +1 -1
- package/__internal__/src/components/TooltipDeprecated/TooltipDeprecated.d.ts +1 -1
- package/__internal__/src/components/TooltipDeprecated/TooltipDeprecated.js.map +1 -1
- package/__internal__/src/utils/state/useClickOutsideAtom/index.d.ts +1 -0
- package/__internal__/src/utils/state/useClickOutsideAtom/index.js +2 -0
- package/__internal__/src/utils/state/useClickOutsideAtom/index.js.map +1 -0
- package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.d.ts +9 -0
- package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.js +2 -0
- package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.js.map +1 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/index.d.ts +1 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/index.js +2 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/index.js.map +1 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.d.ts +2 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js +2 -0
- package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js.map +1 -0
- package/__internal__/src/utils/state/useKeysAtom/index.d.ts +1 -0
- package/__internal__/src/utils/state/useKeysAtom/index.js +2 -0
- package/__internal__/src/utils/state/useKeysAtom/index.js.map +1 -0
- package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.d.ts +14 -0
- package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.js +2 -0
- package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.js.map +1 -0
- package/__internal__/src/utils/state/useRefAtom/useRefAtom.d.ts +1 -1
- package/__internal__/src/utils/state/useRefAtom/useRefAtom.js.map +1 -1
- package/__internal__/src/utils/state/withCtx/withCtx.js +1 -1
- package/__internal__/src/utils/state/withCtx/withCtx.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","names":["React","forwardRef","useEffect","useLayoutEffect","useMemo","PortalWithTheme","PortalWithThemeConsumer","useTheme","useComponentSize","useForkRef","cn","isRenderProp","isNumber","isString","getComputedPositionAndDirection","getPointPosition","getRenderPosition","usePopoverReposition","directionsStartCenter","directionsStartEdge","popoverPropOffset","directions","getOffset","ref","propOffset","current","cssVar","getComputedStyle","getPropertyValue","test","slice","length","fontSize","parseFloat","document","documentElement","rem","em","cnPopover","Popover","props","componentRef","children","direction","passedDirection","offset","arrowOffset","possibleDirections","isInteractive","onClickOutside","spareDirection","style","className","passedPosition","position","anchorRef","equalAnchorWidth","onSetDirection","viewportRef","container","window","body","otherProps","viewportElement","useRef","theme","useState","anchorClientRect","setAnchorClientRect","width","height","anchorSize","previousDirectionRef","bannedDirections","setBannedDirections","resetBannedDirections","state","updateAnchorClientRect","getBoundingClientRect","contentSize","viewportSize","clientWidth","clientHeight","x","left","y","top","isActive","scrollAnchorRef","onRequestReposition","includes","renderPosition","notVisible"],"sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import './Popover.css';\n\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport {\n PortalWithTheme,\n PortalWithThemeConsumer,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { ClickOutsideHandler } from '##/hooks/useClickOutside';\nimport { useComponentSize } from '##/hooks/useComponentSize';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cn } from '##/utils/bem';\nimport { isRenderProp } from '##/utils/isRenderProp';\nimport { isNumber, isString } from '##/utils/type-guards';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport {\n getComputedPositionAndDirection,\n getPointPosition,\n getRenderPosition,\n} from './helpers';\nimport { usePopoverReposition } from './usePopoverReposition';\n\n/**\n * Стороны упорядочены по приоритету:\n * Используется первая сторона, в которую смог вписаться поповер.\n */\nexport const directionsStartCenter = [\n 'downCenter',\n 'upCenter',\n\n 'downRight',\n 'downLeft',\n 'upRight',\n 'upLeft',\n\n 'leftUp',\n 'leftCenter',\n 'leftDown',\n\n 'rightUp',\n 'rightCenter',\n 'rightDown',\n] as const;\n\nexport const directionsStartEdge = [\n 'downStartLeft',\n 'upStartLeft',\n\n 'downStartRight',\n 'upStartRight',\n\n 'leftStartUp',\n 'leftStartDown',\n\n 'rightStartUp',\n 'rightStartDown',\n] as const;\n\nexport const popoverPropOffset = [\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n] as const;\nexport type PopoverPropOffset = typeof popoverPropOffset[number] | number;\n\nexport const directions = [...directionsStartCenter, ...directionsStartEdge];\n\nexport type Direction = typeof directions[number];\n\nexport type Position = { x: number; y: number } | undefined;\n\nexport type PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n equalAnchorWidth?: boolean;\n position?: never;\n }\n | {\n anchorRef?: never;\n equalAnchorWidth?: never;\n position: Position;\n };\n\ntype ChildrenRenderProp = (direction: Direction) => React.ReactNode;\n\nexport type PopoverProps = PropsWithJsxAttributes<\n {\n direction?: Direction;\n spareDirection?: Direction;\n offset?: PopoverPropOffset;\n arrowOffset?: number;\n possibleDirections?: readonly Direction[];\n isInteractive?: boolean;\n children: React.ReactNode | ChildrenRenderProp;\n onClickOutside?: ClickOutsideHandler;\n onSetDirection?: (direction: Direction) => void;\n viewportRef?: React.RefObject<HTMLElement>;\n container?: Element;\n } & PositioningProps\n>;\n\nexport type Props = PopoverProps; // удалить при мажоре\n\nconst getOffset = (\n ref: React.RefObject<HTMLDivElement>,\n propOffset: PopoverPropOffset,\n) => {\n if (isNumber(propOffset)) {\n return propOffset;\n }\n\n if (isString(propOffset) && ref.current) {\n const cssVar = getComputedStyle(ref.current).getPropertyValue(\n `--space-${propOffset}`,\n );\n\n if (cssVar && /px$/.test(cssVar)) {\n return Number(cssVar.slice(0, cssVar.length - 2));\n }\n\n if (cssVar && /rem$/.test(cssVar)) {\n const fontSize = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n );\n const rem = Number(cssVar.slice(0, cssVar.length - 3));\n\n return fontSize * rem;\n }\n\n if (cssVar && /em$/.test(cssVar)) {\n const fontSize = parseFloat(getComputedStyle(ref.current).fontSize);\n const em = Number(cssVar.slice(0, cssVar.length - 2));\n\n return fontSize * em;\n }\n\n return 0;\n }\n\n return 0;\n};\n\nconst cnPopover = cn('Popover');\n\nexport const Popover = forwardRef<HTMLDivElement, PopoverProps>(\n (props, componentRef) => {\n const {\n children,\n direction: passedDirection = 'upCenter',\n offset: propOffset = 0,\n arrowOffset,\n possibleDirections = directions,\n isInteractive = true,\n onClickOutside,\n spareDirection = 'downStartLeft',\n style,\n className,\n position: passedPosition,\n anchorRef,\n equalAnchorWidth,\n onSetDirection,\n viewportRef,\n container = window.document.body,\n ...otherProps\n } = props;\n\n const viewportElement = viewportRef?.current || document.documentElement;\n\n const ref = React.useRef<HTMLDivElement>(null);\n const { theme } = useTheme();\n\n const [anchorClientRect, setAnchorClientRect] = React.useState<\n DOMRect | undefined\n >();\n const { width, height } = useComponentSize(ref);\n const anchorSize = useComponentSize(anchorRef || { current: null });\n const previousDirectionRef = React.useRef<Direction | null>(null);\n const [bannedDirections, setBannedDirections] = React.useState<\n readonly Direction[]\n >([]);\n\n const resetBannedDirections = () => {\n setBannedDirections((state) => (state.length ? [] : state));\n previousDirectionRef.current = null;\n };\n\n const updateAnchorClientRect = () =>\n setAnchorClientRect(anchorRef?.current?.getBoundingClientRect());\n\n const offset = useMemo(\n () => getOffset(ref, propOffset),\n [propOffset, Boolean(ref.current)],\n );\n\n const { position, direction } = getComputedPositionAndDirection({\n contentSize: { width, height },\n viewportSize: {\n // Размер вьюпорта без скроллбаров\n width: viewportElement.clientWidth,\n height: viewportElement.clientHeight,\n },\n arrowOffset,\n offset,\n direction: passedDirection,\n possibleDirections,\n bannedDirections,\n position: getPointPosition(\n viewportElement,\n anchorClientRect\n ? { x: anchorClientRect.left, y: anchorClientRect.top }\n : passedPosition,\n !!viewportRef?.current,\n ),\n anchorSize,\n spareDirection,\n });\n\n useEffect(() => onSetDirection?.(direction), [direction]);\n\n useEffect(updateAnchorClientRect, [anchorSize]);\n\n usePopoverReposition({\n isActive: true,\n scrollAnchorRef: anchorRef || { current: null },\n onRequestReposition: () => {\n resetBannedDirections();\n updateAnchorClientRect();\n },\n });\n\n /**\n * Может возникнуть ситуация, когда перерасчет поповера всегда будет выдавать 2 направления\n * и бесконечно зацикливать себя. Для избежания таких кейсов мы запоминаем стороны,\n * которые не подошли, чтобы не возвращаться к ним и предотвратить бесконечный ререндер.\n * См. PopoverBannedPositionsStory\n */\n\n useLayoutEffect(() => {\n if (previousDirectionRef.current !== direction) {\n if (\n previousDirectionRef.current &&\n !bannedDirections.includes(previousDirectionRef.current) &&\n !bannedDirections.includes(direction) &&\n direction !== spareDirection\n ) {\n setBannedDirections((state) =>\n previousDirectionRef.current\n ? [...state, previousDirectionRef.current]\n : state,\n );\n }\n previousDirectionRef.current = direction;\n }\n }, [direction]);\n\n // Сбрасываем при любом изменении пропсов, чтобы заново начать перебор направлений\n // Главное не сбрасывать при изменении размеров поповера, т.к. именно оно может вызвать бесконечный перебор\n\n useLayoutEffect(resetBannedDirections, [props]);\n\n const renderPosition = getRenderPosition(\n viewportElement,\n position,\n !!viewportRef?.current,\n width,\n height,\n );\n\n const notVisible = !renderPosition || !height || !width;\n\n return (\n <PortalWithTheme\n {...otherProps}\n preset={theme}\n className={cnPopover({ direction, notVisible }, [className])}\n container={container}\n ref={useForkRef([ref, componentRef])}\n style={{\n ...style,\n ...(notVisible\n ? {}\n : {\n ['--popover-left' as string]: `${renderPosition.x}px`,\n ['--popover-top' as string]: `${renderPosition.y}px`,\n [`--popover-width` as string]: equalAnchorWidth\n ? `${anchorSize.width}px`\n : undefined,\n [`--popover-pointer-events` as string]: isInteractive\n ? undefined\n : 'none',\n [`--popover-visibility` as string]: position\n ? undefined\n : 'hidden',\n }),\n }}\n >\n <PortalWithThemeConsumer\n onClickOutside={onClickOutside}\n ignoreClicksInsideRefs={[ref, anchorRef || { current: null }]}\n >\n {isRenderProp(children) ? children(direction) : children}\n </PortalWithThemeConsumer>\n </PortalWithTheme>\n );\n },\n);\n"],"mappings":"knCAAA,sBAEA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,eAAvC,CAAwDC,OAAxD,KAAuE,OAAvE,CAEA,OACEC,eADF,CAEEC,uBAFF,0BAIA,OAASC,QAAT,sBAEA,OAASC,gBAAT,oCACA,OAASC,UAAT,8BACA,OAASC,EAAT,uBACA,OAASC,YAAT,gCACA,OAASC,QAAT,CAAmBC,QAAnB,+BAGA,OACEC,+BADF,CAEEC,gBAFF,CAGEC,iBAHF,iBAKA,OAASC,oBAAT,8BAMA,MAAO,IAAMC,sBAAqB,CAAG,CACnC,YADmC,CAEnC,UAFmC,CAInC,WAJmC,CAKnC,UALmC,CAMnC,SANmC,CAOnC,QAPmC,CASnC,QATmC,CAUnC,YAVmC,CAWnC,UAXmC,CAanC,SAbmC,CAcnC,aAdmC,CAenC,WAfmC,CAA9B,CAkBP,MAAO,IAAMC,oBAAmB,CAAG,CACjC,eADiC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AE,CAAC1B,CAAD,CAAMgC,CAAS,EAAI,CAAE9B,OAAO,CAAE,IAAX,CAAnB,CAF1B,EAIGd,YAAY,CAAC+B,CAAD,CAAZ,CAAyBA,CAAQ,CAACC,CAAD,CAAjC,CAA+CD,CAJlD,CAzBF,CAiCH,CAhK8B,CAA1B"}
|
|
1
|
+
{"version":3,"file":"Popover.js","names":["React","forwardRef","useEffect","useLayoutEffect","useMemo","PortalWithTheme","PortalWithThemeConsumer","useTheme","useComponentSize","useForkRef","cn","isRenderProp","isNumber","isString","getComputedPositionAndDirection","getPointPosition","getRenderPosition","usePopoverReposition","directionsStartCenter","directionsStartEdge","popoverPropOffset","directions","getOffset","ref","propOffset","current","cssVar","getComputedStyle","getPropertyValue","test","slice","length","fontSize","parseFloat","document","documentElement","rem","em","cnPopover","Popover","props","componentRef","children","direction","passedDirection","offset","arrowOffset","possibleDirections","isInteractive","onClickOutside","spareDirection","style","className","passedPosition","position","anchorRef","equalAnchorWidth","onSetDirection","viewportRef","container","window","body","otherProps","viewportElement","useRef","theme","useState","anchorClientRect","setAnchorClientRect","width","height","anchorSize","previousDirectionRef","bannedDirections","setBannedDirections","resetBannedDirections","state","updateAnchorClientRect","getBoundingClientRect","contentSize","viewportSize","clientWidth","clientHeight","x","left","y","top","isActive","scrollAnchorRef","onRequestReposition","includes","renderPosition","notVisible"],"sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import './Popover.css';\n\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';\n\nimport {\n PortalWithTheme,\n PortalWithThemeConsumer,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { ClickOutsideHandler } from '##/hooks/useClickOutside';\nimport { useComponentSize } from '##/hooks/useComponentSize';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cn } from '##/utils/bem';\nimport { isRenderProp } from '##/utils/isRenderProp';\nimport { isNumber, isString } from '##/utils/type-guards';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport {\n getComputedPositionAndDirection,\n getPointPosition,\n getRenderPosition,\n} from './helpers';\nimport { usePopoverReposition } from './usePopoverReposition';\n\n/**\n * Стороны упорядочены по приоритету:\n * Используется первая сторона, в которую смог вписаться поповер.\n */\nexport const directionsStartCenter = [\n 'downCenter',\n 'upCenter',\n\n 'downRight',\n 'downLeft',\n 'upRight',\n 'upLeft',\n\n 'leftUp',\n 'leftCenter',\n 'leftDown',\n\n 'rightUp',\n 'rightCenter',\n 'rightDown',\n] as const;\n\nexport const directionsStartEdge = [\n 'downStartLeft',\n 'upStartLeft',\n\n 'downStartRight',\n 'upStartRight',\n\n 'leftStartUp',\n 'leftStartDown',\n\n 'rightStartUp',\n 'rightStartDown',\n] as const;\n\nexport const popoverPropOffset = [\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n] as const;\nexport type PopoverPropOffset = typeof popoverPropOffset[number] | number;\n\nexport const directions = [...directionsStartCenter, ...directionsStartEdge];\n\nexport type Direction = typeof directions[number];\n\nexport type Position = { x: number; y: number } | undefined;\n\nexport type PositioningProps =\n | {\n anchorRef: React.RefObject<HTMLElement>;\n equalAnchorWidth?: boolean;\n position?: never;\n }\n | {\n anchorRef?: never;\n equalAnchorWidth?: never;\n position: Position;\n };\n\ntype ChildrenRenderProp = (direction: Direction) => React.ReactNode;\n\nexport type PopoverProps = PropsWithJsxAttributes<\n {\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?: Direction[];\n offset?: PopoverPropOffset;\n arrowOffset?: number;\n isInteractive?: boolean;\n children?: React.ReactNode | ChildrenRenderProp;\n onClickOutside?: ClickOutsideHandler;\n onSetDirection?: (direction: Direction) => void;\n viewportRef?: React.RefObject<HTMLElement>;\n container?: Element;\n } & PositioningProps\n>;\n\nexport type Props = PopoverProps; // удалить при мажоре\n\nconst getOffset = (\n ref: React.RefObject<HTMLDivElement>,\n propOffset: PopoverPropOffset,\n) => {\n if (isNumber(propOffset)) {\n return propOffset;\n }\n\n if (isString(propOffset) && ref.current) {\n const cssVar = getComputedStyle(ref.current).getPropertyValue(\n `--space-${propOffset}`,\n );\n\n if (cssVar && /px$/.test(cssVar)) {\n return Number(cssVar.slice(0, cssVar.length - 2));\n }\n\n if (cssVar && /rem$/.test(cssVar)) {\n const fontSize = parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n );\n const rem = Number(cssVar.slice(0, cssVar.length - 3));\n\n return fontSize * rem;\n }\n\n if (cssVar && /em$/.test(cssVar)) {\n const fontSize = parseFloat(getComputedStyle(ref.current).fontSize);\n const em = Number(cssVar.slice(0, cssVar.length - 2));\n\n return fontSize * em;\n }\n\n return 0;\n }\n\n return 0;\n};\n\nconst cnPopover = cn('Popover');\n\nexport const Popover = forwardRef<HTMLDivElement, PopoverProps>(\n (props, componentRef) => {\n const {\n children,\n direction: passedDirection = 'upCenter',\n offset: propOffset = 0,\n arrowOffset,\n possibleDirections = directions,\n isInteractive = true,\n onClickOutside,\n spareDirection = 'downStartLeft',\n style,\n className,\n position: passedPosition,\n anchorRef,\n equalAnchorWidth,\n onSetDirection,\n viewportRef,\n container = window.document.body,\n ...otherProps\n } = props;\n\n const viewportElement = viewportRef?.current || document.documentElement;\n\n const ref = React.useRef<HTMLDivElement>(null);\n const { theme } = useTheme();\n\n const [anchorClientRect, setAnchorClientRect] = React.useState<\n DOMRect | undefined\n >();\n const { width, height } = useComponentSize(ref);\n const anchorSize = useComponentSize(anchorRef || { current: null });\n const previousDirectionRef = React.useRef<Direction | null>(null);\n const [bannedDirections, setBannedDirections] = React.useState<\n readonly Direction[]\n >([]);\n\n const resetBannedDirections = () => {\n setBannedDirections((state) => (state.length ? [] : state));\n previousDirectionRef.current = null;\n };\n\n const updateAnchorClientRect = () =>\n setAnchorClientRect(anchorRef?.current?.getBoundingClientRect());\n\n const offset = useMemo(\n () => getOffset(ref, propOffset),\n [propOffset, Boolean(ref.current)],\n );\n\n const { position, direction } = getComputedPositionAndDirection({\n contentSize: { width, height },\n viewportSize: {\n // Размер вьюпорта без скроллбаров\n width: viewportElement.clientWidth,\n height: viewportElement.clientHeight,\n },\n arrowOffset,\n offset,\n direction: passedDirection,\n possibleDirections,\n bannedDirections,\n position: getPointPosition(\n viewportElement,\n anchorClientRect\n ? { x: anchorClientRect.left, y: anchorClientRect.top }\n : passedPosition,\n !!viewportRef?.current,\n ),\n anchorSize,\n spareDirection,\n });\n\n useEffect(() => onSetDirection?.(direction), [direction]);\n\n useEffect(updateAnchorClientRect, [anchorSize]);\n\n usePopoverReposition({\n isActive: true,\n scrollAnchorRef: anchorRef || { current: null },\n onRequestReposition: () => {\n resetBannedDirections();\n updateAnchorClientRect();\n },\n });\n\n /**\n * Может возникнуть ситуация, когда перерасчет поповера всегда будет выдавать 2 направления\n * и бесконечно зацикливать себя. Для избежания таких кейсов мы запоминаем стороны,\n * которые не подошли, чтобы не возвращаться к ним и предотвратить бесконечный ререндер.\n * См. PopoverBannedPositionsStory\n */\n\n useLayoutEffect(() => {\n if (previousDirectionRef.current !== direction) {\n if (\n previousDirectionRef.current &&\n !bannedDirections.includes(previousDirectionRef.current) &&\n !bannedDirections.includes(direction) &&\n direction !== spareDirection\n ) {\n setBannedDirections((state) =>\n previousDirectionRef.current\n ? [...state, previousDirectionRef.current]\n : state,\n );\n }\n previousDirectionRef.current = direction;\n }\n }, [direction]);\n\n // Сбрасываем при любом изменении пропсов, чтобы заново начать перебор направлений\n // Главное не сбрасывать при изменении размеров поповера, т.к. именно оно может вызвать бесконечный перебор\n\n useLayoutEffect(resetBannedDirections, [props]);\n\n const renderPosition = getRenderPosition(\n viewportElement,\n position,\n !!viewportRef?.current,\n width,\n height,\n );\n\n const notVisible = !renderPosition || !height || !width;\n\n return (\n <PortalWithTheme\n {...otherProps}\n preset={theme}\n className={cnPopover({ direction, notVisible }, [className])}\n container={container}\n ref={useForkRef([ref, componentRef])}\n style={{\n ...style,\n ...(notVisible\n ? {}\n : {\n ['--popover-left' as string]: `${renderPosition.x}px`,\n ['--popover-top' as string]: `${renderPosition.y}px`,\n [`--popover-width` as string]: equalAnchorWidth\n ? `${anchorSize.width}px`\n : undefined,\n [`--popover-pointer-events` as string]: isInteractive\n ? undefined\n : 'none',\n [`--popover-visibility` as string]: position\n ? undefined\n : 'hidden',\n }),\n }}\n >\n <PortalWithThemeConsumer\n onClickOutside={onClickOutside}\n ignoreClicksInsideRefs={[ref, anchorRef || { current: null }]}\n >\n {isRenderProp(children) ? children(direction) : children}\n </PortalWithThemeConsumer>\n </PortalWithTheme>\n );\n },\n);\n"],"mappings":"knCAAA,sBAEA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,eAAvC,CAAwDC,OAAxD,KAAuE,OAAvE,CAEA,OACEC,eADF,CAEEC,uBAFF,0BAIA,OAASC,QAAT,sBAEA,OAASC,gBAAT,oCACA,OAASC,UAAT,8BACA,OAASC,EAAT,uBACA,OAASC,YAAT,gCACA,OAASC,QAAT,CAAmBC,QAAnB,+BAGA,OACEC,+BADF,CAEEC,gBAFF,CAGEC,iBAHF,iBAKA,OAASC,oBAAT,8BAMA,MAAO,IAAMC,sBAAqB,CAAG,CACnC,YADmC,CAEnC,UAFmC,CAInC,WAJmC,CAKnC,UALmC,CAMnC,SANmC,CAOnC,QAPmC,CASnC,QATmC,CAUnC,YAVmC,CAWnC,UAXmC,CAanC,SAbmC,CAcnC,aAdmC,CAenC,WAfmC,CAA9B,CAkBP,MAAO,IAAMC,oBAAmB,CAAG,CACjC,eADiC,CAEjC,aAFiC,CAIjC,gBAJiC,CAKjC,cALiC,CAOjC,aAPiC,CAQjC,eARiC,CAUjC,cAViC,CAWjC,gBAXiC,CAA5B,CAcP,MAAO,IAAMC,kBAAiB,CAAG,CAC/B,KAD+B,CAE/B,KAF+B,CAG/B,IAH+B,CAI/B,GAJ+B,CAK/B,GAL+B,CAM/B,GAN+B,CAO/B,IAP+B,CA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Item.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["content","tooltipContent","label","point","status","progress","direction","size","pointRef","onClick","position","tooltipZIndex","className"];import"./ProgressStepBarItem.css";import React,{useMemo,useRef}from"react";import{ProgressSpin}from"../../ProgressSpin";import{Text}from"../../Text";import{Tooltip}from"../../Tooltip";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef";import{useMouseLeave}from"../../../hooks/useMouseLeave";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cn}from"../../../utils/bem";import{progressStepBarPropPositionDefault,progressStepBarPropStatusDefault}from"../helpers";var cnProgressStepBarItem=cn("ProgressStepBarItem")
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["content","tooltipContent","label","point","status","progress","direction","size","pointRef","onClick","position","tooltipZIndex","className"];import"./ProgressStepBarItem.css";import React,{useMemo,useRef}from"react";import{ProgressSpin}from"../../ProgressSpin";import{Text}from"../../Text";import{Tooltip}from"../../Tooltip";import{useFlag}from"../../../hooks/useFlag/useFlag";import{useForkRef}from"../../../hooks/useForkRef";import{useMouseLeave}from"../../../hooks/useMouseLeave";import{cnMixFocus}from"../../../mixs/MixFocus/MixFocus";import{cn}from"../../../utils/bem";import{progressStepBarPropPositionDefault,progressStepBarPropStatusDefault}from"../helpers";export var cnProgressStepBarItem=cn("ProgressStepBarItem");var possibleVerticalDirections=["leftCenter","rightCenter","rightUp","downCenter"],possibleHorizontalDirections=["downCenter","upCenter","downStartLeft","downStartRight"],renderPointContent=function(a,b,c){if(c)return React.createElement(ProgressSpin,{size:b});if(!a)return null;if("number"==typeof a)return React.createElement(Text,{className:cnProgressStepBarItem("PointText"),size:"s"===b?"2xs":"xs",weight:"bold",view:"primary",lineHeight:"m"},a);return React.createElement(a,{className:cnProgressStepBarItem("PointIcon"),size:"xs"})};export var ProgressStepBarItem=React.forwardRef(function(a,b){var c=a.content,d=a.tooltipContent,e=a.label,f=a.point,g=a.status,h=a.progress,i=a.direction,j=a.size,k=a.pointRef,l=a.onClick,m=a.position,n=void 0===m?progressStepBarPropPositionDefault:m,o=a.tooltipZIndex,p=a.className,q=_objectWithoutProperties(a,_excluded),r=useFlag(),s=_slicedToArray(r,2),t=s[0],u=s[1],v=useRef(null),w=useRef(null),x=useRef(null),y=useForkRef([x,k]),z={onMouseEnter:u.on,className:cnProgressStepBarItem("Point",{size:j,pointer:!!l},[l?cnMixFocus():void 0]),children:"xs"!==j&&renderPointContent(f,j,h),ref:y,onClick:l},A=useMemo(function(){if("vertical"===i)return{tooltipDirection:"leftUp",possibleDirections:possibleVerticalDirections,spareDirection:"rightCenter"};var a="downCenter";return"start"===n&&(a="rightCenter"),"end"===n&&(a="leftCenter"),{tooltipDirection:"downCenter",possibleDirections:possibleHorizontalDirections,spareDirection:a}},[i,n]),B=A.tooltipDirection,C=A.possibleDirections,D=A.spareDirection;return useMouseLeave({isActive:t,refs:[v,x,w],handler:u.off,debounce:100}),React.createElement(React.Fragment,null,React.createElement("div",Object.assign({ref:b,className:cnProgressStepBarItem({direction:i,position:n,status:g||progressStepBarPropStatusDefault,size:j},[p])},q),React.createElement("button",Object.assign({tabIndex:-1,type:"button"},z)),(e||c)&&React.createElement("div",{className:cnProgressStepBarItem("Content",{bottomOffset:!!c})},e&&React.createElement(Text,{className:cnProgressStepBarItem("Label"),ref:v,size:j,onMouseEnter:u.on,lineHeight:"s"===j?"xs":j,view:"primary"},e),c)),React.createElement(Tooltip,{ref:w,isOpen:!!d&&t,anchorRef:x,className:cnProgressStepBarItem("Tooltip"),direction:B,style:{zIndex:o},isInteractive:!1,possibleDirections:C,spareDirection:D},d))});
|
|
2
2
|
//# sourceMappingURL=ProgressStepBarItem.js.map
|
package/__internal__/src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressStepBarItem.js","names":["React","useMemo","useRef","ProgressSpin","Text","Tooltip","useFlag","useForkRef","useMouseLeave","cnMixFocus","cn","progressStepBarPropPositionDefault","progressStepBarPropStatusDefault","cnProgressStepBarItem","possibleVerticalDirections","possibleHorizontalDirections","renderPointContent","point","size","progress","ProgressStepBarItem","forwardRef","props","ref","content","tooltipContent","label","status","direction","pointRefProp","pointRef","onClick","position","tooltipZIndex","className","otherProps","isTooltipVisible","setTooltipVisible","anchorRef","tooltipRef","pointForkedRef","pointProps","onMouseEnter","on","pointer","children","tooltipDirection","possibleDirections","spareDirection","isActive","refs","handler","off","debounce","bottomOffset","zIndex"],"sources":["../../../../../../src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.tsx"],"sourcesContent":["import './ProgressStepBarItem.css';\n\nimport { IconComponent } from '@consta/icons/Icon';\nimport React, { useMemo, useRef } from 'react';\n\nimport { Direction } from '##/components/Popover';\nimport { ProgressSpin } from '##/components/ProgressSpin';\nimport { Text } from '##/components/Text';\nimport { Tooltip } from '##/components/Tooltip';\nimport { useFlag } from '##/hooks/useFlag/useFlag';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useMouseLeave } from '##/hooks/useMouseLeave';\nimport { cnMixFocus } from '##/mixs/MixFocus/MixFocus';\nimport { cn } from '##/utils/bem';\n\nimport {\n ProgressStepBarItemComponent,\n ProgressStepBarPointNumbersMap,\n progressStepBarPropPositionDefault,\n progressStepBarPropStatusDefault,\n} from '../helpers';\n\nconst cnProgressStepBarItem = cn('ProgressStepBarItem');\n\nconst possibleVerticalDirections: Direction[] = [\n 'leftCenter',\n 'rightCenter',\n 'rightUp',\n 'downCenter',\n];\nconst possibleHorizontalDirections: Direction[] = [\n 'downCenter',\n 'upCenter',\n 'downStartLeft',\n 'downStartRight',\n];\n\nconst renderPointContent = (\n point: ProgressStepBarPointNumbersMap | IconComponent | undefined,\n size: 'm' | 's',\n progress: boolean | undefined,\n) => {\n if (progress) return <ProgressSpin size={size} />;\n if (!point) return null;\n\n if (typeof point === 'number') {\n return (\n <Text\n className={cnProgressStepBarItem('PointText')}\n size={size === 's' ? '2xs' : 'xs'}\n weight=\"bold\"\n view=\"primary\"\n lineHeight=\"m\"\n >\n {point}\n </Text>\n );\n }\n\n const Icon = point;\n\n return <Icon className={cnProgressStepBarItem('PointIcon')} size=\"xs\" />;\n};\n\nexport const ProgressStepBarItem: ProgressStepBarItemComponent =\n React.forwardRef((props, ref) => {\n const {\n content,\n tooltipContent,\n label,\n point,\n status,\n progress,\n direction,\n size,\n pointRef: pointRefProp,\n onClick,\n position = progressStepBarPropPositionDefault,\n tooltipZIndex,\n className,\n ...otherProps\n } = props;\n\n const [isTooltipVisible, setTooltipVisible] = useFlag();\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const pointRef = useRef<HTMLButtonElement>(null);\n\n const pointForkedRef = useForkRef([pointRef, pointRefProp]);\n\n const pointProps = {\n onMouseEnter: setTooltipVisible.on,\n className: cnProgressStepBarItem(\n 'Point',\n {\n size,\n pointer: !!onClick,\n },\n [onClick ? cnMixFocus() : undefined],\n ),\n children: size !== 'xs' && renderPointContent(point, size, progress),\n ref: pointForkedRef,\n onClick,\n };\n\n const { tooltipDirection, possibleDirections, spareDirection } = useMemo<{\n tooltipDirection: Direction;\n possibleDirections: Direction[];\n spareDirection: Direction;\n }>(() => {\n if (direction === 'vertical') {\n return {\n tooltipDirection: 'leftUp',\n possibleDirections: possibleVerticalDirections,\n spareDirection: 'rightCenter',\n };\n }\n let spareDirection: Direction = 'downCenter';\n if (position === 'start') {\n spareDirection = 'rightCenter';\n }\n if (position === 'end') {\n spareDirection = 'leftCenter';\n }\n return {\n tooltipDirection: 'downCenter',\n possibleDirections: possibleHorizontalDirections,\n spareDirection,\n };\n }, [direction, position]);\n\n useMouseLeave({\n isActive: isTooltipVisible,\n refs: [anchorRef, pointRef, tooltipRef],\n handler: setTooltipVisible.off,\n debounce: 100,\n });\n\n return (\n <>\n <div\n ref={ref}\n className={cnProgressStepBarItem(\n {\n direction,\n position,\n status: status || progressStepBarPropStatusDefault,\n size,\n },\n [className],\n )}\n {...otherProps}\n >\n <button tabIndex={-1} type=\"button\" {...pointProps} />\n {(label || content) && (\n <div\n className={cnProgressStepBarItem('Content', {\n bottomOffset: !!content,\n })}\n >\n {label && (\n <Text\n className={cnProgressStepBarItem('Label')}\n ref={anchorRef}\n size={size}\n onMouseEnter={setTooltipVisible.on}\n lineHeight={size === 's' ? 'xs' : size}\n view=\"primary\"\n >\n {label}\n </Text>\n )}\n {content}\n </div>\n )}\n </div>\n <Tooltip\n ref={tooltipRef}\n isOpen={!!tooltipContent && isTooltipVisible}\n anchorRef={pointRef}\n className={cnProgressStepBarItem('Tooltip')}\n direction={tooltipDirection}\n style={{ zIndex: tooltipZIndex }}\n isInteractive={false}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n >\n {tooltipContent}\n </Tooltip>\n </>\n );\n });\n"],"mappings":"oTAAA,kCAGA,MAAOA,MAAP,EAAgBC,OAAhB,CAAyBC,MAAzB,KAAuC,OAAvC,CAGA,OAASC,YAAT,0BACA,OAASC,IAAT,kBACA,OAASC,OAAT,qBACA,OAASC,OAAT,sCACA,OAASC,UAAT,iCACA,OAASC,aAAT,oCACA,OAASC,UAAT,uCACA,OAASC,EAAT,0BAEA,OAGEC,kCAHF,CAIEC,gCAJF,kB,GAOMC,sBAAqB,CAAGH,EAAE,CAAC,qBAAD,C,CAE1BI,0BAAuC,CAAG,CAC9C,YAD8C,CAE9C,aAF8C,CAG9C,SAH8C,CAI9C,YAJ8C,C,CAM1CC,4BAAyC,CAAG,CAChD,YADgD,CAEhD,UAFgD,CAGhD,eAHgD,CAIhD,gBAJgD,C,CAO5CC,kBAAkB,CAAG,SACzBC,CADyB,CAEzBC,CAFyB,CAGzBC,CA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CAAC,SAAD,CAJlC,CAKE,SAAS,CAAEiC,CALb,CAME,KAAK,CAAE,CAAES,MAAM,CAAEtB,CAAV,CANT,CAOE,aAAa,GAPf,CAQE,kBAAkB,CAAEc,CARtB,CASE,cAAc,CAAEC,CATlB,EAWGvB,CAXH,CArCF,CAoDH,CA/HD,CADK"}
|
|
1
|
+
{"version":3,"file":"ProgressStepBarItem.js","names":["React","useMemo","useRef","ProgressSpin","Text","Tooltip","useFlag","useForkRef","useMouseLeave","cnMixFocus","cn","progressStepBarPropPositionDefault","progressStepBarPropStatusDefault","cnProgressStepBarItem","possibleVerticalDirections","possibleHorizontalDirections","renderPointContent","point","size","progress","ProgressStepBarItem","forwardRef","props","ref","content","tooltipContent","label","status","direction","pointRefProp","pointRef","onClick","position","tooltipZIndex","className","otherProps","isTooltipVisible","setTooltipVisible","anchorRef","tooltipRef","pointForkedRef","pointProps","onMouseEnter","on","pointer","children","tooltipDirection","possibleDirections","spareDirection","isActive","refs","handler","off","debounce","bottomOffset","zIndex"],"sources":["../../../../../../src/components/ProgressStepBar/ProgressStepBarItem/ProgressStepBarItem.tsx"],"sourcesContent":["import './ProgressStepBarItem.css';\n\nimport { IconComponent } from '@consta/icons/Icon';\nimport React, { useMemo, useRef } from 'react';\n\nimport { Direction } from '##/components/Popover';\nimport { ProgressSpin } from '##/components/ProgressSpin';\nimport { Text } from '##/components/Text';\nimport { Tooltip } from '##/components/Tooltip';\nimport { useFlag } from '##/hooks/useFlag/useFlag';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { useMouseLeave } from '##/hooks/useMouseLeave';\nimport { cnMixFocus } from '##/mixs/MixFocus/MixFocus';\nimport { cn } from '##/utils/bem';\n\nimport {\n ProgressStepBarItemComponent,\n ProgressStepBarPointNumbersMap,\n progressStepBarPropPositionDefault,\n progressStepBarPropStatusDefault,\n} from '../helpers';\n\nexport const cnProgressStepBarItem = cn('ProgressStepBarItem');\n\nconst possibleVerticalDirections: Direction[] = [\n 'leftCenter',\n 'rightCenter',\n 'rightUp',\n 'downCenter',\n];\nconst possibleHorizontalDirections: Direction[] = [\n 'downCenter',\n 'upCenter',\n 'downStartLeft',\n 'downStartRight',\n];\n\nconst renderPointContent = (\n point: ProgressStepBarPointNumbersMap | IconComponent | undefined,\n size: 'm' | 's',\n progress: boolean | undefined,\n) => {\n if (progress) return <ProgressSpin size={size} />;\n if (!point) return null;\n\n if (typeof point === 'number') {\n return (\n <Text\n className={cnProgressStepBarItem('PointText')}\n size={size === 's' ? '2xs' : 'xs'}\n weight=\"bold\"\n view=\"primary\"\n lineHeight=\"m\"\n >\n {point}\n </Text>\n );\n }\n\n const Icon = point;\n\n return <Icon className={cnProgressStepBarItem('PointIcon')} size=\"xs\" />;\n};\n\nexport const ProgressStepBarItem: ProgressStepBarItemComponent =\n React.forwardRef((props, ref) => {\n const {\n content,\n tooltipContent,\n label,\n point,\n status,\n progress,\n direction,\n size,\n pointRef: pointRefProp,\n onClick,\n position = progressStepBarPropPositionDefault,\n tooltipZIndex,\n className,\n ...otherProps\n } = props;\n\n const [isTooltipVisible, setTooltipVisible] = useFlag();\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const pointRef = useRef<HTMLButtonElement>(null);\n\n const pointForkedRef = useForkRef([pointRef, pointRefProp]);\n\n const pointProps = {\n onMouseEnter: setTooltipVisible.on,\n className: cnProgressStepBarItem(\n 'Point',\n {\n size,\n pointer: !!onClick,\n },\n [onClick ? cnMixFocus() : undefined],\n ),\n children: size !== 'xs' && renderPointContent(point, size, progress),\n ref: pointForkedRef,\n onClick,\n };\n\n const { tooltipDirection, possibleDirections, spareDirection } = useMemo<{\n tooltipDirection: Direction;\n possibleDirections: Direction[];\n spareDirection: Direction;\n }>(() => {\n if (direction === 'vertical') {\n return {\n tooltipDirection: 'leftUp',\n possibleDirections: possibleVerticalDirections,\n spareDirection: 'rightCenter',\n };\n }\n let spareDirection: Direction = 'downCenter';\n if (position === 'start') {\n spareDirection = 'rightCenter';\n }\n if (position === 'end') {\n spareDirection = 'leftCenter';\n }\n return {\n tooltipDirection: 'downCenter',\n possibleDirections: possibleHorizontalDirections,\n spareDirection,\n };\n }, [direction, position]);\n\n useMouseLeave({\n isActive: isTooltipVisible,\n refs: [anchorRef, pointRef, tooltipRef],\n handler: setTooltipVisible.off,\n debounce: 100,\n });\n\n return (\n <>\n <div\n ref={ref}\n className={cnProgressStepBarItem(\n {\n direction,\n position,\n status: status || progressStepBarPropStatusDefault,\n size,\n },\n [className],\n )}\n {...otherProps}\n >\n <button tabIndex={-1} type=\"button\" {...pointProps} />\n {(label || content) && (\n <div\n className={cnProgressStepBarItem('Content', {\n bottomOffset: !!content,\n })}\n >\n {label && (\n <Text\n className={cnProgressStepBarItem('Label')}\n ref={anchorRef}\n size={size}\n onMouseEnter={setTooltipVisible.on}\n lineHeight={size === 's' ? 'xs' : size}\n view=\"primary\"\n >\n {label}\n </Text>\n )}\n {content}\n </div>\n )}\n </div>\n <Tooltip\n ref={tooltipRef}\n isOpen={!!tooltipContent && isTooltipVisible}\n anchorRef={pointRef}\n className={cnProgressStepBarItem('Tooltip')}\n direction={tooltipDirection}\n style={{ zIndex: tooltipZIndex }}\n isInteractive={false}\n possibleDirections={possibleDirections}\n spareDirection={spareDirection}\n >\n {tooltipContent}\n </Tooltip>\n </>\n );\n });\n"],"mappings":"oTAAA,kCAGA,MAAOA,MAAP,EAAgBC,OAAhB,CAAyBC,MAAzB,KAAuC,OAAvC,CAGA,OAASC,YAAT,0BACA,OAASC,IAAT,kBACA,OAASC,OAAT,qBACA,OAASC,OAAT,sCACA,OAASC,UAAT,iCACA,OAASC,aAAT,oCACA,OAASC,UAAT,uCACA,OAASC,EAAT,0BAEA,OAGEC,kCAHF,CAIEC,gCAJF,kBAOA,MAAO,IAAMC,sBAAqB,CAAGH,EAAE,CAAC,qBAAD,CAAhC,C,GAEDI,2BAAuC,CAAG,CAC9C,YAD8C,CAE9C,aAF8C,CAG9C,SAH8C,CA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AfJ,CADF,CAqCE,oBAAC,OAAD,EACE,GAAG,CAAEe,CADP,CAEE,MAAM,CAAE,CAAC,CAACd,CAAF,EAAoBW,CAF9B,CAGE,SAAS,CAAEN,CAHb,CAIE,SAAS,CAAEjB,qBAAqB,CAAC,SAAD,CAJlC,CAKE,SAAS,CAAEiC,CALb,CAME,KAAK,CAAE,CAAES,MAAM,CAAEtB,CAAV,CANT,CAOE,aAAa,GAPf,CAQE,kBAAkB,CAAEc,CARtB,CASE,cAAc,CAAEC,CATlB,EAWGvB,CAXH,CArCF,CAoDH,CA/HD,CADK"}
|
|
@@ -116,6 +116,5 @@ export declare function withDefaultGetters<ITEM>(props: ProgressStepBarProps<ITE
|
|
|
116
116
|
getItemOnClick: ProgressStepBarPropGetItemOnClick<ProgressStepBarItemDefault> | ProgressStepBarPropGetItemOnClick<ITEM>;
|
|
117
117
|
};
|
|
118
118
|
export declare const getItemPosition: (index: number, length: number) => "center" | "start" | "end";
|
|
119
|
-
export declare const getLineSize: (container: React.RefObject<HTMLElement>, activeElement: React.RefObject<HTMLElement>, direction: ProgressStepBarPropDirection) => number;
|
|
120
119
|
export declare const calculateLines: (refs: React.RefObject<HTMLElement>[], direction: ProgressStepBarPropDirection) => number[];
|
|
121
120
|
export declare const validateVisibleIndex: (length: number, index: number | undefined) => number | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{cn}from"../../utils/bem";export var progressStepBarPropSize=["s","xs","m"];export var progressStepBarPropSizeDefault=progressStepBarPropSize[0];export var progressStepBarPropDirection=["horizontal","vertical"];export var progressStepBarPropDirectionDefault=progressStepBarPropDirection[0];export var progressStepBarPropStatus=["normal","success","warning","alert"];export var progressStepBarPropStatusDefault=progressStepBarPropStatus[0];export var progressStepBarPointNumbersMap=[0,1,2,3,4,5,6,7,8,9];export var progressStepBarPropPosition=["center","start","end"];export var progressStepBarPropPositionDefault=progressStepBarPropPosition[0];export var cnProgressStepBar=cn("ProgressStepBar");export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemTooltipContent=function(a){return a.tooltipContent};export var defaultGetItemPoint=function(a){return a.point};export var defaultGetItemLineStatus=function(a){return a.lineStatus};export var defaultGetItemProgress=function(a){return a.progress};export var defaultGetItemContent=function(a){return a.content};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemOnClick=function(a){return a.onClick};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemTooltipContent:a.getItemTooltipContent||defaultGetItemTooltipContent,getItemPoint:a.getItemPoint||defaultGetItemPoint,getItemProgress:a.getItemProgress||defaultGetItemProgress,getItemContent:a.getItemContent||defaultGetItemContent,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemLineStatus:a.getItemLineStatus||defaultGetItemLineStatus,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick})}export var getItemPosition=function(a,b){var c="center";return a===b-1&&(c="end"),0===a&&(c="start"),c};
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{cn}from"../../utils/bem";export var progressStepBarPropSize=["s","xs","m"];export var progressStepBarPropSizeDefault=progressStepBarPropSize[0];export var progressStepBarPropDirection=["horizontal","vertical"];export var progressStepBarPropDirectionDefault=progressStepBarPropDirection[0];export var progressStepBarPropStatus=["normal","success","warning","alert"];export var progressStepBarPropStatusDefault=progressStepBarPropStatus[0];export var progressStepBarPointNumbersMap=[0,1,2,3,4,5,6,7,8,9];export var progressStepBarPropPosition=["center","start","end"];export var progressStepBarPropPositionDefault=progressStepBarPropPosition[0];export var cnProgressStepBar=cn("ProgressStepBar");export var defaultGetItemLabel=function(a){return a.label};export var defaultGetItemTooltipContent=function(a){return a.tooltipContent};export var defaultGetItemPoint=function(a){return a.point};export var defaultGetItemLineStatus=function(a){return a.lineStatus};export var defaultGetItemProgress=function(a){return a.progress};export var defaultGetItemContent=function(a){return a.content};export var defaultGetItemStatus=function(a){return a.status};export var defaultGetItemOnClick=function(a){return a.onClick};export function withDefaultGetters(a){return _objectSpread(_objectSpread({},a),{},{getItemLabel:a.getItemLabel||defaultGetItemLabel,getItemTooltipContent:a.getItemTooltipContent||defaultGetItemTooltipContent,getItemPoint:a.getItemPoint||defaultGetItemPoint,getItemProgress:a.getItemProgress||defaultGetItemProgress,getItemContent:a.getItemContent||defaultGetItemContent,getItemStatus:a.getItemStatus||defaultGetItemStatus,getItemLineStatus:a.getItemLineStatus||defaultGetItemLineStatus,getItemOnClick:a.getItemOnClick||defaultGetItemOnClick})}export var getItemPosition=function(a,b){var c="center";return a===b-1&&(c="end"),0===a&&(c="start"),c};var getRefSize=function(a){if(a.current){var b=a.current.getBoundingClientRect(),c=b.width,d=b.height;return[c,d]}return[0,0]};export var calculateLines=function(a,b){var c=[],d=a.length;if(2>d)return c;for(var p=0;p<d-1;p++){var e=getRefSize(a[p]),f=_slicedToArray(e,2),g=f[0],h=f[1],j=getRefSize(a[p+1]),k=_slicedToArray(j,1),l=k[0],m=0;if("horizontal"===b){var n=0===p?g:g/2,o=p===d-2?l:l/2;m=n+o}else m=h,p===d-2&&(m+=2);c.push(m)}return c};export var validateVisibleIndex=function(a,b){return b?0>b?void 0:Math.min(b,a-1):b};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["cn","progressStepBarPropSize","progressStepBarPropSizeDefault","progressStepBarPropDirection","progressStepBarPropDirectionDefault","progressStepBarPropStatus","progressStepBarPropStatusDefault","progressStepBarPointNumbersMap","progressStepBarPropPosition","progressStepBarPropPositionDefault","cnProgressStepBar","defaultGetItemLabel","item","label","defaultGetItemTooltipContent","tooltipContent","defaultGetItemPoint","point","defaultGetItemLineStatus","lineStatus","defaultGetItemProgress","progress","defaultGetItemContent","content","defaultGetItemStatus","status","defaultGetItemOnClick","onClick","withDefaultGetters","props","getItemLabel","getItemTooltipContent","getItemPoint","getItemProgress","getItemContent","getItemStatus","getItemLineStatus","getItemOnClick","getItemPosition","index","length","position","getLineSize","container","activeElement","direction","size","current","containerPosition","getBoundingClientRect","activeElementPosition","y","height","x","getRefSize","ref","width","calculateLines","refs","sizes","i","firstSize","secondSize","push","validateVisibleIndex","Math","min"],"sources":["../../../../../src/components/ProgressStepBar/helpers.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport const progressStepBarPropSize = ['s', 'xs', 'm'] as const;\nexport type ProgressStepBarPropSize = typeof progressStepBarPropSize[number];\nexport const progressStepBarPropSizeDefault = progressStepBarPropSize[0];\n\nexport const progressStepBarPropDirection = ['horizontal', 'vertical'] as const;\nexport type ProgressStepBarPropDirection =\n typeof progressStepBarPropDirection[number];\nexport const progressStepBarPropDirectionDefault =\n progressStepBarPropDirection[0];\n\nexport const progressStepBarPropStatus = [\n 'normal',\n 'success',\n 'warning',\n 'alert',\n] as const;\nexport type ProgressStepBarPropStatus =\n typeof progressStepBarPropStatus[number];\nexport const progressStepBarPropStatusDefault = progressStepBarPropStatus[0];\n\nexport const progressStepBarPointNumbersMap = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n] as const;\nexport type ProgressStepBarPointNumbersMap =\n typeof progressStepBarPointNumbersMap[number];\n\nexport const progressStepBarPropPosition = ['center', 'start', 'end'] as const;\nexport type ProgressStepBarPropPosition =\n typeof progressStepBarPropPosition[number];\nexport const progressStepBarPropPositionDefault: ProgressStepBarPropPosition =\n progressStepBarPropPosition[0];\n\nexport type ProgressStepBarPropGetItemLabel<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ProgressStepBarPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number;\nexport type ProgressStepBarPropGetItemTooltipContent<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ProgressStepBarPropGetItemLineStatus<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPropStatus | undefined;\nexport type ProgressStepBarPropGetItemPoint<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPointNumbersMap | IconComponent | undefined;\nexport type ProgressStepBarPropGetItemProgress<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ProgressStepBarPropGetItemContent<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ProgressStepBarPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPropStatus | undefined;\nexport type ProgressStepBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\n\nexport type ProgressStepBarItemDefault = {\n label?: string;\n tooltipContent?: string;\n lineStatus?: ProgressStepBarPropStatus;\n point?: ProgressStepBarPointNumbersMap | IconComponent;\n status?: ProgressStepBarPropStatus;\n progress?: boolean;\n content?: React.ReactNode;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type Line = {\n status: ProgressStepBarPropStatus;\n size: number;\n};\n\nexport type ProgressStepBarPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n index: number;\n },\n) => void;\n\nexport type ProgressStepBarProps<ITEM = ProgressStepBarItemDefault> =\n PropsWithHTMLAttributesAndRef<\n {\n steps: ITEM[];\n direction?: ProgressStepBarPropDirection;\n size?: ProgressStepBarPropSize;\n activeStepIndex?: number;\n onItemClick?: ProgressStepBarPropOnItemClick<ITEM>;\n getItemLabel?: ProgressStepBarPropGetItemLabel<ITEM>;\n getItemLineStatus?: ProgressStepBarPropGetItemLineStatus<ITEM>;\n getItemTooltipContent?: ProgressStepBarPropGetItemTooltipContent<ITEM>;\n getItemPoint?: ProgressStepBarPropGetItemPoint<ITEM>;\n getItemProgress?: ProgressStepBarPropGetItemProgress<ITEM>;\n getItemContent?: ProgressStepBarPropGetItemContent<ITEM>;\n getItemStatus?: ProgressStepBarPropGetItemStatus<ITEM>;\n getItemOnClick?: ProgressStepBarPropGetItemOnClick<ITEM>;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: ProgressStepBarItemDefault['label'] }\n ? {}\n : { getItemLabel: ProgressStepBarPropGetItemLabel<ITEM> });\n\nexport type ProgressStepBarItemProps = {\n content?: React.ReactNode;\n label?: string;\n point?: ProgressStepBarPointNumbersMap | IconComponent;\n progress?: boolean;\n status?: ProgressStepBarPropStatus | 'system';\n tooltipContent?: string;\n tooltipZIndex?: number;\n position?: ProgressStepBarPropPosition;\n direction: ProgressStepBarPropDirection;\n size: ProgressStepBarPropSize;\n onClick?: (e: React.MouseEvent) => void;\n pointRef?: React.RefObject<HTMLButtonElement>;\n className?: string;\n};\n\nexport const cnProgressStepBar = cn('ProgressStepBar');\n\nexport const defaultGetItemLabel: ProgressStepBarPropGetItemLabel<\n ProgressStepBarItemDefault\n> = (item) => item.label;\nexport const defaultGetItemTooltipContent: ProgressStepBarPropGetItemTooltipContent<\n ProgressStepBarItemDefault\n> = (item) => item.tooltipContent;\nexport const defaultGetItemPoint: ProgressStepBarPropGetItemPoint<\n ProgressStepBarItemDefault\n> = (item) => item.point;\nexport const defaultGetItemLineStatus: ProgressStepBarPropGetItemLineStatus<\n ProgressStepBarItemDefault\n> = (item) => item.lineStatus;\nexport const defaultGetItemProgress: ProgressStepBarPropGetItemProgress<\n ProgressStepBarItemDefault\n> = (item) => item.progress;\nexport const defaultGetItemContent: ProgressStepBarPropGetItemContent<\n ProgressStepBarItemDefault\n> = (item) => item.content;\nexport const defaultGetItemStatus: ProgressStepBarPropGetItemStatus<\n ProgressStepBarItemDefault\n> = (item) => item.status;\nexport const defaultGetItemOnClick: ProgressStepBarPropGetItemOnClick<\n ProgressStepBarItemDefault\n> = (item) => item.onClick;\n\nexport type ProgressStepBarComponent = <ITEM = ProgressStepBarItemDefault>(\n props: ProgressStepBarProps<ITEM>,\n) => React.ReactNode | null;\n\nexport type ProgressStepBarItemComponent = (\n props: PropsWithHTMLAttributesAndRef<\n ProgressStepBarItemProps,\n HTMLDivElement\n >,\n) => React.ReactNode | null;\n\nexport function withDefaultGetters<ITEM>(props: ProgressStepBarProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemTooltipContent:\n props.getItemTooltipContent || defaultGetItemTooltipContent,\n getItemPoint: props.getItemPoint || defaultGetItemPoint,\n getItemProgress: props.getItemProgress || defaultGetItemProgress,\n getItemContent: props.getItemContent || defaultGetItemContent,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemLineStatus: props.getItemLineStatus || defaultGetItemLineStatus,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n };\n}\n\nexport const getItemPosition = (index: number, length: number) => {\n let position: ProgressStepBarPropPosition = 'center';\n if (index === length - 1) position = 'end';\n if (index === 0) position = 'start';\n\n return position;\n};\n\nexport const getLineSize: (\n container: React.RefObject<HTMLElement>,\n activeElement: React.RefObject<HTMLElement>,\n direction: ProgressStepBarPropDirection,\n) => number = (container, activeElement, direction) => {\n let size = 0;\n if (\n container &&\n container.current &&\n activeElement &&\n activeElement.current\n ) {\n const containerPosition = container.current.getBoundingClientRect();\n const activeElementPosition = activeElement.current.getBoundingClientRect();\n if (direction === 'vertical')\n size =\n activeElementPosition.y -\n containerPosition.y +\n activeElementPosition.height;\n else size = activeElementPosition.x - containerPosition.x;\n }\n return size;\n};\n\nconst getRefSize = (ref: React.RefObject<HTMLElement>) => {\n if (ref.current) {\n const { width, height } = ref.current.getBoundingClientRect();\n return [width, height];\n }\n return [0, 0];\n};\n\nexport const calculateLines = (\n refs: React.RefObject<HTMLElement>[],\n direction: ProgressStepBarPropDirection,\n) => {\n const sizes: number[] = [];\n for (let i = 0; i < refs.length - 1; i++) {\n const ref = refs[i];\n const firstSize = getRefSize(ref);\n const secondSize = getRefSize(refs[i + 1]);\n let size = 0;\n if (i === 0) {\n size =\n direction === 'horizontal'\n ? firstSize[0] + secondSize[0] / 2\n : firstSize[1];\n } else if (i === refs.length - 2) {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0]\n : firstSize[1] + 2;\n } else {\n size =\n direction === 'horizontal'\n ? firstSize[0] / 2 + secondSize[0] / 2\n : firstSize[1];\n }\n sizes.push(size);\n }\n\n return sizes;\n};\n\nexport const validateVisibleIndex = (\n length: number,\n index: number | undefined,\n) => {\n if (!index) {\n return index;\n }\n\n if (index < 0) {\n return undefined;\n }\n\n return Math.min(index, length - 1);\n};\n"],"mappings":"qqBAGA,OAASA,EAAT,uBAGA,MAAO,IAAMC,wBAAuB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAhC,CAEP,MAAO,IAAMC,+BAA8B,CAAGD,uBAAuB,CAAC,C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CAAT,CAAe,CAAf,CAAmBC,CAAU,CAAC,CAAD,CAAV,CAAgB,CAD9B,CAELD,CAAS,CAAC,CAAD,CAnBuB,CAqBxCF,CAAK,CAACI,IAAN,CAAWjB,CAAX,CACD,CAED,MAAOa,EACR,CA9BM,CAgCP,MAAO,IAAMK,qBAAoB,CAAG,SAClCxB,CADkC,CAElCD,CAFkC,CAG/B,OACEA,EADF,CAKS,CAAR,CAAAA,CALD,QASI0B,IAAI,CAACC,GAAL,CAAS3B,CAAT,CAAgBC,CAAM,CAAG,CAAzB,CATJ,CAEMD,CAQV,CAbM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["cn","progressStepBarPropSize","progressStepBarPropSizeDefault","progressStepBarPropDirection","progressStepBarPropDirectionDefault","progressStepBarPropStatus","progressStepBarPropStatusDefault","progressStepBarPointNumbersMap","progressStepBarPropPosition","progressStepBarPropPositionDefault","cnProgressStepBar","defaultGetItemLabel","item","label","defaultGetItemTooltipContent","tooltipContent","defaultGetItemPoint","point","defaultGetItemLineStatus","lineStatus","defaultGetItemProgress","progress","defaultGetItemContent","content","defaultGetItemStatus","status","defaultGetItemOnClick","onClick","withDefaultGetters","props","getItemLabel","getItemTooltipContent","getItemPoint","getItemProgress","getItemContent","getItemStatus","getItemLineStatus","getItemOnClick","getItemPosition","index","length","position","getRefSize","ref","current","getBoundingClientRect","width","height","calculateLines","refs","direction","sizes","i","width1","height1","width2","size","first","second","push","validateVisibleIndex","Math","min"],"sources":["../../../../../src/components/ProgressStepBar/helpers.ts"],"sourcesContent":["import { IconComponent } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { cn } from '../../utils/bem';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\n\nexport const progressStepBarPropSize = ['s', 'xs', 'm'] as const;\nexport type ProgressStepBarPropSize = typeof progressStepBarPropSize[number];\nexport const progressStepBarPropSizeDefault = progressStepBarPropSize[0];\n\nexport const progressStepBarPropDirection = ['horizontal', 'vertical'] as const;\nexport type ProgressStepBarPropDirection =\n typeof progressStepBarPropDirection[number];\nexport const progressStepBarPropDirectionDefault =\n progressStepBarPropDirection[0];\n\nexport const progressStepBarPropStatus = [\n 'normal',\n 'success',\n 'warning',\n 'alert',\n] as const;\nexport type ProgressStepBarPropStatus =\n typeof progressStepBarPropStatus[number];\nexport const progressStepBarPropStatusDefault = progressStepBarPropStatus[0];\n\nexport const progressStepBarPointNumbersMap = [\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n] as const;\nexport type ProgressStepBarPointNumbersMap =\n typeof progressStepBarPointNumbersMap[number];\n\nexport const progressStepBarPropPosition = ['center', 'start', 'end'] as const;\nexport type ProgressStepBarPropPosition =\n typeof progressStepBarPropPosition[number];\nexport const progressStepBarPropPositionDefault: ProgressStepBarPropPosition =\n progressStepBarPropPosition[0];\n\nexport type ProgressStepBarPropGetItemLabel<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ProgressStepBarPropGetItemKey<ITEM> = (\n item: ITEM,\n) => string | number;\nexport type ProgressStepBarPropGetItemTooltipContent<ITEM> = (\n item: ITEM,\n) => string | undefined;\nexport type ProgressStepBarPropGetItemLineStatus<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPropStatus | undefined;\nexport type ProgressStepBarPropGetItemPoint<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPointNumbersMap | IconComponent | undefined;\nexport type ProgressStepBarPropGetItemProgress<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type ProgressStepBarPropGetItemContent<ITEM> = (\n item: ITEM,\n) => React.ReactNode | undefined;\nexport type ProgressStepBarPropGetItemStatus<ITEM> = (\n item: ITEM,\n) => ProgressStepBarPropStatus | undefined;\nexport type ProgressStepBarPropGetItemOnClick<ITEM> = (\n item: ITEM,\n) => React.EventHandler<React.MouseEvent> | undefined;\n\nexport type ProgressStepBarItemDefault = {\n label?: string;\n tooltipContent?: string;\n lineStatus?: ProgressStepBarPropStatus;\n point?: ProgressStepBarPointNumbersMap | IconComponent;\n status?: ProgressStepBarPropStatus;\n progress?: boolean;\n content?: React.ReactNode;\n onClick?: React.EventHandler<React.MouseEvent>;\n};\n\nexport type Line = {\n status: ProgressStepBarPropStatus;\n size: number;\n};\n\nexport type ProgressStepBarPropOnItemClick<ITEM> = (\n item: ITEM,\n props: {\n e: React.MouseEvent;\n index: number;\n },\n) => void;\n\nexport type ProgressStepBarProps<ITEM = ProgressStepBarItemDefault> =\n PropsWithHTMLAttributesAndRef<\n {\n steps: ITEM[];\n direction?: ProgressStepBarPropDirection;\n size?: ProgressStepBarPropSize;\n activeStepIndex?: number;\n onItemClick?: ProgressStepBarPropOnItemClick<ITEM>;\n getItemLabel?: ProgressStepBarPropGetItemLabel<ITEM>;\n getItemLineStatus?: ProgressStepBarPropGetItemLineStatus<ITEM>;\n getItemTooltipContent?: ProgressStepBarPropGetItemTooltipContent<ITEM>;\n getItemPoint?: ProgressStepBarPropGetItemPoint<ITEM>;\n getItemProgress?: ProgressStepBarPropGetItemProgress<ITEM>;\n getItemContent?: ProgressStepBarPropGetItemContent<ITEM>;\n getItemStatus?: ProgressStepBarPropGetItemStatus<ITEM>;\n getItemOnClick?: ProgressStepBarPropGetItemOnClick<ITEM>;\n },\n HTMLDivElement\n > &\n (ITEM extends { label: ProgressStepBarItemDefault['label'] }\n ? {}\n : { getItemLabel: ProgressStepBarPropGetItemLabel<ITEM> });\n\nexport type ProgressStepBarItemProps = {\n content?: React.ReactNode;\n label?: string;\n point?: ProgressStepBarPointNumbersMap | IconComponent;\n progress?: boolean;\n status?: ProgressStepBarPropStatus | 'system';\n tooltipContent?: string;\n tooltipZIndex?: number;\n position?: ProgressStepBarPropPosition;\n direction: ProgressStepBarPropDirection;\n size: ProgressStepBarPropSize;\n onClick?: (e: React.MouseEvent) => void;\n pointRef?: React.RefObject<HTMLButtonElement>;\n className?: string;\n};\n\nexport const cnProgressStepBar = cn('ProgressStepBar');\n\nexport const defaultGetItemLabel: ProgressStepBarPropGetItemLabel<\n ProgressStepBarItemDefault\n> = (item) => item.label;\nexport const defaultGetItemTooltipContent: ProgressStepBarPropGetItemTooltipContent<\n ProgressStepBarItemDefault\n> = (item) => item.tooltipContent;\nexport const defaultGetItemPoint: ProgressStepBarPropGetItemPoint<\n ProgressStepBarItemDefault\n> = (item) => item.point;\nexport const defaultGetItemLineStatus: ProgressStepBarPropGetItemLineStatus<\n ProgressStepBarItemDefault\n> = (item) => item.lineStatus;\nexport const defaultGetItemProgress: ProgressStepBarPropGetItemProgress<\n ProgressStepBarItemDefault\n> = (item) => item.progress;\nexport const defaultGetItemContent: ProgressStepBarPropGetItemContent<\n ProgressStepBarItemDefault\n> = (item) => item.content;\nexport const defaultGetItemStatus: ProgressStepBarPropGetItemStatus<\n ProgressStepBarItemDefault\n> = (item) => item.status;\nexport const defaultGetItemOnClick: ProgressStepBarPropGetItemOnClick<\n ProgressStepBarItemDefault\n> = (item) => item.onClick;\n\nexport type ProgressStepBarComponent = <ITEM = ProgressStepBarItemDefault>(\n props: ProgressStepBarProps<ITEM>,\n) => React.ReactNode | null;\n\nexport type ProgressStepBarItemComponent = (\n props: PropsWithHTMLAttributesAndRef<\n ProgressStepBarItemProps,\n HTMLDivElement\n >,\n) => React.ReactNode | null;\n\nexport function withDefaultGetters<ITEM>(props: ProgressStepBarProps<ITEM>) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemTooltipContent:\n props.getItemTooltipContent || defaultGetItemTooltipContent,\n getItemPoint: props.getItemPoint || defaultGetItemPoint,\n getItemProgress: props.getItemProgress || defaultGetItemProgress,\n getItemContent: props.getItemContent || defaultGetItemContent,\n getItemStatus: props.getItemStatus || defaultGetItemStatus,\n getItemLineStatus: props.getItemLineStatus || defaultGetItemLineStatus,\n getItemOnClick: props.getItemOnClick || defaultGetItemOnClick,\n };\n}\n\nexport const getItemPosition = (index: number, length: number) => {\n let position: ProgressStepBarPropPosition = 'center';\n if (index === length - 1) position = 'end';\n if (index === 0) position = 'start';\n\n return position;\n};\n\nconst getRefSize = (ref: React.RefObject<HTMLElement>) => {\n if (ref.current) {\n const { width, height } = ref.current.getBoundingClientRect();\n return [width, height];\n }\n return [0, 0];\n};\n\nexport const calculateLines = (\n refs: React.RefObject<HTMLElement>[],\n direction: ProgressStepBarPropDirection,\n) => {\n const sizes: number[] = [];\n const { length } = refs;\n\n if (length < 2) {\n return sizes;\n }\n\n for (let i = 0; i < length - 1; i++) {\n const [width1, height1] = getRefSize(refs[i]);\n const [width2] = getRefSize(refs[i + 1]);\n\n let size = 0;\n if (direction === 'horizontal') {\n const first = i === 0 ? width1 : width1 / 2;\n const second = i === length - 2 ? width2 : width2 / 2;\n size = first + second;\n } else {\n size = height1;\n if (i === length - 2) {\n size += 2;\n }\n }\n sizes.push(size);\n }\n\n return sizes;\n};\n\nexport const validateVisibleIndex = (\n length: number,\n index: number | undefined,\n) => {\n if (!index) {\n return index;\n }\n\n if (index < 0) {\n return undefined;\n }\n\n return Math.min(index, length - 1);\n};\n"],"mappings":"suBAGA,OAASA,EAAT,uBAGA,MAAO,IAAMC,wBAAuB,CAAG,CAAC,GAAD,CAAM,IAAN,CAAY,GAAZ,CAAhC,CAEP,MAAO,IAAMC,+BAA8B,CAAGD,uBAAuB,CAAC,CAAD,CAA9D,CAEP,MAAO,IAAME,6BAA4B,CAAG,CAAC,YAAD,CAAe,UAAf,CAArC,CAGP,MAAO,IAAMC,oCAAmC,CAC9CD,4BAA4B,CAAC,CAAD,CADvB,CAGP,MAAO,IAAME,0BAAyB,CAAG,CACvC,QADuC,CAEvC,SAFuC,CAGvC,SAHuC,CAIvC,OAJuC,CAAlC,CAQP,MAAO,IAAMC,iCAAgC,CAAGD,yBAAyB,CAAC,CAAD,CAAlE,CAEP,MAAO,IAAME,+BAA8B,CAAG,CAC5C,CAD4C,CACzC,CADyC,CACtC,CADsC,CACnC,CADmC,CAChC,CADgC,CAC7B,CAD6B,CAC1B,CAD0B,CACvB,CADuB,CACpB,CADoB,CACj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AkBA,CAAM,CAAG,CADZ,CAExBK,CAAM,CAAGN,CAAC,GAAKZ,CAAM,CAAG,CAAf,CAAmBe,CAAnB,CAA4BA,CAAM,CAAG,CAFtB,CAG9BC,CAAI,CAAGC,CAAK,CAAGC,CAChB,CAJD,IAKEF,EAAI,CAAGF,CALT,CAMMF,CAAC,GAAKZ,CAAM,CAAG,CANrB,GAOIgB,CAAI,EAAI,CAPZ,EAUAL,CAAK,CAACQ,IAAN,CAAWH,CAAX,CACD,CAED,MAAOL,EACR,CA9BM,CAgCP,MAAO,IAAMS,qBAAoB,CAAG,SAClCpB,CADkC,CAElCD,CAFkC,CAG/B,OACEA,EADF,CAKS,CAAR,CAAAA,CALD,QASIsB,IAAI,CAACC,GAAL,CAASvB,CAAT,CAAgBC,CAAM,CAAG,CAAzB,CATJ,CAEMD,CAQV,CAbM"}
|
|
@@ -53,7 +53,7 @@ export declare function withDefaultGetters<ITEM = SelectItemDefault, GROUP = Sel
|
|
|
53
53
|
iconClear?: import("@consta/icons/Icon").IconComponent;
|
|
54
54
|
selectAll?: (MULTIPLE extends true ? boolean : never) | undefined;
|
|
55
55
|
selectAllLabel?: string;
|
|
56
|
-
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "onFocus" | "onBlur" | "onChange" | "onInput" | "size" | "view" | "form" | "status" | "input" | "disabled" | "value" | "multiple" | "placeholder" | "inputRef" | "items" | "dropdownForm" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "onScrollToBottom" | "labelForCreate" | "inputValue" | "selectAll" | "onDropdownOpen" | "dropdownOpen" | "ignoreOutsideClicksRefs" | "virtualScroll" | "inputDefaultValue" | "clearButton" | "iconClear" | "onCreate" | "
|
|
56
|
+
} & Omit<import("react").HTMLAttributes<HTMLDivElement>, "css" | "onFocus" | "onBlur" | "onChange" | "onInput" | "size" | "view" | "form" | "status" | "input" | "disabled" | "value" | "multiple" | "placeholder" | "inputRef" | "items" | "dropdownForm" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "onScrollToBottom" | "labelForCreate" | "inputValue" | "selectAll" | "onDropdownOpen" | "dropdownOpen" | "ignoreOutsideClicksRefs" | "virtualScroll" | "inputDefaultValue" | "clearButton" | "iconClear" | "onCreate" | "selectAllLabel" | "aria-Label"> & import("react").RefAttributes<HTMLDivElement> & (ITEM extends {
|
|
57
57
|
label: SelectItemDefault["label"];
|
|
58
58
|
} ? {} : {
|
|
59
59
|
getItemLabel: SelectPropGetItemLabel<ITEM>;
|
|
@@ -6,7 +6,7 @@ declare const sidebarPropPosition: readonly ["right", "bottom", "left", "top"];
|
|
|
6
6
|
type SidebarPropPosition = typeof sidebarPropPosition[number];
|
|
7
7
|
export declare const sidebarPropSize: readonly ["s", "m", "l", "full", "1/2", "1/3", "1/4", "2/3", "3/4"];
|
|
8
8
|
export type SidebarPropSize = typeof sidebarPropSize[number];
|
|
9
|
-
type SidebarProps = PropsWithHTMLAttributes<{
|
|
9
|
+
export type SidebarProps = PropsWithHTMLAttributes<{
|
|
10
10
|
isOpen?: boolean;
|
|
11
11
|
onClose?: () => void;
|
|
12
12
|
onOpen?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","names":["React","useEffect","useRef","Transition","PortalWithTheme","PortalWithThemeConsumer","useTheme","useGlobalKeys","cnMixScrollBar","cn","sidebarPropPosition","sidebarPropPositionDefault","sidebarPropSize","sidebarPropSizeDefault","cnSidebar","SidebarContent","className","children","rest","SidebarActions","Sidebar","props","isOpen","onClose","onOpen","hasOverlay","onClickOutside","onEsc","position","size","container","window","document","body","style","rootClassName","afterClose","otherProps","ref","portalRef","theme","Escape","e","animate","zIndex","Content","Actions"],"sources":["../../../../../src/components/Sidebar/Sidebar.tsx"],"sourcesContent":["import './Sidebar.css';\n\nimport React, { useEffect, useRef } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport {\n PortalWithTheme,\n PortalWithThemeConsumer,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { useGlobalKeys } from '##/hooks/useGlobalKeys';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cn } from '##/utils/bem';\nimport { AsTagAttribute } from '##/utils/types/AsTags';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nconst sidebarPropPosition = ['right', 'bottom', 'left', 'top'] as const;\ntype SidebarPropPosition = typeof sidebarPropPosition[number];\nconst sidebarPropPositionDefault: SidebarPropPosition = sidebarPropPosition[0];\n\nexport const sidebarPropSize = [\n 's',\n 'm',\n 'l',\n 'full',\n '1/2',\n '1/3',\n '1/4',\n '2/3',\n '3/4',\n] as const;\n\nexport type SidebarPropSize = typeof sidebarPropSize[number];\nconst sidebarPropSizeDefault: SidebarPropSize = sidebarPropSize[1];\n\
|
|
1
|
+
{"version":3,"file":"Sidebar.js","names":["React","useEffect","useRef","Transition","PortalWithTheme","PortalWithThemeConsumer","useTheme","useGlobalKeys","cnMixScrollBar","cn","sidebarPropPosition","sidebarPropPositionDefault","sidebarPropSize","sidebarPropSizeDefault","cnSidebar","SidebarContent","className","children","rest","SidebarActions","Sidebar","props","isOpen","onClose","onOpen","hasOverlay","onClickOutside","onEsc","position","size","container","window","document","body","style","rootClassName","afterClose","otherProps","ref","portalRef","theme","Escape","e","animate","zIndex","Content","Actions"],"sources":["../../../../../src/components/Sidebar/Sidebar.tsx"],"sourcesContent":["import './Sidebar.css';\n\nimport React, { useEffect, useRef } from 'react';\nimport { Transition } from 'react-transition-group';\n\nimport {\n PortalWithTheme,\n PortalWithThemeConsumer,\n} from '##/components/PortalWithTheme';\nimport { useTheme } from '##/components/Theme/Theme';\nimport { useGlobalKeys } from '##/hooks/useGlobalKeys';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cn } from '##/utils/bem';\nimport { AsTagAttribute } from '##/utils/types/AsTags';\nimport { PropsWithHTMLAttributes } from '##/utils/types/PropsWithHTMLAttributes';\n\nconst sidebarPropPosition = ['right', 'bottom', 'left', 'top'] as const;\ntype SidebarPropPosition = typeof sidebarPropPosition[number];\nconst sidebarPropPositionDefault: SidebarPropPosition = sidebarPropPosition[0];\n\nexport const sidebarPropSize = [\n 's',\n 'm',\n 'l',\n 'full',\n '1/2',\n '1/3',\n '1/4',\n '2/3',\n '3/4',\n] as const;\n\nexport type SidebarPropSize = typeof sidebarPropSize[number];\nconst sidebarPropSizeDefault: SidebarPropSize = sidebarPropSize[1];\n\nexport type SidebarProps = PropsWithHTMLAttributes<\n {\n isOpen?: boolean;\n onClose?: () => void;\n onOpen?: () => void;\n hasOverlay?: boolean;\n onClickOutside?: (event: MouseEvent) => void;\n onEsc?: (event: KeyboardEvent) => void;\n position?: SidebarPropPosition;\n size?: SidebarPropSize;\n rootClassName?: string;\n children?: React.ReactNode;\n container?: HTMLDivElement | undefined;\n afterClose?: () => void;\n },\n HTMLDivElement\n>;\n\ntype SidebarContentProps = {\n className?: string;\n children: React.ReactNode;\n};\n\ntype SidebarActionsProps = {\n className?: string;\n children: React.ReactNode;\n};\n\nexport const cnSidebar = cn('Sidebar');\n\nconst SidebarContent: React.FC<SidebarContentProps> = ({\n className,\n children,\n ...rest\n}) => (\n <div\n className={cnSidebar('Content', [className, cnMixScrollBar()])}\n {...rest}\n >\n {children}\n </div>\n);\n\nconst SidebarActions: React.FC<SidebarActionsProps> = ({\n className,\n children,\n ...rest\n}) => (\n <div className={cnSidebar('Actions', [className])} {...rest}>\n {children}\n </div>\n);\n\ninterface SidebarComponent\n extends React.FC<SidebarProps>,\n AsTagAttribute<'div'> {\n Content: typeof SidebarContent;\n Actions: typeof SidebarActions;\n}\n\nexport const Sidebar: SidebarComponent = (props) => {\n const {\n isOpen,\n onClose,\n onOpen,\n hasOverlay = true,\n onClickOutside,\n onEsc,\n position = sidebarPropPositionDefault,\n size = sidebarPropSizeDefault,\n className,\n children,\n container = window.document.body,\n style,\n rootClassName,\n afterClose,\n ...otherProps\n } = props;\n\n const ref = useRef<HTMLDivElement | null>(null);\n\n const portalRef = useRef<HTMLDivElement>(null);\n\n const { theme } = useTheme();\n\n useEffect(() => {\n if (isOpen) {\n onOpen?.();\n } else {\n onClose?.();\n }\n }, [isOpen]);\n\n useGlobalKeys({\n Escape: (e) => isOpen && onEsc && onEsc(e),\n });\n\n return (\n <Transition\n in={isOpen}\n unmountOnExit\n timeout={240}\n nodeRef={portalRef}\n onExiting={afterClose}\n >\n {(animate) => (\n <PortalWithTheme\n preset={theme}\n ref={portalRef}\n container={container}\n className={cnSidebar({ position, hasOverlay }, [rootClassName])}\n style={\n typeof style?.zIndex === 'number'\n ? { zIndex: style.zIndex }\n : undefined\n }\n >\n {hasOverlay && (\n <div\n className={cnSidebar('Overlay', { animate })}\n aria-label=\"Overlay\"\n />\n )}\n <div\n {...otherProps}\n style={{\n ...style,\n zIndex: undefined,\n }}\n className={cnSidebar('Window', { size, position, animate }, [\n className,\n ])}\n ref={ref}\n >\n <PortalWithThemeConsumer\n onClickOutside={onClickOutside}\n ignoreClicksInsideRefs={[ref]}\n >\n {children}\n </PortalWithThemeConsumer>\n </div>\n </PortalWithTheme>\n )}\n </Transition>\n );\n};\n\nSidebar.Content = SidebarContent;\nSidebar.Actions = SidebarActions;\n"],"mappings":"8+BAAA,sBAEA,MAAOA,MAAP,EAAgBC,SAAhB,CAA2BC,MAA3B,KAAyC,OAAzC,CACA,OAASC,UAAT,KAA2B,wBAA3B,CAEA,OACEC,eADF,CAEEC,uBAFF,0BAIA,OAASC,QAAT,sBACA,OAASC,aAAT,iCACA,OAASC,cAAT,+BACA,OAASC,EAAT,uB,GAIMC,oBAAmB,CAAG,CAAC,OAAD,CAAU,QAAV,CAA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CAJtB,CAKE,KAAK,CACsB,QAAzB,gBAAOD,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAEU,MAAd,EACI,CAAEA,MAAM,CAAEV,CAAK,CAACU,MAAhB,CADJ,OANJ,EAWGnB,CAAU,EACT,2BACE,SAAS,CAAEX,SAAS,CAAC,SAAD,CAAY,CAAE6B,OAAO,CAAPA,CAAF,CAAZ,CADtB,CAEE,aAAW,SAFb,EAZJ,CAiBE,2CACMN,CADN,EAEE,KAAK,gCACAH,CADA,MAEHU,MAAM,OAFH,EAFP,CAME,SAAS,CAAE9B,SAAS,CAAC,QAAD,CAAW,CAAEe,IAAI,CAAJA,CAAF,CAAQD,QAAQ,CAARA,CAAR,CAAkBe,OAAO,CAAPA,CAAlB,CAAX,CAAwC,CAC1D3B,CAD0D,CAAxC,CANtB,CASE,GAAG,CAAEsB,CATP,GAWE,oBAAC,uBAAD,EACE,cAAc,CAAEZ,CADlB,CAEE,sBAAsB,CAAE,CAACY,CAAD,CAF1B,EAIGrB,CAJH,CAXF,CAjBF,CADD,CAPH,CA+CH,CArFM,CAuFPG,OAAO,CAACyB,OAAR,CAAkB9B,c,CAClBK,OAAO,CAAC0B,OAAR,CAAkB3B,c"}
|
|
@@ -11,7 +11,7 @@ export declare function withDefaultGetters(props: ThemeTogglerProps): {
|
|
|
11
11
|
value: ThemeTogglerItemDefault;
|
|
12
12
|
onChange: import("./types").ThemeTogglerPropOnChange<ThemeTogglerItemDefault>;
|
|
13
13
|
direction?: import("../Popover").Direction;
|
|
14
|
-
possibleDirections?:
|
|
14
|
+
possibleDirections?: import("../Popover").Direction[];
|
|
15
15
|
children?: never;
|
|
16
16
|
view?: import("../Button").ButtonPropView;
|
|
17
17
|
defaultChecked?: boolean | undefined | undefined;
|
|
@@ -26,7 +26,7 @@ export type ThemeTogglerProps<ITEM = ThemeTogglerItemDefault> = PropsWithHTMLAtt
|
|
|
26
26
|
getItemLabel?: ThemeTogglerPropGetItemLabel<ITEM>;
|
|
27
27
|
getItemIcon?: ThemeTogglerPropGetItemIcon<ITEM>;
|
|
28
28
|
direction?: Direction;
|
|
29
|
-
possibleDirections?:
|
|
29
|
+
possibleDirections?: Direction[];
|
|
30
30
|
children?: never;
|
|
31
31
|
view?: ButtonPropView;
|
|
32
32
|
}, HTMLButtonElement> & (ITEM extends {
|
|
@@ -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 { 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 ThemeTogglerPropOnChange<ITEM> = (\n value: ITEM,\n props: {\n e: React.MouseEvent;\n },\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: ThemeTogglerPropOnChange<ITEM>;\n getItemKey?: ThemeTogglerPropGetItemKey<ITEM>;\n getItemLabel?: ThemeTogglerPropGetItemLabel<ITEM>;\n getItemIcon?: ThemeTogglerPropGetItemIcon<ITEM>;\n direction?: Direction;\n possibleDirections?:
|
|
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 ThemeTogglerPropOnChange<ITEM> = (\n value: ITEM,\n props: {\n e: React.MouseEvent;\n },\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: ThemeTogglerPropOnChange<ITEM>;\n getItemKey?: ThemeTogglerPropGetItemKey<ITEM>;\n getItemLabel?: ThemeTogglerPropGetItemLabel<ITEM>;\n getItemIcon?: ThemeTogglerPropGetItemIcon<ITEM>;\n direction?: Direction;\n possibleDirections?: 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.ReactNode | 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"}
|
|
@@ -12,7 +12,7 @@ export type TooltipProps = PropsWithJsxAttributes<{
|
|
|
12
12
|
status?: TooltipPropStatus;
|
|
13
13
|
direction?: Direction;
|
|
14
14
|
spareDirection?: Direction;
|
|
15
|
-
possibleDirections?:
|
|
15
|
+
possibleDirections?: Direction[];
|
|
16
16
|
isInteractive?: boolean;
|
|
17
17
|
children: React.ReactNode;
|
|
18
18
|
onClickOutside?: ClickOutsideHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus"],"sources":["../../../../../src/components/Tooltip/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '##/hooks/useClickOutside/useClickOutside';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { Direction, PositioningProps } from '../Popover/Popover';\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\nexport const tooltipPropSizesDefault: TooltipPropSize = tooltipPropSizes[0];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n isOpen?: boolean;\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?:
|
|
1
|
+
{"version":3,"file":"types.js","names":["tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus"],"sources":["../../../../../src/components/Tooltip/types.ts"],"sourcesContent":["import { ClickOutsideHandler } from '##/hooks/useClickOutside/useClickOutside';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { Direction, PositioningProps } from '../Popover/Popover';\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\nexport const tooltipPropSizesDefault: TooltipPropSize = tooltipPropSizes[0];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n isOpen?: boolean;\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?: Direction[];\n isInteractive?: boolean;\n children: React.ReactNode;\n onClickOutside?: ClickOutsideHandler;\n className?: string;\n offset?: number;\n onSetDirection?: (direction: Direction) => void;\n viewportRef?: React.RefObject<HTMLElement>;\n container?: Element;\n } & PositioningProps\n>;\n"],"mappings":"AAKA,MAAO,IAAMA,iBAAgB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAzB,CAEP,MAAO,IAAMC,wBAAwC,CAAGD,gBAAgB,CAAC,CAAD,CAAjE,CAEP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,QAD+B,CAE/B,OAF+B,CAG/B,SAH+B,CAI/B,SAJ+B,CAA1B"}
|
|
@@ -13,7 +13,7 @@ export type TooltipProps = PropsWithJsxAttributes<{
|
|
|
13
13
|
status?: TooltipPropStatus;
|
|
14
14
|
direction?: Direction;
|
|
15
15
|
spareDirection?: Direction;
|
|
16
|
-
possibleDirections?:
|
|
16
|
+
possibleDirections?: Direction[];
|
|
17
17
|
isInteractive?: boolean;
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
onClickOutside?: ClickOutsideHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipDeprecated.js","names":["React","useMemo","useState","cnMixPopoverArrow","cnDeprecated","Popover","Text","generateDeps","generateThemeClassNames","ThemeContext","useTheme","ARROW_SIZE","ARROW_OFFSET","cnTooltip","tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus","renderChildren","children","Tooltip","forwardRef","props","ref","size","className","status","onSetDirectionProp","onSetDirection","style","offset","rest","theme","direction","setDirection","value","tooltipTheme","color","primary","accent","invert","themeClassNames"],"sources":["../../../../../src/components/TooltipDeprecated/TooltipDeprecated.tsx"],"sourcesContent":["import './Tooltip.css';\n\nimport React, { useMemo, useState } from 'react';\n\nimport { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { cnMixPopoverArrow } from '../../mixs/MixPopoverArrow/MixPopoverArrow';\nimport { cnDeprecated } from '../../utils/bem';\nimport { PropsWithJsxAttributes } from '../../utils/types/PropsWithJsxAttributes';\nimport { Direction, Popover, PositioningProps } from '../Popover/Popover';\nimport { Text } from '../Text/Text';\nimport {\n generateDeps,\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../Theme/Theme';\n\nconst ARROW_SIZE = 6;\nconst ARROW_OFFSET = 8;\n\nconst cnTooltip = cnDeprecated('Tooltip');\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport const tooltipPropSizesDefault = tooltipPropSizes[0];\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?:
|
|
1
|
+
{"version":3,"file":"TooltipDeprecated.js","names":["React","useMemo","useState","cnMixPopoverArrow","cnDeprecated","Popover","Text","generateDeps","generateThemeClassNames","ThemeContext","useTheme","ARROW_SIZE","ARROW_OFFSET","cnTooltip","tooltipPropSizes","tooltipPropSizesDefault","tooltipPropStatus","renderChildren","children","Tooltip","forwardRef","props","ref","size","className","status","onSetDirectionProp","onSetDirection","style","offset","rest","theme","direction","setDirection","value","tooltipTheme","color","primary","accent","invert","themeClassNames"],"sources":["../../../../../src/components/TooltipDeprecated/TooltipDeprecated.tsx"],"sourcesContent":["import './Tooltip.css';\n\nimport React, { useMemo, useState } from 'react';\n\nimport { ClickOutsideHandler } from '../../hooks/useClickOutside/useClickOutside';\nimport { cnMixPopoverArrow } from '../../mixs/MixPopoverArrow/MixPopoverArrow';\nimport { cnDeprecated } from '../../utils/bem';\nimport { PropsWithJsxAttributes } from '../../utils/types/PropsWithJsxAttributes';\nimport { Direction, Popover, PositioningProps } from '../Popover/Popover';\nimport { Text } from '../Text/Text';\nimport {\n generateDeps,\n generateThemeClassNames,\n ThemeContext,\n useTheme,\n} from '../Theme/Theme';\n\nconst ARROW_SIZE = 6;\nconst ARROW_OFFSET = 8;\n\nconst cnTooltip = cnDeprecated('Tooltip');\n\nexport const tooltipPropSizes = ['m', 's', 'l'] as const;\nexport const tooltipPropSizesDefault = tooltipPropSizes[0];\nexport type TooltipPropSize = typeof tooltipPropSizes[number];\n\nexport const tooltipPropStatus = [\n 'normal',\n 'alert',\n 'success',\n 'warning',\n] as const;\nexport type TooltipPropStatus = typeof tooltipPropStatus[number];\n\nexport type TooltipProps = PropsWithJsxAttributes<\n {\n size?: TooltipPropSize;\n status?: TooltipPropStatus;\n direction?: Direction;\n spareDirection?: Direction;\n possibleDirections?: Direction[];\n isInteractive?: boolean;\n children: React.ReactNode;\n onClickOutside?: ClickOutsideHandler;\n className?: string;\n offset?: number;\n onSetDirection?: (direction: Direction) => void;\n } & PositioningProps\n>;\n\nfunction renderChildren(children: React.ReactNode): React.ReactNode {\n return typeof children === 'string' || typeof children === 'number' ? (\n <Text size=\"xs\" view=\"primary\" lineHeight=\"m\">\n {children}\n </Text>\n ) : (\n children\n );\n}\n\nexport const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(\n (props, ref) => {\n const {\n children,\n size = tooltipPropSizesDefault,\n className,\n status,\n onSetDirection: onSetDirectionProp,\n style,\n offset = 0,\n ...rest\n } = props;\n const { theme } = useTheme();\n const [direction, setDirection] = useState<Direction | undefined>();\n\n const onSetDirection = (direction: Direction) => {\n onSetDirectionProp && onSetDirectionProp(direction);\n setDirection(direction);\n };\n\n const value = useMemo(() => {\n const tooltipTheme = status\n ? {\n ...theme,\n color: {\n primary: theme.color.accent,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n }\n : {\n ...theme,\n color: {\n primary: theme.color.invert,\n accent: theme.color.accent,\n invert: theme.color.primary,\n },\n };\n\n return {\n theme: tooltipTheme,\n themeClassNames: generateThemeClassNames(tooltipTheme),\n };\n }, [generateDeps(theme), status]);\n\n return (\n <ThemeContext.Provider value={value}>\n <Popover\n {...rest}\n arrowOffset={ARROW_OFFSET + ARROW_SIZE}\n offset={ARROW_SIZE + 4 + offset}\n onSetDirection={onSetDirection}\n ref={ref}\n className={cnTooltip({ status }, [className])}\n style={{\n ['--popover-arrow-size' as string]: `${ARROW_SIZE}px`,\n ['--popover-arrow-offset' as string]: `${ARROW_OFFSET}px`,\n ...style,\n }}\n >\n <div className={cnTooltip('Background')} />\n <div\n className={cnTooltip('Arrow', [cnMixPopoverArrow({ direction })])}\n />\n <div className={cnTooltip('Content', { size })}>\n {renderChildren(children)}\n </div>\n </Popover>\n </ThemeContext.Provider>\n );\n },\n);\n"],"mappings":"o5BAAA,sBAEA,MAAOA,MAAP,EAAgBC,OAAhB,CAAyBC,QAAzB,KAAyC,OAAzC,CAGA,OAASC,iBAAT,kDACA,OAASC,YAAT,uBAEA,OAAoBC,OAApB,0BACA,OAASC,IAAT,oBACA,OACEC,YADF,CAEEC,uBAFF,CAGEC,YAHF,CAIEC,QAJF,sB,GAOMC,WAAU,CAAG,C,CACbC,YAAY,CAAG,C,CAEfC,SAAS,CAAGT,YAAY,CAAC,SAAD,C,CAE9B,MAA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EoB,CAAhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useClickOutside';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/utils/state/useClickOutsideAtom/index.ts"],"sourcesContent":["export * from './useClickOutside';\n"],"mappings":"AAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AtomMut } from '@reatom/core';
|
|
2
|
+
export type ClickOutsideHandler = (event: MouseEvent) => void;
|
|
3
|
+
type UseClickOutsideProps = {
|
|
4
|
+
isActiveAtom?: AtomMut<boolean>;
|
|
5
|
+
ignoreClicksElementsAtom?: AtomMut<(HTMLElement | null)[]>;
|
|
6
|
+
handler?: ClickOutsideHandler;
|
|
7
|
+
};
|
|
8
|
+
export declare const useClickOutsideAtom: ({ isActiveAtom, ignoreClicksElementsAtom, handler, }: UseClickOutsideProps) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useAction}from"@reatom/npm-react";import{useEffect}from"react";import{useSendToAtom}from"../useSendToAtom";export var useClickOutsideAtom=function(a){var b=a.isActiveAtom,c=a.ignoreClicksElementsAtom,d=a.handler,f=useSendToAtom([d]),g=useAction(function(a,d){var e=b&&a.get(b),g=c&&a.get(c),h=a.get(f)[0];e&&h&&(null===g||void 0===g?void 0:g.length)&&g.every(function(a){return!(null!==a&&void 0!==a&&a.contains(d.target))})&&h(d)});useEffect(function(){return document.addEventListener("mousedown",g),function(){document.removeEventListener("mousedown",g)}},[])};
|
|
2
|
+
//# sourceMappingURL=useClickOutside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClickOutside.js","names":["useAction","useEffect","useSendToAtom","useClickOutsideAtom","isActiveAtom","ignoreClicksElementsAtom","handler","handlerAtom","fn","ctx","e","isActive","get","ignoreClicksElements","length","every","el","contains","target","document","addEventListener","removeEventListener"],"sources":["../../../../../../src/utils/state/useClickOutsideAtom/useClickOutside.tsx"],"sourcesContent":["import { AtomMut } from '@reatom/core';\nimport { useAction } from '@reatom/npm-react';\nimport { useEffect } from 'react';\n\nimport { useSendToAtom } from '##/utils/state/useSendToAtom';\n\nexport type ClickOutsideHandler = (event: MouseEvent) => void;\n\ntype UseClickOutsideProps = {\n isActiveAtom?: AtomMut<boolean>;\n ignoreClicksElementsAtom?: AtomMut<(HTMLElement | null)[]>;\n handler?: ClickOutsideHandler;\n};\n\nexport const useClickOutsideAtom = ({\n isActiveAtom,\n ignoreClicksElementsAtom,\n handler,\n}: UseClickOutsideProps) => {\n const handlerAtom = useSendToAtom([handler]);\n\n const fn = useAction((ctx, e: MouseEvent) => {\n const isActive = isActiveAtom && ctx.get(isActiveAtom);\n const ignoreClicksElements =\n ignoreClicksElementsAtom && ctx.get(ignoreClicksElementsAtom);\n const handler = ctx.get(handlerAtom)[0];\n isActive &&\n handler &&\n ignoreClicksElements?.length &&\n ignoreClicksElements.every((el) => !el?.contains(e.target as Node)) &&\n handler(e);\n });\n\n useEffect(() => {\n document.addEventListener('mousedown', fn);\n\n return () => {\n document.removeEventListener('mousedown', fn);\n };\n }, []);\n};\n"],"mappings":"AACA,OAASA,SAAT,KAA0B,mBAA1B,CACA,OAASC,SAAT,KAA0B,OAA1B,CAEA,OAASC,aAAT,wBAUA,MAAO,IAAMC,oBAAmB,CAAG,WAIP,IAH1BC,EAG0B,GAH1BA,YAG0B,CAF1BC,CAE0B,GAF1BA,wBAE0B,CAD1BC,CAC0B,GAD1BA,OAC0B,CACpBC,CAAW,CAAGL,aAAa,CAAC,CAACI,CAAD,CAAD,CADP,CAGpBE,CAAE,CAAGR,SAAS,CAAC,SAACS,CAAD,CAAMC,CAAN,CAAwB,IACrCC,EAAQ,CAAGP,CAAY,EAAIK,CAAG,CAACG,GAAJ,CAAQR,CAAR,CADU,CAErCS,CAAoB,CACxBR,CAAwB,EAAII,CAAG,CAACG,GAAJ,CAAQP,CAAR,CAHa,CAIrCC,CAAO,CAAGG,CAAG,CAACG,GAAJ,CAAQL,CAAR,EAAqB,CAArB,CAJ2B,CAK3CI,CAAQ,EACNL,CADF,UAEEO,CAFF,WAEEA,CAFF,QAEEA,CAAoB,CAAEC,MAFxB,GAGED,CAAoB,CAACE,KAArB,CAA2B,SAACC,CAAD,QAAQ,SAACA,CAAD,WAACA,CAAD,EAACA,CAAE,CAAEC,QAAJ,CAAaP,CAAC,CAACQ,MAAf,CAAD,CAAR,CAA3B,CAHF,EAIEZ,CAAO,CAACI,CAAD,CACV,CAVmB,CAHM,CAe1BT,SAAS,CAAC,UAAM,CAGd,MAFAkB,SAAQ,CAACC,gBAAT,CAA0B,WAA1B,CAAuCZ,CAAvC,CAEA,CAAO,UAAM,CACXW,QAAQ,CAACE,mBAAT,CAA6B,WAA7B,CAA0Cb,CAA1C,CACD,CACF,CANQ,CAMN,EANM,CAOV,CA1BM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useElementAtomEventListener';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/utils/state/useElementAtomEventListener/index.ts"],"sourcesContent":["export * from './useElementAtomEventListener';\n"],"mappings":"AAAA"}
|
package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useUpdate}from"@reatom/npm-react";import{useEffect,useRef}from"react";import{setRef}from"../../setRef";export var useElementAtomEventListener=function(a,b,c){var d=useRef(null);useUpdate(function(a,c,e){var f;null===(f=d.current)||void 0===f?void 0:f.removeEventListener(b,e),null===c||void 0===c?void 0:c.addEventListener(b,e),setRef(d,c||null)},[a,c]),useEffect(function(){return function(){var a;null===(a=d.current)||void 0===a?void 0:a.removeEventListener(b,c)}},[b,c])};
|
|
2
|
+
//# sourceMappingURL=useElementAtomEventListener.js.map
|
package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementAtomEventListener.js","names":["useUpdate","useEffect","useRef","setRef","useElementAtomEventListener","elementAtom","type","listener","currentRef","ctx","element","current","removeEventListener","addEventListener"],"sources":["../../../../../../src/utils/state/useElementAtomEventListener/useElementAtomEventListener.ts"],"sourcesContent":["import { AtomMut } from '@reatom/framework';\nimport { useUpdate } from '@reatom/npm-react';\nimport { useEffect, useRef } from 'react';\n\nimport { setRef } from '##/utils/setRef';\n\nexport const useElementAtomEventListener = <T extends HTMLElement>(\n elementAtom: AtomMut<T | null>,\n type: keyof DocumentEventMap,\n listener: EventListener,\n) => {\n const currentRef = useRef<T | null>(null);\n useUpdate(\n (ctx, element, listener) => {\n currentRef.current?.removeEventListener(type, listener);\n element?.addEventListener(type, listener);\n\n setRef(currentRef, element || null);\n },\n [elementAtom, listener],\n );\n useEffect(() => {\n return () => {\n currentRef.current?.removeEventListener(type, listener);\n };\n }, [type, listener]);\n};\n"],"mappings":"AACA,OAASA,SAAT,KAA0B,mBAA1B,CACA,OAASC,SAAT,CAAoBC,MAApB,KAAkC,OAAlC,CAEA,OAASC,MAAT,oBAEA,MAAO,IAAMC,4BAA2B,CAAG,SACzCC,CADyC,CAEzCC,CAFyC,CAGzCC,CAHyC,CAItC,CACH,GAAMC,EAAU,CAAGN,MAAM,CAAW,IAAX,CAAzB,CACAF,SAAS,CACP,SAACS,CAAD,CAAMC,CAAN,CAAeH,CAAf,CAA4B,iBAC1BC,CAAU,CAACG,OADe,qBAC1B,EAAoBC,mBAApB,CAAwCN,CAAxC,CAA8CC,CAA9C,CAD0B,QAE1BG,CAF0B,WAE1BA,CAF0B,QAE1BA,CAAO,CAAEG,gBAAT,CAA0BP,CAA1B,CAAgCC,CAAhC,CAF0B,CAI1BJ,MAAM,CAACK,CAAD,CAAaE,CAAO,EAAI,IAAxB,CACP,CANM,CAOP,CAACL,CAAD,CAAcE,CAAd,CAPO,CAFN,CAWHN,SAAS,CAAC,UAAM,CACd,MAAO,WAAM,iBACXO,CAAU,CAACG,OADA,qBACX,EAAoBC,mBAApB,CAAwCN,CAAxC,CAA8CC,CAA9C,CACD,CACF,CAJQ,CAIN,CAACD,CAAD,CAAOC,CAAP,CAJM,CAKV,CApBM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useKeysAtom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/utils/state/useKeysAtom/index.ts"],"sourcesContent":["export * from './useKeysAtom';\n"],"mappings":"AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AtomMut } from '@reatom/core';
|
|
2
|
+
import { KeyCode } from '../../types/KeyCode';
|
|
3
|
+
export type KeyHandlers = Partial<Record<KeyCode, (e: KeyboardEvent) => void>> & {
|
|
4
|
+
[key: string]: (e: KeyboardEvent) => void;
|
|
5
|
+
};
|
|
6
|
+
type UseKeysProps<E extends HTMLElement> = {
|
|
7
|
+
elAtom: AtomMut<E | null>;
|
|
8
|
+
keysAtom?: AtomMut<KeyHandlers>;
|
|
9
|
+
isActiveAtom?: AtomMut<boolean>;
|
|
10
|
+
eventHandler?: (e: KeyboardEvent) => void;
|
|
11
|
+
eventType?: 'keypress' | 'keydown' | 'keyup';
|
|
12
|
+
};
|
|
13
|
+
export declare const useKeysAtom: <E extends HTMLElement>({ elAtom, keysAtom, isActiveAtom, eventType, eventHandler, }: UseKeysProps<E>) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useAction}from"@reatom/npm-react";import{useElementAtomEventListener}from"../useElementAtomEventListener";import{useSendToAtom}from"../useSendToAtom";export var useKeysAtom=function(a){var b=a.elAtom,c=a.keysAtom,d=a.isActiveAtom,e=a.eventType,f=void 0===e?"keydown":e,g=a.eventHandler,h=useSendToAtom([g]),i=useAction(function(a,b){var e,f,g=c&&a.get(c),i=d&&a.get(d);if(g&&i){var j;null===(j=g[b.code]||g[b.key])||void 0===j?void 0:j(b)}null===(e=(f=a.get(h))[0])||void 0===e?void 0:e.call(f,b)});useElementAtomEventListener(b,f,i)};
|
|
2
|
+
//# sourceMappingURL=useKeysAtom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeysAtom.js","names":["useAction","useElementAtomEventListener","useSendToAtom","useKeysAtom","elAtom","keysAtom","isActiveAtom","eventType","eventHandler","eventHandlerAtom","fn","ctx","e","keys","get","isActive","code","key"],"sources":["../../../../../../src/utils/state/useKeysAtom/useKeysAtom.ts"],"sourcesContent":["import { AtomMut } from '@reatom/core';\nimport { useAction } from '@reatom/npm-react';\n\nimport { useElementAtomEventListener } from '##/utils/state/useElementAtomEventListener';\nimport { useSendToAtom } from '##/utils/state/useSendToAtom';\nimport { KeyCode } from '##/utils/types/KeyCode';\n\nexport type KeyHandlers = Partial<\n Record<KeyCode, (e: KeyboardEvent) => void>\n> & {\n [key: string]: (e: KeyboardEvent) => void;\n};\n\ntype UseKeysProps<E extends HTMLElement> = {\n elAtom: AtomMut<E | null>;\n keysAtom?: AtomMut<KeyHandlers>;\n isActiveAtom?: AtomMut<boolean>;\n eventHandler?: (e: KeyboardEvent) => void;\n eventType?: 'keypress' | 'keydown' | 'keyup';\n};\n\nexport const useKeysAtom = <E extends HTMLElement>({\n elAtom,\n keysAtom,\n isActiveAtom,\n eventType = 'keydown',\n eventHandler,\n}: UseKeysProps<E>) => {\n const eventHandlerAtom = useSendToAtom([eventHandler]);\n const fn = useAction((ctx, e: KeyboardEvent) => {\n const keys = keysAtom && ctx.get(keysAtom);\n const isActive = isActiveAtom && ctx.get(isActiveAtom);\n if (keys && isActive) {\n (keys[e.code as KeyCode] || keys[e.key as KeyCode])?.(e);\n }\n ctx.get(eventHandlerAtom)[0]?.(e);\n });\n\n useElementAtomEventListener(elAtom, eventType, fn as EventListener);\n};\n"],"mappings":"AACA,OAASA,SAAT,KAA0B,mBAA1B,CAEA,OAASC,2BAAT,sCACA,OAASC,aAAT,wBAiBA,MAAO,IAAMC,YAAW,CAAG,WAMJ,IALrBC,EAKqB,GALrBA,MAKqB,CAJrBC,CAIqB,GAJrBA,QAIqB,CAHrBC,CAGqB,GAHrBA,YAGqB,KAFrBC,SAEqB,CAFrBA,CAEqB,YAFT,SAES,GADrBC,CACqB,GADrBA,YACqB,CACfC,CAAgB,CAAGP,aAAa,CAAC,CAACM,CAAD,CAAD,CADjB,CAEfE,CAAE,CAAGV,SAAS,CAAC,SAACW,CAAD,CAAMC,CAAN,CAA2B,SACxCC,CAAI,CAAGR,CAAQ,EAAIM,CAAG,CAACG,GAAJ,CAAQT,CAAR,CADqB,CAExCU,CAAQ,CAAGT,CAAY,EAAIK,CAAG,CAACG,GAAJ,CAAQR,CAAR,CAFa,CAG9C,GAAIO,CAAI,EAAIE,CAAZ,CAAsB,iBACnBF,CAAI,CAACD,CAAC,CAACI,IAAH,CAAJ,EAA2BH,CAAI,CAACD,CAAC,CAACK,GAAH,CADZ,qBACpB,EAAsDL,CAAtD,CACD,CAL6C,UAM9C,GAAAD,CAAG,CAACG,GAAJ,CAAQL,CAAR,GAA0B,CAA1B,CAN8C,qBAM9C,SAA+BG,CAA/B,CACD,CAPmB,CAFC,CAWrBX,2BAA2B,CAACG,CAAD,CAASG,CAAT,CAAoBG,CAApB,CAC5B,CAlBM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RefCallback } from 'react';
|
|
2
|
-
export declare const useRefAtom: <T extends HTMLElement>() => readonly [import("@reatom/core").AtomMut<T | null>, RefCallback<T>];
|
|
2
|
+
export declare const useRefAtom: <T extends HTMLElement>() => readonly [import("@reatom/core").AtomMut<T | null>, RefCallback<T | null>];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRefAtom.js","names":["useAction","useCreateAtom","useRefAtom","atom","ref","ctx","el"],"sources":["../../../../../../src/utils/state/useRefAtom/useRefAtom.ts"],"sourcesContent":["import { useAction } from '@reatom/npm-react';\nimport { RefCallback } from 'react';\n\nimport { useCreateAtom } from '##/utils/state/useCreateAtom';\n\nexport const useRefAtom = <T extends HTMLElement>() => {\n const atom = useCreateAtom<T | null>(null);\n const ref: RefCallback<T> = useAction((ctx, el: T) => atom(ctx, el));\n return [atom, ref] as const;\n};\n"],"mappings":"AAAA,OAASA,SAAT,KAA0B,mBAA1B,CAGA,OAASC,aAAT,wBAEA,MAAO,IAAMC,WAAU,CAAG,UAA6B,IAC/CC,EAAI,CAAGF,aAAa,CAAW,IAAX,CAD2B,CAE/CG,
|
|
1
|
+
{"version":3,"file":"useRefAtom.js","names":["useAction","useCreateAtom","useRefAtom","atom","ref","ctx","el"],"sources":["../../../../../../src/utils/state/useRefAtom/useRefAtom.ts"],"sourcesContent":["import { useAction } from '@reatom/npm-react';\nimport { RefCallback } from 'react';\n\nimport { useCreateAtom } from '##/utils/state/useCreateAtom';\n\nexport const useRefAtom = <T extends HTMLElement>() => {\n const atom = useCreateAtom<T | null>(null);\n const ref: RefCallback<T | null> = useAction((ctx, el: T) => atom(ctx, el));\n return [atom, ref] as const;\n};\n"],"mappings":"AAAA,OAASA,SAAT,KAA0B,mBAA1B,CAGA,OAASC,aAAT,wBAEA,MAAO,IAAMC,WAAU,CAAG,UAA6B,IAC/CC,EAAI,CAAGF,aAAa,CAAW,IAAX,CAD2B,CAE/CG,CAA0B,CAAGJ,SAAS,CAAC,SAACK,CAAD,CAAMC,CAAN,QAAgBH,EAAI,CAACE,CAAD,CAAMC,CAAN,CAApB,CAAD,CAFS,CAGrD,MAAO,CAACH,CAAD,CAAOC,CAAP,CACR,CAJM"}
|