hrm_ui_lib 3.1.8 → 3.1.10

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.
@@ -13,7 +13,8 @@ export const FormField = (props) => {
13
13
  }
14
14
  const registerOptions = register(name);
15
15
  return (_jsx("div", { className: classnames('form-container__field', className, name), children: _jsx(Controller, Object.assign({ control: control, name: name }, (defaultValue ? { defaultValue } : {}), { render: ({ field, fieldState }) => {
16
- return (_jsxs(_Fragment, { children: [As(Object.assign(Object.assign(Object.assign({ hasError: !!fieldState.error, isValid: fieldState.isTouched && fieldState.isDirty && !fieldState.invalid, dataId }, registerOptions), { setFieldValue: (data, name, options) => setValue(data, name, Object.assign({ shouldValidate: true, shouldDirty: true, shouldTouch: true }, options)) }), field)), !hideErrorMessage ? (_jsx(ReactHookFormErrorMessage, { name: name, errors: errors, render: ({ message }) => {
16
+ var _a;
17
+ return (_jsxs(_Fragment, { children: [As(Object.assign(Object.assign(Object.assign({ hasError: !!fieldState.error, isValid: fieldState.isTouched && fieldState.isDirty && !fieldState.invalid, dataId }, registerOptions), { setFieldValue: (data, name, options) => setValue(data, name, Object.assign({ shouldValidate: true, shouldDirty: true, shouldTouch: true }, options)) }), field)), !hideErrorMessage ? (_jsx(ReactHookFormErrorMessage, { name: ((_a = errors === null || errors === void 0 ? void 0 : errors[name]) === null || _a === void 0 ? void 0 : _a.root) ? `${name}.root` : name, errors: errors, render: ({ message }) => {
17
18
  return (_jsx(ErrorMessage, { dataId: dataId, message: message || '', className: "full-width", icon: errorMessageIcon }));
18
19
  } })) : null] }));
19
20
  } })) }));
@@ -6,12 +6,14 @@ import { ContentTop } from '../../SharedComponents';
6
6
  import { FixedSizeList as List } from 'react-window';
7
7
  import { DROPDOWN_HEIGHT, DROPDOWN_WIDTH, ITEM_SIZE, ITEM_SIZE_MOBILE } from '../../constants';
8
8
  import classNames from 'classnames';
9
+ import { noop } from '../../../../utils/helpers';
9
10
  export const MultiBase = (props) => {
10
11
  const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth } = props;
11
12
  const { emptyListMainMessage, emptyListSecondaryMessage } = translations || {};
12
13
  const [searchValue, setSearchValue] = useState('');
13
14
  const [isAllSelected, setAllSelected] = useState(false);
14
15
  const [activeIndex, setActiveIndex] = useState(0);
16
+ const dropdownRef = useRef(null);
15
17
  const listRef = useRef(null);
16
18
  const handleKeyDown = (e) => {
17
19
  switch (e.key) {
@@ -76,6 +78,11 @@ export const MultiBase = (props) => {
76
78
  setAllSelected(false);
77
79
  onItemDeselect(item);
78
80
  };
81
+ useEffect(() => {
82
+ if (dropdownRef && dropdownRef.current && !isSearchAvailable) {
83
+ dropdownRef.current.focus();
84
+ }
85
+ }, [dropdownRef.current]);
79
86
  const checkIsSelected = (itemValue) => {
80
87
  return selectedValues.find((item) => item.value === itemValue) !== undefined;
81
88
  };
@@ -89,7 +96,7 @@ export const MultiBase = (props) => {
89
96
  }, [labelLeftIconProps, optionRightIconComponent, labelRightIconComponent]);
90
97
  return (_jsxs(_Fragment, { children: [_jsx(ContentTop, { closeDropdown: closeDropdown, dataIdPrefix: dataIdPrefix, menuOptions: menuOptions, selectAll: selectAll, clearAll: clearAll, hasLimitation: !!maxSelectCount, isAnySelected: selectedValues.length !== 0, helperText: helperText, isSearchAvailable: isSearchAvailable, isSelectAllDisabled: isAllSelected || filteredData.length === 0, setSearchValue: setSearchValue, searchValue: searchValue, translations: translations, handleKeyDown: handleKeyDown }), _jsx("div", { className: classNames('select__options__scroll scrollbar', {
91
98
  select__options__scroll_mobile: isMobile
92
- }), style: scrollableContentStyle, children: filteredData.length > 0 && (_jsx(List, { ref: listRef, height: isMobile
99
+ }), style: scrollableContentStyle, ref: dropdownRef, tabIndex: 0, onKeyDown: isSearchAvailable ? noop : handleKeyDown, children: filteredData.length > 0 && (_jsx(List, { ref: listRef, height: isMobile
93
100
  ? window.innerHeight - 80 - 73 - 24
94
101
  : filteredData.length * ITEM_SIZE > DROPDOWN_HEIGHT
95
102
  ? DROPDOWN_HEIGHT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "3.1.8",
3
+ "version": "3.1.10",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",