@skbkontur/react-ui 4.6.0 → 4.7.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 (155) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/cjs/components/ComboBox/ComboBox.d.ts +15 -0
  3. package/cjs/components/ComboBox/ComboBox.js +16 -0
  4. package/cjs/components/ComboBox/ComboBox.js.map +1 -1
  5. package/cjs/components/ComboBox/ComboBox.md +10 -1
  6. package/cjs/components/DropdownMenu/DropdownMenu.md +11 -9
  7. package/cjs/components/FileUploader/FileUploader.d.ts +9 -1
  8. package/cjs/components/FileUploader/FileUploader.js +67 -18
  9. package/cjs/components/FileUploader/FileUploader.js.map +1 -1
  10. package/cjs/components/FileUploader/FileUploader.mixins.d.ts +1 -0
  11. package/cjs/components/FileUploader/FileUploader.mixins.js +10 -0
  12. package/cjs/components/FileUploader/FileUploader.mixins.js.map +1 -0
  13. package/cjs/components/FileUploader/FileUploader.styles.d.ts +12 -1
  14. package/cjs/components/FileUploader/FileUploader.styles.js +119 -22
  15. package/cjs/components/FileUploader/FileUploader.styles.js.map +1 -1
  16. package/cjs/components/Hint/Hint.d.ts +1 -0
  17. package/cjs/components/Hint/Hint.js +6 -2
  18. package/cjs/components/Hint/Hint.js.map +1 -1
  19. package/cjs/components/Paging/Paging.js +20 -15
  20. package/cjs/components/Paging/Paging.js.map +1 -1
  21. package/cjs/components/Paging/Paging.md +13 -0
  22. package/cjs/components/Paging/Paging.styles.d.ts +6 -2
  23. package/cjs/components/Paging/Paging.styles.js +40 -15
  24. package/cjs/components/Paging/Paging.styles.js.map +1 -1
  25. package/cjs/components/Select/Select.js +5 -3
  26. package/cjs/components/Select/Select.js.map +1 -1
  27. package/cjs/components/SidePage/SidePage.d.ts +0 -1
  28. package/cjs/components/SidePage/SidePage.js +0 -2
  29. package/cjs/components/SidePage/SidePage.js.map +1 -1
  30. package/cjs/components/SidePage/SidePageBody.d.ts +0 -1
  31. package/cjs/components/SidePage/SidePageBody.js +6 -11
  32. package/cjs/components/SidePage/SidePageBody.js.map +1 -1
  33. package/cjs/components/Toggle/Toggle.js +2 -1
  34. package/cjs/components/Toggle/Toggle.js.map +1 -1
  35. package/cjs/internal/CustomComboBox/ComboBoxMenu.d.ts +1 -0
  36. package/cjs/internal/CustomComboBox/ComboBoxMenu.js +3 -1
  37. package/cjs/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
  38. package/cjs/internal/CustomComboBox/ComboBoxView.d.ts +1 -0
  39. package/cjs/internal/CustomComboBox/ComboBoxView.js +3 -1
  40. package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
  41. package/cjs/internal/CustomComboBox/CustomComboBox.d.ts +1 -0
  42. package/cjs/internal/CustomComboBox/CustomComboBox.js +3 -1
  43. package/cjs/internal/CustomComboBox/CustomComboBox.js.map +1 -1
  44. package/cjs/internal/CustomComboBox/CustomComboBoxReducer.js +4 -1
  45. package/cjs/internal/CustomComboBox/CustomComboBoxReducer.js.map +1 -1
  46. package/cjs/internal/FileUploaderControl/FileUploaderControlContext.d.ts +2 -0
  47. package/cjs/internal/FileUploaderControl/FileUploaderControlContext.js +2 -0
  48. package/cjs/internal/FileUploaderControl/FileUploaderControlContext.js.map +1 -1
  49. package/cjs/internal/FileUploaderControl/FileUploaderControlProvider.js +4 -1
  50. package/cjs/internal/FileUploaderControl/FileUploaderControlProvider.js.map +1 -1
  51. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.d.ts +3 -0
  52. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js +46 -11
  53. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.js.map +1 -1
  54. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles.d.ts +7 -0
  55. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles.js +54 -7
  56. package/cjs/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles.js.map +1 -1
  57. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.d.ts +2 -0
  58. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.js +15 -3
  59. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.js.map +1 -1
  60. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles.d.ts +3 -0
  61. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles.js +19 -1
  62. package/cjs/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles.js.map +1 -1
  63. package/cjs/internal/FileUploaderControl/hooks/useFileUploaderSize.d.ts +2 -0
  64. package/cjs/internal/FileUploaderControl/hooks/useFileUploaderSize.js +18 -0
  65. package/cjs/internal/FileUploaderControl/hooks/useFileUploaderSize.js.map +1 -0
  66. package/cjs/internal/Popup/Popup.d.ts +5 -0
  67. package/cjs/internal/Popup/Popup.js +10 -2
  68. package/cjs/internal/Popup/Popup.js.map +1 -1
  69. package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  70. package/cjs/internal/themes/DarkTheme.d.ts +1 -0
  71. package/cjs/internal/themes/DarkTheme.js +2 -1
  72. package/cjs/internal/themes/DarkTheme.js.map +1 -1
  73. package/cjs/internal/themes/DefaultTheme.d.ts +16 -0
  74. package/cjs/internal/themes/DefaultTheme.js +41 -1
  75. package/cjs/internal/themes/DefaultTheme.js.map +1 -1
  76. package/cjs/lib/utils.d.ts +2 -3
  77. package/cjs/lib/utils.js +1 -2
  78. package/cjs/lib/utils.js.map +1 -1
  79. package/components/ComboBox/ComboBox/ComboBox.js.map +1 -1
  80. package/components/ComboBox/ComboBox.d.ts +15 -0
  81. package/components/ComboBox/ComboBox.md +10 -1
  82. package/components/DropdownMenu/DropdownMenu.md +11 -9
  83. package/components/FileUploader/FileUploader/FileUploader.js +56 -20
  84. package/components/FileUploader/FileUploader/FileUploader.js.map +1 -1
  85. package/components/FileUploader/FileUploader.d.ts +9 -1
  86. package/components/FileUploader/FileUploader.mixins/FileUploader.mixins.js +8 -0
  87. package/components/FileUploader/FileUploader.mixins/FileUploader.mixins.js.map +1 -0
  88. package/components/FileUploader/FileUploader.mixins/package.json +6 -0
  89. package/components/FileUploader/FileUploader.mixins.d.ts +1 -0
  90. package/components/FileUploader/FileUploader.styles/FileUploader.styles.js +51 -17
  91. package/components/FileUploader/FileUploader.styles/FileUploader.styles.js.map +1 -1
  92. package/components/FileUploader/FileUploader.styles.d.ts +12 -1
  93. package/components/Hint/Hint/Hint.js +13 -5
  94. package/components/Hint/Hint/Hint.js.map +1 -1
  95. package/components/Hint/Hint.d.ts +1 -0
  96. package/components/Paging/Paging/Paging.js +12 -9
  97. package/components/Paging/Paging/Paging.js.map +1 -1
  98. package/components/Paging/Paging.md +13 -0
  99. package/components/Paging/Paging.styles/Paging.styles.js +27 -15
  100. package/components/Paging/Paging.styles/Paging.styles.js.map +1 -1
  101. package/components/Paging/Paging.styles.d.ts +6 -2
  102. package/components/Select/Select/Select.js +5 -5
  103. package/components/Select/Select/Select.js.map +1 -1
  104. package/components/SidePage/SidePage/SidePage.js +0 -1
  105. package/components/SidePage/SidePage/SidePage.js.map +1 -1
  106. package/components/SidePage/SidePage.d.ts +0 -1
  107. package/components/SidePage/SidePageBody/SidePageBody.js +1 -9
  108. package/components/SidePage/SidePageBody/SidePageBody.js.map +1 -1
  109. package/components/SidePage/SidePageBody.d.ts +0 -1
  110. package/components/Toggle/Toggle/Toggle.js +2 -1
  111. package/components/Toggle/Toggle/Toggle.js.map +1 -1
  112. package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js +3 -1
  113. package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js.map +1 -1
  114. package/internal/CustomComboBox/ComboBoxMenu.d.ts +1 -0
  115. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +3 -1
  116. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
  117. package/internal/CustomComboBox/ComboBoxView.d.ts +1 -0
  118. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js +1 -0
  119. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js.map +1 -1
  120. package/internal/CustomComboBox/CustomComboBox.d.ts +1 -0
  121. package/internal/CustomComboBox/CustomComboBoxReducer/CustomComboBoxReducer.js +5 -1
  122. package/internal/CustomComboBox/CustomComboBoxReducer/CustomComboBoxReducer.js.map +1 -1
  123. package/internal/FileUploaderControl/FileUploaderControlContext/FileUploaderControlContext.js.map +1 -1
  124. package/internal/FileUploaderControl/FileUploaderControlContext.d.ts +2 -0
  125. package/internal/FileUploaderControl/FileUploaderControlProvider/FileUploaderControlProvider.js +7 -1
  126. package/internal/FileUploaderControl/FileUploaderControlProvider/FileUploaderControlProvider.js.map +1 -1
  127. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js +38 -13
  128. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile/FileUploaderFile.js.map +1 -1
  129. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.d.ts +3 -0
  130. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles/FileUploaderFile.styles.js +26 -5
  131. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles/FileUploaderFile.styles.js.map +1 -1
  132. package/internal/FileUploaderControl/FileUploaderFile/FileUploaderFile.styles.d.ts +7 -0
  133. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList/FileUploaderFileList.js +13 -3
  134. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList/FileUploaderFileList.js.map +1 -1
  135. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.d.ts +2 -0
  136. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles/FileUploaderFileList.styles.js +10 -1
  137. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles/FileUploaderFileList.styles.js.map +1 -1
  138. package/internal/FileUploaderControl/FileUploaderFileList/FileUploaderFileList.styles.d.ts +3 -0
  139. package/internal/FileUploaderControl/hooks/useFileUploaderSize/package.json +6 -0
  140. package/internal/FileUploaderControl/hooks/useFileUploaderSize/useFileUploaderSize.js +21 -0
  141. package/internal/FileUploaderControl/hooks/useFileUploaderSize/useFileUploaderSize.js.map +1 -0
  142. package/internal/FileUploaderControl/hooks/useFileUploaderSize.d.ts +2 -0
  143. package/internal/Popup/Popup/Popup.js +5 -1
  144. package/internal/Popup/Popup/Popup.js.map +1 -1
  145. package/internal/Popup/Popup.d.ts +5 -0
  146. package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  147. package/internal/themes/DarkTheme/DarkTheme.js +1 -0
  148. package/internal/themes/DarkTheme/DarkTheme.js.map +1 -1
  149. package/internal/themes/DarkTheme.d.ts +1 -0
  150. package/internal/themes/DefaultTheme/DefaultTheme.js +64 -0
  151. package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
  152. package/internal/themes/DefaultTheme.d.ts +16 -0
  153. package/lib/utils/utils.js.map +1 -1
  154. package/lib/utils.d.ts +2 -3
  155. package/package.json +2 -2
