@ozen-ui/kit 0.7.0 → 0.9.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/FieldControl/package.json +5 -0
- package/FieldInput/package.json +5 -0
- package/Fieldset/package.json +5 -0
- package/__inner__/cjs/components/Backdrop/Backdrop.d.ts +2 -2
- package/__inner__/cjs/components/Breadcrumbs/types.d.ts +2 -2
- package/__inner__/cjs/components/DataList/DataList.d.ts +1 -1
- package/__inner__/cjs/components/DataList/DataListProvider.d.ts +5 -5
- package/__inner__/cjs/components/FieldControl/FieldControl.css +135 -0
- package/__inner__/cjs/components/FieldControl/FieldControl.d.ts +13 -0
- package/__inner__/cjs/components/FieldControl/FieldControl.js +82 -0
- package/__inner__/cjs/components/FieldControl/FieldControlContext.d.ts +15 -0
- package/__inner__/cjs/components/FieldControl/FieldControlContext.js +6 -0
- package/__inner__/cjs/components/FieldControl/index.d.ts +2 -0
- package/__inner__/cjs/components/FieldControl/index.js +5 -0
- package/__inner__/cjs/components/FieldHint/FieldHint.d.ts +6 -9
- package/__inner__/cjs/components/FieldHint/FieldHint.js +24 -4
- package/__inner__/cjs/components/FieldIcon/FieldIcon.css +1 -21
- package/__inner__/cjs/components/FieldIcon/FieldIcon.d.ts +8 -12
- package/__inner__/cjs/components/FieldIcon/FieldIcon.js +15 -4
- package/__inner__/cjs/components/FieldInput/FieldInput.d.ts +11 -0
- package/__inner__/cjs/components/FieldInput/FieldInput.js +54 -0
- package/__inner__/cjs/components/FieldInput/index.d.ts +1 -0
- package/__inner__/cjs/components/FieldInput/index.js +4 -0
- package/__inner__/cjs/components/FieldLabel/FieldLabel.d.ts +7 -5
- package/__inner__/cjs/components/FieldLabel/FieldLabel.js +39 -10
- package/__inner__/cjs/components/Fieldset/Fieldset.css +13 -0
- package/__inner__/cjs/components/Fieldset/Fieldset.d.ts +10 -0
- package/__inner__/cjs/components/Fieldset/Fieldset.js +15 -0
- package/__inner__/cjs/components/Fieldset/index.d.ts +1 -0
- package/__inner__/cjs/components/Fieldset/index.js +4 -0
- package/__inner__/cjs/components/FilePicker/FilePicker.css +48 -59
- package/__inner__/cjs/components/FilePicker/FilePicker.js +2 -1
- package/__inner__/cjs/components/Input/Input.css +9 -121
- package/__inner__/cjs/components/Input/Input.d.ts +1 -62
- package/__inner__/cjs/components/Input/Input.js +32 -53
- package/__inner__/cjs/components/Input/constants.d.ts +1 -0
- package/__inner__/cjs/components/Input/constants.js +4 -0
- package/__inner__/cjs/components/Input/index.d.ts +1 -0
- package/__inner__/cjs/components/Input/index.js +1 -0
- package/__inner__/cjs/components/Input/types.d.ts +71 -0
- package/__inner__/cjs/components/Input/types.js +13 -0
- package/__inner__/cjs/components/InputNumber/InputNumber.css +60 -74
- package/__inner__/cjs/components/InputNumber/InputNumber.js +2 -1
- package/__inner__/cjs/components/InputNumber/utils.d.ts +2 -2
- package/__inner__/cjs/components/Link/Link.d.ts +1 -1
- package/__inner__/cjs/components/List/components/ListItem/ListItem.d.ts +1 -2
- package/__inner__/cjs/components/List/components/ListItemButton/ListItemButton.d.ts +1 -2
- package/__inner__/cjs/components/List/types.d.ts +3 -3
- package/__inner__/cjs/components/Menu/components/MenuItem/MenuItem.d.ts +1 -1
- package/__inner__/cjs/components/Menu/components/MenuList/MenuList.d.ts +1 -1
- package/__inner__/cjs/components/Modal/Modal.css +4 -8
- package/__inner__/cjs/components/Modal/Modal.d.ts +18 -2
- package/__inner__/cjs/components/Modal/Modal.js +13 -21
- package/__inner__/cjs/components/Modal/components/ModalConsumer.d.ts +5 -0
- package/__inner__/cjs/components/Modal/components/ModalConsumer.js +15 -0
- package/__inner__/cjs/components/Modal/components/index.d.ts +1 -0
- package/__inner__/cjs/components/Modal/components/index.js +4 -0
- package/__inner__/cjs/components/Pagination/helpers/createPaginationRange/createPaginationRange.d.ts +1 -1
- package/__inner__/cjs/components/Pagination/types.d.ts +5 -5
- package/__inner__/cjs/components/Popover/types.d.ts +4 -5
- package/__inner__/cjs/components/ProgressBar/ProgressBar.d.ts +2 -2
- package/__inner__/cjs/components/Select/Select.css +5 -16
- package/__inner__/cjs/components/Select/components/SelectInput/SelectInput.js +2 -1
- package/__inner__/cjs/components/Select/types.d.ts +3 -4
- package/__inner__/cjs/components/Slider/types.d.ts +1 -1
- package/__inner__/cjs/components/Snackbar/types.d.ts +1 -1
- package/__inner__/cjs/components/Tag/components/RemoveButton/RemoveButton.d.ts +1 -1
- package/__inner__/cjs/components/Textarea/Textarea.css +3 -107
- package/__inner__/cjs/components/Textarea/Textarea.d.ts +1 -59
- package/__inner__/cjs/components/Textarea/Textarea.js +8 -62
- package/__inner__/cjs/components/Textarea/components/TextareaConsumer.d.ts +3 -0
- package/__inner__/cjs/components/Textarea/components/TextareaConsumer.js +36 -0
- package/__inner__/cjs/components/Textarea/components/TextareaCounter.d.ts +7 -0
- package/__inner__/cjs/components/Textarea/components/TextareaCounter.js +25 -0
- package/__inner__/cjs/components/Textarea/components/index.d.ts +2 -0
- package/__inner__/cjs/components/Textarea/components/index.js +5 -0
- package/__inner__/cjs/components/Textarea/constants.d.ts +1 -0
- package/__inner__/cjs/components/Textarea/constants.js +4 -0
- package/__inner__/cjs/components/Textarea/index.d.ts +1 -0
- package/__inner__/cjs/components/Textarea/index.js +1 -0
- package/__inner__/cjs/components/Textarea/types.d.ts +69 -0
- package/__inner__/cjs/components/Textarea/types.js +4 -0
- package/__inner__/cjs/components/ThemeProvider/ThemeProvider.d.ts +2 -1
- package/__inner__/cjs/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/cjs/components/Tooltip/types.d.ts +1 -1
- package/__inner__/cjs/hooks/useLockBodyScroll/index.d.ts +1 -0
- package/__inner__/cjs/hooks/useLockBodyScroll/index.js +4 -0
- package/__inner__/cjs/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +1 -0
- package/__inner__/cjs/hooks/useLockBodyScroll/useLockBodyScroll.js +18 -0
- package/__inner__/cjs/hooks/useMultiRef/useMultiRef.d.ts +2 -3
- package/__inner__/cjs/types/ResponsiveValue.d.ts +1 -1
- package/__inner__/cjs/utils/isKey.d.ts +2 -2
- package/__inner__/cjs/utils/polymorphicComponentWithRef.d.ts +0 -1
- package/__inner__/esm/components/Backdrop/Backdrop.d.ts +2 -2
- package/__inner__/esm/components/Backdrop/Backdrop.js +1 -1
- package/__inner__/esm/components/Breadcrumbs/types.d.ts +2 -2
- package/__inner__/esm/components/DataList/DataList.d.ts +1 -1
- package/__inner__/esm/components/DataList/DataListProvider.d.ts +5 -5
- package/__inner__/esm/components/FieldControl/FieldControl.css +135 -0
- package/__inner__/esm/components/FieldControl/FieldControl.d.ts +13 -0
- package/__inner__/esm/components/FieldControl/FieldControl.js +79 -0
- package/__inner__/esm/components/FieldControl/FieldControlContext.d.ts +15 -0
- package/__inner__/esm/components/FieldControl/FieldControlContext.js +2 -0
- package/__inner__/esm/components/FieldControl/index.d.ts +2 -0
- package/__inner__/esm/components/FieldControl/index.js +2 -0
- package/__inner__/esm/components/FieldHint/FieldHint.d.ts +6 -9
- package/__inner__/esm/components/FieldHint/FieldHint.js +25 -5
- package/__inner__/esm/components/FieldIcon/FieldIcon.css +1 -21
- package/__inner__/esm/components/FieldIcon/FieldIcon.d.ts +8 -12
- package/__inner__/esm/components/FieldIcon/FieldIcon.js +16 -5
- package/__inner__/esm/components/FieldInput/FieldInput.d.ts +11 -0
- package/__inner__/esm/components/FieldInput/FieldInput.js +51 -0
- package/__inner__/esm/components/FieldInput/index.d.ts +1 -0
- package/__inner__/esm/components/FieldInput/index.js +1 -0
- package/__inner__/esm/components/FieldLabel/FieldLabel.d.ts +7 -5
- package/__inner__/esm/components/FieldLabel/FieldLabel.js +38 -8
- package/__inner__/esm/components/Fieldset/Fieldset.css +13 -0
- package/__inner__/esm/components/Fieldset/Fieldset.d.ts +10 -0
- package/__inner__/esm/components/Fieldset/Fieldset.js +12 -0
- package/__inner__/esm/components/Fieldset/index.d.ts +1 -0
- package/__inner__/esm/components/Fieldset/index.js +1 -0
- package/__inner__/esm/components/FilePicker/FilePicker.css +48 -59
- package/__inner__/esm/components/FilePicker/FilePicker.js +2 -1
- package/__inner__/esm/components/Input/Input.css +9 -121
- package/__inner__/esm/components/Input/Input.d.ts +1 -62
- package/__inner__/esm/components/Input/Input.js +33 -54
- package/__inner__/esm/components/Input/constants.d.ts +1 -0
- package/__inner__/esm/components/Input/constants.js +1 -0
- package/__inner__/esm/components/Input/index.d.ts +1 -0
- package/__inner__/esm/components/Input/index.js +1 -0
- package/__inner__/esm/components/Input/types.d.ts +71 -0
- package/__inner__/esm/components/Input/types.js +10 -0
- package/__inner__/esm/components/InputNumber/InputNumber.css +60 -74
- package/__inner__/esm/components/InputNumber/InputNumber.js +2 -1
- package/__inner__/esm/components/InputNumber/utils.d.ts +2 -2
- package/__inner__/esm/components/Link/Link.d.ts +1 -1
- package/__inner__/esm/components/List/components/ListItem/ListItem.d.ts +1 -2
- package/__inner__/esm/components/List/components/ListItemButton/ListItemButton.d.ts +1 -2
- package/__inner__/esm/components/List/types.d.ts +3 -3
- package/__inner__/esm/components/Menu/components/MenuItem/MenuItem.d.ts +1 -1
- package/__inner__/esm/components/Menu/components/MenuList/MenuList.d.ts +1 -1
- package/__inner__/esm/components/Modal/Modal.css +4 -8
- package/__inner__/esm/components/Modal/Modal.d.ts +18 -2
- package/__inner__/esm/components/Modal/Modal.js +13 -21
- package/__inner__/esm/components/Modal/components/ModalConsumer.d.ts +5 -0
- package/__inner__/esm/components/Modal/components/ModalConsumer.js +12 -0
- package/__inner__/esm/components/Modal/components/index.d.ts +1 -0
- package/__inner__/esm/components/Modal/components/index.js +1 -0
- package/__inner__/esm/components/Pagination/helpers/createPaginationRange/createPaginationRange.d.ts +1 -1
- package/__inner__/esm/components/Pagination/types.d.ts +5 -5
- package/__inner__/esm/components/Popover/types.d.ts +4 -5
- package/__inner__/esm/components/ProgressBar/ProgressBar.d.ts +2 -2
- package/__inner__/esm/components/ProgressBar/ProgressBar.js +1 -1
- package/__inner__/esm/components/Select/Select.css +5 -16
- package/__inner__/esm/components/Select/components/SelectInput/SelectInput.js +2 -1
- package/__inner__/esm/components/Select/types.d.ts +3 -4
- package/__inner__/esm/components/Slider/types.d.ts +1 -1
- package/__inner__/esm/components/Snackbar/types.d.ts +1 -1
- package/__inner__/esm/components/Tag/components/RemoveButton/RemoveButton.d.ts +1 -1
- package/__inner__/esm/components/Textarea/Textarea.css +3 -107
- package/__inner__/esm/components/Textarea/Textarea.d.ts +1 -59
- package/__inner__/esm/components/Textarea/Textarea.js +9 -63
- package/__inner__/esm/components/Textarea/components/TextareaConsumer.d.ts +3 -0
- package/__inner__/esm/components/Textarea/components/TextareaConsumer.js +32 -0
- package/__inner__/esm/components/Textarea/components/TextareaCounter.d.ts +7 -0
- package/__inner__/esm/components/Textarea/components/TextareaCounter.js +21 -0
- package/__inner__/esm/components/Textarea/components/index.d.ts +2 -0
- package/__inner__/esm/components/Textarea/components/index.js +2 -0
- package/__inner__/esm/components/Textarea/constants.d.ts +1 -0
- package/__inner__/esm/components/Textarea/constants.js +1 -0
- package/__inner__/esm/components/Textarea/index.d.ts +1 -0
- package/__inner__/esm/components/Textarea/index.js +1 -0
- package/__inner__/esm/components/Textarea/types.d.ts +69 -0
- package/__inner__/esm/components/Textarea/types.js +1 -0
- package/__inner__/esm/components/ThemeProvider/ThemeProvider.d.ts +2 -1
- package/__inner__/esm/components/ThemeProvider/types.d.ts +2 -0
- package/__inner__/esm/components/Tooltip/Tooltip.js +1 -1
- package/__inner__/esm/components/Tooltip/types.d.ts +1 -1
- package/__inner__/esm/hooks/useLockBodyScroll/index.d.ts +1 -0
- package/__inner__/esm/hooks/useLockBodyScroll/index.js +1 -0
- package/__inner__/esm/hooks/useLockBodyScroll/useLockBodyScroll.d.ts +1 -0
- package/__inner__/esm/hooks/useLockBodyScroll/useLockBodyScroll.js +14 -0
- package/__inner__/esm/hooks/useMultiRef/useMultiRef.d.ts +2 -3
- package/__inner__/esm/types/ResponsiveValue.d.ts +1 -1
- package/__inner__/esm/utils/isKey.d.ts +2 -2
- package/__inner__/esm/utils/polymorphicComponentWithRef.d.ts +0 -1
- package/package.json +1 -1
- package/useLockBodyScroll/package.json +5 -0
|
@@ -9,25 +9,27 @@ import { useMultiRef } from '../../hooks/useMultiRef';
|
|
|
9
9
|
import { cn } from '../../utils/classname';
|
|
10
10
|
import { isKey } from '../../utils/isKey';
|
|
11
11
|
import { Backdrop } from '../Backdrop';
|
|
12
|
-
import { Paper } from '../Paper';
|
|
13
12
|
import { Portal } from '../Portal';
|
|
13
|
+
import { ModalConsumer } from './components';
|
|
14
14
|
import { useModalManager } from './index';
|
|
15
15
|
export var cnModal = cn('Modal');
|
|
16
16
|
export var Modal = forwardRef(function (_a, ref) {
|
|
17
|
-
var _b = _a.open, open = _b === void 0 ? false : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? false : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? false : _d, children = _a.children, onEnter = _a.onEnter, onEntered = _a.onEntered, onExit = _a.onExit, onExitedProp = _a.onExited, onClose = _a.onClose, backdropProps = _a.backdropProps, windowProps = _a.windowProps, transitionProps = _a.transitionProps, className = _a.className, other = __rest(_a, ["open", "keepMounted", "hideBackdrop", "children", "onEnter", "onEntered", "onExit", "onExited", "onClose", "backdropProps", "windowProps", "transitionProps", "className"]);
|
|
17
|
+
var _b = _a.open, open = _b === void 0 ? false : _b, _c = _a.keepMounted, keepMounted = _c === void 0 ? false : _c, _d = _a.hideBackdrop, hideBackdrop = _d === void 0 ? false : _d, _e = _a.disableScrollLock, disableScrollLock = _e === void 0 ? false : _e, _f = _a.disableClickOutside, disableClickOutside = _f === void 0 ? false : _f, _g = _a.disableEscapeKeyDown, disableEscapeKeyDown = _g === void 0 ? false : _g, children = _a.children, onEnter = _a.onEnter, onEntered = _a.onEntered, onExit = _a.onExit, onExitedProp = _a.onExited, onClose = _a.onClose, backdropProps = _a.backdropProps, windowProps = _a.windowProps, transitionProps = _a.transitionProps, className = _a.className, ignoreClickOutsideRefs = _a.ignoreClickOutsideRefs, other = __rest(_a, ["open", "keepMounted", "hideBackdrop", "disableScrollLock", "disableClickOutside", "disableEscapeKeyDown", "children", "onEnter", "onEntered", "onExit", "onExited", "onClose", "backdropProps", "windowProps", "transitionProps", "className", "ignoreClickOutsideRefs"]);
|
|
18
18
|
var hasBackdrop = !hideBackdrop;
|
|
19
|
-
var hasScrollOnBody = useRef(null);
|
|
20
19
|
var modalInnerRef = useRef(null);
|
|
21
20
|
var focusedElement = useRef(null);
|
|
22
21
|
var isClickOutSide = useRef(null);
|
|
23
|
-
var
|
|
24
|
-
var
|
|
22
|
+
var _h = __read(useState(false), 2), openState = _h[0], setOpenState = _h[1];
|
|
23
|
+
var _j = useModalManager(modalInnerRef, 1000, openState), isTop = _j.isTop, refsClickOutside = _j.refsClickOutside;
|
|
25
24
|
useClickOutside({
|
|
26
|
-
refs: __spreadArray([
|
|
25
|
+
refs: __spreadArray(__spreadArray([
|
|
26
|
+
modalInnerRef
|
|
27
|
+
], __read(refsClickOutside), false), __read((ignoreClickOutsideRefs || [])), false),
|
|
27
28
|
handler: function () {
|
|
28
29
|
isClickOutSide.current = true;
|
|
29
30
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
30
|
-
}
|
|
31
|
+
},
|
|
32
|
+
active: !disableClickOutside
|
|
31
33
|
});
|
|
32
34
|
useEffect(function () {
|
|
33
35
|
var _a;
|
|
@@ -63,21 +65,11 @@ export var Modal = forwardRef(function (_a, ref) {
|
|
|
63
65
|
}
|
|
64
66
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
65
67
|
},
|
|
66
|
-
active: isTop
|
|
68
|
+
active: isTop && !disableEscapeKeyDown
|
|
67
69
|
});
|
|
68
|
-
// Блокирует прокрутку основного окна приложения
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
if (openState) {
|
|
71
|
-
hasScrollOnBody.current = document.body.classList.contains('no-scroll');
|
|
72
|
-
document.body.classList.add('no-scroll');
|
|
73
|
-
}
|
|
74
|
-
else if (!hasScrollOnBody.current) {
|
|
75
|
-
document.body.classList.remove('no-scroll');
|
|
76
|
-
}
|
|
77
|
-
}, [openState]);
|
|
78
70
|
return (React.createElement(CSSTransition, __assign({ classNames: cnModal({ animation: true }), timeout: 300 }, transitionProps, { "in": openState, onEnter: onEnter, onEntered: onEntered, onExit: onExit, onExited: onExited, unmountOnExit: !keepMounted, appear: true }),
|
|
79
|
-
React.createElement(Portal, __assign({}, other, { className: cnModal({ hidden: keepMounted && !openState, hasBackdrop: hasBackdrop }, [className]), ref:
|
|
80
|
-
!hideBackdrop && (React.createElement(Backdrop, __assign({ zIndex: -1 }, backdropProps, {
|
|
81
|
-
React.createElement(
|
|
71
|
+
React.createElement(Portal, __assign({}, other, { className: cnModal({ hidden: keepMounted && !openState, hasBackdrop: hasBackdrop }, [className]), ref: ref }),
|
|
72
|
+
!hideBackdrop && (React.createElement(Backdrop, __assign({ zIndex: -1 }, backdropProps, { open: openState, className: backdropProps === null || backdropProps === void 0 ? void 0 : backdropProps.className }))),
|
|
73
|
+
React.createElement(ModalConsumer, __assign({}, windowProps, { open: openState && !disableScrollLock, ref: useMultiRef([modalInnerRef, trapRef, windowProps === null || windowProps === void 0 ? void 0 : windowProps.ref]) }), children))));
|
|
82
74
|
});
|
|
83
75
|
Modal.displayName = 'Modal';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useLockBodyScroll } from '../../../hooks/useLockBodyScroll';
|
|
4
|
+
import { Paper } from '../../Paper';
|
|
5
|
+
import { cnModal } from '../index';
|
|
6
|
+
export var ModalConsumer = forwardRef(function (_a, ref) {
|
|
7
|
+
var children = _a.children, className = _a.className, open = _a.open, other = __rest(_a, ["children", "className", "open"]);
|
|
8
|
+
// Блокирует прокрутку основного окна приложения
|
|
9
|
+
useLockBodyScroll(open);
|
|
10
|
+
return (React.createElement(Paper, __assign({ radius: "s", background: "main" }, other, { className: cnModal('Window', [className]), tabIndex: -1, ref: ref }), children));
|
|
11
|
+
});
|
|
12
|
+
ModalConsumer.displayName = 'ModalConsumer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ModalConsumer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ModalConsumer';
|
package/__inner__/esm/components/Pagination/helpers/createPaginationRange/createPaginationRange.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaginationBaseProps } from '../../index';
|
|
2
|
-
import { EllipsisType } from '../../types';
|
|
2
|
+
import type { EllipsisType } from '../../types';
|
|
3
3
|
type Params = Required<Pick<PaginationBaseProps, 'page' | 'pageSize' | 'totalCount' | 'siblingCount'>>;
|
|
4
4
|
export declare const createPaginationRange: ({ page, pageSize, totalCount, siblingCount, }: Params) => (number | EllipsisType)[];
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PaginationItemProps } from './components';
|
|
3
|
-
import { ELLIPSIS, NEXT, PREVIOUS } from './constants';
|
|
4
|
-
import { GetItemAriaLabel } from './helpers/getItemAriaLabel';
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { PaginationItemProps } from './components';
|
|
3
|
+
import type { ELLIPSIS, NEXT, PREVIOUS } from './constants';
|
|
4
|
+
import type { GetItemAriaLabel } from './helpers/getItemAriaLabel';
|
|
5
5
|
export type EllipsisType = typeof ELLIPSIS;
|
|
6
6
|
export type PreviousType = typeof PREVIOUS;
|
|
7
7
|
export type NextType = typeof NEXT;
|
|
@@ -33,6 +33,6 @@ export type PaginationBaseProps = {
|
|
|
33
33
|
/** Функция форматирования атрибута aria-label. */
|
|
34
34
|
getItemAriaLabel?: GetItemAriaLabel;
|
|
35
35
|
/** Рендер функция, для отображения кнопок пагинации. */
|
|
36
|
-
renderComponent?: (PagItemProps: PaginationItemProps) =>
|
|
36
|
+
renderComponent?: (PagItemProps: PaginationItemProps) => ReactNode;
|
|
37
37
|
};
|
|
38
38
|
export type PaginationProps = PaginationBaseProps & HTMLAttributes<HTMLElement>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
3
|
-
import PopperJS from '@popperjs/core';
|
|
1
|
+
import type { RefObject, ComponentRef, ElementType, ReactNode } from 'react';
|
|
2
|
+
import type PopperJS from '@popperjs/core';
|
|
4
3
|
import type { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
5
4
|
import type { PolymorphicComponentPropsWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
5
|
import type { PortalProps } from '../Portal';
|
|
7
6
|
import type { PopoverArrowProps } from './components';
|
|
8
|
-
import { POPOVER_DEFAULT_TAG } from './constants';
|
|
7
|
+
import type { POPOVER_DEFAULT_TAG } from './constants';
|
|
9
8
|
export type VirtualElement = {
|
|
10
9
|
getBoundingClientRect: () => DOMRect;
|
|
11
10
|
contextElement?: Element;
|
|
@@ -25,7 +24,7 @@ export type PopoverBaseProps = {
|
|
|
25
24
|
y: number;
|
|
26
25
|
};
|
|
27
26
|
/** Контент поповера */
|
|
28
|
-
children?:
|
|
27
|
+
children?: ReactNode;
|
|
29
28
|
/** Функция обратного вызова, которая будет вызвана когда компонент запрашивает закрытие */
|
|
30
29
|
onClose?: () => void;
|
|
31
30
|
/** Функция обратного вызова которая будет вызвана до начала
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './ProgressBar.css';
|
|
2
|
-
import {
|
|
3
|
-
import { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
2
|
+
import type { ElementType } from 'react';
|
|
3
|
+
import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
4
4
|
import { PROGRESSBAR_DEFAULT_TAG } from './constants';
|
|
5
5
|
export declare const cnProgressBar: import("@bem-react/classname").ClassNameFormatter;
|
|
6
6
|
export type ProgressBarBaseProps = {
|
|
@@ -2,7 +2,7 @@ import { __assign, __rest } from "tslib";
|
|
|
2
2
|
import './ProgressBar.css';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { cn } from '../../utils/classname';
|
|
5
|
-
import { polymorphicComponentWithRef
|
|
5
|
+
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
|
|
6
6
|
import { PROGRESSBAR_DEFAULT_TAG } from './constants';
|
|
7
7
|
export var cnProgressBar = cn('ProgressBar');
|
|
8
8
|
export var ProgressBar = polymorphicComponentWithRef(function (_a, ref) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--textfield-background-color: var(--color-background-primary);
|
|
5
5
|
--textfield-border-width: var(--border-width-s);
|
|
6
6
|
--textfield-border-color: var(--color-border-main);
|
|
7
|
+
font: var(--textfield-input-font);
|
|
7
8
|
display: inline-flex;
|
|
8
9
|
vertical-align: top;
|
|
9
10
|
flex-direction: column;
|
|
@@ -21,19 +22,6 @@
|
|
|
21
22
|
inline-size: 100%;
|
|
22
23
|
box-sizing: border-box;
|
|
23
24
|
}
|
|
24
|
-
.Select-Fieldset {
|
|
25
|
-
position: absolute;
|
|
26
|
-
inset-block-end: 0;
|
|
27
|
-
inset-inline-end: 0;
|
|
28
|
-
inset-block-start: 0;
|
|
29
|
-
inset-inline-start: 0;
|
|
30
|
-
margin: 0;
|
|
31
|
-
padding: 0;
|
|
32
|
-
pointer-events: none;
|
|
33
|
-
border-radius: var(--border-radius-xs);
|
|
34
|
-
border: var(--textfield-border-width) solid var(--textfield-border-color);
|
|
35
|
-
transition: border var(--transition-default);
|
|
36
|
-
}
|
|
37
25
|
.Select-Body {
|
|
38
26
|
position: relative;
|
|
39
27
|
display: flex;
|
|
@@ -64,7 +52,6 @@
|
|
|
64
52
|
color: var(--textfield-color);
|
|
65
53
|
box-sizing: border-box;
|
|
66
54
|
block-size: var(--textfield-input-block-size);
|
|
67
|
-
font: var(--textfield-input-font);
|
|
68
55
|
align-items: center;
|
|
69
56
|
}
|
|
70
57
|
.Select-Field span {
|
|
@@ -176,7 +163,8 @@
|
|
|
176
163
|
}
|
|
177
164
|
.Select_animation-enter-active {
|
|
178
165
|
opacity: 1;
|
|
179
|
-
transition:
|
|
166
|
+
transition:
|
|
167
|
+
opacity var(--transition-default),
|
|
180
168
|
transform var(--transition-default);
|
|
181
169
|
transform: translate(0);
|
|
182
170
|
pointer-events: none;
|
|
@@ -192,7 +180,8 @@
|
|
|
192
180
|
}
|
|
193
181
|
.Select_animation-exit-active {
|
|
194
182
|
opacity: 0;
|
|
195
|
-
transition:
|
|
183
|
+
transition:
|
|
184
|
+
opacity var(--transition-default),
|
|
196
185
|
transform var(--transition-default);
|
|
197
186
|
transform: translate(0, calc(var(--space-s) * -1));
|
|
198
187
|
pointer-events: none;
|
|
@@ -7,6 +7,7 @@ import { useMultiRef } from '../../../../hooks/useMultiRef';
|
|
|
7
7
|
import { FieldHint } from '../../../FieldHint';
|
|
8
8
|
import { FieldIcon } from '../../../FieldIcon';
|
|
9
9
|
import { FieldLabel } from '../../../FieldLabel';
|
|
10
|
+
import { Fieldset } from '../../../Fieldset';
|
|
10
11
|
import { cnSelect } from '../../index';
|
|
11
12
|
export var SelectInput = forwardRef(function (_a, ref) {
|
|
12
13
|
var _b = _a.size, size = _b === void 0 ? 'm' : _b, _c = _a.multiline, multiline = _c === void 0 ? false : _c, label = _a.label, error = _a.error, id = _a.id, name = _a.name, renderLeft = _a.renderLeft, renderRight = _a.renderRight, inputRef = _a.inputRef, fieldRef = _a.fieldRef, fullWidth = _a.fullWidth, disabled = _a.disabled, hint = _a.hint, required = _a.required, className = _a.className, inputProps = _a.inputProps, valueProp = _a.value, defaultValue = _a.defaultValue, onFocus = _a.onFocus, onBlur = _a.onBlur, onKeyDown = _a.onKeyDown, labelRef = _a.labelRef, labelProps = _a.labelProps, fieldProps = _a.fieldProps, onClick = _a.onClick, focused = _a.focused, placeholderProp = _a.placeholder, renderedValue = _a.renderedValue, bodyProps = _a.bodyProps, bodyRefProp = _a.bodyRef, open = _a.open, other = __rest(_a, ["size", "multiline", "label", "error", "id", "name", "renderLeft", "renderRight", "inputRef", "fieldRef", "fullWidth", "disabled", "hint", "required", "className", "inputProps", "value", "defaultValue", "onFocus", "onBlur", "onKeyDown", "labelRef", "labelProps", "fieldProps", "onClick", "focused", "placeholder", "renderedValue", "bodyProps", "bodyRef", "open"]);
|
|
@@ -32,7 +33,7 @@ export var SelectInput = forwardRef(function (_a, ref) {
|
|
|
32
33
|
React.createElement("input", __assign({ id: id, name: name, defaultValue: defaultValue, value: valueProp, disabled: disabled, required: required, tabIndex: -1, "aria-hidden": true, readOnly: true }, inputProps, { className: cnSelect('Input', [inputProps === null || inputProps === void 0 ? void 0 : inputProps.className]), ref: inputRef }))),
|
|
33
34
|
React.createElement(FieldIcon, { className: cnSelect('RenderRight'), icon: renderRight, size: size }),
|
|
34
35
|
React.createElement(FieldIcon, { className: classnames(cnSelect('RenderRight'), cnSelect('DropDownIcon', { open: open })), icon: ChevronDownIcon, size: size }),
|
|
35
|
-
React.createElement(
|
|
36
|
+
React.createElement(Fieldset, { className: cnSelect('Fieldset') })),
|
|
36
37
|
React.createElement(FieldHint, { size: size, error: error, disabled: disabled }, hint)));
|
|
37
38
|
});
|
|
38
39
|
SelectInput.displayName = 'SelectInput';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { HTMLAttributes } from 'react';
|
|
1
|
+
import type { HTMLAttributes, SyntheticEvent, ReactNode } from 'react';
|
|
3
2
|
import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
|
|
4
3
|
import type { MenuProps } from '../Menu';
|
|
5
4
|
import type { SelectInputProps } from './components';
|
|
@@ -10,7 +9,7 @@ export type SelectedOptionProp = {
|
|
|
10
9
|
label?: SelectPropLabel;
|
|
11
10
|
value?: SelectPropValue;
|
|
12
11
|
};
|
|
13
|
-
export type SelectRenderValue = (option: SelectedOptionProp) =>
|
|
12
|
+
export type SelectRenderValue = (option: SelectedOptionProp) => ReactNode | null;
|
|
14
13
|
type SelectOpenControlledProps = {
|
|
15
14
|
/** Текущее состояние списка. Если `true`, список отображается. */
|
|
16
15
|
open?: boolean;
|
|
@@ -47,7 +46,7 @@ export type SelectProps = {
|
|
|
47
46
|
/** Рендер-функция для выбранного значения */
|
|
48
47
|
renderValue?: SelectRenderValue;
|
|
49
48
|
/** Содержимое компонента */
|
|
50
|
-
children?:
|
|
49
|
+
children?: ReactNode;
|
|
51
50
|
/** Свойства компонента Menu */
|
|
52
51
|
menuProps?: Omit<MenuProps, 'onClose' | 'open' | 'anchorRef'>;
|
|
53
52
|
/** Функция обратного вызова, которая будет вызвана когда компонент запрашивает закрытие */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ElementType, ComponentPropsWithRef, ChangeEvent } from 'react';
|
|
2
2
|
import type { PolymorphicComponentPropsWithoutRef } from '../../utils/polymorphicComponentWithRef';
|
|
3
3
|
import type { TooltipProps } from '../Tooltip';
|
|
4
|
-
import { SLIDER_DEFAULT_TAG } from './constants';
|
|
4
|
+
import type { SLIDER_DEFAULT_TAG } from './constants';
|
|
5
5
|
export declare const sliderSizeVariant: readonly ["m", "l"];
|
|
6
6
|
export type SliderSizeVariant = (typeof sliderSizeVariant)[number];
|
|
7
7
|
export type SliderValue = number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SnackbarItemProps } from './components/SnackbarItem';
|
|
1
|
+
import type { SnackbarItemProps } from './components/SnackbarItem';
|
|
2
2
|
export declare const snackbarVerticalAlignVariant: readonly ["top", "bottom"];
|
|
3
3
|
export declare const snackbarHorizontalAlignVariant: readonly ["left", "center", "right"];
|
|
4
4
|
export declare const snackbarStatusVariant: readonly ["success", "info", "warning", "error"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
2
|
import type { IconProps } from '@ozen-ui/icons';
|
|
3
3
|
export declare const removeButtonSizeVariant: readonly ["s", "xs", "2xs"];
|
|
4
4
|
export type RemoveButtonSizeVariant = (typeof removeButtonSizeVariant)[number];
|
|
@@ -1,39 +1,13 @@
|
|
|
1
1
|
.Textarea {
|
|
2
|
-
--textfield-color: var(--color-content-primary);
|
|
3
|
-
--textfield-background-color: var(--color-background-primary);
|
|
4
|
-
--textfield-border-width: var(--border-width-s);
|
|
5
|
-
--textfield-border-color: var(--color-border-main);
|
|
6
2
|
--textfield-scroll-size: 12px;
|
|
7
|
-
min-block-size: var(--textfield-input-
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
vertical-align: top;
|
|
10
|
-
flex-direction: column;
|
|
3
|
+
min-block-size: var(--textfield-input-height);
|
|
11
4
|
position: relative;
|
|
12
|
-
cursor: text;
|
|
13
5
|
}
|
|
14
6
|
|
|
15
|
-
.Textarea > * {
|
|
16
|
-
cursor: text;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
7
|
.Textarea-Label {
|
|
20
8
|
padding: 0 var(--textfield-gutter-x);
|
|
21
9
|
}
|
|
22
10
|
|
|
23
|
-
.Textarea-Fieldset {
|
|
24
|
-
position: absolute;
|
|
25
|
-
inset-block-end: 0;
|
|
26
|
-
inset-inline-end: 0;
|
|
27
|
-
inset-block-start: 0;
|
|
28
|
-
inset-inline-start: 0;
|
|
29
|
-
margin: 0;
|
|
30
|
-
padding: 0;
|
|
31
|
-
pointer-events: none;
|
|
32
|
-
border-radius: var(--border-radius-xs);
|
|
33
|
-
border: var(--textfield-border-width) solid var(--textfield-border-color);
|
|
34
|
-
transition: border var(--transition-default);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
11
|
.Textarea-Body,
|
|
38
12
|
.Textarea-Field {
|
|
39
13
|
transition: background-color var(--transition-slow);
|
|
@@ -50,10 +24,9 @@
|
|
|
50
24
|
transition: background-color var(--transition-slow);
|
|
51
25
|
color: var(--textfield-color);
|
|
52
26
|
border-radius: var(--border-radius-xs);
|
|
53
|
-
padding-block-start: 16px;
|
|
54
|
-
padding-block-end: 16px;
|
|
55
27
|
min-block-size: inherit;
|
|
56
28
|
block-size: inherit;
|
|
29
|
+
padding: var(--textfield-input-padding);
|
|
57
30
|
}
|
|
58
31
|
|
|
59
32
|
.Textarea-Field {
|
|
@@ -95,7 +68,7 @@
|
|
|
95
68
|
border: none;
|
|
96
69
|
display: flex;
|
|
97
70
|
outline: none;
|
|
98
|
-
font:
|
|
71
|
+
font: inherit;
|
|
99
72
|
background-color: var(--textfield-background-color);
|
|
100
73
|
color: var(--textfield-color);
|
|
101
74
|
padding: 0 var(--textfield-gutter-x);
|
|
@@ -126,80 +99,3 @@
|
|
|
126
99
|
resize: vertical;
|
|
127
100
|
overflow: hidden;
|
|
128
101
|
}
|
|
129
|
-
|
|
130
|
-
.Textarea_hasLabel .Textarea-Field::placeholder {
|
|
131
|
-
opacity: 0;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.Textarea_hasLabel .Textarea-Field:focus::placeholder {
|
|
135
|
-
opacity: 1;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.Textarea_hasLabel .Textarea-Body {
|
|
139
|
-
padding: var(--textfield-input-padding);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.Textarea_fullWidth {
|
|
143
|
-
inline-size: 100%;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.Textarea_size_2xs {
|
|
147
|
-
--textfield-gutter-x: 12px;
|
|
148
|
-
--textfield-input-block-size: 32px;
|
|
149
|
-
--textfield-input-font: var(--typography-text-2xs-font);
|
|
150
|
-
--textfield-input-padding: 8px 0 8px;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.Textarea_size_xs {
|
|
154
|
-
--textfield-gutter-x: 12px;
|
|
155
|
-
--textfield-input-block-size: 40px;
|
|
156
|
-
--textfield-input-font: var(--typography-text-xs-font);
|
|
157
|
-
--textfield-input-padding: 19px 0 4px;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.Textarea_size_s {
|
|
161
|
-
--textfield-gutter-x: 16px;
|
|
162
|
-
--textfield-input-block-size: 48px;
|
|
163
|
-
--textfield-input-font: var(--typography-text-s-font);
|
|
164
|
-
--textfield-input-padding: 21px 0 6px;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.Textarea_size_m {
|
|
168
|
-
--textfield-gutter-x: 20px;
|
|
169
|
-
--textfield-input-block-size: 56px;
|
|
170
|
-
--textfield-input-font: var(--typography-text-m-font);
|
|
171
|
-
--textfield-input-padding: 24px 0 6px;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.Textarea_size_l {
|
|
175
|
-
--textfield-gutter-x: 24px;
|
|
176
|
-
--textfield-input-block-size: 64px;
|
|
177
|
-
--textfield-input-font: var(--typography-text-l-font);
|
|
178
|
-
--textfield-input-padding: 26px 0 6px;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.Textarea:hover {
|
|
182
|
-
--textfield-border-color: var(--color-border-main-hover);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.Textarea_focused,
|
|
186
|
-
.Textarea_focused:hover {
|
|
187
|
-
--textfield-border-width: var(--border-width-m);
|
|
188
|
-
--textfield-background-color: var(--color-background-main);
|
|
189
|
-
--textfield-border-color: var(--color-border-action);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.Textarea_error,
|
|
193
|
-
.Textarea_error.Textarea:hover,
|
|
194
|
-
.Textarea_error.Textarea_focused,
|
|
195
|
-
.Textarea_error.Textarea_focused:hover {
|
|
196
|
-
--textfield-border-color: var(--color-border-error);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.Textarea_disabled {
|
|
200
|
-
--textfield-border-color: var(--color-border-disabled);
|
|
201
|
-
--textfield-background-color: var(--color-background-disabled);
|
|
202
|
-
--textfield-color: var(--color-content-secondary);
|
|
203
|
-
pointer-events: none;
|
|
204
|
-
cursor: default;
|
|
205
|
-
}
|
|
@@ -1,63 +1,5 @@
|
|
|
1
1
|
import './Textarea.css';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
import type { FormElementSizeVariant } from '../../types/FormElementSizeVariant';
|
|
5
|
-
import { type FieldLabelProps } from '../FieldLabel';
|
|
3
|
+
import type { TextareaProps } from './index';
|
|
6
4
|
export declare const cnTextarea: import("@bem-react/classname").ClassNameFormatter;
|
|
7
|
-
export type TextareaSizeVariant = FormElementSizeVariant;
|
|
8
|
-
export declare const textareaExpandVariant: readonly ["autoSize", "verticalResize"];
|
|
9
|
-
export type TextareaExpandVariant = (typeof textareaExpandVariant)[number];
|
|
10
|
-
type TextareaElement = TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
11
|
-
export type TextareaProps = {
|
|
12
|
-
/** Атрибут id для элемента input */
|
|
13
|
-
id?: string;
|
|
14
|
-
/** Атрибут name для элемента input */
|
|
15
|
-
name?: string;
|
|
16
|
-
/** Лейбл */
|
|
17
|
-
label?: string;
|
|
18
|
-
/** Размер компонента */
|
|
19
|
-
size?: TextareaSizeVariant;
|
|
20
|
-
/** Подсказка. Отображается, когда вариант не выбран */
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
/** Если {true} устанавливает автофокус */
|
|
23
|
-
autoFocus?: boolean;
|
|
24
|
-
/** Если {true} переводит поле в состояние ошибки */
|
|
25
|
-
error?: boolean;
|
|
26
|
-
/** Если {true} растягивает поле на всю ширину */
|
|
27
|
-
fullWidth?: boolean;
|
|
28
|
-
/** Дополнительное описание к полю */
|
|
29
|
-
hint?: string | null | undefined;
|
|
30
|
-
/** Если {true} делает элемент неактивным */
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
/** Если {true} делает элемент обязательным к заполнению */
|
|
33
|
-
required?: boolean;
|
|
34
|
-
/** Устанавливает максимальное число символов, которое может быть введено пользователем в текстовом поле. */
|
|
35
|
-
maxLength?: number;
|
|
36
|
-
/** Количество колонок */
|
|
37
|
-
cols?: number;
|
|
38
|
-
/** Количество строк */
|
|
39
|
-
rows?: number;
|
|
40
|
-
/** Расширяемость поля */
|
|
41
|
-
expand?: TextareaExpandVariant;
|
|
42
|
-
/** Выбранное значение */
|
|
43
|
-
value?: string;
|
|
44
|
-
/** Значение по умолчанию (неконтролируемый компонент) */
|
|
45
|
-
defaultValue?: string;
|
|
46
|
-
/** Обработчик события на изменение значения поля */
|
|
47
|
-
onChange?: TextareaElement['onChange'];
|
|
48
|
-
/** Ссылка на элемент textarea */
|
|
49
|
-
textareaRef?: Ref<HTMLTextAreaElement>;
|
|
50
|
-
/** Свойства элемента textarea */
|
|
51
|
-
textareaProps?: TextareaElement & {
|
|
52
|
-
'data-testid'?: string;
|
|
53
|
-
};
|
|
54
|
-
/** Ссылка на FieldLabel */
|
|
55
|
-
labelRef?: FieldLabelProps['ref'];
|
|
56
|
-
/** Свойства FieldLabel */
|
|
57
|
-
labelProps?: FieldLabelProps;
|
|
58
|
-
/** Ссылка на корневой DOM-элемент компонента */
|
|
59
|
-
ref?: Ref<HTMLDivElement>;
|
|
60
|
-
'data-testid'?: string;
|
|
61
|
-
} & Omit<HTMLAttributes<HTMLDivElement>, 'value' | 'defaultValue' | 'onChange'>;
|
|
62
5
|
export declare const Textarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
63
|
-
export {};
|
|
@@ -1,75 +1,21 @@
|
|
|
1
|
-
import { __assign,
|
|
1
|
+
import { __assign, __rest } from "tslib";
|
|
2
2
|
import './Textarea.css';
|
|
3
|
-
import React, {
|
|
4
|
-
import { useMultiRef } from '../../hooks/useMultiRef';
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
5
4
|
import { useThemeProps } from '../../hooks/useThemeProps';
|
|
6
5
|
import { cn } from '../../utils/classname';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { FieldControl } from '../FieldControl';
|
|
7
|
+
import { TextareaConsumer } from './components';
|
|
8
|
+
import { TEXTAREA_DEFAULT_SIZE } from './constants';
|
|
9
9
|
export var cnTextarea = cn('Textarea');
|
|
10
|
-
export var textareaExpandVariant = ['autoSize', 'verticalResize'];
|
|
11
10
|
export var Textarea = forwardRef(function (inProps, ref) {
|
|
12
11
|
var props = useThemeProps({
|
|
13
12
|
props: inProps,
|
|
14
13
|
name: 'Textarea'
|
|
15
14
|
});
|
|
16
|
-
var _a = props.size, size = _a === void 0 ?
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _b = __read(useState(), 2), focused = _b[0], setFocused = _b[1];
|
|
20
|
-
var _c = __read(useState(defaultValue), 2), valueState = _c[0], setValueState = _c[1];
|
|
21
|
-
var filled = isControlled ? !!valueProp : !!valueState;
|
|
22
|
-
// autoSize
|
|
23
|
-
useEffect(function () {
|
|
24
|
-
if (fieldRef.current && expand === 'autoSize') {
|
|
25
|
-
fieldRef.current.style.blockSize = '0px';
|
|
26
|
-
var scrollHeight = fieldRef.current.scrollHeight;
|
|
27
|
-
fieldRef.current.style.blockSize = "".concat(scrollHeight, "px");
|
|
28
|
-
}
|
|
29
|
-
}, [valueProp, valueState]);
|
|
30
|
-
// maxLength
|
|
31
|
-
var counter = useMemo(function () {
|
|
32
|
-
var _a;
|
|
33
|
-
var value = valueProp || valueState;
|
|
34
|
-
return maxLength ? "".concat((_a = value === null || value === void 0 ? void 0 : value.length) !== null && _a !== void 0 ? _a : 0, " / ").concat(maxLength) : undefined;
|
|
35
|
-
}, [maxLength, valueProp, valueState]);
|
|
36
|
-
var handleFocus = useCallback(function (e) {
|
|
37
|
-
var _a;
|
|
38
|
-
setFocused(true);
|
|
39
|
-
(_a = textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(textareaProps, e);
|
|
40
|
-
}, [textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.onFocus]);
|
|
41
|
-
var handleBlur = useCallback(function (e) {
|
|
42
|
-
var _a;
|
|
43
|
-
setFocused(false);
|
|
44
|
-
(_a = textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textareaProps, e);
|
|
45
|
-
}, [textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.onBlur]);
|
|
46
|
-
var handleChange = useCallback(function (e) {
|
|
47
|
-
if (disabled)
|
|
48
|
-
return;
|
|
49
|
-
var value = e.target.value;
|
|
50
|
-
if (!isControlled || maxLength || expand === 'autoSize') {
|
|
51
|
-
setValueState(value);
|
|
52
|
-
}
|
|
53
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
54
|
-
}, [onChange, isControlled, disabled, maxLength, expand]);
|
|
55
|
-
return (React.createElement("div", __assign({}, other, { className: cnTextarea({
|
|
56
|
-
size: size,
|
|
57
|
-
required: required,
|
|
58
|
-
fullWidth: fullWidth,
|
|
59
|
-
error: error,
|
|
60
|
-
disabled: disabled,
|
|
61
|
-
hasLabel: !!label,
|
|
62
|
-
expand: expand,
|
|
63
|
-
focused: focused
|
|
15
|
+
var _a = props.size, size = _a === void 0 ? TEXTAREA_DEFAULT_SIZE : _a, autoFocus = props.autoFocus, maxLength = props.maxLength, expand = props.expand, placeholder = props.placeholder, id = props.id, name = props.name, error = props.error, fullWidth = props.fullWidth, cols = props.cols, rows = props.rows, className = props.className, label = props.label, hint = props.hint, value = props.value, defaultValue = props.defaultValue, onChange = props.onChange, required = props.required, textareaRef = props.textareaRef, disabled = props.disabled, textareaProps = props.textareaProps, labelRef = props.labelRef, labelProps = props.labelProps, other = __rest(props, ["size", "autoFocus", "maxLength", "expand", "placeholder", "id", "name", "error", "fullWidth", "cols", "rows", "className", "label", "hint", "value", "defaultValue", "onChange", "required", "textareaRef", "disabled", "textareaProps", "labelRef", "labelProps"]);
|
|
16
|
+
return (React.createElement(FieldControl, __assign({ size: size, error: error, disabled: disabled, required: required, fullWidth: fullWidth }, other, { className: cnTextarea({
|
|
17
|
+
expand: expand
|
|
64
18
|
}, [className]), ref: ref }),
|
|
65
|
-
React.createElement(
|
|
66
|
-
label && (React.createElement(FieldLabel, __assign({ filled: filled, focused: focused, required: required, disabled: disabled, size: size }, labelProps, { className: cnTextarea('Label', [labelProps === null || labelProps === void 0 ? void 0 : labelProps.className]), ref: labelRef }), label)),
|
|
67
|
-
React.createElement("textarea", __assign({ id: id, name: name, cols: cols, rows: rows, disabled: disabled, value: valueProp, required: required, defaultValue: defaultValue, maxLength: maxLength, placeholder: placeholder, autoFocus: autoFocus }, textareaProps, { className: cnTextarea('Field', { filled: filled }, [
|
|
68
|
-
textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.className,
|
|
69
|
-
]), onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, ref: useMultiRef([textareaRef, fieldRef]) })),
|
|
70
|
-
React.createElement("fieldset", { className: cnTextarea('Fieldset') })),
|
|
71
|
-
(hint || maxLength) && (React.createElement(FieldHint, { size: size, error: error, disabled: disabled },
|
|
72
|
-
hint,
|
|
73
|
-
maxLength && (React.createElement("span", { className: cnTextarea('Counter', { disabled: disabled }) }, counter))))));
|
|
19
|
+
React.createElement(TextareaConsumer, { autoFocus: autoFocus, maxLength: maxLength, placeholder: placeholder, id: id, name: name, cols: cols, expand: expand, rows: rows, label: label, hint: hint, value: value, defaultValue: defaultValue, onChange: onChange, textareaRef: textareaRef, textareaProps: textareaProps, labelRef: labelRef, labelProps: labelProps })));
|
|
74
20
|
});
|
|
75
21
|
Textarea.displayName = 'Textarea';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __assign, __read } from "tslib";
|
|
2
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
3
|
+
import { useMultiRef } from '../../../hooks/useMultiRef';
|
|
4
|
+
import { FieldControlContext } from '../../FieldControl';
|
|
5
|
+
import { FieldHint } from '../../FieldHint';
|
|
6
|
+
import { FieldInput } from '../../FieldInput';
|
|
7
|
+
import { FieldLabel } from '../../FieldLabel';
|
|
8
|
+
import { Fieldset } from '../../Fieldset';
|
|
9
|
+
import { cnTextarea } from '../../Textarea';
|
|
10
|
+
import { TextareaCounter } from './index';
|
|
11
|
+
export var TextareaConsumer = function (_a) {
|
|
12
|
+
var labelProps = _a.labelProps, labelRef = _a.labelRef, maxLength = _a.maxLength, label = _a.label, id = _a.id, name = _a.name, cols = _a.cols, rows = _a.rows, disabled = _a.disabled, valueProp = _a.value, required = _a.required, defaultValue = _a.defaultValue, placeholder = _a.placeholder, autoFocus = _a.autoFocus, textareaProps = _a.textareaProps, onChange = _a.onChange, textareaRef = _a.textareaRef, expand = _a.expand, hint = _a.hint;
|
|
13
|
+
var fieldRef = useRef(null);
|
|
14
|
+
var context = useContext(FieldControlContext);
|
|
15
|
+
var _b = __read(context, 1), value = _b[0].value;
|
|
16
|
+
// autoSize
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
if (fieldRef.current && expand === 'autoSize') {
|
|
19
|
+
fieldRef.current.style.blockSize = '0px';
|
|
20
|
+
var scrollHeight = fieldRef.current.scrollHeight;
|
|
21
|
+
fieldRef.current.style.blockSize = "".concat(scrollHeight, "px");
|
|
22
|
+
}
|
|
23
|
+
}, [value]);
|
|
24
|
+
return (React.createElement(React.Fragment, null,
|
|
25
|
+
React.createElement("label", { className: cnTextarea('Body') },
|
|
26
|
+
React.createElement(FieldLabel, __assign({}, labelProps, { className: cnTextarea('Label', [labelProps === null || labelProps === void 0 ? void 0 : labelProps.className]), ref: labelRef || (labelProps === null || labelProps === void 0 ? void 0 : labelProps.ref) }), label),
|
|
27
|
+
React.createElement(FieldInput, __assign({ as: "textarea", id: id, name: name, cols: cols, rows: rows, disabled: disabled, value: valueProp, required: required, defaultValue: defaultValue, maxLength: maxLength, placeholder: placeholder, autoFocus: autoFocus, onChange: onChange }, textareaProps, { className: cnTextarea('Field', {}, [textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.className]), ref: useMultiRef([textareaRef || (textareaProps === null || textareaProps === void 0 ? void 0 : textareaProps.ref), fieldRef]) })),
|
|
28
|
+
React.createElement(Fieldset, null)),
|
|
29
|
+
React.createElement(FieldHint, null,
|
|
30
|
+
hint,
|
|
31
|
+
maxLength && React.createElement(TextareaCounter, { maxLength: maxLength }))));
|
|
32
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, FC } from 'react';
|
|
2
|
+
import type { TextareaProps } from '../index';
|
|
3
|
+
export type TextareaCounter = ComponentPropsWithRef<'span'> & {
|
|
4
|
+
maxLength: TextareaProps['maxLength'];
|
|
5
|
+
disabled?: TextareaProps['disabled'];
|
|
6
|
+
};
|
|
7
|
+
export declare const TextareaCounter: FC<TextareaCounter>;
|