@consta/uikit 5.25.1 → 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.
Files changed (154) hide show
  1. package/FlatSelect/index.d.ts +1 -0
  2. package/FlatSelect/index.js +1 -0
  3. package/__internal__/src/components/Combobox/Combobox.js +1 -1
  4. package/__internal__/src/components/Combobox/Combobox.js.map +1 -1
  5. package/__internal__/src/components/ContextMenu/ContextMenu.js +1 -1
  6. package/__internal__/src/components/ContextMenu/ContextMenu.js.map +1 -1
  7. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.d.ts +2 -2
  8. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js +1 -1
  9. package/__internal__/src/components/ContextMenu/ContextMenuLevels/ContextMenuLevels.js.map +1 -1
  10. package/__internal__/src/components/ContextMenu/helpers.d.ts +2 -2
  11. package/__internal__/src/components/ContextMenu/types.d.ts +5 -5
  12. package/__internal__/src/components/ContextMenu/types.js.map +1 -1
  13. package/__internal__/src/components/FieldComponents/FieldButton/FieldButton.d.ts +1 -1
  14. package/__internal__/src/components/FieldComponents/FieldButton/FieldButton.js.map +1 -1
  15. package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.d.ts +1 -0
  16. package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.js +1 -1
  17. package/__internal__/src/components/FieldComponents/FieldClearButton/FieldClearButton.js.map +1 -1
  18. package/__internal__/src/components/FlatSelect/FlatSelect.css +9 -0
  19. package/__internal__/src/components/FlatSelect/FlatSelect.d.ts +4 -0
  20. package/__internal__/src/components/FlatSelect/FlatSelect.js +2 -0
  21. package/__internal__/src/components/FlatSelect/FlatSelect.js.map +1 -0
  22. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.d.ts +16 -0
  23. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.js +2 -0
  24. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/FlatSelectControlLayout.js.map +1 -0
  25. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.d.ts +1 -0
  26. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.js +2 -0
  27. package/__internal__/src/components/FlatSelect/FlatSelectControlLayout/index.js.map +1 -0
  28. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.css +1 -0
  29. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.d.ts +19 -0
  30. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.js +2 -0
  31. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/FlatSelectCreateButton.js.map +1 -0
  32. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.d.ts +1 -0
  33. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.js +2 -0
  34. package/__internal__/src/components/FlatSelect/FlatSelectCreateButton/index.js.map +1 -0
  35. package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.css +1 -0
  36. package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.d.ts +12 -0
  37. package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.js +2 -0
  38. package/__internal__/src/components/FlatSelect/FlatSelectFooter/FlatSelectFooter.js.map +1 -0
  39. package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.d.ts +1 -0
  40. package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.js +2 -0
  41. package/__internal__/src/components/FlatSelect/FlatSelectFooter/index.js.map +1 -0
  42. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.d.ts +10 -0
  43. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.js +2 -0
  44. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/FlatSelectGroupLabel.js.map +1 -0
  45. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.d.ts +1 -0
  46. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.js +2 -0
  47. package/__internal__/src/components/FlatSelect/FlatSelectGroupLabel/index.js.map +1 -0
  48. package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.css +1 -0
  49. package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.d.ts +17 -0
  50. package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.js +2 -0
  51. package/__internal__/src/components/FlatSelect/FlatSelectItem/FlatSelectItem.js.map +1 -0
  52. package/__internal__/src/components/FlatSelect/FlatSelectItem/index.d.ts +1 -0
  53. package/__internal__/src/components/FlatSelect/FlatSelectItem/index.js +2 -0
  54. package/__internal__/src/components/FlatSelect/FlatSelectItem/index.js.map +1 -0
  55. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.css +1 -0
  56. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.d.ts +17 -0
  57. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.js +2 -0
  58. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/FlatSelectItemAll.js.map +1 -0
  59. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.d.ts +1 -0
  60. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.js +2 -0
  61. package/__internal__/src/components/FlatSelect/FlatSelectItemAll/index.js.map +1 -0
  62. package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.css +1 -0
  63. package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.d.ts +53 -0
  64. package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.js +2 -0
  65. package/__internal__/src/components/FlatSelect/FlatSelectList/FlatSelectList.js.map +1 -0
  66. package/__internal__/src/components/FlatSelect/FlatSelectList/index.d.ts +1 -0
  67. package/__internal__/src/components/FlatSelect/FlatSelectList/index.js +2 -0
  68. package/__internal__/src/components/FlatSelect/FlatSelectList/index.js.map +1 -0
  69. package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.css +1 -0
  70. package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.d.ts +3 -0
  71. package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.js +2 -0
  72. package/__internal__/src/components/FlatSelect/FlatSelectLoader/FlatSelectLoader.js.map +1 -0
  73. package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.d.ts +1 -0
  74. package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.js +2 -0
  75. package/__internal__/src/components/FlatSelect/FlatSelectLoader/index.js.map +1 -0
  76. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.d.ts +24 -0
  77. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.js +2 -0
  78. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/FlatSelectRenderItem.js.map +1 -0
  79. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.d.ts +1 -0
  80. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.js +2 -0
  81. package/__internal__/src/components/FlatSelect/FlatSelectRenderItem/index.js.map +1 -0
  82. package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.css +1 -0
  83. package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.d.ts +14 -0
  84. package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js +2 -0
  85. package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js.map +1 -0
  86. package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.d.ts +1 -0
  87. package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.js +2 -0
  88. package/__internal__/src/components/FlatSelect/FlatSelectRoot/index.js.map +1 -0
  89. package/__internal__/src/components/FlatSelect/defaultProps.d.ts +22 -0
  90. package/__internal__/src/components/FlatSelect/defaultProps.js +2 -0
  91. package/__internal__/src/components/FlatSelect/defaultProps.js.map +1 -0
  92. package/__internal__/src/components/FlatSelect/index.d.ts +2 -0
  93. package/__internal__/src/components/FlatSelect/index.js +2 -0
  94. package/__internal__/src/components/FlatSelect/index.js.map +1 -0
  95. package/__internal__/src/components/FlatSelect/types.d.ts +133 -0
  96. package/__internal__/src/components/FlatSelect/types.js +2 -0
  97. package/__internal__/src/components/FlatSelect/types.js.map +1 -0
  98. package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.d.ts +4 -0
  99. package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.js +2 -0
  100. package/__internal__/src/components/FlatSelect/useFlatSelect/helpers.js.map +1 -0
  101. package/__internal__/src/components/FlatSelect/useFlatSelect/index.d.ts +1 -0
  102. package/__internal__/src/components/FlatSelect/useFlatSelect/index.js +2 -0
  103. package/__internal__/src/components/FlatSelect/useFlatSelect/index.js.map +1 -0
  104. package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.d.ts +52 -0
  105. package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.js +2 -0
  106. package/__internal__/src/components/FlatSelect/useFlatSelect/useFlatSelect.js.map +1 -0
  107. package/__internal__/src/components/FlatSelect/useRenderItem/index.d.ts +1 -0
  108. package/__internal__/src/components/FlatSelect/useRenderItem/index.js +2 -0
  109. package/__internal__/src/components/FlatSelect/useRenderItem/index.js.map +1 -0
  110. package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.d.ts +10 -0
  111. package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.js +2 -0
  112. package/__internal__/src/components/FlatSelect/useRenderItem/useRenderItem.js.map +1 -0
  113. package/__internal__/src/components/ListCanary/ListBox/ListBox.js +1 -1
  114. package/__internal__/src/components/ListCanary/ListBox/ListBox.js.map +1 -1
  115. package/__internal__/src/components/ListCanary/types.d.ts +1 -0
  116. package/__internal__/src/components/ListCanary/types.js.map +1 -1
  117. package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.d.ts +1 -0
  118. package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.js +1 -1
  119. package/__internal__/src/components/Pagination/PaginationArrow/PaginationArrow.js.map +1 -1
  120. package/__internal__/src/components/Popover/Popover.d.ts +2 -2
  121. package/__internal__/src/components/Popover/Popover.js.map +1 -1
  122. package/__internal__/src/components/SelectCanary/helpers.d.ts +1 -1
  123. package/__internal__/src/components/Sidebar/Sidebar.d.ts +1 -1
  124. package/__internal__/src/components/Sidebar/Sidebar.js.map +1 -1
  125. package/__internal__/src/components/ThemeToggler/helpers.d.ts +1 -1
  126. package/__internal__/src/components/ThemeToggler/types.d.ts +1 -1
  127. package/__internal__/src/components/ThemeToggler/types.js.map +1 -1
  128. package/__internal__/src/components/Tooltip/types.d.ts +1 -1
  129. package/__internal__/src/components/Tooltip/types.js.map +1 -1
  130. package/__internal__/src/components/TooltipDeprecated/TooltipDeprecated.d.ts +1 -1
  131. package/__internal__/src/components/TooltipDeprecated/TooltipDeprecated.js.map +1 -1
  132. package/__internal__/src/utils/state/useClickOutsideAtom/index.d.ts +1 -0
  133. package/__internal__/src/utils/state/useClickOutsideAtom/index.js +2 -0
  134. package/__internal__/src/utils/state/useClickOutsideAtom/index.js.map +1 -0
  135. package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.d.ts +9 -0
  136. package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.js +2 -0
  137. package/__internal__/src/utils/state/useClickOutsideAtom/useClickOutside.js.map +1 -0
  138. package/__internal__/src/utils/state/useElementAtomEventListener/index.d.ts +1 -0
  139. package/__internal__/src/utils/state/useElementAtomEventListener/index.js +2 -0
  140. package/__internal__/src/utils/state/useElementAtomEventListener/index.js.map +1 -0
  141. package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.d.ts +2 -0
  142. package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js +2 -0
  143. package/__internal__/src/utils/state/useElementAtomEventListener/useElementAtomEventListener.js.map +1 -0
  144. package/__internal__/src/utils/state/useKeysAtom/index.d.ts +1 -0
  145. package/__internal__/src/utils/state/useKeysAtom/index.js +2 -0
  146. package/__internal__/src/utils/state/useKeysAtom/index.js.map +1 -0
  147. package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.d.ts +14 -0
  148. package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.js +2 -0
  149. package/__internal__/src/utils/state/useKeysAtom/useKeysAtom.js.map +1 -0
  150. package/__internal__/src/utils/state/useRefAtom/useRefAtom.d.ts +1 -1
  151. package/__internal__/src/utils/state/useRefAtom/useRefAtom.js.map +1 -1
  152. package/__internal__/src/utils/state/withCtx/withCtx.js +1 -1
  153. package/__internal__/src/utils/state/withCtx/withCtx.js.map +1 -1
  154. 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,CAen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GAyBE,oBAAC,uBAAD,EACE,cAAc,CAAEL,CADlB,CAEE,sBAAsB,CAAE,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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1B"}
