@hari_digitus/sms-ui-library 2.0.0 → 2.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 ADDED
@@ -0,0 +1,510 @@
1
+ To import CSS, use:
2
+
3
+ ```js/ts
4
+ import "@digitus-fci-oa/form-controls/style.css";
5
+ ```
6
+
7
+ # CustomDatePicker
8
+
9
+ ## Single Date
10
+
11
+ ```tsx
12
+ <CustomDatePicker
13
+ mode="date"
14
+ value={date}
15
+ onChangeSingle={setDate}
16
+ />
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Date & Time
22
+
23
+ ```tsx
24
+ <CustomDatePicker
25
+ mode="dateTime"
26
+ value={dateTime}
27
+ onChangeSingle={setDateTime}
28
+ />
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Date Range
34
+
35
+ ```tsx
36
+ <CustomDatePicker
37
+ mode="range"
38
+ fromDate={startDate}
39
+ endDate={endDate}
40
+ onRangeChange={(start, end) => {
41
+ setStartDate(start)
42
+ setEndDate(end)
43
+ }}
44
+ />
45
+ ```
46
+ ---
47
+
48
+ # Checkbox
49
+
50
+ ## Basic Checkbox
51
+
52
+ ```tsx
53
+ import { Checkbox } from "@digitus-fci-oa/form-controls";
54
+ import { useState } from "react";
55
+
56
+ export default function TestCheckbox() {
57
+ const [checked, setChecked] = useState(false);
58
+
59
+ return (
60
+ <Checkbox
61
+ label="Mandatory Field"
62
+ checked={checked}
63
+ onChange={setChecked}
64
+ />
65
+ );
66
+ }
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Checkbox With Required
72
+
73
+ ```tsx
74
+ <Checkbox
75
+ label="Accept Terms & Conditions"
76
+ checked={checked}
77
+ onChange={setChecked}
78
+ required
79
+ />
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Disabled Checkbox
85
+
86
+ ```tsx
87
+ <Checkbox
88
+ label="Disabled Checkbox"
89
+ checked={true}
90
+ onChange={setChecked}
91
+ disabled
92
+ />
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Checkbox With Test Id
98
+
99
+ ```tsx
100
+ <Checkbox
101
+ label="Mandatory Field"
102
+ checked={checked}
103
+ onChange={setChecked}
104
+ dataTestId="mandatory-checkbox"
105
+ />
106
+ ```
107
+ npm install @digitus-fci-oa/form-controls
108
+
109
+ ```
110
+ import { DragDropUpload } from "@digitus-fci-oa/form-controls";
111
+ import { Upload } from "lucide-react";
112
+
113
+ function App() {
114
+ const inputRef = useRef<HTMLInputElement>(null);
115
+
116
+ const [isDragging, setIsDragging] = useState(false);
117
+ const [isUploading, setIsUploading] = useState(false);
118
+
119
+ return (
120
+ <DragDropUpload
121
+ inputRef={inputRef}
122
+ isDragging={isDragging}
123
+ isUploading={isUploading}
124
+ disabled={false}
125
+ multiple={true}
126
+ accept=".pdf,.doc,.docx,.png,.jpg"
127
+ onFilesChange={(files) => {
128
+ console.log(files);
129
+ }}
130
+ onDrop={(e) => {
131
+ e.preventDefault();
132
+ setIsDragging(false);
133
+ }}
134
+ onDragOver={(e) => {
135
+ e.preventDefault();
136
+ setIsDragging(true);
137
+ }}
138
+ onDragLeave={() => {
139
+ setIsDragging(false);
140
+ }}
141
+ onClick={() => inputRef.current?.click()}
142
+ title="Drag & Drop Files Here"
143
+ subtitle="or"
144
+ buttonText="Browse"
145
+ uploadingText="Uploading files..."
146
+ footerText="(File Size Max 10MB)"
147
+ icon={<Upload className="w-12 h-12" />}
148
+ buttonClassName="
149
+ !px-[25px]
150
+ !py-[6px]
151
+ !bg-[#1570EF]
152
+ text-white
153
+ hover:bg-[#0047a3]
154
+ "
155
+ />
156
+ );
157
+ }
158
+
159
+ ```
160
+ ---
161
+
162
+ ## Props
163
+
164
+ | Prop | Type | Default | Description |
165
+ | ---------------- | ----------------------------- | ------------ | ------------------------------------ |
166
+ | `label` | `string` | `undefined` | Checkbox label text |
167
+ | `checked` | `boolean` | `false` | Controls checked state |
168
+ | `onChange` | `(checked: boolean) => void` | � | Triggered when checkbox changes |
169
+ | `disabled` | `boolean` | `false` | Disables checkbox |
170
+ | `id` | `string` | `undefined` | HTML id for checkbox |
171
+ | `className` | `string` | `""` | Custom wrapper class |
172
+ | `labelClassName` | `string` | `""` | Custom label class |
173
+ | `required` | `boolean` | `false` | Shows required asterisk |
174
+ | `dataTestId` | `string` | `undefined` | Test id for automation/testing |
175
+ | `onFilesChange` | `(files: FileList \| null) => void` | `undefined` | Callback triggered when files are
176
+ | `accept` | `string` | `"*"` | Allowed file types |
177
+ | `multiple` | `boolean` | `true` | Allows multiple file selection |
178
+ | `disabled` | `boolean` | `false` | Disables uploader interactions |
179
+ | `isUploading` | `boolean` | `false` | Shows uploading state |
180
+ | `title` | `string` | `"Drag & Drop Files Here"` | Main upload area itle |
181
+ | `subtitle` | `string` | `"or"` | Subtitle text below title |
182
+ | `buttonText` |`string` | `"Browse"` | Browse button text |
183
+ | `uploadingText` | `string` | `"Uploading files..."` | Uploading message text |
184
+ | `footerText` | `string` | `"(File Size Max 10MB)"` | Footer/helper text |
185
+ | `icon` | `React.ReactNode` | `undefined` | Custom upload icon |
186
+ | `containerClassName` | `string` | `""` | Custom wrapper/container class |
187
+ | `dropZoneClassName` | `string` | `""` | Custom dropzone class |
188
+ | `buttonClassName` | `string` | `""` | Custom browse button class |
189
+ | `inputId` | `string` | `"file-upload"` | Custom input element id |
190
+
191
+
192
+
193
+ # MultiSelect Component
194
+
195
+ A lightweight, accessible multi-select dropdown built with React and Tailwind CSS.
196
+
197
+ ---
198
+
199
+ ## Usage
200
+
201
+ ```tsx
202
+ import { MultiSelect } from "./components/MultiSelect";
203
+
204
+ const options = [
205
+ { label: "Apple", value: "apple" },
206
+ { label: "Banana", value: "banana" },
207
+ { label: "Cherry", value: "cherry" },
208
+ ];
209
+
210
+ function App() {
211
+ const [selected, setSelected] = React.useState<string[]>([]);
212
+
213
+ return (
214
+ <MultiSelect
215
+ options={options}
216
+ value={selected}
217
+ onChange={setSelected}
218
+ placeholder="Select fruits..."
219
+ />
220
+ );
221
+ }
222
+ ```
223
+
224
+ ```
225
+ interface TooltipProps {
226
+
227
+ value: string;
228
+ icon?: React.ReactNode;
229
+ }
230
+ import Tooltip from "@digitus-fci-oa/form-controls";
231
+
232
+ <Tooltip
233
+ value="View Questionnaire"
234
+ icon={
235
+ <Eye
236
+ size={16}
237
+ className="cursor-pointer text-blue-600"
238
+ />
239
+ }
240
+ />
241
+
242
+
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Props
248
+
249
+ | Prop | Type | Required | Default | Description |
250
+ |---------------|-------------------------------|----------|----------------|------------------------------------------|
251
+ | `options` | `Option[]` | ✅ | — | List of options to display |
252
+ | `value` | `string[]` | ✅ | — | Currently selected values |
253
+ | `onChange` | `(value: string[]) => void` | ✅ | — | Callback when selection changes |
254
+ | `placeholder` | `string` | ❌ | `"Select..."` | Text shown when nothing is selected |
255
+ | `error` | `string` | ❌ | — | Error message shown below the dropdown |
256
+ value="View Questionnaire"| `string` | | text
257
+
258
+ ### Option Type
259
+
260
+ ```ts
261
+ interface Option {
262
+ label: string; // Display text
263
+ value: string; // Underlying value
264
+ }
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Features
270
+
271
+ - Multi-selection with toggle behavior (click to select/deselect)
272
+ - Selected labels shown as comma-separated text in the trigger button
273
+ - Dropdown opens/closes on button click
274
+ - Red border and error message on validation failure via `error` prop
275
+ - Scrollable list capped at `max-h-60`
276
+ - Checkmark indicator on selected items
277
+
278
+ ---
279
+
280
+ ## Error State
281
+
282
+ Pass an `error` string to show validation feedback:
283
+
284
+ ```tsx
285
+ <MultiSelect
286
+ options={options}
287
+ value={selected}
288
+ onChange={setSelected}
289
+ error="Please select at least one option."
290
+ />
291
+ ```
292
+
293
+ ---
294
+
295
+ ## Close on Outside Click
296
+
297
+ The dropdown does not close automatically on outside click. Add this to your component if needed:
298
+
299
+
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Dependencies
305
+
306
+ | Package | Purpose |
307
+ |-----------------|--------------------------------|
308
+ | `lucide-react` | Icons (`ChevronDown`, `Check`) |
309
+ | `tailwindcss` | Utility-based styling |
310
+ | `clsx` / `tailwind-merge` | `cn()` utility for class merging |
311
+
312
+ ---
313
+
314
+ ## File Structure
315
+
316
+ ```
317
+ src/
318
+ ├── components/
319
+ │ └── MultiSelect.tsx ← Component file
320
+ └── lib/
321
+ └── utils.ts ← cn() utility
322
+ ```
323
+
324
+
325
+
326
+
327
+
328
+ # Textarea Component
329
+
330
+ A resizable textarea input built with React and Tailwind CSS, with built-in error state support.
331
+
332
+ ---
333
+
334
+ ## Usage
335
+
336
+ ```tsx
337
+ import { Textarea } from "./components/Textarea";
338
+
339
+ function App() {
340
+ const [value, setValue] = React.useState("");
341
+
342
+ return (
343
+ <Textarea
344
+ value={value}
345
+ onChange={(e) => setValue(e.target.value)}
346
+ placeholder="Enter your text here..."
347
+ />
348
+ );
349
+ }
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Props
355
+
356
+ | Prop | Type | Required | Default | Description |
357
+ |-------------|-----------|----------|------------------------------|----------------------------------------------------------|
358
+ | `error` | `string` | ❌ | — | Error message displayed below the textarea |
359
+ | `className` | `string` | ❌ | — | Additional Tailwind classes to merge |
360
+ | `ref` | `Ref` | ❌ | — | Forwarded ref to the underlying `<textarea>` element |
361
+ | ...rest | `React.TextareaHTMLAttributes` | ❌ | — | All standard HTML textarea attributes (`onChange`, `disabled`, `rows`, etc.) |
362
+
363
+ > Extends all native `React.TextareaHTMLAttributes<HTMLTextAreaElement>` props.
364
+
365
+ ---
366
+
367
+ ## Features
368
+
369
+ - Forwarded ref support via `React.forwardRef`
370
+ - Built-in error state with red border and error message
371
+ - Fixed height of `4.5rem` with `resize-none` by default
372
+ - Custom `className` support with `cn()` merge utility
373
+ - Default placeholder text
374
+
375
+ ---
376
+
377
+ ## Error State
378
+
379
+ Pass an `error` string to highlight the field and show a message:
380
+
381
+ ```tsx
382
+ <Textarea
383
+ value={value}
384
+ onChange={(e) => setValue(e.target.value)}
385
+ error="This field is required."
386
+ />
387
+ ```
388
+
389
+ ---
390
+
391
+ ## With React Hook Form
392
+
393
+ ```tsx
394
+ import { useForm } from "react-hook-form";
395
+ import { Textarea } from "./components/Textarea";
396
+
397
+ function Form() {
398
+ const { register, formState: { errors } } = useForm();
399
+
400
+ return (
401
+ <Textarea
402
+ {...register("description", { required: "Description is required" })}
403
+ error={errors.description?.message}
404
+ />
405
+ );
406
+ }
407
+ ```
408
+
409
+ ---
410
+
411
+ ## Customizing Height
412
+
413
+ Override the default height using `className`:
414
+
415
+ ```tsx
416
+ <Textarea className="h-32" /> {/* taller */}
417
+ <Textarea className="h-20" /> {/* shorter */}
418
+ ```
419
+
420
+ ---
421
+
422
+ ## Dependencies
423
+
424
+ | Package | Purpose |
425
+ |---------------------------|----------------------------------|
426
+ | `react` | `forwardRef`, `TextareaHTMLAttributes` |
427
+ | `tailwindcss` | Utility-based styling |
428
+ | `clsx` / `tailwind-merge` | `cn()` utility for class merging |
429
+
430
+ ---
431
+
432
+ ## File Structure
433
+
434
+ ```
435
+ src/
436
+ ├── components/
437
+ │ └── Textarea.tsx ← Component file
438
+ └── lib/
439
+ └── utils.ts ← cn() utility
440
+ ```
441
+ ## Toggle Switch
442
+
443
+ ## Usage
444
+ import { ToggleSwitch } from "@digitus-fci-oa/form-controls";
445
+ import { useState } from "react";
446
+
447
+ export default function TestToggleSwitch() {
448
+ const [enabled, setEnabled] = useState(false);
449
+
450
+ return (
451
+ <ToggleSwitch
452
+ checked={enabled}
453
+ onChange={setEnabled}
454
+ label={enabled ? "Yes" : "No"}
455
+ />
456
+ );
457
+ }
458
+
459
+ ## Props
460
+
461
+ | Prop | Type | Default | Description |
462
+ | ---------- | ---------------------------- | ----------- | ----------------------------------- |
463
+ | `checked` | `boolean` | `false` | Controls toggle state |
464
+ | `onChange` | `(checked: boolean) => void` | — | Triggered when toggle state changes |
465
+ | `disabled` | `boolean` | `false` | Disables toggle interaction |
466
+ | `label` | `string` | `undefined` | Optional label beside toggle |
467
+
468
+
469
+ # RadioButton
470
+
471
+ import { Radio } from "@digitus-fci-oa/form-controls";
472
+ import { useState } from "react";
473
+
474
+ export default function TestRadio() {
475
+ const [selected, setSelected] = useState("yes");
476
+
477
+ return (
478
+ <div className="flex gap-4">
479
+
480
+ <Radio
481
+ label="Yes"
482
+ name="approval"
483
+ value="yes"
484
+ checked={selected === "yes"}
485
+ onChange={setSelected}
486
+ />
487
+
488
+ <Radio
489
+ label="No"
490
+ name="approval"
491
+ value="no"
492
+ checked={selected === "no"}
493
+ onChange={setSelected}
494
+ />
495
+
496
+ </div>
497
+ );
498
+ }
499
+
500
+ ## Props
501
+
502
+ | Prop | Type | Default | Description |
503
+ | ---------- | ------------------------- | ----------- | ------------------------------------- |
504
+ | `label` | `string` | `undefined` | Radio label text |
505
+ | `name` | `string` | — | Shared group name for radio selection |
506
+ | `value` | `string` | — | Value of radio option |
507
+ | `checked` | `boolean` | `false` | Controls selected state |
508
+ | `onChange` | `(value: string) => void` | — | Triggered when option changes |
509
+ | `disabled` | `boolean` | `false` | Disables radio interaction |
510
+