@ozen-ui/kit 0.47.2 → 0.49.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/DatePicker/package.json +5 -0
- package/__inner__/cjs/components/Alert/Alert.css +11 -12
- package/__inner__/cjs/components/Alert/Alert.d.ts +13 -39
- package/__inner__/cjs/components/Alert/Alert.js +14 -14
- package/__inner__/cjs/components/Alert/constants.d.ts +1 -1
- package/__inner__/cjs/components/Alert/constants.js +2 -2
- package/__inner__/cjs/components/Alert/index.d.ts +1 -0
- package/__inner__/cjs/components/Alert/index.js +1 -0
- package/__inner__/cjs/components/Alert/types.d.ts +46 -0
- package/__inner__/cjs/components/Alert/types.js +10 -0
- package/__inner__/cjs/components/Autocomplete/Autocomplete.js +57 -63
- package/__inner__/cjs/components/Autocomplete/helper.d.ts +6 -0
- package/__inner__/cjs/components/Autocomplete/types.d.ts +1 -1
- package/__inner__/cjs/components/Calendar/types.d.ts +1 -1
- package/__inner__/cjs/components/DatePicker/DatePicker.css +11 -0
- package/__inner__/cjs/components/DatePicker/DatePicker.d.ts +39 -0
- package/__inner__/cjs/components/DatePicker/DatePicker.js +160 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/DateInput.d.ts +6 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/DateInput.js +14 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.js +20 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/dateInputMask/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/components/DateInput/utils/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/components/DatePickerRenderRight/DatePickerRenderRight.d.ts +8 -0
- package/__inner__/cjs/components/DatePicker/components/DatePickerRenderRight/DatePickerRenderRight.js +26 -0
- package/__inner__/cjs/components/DatePicker/components/DatePickerRenderRight/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/components/DatePickerRenderRight/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/components/index.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/components/index.js +5 -0
- package/__inner__/cjs/components/DatePicker/constants.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/constants.js +4 -0
- package/__inner__/cjs/components/DatePicker/index.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/index.js +5 -0
- package/__inner__/cjs/components/DatePicker/types.d.ts +52 -0
- package/__inner__/cjs/components/DatePicker/types.js +2 -0
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/formatDateToString.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/formatDateToString.js +13 -0
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/formatDateToString/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/formatStringToDate.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/formatStringToDate.js +13 -0
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/formatStringToDate/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/index.d.ts +5 -0
- package/__inner__/cjs/components/DatePicker/utils/index.js +8 -0
- package/__inner__/cjs/components/DatePicker/utils/isInExclude/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/isInExclude/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/isInExclude/isInExclude.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/utils/isInExclude/isInExclude.js +14 -0
- package/__inner__/cjs/components/DatePicker/utils/isOutOfRange/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/isOutOfRange/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/isOutOfRange/isOutOfRange.d.ts +2 -0
- package/__inner__/cjs/components/DatePicker/utils/isOutOfRange/isOutOfRange.js +11 -0
- package/__inner__/cjs/components/DatePicker/utils/matchCalendarSizeToFormElement/index.d.ts +1 -0
- package/__inner__/cjs/components/DatePicker/utils/matchCalendarSizeToFormElement/index.js +4 -0
- package/__inner__/cjs/components/DatePicker/utils/matchCalendarSizeToFormElement/matchCalendarSizeToFormElement.d.ts +5 -0
- package/__inner__/cjs/components/DatePicker/utils/matchCalendarSizeToFormElement/matchCalendarSizeToFormElement.js +10 -0
- package/__inner__/cjs/components/Input/Input.css +0 -1
- package/__inner__/cjs/components/Input/Input.js +1 -1
- package/__inner__/cjs/components/InputNumber/utils.d.ts +1 -1
- package/__inner__/cjs/components/List/components/ListItemText/ListItemText.d.ts +5 -5
- package/__inner__/cjs/components/Slider/utils/getPositionOnRail.d.ts +1 -1
- package/__inner__/cjs/components/Snackbar/components/SnackbarItem/SnackbarItem.js +1 -1
- package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/cjs/components/Tooltip/Tooltip.css +5 -6
- package/__inner__/cjs/components/Tooltip/Tooltip.js +6 -2
- package/__inner__/cjs/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/cjs/components/Tooltip/constants.js +2 -2
- package/__inner__/cjs/components/Tooltip/types.d.ts +11 -3
- package/__inner__/cjs/locale/locale.js +12 -0
- package/__inner__/esm/components/Alert/Alert.css +11 -12
- package/__inner__/esm/components/Alert/Alert.d.ts +13 -39
- package/__inner__/esm/components/Alert/Alert.js +14 -14
- package/__inner__/esm/components/Alert/constants.d.ts +1 -1
- package/__inner__/esm/components/Alert/constants.js +1 -1
- package/__inner__/esm/components/Alert/index.d.ts +1 -0
- package/__inner__/esm/components/Alert/index.js +1 -0
- package/__inner__/esm/components/Alert/types.d.ts +46 -0
- package/__inner__/esm/components/Alert/types.js +7 -0
- package/__inner__/esm/components/Autocomplete/Autocomplete.js +57 -63
- package/__inner__/esm/components/Autocomplete/helper.d.ts +6 -0
- package/__inner__/esm/components/Autocomplete/types.d.ts +1 -1
- package/__inner__/esm/components/Calendar/types.d.ts +1 -1
- package/__inner__/esm/components/DatePicker/DatePicker.css +11 -0
- package/__inner__/esm/components/DatePicker/DatePicker.d.ts +39 -0
- package/__inner__/esm/components/DatePicker/DatePicker.js +157 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/DateInput.d.ts +6 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/DateInput.js +11 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/index.js +1 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/dateInputMask.js +15 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/dateInputMask/index.js +1 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/components/DateInput/utils/index.js +1 -0
- package/__inner__/esm/components/DatePicker/components/DatePickerRenderRight/DatePickerRenderRight.d.ts +8 -0
- package/__inner__/esm/components/DatePicker/components/DatePickerRenderRight/DatePickerRenderRight.js +22 -0
- package/__inner__/esm/components/DatePicker/components/DatePickerRenderRight/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/components/DatePickerRenderRight/index.js +1 -0
- package/__inner__/esm/components/DatePicker/components/index.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/components/index.js +2 -0
- package/__inner__/esm/components/DatePicker/constants.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/constants.js +1 -0
- package/__inner__/esm/components/DatePicker/index.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/index.js +2 -0
- package/__inner__/esm/components/DatePicker/types.d.ts +52 -0
- package/__inner__/esm/components/DatePicker/types.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/formatDateToString.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/formatDateToString.js +9 -0
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatDateToString/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/formatStringToDate.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/formatStringToDate.js +9 -0
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/formatStringToDate/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/index.d.ts +5 -0
- package/__inner__/esm/components/DatePicker/utils/index.js +5 -0
- package/__inner__/esm/components/DatePicker/utils/isInExclude/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/isInExclude/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/isInExclude/isInExclude.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/utils/isInExclude/isInExclude.js +10 -0
- package/__inner__/esm/components/DatePicker/utils/isOutOfRange/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/isOutOfRange/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/isOutOfRange/isOutOfRange.d.ts +2 -0
- package/__inner__/esm/components/DatePicker/utils/isOutOfRange/isOutOfRange.js +7 -0
- package/__inner__/esm/components/DatePicker/utils/matchCalendarSizeToFormElement/index.d.ts +1 -0
- package/__inner__/esm/components/DatePicker/utils/matchCalendarSizeToFormElement/index.js +1 -0
- package/__inner__/esm/components/DatePicker/utils/matchCalendarSizeToFormElement/matchCalendarSizeToFormElement.d.ts +5 -0
- package/__inner__/esm/components/DatePicker/utils/matchCalendarSizeToFormElement/matchCalendarSizeToFormElement.js +7 -0
- package/__inner__/esm/components/Input/Input.css +0 -1
- package/__inner__/esm/components/Input/Input.js +1 -1
- package/__inner__/esm/components/InputNumber/utils.d.ts +1 -1
- package/__inner__/esm/components/List/components/ListItemText/ListItemText.d.ts +5 -5
- package/__inner__/esm/components/Slider/utils/getPositionOnRail.d.ts +1 -1
- package/__inner__/esm/components/Snackbar/components/SnackbarItem/SnackbarItem.js +1 -1
- package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/esm/components/Tooltip/Tooltip.css +5 -6
- package/__inner__/esm/components/Tooltip/Tooltip.js +7 -3
- package/__inner__/esm/components/Tooltip/constants.d.ts +1 -1
- package/__inner__/esm/components/Tooltip/constants.js +1 -1
- package/__inner__/esm/components/Tooltip/types.d.ts +11 -3
- package/__inner__/esm/locale/locale.js +12 -0
- package/package.json +4 -4
|
@@ -15,6 +15,7 @@ import type { ChipProps as ChiPropsNext } from '../ChipNext';
|
|
|
15
15
|
import type { CollapseProps } from '../Collapse';
|
|
16
16
|
import type { ContainerProps } from '../Container';
|
|
17
17
|
import type { DataListProps } from '../DataList';
|
|
18
|
+
import type { DatePickerProps } from '../DatePicker';
|
|
18
19
|
import type { DialogProps } from '../Dialog';
|
|
19
20
|
import type { DividerProps } from '../Divider';
|
|
20
21
|
import type { DrawerProps } from '../Drawer';
|
|
@@ -86,6 +87,7 @@ export type Theme = {
|
|
|
86
87
|
Container?: Partial<ContainerProps>;
|
|
87
88
|
DataList?: Partial<DataListProps>;
|
|
88
89
|
Dialog?: Partial<DialogProps>;
|
|
90
|
+
DatePicker?: Partial<DatePickerProps>;
|
|
89
91
|
Divider?: Partial<DividerProps>;
|
|
90
92
|
Drawer?: Partial<DrawerProps>;
|
|
91
93
|
FieldControl?: Partial<FieldControlProps>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* stylelint-disable */
|
|
2
2
|
.Tooltip {
|
|
3
3
|
max-inline-size: 300px;
|
|
4
|
+
color: var(--color-content-primary);
|
|
4
5
|
}
|
|
5
6
|
.Tooltip_size_xs {
|
|
6
7
|
padding: var(--spacing-2xs) var(--spacing-xs);
|
|
@@ -20,9 +21,7 @@
|
|
|
20
21
|
|
|
21
22
|
text-transform: var(--typography-text-s-text_transform, none);
|
|
22
23
|
}
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
color: var(--color-content-primary-inverse);
|
|
28
|
-
}
|
|
24
|
+
.Tooltip_variant_dark,
|
|
25
|
+
.Tooltip_inverse {
|
|
26
|
+
color: var(--color-content-primary-inverse);
|
|
27
|
+
}
|
|
@@ -4,6 +4,7 @@ exports.Tooltip = exports.cnTooltip = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
require("./Tooltip.css");
|
|
6
6
|
var react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
+
var logger_1 = require("@ozen-ui/logger");
|
|
7
8
|
var useControlled_1 = require("../../hooks/useControlled");
|
|
8
9
|
var useDebounceCallback_1 = require("../../hooks/useDebounceCallback");
|
|
9
10
|
var useMultiRef_1 = require("../../hooks/useMultiRef");
|
|
@@ -15,7 +16,10 @@ var constants_1 = require("./constants");
|
|
|
15
16
|
exports.cnTooltip = (0, classname_1.cn)('Tooltip');
|
|
16
17
|
exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)(function (inProps, ref) {
|
|
17
18
|
var props = (0, useThemeProps_1.useThemeProps)({ props: inProps, name: 'Tooltip' });
|
|
18
|
-
var _a = props.trigger, trigger = _a === void 0 ? constants_1.TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? constants_1.TOOLTIP_DEFAULT_SIZE : _b, _c = props.
|
|
19
|
+
var _a = props.trigger, trigger = _a === void 0 ? constants_1.TOOLTIP_DEFAULT_TRIGGER : _a, _b = props.size, size = _b === void 0 ? constants_1.TOOLTIP_DEFAULT_SIZE : _b, _c = props.offset, offset = _c === void 0 ? constants_1.TOOLTIP_DEFAULT_OFFSET : _c, _d = props.delayEnter, delayEnter = _d === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_ENTER : _d, _e = props.delayLeave, delayLeave = _e === void 0 ? constants_1.TOOLTIP_DEFAULT_DELAY_LEAVE : _e, _f = props.arrow, arrow = _f === void 0 ? constants_1.TOOLTIP_DEFAULT_ARROW : _f, _g = props.shouldWrapChildren, shouldWrapChildren = _g === void 0 ? constants_1.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN : _g, _h = props.disabled, disabled = _h === void 0 ? constants_1.TOOLTIP_DEFAULT_DISABLED : _h, _j = props.inverse, inverse = _j === void 0 ? constants_1.TOOLTIP_DEFAULT_INVERSE : _j, variant = props.variant, children = props.children, label = props.label, openProp = props.open, placement = props.placement, disableInteractive = props.disableInteractive, className = props.className, onOpen = props.onOpen, onClose = props.onClose, _k = props.as, as = _k === void 0 ? constants_1.TOOLTIP_DEFAULT_TAG : _k, other = tslib_1.__rest(props, ["trigger", "size", "offset", "delayEnter", "delayLeave", "arrow", "shouldWrapChildren", "disabled", "inverse", "variant", "children", "label", "open", "placement", "disableInteractive", "className", "onOpen", "onClose", "as"]);
|
|
20
|
+
if (process.env.NODE_ENV !== 'production' && variant) {
|
|
21
|
+
(0, logger_1.deprecate)('Свойство «variant» устарело. Для замены используйте «inverse».');
|
|
22
|
+
}
|
|
19
23
|
var _l = tslib_1.__read((0, react_1.useState)(), 2), delay = _l[0], setDelay = _l[1];
|
|
20
24
|
var _m = tslib_1.__read((0, react_1.useState)(), 2), hasFocus = _m[0], setHasFocus = _m[1];
|
|
21
25
|
var _o = tslib_1.__read((0, react_1.useState)(), 2), hasHover = _o[0], setHasHover = _o[1];
|
|
@@ -115,7 +119,7 @@ exports.Tooltip = (0, polymorphicComponentWithRef_1.polymorphicComponentWithRef)
|
|
|
115
119
|
]);
|
|
116
120
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
117
121
|
react_1.default.cloneElement(resolveChildren, composeChildrenProps),
|
|
118
|
-
react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ anchorRef: anchorRef, strategy: "absolute", as: as, background: variant === '
|
|
122
|
+
react_1.default.createElement(Popover_1.Popover, tslib_1.__assign({ anchorRef: anchorRef, strategy: "absolute", as: as, background: "main" }, (variant === 'dark' && { background: 'main-inverse' }), (inverse && { background: 'main-inverse' }), { radius: size === 'xs' ? 's' : 'l' }, other, { ref: ref, offset: offset, placement: placement, open: openState && !disabled, onClose: handleClose, className: (0, exports.cnTooltip)({ size: size, variant: variant, inverse: inverse }, [className]), disableInteractive: disableInteractive, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, arrow: arrow, arrowProps: {
|
|
119
123
|
size: size,
|
|
120
124
|
}, disableEnforceFocus: true, disableReturnFocus: true }), label)));
|
|
121
125
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const TOOLTIP_DEFAULT_TAG: import("../../utils/polymorphicComponentWithRef").PolymorphicComponentWithRef<import("../Paper").PaperBaseProps, "div">;
|
|
2
2
|
export declare const TOOLTIP_DEFAULT_TRIGGER = "hover";
|
|
3
3
|
export declare const TOOLTIP_DEFAULT_SIZE = "s";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const TOOLTIP_DEFAULT_INVERSE = true;
|
|
5
5
|
export declare const TOOLTIP_DEFAULT_OFFSET: number[];
|
|
6
6
|
export declare const TOOLTIP_DEFAULT_DELAY_ENTER = 100;
|
|
7
7
|
export declare const TOOLTIP_DEFAULT_DELAY_LEAVE = 100;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOOLTIP_DEFAULT_DISABLED = exports.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN = exports.TOOLTIP_DEFAULT_ARROW = exports.TOOLTIP_DEFAULT_DELAY_LEAVE = exports.TOOLTIP_DEFAULT_DELAY_ENTER = exports.TOOLTIP_DEFAULT_OFFSET = exports.
|
|
3
|
+
exports.TOOLTIP_DEFAULT_DISABLED = exports.TOOLTIP_DEFAULT_SHOULD_WRAP_CHILDREN = exports.TOOLTIP_DEFAULT_ARROW = exports.TOOLTIP_DEFAULT_DELAY_LEAVE = exports.TOOLTIP_DEFAULT_DELAY_ENTER = exports.TOOLTIP_DEFAULT_OFFSET = exports.TOOLTIP_DEFAULT_INVERSE = exports.TOOLTIP_DEFAULT_SIZE = exports.TOOLTIP_DEFAULT_TRIGGER = exports.TOOLTIP_DEFAULT_TAG = void 0;
|
|
4
4
|
var Paper_1 = require("../Paper");
|
|
5
5
|
exports.TOOLTIP_DEFAULT_TAG = Paper_1.Paper;
|
|
6
6
|
exports.TOOLTIP_DEFAULT_TRIGGER = 'hover';
|
|
7
7
|
exports.TOOLTIP_DEFAULT_SIZE = 's';
|
|
8
|
-
exports.
|
|
8
|
+
exports.TOOLTIP_DEFAULT_INVERSE = true;
|
|
9
9
|
exports.TOOLTIP_DEFAULT_OFFSET = [0, 8];
|
|
10
10
|
exports.TOOLTIP_DEFAULT_DELAY_ENTER = 100;
|
|
11
11
|
exports.TOOLTIP_DEFAULT_DELAY_LEAVE = 100;
|
|
@@ -8,6 +8,13 @@ export declare const tooltipVariant: readonly ["light", "dark"];
|
|
|
8
8
|
export type TooltipVariant = (typeof tooltipVariant)[number];
|
|
9
9
|
export declare const tooltipTriggerVariant: readonly ["hover", "focus", "click", "hover&focus"];
|
|
10
10
|
export type TooltipTriggerVariant = (typeof tooltipTriggerVariant)[number];
|
|
11
|
+
type TooltipPropsDeprecated = {
|
|
12
|
+
/**
|
|
13
|
+
* Вариант представления
|
|
14
|
+
* @deprecated Используйте на замену свойство «inverse»
|
|
15
|
+
* */
|
|
16
|
+
variant?: TooltipVariant;
|
|
17
|
+
};
|
|
11
18
|
export type TooltipBaseProps = {
|
|
12
19
|
/** Признак по которому тултип будет представлен */
|
|
13
20
|
open?: boolean;
|
|
@@ -19,8 +26,8 @@ export type TooltipBaseProps = {
|
|
|
19
26
|
label?: ReactNode;
|
|
20
27
|
/** Размер тултипа */
|
|
21
28
|
size?: TooltipSizeVariant;
|
|
22
|
-
/**
|
|
23
|
-
|
|
29
|
+
/** Если {true} инвертирует основные цвета компонента */
|
|
30
|
+
inverse?: boolean;
|
|
24
31
|
/** Если {true} отключает отображение тултипа */
|
|
25
32
|
disabled?: boolean;
|
|
26
33
|
/** События вызова тултипа */
|
|
@@ -41,6 +48,7 @@ export type TooltipBaseProps = {
|
|
|
41
48
|
'data-testid'?: string;
|
|
42
49
|
/** Дополнительные CSS-классы */
|
|
43
50
|
className?: string;
|
|
44
|
-
} & Pick<PopoverBaseProps, 'offset' | 'placement' | 'arrow' | 'anchorRef' | 'ignoreClickOutsideRefs' | 'disableInteractive' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'setUpdate'>;
|
|
51
|
+
} & TooltipPropsDeprecated & Pick<PopoverBaseProps, 'offset' | 'placement' | 'arrow' | 'anchorRef' | 'ignoreClickOutsideRefs' | 'disableInteractive' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'setUpdate'>;
|
|
45
52
|
export type TooltipRef = ComponentRef<typeof TOOLTIP_DEFAULT_TAG>;
|
|
46
53
|
export type TooltipProps<As extends ElementType = typeof TOOLTIP_DEFAULT_TAG> = PolymorphicComponentPropsWithRef<TooltipBaseProps, As>;
|
|
54
|
+
export {};
|
|
@@ -68,6 +68,10 @@ exports.ruRU = {
|
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
|
+
DatePicker: {
|
|
72
|
+
clearText: 'Очистить',
|
|
73
|
+
placeholder: 'ДД.ММ.ГГГГ',
|
|
74
|
+
},
|
|
71
75
|
},
|
|
72
76
|
};
|
|
73
77
|
exports.kkKZ = {
|
|
@@ -136,6 +140,10 @@ exports.kkKZ = {
|
|
|
136
140
|
},
|
|
137
141
|
},
|
|
138
142
|
},
|
|
143
|
+
DatePicker: {
|
|
144
|
+
clearText: 'Тазалау',
|
|
145
|
+
placeholder: 'КК.АА.ЖЖЖЖ',
|
|
146
|
+
},
|
|
139
147
|
},
|
|
140
148
|
};
|
|
141
149
|
exports.enUS = {
|
|
@@ -205,5 +213,9 @@ exports.enUS = {
|
|
|
205
213
|
},
|
|
206
214
|
},
|
|
207
215
|
},
|
|
216
|
+
DatePicker: {
|
|
217
|
+
clearText: 'Clear',
|
|
218
|
+
placeholder: 'DD.MM.YYYY',
|
|
219
|
+
},
|
|
208
220
|
},
|
|
209
221
|
};
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
.Alert {
|
|
3
3
|
--alert-status-line-width: 8px;
|
|
4
4
|
--alert-status-line-gutter: var(--control-padding-xs);
|
|
5
|
+
--alert-title-text-color: var(--color-content-primary);
|
|
6
|
+
--alert-body-text-color: var(--color-content-secondary);
|
|
7
|
+
--alert-icon-color: var(--color-content-primary);
|
|
8
|
+
--alert-close-button-color: var(--color-content-primary);
|
|
5
9
|
display: flex;
|
|
6
10
|
overflow: auto;
|
|
7
11
|
inline-size: 100%;
|
|
@@ -22,18 +26,13 @@
|
|
|
22
26
|
|
|
23
27
|
text-transform: var(--typography-text-xs-text_transform, none);
|
|
24
28
|
}
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
--alert-title-text-color: var(--color-content-primary-inverse);
|
|
33
|
-
--alert-body-text-color: var(--color-content-primary-inverse);
|
|
34
|
-
--alert-icon-color: var(--color-content-primary-inverse);
|
|
35
|
-
--alert-close-button-color: var(--color-content-primary-inverse);
|
|
36
|
-
}
|
|
29
|
+
.Alert_color_dark,
|
|
30
|
+
.Alert_inverse {
|
|
31
|
+
--alert-title-text-color: var(--color-content-primary-inverse);
|
|
32
|
+
--alert-body-text-color: var(--color-content-primary-inverse);
|
|
33
|
+
--alert-icon-color: var(--color-content-primary-inverse);
|
|
34
|
+
--alert-close-button-color: var(--color-content-primary-inverse);
|
|
35
|
+
}
|
|
37
36
|
.Alert_status_info {
|
|
38
37
|
--alert-icon-color: var(--color-content-info);
|
|
39
38
|
--alert-status-line-color: var(--color-background-info);
|
|
@@ -1,43 +1,17 @@
|
|
|
1
1
|
import './Alert.css';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { HTMLAttributes, ReactElement, ReactNode, MouseEvent } from 'react';
|
|
4
3
|
import type { ButtonProps } from '../ButtonNext';
|
|
5
4
|
export declare const cnAlert: import("@bem-react/classname").ClassNameFormatter;
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
color?: AlertColorVariant;
|
|
20
|
-
/**
|
|
21
|
-
* Если {true} отображает иконку со статусом
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
showIcon?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Функция обратного вызова при нажатии на кнопку закрытия
|
|
27
|
-
*/
|
|
28
|
-
onClose?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Основное содержимое элемента
|
|
31
|
-
* @default null
|
|
32
|
-
* */
|
|
33
|
-
children?: ReactNode;
|
|
34
|
-
/** Действие: кнопка или ссылка. Свойство принимает React-элемент или рендер-функцию */
|
|
35
|
-
action?: ReactElement<ButtonProps> | (({ size, className, }: Pick<ButtonProps, 'size' | 'className'>) => ReactElement);
|
|
36
|
-
/** Дополнительные CSS-классы */
|
|
37
|
-
className?: string;
|
|
38
|
-
/** Текст для кнопки закрытия компонента */
|
|
39
|
-
closeText?: string;
|
|
40
|
-
};
|
|
41
|
-
export type AlertProps = AlertBaseProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'>;
|
|
42
|
-
export declare const Alert: React.ForwardRefExoticComponent<AlertBaseProps & Omit<React.HTMLAttributes<HTMLDivElement>, "title"> & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
-
export {};
|
|
5
|
+
export declare const Alert: React.ForwardRefExoticComponent<{
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
status?: "error" | "info" | "success" | "warning" | undefined;
|
|
8
|
+
inverse?: boolean | undefined;
|
|
9
|
+
showIcon?: boolean | undefined;
|
|
10
|
+
onClose?: ((e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
action?: React.ReactElement<ButtonProps, string | React.JSXElementConstructor<any>> | (({ size, className, }: Pick<ButtonProps, "className" | "size">) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) | undefined;
|
|
13
|
+
className?: string | undefined;
|
|
14
|
+
closeText?: string | undefined;
|
|
15
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "title" | "color"> & {
|
|
16
|
+
color?: "dark" | "light" | undefined;
|
|
17
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -2,32 +2,29 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
import './Alert.css';
|
|
3
3
|
import React, { forwardRef, useMemo } from 'react';
|
|
4
4
|
import { CrossIcon, InfoCircleFilledIcon, CheckCircleFilledIcon, WarningTriangleFilledIcon, WarningCircleFilledIcon, } from '@ozen-ui/icons';
|
|
5
|
+
import { deprecate } from '@ozen-ui/logger';
|
|
5
6
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
7
|
import { cn } from '../../utils/classname';
|
|
7
8
|
import { IconButton } from '../IconButtonNext';
|
|
8
9
|
import { Paper } from '../Paper';
|
|
9
|
-
import { ALERT_DEFAULT_STATUS, ALERT_DEFAULT_SHOW_ICON,
|
|
10
|
+
import { ALERT_DEFAULT_STATUS, ALERT_DEFAULT_SHOW_ICON, ALERT_DEFAULT_INVERSE, } from './constants';
|
|
10
11
|
export var cnAlert = cn('Alert');
|
|
11
|
-
export var alertStatusVariant = [
|
|
12
|
-
'success',
|
|
13
|
-
'error',
|
|
14
|
-
'warning',
|
|
15
|
-
'info',
|
|
16
|
-
];
|
|
17
|
-
export var alertColorVariant = ['light', 'dark'];
|
|
18
12
|
var matchStatusToIcon = {
|
|
19
|
-
neutral: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
20
13
|
info: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
21
|
-
|
|
14
|
+
neutral: React.createElement(InfoCircleFilledIcon, { size: "s" }),
|
|
22
15
|
success: React.createElement(CheckCircleFilledIcon, { size: "s" }),
|
|
23
16
|
error: React.createElement(WarningCircleFilledIcon, { size: "s" }),
|
|
17
|
+
warning: React.createElement(WarningTriangleFilledIcon, { size: "s" }),
|
|
24
18
|
};
|
|
25
19
|
export var Alert = forwardRef(function (inProps, ref) {
|
|
26
20
|
var props = useThemeProps({
|
|
27
21
|
props: inProps,
|
|
28
22
|
name: 'Alert',
|
|
29
23
|
});
|
|
30
|
-
var _a = props.status, status = _a === void 0 ? ALERT_DEFAULT_STATUS : _a, _b = props.showIcon, showIcon = _b === void 0 ? ALERT_DEFAULT_SHOW_ICON : _b, _c = props.
|
|
24
|
+
var _a = props.status, status = _a === void 0 ? ALERT_DEFAULT_STATUS : _a, _b = props.showIcon, showIcon = _b === void 0 ? ALERT_DEFAULT_SHOW_ICON : _b, _c = props.inverse, inverse = _c === void 0 ? ALERT_DEFAULT_INVERSE : _c, color = props.color, closeText = props.closeText, children = props.children, actionProp = props.action, onClose = props.onClose, title = props.title, className = props.className, other = __rest(props, ["status", "showIcon", "inverse", "color", "closeText", "children", "action", "onClose", "title", "className"]);
|
|
25
|
+
if (process.env.NODE_ENV !== 'production' && color) {
|
|
26
|
+
deprecate('Свойство «color» устарело. Для замены используйте «inverse».');
|
|
27
|
+
}
|
|
31
28
|
var action = useMemo(function () {
|
|
32
29
|
var actionProps = {
|
|
33
30
|
size: '2xs',
|
|
@@ -41,9 +38,12 @@ export var Alert = forwardRef(function (inProps, ref) {
|
|
|
41
38
|
}
|
|
42
39
|
return React.cloneElement(actionProp, actionProps);
|
|
43
40
|
}, [actionProp]);
|
|
44
|
-
return (React.createElement(Paper, __assign({ radius: "l", shadow: "m", role: "alert", background: color === '
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
return (React.createElement(Paper, __assign({ radius: "l", shadow: "m", role: "alert", background: "main" }, (color === 'dark' && { background: 'main-inverse' }), (inverse && { background: 'main-inverse' }), other, { className: cnAlert({
|
|
42
|
+
color: color,
|
|
43
|
+
status: status,
|
|
44
|
+
inverse: inverse,
|
|
45
|
+
hasCloseButton: !!onClose,
|
|
46
|
+
}, [className]), ref: ref }),
|
|
47
47
|
showIcon && (React.createElement("div", { className: cnAlert('Icon') }, matchStatusToIcon[status])),
|
|
48
48
|
React.createElement("div", { className: cnAlert('Content') },
|
|
49
49
|
React.createElement("div", { className: cnAlert('Title') }, title),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { HTMLAttributes, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { ButtonProps } from '../ButtonNext';
|
|
3
|
+
export declare const alertStatusVariant: readonly ["success", "error", "warning", "info"];
|
|
4
|
+
export declare const alertColorVariant: readonly ["light", "dark"];
|
|
5
|
+
export type AlertStatusVariant = (typeof alertStatusVariant)[number];
|
|
6
|
+
export type AlertColorVariant = (typeof alertColorVariant)[number];
|
|
7
|
+
type AlertPropsDeprecated = {
|
|
8
|
+
/**
|
|
9
|
+
* Цветовая палитра сообщения
|
|
10
|
+
* @deprecated Используйте на замену свойство «inverse»
|
|
11
|
+
* */
|
|
12
|
+
color?: AlertColorVariant;
|
|
13
|
+
};
|
|
14
|
+
type AlertBaseProps = {
|
|
15
|
+
/** Заголовок сообщения */
|
|
16
|
+
title: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Статус сообщения
|
|
19
|
+
* @default info
|
|
20
|
+
*/
|
|
21
|
+
status?: AlertStatusVariant;
|
|
22
|
+
/** Если {true} инвертирует основные цвета компонента */
|
|
23
|
+
inverse?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Если {true} отображает иконку со статусом
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
showIcon?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Функция обратного вызова при нажатии на кнопку закрытия
|
|
31
|
+
*/
|
|
32
|
+
onClose?: (e: MouseEvent<HTMLButtonElement>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Основное содержимое элемента
|
|
35
|
+
* @default null
|
|
36
|
+
* */
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
/** Действие: кнопка или ссылка. Свойство принимает React-элемент или рендер-функцию */
|
|
39
|
+
action?: ReactElement<ButtonProps> | (({ size, className, }: Pick<ButtonProps, 'size' | 'className'>) => ReactElement);
|
|
40
|
+
/** Дополнительные CSS-классы */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Текст для кнопки закрытия компонента */
|
|
43
|
+
closeText?: string;
|
|
44
|
+
};
|
|
45
|
+
export type AlertProps = AlertBaseProps & Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> & AlertPropsDeprecated;
|
|
46
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import { __assign, __read, __rest, __spreadArray } from "tslib";
|
|
|
2
2
|
import './Autocomplete.css';
|
|
3
3
|
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useControlled } from '../../hooks/useControlled';
|
|
5
|
+
import { useMultiRef } from '../../hooks/useMultiRef';
|
|
5
6
|
import { useMutableRef } from '../../hooks/useMutableRef';
|
|
6
7
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
7
8
|
import { cn } from '../../utils/classname';
|
|
@@ -17,8 +18,10 @@ function AutocompleteRender(inProps, ref) {
|
|
|
17
18
|
props: inProps,
|
|
18
19
|
name: 'Autocomplete',
|
|
19
20
|
});
|
|
20
|
-
var _a = withDefaultGetters(props), _b = _a.disabled, disabled = _b === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLED : _b, _c = _a.required, required = _c === void 0 ? AUTOCOMPLETE_DEFAULT_REQUIRED : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? AUTOCOMPLETE_DEFAULT_AUTOFOCUS : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? AUTOCOMPLETE_DEFAULT_FULLWIDTH : _e, _f = _a.size, size = _f === void 0 ? AUTOCOMPLETE_DEFAULT_SIZE : _f, _g = _a.allowCustomValue, allowCustomValue = _g === void 0 ? AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE : _g, _h = _a.disableShowChevron, disableShowChevron = _h === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON : _h, _j = _a.disableClearButton, disableClearButton = _j === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON : _j, _k = _a.disableShowEmptyOptionsList, disableShowEmptyOptionsList = _k === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST : _k, _l = _a.disableCloseOnSelect, disableCloseOnSelect = _l === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT : _l, _m = _a.renderInput, renderInput = _m === void 0 ? function (props) { return React.createElement(Input, __assign({}, props, { ref: ref })); } : _m, searchFunctionProp = _a.searchFunction, renderOptionProp = _a.renderOption, inputValueProp = _a.inputValue, className = _a.className, valueProp = _a.value, options = _a.options, defaultValue = _a.defaultValue, error = _a.error, onChange = _a.onChange, onInputChange = _a.onInputChange, label = _a.label, placeholder = _a.placeholder, renderLeft = _a.renderLeft, renderRight = _a.renderRight, hint = _a.hint, getOptionKey = _a.getOptionKey, getOptionLabel = _a.getOptionLabel, getOptionDisabled = _a.getOptionDisabled, dataListProps = _a.dataListProps, onCloseProp = _a.onClose, onOpenProp = _a.onOpen, openProp = _a.open, defaultOpen = _a.defaultOpen, loading = _a.loading, inputProps = _a.inputProps, onKeyDown = _a.onKeyDown, noOptionsText = _a.noOptionsText, clearText = _a.clearText, openText = _a.openText, loadingText = _a.loadingText, closeText = _a.closeText, other = __rest(_a, ["disabled", "required", "autoFocus", "fullWidth", "size", "allowCustomValue", "disableShowChevron", "disableClearButton", "disableShowEmptyOptionsList", "disableCloseOnSelect", "renderInput", "searchFunction", "renderOption", "inputValue", "className", "value", "options", "defaultValue", "error", "onChange", "onInputChange", "label", "placeholder", "renderLeft", "renderRight", "hint", "getOptionKey", "getOptionLabel", "getOptionDisabled", "dataListProps", "onClose", "onOpen", "open", "defaultOpen", "loading", "inputProps", "onKeyDown", "noOptionsText", "clearText", "openText", "loadingText", "closeText"]);
|
|
21
|
+
var _a = withDefaultGetters(props), _b = _a.disabled, disabled = _b === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLED : _b, _c = _a.required, required = _c === void 0 ? AUTOCOMPLETE_DEFAULT_REQUIRED : _c, _d = _a.autoFocus, autoFocus = _d === void 0 ? AUTOCOMPLETE_DEFAULT_AUTOFOCUS : _d, _e = _a.fullWidth, fullWidth = _e === void 0 ? AUTOCOMPLETE_DEFAULT_FULLWIDTH : _e, _f = _a.size, size = _f === void 0 ? AUTOCOMPLETE_DEFAULT_SIZE : _f, _g = _a.allowCustomValue, allowCustomValue = _g === void 0 ? AUTOCOMPLETE_DEFAULT_ALLOW_CUSTOM_VALUE : _g, _h = _a.disableShowChevron, disableShowChevron = _h === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_CHEVRON : _h, _j = _a.disableClearButton, disableClearButton = _j === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_CLEAR_BUTTON : _j, _k = _a.disableShowEmptyOptionsList, disableShowEmptyOptionsList = _k === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_SHOW_EMPTY_OPTIONS_LIST : _k, _l = _a.disableCloseOnSelect, disableCloseOnSelect = _l === void 0 ? AUTOCOMPLETE_DEFAULT_DISABLE_CLOSE_ON_SELECT : _l, _m = _a.renderInput, renderInput = _m === void 0 ? function (props) { return React.createElement(Input, __assign({}, props, { ref: ref })); } : _m, searchFunctionProp = _a.searchFunction, renderOptionProp = _a.renderOption, inputValueProp = _a.inputValue, className = _a.className, valueProp = _a.value, options = _a.options, defaultValue = _a.defaultValue, error = _a.error, onChange = _a.onChange, onInputChange = _a.onInputChange, label = _a.label, placeholder = _a.placeholder, renderLeft = _a.renderLeft, renderRight = _a.renderRight, hint = _a.hint, getOptionKey = _a.getOptionKey, getOptionLabel = _a.getOptionLabel, getOptionDisabled = _a.getOptionDisabled, dataListProps = _a.dataListProps, onCloseProp = _a.onClose, onOpenProp = _a.onOpen, openProp = _a.open, defaultOpen = _a.defaultOpen, loading = _a.loading, inputProps = _a.inputProps, bodyProps = _a.bodyProps, onKeyDown = _a.onKeyDown, noOptionsText = _a.noOptionsText, clearText = _a.clearText, openText = _a.openText, loadingText = _a.loadingText, closeText = _a.closeText, other = __rest(_a, ["disabled", "required", "autoFocus", "fullWidth", "size", "allowCustomValue", "disableShowChevron", "disableClearButton", "disableShowEmptyOptionsList", "disableCloseOnSelect", "renderInput", "searchFunction", "renderOption", "inputValue", "className", "value", "options", "defaultValue", "error", "onChange", "onInputChange", "label", "placeholder", "renderLeft", "renderRight", "hint", "getOptionKey", "getOptionLabel", "getOptionDisabled", "dataListProps", "onClose", "onOpen", "open", "defaultOpen", "loading", "inputProps", "bodyProps", "onKeyDown", "noOptionsText", "clearText", "openText", "loadingText", "closeText"]);
|
|
21
22
|
var anchorRef = useRef(null);
|
|
23
|
+
var lastInputValue = useRef('');
|
|
24
|
+
var inputBodyRef = useMultiRef([anchorRef, bodyProps === null || bodyProps === void 0 ? void 0 : bodyProps.ref]);
|
|
22
25
|
var _o = __read(useControlled({
|
|
23
26
|
value: inputValueProp,
|
|
24
27
|
defaultValue: '',
|
|
@@ -51,47 +54,43 @@ function AutocompleteRender(inProps, ref) {
|
|
|
51
54
|
var showNoOptions = !hasOptions && !loading;
|
|
52
55
|
var showLoading = !hasOptions && !!loading;
|
|
53
56
|
var _s = __read(useState(undefined), 2), search = _s[0], setSearch = _s[1];
|
|
54
|
-
|
|
57
|
+
var changeInputValue = function (e, value) {
|
|
58
|
+
var _a;
|
|
59
|
+
setInputValue(value);
|
|
60
|
+
(_a = savedOnInputChange.current) === null || _a === void 0 ? void 0 : _a.call(savedOnInputChange, e, value);
|
|
61
|
+
};
|
|
62
|
+
var callOnChange = function (e, value) {
|
|
63
|
+
var inputValue = value ? getOptionLabel(value) : '';
|
|
64
|
+
setValueState(value);
|
|
65
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e, value);
|
|
66
|
+
changeInputValue(null, inputValue);
|
|
67
|
+
};
|
|
68
|
+
/** Эффект – фильтрация списка при изменении опций */
|
|
55
69
|
useEffect(function () {
|
|
56
|
-
if (!open)
|
|
70
|
+
if (!open)
|
|
57
71
|
return;
|
|
58
|
-
}
|
|
59
72
|
setFilteredOptions(search ? search(options) : __spreadArray([], __read(options), false));
|
|
60
73
|
}, [search, options, open, searchFunctionProp]);
|
|
61
74
|
/** Эффект – синхронизируем значение текстового поля со значением в списке */
|
|
62
75
|
useEffect(function () {
|
|
63
|
-
var _a
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
(
|
|
76
|
+
var _a;
|
|
77
|
+
if (allowCustomValue)
|
|
78
|
+
return;
|
|
79
|
+
lastInputValue.current = valueState
|
|
80
|
+
? (_a = savedGetOptionLabel.current) === null || _a === void 0 ? void 0 : _a.call(savedGetOptionLabel, valueState)
|
|
81
|
+
: '';
|
|
82
|
+
if (lastInputValue.current !== inputValue) {
|
|
83
|
+
changeInputValue(null, lastInputValue.current);
|
|
71
84
|
}
|
|
72
|
-
}, [valueState]);
|
|
85
|
+
}, [valueState, allowCustomValue]);
|
|
73
86
|
/** Эффект – автофокусировка в текстовом поле */
|
|
74
87
|
useEffect(function () {
|
|
75
88
|
var _a;
|
|
76
|
-
if (autoFocus)
|
|
89
|
+
if (autoFocus)
|
|
77
90
|
(_a = anchorRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
78
|
-
}
|
|
79
91
|
}, [autoFocus]);
|
|
80
|
-
/**
|
|
81
|
-
var
|
|
82
|
-
var _a;
|
|
83
|
-
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
84
|
-
if (allowCustomValue) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
var value = valueState ? getOptionLabel(valueState) : '';
|
|
88
|
-
if (inputValue !== value) {
|
|
89
|
-
setInputValue(value);
|
|
90
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, value);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
/** Ждем выполнения анимации на закрытие и делаем сброс */
|
|
94
|
-
var onExited = function () {
|
|
92
|
+
/** Ждём выполнения анимации на закрытие и делаем сброс функции фильтрации */
|
|
93
|
+
var handleExited = function () {
|
|
95
94
|
var _a;
|
|
96
95
|
setSearch(undefined);
|
|
97
96
|
(_a = dataListProps === null || dataListProps === void 0 ? void 0 : dataListProps.onExited) === null || _a === void 0 ? void 0 : _a.call(dataListProps);
|
|
@@ -110,21 +109,26 @@ function AutocompleteRender(inProps, ref) {
|
|
|
110
109
|
var handleToggle = function () {
|
|
111
110
|
if (disabled)
|
|
112
111
|
return;
|
|
113
|
-
if (open)
|
|
112
|
+
if (open)
|
|
114
113
|
handleClose();
|
|
115
|
-
|
|
116
|
-
else {
|
|
114
|
+
else
|
|
117
115
|
handleOpen();
|
|
118
|
-
}
|
|
119
116
|
};
|
|
120
117
|
/** Очистка поля */
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
setInputValue('');
|
|
124
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(e, null);
|
|
125
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, '');
|
|
118
|
+
var handleClear = function (e) {
|
|
119
|
+
callOnChange(e, null);
|
|
126
120
|
setSearch(undefined);
|
|
127
121
|
};
|
|
122
|
+
/** Актуализация значения текстового поля после его покидания */
|
|
123
|
+
var handleBlur = function (e) {
|
|
124
|
+
var _a;
|
|
125
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
126
|
+
if (allowCustomValue)
|
|
127
|
+
return;
|
|
128
|
+
if (inputValue !== lastInputValue.current) {
|
|
129
|
+
changeInputValue(null, lastInputValue.current);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
128
132
|
/** Открытие списка по клику на текстовом поле */
|
|
129
133
|
var handleClickOnInput = function (e) {
|
|
130
134
|
var _a;
|
|
@@ -132,49 +136,39 @@ function AutocompleteRender(inProps, ref) {
|
|
|
132
136
|
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onClick) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
133
137
|
};
|
|
134
138
|
/** Управление элементом контроля через клавиатуру */
|
|
135
|
-
var handleKeyDown = function (
|
|
136
|
-
if (isKeys(
|
|
137
|
-
|
|
139
|
+
var handleKeyDown = function (e) {
|
|
140
|
+
if (isKeys(e, ['ArrowDown', 'ArrowUp']) && !open) {
|
|
141
|
+
e.preventDefault();
|
|
138
142
|
handleToggle();
|
|
139
143
|
}
|
|
140
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(
|
|
144
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
141
145
|
};
|
|
142
146
|
/** Событие ввода значения в текстовом поле */
|
|
143
147
|
var handleChangeInput = function (e) {
|
|
144
148
|
var value = e.target.value;
|
|
145
149
|
// Открываем список при вводе первого символа (при условии, что список еще не открыт)
|
|
146
|
-
if (value.length && !open)
|
|
150
|
+
if (value.length && !open)
|
|
147
151
|
handleOpen();
|
|
152
|
+
if (value) {
|
|
153
|
+
changeInputValue(e, value);
|
|
148
154
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
setValueState(null);
|
|
152
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(e, null);
|
|
155
|
+
else {
|
|
156
|
+
callOnChange(e, null);
|
|
153
157
|
}
|
|
154
|
-
// Назначаем значение
|
|
155
|
-
setInputValue(value);
|
|
156
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(e, value);
|
|
157
158
|
// Задаем функцию фильтрации
|
|
158
159
|
setSearch(function () { return function (options) { return searchFunction(__spreadArray([], __read(options), false), value); }; });
|
|
159
160
|
};
|
|
160
161
|
/** Событие выбора значения из раскрывающегося списка */
|
|
161
|
-
var handleChangeDataList = function (
|
|
162
|
+
var handleChangeDataList = function (e, _a) {
|
|
162
163
|
var value = _a.value;
|
|
163
164
|
var selectedOption = filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.find(function (option) { return (getOptionKey === null || getOptionKey === void 0 ? void 0 : getOptionKey(option)) === value; });
|
|
164
|
-
|
|
165
|
-
var newInputValue = getOptionLabel(selectedOption);
|
|
166
|
-
setValueState(selectedOption);
|
|
167
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event, selectedOption);
|
|
168
|
-
setInputValue(newInputValue);
|
|
169
|
-
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(null, newInputValue);
|
|
170
|
-
}
|
|
165
|
+
callOnChange(e, selectedOption || null);
|
|
171
166
|
// Закрываем список после выбора
|
|
172
|
-
if (!disableCloseOnSelect)
|
|
167
|
+
if (!disableCloseOnSelect)
|
|
173
168
|
handleClose();
|
|
174
|
-
}
|
|
175
169
|
};
|
|
176
170
|
/** Отображение текстового поля */
|
|
177
|
-
var input = renderInput(__assign(__assign({ size: size, hint: hint, disabled: disabled, label: label, required: required, error: error, fullWidth: fullWidth, placeholder: placeholder, renderLeft: renderLeft }, other), { renderRight: (React.createElement(AutocompleteRenderRight, { open: open, size: size, disabled: disabled, clearText: clearText, closeText: closeText, openText: openText, hasValue: !!inputValue, onClear:
|
|
171
|
+
var input = renderInput(__assign(__assign({ size: size, hint: hint, disabled: disabled, label: label, required: required, error: error, fullWidth: fullWidth, placeholder: placeholder, renderLeft: renderLeft }, other), { renderRight: (React.createElement(AutocompleteRenderRight, { open: open, size: size, disabled: disabled, clearText: clearText, closeText: closeText, openText: openText, hasValue: !!inputValue, onClear: handleClear, onOpen: handleToggle, renderRight: renderRight, disableShowChevron: disableShowChevron, disableClearButton: disableClearButton })), onChange: handleChangeInput, onKeyDown: handleKeyDown, value: inputValue || '', inputProps: __assign(__assign({}, inputProps), { onBlur: handleBlur, onClick: handleClickOnInput }), bodyProps: __assign(__assign({ 'aria-expanded': open }, bodyProps), { ref: inputBodyRef }), className: cnAutocomplete({ size: size, hasChevron: !disableShowChevron }, [
|
|
178
172
|
className,
|
|
179
173
|
]), ref: ref }));
|
|
180
174
|
/** Отображение опций */
|
|
@@ -191,7 +185,7 @@ function AutocompleteRender(inProps, ref) {
|
|
|
191
185
|
});
|
|
192
186
|
return (React.createElement(React.Fragment, null,
|
|
193
187
|
input,
|
|
194
|
-
React.createElement(DataList, __assign({ size: size, equalAnchorWidth: true, offset: [0, 4], placement: "bottom-start" }, dataListProps, { open: open,
|
|
188
|
+
React.createElement(DataList, __assign({ size: size, equalAnchorWidth: true, offset: [0, 4], placement: "bottom-start" }, dataListProps, { open: open, onClose: handleClose, anchorRef: anchorRef, onExited: handleExited, selected: dataListValue, onSelect: handleChangeDataList, listProps: __assign({ role: 'listbox' }, dataListProps === null || dataListProps === void 0 ? void 0 : dataListProps.listProps) }),
|
|
195
189
|
renderOptions,
|
|
196
190
|
!disableShowEmptyOptionsList && (React.createElement(AutocompleteNoOptions, { showNoOptions: showNoOptions, noOptionsText: noOptionsText })),
|
|
197
191
|
React.createElement(AutocompleteLoading, { showLoading: showLoading, loadingText: loadingText, size: size }))));
|