react-lookup-select 1.0.2 → 1.0.4
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/LICENSE +21 -0
- package/dist/index.cjs +109 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +152 -1
- package/dist/index.d.ts +152 -1
- package/dist/index.js +110 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +49 -59
- package/package.json +2 -2
- package/readme.md +166 -0
package/dist/styles.css
CHANGED
|
@@ -131,20 +131,7 @@
|
|
|
131
131
|
box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2), var(--lookup-select-shadow);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
.lookup-select__trigger--open {
|
|
135
|
-
border-color: var(--lookup-select-color-border-focus);
|
|
136
|
-
box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2), var(--lookup-select-shadow);
|
|
137
|
-
}
|
|
138
134
|
|
|
139
|
-
.lookup-select__trigger--disabled {
|
|
140
|
-
cursor: not-allowed;
|
|
141
|
-
opacity: 0.6;
|
|
142
|
-
background: var(--lookup-select-color-bg-secondary);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.lookup-select__trigger--error {
|
|
146
|
-
border-color: var(--lookup-select-color-error);
|
|
147
|
-
}
|
|
148
135
|
|
|
149
136
|
.lookup-select__trigger-content {
|
|
150
137
|
flex: 1;
|
|
@@ -194,55 +181,74 @@
|
|
|
194
181
|
transition: transform var(--lookup-select-transition-duration) var(--lookup-select-transition-timing);
|
|
195
182
|
}
|
|
196
183
|
|
|
197
|
-
|
|
198
|
-
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
/* Trigger content styles */
|
|
187
|
+
.lookup-select__placeholder {
|
|
188
|
+
color: var(--lookup-select-color-text-muted);
|
|
189
|
+
font-style: italic;
|
|
199
190
|
}
|
|
200
191
|
|
|
201
|
-
|
|
202
|
-
|
|
192
|
+
.lookup-select__selected-text {
|
|
193
|
+
color: var(--lookup-select-color-text);
|
|
194
|
+
font-weight: var(--lookup-select-font-weight-medium);
|
|
195
|
+
overflow: hidden;
|
|
196
|
+
text-overflow: ellipsis;
|
|
197
|
+
white-space: nowrap;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
/* === TAGS (Multi-select trigger) === */
|
|
203
|
+
.lookup-select__tags {
|
|
203
204
|
display: flex;
|
|
204
|
-
align-items: center;
|
|
205
|
-
gap: var(--lookup-select-spacing-sm);
|
|
206
205
|
flex-wrap: wrap;
|
|
207
|
-
|
|
206
|
+
gap: var(--lookup-select-spacing-sm);
|
|
207
|
+
align-items: center;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
.lookup-
|
|
210
|
+
.lookup-select__tag {
|
|
211
211
|
display: inline-flex;
|
|
212
212
|
align-items: center;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
gap: var(--lookup-select-spacing-sm);
|
|
214
|
+
background: var(--lookup-select-color-bg-secondary);
|
|
215
|
+
color: var(--lookup-select-color-text);
|
|
216
|
+
padding: 4px 8px;
|
|
217
|
+
border-radius: var(--lookup-select-border-radius);
|
|
217
218
|
font-size: var(--lookup-select-font-size-sm);
|
|
218
219
|
font-weight: var(--lookup-select-font-weight-medium);
|
|
220
|
+
border: 1px solid var(--lookup-select-color-border);
|
|
219
221
|
max-width: 120px;
|
|
220
222
|
}
|
|
221
223
|
|
|
222
|
-
.lookup-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.lookup-select__selected-item--more {
|
|
229
|
-
background: var(--lookup-select-color-text-secondary);
|
|
224
|
+
.lookup-select__tag--more {
|
|
225
|
+
background: var(--lookup-select-color-primary);
|
|
226
|
+
color: white;
|
|
227
|
+
border-color: var(--lookup-select-color-primary);
|
|
230
228
|
}
|
|
231
229
|
|
|
232
|
-
.lookup-
|
|
233
|
-
background:
|
|
230
|
+
.lookup-select__tag-remove {
|
|
231
|
+
background: rgba(0, 0, 0, 0.1);
|
|
234
232
|
border: none;
|
|
235
|
-
color:
|
|
236
|
-
margin-left: var(--lookup-select-spacing-sm);
|
|
233
|
+
color: currentColor;
|
|
237
234
|
cursor: pointer;
|
|
238
|
-
padding:
|
|
239
|
-
font-size:
|
|
235
|
+
padding: 2px 4px;
|
|
236
|
+
font-size: 12px;
|
|
240
237
|
line-height: 1;
|
|
241
|
-
|
|
238
|
+
border-radius: 50%;
|
|
239
|
+
width: 16px;
|
|
240
|
+
height: 16px;
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: center;
|
|
244
|
+
transition: all var(--lookup-select-transition-duration) var(--lookup-select-transition-timing);
|
|
245
|
+
opacity: 0.7;
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
.lookup-
|
|
248
|
+
.lookup-select__tag-remove:hover {
|
|
249
|
+
background: rgba(0, 0, 0, 0.2);
|
|
245
250
|
opacity: 1;
|
|
251
|
+
transform: scale(1.1);
|
|
246
252
|
}
|
|
247
253
|
|
|
248
254
|
/* === MODAL === */
|
|
@@ -256,7 +262,7 @@
|
|
|
256
262
|
display: flex;
|
|
257
263
|
align-items: center;
|
|
258
264
|
justify-content: center;
|
|
259
|
-
z-index:
|
|
265
|
+
z-index: var(--lookup-select-z-index-overlay);
|
|
260
266
|
padding: 20px;
|
|
261
267
|
}
|
|
262
268
|
|
|
@@ -358,11 +364,7 @@
|
|
|
358
364
|
padding: calc(var(--lookup-select-spacing) * 2);
|
|
359
365
|
}
|
|
360
366
|
|
|
361
|
-
|
|
362
|
-
text-align: center;
|
|
363
|
-
color: #6b7280;
|
|
364
|
-
padding: calc(var(--lookup-select-spacing) * 4);
|
|
365
|
-
}
|
|
367
|
+
|
|
366
368
|
|
|
367
369
|
/* === MODAL FOOTER === */
|
|
368
370
|
.lookup-select__modal-footer {
|
|
@@ -799,19 +801,7 @@
|
|
|
799
801
|
background: var(--lookup-select-color-bg-hover);
|
|
800
802
|
}
|
|
801
803
|
|
|
802
|
-
.lookup-select__virtual-row--selected {
|
|
803
|
-
background: rgba(0, 102, 204, 0.1);
|
|
804
|
-
border-left: 3px solid var(--lookup-select-color-primary);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
.lookup-select__virtual-row--disabled {
|
|
808
|
-
opacity: 0.6;
|
|
809
|
-
cursor: not-allowed;
|
|
810
|
-
}
|
|
811
804
|
|
|
812
|
-
.lookup-select__virtual-row--disabled:hover {
|
|
813
|
-
background: transparent;
|
|
814
|
-
}
|
|
815
805
|
|
|
816
806
|
.lookup-select__virtual-row .lookup-select__table {
|
|
817
807
|
width: 100%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lookup-select",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "git+https://github.com/Onurlulardan/react-lookup-select.git"
|
|
42
42
|
},
|
|
43
|
-
"homepage": "https://
|
|
43
|
+
"homepage": "https://react-lookup-select.vercel.app",
|
|
44
44
|
"bugs": {
|
|
45
45
|
"url": "https://github.com/Onurlulardan/react-lookup-select/issues"
|
|
46
46
|
},
|
package/readme.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# react-lookup-select
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/react-lookup-select)
|
|
4
|
+
[](https://www.npmjs.com/package/react-lookup-select)
|
|
5
|
+
[](https://github.com/Onurlulardan/react-lookup-select)
|
|
6
|
+
|
|
3
7
|
A headless, customizable React lookup select component with modal and grid support for single/multiple selection.
|
|
4
8
|
|
|
5
9
|
## Features
|
|
@@ -189,6 +193,168 @@ const dataSource = async (q: QueryState) => {
|
|
|
189
193
|
/>
|
|
190
194
|
```
|
|
191
195
|
|
|
196
|
+
## Custom Rendering with Render Props
|
|
197
|
+
|
|
198
|
+
### Overview
|
|
199
|
+
|
|
200
|
+
The LookupSelect component supports complete customization through render props, allowing you to integrate with any UI library (Ant Design, Material-UI, etc.) or create custom designs.
|
|
201
|
+
|
|
202
|
+
### Available Render Props
|
|
203
|
+
|
|
204
|
+
- `renderTrigger` - Customize the trigger button
|
|
205
|
+
- `renderModal` - Customize the modal container
|
|
206
|
+
- `renderGrid` - Customize the data grid
|
|
207
|
+
- `renderHeader` - Customize the modal header
|
|
208
|
+
- `renderFooter` - Customize the modal footer
|
|
209
|
+
- `renderSearch` - Customize the search input
|
|
210
|
+
- `renderPagination` - Customize pagination controls
|
|
211
|
+
|
|
212
|
+
### Custom Modal Example
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
<LookupSelect
|
|
216
|
+
data={users}
|
|
217
|
+
columns={columns}
|
|
218
|
+
mapper={mapper}
|
|
219
|
+
renderModal={({ isOpen, onClose, children, title, selectedCount }) => {
|
|
220
|
+
if (!isOpen) return null;
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div className="custom-modal-overlay" onClick={onClose}>
|
|
224
|
+
<div className="custom-modal" onClick={(e) => e.stopPropagation()}>
|
|
225
|
+
<div className="modal-header">
|
|
226
|
+
<h2>{title}</h2>
|
|
227
|
+
{selectedCount > 0 && (
|
|
228
|
+
<span className="selection-count">{selectedCount} selected</span>
|
|
229
|
+
)}
|
|
230
|
+
<button onClick={onClose}>×</button>
|
|
231
|
+
</div>
|
|
232
|
+
{children}
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Custom Grid with Cards
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
<LookupSelect
|
|
244
|
+
data={users}
|
|
245
|
+
columns={columns}
|
|
246
|
+
mapper={mapper}
|
|
247
|
+
renderGrid={({ data, selectedIds, onRowSelect, mapper }) => (
|
|
248
|
+
<div className="card-grid">
|
|
249
|
+
{data.map((user) => {
|
|
250
|
+
const isSelected = selectedIds.includes(mapper.getId(user));
|
|
251
|
+
return (
|
|
252
|
+
<div
|
|
253
|
+
key={mapper.getId(user)}
|
|
254
|
+
className={`user-card ${isSelected ? 'selected' : ''}`}
|
|
255
|
+
onClick={() => onRowSelect(user)}
|
|
256
|
+
>
|
|
257
|
+
<img src={user.avatar} alt={user.name} />
|
|
258
|
+
<h3>{user.name}</h3>
|
|
259
|
+
<p>{user.email}</p>
|
|
260
|
+
<span className="role">{user.role}</span>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
})}
|
|
264
|
+
</div>
|
|
265
|
+
)}
|
|
266
|
+
/>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Ant Design Integration
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
import { Modal, Table, Input, Button } from 'antd';
|
|
273
|
+
|
|
274
|
+
<LookupSelect
|
|
275
|
+
data={users}
|
|
276
|
+
columns={columns}
|
|
277
|
+
mapper={mapper}
|
|
278
|
+
renderModal={({ isOpen, onClose, children }) => (
|
|
279
|
+
<Modal
|
|
280
|
+
open={isOpen}
|
|
281
|
+
onCancel={onClose}
|
|
282
|
+
title="Select Users"
|
|
283
|
+
width={800}
|
|
284
|
+
footer={null}
|
|
285
|
+
>
|
|
286
|
+
{children}
|
|
287
|
+
</Modal>
|
|
288
|
+
)}
|
|
289
|
+
renderGrid={({ data, columns, selectedRowKeys, onRowSelect }) => (
|
|
290
|
+
<Table
|
|
291
|
+
dataSource={data}
|
|
292
|
+
columns={columns}
|
|
293
|
+
rowSelection={{
|
|
294
|
+
selectedRowKeys,
|
|
295
|
+
onChange: onRowSelect,
|
|
296
|
+
}}
|
|
297
|
+
pagination={false}
|
|
298
|
+
/>
|
|
299
|
+
)}
|
|
300
|
+
renderSearch={({ value, onChange, placeholder }) => (
|
|
301
|
+
<Input.Search
|
|
302
|
+
value={value}
|
|
303
|
+
onChange={(e) => onChange(e.target.value)}
|
|
304
|
+
placeholder={placeholder}
|
|
305
|
+
style={{ marginBottom: 16 }}
|
|
306
|
+
/>
|
|
307
|
+
)}
|
|
308
|
+
/>;
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Material-UI Integration
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
import { Dialog, DataGrid, TextField, Chip } from '@mui/material';
|
|
315
|
+
|
|
316
|
+
<LookupSelect
|
|
317
|
+
data={users}
|
|
318
|
+
columns={columns}
|
|
319
|
+
mapper={mapper}
|
|
320
|
+
renderModal={({ isOpen, onClose, children }) => (
|
|
321
|
+
<Dialog open={isOpen} onClose={onClose} maxWidth="md" fullWidth>
|
|
322
|
+
{children}
|
|
323
|
+
</Dialog>
|
|
324
|
+
)}
|
|
325
|
+
renderGrid={({ data, columns, onRowSelect }) => (
|
|
326
|
+
<DataGrid
|
|
327
|
+
rows={data}
|
|
328
|
+
columns={columns}
|
|
329
|
+
onRowSelectionModelChange={onRowSelect}
|
|
330
|
+
checkboxSelection
|
|
331
|
+
/>
|
|
332
|
+
)}
|
|
333
|
+
/>;
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### TypeScript Support for Render Props
|
|
337
|
+
|
|
338
|
+
```tsx
|
|
339
|
+
import type {
|
|
340
|
+
ModalRenderProps,
|
|
341
|
+
GridRenderProps,
|
|
342
|
+
SearchRenderProps,
|
|
343
|
+
} from 'react-lookup-select';
|
|
344
|
+
|
|
345
|
+
const CustomModal = ({ isOpen, onClose, children }: ModalRenderProps<User>) => {
|
|
346
|
+
// Your custom modal implementation
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const CustomGrid = ({
|
|
350
|
+
data,
|
|
351
|
+
selectedIds,
|
|
352
|
+
onRowSelect,
|
|
353
|
+
}: GridRenderProps<User>) => {
|
|
354
|
+
// Your custom grid implementation
|
|
355
|
+
};
|
|
356
|
+
```
|
|
357
|
+
|
|
192
358
|
## Virtualization - Large Data Performance
|
|
193
359
|
|
|
194
360
|
### Auto Virtualization
|