dropdowns-js 1.1.6 → 2.0.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.
@@ -0,0 +1,2 @@
1
+ declare function App(): import("react/jsx-runtime").JSX.Element;
2
+ export default App;
@@ -0,0 +1,29 @@
1
+ /**File: ./src/MultiSelectionDropdownTest.jsx
2
+ * Author: ITA
3
+ * MultiSelectionDropdownTest: A sample component demonstrating the use of the MultiSelectionDropdown.
4
+ *
5
+ * Change Log
6
+ * =========================================================
7
+ * Start Date End Date Version Dev Description
8
+ * =========================================================
9
+ * 2025/12/19 1.0.0 ITA Genesis.
10
+ * 2026/01/11 2026/01/16 1.0.1 ITA Working with MultiSelectionObj dropdown no longer requires a Collections context provider.
11
+ * 2026/01/20 2026/01/27 1.0.2 ITA Added a test for selReset prop.
12
+ * 2026/05/11 2026/05/15 2.0.0 ITA Changed the file extension to .tsx and migrated to Typescript.
13
+ * ==========================================================
14
+ */
15
+ /** VERY IMPORTANT!!!
16
+ * Depending on how you are testing the components, you need to uncomment the appropriate import statements below.
17
+ *
18
+ * Test type 1:
19
+ * If you are testing the dropdown components as part of this project,
20
+ * then import MultiSelectionDropdown from the local filepath of this project.
21
+ *
22
+ * Test type 2:
23
+ * If you are testing the component as an npm package, then import from 'dropdowns-js'.
24
+ *
25
+ *
26
+ * Based on the above, please comment/uncomment the appropriate import statements below.
27
+ */
28
+ import 'dropdowns-js/style.css';
29
+ export default function MultiSelectionDropdownObjTest(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * File: ./src/dropdowns/Dropdown.tsx
3
+ * ------------------------------------------------------------------------------------------------------
4
+ * Description:
5
+ * Provide a single selection searchable dropdown that takes an array of primitive types.
6
+ * * ----------------------------------------------------------------------------------------------------
7
+ * Start Date End Date Dev Version Description
8
+ * 2023/12/19 ITA 1.00 Genesis.
9
+ * 2024/06/18 ITA 1.01 Add the version number.
10
+ * 2024/09/17 ITA 1.02 Toggle (add/remove) class name (w3-show) for displaying list items. Remove the style attribute.
11
+ * Adjust width and add borders.
12
+ * Import context directly.
13
+ * 2024/10/11 ITA 1.04 Reduce the width of the text box so that it appears side by side with the drop-down on even smaller screens.
14
+ * 2024/10/28 ITA 1.05 Improve the responsiveness of the Dropdown.
15
+ * 2025/12/18 ITA 1.06 Performed further tweaks and tests, preparing this component for npm publishing.
16
+ * 2025/12/26 ITA 1.07 Changed the arrow symbols to + and - for better visibility across different platforms.
17
+ * 2025/12/29 ITA 1.08 Placeholder must show the name of the data, as provided by the label attribute.
18
+ * 2026/01/11 2026/01/16 ITA 1.09 Improved the component so that it stores its own data instead of relying on the Collections context provider.
19
+ * 2026/01/17 2026/01/17 ITA 1.10 Removed attributes that do no apply to this component.
20
+ * Corrected the description of 'selected' attribute in the function header.
21
+ * 2026/01/17 2026/01/17 ITA 1.11 Corrected the component proptypes to include onItemSelected, instead of onItemsSelected.
22
+ * 2026/01/19 2026/01/19 ITA 1.12 Used useId() to ensure the uniqueness of ids of the concerned html elements even when the component is used multiple times in the same page.
23
+ * 2026/01/20 2026/02/01 ITA 1.13 Added a 'selReset' attribute. When set to true, the dropdown updates to the default selected item when this value changes in the parent component.
24
+ * Combined searchItems and list state variables into a single variable: list.
25
+ * Improved the logic for setting selected items.
26
+ * 2026/05/11 2026/05/15 ITA 2.0.0 Changed the file extension to .tsx and migrated to Typescript.
27
+ */
28
+ import { JSX } from 'react';
29
+ import './dropdown.css';
30
+ import { DropdownStyle, ButtonStyle } from './dropdowns.models.js';
31
+ interface DropdownPropTypes<T> {
32
+ label: string;
33
+ data: NonNullable<T>[];
34
+ sortOrder?: 'asc' | 'desc';
35
+ onItemSelected?: (selectedItem: T) => void;
36
+ selected?: T | null;
37
+ selReset?: boolean;
38
+ isDisabled?: boolean;
39
+ dropdownStyle: DropdownStyle;
40
+ buttonStyle?: ButtonStyle;
41
+ }
42
+ /**Single selection dropdown component.
43
+ */
44
+ export declare function Dropdown<T extends number | string | bigint | boolean>({ label, // label with which to describe the dropdown.
45
+ data, // Primitive type array.
46
+ sortOrder, onItemSelected, // Function to pass on the value of the selected item to the parent component
47
+ selected, // Initial selected item.
48
+ selReset, // If true, selected item via parent component.
49
+ dropdownStyle, // Styling object with fields {color, backgroundColor, borderColor (optional), fontSize}.
50
+ isDisabled }: DropdownPropTypes<T>): JSX.Element;
51
+ export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * File: ./src/dropdowns/DropdownObj.tsx
3
+ * --------------------------------------------------------------------------------
4
+ * Description:
5
+ * Provide a single selection, searchable dropdown that takes an array of objects.
6
+ * A developer must specify which field name to use for displaying (the displayName), and which field name to use as value (valueName).
7
+ * * --------------------------------------------------------------------------------
8
+ * Start Date End Date Dev Version Description
9
+ * 2023/12/19 ITA 1.00 Genesis.
10
+ * 2024/06/18 ITA 1.01 Add version number.
11
+ * 2024/07/14 ITA 1.02 Use the underlying field value (valueName) as the key when displaying collection items.
12
+ * 2024/09/17 ITA 1.03 Toggle (add/remove) class name (w3-show) for displaying list items. Remove the extra style attribute.
13
+ * Adjust width and add borders.
14
+ * Import context directly.
15
+ * 2024/10/11 ITA 1.04 Reduce the width of the text box so that it appears side by side with the drop-down on even smaller screens.
16
+ * 2024/10/28 ITA 1.05 Improve the responsiveness of the dropdown.
17
+ * 2025/12/18 ITA 1.06 Renamed to from Dropdown2 to DropdownObj, and performed further tweaks and tests towards preparing this component
18
+ * for npm publishing.
19
+ * 2025/12/26 ITA 1.07 Changed the arrow symbols to + and - for better visibility across different platforms.
20
+ * 2025/12/29 ITA 1.08 Placeholder must show the name of the data as provided by the label attribute.
21
+ * 2026/01/11 2026/01/16 ITA 1.09 Improved the component so that it stores its own data instead of relying on the Collections context provider.
22
+ * 2026/01/19 2026/01/19 ITA 1.10 Used useId() to ensure the uniqueness of ids of the concerned html elements even when the component is used multiple times in the same page.
23
+ * 2026/01/20 2026/02/01 ITA 1.11 Added a 'selReset' attribute. When set to true, the dropdown updates to the default selected item when this value changes in the parent component.
24
+ * Combined searchItems and list state variables into one: list.
25
+ * Improved the logic for setting selected items.
26
+ * 2026/05/11 2026/05/15 ITA 2.0.0 Changed the file extension to .tsx and migrated to Typescript.
27
+ */
28
+ import { JSX } from 'react';
29
+ import './dropdown.css';
30
+ import { DropdownStyle } from './dropdowns.models.js';
31
+ interface DropdownObjPropTypes<T extends object> {
32
+ label: string;
33
+ data: NonNullable<T>[];
34
+ sortFields: string[];
35
+ selected?: T | null;
36
+ selReset?: boolean;
37
+ displayName: string;
38
+ valueName: string;
39
+ isDisabled?: boolean;
40
+ onItemSelected?: (selItem: T) => void;
41
+ dropdownStyle: DropdownStyle;
42
+ }
43
+ /** Provide a multi-selection, searchable dropdown that takes an array of objects.**/
44
+ export declare function DropdownObj<T extends object>({ label, // label with which to describe the dropdown.
45
+ data, sortFields, selected, selReset, displayName, // the name of the field that will be used for displaying the list items to the user.
46
+ valueName, // the name of the field that will be used as the underlying unique value of each list item.
47
+ isDisabled, onItemSelected, dropdownStyle }: DropdownObjPropTypes<T>): JSX.Element;
48
+ export {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * File: ./src/components/MultiSelectionDropdown.js
3
+ * --------------------------------------------------------------------------------
4
+ * Description:
5
+ * Provide a multi-selection, searchable dropdown that takes an array of primitve types.
6
+ * * --------------------------------------------------------------------------------
7
+ * Start Date End Date Dev Version Description
8
+ * 2024/02/27 ITA 1.00 Genesis.
9
+ * 2024/09/17 ITA 1.02 Toggle (add/remove) class name (w3-show) for displaying list items. Remove the style attribute.
10
+ * Adjust width and add borders.
11
+ * Import context directly. Variable names moved to VarNames object.
12
+ * 2024/10/28 ITA 1.03 Improve the responsiveness of the dropdown.
13
+ * 2025/12/18 ITA 1.06 Performed further tweaks and tests, to prepare this component for npm publishing.
14
+ * 2025/12/26 ITA 1.07 Changed the arrow symbols to + and - for better cross-platform rendering.
15
+ * 2025/12/29 ITA 1.09 Placeholder to show the name of the data, as provided by the label attribute.
16
+ * 2026/01/11 2026/01/16 ITA 1.10 Improved the component so that it stores its own data instead of relying on the Collections context provider.
17
+ * 2026/01/17 2026/01/17 ITA 1.11 Renamed sortDirection to sortOrder, so as to maintain attribute naming consistency across the dropdowns.
18
+ * 2026/01/19 2026/01/19 ITA 1.12 Used useId() to ensure the uniqueness of ids of the concerned html elements even when the component is used multiple times in the same page.
19
+ * 2026/01/19 2026/01/19 ITA 1.13 SelectedData attribute is meant to be optional. Updated accordingly.
20
+ * 2026/01/20 2026/02/01 ITA 1.14 Added a 'selReset' attribute. When set to true, the dropdown updates to the default selected items when this value changes in the parent component.
21
+ * Combined searchItems and list state variables into one: list.
22
+ * Improved the logic for setting selected items.
23
+ * 2026/05/11 2026/05/15 ITA 2.0.0 Changed the file extension to .tsx and migrated to Typescript.
24
+ */
25
+ import { JSX } from 'react';
26
+ import { DropdownStyle, ButtonStyle } from './dropdowns.models.js';
27
+ import './dropdown.css';
28
+ /** Provide a multi-selection, searchable dropdown that takes an array of primitve types.*/
29
+ interface MultiselectionDropdownPropTypes<T> {
30
+ label: string;
31
+ data: NonNullable<T>[];
32
+ sortOrder?: 'asc' | 'desc';
33
+ selectedData?: NonNullable<T>[];
34
+ selReset?: boolean;
35
+ maxNumSelections?: number;
36
+ isDisabled?: boolean;
37
+ onItemsSelected?: (selItems: T[]) => void;
38
+ dropdownStyle: DropdownStyle;
39
+ buttonStyle: ButtonStyle;
40
+ }
41
+ export declare function MultiSelectionDropdown<T extends number | string | bigint | boolean>({ label, // label with which to describe the dropdown.
42
+ data, sortOrder, selectedData, selReset, maxNumSelections, isDisabled, onItemsSelected, dropdownStyle, // Styling object with fields {color, backgroundColor, borderColor (optional), fontSize}.
43
+ buttonStyle }: MultiselectionDropdownPropTypes<T>): JSX.Element;
44
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * File: ./src/dropdowns/MultiSelectionDropdownObj.jsx
3
+ * --------------------------------------------------------------------------------
4
+ * Description:
5
+ * Provide a multi-selection, searchable dropdown that takes an array of objects.
6
+ * A developer must specify which field name to use for displaying (the displayName), and which field name (valueName) to use as value selected.
7
+ * * --------------------------------------------------------------------------------
8
+ * Start Date End Date Dev Version Description
9
+ * 2024/02/07 ITA 1.00 Genesis.
10
+ * 2024/09/18 ITA 1.01 Toggle (add/remove) class name (w3-show) for displaying list items. Remove the style attribute.
11
+ * Adjust width and add borders.
12
+ * Import context directly. Variable names moved to VarNames object.
13
+ * 2024/10/28 ITA 1.02 Improve the responsiveness of the dropdown.
14
+ * 2025/12/21 ITA 1.03 Performed further tweaks and tests, preparing this component for npm publishing.
15
+ * 2025/12/26 ITA 1.04 Changed the arrow symbols to + and - for better cross-platform rendering.
16
+ * 2025/12/29 ITA 1.05 Placeholder to show the name of the data, as provided by the label attribute.
17
+ * 2026/01/11 2026/01/16 ITA 1.06 Improved the component so that it stores its own data instead of relying on the Collections context provider.
18
+ * 2026/01/19 2026/01/19 ITA 1.07 Used useId() to ensure the uniqueness of ids of the concerned html elements even when the component is used multiple times in the same page.
19
+ * 2026/01/20 2026/02/01 ITA 1.08 Added a 'selReset' attribute. When set to true, the dropdown updates to the default selected items when this value changes in the parent component.
20
+ * Combined list and searchItems state variables into one: list.
21
+ * Improved the logic for setting selected items.
22
+ * 2026/05/11 2026/05/15 ITA 2.0.0 Changed the file extension to .tsx and migrated to Typescript.
23
+ */
24
+ import { JSX } from 'react';
25
+ import './dropdown.css';
26
+ import type { ButtonStyle, DropdownStyle } from './dropdowns.models.js';
27
+ interface MultiSelectionDropdownObjPropType<T> {
28
+ label: string;
29
+ data: NonNullable<T>[];
30
+ sortFields: string[];
31
+ selectedData?: NonNullable<T>[];
32
+ selReset?: boolean;
33
+ displayName: string;
34
+ valueName: string;
35
+ maxNumSelections?: number | null;
36
+ isDisabled?: boolean;
37
+ onItemsSelected?: (selItems: T[]) => void;
38
+ dropdownStyle: DropdownStyle;
39
+ buttonStyle: ButtonStyle;
40
+ }
41
+ /** Provide a multi-selection, searchable dropdown that takes an array of plain objects. */
42
+ export declare function MultiSelectionDropdownObj<T extends object>({ label, // label with which to describe the dropdown.
43
+ data, sortFields, selectedData, selReset, maxNumSelections, displayName, // the name of the field that will be used for displaying the list items to the user.
44
+ valueName, // the name of the field that will be used as the underlying unique value of each list item.
45
+ isDisabled, onItemsSelected, dropdownStyle, buttonStyle }: MultiSelectionDropdownObjPropType<T>): JSX.Element;
46
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * File: ./src/dropdowns/dropdowns.models.tsx
3
+ * --------------------------------------------------------------------------------
4
+ * Description:
5
+ * For definition of interfaces and type aliases that are common among the dropdowns.
6
+ * --------------------------------------------------------------------------------
7
+ * Change log
8
+ * Start Date End Date Version Dev Description
9
+ * 2026/05/11 2026/05/15 1.00 ITA Genesis
10
+ */
11
+ interface DropdownStyle {
12
+ color: string;
13
+ backgroundColor: string;
14
+ fontSize?: string;
15
+ borderColor?: string;
16
+ }
17
+ export type { DropdownStyle };
18
+ interface ButtonStyle {
19
+ color: string;
20
+ backgroundColor: string;
21
+ fontSize?: string;
22
+ borderColor?: string;
23
+ }
24
+ export type { ButtonStyle };
@@ -0,0 +1,16 @@
1
+ /** ./src/index.js
2
+ * Start Date End Date Dev Version Description
3
+ * 2025/12/18 ITA 1.0.0 Genesis
4
+ * 2026/01/11 2026/01/16 ITA 1.0.1 Collections context and provider no longer required
5
+ * 2026/05/11 2026/05/15 ITA 2.0.0 Changed the file extension to .tsx and migrated to Typescript.
6
+ */
7
+ /**
8
+ * @reference ./declarations.d.ts
9
+ */
10
+ import './dropdowns/dropdown.css';
11
+ import { Dropdown } from './dropdowns/Dropdown.jsx';
12
+ import { DropdownObj } from './dropdowns/DropdownObj.jsx';
13
+ import { MultiSelectionDropdownObj } from './dropdowns/MultiSelectionDropdownObj.jsx';
14
+ import { MultiSelectionDropdown } from './dropdowns/MultiSelectionDropdown.jsx';
15
+ import type { DropdownStyle, ButtonStyle } from './dropdowns/dropdowns.models.js';
16
+ export { Dropdown, DropdownObj, MultiSelectionDropdown, MultiSelectionDropdownObj, DropdownStyle, ButtonStyle };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "ITA",
4
4
  "description": "A React library providing customizable search dropdown components with single and multi-selection capabilities.",
5
5
  "private": false,
6
- "version": "1.1.6",
6
+ "version": "2.0.0",
7
7
  "type": "module",
8
8
  "main": "./dist/dropdowns-js.cjs.js",
9
9
  "module": "./dist/dropdowns-js.es.js",
@@ -23,19 +23,22 @@
23
23
  },
24
24
  "scripts": {
25
25
  "dev": "vite",
26
- "build": "vite build",
26
+ "build": "vite build && tsc -p ./tsconfig.build.json --emitDeclarationOnly",
27
27
  "lint": "eslint .",
28
28
  "preview": "vite preview"
29
29
  },
30
30
  "dependencies": {
31
31
  "prop-types": "^15.8.1",
32
- "some-common-functions-js": "^1.2.1"
32
+ "some-common-functions-js": "^2.0.1"
33
33
  },
34
34
  "devDependencies": {
35
+ "@types/node": "^25.6.2",
36
+ "@types/react": "^19.2.14",
35
37
  "@vitejs/plugin-react": "^5.1.1",
36
38
  "eslint": "^9.39.1",
37
39
  "react": "^19.2.3",
38
40
  "react-dom": "^19.2.3",
41
+ "typescript": "^6.0.3",
39
42
  "vite": "^7.2.4"
40
43
  },
41
44
  "peerDependencies": {