form-input-fields 1.0.5 → 1.0.7
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 +337 -4
- package/dist/controls/FormDropDownField/FormDropDownField.d.ts +56 -0
- package/dist/controls/FormDropDownField/FormDropDownField.d.ts.map +1 -0
- package/dist/controls/FormDropDownField/styles.d.ts +2 -0
- package/dist/controls/FormDropDownField/styles.d.ts.map +1 -0
- package/dist/controls/FormSwitch/FormSwitch.d.ts +60 -0
- package/dist/controls/FormSwitch/FormSwitch.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +4683 -4562
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +79 -79
- package/dist/index.js.map +1 -1
- package/dist/test/FormDropDownField.spec.d.ts +2 -0
- package/dist/test/FormDropDownField.spec.d.ts.map +1 -0
- package/dist/test/FormSwitch.spec.d.ts +2 -0
- package/dist/test/FormSwitch.spec.d.ts.map +1 -0
- package/dist/test/FormTextField.spec.d.ts +2 -0
- package/dist/test/FormTextField.spec.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ yarn add @your-org/form-fields @mui/material @emotion/react @emotion/styled form
|
|
|
32
32
|
### Using pnpm
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
pnpm add
|
|
35
|
+
pnpm add form-input-fields @mui/material @emotion/react @emotion/styled formik @mui/x-date-pickers dayjs
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Peer Dependencies
|
|
@@ -41,7 +41,7 @@ Make sure your project includes these peer dependencies:
|
|
|
41
41
|
|
|
42
42
|
```json
|
|
43
43
|
{
|
|
44
|
-
"
|
|
44
|
+
"devDependencies": {
|
|
45
45
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
46
46
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
47
47
|
"@mui/material": "^5.0.0",
|
|
@@ -73,7 +73,7 @@ For Internet Explorer 11 support, you'll need to include polyfills. See [Browser
|
|
|
73
73
|
After installation, you can import and use the components in your application:
|
|
74
74
|
|
|
75
75
|
```tsx
|
|
76
|
-
import { FormTextField, FormDateField, FormMaskField } from '
|
|
76
|
+
import { FormTextField, FormDateField, FormMaskField, FormSwitch } from 'form-input-fields';
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Troubleshooting
|
|
@@ -100,7 +100,7 @@ If you encounter any issues during installation, try the following:
|
|
|
100
100
|
pnpm install
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
If you're still experiencing issues, please
|
|
103
|
+
If you're still experiencing issues, please reach me at vladimir.vorobiev@gmail.com with details about your environment and the error message you're seeing.
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
## Table of Contents
|
|
@@ -113,6 +113,14 @@ If you're still experiencing issues, please [open an issue](https://github.com/y
|
|
|
113
113
|
- [Basic Text Input](#basic-text-input)
|
|
114
114
|
- [Text Field with Formik](#text-field-with-formik)
|
|
115
115
|
- [Custom Validation](#custom-validation)
|
|
116
|
+
- [FormDropDownField](#formdropdownfield)
|
|
117
|
+
- [Features](#features-4)
|
|
118
|
+
- [Basic Usage](#basic-usage-4)
|
|
119
|
+
- [Props](#props-4)
|
|
120
|
+
- [Examples](#examples-4)
|
|
121
|
+
- [Basic Dropdown](#basic-dropdown)
|
|
122
|
+
- [Dropdown with Default Selection](#dropdown-with-default-selection)
|
|
123
|
+
- [Required Dropdown with Validation](#required-dropdown-with-validation)
|
|
116
124
|
- [FormDateField](#formdatefield)
|
|
117
125
|
- [Features](#features)
|
|
118
126
|
- [Available Date Formats](#available-date-formats)
|
|
@@ -148,6 +156,14 @@ If you're still experiencing issues, please [open an issue](https://github.com/y
|
|
|
148
156
|
- [Basic Checkbox](#basic-checkbox)
|
|
149
157
|
- [Checkbox with Formik](#checkbox-with-formik)
|
|
150
158
|
- [Custom Styled Checkbox](#custom-styled-checkbox)
|
|
159
|
+
- [FormSwitch](#formswitch)
|
|
160
|
+
- [Features](#features-5)
|
|
161
|
+
- [Basic Usage](#basic-usage-5)
|
|
162
|
+
- [Props](#props-5)
|
|
163
|
+
- [Examples](#examples-5)
|
|
164
|
+
- [Basic Switch](#basic-switch)
|
|
165
|
+
- [Switch with Formik](#switch-with-formik)
|
|
166
|
+
- [Custom Styled Switch](#custom-styled-switch)
|
|
151
167
|
- [FormDateTextField](#formdatetextfield)
|
|
152
168
|
- [Features](#features-3)
|
|
153
169
|
- [Available Date Formats](#available-date-formats-1)
|
|
@@ -280,6 +296,131 @@ The FormTextField component accepts all props from `FormTextFieldProps`, `FieldP
|
|
|
280
296
|
|
|
281
297
|
---
|
|
282
298
|
|
|
299
|
+
## FormDropDownField
|
|
300
|
+
|
|
301
|
+
A customizable dropdown/select component that integrates Material-UI's Select with Formik form handling.
|
|
302
|
+
|
|
303
|
+
### Features
|
|
304
|
+
|
|
305
|
+
- **Seamless Formik Integration**: Automatically handles form state, validation, and error messages
|
|
306
|
+
- **Material-UI Styling**: Consistent look and feel with Material Design
|
|
307
|
+
- **TypeScript Support**: Fully typed component with proper type definitions
|
|
308
|
+
- **Flexible Data Binding**: Works with array of objects with `id` and `description` properties
|
|
309
|
+
- **Optional Default Selection**: Add a default "Select" option with customizable text
|
|
310
|
+
- **Form Validation**: Built-in error state management with Formik
|
|
311
|
+
- **Responsive Design**: Works well across different screen sizes
|
|
312
|
+
|
|
313
|
+
### Basic Usage
|
|
314
|
+
|
|
315
|
+
```tsx
|
|
316
|
+
import { Formik, Field } from 'formik';
|
|
317
|
+
import { FormDropDownField } from 'form-input-fields';
|
|
318
|
+
|
|
319
|
+
const items = [
|
|
320
|
+
{ id: '1', description: 'Option 1' },
|
|
321
|
+
{ id: '2', description: 'Option 2' },
|
|
322
|
+
{ id: '3', description: 'Option 3' },
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
<Formik
|
|
326
|
+
initialValues={{ category: '' }}
|
|
327
|
+
onSubmit={(values) => console.log(values)}
|
|
328
|
+
>
|
|
329
|
+
<Field
|
|
330
|
+
component={FormDropDownField}
|
|
331
|
+
name="category"
|
|
332
|
+
label="Category"
|
|
333
|
+
items={items}
|
|
334
|
+
addInputSelect={true}
|
|
335
|
+
/>
|
|
336
|
+
</Formik>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Props
|
|
340
|
+
|
|
341
|
+
The FormDropDownField component accepts all props from `FormDropDownFieldProps`, `FieldProps` (Formik), and Material-UI's `TextFieldProps` (with some exceptions).
|
|
342
|
+
|
|
343
|
+
#### FormDropDownFieldProps Interface
|
|
344
|
+
|
|
345
|
+
| Prop | Type | Default | Description |
|
|
346
|
+
|------|------|---------|-------------|
|
|
347
|
+
| `items` | `Array<{ id: string | number; description: string }>` | `[]` | Array of items to display in the dropdown |
|
|
348
|
+
| `addInputSelect` | `boolean` | `false` | Whether to show a default "Select" option as the first item |
|
|
349
|
+
| `selectText` | `string` | `'Select'` | Text to display for the default "Select" option |
|
|
350
|
+
| `required` | `boolean` | `false` | Whether the field is required |
|
|
351
|
+
| `disabled` | `boolean` | `false` | Whether the field is disabled |
|
|
352
|
+
| `className` | `string` | - | Custom class name for the root element |
|
|
353
|
+
| `helperText` | `string` | - | Helper text to display below the field |
|
|
354
|
+
| `error` | `boolean` | - | Error state of the field (overrides Formik error state) |
|
|
355
|
+
| `onChange` | `(value: any) => void` | - | Custom change handler |
|
|
356
|
+
| `onBlur` | `(event: React.FocusEvent<HTMLInputElement>) => void` | - | Custom blur handler |
|
|
357
|
+
|
|
358
|
+
### Examples
|
|
359
|
+
|
|
360
|
+
#### Basic Dropdown
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
const items = [
|
|
364
|
+
{ id: 'us', description: 'United States' },
|
|
365
|
+
{ id: 'ca', description: 'Canada' },
|
|
366
|
+
{ id: 'uk', description: 'United Kingdom' },
|
|
367
|
+
];
|
|
368
|
+
|
|
369
|
+
<Field
|
|
370
|
+
component={FormDropDownField}
|
|
371
|
+
name="country"
|
|
372
|
+
label="Country"
|
|
373
|
+
items={items}
|
|
374
|
+
fullWidth
|
|
375
|
+
/>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
#### Dropdown with Default Selection
|
|
379
|
+
|
|
380
|
+
```tsx
|
|
381
|
+
<Field
|
|
382
|
+
component={FormDropDownField}
|
|
383
|
+
name="category"
|
|
384
|
+
label="Category"
|
|
385
|
+
items={categories}
|
|
386
|
+
addInputSelect={true}
|
|
387
|
+
selectText="Select a category"
|
|
388
|
+
helperText="Please select a category from the list"
|
|
389
|
+
/>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### Required Dropdown with Validation
|
|
393
|
+
|
|
394
|
+
```tsx
|
|
395
|
+
<Formik
|
|
396
|
+
initialValues={{ department: '' }}
|
|
397
|
+
validationSchema={Yup.object({
|
|
398
|
+
department: Yup.string().required('Department is required'),
|
|
399
|
+
})}
|
|
400
|
+
onSubmit={(values) => console.log(values)}
|
|
401
|
+
>
|
|
402
|
+
{({ errors, touched }) => (
|
|
403
|
+
<Form>
|
|
404
|
+
<Field
|
|
405
|
+
component={FormDropDownField}
|
|
406
|
+
name="department"
|
|
407
|
+
label="Department"
|
|
408
|
+
items={departments}
|
|
409
|
+
addInputSelect={true}
|
|
410
|
+
required
|
|
411
|
+
error={touched.department && Boolean(errors.department)}
|
|
412
|
+
helperText={touched.department && errors.department}
|
|
413
|
+
/>
|
|
414
|
+
<Button type="submit" variant="contained" color="primary">
|
|
415
|
+
Submit
|
|
416
|
+
</Button>
|
|
417
|
+
</Form>
|
|
418
|
+
)}
|
|
419
|
+
</Formik>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
283
424
|
## FormDateField
|
|
284
425
|
|
|
285
426
|
A date input field component with Material-UI and Formik integration, powered by MUI X Date Pickers.
|
|
@@ -676,6 +817,198 @@ function CustomCheckbox() {
|
|
|
676
817
|
}
|
|
677
818
|
```
|
|
678
819
|
|
|
820
|
+
## FormSwitch
|
|
821
|
+
|
|
822
|
+
A customizable switch component with Material-UI and Formik integration, providing consistent styling and behavior for boolean inputs across your application.
|
|
823
|
+
|
|
824
|
+
### Features
|
|
825
|
+
|
|
826
|
+
- **Material-UI Integration**: Consistent styling with Material-UI's design system
|
|
827
|
+
- **Formik Integration**: Seamless form state management with error handling
|
|
828
|
+
- **Flexible Label Placement**: Support for different label positions
|
|
829
|
+
- **TypeScript Support**: Full type safety with exported interfaces
|
|
830
|
+
- **Accessibility**: Built with accessibility in mind, following WAI-ARIA guidelines
|
|
831
|
+
- **Error Handling**: Built-in error state management with Formik
|
|
832
|
+
- **Responsive Design**: Works well on all screen sizes
|
|
833
|
+
|
|
834
|
+
### Basic Usage
|
|
835
|
+
|
|
836
|
+
```tsx
|
|
837
|
+
import { Formik, Field } from 'formik';
|
|
838
|
+
import { FormSwitch } from 'form-input-fields';
|
|
839
|
+
|
|
840
|
+
// Basic usage
|
|
841
|
+
<FormSwitch
|
|
842
|
+
label="Enable Notifications"
|
|
843
|
+
checked={notificationsEnabled}
|
|
844
|
+
onChange={(e, checked) => setNotificationsEnabled(checked)}
|
|
845
|
+
/>
|
|
846
|
+
|
|
847
|
+
// With Formik
|
|
848
|
+
<Formik
|
|
849
|
+
initialValues={{ notifications: false }}
|
|
850
|
+
onSubmit={(values) => console.log(values)}
|
|
851
|
+
>
|
|
852
|
+
<Field
|
|
853
|
+
component={FormSwitch}
|
|
854
|
+
name="notifications"
|
|
855
|
+
label="Enable Notifications"
|
|
856
|
+
helperText="Receive email notifications"
|
|
857
|
+
/>
|
|
858
|
+
</Formik>
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### Props
|
|
862
|
+
|
|
863
|
+
The FormSwitch component accepts all props from `FormSwitchProps`, `FieldProps` (Formik), and Material-UI's `SwitchProps`.
|
|
864
|
+
|
|
865
|
+
#### FormSwitchProps Interface
|
|
866
|
+
|
|
867
|
+
| Prop | Type | Default | Description |
|
|
868
|
+
| ---------------- | ---------- | ------- | ------------------------------------------------ |
|
|
869
|
+
| `label` | `string` | - | Label text displayed next to the switch |
|
|
870
|
+
| `labelPlacement` | `string` | 'end' | Position of label ('top', 'start', 'bottom', 'end') |
|
|
871
|
+
| `color` | `string` | 'primary'| Switch color ('primary', 'secondary', 'error', 'info', 'success', 'warning', 'default') |
|
|
872
|
+
| `size` | `string` | 'medium'| Switch size ('small' or 'medium') |
|
|
873
|
+
| `disabled` | `boolean` | `false` | Disable the switch |
|
|
874
|
+
| `required` | `boolean` | `false` | Mark the field as required |
|
|
875
|
+
| `onChange` | `function` | - | Custom change handler with context data |
|
|
876
|
+
| `onBlur` | `function` | - | Custom blur handler |
|
|
877
|
+
| `helperText` | `string` | - | Helper text to display below the switch |
|
|
878
|
+
| `error` | `boolean` | `false` | Error state of the switch |
|
|
879
|
+
| `className` | `string` | - | Custom class name for the root element |
|
|
880
|
+
|
|
881
|
+
#### Common Props (from FieldProps & SwitchProps)
|
|
882
|
+
|
|
883
|
+
| Prop | Type | Required | Description |
|
|
884
|
+
|--------------|------------------|----------|-----------------------------------------------|
|
|
885
|
+
| `name` | `string` | Yes | Field name in Formik values |
|
|
886
|
+
| `label` | `string` | No | Field label |
|
|
887
|
+
| `helperText` | `string` | No | Custom helper text |
|
|
888
|
+
| `error` | `boolean` | No | Error state (auto-managed by Formik) |
|
|
889
|
+
| `disabled` | `boolean` | No | Disabled state |
|
|
890
|
+
| `required` | `boolean` | No | Required field indicator |
|
|
891
|
+
| Other | `SwitchProps` | No | All Material-UI Switch props are supported |
|
|
892
|
+
|
|
893
|
+
### Examples
|
|
894
|
+
|
|
895
|
+
#### Basic Switch
|
|
896
|
+
|
|
897
|
+
```tsx
|
|
898
|
+
<FormSwitch
|
|
899
|
+
label="Enable Dark Mode"
|
|
900
|
+
checked={darkModeEnabled}
|
|
901
|
+
onChange={(e, checked) => setDarkModeEnabled(checked)}
|
|
902
|
+
color="secondary"
|
|
903
|
+
size="small"
|
|
904
|
+
/>
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### Switch with Formik
|
|
908
|
+
|
|
909
|
+
```tsx
|
|
910
|
+
<Formik
|
|
911
|
+
initialValues={{
|
|
912
|
+
notifications: false,
|
|
913
|
+
darkMode: true,
|
|
914
|
+
autoSave: false
|
|
915
|
+
}}
|
|
916
|
+
onSubmit={(values) => console.log('Form values:', values)}
|
|
917
|
+
>
|
|
918
|
+
<Form>
|
|
919
|
+
<Field
|
|
920
|
+
component={FormSwitch}
|
|
921
|
+
name="notifications"
|
|
922
|
+
label="Enable Notifications"
|
|
923
|
+
helperText="Receive email notifications"
|
|
924
|
+
color="primary"
|
|
925
|
+
/>
|
|
926
|
+
|
|
927
|
+
<Field
|
|
928
|
+
component={FormSwitch}
|
|
929
|
+
name="darkMode"
|
|
930
|
+
label="Dark Mode"
|
|
931
|
+
helperText="Use dark theme"
|
|
932
|
+
color="secondary"
|
|
933
|
+
labelPlacement="start"
|
|
934
|
+
/>
|
|
935
|
+
|
|
936
|
+
<Field
|
|
937
|
+
component={FormSwitch}
|
|
938
|
+
name="autoSave"
|
|
939
|
+
label="Auto Save"
|
|
940
|
+
helperText="Automatically save changes"
|
|
941
|
+
color="success"
|
|
942
|
+
size="small"
|
|
943
|
+
/>
|
|
944
|
+
|
|
945
|
+
<Button type="submit" variant="contained" color="primary">
|
|
946
|
+
Save Settings
|
|
947
|
+
</Button>
|
|
948
|
+
</Form>
|
|
949
|
+
</Formik>
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
#### Custom Styled Switch
|
|
953
|
+
|
|
954
|
+
```tsx
|
|
955
|
+
<FormSwitch
|
|
956
|
+
label="Custom Styled Switch"
|
|
957
|
+
checked={false}
|
|
958
|
+
onChange={(e, checked) => console.log('Switch toggled:', checked)}
|
|
959
|
+
className="custom-switch-class"
|
|
960
|
+
color="warning"
|
|
961
|
+
labelPlacement="top"
|
|
962
|
+
helperText="This is a custom styled switch"
|
|
963
|
+
/>
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
#### Switch with Custom Change Handler
|
|
967
|
+
|
|
968
|
+
```tsx
|
|
969
|
+
<Field
|
|
970
|
+
component={FormSwitch}
|
|
971
|
+
name="advancedMode"
|
|
972
|
+
label="Advanced Mode"
|
|
973
|
+
onChange={(e, checked, context) => {
|
|
974
|
+
console.log('Field name:', context.fieldName);
|
|
975
|
+
console.log('Formik value:', context.formikValue);
|
|
976
|
+
// Custom logic here
|
|
977
|
+
}}
|
|
978
|
+
helperText="Enable advanced features"
|
|
979
|
+
/>
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
#### Switch with Validation
|
|
983
|
+
|
|
984
|
+
```tsx
|
|
985
|
+
<Formik
|
|
986
|
+
initialValues={{ termsAccepted: false }}
|
|
987
|
+
validate={(values) => {
|
|
988
|
+
const errors = {};
|
|
989
|
+
if (!values.termsAccepted) {
|
|
990
|
+
errors.termsAccepted = 'You must accept the terms to continue';
|
|
991
|
+
}
|
|
992
|
+
return errors;
|
|
993
|
+
}}
|
|
994
|
+
onSubmit={(values) => console.log(values)}
|
|
995
|
+
>
|
|
996
|
+
<Form>
|
|
997
|
+
<Field
|
|
998
|
+
component={FormSwitch}
|
|
999
|
+
name="termsAccepted"
|
|
1000
|
+
label="I accept the terms and conditions"
|
|
1001
|
+
helperText="Please read and accept the terms"
|
|
1002
|
+
required
|
|
1003
|
+
/>
|
|
1004
|
+
|
|
1005
|
+
<Button type="submit" variant="contained" color="primary">
|
|
1006
|
+
Continue
|
|
1007
|
+
</Button>
|
|
1008
|
+
</Form>
|
|
1009
|
+
</Formik>
|
|
1010
|
+
```
|
|
1011
|
+
|
|
679
1012
|
## FormDateTextField
|
|
680
1013
|
|
|
681
1014
|
A versatile date input field component that provides a text-based date picker with Formik integration and Material-UI styling.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { FieldProps } from 'formik';
|
|
2
|
+
import { TextFieldProps } from '@mui/material';
|
|
3
|
+
export interface FormDropDownFieldProps {
|
|
4
|
+
/**
|
|
5
|
+
* Array of items to display in the dropdown
|
|
6
|
+
* Each item should have an `id` and `description` property
|
|
7
|
+
*/
|
|
8
|
+
items: Array<{
|
|
9
|
+
id: string | number;
|
|
10
|
+
description: string;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to show a default "Select" option as the first item
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
addInputSelect?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Text to display for the default "Select" option
|
|
19
|
+
* @default 'Select'
|
|
20
|
+
*/
|
|
21
|
+
selectText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the field is required
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the field is disabled
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Custom class name for the root element
|
|
34
|
+
*/
|
|
35
|
+
className?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Helper text to display below the field
|
|
38
|
+
*/
|
|
39
|
+
helperText?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Error state of the field
|
|
42
|
+
*/
|
|
43
|
+
error?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Custom onChange handler
|
|
46
|
+
*/
|
|
47
|
+
onChange?: (value: any) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Custom onBlur handler
|
|
50
|
+
*/
|
|
51
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
52
|
+
}
|
|
53
|
+
type FormDropDownFieldComponentProps = FormDropDownFieldProps & FieldProps & Omit<TextFieldProps, 'value' | 'onChange' | 'onBlur' | 'name' | 'defaultValue' | 'onError' | 'onFocus' | 'InputProps' | 'select' | 'SelectProps'>;
|
|
54
|
+
export declare const FormDropDownField: ({ field, form, items, addInputSelect, selectText, required, disabled, className, helperText, error, onChange, onBlur, ...props }: FormDropDownFieldComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=FormDropDownField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormDropDownField.d.ts","sourceRoot":"","sources":["../../../src/controls/FormDropDownField/FormDropDownField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAS,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAoC,MAAM,eAAe,CAAC;AAGjF,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE3D;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAEhC;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CAC9D;AAED,KAAK,+BAA+B,GAAG,sBAAsB,GAC3D,UAAU,GACV,IAAI,CACF,cAAc,EACZ,OAAO,GACP,UAAU,GACV,QAAQ,GACR,MAAM,GACN,cAAc,GACd,SAAS,GACT,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,aAAa,CAChB,CAAC;AAEJ,eAAO,MAAM,iBAAiB,GAAI,kIAc/B,+BAA+B,4CAiEjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/controls/FormDropDownField/styles.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,+EAYrB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FieldProps } from 'formik';
|
|
3
|
+
import { SwitchProps } from '@mui/material/Switch';
|
|
4
|
+
export interface FormSwitchProps {
|
|
5
|
+
/**
|
|
6
|
+
* Label text displayed next to the switch
|
|
7
|
+
*/
|
|
8
|
+
label?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Position of the label relative to the switch
|
|
11
|
+
* @default 'end'
|
|
12
|
+
*/
|
|
13
|
+
labelPlacement?: 'top' | 'start' | 'bottom' | 'end';
|
|
14
|
+
/**
|
|
15
|
+
* Color of the switch when checked
|
|
16
|
+
* @default 'primary'
|
|
17
|
+
*/
|
|
18
|
+
color?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'default';
|
|
19
|
+
/**
|
|
20
|
+
* Size of the switch
|
|
21
|
+
* @default 'medium'
|
|
22
|
+
*/
|
|
23
|
+
size?: 'small' | 'medium';
|
|
24
|
+
/**
|
|
25
|
+
* Whether the switch is disabled
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the switch is required
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Custom onChange handler with additional switch-related data
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean, context: {
|
|
38
|
+
fieldName: string;
|
|
39
|
+
formikValue: boolean;
|
|
40
|
+
}) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Custom onBlur handler
|
|
43
|
+
*/
|
|
44
|
+
onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Helper text to display below the switch
|
|
47
|
+
*/
|
|
48
|
+
helperText?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Error state of the switch
|
|
51
|
+
*/
|
|
52
|
+
error?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Custom class name for the root element
|
|
55
|
+
*/
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
export type FormSwitchComponentProps = FieldProps & SwitchProps & FormSwitchProps;
|
|
59
|
+
export declare const FormSwitch: (props: FormSwitchComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
//# sourceMappingURL=FormSwitch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormSwitch.d.ts","sourceRoot":"","sources":["../../../src/controls/FormSwitch/FormSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAS,MAAM,QAAQ,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAEpD;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAEvF;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAC1C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;KACtB,KACE,IAAI,CAAC;IAEV;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAE9D;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,GAAG,WAAW,GAAG,eAAe,CAAC;AAElF,eAAO,MAAM,UAAU,GAAI,OAAO,wBAAwB,4CAyFzD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ export { FormDateField, type FormDateFieldProps, } from './controls/FormDateFiel
|
|
|
4
4
|
export { FormCheckboxField, type FormCheckboxFieldProps, } from './controls/FormCheckboxField/FormCheckboxField';
|
|
5
5
|
export { FormDateTextField, type FormDateTextFieldProps, } from './controls/FormDateTextField/FormDateTextField';
|
|
6
6
|
export { FormTextField, type FormTextFieldProps, } from './controls/FormTextField/FormTextField';
|
|
7
|
+
export { FormDropDownField, type FormDropDownFieldProps, } from './controls/FormDropDownField/FormDropDownField';
|
|
8
|
+
export { FormSwitch, type FormSwitchProps, } from './controls/FormSwitch/FormSwitch';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gDAAgD,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gDAAgD,CAAC;AAExD,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,UAAU,EACV,KAAK,eAAe,GACrB,MAAM,kCAAkC,CAAC"}
|