@knkcs/anker 0.0.1

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.
Files changed (39) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +129 -0
  3. package/dist/atoms/index.d.ts +536 -0
  4. package/dist/atoms/index.js +845 -0
  5. package/dist/atoms/index.js.map +1 -0
  6. package/dist/avatar-DhqkKdqc.d.ts +29 -0
  7. package/dist/chunk-4D3EY2W2.js +1628 -0
  8. package/dist/chunk-4D3EY2W2.js.map +1 -0
  9. package/dist/chunk-4T32UC26.js +81 -0
  10. package/dist/chunk-4T32UC26.js.map +1 -0
  11. package/dist/chunk-FGKGX4UF.js +36 -0
  12. package/dist/chunk-FGKGX4UF.js.map +1 -0
  13. package/dist/chunk-PZCL4M6I.js +62 -0
  14. package/dist/chunk-PZCL4M6I.js.map +1 -0
  15. package/dist/chunk-QSCNXHMU.js +32 -0
  16. package/dist/chunk-QSCNXHMU.js.map +1 -0
  17. package/dist/chunk-RJPEVNMJ.js +23 -0
  18. package/dist/chunk-RJPEVNMJ.js.map +1 -0
  19. package/dist/chunk-YXTW5OAJ.js +303 -0
  20. package/dist/chunk-YXTW5OAJ.js.map +1 -0
  21. package/dist/components/index.d.ts +413 -0
  22. package/dist/components/index.js +982 -0
  23. package/dist/components/index.js.map +1 -0
  24. package/dist/feedback/index.d.ts +27 -0
  25. package/dist/feedback/index.js +100 -0
  26. package/dist/feedback/index.js.map +1 -0
  27. package/dist/forms/index.d.ts +272 -0
  28. package/dist/forms/index.js +947 -0
  29. package/dist/forms/index.js.map +1 -0
  30. package/dist/number-input-D2X0rWOg.d.ts +18 -0
  31. package/dist/primitives/index.d.ts +396 -0
  32. package/dist/primitives/index.js +478 -0
  33. package/dist/primitives/index.js.map +1 -0
  34. package/dist/search-input-C_Cl2OEx.d.ts +17 -0
  35. package/dist/switch-B0o6G2XE.d.ts +28 -0
  36. package/dist/theme/index.d.ts +496 -0
  37. package/dist/theme/index.js +3 -0
  38. package/dist/theme/index.js.map +1 -0
  39. package/package.json +96 -0
