hrm_ui_lib 3.1.10 → 3.1.12

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.
@@ -8,8 +8,9 @@ import { DROPDOWN_HEIGHT, DROPDOWN_WIDTH, ITEM_SIZE, ITEM_SIZE_MOBILE } from '..
8
8
  import classNames from 'classnames';
9
9
  import { noop } from '../../../../utils/helpers';
10
10
  export const MultiBase = (props) => {
11
- const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth } = props;
11
+ const { isMobile, closeDropdown, scrollableContentStyle, options, helperText, translations, onItemSelect, onItemDeselect, isSearchAvailable, setSelectedValues, selectedValues, labelLeftIconProps, labelRightIconComponent, optionRightIconComponent, maxSelectCount, menuOptions, dataIdPrefix, dropdownWidth, applySelectedItems } = props;
12
12
  const { emptyListMainMessage, emptyListSecondaryMessage } = translations || {};
13
+ const [navigationMode, setNavigationMode] = useState(false);
13
14
  const [searchValue, setSearchValue] = useState('');
14
15
  const [isAllSelected, setAllSelected] = useState(false);
15
16
  const [activeIndex, setActiveIndex] = useState(0);
@@ -19,29 +20,40 @@ export const MultiBase = (props) => {
19
20
  switch (e.key) {
20
21
  case 'ArrowDown':
21
22
  e.preventDefault();
22
- setActiveIndex((prev) => Math.min(prev + 1, options.length - 1));
23
+ setActiveIndex((prev) => Math.min(prev + 1, filteredData.length - 1));
24
+ setNavigationMode(true);
23
25
  break;
24
26
  case 'ArrowUp':
25
27
  e.preventDefault();
26
28
  setActiveIndex((prev) => Math.max(prev - 1, 0));
29
+ setNavigationMode(true);
30
+ break;
31
+ case ' ':
32
+ if (navigationMode && activeIndex !== null) {
33
+ e.preventDefault();
34
+ const item = filteredData[activeIndex];
35
+ if (!item) {
36
+ return;
37
+ }
38
+ const isSelected = checkIsSelected(item.value);
39
+ if (isSelected) {
40
+ onDeselect(item);
41
+ }
42
+ else {
43
+ onItemSelect(item);
44
+ }
45
+ }
27
46
  break;
28
47
  case 'Enter':
29
48
  e.preventDefault();
30
- const item = filteredData[activeIndex];
31
- if (!item) {
32
- return;
33
- }
34
- const isSelected = checkIsSelected(item.value);
35
- if (isSelected) {
36
- onDeselect(item);
37
- }
38
- else {
39
- onItemSelect(item);
40
- }
49
+ applySelectedItems();
41
50
  break;
42
51
  case 'Escape':
43
52
  closeDropdown();
44
53
  break;
54
+ default:
55
+ // any typing key exits navigation mode
56
+ setNavigationMode(false);
45
57
  }
46
58
  };
47
59
  useEffect(() => {
@@ -63,6 +63,6 @@ export const MultiSelect = forwardRef((props, _ref) => {
63
63
  // @ts-ignore
64
64
  , Object.assign({
65
65
  // @ts-ignore
66
- options: options, isOpen: isOpen, translations: localizations, setIsOpen: setIsOpen, dropdownRef: dropdownRef, openDropdown: openDropdown, selectedValues: selectedValues, setSelectedValues: setSelectedValues, containerRef: containerRef, dropdownWidth: dropdownWidth, isMobileFullScreen: isMobileFullScreen }, rest)), options.length && !(isMobile && isMobileFullScreen) ? (_jsx(Footer, { checkboxInfo: checkboxInfo, hasChange: hasChange, buttonProps: footerButtonProps, onCancel: cancelSelectedItems, onApply: applySelectedItems, language: language })) : null] }) }));
66
+ options: options, isOpen: isOpen, translations: localizations, setIsOpen: setIsOpen, dropdownRef: dropdownRef, openDropdown: openDropdown, selectedValues: selectedValues, setSelectedValues: setSelectedValues, containerRef: containerRef, dropdownWidth: dropdownWidth, isMobileFullScreen: isMobileFullScreen, applySelectedItems: applySelectedItems }, rest)), options.length && !(isMobile && isMobileFullScreen) ? (_jsx(Footer, { checkboxInfo: checkboxInfo, hasChange: hasChange, buttonProps: footerButtonProps, onCancel: cancelSelectedItems, onApply: applySelectedItems, language: language })) : null] }) }));
67
67
  });
68
68
  MultiSelect.displayName = 'MultiSelect';
@@ -121,6 +121,6 @@ export const Select = forwardRef((props, _ref) => {
121
121
  }, [setCurrentSelectedLabel]);
