@hari_digitus/sms-ui-library 4.0.12 → 4.0.14
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 +462 -0
- package/dist/notifications.cjs.js +85 -0
- package/dist/notifications.es.js +3718 -0
- package/dist/types/components/Loader/Loader.d.ts +1 -0
- package/dist/types/components/Modal/Modal.d.ts +12 -0
- package/dist/types/components/Modal/Modal.types.d.ts +11 -0
- package/dist/types/components/Popover/Popover.d.ts +15 -0
- package/dist/types/components/ProgressBar/ProgressBar.d.ts +20 -0
- package/dist/types/components/Toast/Toast.d.ts +3 -0
- package/dist/types/components/Toast/Toast.types.d.ts +7 -0
- package/dist/types/icons/icon.d.ts +4 -4
- package/dist/types/index.d.ts +9 -13
- package/package.json +18 -22
- package/README.md +0 -510
- package/dist/form-controls.cjs.js +0 -209
- package/dist/form-controls.es.js +0 -11473
- package/dist/sms-ui-library.css +0 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +0 -19
- package/dist/types/components/DatePicker/DatePicker.d.ts +0 -22
- package/dist/types/components/DragDropUpload/DragDropUpload.d.ts +0 -26
- package/dist/types/components/InputFields/Input.d.ts +0 -14
- package/dist/types/components/MultiSelect/MultiSelect.d.ts +0 -22
- package/dist/types/components/RadioButton/RadioButton.d.ts +0 -15
- package/dist/types/components/Select/Select.d.ts +0 -41
- package/dist/types/components/SingleSelect/SingleSelect.d.ts +0 -24
- package/dist/types/components/TextArea/textarea.d.ts +0 -6
- package/dist/types/components/ToggleButton/ToggleSwitch.d.ts +0 -15
- package/dist/types/components/Tooltip/Tooltip.d.ts +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Loader(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
footer?: any;
|
|
8
|
+
width?: string;
|
|
9
|
+
showCloseIcon: any;
|
|
10
|
+
}
|
|
11
|
+
declare const Modal: React.FC<ModalProps>;
|
|
12
|
+
export default Modal;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FC, type CSSProperties } from "react";
|
|
2
|
+
type Position = "top" | "bottom" | "left" | "right";
|
|
3
|
+
export interface TextPopoverProps {
|
|
4
|
+
text: string;
|
|
5
|
+
maxLength?: number;
|
|
6
|
+
maxWidth?: number;
|
|
7
|
+
position?: Position;
|
|
8
|
+
bgColor?: string;
|
|
9
|
+
textColor?: string;
|
|
10
|
+
borderColor?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare const TextPopover: FC<TextPopoverProps>;
|
|
15
|
+
export default TextPopover;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ProgressBarProps {
|
|
3
|
+
value: number;
|
|
4
|
+
showLabel?: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
showPercentage?: boolean;
|
|
7
|
+
height?: string;
|
|
8
|
+
containerClassName?: string;
|
|
9
|
+
progressClassName?: string;
|
|
10
|
+
wrapperClassName?: string;
|
|
11
|
+
labelClassName?: string;
|
|
12
|
+
percentageClassName?: string;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
progressColor?: string;
|
|
15
|
+
animated?: boolean;
|
|
16
|
+
striped?: boolean;
|
|
17
|
+
orientation?: "horizontal" | "vertical";
|
|
18
|
+
dataTestId?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const ProgressBar: React.FC<ProgressBarProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
1
|
+
import SaveIcon from './save-icon.svg?react';
|
|
2
|
+
import CloseIcon from './close.svg?react';
|
|
3
|
+
import ErrorIcon from './error-icon.svg?react';
|
|
4
|
+
export { SaveIcon, CloseIcon, ErrorIcon };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
10
|
-
export { Input } from "./components/InputFields/Input";
|
|
11
|
-
export { default as CustomDatePicker } from "./components/DatePicker/DatePicker";
|
|
12
|
-
export { default as SingleSelect } from "./components/SingleSelect/SingleSelect";
|
|
13
|
-
export { default as Tooltip } from "./components/Tooltip/Tooltip";
|
|
1
|
+
export { cn } from "./lib/utils";
|
|
2
|
+
export { Loader } from "./components/Loader/Loader";
|
|
3
|
+
export { ProgressBar } from "./components/ProgressBar/ProgressBar";
|
|
4
|
+
export { TextPopover } from "./components/Popover/Popover";
|
|
5
|
+
export type { TextPopoverProps } from "./components/Popover/Popover";
|
|
6
|
+
export { default as Toast } from "./components/Toast/Toast";
|
|
7
|
+
export type { ToastProps } from "./components/Toast/Toast.types";
|
|
8
|
+
export { default as Modal } from "./components/Modal/Modal";
|
|
9
|
+
export type { ModalProps } from "./components/Modal/Modal.types";
|
package/package.json
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"main": "dist/
|
|
5
|
-
"module": "dist/
|
|
2
|
+
"name": "@hari_digitus/sms-ui-library",
|
|
3
|
+
"version": "4.0.14",
|
|
4
|
+
"main": "dist/notifications.cjs.js",
|
|
5
|
+
"module": "dist/notifications.es.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/
|
|
10
|
-
"require": "./dist/
|
|
11
|
-
}
|
|
12
|
-
"./dist/form-controls.css": "./dist/form-controls.css",
|
|
13
|
-
"./style.css": "./dist/form-controls.css"
|
|
9
|
+
"import": "./dist/notifications.es.js",
|
|
10
|
+
"require": "./dist/notifications.cjs.js"
|
|
11
|
+
}
|
|
14
12
|
},
|
|
15
13
|
"files": [
|
|
16
14
|
"dist"
|
|
17
15
|
],
|
|
18
16
|
"scripts": {
|
|
19
17
|
"build": "vite build && npx tsc --emitDeclarationOnly",
|
|
20
|
-
"dev": "vite build --watch"
|
|
21
|
-
"test": "vite"
|
|
18
|
+
"dev": "vite build --watch"
|
|
22
19
|
},
|
|
23
20
|
"repository": {
|
|
24
21
|
"type": "git",
|
|
25
22
|
"url": "https://github.com/digitus-git/AFCI_OffAuto/tree/develop_rel_phase1/packages"
|
|
26
23
|
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^18.3.1",
|
|
26
|
+
"react-dom": "^18.3.1"
|
|
27
|
+
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
+
"@tailwindcss/postcss": "^4.3.0",
|
|
30
|
+
"@types/react": "18.3.1",
|
|
29
31
|
"@types/react-dom": "18.3.1",
|
|
30
32
|
"@vitejs/plugin-react": "^4.0.0",
|
|
33
|
+
"autoprefixer": "^10.5.0",
|
|
34
|
+
"postcss": "^8.5.15",
|
|
35
|
+
"tailwindcss": "^4.3.0",
|
|
31
36
|
"typescript": "^4.9.5",
|
|
32
37
|
"vite": "^6.0.0",
|
|
33
38
|
"vite-plugin-svgr": "^5.2.0"
|
|
34
39
|
},
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"react": "^18.3.1",
|
|
37
|
-
"react-dom": "^18.3.1"
|
|
38
|
-
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"@radix-ui/react-select": "^2.2.6",
|
|
41
|
-
"@tailwindcss/postcss": "^4.3.0",
|
|
42
|
-
"autoprefixer": "^10.5.0",
|
|
43
42
|
"class-variance-authority": "^0.7.0",
|
|
44
43
|
"clsx": "2.1.1",
|
|
45
44
|
"lucide-react": "^1.16.0",
|
|
46
|
-
"
|
|
47
|
-
"react-datepicker": "^8.7.0",
|
|
48
|
-
"tailwind-merge": "3.2.0",
|
|
49
|
-
"tailwindcss": "^4.3.0"
|
|
45
|
+
"tailwind-merge": "3.2.0"
|
|
50
46
|
}
|
|
51
47
|
}
|
package/README.md
DELETED
|
@@ -1,510 +0,0 @@
|
|
|
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
|
-
|