form-input-fields 1.0.2 → 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/README.md CHANGED
@@ -31,6 +31,14 @@ A collection of Material-UI form field components with Formik integration.
31
31
  - [Show Mask Pattern](#show-mask-pattern)
32
32
  - [Show Placeholder](#show-placeholder)
33
33
  - [Custom Mask with Validation](#custom-mask-with-validation)
34
+ - [FormCheckboxField](#formcheckboxfield)
35
+ - [Features](#features-2)
36
+ - [Basic Usage](#basic-usage-1)
37
+ - [Props](#props-2)
38
+ - [Examples](#examples-2)
39
+ - [Basic Checkbox](#basic-checkbox)
40
+ - [Checkbox with Formik](#checkbox-with-formik)
41
+ - [Custom Styled Checkbox](#custom-styled-checkbox)
34
42
 
35
43
  ---
36
44
 
@@ -267,6 +275,169 @@ The FormDateField component accepts all props from `FormDateFieldProps`, `FieldP
267
275
  />
268
276
  ```
269
277
 
278
+ ## FormCheckboxField
279
+
280
+ A customizable checkbox component with Material-UI and Formik integration, providing consistent styling and behavior across your application.
281
+
282
+ ### Features
283
+
284
+ - **Material-UI Integration**: Consistent styling with Material-UI's design system
285
+ - **Formik Integration**: Seamless form state management with error handling
286
+ - **Custom Styling**: Easy customization through Material-UI's styling system
287
+ - **TypeScript Support**: Full type safety with exported interfaces
288
+ - **Accessibility**: Built with accessibility in mind, following WAI-ARIA guidelines
289
+ - **Responsive Design**: Works well on all screen sizes
290
+
291
+ ### Basic Usage
292
+
293
+ ```tsx
294
+ import { Formik, Field } from 'formik';
295
+ import { FormCheckboxField } from 'form-input-mask-field';
296
+
297
+ // Basic usage
298
+ <FormCheckboxField
299
+ id="terms"
300
+ label="I agree to the terms and conditions"
301
+ checked={false}
302
+ onChange={(e) => console.log('Checked:', e.target.checked)}
303
+ />
304
+
305
+ // With Formik
306
+ <Formik
307
+ initialValues={{ termsAccepted: false }}
308
+ onSubmit={(values) => console.log(values)}
309
+ >
310
+ {({ values }) => (
311
+ <Field
312
+ name="termsAccepted"
313
+ component={({ field, form }) => (
314
+ <FormCheckboxField
315
+ {...field}
316
+ label="I agree to the terms and conditions"
317
+ checked={field.value}
318
+ onChange={(e) => {
319
+ form.setFieldValue(field.name, e.target.checked);
320
+ }}
321
+ />
322
+ )}
323
+ />
324
+ )}
325
+ </Formik>
326
+ ```
327
+
328
+ ### Props
329
+
330
+ The FormCheckboxField component accepts all props from `FormCheckboxFieldProps` and Material-UI's `CheckboxProps`.
331
+
332
+ #### FormCheckboxFieldProps Interface
333
+
334
+ | Prop | Type | Default | Description |
335
+ | -------------- | --------- | ------- | ------------------------------------------------ |
336
+ | `id` | `string` | - | Unique identifier for the checkbox |
337
+ | `label` | `string` | - | Label text displayed next to the checkbox |
338
+ | `checked` | `boolean` | `false` | Whether the checkbox is checked |
339
+ | `onChange` | `function`| - | Callback when checkbox state changes |
340
+ | `disabled` | `boolean` | `false` | Disable the checkbox |
341
+ | `required` | `boolean` | `false` | Mark the field as required |
342
+ | `color` | `string` | 'primary'| Color of the checkbox when checked |
343
+ | `size` | `string` | 'medium'| Size of the checkbox ('small' or 'medium') |
344
+ | `labelPlacement`| `string` | 'end' | Position of the label ('end', 'start', 'top', 'bottom') |
345
+
346
+ ### Examples
347
+
348
+ #### Basic Checkbox
349
+
350
+ ```tsx
351
+ <FormCheckboxField
352
+ id="notifications"
353
+ label="Enable email notifications"
354
+ checked={notificationsEnabled}
355
+ onChange={(e) => setNotificationsEnabled(e.target.checked)}
356
+ color="secondary"
357
+ />
358
+ ```
359
+
360
+ #### Checkbox with Formik
361
+
362
+ ```tsx
363
+ <Formik
364
+ initialValues={{
365
+ termsAccepted: false,
366
+ newsletter: true,
367
+ notifications: false
368
+ }}
369
+ onSubmit={(values) => console.log('Form values:', values)}
370
+ >
371
+ {({ values }) => (
372
+ <Form>
373
+ <Field
374
+ name="termsAccepted"
375
+ component={({ field, form }) => (
376
+ <FormCheckboxField
377
+ {...field}
378
+ label="I agree to the terms and conditions"
379
+ checked={field.value}
380
+ onChange={(e) => form.setFieldValue(field.name, e.target.checked)}
381
+ required
382
+ />
383
+ )}
384
+ />
385
+
386
+ <Field
387
+ name="newsletter"
388
+ component={({ field, form }) => (
389
+ <FormCheckboxField
390
+ {...field}
391
+ label="Subscribe to newsletter"
392
+ checked={field.value}
393
+ onChange={(e) => form.setFieldValue(field.name, e.target.checked)}
394
+ color="secondary"
395
+ />
396
+ )}
397
+ />
398
+
399
+ <Button type="submit" variant="contained" color="primary">
400
+ Submit
401
+ </Button>
402
+ </Form>
403
+ )}
404
+ </Formik>
405
+ ```
406
+
407
+ #### Custom Styled Checkbox
408
+
409
+ ```tsx
410
+ import { makeStyles } from '@mui/styles';
411
+
412
+ const useStyles = makeStyles((theme) => ({
413
+ root: {
414
+ margin: theme.spacing(1),
415
+ },
416
+ labelRoot: {
417
+ color: theme.palette.primary.main,
418
+ fontWeight: 500,
419
+ },
420
+ }));
421
+
422
+ function CustomCheckbox() {
423
+ const classes = useStyles();
424
+
425
+ return (
426
+ <FormCheckboxField
427
+ id="custom-checkbox"
428
+ label="Custom Styled Checkbox"
429
+ checked={false}
430
+ onChange={() => {}}
431
+ classes={{
432
+ root: classes.root,
433
+ label: classes.labelRoot,
434
+ }}
435
+ color="primary"
436
+ />
437
+ );
438
+ }
439
+ ```
440
+
270
441
  ## FormMaskField
271
442
 
272
443
  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;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE;QACL,MAAM,EAAE;YACN,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,EAAE,MAAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,GAAG,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KACpC,IAAI,CAAC;IAEV,4DAA4D;IAC5D,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,iDAAiD;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,2BAA2B,GAAG,UAAU,GAClD,cAAc,GACd,kBAAkB,CAAC;AAErB,eAAO,MAAM,aAAa,GAAI,OAAO,2BAA2B,4CAmI/D,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormMaskFiledUtils.d.ts","sourceRoot":"","sources":["../../../src/controls/FormMaskField/FormMaskFiledUtils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,wBAAqB,KAAG,UAanE,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,YAAY,UAAU,GAAG,IAAI,EAC7B,qBAAmB,KAClB,MA6CF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,YAAY,UAAU,GAAG,IAAI,KAAG,MAgBzE,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"}