@bolttech/molecules-dropdown 0.10.0 → 0.13.0

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
@@ -1,7 +1,86 @@
1
- # molecules-dropdown
1
+ # Dropdown Component
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ The **Dropdown** component is a customizable React component that provides a dropdown input with a list of selectable options.
4
4
 
5
- ## Running unit tests
5
+ ## Installation
6
6
 
7
- Run `nx test molecules-dropdown` to execute the unit tests via [Jest](https://jestjs.io).
7
+ To use the **Dropdown** component, you need to install the required dependencies:
8
+
9
+ ```bash
10
+ npm install @edirect/frontend-foundations @bolttech/molecules-dropdown
11
+ ```
12
+
13
+ or
14
+
15
+ ```bash
16
+ yarn add @edirect/frontend-foundations @bolttech/molecules-dropdown
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ You can utilize the **Dropdown** component by importing it and including it in your JSX. Here's an example:
22
+
23
+ ```jsx
24
+ import React from 'react';
25
+ import {Dropdown} from '@bolttech/molecules-dropdown'; // Adjust the path to your component
26
+
27
+ const options = [
28
+ { id: '1', label: 'Option 1', value: 'option1' },
29
+ { id: '2', label: 'Option 2', value: 'option2' },
30
+ { id: '3', label: 'Option 3', value: 'option3' },
31
+ ];
32
+
33
+ function App() {
34
+ const handleOptionChange = (selectedOption) => {
35
+ console.log('Selected option:', selectedOption);
36
+ };
37
+
38
+ return (
39
+ <div>
40
+ <Dropdown
41
+ label="Select an option"
42
+ optionList={options}
43
+ value="option2"
44
+ onChange={handleOptionChange}
45
+ />
46
+ </div>
47
+ );
48
+ }
49
+
50
+ export default App;
51
+ ```
52
+
53
+ ## Props
54
+
55
+ The **Dropdown** component accepts the following props:
56
+
57
+ | Prop | Type | Description |
58
+ | --------------------- | ---------------- | ------------------------------------------------------------------------------------------------------- |
59
+ | `label` | `string` | Label for the dropdown. |
60
+ | `variant` | `string` | Variant style of the dropdown. Defaults to `'grey'`. |
61
+ | `required` | `boolean` | Whether the dropdown is required or not. |
62
+ | `optionList` | `OptionType[]` | Array of selectable options for the dropdown. |
63
+ | `disabled` | `boolean` | Whether the dropdown is disabled or not. |
64
+ | `errorMessage` | `string` | Error message to display when there's an error with the dropdown. |
65
+ | `urlFilterOptions` | `string` | URL for fetching filtered options based on input. |
66
+ | `id` | `string` | Component identification. |
67
+ | `dataTestId` | `string` | The data-testid attribute for testing purposes. |
68
+ | `filterOptionsParam` | `function` | Function to filter options based on input and URL. |
69
+ | `value` | `string` | Currently selected value. |
70
+ | `onChange` | `function` | Callback function triggered when the selected option changes. |
71
+ | `onBlur` | `function` | Callback function triggered when the dropdown loses focus. |
72
+ | `onFocus` | `function` | Callback function triggered when the dropdown is focused. |
73
+ | `placeholder` | `string` | Placeholder text for the input. |
74
+
75
+ ## Functionality
76
+
77
+ The **Dropdown** component provides the following functionality:
78
+
79
+ - Option Selection: Allows the user to select an option from the dropdown.
80
+ - Input Interaction: The input field can be focused, blurred, and modified.
81
+ - Filtering: Supports dynamic option filtering based on input and URL.
82
+ - Accessibility: Proper accessibility structure is maintained for interacting with the dropdown.
83
+
84
+ ## Contribution
85
+
86
+ Contributions to the **Dropdown** component are welcomed. If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the component's Bitbucket repository.
package/index.cjs CHANGED
@@ -2632,7 +2632,7 @@ function filterOptionsWithHeaders(inputValue, optionList) {
2632
2632
  });
2633
2633
  }
2634
2634
 
2635
- const Dropdown = ({
2635
+ const Dropdown = /*#__PURE__*/react.forwardRef(({
2636
2636
  label,
2637
2637
  variant: _variant = 'grey',
2638
2638
  required,
@@ -2648,7 +2648,7 @@ const Dropdown = ({
2648
2648
  onBlur,
2649
2649
  onFocus,
2650
2650
  placeholder
2651
- }) => {
2651
+ }, ref) => {
2652
2652
  var _a;
2653
2653
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2654
2654
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
@@ -2697,6 +2697,7 @@ const Dropdown = ({
2697
2697
  style: {
2698
2698
  maxWidth: (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.style.width
2699
2699
  },
2700
+ ref: ref,
2700
2701
  children: [jsxRuntime.jsx(ReusableDropdownComponent, {
2701
2702
  id: _id,
2702
2703
  dataTestId: _dataTestId,
@@ -2735,9 +2736,9 @@ const Dropdown = ({
2735
2736
  })
2736
2737
  })]
2737
2738
  });
2738
- };
2739
+ });
2739
2740
 
2740
- const DropdownWithHeaders = ({
2741
+ const DropdownWithHeaders = /*#__PURE__*/react.forwardRef(({
2741
2742
  label,
2742
2743
  variant: _variant = 'grey',
2743
2744
  required,
@@ -2752,7 +2753,7 @@ const DropdownWithHeaders = ({
2752
2753
  onBlur,
2753
2754
  onFocus,
2754
2755
  placeholder
2755
- }) => {
2756
+ }, ref) => {
2756
2757
  const [showSelectComponent, setShowSelectComponent] = react.useState(false);
2757
2758
  const [currentOptionList, setCurrentOptionList] = react.useState([]);
2758
2759
  const [inputValue, setInputValue] = react.useState('');
@@ -2802,6 +2803,7 @@ const DropdownWithHeaders = ({
2802
2803
  },
2803
2804
  variant: _variant,
2804
2805
  "data-testid": `${dataTestId}-container`,
2806
+ ref: ref,
2805
2807
  children: [jsxRuntime.jsx(ReusableDropdownComponent, {
2806
2808
  label: label,
2807
2809
  variant: _variant,
@@ -2838,7 +2840,7 @@ const DropdownWithHeaders = ({
2838
2840
  })
2839
2841
  })]
2840
2842
  });
2841
- };
2843
+ });
2842
2844
 
2843
2845
  exports.Dropdown = Dropdown;
2844
2846
  exports.DropdownWithHeaders = DropdownWithHeaders;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.10.0",
3
+ "version": "0.13.0",
4
4
  "main": "./index.cjs",
5
5
  "type": "commonjs",
6
6
  "types": "./src/index.d.ts",
7
7
  "dependencies": {
8
- "@bolttech/atoms-icon": "0.6.0",
9
- "@bolttech/atoms-input": "0.11.0",
10
- "@bolttech/atoms-select": "0.2.0",
11
- "@edirect/frontend-foundations": "0.0.58",
8
+ "@bolttech/atoms-icon": "0.19.0",
9
+ "@bolttech/atoms-input": "0.16.0",
10
+ "@bolttech/atoms-select": "0.16.0",
11
+ "@edirect/frontend-foundations": "0.0.67",
12
12
  "jest-styled-components": "7.1.1",
13
13
  "react": "18.2.0",
14
14
  "react-dom": "18.2.0",
@@ -1,3 +1,21 @@
1
1
  /// <reference types="react" />
2
- import { DropdownWithHeadersProps } from './molecules-dropdown.type';
3
- export declare const DropdownWithHeaders: ({ label, variant, required, optionList, disabled, errorMessage, urlFilterOptions, dataTestId, filterOptionsParam, value, onChange, onBlur, onFocus, placeholder, }: DropdownWithHeadersProps) => JSX.Element;
2
+ import { OptionWithHeaderType, OptionType } from '@bolttech/atoms-select';
3
+ export declare const DropdownWithHeaders: import("react").ForwardRefExoticComponent<{
4
+ label: string;
5
+ placeholder?: string | undefined;
6
+ disabled?: boolean | undefined;
7
+ id?: string | undefined;
8
+ dataTestId?: string | undefined;
9
+ errorMessage?: string | undefined;
10
+ required?: boolean | undefined;
11
+ variant?: import("./molecules-dropdown.type").StyleVariants | undefined;
12
+ onBlur?: ((value?: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
13
+ onFocus?: ((value?: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
14
+ } & {
15
+ optionList?: OptionWithHeaderType[] | undefined;
16
+ filterOptionsParam?: ((inputValue: string, optionList?: OptionWithHeaderType[] | undefined, urlValue?: string | undefined) => OptionWithHeaderType[] | Promise<OptionWithHeaderType[]>) | undefined;
17
+ urlFilterOptions?: string | undefined;
18
+ onChange: (selectedOption?: OptionType | undefined) => void | import("react").Dispatch<import("react").SetStateAction<OptionType>>;
19
+ value?: string | undefined;
20
+ } & import("react").RefAttributes<HTMLElement>>;
21
+ export default DropdownWithHeaders;
@@ -1,3 +1,21 @@
1
1
  /// <reference types="react" />
2
- import { DropdownProps } from './molecules-dropdown.type';
3
- export declare const Dropdown: ({ label, variant, required, optionList, disabled, errorMessage, urlFilterOptions, id, dataTestId, filterOptionsParam, value, onChange, onBlur, onFocus, placeholder, }: DropdownProps) => JSX.Element;
2
+ import { OptionType } from '@bolttech/atoms-select';
3
+ export declare const Dropdown: import("react").ForwardRefExoticComponent<{
4
+ label: string;
5
+ placeholder?: string | undefined;
6
+ disabled?: boolean | undefined;
7
+ id?: string | undefined;
8
+ dataTestId?: string | undefined;
9
+ errorMessage?: string | undefined;
10
+ required?: boolean | undefined;
11
+ variant?: import("./molecules-dropdown.type").StyleVariants | undefined;
12
+ onBlur?: ((value?: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
13
+ onFocus?: ((value?: unknown) => void) | ((evt: import("react").FocusEvent<HTMLElement, Element>) => void) | undefined;
14
+ } & {
15
+ optionList?: OptionType[] | undefined;
16
+ filterOptionsParam?: ((inputValue: string, optionList?: OptionType[] | undefined, urlValue?: string | undefined) => OptionType[] | Promise<OptionType[]>) | undefined;
17
+ urlFilterOptions?: string | undefined;
18
+ onChange: (selectedOption?: OptionType | undefined) => void | import("react").Dispatch<import("react").SetStateAction<OptionType>>;
19
+ value?: string | undefined;
20
+ } & import("react").RefAttributes<HTMLElement>>;
21
+ export default Dropdown;