@aziziaziz/react-components 1.0.1 → 1.0.3

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/dist/index.d.mts CHANGED
@@ -1,25 +1,468 @@
1
- import { FC } from 'react';
1
+ import { FC, PropsWithChildren } from 'react';
2
2
 
3
+ /**
4
+ * Props for the Input component.
5
+ */
3
6
  interface InputProps {
7
+ /**
8
+ * Unique identifier for the input field.
9
+ * Used by react-hook-form as the field name.
10
+ */
4
11
  id: string;
12
+ /**
13
+ * Label text displayed above the input.
14
+ *
15
+ * @default "Label"
16
+ */
5
17
  label?: string;
18
+ /**
19
+ * Placeholder text shown when the input is empty.
20
+ *
21
+ * @default "Placeholder"
22
+ */
6
23
  placeholder?: string;
24
+ /**
25
+ * Marks the input as required in form validation.
26
+ *
27
+ * When true, react-hook-form will enforce a required rule.
28
+ *
29
+ * @default false
30
+ */
7
31
  required?: boolean;
32
+ /**
33
+ * Hides the label visually while keeping the input functional.
34
+ *
35
+ * Useful for compact layouts or custom label rendering.
36
+ *
37
+ * @default false
38
+ */
8
39
  hideLabel?: boolean;
40
+ /**
41
+ * Displays a loading indicator inside the input.
42
+ *
43
+ * Typically used while fetching or validating data.
44
+ *
45
+ * @default false
46
+ */
9
47
  loading?: boolean;
48
+ /**
49
+ * Disables the input field.
50
+ *
51
+ * Prevents user interaction and applies disabled styles.
52
+ *
53
+ * @default false
54
+ */
10
55
  disabled?: boolean;
11
56
  }
12
57
 
58
+ /** Create an input component including label
59
+ *
60
+ * This component needs to be wrap in FormProvider from react-hook-form
61
+ */
13
62
  declare const Input: FC<InputProps>;
14
63
 
15
64
  interface SkeletonLoadingProps {
16
65
  /** The border radius of the skeleton
17
66
  *
18
- * Default: 10
67
+ * @default 10
19
68
  */
20
69
  radius?: number;
21
70
  }
22
71
 
72
+ /** A skeleton loading with animation
73
+ *
74
+ * This needs to be wrap in a container with position: relative;
75
+ */
23
76
  declare const SkeletonLoading: FC<SkeletonLoadingProps>;
24
77
 
