@learnforjob/react-multi-select-dropdown 1.0.0 → 1.0.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 +69 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
A customizable, searchable, lightweight React multi-select dropdown with async loading, checkbox support, keyboard navigation, and virtualization.
|
|
4
4
|
|
|
5
|
+
**NPM Package:** `@learnforjob/react-multi-select-dropdown`
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install react-multi-select-dropdown
|
|
10
|
+
npm install @learnforjob/react-multi-select-dropdown
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
```jsx
|
|
14
16
|
import React, { useState } from 'react';
|
|
15
|
-
import MultiSelectDropdown from 'react-multi-select-dropdown';
|
|
17
|
+
import { MultiSelectDropdown } from '@learnforjob/react-multi-select-dropdown';
|
|
16
18
|
|
|
17
19
|
const options = [
|
|
18
20
|
{ label: 'React', value: 'react' },
|
|
@@ -36,30 +38,75 @@ function App() {
|
|
|
36
38
|
export default App;
|
|
37
39
|
```
|
|
38
40
|
|
|
41
|
+
## Live Demo
|
|
42
|
+
|
|
43
|
+
Try it out in the **npm-dropdown-example** app:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cd npm-dropdown-example
|
|
47
|
+
npm install
|
|
48
|
+
npm start
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Open `http://localhost:3000` to see all features in action.
|
|
52
|
+
|
|
39
53
|
## Props
|
|
40
54
|
|
|
41
55
|
| Prop | Type | Default | Description |
|
|
42
56
|
|------|------|---------|-------------|
|
|
43
|
-
| options | `Option[]` | `[]` | Array of options to display |
|
|
57
|
+
| options | `Option[]` | `[]` | Array of `{label, value}` options to display |
|
|
44
58
|
| value | `(string \| number)[]` | `[]` | Currently selected values |
|
|
45
59
|
| onChange | `(values: (string \| number)[]) => void` | `undefined` | Callback when selection changes |
|
|
46
60
|
| placeholder | `string` | `'Select options'` | Placeholder text when nothing is selected |
|
|
47
61
|
| disabled | `boolean` | `false` | Disable the dropdown |
|
|
48
|
-
| selectAllText | `string` | `'Select All'` | Text for
|
|
49
|
-
| searchable | `boolean` | `true` | Enable search
|
|
50
|
-
| groupBy | `string` | `undefined` | Property to group options by |
|
|
62
|
+
| selectAllText | `string` | `'Select All'` | Text for the "Select All" checkbox |
|
|
63
|
+
| searchable | `boolean` | `true` | Enable/disable the search input |
|
|
64
|
+
| groupBy | `string` | `undefined` | Property name to group options by |
|
|
51
65
|
| maxSelectionLimit | `number` | `undefined` | Maximum number of options that can be selected |
|
|
52
|
-
| renderOption | `(option: Option) => React.ReactNode` | `undefined` | Custom renderer for
|
|
53
|
-
| renderTag | `(option: Option) => React.ReactNode` | `undefined` | Custom renderer for selected tags |
|
|
54
|
-
| customClassName | `string` | `undefined` | Additional CSS class
|
|
66
|
+
| renderOption | `(option: Option) => React.ReactNode` | `undefined` | Custom renderer for each option row |
|
|
67
|
+
| renderTag | `(option: Option) => React.ReactNode` | `undefined` | Custom renderer for selected tags in the header |
|
|
68
|
+
| customClassName | `string` | `undefined` | Additional CSS class added to the root container |
|
|
69
|
+
| theme | `Theme` | `undefined` | Theme object to customize colors, sizes, and borders |
|
|
70
|
+
|
|
71
|
+
### Theme Properties
|
|
72
|
+
|
|
73
|
+
| Property | Type | Default | Description |
|
|
74
|
+
|----------|------|---------|-------------|
|
|
75
|
+
| primaryColor | `string` | `'#339ef7'` | Primary accent color |
|
|
76
|
+
| primaryHover | `string` | `'#1a8ceb'` | Hover accent color |
|
|
77
|
+
| bgColor | `string` | `'#ffffff'` | Background color |
|
|
78
|
+
| borderColor | `string` | `'#cccccc'` | Border color |
|
|
79
|
+
| textColor | `string` | `'#333333'` | Text color |
|
|
80
|
+
| placeholderColor | `string` | `'#495057'` | Placeholder text color |
|
|
81
|
+
| itemHoverBg | `string` | `'#ebf5ff'` | Option hover background |
|
|
82
|
+
| selectedBg | `string` | `'#339ef7'` | Selected item background |
|
|
83
|
+
| selectedColor | `string` | `'#ffffff'` | Selected item text color |
|
|
84
|
+
| disabledBg | `string` | `'#e9ecef'` | Disabled background |
|
|
85
|
+
| disabledColor | `string` | `'#b3b3b3'` | Disabled text color |
|
|
86
|
+
| borderRadius | `string` | `'4px'` | Border radius |
|
|
87
|
+
| fontSize | `string` | `'1rem'` | Font size |
|
|
88
|
+
| headerHeight | `string` | `'36px'` | Header height |
|
|
55
89
|
|
|
56
90
|
## TypeScript Support
|
|
57
91
|
|
|
58
|
-
This package is written in TypeScript and includes type definitions.
|
|
92
|
+
This package is written in TypeScript and includes type definitions — no extra `@types` package needed.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { MultiSelectDropdown, Theme } from '@learnforjob/react-multi-select-dropdown';
|
|
96
|
+
|
|
97
|
+
const myTheme: Theme = {
|
|
98
|
+
primaryColor: '#ff6b6b',
|
|
99
|
+
itemHoverBg: '#ffe0e0',
|
|
100
|
+
borderRadius: '8px',
|
|
101
|
+
headerHeight: '42px',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
<MultiSelectDropdown theme={myTheme} ... />
|
|
105
|
+
```
|
|
59
106
|
|
|
60
107
|
## Customization
|
|
61
108
|
|
|
62
|
-
|
|
109
|
+
Customize rendering of options and selected tags:
|
|
63
110
|
|
|
64
111
|
```jsx
|
|
65
112
|
<MultiSelectDropdown
|
|
@@ -67,12 +114,13 @@ You can customize the rendering of options and selected tags:
|
|
|
67
114
|
value={selected}
|
|
68
115
|
onChange={setSelected}
|
|
69
116
|
renderOption={(option) => (
|
|
70
|
-
<div>
|
|
71
|
-
<
|
|
117
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
118
|
+
<span>{option.label}</span>
|
|
119
|
+
<small style={{ color: '#888' }}>{option.value}</small>
|
|
72
120
|
</div>
|
|
73
121
|
)}
|
|
74
122
|
renderTag={(option) => (
|
|
75
|
-
<span style={{ backgroundColor: 'lightblue' }}>
|
|
123
|
+
<span style={{ backgroundColor: 'lightblue', borderRadius: '12px', padding: '2px 8px' }}>
|
|
76
124
|
{option.label}
|
|
77
125
|
</span>
|
|
78
126
|
)}
|
|
@@ -81,7 +129,7 @@ You can customize the rendering of options and selected tags:
|
|
|
81
129
|
|
|
82
130
|
## Grouped Options
|
|
83
131
|
|
|
84
|
-
|
|
132
|
+
Use the `groupBy` prop to visually group options by a shared property:
|
|
85
133
|
|
|
86
134
|
```jsx
|
|
87
135
|
const groupedOptions = [
|
|
@@ -101,10 +149,13 @@ const groupedOptions = [
|
|
|
101
149
|
|
|
102
150
|
## Accessibility
|
|
103
151
|
|
|
104
|
-
The component
|
|
152
|
+
The component includes:
|
|
105
153
|
- Keyboard navigation (Arrow keys, Enter, Escape)
|
|
106
|
-
-
|
|
107
|
-
|
|
154
|
+
- Checkbox semantics with proper labeling
|
|
155
|
+
|
|
156
|
+
## Security
|
|
157
|
+
|
|
158
|
+
This package has been audited. Run `npm audit` in your project after installation for the latest vulnerability report.
|
|
108
159
|
|
|
109
160
|
## License
|
|
110
161
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learnforjob/react-multi-select-dropdown",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A customizable, searchable, lightweight React multi-select dropdown with async loading, checkbox support, keyboard navigation, virtualization, and TypeScript support.",
|
|
5
5
|
"author": "LearnForJob",
|
|
6
6
|
"license": "MIT",
|