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

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,4 +1,4 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { mapById, isMultiple, renderLabel } from './Select.helpers.js';
3
3
  import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
4
4
  import { INTERACTION_MODE, getInteractionMode } from '../../tools/dom.js';
@@ -7,16 +7,17 @@ import omit from 'lodash.omit';
7
7
  import { AssistiveText } from '../AssistiveText/AssistiveText.js';
8
8
  import { Button } from '../Button/Button.js';
9
9
  import { Input } from '../Input/Input.js';
10
+ import { Icon } from '../Icon/Icon.js';
10
11
  import { Label } from '../Label/Label.js';
11
12
  import { Popup } from '../Popup/Popup.js';
12
13
  import { RequiredStar } from '../RequiredStar/RequiredStar.js';
13
- import S from './Select.styl.js';
14
14
  import { Scroll } from '../Scroll/Scroll.js';
15
15
  import { useThrottle } from '../../hooks/useThrottle.js';
16
16
  import useEvent from '../../hooks/useEvent.js';
17
+ import S from './Select.styl.js';
17
18
 
18
19
  function Select2(props) {
19
- 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;
20
21
  const isMultiple$1 = isMultiple(value);
21
22
  const closeOnSelect = props.closeOnSelect ?? !isMultiple$1;
22
23
  const contentRef = useRef(null);
@@ -45,9 +46,10 @@ function Select2(props) {
45
46
  const triggerProps = useMemo(() => ({
46
47
  label,
47
48
  size,
49
+ round,
48
50
  variant,
49
51
  ...props.triggerProps,
50
- }), [props.triggerProps, label, size, variant]);
52
+ }), [props.triggerProps, label, size, round, variant]);
51
53
  // Simplified isSelected check
52
54
  const isSelected = (id) =>
53
55
  // @ts-ignore
@@ -167,13 +169,15 @@ function Select2(props) {
167
169
  .join(', '));
168
170
  }, [isMultiple$1, value]);
169
171
  // console.log('selectedLabel::', selectedLabel);
170
- const renderTriggerArrow = () => {
171
- return null;
172
- };
172
+ const triggerArrow = useMemo(() => {
173
+ if (inputProps?.hasClear && searchVal)
174
+ return null;
175
+ return (jsx(Icon, { type: "chevronDown", className: cn(S.triggerArrow, isOpen && S.isOpen), size: size }));
176
+ }, [isOpen, searchVal]);
173
177
  const renderTriggerInput = () => {
174
178
  return (jsx(Input, { ...triggerProps, ...inputProps,
175
179
  // TODO: autoComplete
176
- addonRight: renderTriggerArrow(), error: isErrorVisible, value: isFocused ? searchVal : selectedLabel, onChange: handleSearchChange, label: getFieldLabel(label) }));
180
+ addonRight: triggerArrow, error: isErrorVisible, value: isFocused ? searchVal : selectedLabel, onChange: handleSearchChange, label: getFieldLabel(label) }));
177
181
  };
178
182
  const renderAdditionalLabel = () => {
179
183
  return null;
@@ -185,9 +189,8 @@ function Select2(props) {
185
189
  const hasSelected = fullSelectedLabel.length > 0;
186
190
  const displayLabel = hasSelected ? fullSelectedLabel : label;
187
191
  const title = hasSelected ? fullSelectedLabel : null;
188
- const triggerArrow = renderTriggerArrow();
189
192
  const isError = isErrorVisible;
190
- const classes = cn(S.triggerButton, isError && S.isError, triggerArrow , className);
193
+ const classes = cn(S.triggerButton, isError && S.isError, triggerArrow && S.hasTriggerArrow, className);
191
194
  return (jsxs("div", { children: [jsxs(Button, { className: classes, variant: "default", ...props, style: { clipPath: labelClipPath }, title: title?.join?.(', '), children: [jsx("div", { className: cn(S.triggerButtonLabel, hasSelected && S.hasSelected), children: displayLabel }), triggerArrow] }), jsx(Label, { size: size, isOnTop: hasSelected, isError: isError, onClipPathChange: setLabelClipPath, children: getFieldLabel(label) })] }));
192
195
  };
193
196
  const renderTrigger = () => {
@@ -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,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-0",
3
+ "version": "4.20.0-beta-2",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "jest",