armtek-uikit-react 1.0.265 → 1.0.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/assets/Accordion.scss +123 -123
  2. package/assets/Adornment.scss +22 -22
  3. package/assets/Alert.scss +56 -56
  4. package/assets/Avatar.scss +111 -111
  5. package/assets/AvatarGroup.scss +47 -47
  6. package/assets/BackDrop.scss +39 -39
  7. package/assets/Badge.scss +96 -96
  8. package/assets/Button.scss +750 -750
  9. package/assets/ButtonGroup.scss +37 -37
  10. package/assets/ButtonIcon.scss +59 -59
  11. package/assets/Card.scss +13 -13
  12. package/assets/Checkbox.scss +313 -313
  13. package/assets/Chip.scss +327 -327
  14. package/assets/DateField.scss +2 -2
  15. package/assets/DatePicker.scss +72 -72
  16. package/assets/Dropdown.scss +42 -42
  17. package/assets/FormControls.scss +14 -14
  18. package/assets/HelperText.scss +11 -11
  19. package/assets/Icon.scss +30 -30
  20. package/assets/Interval.scss +34 -34
  21. package/assets/Link.scss +96 -96
  22. package/assets/ListItem.scss +76 -76
  23. package/assets/Loader.scss +56 -56
  24. package/assets/Logo.scss +28 -28
  25. package/assets/Modal.scss +103 -103
  26. package/assets/Pagination.scss +3 -3
  27. package/assets/Paper.scss +22 -22
  28. package/assets/Period.scss +8 -8
  29. package/assets/Popper.scss +2 -2
  30. package/assets/Rating.scss +26 -26
  31. package/assets/Select.scss +85 -85
  32. package/assets/Skeleton.scss +25 -25
  33. package/assets/Slider.scss +5 -5
  34. package/assets/Stack.scss +27 -27
  35. package/assets/Status.scss +69 -69
  36. package/assets/StepItem.scss +89 -89
  37. package/assets/StepItemIcon.scss +47 -47
  38. package/assets/Stepper.scss +30 -30
  39. package/assets/Switch.scss +67 -67
  40. package/assets/Table.scss +52 -52
  41. package/assets/TextArea.scss +23 -18
  42. package/assets/TextField.scss +209 -198
  43. package/assets/Tooltip.scss +17 -17
  44. package/assets/classes.scss +422 -422
  45. package/assets/fonts.scss +24 -24
  46. package/assets/global.scss +222 -222
  47. package/assets/styles.min.css +1 -1
  48. package/assets/styles.min.css.map +1 -1
  49. package/assets/styles.scss +46 -46
  50. package/assets/variables.scss +13 -13
  51. package/lib/hooks/useEnhancedEffect.js +6 -6
  52. package/lib/hooks/useTimeout.js +2 -2
  53. package/package.json +1 -1
  54. package/ui/Form/DateField/DateField.js +2 -2
  55. package/ui/Form/DatePicker/styles.css +802 -802
  56. package/ui/Form/Password/Password.d.ts +4 -0
  57. package/ui/Form/TextArea/TextArea.d.ts +4 -0
  58. package/ui/Form/TextArea/TextArea.js +13 -36
  59. package/ui/Form/TextField/TextField.d.ts +12 -0
  60. package/ui/Form/TextField/TextField.js +106 -5
  61. package/ui/Slider/style.scss +346 -346
