@allhailai/formfoundry-baseui 1.2.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.cjs ADDED
@@ -0,0 +1,827 @@
1
+ 'use strict';
2
+
3
+ var core = require('@allhailai/formfoundry-core');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var checkbox = require('@base-ui/react/checkbox');
6
+ var field = require('@base-ui/react/field');
7
+ require('react');
8
+ var checkboxGroup = require('@base-ui/react/checkbox-group');
9
+ var numberField = require('@base-ui/react/number-field');
10
+ var radio = require('@base-ui/react/radio');
11
+ var radioGroup = require('@base-ui/react/radio-group');
12
+ var select = require('@base-ui/react/select');
13
+ var slider = require('@base-ui/react/slider');
14
+ var _switch = require('@base-ui/react/switch');
15
+ var input = require('@base-ui/react/input');
16
+
17
+ function ButtonInput({
18
+ label,
19
+ onClick,
20
+ disabled,
21
+ classNames
22
+ }) {
23
+ return /* @__PURE__ */ jsxRuntime.jsx(
24
+ "div",
25
+ {
26
+ className: classNames?.outer,
27
+ "data-formfoundry": "button",
28
+ children: /* @__PURE__ */ jsxRuntime.jsx(
29
+ "button",
30
+ {
31
+ type: "button",
32
+ onClick,
33
+ disabled,
34
+ className: classNames?.input,
35
+ children: label ?? "Button"
36
+ }
37
+ )
38
+ }
39
+ );
40
+ }
41
+ function CheckboxInput({
42
+ name,
43
+ label,
44
+ help,
45
+ validation,
46
+ validationBehavior,
47
+ classNames,
48
+ disabled,
49
+ defaultValue
50
+ }) {
51
+ const field$1 = core.useFormFoundryField({
52
+ name,
53
+ validation,
54
+ validationBehavior,
55
+ defaultValue: defaultValue ?? false,
56
+ disabled,
57
+ label: typeof label === "string" ? label : void 0,
58
+ inputType: "checkbox"
59
+ });
60
+ return /* @__PURE__ */ jsxRuntime.jsxs(
61
+ field.Field.Root,
62
+ {
63
+ name,
64
+ invalid: !field$1.valid && field$1.touched,
65
+ disabled,
66
+ className: classNames?.outer,
67
+ "data-formfoundry": "checkbox",
68
+ "data-touched": field$1.touched || void 0,
69
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
70
+ children: [
71
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.wrapper, style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx(
73
+ checkbox.Checkbox.Root,
74
+ {
75
+ id: field$1.id,
76
+ checked: !!field$1.value,
77
+ onCheckedChange: (checked) => field$1.onChange(!!checked),
78
+ onBlur: field$1.onBlur,
79
+ className: classNames?.input,
80
+ children: /* @__PURE__ */ jsxRuntime.jsx(checkbox.Checkbox.Indicator, { children: "\u2713" })
81
+ }
82
+ ),
83
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label })
84
+ ] }),
85
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
86
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
87
+ ]
88
+ }
89
+ );
90
+ }
91
+ function normalizeOptions(options) {
92
+ return options.map(
93
+ (opt) => typeof opt === "string" ? { label: opt, value: opt } : opt
94
+ );
95
+ }
96
+ function CheckboxGroupInput({
97
+ name,
98
+ label,
99
+ help,
100
+ validation,
101
+ validationBehavior,
102
+ classNames,
103
+ options: rawOptions = [],
104
+ disabled,
105
+ defaultValue
106
+ }) {
107
+ const options = normalizeOptions(rawOptions);
108
+ const field$1 = core.useFormFoundryField({
109
+ name,
110
+ validation,
111
+ validationBehavior,
112
+ defaultValue: defaultValue ?? [],
113
+ disabled,
114
+ label: typeof label === "string" ? label : void 0,
115
+ inputType: "checkboxgroup",
116
+ selectOptions: options
117
+ });
118
+ const selectedValues = field$1.value ?? [];
119
+ return /* @__PURE__ */ jsxRuntime.jsxs(
120
+ field.Field.Root,
121
+ {
122
+ name,
123
+ invalid: !field$1.valid && field$1.touched,
124
+ disabled,
125
+ className: classNames?.outer,
126
+ "data-formfoundry": "checkboxGroup",
127
+ children: [
128
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
129
+ /* @__PURE__ */ jsxRuntime.jsx(
130
+ checkboxGroup.CheckboxGroup,
131
+ {
132
+ value: selectedValues,
133
+ onValueChange: (val) => field$1.onChange(val),
134
+ className: classNames?.wrapper,
135
+ children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
136
+ /* @__PURE__ */ jsxRuntime.jsx(checkbox.Checkbox.Root, { value: opt.value, className: classNames?.input, children: /* @__PURE__ */ jsxRuntime.jsx(checkbox.Checkbox.Indicator, { children: "\u2713" }) }),
137
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: opt.label })
138
+ ] }, opt.value))
139
+ }
140
+ ),
141
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
142
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
143
+ ]
144
+ }
145
+ );
146
+ }
147
+ function ColorInput({
148
+ name,
149
+ label,
150
+ help,
151
+ validation,
152
+ validationBehavior,
153
+ classNames,
154
+ disabled,
155
+ defaultValue
156
+ }) {
157
+ const field$1 = core.useFormFoundryField({
158
+ name,
159
+ validation,
160
+ validationBehavior,
161
+ defaultValue: defaultValue ?? "#000000",
162
+ disabled,
163
+ label: typeof label === "string" ? label : void 0,
164
+ inputType: "color"
165
+ });
166
+ return /* @__PURE__ */ jsxRuntime.jsxs(
167
+ field.Field.Root,
168
+ {
169
+ name,
170
+ invalid: !field$1.valid && field$1.touched,
171
+ disabled,
172
+ className: classNames?.outer,
173
+ "data-formfoundry": "color",
174
+ "data-touched": field$1.touched || void 0,
175
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
176
+ children: [
177
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
178
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames?.wrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
179
+ "input",
180
+ {
181
+ id: field$1.id,
182
+ type: "color",
183
+ value: field$1.value ?? "#000000",
184
+ onChange: (e) => field$1.onChange(e.target.value),
185
+ onBlur: field$1.onBlur,
186
+ className: classNames?.input
187
+ }
188
+ ) }),
189
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
190
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
191
+ ]
192
+ }
193
+ );
194
+ }
195
+ function DateInput({
196
+ name,
197
+ label,
198
+ help,
199
+ validation,
200
+ validationBehavior,
201
+ classNames,
202
+ type = "date",
203
+ placeholder,
204
+ disabled,
205
+ defaultValue,
206
+ min,
207
+ max,
208
+ step
209
+ }) {
210
+ const field$1 = core.useFormFoundryField({
211
+ name,
212
+ validation,
213
+ validationBehavior,
214
+ defaultValue,
215
+ disabled,
216
+ label: typeof label === "string" ? label : void 0,
217
+ inputType: type ?? "date"
218
+ });
219
+ return /* @__PURE__ */ jsxRuntime.jsxs(
220
+ field.Field.Root,
221
+ {
222
+ name,
223
+ invalid: !field$1.valid && field$1.touched,
224
+ disabled,
225
+ className: classNames?.outer,
226
+ "data-formfoundry": type,
227
+ "data-touched": field$1.touched || void 0,
228
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
229
+ "data-dirty": field$1.dirty || void 0,
230
+ children: [
231
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
232
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames?.wrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
233
+ "input",
234
+ {
235
+ id: field$1.id,
236
+ type,
237
+ value: field$1.value ?? "",
238
+ onChange: (e) => field$1.onChange(e.target.value),
239
+ onBlur: field$1.onBlur,
240
+ placeholder,
241
+ min,
242
+ max,
243
+ step,
244
+ className: classNames?.input
245
+ }
246
+ ) }),
247
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
248
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
249
+ ]
250
+ }
251
+ );
252
+ }
253
+ function FileInput({
254
+ name,
255
+ label,
256
+ help,
257
+ validation,
258
+ validationBehavior,
259
+ classNames,
260
+ disabled,
261
+ defaultValue,
262
+ accept,
263
+ multiple
264
+ }) {
265
+ const field$1 = core.useFormFoundryField({
266
+ name,
267
+ validation,
268
+ validationBehavior,
269
+ defaultValue,
270
+ disabled,
271
+ label: typeof label === "string" ? label : void 0,
272
+ inputType: "file"
273
+ });
274
+ return /* @__PURE__ */ jsxRuntime.jsxs(
275
+ field.Field.Root,
276
+ {
277
+ name,
278
+ invalid: !field$1.valid && field$1.touched,
279
+ disabled,
280
+ className: classNames?.outer,
281
+ "data-formfoundry": "file",
282
+ "data-touched": field$1.touched || void 0,
283
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
284
+ children: [
285
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
286
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames?.wrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
287
+ "input",
288
+ {
289
+ id: field$1.id,
290
+ type: "file",
291
+ accept,
292
+ multiple,
293
+ onChange: (e) => field$1.onChange(e.target.files),
294
+ onBlur: field$1.onBlur,
295
+ className: classNames?.input
296
+ }
297
+ ) }),
298
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
299
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
300
+ ]
301
+ }
302
+ );
303
+ }
304
+ function HiddenInput({
305
+ name,
306
+ validation,
307
+ defaultValue
308
+ }) {
309
+ const field = core.useFormFoundryField({
310
+ name,
311
+ validation,
312
+ defaultValue,
313
+ inputType: "hidden"
314
+ });
315
+ return /* @__PURE__ */ jsxRuntime.jsx(
316
+ "input",
317
+ {
318
+ type: "hidden",
319
+ id: field.id,
320
+ name,
321
+ value: field.value ?? ""
322
+ }
323
+ );
324
+ }
325
+ function NumberInput({
326
+ name,
327
+ label,
328
+ help,
329
+ validation,
330
+ validationBehavior,
331
+ classNames,
332
+ min,
333
+ max,
334
+ step,
335
+ placeholder,
336
+ disabled,
337
+ defaultValue
338
+ }) {
339
+ const field$1 = core.useFormFoundryField({
340
+ name,
341
+ validation,
342
+ validationBehavior,
343
+ defaultValue,
344
+ disabled,
345
+ label: typeof label === "string" ? label : void 0,
346
+ inputType: "number"
347
+ });
348
+ return /* @__PURE__ */ jsxRuntime.jsxs(
349
+ field.Field.Root,
350
+ {
351
+ name,
352
+ invalid: !field$1.valid && field$1.touched,
353
+ disabled,
354
+ className: classNames?.outer,
355
+ "data-formfoundry": "number",
356
+ "data-touched": field$1.touched || void 0,
357
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
358
+ children: [
359
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
360
+ /* @__PURE__ */ jsxRuntime.jsx(
361
+ numberField.NumberField.Root,
362
+ {
363
+ value: field$1.value,
364
+ onValueChange: (val) => field$1.onChange(val),
365
+ min,
366
+ max,
367
+ step,
368
+ children: /* @__PURE__ */ jsxRuntime.jsxs(numberField.NumberField.Group, { className: classNames?.wrapper, children: [
369
+ /* @__PURE__ */ jsxRuntime.jsx(numberField.NumberField.Decrement, { children: "\u2212" }),
370
+ /* @__PURE__ */ jsxRuntime.jsx(
371
+ numberField.NumberField.Input,
372
+ {
373
+ id: field$1.id,
374
+ onBlur: field$1.onBlur,
375
+ placeholder,
376
+ className: classNames?.input
377
+ }
378
+ ),
379
+ /* @__PURE__ */ jsxRuntime.jsx(numberField.NumberField.Increment, { children: "+" })
380
+ ] })
381
+ }
382
+ ),
383
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
384
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
385
+ ]
386
+ }
387
+ );
388
+ }
389
+ function normalizeOptions2(options) {
390
+ return options.map(
391
+ (opt) => typeof opt === "string" ? { label: opt, value: opt } : opt
392
+ );
393
+ }
394
+ function RadioInput({
395
+ name,
396
+ label,
397
+ help,
398
+ validation,
399
+ validationBehavior,
400
+ classNames,
401
+ options: rawOptions = [],
402
+ disabled,
403
+ defaultValue
404
+ }) {
405
+ const options = normalizeOptions2(rawOptions);
406
+ const field$1 = core.useFormFoundryField({
407
+ name,
408
+ validation,
409
+ validationBehavior,
410
+ defaultValue,
411
+ disabled,
412
+ label: typeof label === "string" ? label : void 0,
413
+ inputType: "radio",
414
+ selectOptions: options
415
+ });
416
+ return /* @__PURE__ */ jsxRuntime.jsxs(
417
+ field.Field.Root,
418
+ {
419
+ name,
420
+ invalid: !field$1.valid && field$1.touched,
421
+ disabled,
422
+ className: classNames?.outer,
423
+ "data-formfoundry": "radio",
424
+ "data-touched": field$1.touched || void 0,
425
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
426
+ children: [
427
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
428
+ /* @__PURE__ */ jsxRuntime.jsx(
429
+ radioGroup.RadioGroup,
430
+ {
431
+ value: field$1.value,
432
+ onValueChange: (val) => field$1.onChange(val),
433
+ className: classNames?.wrapper,
434
+ children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
435
+ "label",
436
+ {
437
+ style: { display: "flex", alignItems: "center", gap: "0.5rem" },
438
+ children: [
439
+ /* @__PURE__ */ jsxRuntime.jsx(
440
+ radio.Radio.Root,
441
+ {
442
+ value: opt.value,
443
+ onBlur: field$1.onBlur,
444
+ className: classNames?.input,
445
+ children: /* @__PURE__ */ jsxRuntime.jsx(radio.Radio.Indicator, {})
446
+ }
447
+ ),
448
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: opt.label })
449
+ ]
450
+ },
451
+ opt.value
452
+ ))
453
+ }
454
+ ),
455
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
456
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
457
+ ]
458
+ }
459
+ );
460
+ }
461
+ function normalizeOptions3(options) {
462
+ return options.map(
463
+ (opt) => typeof opt === "string" ? { label: opt, value: opt } : opt
464
+ );
465
+ }
466
+ function SelectInput({
467
+ name,
468
+ label,
469
+ help,
470
+ validation,
471
+ validationBehavior,
472
+ classNames,
473
+ options: rawOptions = [],
474
+ placeholder,
475
+ disabled,
476
+ defaultValue
477
+ }) {
478
+ const options = normalizeOptions3(rawOptions);
479
+ const field$1 = core.useFormFoundryField({
480
+ name,
481
+ validation,
482
+ validationBehavior,
483
+ defaultValue,
484
+ disabled,
485
+ label: typeof label === "string" ? label : void 0,
486
+ inputType: "select",
487
+ selectOptions: options
488
+ });
489
+ return /* @__PURE__ */ jsxRuntime.jsxs(
490
+ field.Field.Root,
491
+ {
492
+ name,
493
+ invalid: !field$1.valid && field$1.touched,
494
+ disabled,
495
+ className: classNames?.outer,
496
+ "data-formfoundry": "select",
497
+ "data-touched": field$1.touched || void 0,
498
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
499
+ children: [
500
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
501
+ /* @__PURE__ */ jsxRuntime.jsxs(
502
+ select.Select.Root,
503
+ {
504
+ value: String(field$1.value ?? ""),
505
+ onValueChange: (val) => field$1.onChange(val),
506
+ children: [
507
+ /* @__PURE__ */ jsxRuntime.jsx(
508
+ select.Select.Trigger,
509
+ {
510
+ id: field$1.id,
511
+ onBlur: field$1.onBlur,
512
+ className: classNames?.input,
513
+ children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.Value, { placeholder: placeholder ?? "Select..." })
514
+ }
515
+ ),
516
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.Positioner, { children: /* @__PURE__ */ jsxRuntime.jsx(select.Select.Popup, { className: classNames?.wrapper, children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(select.Select.Item, { value: opt.value, children: [
517
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemText, { children: opt.label }),
518
+ /* @__PURE__ */ jsxRuntime.jsx(select.Select.ItemIndicator, { children: "\u2713" })
519
+ ] }, opt.value)) }) }) })
520
+ ]
521
+ }
522
+ ),
523
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
524
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
525
+ ]
526
+ }
527
+ );
528
+ }
529
+ function SliderInput({
530
+ name,
531
+ label,
532
+ help,
533
+ validation,
534
+ validationBehavior,
535
+ classNames,
536
+ min = 0,
537
+ max = 100,
538
+ step = 1,
539
+ disabled,
540
+ defaultValue
541
+ }) {
542
+ const field$1 = core.useFormFoundryField({
543
+ name,
544
+ validation,
545
+ validationBehavior,
546
+ defaultValue: defaultValue ?? min,
547
+ disabled,
548
+ label: typeof label === "string" ? label : void 0,
549
+ inputType: "slider"
550
+ });
551
+ return /* @__PURE__ */ jsxRuntime.jsxs(
552
+ field.Field.Root,
553
+ {
554
+ name,
555
+ invalid: !field$1.valid && field$1.touched,
556
+ disabled,
557
+ className: classNames?.outer,
558
+ "data-formfoundry": "slider",
559
+ "data-touched": field$1.touched || void 0,
560
+ children: [
561
+ label && /* @__PURE__ */ jsxRuntime.jsxs(field.Field.Label, { className: classNames?.label, children: [
562
+ label,
563
+ " ",
564
+ field$1.value !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
565
+ "(",
566
+ String(field$1.value),
567
+ ")"
568
+ ] })
569
+ ] }),
570
+ /* @__PURE__ */ jsxRuntime.jsx(
571
+ slider.Slider.Root,
572
+ {
573
+ value: field$1.value ?? min,
574
+ onValueChange: (val) => field$1.onChange(val),
575
+ onValueCommitted: () => field$1.onBlur(),
576
+ min,
577
+ max,
578
+ step,
579
+ className: classNames?.wrapper,
580
+ children: /* @__PURE__ */ jsxRuntime.jsx(slider.Slider.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs(slider.Slider.Track, { className: classNames?.input, children: [
581
+ /* @__PURE__ */ jsxRuntime.jsx(slider.Slider.Indicator, {}),
582
+ /* @__PURE__ */ jsxRuntime.jsx(slider.Slider.Thumb, { id: field$1.id })
583
+ ] }) })
584
+ }
585
+ ),
586
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
587
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
588
+ ]
589
+ }
590
+ );
591
+ }
592
+ function SubmitInput({
593
+ label,
594
+ submittingLabel,
595
+ disabled,
596
+ classNames
597
+ }) {
598
+ const meta = core.useFormMeta();
599
+ return /* @__PURE__ */ jsxRuntime.jsx(
600
+ "div",
601
+ {
602
+ className: classNames?.outer,
603
+ "data-formfoundry": "submit",
604
+ children: /* @__PURE__ */ jsxRuntime.jsx(
605
+ "button",
606
+ {
607
+ type: "submit",
608
+ disabled: disabled || meta.isSubmitting,
609
+ className: classNames?.input,
610
+ children: meta.isSubmitting ? submittingLabel ?? "Submitting\u2026" : label ?? "Submit"
611
+ }
612
+ )
613
+ }
614
+ );
615
+ }
616
+ function SwitchInput({
617
+ name,
618
+ label,
619
+ help,
620
+ validation,
621
+ validationBehavior,
622
+ classNames,
623
+ disabled,
624
+ defaultValue
625
+ }) {
626
+ const field$1 = core.useFormFoundryField({
627
+ name,
628
+ validation,
629
+ validationBehavior,
630
+ defaultValue: defaultValue ?? false,
631
+ disabled,
632
+ label: typeof label === "string" ? label : void 0,
633
+ inputType: "switch"
634
+ });
635
+ return /* @__PURE__ */ jsxRuntime.jsxs(
636
+ field.Field.Root,
637
+ {
638
+ name,
639
+ invalid: !field$1.valid && field$1.touched,
640
+ disabled,
641
+ className: classNames?.outer,
642
+ "data-formfoundry": "switch",
643
+ "data-touched": field$1.touched || void 0,
644
+ children: [
645
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.wrapper, style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
646
+ /* @__PURE__ */ jsxRuntime.jsx(
647
+ _switch.Switch.Root,
648
+ {
649
+ id: field$1.id,
650
+ checked: !!field$1.value,
651
+ onCheckedChange: (checked) => field$1.onChange(checked),
652
+ onBlur: field$1.onBlur,
653
+ className: classNames?.input,
654
+ children: /* @__PURE__ */ jsxRuntime.jsx(_switch.Switch.Thumb, {})
655
+ }
656
+ ),
657
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label })
658
+ ] }),
659
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
660
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
661
+ ]
662
+ }
663
+ );
664
+ }
665
+ function TextInput({
666
+ name,
667
+ label,
668
+ help,
669
+ validation,
670
+ validationBehavior,
671
+ classNames,
672
+ type = "text",
673
+ placeholder,
674
+ disabled,
675
+ defaultValue
676
+ }) {
677
+ const field$1 = core.useFormFoundryField({
678
+ name,
679
+ validation,
680
+ validationBehavior,
681
+ defaultValue,
682
+ disabled,
683
+ label: typeof label === "string" ? label : void 0,
684
+ inputType: type ?? "text"
685
+ });
686
+ return /* @__PURE__ */ jsxRuntime.jsxs(
687
+ field.Field.Root,
688
+ {
689
+ name,
690
+ invalid: !field$1.valid && field$1.touched,
691
+ disabled,
692
+ className: classNames?.outer,
693
+ "data-formfoundry": "text",
694
+ "data-touched": field$1.touched || void 0,
695
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
696
+ "data-dirty": field$1.dirty || void 0,
697
+ children: [
698
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
699
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames?.wrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
700
+ input.Input,
701
+ {
702
+ id: field$1.id,
703
+ type,
704
+ value: field$1.value ?? "",
705
+ onChange: (e) => field$1.onChange(e.target.value),
706
+ onBlur: field$1.onBlur,
707
+ placeholder,
708
+ className: classNames?.input
709
+ }
710
+ ) }),
711
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
712
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
713
+ ]
714
+ }
715
+ );
716
+ }
717
+ function TextareaInput({
718
+ name,
719
+ label,
720
+ help,
721
+ validation,
722
+ validationBehavior,
723
+ classNames,
724
+ placeholder,
725
+ disabled,
726
+ defaultValue,
727
+ rows = 3,
728
+ cols
729
+ }) {
730
+ const field$1 = core.useFormFoundryField({
731
+ name,
732
+ validation,
733
+ validationBehavior,
734
+ defaultValue,
735
+ disabled,
736
+ label: typeof label === "string" ? label : void 0,
737
+ inputType: "textarea"
738
+ });
739
+ return /* @__PURE__ */ jsxRuntime.jsxs(
740
+ field.Field.Root,
741
+ {
742
+ name,
743
+ invalid: !field$1.valid && field$1.touched,
744
+ disabled,
745
+ className: classNames?.outer,
746
+ "data-formfoundry": "textarea",
747
+ "data-touched": field$1.touched || void 0,
748
+ "data-invalid": !field$1.valid && field$1.touched || void 0,
749
+ children: [
750
+ label && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Label, { className: classNames?.label, children: label }),
751
+ /* @__PURE__ */ jsxRuntime.jsx(
752
+ field.Field.Control,
753
+ {
754
+ render: /* @__PURE__ */ jsxRuntime.jsx(
755
+ "textarea",
756
+ {
757
+ id: field$1.id,
758
+ value: field$1.value ?? "",
759
+ onChange: (e) => field$1.onChange(e.target.value),
760
+ onBlur: field$1.onBlur,
761
+ placeholder,
762
+ rows,
763
+ cols,
764
+ className: classNames?.input
765
+ }
766
+ )
767
+ }
768
+ ),
769
+ help && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Description, { className: classNames?.help, children: help }),
770
+ field$1.error && /* @__PURE__ */ jsxRuntime.jsx(field.Field.Error, { className: classNames?.message, children: field$1.error })
771
+ ]
772
+ }
773
+ );
774
+ }
775
+ function createBaseUIRegistry() {
776
+ return core.createRegistry({
777
+ text: TextInput,
778
+ email: TextInput,
779
+ password: TextInput,
780
+ url: TextInput,
781
+ tel: TextInput,
782
+ number: NumberInput,
783
+ textarea: TextareaInput,
784
+ select: SelectInput,
785
+ checkbox: CheckboxInput,
786
+ checkboxGroup: CheckboxGroupInput,
787
+ switch: SwitchInput,
788
+ radio: RadioInput,
789
+ slider: SliderInput,
790
+ button: ButtonInput,
791
+ submit: SubmitInput,
792
+ hidden: HiddenInput,
793
+ file: FileInput,
794
+ color: ColorInput,
795
+ date: DateInput,
796
+ "datetime-local": DateInput,
797
+ time: DateInput,
798
+ month: DateInput,
799
+ week: DateInput
800
+ });
801
+ }
802
+
803
+ // src/adapter.ts
804
+ var baseUIAdapter = {
805
+ name: "baseui",
806
+ createRegistry: createBaseUIRegistry
807
+ };
808
+
809
+ exports.ButtonInput = ButtonInput;
810
+ exports.CheckboxGroupInput = CheckboxGroupInput;
811
+ exports.CheckboxInput = CheckboxInput;
812
+ exports.ColorInput = ColorInput;
813
+ exports.DateInput = DateInput;
814
+ exports.FileInput = FileInput;
815
+ exports.HiddenInput = HiddenInput;
816
+ exports.NumberInput = NumberInput;
817
+ exports.RadioInput = RadioInput;
818
+ exports.SelectInput = SelectInput;
819
+ exports.SliderInput = SliderInput;
820
+ exports.SubmitInput = SubmitInput;
821
+ exports.SwitchInput = SwitchInput;
822
+ exports.TextInput = TextInput;
823
+ exports.TextareaInput = TextareaInput;
824
+ exports.baseUIAdapter = baseUIAdapter;
825
+ exports.createBaseUIRegistry = createBaseUIRegistry;
826
+ //# sourceMappingURL=index.cjs.map
827
+ //# sourceMappingURL=index.cjs.map