@arturton/react-form-constructor 0.1.3 → 0.1.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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // src/FormLayout.tsx
1
+ // src/JsonMethod/FormLayout.tsx
2
2
  import { useForm } from "react-hook-form";
3
3
 
4
4
  // src/InputForm/layouts/mainLayout.tsx
@@ -13,7 +13,7 @@ function MainLayout({
13
13
  errorClass
14
14
  }) {
15
15
  return /* @__PURE__ */ jsxs("div", { children: [
16
- /* @__PURE__ */ jsxs("label", { className: labelClass, children: [
16
+ label && /* @__PURE__ */ jsxs("label", { className: labelClass, children: [
17
17
  label,
18
18
  " ",
19
19
  required ? /* @__PURE__ */ jsx("span", { children: "*" }) : null
@@ -134,26 +134,14 @@ function InputForm({
134
134
  }
135
135
  var InputForm_default = InputForm;
136
136
 
137
- // src/FormContext.tsx
138
- import { createContext, useContext } from "react";
139
- var FormContext = createContext(null);
140
- var FormProvider = FormContext.Provider;
141
- function useFormContext() {
142
- const context = useContext(FormContext);
143
- if (!context) {
144
- throw new Error("useFormContext must be used within FormLayout");
145
- }
146
- return context;
147
- }
148
-
149
- // src/FormLayout.tsx
137
+ // src/JsonMethod/FormLayout.tsx
150
138
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
151
139
  function FormLayout({
152
140
  formData,
153
141
  funSubmit,
154
142
  formClass,
155
143
  buttonClass,
156
- children
144
+ buttonName
157
145
  }) {
158
146
  const {
159
147
  control,
@@ -164,8 +152,8 @@ function FormLayout({
164
152
  const onSubmit = (data) => {
165
153
  funSubmit(data);
166
154
  };
167
- return /* @__PURE__ */ jsx5(FormProvider, { value: { control, register, errors }, children: /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit(onSubmit), className: formClass, children: [
168
- formData ? formData.map((item) => /* @__PURE__ */ jsx5(
155
+ return /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit(onSubmit), className: formClass, children: [
156
+ formData.map((item) => /* @__PURE__ */ jsx5(
169
157
  InputForm_default,
170
158
  {
171
159
  type: item.type,
@@ -188,12 +176,668 @@ function FormLayout({
188
176
  labelClass: item.labelClass
189
177
  },
190
178
  String(item.key)
191
- )) : children,
192
- /* @__PURE__ */ jsx5("button", { type: "submit", className: buttonClass, children: "\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C" })
193
- ] }) });
179
+ )),
180
+ /* @__PURE__ */ jsx5("button", { type: "submit", className: buttonClass, children: buttonName || "Submit" })
181
+ ] });
182
+ }
183
+
184
+ // src/ProviderMethod/layouts/FormProvider.tsx
185
+ import { useForm as useForm2, useWatch } from "react-hook-form";
186
+
187
+ // src/ProviderMethod/context/FormContext.tsx
188
+ import React from "react";
189
+ var FormContext = React.createContext(void 0);
190
+ function useFormContext() {
191
+ const context = React.useContext(FormContext);
192
+ if (!context) {
193
+ throw new Error("useFormContext \u0434\u043E\u043B\u0436\u0435\u043D \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C\u0441\u044F \u0432\u043D\u0443\u0442\u0440\u0438 FormProvider");
194
+ }
195
+ return context;
196
+ }
197
+
198
+ // src/ProviderMethod/layouts/FormProvider.tsx
199
+ import { useEffect } from "react";
200
+ import { jsx as jsx6 } from "react/jsx-runtime";
201
+ function FormProvider({
202
+ setFormApi,
203
+ children,
204
+ funSubmit,
205
+ className
206
+ }) {
207
+ const {
208
+ control,
209
+ register,
210
+ handleSubmit,
211
+ formState: { errors }
212
+ } = useForm2();
213
+ const onSubmit = (data) => {
214
+ funSubmit(data);
215
+ };
216
+ const values = useWatch({ control });
217
+ const contextValue = {
218
+ register,
219
+ errors,
220
+ control,
221
+ values
222
+ };
223
+ useEffect(() => {
224
+ setFormApi && setFormApi({ control, register, errors, values });
225
+ }, [setFormApi, control, register, errors, values]);
226
+ return /* @__PURE__ */ jsx6(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx6("form", { onSubmit: handleSubmit(onSubmit), className, children }) });
227
+ }
228
+
229
+ // src/ProviderMethod/layouts/FormInputLayout.tsx
230
+ import React2 from "react";
231
+ import { jsx as jsx7 } from "react/jsx-runtime";
232
+ var FormInputLayoutContext = React2.createContext(void 0);
233
+ function useInputLayoutContext() {
234
+ const context = React2.useContext(FormInputLayoutContext);
235
+ if (!context) {
236
+ throw new Error(
237
+ "useInputLayoutContext \u0434\u043E\u043B\u0436\u0435\u043D \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C\u0441\u044F \u0432\u043D\u0443\u0442\u0440\u0438 FormInputLayout"
238
+ );
239
+ }
240
+ return context;
241
+ }
242
+ function useOptionalInputLayoutContext() {
243
+ return React2.useContext(FormInputLayoutContext);
244
+ }
245
+ function FormInputLayout({
246
+ name,
247
+ minLength,
248
+ maxLength,
249
+ pattern,
250
+ required,
251
+ validate,
252
+ children,
253
+ className,
254
+ maska
255
+ }) {
256
+ const contextValue = {
257
+ name,
258
+ minLength,
259
+ maxLength,
260
+ pattern,
261
+ required,
262
+ validate,
263
+ maska
264
+ };
265
+ return /* @__PURE__ */ jsx7(FormInputLayoutContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx7("div", { className, children }) });
266
+ }
267
+ var FormInputLayout_default = FormInputLayout;
268
+
269
+ // src/ProviderMethod/components/FormInput.tsx
270
+ import { jsx as jsx8 } from "react/jsx-runtime";
271
+ function FormInput({
272
+ placeholder,
273
+ className,
274
+ classNameError,
275
+ type
276
+ }) {
277
+ const { register, errors } = useFormContext();
278
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
279
+ const isErrorMessage = !!errors[name]?.message;
280
+ return /* @__PURE__ */ jsx8(
281
+ "input",
282
+ {
283
+ id: name,
284
+ ...register(name, {
285
+ required,
286
+ minLength,
287
+ maxLength,
288
+ pattern,
289
+ validate
290
+ }),
291
+ type: type ? type : "text",
292
+ placeholder: placeholder ? placeholder : "",
293
+ className: `${className} ${isErrorMessage ? classNameError : ""}`
294
+ }
295
+ );
296
+ }
297
+ var FormInput_default = FormInput;
298
+
299
+ // src/ProviderMethod/components/FormPasswordInput.tsx
300
+ import { useState } from "react";
301
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
302
+ var EyeIcon = ({ className }) => /* @__PURE__ */ jsxs3(
303
+ "svg",
304
+ {
305
+ width: "20",
306
+ height: "20",
307
+ viewBox: "0 0 24 24",
308
+ fill: "none",
309
+ stroke: "currentColor",
310
+ strokeWidth: "2",
311
+ strokeLinecap: "round",
312
+ strokeLinejoin: "round",
313
+ className,
314
+ children: [
315
+ /* @__PURE__ */ jsx9("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
316
+ /* @__PURE__ */ jsx9("circle", { cx: "12", cy: "12", r: "3" })
317
+ ]
318
+ }
319
+ );
320
+ var EyeOffIcon = ({ className }) => /* @__PURE__ */ jsxs3(
321
+ "svg",
322
+ {
323
+ width: "20",
324
+ height: "20",
325
+ viewBox: "0 0 24 24",
326
+ fill: "none",
327
+ stroke: "currentColor",
328
+ strokeWidth: "2",
329
+ strokeLinecap: "round",
330
+ strokeLinejoin: "round",
331
+ className,
332
+ children: [
333
+ /* @__PURE__ */ jsx9("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
334
+ /* @__PURE__ */ jsx9("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
335
+ ]
336
+ }
337
+ );
338
+ function FormPasswordInput({
339
+ placeholder,
340
+ className,
341
+ inputClassName,
342
+ classNameError,
343
+ visibleIcon = /* @__PURE__ */ jsx9(EyeIcon, {}),
344
+ hiddenIcon = /* @__PURE__ */ jsx9(EyeOffIcon, {}),
345
+ iconClassName,
346
+ iconWrapperClassName = "cursor-pointer"
347
+ }) {
348
+ const [isVisible, setIsVisible] = useState(false);
349
+ const { register, errors } = useFormContext();
350
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
351
+ const isErrorMessage = !!errors[name]?.message;
352
+ const toggleVisibility = () => {
353
+ setIsVisible(!isVisible);
354
+ };
355
+ return /* @__PURE__ */ jsxs3(
356
+ "div",
357
+ {
358
+ className,
359
+ style: { display: "flex", alignItems: "center", gap: "8px" },
360
+ children: [
361
+ /* @__PURE__ */ jsx9(
362
+ "input",
363
+ {
364
+ id: name,
365
+ ...register(name, {
366
+ required,
367
+ minLength,
368
+ maxLength,
369
+ pattern,
370
+ validate
371
+ }),
372
+ type: isVisible ? "text" : "password",
373
+ placeholder: placeholder ? placeholder : "",
374
+ className: `${inputClassName} ${isErrorMessage ? classNameError : ""}`,
375
+ style: { flex: 1 }
376
+ }
377
+ ),
378
+ /* @__PURE__ */ jsx9(
379
+ "div",
380
+ {
381
+ onClick: toggleVisibility,
382
+ className: `${iconClassName ? iconClassName : iconWrapperClassName}`,
383
+ style: {
384
+ cursor: "pointer",
385
+ userSelect: "none",
386
+ display: "flex",
387
+ alignItems: "center"
388
+ },
389
+ title: isVisible ? "\u0421\u043A\u0440\u044B\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C" : "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u043F\u0430\u0440\u043E\u043B\u044C",
390
+ children: isVisible ? visibleIcon : hiddenIcon
391
+ }
392
+ )
393
+ ]
394
+ }
395
+ );
396
+ }
397
+ var FormPasswordInput_default = FormPasswordInput;
398
+
399
+ // src/ProviderMethod/components/FormTextarea.tsx
400
+ import { jsx as jsx10 } from "react/jsx-runtime";
401
+ function FormTextarea({
402
+ placeholder,
403
+ className,
404
+ classNameError,
405
+ rows,
406
+ cols
407
+ }) {
408
+ const { register, errors } = useFormContext();
409
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
410
+ const isErrorMessage = !!errors[name]?.message;
411
+ return /* @__PURE__ */ jsx10(
412
+ "textarea",
413
+ {
414
+ id: name,
415
+ ...register(name, {
416
+ required,
417
+ minLength,
418
+ maxLength,
419
+ pattern,
420
+ validate
421
+ }),
422
+ placeholder: placeholder ? placeholder : "",
423
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
424
+ rows,
425
+ cols
426
+ }
427
+ );
428
+ }
429
+ var FormTextarea_default = FormTextarea;
430
+
431
+ // src/ProviderMethod/components/FormMaskedInput.tsx
432
+ import { Controller as Controller2 } from "react-hook-form";
433
+ import { PatternFormat as PatternFormat2 } from "react-number-format";
434
+ import { jsx as jsx11 } from "react/jsx-runtime";
435
+ function FormMaskedInput({
436
+ placeholder,
437
+ className,
438
+ classNameError
439
+ }) {
440
+ const { control, errors } = useFormContext();
441
+ const { name, required, minLength, maxLength, pattern, validate, maska } = useInputLayoutContext();
442
+ const isErrorMessage = !!errors[name]?.message;
443
+ if (!maska) {
444
+ return null;
445
+ }
446
+ return /* @__PURE__ */ jsx11(
447
+ Controller2,
448
+ {
449
+ name: name || "",
450
+ control,
451
+ rules: {
452
+ required: maska.required ?? required,
453
+ minLength,
454
+ maxLength,
455
+ pattern,
456
+ validate
457
+ },
458
+ render: ({ field }) => /* @__PURE__ */ jsx11(
459
+ PatternFormat2,
460
+ {
461
+ ...field,
462
+ format: maska.format,
463
+ mask: maska.mask,
464
+ placeholder: placeholder ? placeholder : "",
465
+ className: `${className} ${isErrorMessage ? classNameError : ""}`
466
+ }
467
+ )
468
+ }
469
+ );
470
+ }
471
+ var FormMaskedInput_default = FormMaskedInput;
472
+
473
+ // src/ProviderMethod/components/FormSelect.tsx
474
+ import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
475
+ function FormSelect({
476
+ options,
477
+ className,
478
+ classNameError,
479
+ multiple,
480
+ placeholder
481
+ }) {
482
+ const { register, errors } = useFormContext();
483
+ const { name, required, validate } = useInputLayoutContext();
484
+ const isErrorMessage = !!errors[name]?.message;
485
+ return /* @__PURE__ */ jsxs4(
486
+ "select",
487
+ {
488
+ id: name,
489
+ ...register(name, {
490
+ required,
491
+ validate
492
+ }),
493
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
494
+ multiple,
495
+ children: [
496
+ placeholder && /* @__PURE__ */ jsx12("option", { value: "", children: placeholder }),
497
+ options.map((option) => /* @__PURE__ */ jsx12("option", { value: option.value, children: option.label }, option.value))
498
+ ]
499
+ }
500
+ );
501
+ }
502
+ var FormSelect_default = FormSelect;
503
+
504
+ // src/ProviderMethod/components/FormNumber.tsx
505
+ import { jsx as jsx13 } from "react/jsx-runtime";
506
+ function FormNumber({
507
+ placeholder,
508
+ className,
509
+ classNameError,
510
+ min,
511
+ max,
512
+ step
513
+ }) {
514
+ const { register, errors } = useFormContext();
515
+ const { name, required, validate } = useInputLayoutContext();
516
+ const isErrorMessage = !!errors[name]?.message;
517
+ return /* @__PURE__ */ jsx13(
518
+ "input",
519
+ {
520
+ id: name,
521
+ type: "number",
522
+ ...register(name, {
523
+ required,
524
+ validate,
525
+ valueAsNumber: true
526
+ }),
527
+ placeholder: placeholder ? placeholder : "",
528
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
529
+ min,
530
+ max,
531
+ step
532
+ }
533
+ );
534
+ }
535
+ var FormNumber_default = FormNumber;
536
+
537
+ // src/ProviderMethod/components/FormDate.tsx
538
+ import { jsx as jsx14 } from "react/jsx-runtime";
539
+ function FormDate({
540
+ placeholder,
541
+ className,
542
+ classNameError,
543
+ min,
544
+ max,
545
+ type = "date"
546
+ }) {
547
+ const { register, errors } = useFormContext();
548
+ const { name, required, validate } = useInputLayoutContext();
549
+ const isErrorMessage = !!errors[name]?.message;
550
+ return /* @__PURE__ */ jsx14(
551
+ "input",
552
+ {
553
+ id: name,
554
+ type,
555
+ ...register(name, {
556
+ required,
557
+ validate
558
+ }),
559
+ placeholder: placeholder ? placeholder : "",
560
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
561
+ min,
562
+ max
563
+ }
564
+ );
565
+ }
566
+ var FormDate_default = FormDate;
567
+
568
+ // src/ProviderMethod/components/FormRange.tsx
569
+ import { useState as useState2 } from "react";
570
+ import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
571
+ function FormRange({
572
+ className,
573
+ classNameError,
574
+ min = 0,
575
+ max = 100,
576
+ step = 1,
577
+ range = "single",
578
+ showValue,
579
+ containerClassName
580
+ }) {
581
+ const { register, control, errors } = useFormContext();
582
+ const { name, required, validate } = useInputLayoutContext();
583
+ const [value, setValue] = useState2(min);
584
+ const [maxValue, setMaxValue] = useState2(max);
585
+ const isErrorMessage = !!errors[name]?.message;
586
+ return /* @__PURE__ */ jsx15("div", { className: containerClassName, children: /* @__PURE__ */ jsxs5(
587
+ "div",
588
+ {
589
+ style: {
590
+ display: "flex",
591
+ gap: "16px",
592
+ alignItems: "flex-start",
593
+ flexWrap: "wrap"
594
+ },
595
+ children: [
596
+ range === "single" && /* @__PURE__ */ jsxs5("div", { style: { flex: 1, minWidth: "200px" }, children: [
597
+ /* @__PURE__ */ jsx15(
598
+ "input",
599
+ {
600
+ id: name,
601
+ type: "range",
602
+ ...register(name, {
603
+ required,
604
+ validate
605
+ }),
606
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
607
+ min,
608
+ max,
609
+ step,
610
+ onChange: (e) => setValue(Number(e.target.value)),
611
+ style: { cursor: "pointer" }
612
+ }
613
+ ),
614
+ showValue && /* @__PURE__ */ jsx15("div", { style: { marginTop: "8px", fontSize: "14px" }, children: value })
615
+ ] }),
616
+ range === "double" && /* @__PURE__ */ jsx15("div", { style: { flex: 1, minWidth: "200px" }, children: /* @__PURE__ */ jsxs5(
617
+ "div",
618
+ {
619
+ style: {
620
+ display: "flex",
621
+ flexDirection: "column",
622
+ gap: "12px"
623
+ },
624
+ children: [
625
+ /* @__PURE__ */ jsxs5("div", { children: [
626
+ /* @__PURE__ */ jsx15("label", { style: { fontSize: "12px", marginRight: "8px" }, children: "\u041E\u0442:" }),
627
+ /* @__PURE__ */ jsx15(
628
+ "input",
629
+ {
630
+ type: "range",
631
+ ...register(`${name}_min`, {
632
+ required,
633
+ validate
634
+ }),
635
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
636
+ min,
637
+ max: maxValue,
638
+ step,
639
+ onChange: (e) => setValue(Number(e.target.value)),
640
+ style: { cursor: "pointer" }
641
+ }
642
+ ),
643
+ showValue && /* @__PURE__ */ jsx15("div", { style: { marginTop: "4px", fontSize: "12px" }, children: value })
644
+ ] }),
645
+ /* @__PURE__ */ jsxs5("div", { children: [
646
+ /* @__PURE__ */ jsx15("label", { style: { fontSize: "12px", marginRight: "8px" }, children: "\u0414\u043E:" }),
647
+ /* @__PURE__ */ jsx15(
648
+ "input",
649
+ {
650
+ type: "range",
651
+ ...register(`${name}_max`, {
652
+ required,
653
+ validate
654
+ }),
655
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
656
+ min: value,
657
+ max,
658
+ step,
659
+ onChange: (e) => setMaxValue(Number(e.target.value)),
660
+ style: { cursor: "pointer" }
661
+ }
662
+ ),
663
+ showValue && /* @__PURE__ */ jsx15("div", { style: { marginTop: "4px", fontSize: "12px" }, children: maxValue })
664
+ ] }),
665
+ showValue && /* @__PURE__ */ jsxs5("div", { style: { fontSize: "14px", fontWeight: "bold" }, children: [
666
+ "\u0414\u0438\u0430\u043F\u0430\u0437\u043E\u043D: ",
667
+ value,
668
+ " - ",
669
+ maxValue
670
+ ] })
671
+ ]
672
+ }
673
+ ) })
674
+ ]
675
+ }
676
+ ) });
677
+ }
678
+ var FormRange_default = FormRange;
679
+
680
+ // src/ProviderMethod/components/FormFileInput.tsx
681
+ import { jsx as jsx16 } from "react/jsx-runtime";
682
+ function FormFileInput({
683
+ className,
684
+ classNameError,
685
+ accept,
686
+ multiple
687
+ }) {
688
+ const { register, errors } = useFormContext();
689
+ const { name, required, validate } = useInputLayoutContext();
690
+ const isErrorMessage = !!errors[name]?.message;
691
+ return /* @__PURE__ */ jsx16(
692
+ "input",
693
+ {
694
+ id: name,
695
+ type: "file",
696
+ ...register(name, {
697
+ required,
698
+ validate
699
+ }),
700
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
701
+ accept,
702
+ multiple
703
+ }
704
+ );
705
+ }
706
+ var FormFileInput_default = FormFileInput;
707
+
708
+ // src/ProviderMethod/components/FormCheckbox.tsx
709
+ import { jsx as jsx17 } from "react/jsx-runtime";
710
+ function FormCheckbox({
711
+ className,
712
+ classNameError,
713
+ value,
714
+ defaultChecked,
715
+ disabled
716
+ }) {
717
+ const { register, errors } = useFormContext();
718
+ const { name, required, validate } = useInputLayoutContext();
719
+ const isErrorMessage = !!errors[name]?.message;
720
+ return /* @__PURE__ */ jsx17(
721
+ "input",
722
+ {
723
+ id: name,
724
+ type: "checkbox",
725
+ ...register(name, {
726
+ required,
727
+ validate
728
+ }),
729
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
730
+ value,
731
+ defaultChecked,
732
+ disabled
733
+ }
734
+ );
735
+ }
736
+ var FormCheckbox_default = FormCheckbox;
737
+
738
+ // src/ProviderMethod/components/FormRadio.tsx
739
+ import { jsx as jsx18 } from "react/jsx-runtime";
740
+ function FormRadio({
741
+ className,
742
+ classNameError,
743
+ value,
744
+ defaultChecked,
745
+ disabled
746
+ }) {
747
+ const { register, errors } = useFormContext();
748
+ const { name, required, validate } = useInputLayoutContext();
749
+ const isErrorMessage = !!errors[name]?.message;
750
+ return /* @__PURE__ */ jsx18(
751
+ "input",
752
+ {
753
+ id: `${name}-${value}`,
754
+ type: "radio",
755
+ ...register(name, {
756
+ required,
757
+ validate
758
+ }),
759
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
760
+ value,
761
+ defaultChecked,
762
+ disabled
763
+ }
764
+ );
765
+ }
766
+ var FormRadio_default = FormRadio;
767
+
768
+ // src/ProviderMethod/components/FormButton.tsx
769
+ import { jsx as jsx19 } from "react/jsx-runtime";
770
+ function FormButton({
771
+ children,
772
+ className,
773
+ disabledError,
774
+ ...props
775
+ }) {
776
+ const { errors } = useFormContext();
777
+ const errorMessage = errors && Object.keys(errors).length > 0;
778
+ return /* @__PURE__ */ jsx19(
779
+ "button",
780
+ {
781
+ type: "submit",
782
+ className: `${className}`,
783
+ ...props,
784
+ disabled: errorMessage && disabledError,
785
+ children
786
+ }
787
+ );
788
+ }
789
+ var FormButton_default = FormButton;
790
+
791
+ // src/ProviderMethod/components/FormError.tsx
792
+ import { jsx as jsx20 } from "react/jsx-runtime";
793
+ function FormError({ ...props }) {
794
+ const { errors } = useFormContext();
795
+ const { name } = useInputLayoutContext();
796
+ const layout = useOptionalInputLayoutContext();
797
+ const resolvedName = name ?? layout?.name;
798
+ if (!resolvedName) {
799
+ return null;
800
+ }
801
+ const errorMessage = errors[resolvedName]?.message;
802
+ return /* @__PURE__ */ jsx20("span", { ...props, children: typeof errorMessage === "string" ? errorMessage : null });
803
+ }
804
+ var FormError_default = FormError;
805
+
806
+ // src/ProviderMethod/components/FormLabel.tsx
807
+ import { jsxs as jsxs6 } from "react/jsx-runtime";
808
+ function FormLabel({
809
+ children,
810
+ className,
811
+ classNameError
812
+ }) {
813
+ const { required } = useInputLayoutContext();
814
+ const { errors } = useFormContext();
815
+ const { name } = useInputLayoutContext();
816
+ const isErrorMessage = !!errors[name]?.message;
817
+ return /* @__PURE__ */ jsxs6("label", { className: `${className} ${isErrorMessage ? classNameError : ""}`, children: [
818
+ children,
819
+ !!required && "*"
820
+ ] });
194
821
  }
822
+ var FormLabel_default = FormLabel;
195
823
  export {
824
+ FormButton_default as FormButton,
825
+ FormCheckbox_default as FormCheckbox,
826
+ FormDate_default as FormDate,
827
+ FormError_default as FormError,
828
+ FormFileInput_default as FormFileInput,
829
+ FormInput_default as FormInput,
830
+ FormInputLayout_default as FormInputLayout,
831
+ FormLabel_default as FormLabel,
196
832
  FormLayout,
833
+ FormMaskedInput_default as FormMaskedInput,
834
+ FormNumber_default as FormNumber,
835
+ FormPasswordInput_default as FormPasswordInput,
836
+ FormProvider,
837
+ FormRadio_default as FormRadio,
838
+ FormRange_default as FormRange,
839
+ FormSelect_default as FormSelect,
840
+ FormTextarea_default as FormTextarea,
197
841
  InputForm_default as InputForm,
198
842
  useFormContext
199
843
  };