@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.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,18 +17,42 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
21
31
  var index_exports = {};
22
32
  __export(index_exports, {
33
+ FormButton: () => FormButton_default,
34
+ FormCheckbox: () => FormCheckbox_default,
35
+ FormDate: () => FormDate_default,
36
+ FormError: () => FormError_default,
37
+ FormFileInput: () => FormFileInput_default,
38
+ FormInput: () => FormInput_default,
39
+ FormInputLayout: () => FormInputLayout_default,
40
+ FormLabel: () => FormLabel_default,
23
41
  FormLayout: () => FormLayout,
42
+ FormMaskedInput: () => FormMaskedInput_default,
43
+ FormNumber: () => FormNumber_default,
44
+ FormPasswordInput: () => FormPasswordInput_default,
45
+ FormProvider: () => FormProvider,
46
+ FormRadio: () => FormRadio_default,
47
+ FormRange: () => FormRange_default,
48
+ FormSelect: () => FormSelect_default,
49
+ FormTextarea: () => FormTextarea_default,
24
50
  InputForm: () => InputForm_default,
25
51
  useFormContext: () => useFormContext
26
52
  });
27
53
  module.exports = __toCommonJS(index_exports);
28
54
 
29
- // src/FormLayout.tsx
55
+ // src/JsonMethod/FormLayout.tsx
30
56
  var import_react_hook_form2 = require("react-hook-form");
31
57
 
32
58
  // src/InputForm/layouts/mainLayout.tsx