@@ -496,6 +496,7 @@ export declare class DefaultTheme {
496
496
  static pagingDotsColor: string;
497
497
  static pagingDotsPadding: string;
498
498
  static pagingPageLinkActiveBg: string;
499
+ static pagingPageLinkDisabledActiveBg: string;
499
500
  static get pagingPageLinkActiveColor(): string;
500
501
  static pagingPageLinkHoverBg: string;
501
502
  static pagingPageLinkBorderRadius: string;
@@ -854,7 +855,19 @@ export declare class DefaultTheme {
854
855
  static fileUploaderWidth: string;
855
856
  static fileUploaderBg: string;
856
857
  static get fileUploaderFontSize(): string;
858
+ static get fileUploaderPaddingXSmall(): string;
859
+ static get fileUploaderPaddingXMedium(): string;
860
+ static get fileUploaderPaddingXLarge(): string;
861
+ static get fileUploaderFontSizeSmall(): string;
862
+ static get fileUploaderFontSizeMedium(): string;
863
+ static get fileUploaderFontSizeLarge(): string;
857
864
  static get fileUploaderLineHeight(): string;
865
+ static get fileUploaderLineHeightSmall(): string;
866
+ static get fileUploaderLineHeightMedium(): string;
867
+ static get fileUploaderLineHeightLarge(): string;
868
+ static get fileUploaderPaddingYSmall(): string;
869
+ static get fileUploaderPaddingYMedium(): string;
870
+ static get fileUploaderPaddingYLarge(): string;
858
871
  static get fileUploaderTextColorDefault(): string;
859
872
  static fileUploaderPaddingX: string;
860
873
  static get fileUploaderPaddingY(): string;
@@ -876,5 +889,8 @@ export declare class DefaultTheme {
876
889
  static fileUploaderDisabledIconColor: string;
877
890
  static get fileUploaderLinkHoverTextDecoration(): string;
878
891
  static fileUploaderHoveredBg: string;
892
+ static fileUploaderIconGapSmall: string;
893
+ static fileUploaderIconGapMedium: string;
894
+ static fileUploaderIconGapLarge: string;
879
895
  }
880
896
  export declare const DefaultThemeInternal: typeof DefaultTheme;
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["React","isForwardRef","isBrowser","delay","ms","Promise","resolve","setTimeout","emptyHandler","CancelationError","code","Error","taskWithDelay","task","cancelationToken","reject","then","isFunction","x","isFunctionalComponent","Component","Boolean","prototype","isReactComponent","isClassComponent","isIntrinsicElement","element","type","isRefableElement","escapeRegExpSpecChars","s","replace","getRandomID","Math","random","toString","slice","isExternalLink","link","RegExp","window","location","host","test","isReactUINode","componentName","node","isValidElement","Object","hasOwnProperty","call","__KONTUR_REACT_UI__","KB","UNITS","calculateDecimals","decimals","formatBytes","bytes","calculatedDecimals","i","floor","log2","formattedBytes","parseFloat","pow","toFixed","isNonNullable","value","undefined","isNullable","isReactUIComponent","name","child","mergeRefs","refs","forEach","ref","current","extractDataProps","props","dataProps","restWithoutDataProps","entries","map","startsWith","startsWithOneOf","searchKeys","inputString","keyIndex","findIndex","key"],"mappings":";AACA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,QAA6B,UAA7B;;AAEA,SAASC,SAAT,QAA0B,UAA1B;;AAEA;;;;;;;;;;;;;AAaA,OAAO,IAA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AACC,UAAD,EAAuBC,WAAvB,EAA+C;AAC5E,MAAMC,QAAQ,GAAGF,UAAU,CAACG,SAAX,CAAqB,UAACC,GAAD,EAAS;AAC7C,WAAOH,WAAW,CAACH,UAAZ,CAAuBM,GAAvB,CAAP;AACD,GAFgB,CAAjB;;AAIA,SAAOF,QAAQ,IAAI,CAAnB;AACD,CANM","sourcesContent":["import { ReactComponentLike } from 'prop-types';\nimport React from 'react';\nimport { isForwardRef } from 'react-is';\n\nimport { isBrowser } from './client';\n\n// NOTE: Copy-paste from @types/react\nexport type Defaultize<P, D> = P extends any\n ? string extends keyof P\n ? P\n : Pick<P, Exclude<keyof P, keyof D>> &\n Partial<Pick<P, Extract<keyof P, keyof D>>> &\n Partial<Pick<D, Exclude<keyof D, keyof P>>>\n : never;\n\nexport type DefaultizeProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;\n\nexport type AnyObject = Record<string, unknown>;\n\nexport const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport const emptyHandler = () => {\n /* noop */\n};\n\nexport class CancelationError extends Error {\n public code = 'CancelationError';\n}\n\nexport function taskWithDelay(task: () => void, ms: number) {\n let cancelationToken: () => void = () => null;\n\n new Promise((resolve, reject) => {\n cancelationToken = reject;\n setTimeout(resolve, ms);\n })\n .then(task)\n .catch(() => null);\n\n return cancelationToken;\n}\n\nexport type FunctionWithParams<R = any> = (...args: any[]) => R;\nexport function isFunction<T>(x: T | FunctionWithParams): x is FunctionWithParams {\n return typeof x === 'function';\n}\n\nexport function isFunctionalComponent(Component: ReactComponentLike): boolean {\n return Boolean(typeof Component === 'function' && !(Component.prototype && Component.prototype.isReactComponent));\n}\n\nexport function isClassComponent(Component: ReactComponentLike): boolean {\n return Boolean(typeof Component === 'function' && Component.prototype && Component.prototype.isReactComponent);\n}\n\nexport function isIntrinsicElement(element: React.ReactElement): boolean {\n return typeof element.type === 'string';\n}\n\nexport function isRefableElement(element: React.ReactElement): boolean {\n return Boolean(isIntrinsicElement(element) || isClassComponent(element.type) || isForwardRef(element));\n}\n\nexport function escapeRegExpSpecChars(s: string): string {\n return s.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n\nexport const getRandomID = (): string => Math.random().toString(16).slice(2);\n\nexport const isExternalLink = (link: string): boolean => {\n return new RegExp(`^(https?:)?//${isBrowser ? `(?!${window.location.host})` : ``}\\\\S+`, 'gi').test(link);\n};\n\n/**\n * Check if the given ReactNode is an element of the specified ReactUI component\n */\nexport const isReactUINode = (componentName: string, node: React.ReactNode): boolean => {\n if (React.isValidElement(node)) {\n return (\n Object.prototype.hasOwnProperty.call(node.type, '__KONTUR_REACT_UI__') &&\n // @ts-expect-error: React doesn't know about existence of __KONTUR_REACT_UI__.\n node.type.__KONTUR_REACT_UI__ === componentName\n );\n }\n\n return false;\n};\n\nconst KB = 1024;\nconst UNITS = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\nconst calculateDecimals = (decimals: number) => {\n if (decimals < 0) {\n return 0;\n }\n\n return 0;\n};\n\nexport const formatBytes = (bytes: number, decimals = 2): string | null => {\n if (bytes === 0) {\n return '0 Bytes';\n }\n\n if (!bytes) {\n return null;\n }\n\n const calculatedDecimals = calculateDecimals(decimals);\n\n const i = Math.floor(Math.log2(bytes) / Math.log2(KB));\n const formattedBytes = parseFloat((bytes / Math.pow(KB, i)).toFixed(calculatedDecimals));\n\n return `${formattedBytes} ${UNITS[i]}`;\n};\n\n/**\n * Проверяет, не является ли переданный аргумент null или undefined и исключает типы null и undefined из типа аргумента\n *\n * @param value Значение, которое нужно проверить и исключить из него типы\n * @returns Возвращает true, если переданный аргумент не является null или undefined иначе false\n */\nexport const isNonNullable = <T>(value: T): value is NonNullable<T> => {\n return value !== null && value !== undefined;\n};\n\n/**\n * Checks if the value `null` or `undefined`.\n *\n * @param value Value to check for `null` and `undefined`.\n * @returns Returns `true` if `value` is `null` or `undefined`, else `false`.\n */\nexport const isNullable = (value: unknown): value is null | undefined => {\n return value === null || value === undefined;\n};\n\n/**\n * Creates a function that checks if the given `child`\n * is an instance of some component specified by `name`.\n *\n * @param name Component name for which function will be created.\n * @returns A function that checks if the given `child` is an instance of the component specified by `name`.\n */\nexport const isReactUIComponent = <P = any>(name: string) => {\n return (child: React.ReactNode): child is React.ReactElement<P> => {\n // @ts-expect-error: Property `type` doesn't exist on type `React.ReactNode`, but exists on type `React.ReactElement` meanwhile `React.ReactElement` is not compatible with `React` `children` type.\n return child?.type?.__KONTUR_REACT_UI__ === name;\n };\n};\n\n/**\n * Merges two or more refs into one.\n *\n * @param refs Array of refs.\n * @returns A single ref composing all the refs passed.\n *\n * @example\n * const SomeComponent = forwardRef((props, ref) => {\n * const localRef = useRef();\n *\n * return <div ref={mergeRefs([localRef, ref])} />;\n * });\n */\nexport function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (isNonNullable(ref)) {\n return ((ref as React.MutableRefObject<T | null>).current = value);\n }\n });\n };\n}\n\n/**\n * Extracts all data attributes from props and returns them as well as props.\n *\n * @param props Props object to extract data attributes from.\n * @returns Separated data attributes and all other props.\n */\nexport const extractDataProps = <T>(props: T) => {\n const dataProps: Record<string, any> = {};\n const restWithoutDataProps: Record<string, any> = {};\n\n Object.entries(props).map(([name, value]) => {\n if (name.startsWith('data-')) {\n return (dataProps[name] = value);\n }\n\n return (restWithoutDataProps[name] = value);\n });\n\n return { dataProps, restWithoutDataProps };\n};\n\n/**\n * Basically `.startsWith` for arrays.\n *\n * @param searchKeys Array of strings to test against `inputString`.\n * @param inputString String on which search will be performed.\n * @returns `true` if `inputString` starts with one of keys, else `false`.\n */\nexport const startsWithOneOf = (searchKeys: string[], inputString: string) => {\n const keyIndex = searchKeys.findIndex((key) => {\n return inputString.startsWith(key);\n });\n\n return keyIndex >= 0;\n};\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["React","isForwardRef","isBrowser","delay","ms","Promise","resolve","setTimeout","emptyHandler","CancelationError","code","Error","taskWithDelay","task","cancelationToken","reject","then","isFunction","x","isFunctionalComponent","Component","Boolean","prototype","isReactComponent","isClassComponent","isIntrinsicElement","element","type","isRefableElement","escapeRegExpSpecChars","s","replace","getRandomID","Math","random","toString","slice","isExternalLink","link","RegExp","window","location","host","test","isReactUINode","componentName","node","isValidElement","Object","hasOwnProperty","call","__KONTUR_REACT_UI__","KB","UNITS","calculateDecimals","decimals","formatBytes","bytes","calculatedDecimals","i","floor","log2","formattedBytes","parseFloat","pow","toFixed","isNonNullable","value","undefined","isNullable","isReactUIComponent","name","child","mergeRefs","refs","forEach","ref","current","extractDataProps","props","dataProps","restWithoutDataProps","entries","map","startsWith","startsWithOneOf","searchKeys","inputString","keyIndex","findIndex","key"],"mappings":"gJAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,YAAT,QAA6B,UAA7B;;AAEA,SAASC,SAAT,QAA0B,UAA1B;;AAEA;;;;;;;;;;;;;AAaA,OAAO,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAACC,EAAD,UAAgB,IAAIC,OAAJ,CAAY,UAACC,OAAD,UAAaC,UAAU,CAACD,OAAD,EAAUF,EAAV,CAAvB,EAAZ,CAAhB,EAAd;;AAEP,OAAO,IAAMI,YAAY,GAAG,SAAfA,YAAe,GAAM;AAChC;AACD,CAFM;;AAIP,WAAaC,gBAAb;AACSC,IAAAA,IADT,GACgB,kBADhB,wEAAsCC,KAAtC;;;AAIA,OAAO,SAASC,aAAT,CAAuBC,IAAvB,EAAyCT,EAAzC,EAAqD;AAC1D,MAAIU,gBAA4B,GAAG,oCAAM,IAAN,EAAnC;;AAEA,MAAIT,OAAJ,CAAY,UAACC,OAAD,EAAUS,MAAV,EAAqB;AAC/BD,IAAAA,gBAAgB,GAAGC,MAAnB;AACAR,IAAAA,UAAU,CAACD,OAAD,EAAUF,EAAV,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OAA1C,GAAoDV,KAA5D;AACD;AACF,KAND;AAOD,GARD;AASD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMW,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAIC,KAAJ,EAAiB;AAC/C,MAAMC,SAA8B,GAAG,EAAvC;AACA,MAAMC,oBAAyC,GAAG,EAAlD;;AAEAjC,EAAAA,MAAM,CAACkC,OAAP,CAAeH,KAAf,EAAsBI,GAAtB,CAA0B,gBAAmB,KAAjBZ,IAAiB,WAAXJ,KAAW;AAC3C,QAAII,IAAI,CAACa,UAAL,CAAgB,OAAhB,CAAJ,EAA8B;AAC5B,aAAQJ,SAAS,CAACT,IAAD,CAAT,GAAkBJ,KAA1B;AACD;;AAED,WAAQc,oBAAoB,CAACV,IAAD,CAApB,GAA6BJ,KAArC;AACD,GAND;;AAQA,SAAO,EAAEa,SAAS,EAATA,SAAF,EAAaC,oBAAoB,EAApBA,oBAAb,EAAP;AACD,CAbM;;AAeP;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMI,eAAe,GAAG,SAAlBA,eAAkB,CAACC,UAAD,EAAuBC,WAAvB,EAA+C;AAC5E,MAAMC,QAAQ,GAAGF,UAAU,CAACG,SAAX,CAAqB,UAACC,GAAD,EAAS;AAC7C,WAAOH,WAAW,CAACH,UAAZ,CAAuBM,GAAvB,CAAP;AACD,GAFgB,CAAjB;;AAIA,SAAOF,QAAQ,IAAI,CAAnB;AACD,CANM","sourcesContent":["import React from 'react';\nimport { isForwardRef } from 'react-is';\n\nimport { isBrowser } from './client';\n\n// NOTE: Copy-paste from @types/react\nexport type Defaultize<P, D> = P extends any\n ? string extends keyof P\n ? P\n : Pick<P, Exclude<keyof P, keyof D>> &\n Partial<Pick<P, Extract<keyof P, keyof D>>> &\n Partial<Pick<D, Exclude<keyof D, keyof P>>>\n : never;\n\nexport type DefaultizeProps<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D> : P;\n\nexport type AnyObject = Record<string, unknown>;\n\nexport const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport const emptyHandler = () => {\n /* noop */\n};\n\nexport class CancelationError extends Error {\n public code = 'CancelationError';\n}\n\nexport function taskWithDelay(task: () => void, ms: number) {\n let cancelationToken: () => void = () => null;\n\n new Promise((resolve, reject) => {\n cancelationToken = reject;\n setTimeout(resolve, ms);\n })\n .then(task)\n .catch(() => null);\n\n return cancelationToken;\n}\n\nexport type FunctionWithParams<R = any> = (...args: any[]) => R;\nexport function isFunction<T>(x: T | FunctionWithParams): x is FunctionWithParams {\n return typeof x === 'function';\n}\n\nexport function isFunctionalComponent(Component: unknown): Component is React.ComponentType {\n return Boolean(typeof Component === 'function' && !(Component.prototype && Component.prototype.isReactComponent));\n}\n\nexport function isClassComponent(Component: unknown): Component is React.ComponentType {\n return Boolean(typeof Component === 'function' && Component.prototype && Component.prototype.isReactComponent);\n}\n\nexport function isIntrinsicElement(element: React.ReactElement): boolean {\n return typeof element.type === 'string';\n}\n\nexport function isRefableElement(element: React.ReactElement): boolean {\n return Boolean(isIntrinsicElement(element) || isClassComponent(element.type) || isForwardRef(element));\n}\n\nexport function escapeRegExpSpecChars(s: string): string {\n return s.replace(/[\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n\nexport const getRandomID = (): string => Math.random().toString(16).slice(2);\n\nexport const isExternalLink = (link: string): boolean => {\n return new RegExp(`^(https?:)?//${isBrowser ? `(?!${window.location.host})` : ``}\\\\S+`, 'gi').test(link);\n};\n\n/**\n * Check if the given ReactNode is an element of the specified ReactUI component\n */\nexport const isReactUINode = (componentName: string, node: React.ReactNode): boolean => {\n if (React.isValidElement(node)) {\n return (\n Object.prototype.hasOwnProperty.call(node.type, '__KONTUR_REACT_UI__') &&\n // @ts-expect-error: React doesn't know about existence of __KONTUR_REACT_UI__.\n node.type.__KONTUR_REACT_UI__ === componentName\n );\n }\n\n return false;\n};\n\nconst KB = 1024;\nconst UNITS = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\nconst calculateDecimals = (decimals: number) => {\n if (decimals < 0) {\n return 0;\n }\n\n return 0;\n};\n\nexport const formatBytes = (bytes: number, decimals = 2): string | null => {\n if (bytes === 0) {\n return '0 Bytes';\n }\n\n if (!bytes) {\n return null;\n }\n\n const calculatedDecimals = calculateDecimals(decimals);\n\n const i = Math.floor(Math.log2(bytes) / Math.log2(KB));\n const formattedBytes = parseFloat((bytes / Math.pow(KB, i)).toFixed(calculatedDecimals));\n\n return `${formattedBytes} ${UNITS[i]}`;\n};\n\n/**\n * Проверяет, не является ли переданный аргумент null или undefined и исключает типы null и undefined из типа аргумента\n *\n * @param value Значение, которое нужно проверить и исключить из него типы\n * @returns Возвращает true, если переданный аргумент не является null или undefined иначе false\n */\nexport const isNonNullable = <T>(value: T): value is NonNullable<T> => {\n return value !== null && value !== undefined;\n};\n\n/**\n * Checks if the value `null` or `undefined`.\n *\n * @param value Value to check for `null` and `undefined`.\n * @returns Returns `true` if `value` is `null` or `undefined`, else `false`.\n */\nexport const isNullable = (value: unknown): value is null | undefined => {\n return value === null || value === undefined;\n};\n\n/**\n * Creates a function that checks if the given `child`\n * is an instance of some component specified by `name`.\n *\n * @param name Component name for which function will be created.\n * @returns A function that checks if the given `child` is an instance of the component specified by `name`.\n */\nexport const isReactUIComponent = <P = any>(name: string) => {\n return (child: React.ReactNode): child is React.ReactElement<P> => {\n // @ts-expect-error: Property `type` doesn't exist on type `React.ReactNode`, but exists on type `React.ReactElement` meanwhile `React.ReactElement` is not compatible with `React` `children` type.\n return child?.type?.__KONTUR_REACT_UI__ === name;\n };\n};\n\n/**\n * Merges two or more refs into one.\n *\n * @param refs Array of refs.\n * @returns A single ref composing all the refs passed.\n *\n * @example\n * const SomeComponent = forwardRef((props, ref) => {\n * const localRef = useRef();\n *\n * return <div ref={mergeRefs([localRef, ref])} />;\n * });\n */\nexport function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (isNonNullable(ref)) {\n return ((ref as React.MutableRefObject<T | null>).current = value);\n }\n });\n };\n}\n\n/**\n * Extracts all data attributes from props and returns them as well as props.\n *\n * @param props Props object to extract data attributes from.\n * @returns Separated data attributes and all other props.\n */\nexport const extractDataProps = <T>(props: T) => {\n const dataProps: Record<string, any> = {};\n const restWithoutDataProps: Record<string, any> = {};\n\n Object.entries(props).map(([name, value]) => {\n if (name.startsWith('data-')) {\n return (dataProps[name] = value);\n }\n\n return (restWithoutDataProps[name] = value);\n });\n\n return { dataProps, restWithoutDataProps };\n};\n\n/**\n * Basically `.startsWith` for arrays.\n *\n * @param searchKeys Array of strings to test against `inputString`.\n * @param inputString String on which search will be performed.\n * @returns `true` if `inputString` starts with one of keys, else `false`.\n */\nexport const startsWithOneOf = (searchKeys: string[], inputString: string) => {\n const keyIndex = searchKeys.findIndex((key) => {\n return inputString.startsWith(key);\n });\n\n return keyIndex >= 0;\n};\n"]}
package/lib/utils.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { ReactComponentLike } from 'prop-types';
2
1
  import React from 'react';
3
2
  export declare type Defaultize<P, D> = P extends any ? string extends keyof P ? P : Pick<P, Exclude<keyof P, keyof D>> & Partial<Pick<P, Extract<keyof P, keyof D>>> & Partial<Pick<D, Exclude<keyof D, keyof P>>> : never;
4
3
  export declare type DefaultizeProps<C, P> = C extends {
@@ -13,8 +12,8 @@ export declare class CancelationError extends Error {
13
12
  export declare function taskWithDelay(task: () => void, ms: number): () => void;
14
13
  export declare type FunctionWithParams<R = any> = (...args: any[]) => R;
15
14
  export declare function isFunction<T>(x: T | FunctionWithParams): x is FunctionWithParams;
16
- export declare function isFunctionalComponent(Component: ReactComponentLike): boolean;
17
- export declare function isClassComponent(Component: ReactComponentLike): boolean;
15
+ export declare function isFunctionalComponent(Component: unknown): Component is React.ComponentType;
16
+ export declare function isClassComponent(Component: unknown): Component is React.ComponentType;
18
17
  export declare function isIntrinsicElement(element: React.ReactElement): boolean;
19
18
  export declare function isRefableElement(element: React.ReactElement): boolean;
20
19
  export declare function escapeRegExpSpecChars(s: string): string;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@skbkontur/react-ui",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "UI Components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "index.js",
7
7
  "sideEffects": false,
8
- "homepage": "https://tech.skbkontur.ru/react-ui/4.6.0/",
8
+ "homepage": "https://tech.skbkontur.ru/react-ui/4.7.0/",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git@github.com:skbkontur/retail-ui.git"