form-input-fields 1.0.2 → 1.0.4

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A collection of Material-UI form field components with Formik integration.
4
4
 
5
+ More controls are coming soon.
6
+
5
7
  ## Table of Contents
6
8
 
7
9
  - [FormDateField](#formdatefield)
@@ -31,6 +33,14 @@ A collection of Material-UI form field components with Formik integration.
31
33
  - [Show Mask Pattern](#show-mask-pattern)
32
34
  - [Show Placeholder](#show-placeholder)
33
35
  - [Custom Mask with Validation](#custom-mask-with-validation)
36
+ - [FormCheckboxField](#formcheckboxfield)
37
+ - [Features](#features-2)
38
+ - [Basic Usage](#basic-usage-1)
39
+ - [Props](#props-2)
40
+ - [Examples](#examples-2)
41
+ - [Basic Checkbox](#basic-checkbox)
42
+ - [Checkbox with Formik](#checkbox-with-formik)
43
+ - [Custom Styled Checkbox](#custom-styled-checkbox)
34
44
 
35
45
  ---
36
46
 
@@ -267,6 +277,169 @@ The FormDateField component accepts all props from `FormDateFieldProps`, `FieldP
267
277
  />
268
278
  ```
269
279
 
280
+ ## FormCheckboxField
281
+
282
+ A customizable checkbox component with Material-UI and Formik integration, providing consistent styling and behavior across your application.
283
+
284
+ ### Features
285
+
286
+ - **Material-UI Integration**: Consistent styling with Material-UI's design system
287
+ - **Formik Integration**: Seamless form state management with error handling
288
+ - **Custom Styling**: Easy customization through Material-UI's styling system
289
+ - **TypeScript Support**: Full type safety with exported interfaces
290
+ - **Accessibility**: Built with accessibility in mind, following WAI-ARIA guidelines
291
+ - **Responsive Design**: Works well on all screen sizes
292
+
293
+ ### Basic Usage
294
+
295
+ ```tsx
296
+ import { Formik, Field } from 'formik';
297
+ import { FormCheckboxField } from 'form-input-mask-field';
298
+
299
+ // Basic usage
300
+ <FormCheckboxField
301
+ id="terms"
302
+ label="I agree to the terms and conditions"
303
+ checked={false}
304
+ onChange={(e) => console.log('Checked:', e.target.checked)}
305
+ />
306
+
307
+ // With Formik
308
+ <Formik
309
+ initialValues={{ termsAccepted: false }}
310
+ onSubmit={(values) => console.log(values)}
311
+ >
312
+ {({ values }) => (
313
+ <Field
314
+ name="termsAccepted"
315
+ component={({ field, form }) => (
316
+ <FormCheckboxField
317
+ {...field}
318
+ label="I agree to the terms and conditions"
319
+ checked={field.value}
320
+ onChange={(e) => {
321
+ form.setFieldValue(field.name, e.target.checked);
322
+ }}
323
+ />
324
+ )}
325
+ />
326
+ )}
327
+ </Formik>
328
+ ```
329
+
330
+ ### Props
331
+
332
+ The FormCheckboxField component accepts all props from `FormCheckboxFieldProps` and Material-UI's `CheckboxProps`.
333
+
334
+ #### FormCheckboxFieldProps Interface
335
+
336
+ | Prop | Type | Default | Description |
337
+ | -------------- | --------- | ------- | ------------------------------------------------ |
338
+ | `id` | `string` | - | Unique identifier for the checkbox |
339
+ | `label` | `string` | - | Label text displayed next to the checkbox |
340
+ | `checked` | `boolean` | `false` | Whether the checkbox is checked |
341
+ | `onChange` | `function`| - | Callback when checkbox state changes |
342
+ | `disabled` | `boolean` | `false` | Disable the checkbox |
343
+ | `required` | `boolean` | `false` | Mark the field as required |
344
+ | `color` | `string` | 'primary'| Color of the checkbox when checked |
345
+ | `size` | `string` | 'medium'| Size of the checkbox ('small' or 'medium') |
346
+ | `labelPlacement`| `string` | 'end' | Position of the label ('end', 'start', 'top', 'bottom') |
347
+
348
+ ### Examples
349
+
350
+ #### Basic Checkbox
351
+
352
+ ```tsx
353
+ <FormCheckboxField
354
+ id="notifications"
355
+ label="Enable email notifications"
356
+ checked={notificationsEnabled}
357
+ onChange={(e) => setNotificationsEnabled(e.target.checked)}
358
+ color="secondary"
359
+ />
360
+ ```
361
+
362
+ #### Checkbox with Formik
363
+
364
+ ```tsx
365
+ <Formik
366
+ initialValues={{
367
+ termsAccepted: false,
368
+ newsletter: true,
369
+ notifications: false
370
+ }}
371
+ onSubmit={(values) => console.log('Form values:', values)}
372
+ >
373
+ {({ values }) => (
374
+ <Form>
375
+ <Field
376
+ name="termsAccepted"
377
+ component={({ field, form }) => (
378
+ <FormCheckboxField
379
+ {...field}
380
+ label="I agree to the terms and conditions"
381
+ checked={field.value}
382
+ onChange={(e) => form.setFieldValue(field.name, e.target.checked)}
383
+ required
384
+ />
385
+ )}
386
+ />
387
+
388
+ <Field
389
+ name="newsletter"
390
+ component={({ field, form }) => (
391
+ <FormCheckboxField
392
+ {...field}
393
+ label="Subscribe to newsletter"
394
+ checked={field.value}
395
+ onChange={(e) => form.setFieldValue(field.name, e.target.checked)}
396
+ color="secondary"
397
+ />
398
+ )}
399
+ />
400
+
401
+ <Button type="submit" variant="contained" color="primary">
402
+ Submit
403
+ </Button>
404
+ </Form>
405
+ )}
406
+ </Formik>
407
+ ```
408
+
409
+ #### Custom Styled Checkbox
410
+
411
+ ```tsx
412
+ import { makeStyles } from '@mui/styles';
413
+
414
+ const useStyles = makeStyles((theme) => ({
415
+ root: {
416
+ margin: theme.spacing(1),
417
+ },
418
+ labelRoot: {
419
+ color: theme.palette.primary.main,
420
+ fontWeight: 500,
421
+ },
422
+ }));
423
+
424
+ function CustomCheckbox() {
425
+ const classes = useStyles();
426
+
427
+ return (
428
+ <FormCheckboxField
429
+ id="custom-checkbox"
430
+ label="Custom Styled Checkbox"
431
+ checked={false}
432
+ onChange={() => {}}
433
+ classes={{
434
+ root: classes.root,
435
+ label: classes.labelRoot,
436
+ }}
437
+ color="primary"
438
+ />
439
+ );
440
+ }
441
+ ```
442
+
270
443
  ## FormMaskField
271
444
 
272
445
  A flexible form field component with advanced text masking capabilities.
@@ -0,0 +1,22 @@
1
+ export interface FormCheckboxFieldProps {
2
+ /**
3
+ * Unique identifier for the checkbox
4
+ */
5
+ id: string;
6
+ /**
7
+ * Label text displayed next to the checkbox
8
+ */
9
+ label: string;
10
+ /**
11
+ * Whether the checkbox is checked
12
+ */
13
+ checked: boolean;
14
+ /**
15
+ * Callback fired when the state is changed
16
+ * @param event The event source of the callback
17
+ * @param checked The new checked state
18
+ */
19
+ onChange: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
20
+ }
21
+ export declare const FormCheckboxField: ({ id, label, checked, onChange }: FormCheckboxFieldProps) => import("react/jsx-runtime").JSX.Element;
22
+ //# sourceMappingURL=FormCheckboxField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormCheckboxField.d.ts","sourceRoot":"","sources":["../../../src/controls/FormCheckboxField/FormCheckboxField.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAClF;AAED,eAAO,MAAM,iBAAiB,GAAI,kCAAkC,sBAAsB,4CAqBzF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const useStyles: (props?: any) => import('@mui/styles').ClassNameMap<"margin" | "labelRoot">;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/controls/FormCheckboxField/styles.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,6EAWrB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormDateField.d.ts","sourceRoot":"","sources":["../../../src/controls/FormDateField/FormDateField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAS,MAAM,QAAQ,CAAC;AAC3C,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAMrC,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,KAAK,CAAC;IAEhB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,KAAK,CAAC;IAEhB,yBAAyB;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,2BAA2B;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,sCAAsC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,KAAK,GAAG,IAAI,EACnB,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,cAAc,EAAE,MAAM,CAAC;KACxB,KACE,IAAI,CAAC;IAEV,2DAA2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,2BAA2B,GAAG,UAAU,GAClD,cAAc,GACd,kBAAkB,CAAC;AAErB,eAAO,MAAM,aAAa,GAAI,OAAO,2BAA2B,4CAsG/D,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/controls/FormDateField/date.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB;;CAEnC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;CAGzC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormMaskField.d.ts","sourceRoot":"","sources":["../../../src/controls/FormMaskField/FormMaskField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAS,MAAM,QAAQ,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAS9D,MAAM,WAAW,kBAAkB;IACjC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E,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,YAAY,UAAU,GAAG,IAAI,KAAG,MAkBnE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { CSSProperties } from '@mui/styles';
2
+ declare const drawerBackGround = "#19212b";
3
+ declare const dividerColor = "#404854";
4
+ declare const headerBackground = "#262f3d";
5
+ declare const defaultLabelFont: CSSProperties;
6
+ export { drawerBackGround, defaultLabelFont, dividerColor, headerBackground };
7
+ //# sourceMappingURL=portal-material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-material.d.ts","sourceRoot":"","sources":["../../src/controls/portal-material.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,QAAA,MAAM,gBAAgB,YAAY,CAAC;AACnC,QAAA,MAAM,YAAY,YAAY,CAAC;AAC/B,QAAA,MAAM,gBAAgB,YAAY,CAAC;AAMnC,QAAA,MAAM,gBAAgB,EAAE,aAKvB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { FormMaskField, type FormMaskFieldProps, } from './controls/FormMaskField';
2
- export { createMask, applyMask, removeMask, generatePlaceholder, type MaskConfig, } from './controls/FormMaskFiledUtils';
3
- export { FormDateField, type FormDateFieldProps, } from './controls/FormDateField';
1
+ export { FormMaskField, type FormMaskFieldProps, } from './controls/FormMaskField/FormMaskField';
2
+ export { createMask, applyMask, removeMask, generatePlaceholder, type MaskConfig, } from './controls/FormMaskField/FormMaskFiledUtils';
3
+ export { FormDateField, type FormDateFieldProps, } from './controls/FormDateField/FormDateField';
4
+ export { FormCheckboxField, type FormCheckboxFieldProps, } from './controls/FormCheckboxField/FormCheckboxField';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -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,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,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"}