@@ -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" | "aria-Label" | "selectAllLabel"> & import("react").RefAttributes<HTMLDivElement> & (ITEM extends {
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\ntype 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,CAAoB,MAApB,CAA4B,KAA5B,C,CAEtBC,0BAA+C,CAAGD,mBAAmB,CAAC,CAAD,C,CAE3E,MAAO,IAAME,gBAAe,CAAG,CAC7B,GAD6B,CAE7B,GAF6B,CAG7B,GAH6B,CAI7B,MAJ6B,CAK7B,KAL6B,CAM7B,KAN6B,CAO7B,KAP6B,CAQ7B,KAR6B,CAS7B,KAT6B,CAAxB,CAaP,GAAMC,uBAAuC,CAAGD,eAAe,CAAC,CAAD,CAA/D,CA8BA,MAAO,IAAME,UAAS,CAAGL,EAAE,CAAC,SAAD,CAApB,C,GAEDM,eAA6C,CAAG,eACpDC,E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Ee,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"}
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,CAAoB,MAApB,CAA4B,KAA5B,C,CAEtBC,0BAA+C,CAAGD,mBAAmB,CAAC,CAAD,C,CAE3E,MAAO,IAAME,gBAAe,CAAG,CAC7B,GAD6B,CAE7B,GAF6B,CAG7B,GAH6B,CAI7B,MAJ6B,CAK7B,KAL6B,CAM7B,KAN6B,CAO7B,KAP6B,CAQ7B,KAR6B,CAS7B,KAT6B,CAAxB,CAaP,GAAMC,uBAAuC,CAAGD,eAAe,CAAC,CAAD,CAA/D,CA8BA,MAAO,IAAME,UAAS,CAAGL,EAAE,CAAC,SAAD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S,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?: readonly import("../Popover").Direction[];
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?: readonly Direction[];
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?: readonly Direction[];\n children?: never;\n view?: ButtonPropView;\n },\n HTMLButtonElement\n > &\n (ITEM extends { key: ThemeTogglerItemDefault['key'] }\n ? {}\n : { getItemKey: ThemeTogglerPropGetItemLabel<ITEM> }) &\n (ITEM extends { label: ThemeTogglerItemDefault['label'] }\n ? {}\n : { getItemLabel: ThemeTogglerPropGetItemLabel<ITEM> }) &\n (ITEM extends { icon: ThemeTogglerItemDefault['icon'] }\n ? {}\n : { getItemIcon: ThemeTogglerPropGetItemIcon<ITEM> });\n\nexport type ThemeTogglerComponent = <ITEM>(\n props: ThemeTogglerProps<ITEM>,\n) => React.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"}
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?: readonly Direction[];
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?: readonly 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"}
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?: readonly Direction[];
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?: readonly 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,MAAO,IAAMU,iBAAgB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAzB,CACP,MAAO,IAAMC,wBAAuB,CAAGD,gBAAgB,CAAC,CAAD,CAAhD,CAGP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,QAD+B,CAE/B,OAF+B,CAG/B,SAH+B,CAI/B,SAJ+B,CAA1B,CAwBP,QAASC,eAAT,CAAwBC,CAAxB,CAAoE,CAClE,MAA2B,QAApB,QAAOA,EAAP,EAAoD,QAApB,QAAOA,EAAvC,CACL,oBAAC,IAAD,EAAM,IAAI,CAAC,IAAX,CAAgB,IAAI,CAAC,SAArB,CAA+B,UAAU,CAAC,GAA1C,EACGA,CADH,CADK,CAKLA,CAEH,CAED,MAAO,IAAMC,QAAO,CAAGnB,KAAK,CAACoB,UAAN,CACrB,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAEZJ,CAFY,CAUVG,CAVU,CAEZH,QAFY,GAUVG,CAVU,CAGZE,IAHY,CAGZA,CAHY,YAGLR,uBAHK,GAIZS,CAJY,CAUVH,CAVU,CAIZG,SAJY,CAKZC,CALY,CAUVJ,CAVU,CAKZI,MALY,CAMIC,CANJ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SAAS,CAAET,SAAS,CAAC,CAAEY,MAAM,CAANA,CAAF,CAAD,CAAa,CAACD,CAAD,CAAb,CANtB,CAOE,KAAK,uCACF,sBADE,WACoCb,UADpC,0BAEF,wBAFE,WAEsCC,YAFtC,WAGAgB,CAHA,CAPP,GAaE,2BAAK,SAAS,CAAEf,SAAS,CAAC,YAAD,CAAzB,EAbF,CAcE,2BACE,SAAS,CAAEA,SAAS,CAAC,OAAD,CAAU,CAACV,iBAAiB,CAAC,CAAE6B,SAAS,CAATA,CAAF,CAAD,CAAlB,CAAV,CADtB,EAdF,CAiBE,2BAAK,SAAS,CAAEnB,SAAS,CAAC,SAAD,CAAY,CAAEU,IAAI,CAAJA,CAAF,CAAZ,CAAzB,EACGN,cAAc,CAACC,CAAD,CADjB,CAjBF,CADF,CAwBH,CAtEoB,CAAhB"}
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,MAAO,IAAMU,iBAAgB,CAAG,CAAC,GAAD,CAAM,GAAN,CAAW,GAAX,CAAzB,CACP,MAAO,IAAMC,wBAAuB,CAAGD,gBAAgB,CAAC,CAAD,CAAhD,CAGP,MAAO,IAAME,kBAAiB,CAAG,CAC/B,QAD+B,CAE/B,OAF+B,CAG/B,SAH+B,CAI/B,SAJ+B,CAA1B,CAwBP,QAASC,eAAT,CAAwBC,CAAxB,CAAoE,CAClE,MAA2B,QAApB,QAAOA,EAAP,EAAoD,QAApB,QAAOA,EAAvC,CACL,oBAAC,IAAD,EAAM,IAAI,CAAC,IAAX,CAAgB,IAAI,CAAC,SAArB,CAA+B,UAAU,CAAC,GAA1C,EACGA,CADH,CADK,CAKLA,CAEH,CAED,MAAO,IAAMC,QAAO,CAAGnB,KAAK,CAACoB,UAAN,CACrB,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAEZJ,CAFY,CAU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AIE,cAAc,CApCG,QAAjBF,eAAiB,CAACK,CAAD,CAA0B,CAC/CN,CAAkB,EAAIA,CAAkB,CAACM,CAAD,CADO,CAE/CC,CAAY,CAACD,CAAD,CACb,CA6BG,CAKE,GAAG,CAAEV,CALP,CAME,SAAS,CAAET,SAAS,CAAC,CAAEY,MAAM,CAANA,CAAF,CAAD,CAAa,CAACD,CAAD,CAAb,CANtB,CAOE,KAAK,uCACF,sBADE,WACoCb,UADpC,0BAEF,wBAFE,WAEsCC,YAFtC,WAGAgB,CAHA,CAPP,GAaE,2BAAK,SAAS,CAAEf,SAAS,CAAC,YAAD,CAAzB,EAbF,CAcE,2BACE,SAAS,CAAEA,SAAS,CAAC,OAAD,CAAU,CAACV,iBAAiB,CAAC,CAAE6B,SAAS,CAATA,CAAF,CAAD,CAAlB,CAAV,CADtB,EAdF,CAiBE,2BAAK,SAAS,CAAEnB,SAAS,CAAC,SAAD,CAAY,CAAEU,IAAI,CAAJA,CAAF,CAAZ,CAAzB,EACGN,cAAc,CAACC,CAAD,CADjB,CAjBF,CADF,CAwBH,CAtEoB,CAAhB"}
@@ -0,0 +1 @@
1
+ export * from './useClickOutside';
@@ -0,0 +1,2 @@
1
+ export*from"./useClickOutside";
2
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export*from"./useElementAtomEventListener";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/utils/state/useElementAtomEventListener/index.ts"],"sourcesContent":["export * from './useElementAtomEventListener';\n"],"mappings":"AAAA"}
@@ -0,0 +1,2 @@
1
+ import { AtomMut } from '@reatom/framework';
2
+ export declare const useElementAtomEventListener: <T extends HTMLElement>(elementAtom: AtomMut<T | null>, type: keyof DocumentEventMap, listener: EventListener) => void;
@@ -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
@@ -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,2 @@
1
+ export*from"./useKeysAtom";
2
+ //# sourceMappingURL=index.js.map
@@ -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,CAAmB,CAAGJ,SAAS,CAAC,SAACK,CAAD,CAAMC,CAAN,QAAgBH,EAAI,CAACE,CAAD,CAAMC,CAAN,CAApB,CAAD,CAFgB,CAGrD,MAAO,CAACH,CAAD,CAAOC,CAAP,CACR,CAJM"}
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"}
@@ -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{reatomContext,useCreateCtx}from"@reatom/npm-react";import React,{createElement,forwardRef,useContext}from"react";var ProviderWithCtx=function(a){var b=a.children;return React.createElement(reatomContext.Provider,{value:useCreateCtx()},b)};export var withCtx=function(a){return forwardRef(function(b,c){var d=createElement(a,_objectSpread(_objectSpread({},b),{},{ref:c}));return useContext(reatomContext)?d:React.createElement(ProviderWithCtx,null,d)})};
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{reatomContext,useCreateCtx}from"@reatom/npm-react";import React,{createElement,forwardRef,useContext}from"react";var ProviderWithCtx=function(a){var b=a.children;return createElement(reatomContext.Provider,{value:useCreateCtx()},b)};export var withCtx=function(a){return forwardRef(function(b,c){var d=createElement(a,_objectSpread(_objectSpread({},b),{},{ref:c}));return useContext(reatomContext)?d:React.createElement(ProviderWithCtx,null,d)})};
2
2
  //# sourceMappingURL=withCtx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withCtx.js","names":["reatomContext","useCreateCtx","React","createElement","forwardRef","useContext","ProviderWithCtx","children","withCtx","component","props","ref","element"],"sources":["../../../../../../src/utils/state/withCtx/withCtx.tsx"],"sourcesContent":["import { reatomContext, useCreateCtx } from '@reatom/npm-react';\nimport React, { createElement, forwardRef, useContext } from 'react';\n\nconst ProviderWithCtx = ({ children }: { children: React.ReactNode }) => (\n <reatomContext.Provider value={useCreateCtx()}>\n {children}\n </reatomContext.Provider>\n);\n\nexport const withCtx = <C, P extends {}>(component: C): C =>\n forwardRef<HTMLElement, P>((props, ref) => {\n const element = createElement(\n component as unknown as React.ComponentType<P>,\n {\n ...(props as P),\n ref,\n },\n );\n\n if (useContext(reatomContext)) {\n return element;\n }\n\n return <ProviderWithCtx>{element}</ProviderWithCtx>;\n }) as unknown as C;\n"],"mappings":"qqBAAA,OAASA,aAAT,CAAwBC,YAAxB,KAA4C,mBAA5C,CACA,MAAOC,MAAP,EAAgBC,aAAhB,CAA+BC,UAA/B,CAA2CC,UAA3C,KAA6D,OAA7D,CAEA,GAAMC,gBAAe,CAAG,eAAGC,EAAH,GAAGA,QAAH,OACtB,qBAAC,aAAD,CAAe,QAAf,EAAwB,KAAK,CAAEN,YAAY,EAA3C,EACGM,CADH,CADsB,CAAxB,CAMA,MAAO,IAAMC,QAAO,CAAG,SAAkBC,CAAlB,QACrBL,WAAU,CAAiB,SAACM,CAAD,CAAQC,CAAR,CAAgB,CACzC,GAAMC,EAAO,CAAGT,aAAa,CAC3BM,CAD2B,gCAGrBC,CAHqB,MAIzBC,GAAG,CAAHA,CAJyB,GAA7B,CADyC,MASrCN,WAAU,CAACL,aAAD,CAT2B,CAUhCY,CAVgC,CAalC,oBAAC,eAAD,MAAkBA,CAAlB,CACR,CAdS,CADW,CAAhB"}
