@mystaline/mysta-lib 1.0.0-alpha.5
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/build-entry.d.ts +4 -0
- package/components/button/Button.d.ts +119 -0
- package/components/checkbox/Checkbox.d.ts +81 -0
- package/components/dialog/Dialog.d.ts +50 -0
- package/components/dialogform/DialogForm.d.ts +24 -0
- package/components/fieldwrapper/FieldWrapper.d.ts +53 -0
- package/components/form/Form.d.ts +53 -0
- package/components/icon/Icon.d.ts +39 -0
- package/components/index.d.ts +20 -0
- package/components/inputtext/InputText.d.ts +111 -0
- package/components/radiobutton/RadioButton.d.ts +65 -0
- package/components/slot/Slot.d.ts +23 -0
- package/components/toggleswitch/ToggleSwitch.d.ts +64 -0
- package/context/FormContext.d.ts +12 -0
- package/context/LibContext.d.ts +16 -0
- package/context/index.d.ts +2 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/useComponentPreset.d.ts +5 -0
- package/hooks/useEffectiveControl.d.ts +2 -0
- package/hooks/useValidator.d.ts +22 -0
- package/index.d.ts +2 -0
- package/main.d.ts +2 -0
- package/mysta-lib.es.js +10120 -0
- package/mysta-lib.system.js +565 -0
- package/package.json +15 -0
- package/style.css +1 -0
- package/types/index.d.ts +0 -0
- package/utils/getSeverity.d.ts +7 -0
- package/utils/index.d.ts +4 -0
package/build-entry.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Severities } from '../../utils';
|
|
3
|
+
import { Icons } from '../icon/Icon.d';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props for the PrimaryButton component.
|
|
7
|
+
*
|
|
8
|
+
* @description Defines the props for the PrimaryButton, including visual customization, loading state, icon support, and click handling.
|
|
9
|
+
*/
|
|
10
|
+
export interface ButtonProps {
|
|
11
|
+
/**
|
|
12
|
+
* Height of the button (e.g., px, rem, %, etc.)
|
|
13
|
+
* Can be specified as a number (pixels) or string (e.g., '50px', '10rem').
|
|
14
|
+
*
|
|
15
|
+
* @default '26px'
|
|
16
|
+
*/
|
|
17
|
+
height?: number | string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Width of the button (e.g., px, rem, %, etc.)
|
|
21
|
+
* Can be specified as a number (pixels) or string (e.g., '100px', '50%').
|
|
22
|
+
*
|
|
23
|
+
* @default 'max-content'
|
|
24
|
+
*/
|
|
25
|
+
width?: number | string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Severity level for styling the button (e.g., "error", "warning", "success").
|
|
29
|
+
* Determines the color and style applied to the button.
|
|
30
|
+
*
|
|
31
|
+
* @default 'primary'
|
|
32
|
+
*/
|
|
33
|
+
severity?: Severities;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* If true, displays a loading spinner instead of the icon or label.
|
|
37
|
+
* Useful when the button is performing an asynchronous operation.
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
loading?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* If true, applies an outlined style (typically a button with just a border).
|
|
45
|
+
*
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
outlined?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* If true, applies a text-only style (no background, only text).
|
|
52
|
+
*
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
text?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If true, disables the button, preventing user interaction.
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* If true, adds a shadow to indicate elevation (e.g., raised effect).
|
|
66
|
+
*
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
raised?: boolean | undefined;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* If true, applies a circular border radius to the button.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
rounded?: boolean | undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Icon to display inside the button.
|
|
80
|
+
* Should be a valid `Icons` value from the icon library.
|
|
81
|
+
*
|
|
82
|
+
* @default undefined
|
|
83
|
+
*/
|
|
84
|
+
icon?: Icons;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Text label to display inside the button.
|
|
88
|
+
* Can be used alongside or instead of the icon.
|
|
89
|
+
*
|
|
90
|
+
* @default undefined
|
|
91
|
+
*/
|
|
92
|
+
label?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Click handler for the button.
|
|
96
|
+
* Called when the button is clicked.
|
|
97
|
+
*
|
|
98
|
+
* @default undefined
|
|
99
|
+
*/
|
|
100
|
+
onClick?: () => void;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Specifies the type of the button.
|
|
104
|
+
* - 'button': A generic button that does not submit a form.
|
|
105
|
+
* - 'submit': A button that submits the form.
|
|
106
|
+
* - 'reset': A button that resets the form fields.
|
|
107
|
+
*
|
|
108
|
+
* @default 'button'
|
|
109
|
+
*/
|
|
110
|
+
type?: 'button' | 'submit' | 'reset';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Primary button component with loading, severity, and preset support.
|
|
115
|
+
*
|
|
116
|
+
* @component
|
|
117
|
+
* @description Renders a customizable button with support for loading states, severity levels, icons, and text.
|
|
118
|
+
*/
|
|
119
|
+
export const Button: FC<ButtonProps>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
export type CheckboxValue =
|
|
4
|
+
| (string | number | Record<string, unknown>)[]
|
|
5
|
+
| boolean
|
|
6
|
+
| null;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Checkbox component.
|
|
10
|
+
*
|
|
11
|
+
* @description This defines the props for the Checkbox component including its field name, label, and event handlers.
|
|
12
|
+
*/
|
|
13
|
+
export interface CheckboxProps extends CheckboxEvent, FieldValidation {
|
|
14
|
+
/** The name of the field used for form submission */
|
|
15
|
+
fieldName?: string;
|
|
16
|
+
|
|
17
|
+
/** The label text to display above the input */
|
|
18
|
+
label?: string;
|
|
19
|
+
|
|
20
|
+
/** Whether the input is disabled */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
|
|
23
|
+
/** The value for this checkbox, switch mode to value to use this props */
|
|
24
|
+
optionValue?: string | number | Record<string, unknown>;
|
|
25
|
+
|
|
26
|
+
mode?: 'value' | 'binary' | 'tristate';
|
|
27
|
+
|
|
28
|
+
value?: CheckboxValue;
|
|
29
|
+
|
|
30
|
+
/** Additional information to display beside the input, typically as a tooltip */
|
|
31
|
+
info?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* To hide mark asterisk to required field
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
hideRequiredMark?: boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Input role
|
|
42
|
+
*
|
|
43
|
+
* @default checkbox
|
|
44
|
+
*/
|
|
45
|
+
role?: 'toggleswitch' | 'checkbox';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Validation rules for an input field.
|
|
50
|
+
*
|
|
51
|
+
* @description Defines various validation rules for the input text field, including required fields, min/max length, and custom validation.
|
|
52
|
+
*/
|
|
53
|
+
export interface FieldValidation {
|
|
54
|
+
/** Whether the input is required */
|
|
55
|
+
required?: boolean;
|
|
56
|
+
|
|
57
|
+
/** Custom validation function to validate the input value */
|
|
58
|
+
customValidation?: (
|
|
59
|
+
e: (string | number | Record<string, unknown>)[] | boolean | null,
|
|
60
|
+
) => boolean;
|
|
61
|
+
|
|
62
|
+
customMessage?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Event handlers for the Checkbox component.
|
|
67
|
+
*
|
|
68
|
+
* @description Defines event handler functions related to changes and input in the Checkbox component.
|
|
69
|
+
*/
|
|
70
|
+
export interface CheckboxEvent {
|
|
71
|
+
/** Called when the input value changes */
|
|
72
|
+
onChange?: (value: CheckboxValue) => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Checkbox component for form input with built-in validation and custom event handling.
|
|
77
|
+
*
|
|
78
|
+
* @component
|
|
79
|
+
* @description Renders an input field with support for labels, validation, dynamic event handling, and optional styling.
|
|
80
|
+
*/
|
|
81
|
+
export const Checkbox: FC<CheckboxProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface DialogProps {
|
|
4
|
+
/**
|
|
5
|
+
* Dialog children
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
|
|
11
|
+
useCloseIcon?: boolean;
|
|
12
|
+
closeOnEscape?: boolean;
|
|
13
|
+
closeOnBlur?: boolean;
|
|
14
|
+
|
|
15
|
+
defaultVisibility?: boolean;
|
|
16
|
+
|
|
17
|
+
header: string;
|
|
18
|
+
|
|
19
|
+
modal?: boolean;
|
|
20
|
+
|
|
21
|
+
slots?: Record<keyof DialogSlots, JSX.Element>;
|
|
22
|
+
|
|
23
|
+
size?:
|
|
24
|
+
| 'xs'
|
|
25
|
+
| 'sm'
|
|
26
|
+
| 'md'
|
|
27
|
+
| 'lg'
|
|
28
|
+
| 'xl'
|
|
29
|
+
| '2xl'
|
|
30
|
+
| '3xl'
|
|
31
|
+
| '4xl'
|
|
32
|
+
| '5xl'
|
|
33
|
+
| '6xl'
|
|
34
|
+
| '7xl'
|
|
35
|
+
| 'full';
|
|
36
|
+
|
|
37
|
+
containerClass?: string;
|
|
38
|
+
headerClass?: string;
|
|
39
|
+
contentClass?: string;
|
|
40
|
+
|
|
41
|
+
onVisibleChange?: (e: boolean) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface DialogSlots {
|
|
45
|
+
header?: JSX.Element;
|
|
46
|
+
content?: JSX.Element;
|
|
47
|
+
footer?: JSX.Element;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export declare const Dialog: (props: DialogProps) => JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DialogProps } from '../dialog/Dialog.d';
|
|
3
|
+
import { FormProps } from '../form/Form.d';
|
|
4
|
+
import {
|
|
5
|
+
UseFormGetValues,
|
|
6
|
+
UseFormReset,
|
|
7
|
+
UseFormResetField,
|
|
8
|
+
} from 'react-hook-form';
|
|
9
|
+
|
|
10
|
+
export interface DialogFormProps<T extends Record<string, any>>
|
|
11
|
+
extends DialogProps,
|
|
12
|
+
FormProps<T> {
|
|
13
|
+
closeOnSubmit?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DialogFormSlots {
|
|
17
|
+
header?: ReactNode;
|
|
18
|
+
content?: ReactNode;
|
|
19
|
+
footer?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare const DialogForm: <T extends Record<string, any> = any>(
|
|
23
|
+
props: DialogFormProps<T>,
|
|
24
|
+
) => JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// FieldWrapper.d.ts
|
|
2
|
+
|
|
3
|
+
import { ReactNode, FC } from 'react';
|
|
4
|
+
import { FieldErrors } from 'react-hook-form';
|
|
5
|
+
|
|
6
|
+
export interface FieldWrapperProps extends FieldWrapperEvent {
|
|
7
|
+
errors: FieldErrors<any>;
|
|
8
|
+
|
|
9
|
+
/** The name of the field used for form submission */
|
|
10
|
+
fieldName?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* FieldWrapper children
|
|
14
|
+
*/
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
|
|
17
|
+
className?: string;
|
|
18
|
+
|
|
19
|
+
context?: Partial<
|
|
20
|
+
Record<'invalid' | 'disabled' | 'containerless' | 'borderless', boolean>
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
/** The label text to display above the input */
|
|
24
|
+
label?: string;
|
|
25
|
+
|
|
26
|
+
/** Additional information to display beside the input, typically as a tooltip */
|
|
27
|
+
info?: string;
|
|
28
|
+
|
|
29
|
+
/** Whether the input is required */
|
|
30
|
+
required?: boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* To hide mark asterisk to required field
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
hideRequiredMark?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Event handlers for the FieldWrapper component.
|
|
42
|
+
*
|
|
43
|
+
* @description Defines event handler functions related to DOM interaction in the FieldWrapper component.
|
|
44
|
+
*/
|
|
45
|
+
export interface FieldWrapperEvent {
|
|
46
|
+
/** Called when the input value changes */
|
|
47
|
+
onClick?: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* FieldWrapper component.
|
|
52
|
+
*/
|
|
53
|
+
export const FieldWrapper: FC<FieldWrapperProps>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
FieldErrors,
|
|
4
|
+
SubmitErrorHandler,
|
|
5
|
+
SubmitHandler,
|
|
6
|
+
UseFormGetValues,
|
|
7
|
+
UseFormReset,
|
|
8
|
+
UseFormResetField,
|
|
9
|
+
} from 'react-hook-form';
|
|
10
|
+
|
|
11
|
+
export interface FormProps<T extends Record<string, any>> {
|
|
12
|
+
ref?: Ref<FormHandle<T>>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Form children
|
|
16
|
+
*/
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Determine whether form should be reset to default on submit or not
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
resetOnSubmit?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* To gives default value to form
|
|
28
|
+
*
|
|
29
|
+
* @default {}
|
|
30
|
+
*/
|
|
31
|
+
defaultValues?: Record<string, any>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Submit emit
|
|
35
|
+
*/
|
|
36
|
+
onSubmit?: SubmitHandler<T>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Error emit
|
|
40
|
+
*/
|
|
41
|
+
onError?: SubmitErrorHandler<T>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface FormHandle<T extends Record<string, any>> {
|
|
45
|
+
resetField: UseFormResetField<T>;
|
|
46
|
+
reset: UseFormReset<T>;
|
|
47
|
+
getValues: UseFormGetValues<T>;
|
|
48
|
+
errors: FieldErrors<T>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export declare const Form: <T extends Record<string, any> = any>(
|
|
52
|
+
props: FormProps<T>,
|
|
53
|
+
) => JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// types/components.d.ts (or you can name it types/icon.d.ts if it's specific)
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
export type Icons =
|
|
6
|
+
| 'plus'
|
|
7
|
+
| 'minus'
|
|
8
|
+
| 'minus-4'
|
|
9
|
+
| 'info'
|
|
10
|
+
| 'eye-on'
|
|
11
|
+
| 'eye-off'
|
|
12
|
+
| 'check'
|
|
13
|
+
| 'check-4'
|
|
14
|
+
| 'x'
|
|
15
|
+
| 'circle'
|
|
16
|
+
| 'circle-fill';
|
|
17
|
+
|
|
18
|
+
export interface IconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
19
|
+
/**
|
|
20
|
+
* Icon class like 'plus', 'minus', etc.
|
|
21
|
+
* Should be defined with a `--svg` mask in CSS.
|
|
22
|
+
*/
|
|
23
|
+
name: Icons;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Additional Tailwind/utility classes
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Tooltip text
|
|
32
|
+
*/
|
|
33
|
+
tooltip?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Tooltip position
|
|
37
|
+
*/
|
|
38
|
+
tooltipPos?: 'mouse' | 'right' | 'top' | 'bottom' | 'left';
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { Button } from './button/Button';
|
|
2
|
+
export { Checkbox } from './checkbox/Checkbox';
|
|
3
|
+
export { Dialog } from './dialog/Dialog';
|
|
4
|
+
export { DialogForm } from './dialogform/DialogForm';
|
|
5
|
+
export { Form } from './form/Form';
|
|
6
|
+
export { Icon } from './icon/Icon';
|
|
7
|
+
export { InputText } from './inputtext/InputText';
|
|
8
|
+
export { RadioButton } from './radiobutton/RadioButton';
|
|
9
|
+
export { Slot } from './slot/Slot';
|
|
10
|
+
export { ToggleSwitch } from './toggleswitch/ToggleSwitch';
|
|
11
|
+
export { Button } from './button/Button';
|
|
12
|
+
export { Checkbox } from './checkbox/Checkbox';
|
|
13
|
+
export { Dialog } from './dialog/Dialog';
|
|
14
|
+
export { DialogForm } from './dialogform/DialogForm';
|
|
15
|
+
export { Form } from './form/Form';
|
|
16
|
+
export { Icon } from './icon/Icon';
|
|
17
|
+
export { InputText } from './inputtext/InputText';
|
|
18
|
+
export { RadioButton } from './radiobutton/RadioButton';
|
|
19
|
+
export { Slot } from './slot/Slot';
|
|
20
|
+
export { ToggleSwitch } from './toggleswitch/ToggleSwitch';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { RegisterOptions } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for the InputText component.
|
|
6
|
+
*
|
|
7
|
+
* @description This defines the props for the InputText component including its field name, label, and event handlers.
|
|
8
|
+
*/
|
|
9
|
+
export interface InputTextProps extends InputTextEvent, FieldValidation {
|
|
10
|
+
/** The name of the field used for form submission */
|
|
11
|
+
fieldName?: string;
|
|
12
|
+
|
|
13
|
+
/** The label text to display above the input */
|
|
14
|
+
label?: string;
|
|
15
|
+
|
|
16
|
+
/** Whether the input is disabled */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Placeholder text for the input field */
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
|
|
22
|
+
/** The current value of the input */
|
|
23
|
+
value?: string;
|
|
24
|
+
|
|
25
|
+
/** Additional information to display beside the input, typically as a tooltip */
|
|
26
|
+
info?: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Menentukan jenis input yang ditampilkan oleh komponen input.
|
|
30
|
+
* Nilai ini diteruskan ke atribut `type` dari elemen HTML `<input>`.
|
|
31
|
+
* Gunakan tipe ini untuk mengontrol keyboard, validasi, dan tampilan field.
|
|
32
|
+
*
|
|
33
|
+
* @default 'text'
|
|
34
|
+
*/
|
|
35
|
+
type?: 'text' | 'password' | 'email' | 'number';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* To hide mark asterisk to required field
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
hideRequiredMark?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Validation rules for an input field.
|
|
47
|
+
*
|
|
48
|
+
* @description Defines various validation rules for the input text field, including required fields, min/max length, and custom validation.
|
|
49
|
+
*/
|
|
50
|
+
export interface FieldValidation {
|
|
51
|
+
/** Whether the input is required */
|
|
52
|
+
required?: boolean;
|
|
53
|
+
|
|
54
|
+
/** Minimum value of the input value */
|
|
55
|
+
min?: number;
|
|
56
|
+
|
|
57
|
+
/** Maximum value of the input value */
|
|
58
|
+
max?: number;
|
|
59
|
+
|
|
60
|
+
/** Minimum length of the input value */
|
|
61
|
+
minLength?: number;
|
|
62
|
+
|
|
63
|
+
/** Maximum length of the input value */
|
|
64
|
+
maxLength?: number;
|
|
65
|
+
|
|
66
|
+
/** A regular expression pattern to validate the input value */
|
|
67
|
+
pattern?: RegExp;
|
|
68
|
+
|
|
69
|
+
passwordRequirements?: (
|
|
70
|
+
| 'uppercase'
|
|
71
|
+
| 'lowercase'
|
|
72
|
+
| 'special-character'
|
|
73
|
+
| 'alpha-numeric'
|
|
74
|
+
)[];
|
|
75
|
+
|
|
76
|
+
/** Custom validation function to validate the input value */
|
|
77
|
+
customValidation?: (e?: string) => boolean;
|
|
78
|
+
|
|
79
|
+
/** Custom error messages for specific validation rules */
|
|
80
|
+
customMessage?: Record<keyof RegisterOptions, string>;
|
|
81
|
+
|
|
82
|
+
/** Whether to prevent the user from typing if the input is invalid */
|
|
83
|
+
preventInputOnError?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Event handlers for the InputText component.
|
|
88
|
+
*
|
|
89
|
+
* @description Defines event handler functions related to changes and input in the InputText component.
|
|
90
|
+
*/
|
|
91
|
+
export interface InputTextEvent {
|
|
92
|
+
/** Called when the input field loses focus */
|
|
93
|
+
onBlur?: (value: string) => void;
|
|
94
|
+
|
|
95
|
+
/** Called when the input value changes */
|
|
96
|
+
onChange?: (value: string) => void;
|
|
97
|
+
|
|
98
|
+
/** Called when the input value is being typed (on input) */
|
|
99
|
+
onInput?: (value: string) => void;
|
|
100
|
+
|
|
101
|
+
/** Called when the keyboard is being pressed (on keydown) */
|
|
102
|
+
onKeydown?: (value: string) => void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* InputText component for form input with built-in validation and custom event handling.
|
|
107
|
+
*
|
|
108
|
+
* @component
|
|
109
|
+
* @description Renders an input field with support for labels, validation, dynamic event handling, and optional styling.
|
|
110
|
+
*/
|
|
111
|
+
export const InputText: FC<InputTextProps>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for the RadioButton component.
|
|
5
|
+
*
|
|
6
|
+
* @description This defines the props for the RadioButton component including its field name, label, and event handlers.
|
|
7
|
+
*/
|
|
8
|
+
export interface RadioButtonProps extends RadioButtonEvent, FieldValidation {
|
|
9
|
+
/** The name of the field used for form submission */
|
|
10
|
+
fieldName?: string;
|
|
11
|
+
|
|
12
|
+
/** The label text to display above the input */
|
|
13
|
+
label?: string;
|
|
14
|
+
|
|
15
|
+
/** Whether the input is disabled */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
|
|
18
|
+
value?: string | boolean;
|
|
19
|
+
|
|
20
|
+
/** The value for this checkbox, switch mode to value to use this props */
|
|
21
|
+
optionValue?: string | boolean;
|
|
22
|
+
|
|
23
|
+
/** Additional information to display beside the input, typically as a tooltip */
|
|
24
|
+
info?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* To hide mark asterisk to required field
|
|
28
|
+
*
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
hideRequiredMark?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validation rules for an input field.
|
|
36
|
+
*
|
|
37
|
+
* @description Defines various validation rules for the input text field, including required fields, min/max length, and custom validation.
|
|
38
|
+
*/
|
|
39
|
+
export interface FieldValidation {
|
|
40
|
+
/** Whether the input is required */
|
|
41
|
+
required?: boolean;
|
|
42
|
+
|
|
43
|
+
/** Custom validation function to validate the input value */
|
|
44
|
+
customValidation?: (e: string | boolean) => boolean;
|
|
45
|
+
|
|
46
|
+
customMessage?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Event handlers for the RadioButton component.
|
|
51
|
+
*
|
|
52
|
+
* @description Defines event handler functions related to changes and input in the RadioButton component.
|
|
53
|
+
*/
|
|
54
|
+
export interface RadioButtonEvent {
|
|
55
|
+
/** Called when the input value changes */
|
|
56
|
+
onChange?: (value: string | boolean) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* RadioButton component for form input with built-in validation and custom event handling.
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
* @description Renders an input field with support for labels, validation, dynamic event handling, and optional styling.
|
|
64
|
+
*/
|
|
65
|
+
export const RadioButton: FC<RadioButtonProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for the Slot component.
|
|
5
|
+
*
|
|
6
|
+
* @description This defines the props for the Slot component including its field name, label, and event handlers.
|
|
7
|
+
*/
|
|
8
|
+
export interface SlotProps {
|
|
9
|
+
/** The name of the slot */
|
|
10
|
+
name?: string;
|
|
11
|
+
|
|
12
|
+
/** The slot content */
|
|
13
|
+
slots?: Record<string, ReactNode>;
|
|
14
|
+
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Slot component for custom section.
|
|
20
|
+
*
|
|
21
|
+
* @component
|
|
22
|
+
*/
|
|
23
|
+
export const Slot: FC<SlotProps>;
|