@bolttech/molecules-dropdown 0.1.8 → 0.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.
package/README.md CHANGED
@@ -4,5 +4,4 @@ This library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  ## Running unit tests
6
6
 
7
-
8
7
  Run `nx test molecules-dropdown` to execute the unit tests via [Jest](https://jestjs.io).
package/index.cjs CHANGED
@@ -2252,7 +2252,7 @@ const ClickableElement = /*#__PURE__*/styled__default["default"].div.withConfig(
2252
2252
  const ContainerDropdown = /*#__PURE__*/styled__default["default"].section.withConfig({
2253
2253
  displayName: "molecules-dropdownstyles__ContainerDropdown",
2254
2254
  componentId: "sc-3wugi4-1"
2255
- })(["display:flex;padding-top:", ";padding-bottom:", ";padding-right:", ";padding-left:", ";gap:", ";background-color:", ";border:", ";border-radius:", ";box-shadow:", ";.fieldLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}.requiredLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}svg{fill:", ";}&:focus-within{background-color:", ";border:", ";", "}", " ", ""], ({
2255
+ })(["display:flex;padding-top:", ";padding-bottom:", ";padding-right:", ";padding-left:", ";gap:", ";background-color:", ";border:", ";border-radius:", ";box-shadow:", ";input{display:inline-block;text-overflow:ellipsis;white-space:nowrap;width:100%;overflow-x:hidden;}.fieldLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}.requiredLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}svg{fill:", ";}&:focus-within{background-color:", ";border:", ";", "}", " ", ""], ({
2256
2256
  theme
2257
2257
  }) => theme.components.dropdown.paddingVertical, ({
2258
2258
  theme
@@ -2374,7 +2374,7 @@ const ContainerDropdown = /*#__PURE__*/styled__default["default"].section.withCo
2374
2374
  const SectionContainer = /*#__PURE__*/styled__default["default"].section.withConfig({
2375
2375
  displayName: "molecules-dropdownstyles__SectionContainer",
2376
2376
  componentId: "sc-3wugi4-2"
2377
- })(["width:fit-content;.errorMessage{padding-right:", ";padding-left:", ";label{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}}"], ({
2377
+ })([".errorMessage{padding-right:", ";padding-left:", ";label{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}}"], ({
2378
2378
  theme
2379
2379
  }) => theme.components.dropdown.paddingHorizontal, ({
2380
2380
  theme
@@ -2399,7 +2399,7 @@ const InputAndIconDropdown = /*#__PURE__*/styled__default["default"].div.withCon
2399
2399
  const ContentDropdown = /*#__PURE__*/styled__default["default"].div.withConfig({
2400
2400
  displayName: "molecules-dropdownstyles__ContentDropdown",
2401
2401
  componentId: "sc-3wugi4-4"
2402
- })(["display:flex;flex-direction:column;gap:", ";"], ({
2402
+ })(["flex:1;display:flex;flex-direction:column;gap:", ";"], ({
2403
2403
  theme
2404
2404
  }) => theme.components.dropdown.contentGap);
2405
2405
  const FieldLabelAndRequiredLabelDropdown = /*#__PURE__*/styled__default["default"].div.withConfig({
@@ -2414,10 +2414,12 @@ const ReusableDropdownComponent = ({
2414
2414
  variant: _variant = 'grey',
2415
2415
  required,
2416
2416
  inputValue,
2417
+ inputLabel,
2417
2418
  hasError,
2418
2419
  disabled,
2419
2420
  errorMessage,
2420
2421
  onChangeInputValue,
2422
+ onChangeInputLabel,
2421
2423
  setShowSelectComponent,
2422
2424
  showSelectComponent,
2423
2425
  setSelectedOptionOnInputValue,
@@ -2458,16 +2460,18 @@ const ReusableDropdownComponent = ({
2458
2460
  "data-testid": `${dataTestId}-input`,
2459
2461
  ref: inputRef,
2460
2462
  disabled: disabled,
2461
- value: inputValue,
2463
+ value: inputLabel,
2462
2464
  variant: _variant,
2463
2465
  placeholder: placeholder,
2464
2466
  onChange: e => {
2465
- var _a;
2467
+ var _a, _b;
2466
2468
  onChangeInputValue(((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value) || '');
2469
+ onChangeInputLabel(((_b = e === null || e === void 0 ? void 0 : e.target) === null || _b === void 0 ? void 0 : _b.value) || '');
2467
2470
  setShowSelectComponent(true);
2468
2471
  },
2469
2472
  onFocus: () => {
2470
2473
  onChangeInputValue('');
2474
+ onChangeInputLabel('');
2471
2475
  setShowSelectComponent(true);
2472
2476
  },
2473
2477
  onBlur: () => {
@@ -2638,9 +2642,11 @@ const Dropdown = ({
2638
2642
  setSelectedOption,
2639
2643
  placeholder
2640
2644
  }) => {
2645
+ var _a;
2641
2646
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2642
2647
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2643
2648
  const [inputValue, setInputValue] = react.useState('');
2649
+ const [inputLabel, setInputLabel] = react.useState('');
2644
2650
  const inputRef = react.useRef(null);
2645
2651
  react.useEffect(() => {
2646
2652
  const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2651,11 +2657,15 @@ const Dropdown = ({
2651
2657
  const setSelectedOptionOnInputValue = react.useCallback(() => {
2652
2658
  if (!inputValue && selectedOption) {
2653
2659
  setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2660
+ setInputLabel((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '');
2654
2661
  return;
2655
2662
  }
2656
2663
  if (inputValue !== (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value)) {
2657
2664
  const isValidValue = currentOptionList.some(currentOption => currentOption.value === inputValue);
2658
- if (!isValidValue) setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2665
+ if (!isValidValue) {
2666
+ setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2667
+ setInputLabel((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '');
2668
+ }
2659
2669
  }
2660
2670
  }, [currentOptionList, inputValue, selectedOption]);
2661
2671
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
@@ -2664,13 +2674,17 @@ const Dropdown = ({
2664
2674
  return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
2665
2675
  },
2666
2676
  variant: _variant,
2667
- "data-testid": `${dataTestId}-container`
2677
+ "data-testid": `${dataTestId}-container`,
2678
+ style: {
2679
+ maxWidth: (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.style.width
2680
+ }
2668
2681
  }, {
2669
2682
  children: [jsxRuntime.jsx(ReusableDropdownComponent, {
2670
2683
  label: label,
2671
2684
  variant: _variant,
2672
2685
  required: required,
2673
2686
  inputValue: inputValue,
2687
+ inputLabel: inputLabel,
2674
2688
  dataTestId: dataTestId,
2675
2689
  disabled: disabled,
2676
2690
  errorMessage: errorMessage,
@@ -2680,12 +2694,14 @@ const Dropdown = ({
2680
2694
  placeholder: placeholder,
2681
2695
  setShowSelectComponent: setShowSelectComponent,
2682
2696
  onChangeInputValue: setInputValue,
2683
- setSelectedOptionOnInputValue: setSelectedOptionOnInputValue
2697
+ setSelectedOptionOnInputValue: setSelectedOptionOnInputValue,
2698
+ onChangeInputLabel: setInputLabel
2684
2699
  }), showSelectComponent && !disabled && jsxRuntime.jsx("div", {
2685
2700
  children: jsxRuntime.jsx(atomsSelect.Select, {
2686
2701
  dataTestId: `${dataTestId}-select`,
2687
2702
  onChange: selectedValue => {
2688
2703
  setInputValue(selectedValue.value);
2704
+ setInputLabel(selectedValue.label);
2689
2705
  setSelectedOption(selectedValue);
2690
2706
  },
2691
2707
  active: selectedOption,
@@ -2713,6 +2729,7 @@ const DropdownOptionsWithHeaders = ({
2713
2729
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2714
2730
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2715
2731
  const [inputValue, setInputValue] = react.useState('');
2732
+ const [inputLabel, setInputLabel] = react.useState('');
2716
2733
  const inputRef = react.useRef(null);
2717
2734
  react.useEffect(() => {
2718
2735
  const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2723,6 +2740,7 @@ const DropdownOptionsWithHeaders = ({
2723
2740
  const setSelectedOptionOnInputValue = react.useCallback(() => {
2724
2741
  if (!inputValue && selectedOption) {
2725
2742
  setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2743
+ setInputLabel((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '');
2726
2744
  return;
2727
2745
  }
2728
2746
  if (inputValue !== (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value)) {
@@ -2731,7 +2749,10 @@ const DropdownOptionsWithHeaders = ({
2731
2749
  isValidValue = currentOptionsGroup.options.some(currentOption => currentOption.value === inputValue);
2732
2750
  if (isValidValue) return;
2733
2751
  });
2734
- if (!isValidValue) setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2752
+ if (!isValidValue) {
2753
+ setInputLabel((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || '');
2754
+ setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
2755
+ }
2735
2756
  }
2736
2757
  }, [currentOptionList, inputValue, selectedOption]);
2737
2758
  return jsxRuntime.jsxs(SectionContainer, Object.assign({
@@ -2747,6 +2768,7 @@ const DropdownOptionsWithHeaders = ({
2747
2768
  variant: _variant,
2748
2769
  required: required,
2749
2770
  inputValue: inputValue,
2771
+ inputLabel: inputLabel,
2750
2772
  dataTestId: dataTestId,
2751
2773
  disabled: disabled,
2752
2774
  errorMessage: errorMessage,
@@ -2756,11 +2778,13 @@ const DropdownOptionsWithHeaders = ({
2756
2778
  placeholder: placeholder,
2757
2779
  setShowSelectComponent: setShowSelectComponent,
2758
2780
  onChangeInputValue: setInputValue,
2781
+ onChangeInputLabel: setInputLabel,
2759
2782
  setSelectedOptionOnInputValue: setSelectedOptionOnInputValue
2760
2783
  }), showSelectComponent && !disabled && jsxRuntime.jsx("div", {
2761
2784
  children: jsxRuntime.jsx(atomsSelect.SelectWithHeaders, {
2762
2785
  dataTestId: `${dataTestId}-select`,
2763
2786
  onChange: selectedValue => {
2787
+ setInputLabel(selectedValue.label);
2764
2788
  setInputValue(selectedValue.value);
2765
2789
  setSelectedOption(selectedValue);
2766
2790
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "dependencies": {
5
5
  "@bolttech/atoms-icon": "0.0.1",
6
6
  "@bolttech/atoms-input": "0.0.1"
@@ -9,7 +9,8 @@
9
9
  "type": "commonjs",
10
10
  "types": "./src/index.d.ts",
11
11
  "peerDependencies": {
12
- "@bolttech/atoms-select": "0.1.5",
12
+ "@bolttech/atoms-select": "0.1.7",
13
+ "@edirect/frontend-foundations": "0.0.36",
13
14
  "jest-styled-components": "7.1.1",
14
15
  "react": "18.2.0",
15
16
  "styled-components": "5.3.6"
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { DropdownProps } from './molecules-dropdown.type';
3
- export declare const Dropdown: ({ label, variant, required, hasError, optionList, disabled, errorMessage, urlFilterOptions, dataTestId, filterOptionsParam, selectedOption, setSelectedOption, placeholder }: DropdownProps) => JSX.Element;
3
+ export declare const Dropdown: ({ label, variant, required, hasError, optionList, disabled, errorMessage, urlFilterOptions, dataTestId, filterOptionsParam, selectedOption, setSelectedOption, placeholder, }: DropdownProps) => JSX.Element;
@@ -160,7 +160,9 @@ export type DropdownOptionsWithHeadersProps = DefaultProps & {
160
160
  @property setShowSelectComponent - A function to set the visibility of the dropdown
161
161
  @property showSelectComponent - A boolean indicating the visibility of the dropdown
162
162
  @property onChangeInputValue - A function to set the input value of the dropdown
163
+ @property onChangeInputLabel - A function to set the input label of the dropdown
163
164
  @property inputValue - A string representing the input value of the dropdown
165
+ @property inputLabel - A string representing the input value of the dropdown that will show on field
164
166
  @property setSelectedOptionOnInputValue - A function to set the selected option based on the input value
165
167
  @property inputRef - A ref to the input element of the dropdown
166
168
  */
@@ -168,7 +170,9 @@ export type ReusableDropdownComponentProps = DefaultProps & {
168
170
  setShowSelectComponent: React.Dispatch<React.SetStateAction<boolean>>;
169
171
  showSelectComponent: boolean;
170
172
  onChangeInputValue: React.Dispatch<React.SetStateAction<string>>;
173
+ onChangeInputLabel: React.Dispatch<React.SetStateAction<string>>;
171
174
  inputValue: string;
175
+ inputLabel: string;
172
176
  setSelectedOptionOnInputValue: () => void;
173
177
  inputRef: React.RefObject<HTMLInputElement>;
174
178
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { ReusableDropdownComponentProps } from './molecules-dropdown.type';
3
- export declare const ReusableDropdownComponent: ({ label, variant, required, inputValue, hasError, disabled, errorMessage, onChangeInputValue, setShowSelectComponent, showSelectComponent, setSelectedOptionOnInputValue, inputRef, dataTestId, placeholder, }: ReusableDropdownComponentProps) => JSX.Element;
3
+ export declare const ReusableDropdownComponent: ({ label, variant, required, inputValue, inputLabel, hasError, disabled, errorMessage, onChangeInputValue, onChangeInputLabel, setShowSelectComponent, showSelectComponent, setSelectedOptionOnInputValue, inputRef, dataTestId, placeholder, }: ReusableDropdownComponentProps) => JSX.Element;