1
+ {"version":3,"file":"withCtx.js","names":["reatomContext","useCreateCtx","React","createElement","forwardRef","useContext","ProviderWithCtx","children","Provider","value","withCtx","component","props","ref","element"],"sources":["../../../../../../src/utils/state/withCtx/withCtx.tsx"],"sourcesContent":["import { reatomContext, useCreateCtx } from '@reatom/npm-react';\nimport React, { createElement, forwardRef, useContext } from 'react';\n\nconst ProviderWithCtx = ({ children }: { children: React.ReactNode }) =>\n createElement(reatomContext.Provider, { value: useCreateCtx() }, children);\n\nexport const withCtx = <C, P extends {}>(component: C): C =>\n forwardRef<HTMLElement, P>((props, ref) => {\n const element = createElement(\n component as unknown as React.ComponentType<P>,\n {\n ...(props as P),\n ref,\n },\n );\n\n if (useContext(reatomContext)) {\n return element;\n }\n\n return <ProviderWithCtx>{element}</ProviderWithCtx>;\n }) as unknown as C;\n"],"mappings":"qqBAAA,OAASA,aAAT,CAAwBC,YAAxB,KAA4C,mBAA5C,CACA,MAAOC,MAAP,EAAgBC,aAAhB,CAA+BC,UAA/B,CAA2CC,UAA3C,KAA6D,OAA7D,CAEA,GAAMC,gBAAe,CAAG,eAAGC,EAAH,GAAGA,QAAH,OACtBJ,cAAa,CAACH,aAAa,CAACQ,QAAf,CAAyB,CAAEC,KAAK,CAAER,YAAY,EAArB,CAAzB,CAAoDM,CAApD,CADS,CAAxB,CAGA,MAAO,IAAMG,QAAO,CAAG,SAAkBC,CAAlB,QACrBP,WAAU,CAAiB,SAACQ,CAAD,CAAQC,CAAR,CAAgB,CACzC,GAAMC,EAAO,CAAGX,aAAa,CAC3BQ,CAD2B,gCAGrBC,CAHqB,MAIzBC,GAAG,CAAHA,CAJyB,GAA7B,CADyC,MASrCR,WAAU,CAACL,aAAD,CAT2B,CAUhCc,CAVgC,CAalC,oBAAC,eAAD,MAAkBA,CAAlB,CACR,CAdS,CADW,CAAhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@consta/uikit",
3
- "version": "5.25.1",
3
+ "version": "5.26.0",
4
4
  "keywords": [
5
5
  "ui-kit",
6
6
  "design-system",