formik-mui-fields 0.1.0

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.js ADDED
@@ -0,0 +1,660 @@
1
+ "use client";
2
+
3
+ // src/FormikTextField/FormikTextField.tsx
4
+ import { TextField } from "@mui/material";
5
+ import { useField } from "formik";
6
+ import { jsx } from "react/jsx-runtime";
7
+ var FormikTextField = ({ name, ...props }) => {
8
+ const [field, meta] = useField(name);
9
+ return /* @__PURE__ */ jsx(
10
+ TextField,
11
+ {
12
+ ...field,
13
+ ...props,
14
+ error: meta.touched && Boolean(meta.error),
15
+ helperText: meta.touched && meta.error
16
+ }
17
+ );
18
+ };
19
+ var FormikTextField_default = FormikTextField;
20
+
21
+ // src/FormikSelect/FormikSelect.tsx
22
+ import {
23
+ FormControl,
24
+ FormHelperText,
25
+ FormLabel,
26
+ MenuItem,
27
+ Select
28
+ } from "@mui/material";
29
+ import { useField as useField2 } from "formik";
30
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
31
+ var FormikSelect = ({ name, label, options, ...props }) => {
32
+ const [field, meta] = useField2(name);
33
+ const hasError = meta.touched && Boolean(meta.error);
34
+ return /* @__PURE__ */ jsxs(FormControl, { fullWidth: true, error: hasError, children: [
35
+ label && /* @__PURE__ */ jsx2(FormLabel, { children: label }),
36
+ /* @__PURE__ */ jsx2(Select, { ...field, ...props, children: options.map((option) => /* @__PURE__ */ jsx2(MenuItem, { value: option.value, children: option.label }, option.value)) }),
37
+ hasError && /* @__PURE__ */ jsx2(FormHelperText, { children: meta.error })
38
+ ] });
39
+ };
40
+ var FormikSelect_default = FormikSelect;
41
+
42
+ // src/FormikRadioGroup/FormikRadioGroup.tsx
43
+ import {
44
+ FormControl as FormControl2,
45
+ FormControlLabel,
46
+ FormHelperText as FormHelperText2,
47
+ FormLabel as FormLabel2,
48
+ Radio,
49
+ RadioGroup
50
+ } from "@mui/material";
51
+ import { useField as useField3 } from "formik";
52
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
53
+ var FormikRadioGroup = ({ name, label, options, row }) => {
54
+ const [field, meta] = useField3(name);
55
+ const hasError = meta.touched && Boolean(meta.error);
56
+ return /* @__PURE__ */ jsxs2(FormControl2, { error: hasError, children: [
57
+ label && /* @__PURE__ */ jsx3(FormLabel2, { children: label }),
58
+ /* @__PURE__ */ jsx3(RadioGroup, { ...field, row, children: options.map((option) => /* @__PURE__ */ jsx3(
59
+ FormControlLabel,
60
+ {
61
+ value: option.value,
62
+ control: /* @__PURE__ */ jsx3(Radio, {}),
63
+ label: option.label
64
+ },
65
+ option.value
66
+ )) }),
67
+ hasError && /* @__PURE__ */ jsx3(FormHelperText2, { children: meta.error })
68
+ ] });
69
+ };
70
+ var FormikRadioGroup_default = FormikRadioGroup;
71
+
72
+ // src/FormikSlider/FormikSlider.tsx
73
+ import {
74
+ FormControl as FormControl3,
75
+ FormHelperText as FormHelperText3,
76
+ FormLabel as FormLabel3,
77
+ Slider
78
+ } from "@mui/material";
79
+ import { useField as useField4 } from "formik";
80
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
81
+ var FormikSlider = ({ name, label, ...props }) => {
82
+ const [field, meta, helpers] = useField4(name);
83
+ const hasError = meta.touched && Boolean(meta.error);
84
+ return /* @__PURE__ */ jsxs3(FormControl3, { fullWidth: true, error: hasError, children: [
85
+ label && /* @__PURE__ */ jsx4(FormLabel3, { children: label }),
86
+ /* @__PURE__ */ jsx4(
87
+ Slider,
88
+ {
89
+ ...props,
90
+ value: field.value,
91
+ onChange: (_, value) => helpers.setValue(value),
92
+ onBlur: field.onBlur
93
+ }
94
+ ),
95
+ hasError && /* @__PURE__ */ jsx4(FormHelperText3, { children: meta.error })
96
+ ] });
97
+ };
98
+ var FormikSlider_default = FormikSlider;
99
+
100
+ // src/FormikColorPicker/FormikColorPicker.tsx
101
+ import {
102
+ Box,
103
+ ClickAwayListener,
104
+ FormControl as FormControl4,
105
+ FormLabel as FormLabel4,
106
+ Popper
107
+ } from "@mui/material";
108
+ import { useField as useField5 } from "formik";
109
+ import { useRef, useState } from "react";
110
+ import { ChromePicker } from "react-color";
111
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
112
+ var FormikColorPicker = ({ name, label }) => {
113
+ const [field, , helpers] = useField5(name);
114
+ const [open, setOpen] = useState(false);
115
+ const anchorRef = useRef(null);
116
+ const handleChange = (color) => {
117
+ helpers.setValue(color.hex);
118
+ };
119
+ return /* @__PURE__ */ jsxs4(FormControl4, { children: [
120
+ label && /* @__PURE__ */ jsx5(FormLabel4, { sx: { mb: 1 }, children: label }),
121
+ /* @__PURE__ */ jsx5(
122
+ Box,
123
+ {
124
+ ref: anchorRef,
125
+ onClick: () => setOpen((prev) => !prev),
126
+ sx: {
127
+ width: 32,
128
+ height: 32,
129
+ borderRadius: "50%",
130
+ backgroundColor: field.value,
131
+ border: "2px solid",
132
+ borderColor: "grey.300",
133
+ cursor: "pointer",
134
+ transition: "border-color 0.2s",
135
+ "&:hover": { borderColor: "grey.500" }
136
+ }
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx5(
140
+ Popper,
141
+ {
142
+ open,
143
+ anchorEl: anchorRef.current,
144
+ placement: "bottom-start",
145
+ sx: { zIndex: 1500 },
146
+ children: /* @__PURE__ */ jsx5(ClickAwayListener, { onClickAway: () => setOpen(false), children: /* @__PURE__ */ jsx5(Box, { children: /* @__PURE__ */ jsx5(
147
+ ChromePicker,
148
+ {
149
+ color: field.value,
150
+ onChange: handleChange,
151
+ disableAlpha: true
152
+ }
153
+ ) }) })
154
+ }
155
+ )
156
+ ] });
157
+ };
158
+ var FormikColorPicker_default = FormikColorPicker;
159
+
160
+ // src/FormikFontPicker/FormikFontPicker.tsx
161
+ import { useEffect, useState as useState2 } from "react";
162
+ import { Autocomplete, FormControl as FormControl5, FormLabel as FormLabel5, TextField as TextField2 } from "@mui/material";
163
+ import { useField as useField6 } from "formik";
164
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
165
+ var FormikFontPicker = ({ name, label }) => {
166
+ const [fonts, setFonts] = useState2([]);
167
+ const [loading, setLoading] = useState2(true);
168
+ const [field, meta, helpers] = useField6(name);
169
+ useEffect(() => {
170
+ fetch("/api/google/fonts").then((res) => res.json()).then((data) => setFonts(data)).catch(() => setFonts([])).finally(() => setLoading(false));
171
+ }, []);
172
+ useEffect(() => {
173
+ if (!field.value) return;
174
+ const linkId = "google-font-preview";
175
+ let link = document.getElementById(linkId);
176
+ if (!link) {
177
+ link = document.createElement("link");
178
+ link.id = linkId;
179
+ link.rel = "stylesheet";
180
+ document.head.appendChild(link);
181
+ }
182
+ link.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(field.value)}&display=swap`;
183
+ }, [field.value]);
184
+ const selectedOption = fonts.find((f) => f.value === field.value) ?? null;
185
+ const hasError = meta.touched && Boolean(meta.error);
186
+ return /* @__PURE__ */ jsxs5(FormControl5, { fullWidth: true, error: hasError, children: [
187
+ label && /* @__PURE__ */ jsx6(FormLabel5, { children: label }),
188
+ /* @__PURE__ */ jsx6(
189
+ Autocomplete,
190
+ {
191
+ options: fonts,
192
+ loading,
193
+ getOptionLabel: (option) => option.label,
194
+ value: selectedOption,
195
+ onChange: (_, newValue) => {
196
+ helpers.setValue(newValue?.value ?? "");
197
+ },
198
+ onBlur: () => helpers.setTouched(true),
199
+ isOptionEqualToValue: (option, value) => option.value === value.value,
200
+ renderInput: (params) => /* @__PURE__ */ jsx6(
201
+ TextField2,
202
+ {
203
+ ...params,
204
+ size: "small",
205
+ error: hasError,
206
+ helperText: hasError ? meta.error : void 0
207
+ }
208
+ )
209
+ }
210
+ )
211
+ ] });
212
+ };
213
+ var FormikFontPicker_default = FormikFontPicker;
214
+
215
+ // src/FormikImageUpload/FormikImageUpload.tsx
216
+ import { Box as Box3, FormControl as FormControl6, FormHelperText as FormHelperText4, Typography as Typography2 } from "@mui/material";
217
+ import { useField as useField7 } from "formik";
218
+ import { useCallback as useCallback2, useState as useState4 } from "react";
219
+
220
+ // src/CropDialog/CropDialog.tsx
221
+ import {
222
+ Box as Box2,
223
+ Button,
224
+ Dialog,
225
+ DialogActions,
226
+ DialogContent,
227
+ DialogTitle,
228
+ ToggleButton,
229
+ ToggleButtonGroup,
230
+ Typography
231
+ } from "@mui/material";
232
+ import { useCallback, useRef as useRef2, useState as useState3 } from "react";
233
+ import ReactCrop from "react-image-crop";
234
+ import "react-image-crop/dist/ReactCrop.css";
235
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
236
+ var ASPECT_RATIOS = {
237
+ "1.91:1": 1.91,
238
+ "1:1": 1,
239
+ "3:1": 3
240
+ };
241
+ var getCroppedImageUrl = (image, crop) => {
242
+ const canvas = document.createElement("canvas");
243
+ const scaleX = image.naturalWidth / image.width;
244
+ const scaleY = image.naturalHeight / image.height;
245
+ canvas.width = crop.width * scaleX;
246
+ canvas.height = crop.height * scaleY;
247
+ const ctx = canvas.getContext("2d");
248
+ if (!ctx) return "";
249
+ ctx.drawImage(
250
+ image,
251
+ crop.x * scaleX,
252
+ crop.y * scaleY,
253
+ crop.width * scaleX,
254
+ crop.height * scaleY,
255
+ 0,
256
+ 0,
257
+ canvas.width,
258
+ canvas.height
259
+ );
260
+ return canvas.toDataURL("image/png");
261
+ };
262
+ var CropDialog = ({
263
+ open,
264
+ imageSrc,
265
+ cropOptions,
266
+ onConfirm,
267
+ onCancel
268
+ }) => {
269
+ const imgRef = useRef2(null);
270
+ const [selectedAspect, setSelectedAspect] = useState3(
271
+ cropOptions[0]
272
+ );
273
+ const [crop, setCrop] = useState3();
274
+ const handleImageLoad = useCallback(
275
+ (e) => {
276
+ imgRef.current = e.currentTarget;
277
+ const aspect = ASPECT_RATIOS[selectedAspect];
278
+ const { width, height } = e.currentTarget;
279
+ const cropWidth = Math.min(width, height * aspect);
280
+ const cropHeight = cropWidth / aspect;
281
+ setCrop({
282
+ unit: "px",
283
+ x: (width - cropWidth) / 2,
284
+ y: (height - cropHeight) / 2,
285
+ width: cropWidth,
286
+ height: cropHeight
287
+ });
288
+ },
289
+ [selectedAspect]
290
+ );
291
+ const handleAspectChange = useCallback(
292
+ (_, value) => {
293
+ if (!value || !imgRef.current) return;
294
+ setSelectedAspect(value);
295
+ const aspect = ASPECT_RATIOS[value];
296
+ const { width, height } = imgRef.current;
297
+ const cropWidth = Math.min(width, height * aspect);
298
+ const cropHeight = cropWidth / aspect;
299
+ setCrop({
300
+ unit: "px",
301
+ x: (width - cropWidth) / 2,
302
+ y: (height - cropHeight) / 2,
303
+ width: cropWidth,
304
+ height: cropHeight
305
+ });
306
+ },
307
+ []
308
+ );
309
+ const handleConfirm = useCallback(() => {
310
+ if (!imgRef.current || !crop) return;
311
+ const url = getCroppedImageUrl(imgRef.current, crop);
312
+ onConfirm(url);
313
+ }, [crop, onConfirm]);
314
+ return /* @__PURE__ */ jsxs6(Dialog, { open, onClose: onCancel, maxWidth: "md", fullWidth: true, children: [
315
+ /* @__PURE__ */ jsx7(DialogTitle, { children: "Crop Image" }),
316
+ /* @__PURE__ */ jsx7(DialogContent, { children: /* @__PURE__ */ jsxs6(
317
+ Box2,
318
+ {
319
+ sx: {
320
+ display: "flex",
321
+ flexDirection: "column",
322
+ alignItems: "center",
323
+ gap: 2,
324
+ mt: 1
325
+ },
326
+ children: [
327
+ /* @__PURE__ */ jsx7(
328
+ ReactCrop,
329
+ {
330
+ crop,
331
+ onChange: (c) => setCrop(c),
332
+ aspect: ASPECT_RATIOS[selectedAspect],
333
+ children: /* @__PURE__ */ jsx7(
334
+ "img",
335
+ {
336
+ src: imageSrc,
337
+ alt: "Crop preview",
338
+ onLoad: handleImageLoad,
339
+ style: { maxWidth: "100%", maxHeight: 400 }
340
+ }
341
+ )
342
+ }
343
+ ),
344
+ /* @__PURE__ */ jsxs6(Box2, { children: [
345
+ /* @__PURE__ */ jsx7(Typography, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: "Aspect ratio" }),
346
+ /* @__PURE__ */ jsx7(
347
+ ToggleButtonGroup,
348
+ {
349
+ value: selectedAspect,
350
+ exclusive: true,
351
+ onChange: handleAspectChange,
352
+ size: "small",
353
+ children: cropOptions.map((option) => /* @__PURE__ */ jsx7(ToggleButton, { value: option, children: option }, option))
354
+ }
355
+ )
356
+ ] })
357
+ ]
358
+ }
359
+ ) }),
360
+ /* @__PURE__ */ jsxs6(DialogActions, { children: [
361
+ /* @__PURE__ */ jsx7(Button, { onClick: onCancel, children: "Cancel" }),
362
+ /* @__PURE__ */ jsx7(Button, { variant: "contained", onClick: handleConfirm, children: "Confirm" })
363
+ ] })
364
+ ] });
365
+ };
366
+ var CropDialog_default = CropDialog;
367
+
368
+ // src/FormikImageUpload/FormikImageUpload.tsx
369
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
370
+ var ALL_CROP_OPTIONS = ["1.91:1", "1:1", "3:1"];
371
+ var FormikImageUpload = ({
372
+ name,
373
+ label,
374
+ height = 120,
375
+ cropEnabled = false,
376
+ cropOptions = ALL_CROP_OPTIONS
377
+ }) => {
378
+ const [field, meta, helpers] = useField7(name);
379
+ const hasError = meta.touched && Boolean(meta.error);
380
+ const [rawImageSrc, setRawImageSrc] = useState4(null);
381
+ const handleFileChange = useCallback2(
382
+ (e) => {
383
+ const file = e.target.files?.[0];
384
+ if (!file) return;
385
+ const url = URL.createObjectURL(file);
386
+ if (cropEnabled) {
387
+ setRawImageSrc(url);
388
+ } else {
389
+ helpers.setValue(url);
390
+ }
391
+ e.target.value = "";
392
+ },
393
+ [helpers, cropEnabled]
394
+ );
395
+ const handleCropConfirm = useCallback2(
396
+ (croppedUrl) => {
397
+ helpers.setValue(croppedUrl);
398
+ setRawImageSrc(null);
399
+ },
400
+ [helpers]
401
+ );
402
+ const handleCropCancel = useCallback2(() => {
403
+ setRawImageSrc(null);
404
+ }, []);
405
+ return /* @__PURE__ */ jsxs7(FormControl6, { fullWidth: true, error: hasError, children: [
406
+ label && /* @__PURE__ */ jsx8(Typography2, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: label }),
407
+ /* @__PURE__ */ jsxs7(
408
+ Box3,
409
+ {
410
+ component: "label",
411
+ sx: {
412
+ display: "flex",
413
+ alignItems: "center",
414
+ justifyContent: "center",
415
+ width: "100%",
416
+ height,
417
+ border: "2px dashed",
418
+ borderColor: hasError ? "error.main" : "divider",
419
+ borderRadius: 1,
420
+ cursor: "pointer",
421
+ overflow: "hidden",
422
+ backgroundImage: field.value ? `url(${field.value})` : "none",
423
+ backgroundSize: "contain",
424
+ backgroundRepeat: "no-repeat",
425
+ backgroundPosition: "center",
426
+ "&:hover": { borderColor: "primary.main" }
427
+ },
428
+ children: [
429
+ !field.value && /* @__PURE__ */ jsx8(Typography2, { variant: "body2", color: "text.secondary", children: "Upload image" }),
430
+ /* @__PURE__ */ jsx8(
431
+ "input",
432
+ {
433
+ type: "file",
434
+ accept: "image/*",
435
+ hidden: true,
436
+ onChange: handleFileChange
437
+ }
438
+ )
439
+ ]
440
+ }
441
+ ),
442
+ hasError && /* @__PURE__ */ jsx8(FormHelperText4, { children: meta.error }),
443
+ cropEnabled && rawImageSrc && /* @__PURE__ */ jsx8(
444
+ CropDialog_default,
445
+ {
446
+ open: true,
447
+ imageSrc: rawImageSrc,
448
+ cropOptions,
449
+ onConfirm: handleCropConfirm,
450
+ onCancel: handleCropCancel
451
+ }
452
+ )
453
+ ] });
454
+ };
455
+ var FormikImageUpload_default = FormikImageUpload;
456
+
457
+ // src/FormikCheckbox/FormikCheckbox.tsx
458
+ import {
459
+ Checkbox,
460
+ FormControl as FormControl7,
461
+ FormControlLabel as FormControlLabel2,
462
+ FormHelperText as FormHelperText5
463
+ } from "@mui/material";
464
+ import { useField as useField8 } from "formik";
465
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
466
+ var FormikCheckbox = ({ name, label, ...props }) => {
467
+ const [field, meta] = useField8({ name, type: "checkbox" });
468
+ const hasError = meta.touched && Boolean(meta.error);
469
+ return /* @__PURE__ */ jsxs8(FormControl7, { error: hasError, children: [
470
+ /* @__PURE__ */ jsx9(
471
+ FormControlLabel2,
472
+ {
473
+ control: /* @__PURE__ */ jsx9(Checkbox, { ...field, ...props, checked: field.checked }),
474
+ label: label ?? ""
475
+ }
476
+ ),
477
+ hasError && /* @__PURE__ */ jsx9(FormHelperText5, { children: meta.error })
478
+ ] });
479
+ };
480
+ var FormikCheckbox_default = FormikCheckbox;
481
+
482
+ // src/FormikSwitch/FormikSwitch.tsx
483
+ import {
484
+ FormControl as FormControl8,
485
+ FormControlLabel as FormControlLabel3,
486
+ FormHelperText as FormHelperText6,
487
+ Switch
488
+ } from "@mui/material";
489
+ import { useField as useField9 } from "formik";
490
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
491
+ var FormikSwitch = ({ name, label, ...props }) => {
492
+ const [field, meta] = useField9({ name, type: "checkbox" });
493
+ const hasError = meta.touched && Boolean(meta.error);
494
+ return /* @__PURE__ */ jsxs9(FormControl8, { error: hasError, children: [
495
+ /* @__PURE__ */ jsx10(
496
+ FormControlLabel3,
497
+ {
498
+ control: /* @__PURE__ */ jsx10(Switch, { ...field, ...props, checked: field.checked }),
499
+ label: label ?? ""
500
+ }
501
+ ),
502
+ hasError && /* @__PURE__ */ jsx10(FormHelperText6, { children: meta.error })
503
+ ] });
504
+ };
505
+ var FormikSwitch_default = FormikSwitch;
506
+
507
+ // src/FormikAutocomplete/FormikAutocomplete.tsx
508
+ import {
509
+ Autocomplete as Autocomplete2,
510
+ FormControl as FormControl9,
511
+ FormLabel as FormLabel6,
512
+ TextField as TextField3
513
+ } from "@mui/material";
514
+ import { useField as useField10 } from "formik";
515
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
516
+ var FormikAutocomplete = ({
517
+ name,
518
+ label,
519
+ options,
520
+ getOptionLabel,
521
+ isOptionEqualToValue,
522
+ ...props
523
+ }) => {
524
+ const [field, meta, helpers] = useField10(name);
525
+ const hasError = meta.touched && Boolean(meta.error);
526
+ return /* @__PURE__ */ jsxs10(FormControl9, { fullWidth: true, error: hasError, children: [
527
+ label && /* @__PURE__ */ jsx11(FormLabel6, { children: label }),
528
+ /* @__PURE__ */ jsx11(
529
+ Autocomplete2,
530
+ {
531
+ ...props,
532
+ options,
533
+ getOptionLabel,
534
+ isOptionEqualToValue,
535
+ value: field.value ?? null,
536
+ onChange: (_, newValue) => helpers.setValue(newValue),
537
+ onBlur: () => helpers.setTouched(true),
538
+ renderInput: (params) => /* @__PURE__ */ jsx11(
539
+ TextField3,
540
+ {
541
+ ...params,
542
+ error: hasError,
543
+ helperText: hasError ? meta.error : void 0
544
+ }
545
+ )
546
+ }
547
+ )
548
+ ] });
549
+ };
550
+ var FormikAutocomplete_default = FormikAutocomplete;
551
+
552
+ // src/FormikRating/FormikRating.tsx
553
+ import {
554
+ FormControl as FormControl10,
555
+ FormHelperText as FormHelperText7,
556
+ FormLabel as FormLabel7,
557
+ Rating
558
+ } from "@mui/material";
559
+ import { useField as useField11 } from "formik";
560
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
561
+ var FormikRating = ({ name, label, ...props }) => {
562
+ const [field, meta, helpers] = useField11(name);
563
+ const hasError = meta.touched && Boolean(meta.error);
564
+ return /* @__PURE__ */ jsxs11(FormControl10, { error: hasError, children: [
565
+ label && /* @__PURE__ */ jsx12(FormLabel7, { children: label }),
566
+ /* @__PURE__ */ jsx12(
567
+ Rating,
568
+ {
569
+ ...props,
570
+ name,
571
+ value: field.value ?? null,
572
+ onChange: (_, newValue) => helpers.setValue(newValue),
573
+ onBlur: field.onBlur
574
+ }
575
+ ),
576
+ hasError && /* @__PURE__ */ jsx12(FormHelperText7, { children: meta.error })
577
+ ] });
578
+ };
579
+ var FormikRating_default = FormikRating;
580
+
581
+ // src/FormikToggleButtonGroup/FormikToggleButtonGroup.tsx
582
+ import {
583
+ FormControl as FormControl11,
584
+ FormHelperText as FormHelperText8,
585
+ FormLabel as FormLabel8,
586
+ ToggleButton as ToggleButton2,
587
+ ToggleButtonGroup as ToggleButtonGroup2
588
+ } from "@mui/material";
589
+ import { useField as useField12 } from "formik";
590
+ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
591
+ var FormikToggleButtonGroup = ({ name, label, options, ...props }) => {
592
+ const [field, meta, helpers] = useField12(name);
593
+ const hasError = meta.touched && Boolean(meta.error);
594
+ return /* @__PURE__ */ jsxs12(FormControl11, { error: hasError, children: [
595
+ label && /* @__PURE__ */ jsx13(FormLabel8, { children: label }),
596
+ /* @__PURE__ */ jsx13(
597
+ ToggleButtonGroup2,
598
+ {
599
+ ...props,
600
+ value: field.value,
601
+ onChange: (_, newValue) => {
602
+ if (newValue !== null) {
603
+ helpers.setValue(newValue);
604
+ }
605
+ },
606
+ onBlur: field.onBlur,
607
+ children: options.map((option) => /* @__PURE__ */ jsx13(ToggleButton2, { value: option.value, children: option.label }, option.value))
608
+ }
609
+ ),
610
+ hasError && /* @__PURE__ */ jsx13(FormHelperText8, { children: meta.error })
611
+ ] });
612
+ };
613
+ var FormikToggleButtonGroup_default = FormikToggleButtonGroup;
614
+
615
+ // src/FormikDatePicker/FormikDatePicker.tsx
616
+ import { FormControl as FormControl12, FormHelperText as FormHelperText9, FormLabel as FormLabel9 } from "@mui/material";
617
+ import {
618
+ DatePicker
619
+ } from "@mui/x-date-pickers/DatePicker";
620
+ import { useField as useField13 } from "formik";
621
+ import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
622
+ var FormikDatePicker = ({ name, label, ...props }) => {
623
+ const [field, meta, helpers] = useField13(name);
624
+ const hasError = meta.touched && Boolean(meta.error);
625
+ return /* @__PURE__ */ jsxs13(FormControl12, { fullWidth: true, error: hasError, children: [
626
+ label && /* @__PURE__ */ jsx14(FormLabel9, { children: label }),
627
+ /* @__PURE__ */ jsx14(
628
+ DatePicker,
629
+ {
630
+ ...props,
631
+ value: field.value ?? null,
632
+ onChange: (value) => helpers.setValue(value),
633
+ slotProps: {
634
+ textField: {
635
+ onBlur: () => helpers.setTouched(true),
636
+ error: hasError
637
+ },
638
+ ...props.slotProps
639
+ }
640
+ }
641
+ ),
642
+ hasError && /* @__PURE__ */ jsx14(FormHelperText9, { children: meta.error })
643
+ ] });
644
+ };
645
+ var FormikDatePicker_default = FormikDatePicker;
646
+ export {
647
+ FormikAutocomplete_default as FormikAutocomplete,
648
+ FormikCheckbox_default as FormikCheckbox,
649
+ FormikColorPicker_default as FormikColorPicker,
650
+ FormikDatePicker_default as FormikDatePicker,
651
+ FormikFontPicker_default as FormikFontPicker,
652
+ FormikImageUpload_default as FormikImageUpload,
653
+ FormikRadioGroup_default as FormikRadioGroup,
654
+ FormikRating_default as FormikRating,
655
+ FormikSelect_default as FormikSelect,
656
+ FormikSlider_default as FormikSlider,
657
+ FormikSwitch_default as FormikSwitch,
658
+ FormikTextField_default as FormikTextField,
659
+ FormikToggleButtonGroup_default as FormikToggleButtonGroup
660
+ };