sdcpl-react-component 1.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.
- package/LICENSE +22 -0
- package/README.md +986 -0
- package/dist/sdcpl-react-component.es.js +83826 -0
- package/dist/sdcpl-react-component.es.js.map +1 -0
- package/dist/sdcpl-react-component.umd.js +929 -0
- package/dist/sdcpl-react-component.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +87 -0
package/README.md
ADDED
|
@@ -0,0 +1,986 @@
|
|
|
1
|
+
# sdcpl-react-component
|
|
2
|
+
|
|
3
|
+
A comprehensive React component library with 20+ professional UI components including forms, tables, dashboards, charts, and more. Built with React 18+ and 19+ support, featuring full keyboard navigation, validation, icon support, and IndexedDB integration.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install sdcpl-react-component
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or using yarn:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add sdcpl-react-component
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Peer Dependencies
|
|
18
|
+
|
|
19
|
+
This library requires React and React DOM as peer dependencies:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install react react-dom
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Optional Dependencies
|
|
26
|
+
|
|
27
|
+
For full functionality, you may also want to install:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @fortawesome/react-fontawesome @fortawesome/free-solid-svg-icons
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🚀 Quick Start
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import { CustomTextBox, CustomButton, CustomForm } from 'sdcpl-react-component';
|
|
37
|
+
import 'sdcpl-react-component/styles';
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
const [name, setName] = useState('');
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<CustomTextBox
|
|
44
|
+
type="text"
|
|
45
|
+
value={name}
|
|
46
|
+
onChange={setName}
|
|
47
|
+
placeholder="Enter your name"
|
|
48
|
+
icon="user"
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 📚 Table of Contents
|
|
55
|
+
|
|
56
|
+
- [Components](#components)
|
|
57
|
+
- [Form Components](#form-components)
|
|
58
|
+
- [Layout Components](#layout-components)
|
|
59
|
+
- [Data Components](#data-components)
|
|
60
|
+
- [Dashboard Components](#dashboard-components)
|
|
61
|
+
- [Usage Examples](#usage-examples)
|
|
62
|
+
- [API Reference](#api-reference)
|
|
63
|
+
- [Theming](#theming)
|
|
64
|
+
- [Utilities](#utilities)
|
|
65
|
+
- [IndexedDB Integration](#indexeddb-integration)
|
|
66
|
+
|
|
67
|
+
## 📦 Components
|
|
68
|
+
|
|
69
|
+
### Form Components
|
|
70
|
+
|
|
71
|
+
#### CustomTextBox
|
|
72
|
+
|
|
73
|
+
Advanced text input component with validation, masking, currency, date/time support.
|
|
74
|
+
|
|
75
|
+
**Props:**
|
|
76
|
+
- `type` (string): Input type - 'text', 'number', 'currency', 'date', 'datetime', 'time', 'password'
|
|
77
|
+
- `value` (string): Controlled value
|
|
78
|
+
- `onChange` (function): Callback: `(value: string) => void`
|
|
79
|
+
- `placeholder` (string): Placeholder text
|
|
80
|
+
- `validationType` (string): 'email', 'creditcard', 'pin', 'phone', 'url'
|
|
81
|
+
- `masking` (string): Mask pattern (e.g., '(000) 000-0000')
|
|
82
|
+
- `icon` (string): FontAwesome icon name
|
|
83
|
+
- `required` (boolean): Mark as required field
|
|
84
|
+
- `disabled` (boolean): Disable input
|
|
85
|
+
- `loading` (boolean): Show loading spinner
|
|
86
|
+
- `showValidationIcon` (boolean): Show check/cross validation icon
|
|
87
|
+
- `currency` (string): Currency symbol (default: '$')
|
|
88
|
+
- `decimalPlaces` (number): Decimal places for number/currency
|
|
89
|
+
- `length` (number): Maximum character length
|
|
90
|
+
- `fullWidth` (boolean): Take full container width
|
|
91
|
+
- `helpText` (string): Help text below input
|
|
92
|
+
- `tooltip` (string): Tooltip on hover
|
|
93
|
+
|
|
94
|
+
**Methods (via ref):**
|
|
95
|
+
- `getValue()`: Returns current value (ISO format for dates)
|
|
96
|
+
- `setValue(value)`: Sets input value
|
|
97
|
+
- `focus()`: Focuses the input
|
|
98
|
+
- `reset()`: Resets to default and clears validation
|
|
99
|
+
- `isValid()`: Returns validation state
|
|
100
|
+
- `showLoading()`: Shows loading spinner
|
|
101
|
+
- `hideLoading()`: Hides loading spinner
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
```javascript
|
|
105
|
+
import { CustomTextBox } from 'sdcpl-react-component';
|
|
106
|
+
import { useRef } from 'react';
|
|
107
|
+
|
|
108
|
+
function MyComponent() {
|
|
109
|
+
const textBoxRef = useRef();
|
|
110
|
+
const [value, setValue] = useState('');
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<CustomTextBox
|
|
114
|
+
ref={textBoxRef}
|
|
115
|
+
type="text"
|
|
116
|
+
value={value}
|
|
117
|
+
onChange={setValue}
|
|
118
|
+
placeholder="Enter email"
|
|
119
|
+
validationType="email"
|
|
120
|
+
icon="envelope"
|
|
121
|
+
required
|
|
122
|
+
showValidationIcon
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### CustomMultilineTextBox
|
|
129
|
+
|
|
130
|
+
Multi-line text area with character counting and validation.
|
|
131
|
+
|
|
132
|
+
**Props:**
|
|
133
|
+
- `value` (string): Controlled value
|
|
134
|
+
- `onChange` (function): Callback: `(value: string) => void`
|
|
135
|
+
- `rows` (number): Number of rows (default: 4)
|
|
136
|
+
- `maxLength` (number): Maximum character length
|
|
137
|
+
- `showCharCount` (boolean): Show character counter
|
|
138
|
+
- `placeholder` (string): Placeholder text
|
|
139
|
+
- `icon` (string): FontAwesome icon name
|
|
140
|
+
- `required` (boolean): Mark as required field
|
|
141
|
+
- `disabled` (boolean): Disable input
|
|
142
|
+
- `helpText` (string): Help text below input
|
|
143
|
+
|
|
144
|
+
**Example:**
|
|
145
|
+
```javascript
|
|
146
|
+
import { CustomMultilineTextBox } from 'sdcpl-react-component';
|
|
147
|
+
|
|
148
|
+
function MyComponent() {
|
|
149
|
+
const [notes, setNotes] = useState('');
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<CustomMultilineTextBox
|
|
153
|
+
value={notes}
|
|
154
|
+
onChange={setNotes}
|
|
155
|
+
rows={6}
|
|
156
|
+
maxLength={500}
|
|
157
|
+
showCharCount
|
|
158
|
+
placeholder="Enter your notes..."
|
|
159
|
+
icon="file-text"
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### CustomButton
|
|
166
|
+
|
|
167
|
+
Professional button with icon support and multiple styles.
|
|
168
|
+
|
|
169
|
+
**Props:**
|
|
170
|
+
- `text` (string): Button text
|
|
171
|
+
- `icon` (string): FontAwesome icon name
|
|
172
|
+
- `iconPosition` (string): 'left', 'right', 'top', 'bottom' (default: 'left')
|
|
173
|
+
- `onClick` (function): Click handler
|
|
174
|
+
- `backgroundColor` (string): Button background color
|
|
175
|
+
- `width` (string): Button width
|
|
176
|
+
- `height` (string): Button height
|
|
177
|
+
- `disabled` (boolean): Disable button
|
|
178
|
+
- `loading` (boolean): Show loading state
|
|
179
|
+
- `iconColor` (string): Icon color
|
|
180
|
+
- `iconSize` (string): Icon size
|
|
181
|
+
- `textSize` (string): Text font size
|
|
182
|
+
|
|
183
|
+
**Example:**
|
|
184
|
+
```javascript
|
|
185
|
+
import { CustomButton } from 'sdcpl-react-component';
|
|
186
|
+
|
|
187
|
+
function MyComponent() {
|
|
188
|
+
return (
|
|
189
|
+
<CustomButton
|
|
190
|
+
text="Save"
|
|
191
|
+
icon="save"
|
|
192
|
+
onClick={() => console.log('Saved!')}
|
|
193
|
+
backgroundColor="#3b82f6"
|
|
194
|
+
iconPosition="left"
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### CustomCheckBox
|
|
201
|
+
|
|
202
|
+
Multi-select and single-select checkbox/radio with search functionality.
|
|
203
|
+
|
|
204
|
+
**Props:**
|
|
205
|
+
- `data` (object): Data source - `{ list: [[id, label], ...] }` or `{ indexdbKey: 'key' }`
|
|
206
|
+
- `value` (array): Selected IDs array
|
|
207
|
+
- `onChange` (function): Callback: `(ids: array) => void`
|
|
208
|
+
- `mode` (string): 'multi' or 'single' (default: 'multi')
|
|
209
|
+
- `searchable` (boolean): Enable search (default: true)
|
|
210
|
+
- `layout` (string): 'list' or 'card' (default: 'list')
|
|
211
|
+
- `icon` (string): FontAwesome icon name
|
|
212
|
+
- `required` (boolean): Mark as required field
|
|
213
|
+
- `disabled` (boolean): Disable checkbox
|
|
214
|
+
|
|
215
|
+
**Methods (via ref):**
|
|
216
|
+
- `getValue()`: Returns selected IDs array
|
|
217
|
+
- `getObjectValue()`: Returns full selected items array
|
|
218
|
+
- `setValue(ids)`: Sets selected IDs
|
|
219
|
+
- `reset()`: Clears selection
|
|
220
|
+
|
|
221
|
+
**Example:**
|
|
222
|
+
```javascript
|
|
223
|
+
import { CustomCheckBox } from 'sdcpl-react-component';
|
|
224
|
+
|
|
225
|
+
function MyComponent() {
|
|
226
|
+
const [selected, setSelected] = useState([]);
|
|
227
|
+
const data = {
|
|
228
|
+
list: [
|
|
229
|
+
[1, 'Option 1'],
|
|
230
|
+
[2, 'Option 2'],
|
|
231
|
+
[3, 'Option 3']
|
|
232
|
+
]
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<CustomCheckBox
|
|
237
|
+
data={data}
|
|
238
|
+
value={selected}
|
|
239
|
+
onChange={setSelected}
|
|
240
|
+
mode="multi"
|
|
241
|
+
searchable
|
|
242
|
+
layout="card"
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### CustomCheckBoxSingle
|
|
249
|
+
|
|
250
|
+
Single checkbox/switch control with caption and icon support.
|
|
251
|
+
|
|
252
|
+
**Props:**
|
|
253
|
+
- `value` (boolean): Checked state
|
|
254
|
+
- `onChange` (function): Callback: `(checked: boolean) => void`
|
|
255
|
+
- `caption` (string): Label text
|
|
256
|
+
- `icon` (string): FontAwesome icon name
|
|
257
|
+
- `position` (string): 'left' or 'right' (default: 'left')
|
|
258
|
+
- `required` (boolean): Mark as required field
|
|
259
|
+
- `disabled` (boolean): Disable checkbox
|
|
260
|
+
|
|
261
|
+
**Example:**
|
|
262
|
+
```javascript
|
|
263
|
+
import { CustomCheckBoxSingle } from 'sdcpl-react-component';
|
|
264
|
+
|
|
265
|
+
function MyComponent() {
|
|
266
|
+
const [agreed, setAgreed] = useState(false);
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<CustomCheckBoxSingle
|
|
270
|
+
value={agreed}
|
|
271
|
+
onChange={setAgreed}
|
|
272
|
+
caption="I agree to the terms and conditions"
|
|
273
|
+
icon="check"
|
|
274
|
+
/>
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### CustomComboBox
|
|
280
|
+
|
|
281
|
+
Dropdown select with search, keyboard navigation, and portal rendering.
|
|
282
|
+
|
|
283
|
+
**Props:**
|
|
284
|
+
- `data` (object): Data source - `{ list: [[id, label], ...] }` or `{ indexdbKey: 'key' }`
|
|
285
|
+
- `value` (string|number): Selected ID
|
|
286
|
+
- `onChange` (function): Callback: `(id: string|number) => void`
|
|
287
|
+
- `placeholder` (string): Placeholder text
|
|
288
|
+
- `searchable` (boolean): Enable search (default: true)
|
|
289
|
+
- `icon` (string): FontAwesome icon name
|
|
290
|
+
- `required` (boolean): Mark as required field
|
|
291
|
+
- `disabled` (boolean): Disable combobox
|
|
292
|
+
- `loading` (boolean): Show loading state
|
|
293
|
+
|
|
294
|
+
**Methods (via ref):**
|
|
295
|
+
- `getValue()`: Returns selected ID
|
|
296
|
+
- `getObjectValue()`: Returns full selected item object
|
|
297
|
+
- `setValue(id)`: Sets selected ID
|
|
298
|
+
- `focus()`: Focuses the combobox
|
|
299
|
+
- `reset()`: Clears selection
|
|
300
|
+
|
|
301
|
+
**Example:**
|
|
302
|
+
```javascript
|
|
303
|
+
import { CustomComboBox } from 'sdcpl-react-component';
|
|
304
|
+
|
|
305
|
+
function MyComponent() {
|
|
306
|
+
const [selected, setSelected] = useState('');
|
|
307
|
+
const data = {
|
|
308
|
+
list: [
|
|
309
|
+
[1, 'Option 1'],
|
|
310
|
+
[2, 'Option 2'],
|
|
311
|
+
[3, 'Option 3']
|
|
312
|
+
]
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
return (
|
|
316
|
+
<CustomComboBox
|
|
317
|
+
data={data}
|
|
318
|
+
value={selected}
|
|
319
|
+
onChange={setSelected}
|
|
320
|
+
placeholder="Select an option"
|
|
321
|
+
searchable
|
|
322
|
+
icon="list"
|
|
323
|
+
/>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
#### CustomComboBoxMultiSelect
|
|
329
|
+
|
|
330
|
+
Multi-select dropdown with badge display.
|
|
331
|
+
|
|
332
|
+
**Props:**
|
|
333
|
+
- `data` (object): Data source - `{ list: [[id, label], ...] }` or `{ indexdbKey: 'key' }`
|
|
334
|
+
- `value` (array): Selected IDs array
|
|
335
|
+
- `onChange` (function): Callback: `(ids: array) => void`
|
|
336
|
+
- `placeholder` (string): Placeholder text
|
|
337
|
+
- `searchable` (boolean): Enable search (default: true)
|
|
338
|
+
- `icon` (string): FontAwesome icon name
|
|
339
|
+
- `required` (boolean): Mark as required field
|
|
340
|
+
- `disabled` (boolean): Disable combobox
|
|
341
|
+
|
|
342
|
+
**Methods (via ref):**
|
|
343
|
+
- `getValue()`: Returns selected IDs array
|
|
344
|
+
- `getObjectValue()`: Returns full selected items array
|
|
345
|
+
- `setValue(ids)`: Sets selected IDs
|
|
346
|
+
- `reset()`: Clears selection
|
|
347
|
+
|
|
348
|
+
**Example:**
|
|
349
|
+
```javascript
|
|
350
|
+
import { CustomComboBoxMultiSelect } from 'sdcpl-react-component';
|
|
351
|
+
|
|
352
|
+
function MyComponent() {
|
|
353
|
+
const [selected, setSelected] = useState([]);
|
|
354
|
+
const data = {
|
|
355
|
+
list: [
|
|
356
|
+
[1, 'Tag 1'],
|
|
357
|
+
[2, 'Tag 2'],
|
|
358
|
+
[3, 'Tag 3']
|
|
359
|
+
]
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
return (
|
|
363
|
+
<CustomComboBoxMultiSelect
|
|
364
|
+
data={data}
|
|
365
|
+
value={selected}
|
|
366
|
+
onChange={setSelected}
|
|
367
|
+
placeholder="Select tags"
|
|
368
|
+
searchable
|
|
369
|
+
/>
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
#### CustomFileUpload
|
|
375
|
+
|
|
376
|
+
File upload component with drag & drop, validation, and optional textbox.
|
|
377
|
+
|
|
378
|
+
**Props:**
|
|
379
|
+
- `onFileSelect` (function): Callback: `(file: File) => void`
|
|
380
|
+
- `accept` (string): Accepted file types (e.g., 'image/*', '.pdf')
|
|
381
|
+
- `maxSize` (number): Maximum file size in bytes
|
|
382
|
+
- `showTextBox` (boolean): Show optional textbox for notes
|
|
383
|
+
- `textBoxValue` (string): Textbox value
|
|
384
|
+
- `onTextBoxChange` (function): Textbox change handler
|
|
385
|
+
- `textBoxPlaceholder` (string): Textbox placeholder
|
|
386
|
+
- `icon` (string): FontAwesome icon name
|
|
387
|
+
- `disabled` (boolean): Disable upload
|
|
388
|
+
- `required` (boolean): Mark as required field
|
|
389
|
+
|
|
390
|
+
**Example:**
|
|
391
|
+
```javascript
|
|
392
|
+
import { CustomFileUpload } from 'sdcpl-react-component';
|
|
393
|
+
|
|
394
|
+
function MyComponent() {
|
|
395
|
+
const handleFileSelect = (file) => {
|
|
396
|
+
console.log('Selected file:', file);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<CustomFileUpload
|
|
401
|
+
onFileSelect={handleFileSelect}
|
|
402
|
+
accept="image/*"
|
|
403
|
+
maxSize={5 * 1024 * 1024} // 5MB
|
|
404
|
+
showTextBox
|
|
405
|
+
textBoxPlaceholder="Add notes about the file..."
|
|
406
|
+
/>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### CustomProgressBar
|
|
412
|
+
|
|
413
|
+
Progress bar component with optional textbox and visual indicator.
|
|
414
|
+
|
|
415
|
+
**Props:**
|
|
416
|
+
- `value` (number): Progress value (0-100)
|
|
417
|
+
- `showTextBox` (boolean): Show optional textbox
|
|
418
|
+
- `textBoxValue` (string): Textbox value
|
|
419
|
+
- `onTextBoxChange` (function): Textbox change handler
|
|
420
|
+
- `height` (string): Progress bar height
|
|
421
|
+
- `color` (string): Progress bar color
|
|
422
|
+
- `animated` (boolean): Show animated stripes
|
|
423
|
+
- `showButton` (boolean): Show embedded button
|
|
424
|
+
- `buttonText` (string): Button text
|
|
425
|
+
- `buttonIcon` (string): Button icon
|
|
426
|
+
- `onButtonClick` (function): Button click handler
|
|
427
|
+
|
|
428
|
+
**Example:**
|
|
429
|
+
```javascript
|
|
430
|
+
import { CustomProgressBar } from 'sdcpl-react-component';
|
|
431
|
+
|
|
432
|
+
function MyComponent() {
|
|
433
|
+
const [progress, setProgress] = useState(45);
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<CustomProgressBar
|
|
437
|
+
value={progress}
|
|
438
|
+
height="20px"
|
|
439
|
+
color="#3b82f6"
|
|
440
|
+
animated
|
|
441
|
+
showTextBox
|
|
442
|
+
textBoxValue={`${progress}% complete`}
|
|
443
|
+
/>
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
#### CustomSlider
|
|
449
|
+
|
|
450
|
+
Slider and range selector with keyboard navigation and multiple data types.
|
|
451
|
+
|
|
452
|
+
**Props:**
|
|
453
|
+
- `value` (number|string): Current value
|
|
454
|
+
- `onChange` (function): Callback: `(value: number|string) => void`
|
|
455
|
+
- `min` (number): Minimum value
|
|
456
|
+
- `max` (number): Maximum value
|
|
457
|
+
- `step` (number): Step size
|
|
458
|
+
- `dataType` (string): 'number', 'date', 'weekday', 'hour', 'month'
|
|
459
|
+
- `showTicks` (boolean): Show tick marks
|
|
460
|
+
- `showLabels` (boolean): Show value labels
|
|
461
|
+
- `icon` (string): FontAwesome icon name
|
|
462
|
+
- `disabled` (boolean): Disable slider
|
|
463
|
+
|
|
464
|
+
**Example:**
|
|
465
|
+
```javascript
|
|
466
|
+
import { CustomSlider } from 'sdcpl-react-component';
|
|
467
|
+
|
|
468
|
+
function MyComponent() {
|
|
469
|
+
const [value, setValue] = useState(50);
|
|
470
|
+
|
|
471
|
+
return (
|
|
472
|
+
<CustomSlider
|
|
473
|
+
value={value}
|
|
474
|
+
onChange={setValue}
|
|
475
|
+
min={0}
|
|
476
|
+
max={100}
|
|
477
|
+
step={1}
|
|
478
|
+
showTicks
|
|
479
|
+
showLabels
|
|
480
|
+
/>
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### Layout Components
|
|
486
|
+
|
|
487
|
+
#### CustomMenu
|
|
488
|
+
|
|
489
|
+
Hierarchical sidebar navigation with collapsible groups and icons.
|
|
490
|
+
|
|
491
|
+
**Props:**
|
|
492
|
+
- `data` (array): Menu items array
|
|
493
|
+
- `value` (string): Selected menu item ID
|
|
494
|
+
- `onChange` (function): Callback: `(id: string) => void`
|
|
495
|
+
- `searchable` (boolean): Enable search
|
|
496
|
+
- `icon` (string): FontAwesome icon name
|
|
497
|
+
|
|
498
|
+
**Methods (via ref):**
|
|
499
|
+
- `getValue()`: Returns selected menu item ID
|
|
500
|
+
- `getObjectValue()`: Returns full selected menu item object
|
|
501
|
+
- `setValue(id)`: Sets selected menu item
|
|
502
|
+
|
|
503
|
+
**Example:**
|
|
504
|
+
```javascript
|
|
505
|
+
import { CustomMenu } from 'sdcpl-react-component';
|
|
506
|
+
|
|
507
|
+
function MyComponent() {
|
|
508
|
+
const menuData = [
|
|
509
|
+
{
|
|
510
|
+
id: 'dashboard',
|
|
511
|
+
caption: 'Dashboard',
|
|
512
|
+
icon: 'home',
|
|
513
|
+
children: [
|
|
514
|
+
{ id: 'overview', caption: 'Overview', icon: 'chart-line' },
|
|
515
|
+
{ id: 'analytics', caption: 'Analytics', icon: 'chart-bar' }
|
|
516
|
+
]
|
|
517
|
+
},
|
|
518
|
+
{ id: 'settings', caption: 'Settings', icon: 'cog' }
|
|
519
|
+
];
|
|
520
|
+
|
|
521
|
+
return (
|
|
522
|
+
<CustomMenu
|
|
523
|
+
data={menuData}
|
|
524
|
+
value="dashboard"
|
|
525
|
+
onChange={(id) => console.log('Selected:', id)}
|
|
526
|
+
/>
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
#### CustomForm
|
|
532
|
+
|
|
533
|
+
Dynamic form generator with sections, formulas, and conditional visibility.
|
|
534
|
+
|
|
535
|
+
**Props:**
|
|
536
|
+
- `config` (object): Form configuration
|
|
537
|
+
- `onButtonClick` (function): Button click handler
|
|
538
|
+
- `onFieldChange` (function): Field change handler
|
|
539
|
+
- `initialData` (object): Initial form data
|
|
540
|
+
|
|
541
|
+
**Methods (via ref):**
|
|
542
|
+
- `getValue()`: Returns form values as object
|
|
543
|
+
- `getObjectValue()`: Returns full form data with metadata
|
|
544
|
+
- `setValue(data)`: Sets form values
|
|
545
|
+
- `validate()`: Validates all fields
|
|
546
|
+
- `getValidationErrors()`: Returns validation errors
|
|
547
|
+
- `reset()`: Resets form to initial state
|
|
548
|
+
|
|
549
|
+
**Example:**
|
|
550
|
+
```javascript
|
|
551
|
+
import { CustomForm } from 'sdcpl-react-component';
|
|
552
|
+
import { useRef } from 'react';
|
|
553
|
+
|
|
554
|
+
function MyComponent() {
|
|
555
|
+
const formRef = useRef();
|
|
556
|
+
|
|
557
|
+
const config = {
|
|
558
|
+
form: {
|
|
559
|
+
caption: 'User Registration',
|
|
560
|
+
logo: 'user-plus'
|
|
561
|
+
},
|
|
562
|
+
sections: [
|
|
563
|
+
{
|
|
564
|
+
id: 'personal',
|
|
565
|
+
title: 'Personal Information',
|
|
566
|
+
icon: 'user',
|
|
567
|
+
fields: [
|
|
568
|
+
{ id: 'firstName', caption: 'First Name', type: 'text', required: true },
|
|
569
|
+
{ id: 'email', caption: 'Email', type: 'text', validationType: 'email', required: true }
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
],
|
|
573
|
+
buttons: [
|
|
574
|
+
{ id: 'submit', caption: 'Register', settings: { validate: true, icon: 'check' } }
|
|
575
|
+
]
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const handleButtonClick = (buttonId) => {
|
|
579
|
+
if (buttonId === 'submit') {
|
|
580
|
+
const values = formRef.current.getValue();
|
|
581
|
+
console.log('Form values:', values);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
return (
|
|
586
|
+
<CustomForm
|
|
587
|
+
ref={formRef}
|
|
588
|
+
config={config}
|
|
589
|
+
onButtonClick={handleButtonClick}
|
|
590
|
+
/>
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
#### CustomLogin
|
|
596
|
+
|
|
597
|
+
Comprehensive login component with Login, Register, and MFA views.
|
|
598
|
+
|
|
599
|
+
**Props:**
|
|
600
|
+
- `config` (object): Login configuration
|
|
601
|
+
- `onLogin` (function): Login handler
|
|
602
|
+
- `onRegister` (function): Register handler
|
|
603
|
+
- `onMFAVerify` (function): MFA verification handler
|
|
604
|
+
- `theme` (string): 'light' or 'dark'
|
|
605
|
+
|
|
606
|
+
**Example:**
|
|
607
|
+
```javascript
|
|
608
|
+
import { CustomLogin } from 'sdcpl-react-component';
|
|
609
|
+
|
|
610
|
+
function MyComponent() {
|
|
611
|
+
const handleLogin = (credentials) => {
|
|
612
|
+
console.log('Login:', credentials);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
return (
|
|
616
|
+
<CustomLogin
|
|
617
|
+
config={{
|
|
618
|
+
title: 'Welcome Back',
|
|
619
|
+
logo: 'user-circle'
|
|
620
|
+
}}
|
|
621
|
+
onLogin={handleLogin}
|
|
622
|
+
/>
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
#### HomePageComponent
|
|
628
|
+
|
|
629
|
+
Complete application layout with title bar, menu sidebar, container, and status bar.
|
|
630
|
+
|
|
631
|
+
**Props:**
|
|
632
|
+
- `config` (object): Homepage configuration
|
|
633
|
+
- `onEvent` (function): Unified event handler
|
|
634
|
+
- `theme` (string): 'light' or 'dark'
|
|
635
|
+
|
|
636
|
+
**Example:**
|
|
637
|
+
```javascript
|
|
638
|
+
import { HomePageComponent } from 'sdcpl-react-component';
|
|
639
|
+
|
|
640
|
+
function MyComponent() {
|
|
641
|
+
const handleEvent = (event) => {
|
|
642
|
+
console.log('Event:', event);
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
return (
|
|
646
|
+
<HomePageComponent
|
|
647
|
+
config={{
|
|
648
|
+
titleBar: { title: 'My Application', logo: 'home' },
|
|
649
|
+
menu: { data: menuData }
|
|
650
|
+
}}
|
|
651
|
+
onEvent={handleEvent}
|
|
652
|
+
/>
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### Data Components
|
|
658
|
+
|
|
659
|
+
#### CustomTable
|
|
660
|
+
|
|
661
|
+
Data grid with inline editing, formulas, and custom cell types.
|
|
662
|
+
|
|
663
|
+
**Props:**
|
|
664
|
+
- `columns` (array): Column definitions
|
|
665
|
+
- `data` (array): Table data (2D array)
|
|
666
|
+
- `onChange` (function): Data change handler
|
|
667
|
+
- `onCellBlur` (function): Cell blur handler
|
|
668
|
+
- `onCellFocus` (function): Cell focus handler
|
|
669
|
+
- `doNotAllowRowAdd` (boolean): Disable row addition
|
|
670
|
+
- `loading` (boolean): Show loading state
|
|
671
|
+
|
|
672
|
+
**Methods (via ref):**
|
|
673
|
+
- `getValue()`: Returns table data as 2D array
|
|
674
|
+
- `getObjectValue()`: Returns table data with column metadata
|
|
675
|
+
- `setValue(data)`: Sets table data
|
|
676
|
+
- `getCellValue(row, col)`: Gets cell value
|
|
677
|
+
- `setCellValue(row, col, value)`: Sets cell value
|
|
678
|
+
- `addRow()`: Adds new row
|
|
679
|
+
- `deleteRow(rowIndex)`: Deletes row
|
|
680
|
+
|
|
681
|
+
**Example:**
|
|
682
|
+
```javascript
|
|
683
|
+
import { CustomTable } from 'sdcpl-react-component';
|
|
684
|
+
import { useRef } from 'react';
|
|
685
|
+
|
|
686
|
+
function MyComponent() {
|
|
687
|
+
const tableRef = useRef();
|
|
688
|
+
|
|
689
|
+
const columns = [
|
|
690
|
+
{ header: 'Name', width: 200, type: 'textbox', params: { type: 'text' } },
|
|
691
|
+
{ header: 'Price', width: 120, type: 'textbox', params: { type: 'currency' } },
|
|
692
|
+
{ header: 'Total', width: 120, type: 'label', params: { formula: 'C1 * C2' } }
|
|
693
|
+
];
|
|
694
|
+
|
|
695
|
+
const data = [
|
|
696
|
+
['Laptop', 999.99, ''],
|
|
697
|
+
['Desk', 299.99, '']
|
|
698
|
+
];
|
|
699
|
+
|
|
700
|
+
return (
|
|
701
|
+
<CustomTable
|
|
702
|
+
ref={tableRef}
|
|
703
|
+
columns={columns}
|
|
704
|
+
data={data}
|
|
705
|
+
onChange={(newData) => console.log('Data changed:', newData)}
|
|
706
|
+
/>
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
#### CustomTableComboBox
|
|
712
|
+
|
|
713
|
+
Advanced table with embedded combobox columns.
|
|
714
|
+
|
|
715
|
+
**Props:**
|
|
716
|
+
- `columns` (array): Column definitions (supports combobox type)
|
|
717
|
+
- `data` (array): Table data
|
|
718
|
+
- `onChange` (function): Data change handler
|
|
719
|
+
- Similar to CustomTable props
|
|
720
|
+
|
|
721
|
+
**Example:**
|
|
722
|
+
```javascript
|
|
723
|
+
import { CustomTableComboBox } from 'sdcpl-react-component';
|
|
724
|
+
|
|
725
|
+
function MyComponent() {
|
|
726
|
+
const columns = [
|
|
727
|
+
{ header: 'Product', width: 200, type: 'textbox' },
|
|
728
|
+
{ header: 'Category', width: 150, type: 'combobox', params: {
|
|
729
|
+
data: { list: [[1, 'Electronics'], [2, 'Furniture']] }
|
|
730
|
+
}}
|
|
731
|
+
];
|
|
732
|
+
|
|
733
|
+
return (
|
|
734
|
+
<CustomTableComboBox
|
|
735
|
+
columns={columns}
|
|
736
|
+
data={[['Laptop', '1']]}
|
|
737
|
+
onChange={(data) => console.log(data)}
|
|
738
|
+
/>
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
#### CustomReport
|
|
744
|
+
|
|
745
|
+
Advanced report component with conditional formatting and data visualization.
|
|
746
|
+
|
|
747
|
+
**Props:**
|
|
748
|
+
- `config` (object): Report configuration
|
|
749
|
+
- `data` (array): Report data
|
|
750
|
+
- `onEvent` (function): Event handler
|
|
751
|
+
|
|
752
|
+
**Methods (via ref):**
|
|
753
|
+
- `getValue()`: Returns report data
|
|
754
|
+
- `setValue(data)`: Sets report data
|
|
755
|
+
- `export(format)`: Exports report (format: 'pdf', 'excel', 'csv')
|
|
756
|
+
|
|
757
|
+
**Example:**
|
|
758
|
+
```javascript
|
|
759
|
+
import { CustomReport } from 'sdcpl-react-component';
|
|
760
|
+
|
|
761
|
+
function MyComponent() {
|
|
762
|
+
const reportConfig = {
|
|
763
|
+
title: 'Sales Report',
|
|
764
|
+
columns: [
|
|
765
|
+
{ header: 'Date', field: 'date', type: 'date' },
|
|
766
|
+
{ header: 'Amount', field: 'amount', type: 'currency' }
|
|
767
|
+
]
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
return (
|
|
771
|
+
<CustomReport
|
|
772
|
+
config={reportConfig}
|
|
773
|
+
data={reportData}
|
|
774
|
+
/>
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
#### CustomDashboard
|
|
780
|
+
|
|
781
|
+
Comprehensive dashboard component with 45+ component types and unified event handling.
|
|
782
|
+
|
|
783
|
+
**Props:**
|
|
784
|
+
- `config` (object): Dashboard configuration
|
|
785
|
+
- `onEvent` (function): Unified event handler
|
|
786
|
+
- `theme` (string): 'light' or 'dark'
|
|
787
|
+
|
|
788
|
+
**Methods (via ref):**
|
|
789
|
+
- `getValue()`: Returns dashboard configuration
|
|
790
|
+
- `setValue(config)`: Sets dashboard configuration
|
|
791
|
+
- `getComponentValue(id)`: Gets component value
|
|
792
|
+
- `setComponentValue(id, value)`: Sets component value
|
|
793
|
+
|
|
794
|
+
**Example:**
|
|
795
|
+
```javascript
|
|
796
|
+
import { CustomDashboard } from 'sdcpl-react-component';
|
|
797
|
+
|
|
798
|
+
function MyComponent() {
|
|
799
|
+
const dashboardConfig = {
|
|
800
|
+
layout: 'grid',
|
|
801
|
+
components: [
|
|
802
|
+
{ id: 'chart1', type: 'barchart', settings: { data: chartData } },
|
|
803
|
+
{ id: 'table1', type: 'table', settings: { columns: columns, data: data } }
|
|
804
|
+
]
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
return (
|
|
808
|
+
<CustomDashboard
|
|
809
|
+
config={dashboardConfig}
|
|
810
|
+
onEvent={(event) => console.log('Event:', event)}
|
|
811
|
+
/>
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Dashboard Components
|
|
817
|
+
|
|
818
|
+
The library includes 30+ dashboard chart components:
|
|
819
|
+
|
|
820
|
+
- **BarChart** - Bar chart visualization
|
|
821
|
+
- **LineChart** - Line chart visualization
|
|
822
|
+
- **PieChart** - Pie chart visualization
|
|
823
|
+
- **ScatterPlot** - Scatter plot visualization
|
|
824
|
+
- **Radar** - Radar chart
|
|
825
|
+
- **HeatMap** - Heat map visualization
|
|
826
|
+
- **BoxPlot** - Box plot visualization
|
|
827
|
+
- **PolarBar** - Polar bar chart
|
|
828
|
+
- **Sankey** - Sankey diagram
|
|
829
|
+
- **TreeMap** - Tree map visualization
|
|
830
|
+
- **Sunburst** - Sunburst chart
|
|
831
|
+
- **Tree** - Tree visualization
|
|
832
|
+
- **Icicle** - Icicle chart
|
|
833
|
+
- **CirclePacking** - Circle packing visualization
|
|
834
|
+
- **Voronoi** - Voronoi diagram
|
|
835
|
+
- **Funnel** - Funnel chart
|
|
836
|
+
- **Stream** - Stream graph
|
|
837
|
+
- **Bump** - Bump chart
|
|
838
|
+
- **Bullet** - Bullet chart
|
|
839
|
+
- **Chord** - Chord diagram
|
|
840
|
+
- **Network** - Network graph
|
|
841
|
+
- **ParallelCoordinates** - Parallel coordinates
|
|
842
|
+
- **Calendar** - Calendar heatmap
|
|
843
|
+
- **Waffle** - Waffle chart
|
|
844
|
+
- **SwarmPlot** - Swarm plot
|
|
845
|
+
- **RadialBar** - Radial bar chart
|
|
846
|
+
- **Marimekko** - Marimekko chart
|
|
847
|
+
- **Geo** - Geographic visualization
|
|
848
|
+
- **ActivityFeed** - Activity feed component
|
|
849
|
+
- **MetricCard** - Metric card display
|
|
850
|
+
- **DataTable** - Data table widget
|
|
851
|
+
- **MuiChartWrapper** - MUI chart wrapper
|
|
852
|
+
- **HeatmapVisualizer** - Heatmap visualizer
|
|
853
|
+
- **ComparisonVisualizer** - Comparison visualizer
|
|
854
|
+
- **DistributionVisualizer** - Distribution visualizer
|
|
855
|
+
- **MultiMetricVisualizer** - Multi-metric visualizer
|
|
856
|
+
- **ProgressVisualizer** - Progress visualizer
|
|
857
|
+
- **TimeSeriesVisualizer** - Time series visualizer
|
|
858
|
+
|
|
859
|
+
**Example:**
|
|
860
|
+
```javascript
|
|
861
|
+
import { BarChart, LineChart, PieChart } from 'sdcpl-react-component';
|
|
862
|
+
|
|
863
|
+
function MyComponent() {
|
|
864
|
+
const chartData = [
|
|
865
|
+
{ x: 'Jan', y: 100 },
|
|
866
|
+
{ x: 'Feb', y: 150 },
|
|
867
|
+
{ x: 'Mar', y: 200 }
|
|
868
|
+
];
|
|
869
|
+
|
|
870
|
+
return (
|
|
871
|
+
<div>
|
|
872
|
+
<BarChart data={chartData} />
|
|
873
|
+
<LineChart data={chartData} />
|
|
874
|
+
<PieChart data={chartData} />
|
|
875
|
+
</div>
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
## 🎨 Theming
|
|
881
|
+
|
|
882
|
+
All components support CSS variables for theming. Import the styles and customize:
|
|
883
|
+
|
|
884
|
+
```javascript
|
|
885
|
+
import 'sdcpl-react-component/styles';
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
Then override CSS variables in your CSS:
|
|
889
|
+
|
|
890
|
+
```css
|
|
891
|
+
:root {
|
|
892
|
+
/* Primary Colors */
|
|
893
|
+
--ctrl-primary-color: #3b82f6;
|
|
894
|
+
--ctrl-primary-hover: #2563eb;
|
|
895
|
+
--ctrl-primary-active: #1d4ed8;
|
|
896
|
+
|
|
897
|
+
/* Input Colors */
|
|
898
|
+
--ctrl-input-bg: #ffffff;
|
|
899
|
+
--ctrl-input-border: #d1d5db;
|
|
900
|
+
--ctrl-input-focus: #3b82f6;
|
|
901
|
+
|
|
902
|
+
/* Text Colors */
|
|
903
|
+
--ctrl-text-primary: #1f2937;
|
|
904
|
+
--ctrl-text-secondary: #6b7280;
|
|
905
|
+
--ctrl-text-disabled: #9ca3af;
|
|
906
|
+
|
|
907
|
+
/* Validation Colors */
|
|
908
|
+
--ctrl-error-color: #ef4444;
|
|
909
|
+
--ctrl-success-color: #10b981;
|
|
910
|
+
}
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
## 🔧 Utilities
|
|
914
|
+
|
|
915
|
+
### Icon Resolver
|
|
916
|
+
|
|
917
|
+
Resolve FontAwesome icons by name:
|
|
918
|
+
|
|
919
|
+
```javascript
|
|
920
|
+
import { resolveIcon } from 'sdcpl-react-component';
|
|
921
|
+
|
|
922
|
+
const icon = resolveIcon('user'); // Returns FontAwesome icon object
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
### Utility Functions
|
|
926
|
+
|
|
927
|
+
```javascript
|
|
928
|
+
import { utils } from 'sdcpl-react-component';
|
|
929
|
+
|
|
930
|
+
// Formatting functions
|
|
931
|
+
utils.formatCurrency(1000, '$'); // '$1,000.00'
|
|
932
|
+
utils.formatNumber(1234.56, 2); // '1,234.56'
|
|
933
|
+
utils.formatDateTime(new Date(), 'date'); // '2024-01-01'
|
|
934
|
+
|
|
935
|
+
// Validation functions
|
|
936
|
+
utils.validateEmail('test@example.com'); // true
|
|
937
|
+
utils.validatePhone('123-456-7890'); // true
|
|
938
|
+
|
|
939
|
+
// Focus management
|
|
940
|
+
utils.moveFocus(currentElement, direction); // 'next' | 'prev' | 'first' | 'last'
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
## 🗄️ IndexedDB Integration
|
|
944
|
+
|
|
945
|
+
The library includes IndexedDB support for offline data storage:
|
|
946
|
+
|
|
947
|
+
```javascript
|
|
948
|
+
import { IndexDBStore } from 'sdcpl-react-component';
|
|
949
|
+
|
|
950
|
+
// Initialize IndexedDB
|
|
951
|
+
await IndexDBStore.initialize('myapp.com', {
|
|
952
|
+
categories: {
|
|
953
|
+
version: 1,
|
|
954
|
+
type: 'object',
|
|
955
|
+
data: [
|
|
956
|
+
{ id: 1, name: 'Electronics' },
|
|
957
|
+
{ id: 2, name: 'Furniture' }
|
|
958
|
+
]
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
// Use in ComboBox
|
|
963
|
+
<CustomComboBox
|
|
964
|
+
datasource="indexdb"
|
|
965
|
+
indexdbKey="categories"
|
|
966
|
+
idColumn={0}
|
|
967
|
+
valueColumn={1}
|
|
968
|
+
/>
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
## 📝 License
|
|
972
|
+
|
|
973
|
+
MIT
|
|
974
|
+
|
|
975
|
+
## 🤝 Contributing
|
|
976
|
+
|
|
977
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
978
|
+
|
|
979
|
+
## 📧 Support
|
|
980
|
+
|
|
981
|
+
For issues and questions, please open an issue on GitHub.
|
|
982
|
+
|
|
983
|
+
---
|
|
984
|
+
|
|
985
|
+
**Built with ❤️ using React and FontAwesome**
|
|
986
|
+
|