@bolttech/molecules-dropdown 0.25.0 → 0.25.1

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/README.md CHANGED
@@ -67,6 +67,9 @@ The **Dropdown** component accepts the following props:
67
67
  | `onFocus` | `function` | Callback function triggered when the dropdown is focused. |
68
68
  | `placeholder` | `string` | Placeholder text for the input. |
69
69
  | `disableSearch` | `boolean` | Boolean that represent if we should disable user searching on the dropdown. Defaults to false |
70
+ | `onKeyUp` | `function` | The onkeyup event occurs when the user releases a key on the keyboard |
71
+ | `onKeyDown` | `boolean` | Onkeydown is an event handler in Javascript that gets called when a key is pressed on the keyboard |
72
+ | `asyncOptionList` | `boolean` | A boolean prop that controls a different behavior when OptionList are set by an API request |
70
73
 
71
74
  ## Functionality
72
75
 
package/index.cjs CHANGED
@@ -2690,9 +2690,10 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2690
2690
  placeholder,
2691
2691
  onKeyUp,
2692
2692
  onKeyDown,
2693
- disableSearch
2693
+ disableSearch,
2694
+ asyncOptionList = false
2694
2695
  } = _a,
2695
- props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "id", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown", "disableSearch"]);
2696
+ props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "id", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown", "disableSearch", "asyncOptionList"]);
2696
2697
  const [isFirstRender, setIsFirstRender] = react.useState(true);
2697
2698
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2698
2699
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
@@ -2735,14 +2736,14 @@ const Dropdown = /*#__PURE__*/react.forwardRef((_a, ref) => {
2735
2736
  const foundOption = optionList === null || optionList === void 0 ? void 0 : optionList.find(option => option.id === value);
2736
2737
  setInternalSelectedOption(foundOption);
2737
2738
  setInputValue((foundOption === null || foundOption === void 0 ? void 0 : foundOption.value) || '');
2738
- if (!onKeyUp && !onKeyDown) {
2739
+ if (!asyncOptionList) {
2739
2740
  setInputLabel((foundOption === null || foundOption === void 0 ? void 0 : foundOption.label) || '');
2740
2741
  }
2741
2742
  }
2742
2743
  if (!isFirstRender || currentOptionList.length === 0) return;
2743
2744
  setInternalSelectedOption(currentOptionList.find(option => option.id === value));
2744
2745
  setIsFirstRender(false);
2745
- }, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender, onKeyUp, onKeyDown]);
2746
+ }, [currentOptionList, setSelectedOptionOnInputValue, value, internalSelectedOption, optionList, isFirstRender, onKeyUp, onKeyDown, asyncOptionList]);
2746
2747
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2747
2748
  "$variant": variant,
2748
2749
  id: `${id}-container`,
@@ -2815,9 +2816,10 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2815
2816
  placeholder,
2816
2817
  onKeyUp,
2817
2818
  onKeyDown,
2818
- disableSearch
2819
+ disableSearch,
2820
+ asyncOptionList = false
2819
2821
  } = _a,
2820
- props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown", "disableSearch"]);
2822
+ props = __rest(_a, ["label", "variant", "required", "optionList", "disabled", "errorMessage", "urlFilterOptions", "dataTestId", "filterOptionsParam", "value", "onChange", "onBlur", "onFocus", "placeholder", "onKeyUp", "onKeyDown", "disableSearch", "asyncOptionList"]);
2821
2823
  const [isFirstRender, setIsFirstRender] = react.useState(true);
2822
2824
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2823
2825
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
@@ -2864,7 +2866,7 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2864
2866
  })[0]) || undefined;
2865
2867
  setInternalSelectedOption(option);
2866
2868
  setInputValue((option === null || option === void 0 ? void 0 : option.value) || '');
2867
- if (!onKeyUp && !onKeyDown) {
2869
+ if (!asyncOptionList) {
2868
2870
  setInputLabel((option === null || option === void 0 ? void 0 : option.label) || '');
2869
2871
  }
2870
2872
  return;
@@ -2874,7 +2876,7 @@ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef((_a, ref) => {
2874
2876
  return optionsList.options.find(option => option.id === value);
2875
2877
  })[0] || undefined);
