@bolttech/molecules-dropdown 0.22.0 → 0.22.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.
package/index.cjs
CHANGED
|
@@ -2459,9 +2459,11 @@ const ReusableDropdownComponent = _a => {
|
|
|
2459
2459
|
inputRef,
|
|
2460
2460
|
placeholder,
|
|
2461
2461
|
onBlur,
|
|
2462
|
-
onFocus
|
|
2462
|
+
onFocus,
|
|
2463
|
+
onKeyUp,
|
|
2464
|
+
onKeyDown
|
|
2463
2465
|
} = _a,
|
|
2464
|
-
props = __rest(_a, ["id", "dataTestId", "label", "variant", "required", "inputValue", "inputLabel", "disabled", "errorMessage", "onChangeInputValue", "onChangeInputLabel", "setShowSelectComponent", "showSelectComponent", "setSelectedOptionOnInputValue", "disableSearch", "inputRef", "placeholder", "onBlur", "onFocus"]);
|
|
2466
|
+
props = __rest(_a, ["id", "dataTestId", "label", "variant", "required", "inputValue", "inputLabel", "disabled", "errorMessage", "onChangeInputValue", "onChangeInputLabel", "setShowSelectComponent", "showSelectComponent", "setSelectedOptionOnInputValue", "disableSearch", "inputRef", "placeholder", "onBlur", "onFocus", "onKeyUp", "onKeyDown"]);
|
|
2465
2467
|
const hasError = !!errorMessage;
|
|
2466
2468
|
// we have to type cast because of jest. when testing it sets the type of useTheme to DefaultTheme
|
|
2467
2469
|
const theme = /*#__PURE__*/styled.useTheme();
|
|
@@ -2516,8 +2518,10 @@ const ReusableDropdownComponent = _a => {
|
|
|
2516
2518
|
setSelectedOptionOnInputValue();
|
|
2517
2519
|
setShowSelectComponent(false);
|
|
2518
2520
|
onBlur && onBlur(event);
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
+
},
|
|
2522
|
+
onKeyUp: onKeyUp,
|
|
2523
|
+
onKeyDown: onKeyDown
|
|
2524
|
+
}, uiUtils.applyDataAttributes(props, 'input')))
|
|
2521
2525
|
})]
|
|
2522
2526
|
}), jsxRuntime.jsx(ClickableElement, {
|
|
2523
2527
|
onClick: () => {
|
|
@@ -2682,9 +2686,11 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2682
2686
|
onChange,
|
|
2683
2687
|
onBlur,
|
|
2684
2688
|
onFocus,
|
|
2685
|
-
placeholder
|
|
2689
|
+
placeholder,
|
|
2690
|
+
onKeyUp,
|
|
2691
|
+
onKeyDown
|
|
2686
2692
|
} = _a,
|
|
2687
|
-
props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "id", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder"]);
|
|
2693
|
+
props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "id", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown"]);
|
|
2688
2694
|
const [isFirstRender, setIsFirstRender] = react.useState(true);
|
|
2689
2695
|
const [showSelectComponent, setShowSelectComponent] = react.useState(false);
|
|
2690
2696
|
const [currentOptionList, setCurrentOptionList] = react.useState([]);
|
|
@@ -2727,12 +2733,14 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2727
2733
|
const foundOption = optionList === null || optionList === void 0 ? void 0 : optionList.find(option => option.id === value);
|
|
2728
2734
|
setInternalSelectedOption(foundOption);
|
|
2729
2735
|
setInputValue((foundOption === null || foundOption === void 0 ? void 0 : foundOption.value) || '');
|
|
2730
|
-
|
|
2736
|
+
if (!onKeyUp && !onKeyDown) {
|
|
2737
|
+
setInputLabel((foundOption === null || foundOption === void 0 ? void 0 : foundOption.label) || '');
|
|
2738
|
+
}
|
|
2731
2739
|
}
|
|
2732
2740
|
if (!isFirstRender || currentOptionList.length === 0) return;
|
|
2733
2741
|
setInternalSelectedOption(currentOptionList.find(option => option.id === value));
|
|
2734
2742
|
setIsFirstRender(false);
|
|
2735
|
-
}, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender]);
|
|
2743
|
+
}, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender, onKeyUp, onKeyDown]);
|
|
2736
2744
|
return jsxRuntime.jsxs(SectionContainer, Object.assign({
|
|
2737
2745
|
"$variant": variant,
|
|
2738
2746
|
id: `${id}-container`,
|
|
@@ -2764,7 +2772,9 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2764
2772
|
setSelectedOptionOnInputValue: setSelectedOptionOnInputValue,
|
|
2765
2773
|
onChangeInputLabel: setInputLabel,
|
|
2766
2774
|
onBlur: onBlur,
|
|
2767
|
-
onFocus: onFocus
|
|
2775
|
+
onFocus: onFocus,
|
|
2776
|
+
onKeyUp: onKeyUp,
|
|
2777
|
+
onKeyDown: onKeyDown
|
|
2768
2778
|
}, props)), showSelectComponent && !disabled && jsxRuntime.jsx(DropdownOptionsContainer, {
|
|
2769
2779
|
children: jsxRuntime.jsx(atomsSelect.Select, Object.assign({
|
|
2770
2780
|
id: `${id}-select`,
|
|
@@ -2801,9 +2811,11 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2801
2811
|
onChange,
|
|
2802
2812
|
onBlur,
|
|
2803
2813
|
onFocus,
|
|
2804
|
-
placeholder
|
|
2814
|
+
placeholder,
|
|
2815
|
+
onKeyUp,
|
|
2816
|
+
onKeyDown
|
|
2805
2817
|
} = _a,
|
|
2806
|
-
props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder"]);
|
|
2818
|
+
props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown"]);
|
|
2807
2819
|
const [isFirstRender, setIsFirstRender] = react.useState(true);
|
|
2808
2820
|
const [showSelectComponent, setShowSelectComponent] = react.useState(false);
|
|
2809
2821
|
const [currentOptionList, setCurrentOptionList] = react.useState([]);
|
|
@@ -2850,7 +2862,9 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2850
2862
|
})[0]) || undefined;
|
|
2851
2863
|
setInternalSelectedOption(option);
|
|
2852
2864
|
setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
|
|
2853
|
-
|
|
2865
|
+
if (!onKeyUp && !onKeyDown) {
|
|
2866
|
+
setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
|
|
2867
|
+
}
|
|
2854
2868
|
return;
|
|
2855
2869
|
}
|
|
2856
2870
|
if (!isFirstRender || currentOptionList.length === 0) return;
|
|
@@ -2885,7 +2899,9 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
|
|
|
2885
2899
|
onChangeInputLabel: setInputLabel,
|
|
2886
2900
|
setSelectedOptionOnInputValue: setSelectedOptionOnInputValue,
|
|
2887
2901
|
onBlur: onBlur,
|
|
2888
|
-
onFocus: onFocus
|
|
2902
|
+
onFocus: onFocus,
|
|
2903
|
+
onKeyUp: onKeyUp,
|
|
2904
|
+
onKeyDown: onKeyDown
|
|
2889
2905
|
}, props)), showSelectComponent && !disabled && jsxRuntime.jsx(DropdownOptionsContainer, {
|
|
2890
2906
|
children: jsxRuntime.jsx(atomsSelect.SelectWithHeaders, Object.assign({
|
|
2891
2907
|
dataTestId: `${dataTestId}-select`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { OptionWithHeaderType, OptionType } from '@bolttech/atoms-select';
|
|
3
|
-
export declare const DropdownWithHeaders: import("react").ForwardRefExoticComponent<
|
|
3
|
+
export declare const DropdownWithHeaders: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<HTMLInputElement>, "onKeyUp" | "onKeyDown"> & import("@bolttech/ui-utils").DefaultProps & {
|
|
4
4
|
label: string;
|
|
5
5
|
placeholder?: string | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { OptionType } from '@bolttech/atoms-select';
|
|
3
|
-
export declare const Dropdown: import("react").ForwardRefExoticComponent<
|
|
3
|
+
export declare const Dropdown: import("react").ForwardRefExoticComponent<Pick<import("react").DOMAttributes<HTMLInputElement>, "onKeyUp" | "onKeyDown"> & import("@bolttech/ui-utils").DefaultProps & {
|
|
4
4
|
label: string;
|
|
5
5
|
placeholder?: string | undefined;
|
|
6
6
|
disabled?: boolean | undefined;
|
|
@@ -40,7 +40,7 @@ type DefaultDropdownProps = {
|
|
|
40
40
|
@property setSelectedOption - A function to set the selected option
|
|
41
41
|
@property selectedOption - An optional object representing the currently selected option
|
|
42
42
|
*/
|
|
43
|
-
export type DropdownProps =
|
|
43
|
+
export type DropdownProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
|
|
44
44
|
optionList?: OptionType[];
|
|
45
45
|
/**
|
|
46
46
|
* An optional function that filters the option list based on input value
|
|
@@ -100,7 +100,7 @@ export type DropdownProps = Omit<DOMAttributes<HTMLInputElement>, 'children' | '
|
|
|
100
100
|
@property setSelectedOption - A function to set the selected option
|
|
101
101
|
@property selectedOption - An optional object representing the currently selected option
|
|
102
102
|
*/
|
|
103
|
-
export type DropdownWithHeadersProps =
|
|
103
|
+
export type DropdownWithHeadersProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
|
|
104
104
|
optionList?: OptionWithHeaderType[];
|
|
105
105
|
/**
|
|
106
106
|
* An optional function that filters the option list based on input value
|
|
@@ -170,7 +170,7 @@ export type DropdownWithHeadersProps = Omit<DOMAttributes<HTMLInputElement>, 'ch
|
|
|
170
170
|
@property setSelectedOptionOnInputValue - A function to set the selected option based on the input value
|
|
171
171
|
@property inputRef - A ref to the input element of the dropdown
|
|
172
172
|
*/
|
|
173
|
-
export type ReusableDropdownComponentProps = DefaultProps &
|
|
173
|
+
export type ReusableDropdownComponentProps = DefaultProps & Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'onKeyDown'> & DefaultDropdownProps & {
|
|
174
174
|
setShowSelectComponent: React.Dispatch<React.SetStateAction<boolean>>;
|
|
175
175
|
showSelectComponent: boolean;
|
|
176
176
|
onChangeInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ReusableDropdownComponentProps } from './molecules-dropdown.type';
|
|
2
|
-
export declare const ReusableDropdownComponent: ({ id, dataTestId, label, variant, required, inputValue, inputLabel, disabled, errorMessage, onChangeInputValue, onChangeInputLabel, setShowSelectComponent, showSelectComponent, setSelectedOptionOnInputValue, disableSearch, inputRef, placeholder, onBlur, onFocus, ...props }: ReusableDropdownComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ReusableDropdownComponent: ({ id, dataTestId, label, variant, required, inputValue, inputLabel, disabled, errorMessage, onChangeInputValue, onChangeInputLabel, setShowSelectComponent, showSelectComponent, setSelectedOptionOnInputValue, disableSearch, inputRef, placeholder, onBlur, onFocus, onKeyUp, onKeyDown, ...props }: ReusableDropdownComponentProps) => import("react/jsx-runtime").JSX.Element;
|