@vkontakte/vkui 6.1.0 → 6.1.2

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 (167) hide show
  1. package/dist/cjs/components/Clickable/useState.d.ts.map +1 -1
  2. package/dist/cjs/components/Clickable/useState.js +7 -6
  3. package/dist/cjs/components/Clickable/useState.js.map +1 -1
  4. package/dist/cjs/components/CustomScrollView/CustomScrollView.d.ts.map +1 -1
  5. package/dist/cjs/components/CustomScrollView/CustomScrollView.js +8 -1
  6. package/dist/cjs/components/CustomScrollView/CustomScrollView.js.map +1 -1
  7. package/dist/cjs/components/DatePicker/DatePicker.d.ts +3 -2
  8. package/dist/cjs/components/DatePicker/DatePicker.d.ts.map +1 -1
  9. package/dist/cjs/components/DatePicker/DatePicker.js +64 -50
  10. package/dist/cjs/components/DatePicker/DatePicker.js.map +1 -1
  11. package/dist/cjs/components/FocusTrap/FocusTrap.d.ts +2 -2
  12. package/dist/cjs/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  13. package/dist/cjs/components/FocusTrap/FocusTrap.js +36 -11
  14. package/dist/cjs/components/FocusTrap/FocusTrap.js.map +1 -1
  15. package/dist/cjs/components/Select/Select.d.ts +1 -1
  16. package/dist/cjs/components/Select/Select.d.ts.map +1 -1
  17. package/dist/cjs/components/Select/Select.js +12 -6
  18. package/dist/cjs/components/Select/Select.js.map +1 -1
  19. package/dist/cjs/components/Spacing/Spacing.d.ts +16 -5
  20. package/dist/cjs/components/Spacing/Spacing.d.ts.map +1 -1
  21. package/dist/cjs/components/Spacing/Spacing.js +38 -31
  22. package/dist/cjs/components/Spacing/Spacing.js.map +1 -1
  23. package/dist/cjs/components/SplitLayout/SplitLayout.js +2 -2
  24. package/dist/cjs/components/SplitLayout/SplitLayout.js.map +1 -1
  25. package/dist/cjs/components/ToolButton/ToolButton.d.ts +5 -0
  26. package/dist/cjs/components/ToolButton/ToolButton.d.ts.map +1 -1
  27. package/dist/cjs/components/ToolButton/ToolButton.js +2 -1
  28. package/dist/cjs/components/ToolButton/ToolButton.js.map +1 -1
  29. package/dist/cjs/hooks/useDraggableWithDomApi/autoScroll.d.ts +0 -1
  30. package/dist/cjs/hooks/useDraggableWithDomApi/autoScroll.d.ts.map +1 -1
  31. package/dist/cjs/hooks/useDraggableWithDomApi/autoScroll.js +1 -5
  32. package/dist/cjs/hooks/useDraggableWithDomApi/autoScroll.js.map +1 -1
  33. package/dist/cjs/hooks/useResizeObserver.d.ts +6 -0
  34. package/dist/cjs/hooks/useResizeObserver.d.ts.map +1 -0
  35. package/dist/cjs/hooks/useResizeObserver.js +32 -0
  36. package/dist/cjs/hooks/useResizeObserver.js.map +1 -0
  37. package/dist/cjs/lib/floating/customResizeObserver.d.ts.map +1 -1
  38. package/dist/cjs/lib/floating/customResizeObserver.js +2 -1
  39. package/dist/cjs/lib/floating/customResizeObserver.js.map +1 -1
  40. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  41. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +11 -1
  42. package/dist/cjs/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  43. package/dist/cjs/lib/utils.d.ts.map +1 -1
  44. package/dist/cjs/lib/utils.js +1 -2
  45. package/dist/cjs/lib/utils.js.map +1 -1
  46. package/dist/components/Clickable/useState.d.ts.map +1 -1
  47. package/dist/components/Clickable/useState.js +7 -6
  48. package/dist/components/Clickable/useState.js.map +1 -1
  49. package/dist/components/CustomScrollView/CustomScrollView.d.ts.map +1 -1
  50. package/dist/components/CustomScrollView/CustomScrollView.js +8 -1
  51. package/dist/components/CustomScrollView/CustomScrollView.js.map +1 -1
  52. package/dist/components/DatePicker/DatePicker.d.ts +3 -2
  53. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  54. package/dist/components/DatePicker/DatePicker.js +64 -50
  55. package/dist/components/DatePicker/DatePicker.js.map +1 -1
  56. package/dist/components/FocusTrap/FocusTrap.d.ts +2 -2
  57. package/dist/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  58. package/dist/components/FocusTrap/FocusTrap.js +37 -11
  59. package/dist/components/FocusTrap/FocusTrap.js.map +1 -1
  60. package/dist/components/Select/Select.d.ts +1 -1
  61. package/dist/components/Select/Select.d.ts.map +1 -1
  62. package/dist/components/Select/Select.js +12 -6
  63. package/dist/components/Select/Select.js.map +1 -1
  64. package/dist/components/Spacing/Spacing.d.ts +16 -5
  65. package/dist/components/Spacing/Spacing.d.ts.map +1 -1
  66. package/dist/components/Spacing/Spacing.js +33 -28
  67. package/dist/components/Spacing/Spacing.js.map +1 -1
  68. package/dist/components/SplitLayout/SplitLayout.js +2 -2
  69. package/dist/components/SplitLayout/SplitLayout.js.map +1 -1
  70. package/dist/components/ToolButton/ToolButton.d.ts +5 -0
  71. package/dist/components/ToolButton/ToolButton.d.ts.map +1 -1
  72. package/dist/components/ToolButton/ToolButton.js +2 -1
  73. package/dist/components/ToolButton/ToolButton.js.map +1 -1
  74. package/dist/components.css +6 -6
  75. package/dist/components.css.map +1 -1
  76. package/dist/components.js.tmp +542 -399
  77. package/dist/cssm/components/Clickable/useState.d.ts.map +1 -1
  78. package/dist/cssm/components/Clickable/useState.js +7 -6
  79. package/dist/cssm/components/Clickable/useState.js.map +1 -1
  80. package/dist/cssm/components/CustomScrollView/CustomScrollView.d.ts.map +1 -1
  81. package/dist/cssm/components/CustomScrollView/CustomScrollView.js +8 -1
  82. package/dist/cssm/components/CustomScrollView/CustomScrollView.js.map +1 -1
  83. package/dist/cssm/components/CustomScrollView/CustomScrollView.module.css +4 -0
  84. package/dist/cssm/components/DatePicker/DatePicker.d.ts +3 -2
  85. package/dist/cssm/components/DatePicker/DatePicker.d.ts.map +1 -1
  86. package/dist/cssm/components/DatePicker/DatePicker.js +57 -41
  87. package/dist/cssm/components/DatePicker/DatePicker.js.map +1 -1
  88. package/dist/cssm/components/FocusTrap/FocusTrap.d.ts +2 -2
  89. package/dist/cssm/components/FocusTrap/FocusTrap.d.ts.map +1 -1
  90. package/dist/cssm/components/FocusTrap/FocusTrap.js +37 -11
  91. package/dist/cssm/components/FocusTrap/FocusTrap.js.map +1 -1
  92. package/dist/cssm/components/Select/Select.d.ts +1 -1
  93. package/dist/cssm/components/Select/Select.d.ts.map +1 -1
  94. package/dist/cssm/components/Select/Select.js +8 -5
  95. package/dist/cssm/components/Select/Select.js.map +1 -1
  96. package/dist/cssm/components/Spacing/Spacing.d.ts +16 -5
  97. package/dist/cssm/components/Spacing/Spacing.d.ts.map +1 -1
  98. package/dist/cssm/components/Spacing/Spacing.js +31 -30
  99. package/dist/cssm/components/Spacing/Spacing.js.map +1 -1
  100. package/dist/cssm/components/Spacing/Spacing.module.css +44 -0
  101. package/dist/cssm/components/SplitLayout/SplitLayout.js +2 -2
  102. package/dist/cssm/components/SplitLayout/SplitLayout.js.map +1 -1
  103. package/dist/cssm/components/SplitLayout/SplitLayout.module.css +1 -1
  104. package/dist/cssm/components/Textarea/Textarea.module.css +1 -0
  105. package/dist/cssm/components/ToolButton/ToolButton.d.ts +5 -0
  106. package/dist/cssm/components/ToolButton/ToolButton.d.ts.map +1 -1
  107. package/dist/cssm/components/ToolButton/ToolButton.js +2 -1
  108. package/dist/cssm/components/ToolButton/ToolButton.js.map +1 -1
  109. package/dist/cssm/components/ToolButton/ToolButton.module.css +6 -20
  110. package/dist/cssm/hooks/useDraggableWithDomApi/autoScroll.d.ts +0 -1
  111. package/dist/cssm/hooks/useDraggableWithDomApi/autoScroll.d.ts.map +1 -1
  112. package/dist/cssm/hooks/useDraggableWithDomApi/autoScroll.js +1 -2
  113. package/dist/cssm/hooks/useDraggableWithDomApi/autoScroll.js.map +1 -1
  114. package/dist/cssm/hooks/useResizeObserver.d.ts +6 -0
  115. package/dist/cssm/hooks/useResizeObserver.d.ts.map +1 -0
  116. package/dist/cssm/hooks/useResizeObserver.js +23 -0
  117. package/dist/cssm/hooks/useResizeObserver.js.map +1 -0
  118. package/dist/cssm/lib/floating/customResizeObserver.d.ts.map +1 -1
  119. package/dist/cssm/lib/floating/customResizeObserver.js +2 -1
  120. package/dist/cssm/lib/floating/customResizeObserver.js.map +1 -1
  121. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  122. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +11 -1
  123. package/dist/cssm/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  124. package/dist/cssm/lib/utils.d.ts.map +1 -1
  125. package/dist/cssm/lib/utils.js +1 -2
  126. package/dist/cssm/lib/utils.js.map +1 -1
  127. package/dist/cssm/styles/adaptivity.module.css +1 -2
  128. package/dist/hooks/useDraggableWithDomApi/autoScroll.d.ts +0 -1
  129. package/dist/hooks/useDraggableWithDomApi/autoScroll.d.ts.map +1 -1
  130. package/dist/hooks/useDraggableWithDomApi/autoScroll.js +1 -2
  131. package/dist/hooks/useDraggableWithDomApi/autoScroll.js.map +1 -1
  132. package/dist/hooks/useResizeObserver.d.ts +6 -0
  133. package/dist/hooks/useResizeObserver.d.ts.map +1 -0
  134. package/dist/hooks/useResizeObserver.js +23 -0
  135. package/dist/hooks/useResizeObserver.js.map +1 -0
  136. package/dist/lib/floating/customResizeObserver.d.ts.map +1 -1
  137. package/dist/lib/floating/customResizeObserver.js +2 -1
  138. package/dist/lib/floating/customResizeObserver.js.map +1 -1
  139. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.d.ts.map +1 -1
  140. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js +11 -1
  141. package/dist/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.js.map +1 -1
  142. package/dist/lib/utils.d.ts.map +1 -1
  143. package/dist/lib/utils.js +1 -2
  144. package/dist/lib/utils.js.map +1 -1
  145. package/dist/vkui.css +6 -6
  146. package/dist/vkui.css.map +1 -1
  147. package/dist/vkui.js.tmp +542 -399
  148. package/package.json +1 -1
  149. package/src/components/Clickable/useState.tsx +16 -6
  150. package/src/components/CustomScrollView/CustomScrollView.module.css +4 -0
  151. package/src/components/CustomScrollView/CustomScrollView.tsx +7 -1
  152. package/src/components/DatePicker/DatePicker.tsx +80 -45
  153. package/src/components/FocusTrap/FocusTrap.tsx +54 -20
  154. package/src/components/Select/Select.tsx +12 -5
  155. package/src/components/Spacing/Spacing.module.css +44 -0
  156. package/src/components/Spacing/Spacing.tsx +38 -34
  157. package/src/components/SplitLayout/SplitLayout.module.css +1 -1
  158. package/src/components/SplitLayout/SplitLayout.tsx +1 -1
  159. package/src/components/Textarea/Textarea.module.css +1 -0
  160. package/src/components/ToolButton/ToolButton.module.css +4 -14
  161. package/src/components/ToolButton/ToolButton.tsx +7 -2
  162. package/src/hooks/useDraggableWithDomApi/autoScroll.ts +1 -4
  163. package/src/hooks/useResizeObserver.ts +30 -0
  164. package/src/lib/floating/customResizeObserver.ts +10 -1
  165. package/src/lib/floating/useFloatingWithInteractions/useFloatingWithInteractions.ts +11 -1
  166. package/src/lib/utils.ts +1 -2
  167. package/src/styles/adaptivity.module.css +1 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/FocusTrap/FocusTrap.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useExternRef } from '../../hooks/useExternRef';\nimport { FOCUSABLE_ELEMENTS_LIST, Keys, pressedKey } from '../../lib/accessibility';\nimport {\n contains,\n getActiveElementByAnotherElement,\n getWindow,\n isHTMLElement,\n} from '../../lib/dom';\nimport { useIsomorphicLayoutEffect } from '../../lib/useIsomorphicLayoutEffect';\nimport { HasComponent, HasRootRef } from '../../types';\nimport { AppRootContext } from '../AppRoot/AppRootContext';\n\nconst FOCUSABLE_ELEMENTS: string = FOCUSABLE_ELEMENTS_LIST.join();\nexport interface FocusTrapProps<T extends HTMLElement = HTMLElement>\n extends React.AllHTMLAttributes<T>,\n HasRootRef<T>,\n HasComponent {\n autoFocus?: boolean;\n restoreFocus?: boolean | (() => boolean);\n timeout?: number;\n onClose?: () => void;\n}\n\n/**\n * @see https://vkcom.github.io/VKUI/#/FocusTrap\n */\nexport const FocusTrap = <T extends HTMLElement = HTMLElement>({\n Component = 'div',\n onClose,\n autoFocus = true,\n restoreFocus = true,\n timeout = 0,\n getRootRef,\n children,\n ...restProps\n}: FocusTrapProps<T>) => {\n const ref = useExternRef<T>(getRootRef);\n\n const { keyboardInput } = React.useContext(AppRootContext);\n const focusableNodesRef = React.useRef<HTMLElement[]>([]);\n\n useIsomorphicLayoutEffect(\n function collectFocusableNodesRef() {\n if (!ref.current) {\n return;\n }\n\n const nodes: HTMLElement[] = [];\n // eslint-disable-next-line no-restricted-properties\n ref.current.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENTS).forEach((focusableEl) => {\n const { display, visibility } = getComputedStyle(focusableEl);\n if (display !== 'none' && visibility !== 'hidden') {\n nodes.push(focusableEl);\n }\n });\n\n if (nodes.length === 0) {\n // Чтобы фокус был хотя бы на родителе\n nodes.push(ref.current);\n }\n\n focusableNodesRef.current = nodes;\n },\n [children],\n );\n\n useIsomorphicLayoutEffect(\n function tryToAutoFocusToFirstNode() {\n if (!ref.current || !autoFocus || !keyboardInput) {\n return;\n }\n const autoFocusToFirstNode = () => {\n if (!ref.current || !focusableNodesRef.current.length) {\n return;\n }\n const activeElement = getActiveElementByAnotherElement(ref.current);\n if (!contains(ref.current, activeElement)) {\n focusableNodesRef.current[0].focus();\n }\n };\n const timeoutId = setTimeout(autoFocusToFirstNode, timeout);\n return () => {\n clearTimeout(timeoutId);\n };\n },\n [autoFocus, timeout, keyboardInput],\n );\n\n useIsomorphicLayoutEffect(\n function tryToRestoreFocusOnUnmount() {\n if (!ref.current || !restoreFocus) {\n return;\n }\n\n const restoreFocusTo = getActiveElementByAnotherElement(ref.current);\n\n return () => {\n const shouldRestoreFocus =\n typeof restoreFocus === 'function' ? restoreFocus() : restoreFocus;\n\n if (!shouldRestoreFocus || !isHTMLElement(restoreFocusTo)) {\n return;\n }\n\n setTimeout(() => {\n if (restoreFocusTo) {\n restoreFocusTo.focus();\n }\n }, timeout);\n };\n },\n [restoreFocus, timeout],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!ref.current) {\n return;\n }\n\n const onDocumentKeydown = (event: KeyboardEvent) => {\n const pressedKeyResult = pressedKey(event);\n\n switch (pressedKeyResult) {\n case Keys.TAB: {\n if (!focusableNodesRef.current.length) {\n return false;\n }\n\n const lastIdx = focusableNodesRef.current.length - 1;\n const targetIdx = focusableNodesRef.current.findIndex((node) => node === event.target);\n\n const shouldFocusFirstNode =\n targetIdx === -1 || (targetIdx === lastIdx && !event.shiftKey);\n\n if (shouldFocusFirstNode || (targetIdx === 0 && event.shiftKey)) {\n event.preventDefault();\n\n const node = focusableNodesRef.current[shouldFocusFirstNode ? 0 : lastIdx];\n\n if (node !== getActiveElementByAnotherElement(node)) {\n node.focus();\n }\n\n return false;\n }\n\n break;\n }\n case Keys.ESCAPE: {\n if (onClose) {\n event.preventDefault();\n onClose();\n }\n }\n }\n\n return true;\n };\n\n const doc = getWindow(ref.current).document;\n doc.addEventListener('keydown', onDocumentKeydown, {\n capture: true,\n });\n return () => {\n doc.removeEventListener('keydown', onDocumentKeydown, true);\n };\n }, [onClose, ref]);\n\n return (\n <Component tabIndex={-1} ref={ref} {...restProps}>\n {children}\n </Component>\n );\n};\n"],"names":["React","useExternRef","FOCUSABLE_ELEMENTS_LIST","Keys","pressedKey","contains","getActiveElementByAnotherElement","getWindow","isHTMLElement","useIsomorphicLayoutEffect","AppRootContext","FOCUSABLE_ELEMENTS","join","FocusTrap","Component","onClose","autoFocus","restoreFocus","timeout","getRootRef","children","restProps","ref","keyboardInput","useContext","focusableNodesRef","useRef","collectFocusableNodesRef","current","nodes","querySelectorAll","forEach","focusableEl","display","visibility","getComputedStyle","push","length","tryToAutoFocusToFirstNode","autoFocusToFirstNode","activeElement","focus","timeoutId","setTimeout","clearTimeout","tryToRestoreFocusOnUnmount","restoreFocusTo","shouldRestoreFocus","onDocumentKeydown","event","pressedKeyResult","TAB","lastIdx","targetIdx","findIndex","node","target","shouldFocusFirstNode","shiftKey","preventDefault","ESCAPE","doc","document","addEventListener","capture","removeEventListener","tabIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
1
+ {"version":3,"sources":["../../../../src/components/FocusTrap/FocusTrap.tsx"],"sourcesContent":["import { AllHTMLAttributes, useContext, useRef } from 'react';\nimport { useExternRef } from '../../hooks/useExternRef';\nimport { FOCUSABLE_ELEMENTS_LIST, Keys, pressedKey } from '../../lib/accessibility';\nimport {\n contains,\n getActiveElementByAnotherElement,\n getWindow,\n isHTMLElement,\n useDOM,\n} from '../../lib/dom';\nimport { useIsomorphicLayoutEffect } from '../../lib/useIsomorphicLayoutEffect';\nimport { HasComponent, HasRootRef } from '../../types';\nimport { AppRootContext } from '../AppRoot/AppRootContext';\n\nconst FOCUSABLE_ELEMENTS: string = FOCUSABLE_ELEMENTS_LIST.join();\nexport interface FocusTrapProps<T extends HTMLElement = HTMLElement>\n extends AllHTMLAttributes<T>,\n HasRootRef<T>,\n HasComponent {\n autoFocus?: boolean;\n restoreFocus?: boolean | (() => boolean);\n timeout?: number;\n onClose?: () => void;\n}\n\n/**\n * @see https://vkcom.github.io/VKUI/#/FocusTrap\n */\nexport const FocusTrap = <T extends HTMLElement = HTMLElement>({\n Component = 'div',\n onClose,\n autoFocus = true,\n restoreFocus = true,\n timeout = 0,\n getRootRef,\n children,\n ...restProps\n}: FocusTrapProps<T>) => {\n const ref = useExternRef<T>(getRootRef);\n const { document } = useDOM();\n\n const { keyboardInput } = useContext(AppRootContext);\n const focusableNodesRef = useRef<HTMLElement[]>([]);\n\n const focusNodeByIndex = (nodeIndex: number) => {\n const element = focusableNodesRef.current[nodeIndex];\n\n if (element) {\n element.focus();\n }\n };\n\n const recalculateFocusableNodesRef = (parentNode: HTMLElement) => {\n // eslint-disable-next-line no-restricted-properties\n const newFocusableElements = parentNode.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENTS);\n\n const nodes: HTMLElement[] = [];\n newFocusableElements.forEach((focusableEl) => {\n const { display, visibility } = getComputedStyle(focusableEl);\n if (display !== 'none' && visibility !== 'hidden') {\n nodes.push(focusableEl);\n }\n });\n\n if (nodes.length === 0) {\n // Чтобы фокус был хотя бы на родителе\n nodes.push(parentNode);\n }\n focusableNodesRef.current = nodes;\n };\n\n const onMutateParentHandler = (parentNode: HTMLElement) => {\n recalculateFocusableNodesRef(parentNode);\n\n if (document) {\n const activeElement = document.activeElement as HTMLElement;\n const currentElementIndex = Math.max(\n document.activeElement ? focusableNodesRef.current.indexOf(activeElement) : -1,\n 0,\n );\n focusNodeByIndex(currentElementIndex);\n }\n };\n\n useIsomorphicLayoutEffect(\n function collectFocusableNodesRef() {\n if (!ref.current) {\n return;\n }\n const parentNode = ref.current;\n const observer = new MutationObserver(() => onMutateParentHandler(parentNode));\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n });\n recalculateFocusableNodesRef(parentNode);\n return () => observer.disconnect();\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(\n function tryToAutoFocusToFirstNode() {\n if (!ref.current || !autoFocus || !keyboardInput) {\n return;\n }\n const autoFocusToFirstNode = () => {\n if (!ref.current || !focusableNodesRef.current.length) {\n return;\n }\n const activeElement = getActiveElementByAnotherElement(ref.current);\n if (!contains(ref.current, activeElement)) {\n focusableNodesRef.current[0].focus();\n }\n };\n const timeoutId = setTimeout(autoFocusToFirstNode, timeout);\n return () => {\n clearTimeout(timeoutId);\n };\n },\n [autoFocus, timeout, keyboardInput],\n );\n\n useIsomorphicLayoutEffect(\n function tryToRestoreFocusOnUnmount() {\n if (!ref.current || !restoreFocus) {\n return;\n }\n\n const restoreFocusTo = getActiveElementByAnotherElement(ref.current);\n\n return () => {\n const shouldRestoreFocus =\n typeof restoreFocus === 'function' ? restoreFocus() : restoreFocus;\n\n if (!shouldRestoreFocus || !isHTMLElement(restoreFocusTo)) {\n return;\n }\n\n setTimeout(() => {\n if (restoreFocusTo) {\n restoreFocusTo.focus();\n }\n }, timeout);\n };\n },\n [restoreFocus, timeout],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!ref.current) {\n return;\n }\n\n const onDocumentKeydown = (event: KeyboardEvent) => {\n const pressedKeyResult = pressedKey(event);\n\n switch (pressedKeyResult) {\n case Keys.TAB: {\n if (!focusableNodesRef.current.length) {\n return false;\n }\n\n const lastIdx = focusableNodesRef.current.length - 1;\n const targetIdx = focusableNodesRef.current.findIndex((node) => node === event.target);\n\n const shouldFocusFirstNode =\n targetIdx === -1 || (targetIdx === lastIdx && !event.shiftKey);\n\n if (shouldFocusFirstNode || (targetIdx === 0 && event.shiftKey)) {\n event.preventDefault();\n\n const node = focusableNodesRef.current[shouldFocusFirstNode ? 0 : lastIdx];\n\n if (node !== getActiveElementByAnotherElement(node)) {\n node.focus();\n }\n\n return false;\n }\n\n break;\n }\n case Keys.ESCAPE: {\n if (onClose) {\n event.preventDefault();\n onClose();\n }\n }\n }\n\n return true;\n };\n\n const doc = getWindow(ref.current).document;\n doc.addEventListener('keydown', onDocumentKeydown, {\n capture: true,\n });\n return () => {\n doc.removeEventListener('keydown', onDocumentKeydown, true);\n };\n }, [onClose, ref]);\n\n return (\n <Component tabIndex={-1} ref={ref} {...restProps}>\n {children}\n </Component>\n );\n};\n"],"names":["useContext","useRef","useExternRef","FOCUSABLE_ELEMENTS_LIST","Keys","pressedKey","contains","getActiveElementByAnotherElement","getWindow","isHTMLElement","useDOM","useIsomorphicLayoutEffect","AppRootContext","FOCUSABLE_ELEMENTS","join","FocusTrap","Component","onClose","autoFocus","restoreFocus","timeout","getRootRef","children","restProps","ref","document","keyboardInput","focusableNodesRef","focusNodeByIndex","nodeIndex","element","current","focus","recalculateFocusableNodesRef","parentNode","newFocusableElements","querySelectorAll","nodes","forEach","focusableEl","display","visibility","getComputedStyle","push","length","onMutateParentHandler","activeElement","currentElementIndex","Math","max","indexOf","collectFocusableNodesRef","observer","MutationObserver","observe","subtree","childList","disconnect","tryToAutoFocusToFirstNode","autoFocusToFirstNode","timeoutId","setTimeout","clearTimeout","tryToRestoreFocusOnUnmount","restoreFocusTo","shouldRestoreFocus","onDocumentKeydown","event","pressedKeyResult","TAB","lastIdx","targetIdx","findIndex","node","target","shouldFocusFirstNode","shiftKey","preventDefault","ESCAPE","doc","addEventListener","capture","removeEventListener","tabIndex"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
@@ -3,5 +3,5 @@ export type SelectType = 'default' | 'plain' | 'accent';
3
3
  /**
4
4
  * @see https://vkcom.github.io/VKUI/#/Select
5
5
  */
6
- export declare const Select: <OptionT extends CustomSelectOptionInterface>({ children, ...props }: SelectProps<OptionT>) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const Select: <OptionT extends CustomSelectOptionInterface>({ children, className, ...props }: SelectProps<OptionT>) => import("react/jsx-runtime").JSX.Element;
7
7
  //# sourceMappingURL=Select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,MAAM,wEAGhB,YAAY,OAAO,CAAC,4CAgDtB,CAAC"}
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,MAAM,mFAIhB,YAAY,OAAO,CAAC,4CAqDtB,CAAC"}
@@ -1,20 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
- import { useAdaptivityHasPointer } from '../../hooks/useAdaptivityHasPointer';
3
+ import { classNames } from '@vkontakte/vkjs';
4
+ import { useAdaptivityConditionalRender } from '../../hooks/useAdaptivityConditionalRender';
4
5
  import { CustomSelect } from '../CustomSelect/CustomSelect';
5
6
  import { NativeSelect } from '../NativeSelect/NativeSelect';
6
7
  /**
7
8
  * @see https://vkcom.github.io/VKUI/#/Select
8
- */ export const Select = ({ children, ...props })=>{
9
+ */ export const Select = ({ children, className, ...props })=>{
9
10
  const { options = [], searchable, emptyText, onInputChange, filterFn, popupDirection, renderOption, renderDropdown, fetching, onClose, onOpen, icon, ClearButton, allowClearButton, clearButtonTestId, dropdownOffsetDistance, dropdownAutoWidth, forceDropdownPortal, noMaxHeight, autoHideScrollbar, autoHideScrollbarDelay, labelTextTestId, nativeSelectTestId, after, mode, ...restProps } = props;
10
- const hasPointer = useAdaptivityHasPointer();
11
+ const { deviceType } = useAdaptivityConditionalRender();
11
12
  const nativeProps = restProps;
12
13
  return /*#__PURE__*/ _jsxs(React.Fragment, {
13
14
  children: [
14
- (hasPointer === undefined || hasPointer) && /*#__PURE__*/ _jsx(CustomSelect, {
15
+ deviceType.desktop && /*#__PURE__*/ _jsx(CustomSelect, {
16
+ className: classNames(className, deviceType.desktop.className),
15
17
  ...props
16
18
  }),
17
- (hasPointer === undefined || !hasPointer) && /*#__PURE__*/ _jsx(NativeSelect, {
19
+ deviceType.mobile && /*#__PURE__*/ _jsx(NativeSelect, {
20
+ className: classNames(className, deviceType.mobile.className),
18
21
  ...nativeProps,
19
22
  children: options.map(({ label, value })=>/*#__PURE__*/ _jsx("option", {
20
23
  value: value,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useAdaptivityHasPointer } from '../../hooks/useAdaptivityHasPointer';\nimport { HasOnlyExpectedProps } from '../../types';\nimport {\n CustomSelect,\n type CustomSelectOptionInterface,\n type SelectProps,\n} from '../CustomSelect/CustomSelect';\nimport { NativeSelect, type NativeSelectProps } from '../NativeSelect/NativeSelect';\nexport type SelectType = 'default' | 'plain' | 'accent';\n\n/**\n * @see https://vkcom.github.io/VKUI/#/Select\n */\nexport const Select = <OptionT extends CustomSelectOptionInterface>({\n children,\n ...props\n}: SelectProps<OptionT>) => {\n const {\n options = [],\n searchable,\n emptyText,\n onInputChange,\n filterFn,\n popupDirection,\n renderOption,\n renderDropdown,\n fetching,\n onClose,\n onOpen,\n icon,\n ClearButton,\n allowClearButton,\n clearButtonTestId,\n dropdownOffsetDistance,\n dropdownAutoWidth,\n forceDropdownPortal,\n noMaxHeight,\n autoHideScrollbar,\n autoHideScrollbarDelay,\n labelTextTestId,\n nativeSelectTestId,\n after,\n mode,\n ...restProps\n } = props;\n\n const hasPointer = useAdaptivityHasPointer();\n\n const nativeProps: HasOnlyExpectedProps<typeof restProps, NativeSelectProps> = restProps;\n\n return (\n <React.Fragment>\n {(hasPointer === undefined || hasPointer) && <CustomSelect {...props} />}\n {(hasPointer === undefined || !hasPointer) && (\n <NativeSelect {...nativeProps}>\n {options.map(({ label, value }) => (\n <option value={value} key={`${value}`}>\n {label}\n </option>\n ))}\n </NativeSelect>\n )}\n </React.Fragment>\n );\n};\n"],"names":["React","useAdaptivityHasPointer","CustomSelect","NativeSelect","Select","children","props","options","searchable","emptyText","onInputChange","filterFn","popupDirection","renderOption","renderDropdown","fetching","onClose","onOpen","icon","ClearButton","allowClearButton","clearButtonTestId","dropdownOffsetDistance","dropdownAutoWidth","forceDropdownPortal","noMaxHeight","autoHideScrollbar","autoHideScrollbarDelay","labelTextTestId","nativeSelectTestId","after","mode","restProps","hasPointer","nativeProps","Fragment","undefined","map","label","value","option"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,sCAAsC;AAE9E,SACEC,YAAY,QAGP,+BAA+B;AACtC,SAASC,YAAY,QAAgC,+BAA+B;AAGpF;;CAEC,GACD,OAAO,MAAMC,SAAS,CAA8C,EAClEC,QAAQ,EACR,GAAGC,OACkB;IACrB,MAAM,EACJC,UAAU,EAAE,EACZC,UAAU,EACVC,SAAS,EACTC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,YAAY,EACZC,cAAc,EACdC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,WAAW,EACXC,iBAAiB,EACjBC,sBAAsB,EACtBC,eAAe,EACfC,kBAAkB,EAClBC,KAAK,EACLC,IAAI,EACJ,GAAGC,WACJ,GAAG1B;IAEJ,MAAM2B,aAAahC;IAEnB,MAAMiC,cAAyEF;IAE/E,qBACE,MAAChC,MAAMmC,QAAQ;;YACXF,CAAAA,eAAeG,aAAaH,UAAS,mBAAM,KAAC/B;gBAAc,GAAGI,KAAK;;YAClE2B,CAAAA,eAAeG,aAAa,CAACH,UAAS,mBACtC,KAAC9B;gBAAc,GAAG+B,WAAW;0BAC1B3B,QAAQ8B,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE,iBAC5B,KAACC;wBAAOD,OAAOA;kCACZD;uBADwB,CAAC,EAAEC,MAAM,CAAC;;;;AAQjD,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@vkontakte/vkjs';\nimport { useAdaptivityConditionalRender } from '../../hooks/useAdaptivityConditionalRender';\nimport { HasOnlyExpectedProps } from '../../types';\nimport {\n CustomSelect,\n type CustomSelectOptionInterface,\n type SelectProps,\n} from '../CustomSelect/CustomSelect';\nimport { NativeSelect, type NativeSelectProps } from '../NativeSelect/NativeSelect';\nexport type SelectType = 'default' | 'plain' | 'accent';\n\n/**\n * @see https://vkcom.github.io/VKUI/#/Select\n */\nexport const Select = <OptionT extends CustomSelectOptionInterface>({\n children,\n className,\n ...props\n}: SelectProps<OptionT>) => {\n const {\n options = [],\n searchable,\n emptyText,\n onInputChange,\n filterFn,\n popupDirection,\n renderOption,\n renderDropdown,\n fetching,\n onClose,\n onOpen,\n icon,\n ClearButton,\n allowClearButton,\n clearButtonTestId,\n dropdownOffsetDistance,\n dropdownAutoWidth,\n forceDropdownPortal,\n noMaxHeight,\n autoHideScrollbar,\n autoHideScrollbarDelay,\n labelTextTestId,\n nativeSelectTestId,\n after,\n mode,\n ...restProps\n } = props;\n\n const { deviceType } = useAdaptivityConditionalRender();\n\n const nativeProps: HasOnlyExpectedProps<typeof restProps, NativeSelectProps> = restProps;\n\n return (\n <React.Fragment>\n {deviceType.desktop && (\n <CustomSelect className={classNames(className, deviceType.desktop.className)} {...props} />\n )}\n {deviceType.mobile && (\n <NativeSelect\n className={classNames(className, deviceType.mobile.className)}\n {...nativeProps}\n >\n {options.map(({ label, value }) => (\n <option value={value} key={`${value}`}>\n {label}\n </option>\n ))}\n </NativeSelect>\n )}\n </React.Fragment>\n );\n};\n"],"names":["React","classNames","useAdaptivityConditionalRender","CustomSelect","NativeSelect","Select","children","className","props","options","searchable","emptyText","onInputChange","filterFn","popupDirection","renderOption","renderDropdown","fetching","onClose","onOpen","icon","ClearButton","allowClearButton","clearButtonTestId","dropdownOffsetDistance","dropdownAutoWidth","forceDropdownPortal","noMaxHeight","autoHideScrollbar","autoHideScrollbarDelay","labelTextTestId","nativeSelectTestId","after","mode","restProps","deviceType","nativeProps","Fragment","desktop","mobile","map","label","value","option"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,8BAA8B,QAAQ,6CAA6C;AAE5F,SACEC,YAAY,QAGP,+BAA+B;AACtC,SAASC,YAAY,QAAgC,+BAA+B;AAGpF;;CAEC,GACD,OAAO,MAAMC,SAAS,CAA8C,EAClEC,QAAQ,EACRC,SAAS,EACT,GAAGC,OACkB;IACrB,MAAM,EACJC,UAAU,EAAE,EACZC,UAAU,EACVC,SAAS,EACTC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,YAAY,EACZC,cAAc,EACdC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,EACnBC,WAAW,EACXC,iBAAiB,EACjBC,sBAAsB,EACtBC,eAAe,EACfC,kBAAkB,EAClBC,KAAK,EACLC,IAAI,EACJ,GAAGC,WACJ,GAAG1B;IAEJ,MAAM,EAAE2B,UAAU,EAAE,GAAGjC;IAEvB,MAAMkC,cAAyEF;IAE/E,qBACE,MAAClC,MAAMqC,QAAQ;;YACZF,WAAWG,OAAO,kBACjB,KAACnC;gBAAaI,WAAWN,WAAWM,WAAW4B,WAAWG,OAAO,CAAC/B,SAAS;gBAAI,GAAGC,KAAK;;YAExF2B,WAAWI,MAAM,kBAChB,KAACnC;gBACCG,WAAWN,WAAWM,WAAW4B,WAAWI,MAAM,CAAChC,SAAS;gBAC3D,GAAG6B,WAAW;0BAEd3B,QAAQ+B,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE,iBAC5B,KAACC;wBAAOD,OAAOA;kCACZD;uBADwB,CAAC,EAAEC,MAAM,CAAC;;;;AAQjD,EAAE"}
@@ -1,15 +1,26 @@
1
1
  import { HTMLAttributesWithRootRef } from '../../types';
2
- export declare const ALLOWED_SIZES: readonly ["3xs", "2xs", "xs", "s", "m", "l", "xl", "2xl", "3xl", "4xl"];
3
- type Size = (typeof ALLOWED_SIZES)[number];
2
+ export declare const CUSTOM_CSS_TOKEN_FOR_USER_GAP = "--vkui_internal--Spacing_gap";
3
+ export declare const sizesClassNames: {
4
+ '3xs': string;
5
+ '2xs': string;
6
+ xs: string;
7
+ s: string;
8
+ m: string;
9
+ l: string;
10
+ xl: string;
11
+ '2xl': string;
12
+ '3xl': string;
13
+ '4xl': string;
14
+ };
15
+ export type SpacingSize = keyof typeof sizesClassNames;
4
16
  export interface SpacingProps extends HTMLAttributesWithRootRef<HTMLDivElement> {
5
17
  /**
6
18
  * Высота спэйсинга
7
19
  */
8
- size?: number | Size;
20
+ size?: number | SpacingSize;
9
21
  }
10
22
  /**
11
23
  * @see https://vkcom.github.io/VKUI/#/Spacing
12
24
  */
13
- export declare const Spacing: ({ size, style: styleProp, ...restProps }: SpacingProps) => import("react/jsx-runtime").JSX.Element;
14
- export {};
25
+ export declare const Spacing: ({ size, style, className, ...restProps }: SpacingProps) => import("react/jsx-runtime").JSX.Element;
15
26
  //# sourceMappingURL=Spacing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Spacing.d.ts","sourceRoot":"","sources":["../../../../src/components/Spacing/Spacing.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAIxD,eAAO,MAAM,aAAa,yEAWhB,CAAC;AACX,KAAK,IAAI,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3C,MAAM,WAAW,YAAa,SAAQ,yBAAyB,CAAC,cAAc,CAAC;IAC7E;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AACD;;GAEG;AACH,eAAO,MAAM,OAAO,6CAAoD,YAAY,4CAOnF,CAAC"}
1
+ {"version":3,"file":"Spacing.d.ts","sourceRoot":"","sources":["../../../../src/components/Spacing/Spacing.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAIxD,eAAO,MAAM,6BAA6B,iCAAiC,CAAC;AAE5E,eAAO,MAAM,eAAe;;;;;;;;;;;CAW3B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,eAAe,CAAC;AAEvD,MAAM,WAAW,YAAa,SAAQ,yBAAyB,CAAC,cAAc,CAAC;IAC7E;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC7B;AACD;;GAEG;AACH,eAAO,MAAM,OAAO,6CAAoD,YAAY,4CAqBnF,CAAC"}
@@ -1,41 +1,42 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
2
+ import { classNames } from '@vkontakte/vkjs';
3
3
  import { RootComponent } from '../RootComponent/RootComponent';
4
4
  import styles from './Spacing.module.css';
5
- export const ALLOWED_SIZES = [
6
- '3xs',
7
- '2xs',
8
- 'xs',
9
- 's',
10
- 'm',
11
- 'l',
12
- 'xl',
13
- '2xl',
14
- '3xl',
15
- '4xl'
16
- ];
5
+ export const CUSTOM_CSS_TOKEN_FOR_USER_GAP = '--vkui_internal--Spacing_gap';
6
+ export const sizesClassNames = {
7
+ '3xs': styles['Spacing--3xs'],
8
+ '2xs': styles['Spacing--2xs'],
9
+ 'xs': styles['Spacing--xs'],
10
+ 's': styles['Spacing--s'],
11
+ 'm': styles['Spacing--m'],
12
+ 'l': styles['Spacing--l'],
13
+ 'xl': styles['Spacing--xl'],
14
+ '2xl': styles['Spacing--2xl'],
15
+ '3xl': styles['Spacing--3xl'],
16
+ '4xl': styles['Spacing--4xl']
17
+ };
17
18
  /**
18
19
  * @see https://vkcom.github.io/VKUI/#/Spacing
19
- */ export const Spacing = ({ size = 'm', style: styleProp, ...restProps })=>{
20
- const style = {
21
- ...getSizeStyle(size),
22
- ...styleProp
23
- };
20
+ */ export const Spacing = ({ size = 'm', style, className, ...restProps })=>{
21
+ if (typeof size === 'string') {
22
+ className = className ? classNames(sizesClassNames[size], className) : sizesClassNames[size];
23
+ } else {
24
+ if (style) {
25
+ // @ts-expect-error: TS7053 В React.CSSProperties не учитывается Custom Properties
26
+ style[CUSTOM_CSS_TOKEN_FOR_USER_GAP] = size;
27
+ } else {
28
+ // @ts-expect-error: TS2353 В React.CSSProperties не учитывается Custom Properties
29
+ style = {
30
+ [CUSTOM_CSS_TOKEN_FOR_USER_GAP]: size
31
+ };
32
+ }
33
+ }
24
34
  return /*#__PURE__*/ _jsx(RootComponent, {
25
35
  ...restProps,
26
- baseClassName: styles['Spacing'],
27
- style: style
36
+ style: style,
37
+ className: className,
38
+ baseClassName: styles['Spacing']
28
39
  });
29
40
  };
30
- function getSizeStyle(size) {
31
- const sizeValue = getSizeValue(size);
32
- return {
33
- height: sizeValue,
34
- padding: `calc(${sizeValue} / 2px) 0`
35
- };
36
- }
37
- function getSizeValue(size) {
38
- return typeof size === 'string' ? `var(--vkui--spacing_size_${size})` : size;
39
- }
40
41
 
41
42
  //# sourceMappingURL=Spacing.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Spacing/Spacing.tsx"],"sourcesContent":["import * as React from 'react';\nimport { HTMLAttributesWithRootRef } from '../../types';\nimport { RootComponent } from '../RootComponent/RootComponent';\nimport styles from './Spacing.module.css';\n\nexport const ALLOWED_SIZES = [\n '3xs',\n '2xs',\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n] as const;\ntype Size = (typeof ALLOWED_SIZES)[number];\n\nexport interface SpacingProps extends HTMLAttributesWithRootRef<HTMLDivElement> {\n /**\n * Высота спэйсинга\n */\n size?: number | Size;\n}\n/**\n * @see https://vkcom.github.io/VKUI/#/Spacing\n */\nexport const Spacing = ({ size = 'm', style: styleProp, ...restProps }: SpacingProps) => {\n const style: React.CSSProperties = {\n ...getSizeStyle(size),\n ...styleProp,\n };\n\n return <RootComponent {...restProps} baseClassName={styles['Spacing']} style={style} />;\n};\n\nfunction getSizeStyle(size: number | Size): React.CSSProperties {\n const sizeValue = getSizeValue(size);\n\n return {\n height: sizeValue,\n padding: `calc(${sizeValue} / 2px) 0`,\n };\n}\n\nfunction getSizeValue(size: number | Size): `var(--vkui--spacing_size_${Size})` | number {\n return typeof size === 'string' ? `var(--vkui--spacing_size_${size})` : size;\n}\n"],"names":["React","RootComponent","styles","ALLOWED_SIZES","Spacing","size","style","styleProp","restProps","getSizeStyle","baseClassName","sizeValue","getSizeValue","height","padding"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,OAAOC,YAAY,uBAAuB;AAE1C,OAAO,MAAMC,gBAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAU;AASX;;CAEC,GACD,OAAO,MAAMC,UAAU,CAAC,EAAEC,OAAO,GAAG,EAAEC,OAAOC,SAAS,EAAE,GAAGC,WAAyB;IAClF,MAAMF,QAA6B;QACjC,GAAGG,aAAaJ,KAAK;QACrB,GAAGE,SAAS;IACd;IAEA,qBAAO,KAACN;QAAe,GAAGO,SAAS;QAAEE,eAAeR,MAAM,CAAC,UAAU;QAAEI,OAAOA;;AAChF,EAAE;AAEF,SAASG,aAAaJ,IAAmB;IACvC,MAAMM,YAAYC,aAAaP;IAE/B,OAAO;QACLQ,QAAQF;QACRG,SAAS,CAAC,KAAK,EAAEH,UAAU,SAAS,CAAC;IACvC;AACF;AAEA,SAASC,aAAaP,IAAmB;IACvC,OAAO,OAAOA,SAAS,WAAW,CAAC,yBAAyB,EAAEA,KAAK,CAAC,CAAC,GAAGA;AAC1E"}
1
+ {"version":3,"sources":["../../../../src/components/Spacing/Spacing.tsx"],"sourcesContent":["import { classNames } from '@vkontakte/vkjs';\nimport { HTMLAttributesWithRootRef } from '../../types';\nimport { RootComponent } from '../RootComponent/RootComponent';\nimport styles from './Spacing.module.css';\n\nexport const CUSTOM_CSS_TOKEN_FOR_USER_GAP = '--vkui_internal--Spacing_gap';\n\nexport const sizesClassNames = {\n '3xs': styles['Spacing--3xs'],\n '2xs': styles['Spacing--2xs'],\n 'xs': styles['Spacing--xs'],\n 's': styles['Spacing--s'],\n 'm': styles['Spacing--m'],\n 'l': styles['Spacing--l'],\n 'xl': styles['Spacing--xl'],\n '2xl': styles['Spacing--2xl'],\n '3xl': styles['Spacing--3xl'],\n '4xl': styles['Spacing--4xl'],\n};\n\nexport type SpacingSize = keyof typeof sizesClassNames;\n\nexport interface SpacingProps extends HTMLAttributesWithRootRef<HTMLDivElement> {\n /**\n * Высота спэйсинга\n */\n size?: number | SpacingSize;\n}\n/**\n * @see https://vkcom.github.io/VKUI/#/Spacing\n */\nexport const Spacing = ({ size = 'm', style, className, ...restProps }: SpacingProps) => {\n if (typeof size === 'string') {\n className = className ? classNames(sizesClassNames[size], className) : sizesClassNames[size];\n } else {\n if (style) {\n // @ts-expect-error: TS7053 В React.CSSProperties не учитывается Custom Properties\n style[CUSTOM_CSS_TOKEN_FOR_USER_GAP] = size;\n } else {\n // @ts-expect-error: TS2353 В React.CSSProperties не учитывается Custom Properties\n style = { [CUSTOM_CSS_TOKEN_FOR_USER_GAP]: size };\n }\n }\n\n return (\n <RootComponent\n {...restProps}\n style={style}\n className={className}\n baseClassName={styles['Spacing']}\n />\n );\n};\n"],"names":["classNames","RootComponent","styles","CUSTOM_CSS_TOKEN_FOR_USER_GAP","sizesClassNames","Spacing","size","style","className","restProps","baseClassName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,aAAa,QAAQ,iCAAiC;AAC/D,OAAOC,YAAY,uBAAuB;AAE1C,OAAO,MAAMC,gCAAgC,+BAA+B;AAE5E,OAAO,MAAMC,kBAAkB;IAC7B,OAAOF,MAAM,CAAC,eAAe;IAC7B,OAAOA,MAAM,CAAC,eAAe;IAC7B,MAAMA,MAAM,CAAC,cAAc;IAC3B,KAAKA,MAAM,CAAC,aAAa;IACzB,KAAKA,MAAM,CAAC,aAAa;IACzB,KAAKA,MAAM,CAAC,aAAa;IACzB,MAAMA,MAAM,CAAC,cAAc;IAC3B,OAAOA,MAAM,CAAC,eAAe;IAC7B,OAAOA,MAAM,CAAC,eAAe;IAC7B,OAAOA,MAAM,CAAC,eAAe;AAC/B,EAAE;AAUF;;CAEC,GACD,OAAO,MAAMG,UAAU,CAAC,EAAEC,OAAO,GAAG,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAGC,WAAyB;IAClF,IAAI,OAAOH,SAAS,UAAU;QAC5BE,YAAYA,YAAYR,WAAWI,eAAe,CAACE,KAAK,EAAEE,aAAaJ,eAAe,CAACE,KAAK;IAC9F,OAAO;QACL,IAAIC,OAAO;YACT,kFAAkF;YAClFA,KAAK,CAACJ,8BAA8B,GAAGG;QACzC,OAAO;YACL,kFAAkF;YAClFC,QAAQ;gBAAE,CAACJ,8BAA8B,EAAEG;YAAK;QAClD;IACF;IAEA,qBACE,KAACL;QACE,GAAGQ,SAAS;QACbF,OAAOA;QACPC,WAAWA;QACXE,eAAeR,MAAM,CAAC,UAAU;;AAGtC,EAAE"}
@@ -1,4 +1,48 @@
1
1
  .Spacing {
2
+ --vkui_internal--Spacing_gap: 0;
3
+
2
4
  position: relative;
5
+ block-size: var(--vkui_internal--Spacing_gap);
6
+ padding-block: calc(1px * var(--vkui_internal--Spacing_gap) / 2);
3
7
  box-sizing: border-box;
4
8
  }
9
+
10
+ .Spacing--3xs {
11
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_3xs);
12
+ }
13
+
14
+ .Spacing--2xs {
15
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_2xs);
16
+ }
17
+
18
+ .Spacing--xs {
19
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_xs);
20
+ }
21
+
22
+ .Spacing--s {
23
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_s);
24
+ }
25
+
26
+ .Spacing--m {
27
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_m);
28
+ }
29
+
30
+ .Spacing--l {
31
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_l);
32
+ }
33
+
34
+ .Spacing--xl {
35
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_xl);
36
+ }
37
+
38
+ .Spacing--2xl {
39
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_2xl);
40
+ }
41
+
42
+ .Spacing--3xl {
43
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_3xl);
44
+ }
45
+
46
+ .Spacing--4xl {
47
+ --vkui_internal--Spacing_gap: var(--vkui--spacing_size_4xl);
48
+ }
@@ -9,7 +9,7 @@ import styles from './SplitLayout.module.css';
9
9
  */ export const SplitLayout = ({ popout, modal, header, children, getRootRef, getRef, className, center, ...restProps })=>{
10
10
  const platform = usePlatform();
11
11
  return /*#__PURE__*/ _jsxs(PopoutRoot, {
12
- className: classNames(styles['SplitLayout'], platform === 'ios' && styles['SplitLayout--ios'], center && styles['SplitLayout--center']),
12
+ className: classNames(styles['SplitLayout'], platform === 'ios' && styles['SplitLayout--ios']),
13
13
  popout: popout,
14
14
  modal: modal,
15
15
  getRootRef: getRootRef,
@@ -18,7 +18,7 @@ import styles from './SplitLayout.module.css';
18
18
  /*#__PURE__*/ _jsx("div", {
19
19
  ...restProps,
20
20
  ref: getRef,
21
- className: classNames(styles['SplitLayout__inner'], !!header && styles['SplitLayout__inner--header'], className),
21
+ className: classNames(styles['SplitLayout__inner'], !!header && styles['SplitLayout__inner--header'], center && styles['SplitLayout__inner--center'], className),
22
22
  children: children
23
23
  })
24
24
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/SplitLayout/SplitLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@vkontakte/vkjs';\nimport { usePlatform } from '../../hooks/usePlatform';\nimport { HasRef, HTMLAttributesWithRootRef } from '../../types';\nimport { PopoutRoot } from '../PopoutRoot/PopoutRoot';\nimport styles from './SplitLayout.module.css';\n\nexport interface SplitLayoutProps\n extends HTMLAttributesWithRootRef<HTMLDivElement>,\n HasRef<HTMLDivElement> {\n /**\n * Свойство для отрисовки `Alert`, `ActionSheet` и `ScreenSpinner`.\n */\n popout?: React.ReactNode;\n /**\n * Свойство для отрисовки `ModalRoot`.\n */\n modal?: React.ReactNode;\n header?: React.ReactNode;\n /**\n * Центрирует контент.\n */\n center?: boolean;\n}\n\n/**\n * @see https://vkcom.github.io/VKUI/#/SplitLayout\n */\nexport const SplitLayout = ({\n popout,\n modal,\n header,\n children,\n getRootRef,\n getRef,\n className,\n center,\n ...restProps\n}: SplitLayoutProps) => {\n const platform = usePlatform();\n\n return (\n <PopoutRoot\n className={classNames(\n styles['SplitLayout'],\n platform === 'ios' && styles['SplitLayout--ios'],\n center && styles['SplitLayout--center'],\n )}\n popout={popout}\n modal={modal}\n getRootRef={getRootRef}\n >\n {header}\n <div\n {...restProps}\n ref={getRef}\n className={classNames(\n styles['SplitLayout__inner'],\n !!header && styles['SplitLayout__inner--header'],\n className,\n )}\n >\n {children}\n </div>\n </PopoutRoot>\n );\n};\n"],"names":["React","classNames","usePlatform","PopoutRoot","styles","SplitLayout","popout","modal","header","children","getRootRef","getRef","className","center","restProps","platform","div","ref"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,WAAW,QAAQ,0BAA0B;AAEtD,SAASC,UAAU,QAAQ,2BAA2B;AACtD,OAAOC,YAAY,2BAA2B;AAoB9C;;CAEC,GACD,OAAO,MAAMC,cAAc,CAAC,EAC1BC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,MAAM,EACN,GAAGC,WACc;IACjB,MAAMC,WAAWb;IAEjB,qBACE,MAACC;QACCS,WAAWX,WACTG,MAAM,CAAC,cAAc,EACrBW,aAAa,SAASX,MAAM,CAAC,mBAAmB,EAChDS,UAAUT,MAAM,CAAC,sBAAsB;QAEzCE,QAAQA;QACRC,OAAOA;QACPG,YAAYA;;YAEXF;0BACD,KAACQ;gBACE,GAAGF,SAAS;gBACbG,KAAKN;gBACLC,WAAWX,WACTG,MAAM,CAAC,qBAAqB,EAC5B,CAAC,CAACI,UAAUJ,MAAM,CAAC,6BAA6B,EAChDQ;0BAGDH;;;;AAIT,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/SplitLayout/SplitLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@vkontakte/vkjs';\nimport { usePlatform } from '../../hooks/usePlatform';\nimport { HasRef, HTMLAttributesWithRootRef } from '../../types';\nimport { PopoutRoot } from '../PopoutRoot/PopoutRoot';\nimport styles from './SplitLayout.module.css';\n\nexport interface SplitLayoutProps\n extends HTMLAttributesWithRootRef<HTMLDivElement>,\n HasRef<HTMLDivElement> {\n /**\n * Свойство для отрисовки `Alert`, `ActionSheet` и `ScreenSpinner`.\n */\n popout?: React.ReactNode;\n /**\n * Свойство для отрисовки `ModalRoot`.\n */\n modal?: React.ReactNode;\n header?: React.ReactNode;\n /**\n * Центрирует контент.\n */\n center?: boolean;\n}\n\n/**\n * @see https://vkcom.github.io/VKUI/#/SplitLayout\n */\nexport const SplitLayout = ({\n popout,\n modal,\n header,\n children,\n getRootRef,\n getRef,\n className,\n center,\n ...restProps\n}: SplitLayoutProps) => {\n const platform = usePlatform();\n\n return (\n <PopoutRoot\n className={classNames(\n styles['SplitLayout'],\n platform === 'ios' && styles['SplitLayout--ios'],\n )}\n popout={popout}\n modal={modal}\n getRootRef={getRootRef}\n >\n {header}\n <div\n {...restProps}\n ref={getRef}\n className={classNames(\n styles['SplitLayout__inner'],\n !!header && styles['SplitLayout__inner--header'],\n center && styles['SplitLayout__inner--center'],\n className,\n )}\n >\n {children}\n </div>\n </PopoutRoot>\n );\n};\n"],"names":["React","classNames","usePlatform","PopoutRoot","styles","SplitLayout","popout","modal","header","children","getRootRef","getRef","className","center","restProps","platform","div","ref"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,WAAW,QAAQ,0BAA0B;AAEtD,SAASC,UAAU,QAAQ,2BAA2B;AACtD,OAAOC,YAAY,2BAA2B;AAoB9C;;CAEC,GACD,OAAO,MAAMC,cAAc,CAAC,EAC1BC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,MAAM,EACN,GAAGC,WACc;IACjB,MAAMC,WAAWb;IAEjB,qBACE,MAACC;QACCS,WAAWX,WACTG,MAAM,CAAC,cAAc,EACrBW,aAAa,SAASX,MAAM,CAAC,mBAAmB;QAElDE,QAAQA;QACRC,OAAOA;QACPG,YAAYA;;YAEXF;0BACD,KAACQ;gBACE,GAAGF,SAAS;gBACbG,KAAKN;gBACLC,WAAWX,WACTG,MAAM,CAAC,qBAAqB,EAC5B,CAAC,CAACI,UAAUJ,MAAM,CAAC,6BAA6B,EAChDS,UAAUT,MAAM,CAAC,6BAA6B,EAC9CQ;0BAGDH;;;;AAIT,EAAE"}
@@ -34,6 +34,6 @@
34
34
  );
35
35
  }
36
36
 
37
- .SplitLayout--center {
37
+ .SplitLayout__inner--center {
38
38
  justify-content: center;
39
39
  }
@@ -1,4 +1,5 @@
1
1
  .Textarea {
2
+ overflow: hidden;
2
3
  position: relative;
3
4
  }
4
5
 
@@ -4,6 +4,11 @@ export interface ToolButtonProps extends TappableProps, AdaptiveIconRendererProp
4
4
  mode?: 'primary' | 'secondary' | 'tertiary' | 'outline';
5
5
  appearance?: 'accent' | 'neutral';
6
6
  direction?: 'row' | 'column';
7
+ /**
8
+ * Задаёт `50%` закругления для контейнера.
9
+ *
10
+ * > Note: игнорируется при передаче `children`.
11
+ */
7
12
  rounded?: boolean;
8
13
  }
9
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ToolButton.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolButton/ToolButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,yBAAyB,EAC1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAyB/D,MAAM,WAAW,eAAgB,SAAQ,aAAa,EAAE,yBAAyB;IAC/E,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IACxD,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,mHAWpB,eAAe,4CA0BjB,CAAC"}
1
+ {"version":3,"file":"ToolButton.d.ts","sourceRoot":"","sources":["../../../../src/components/ToolButton/ToolButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,yBAAyB,EAC1B,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAyB/D,MAAM,WAAW,eAAgB,SAAQ,aAAa,EAAE,yBAAyB;IAC/E,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IACxD,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,mHAWpB,eAAe,4CA0BjB,CAAC"}
@@ -20,7 +20,7 @@ const stylesDirection = {
20
20
  };
21
21
  const sizeYClassNames = {
22
22
  none: styles['ToolButton--sizeY-none'],
23
- ['regular']: styles['ToolButton--sizeY-regular']
23
+ regular: styles['ToolButton--sizeY-regular']
24
24
  };
25
25
  /**
26
26
  * Кнопки, которые используются для вызова инструмента, вставки аттачей или
@@ -45,6 +45,7 @@ const sizeYClassNames = {
45
45
  IconRegular: IconRegular
46
46
  }),
47
47
  hasChildren && /*#__PURE__*/ _jsx("span", {
48
+ className: styles['ToolButton__text'],
48
49
  children: children
49
50
  })
50
51
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/ToolButton/ToolButton.tsx"],"sourcesContent":["import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';\nimport { useAdaptivity } from '../../hooks/useAdaptivity';\nimport {\n AdaptiveIconRenderer,\n AdaptiveIconRendererProps,\n} from '../AdaptiveIconRenderer/AdaptiveIconRenderer';\nimport { Tappable, TappableProps } from '../Tappable/Tappable';\nimport styles from './ToolButton.module.css';\n\nconst stylesMode = {\n primary: styles['ToolButton--mode-primary'],\n secondary: styles['ToolButton--mode-secondary'],\n tertiary: styles['ToolButton--mode-tertiary'],\n outline: styles['ToolButton--mode-outline'],\n};\n\nconst stylesAppearance = {\n accent: styles['ToolButton--appearance-accent'],\n neutral: styles['ToolButton--appearance-neutral'],\n};\n\nconst stylesDirection = {\n row: styles['ToolButton--direction-row'],\n column: styles['ToolButton--direction-column'],\n};\n\nconst sizeYClassNames = {\n none: styles['ToolButton--sizeY-none'],\n ['regular']: styles['ToolButton--sizeY-regular'],\n};\n\nexport interface ToolButtonProps extends TappableProps, AdaptiveIconRendererProps {\n mode?: 'primary' | 'secondary' | 'tertiary' | 'outline';\n appearance?: 'accent' | 'neutral';\n direction?: 'row' | 'column';\n rounded?: boolean;\n}\n\n/**\n * Кнопки, которые используются для вызова инструмента, вставки аттачей или\n * для форматирования. Их можно использовать как кнопки для разового действия\n * или для включения/выключения режима.\n *\n * @see https://vkcom.github.io/VKUI/#/ToolButton\n */\nexport const ToolButton = ({\n mode = 'primary',\n appearance = 'accent',\n direction = 'row',\n onClick = noop,\n className,\n children,\n IconCompact,\n IconRegular,\n rounded,\n ...restProps\n}: ToolButtonProps) => {\n const { sizeY = 'none' } = useAdaptivity();\n const hasChildren = hasReactNode(children);\n\n return (\n <Tappable\n hoverMode={styles['ToolButton--hover']}\n activeMode={styles['ToolButton--active']}\n Component={restProps.href ? 'a' : 'button'}\n focusVisibleMode=\"outside\"\n onClick={onClick}\n className={classNames(\n className,\n styles['ToolButton'],\n rounded && !hasChildren && styles['ToolButton--rounded'],\n stylesMode[mode],\n stylesAppearance[appearance],\n stylesDirection[direction],\n sizeY !== 'compact' && sizeYClassNames[sizeY],\n )}\n {...restProps}\n >\n <AdaptiveIconRenderer IconCompact={IconCompact} IconRegular={IconRegular} />\n {hasChildren && <span>{children}</span>}\n </Tappable>\n );\n};\n"],"names":["classNames","hasReactNode","noop","useAdaptivity","AdaptiveIconRenderer","Tappable","styles","stylesMode","primary","secondary","tertiary","outline","stylesAppearance","accent","neutral","stylesDirection","row","column","sizeYClassNames","none","ToolButton","mode","appearance","direction","onClick","className","children","IconCompact","IconRegular","rounded","restProps","sizeY","hasChildren","hoverMode","activeMode","Component","href","focusVisibleMode","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,UAAU,EAAEC,YAAY,EAAEC,IAAI,QAAQ,kBAAkB;AACjE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SACEC,oBAAoB,QAEf,+CAA+C;AACtD,SAASC,QAAQ,QAAuB,uBAAuB;AAC/D,OAAOC,YAAY,0BAA0B;AAE7C,MAAMC,aAAa;IACjBC,SAASF,MAAM,CAAC,2BAA2B;IAC3CG,WAAWH,MAAM,CAAC,6BAA6B;IAC/CI,UAAUJ,MAAM,CAAC,4BAA4B;IAC7CK,SAASL,MAAM,CAAC,2BAA2B;AAC7C;AAEA,MAAMM,mBAAmB;IACvBC,QAAQP,MAAM,CAAC,gCAAgC;IAC/CQ,SAASR,MAAM,CAAC,iCAAiC;AACnD;AAEA,MAAMS,kBAAkB;IACtBC,KAAKV,MAAM,CAAC,4BAA4B;IACxCW,QAAQX,MAAM,CAAC,+BAA+B;AAChD;AAEA,MAAMY,kBAAkB;IACtBC,MAAMb,MAAM,CAAC,yBAAyB;IACtC,CAAC,UAAU,EAAEA,MAAM,CAAC,4BAA4B;AAClD;AASA;;;;;;CAMC,GACD,OAAO,MAAMc,aAAa,CAAC,EACzBC,OAAO,SAAS,EAChBC,aAAa,QAAQ,EACrBC,YAAY,KAAK,EACjBC,UAAUtB,IAAI,EACduB,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,OAAO,EACP,GAAGC,WACa;IAChB,MAAM,EAAEC,QAAQ,MAAM,EAAE,GAAG5B;IAC3B,MAAM6B,cAAc/B,aAAayB;IAEjC,qBACE,MAACrB;QACC4B,WAAW3B,MAAM,CAAC,oBAAoB;QACtC4B,YAAY5B,MAAM,CAAC,qBAAqB;QACxC6B,WAAWL,UAAUM,IAAI,GAAG,MAAM;QAClCC,kBAAiB;QACjBb,SAASA;QACTC,WAAWzB,WACTyB,WACAnB,MAAM,CAAC,aAAa,EACpBuB,WAAW,CAACG,eAAe1B,MAAM,CAAC,sBAAsB,EACxDC,UAAU,CAACc,KAAK,EAChBT,gBAAgB,CAACU,WAAW,EAC5BP,eAAe,CAACQ,UAAU,EAC1BQ,UAAU,aAAab,eAAe,CAACa,MAAM;QAE9C,GAAGD,SAAS;;0BAEb,KAAC1B;gBAAqBuB,aAAaA;gBAAaC,aAAaA;;YAC5DI,6BAAe,KAACM;0BAAMZ;;;;AAG7B,EAAE"}
1
+ {"version":3,"sources":["../../../../src/components/ToolButton/ToolButton.tsx"],"sourcesContent":["import { classNames, hasReactNode, noop } from '@vkontakte/vkjs';\nimport { useAdaptivity } from '../../hooks/useAdaptivity';\nimport {\n AdaptiveIconRenderer,\n AdaptiveIconRendererProps,\n} from '../AdaptiveIconRenderer/AdaptiveIconRenderer';\nimport { Tappable, TappableProps } from '../Tappable/Tappable';\nimport styles from './ToolButton.module.css';\n\nconst stylesMode = {\n primary: styles['ToolButton--mode-primary'],\n secondary: styles['ToolButton--mode-secondary'],\n tertiary: styles['ToolButton--mode-tertiary'],\n outline: styles['ToolButton--mode-outline'],\n};\n\nconst stylesAppearance = {\n accent: styles['ToolButton--appearance-accent'],\n neutral: styles['ToolButton--appearance-neutral'],\n};\n\nconst stylesDirection = {\n row: styles['ToolButton--direction-row'],\n column: styles['ToolButton--direction-column'],\n};\n\nconst sizeYClassNames = {\n none: styles['ToolButton--sizeY-none'],\n regular: styles['ToolButton--sizeY-regular'],\n};\n\nexport interface ToolButtonProps extends TappableProps, AdaptiveIconRendererProps {\n mode?: 'primary' | 'secondary' | 'tertiary' | 'outline';\n appearance?: 'accent' | 'neutral';\n direction?: 'row' | 'column';\n /**\n * Задаёт `50%` закругления для контейнера.\n *\n * > Note: игнорируется при передаче `children`.\n */\n rounded?: boolean;\n}\n\n/**\n * Кнопки, которые используются для вызова инструмента, вставки аттачей или\n * для форматирования. Их можно использовать как кнопки для разового действия\n * или для включения/выключения режима.\n *\n * @see https://vkcom.github.io/VKUI/#/ToolButton\n */\nexport const ToolButton = ({\n mode = 'primary',\n appearance = 'accent',\n direction = 'row',\n onClick = noop,\n className,\n children,\n IconCompact,\n IconRegular,\n rounded,\n ...restProps\n}: ToolButtonProps) => {\n const { sizeY = 'none' } = useAdaptivity();\n const hasChildren = hasReactNode(children);\n\n return (\n <Tappable\n hoverMode={styles['ToolButton--hover']}\n activeMode={styles['ToolButton--active']}\n Component={restProps.href ? 'a' : 'button'}\n focusVisibleMode=\"outside\"\n onClick={onClick}\n className={classNames(\n className,\n styles['ToolButton'],\n rounded && !hasChildren && styles['ToolButton--rounded'],\n stylesMode[mode],\n stylesAppearance[appearance],\n stylesDirection[direction],\n sizeY !== 'compact' && sizeYClassNames[sizeY],\n )}\n {...restProps}\n >\n <AdaptiveIconRenderer IconCompact={IconCompact} IconRegular={IconRegular} />\n {hasChildren && <span className={styles['ToolButton__text']}>{children}</span>}\n </Tappable>\n );\n};\n"],"names":["classNames","hasReactNode","noop","useAdaptivity","AdaptiveIconRenderer","Tappable","styles","stylesMode","primary","secondary","tertiary","outline","stylesAppearance","accent","neutral","stylesDirection","row","column","sizeYClassNames","none","regular","ToolButton","mode","appearance","direction","onClick","className","children","IconCompact","IconRegular","rounded","restProps","sizeY","hasChildren","hoverMode","activeMode","Component","href","focusVisibleMode","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,UAAU,EAAEC,YAAY,EAAEC,IAAI,QAAQ,kBAAkB;AACjE,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SACEC,oBAAoB,QAEf,+CAA+C;AACtD,SAASC,QAAQ,QAAuB,uBAAuB;AAC/D,OAAOC,YAAY,0BAA0B;AAE7C,MAAMC,aAAa;IACjBC,SAASF,MAAM,CAAC,2BAA2B;IAC3CG,WAAWH,MAAM,CAAC,6BAA6B;IAC/CI,UAAUJ,MAAM,CAAC,4BAA4B;IAC7CK,SAASL,MAAM,CAAC,2BAA2B;AAC7C;AAEA,MAAMM,mBAAmB;IACvBC,QAAQP,MAAM,CAAC,gCAAgC;IAC/CQ,SAASR,MAAM,CAAC,iCAAiC;AACnD;AAEA,MAAMS,kBAAkB;IACtBC,KAAKV,MAAM,CAAC,4BAA4B;IACxCW,QAAQX,MAAM,CAAC,+BAA+B;AAChD;AAEA,MAAMY,kBAAkB;IACtBC,MAAMb,MAAM,CAAC,yBAAyB;IACtCc,SAASd,MAAM,CAAC,4BAA4B;AAC9C;AAcA;;;;;;CAMC,GACD,OAAO,MAAMe,aAAa,CAAC,EACzBC,OAAO,SAAS,EAChBC,aAAa,QAAQ,EACrBC,YAAY,KAAK,EACjBC,UAAUvB,IAAI,EACdwB,SAAS,EACTC,QAAQ,EACRC,WAAW,EACXC,WAAW,EACXC,OAAO,EACP,GAAGC,WACa;IAChB,MAAM,EAAEC,QAAQ,MAAM,EAAE,GAAG7B;IAC3B,MAAM8B,cAAchC,aAAa0B;IAEjC,qBACE,MAACtB;QACC6B,WAAW5B,MAAM,CAAC,oBAAoB;QACtC6B,YAAY7B,MAAM,CAAC,qBAAqB;QACxC8B,WAAWL,UAAUM,IAAI,GAAG,MAAM;QAClCC,kBAAiB;QACjBb,SAASA;QACTC,WAAW1B,WACT0B,WACApB,MAAM,CAAC,aAAa,EACpBwB,WAAW,CAACG,eAAe3B,MAAM,CAAC,sBAAsB,EACxDC,UAAU,CAACe,KAAK,EAChBV,gBAAgB,CAACW,WAAW,EAC5BR,eAAe,CAACS,UAAU,EAC1BQ,UAAU,aAAad,eAAe,CAACc,MAAM;QAE9C,GAAGD,SAAS;;0BAEb,KAAC3B;gBAAqBwB,aAAaA;gBAAaC,aAAaA;;YAC5DI,6BAAe,KAACM;gBAAKb,WAAWpB,MAAM,CAAC,mBAAmB;0BAAGqB;;;;AAGpE,EAAE"}
@@ -49,30 +49,16 @@
49
49
  flex-direction: column;
50
50
  }
51
51
 
52
- /* stylelint-disable selector-max-universal -- gap для элементов */
53
-
54
- .ToolButton--direction-row > * {
55
- -webkit-margin-end: 4px;
56
- margin-inline-end: 4px;
57
- }
58
-
59
- .ToolButton--direction-row > *:last-child {
60
- -webkit-margin-end: 0;
61
- margin-inline-end: 0;
52
+ .ToolButton--direction-row .ToolButton__text {
53
+ -webkit-margin-start: 4px;
54
+ margin-inline-start: 4px;
62
55
  }
63
56
 
64
- .ToolButton--direction-column > * {
65
- -webkit-margin-after: 4px;
66
- margin-block-end: 4px;
57
+ .ToolButton--direction-column .ToolButton__text {
58
+ -webkit-margin-before: 4px;
59
+ margin-block-start: 4px;
67
60
  }
68
61
 
69
- .ToolButton--direction-column > *:last-child {
70
- -webkit-margin-after: 0;
71
- margin-block-end: 0;
72
- }
73
-
74
- /* stylelint-enable selector-max-universal */
75
-
76
62
  /* ToolButton's backgrounds */
77
63
 
78
64
  /* Mode = Primary */
@@ -1,5 +1,4 @@
1
1
  export declare const EDGE_SIZE = 50;
2
- export declare const OUTBOX_OFFSET = -30;
3
2
  export declare const getAutoScrollingData: (clientY: number, scrollEl: Element | Window) => {
4
3
  shouldScrolling: boolean;
5
4
  y: number;
@@ -1 +1 @@
1
- {"version":3,"file":"autoScroll.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDraggableWithDomApi/autoScroll.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,eAAO,MAAM,oBAAoB,YAAa,MAAM,YAAY,OAAO,GAAG,MAAM;;;CA+B/E,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,eAAO,MAAM,0BAA0B,aAAc,OAAO,GAAG,MAAM;wBAgBxC,mBAAmB;;;CAgB/C,CAAC"}
1
+ {"version":3,"file":"autoScroll.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useDraggableWithDomApi/autoScroll.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,eAAO,MAAM,oBAAoB,YAAa,MAAM,YAAY,OAAO,GAAG,MAAM;;;CA6B/E,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,MAAM;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,eAAO,MAAM,0BAA0B,aAAc,OAAO,GAAG,MAAM;wBAgBxC,mBAAmB;;;CAgB/C,CAAC"}
@@ -2,7 +2,6 @@ import { getNodeScroll, getScrollHeight, getScrollRect } from '../../lib/dom';
2
2
  import { rafSchd } from '../../lib/rafSchd';
3
3
  const SCROLL_SPEED = 10;
4
4
  export const EDGE_SIZE = 50;
5
- export const OUTBOX_OFFSET = -30;
6
5
  export const getAutoScrollingData = (clientY, scrollEl)=>{
7
6
  const scrollTop = Math.floor(getNodeScroll(scrollEl).scrollTop);
8
7
  const { relative, edges } = getScrollRect(scrollEl);
@@ -17,7 +16,7 @@ export const getAutoScrollingData = (clientY, scrollEl)=>{
17
16
  const isInTopEdge = topDistance <= EDGE_SIZE;
18
17
  const isInBottomEdge = bottomDistance <= EDGE_SIZE;
19
18
  const result = {
20
- shouldScrolling: canScrollUp && isInTopEdge && topDistance >= OUTBOX_OFFSET || canScrollDown && isInBottomEdge && bottomDistance >= OUTBOX_OFFSET,
19
+ shouldScrolling: canScrollUp && isInTopEdge || canScrollDown && isInBottomEdge,
21
20
  y: 0
22
21
  };
23
22
  // Inspired by https://github.com/SortableJS/Sortable/issues/1907#issuecomment-1495403785
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/hooks/useDraggableWithDomApi/autoScroll.ts"],"sourcesContent":["import { getNodeScroll, getScrollHeight, getScrollRect } from '../../lib/dom';\nimport { rafSchd } from '../../lib/rafSchd';\n\nconst SCROLL_SPEED = 10;\nexport const EDGE_SIZE = 50;\nexport const OUTBOX_OFFSET = -30;\n\nexport const getAutoScrollingData = (clientY: number, scrollEl: Element | Window) => {\n const scrollTop = Math.floor(getNodeScroll(scrollEl).scrollTop);\n\n const { relative, edges } = getScrollRect(scrollEl);\n const viewportHeight = relative.height;\n const documentHeight = getScrollHeight(scrollEl);\n const maxScrollY = documentHeight - viewportHeight;\n const canScrollUp = scrollTop > 0;\n const canScrollDown = scrollTop < maxScrollY;\n\n const [edgeTop, edgeBottom] = edges.y;\n const topDistance = clientY - edgeTop;\n const bottomDistance = edgeBottom - clientY;\n const isInTopEdge = topDistance <= EDGE_SIZE;\n const isInBottomEdge = bottomDistance <= EDGE_SIZE;\n\n const result = {\n shouldScrolling:\n (canScrollUp && isInTopEdge && topDistance >= OUTBOX_OFFSET) ||\n (canScrollDown && isInBottomEdge && bottomDistance >= OUTBOX_OFFSET),\n y: 0,\n };\n\n // Inspired by https://github.com/SortableJS/Sortable/issues/1907#issuecomment-1495403785\n if (isInTopEdge) {\n result.y = -1 * ((EDGE_SIZE - topDistance) / EDGE_SIZE) * SCROLL_SPEED;\n } else if (isInBottomEdge) {\n result.y = ((EDGE_SIZE - bottomDistance) / EDGE_SIZE) * SCROLL_SPEED;\n }\n\n return result;\n};\n\nexport type AutoScrollingDataFn = () => { shouldScrolling: boolean; y: number };\n\nexport const createAutoScrollController = (scrollEl: Element | Window) => {\n let isRunning = false;\n const scheduledScroll = rafSchd(scroll);\n\n function scroll(fn: AutoScrollingDataFn) {\n const { shouldScrolling, y } = fn();\n if (shouldScrolling) {\n isRunning = true;\n scrollEl.scrollBy(0, y);\n scheduledScroll(fn);\n } else {\n isRunning = false;\n scheduledScroll.cancel();\n }\n }\n\n const tryAutoScroll = (fn: AutoScrollingDataFn) => {\n scheduledScroll(fn);\n };\n\n const stop = () => {\n isRunning = false;\n scheduledScroll.cancel();\n };\n\n return {\n tryAutoScroll,\n stop,\n get isRunning() {\n return isRunning;\n },\n };\n};\n"],"names":["getNodeScroll","getScrollHeight","getScrollRect","rafSchd","SCROLL_SPEED","EDGE_SIZE","OUTBOX_OFFSET","getAutoScrollingData","clientY","scrollEl","scrollTop","Math","floor","relative","edges","viewportHeight","height","documentHeight","maxScrollY","canScrollUp","canScrollDown","edgeTop","edgeBottom","y","topDistance","bottomDistance","isInTopEdge","isInBottomEdge","result","shouldScrolling","createAutoScrollController","isRunning","scheduledScroll","scroll","fn","scrollBy","cancel","tryAutoScroll","stop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,EAAEC,eAAe,EAAEC,aAAa,QAAQ,gBAAgB;AAC9E,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,eAAe;AACrB,OAAO,MAAMC,YAAY,GAAG;AAC5B,OAAO,MAAMC,gBAAgB,CAAC,GAAG;AAEjC,OAAO,MAAMC,uBAAuB,CAACC,SAAiBC;IACpD,MAAMC,YAAYC,KAAKC,KAAK,CAACZ,cAAcS,UAAUC,SAAS;IAE9D,MAAM,EAAEG,QAAQ,EAAEC,KAAK,EAAE,GAAGZ,cAAcO;IAC1C,MAAMM,iBAAiBF,SAASG,MAAM;IACtC,MAAMC,iBAAiBhB,gBAAgBQ;IACvC,MAAMS,aAAaD,iBAAiBF;IACpC,MAAMI,cAAcT,YAAY;IAChC,MAAMU,gBAAgBV,YAAYQ;IAElC,MAAM,CAACG,SAASC,WAAW,GAAGR,MAAMS,CAAC;IACrC,MAAMC,cAAchB,UAAUa;IAC9B,MAAMI,iBAAiBH,aAAad;IACpC,MAAMkB,cAAcF,eAAenB;IACnC,MAAMsB,iBAAiBF,kBAAkBpB;IAEzC,MAAMuB,SAAS;QACbC,iBACE,AAACV,eAAeO,eAAeF,eAAelB,iBAC7Cc,iBAAiBO,kBAAkBF,kBAAkBnB;QACxDiB,GAAG;IACL;IAEA,yFAAyF;IACzF,IAAIG,aAAa;QACfE,OAAOL,CAAC,GAAG,CAAC,IAAK,CAAA,AAAClB,CAAAA,YAAYmB,WAAU,IAAKnB,SAAQ,IAAKD;IAC5D,OAAO,IAAIuB,gBAAgB;QACzBC,OAAOL,CAAC,GAAG,AAAElB,CAAAA,YAAYoB,cAAa,IAAKpB,YAAaD;IAC1D;IAEA,OAAOwB;AACT,EAAE;AAIF,OAAO,MAAME,6BAA6B,CAACrB;IACzC,IAAIsB,YAAY;IAChB,MAAMC,kBAAkB7B,QAAQ8B;IAEhC,SAASA,OAAOC,EAAuB;QACrC,MAAM,EAAEL,eAAe,EAAEN,CAAC,EAAE,GAAGW;QAC/B,IAAIL,iBAAiB;YACnBE,YAAY;YACZtB,SAAS0B,QAAQ,CAAC,GAAGZ;YACrBS,gBAAgBE;QAClB,OAAO;YACLH,YAAY;YACZC,gBAAgBI,MAAM;QACxB;IACF;IAEA,MAAMC,gBAAgB,CAACH;QACrBF,gBAAgBE;IAClB;IAEA,MAAMI,OAAO;QACXP,YAAY;QACZC,gBAAgBI,MAAM;IACxB;IAEA,OAAO;QACLC;QACAC;QACA,IAAIP,aAAY;YACd,OAAOA;QACT;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/hooks/useDraggableWithDomApi/autoScroll.ts"],"sourcesContent":["import { getNodeScroll, getScrollHeight, getScrollRect } from '../../lib/dom';\nimport { rafSchd } from '../../lib/rafSchd';\n\nconst SCROLL_SPEED = 10;\nexport const EDGE_SIZE = 50;\n\nexport const getAutoScrollingData = (clientY: number, scrollEl: Element | Window) => {\n const scrollTop = Math.floor(getNodeScroll(scrollEl).scrollTop);\n\n const { relative, edges } = getScrollRect(scrollEl);\n const viewportHeight = relative.height;\n const documentHeight = getScrollHeight(scrollEl);\n const maxScrollY = documentHeight - viewportHeight;\n const canScrollUp = scrollTop > 0;\n const canScrollDown = scrollTop < maxScrollY;\n\n const [edgeTop, edgeBottom] = edges.y;\n const topDistance = clientY - edgeTop;\n const bottomDistance = edgeBottom - clientY;\n const isInTopEdge = topDistance <= EDGE_SIZE;\n const isInBottomEdge = bottomDistance <= EDGE_SIZE;\n\n const result = {\n shouldScrolling: (canScrollUp && isInTopEdge) || (canScrollDown && isInBottomEdge),\n y: 0,\n };\n\n // Inspired by https://github.com/SortableJS/Sortable/issues/1907#issuecomment-1495403785\n if (isInTopEdge) {\n result.y = -1 * ((EDGE_SIZE - topDistance) / EDGE_SIZE) * SCROLL_SPEED;\n } else if (isInBottomEdge) {\n result.y = ((EDGE_SIZE - bottomDistance) / EDGE_SIZE) * SCROLL_SPEED;\n }\n\n return result;\n};\n\nexport type AutoScrollingDataFn = () => { shouldScrolling: boolean; y: number };\n\nexport const createAutoScrollController = (scrollEl: Element | Window) => {\n let isRunning = false;\n const scheduledScroll = rafSchd(scroll);\n\n function scroll(fn: AutoScrollingDataFn) {\n const { shouldScrolling, y } = fn();\n if (shouldScrolling) {\n isRunning = true;\n scrollEl.scrollBy(0, y);\n scheduledScroll(fn);\n } else {\n isRunning = false;\n scheduledScroll.cancel();\n }\n }\n\n const tryAutoScroll = (fn: AutoScrollingDataFn) => {\n scheduledScroll(fn);\n };\n\n const stop = () => {\n isRunning = false;\n scheduledScroll.cancel();\n };\n\n return {\n tryAutoScroll,\n stop,\n get isRunning() {\n return isRunning;\n },\n };\n};\n"],"names":["getNodeScroll","getScrollHeight","getScrollRect","rafSchd","SCROLL_SPEED","EDGE_SIZE","getAutoScrollingData","clientY","scrollEl","scrollTop","Math","floor","relative","edges","viewportHeight","height","documentHeight","maxScrollY","canScrollUp","canScrollDown","edgeTop","edgeBottom","y","topDistance","bottomDistance","isInTopEdge","isInBottomEdge","result","shouldScrolling","createAutoScrollController","isRunning","scheduledScroll","scroll","fn","scrollBy","cancel","tryAutoScroll","stop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,EAAEC,eAAe,EAAEC,aAAa,QAAQ,gBAAgB;AAC9E,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,eAAe;AACrB,OAAO,MAAMC,YAAY,GAAG;AAE5B,OAAO,MAAMC,uBAAuB,CAACC,SAAiBC;IACpD,MAAMC,YAAYC,KAAKC,KAAK,CAACX,cAAcQ,UAAUC,SAAS;IAE9D,MAAM,EAAEG,QAAQ,EAAEC,KAAK,EAAE,GAAGX,cAAcM;IAC1C,MAAMM,iBAAiBF,SAASG,MAAM;IACtC,MAAMC,iBAAiBf,gBAAgBO;IACvC,MAAMS,aAAaD,iBAAiBF;IACpC,MAAMI,cAAcT,YAAY;IAChC,MAAMU,gBAAgBV,YAAYQ;IAElC,MAAM,CAACG,SAASC,WAAW,GAAGR,MAAMS,CAAC;IACrC,MAAMC,cAAchB,UAAUa;IAC9B,MAAMI,iBAAiBH,aAAad;IACpC,MAAMkB,cAAcF,eAAelB;IACnC,MAAMqB,iBAAiBF,kBAAkBnB;IAEzC,MAAMsB,SAAS;QACbC,iBAAiB,AAACV,eAAeO,eAAiBN,iBAAiBO;QACnEJ,GAAG;IACL;IAEA,yFAAyF;IACzF,IAAIG,aAAa;QACfE,OAAOL,CAAC,GAAG,CAAC,IAAK,CAAA,AAACjB,CAAAA,YAAYkB,WAAU,IAAKlB,SAAQ,IAAKD;IAC5D,OAAO,IAAIsB,gBAAgB;QACzBC,OAAOL,CAAC,GAAG,AAAEjB,CAAAA,YAAYmB,cAAa,IAAKnB,YAAaD;IAC1D;IAEA,OAAOuB;AACT,EAAE;AAIF,OAAO,MAAME,6BAA6B,CAACrB;IACzC,IAAIsB,YAAY;IAChB,MAAMC,kBAAkB5B,QAAQ6B;IAEhC,SAASA,OAAOC,EAAuB;QACrC,MAAM,EAAEL,eAAe,EAAEN,CAAC,EAAE,GAAGW;QAC/B,IAAIL,iBAAiB;YACnBE,YAAY;YACZtB,SAAS0B,QAAQ,CAAC,GAAGZ;YACrBS,gBAAgBE;QAClB,OAAO;YACLH,YAAY;YACZC,gBAAgBI,MAAM;QACxB;IACF;IAEA,MAAMC,gBAAgB,CAACH;QACrBF,gBAAgBE;IAClB;IAEA,MAAMI,OAAO;QACXP,YAAY;QACZC,gBAAgBI,MAAM;IACxB;IAEA,OAAO;QACLC;QACAC;QACA,IAAIP,aAAY;YACd,OAAOA;QACT;IACF;AACF,EAAE"}
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Хук вызывает переданный коллбэк при изменении размеров элемента.
4
+ */
5
+ export declare function useResizeObserver(ref: React.MutableRefObject<HTMLElement | null>, callback: (element: HTMLElement) => void): void;
6
+ //# sourceMappingURL=useResizeObserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../src/hooks/useResizeObserver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,EAC/C,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,QAmBzC"}
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { CustomResizeObserver } from '../lib/floating/customResizeObserver';
3
+ import { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect';
4
+ import { useStableCallback } from './useStableCallback';
5
+ /**
6
+ * Хук вызывает переданный коллбэк при изменении размеров элемента.
7
+ */ export function useResizeObserver(ref, callback) {
8
+ const stableCallback = useStableCallback(callback);
9
+ useIsomorphicLayoutEffect(function addResizeObserverHandler() {
10
+ /* istanbul ignore if: невозможный кейс (в SSR вызова этой функции не будет) */ if (!ref.current) {
11
+ return;
12
+ }
13
+ const element = ref.current;
14
+ const observer = new CustomResizeObserver(()=>stableCallback(element));
15
+ observer.observe(element);
16
+ observer.appendToTheDOM();
17
+ return ()=>observer.disconnect();
18
+ }, [
19
+ ref
20
+ ]);
21
+ }
22
+
23
+ //# sourceMappingURL=useResizeObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useResizeObserver.ts"],"sourcesContent":["import * as React from 'react';\nimport { CustomResizeObserver } from '../lib/floating/customResizeObserver';\nimport { useIsomorphicLayoutEffect } from '../lib/useIsomorphicLayoutEffect';\nimport { useStableCallback } from './useStableCallback';\n\n/**\n * Хук вызывает переданный коллбэк при изменении размеров элемента.\n */\nexport function useResizeObserver(\n ref: React.MutableRefObject<HTMLElement | null>,\n callback: (element: HTMLElement) => void,\n) {\n const stableCallback = useStableCallback(callback);\n\n useIsomorphicLayoutEffect(\n function addResizeObserverHandler() {\n /* istanbul ignore if: невозможный кейс (в SSR вызова этой функции не будет) */\n if (!ref.current) {\n return;\n }\n const element = ref.current;\n const observer = new CustomResizeObserver(() => stableCallback(element));\n observer.observe(element);\n observer.appendToTheDOM();\n\n return () => observer.disconnect();\n },\n [ref],\n );\n}\n"],"names":["React","CustomResizeObserver","useIsomorphicLayoutEffect","useStableCallback","useResizeObserver","ref","callback","stableCallback","addResizeObserverHandler","current","element","observer","observe","appendToTheDOM","disconnect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,uCAAuC;AAC5E,SAASC,yBAAyB,QAAQ,mCAAmC;AAC7E,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD;;CAEC,GACD,OAAO,SAASC,kBACdC,GAA+C,EAC/CC,QAAwC;IAExC,MAAMC,iBAAiBJ,kBAAkBG;IAEzCJ,0BACE,SAASM;QACP,6EAA6E,GAC7E,IAAI,CAACH,IAAII,OAAO,EAAE;YAChB;QACF;QACA,MAAMC,UAAUL,IAAII,OAAO;QAC3B,MAAME,WAAW,IAAIV,qBAAqB,IAAMM,eAAeG;QAC/DC,SAASC,OAAO,CAACF;QACjBC,SAASE,cAAc;QAEvB,OAAO,IAAMF,SAASG,UAAU;IAClC,GACA;QAACT;KAAI;AAET"}
@@ -1 +1 @@
1
- {"version":3,"file":"customResizeObserver.d.ts","sourceRoot":"","sources":["../../../../src/lib/floating/customResizeObserver.ts"],"names":[],"mappings":"AA6BA,qBAAa,oBAAoB;IAOnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAN3C,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,WAAW,CAAC;QACpB,MAAM,EAAE,iBAAiB,CAAC;KAC3B,CAAC,CAAM;IACR,wBAAwB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;gBAE5B,cAAc,EAAE,MAAM,IAAI;IAIvD,OAAO,CAAC,OAAO,EAAE,WAAW;IAO5B,cAAc;IAYd,kBAAkB,CAAC,OAAO,EAAE,WAAW;IAUvC,4BAA4B,CAAC,OAAO,EAAE,WAAW;IAWjD,UAAU;CAeX"}
1
+ {"version":3,"file":"customResizeObserver.d.ts","sourceRoot":"","sources":["../../../../src/lib/floating/customResizeObserver.ts"],"names":[],"mappings":"AAsCA,qBAAa,oBAAoB;IAOnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAN3C,OAAO,EAAE,KAAK,CAAC;QACb,MAAM,EAAE,WAAW,CAAC;QACpB,MAAM,EAAE,iBAAiB,CAAC;KAC3B,CAAC,CAAM;IACR,wBAAwB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;gBAE5B,cAAc,EAAE,MAAM,IAAI;IAIvD,OAAO,CAAC,OAAO,EAAE,WAAW;IAO5B,cAAc;IAYd,kBAAkB,CAAC,OAAO,EAAE,WAAW;IAUvC,4BAA4B,CAAC,OAAO,EAAE,WAAW;IAWjD,UAAU;CAeX"}
@@ -6,7 +6,8 @@ const defaultIframeStyles = {
6
6
  width: '100%',
7
7
  height: '100%',
8
8
  pointerEvents: 'none',
9
- opacity: '0'
9
+ opacity: '0',
10
+ border: '0'
10
11
  };
11
12
  /*
12
13
  * Специальный CustomResizeObserver как fallback для ResizeObserver