@@ -41,7 +67,7 @@ function MainLayout({
41
67
  errorClass
42
68
  }) {
43
69
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
44
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: labelClass, children: [
70
+ label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: labelClass, children: [
45
71
  label,
46
72
  " ",
47
73
  required ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "*" }) : null
@@ -162,26 +188,14 @@ function InputForm({
162
188
  }
163
189
  var InputForm_default = InputForm;
164
190
 
165
- // src/FormContext.tsx
166
- var import_react = require("react");
167
- var FormContext = (0, import_react.createContext)(null);
168
- var FormProvider = FormContext.Provider;
169
- function useFormContext() {
170
- const context = (0, import_react.useContext)(FormContext);
171
- if (!context) {
172
- throw new Error("useFormContext must be used within FormLayout");
173
- }
174
- return context;
175
- }
176
-
177
- // src/FormLayout.tsx
191
+ // src/JsonMethod/FormLayout.tsx
178
192
  var import_jsx_runtime5 = require("react/jsx-runtime");
179
193
  function FormLayout({
180
194
  formData,
181
195
  funSubmit,
182
196
  formClass,
183
197
  buttonClass,
184
- children
198
+ buttonName
185
199
  }) {
186
200
  const {
187
201
  control,
@@ -192,8 +206,8 @@ function FormLayout({
192
206
  const onSubmit = (data) => {
193
207
  funSubmit(data);
194
208
  };
195
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormProvider, { value: { control, register, errors }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit(onSubmit), className: formClass, children: [
196
- formData ? formData.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
209
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit(onSubmit), className: formClass, children: [
210
+ formData.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
197
211
  InputForm_default,
198
212
  {
199
213
  type: item.type,
@@ -216,13 +230,669 @@ function FormLayout({
216
230
  labelClass: item.labelClass
217
231
  },
218
232
  String(item.key)
219
- )) : children,
220
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "submit", className: buttonClass, children: "\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C" })
221
- ] }) });
233
+ )),
234
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "submit", className: buttonClass, children: buttonName || "Submit" })
235
+ ] });
236
+ }
237
+
238
+ // src/ProviderMethod/layouts/FormProvider.tsx
239
+ var import_react_hook_form3 = require("react-hook-form");
240
+
241
+ // src/ProviderMethod/context/FormContext.tsx
242
+ var import_react = __toESM(require("react"));
243
+ var FormContext = import_react.default.createContext(void 0);
244
+ function useFormContext() {
245
+ const context = import_react.default.useContext(FormContext);
246
+ if (!context) {
247
+ 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");
248
+ }
249
+ return context;
250
+ }
251
+
252
+ // src/ProviderMethod/layouts/FormProvider.tsx
253
+ var import_react2 = require("react");
254
+ var import_jsx_runtime6 = require("react/jsx-runtime");
255
+ function FormProvider({
256
+ setFormApi,
257
+ children,
258
+ funSubmit,
259
+ className
260
+ }) {
261
+ const {
262
+ control,
263
+ register,
264
+ handleSubmit,
265
+ formState: { errors }
266
+ } = (0, import_react_hook_form3.useForm)();
267
+ const onSubmit = (data) => {
268
+ funSubmit(data);
269
+ };
270
+ const values = (0, import_react_hook_form3.useWatch)({ control });
271
+ const contextValue = {
272
+ register,
273
+ errors,
274
+ control,
275
+ values
276
+ };
277
+ (0, import_react2.useEffect)(() => {
278
+ setFormApi && setFormApi({ control, register, errors, values });
279
+ }, [setFormApi, control, register, errors, values]);
280
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { onSubmit: handleSubmit(onSubmit), className, children }) });
281
+ }
282
+
283
+ // src/ProviderMethod/layouts/FormInputLayout.tsx
284
+ var import_react3 = __toESM(require("react"));
285
+ var import_jsx_runtime7 = require("react/jsx-runtime");
286
+ var FormInputLayoutContext = import_react3.default.createContext(void 0);
287
+ function useInputLayoutContext() {
288
+ const context = import_react3.default.useContext(FormInputLayoutContext);
289
+ if (!context) {
290
+ throw new Error(
291
+ "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"
292
+ );
293
+ }
294
+ return context;
295
+ }
296
+ function useOptionalInputLayoutContext() {
297
+ return import_react3.default.useContext(FormInputLayoutContext);
298
+ }
299
+ function FormInputLayout({
300
+ name,
301
+ minLength,
302
+ maxLength,
303
+ pattern,
304
+ required,
305
+ validate,
306
+ children,
307
+ className,
308
+ maska
309
+ }) {
310
+ const contextValue = {
311
+ name,
312
+ minLength,
313
+ maxLength,
314
+ pattern,
315
+ required,
316
+ validate,
317
+ maska
318
+ };
319
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FormInputLayoutContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, children }) });
320
+ }
321
+ var FormInputLayout_default = FormInputLayout;
322
+
323
+ // src/ProviderMethod/components/FormInput.tsx
324
+ var import_jsx_runtime8 = require("react/jsx-runtime");
325
+ function FormInput({
326
+ placeholder,
327
+ className,
328
+ classNameError,
329
+ type
330
+ }) {
331
+ const { register, errors } = useFormContext();
332
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
333
+ const isErrorMessage = !!errors[name]?.message;
334
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
335
+ "input",
336
+ {
337
+ id: name,
338
+ ...register(name, {
339
+ required,
340
+ minLength,
341
+ maxLength,
342
+ pattern,
343
+ validate
344
+ }),
345
+ type: type ? type : "text",
346
+ placeholder: placeholder ? placeholder : "",
347
+ className: `${className} ${isErrorMessage ? classNameError : ""}`
348
+ }
349
+ );
350
+ }
351
+ var FormInput_default = FormInput;
352
+
353
+ // src/ProviderMethod/components/FormPasswordInput.tsx
354
+ var import_react4 = require("react");
355
+ var import_jsx_runtime9 = require("react/jsx-runtime");
356
+ var EyeIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
357
+ "svg",
358
+ {
359
+ width: "20",
360
+ height: "20",
361
+ viewBox: "0 0 24 24",
362
+ fill: "none",
363
+ stroke: "currentColor",
364
+ strokeWidth: "2",
365
+ strokeLinecap: "round",
366
+ strokeLinejoin: "round",
367
+ className,
368
+ children: [
369
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
370
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: "12", cy: "12", r: "3" })
371
+ ]
372
+ }
373
+ );
374
+ var EyeOffIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
375
+ "svg",
376
+ {
377
+ width: "20",
378
+ height: "20",
379
+ viewBox: "0 0 24 24",
380
+ fill: "none",
381
+ stroke: "currentColor",
382
+ strokeWidth: "2",
383
+ strokeLinecap: "round",
384
+ strokeLinejoin: "round",
385
+ className,
386
+ children: [
387
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("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" }),
388
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
389
+ ]
390
+ }
391
+ );
392
+ function FormPasswordInput({
393
+ placeholder,
394
+ className,
395
+ inputClassName,
396
+ classNameError,
397
+ visibleIcon = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EyeIcon, {}),
398
+ hiddenIcon = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EyeOffIcon, {}),
399
+ iconClassName,
400
+ iconWrapperClassName = "cursor-pointer"
401
+ }) {
402
+ const [isVisible, setIsVisible] = (0, import_react4.useState)(false);
403
+ const { register, errors } = useFormContext();
404
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
405
+ const isErrorMessage = !!errors[name]?.message;
406
+ const toggleVisibility = () => {
407
+ setIsVisible(!isVisible);
408
+ };
409
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
410
+ "div",
411
+ {
412
+ className,
413
+ style: { display: "flex", alignItems: "center", gap: "8px" },
414
+ children: [
415
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
416
+ "input",
417
+ {
418
+ id: name,
419
+ ...register(name, {
420
+ required,
421
+ minLength,
422
+ maxLength,
423
+ pattern,
424
+ validate
425
+ }),
426
+ type: isVisible ? "text" : "password",
427
+ placeholder: placeholder ? placeholder : "",
428
+ className: `${inputClassName} ${isErrorMessage ? classNameError : ""}`,
429
+ style: { flex: 1 }
430
+ }
431
+ ),
432
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
433
+ "div",
434
+ {
435
+ onClick: toggleVisibility,
436
+ className: `${iconClassName ? iconClassName : iconWrapperClassName}`,
437
+ style: {
438
+ cursor: "pointer",
439
+ userSelect: "none",
440
+ display: "flex",
441
+ alignItems: "center"
442
+ },
443
+ 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",
444
+ children: isVisible ? visibleIcon : hiddenIcon
445
+ }
446
+ )
447
+ ]
448
+ }
449
+ );
450
+ }
451
+ var FormPasswordInput_default = FormPasswordInput;
452
+
453
+ // src/ProviderMethod/components/FormTextarea.tsx
454
+ var import_jsx_runtime10 = require("react/jsx-runtime");
455
+ function FormTextarea({
456
+ placeholder,
457
+ className,
458
+ classNameError,
459
+ rows,
460
+ cols
461
+ }) {
462
+ const { register, errors } = useFormContext();
463
+ const { name, required, minLength, maxLength, pattern, validate } = useInputLayoutContext();
464
+ const isErrorMessage = !!errors[name]?.message;
465
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
466
+ "textarea",
467
+ {
468
+ id: name,
469
+ ...register(name, {
470
+ required,
471
+ minLength,
472
+ maxLength,
473
+ pattern,
474
+ validate
475
+ }),
476
+ placeholder: placeholder ? placeholder : "",
477
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
478
+ rows,
479
+ cols
480
+ }
481
+ );
482
+ }
483
+ var FormTextarea_default = FormTextarea;
484
+
485
+ // src/ProviderMethod/components/FormMaskedInput.tsx
486
+ var import_react_hook_form4 = require("react-hook-form");
487
+ var import_react_number_format2 = require("react-number-format");
488
+ var import_jsx_runtime11 = require("react/jsx-runtime");
489
+ function FormMaskedInput({
490
+ placeholder,
491
+ className,
492
+ classNameError
493
+ }) {
494
+ const { control, errors } = useFormContext();
495
+ const { name, required, minLength, maxLength, pattern, validate, maska } = useInputLayoutContext();
496
+ const isErrorMessage = !!errors[name]?.message;
497
+ if (!maska) {
498
+ return null;
499
+ }
500
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
501
+ import_react_hook_form4.Controller,
502
+ {
503
+ name: name || "",
504
+ control,
505
+ rules: {
506
+ required: maska.required ?? required,
507
+ minLength,
508
+ maxLength,
509
+ pattern,
510
+ validate
511
+ },
512
+ render: ({ field }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
513
+ import_react_number_format2.PatternFormat,
514
+ {
515
+ ...field,
516
+ format: maska.format,
517
+ mask: maska.mask,
518
+ placeholder: placeholder ? placeholder : "",
519
+ className: `${className} ${isErrorMessage ? classNameError : ""}`
520
+ }
521
+ )
522
+ }
523
+ );
524
+ }
525
+ var FormMaskedInput_default = FormMaskedInput;
526
+
527
+ // src/ProviderMethod/components/FormSelect.tsx
528
+ var import_jsx_runtime12 = require("react/jsx-runtime");
529
+ function FormSelect({
530
+ options,
531
+ className,
532
+ classNameError,
533
+ multiple,
534
+ placeholder
535
+ }) {
536
+ const { register, errors } = useFormContext();
537
+ const { name, required, validate } = useInputLayoutContext();
538
+ const isErrorMessage = !!errors[name]?.message;
539
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
540
+ "select",
541
+ {
542
+ id: name,
543
+ ...register(name, {
544
+ required,
545
+ validate
546
+ }),
547
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
548
+ multiple,
549
+ children: [
550
+ placeholder && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: placeholder }),
551
+ options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: option.value, children: option.label }, option.value))
552
+ ]
553
+ }
554
+ );
555
+ }
556
+ var FormSelect_default = FormSelect;
557
+
558
+ // src/ProviderMethod/components/FormNumber.tsx
559
+ var import_jsx_runtime13 = require("react/jsx-runtime");
560
+ function FormNumber({
561
+ placeholder,
562
+ className,
563
+ classNameError,
564
+ min,
565
+ max,
566
+ step
567
+ }) {
568
+ const { register, errors } = useFormContext();
569
+ const { name, required, validate } = useInputLayoutContext();
570
+ const isErrorMessage = !!errors[name]?.message;
571
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
572
+ "input",
573
+ {
574
+ id: name,
575
+ type: "number",
576
+ ...register(name, {
577
+ required,
578
+ validate,
579
+ valueAsNumber: true
580
+ }),
581
+ placeholder: placeholder ? placeholder : "",
582
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
583
+ min,
584
+ max,
585
+ step
586
+ }
587
+ );
588
+ }
589
+ var FormNumber_default = FormNumber;
590
+
591
+ // src/ProviderMethod/components/FormDate.tsx
592
+ var import_jsx_runtime14 = require("react/jsx-runtime");
593
+ function FormDate({
594
+ placeholder,
595
+ className,
596
+ classNameError,
597
+ min,
598
+ max,
599
+ type = "date"
600
+ }) {
601
+ const { register, errors } = useFormContext();
602
+ const { name, required, validate } = useInputLayoutContext();
603
+ const isErrorMessage = !!errors[name]?.message;
604
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
605
+ "input",
606
+ {
607
+ id: name,
608
+ type,
609
+ ...register(name, {
610
+ required,
611
+ validate
612
+ }),
613
+ placeholder: placeholder ? placeholder : "",
614
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
615
+ min,
616
+ max
617
+ }
618
+ );
619
+ }
620
+ var FormDate_default = FormDate;
621
+
622
+ // src/ProviderMethod/components/FormRange.tsx
623
+ var import_react5 = require("react");
624
+ var import_jsx_runtime15 = require("react/jsx-runtime");
625
+ function FormRange({
626
+ className,
627
+ classNameError,
628
+ min = 0,
629
+ max = 100,
630
+ step = 1,
631
+ range = "single",
632
+ showValue,
633
+ containerClassName
634
+ }) {
635
+ const { register, control, errors } = useFormContext();
636
+ const { name, required, validate } = useInputLayoutContext();
637
+ const [value, setValue] = (0, import_react5.useState)(min);
638
+ const [maxValue, setMaxValue] = (0, import_react5.useState)(max);
639
+ const isErrorMessage = !!errors[name]?.message;
640
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: containerClassName, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
641
+ "div",
642
+ {
643
+ style: {
644
+ display: "flex",
645
+ gap: "16px",
646
+ alignItems: "flex-start",
647
+ flexWrap: "wrap"
648
+ },
649
+ children: [
650
+ range === "single" && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { flex: 1, minWidth: "200px" }, children: [
651
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
652
+ "input",
653
+ {
654
+ id: name,
655
+ type: "range",
656
+ ...register(name, {
657
+ required,
658
+ validate
659
+ }),
660
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
661
+ min,
662
+ max,
663
+ step,
664
+ onChange: (e) => setValue(Number(e.target.value)),
665
+ style: { cursor: "pointer" }
666
+ }
667
+ ),
668
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { marginTop: "8px", fontSize: "14px" }, children: value })
669
+ ] }),
670
+ range === "double" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { flex: 1, minWidth: "200px" }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
671
+ "div",
672
+ {
673
+ style: {
674
+ display: "flex",
675
+ flexDirection: "column",
676
+ gap: "12px"
677
+ },
678
+ children: [
679
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
680
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { style: { fontSize: "12px", marginRight: "8px" }, children: "\u041E\u0442:" }),
681
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
682
+ "input",
683
+ {
684
+ type: "range",
685
+ ...register(`${name}_min`, {
686
+ required,
687
+ validate
688
+ }),
689
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
690
+ min,
691
+ max: maxValue,
692
+ step,
693
+ onChange: (e) => setValue(Number(e.target.value)),
694
+ style: { cursor: "pointer" }
695
+ }
696
+ ),
697
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { marginTop: "4px", fontSize: "12px" }, children: value })
698
+ ] }),
699
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
700
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { style: { fontSize: "12px", marginRight: "8px" }, children: "\u0414\u043E:" }),
701
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
702
+ "input",
703
+ {
704
+ type: "range",
705
+ ...register(`${name}_max`, {
706
+ required,
707
+ validate
708
+ }),
709
+ className: `${className} w-full ${isErrorMessage ? classNameError : ""}`,
710
+ min: value,
711
+ max,
712
+ step,
713
+ onChange: (e) => setMaxValue(Number(e.target.value)),
714
+ style: { cursor: "pointer" }
715
+ }
716
+ ),
717
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { marginTop: "4px", fontSize: "12px" }, children: maxValue })
718
+ ] }),
719
+ showValue && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { fontSize: "14px", fontWeight: "bold" }, children: [
720
+ "\u0414\u0438\u0430\u043F\u0430\u0437\u043E\u043D: ",
721
+ value,
722
+ " - ",
723
+ maxValue
724
+ ] })
725
+ ]
726
+ }
727
+ ) })
728
+ ]
729
+ }
730
+ ) });
731
+ }
732
+ var FormRange_default = FormRange;
733
+
734
+ // src/ProviderMethod/components/FormFileInput.tsx
735
+ var import_jsx_runtime16 = require("react/jsx-runtime");
736
+ function FormFileInput({
737
+ className,
738
+ classNameError,
739
+ accept,
740
+ multiple
741
+ }) {
742
+ const { register, errors } = useFormContext();
743
+ const { name, required, validate } = useInputLayoutContext();
744
+ const isErrorMessage = !!errors[name]?.message;
745
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
746
+ "input",
747
+ {
748
+ id: name,
749
+ type: "file",
750
+ ...register(name, {
751
+ required,
752
+ validate
753
+ }),
754
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
755
+ accept,
756
+ multiple
757
+ }
758
+ );
759
+ }
760
+ var FormFileInput_default = FormFileInput;
761
+
762
+ // src/ProviderMethod/components/FormCheckbox.tsx
763
+ var import_jsx_runtime17 = require("react/jsx-runtime");
764
+ function FormCheckbox({
765
+ className,
766
+ classNameError,
767
+ value,
768
+ defaultChecked,
769
+ disabled
770
+ }) {
771
+ const { register, errors } = useFormContext();
772
+ const { name, required, validate } = useInputLayoutContext();
773
+ const isErrorMessage = !!errors[name]?.message;
774
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
775
+ "input",
776
+ {
777
+ id: name,
778
+ type: "checkbox",
779
+ ...register(name, {
780
+ required,
781
+ validate
782
+ }),
783
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
784
+ value,
785
+ defaultChecked,
786
+ disabled
787
+ }
788
+ );
789
+ }
790
+ var FormCheckbox_default = FormCheckbox;
791
+
792
+ // src/ProviderMethod/components/FormRadio.tsx
793
+ var import_jsx_runtime18 = require("react/jsx-runtime");
794
+ function FormRadio({
795
+ className,
796
+ classNameError,
797
+ value,
798
+ defaultChecked,
799
+ disabled
800
+ }) {
801
+ const { register, errors } = useFormContext();
802
+ const { name, required, validate } = useInputLayoutContext();
803
+ const isErrorMessage = !!errors[name]?.message;
804
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
805
+ "input",
806
+ {
807
+ id: `${name}-${value}`,
808
+ type: "radio",
809
+ ...register(name, {
810
+ required,
811
+ validate
812
+ }),
813
+ className: `${className} ${isErrorMessage ? classNameError : ""}`,
814
+ value,
815
+ defaultChecked,
816
+ disabled
817
+ }
818
+ );
819
+ }
820
+ var FormRadio_default = FormRadio;
821
+
822
+ // src/ProviderMethod/components/FormButton.tsx
823
+ var import_jsx_runtime19 = require("react/jsx-runtime");
824
+ function FormButton({
825
+ children,
826
+ className,
827
+ disabledError,
828
+ ...props
829
+ }) {
830
+ const { errors } = useFormContext();
831
+ const errorMessage = errors && Object.keys(errors).length > 0;
832
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
833
+ "button",
834
+ {
835
+ type: "submit",
836
+ className: `${className}`,
837
+ ...props,
838
+ disabled: errorMessage && disabledError,
839
+ children
840
+ }
841
+ );
842
+ }
843
+ var FormButton_default = FormButton;
844
+
845
+ // src/ProviderMethod/components/FormError.tsx
846
+ var import_jsx_runtime20 = require("react/jsx-runtime");
847
+ function FormError({ ...props }) {
848
+ const { errors } = useFormContext();
849
+ const { name } = useInputLayoutContext();
850
+ const layout = useOptionalInputLayoutContext();
851
+ const resolvedName = name ?? layout?.name;
852
+ if (!resolvedName) {
853
+ return null;
854
+ }
855
+ const errorMessage = errors[resolvedName]?.message;
856
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { ...props, children: typeof errorMessage === "string" ? errorMessage : null });
857
+ }
858
+ var FormError_default = FormError;
859
+
860
+ // src/ProviderMethod/components/FormLabel.tsx
861
+ var import_jsx_runtime21 = require("react/jsx-runtime");
862
+ function FormLabel({
863
+ children,
864
+ className,
865
+ classNameError
866
+ }) {
867
+ const { required } = useInputLayoutContext();
868
+ const { errors } = useFormContext();
869
+ const { name } = useInputLayoutContext();
870
+ const isErrorMessage = !!errors[name]?.message;
871
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("label", { className: `${className} ${isErrorMessage ? classNameError : ""}`, children: [
872
+ children,
873
+ !!required && "*"
874
+ ] });
222
875
  }
876
+ var FormLabel_default = FormLabel;
223
877
  // Annotate the CommonJS export names for ESM import in node:
224
878
  0 && (module.exports = {
879
+ FormButton,
880
+ FormCheckbox,
881
+ FormDate,
882
+ FormError,
883
+ FormFileInput,
884
+ FormInput,
885
+ FormInputLayout,
886
+ FormLabel,
225
887
  FormLayout,
888
+ FormMaskedInput,
889
+ FormNumber,
890
+ FormPasswordInput,
891
+ FormProvider,
892
+ FormRadio,
893
+ FormRange,
894
+ FormSelect,
895
+ FormTextarea,
226
896
  InputForm,
227
897
  useFormContext
228
898
  });