@skbkontur/react-ui 6.1.3 → 6.1.4-4e59f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Group/Group.js +3 -2
- package/components/Group/Group.js.map +1 -1
- package/components/Input/Input.d.ts +1 -1
- package/components/Input/Input.js.map +1 -1
- package/components/TimePicker/TimeClockIcon.d.ts +3 -0
- package/components/TimePicker/TimeClockIcon.js +11 -0
- package/components/TimePicker/TimeClockIcon.js.map +1 -0
- package/components/TimePicker/TimePicker.d.ts +79 -0
- package/components/TimePicker/TimePicker.js +513 -0
- package/components/TimePicker/TimePicker.js.map +1 -0
- package/components/TimePicker/TimePicker.styles.d.ts +11 -0
- package/components/TimePicker/TimePicker.styles.js +36 -0
- package/components/TimePicker/TimePicker.styles.js.map +1 -0
- package/components/TimePicker/TimePickerItems.d.ts +17 -0
- package/components/TimePicker/TimePickerItems.js +80 -0
- package/components/TimePicker/TimePickerItems.js.map +1 -0
- package/components/TimePicker/TimePickerMobilePopup.d.ts +38 -0
- package/components/TimePicker/TimePickerMobilePopup.js +21 -0
- package/components/TimePicker/TimePickerMobilePopup.js.map +1 -0
- package/components/TimePicker/TimePickerPopup.d.ts +20 -0
- package/components/TimePicker/TimePickerPopup.js +18 -0
- package/components/TimePicker/TimePickerPopup.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.constants.d.ts +22 -0
- package/components/TimePicker/helpers/TimePicker.constants.js +31 -0
- package/components/TimePicker/helpers/TimePicker.constants.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.editing.d.ts +23 -0
- package/components/TimePicker/helpers/TimePicker.editing.js +101 -0
- package/components/TimePicker/helpers/TimePicker.editing.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.layout.d.ts +6 -0
- package/components/TimePicker/helpers/TimePicker.layout.js +49 -0
- package/components/TimePicker/helpers/TimePicker.layout.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.selection.d.ts +5 -0
- package/components/TimePicker/helpers/TimePicker.selection.js +23 -0
- package/components/TimePicker/helpers/TimePicker.selection.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.shared.d.ts +47 -0
- package/components/TimePicker/helpers/TimePicker.shared.js +70 -0
- package/components/TimePicker/helpers/TimePicker.shared.js.map +1 -0
- package/components/TimePicker/helpers/TimePicker.value.d.ts +30 -0
- package/components/TimePicker/helpers/TimePicker.value.js +96 -0
- package/components/TimePicker/helpers/TimePicker.value.js.map +1 -0
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.d.ts +4 -0
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.js +24 -0
- package/components/TimePicker/helpers/scrollSelectedItemIntoView.js.map +1 -0
- package/components/TimePicker/helpers/validateTimePicker.d.ts +8 -0
- package/components/TimePicker/helpers/validateTimePicker.js +16 -0
- package/components/TimePicker/helpers/validateTimePicker.js.map +1 -0
- package/components/TimePicker/hooks/useTimePickerDropdown.d.ts +17 -0
- package/components/TimePicker/hooks/useTimePickerDropdown.js +62 -0
- package/components/TimePicker/hooks/useTimePickerDropdown.js.map +1 -0
- package/components/TimePicker/hooks/useTimePickerSelection.d.ts +18 -0
- package/components/TimePicker/hooks/useTimePickerSelection.js +66 -0
- package/components/TimePicker/hooks/useTimePickerSelection.js.map +1 -0
- package/components/TimePicker/hooks/useTimePickerValue.d.ts +18 -0
- package/components/TimePicker/hooks/useTimePickerValue.js +59 -0
- package/components/TimePicker/hooks/useTimePickerValue.js.map +1 -0
- package/components/TimePicker/index.d.ts +2 -0
- package/components/TimePicker/index.js +2 -0
- package/components/TimePicker/index.js.map +1 -0
- package/components/TimePicker/locale/index.d.ts +4 -0
- package/components/TimePicker/locale/index.js +9 -0
- package/components/TimePicker/locale/index.js.map +1 -0
- package/components/TimePicker/locale/locales/en.d.ts +2 -0
- package/components/TimePicker/locale/locales/en.js +5 -0
- package/components/TimePicker/locale/locales/en.js.map +1 -0
- package/components/TimePicker/locale/locales/ru.d.ts +2 -0
- package/components/TimePicker/locale/locales/ru.js +5 -0
- package/components/TimePicker/locale/locales/ru.js.map +1 -0
- package/components/TimePicker/locale/types.d.ts +4 -0
- package/components/TimePicker/locale/types.js +2 -0
- package/components/TimePicker/locale/types.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/NativeTimeInput/NativeTimeInput.d.ts +16 -0
- package/internal/NativeTimeInput/NativeTimeInput.js +25 -0
- package/internal/NativeTimeInput/NativeTimeInput.js.map +1 -0
- package/internal/NativeTimeInput/NativeTimeInput.styles.d.ts +3 -0
- package/internal/NativeTimeInput/NativeTimeInput.styles.js +15 -0
- package/internal/NativeTimeInput/NativeTimeInput.styles.js.map +1 -0
- package/internal/NativeTimeInput/NativeTimeInput.utils.d.ts +7 -0
- package/internal/NativeTimeInput/NativeTimeInput.utils.js +28 -0
- package/internal/NativeTimeInput/NativeTimeInput.utils.js.map +1 -0
- package/internal/NativeTimeInput/index.d.ts +1 -0
- package/internal/NativeTimeInput/index.js +2 -0
- package/internal/NativeTimeInput/index.js.map +1 -0
- package/internal/TimeInput/TimeFragments.d.ts +15 -0
- package/internal/TimeInput/TimeFragments.js +72 -0
- package/internal/TimeInput/TimeFragments.js.map +1 -0
- package/internal/TimeInput/TimeFragments.styles.d.ts +12 -0
- package/internal/TimeInput/TimeFragments.styles.js +43 -0
- package/internal/TimeInput/TimeFragments.styles.js.map +1 -0
- package/internal/TimeInput/TimeInput.d.ts +22 -0
- package/internal/TimeInput/TimeInput.js +103 -0
- package/internal/TimeInput/TimeInput.js.map +1 -0
- package/internal/TimeInput/TimeInput.styles.d.ts +6 -0
- package/internal/TimeInput/TimeInput.styles.js +21 -0
- package/internal/TimeInput/TimeInput.styles.js.map +1 -0
- package/internal/TimeInput/index.d.ts +1 -0
- package/internal/TimeInput/index.js +2 -0
- package/internal/TimeInput/index.js.map +1 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.d.ts +2 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.js +20 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon16Light.js.map +1 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.d.ts +2 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.js +20 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon20Light.js.map +1 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.d.ts +2 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.js +20 -0
- package/internal/icons2022/TimeClockIcon/TimeClockIcon24Regular.js.map +1 -0
- package/internal/themes/BasicTheme.d.ts +34 -0
- package/internal/themes/BasicTheme.js +96 -0
- package/internal/themes/BasicTheme.js.map +1 -1
- package/lib/locale/types.d.ts +2 -0
- package/lib/locale/types.js.map +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +1 -0
- package/lib/utils.js.map +1 -1
- package/package.json +9 -1
package/lib/locale/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { PagingLocale } from '../../components/Paging/locale/index.js';
|
|
|
5
5
|
import type { PasswordInputLocale } from '../../components/PasswordInput/locale/index.js';
|
|
6
6
|
import type { SelectLocale } from '../../components/Select/locale/index.js';
|
|
7
7
|
import type { SidePageLocale } from '../../components/SidePage/locale/index.js';
|
|
8
|
+
import type { TimePickerLocale } from '../../components/TimePicker/locale/index.js';
|
|
8
9
|
import type { TokenLocale } from '../../components/Token/locale/index.js';
|
|
9
10
|
import type { TokenInputLocale } from '../../components/TokenInput/locale/index.js';
|
|
10
11
|
import type { ComboBoxLocale } from '../../internal/CustomComboBox/locale/index.js';
|
|
@@ -20,6 +21,7 @@ export interface LocaleControls {
|
|
|
20
21
|
FileUploader?: Partial<FileUploaderLocale>;
|
|
21
22
|
PasswordInput?: Partial<PasswordInputLocale>;
|
|
22
23
|
SidePage?: Partial<SidePageLocale>;
|
|
24
|
+
TimePicker?: Partial<TimePickerLocale>;
|
|
23
25
|
}
|
|
24
26
|
export declare enum LangCodes {
|
|
25
27
|
ru_RU = "ru_RU",
|
package/lib/locale/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;AACjB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB","sourcesContent":["import type { CalendarLocale } from '../../components/Calendar/locale/types.js';\nimport type { DatePickerLocale } from '../../components/DatePicker/locale/index.js';\nimport type { FileUploaderLocale } from '../../components/FileUploader/locale/index.js';\nimport type { PagingLocale } from '../../components/Paging/locale/index.js';\nimport type { PasswordInputLocale } from '../../components/PasswordInput/locale/index.js';\nimport type { SelectLocale } from '../../components/Select/locale/index.js';\nimport type { SidePageLocale } from '../../components/SidePage/locale/index.js';\nimport type { TimePickerLocale } from '../../components/TimePicker/locale/index.js';\nimport type { TokenLocale } from '../../components/Token/locale/index.js';\nimport type { TokenInputLocale } from '../../components/TokenInput/locale/index.js';\nimport type { ComboBoxLocale } from '../../internal/CustomComboBox/locale/index.js';\n\nexport interface LocaleControls {\n [key: string]: any;\n TokenInput?: Partial<TokenInputLocale>;\n Token?: Partial<TokenLocale>;\n ComboBox?: Partial<ComboBoxLocale>;\n Select?: Partial<SelectLocale>;\n Paging?: Partial<PagingLocale>;\n DatePicker?: Partial<DatePickerLocale>;\n Calendar?: Partial<CalendarLocale>;\n FileUploader?: Partial<FileUploaderLocale>;\n PasswordInput?: Partial<PasswordInputLocale>;\n SidePage?: Partial<SidePageLocale>;\n TimePicker?: Partial<TimePickerLocale>;\n}\n\nexport enum LangCodes {\n ru_RU = 'ru_RU',\n en_GB = 'en_GB',\n}\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { HintProps } from '../components/Hint/index.js';
|
|
|
9
9
|
import type { InputProps } from '../components/Input/index.js';
|
|
10
10
|
import type { PasswordInputProps } from '../components/PasswordInput/index.js';
|
|
11
11
|
import type { SelectProps } from '../components/Select/index.js';
|
|
12
|
+
import type { TimePickerProps } from '../components/TimePicker/index.js';
|
|
12
13
|
import type { TooltipProps } from '../components/Tooltip/index.js';
|
|
13
14
|
import type { GlobalObject } from '../lib/globalObject.js';
|
|
14
15
|
export { delay } from './delay.js';
|
|
@@ -97,6 +98,7 @@ export declare const isDropdown: (child: React.ReactNode) => child is React.Reac
|
|
|
97
98
|
export declare const isDropdownMenu: (child: React.ReactNode) => child is React.ReactElement<DropdownMenuProps, string | React.JSXElementConstructor<any>>;
|
|
98
99
|
export declare const isHint: (child: React.ReactNode) => child is React.ReactElement<HintProps, string | React.JSXElementConstructor<any>>;
|
|
99
100
|
export declare const isTooltip: (child: React.ReactNode) => child is React.ReactElement<TooltipProps, string | React.JSXElementConstructor<any>>;
|
|
101
|
+
export declare const isTimePicker: (child: React.ReactNode) => child is React.ReactElement<TimePickerProps, string | React.JSXElementConstructor<any>>;
|
|
100
102
|
export declare const isKonturIcon: (icon: React.ReactElement) => boolean;
|
|
101
103
|
export declare function clickOutside(eventType?: 'touchstart' | 'mousedown' | 'pointerup'): void;
|
|
102
104
|
export declare function isElement(el: unknown): el is Element;
|
package/lib/utils.js
CHANGED
|
@@ -180,6 +180,7 @@ export var isDropdown = isReactUIComponent('Dropdown');
|
|
|
180
180
|
export var isDropdownMenu = isReactUIComponent('DropdownMenu');
|
|
181
181
|
export var isHint = isReactUIComponent('Hint');
|
|
182
182
|
export var isTooltip = isReactUIComponent('Tooltip');
|
|
183
|
+
export var isTimePicker = isReactUIComponent('TimePicker');
|
|
183
184
|
export var isKonturIcon = function (icon) {
|
|
184
185
|
return Object.prototype.hasOwnProperty.call(icon === null || icon === void 0 ? void 0 : icon.type, '__KONTUR_ICON__');
|
|
185
186
|
};
|
package/lib/utils.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AAC;AAC7E,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,SAAiE;IAAjE,0BAAA,EAAA,uBAAiE;IAC5F,IAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACjD,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAW;IACnC,OAAO,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,UAAU,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,CAAC;AACjG,CAAC","sourcesContent":["import type React from 'react';\nimport { isValidElement } from 'react';\n\nimport type { AutocompleteProps } from '../components/Autocomplete/index.js';\nimport type { ButtonProps } from '../components/Button/index.js';\nimport type { CurrencyInputProps } from '../components/CurrencyInput/index.js';\nimport type { DropdownProps } from '../components/Dropdown/index.js';\nimport type { DropdownMenuProps } from '../components/DropdownMenu/index.js';\nimport type { FxInputProps } from '../components/FxInput/index.js';\nimport type { HintProps } from '../components/Hint/index.js';\nimport type { InputProps } from '../components/Input/index.js';\nimport type { PasswordInputProps } from '../components/PasswordInput/index.js';\nimport type { SelectProps } from '../components/Select/index.js';\nimport type { TooltipProps } from '../components/Tooltip/index.js';\nimport type { GlobalObject } from '../lib/globalObject.js';\nimport { isBrowser } from '../lib/globalObject.js';\nimport { isForwardRef, isMemo } from './react-is.js';\n\nexport { delay } from './delay.js';\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 type NoInfer<T> = T extends infer U ? U : never;\n\nexport const emptyHandler = (): void => {\n /* noop */\n};\n\nexport class CancelationError extends Error {\n public code = 'CancelationError';\n}\n\nexport function taskWithDelay(task: () => void, ms: number): () => void {\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;\n\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<unknown>): boolean {\n return typeof element.type === 'string';\n}\n\nexport function isRefableElement(element: React.ReactElement<unknown>): boolean {\n return (\n Boolean(isIntrinsicElement(element) || isClassComponent(element.type) || isForwardRef(element)) || isMemo(element)\n );\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, globalObject: GlobalObject): boolean => {\n return isBrowser(globalObject) && new RegExp(`^(https?:)?//(?!${globalObject.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 (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 * Checks if a component instance is a ReactUI component with the given name.\n *\n * @typeParam T Expected ReactUI component type.\n * @param instance Component instance.\n * @param componentName ReactUI component name.\n * @returns `true` if it matches, otherwise `false`.\n */\nexport const isReactUIInstance = <T extends React.Component>(\n instance: React.Component,\n componentName: string,\n): instance is T => {\n const constructor = instance?.constructor;\n return '__KONTUR_REACT_UI__' in constructor && constructor.__KONTUR_REACT_UI__ === componentName;\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 extends Record<string, unknown>>(\n props: T,\n): { dataProps: Record<string, unknown>; restWithoutDataProps: Record<string, unknown> } => {\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): boolean => {\n const keyIndex = searchKeys.findIndex((key) => {\n return inputString.startsWith(key);\n });\n\n return keyIndex >= 0;\n};\n\nexport const isButton = isReactUIComponent<ButtonProps>('Button');\nexport const isInput = isReactUIComponent<InputProps>('Input');\nexport const isFxInput = isReactUIComponent<FxInputProps>('FxInput');\nexport const isAutocomplete = isReactUIComponent<AutocompleteProps>('Autocomplete');\nexport const isPasswordInput = isReactUIComponent<PasswordInputProps>('PasswordInput');\nexport const isCurrencyInput = isReactUIComponent<CurrencyInputProps>('CurrencyInput');\nexport const isSelect = isReactUIComponent<SelectProps<unknown, unknown>>('Select');\nexport const isDropdown = isReactUIComponent<DropdownProps>('Dropdown');\nexport const isDropdownMenu = isReactUIComponent<DropdownMenuProps>('DropdownMenu');\nexport const isHint = isReactUIComponent<HintProps>('Hint');\nexport const isTooltip = isReactUIComponent<TooltipProps>('Tooltip');\n\nexport const isKonturIcon = (icon: React.ReactElement): boolean => {\n return Object.prototype.hasOwnProperty.call(icon?.type, '__KONTUR_ICON__');\n};\n\nexport function clickOutside(eventType: 'touchstart' | 'mousedown' | 'pointerup' = 'mousedown'): void {\n const event = document.createEvent('HTMLEvents');\n event.initEvent(eventType, true, true);\n document.body.dispatchEvent(event);\n}\n\nexport function isElement(el: unknown): el is Element {\n return !!el && typeof el === 'object' && 'nodeType' in el && el.nodeType === Node.ELEMENT_NODE;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAevC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBnC,MAAM,CAAC,IAAM,YAAY,GAAG;IAC1B,UAAU;AACZ,CAAC,CAAC;AAEF;IAAsC,oCAAK;IAA3C;;QACS,UAAI,GAAG,kBAAkB,CAAC;;IACnC,CAAC;IAAD,uBAAC;AAAD,CAAC,AAFD,CAAsC,KAAK,GAE1C;;AAED,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,EAAU;IACxD,IAAI,gBAAgB,GAAe,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;IAE9C,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;QAC1B,gBAAgB,GAAG,MAAM,CAAC;QAC1B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC;SACC,IAAI,CAAC,IAAI,CAAC;SACV,KAAK,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAC;IAErB,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAID,MAAM,UAAU,UAAU,CAAI,CAAyB;IACrD,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;AACjC,CAAC;AAED,M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AM,SAAS,GAAG,kBAAkB,CAAe,SAAS,CAAC,CAAC;AACrE,MAAM,CAAC,IAAM,YAAY,GAAG,kBAAkB,CAAkB,YAAY,CAAC,CAAC;AAE9E,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,IAAwB;IACnD,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAC7E,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,SAAiE;IAAjE,0BAAA,EAAA,uBAAiE;IAC5F,IAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IACjD,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAW;IACnC,OAAO,CAAC,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,UAAU,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,CAAC;AACjG,CAAC","sourcesContent":["import type React from 'react';\nimport { isValidElement } from 'react';\n\nimport type { AutocompleteProps } from '../components/Autocomplete/index.js';\nimport type { ButtonProps } from '../components/Button/index.js';\nimport type { CurrencyInputProps } from '../components/CurrencyInput/index.js';\nimport type { DropdownProps } from '../components/Dropdown/index.js';\nimport type { DropdownMenuProps } from '../components/DropdownMenu/index.js';\nimport type { FxInputProps } from '../components/FxInput/index.js';\nimport type { HintProps } from '../components/Hint/index.js';\nimport type { InputProps } from '../components/Input/index.js';\nimport type { PasswordInputProps } from '../components/PasswordInput/index.js';\nimport type { SelectProps } from '../components/Select/index.js';\nimport type { TimePickerProps } from '../components/TimePicker/index.js';\nimport type { TooltipProps } from '../components/Tooltip/index.js';\nimport type { GlobalObject } from '../lib/globalObject.js';\nimport { isBrowser } from '../lib/globalObject.js';\nimport { isForwardRef, isMemo } from './react-is.js';\n\nexport { delay } from './delay.js';\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 type NoInfer<T> = T extends infer U ? U : never;\n\nexport const emptyHandler = (): void => {\n /* noop */\n};\n\nexport class CancelationError extends Error {\n public code = 'CancelationError';\n}\n\nexport function taskWithDelay(task: () => void, ms: number): () => void {\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;\n\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<unknown>): boolean {\n return typeof element.type === 'string';\n}\n\nexport function isRefableElement(element: React.ReactElement<unknown>): boolean {\n return (\n Boolean(isIntrinsicElement(element) || isClassComponent(element.type) || isForwardRef(element)) || isMemo(element)\n );\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, globalObject: GlobalObject): boolean => {\n return isBrowser(globalObject) && new RegExp(`^(https?:)?//(?!${globalObject.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 (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 * Checks if a component instance is a ReactUI component with the given name.\n *\n * @typeParam T Expected ReactUI component type.\n * @param instance Component instance.\n * @param componentName ReactUI component name.\n * @returns `true` if it matches, otherwise `false`.\n */\nexport const isReactUIInstance = <T extends React.Component>(\n instance: React.Component,\n componentName: string,\n): instance is T => {\n const constructor = instance?.constructor;\n return '__KONTUR_REACT_UI__' in constructor && constructor.__KONTUR_REACT_UI__ === componentName;\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 extends Record<string, unknown>>(\n props: T,\n): { dataProps: Record<string, unknown>; restWithoutDataProps: Record<string, unknown> } => {\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): boolean => {\n const keyIndex = searchKeys.findIndex((key) => {\n return inputString.startsWith(key);\n });\n\n return keyIndex >= 0;\n};\n\nexport const isButton = isReactUIComponent<ButtonProps>('Button');\nexport const isInput = isReactUIComponent<InputProps>('Input');\nexport const isFxInput = isReactUIComponent<FxInputProps>('FxInput');\nexport const isAutocomplete = isReactUIComponent<AutocompleteProps>('Autocomplete');\nexport const isPasswordInput = isReactUIComponent<PasswordInputProps>('PasswordInput');\nexport const isCurrencyInput = isReactUIComponent<CurrencyInputProps>('CurrencyInput');\nexport const isSelect = isReactUIComponent<SelectProps<unknown, unknown>>('Select');\nexport const isDropdown = isReactUIComponent<DropdownProps>('Dropdown');\nexport const isDropdownMenu = isReactUIComponent<DropdownMenuProps>('DropdownMenu');\nexport const isHint = isReactUIComponent<HintProps>('Hint');\nexport const isTooltip = isReactUIComponent<TooltipProps>('Tooltip');\nexport const isTimePicker = isReactUIComponent<TimePickerProps>('TimePicker');\n\nexport const isKonturIcon = (icon: React.ReactElement): boolean => {\n return Object.prototype.hasOwnProperty.call(icon?.type, '__KONTUR_ICON__');\n};\n\nexport function clickOutside(eventType: 'touchstart' | 'mousedown' | 'pointerup' = 'mousedown'): void {\n const event = document.createEvent('HTMLEvents');\n event.initEvent(eventType, true, true);\n document.body.dispatchEvent(event);\n}\n\nexport function isElement(el: unknown): el is Element {\n return !!el && typeof el === 'object' && 'nodeType' in el && el.nodeType === Node.ELEMENT_NODE;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/react-ui",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.4-4e59f.0",
|
|
4
4
|
"description": "UI Components",
|
|
5
5
|
"homepage": "https://tech.skbkontur.ru/kontur-ui",
|
|
6
6
|
"bugs": {
|
|
@@ -146,6 +146,10 @@
|
|
|
146
146
|
"./components/Tabs/Tab": "./components/Tabs/Tab.js",
|
|
147
147
|
"./components/Textarea": "./components/Textarea/index.js",
|
|
148
148
|
"./components/Textarea/Textarea": "./components/Textarea/Textarea.js",
|
|
149
|
+
"./components/TimePicker": "./components/TimePicker/index.js",
|
|
150
|
+
"./components/TimePicker/TimePicker": "./components/TimePicker/TimePicker.js",
|
|
151
|
+
"./components/TimePicker/locale": "./components/TimePicker/locale/index.js",
|
|
152
|
+
"./components/TimePicker/locale/types": "./components/TimePicker/locale/types.js",
|
|
149
153
|
"./components/Toast": "./components/Toast/index.js",
|
|
150
154
|
"./components/Toast/Toast": "./components/Toast/Toast.js",
|
|
151
155
|
"./components/Toast/locale": "./components/Toast/locale/index.js",
|
|
@@ -197,6 +201,8 @@
|
|
|
197
201
|
"./internal/MobilePopup/MobilePopup": "./internal/MobilePopup/MobilePopup.js",
|
|
198
202
|
"./internal/NativeDateInput": "./internal/NativeDateInput/index.js",
|
|
199
203
|
"./internal/NativeDateInput/NativeDateInput": "./internal/NativeDateInput/NativeDateInput.js",
|
|
204
|
+
"./internal/NativeTimeInput": "./internal/NativeTimeInput/index.js",
|
|
205
|
+
"./internal/NativeTimeInput/NativeTimeInput": "./internal/NativeTimeInput/NativeTimeInput.js",
|
|
200
206
|
"./internal/Popup": "./internal/Popup/index.js",
|
|
201
207
|
"./internal/Popup/Popup": "./internal/Popup/Popup.js",
|
|
202
208
|
"./internal/PopupMenu": "./internal/PopupMenu/index.js",
|
|
@@ -207,6 +213,8 @@
|
|
|
207
213
|
"./internal/RenderLayer/RenderLayer": "./internal/RenderLayer/RenderLayer.js",
|
|
208
214
|
"./internal/ResizeDetector": "./internal/ResizeDetector/index.js",
|
|
209
215
|
"./internal/ResizeDetector/ResizeDetector": "./internal/ResizeDetector/ResizeDetector.js",
|
|
216
|
+
"./internal/TimeInput": "./internal/TimeInput/index.js",
|
|
217
|
+
"./internal/TimeInput/TimeInput": "./internal/TimeInput/TimeInput.js",
|
|
210
218
|
"./internal/ZIndex": "./internal/ZIndex/index.js",
|
|
211
219
|
"./internal/ZIndex/ZIndex": "./internal/ZIndex/ZIndex.js",
|
|
212
220
|
"./internal/react-focus-lock": "./internal/react-focus-lock/index.js",
|