@@ -6,8 +6,12 @@ export declare const Password: import("react").ForwardRefExoticComponent<{
6
6
  errorTooltip?: string;
7
7
  success?: boolean;
8
8
  helperText?: string | import("react").ReactNode;
9
+ startAdornment?: string | import("react").ReactNode;
9
10
  endAdornment?: string | import("react").ReactNode;
10
11
  multiline?: boolean;
12
+ rows?: number;
13
+ minRows?: number;
14
+ maxRows?: number;
11
15
  focused?: boolean;
12
16
  editable?: boolean;
13
17
  classes?: Partial<{
@@ -14,8 +14,12 @@ declare const TextArea: import("react").ForwardRefExoticComponent<{
14
14
  errorTooltip?: string;
15
15
  success?: boolean;
16
16
  helperText?: string | import("react").ReactNode;
17
+ startAdornment?: string | import("react").ReactNode;
17
18
  endAdornment?: string | import("react").ReactNode;
18
19
  multiline?: boolean;
20
+ rows?: number;
21
+ minRows?: number;
22
+ maxRows?: number;
19
23
  focused?: boolean;
20
24
  editable?: boolean;
21
25
  classes?: Partial<{
@@ -11,53 +11,30 @@ var _jsxRuntime = require("react/jsx-runtime");
11
11
  const TextArea = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
12
12
  let {
13
13
  className,
14
- minRows,
15
- maxRows,
16
- onInput,
17
14
  style,
15
+ minRows = 3,
16
+ maxRows = 10,
17
+ rows,
18
18
  ...restProps
19
19
  } = props;
20
20
  let textareaRef = (0, _react.useRef)(null);
21
+ const getRowsCount = value => {
22
+ if (typeof value !== 'number' || !Number.isFinite(value)) return undefined;
23
+ return Math.max(1, Math.floor(value));
24
+ };
25
+ const normalizedRows = getRowsCount(rows);
26
+ const normalizedMinRows = getRowsCount(minRows);
27
+ const initialRows = normalizedRows !== undefined ? normalizedRows : normalizedMinRows;
21
28
  (0, _react.useImperativeHandle)(ref, () => {
22
29
  return textareaRef.current;
23
30
  }, []);
24
- const getRowsCount = rows => {
25
- if (typeof rows !== 'number' || !Number.isFinite(rows)) return undefined;
26
- return Math.max(1, Math.floor(rows));
27
- };
28
- const getHeightByRows = (rows, textarea) => {
29
- const style = window.getComputedStyle(textarea);
30
- const parsedLineHeight = parseFloat(style.lineHeight);
31
- const lineHeight = Number.isFinite(parsedLineHeight) ? parsedLineHeight : 20;
32
- const verticalPadding = (parseFloat(style.paddingTop) || 0) + (parseFloat(style.paddingBottom) || 0);
33
- const verticalBorders = (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.borderBottomWidth) || 0);
34
- return lineHeight * rows + verticalPadding + verticalBorders;
35
- };
36
- const resizeTextarea = () => {
37
- if (!textareaRef.current) return;
38
- const textarea = textareaRef.current;
39
- const minRowsValue = getRowsCount(minRows) || 1;
40
- const maxRowsValue = getRowsCount(maxRows);
41
- const resolvedMaxRows = maxRowsValue !== undefined ? Math.max(minRowsValue, maxRowsValue) : undefined;
42
- const minHeight = getHeightByRows(minRowsValue, textarea);
43
- const maxHeight = resolvedMaxRows !== undefined ? getHeightByRows(resolvedMaxRows, textarea) : undefined;
44
- textarea.style.height = 'auto';
45
- let nextHeight = Math.max(textarea.scrollHeight, minHeight);
46
- if (maxHeight !== undefined) nextHeight = Math.min(nextHeight, maxHeight);
47
- textarea.style.height = nextHeight + 'px';
48
- };
49
- (0, _react.useEffect)(() => {
50
- resizeTextarea();
51
- }, [minRows, maxRows, props.value, props.defaultValue, props.size]);
52
- const handleInput = event => {
53
- resizeTextarea();
54
- if (onInput) onInput(event);
55
- };
56
31
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
57
32
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, {
58
33
  ref: textareaRef,
59
34
  ...restProps,
60
- onInput: handleInput,
35
+ rows: initialRows,
36
+ minRows: normalizedMinRows,
37
+ maxRows: maxRows,
61
38
  className: (0, _clsx.default)('arm-textarea', ['arm-textarea_size_' + restProps.size], className),
62
39
  multiline: true,
63
40
  classes: {
@@ -9,8 +9,12 @@ export type TextFieldProps = {
9
9
  errorTooltip?: string;
10
10
  success?: boolean;
11
11
  helperText?: string | ReactNode;
12
+ startAdornment?: string | ReactNode;
12
13
  endAdornment?: string | ReactNode;
13
14
  multiline?: boolean;
15
+ rows?: number;
16
+ minRows?: number;
17
+ maxRows?: number;
14
18
  focused?: boolean;
15
19
  editable?: boolean;
16
20
  classes?: Partial<Classes>;
@@ -24,8 +28,12 @@ export declare const TextField: import("react").ForwardRefExoticComponent<{
24
28
  errorTooltip?: string;
25
29
  success?: boolean;
26
30
  helperText?: string | ReactNode;
31
+ startAdornment?: string | ReactNode;
27
32
  endAdornment?: string | ReactNode;
28
33
  multiline?: boolean;
34
+ rows?: number;
35
+ minRows?: number;
36
+ maxRows?: number;
29
37
  focused?: boolean;
30
38
  editable?: boolean;
31
39
  classes?: Partial<Classes>;
@@ -46,9 +54,13 @@ export declare const TextFieldInput: import("react").ForwardRefExoticComponent<{
46
54
  size?: TextFieldProps["size"];
47
55
  variant?: TextFieldProps["variant"];
48
56
  multiline?: boolean;
57
+ rows?: number;
58
+ minRows?: number;
59
+ maxRows?: number;
49
60
  error?: boolean;
50
61
  label?: string;
51
62
  wrapperClass?: string;
52
63
  WrapperProps?: ComponentPropsWithoutRef<"div">;
64
+ disableLabelTransition?: boolean;
53
65
  } & Omit<InputHTMLAttributes<any>, "size"> & import("react").RefAttributes<unknown>>;
54
66
  export default TextField;
@@ -12,6 +12,11 @@ var _Icon = require("../../Icon");
12
12
  var _Tooltip = _interopRequireDefault(require("../../Tooltip"));
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
+ const LABEL_TRANSITION_RESTORE_TIMEOUT = 100;
16
+ const hasInputValue = value => {
17
+ if (value === undefined || value === null) return false;
18
+ return String(value).length > 0;
19
+ };
15
20
  const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
16
21
  var _inputRef$current;
17
22
  let {
@@ -22,6 +27,7 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
22
27
  helperText,
23
28
  size = 'large',
24
29
  variant = 'solid',
30
+ startAdornment,
25
31
  endAdornment,
26
32
  className,
27
33
  classes,
@@ -30,8 +36,18 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
30
36
  WrapperProps,
31
37
  ...inputProps
32
38
  } = props;
33
- let [focused, setFocused] = (0, _react.useState)(!!props.defaultValue);
39
+ let [focused, setFocused] = (0, _react.useState)(hasInputValue(props.defaultValue) || hasInputValue(props.value));
40
+ let [disableLabelTransition, setDisableLabelTransition] = (0, _react.useState)(false);
41
+ const restoreLabelTransitionTimeoutRef = (0, _react.useRef)(null);
34
42
  const inputRef = (0, _react.useRef)(null);
43
+ const temporarilyDisableLabelTransition = () => {
44
+ setDisableLabelTransition(true);
45
+ if (restoreLabelTransitionTimeoutRef.current !== null) window.clearTimeout(restoreLabelTransitionTimeoutRef.current);
46
+ restoreLabelTransitionTimeoutRef.current = window.setTimeout(() => {
47
+ setDisableLabelTransition(false);
48
+ restoreLabelTransitionTimeoutRef.current = null;
49
+ }, LABEL_TRANSITION_RESTORE_TIMEOUT);
50
+ };
35
51
  const currentScrollHeight = (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.scrollHeight;
36
52
  (0, _react.useImperativeHandle)(ref, () => {
37
53
  return inputRef.current;
@@ -46,6 +62,40 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
46
62
  // }
47
63
  // }
48
64
  }, [currentScrollHeight]);
65
+ (0, _react.useEffect)(() => {
66
+ return () => {
67
+ if (restoreLabelTransitionTimeoutRef.current !== null) window.clearTimeout(restoreLabelTransitionTimeoutRef.current);
68
+ };
69
+ }, []);
70
+ (0, _react.useLayoutEffect)(() => {
71
+ var _valueDescriptor$enum;
72
+ const inputElement = inputRef.current;
73
+ if (!inputElement) return;
74
+ const prototype = inputElement instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
75
+ const valueDescriptor = Object.getOwnPropertyDescriptor(prototype, 'value');
76
+ const syncFocusedState = () => {
77
+ setFocused(hasInputValue(inputElement.value));
78
+ };
79
+ syncFocusedState();
80
+ if (!(valueDescriptor != null && valueDescriptor.get) || !(valueDescriptor != null && valueDescriptor.set)) return;
81
+ Object.defineProperty(inputElement, 'value', {
82
+ configurable: true,
83
+ enumerable: (_valueDescriptor$enum = valueDescriptor.enumerable) != null ? _valueDescriptor$enum : true,
84
+ get() {
85
+ var _valueDescriptor$get;
86
+ return (_valueDescriptor$get = valueDescriptor.get) == null ? void 0 : _valueDescriptor$get.call(this);
87
+ },
88
+ set(nextValue) {
89
+ var _valueDescriptor$set;
90
+ (_valueDescriptor$set = valueDescriptor.set) == null || _valueDescriptor$set.call(this, nextValue);
91
+ temporarilyDisableLabelTransition();
92
+ syncFocusedState();
93
+ }
94
+ });
95
+ return () => {
96
+ Reflect.deleteProperty(inputElement, 'value');
97
+ };
98
+ }, [multiline]);
49
99
  const handleFocus = e => {
50
100
  setFocused(true);
51
101
  if (inputProps.onFocus) inputProps.onFocus(e);
@@ -54,6 +104,10 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
54
104
  setFocused(false);
55
105
  if (inputProps.onBlur) inputProps.onBlur(e);
56
106
  };
107
+ let startContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Adornment.AdornmentContainer, {
108
+ className: 'arm-textfield__adornment arm-textfield__adornment_start',
109
+ children: startAdornment
110
+ });
57
111
  let endContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Adornment.AdornmentContainer, {
58
112
  className: 'arm-textfield__adornment',
59
113
  children: [endAdornment, error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
@@ -91,7 +145,7 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
91
145
  error: error,
92
146
  success: success,
93
147
  className: classes == null ? void 0 : classes.root,
94
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(TextFieldInput, {
148
+ children: [startAdornment && startContent, /*#__PURE__*/(0, _jsxRuntime.jsx)(TextFieldInput, {
95
149
  WrapperProps: WrapperProps,
96
150
  wrapperClass: classes == null ? void 0 : classes.wrapper,
97
151
  className: classes == null ? void 0 : classes.input,
@@ -101,6 +155,7 @@ const TextField = exports.TextField = /*#__PURE__*/(0, _react.forwardRef)((props
101
155
  variant: variant,
102
156
  label: label,
103
157
  focused: realFocused,
158
+ disableLabelTransition: disableLabelTransition,
104
159
  error: error,
105
160
  multiline: multiline,
106
161
  ...inputProps,
@@ -143,20 +198,63 @@ const TextFieldContainer = props => {
143
198
  };
144
199
  exports.TextFieldContainer = TextFieldContainer;
145
200
  const TextFieldInput = exports.TextFieldInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
146
- var _ref$current, _ref$current2;
201
+ var _inputElementRef$curr, _inputElementRef$curr2;
147
202
  let {
148
203
  Component = 'input',
149
204
  size,
150
205
  variant,
151
206
  multiline,
207
+ rows,
208
+ minRows,
209
+ maxRows,
152
210
  error,
153
211
  focused,
154
212
  label,
155
213
  wrapperClass,
156
214
  WrapperProps,
215
+ disableLabelTransition,
157
216
  className,
217
+ onInput,
158
218
  ...inputProps
159
219
  } = props;
220
+ const inputElementRef = (0, _react.useRef)(null);
221
+ const setInputRef = node => {
222
+ inputElementRef.current = node;
223
+ if (typeof ref === 'function') ref(node);else if (ref) ref.current = node;
224
+ };
225
+ const getRowsCount = rows => {
226
+ if (typeof rows !== 'number' || !Number.isFinite(rows)) return undefined;
227
+ return Math.max(1, Math.floor(rows));
228
+ };
229
+ const getHeightByRows = (rows, textarea) => {
230
+ const style = window.getComputedStyle(textarea);
231
+ const parsedLineHeight = parseFloat(style.lineHeight);
232
+ const lineHeight = Number.isFinite(parsedLineHeight) ? parsedLineHeight : 20;
233
+ const verticalPadding = (parseFloat(style.paddingTop) || 0) + (parseFloat(style.paddingBottom) || 0);
234
+ const verticalBorders = (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.borderBottomWidth) || 0);
235
+ return lineHeight * rows + verticalPadding + verticalBorders;
236
+ };
237
+ const resizeTextarea = () => {
238
+ if (!multiline || !(inputElementRef.current instanceof HTMLTextAreaElement)) return;
239
+ const textarea = inputElementRef.current;
240
+ const minRowsValue = getRowsCount(minRows) || 1;
241
+ const maxRowsValue = getRowsCount(maxRows);
242
+ const resolvedMaxRows = maxRowsValue !== undefined ? Math.max(minRowsValue, maxRowsValue) : undefined;
243
+ const minHeight = getHeightByRows(minRowsValue, textarea);
244
+ const maxHeight = resolvedMaxRows !== undefined ? getHeightByRows(resolvedMaxRows, textarea) : undefined;
245
+ textarea.style.height = 'auto';
246
+ const hasValue = textarea.value.length > 0;
247
+ let nextHeight = hasValue ? Math.max(textarea.scrollHeight, minHeight) : minHeight;
248
+ if (maxHeight !== undefined) nextHeight = Math.min(nextHeight, maxHeight);
249
+ textarea.style.height = nextHeight + 'px';
250
+ };
251
+ (0, _react.useEffect)(() => {
252
+ resizeTextarea();
253
+ }, [multiline, minRows, maxRows, inputProps.value, inputProps.defaultValue, size]);
254
+ const handleInput = event => {
255
+ if (multiline) resizeTextarea();
256
+ if (onInput) onInput(event);
257
+ };
160
258
  const handleWheel = e => {
161
259
  if (inputProps.type === 'number' && e.target instanceof HTMLElement) e.target.blur();else if (props.onWheel) props.onWheel(e);
162
260
  };
@@ -168,8 +266,10 @@ const TextFieldInput = exports.TextFieldInput = /*#__PURE__*/(0, _react.forwardR
168
266
  'arm-textfield__wrapper_outlined': variant === 'outlined'
169
267
  }),
170
268
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
171
- ref: ref,
269
+ ref: setInputRef,
172
270
  ...inputProps,
271
+ rows: multiline ? rows : undefined,
272
+ onInput: handleInput,
173
273
  onWheel: handleWheel,
174
274
  className: (0, _clsx.default)('arm-textfield__input', ['arm-textfield__input_size_' + size], ['arm-textfield__input_' + variant], {
175
275
  'arm-textfield__input_label': !!label,
@@ -179,7 +279,8 @@ const TextFieldInput = exports.TextFieldInput = /*#__PURE__*/(0, _react.forwardR
179
279
  }, className)
180
280
  }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
181
281
  className: (0, _clsx.default)('arm-textfield__label', {
182
- 'arm-textfield__label_focused': focused || !!props.value || typeof ((_ref$current = ref.current) == null ? void 0 : _ref$current.value) === 'string' && !!((_ref$current2 = ref.current) != null && _ref$current2.value),
282
+ 'arm-textfield__label_focused': focused || !!props.value || typeof ((_inputElementRef$curr = inputElementRef.current) == null ? void 0 : _inputElementRef$curr.value) === 'string' && !!((_inputElementRef$curr2 = inputElementRef.current) != null && _inputElementRef$curr2.value),
283
+ 'arm-textfield__label_noTransition': disableLabelTransition,
183
284
  'arm-textfield__label_small': size === 'small',
184
285
  'arm-textfield__label_error': error
185
286
  }),