@homecode/ui 4.20.0-beta-1 → 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.
@@ -62,7 +62,6 @@ function Autocomplete(props) {
62
62
  const [searchValue, setSearchValue] = useState(value);
63
63
  const [options, setOptions] = useState([]);
64
64
  const [isLoading, setIsLoading] = useState(false);
65
- const [isFocused, setIsFocused] = useState(false);
66
65
  const currentRequest = useRef('');
67
66
  // @ts-ignore
68
67
  const inputRef = useRef(null);
@@ -124,17 +123,11 @@ function Autocomplete(props) {
124
123
  const optionsList = useMemo(() => {
125
124
  if (!options.length)
126
125
  return null;
127
- return (jsx(Menu, { className: S.options, size: size, children: options.map((option, index) => (jsx(Menu.Item, { focused: focusedIndex === index, className: S.option, onClick: () => handleSelect(option.label), onMouseEnter: () => setFocusedIndex(index), children: option.label }, option.id))) }));
126
+ return (jsx(Menu, { className: S.options, size: size, offset: { y: { before: 20, after: 20 } }, children: options.map((option, index) => (jsx(Menu.Item, { focused: focusedIndex === index, className: S.option, onClick: () => handleSelect(option.label), onMouseEnter: () => setFocusedIndex(index), children: option.label }, option.id))) }));
128
127
  }, [options, focusedIndex]);
129
- return (jsx(Popup, { className: classes, isOpen: isOpen, focusControl: true, size: size, ...popupProps, trigger: jsxs("div", { className: inputWrapperClassName, children: [jsx(Input, { ref: inputRef,
128
+ return (jsx(Popup, { className: classes, isOpen: isOpen, focusControl: true, size: size, direction: "bottom", ...popupProps, trigger: jsxs("div", { className: inputWrapperClassName, children: [jsx(Input, { ref: inputRef,
130
129
  // @ts-ignore
131
- size: size, ...inputProps, value: searchValue, onChange: handleInputChange, className: inputProps.className, onFocus: e => {
132
- setIsFocused(true);
133
- inputProps.onFocus?.(e);
134
- }, onBlur: e => {
135
- setIsFocused(false);
136
- inputProps.onBlur?.(e);
137
- } }), isLoading && jsx(Shimmer, { className: S.shimmer, size: size })] }), content: optionsList, contentProps: {
130
+ size: size, ...inputProps, value: searchValue, onChange: handleInputChange, className: inputProps.className }), isLoading && (jsx(Shimmer, { className: S.shimmer, size: size, round: inputProps?.round }))] }), content: optionsList, contentProps: {
138
131
  className: S.popupContent,
139
132
  } }));
140
133
  }
@@ -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';
@@ -17,7 +17,7 @@ import useEvent from '../../hooks/useEvent.js';
17
17
  import S from './Select.styl.js';
18
18
 
19
19
  function Select2(props) {
20
- const { className, value, onChange, onSearchChange, inputProps, popupProps, size = 'm', optionClassName, additionalOptions = [], options, variant, label, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, } = props;
20
+ const { className, value, onChange, onSearchChange, inputProps, popupProps, size = 'm', round, optionClassName, additionalOptions = [], options, variant, label, error, blur, disabled, trigger, required, hideRequiredStar, isSearchable, presets = [], selectAllButton, clearButton, showSelectedCount, disableLabel, } = props;
21
21
  const isMultiple$1 = isMultiple(value);
22
22
  const closeOnSelect = props.closeOnSelect ?? !isMultiple$1;
23
23
  const contentRef = useRef(null);
@@ -46,9 +46,10 @@ function Select2(props) {
46
46
  const triggerProps = useMemo(() => ({
47
47
  label,
48
48
  size,
49
+ round,
49
50
  variant,
50
51
  ...props.triggerProps,
51
- }), [props.triggerProps, label, size, variant]);
52
+ }), [props.triggerProps, label, size, round, variant]);
52
53
  // Simplified isSelected check
53
54
  const isSelected = (id) =>
54
55
  // @ts-ignore
@@ -2,6 +2,6 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import S from './Shimmer.styl.js';
3
3
  import cn from 'classnames';
4
4
 
5
- const Shimmer = ({ className, size = 'm' }) => (jsx("div", { className: cn(S.root, className, S[`size-${size}`]), children: jsx("div", { className: S.inner }) }));
5
+ const Shimmer = ({ className, size = 'm', round = false, }) => (jsx("div", { className: cn(S.root, className, S[`size-${size}`], round && S.round), children: jsx("div", { className: S.inner }) }));
6
6
 
7
7
  export { Shimmer };
@@ -1,7 +1,7 @@
1
1
  import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
2
 
3
- var css_248z = ".Shimmer_root__XaY5r{height:100%;left:0;overflow:hidden;pointer-events:none;position:absolute;top:0;width:100%}.Shimmer_inner__zssMV{animation:Shimmer_shimmer__hGfzF 1.5s linear infinite;background:linear-gradient(90deg,transparent,hsla(0,0%,100%,.2) 50%,transparent);inset:0;position:absolute}.Shimmer_size-s__EYKhC{border-radius:4px}.Shimmer_size-m__AYziL{border-radius:6px}.Shimmer_size-l__GqE0a{border-radius:8px}@keyframes Shimmer_shimmer__hGfzF{0%{transform:translateX(-100%)}20%{transform:translateX(100%)}to{transform:translateX(100%)}}";
4
- var S = {"root":"Shimmer_root__XaY5r","inner":"Shimmer_inner__zssMV","shimmer":"Shimmer_shimmer__hGfzF","size-s":"Shimmer_size-s__EYKhC","size-m":"Shimmer_size-m__AYziL","size-l":"Shimmer_size-l__GqE0a"};
3
+ var css_248z = ".Shimmer_root__XaY5r{height:100%;left:0;overflow:hidden;pointer-events:none;position:absolute;top:0;width:100%}.Shimmer_inner__zssMV{animation:Shimmer_shimmer__hGfzF 1.5s linear infinite;background:linear-gradient(90deg,transparent,hsla(0,0%,100%,.2) 50%,transparent);inset:0;position:absolute}.Shimmer_size-s__EYKhC{border-radius:4px}.Shimmer_round__rwhjn.Shimmer_size-s__EYKhC{border-radius:15px}.Shimmer_size-m__AYziL{border-radius:6px}.Shimmer_round__rwhjn.Shimmer_size-m__AYziL{border-radius:20px}.Shimmer_size-l__GqE0a{border-radius:8px}.Shimmer_round__rwhjn.Shimmer_size-l__GqE0a{border-radius:25px}@keyframes Shimmer_shimmer__hGfzF{0%{transform:translateX(-100%)}20%{transform:translateX(100%)}to{transform:translateX(100%)}}";
4
+ var S = {"root":"Shimmer_root__XaY5r","inner":"Shimmer_inner__zssMV","shimmer":"Shimmer_shimmer__hGfzF","size-s":"Shimmer_size-s__EYKhC","round":"Shimmer_round__rwhjn","size-m":"Shimmer_size-m__AYziL","size-l":"Shimmer_size-l__GqE0a"};
5
5
  styleInject(css_248z);
6
6
 
7
7
  export { S as default };
@@ -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>>;
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { Size } from 'uilib/types';
3
- export interface MenuProps {
3
+ import { Props as ScrollProps } from 'uilib/components/Scroll/Scroll.types';
4
+ export interface MenuProps extends ScrollProps {
4
5
  children: ReactNode;
5
6
  className?: string;
6
7
  size?: Size;
@@ -53,6 +53,7 @@ export type Props = FormControl<Value> & InheritedInputProps & {
53
53
  onClose?: () => void;
54
54
  isSearchable?: boolean;
55
55
  inputProps?: Omit<InputProps, 'value' | 'onChange' | 'onFocus' | 'onBlur' | 'size'>;
56
+ round?: boolean;
56
57
  trigger?: ReactNode;
57
58
  triggerProps?: any;
58
59
  popupProps?: SelectPopupProps;
@@ -2,5 +2,6 @@ import { Size } from 'uilib/types';
2
2
  export type ShimmerProps = {
3
3
  className?: string;
4
4
  size?: Size;
5
+ round?: boolean;
5
6
  };
6
- export declare const Shimmer: ({ className, size }: ShimmerProps) => JSX.Element;
7
+ export declare const Shimmer: ({ className, size, round, }: ShimmerProps) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.20.0-beta-1",
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",