@bolttech/molecules-dropdown 0.5.0 → 0.6.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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bolttech/molecules-dropdown",
3
- "version": "0.5.0",
3
+ "version": "0.6.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.5.1",
9
- "@bolttech/atoms-input": "0.5.0",
10
- "@bolttech/atoms-select": "0.5.1",
11
- "@edirect/frontend-foundations": "0.0.55",
8
+ "@bolttech/atoms-icon": "0.6.0",
9
+ "@bolttech/atoms-input": "0.6.0",
10
+ "@bolttech/atoms-select": "0.6.0",
11
+ "@edirect/frontend-foundations": "0.0.56",
12
12
  "jest-styled-components": "7.1.1",
13
13
  "react": "18.2.0",
14
14
  "react-dom": "18.2.0",
package/src/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Dropdown } from './lib/molecules-dropdown';
2
- export { DropdownWithHeaders } from './lib/molecules-dropdown-with-header-options';
3
- export type { DropdownProps, DropdownWithHeadersProps, } from './lib/molecules-dropdown.type';
1
+ export { Dropdown } from './lib/molecules-dropdown';
2
+ export { DropdownWithHeaders } from './lib/molecules-dropdown-with-header-options';
3
+ export type { DropdownProps, DropdownWithHeadersProps, } from './lib/molecules-dropdown.type';
@@ -1,3 +1,3 @@
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;
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;
@@ -1,3 +1,3 @@
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;
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;
@@ -1,15 +1,15 @@
1
- import { StyleVariants } from './molecules-dropdown.type';
2
- type DropdownStyledProps = {
3
- variant: StyleVariants;
4
- hasValue: string;
5
- hasError?: boolean;
6
- disabled?: boolean;
7
- };
8
- export declare const ClickableElement: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
- export declare const ContainerDropdown: import("styled-components").StyledComponent<"section", import("styled-components").DefaultTheme, DropdownStyledProps, never>;
10
- export declare const SectionContainer: import("styled-components").StyledComponent<"section", import("styled-components").DefaultTheme, Omit<DropdownStyledProps, "hasValue">, never>;
11
- export declare const InputAndIconDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
- export declare const ContentDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
13
- export declare const FieldLabelAndRequiredLabelDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
14
- export declare const DropdownOptionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
15
- export {};
1
+ import { StyleVariants } from './molecules-dropdown.type';
2
+ type DropdownStyledProps = {
3
+ variant: StyleVariants;
4
+ hasValue: string;
5
+ hasError?: boolean;
6
+ disabled?: boolean;
7
+ };
8
+ export declare const ClickableElement: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
+ export declare const ContainerDropdown: import("styled-components").StyledComponent<"section", import("styled-components").DefaultTheme, DropdownStyledProps, never>;
10
+ export declare const SectionContainer: import("styled-components").StyledComponent<"section", import("styled-components").DefaultTheme, Omit<DropdownStyledProps, "hasValue">, never>;
11
+ export declare const InputAndIconDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
+ export declare const ContentDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
13
+ export declare const FieldLabelAndRequiredLabelDropdown: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
14
+ export declare const DropdownOptionsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
15
+ export {};
@@ -1,180 +1,180 @@
1
- /// <reference types="react" />
2
- import { OptionType, OptionWithHeaderType } from '@bolttech/atoms-select';
3
- /**
4
- * @typedef {StyleVariants}
5
- The string value possibilities to affect the theme
6
- */
7
- export type StyleVariants = 'grey' | 'border';
8
- /**
1
+ /// <reference types="react" />
2
+ import { OptionType, OptionWithHeaderType } from '@bolttech/atoms-select';
3
+ /**
4
+ * @typedef {StyleVariants}
5
+ The string value possibilities to affect the theme
6
+ */
7
+ export type StyleVariants = 'grey' | 'border';
8
+ /**
9
9
 
10
- Default props for Dropdown component
11
- @property label - A string to display as the label of the dropdown
12
- @property placeholder - An optional string to display as the placeholder of the dropdown
13
- @property disabled - An optional boolean to disable the dropdown
14
- @property dataTestId - An optional string to use as the data-testid attribute for the dropdown
15
- @property errorMessage - An optional string to display as an error message for the dropdown
16
- @property required - An optional boolean to indicate if the dropdown is required
17
- @property variant - An optional string to set the variant of the dropdown
18
- */
19
- type DefaultProps = {
20
- label: string;
21
- placeholder?: string;
22
- disabled?: boolean;
23
- id?: string;
24
- dataTestId?: string;
25
- errorMessage?: string;
26
- required?: boolean;
27
- variant?: StyleVariants;
28
- onBlur?: ((value?: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);
29
- onFocus?: ((value?: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);
30
- };
31
- /**
32
- Props for Dropdown component
33
- @extends DefaultProps
34
- @property optionList - An optional array of option objects to display in the dropdown
35
- @property filterOptionsParam - An optional function that filters the option list based on input value
36
- @property urlFilterOptions - An optional string representing the url to fetch options
37
- @property setSelectedOption - A function to set the selected option
38
- @property selectedOption - An optional object representing the currently selected option
39
- */
40
- export type DropdownProps = DefaultProps & {
41
- optionList?: OptionType[];
42
- /**
43
- * An optional function that filters the option list based on input value
44
- * The function can be get by the current optionList or can get by url from server side
45
- * @example
46
- * // Filter by current optionList
47
- * function filterOptions(inputValue: string, optionList?: OptionType[]) {
48
- * if (!optionList) return [];
49
- * if (!inputValue) return optionList;
50
- * return optionList.filter(
51
- * (opt) =>
52
- * opt.label.toLowerCase().search(inputValue.trim().toLowerCase()) !== -1
53
- * );
54
- * }
55
- * @example
56
- * // Filter by url
57
- * function filterOptions(inputValue: string, optionList?: OptionType[], urlValue?: string) {
58
- * if (!inputValue || !urlValue) return [];
59
- * return fetch(`${urlValue}?valueSearch=${inputValue}`)
60
- * .then(response => {
61
- * if (!response.ok) {
62
- * throw new Error('Network response was not ok');
63
- * }
64
- * return response.json();
65
- * })
66
- * .then(data => {
67
- * const options: OptionType[] = data.map(option => ({
68
- * label: option.name,
69
- * value: option.id
70
- * }));
71
- * return options;
72
- * });
73
- * }
74
- */
75
- filterOptionsParam?: (inputValue: string, optionList?: OptionType[], urlValue?: string) => OptionType[] | Promise<OptionType[]>;
76
- urlFilterOptions?: string;
77
- /**
78
- * A function to set the selected option it's possible to use a void function or useStateFunction
79
- * @example useStateFunction
80
- * const [selectedOption, setSelectedOption] = useState<OptionType>();
81
- * <Dropdown setSelectedOption={setSelectedOption} />
82
- * @example void
83
- * const manipulateData = (selectedOption?: OptionType) => {
84
- * console.log(selectedOption);
85
- * }
86
- * <Dropdown setSelectedOption={manipulateData} />
87
- */
88
- onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
89
- value?: OptionType;
90
- };
91
- /**
92
- Props for DropdownOptionsWithHeaders component
93
- @extends DefaultProps
94
- @property optionList - An optional array of option objects to display in the dropdown with headers
95
- @property filterOptionsParam - An optional function that filters the option list based on input value
96
- @property urlFilterOptions - An optional string representing the url to fetch options
97
- @property setSelectedOption - A function to set the selected option
98
- @property selectedOption - An optional object representing the currently selected option
99
- */
100
- export type DropdownWithHeadersProps = DefaultProps & {
101
- optionList?: OptionWithHeaderType[];
102
- /**
103
- * An optional function that filters the option list based on input value
104
- * The function can be get by the current optionList or can get by url from server side
105
- * @example
106
- * // Filter by current optionList
107
- * function filterOptionsWithHeaders(
108
- * inputValue: string,
109
- * optionList?: OptionWithHeaderType[]
110
- * ) {
111
- * if (!optionList) return [];
112
- * if (!inputValue) return optionList;
113
- * return optionList.map((element) => {
114
- * return {
115
- * ...element,
116
- * options: element.options.filter(
117
- * (subElement) =>
118
- * subElement.label
119
- * .toLowerCase()
120
- * .search(inputValue.trim().toLowerCase()) !== -1
121
- * ),
122
- * };
123
- * });
124
- * }
125
- * @example
126
- * // Filter by url
127
- * function filterOptions(inputValue: string, optionList?: OptionWithHeaderType[], urlValue?: string) {
128
- * if (!inputValue || !urlValue) return [];
129
- * return fetch(`${urlValue}?valueSearch=${inputValue}`)
130
- * .then(response => {
131
- * if (!response.ok) {
132
- * throw new Error('Network response was not ok');
133
- * }
134
- * return response.json();
135
- * })
136
- * .then(data => {
137
- * return options as OptionWithHeaderType[];
138
- * });
139
- * }
140
- */
141
- filterOptionsParam?: (inputValue: string, optionList?: OptionWithHeaderType[], urlValue?: string) => OptionWithHeaderType[] | Promise<OptionWithHeaderType[]>;
142
- urlFilterOptions?: string;
143
- /**
144
- * A function to set the selected option it's possible to use a void function or useStateFunction
145
- * @example useStateFunction
146
- * const [selectedOption, setSelectedOption] = useState<OptionType>();
147
- * <Dropdown setSelectedOption={setSelectedOption} />
148
- * @example void
149
- * const manipulateData = (selectedOption?: OptionType) => {
150
- * console.log(selectedOption);
151
- * }
152
- * <Dropdown setSelectedOption={manipulateData} />
153
- */
154
- onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
155
- value?: OptionType;
156
- };
157
- /**
158
- Props for ReusableDropdownComponent component
159
- This type will be private, it will be use by only by our ReusableDropdownComponent
160
- @extends DefaultProps
161
- @property setShowSelectComponent - A function to set the visibility of the dropdown
162
- @property showSelectComponent - A boolean indicating the visibility of the dropdown
163
- @property onChangeInputValue - A function to set the input value of the dropdown
164
- @property onChangeInputLabel - A function to set the input label of the dropdown
165
- @property inputValue - A string representing the input value of the dropdown
166
- @property inputLabel - A string representing the input value of the dropdown that will show on field
167
- @property setSelectedOptionOnInputValue - A function to set the selected option based on the input value
168
- @property inputRef - A ref to the input element of the dropdown
169
- */
170
- export type ReusableDropdownComponentProps = DefaultProps & {
171
- setShowSelectComponent: React.Dispatch<React.SetStateAction<boolean>>;
172
- showSelectComponent: boolean;
173
- onChangeInputValue: React.Dispatch<React.SetStateAction<string>>;
174
- onChangeInputLabel: React.Dispatch<React.SetStateAction<string>>;
175
- inputValue: string;
176
- inputLabel: string;
177
- setSelectedOptionOnInputValue: () => void;
178
- inputRef: React.RefObject<HTMLInputElement>;
179
- };
180
- export {};
10
+ Default props for Dropdown component
11
+ @property label - A string to display as the label of the dropdown
12
+ @property placeholder - An optional string to display as the placeholder of the dropdown
13
+ @property disabled - An optional boolean to disable the dropdown
14
+ @property dataTestId - An optional string to use as the data-testid attribute for the dropdown
15
+ @property errorMessage - An optional string to display as an error message for the dropdown
16
+ @property required - An optional boolean to indicate if the dropdown is required
17
+ @property variant - An optional string to set the variant of the dropdown
18
+ */
19
+ type DefaultProps = {
20
+ label: string;
21
+ placeholder?: string;
22
+ disabled?: boolean;
23
+ id?: string;
24
+ dataTestId?: string;
25
+ errorMessage?: string;
26
+ required?: boolean;
27
+ variant?: StyleVariants;
28
+ onBlur?: ((value?: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);
29
+ onFocus?: ((value?: unknown) => void) | ((evt: React.FocusEvent<HTMLElement, Element>) => void);
30
+ };
31
+ /**
32
+ Props for Dropdown component
33
+ @extends DefaultProps
34
+ @property optionList - An optional array of option objects to display in the dropdown
35
+ @property filterOptionsParam - An optional function that filters the option list based on input value
36
+ @property urlFilterOptions - An optional string representing the url to fetch options
37
+ @property setSelectedOption - A function to set the selected option
38
+ @property selectedOption - An optional object representing the currently selected option
39
+ */
40
+ export type DropdownProps = DefaultProps & {
41
+ optionList?: OptionType[];
42
+ /**
43
+ * An optional function that filters the option list based on input value
44
+ * The function can be get by the current optionList or can get by url from server side
45
+ * @example
46
+ * // Filter by current optionList
47
+ * function filterOptions(inputValue: string, optionList?: OptionType[]) {
48
+ * if (!optionList) return [];
49
+ * if (!inputValue) return optionList;
50
+ * return optionList.filter(
51
+ * (opt) =>
52
+ * opt.label.toLowerCase().search(inputValue.trim().toLowerCase()) !== -1
53
+ * );
54
+ * }
55
+ * @example
56
+ * // Filter by url
57
+ * function filterOptions(inputValue: string, optionList?: OptionType[], urlValue?: string) {
58
+ * if (!inputValue || !urlValue) return [];
59
+ * return fetch(`${urlValue}?valueSearch=${inputValue}`)
60
+ * .then(response => {
61
+ * if (!response.ok) {
62
+ * throw new Error('Network response was not ok');
63
+ * }
64
+ * return response.json();
65
+ * })
66
+ * .then(data => {
67
+ * const options: OptionType[] = data.map(option => ({
68
+ * label: option.name,
69
+ * value: option.id
70
+ * }));
71
+ * return options;
72
+ * });
73
+ * }
74
+ */
75
+ filterOptionsParam?: (inputValue: string, optionList?: OptionType[], urlValue?: string) => OptionType[] | Promise<OptionType[]>;
76
+ urlFilterOptions?: string;
77
+ /**
78
+ * A function to set the selected option it's possible to use a void function or useStateFunction
79
+ * @example useStateFunction
80
+ * const [selectedOption, setSelectedOption] = useState<OptionType>();
81
+ * <Dropdown setSelectedOption={setSelectedOption} />
82
+ * @example void
83
+ * const manipulateData = (selectedOption?: OptionType) => {
84
+ * console.log(selectedOption);
85
+ * }
86
+ * <Dropdown setSelectedOption={manipulateData} />
87
+ */
88
+ onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
89
+ value?: string;
90
+ };
91
+ /**
92
+ Props for DropdownOptionsWithHeaders component
93
+ @extends DefaultProps
94
+ @property optionList - An optional array of option objects to display in the dropdown with headers
95
+ @property filterOptionsParam - An optional function that filters the option list based on input value
96
+ @property urlFilterOptions - An optional string representing the url to fetch options
97
+ @property setSelectedOption - A function to set the selected option
98
+ @property selectedOption - An optional object representing the currently selected option
99
+ */
100
+ export type DropdownWithHeadersProps = DefaultProps & {
101
+ optionList?: OptionWithHeaderType[];
102
+ /**
103
+ * An optional function that filters the option list based on input value
104
+ * The function can be get by the current optionList or can get by url from server side
105
+ * @example
106
+ * // Filter by current optionList
107
+ * function filterOptionsWithHeaders(
108
+ * inputValue: string,
109
+ * optionList?: OptionWithHeaderType[]
110
+ * ) {
111
+ * if (!optionList) return [];
112
+ * if (!inputValue) return optionList;
113
+ * return optionList.map((element) => {
114
+ * return {
115
+ * ...element,
116
+ * options: element.options.filter(
117
+ * (subElement) =>
118
+ * subElement.label
119
+ * .toLowerCase()
120
+ * .search(inputValue.trim().toLowerCase()) !== -1
121
+ * ),
122
+ * };
123
+ * });
124
+ * }
125
+ * @example
126
+ * // Filter by url
127
+ * function filterOptions(inputValue: string, optionList?: OptionWithHeaderType[], urlValue?: string) {
128
+ * if (!inputValue || !urlValue) return [];
129
+ * return fetch(`${urlValue}?valueSearch=${inputValue}`)
130
+ * .then(response => {
131
+ * if (!response.ok) {
132
+ * throw new Error('Network response was not ok');
133
+ * }
134
+ * return response.json();
135
+ * })
136
+ * .then(data => {
137
+ * return options as OptionWithHeaderType[];
138
+ * });
139
+ * }
140
+ */
141
+ filterOptionsParam?: (inputValue: string, optionList?: OptionWithHeaderType[], urlValue?: string) => OptionWithHeaderType[] | Promise<OptionWithHeaderType[]>;
142
+ urlFilterOptions?: string;
143
+ /**
144
+ * A function to set the selected option it's possible to use a void function or useStateFunction
145
+ * @example useStateFunction
146
+ * const [selectedOption, setSelectedOption] = useState<OptionType>();
147
+ * <Dropdown setSelectedOption={setSelectedOption} />
148
+ * @example void
149
+ * const manipulateData = (selectedOption?: OptionType) => {
150
+ * console.log(selectedOption);
151
+ * }
152
+ * <Dropdown setSelectedOption={manipulateData} />
153
+ */
154
+ onChange: (selectedOption?: OptionType) => void | React.Dispatch<React.SetStateAction<OptionType>>;
155
+ value?: string;
156
+ };
157
+ /**
158
+ Props for ReusableDropdownComponent component
159
+ This type will be private, it will be use by only by our ReusableDropdownComponent
160
+ @extends DefaultProps
161
+ @property setShowSelectComponent - A function to set the visibility of the dropdown
162
+ @property showSelectComponent - A boolean indicating the visibility of the dropdown
163
+ @property onChangeInputValue - A function to set the input value of the dropdown
164
+ @property onChangeInputLabel - A function to set the input label of the dropdown
165
+ @property inputValue - A string representing the input value of the dropdown
166
+ @property inputLabel - A string representing the input value of the dropdown that will show on field
167
+ @property setSelectedOptionOnInputValue - A function to set the selected option based on the input value
168
+ @property inputRef - A ref to the input element of the dropdown
169
+ */
170
+ export type ReusableDropdownComponentProps = DefaultProps & {
171
+ setShowSelectComponent: React.Dispatch<React.SetStateAction<boolean>>;
172
+ showSelectComponent: boolean;
173
+ onChangeInputValue: React.Dispatch<React.SetStateAction<string>>;
174
+ onChangeInputLabel: React.Dispatch<React.SetStateAction<string>>;
175
+ inputValue: string;
176
+ inputLabel: string;
177
+ setSelectedOptionOnInputValue: () => void;
178
+ inputRef: React.RefObject<HTMLInputElement>;
179
+ };
180
+ export {};
@@ -1,3 +1,3 @@
1
- import { OptionType, OptionWithHeaderType } from '@bolttech/atoms-select';
2
- export declare function filterOptions(inputValue: string, optionList?: OptionType[]): OptionType[];
3
- export declare function filterOptionsWithHeaders(inputValue: string, optionList?: OptionWithHeaderType[]): OptionWithHeaderType[];
1
+ import { OptionType, OptionWithHeaderType } from '@bolttech/atoms-select';
2
+ export declare function filterOptions(inputValue: string, optionList?: OptionType[]): OptionType[];
3
+ export declare function filterOptionsWithHeaders(inputValue: string, optionList?: OptionWithHeaderType[]): OptionWithHeaderType[];
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
- import { ReusableDropdownComponentProps } from './molecules-dropdown.type';
3
- export declare const ReusableDropdownComponent: ({ id, dataTestId, label, variant, required, inputValue, inputLabel, disabled, errorMessage, onChangeInputValue, onChangeInputLabel, setShowSelectComponent, showSelectComponent, setSelectedOptionOnInputValue, inputRef, placeholder, onBlur, onFocus, }: ReusableDropdownComponentProps) => JSX.Element;
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, inputRef, placeholder, onBlur, onFocus, }: ReusableDropdownComponentProps) => import("react/jsx-runtime").JSX.Element;