25
- export { Input, type InputProps, SkeletonLoading, type SkeletonLoadingProps };
78
+ /**
79
+ * Props for the Button component.
80
+ */
81
+ interface ButtonProps extends PropsWithChildren {
82
+ /**
83
+ * Callback fired when the button is clicked.
84
+ */
85
+ onClick: () => void;
86
+ /**
87
+ * Additional CSS class names to apply to the button.
88
+ *
89
+ * Useful for custom styling or utility classes.
90
+ */
91
+ className?: string;
92
+ /**
93
+ * Visual style of the button.
94
+ *
95
+ * @default "submit"
96
+ */
97
+ type?: "warning" | "danger" | "submit";
98
+ /**
99
+ * Displays a loading state inside the button.
100
+ *
101
+ * When true, the button may show a spinner and
102
+ * user interaction should be disabled.
103
+ *
104
+ * @default false
105
+ */
106
+ loading?: boolean;
107
+ /**
108
+ * Disables the button.
109
+ *
110
+ * Prevents click events and applies disabled styles.
111
+ *
112
+ * @default false
113
+ */
114
+ disabled?: boolean;
115
+ /**
116
+ * Size variant of the button.
117
+ *
118
+ * @default "default"
119
+ */
120
+ size?: "default" | "medium" | "small";
121
+ /**
122
+ * Removes the minimum width constraint from the button.
123
+ *
124
+ * Useful for icon-only or compact buttons.
125
+ *
126
+ * @default false
127
+ */
128
+ removeMinWidth?: boolean;
129
+ }
130
+
131
+ /** The button component with size and type */
132
+ declare const Button: FC<ButtonProps>;
133
+
134
+ /**
135
+ * Props for the DatePicker component.
136
+ */
137
+ interface DatePickerProps {
138
+ /**
139
+ * Unique identifier for the date picker input.
140
+ * Used for accessibility and form association.
141
+ */
142
+ id: string;
143
+ /**
144
+ * Optional label text displayed for the date picker.
145
+ *
146
+ * @default "Label"
147
+ */
148
+ label?: string;
149
+ /**
150
+ * Placeholder text shown when no date is selected.
151
+ *
152
+ * @default "Placeholder"
153
+ */
154
+ placeholder?: string;
155
+ /**
156
+ * Whether the date picker is in a loading state.
157
+ * Typically used to indicate async data or processing.
158
+ *
159
+ * @default false
160
+ */
161
+ loading?: boolean;
162
+ /**
163
+ * Whether the date picker is disabled and non-interactive.
164
+ *
165
+ * @default false
166
+ */
167
+ disabled?: boolean;
168
+ }
169
+
170
+ declare const DatePicker: React.FC<DatePickerProps>;
171
+
172
+ /**
173
+ * Props for the Drawer component.
174
+ */
175
+ interface DrawerProps extends PropsWithChildren {
176
+ /**
177
+ * Controls whether the drawer is visible.
178
+ */
179
+ show: boolean;
180
+ /**
181
+ * Callback invoked to update the drawer's visibility state.
182
+ *
183
+ * @param value - The new visibility state.
184
+ */
185
+ updateShow: (value: boolean) => void;
186
+ }
187
+
188
+ declare const Drawer: React.FC<DrawerProps>;
189
+
190
+ /**
191
+ * Represents a single selectable option in the Dropdown component.
192
+ */
193
+ interface DropdownOptions {
194
+ /**
195
+ * The underlying value associated with the option.
196
+ * Can be a primitive or an object, depending on usage.
197
+ */
198
+ value: object | string;
199
+ /**
200
+ * The text label displayed to the user for this option.
201
+ */
202
+ label: string;
203
+ }
204
+ /**
205
+ * Props for the Dropdown component.
206
+ */
207
+ interface DropdownProps {
208
+ /**
209
+ * Unique identifier for the dropdown element.
210
+ * Used for accessibility and form integration.
211
+ */
212
+ id: string;
213
+ /**
214
+ * List of selectable options displayed in the dropdown.
215
+ */
216
+ options: DropdownOptions[];
217
+ /**
218
+ * Optional label text displayed above or alongside the dropdown.
219
+ *
220
+ * @default "Label"
221
+ */
222
+ label?: string;
223
+ /**
224
+ * Placeholder text shown when no option is selected.
225
+ *
226
+ * @default "Placeholder"
227
+ */
228
+ placeholder?: string;
229
+ /**
230
+ * Whether the dropdown is in a loading state.
231
+ * Typically used to indicate asynchronous option loading.
232
+ *
233
+ * @default false
234
+ */
235
+ loading?: boolean;
236
+ /**
237
+ * Whether the dropdown is disabled and non-interactive.
238
+ *
239
+ * @default false
240
+ */
241
+ disabled?: boolean;
242
+ }
243
+
244
+ declare const Dropdown: React.FC<DropdownProps>;
245
+
246
+ /**
247
+ * Props for the Icon component.
248
+ */
249
+ interface IconProps {
250
+ /**
251
+ * Source URL or path for the icon image.
252
+ */
253
+ src: string;
254
+ /**
255
+ * Optional CSS class names applied to the icon element.
256
+ */
257
+ className?: string;
258
+ /**
259
+ * Whether the icon should be rendered in a flat style
260
+ *
261
+ * @default true
262
+ */
263
+ flat?: boolean;
264
+ }
265
+
266
+ declare const Icon: React.FC<IconProps>;
267
+
268
+ type SnackbarType = "info" | "danger" | "warning" | "success";
269
+ interface SnackbarReturn {
270
+ /** To show the snackbar */
271
+ showSnackbar: (
272
+ /** Can be in any string format of the message to show */
273
+ message: string,
274
+ /** info, danger, warning or success - default: info */
275
+ type?: SnackbarType) => void;
276
+ }
277
+ /** Init the snackbar container
278
+ *
279
+ * @param id To set the id of the root container of the snackbar - default: snackbarRoot
280
+ * @param timeout To set the timeout on when the snackbar will be auto hide - default: 3000
281
+ */
282
+ declare const useSnackbar: (body?: HTMLElement | null, id?: string, timeout?: number) => SnackbarReturn;
283
+
284
+ /**
285
+ * Available notification types.
286
+ */
287
+ type NotiTypes = "default" | "error" | "warning" | "success";
288
+ /**
289
+ * Notification payload structure sent to the parent window.
290
+ */
291
+ interface NotificationType {
292
+ /**
293
+ * The notification message text.
294
+ */
295
+ message: string;
296
+ /**
297
+ * Notification visual type.
298
+ *
299
+ * @default "default"
300
+ */
301
+ type?: NotiTypes;
302
+ /**
303
+ * Duration (in milliseconds) before the notification auto-dismisses.
304
+ *
305
+ * @default undefined
306
+ */
307
+ duration?: number;
308
+ }
309
+ /**
310
+ * Configuration object for a popup component.
311
+ */
312
+ interface PopupType {
313
+ /**
314
+ * Title or header text displayed at the top of the popup.
315
+ */
316
+ header?: string;
317
+ /**
318
+ * Main content text displayed inside the popup.
319
+ *
320
+ * Can be plain text or formatted content depending on usage.
321
+ */
322
+ content?: string;
323
+ }
324
+ /**
325
+ * Configuration object for a confirmation or question dialog.
326
+ */
327
+ interface QuestionType {
328
+ /**
329
+ * Title or header text of the question dialog.
330
+ */
331
+ header: string;
332
+ /**
333
+ * Main content or message of the question.
334
+ *
335
+ * Typically explains what action the user is being asked to confirm.
336
+ */
337
+ content: string;
338
+ /**
339
+ * Value returned when the user confirms or selects "Yes".
340
+ *
341
+ * @default "Yes"
342
+ */
343
+ yesValue?: string;
344
+ /**
345
+ * Value returned when the user declines or selects "No".
346
+ *
347
+ * @default "No"
348
+ */
349
+ noValue?: string;
350
+ /**
351
+ * Indicates whether the action is destructive.
352
+ *
353
+ * When true, the dialog should visually emphasize caution
354
+ * (e.g. red buttons or warning styles).
355
+ *
356
+ * @default false
357
+ */
358
+ isDestructive?: boolean;
359
+ }
360
+ /**
361
+ * Function signature for posting a message to the parent window.
362
+ */
363
+ interface PostMessage {
364
+ /**
365
+ * Sends a message to the parent window via `window.postMessage`.
366
+ *
367
+ * @param data - The data payload to send to the parent window
368
+ */
369
+ (data: any): void;
370
+ }
371
+ /**
372
+ * Function signature for posting a notification message
373
+ * to the parent window.
374
+ */
375
+ interface PostNotification {
376
+ /**
377
+ * Sends a notification payload to the parent window.
378
+ *
379
+ * @param data - Notification data including message, type and duration
380
+ */
381
+ (data: NotificationType): void;
382
+ }
383
+ /**
384
+ * Function signature for posting a popup payload
385
+ * to the parent window.
386
+ */
387
+ interface PostPopup {
388
+ /**
389
+ * Sends a popup configuration to the parent window.
390
+ *
391
+ * Typically used to trigger modal or popup displays
392
+ * in the parent application.
393
+ *
394
+ * @param data - Popup configuration including header and content
395
+ */
396
+ (data: PopupType): void;
397
+ }
398
+ /**
399
+ * Function signature for posting a question or confirmation dialog
400
+ * to the parent window.
401
+ */
402
+ interface PostQuestion {
403
+ /**
404
+ * Sends a question configuration to the parent window.
405
+ *
406
+ * Typically used to trigger confirmation or decision dialogs
407
+ * in the parent application.
408
+ *
409
+ * @param data - Question configuration including content and response values
410
+ *
411
+ * @returns The yes or no text from the button that the user clicked
412
+ */
413
+ (data: QuestionType): Promise<string>;
414
+ }
415
+ /**
416
+ * Return object of the `usePostMessage` / `useIFrameDimensions` hook.
417
+ */
418
+ interface UsePostMessageReturn {
419
+ /**
420
+ * Sends the current iframe width and height to the parent window.
421
+ *
422
+ * Useful when the iframe content changes size dynamically.
423
+ */
424
+ sendDimension: () => void;
425
+ /**
426
+ * Posts a custom message to the parent window.
427
+ */
428
+ postMessage: PostMessage;
429
+ /**
430
+ * Posts a notification message to the parent window.
431
+ *
432
+ * Typically used to trigger toast/snackbar notifications
433
+ * in the parent application.
434
+ */
435
+ postNotification: PostNotification;
436
+ /**
437
+ * Posts a popup configuration to the parent window.
438
+ *
439
+ * Typically used to trigger modal or popup displays
440
+ * in the parent application.
441
+ */
442
+ postPopup: PostPopup;
443
+ /**
444
+ * Posts a question or confirmation dialog configuration
445
+ * to the parent window.
446
+ *
447
+ * Typically used to prompt the user to confirm or
448
+ * make a decision in the parent application.
449
+ */
450
+ postQuestion: PostQuestion;
451
+ }
452
+
453
+ /**
454
+ * React hook for communicating iframe dimensions and messages
455
+ * to a parent window.
456
+ *
457
+ * This hook automatically:
458
+ * - Sends initial iframe dimensions on mount
459
+ * - Updates dimensions on DOM content load
460
+ * - Updates dimensions on window resize
461
+ *
462
+ * @param url - The target origin for `postMessage`
463
+ *
464
+ * @returns Functions for sending dimensions and posting custom messages
465
+ */
466
+ declare const usePostMessage: (url: string) => UsePostMessageReturn;
467
+
468
+ export { Button, type ButtonProps, DatePicker, type DatePickerProps, Drawer, type DrawerProps, Dropdown, type DropdownOptions, type DropdownProps, Icon, type IconProps, Input, type InputProps, type NotificationType, SkeletonLoading, type SkeletonLoadingProps, usePostMessage, useSnackbar };