122
122
  return (_jsxs("div", { "data-id": `${dataId}-content`, className: classNames(`select select--${size}`, className, {
123
123
  'select--opened': isOpen
124
- }), ref: containerRef, children: [!isButtonSelect && (_jsx(Input, { onClick: disabled ? noop : onOpenOptions, size: size === 'large' ? 'large' : 'small', dataId: dataId, hasError: hasError, className: "select__input", label: label, onChange: onSearch, required: isRequiredField, leftIconProps: leftIconProps, rightIconProps: isOpen ? selectRightIconOpenedProps : selectRightIconProps, placeholder: placeHolder, currentValue: searchValue || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label.toString()) || '', isValid: isValid, disabled: disabled, helperText: isOpen ? '' : outerHelperText, ref: inputRef, labelAddons: labelAddons, autoComplete: "false", readOnly: (isMobile && isMobileFullScreen) || !isWithSearch, onKeyDown: handleKeyDown })), isButtonSelect && (_jsx(Button, { size: size, type: "secondary", dataId: dataId, iconProps: selectRightIconProps, buttonText: placeHolder || '', onClick: disabled ? noop : openDropdown, className: "select_button" })), isMobile && isMobileFullScreen ? (_jsx(SelectMobile, Object.assign({}, rest, { isOpen: isOpen, filteredData: filteredData, closeDropdown: closeDropdown, currentSelection: currentSelection, isRequiredField: isRequiredField, onItemDeselect: onItemDeselect, onItemSelect: onItemSelect, translations: localizations, withSearch: withSearch }))) : (_jsx(SelectDesktop, Object.assign({}, rest, { onItemDeselect: onItemDeselect, onItemSelect: onItemSelect, currentSelection: currentSelection, isRequiredField: isRequiredField, filteredData: filteredData, inputRef: inputRef.current, containerRef: containerRef.current, isOpen: isOpen, closeDropdown: closeDropdown, setCurrentSelectedLabel: setCurrentSelectedLabel, searchValue: searchValue, setSearchValue: setSearchValue, translations: localizations, activeIndex: activeIndex, setActiveIndex: setActiveIndex })))] }));
124
+ }), ref: containerRef, children: [!isButtonSelect && (_jsx(Input, { onClick: disabled ? noop : onOpenOptions, size: size === 'large' ? 'large' : 'small', dataId: dataId, hasError: hasError, className: "select__input", label: label, onChange: onSearch, required: isRequiredField, leftIconProps: leftIconProps, rightIconProps: isOpen ? selectRightIconOpenedProps : selectRightIconProps, placeholder: placeHolder, currentValue: searchValue || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label.toString()) || '', isValid: isValid, disabled: disabled, helperText: isOpen ? '' : outerHelperText, ref: inputRef, labelAddons: labelAddons, autoComplete: "false", readOnly: (isMobile && isMobileFullScreen) || !isWithSearch, onKeyDown: handleKeyDown })), isButtonSelect && (_jsx(Button, { size: size, type: "secondary", dataId: dataId, iconProps: selectRightIconProps, buttonText: placeHolder || '', onClick: disabled ? noop : openDropdown, className: "select_button" })), isMobile && isMobileFullScreen ? (_jsx(SelectMobile, Object.assign({}, rest, { isOpen: isOpen, filteredData: filteredData, closeDropdown: closeDropdown, currentSelection: currentSelection, isRequiredField: isRequiredField, onItemDeselect: onItemDeselect, onItemSelect: onItemSelect, translations: localizations, withSearch: withSearch, searchValue: searchValue, setSearchValue: setSearchValue }))) : (_jsx(SelectDesktop, Object.assign({}, rest, { onItemDeselect: onItemDeselect, onItemSelect: onItemSelect, currentSelection: currentSelection, isRequiredField: isRequiredField, filteredData: filteredData, inputRef: inputRef.current, containerRef: containerRef.current, isOpen: isOpen, closeDropdown: closeDropdown, setCurrentSelectedLabel: setCurrentSelectedLabel, searchValue: searchValue, setSearchValue: setSearchValue, translations: localizations, activeIndex: activeIndex, setActiveIndex: setActiveIndex })))] }));
125
125
  });
126
126
  Select.displayName = 'Select';
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
2
  import { OptionItem } from '../../../../helperComponents/OptionItem';
4
3
  import { Empty } from '../../../Empty';
5
4
  import { Modal } from '../../../Modal';
@@ -9,8 +8,7 @@ import { Loading } from '../../SharedComponents';
9
8
  import { MobileTopContent } from './MobileTopContent';
10
9
  import { FixedSizeList as List } from 'react-window';
11
10
  export const SelectMobile = (props) => {
12
- const { translations, currentSelection, isOpen, closeDropdown, isLoading, dataId, innerHelperText, filteredData, isRequiredField, onItemSelect, onItemDeselect, tooltipAddons, labelLeftIconProps, optionRightIconComponent, labelRightIconComponent, withSearch } = props;
13
- const [searchValue, setSearchValue] = useState('');
11
+ const { translations, currentSelection, isOpen, closeDropdown, isLoading, dataId, innerHelperText, filteredData, isRequiredField, onItemSelect, onItemDeselect, tooltipAddons, labelLeftIconProps, optionRightIconComponent, labelRightIconComponent, withSearch, searchValue, setSearchValue } = props;
14
12
  const clickHandler = (isSelected) => ({ value }) => {
15
13
  setSearchValue('');
16
14
  if (!isSelected) {
@@ -66,6 +66,7 @@ interface TMultiSelectCompProps extends IFormCompProps, TSelectBaseProps {
66
66
  }
67
67
  export interface TMultiSingleTabPropTypes extends TMultiSelectCompProps {
68
68
  options: TSelectOptions;
69
+ applySelectedItems: () => void;
69
70
  }
70
71
  export interface TMultiSelectGroupedProps extends TMultiSelectCompProps {
71
72
  options: TSelectGroupOptions;
@@ -149,13 +150,13 @@ export interface ISingleSelectResponsiveProps {
149
150
  isRequiredField?: boolean;
150
151
  translations?: TSelectTranslations;
151
152
  language?: string;
153
+ searchValue: string;
154
+ setSearchValue: (value: string) => void;
152
155
  }
153
156
  export interface ISingleSelectMobileProps extends ISingleSelectResponsiveProps {
154
157
  withSearch: boolean;
155
158
  }
156
159
  export interface ISingleSelectDesktopProps extends ISingleSelectResponsiveProps {
157
- searchValue: string;
158
- setSearchValue: (value: string) => void;
159
160
  withSearch?: boolean;
160
161
  dropdownWidth?: number;
161
162
  inputRef: HTMLInputElement | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "3.1.10",
3
+ "version": "3.1.12",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",