2876
2878
  setIsFirstRender(false);
2877
- }, [currentOptionList, value, optionList, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id, isFirstRender, onKeyUp, onKeyDown]);
2879
+ }, [currentOptionList, value, optionList, internalSelectedOption === null || internalSelectedOption === void 0 ? void 0 : internalSelectedOption.id, isFirstRender, asyncOptionList]);
2878
2880
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
2879
2881
  "$variant": variant,
2880
2882
  "data-testid": `${dataTestId}-container`,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
8
  "@bolttech/atoms-icon": "0.22.1",
9
- "@bolttech/atoms-input": "0.21.1",
9
+ "@bolttech/atoms-input": "0.0.1",
10
10
  "@bolttech/atoms-select": "0.21.0",
11
- "@bolttech/default-theme": "0.3.0",
11
+ "@bolttech/default-theme": "0.3.1",
12
12
  "@bolttech/form-engine": "0.10.3",
13
13
  "@bolttech/frontend-foundations": "0.3.1",
14
14
  "@bolttech/ui-utils": "0.2.4",
@@ -18,5 +18,6 @@ export declare const DropdownWithHeaders: import("react").ForwardRefExoticCompon
18
18
  urlFilterOptions?: string | undefined;
19
19
  onChange: (selectedOption?: OptionType | undefined) => void | import("react").Dispatch<import("react").SetStateAction<OptionType>>;
20
20
  value?: string | undefined;
21
+ asyncOptionList?: boolean | undefined;
21
22
  } & import("react").RefAttributes<HTMLElement>>;
22
23
  export default DropdownWithHeaders;
@@ -18,5 +18,6 @@ export declare const Dropdown: import("react").ForwardRefExoticComponent<Pick<im
18
18
  urlFilterOptions?: string | undefined;
19
19
  onChange: (selectedOption?: OptionType | undefined) => void | import("react").Dispatch<import("react").SetStateAction<OptionType>>;
20
20
  value?: string | undefined;
21
+ asyncOptionList?: boolean | undefined;
21
22
  } & import("react").RefAttributes<HTMLElement>>;
22
23
  export default Dropdown;
@@ -39,6 +39,7 @@ type DefaultDropdownProps = {
39
39
  @property urlFilterOptions - An optional string representing the url to fetch options
40
40
  @property setSelectedOption - A function to set the selected option
41
41
  @property selectedOption - An optional object representing the currently selected option
42
+ @property asyncOptionList - A boolean prop that controls a different behavior when OptionList are set by an API request
42
43
  */
43
44
  export type DropdownProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
44
45
  optionList?: OptionType[];
@@ -90,6 +91,10 @@ export type DropdownProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'o
90
91
  */
91
92
  onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
92
93
  value?: string;
94
+ /**
95
+ * A boolean prop that controls a different behavior when OptionList are set by an API request
96
+ */
97
+ asyncOptionList?: boolean;
93
98
  };
94
99
  /**
95
100
  Props for DropdownOptionsWithHeaders component
@@ -99,6 +104,7 @@ export type DropdownProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'o
99
104
  @property urlFilterOptions - An optional string representing the url to fetch options
100
105
  @property setSelectedOption - A function to set the selected option
101
106
  @property selectedOption - An optional object representing the currently selected option
107
+ @property asyncOptionList - A boolean prop that controls a different behavior when OptionList are set by an API request
102
108
  */
103
109
  export type DropdownWithHeadersProps = Pick<DOMAttributes<HTMLInputElement>, 'onKeyUp' | 'onKeyDown'> & DefaultProps & DefaultDropdownProps & {
104
110
  optionList?: OptionWithHeaderType[];
@@ -156,6 +162,10 @@ export type DropdownWithHeadersProps = Pick<DOMAttributes<HTMLInputElement>, 'on
156
162
  */
157
163
  onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
158
164
  value?: string;
165
+ /**
166
+ * A boolean prop that controls a different behavior when OptionList are set by an API request
167
+ */
168
+ asyncOptionList?: boolean;
159
169
  };
160
170
  /**
161
171
  Props for ReusableDropdownComponent component