@@ -0,0 +1,947 @@
1
+ import { LeavePageConfirmation, NumberInputRoot, NumberInputField, Radio } from '../chunk-4T32UC26.js';
2
+ import { Switch } from '../chunk-RJPEVNMJ.js';
3
+ import { text_input_default } from '../chunk-PZCL4M6I.js';
4
+ export { SearchInput } from '../chunk-PZCL4M6I.js';
5
+ import { Stack, Grid, GridItem, Text, Input, IconButton, Box, ButtonGroup, Button, Field, HStack, Checkbox, Popover, Square, Editable, Flex, RadioGroup, Menu, Portal, NativeSelect, Textarea, useEditableContext } from '@chakra-ui/react';
6
+ import { Trash2, Plus, Upload, ChevronDown, Pencil } from 'lucide-react';
7
+ import React, { useId, useCallback, useEffect } from 'react';
8
+ import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
9
+ import { jsxs, jsx } from 'react/jsx-runtime';
10
+ import { useBlocker } from 'react-router-dom';
11
+
12
+ function FormField({
13
+ name,
14
+ label,
15
+ helperText,
16
+ description,
17
+ required,
18
+ disabled,
19
+ readOnly,
20
+ actions,
21
+ children
22
+ }) {
23
+ const { control } = useFormContext();
24
+ const uid = useId();
25
+ const descriptionId = `${uid}-description`;
26
+ const helperId = `${uid}-helper`;
27
+ const errorId = `${uid}-error`;
28
+ return /* @__PURE__ */ jsx(
29
+ Controller,
30
+ {
31
+ name,
32
+ control,
33
+ render: ({ field, fieldState }) => {
34
+ const describedBy = [
35
+ description ? descriptionId : null,
36
+ helperText ? helperId : null,
37
+ fieldState.error ? errorId : null
38
+ ].filter(Boolean).join(" ") || void 0;
39
+ return /* @__PURE__ */ jsxs(
40
+ Field.Root,
41
+ {
42
+ invalid: !!fieldState.error,
43
+ required,
44
+ disabled,
45
+ readOnly,
46
+ children: [
47
+ label && (typeof label === "string" ? /* @__PURE__ */ jsxs(HStack, { children: [
48
+ /* @__PURE__ */ jsx(Field.Label, { flex: "1", htmlFor: name, children: label }),
49
+ actions
50
+ ] }) : label),
51
+ children({ ...field, "aria-describedby": describedBy }),
52
+ description && /* @__PURE__ */ jsx(Text, { id: descriptionId, fontSize: "xs", color: "muted", children: description }),
53
+ helperText && (typeof helperText === "string" ? /* @__PURE__ */ jsx(Field.HelperText, { id: helperId, children: helperText }) : /* @__PURE__ */ jsx("span", { id: helperId, children: helperText })),
54
+ fieldState.error && /* @__PURE__ */ jsx(Field.ErrorText, { id: errorId, "aria-live": "polite", children: fieldState.error.message })
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ }
60
+ );
61
+ }
62
+ FormField.displayName = "FormField";
63
+ function ArrayField(props) {
64
+ const {
65
+ name,
66
+ label,
67
+ mode = "dynamic",
68
+ valueHeader = "Value",
69
+ keyHeader = "Key",
70
+ keys = [],
71
+ addLabel = "Add Field",
72
+ removeLabel = "Remove Item",
73
+ readOnly,
74
+ emptyState,
75
+ ...rest
76
+ } = props;
77
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (_field) => /* @__PURE__ */ jsx(Box, { py: 4, px: 4, bg: "bg", rounded: "md", children: mode === "dynamic" ? /* @__PURE__ */ jsx(
78
+ DynamicArray,
79
+ {
80
+ name,
81
+ valueHeader,
82
+ keyHeader,
83
+ addLabel,
84
+ removeLabel,
85
+ readOnly,
86
+ emptyState
87
+ }
88
+ ) : /* @__PURE__ */ jsx(
89
+ KeyedArray,
90
+ {
91
+ name,
92
+ valueHeader,
93
+ keyHeader,
94
+ keys,
95
+ readOnly
96
+ }
97
+ ) }) });
98
+ }
99
+ ArrayField.displayName = "ArrayField";
100
+ var DynamicArray = React.memo((props) => {
101
+ const {
102
+ name,
103
+ valueHeader,
104
+ keyHeader,
105
+ addLabel,
106
+ removeLabel,
107
+ readOnly,
108
+ emptyState
109
+ } = props;
110
+ const { control, register } = useFormContext();
111
+ const { fields, append, remove } = useFieldArray({
112
+ control,
113
+ name
114
+ });
115
+ return /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
116
+ /* @__PURE__ */ jsxs(Grid, { templateColumns: "200px 1fr 50px", gap: 2, children: [
117
+ /* @__PURE__ */ jsx(GridItem, { children: /* @__PURE__ */ jsx(Text, { fontWeight: 500, children: keyHeader }) }),
118
+ /* @__PURE__ */ jsx(GridItem, { colSpan: 2, children: /* @__PURE__ */ jsx(Text, { fontWeight: 500, children: valueHeader }) }),
119
+ fields.map((item, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
120
+ /* @__PURE__ */ jsx(
121
+ Input,
122
+ {
123
+ ...register(`${name}.${index}.key`),
124
+ readOnly
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx(
128
+ Input,
129
+ {
130
+ ...register(`${name}.${index}.value`),
131
+ readOnly
132
+ }
133
+ ),
134
+ /* @__PURE__ */ jsx(
135
+ IconButton,
136
+ {
137
+ size: "sm",
138
+ variant: "ghost",
139
+ colorPalette: "red",
140
+ "aria-label": removeLabel,
141
+ onClick: () => remove(index),
142
+ disabled: readOnly,
143
+ children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
144
+ }
145
+ )
146
+ ] }, item.id))
147
+ ] }),
148
+ fields.length === 0 && emptyState && /* @__PURE__ */ jsx(Box, { py: 4, textAlign: "center", children: emptyState }),
149
+ /* @__PURE__ */ jsx(ButtonGroup, { children: /* @__PURE__ */ jsxs(
150
+ Button,
151
+ {
152
+ variant: "outline",
153
+ size: "sm",
154
+ onClick: () => append({ key: "", value: "" }),
155
+ disabled: readOnly,
156
+ children: [
157
+ /* @__PURE__ */ jsx(Plus, { size: 16 }),
158
+ addLabel
159
+ ]
160
+ }
161
+ ) })
162
+ ] });
163
+ });
164
+ DynamicArray.displayName = "DynamicArray";
165
+ var KeyedArray = React.memo((props) => {
166
+ const { name, valueHeader, keyHeader, keys, readOnly } = props;
167
+ const { register } = useFormContext();
168
+ return /* @__PURE__ */ jsx(Stack, { gap: 4, children: /* @__PURE__ */ jsxs(Grid, { templateColumns: "200px 1fr", gap: 2, children: [
169
+ /* @__PURE__ */ jsx(GridItem, { children: /* @__PURE__ */ jsx(Text, { fontWeight: 500, children: keyHeader }) }),
170
+ /* @__PURE__ */ jsx(GridItem, { children: /* @__PURE__ */ jsx(Text, { fontWeight: 500, children: valueHeader }) }),
171
+ keys.map((keyItem) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
172
+ /* @__PURE__ */ jsx(Text, { py: 2, children: keyItem.value ?? keyItem.key }),
173
+ /* @__PURE__ */ jsx(
174
+ Input,
175
+ {
176
+ ...register(`${name}.${keyItem.key}`),
177
+ readOnly
178
+ }
179
+ )
180
+ ] }, keyItem.key))
181
+ ] }) });
182
+ });
183
+ KeyedArray.displayName = "KeyedArray";
184
+ function CheckboxField({
185
+ ref,
186
+ ...props
187
+ }) {
188
+ const { name, label, value, disabled, children } = props;
189
+ const { control } = useFormContext();
190
+ return /* @__PURE__ */ jsx(
191
+ Controller,
192
+ {
193
+ name,
194
+ control,
195
+ render: ({ field, fieldState }) => {
196
+ const isArrayMode = value !== void 0;
197
+ const isChecked = isArrayMode ? Array.isArray(field.value) && field.value.includes(value) : !!field.value;
198
+ const handleCheckedChange = (details) => {
199
+ if (isArrayMode) {
200
+ const currentValue = Array.isArray(field.value) ? [...field.value] : [];
201
+ if (details.checked) {
202
+ if (!currentValue.includes(value)) {
203
+ currentValue.push(value);
204
+ }
205
+ } else {
206
+ const idx = currentValue.indexOf(value);
207
+ if (idx > -1) currentValue.splice(idx, 1);
208
+ }
209
+ field.onChange(currentValue);
210
+ } else {
211
+ field.onChange(!!details.checked);
212
+ }
213
+ };
214
+ const uniqueId = isArrayMode ? `${name}-${String(value)}` : name;
215
+ return /* @__PURE__ */ jsxs(
216
+ Checkbox.Root,
217
+ {
218
+ id: uniqueId,
219
+ name: field.name,
220
+ value: isArrayMode ? String(value) : void 0,
221
+ invalid: !!fieldState.error,
222
+ ref,
223
+ checked: isChecked,
224
+ onCheckedChange: handleCheckedChange,
225
+ onBlur: field.onBlur,
226
+ disabled,
227
+ children: [
228
+ /* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
229
+ /* @__PURE__ */ jsx(Checkbox.Control, { children: /* @__PURE__ */ jsx(Checkbox.Indicator, {}) }),
230
+ (label || children) && /* @__PURE__ */ jsxs(Checkbox.Label, { children: [
231
+ label,
232
+ children
233
+ ] })
234
+ ]
235
+ }
236
+ );
237
+ }
238
+ }
239
+ );
240
+ }
241
+ CheckboxField.displayName = "CheckboxField";
242
+ function CodeField({
243
+ ref,
244
+ ...props
245
+ }) {
246
+ const {
247
+ name,
248
+ label,
249
+ language = "typescript",
250
+ height = "400px",
251
+ indentWithTab = true,
252
+ readOnly,
253
+ Editor,
254
+ ...rest
255
+ } = props;
256
+ const onMount = useCallback(
257
+ (editorInstance, _monaco) => {
258
+ if (typeof ref === "function") {
259
+ ref(editorInstance);
260
+ } else if (ref && typeof ref === "object") {
261
+ ref.current = editorInstance;
262
+ }
263
+ editorInstance.updateOptions?.({
264
+ tabCompletion: indentWithTab ? "on" : "off"
265
+ });
266
+ },
267
+ [ref, indentWithTab]
268
+ );
269
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (field) => Editor ? /* @__PURE__ */ jsx(
270
+ Editor,
271
+ {
272
+ value: field.value,
273
+ language,
274
+ onChange: (value) => field.onChange(value ?? ""),
275
+ onMount,
276
+ height,
277
+ options: {
278
+ readOnly,
279
+ wordWrap: "on",
280
+ minimap: { enabled: false },
281
+ scrollBeyondLastLine: false,
282
+ tabCompletion: indentWithTab ? "on" : "off"
283
+ }
284
+ }
285
+ ) : /* @__PURE__ */ jsx(
286
+ "textarea",
287
+ {
288
+ value: field.value ?? "",
289
+ onChange: (e) => field.onChange(e.target.value),
290
+ onBlur: field.onBlur,
291
+ readOnly,
292
+ style: {
293
+ fontFamily: "monospace",
294
+ fontSize: "0.875rem",
295
+ padding: "0.75rem",
296
+ border: "1px solid var(--chakra-colors-border)",
297
+ borderRadius: "0.375rem",
298
+ width: "100%",
299
+ minHeight: height,
300
+ resize: "vertical"
301
+ }
302
+ }
303
+ ) });
304
+ }
305
+ CodeField.displayName = "CodeField";
306
+ function ColorPickerField({
307
+ ref,
308
+ ...props
309
+ }) {
310
+ const { name, label, size = "md", readOnly, ColorPicker, ...rest } = props;
311
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (field) => /* @__PURE__ */ jsxs(Popover.Root, { children: [
312
+ /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
313
+ IconButton,
314
+ {
315
+ ref,
316
+ size,
317
+ w: "fit-content",
318
+ borderWidth: "1px",
319
+ rounded: "md",
320
+ p: 1,
321
+ variant: "outline",
322
+ disabled: readOnly,
323
+ "aria-label": `Color: ${field.value || "none"}`,
324
+ children: /* @__PURE__ */ jsx(Square, { rounded: "sm", bg: field.value, size: 6 })
325
+ }
326
+ ) }),
327
+ /* @__PURE__ */ jsx(Popover.Positioner, { children: /* @__PURE__ */ jsxs(Popover.Content, { width: "auto", children: [
328
+ /* @__PURE__ */ jsx(Popover.Arrow, {}),
329
+ /* @__PURE__ */ jsx(Popover.Body, { children: ColorPicker ? /* @__PURE__ */ jsx(
330
+ ColorPicker,
331
+ {
332
+ color: field.value,
333
+ onChange: (color) => field.onChange(color)
334
+ }
335
+ ) : /* @__PURE__ */ jsx(
336
+ "input",
337
+ {
338
+ type: "color",
339
+ value: field.value || "#000000",
340
+ onChange: (e) => field.onChange(e.target.value),
341
+ style: {
342
+ width: 200,
343
+ height: 200,
344
+ border: "none",
345
+ cursor: "pointer"
346
+ }
347
+ }
348
+ ) })
349
+ ] }) })
350
+ ] }) });
351
+ }
352
+ ColorPickerField.displayName = "ColorPickerField";
353
+ var ControlledFormField = ({
354
+ name,
355
+ label,
356
+ helperText,
357
+ errorMessage,
358
+ required,
359
+ disabled,
360
+ readOnly,
361
+ actions,
362
+ children
363
+ }) => {
364
+ const uid = useId();
365
+ const helperId = `${uid}-helper`;
366
+ const errorId = `${uid}-error`;
367
+ return /* @__PURE__ */ jsxs(
368
+ Field.Root,
369
+ {
370
+ invalid: !!errorMessage,
371
+ required,
372
+ disabled,
373
+ readOnly,
374
+ children: [
375
+ label && (typeof label === "string" ? /* @__PURE__ */ jsxs(HStack, { children: [
376
+ /* @__PURE__ */ jsx(Field.Label, { flex: "1", htmlFor: name, children: label }),
377
+ actions
378
+ ] }) : label),
379
+ children,
380
+ helperText && (typeof helperText === "string" ? /* @__PURE__ */ jsx(Field.HelperText, { id: helperId, children: helperText }) : /* @__PURE__ */ jsx("span", { id: helperId, children: helperText })),
381
+ errorMessage && /* @__PURE__ */ jsx(Field.ErrorText, { id: errorId, "aria-live": "polite", children: errorMessage })
382
+ ]
383
+ }
384
+ );
385
+ };
386
+ ControlledFormField.displayName = "ControlledFormField";
387
+ function DatePickerField({
388
+ ref,
389
+ ...props
390
+ }) {
391
+ const {
392
+ name,
393
+ label,
394
+ min,
395
+ max,
396
+ type = "date",
397
+ readOnly,
398
+ disabled,
399
+ ...rest
400
+ } = props;
401
+ return /* @__PURE__ */ jsx(
402
+ FormField,
403
+ {
404
+ name,
405
+ label,
406
+ readOnly,
407
+ disabled,
408
+ ...rest,
409
+ children: (field) => /* @__PURE__ */ jsx(
410
+ Input,
411
+ {
412
+ ...field,
413
+ value: field.value ?? "",
414
+ type,
415
+ id: name,
416
+ min,
417
+ max,
418
+ readOnly,
419
+ disabled,
420
+ ref
421
+ }
422
+ )
423
+ }
424
+ );
425
+ }
426
+ DatePickerField.displayName = "DatePickerField";
427
+ var DirtyFormGuard = ({
428
+ title,
429
+ message,
430
+ confirmLabel,
431
+ cancelLabel
432
+ }) => {
433
+ const { formState } = useFormContext();
434
+ const blocker = useBlocker(formState.isDirty);
435
+ return /* @__PURE__ */ jsx(
436
+ LeavePageConfirmation,
437
+ {
438
+ blocked: blocker.state === "blocked",
439
+ onConfirmLeave: () => blocker.proceed?.(),
440
+ onCancelLeave: () => blocker.reset?.(),
441
+ title,
442
+ message,
443
+ confirmLabel,
444
+ cancelLabel
445
+ }
446
+ );
447
+ };
448
+ DirtyFormGuard.displayName = "DirtyFormGuard";
449
+ var EditableControls = ({ editLabel }) => {
450
+ const { editing } = useEditableContext();
451
+ if (editing) return null;
452
+ return /* @__PURE__ */ jsx(ButtonGroup, { children: /* @__PURE__ */ jsx(Editable.EditTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
453
+ IconButton,
454
+ {
455
+ variant: "ghost",
456
+ marginInlineStart: 2,
457
+ "aria-label": editLabel,
458
+ children: /* @__PURE__ */ jsx(Pencil, { size: 20 })
459
+ }
460
+ ) }) });
461
+ };
462
+ var EditableHeading = ({
463
+ value,
464
+ onChange,
465
+ onCancel,
466
+ onSubmit,
467
+ editLabel = "Edit",
468
+ fontSize = "3xl",
469
+ maxW = "lg"
470
+ }) => {
471
+ return /* @__PURE__ */ jsxs(
472
+ Editable.Root,
473
+ {
474
+ fontSize,
475
+ maxW,
476
+ value: String(value ?? ""),
477
+ onValueChange: (details) => onChange?.(details.value),
478
+ onValueRevert: (details) => onCancel?.(details.value),
479
+ onValueCommit: (details) => onSubmit?.(details.value),
480
+ children: [
481
+ /* @__PURE__ */ jsx(Editable.Preview, {}),
482
+ /* @__PURE__ */ jsx(Editable.Input, {}),
483
+ /* @__PURE__ */ jsx(EditableControls, { editLabel })
484
+ ]
485
+ }
486
+ );
487
+ };
488
+ EditableHeading.displayName = "EditableHeading";
489
+ function FileField(props) {
490
+ const {
491
+ name,
492
+ label,
493
+ accept,
494
+ multiple = false,
495
+ disabled,
496
+ dragActiveText = "Release to upload",
497
+ dropHintText = "Drag & drop a file to upload",
498
+ buttonLabel = "Choose File",
499
+ useDropzone,
500
+ ...rest
501
+ } = props;
502
+ return /* @__PURE__ */ jsx(FormField, { name, label, disabled, ...rest, children: (field) => {
503
+ if (useDropzone) {
504
+ return /* @__PURE__ */ jsx(
505
+ DropzoneContent,
506
+ {
507
+ field,
508
+ accept,
509
+ multiple,
510
+ disabled,
511
+ dragActiveText,
512
+ dropHintText,
513
+ buttonLabel,
514
+ useDropzone
515
+ }
516
+ );
517
+ }
518
+ return /* @__PURE__ */ jsxs(Box, { children: [
519
+ /* @__PURE__ */ jsx(
520
+ "input",
521
+ {
522
+ type: "file",
523
+ accept: accept ? Object.values(accept).flat().join(",") : void 0,
524
+ multiple,
525
+ disabled,
526
+ onChange: (e) => {
527
+ const files = e.target.files;
528
+ if (!files) return;
529
+ if (multiple) {
530
+ field.onChange(Array.from(files));
531
+ } else {
532
+ field.onChange(files[0] || null);
533
+ }
534
+ }
535
+ }
536
+ ),
537
+ field.value && /* @__PURE__ */ jsx(Text, { mt: 2, fontSize: "sm", color: "fg.muted", children: field.value?.name ?? "File selected" })
538
+ ] });
539
+ } });
540
+ }
541
+ FileField.displayName = "FileField";
542
+ var DropzoneContent = ({
543
+ field,
544
+ accept,
545
+ multiple,
546
+ disabled,
547
+ dragActiveText,
548
+ dropHintText,
549
+ buttonLabel,
550
+ useDropzone
551
+ }) => {
552
+ const handleDrop = useCallback(
553
+ (files) => {
554
+ if (multiple) {
555
+ field.onChange(files);
556
+ } else {
557
+ const file = files[0];
558
+ if (file) {
559
+ field.onChange(
560
+ Object.assign(file, {
561
+ preview: URL.createObjectURL(file)
562
+ })
563
+ );
564
+ }
565
+ }
566
+ },
567
+ [field, multiple]
568
+ );
569
+ useEffect(() => {
570
+ return () => {
571
+ if (field.value?.preview) {
572
+ URL.revokeObjectURL(field.value.preview);
573
+ }
574
+ };
575
+ }, [field.value]);
576
+ const { getRootProps, getInputProps, isDragActive, open } = useDropzone({
577
+ noClick: true,
578
+ multiple,
579
+ disabled,
580
+ accept,
581
+ onDrop: handleDrop
582
+ });
583
+ return /* @__PURE__ */ jsxs(Box, { ...getRootProps(), children: [
584
+ /* @__PURE__ */ jsx(Box, { display: "none", ...getInputProps(), asChild: true, children: /* @__PURE__ */ jsx("input", {}) }),
585
+ /* @__PURE__ */ jsxs(
586
+ Box,
587
+ {
588
+ bgColor: "bg.muted",
589
+ p: 4,
590
+ rounded: "md",
591
+ overflow: "hidden",
592
+ position: "relative",
593
+ textAlign: "center",
594
+ children: [
595
+ isDragActive && /* @__PURE__ */ jsxs(
596
+ Flex,
597
+ {
598
+ pointerEvents: "none",
599
+ top: "0",
600
+ insetInlineStart: "0",
601
+ position: "absolute",
602
+ backgroundColor: "blackAlpha.400",
603
+ width: "100%",
604
+ height: "100%",
605
+ zIndex: 1,
606
+ alignItems: "center",
607
+ justifyContent: "center",
608
+ direction: "column",
609
+ color: "white",
610
+ gap: "3",
611
+ children: [
612
+ /* @__PURE__ */ jsx(Upload, { size: 48 }),
613
+ /* @__PURE__ */ jsx(Text, { fontSize: "lg", fontWeight: "bold", children: dragActiveText })
614
+ ]
615
+ }
616
+ ),
617
+ field.value?.name && /* @__PURE__ */ jsx(Text, { fontSize: "sm", color: "fg.muted", children: field.value.name }),
618
+ /* @__PURE__ */ jsx(Text, { color: "fg.muted", fontSize: "xs", mt: 2, children: dropHintText }),
619
+ /* @__PURE__ */ jsxs(Button, { mt: 2, size: "sm", variant: "outline", onClick: open, children: [
620
+ /* @__PURE__ */ jsx(Upload, { size: 14 }),
621
+ buttonLabel
622
+ ] })
623
+ ]
624
+ }
625
+ )
626
+ ] });
627
+ };
628
+ function InputField({
629
+ ref,
630
+ ...props
631
+ }) {
632
+ const {
633
+ name,
634
+ label,
635
+ placeholder,
636
+ type,
637
+ append,
638
+ prepend,
639
+ inputProps,
640
+ readOnly,
641
+ disabled,
642
+ ...rest
643
+ } = props;
644
+ return /* @__PURE__ */ jsx(
645
+ FormField,
646
+ {
647
+ name,
648
+ label,
649
+ readOnly,
650
+ disabled,
651
+ ...rest,
652
+ children: (field) => /* @__PURE__ */ jsx(
653
+ text_input_default,
654
+ {
655
+ ...field,
656
+ value: field.value ?? "",
657
+ id: name,
658
+ placeholder,
659
+ type,
660
+ append,
661
+ prepend,
662
+ readOnly,
663
+ disabled,
664
+ opacity: readOnly ? 0.8 : 1,
665
+ ref,
666
+ ...inputProps
667
+ }
668
+ )
669
+ }
670
+ );
671
+ }
672
+ InputField.displayName = "InputField";
673
+ function MarkdownField(props) {
674
+ const {
675
+ name,
676
+ label,
677
+ readOnly,
678
+ MDEditor,
679
+ minHeight = 200,
680
+ maxHeight = 600,
681
+ ...rest
682
+ } = props;
683
+ return /* @__PURE__ */ jsx(FormField, { name, label, readOnly, ...rest, children: (field) => {
684
+ if (MDEditor) {
685
+ if (readOnly && MDEditor.Markdown) {
686
+ return /* @__PURE__ */ jsx(MDEditor.Markdown, { source: field.value });
687
+ }
688
+ return /* @__PURE__ */ jsx(
689
+ MDEditor,
690
+ {
691
+ value: field.value,
692
+ onChange: (value) => field.onChange(value ?? ""),
693
+ minHeight,
694
+ maxHeight,
695
+ visibleDragbar: true
696
+ }
697
+ );
698
+ }
699
+ return /* @__PURE__ */ jsx(
700
+ "textarea",
701
+ {
702
+ value: field.value ?? "",
703
+ onChange: (e) => field.onChange(e.target.value),
704
+ onBlur: field.onBlur,
705
+ readOnly,
706
+ style: {
707
+ padding: "0.75rem",
708
+ border: "1px solid var(--chakra-colors-border)",
709
+ borderRadius: "0.375rem",
710
+ width: "100%",
711
+ minHeight: `${minHeight}px`,
712
+ resize: "vertical"
713
+ }
714
+ }
715
+ );
716
+ } });
717
+ }
718
+ MarkdownField.displayName = "MarkdownField";
719
+ function NumberInputField2({
720
+ ref,
721
+ ...props
722
+ }) {
723
+ const {
724
+ name,
725
+ label,
726
+ min,
727
+ max,
728
+ step,
729
+ showStepper = true,
730
+ numberInputProps,
731
+ readOnly,
732
+ disabled,
733
+ ...rest
734
+ } = props;
735
+ return /* @__PURE__ */ jsx(
736
+ FormField,
737
+ {
738
+ name,
739
+ label,
740
+ readOnly,
741
+ disabled,
742
+ ...rest,
743
+ children: (field) => /* @__PURE__ */ jsx(
744
+ NumberInputRoot,
745
+ {
746
+ min,
747
+ max,
748
+ step,
749
+ value: String(field.value ?? 0),
750
+ onValueChange: (details) => {
751
+ field.onChange(
752
+ details.value === "" ? 0 : Number.parseFloat(details.value)
753
+ );
754
+ },
755
+ id: name,
756
+ readOnly,
757
+ disabled,
758
+ showStepper: showStepper && !readOnly,
759
+ opacity: readOnly ? 0.8 : 1,
760
+ ...numberInputProps,
761
+ children: /* @__PURE__ */ jsx(NumberInputField, { name: field.name, ref, onBlur: field.onBlur })
762
+ }
763
+ )
764
+ }
765
+ );
766
+ }
767
+ NumberInputField2.displayName = "NumberInputField";
768
+ function RadioGroupField(props) {
769
+ const { name, label, options, radioGroupProps, stackProps, ...rest } = props;
770
+ return /* @__PURE__ */ jsx(FormField, { name, label, ...rest, children: (field) => /* @__PURE__ */ jsx(
771
+ RadioGroup.Root,
772
+ {
773
+ value: String(field.value ?? ""),
774
+ onValueChange: (e) => field.onChange(e.value),
775
+ ...radioGroupProps,
776
+ children: /* @__PURE__ */ jsx(Stack, { direction: "row", ...stackProps, children: options.map((option) => /* @__PURE__ */ jsx(Radio, { value: option.value, children: option.label }, option.value)) })
777
+ }
778
+ ) });
779
+ }
780
+ RadioGroupField.displayName = "RadioGroupField";
781
+ var SelectActionField = (props) => {
782
+ const { label, menuItems, onClick, ...rest } = props;
783
+ const hasMenuItems = menuItems && menuItems.length > 0;
784
+ return /* @__PURE__ */ jsxs(HStack, { gap: 0.5, children: [
785
+ onClick && /* @__PURE__ */ jsxs(
786
+ Button,
787
+ {
788
+ ...rest,
789
+ colorPalette: "blue",
790
+ onClick,
791
+ size: "lg",
792
+ roundedRight: hasMenuItems ? "none" : void 0,
793
+ children: [
794
+ /* @__PURE__ */ jsx(Plus, { size: 16 }),
795
+ label
796
+ ]
797
+ }
798
+ ),
799
+ hasMenuItems && /* @__PURE__ */ jsxs(Menu.Root, { children: [
800
+ /* @__PURE__ */ jsx(Menu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
801
+ Button,
802
+ {
803
+ ...rest,
804
+ size: "lg",
805
+ colorPalette: "blue",
806
+ roundedLeft: onClick ? "none" : void 0,
807
+ children: [
808
+ /* @__PURE__ */ jsx(ChevronDown, { size: 16 }),
809
+ onClick ? null : label
810
+ ]
811
+ }
812
+ ) }),
813
+ /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, { children: /* @__PURE__ */ jsx(Menu.Content, { children: menuItems.map((menuItem) => /* @__PURE__ */ jsxs(
814
+ Menu.Item,
815
+ {
816
+ value: menuItem.label,
817
+ onClick: menuItem.onClick,
818
+ color: menuItem.color,
819
+ children: [
820
+ menuItem.icon,
821
+ menuItem.label
822
+ ]
823
+ },
824
+ menuItem.label
825
+ )) }) }) })
826
+ ] })
827
+ ] });
828
+ };
829
+ SelectActionField.displayName = "SelectActionField";
830
+ function SelectField({
831
+ ref,
832
+ ...props
833
+ }) {
834
+ const {
835
+ name,
836
+ label,
837
+ placeholder,
838
+ selectProps,
839
+ children,
840
+ readOnly,
841
+ disabled,
842
+ ...rest
843
+ } = props;
844
+ return /* @__PURE__ */ jsx(
845
+ FormField,
846
+ {
847
+ name,
848
+ label,
849
+ readOnly,
850
+ disabled,
851
+ ...rest,
852
+ children: (field) => /* @__PURE__ */ jsxs(NativeSelect.Root, { disabled: readOnly || disabled, children: [
853
+ /* @__PURE__ */ jsxs(
854
+ NativeSelect.Field,
855
+ {
856
+ ...field,
857
+ value: String(field.value ?? ""),
858
+ id: name,
859
+ ref,
860
+ ...selectProps,
861
+ children: [
862
+ placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
863
+ children
864
+ ]
865
+ }
866
+ ),
867
+ /* @__PURE__ */ jsx(NativeSelect.Indicator, {})
868
+ ] })
869
+ }
870
+ );
871
+ }
872
+ SelectField.displayName = "SelectField";
873
+ function SwitchField({
874
+ ref,
875
+ ...props
876
+ }) {
877
+ const { name, label, readOnly, disabled, switchProps, ...rest } = props;
878
+ return /* @__PURE__ */ jsx(
879
+ FormField,
880
+ {
881
+ name,
882
+ label,
883
+ readOnly,
884
+ disabled,
885
+ ...rest,
886
+ children: (field) => /* @__PURE__ */ jsx(
887
+ Switch,
888
+ {
889
+ id: name,
890
+ name: field.name,
891
+ checked: field.value || false,
892
+ onCheckedChange: (details) => field.onChange(!!details.checked),
893
+ onBlur: field.onBlur,
894
+ disabled,
895
+ readOnly,
896
+ opacity: readOnly ? 0.8 : 1,
897
+ ref,
898
+ ...switchProps
899
+ }
900
+ )
901
+ }
902
+ );
903
+ }
904
+ SwitchField.displayName = "SwitchField";
905
+ function TextareaField({
906
+ ref,
907
+ ...props
908
+ }) {
909
+ const {
910
+ name,
911
+ label,
912
+ placeholder,
913
+ textareaProps,
914
+ readOnly,
915
+ disabled,
916
+ ...rest
917
+ } = props;
918
+ return /* @__PURE__ */ jsx(
919
+ FormField,
920
+ {
921
+ name,
922
+ label,
923
+ readOnly,
924
+ disabled,
925
+ ...rest,
926
+ children: (field) => /* @__PURE__ */ jsx(
927
+ Textarea,
928
+ {
929
+ ...field,
930
+ value: String(field.value ?? ""),
931
+ id: name,
932
+ placeholder,
933
+ readOnly,
934
+ disabled,
935
+ opacity: readOnly ? 0.8 : 1,
936
+ ref,
937
+ ...textareaProps
938
+ }
939
+ )
940
+ }
941
+ );
942
+ }
943
+ TextareaField.displayName = "TextareaField";
944
+
945
+ export { ArrayField, CheckboxField, CodeField, ColorPickerField, ControlledFormField, DatePickerField, DirtyFormGuard, EditableHeading, FileField, FormField, InputField, MarkdownField, NumberInputField2 as NumberInputField, RadioGroupField, SelectActionField, SelectField, SwitchField, TextareaField };
946
+ //# sourceMappingURL=index.js.map
947
+ //# sourceMappingURL=index.js.map