@homecode/ui 4.20.0-beta-2 → 4.20.0-beta-3

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.
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { useRef, useState, useMemo, useEffect, createElement } from 'react';
2
+ import { forwardRef, useRef, useState, useMemo, useEffect, createElement } from 'react';
3
3
  import cn from 'classnames';
4
4
  import omit from 'lodash.omit';
5
5
  import { Label } from '../Label/Label.js';
@@ -60,8 +60,9 @@ const TEXTAREA_SCROLL_TOP_OFFSET = {
60
60
  m: 40,
61
61
  l: 50,
62
62
  };
63
- const Input = (props) => {
63
+ const Input = forwardRef((props, ref) => {
64
64
  const { type = 'text', size = 'm', variant = 'default', value, defaultValue = '', onChange, onFocus, onBlur, onClear, onInput, changeOnEnd, checkAutofill, hasClear, required, hideRequiredStar, disabled, error, label, placeholder, addonLeft, addonRight, forceLabelOnTop, scrollProps, step = 1, round, className, } = props;
65
+ const inputRef = useRef(null);
65
66
  const updateAutoComplete = () => {
66
67
  const form = inputRef.current?.closest('form');
67
68
  const val = form?.getAttribute('autocomplete');
@@ -76,7 +77,6 @@ const Input = (props) => {
76
77
  elem.selectionStart = cursorPos.current;
77
78
  elem.selectionEnd = cursorPos.current;
78
79
  };
79
- const inputRef = useRef(null);
80
80
  const isFocusedRef = useRef(false);
81
81
  const [isFocused, _setIsFocused] = useState(false);
82
82
  const setIsFocused = (val) => {
@@ -271,7 +271,7 @@ const Input = (props) => {
271
271
  useEffect(() => {
272
272
  document.addEventListener('keydown', onDocKeyUp);
273
273
  if (isTextArea) {
274
- inputRef.current.addEventListener('paste', onTextareaPaste);
274
+ inputRef.current?.addEventListener('paste', onTextareaPaste);
275
275
  }
276
276
  return () => {
277
277
  document.removeEventListener('keydown', onDocKeyUp);
@@ -293,6 +293,6 @@ const Input = (props) => {
293
293
  const Control = isTextArea ? 'span' : 'input';
294
294
  const classes = cn(S.root, isTextArea && S.isTextArea, S[`size-${size}`], S[`variant-${variant}`], isFocused && S.isFocused, error && S.hasError, hasClear && S.hasClear, disabled && S.isDisabled, round && S.round, className);
295
295
  return (jsxs("div", { className: classes, title: String(value), children: [jsxs("label", { className: S.main, children: [jsx("div", { className: S.border, suppressHydrationWarning: true, style: { clipPath: labelClipPath } }, "border"), renderAddon('left'), wrapControl(jsxs(Fragment, { children: [createElement(Control, { ...controlProps, className: cn(S.control, controlProps?.className), ref: inputRef, key: "control" }), isTextArea && controlProps.placeholder && !controlProps.value && (jsx("span", { className: S.placeholder, spellCheck: false, children: controlProps.placeholder }))] })), isNumber && (jsxs("div", { className: S.numberArrows, children: [jsx(Button, { variant: "clear", onClick: () => onNumberWheel(1), tabIndex: -1, children: jsx(Icon, { type: "chevronUp", size: size }) }), jsx(Button, { variant: "clear", onClick: () => onNumberWheel(-1), tabIndex: -1, children: jsx(Icon, { type: "chevronDown", size: size }) })] })), jsx(Label, { className: cn(S.label, addonRight && S.hasAddonRight), size: size, isOnTop: isLabelOnTop, isError: Boolean(error), onClipPathChange: onLabelClipPathChange, children: label }, "label"), renderAddon('right'), required && !hideRequiredStar && (jsx(RequiredStar, { size: size }, "required-star"))] }, "main"), hasClear && !disabled && hasValue && (jsx(Button, { className: S.clearButton, variant: "clear", size: size, square: true, onClick: onClearPress, title: "", children: jsx(Icon, { className: S.clearIcon, size: size, type: "close" }) }, "clear")), !disabled && typeof error === 'string' && (jsx(AssistiveText, { variant: "danger", size: size, children: error }, "assistive-text"))] }));
296
- };
296
+ });
297
297
 
298
298
  export { Input };
@@ -19,16 +19,16 @@ import '../Spinner/Spinner.styl.js';
19
19
  import '../Button/Button.styl.js';
20
20
  import '../ButtonGroup/ButtonGroup.styl.js';
21
21
  import '../Calendar/Calendar.styl.js';
22
- import 'lodash.omit';
23
- import '../RequiredStar/RequiredStar.styl.js';
24
- import 'nanoid';
25
- import '../Input/Input.styl.js';
22
+ import '../Input/Input.js';
26
23
  import '../../tools/dom.js';
24
+ import 'nanoid';
27
25
  import '../../tools/queryParams.js';
28
26
  import '../Portal/Portal.js';
29
27
  import '../Paranja/Paranja.styl.js';
30
28
  import '../Popup/Popup.styl.js';
29
+ import '../RequiredStar/RequiredStar.styl.js';
31
30
  import '../Select/Select.styl.js';
31
+ import 'lodash.omit';
32
32
  import '../Checkbox/Checkbox.styl.js';
33
33
  import '../Container/Container.styl.js';
34
34
  import '../DatePicker/DatePicker.styl.js';
@@ -1,3 +1,23 @@
1
1
  import * as T from './Input.types';
2
2
  export type InputProps = T.Props;
3
- export declare const Input: (props: T.Props) => JSX.Element;
3
+ export declare const Input: import("react").ForwardRefExoticComponent<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "onChange"> & Omit<T.ControlProps, "onChange" | "ref"> & import("../../types").FormControl<T.Value, HTMLInputElement> & {
4
+ name?: string;
5
+ step?: number;
6
+ size?: import("../../types").Size;
7
+ label?: string;
8
+ variant?: import("../../types").Variant;
9
+ round?: boolean;
10
+ hideRequiredStar?: boolean;
11
+ forceLabelOnTop?: boolean;
12
+ error?: string | boolean;
13
+ hasClear?: boolean;
14
+ changeOnEnd?: boolean;
15
+ addonLeft?: import("react").ReactNode;
16
+ addonLeftClassName?: string;
17
+ addonRight?: import("react").ReactNode;
18
+ addonRightClassName?: string;
19
+ onClear?: () => void;
20
+ controlProps?: T.ControlProps & import("../../types").ComponentType;
21
+ checkAutofill?: boolean;
22
+ scrollProps?: Partial<import("../Scroll/Scroll.types").Props>;
23
+ } & import("react").RefAttributes<HTMLInputElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.20.0-beta-2",
3
+ "version": "4.20.0-beta-3",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -39,6 +39,12 @@
39
39
  "module": "dist/esm",
40
40
  "types": "dist/esm/types/index.d.ts",
41
41
  "type": "module",
42
+ "bugs": {
43
+ "url": "https://github.com/apostololeg/uilib/issues"
44
+ },
45
+ "directories": {
46
+ "dist": "./dist"
47
+ },
42
48
  "dependencies": {
43
49
  "@homecode/ui": "^4.17.2",
44
50
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
@@ -63,11 +69,10 @@
63
69
  "svgo": "^3.0.2",
64
70
  "timen": "^0.1.0"
65
71
  },
66
- "bugs": {
67
- "url": "https://github.com/apostololeg/uilib/issues"
68
- },
69
- "directories": {
70
- "dist": "./dist"
72
+ "peerDependencies": {
73
+ "justorm": ">=3.0.0-beta-24",
74
+ "react": ">=18.0.0",
75
+ "react-dom": ">=18.0.0"
71
76
  },
72
77
  "devDependencies": {
73
78
  "@babel/core": "^7.20.12",