@knkcs/anker 2.3.2 → 2.5.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.
- package/CLAUDE-ANKER.md +3 -0
- package/dist/atoms/index.js +1 -1
- package/dist/{chunk-L7SKAZX3.js → chunk-PLXVGYFW.js} +9 -3
- package/dist/chunk-PLXVGYFW.js.map +1 -0
- package/dist/components/index.d.ts +46 -1
- package/dist/components/index.js +154 -107
- package/dist/components/index.js.map +1 -1
- package/dist/feedback/index.js +1 -1
- package/dist/forms/index.d.ts +35 -10
- package/dist/forms/index.js +168 -65
- package/dist/forms/index.js.map +1 -1
- package/dist/templates/index.d.ts +36 -1
- package/dist/templates/index.js +122 -3
- package/dist/templates/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-L7SKAZX3.js.map +0 -1
package/dist/feedback/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Progress } from '../chunk-WEP2AIQ5.js';
|
|
2
|
-
import { IconButton } from '../chunk-JS7ZEZV3.js';
|
|
3
2
|
import { Spinner } from '../chunk-5YDCDC4B.js';
|
|
3
|
+
import { IconButton } from '../chunk-JS7ZEZV3.js';
|
|
4
4
|
import { Box, Flex, Text, Stack, HStack } from '../chunk-G4QMIXLC.js';
|
|
5
5
|
import { Dialog, Portal, ButtonGroup, Button } from '@chakra-ui/react';
|
|
6
6
|
import { createContext, useState, useRef, useCallback, useContext, useEffect } from 'react';
|
package/dist/forms/index.d.ts
CHANGED
|
@@ -16,12 +16,17 @@ interface FormFieldProps<T extends FieldValues> {
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
readOnly?: boolean;
|
|
18
18
|
actions?: React__default.ReactNode;
|
|
19
|
+
/** When false, the dirty-marker on the label is suppressed and the
|
|
20
|
+
* children-callback's `meta.isDirty` is forced to false. @default true */
|
|
21
|
+
showDirtyState?: boolean;
|
|
19
22
|
children: (field: ControllerRenderProps<T, Path<T>> & {
|
|
20
23
|
/** Computed aria-describedby linking to helper/description/error elements. */
|
|
21
24
|
"aria-describedby"?: string;
|
|
25
|
+
}, meta: {
|
|
26
|
+
isDirty: boolean;
|
|
22
27
|
}) => React__default.ReactNode;
|
|
23
28
|
}
|
|
24
|
-
declare function FormField<T extends FieldValues>({ name, label, helperText, description, required, disabled, readOnly, actions, children, }: FormFieldProps<T>): react_jsx_runtime.JSX.Element;
|
|
29
|
+
declare function FormField<T extends FieldValues>({ name, label, helperText, description, required, disabled, readOnly, actions, showDirtyState, children, }: FormFieldProps<T>): react_jsx_runtime.JSX.Element;
|
|
25
30
|
|
|
26
31
|
interface ArrayFieldProps<T extends FieldValues> extends Omit<FormFieldProps<T>, "children"> {
|
|
27
32
|
/**
|
|
@@ -52,18 +57,13 @@ declare namespace ArrayField {
|
|
|
52
57
|
var displayName: string;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
interface CheckboxFieldProps<T extends FieldValues> {
|
|
56
|
-
name: Path<T>;
|
|
57
|
-
label?: string;
|
|
60
|
+
interface CheckboxFieldProps<T extends FieldValues> extends Omit<FormFieldProps<T>, "children"> {
|
|
58
61
|
/** When provided, the field is treated as an array of checked values. */
|
|
59
62
|
value?: string | number;
|
|
60
|
-
|
|
61
|
-
helperText?: React__default.ReactNode;
|
|
63
|
+
/** Content to display after the checkbox. */
|
|
62
64
|
children?: React__default.ReactNode;
|
|
63
65
|
}
|
|
64
|
-
declare function CheckboxField<T extends FieldValues>({
|
|
65
|
-
ref?: React__default.Ref<HTMLLabelElement>;
|
|
66
|
-
}): react_jsx_runtime.JSX.Element;
|
|
66
|
+
declare function CheckboxField<T extends FieldValues>({ ...props }: CheckboxFieldProps<T>): react_jsx_runtime.JSX.Element;
|
|
67
67
|
|
|
68
68
|
type MonacoEditorProps = {
|
|
69
69
|
value?: string;
|
|
@@ -123,6 +123,20 @@ declare function DatePickerField<T extends FieldValues>({ ref, ...props }: DateP
|
|
|
123
123
|
ref?: React__default.Ref<HTMLInputElement>;
|
|
124
124
|
}): react_jsx_runtime.JSX.Element;
|
|
125
125
|
|
|
126
|
+
interface DirtyCounterProps {
|
|
127
|
+
/**
|
|
128
|
+
* Label template. The literal `{count}` is replaced with the dirty
|
|
129
|
+
* field count. @default "{count} ungespeicherte Änderungen"
|
|
130
|
+
*/
|
|
131
|
+
label?: string;
|
|
132
|
+
/** Render nothing when no fields are dirty. @default true */
|
|
133
|
+
hideWhenClean?: boolean;
|
|
134
|
+
}
|
|
135
|
+
declare function DirtyCounter({ label, hideWhenClean, }: DirtyCounterProps): react_jsx_runtime.JSX.Element | null;
|
|
136
|
+
declare namespace DirtyCounter {
|
|
137
|
+
var displayName: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
126
140
|
interface DirtyFormGuardProps {
|
|
127
141
|
/** Dialog title. @default "You have unsaved changes" */
|
|
128
142
|
title?: string;
|
|
@@ -266,4 +280,15 @@ declare function TextareaField<T extends FieldValues>({ ref, ...props }: Textare
|
|
|
266
280
|
ref?: React__default.Ref<HTMLTextAreaElement>;
|
|
267
281
|
}): react_jsx_runtime.JSX.Element;
|
|
268
282
|
|
|
269
|
-
|
|
283
|
+
interface UseFieldDirtyOptions {
|
|
284
|
+
/** Set to false to never report dirty (opt-out per field). */
|
|
285
|
+
showDirtyState?: boolean;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* useFieldDirty returns true when the field at `name` is dirty (changed
|
|
289
|
+
* from its react-hook-form default) AND visual marking isn't suppressed.
|
|
290
|
+
* Safe to call outside a FormProvider — returns false in that case.
|
|
291
|
+
*/
|
|
292
|
+
declare function useFieldDirty(name: string, opts?: UseFieldDirtyOptions): boolean;
|
|
293
|
+
|
|
294
|
+
export { ArrayField, type ArrayFieldProps, CheckboxField, type CheckboxFieldProps, CodeField, type CodeFieldProps, ColorPickerField, type ColorPickerFieldProps, ControlledFormField, type ControlledFormFieldProps, DatePickerField, type DatePickerFieldProps, DirtyCounter, type DirtyCounterProps, DirtyFormGuard, type DirtyFormGuardProps, FileField, type FileFieldProps, FormField, type FormFieldProps, InlineEdit, type InlineEditProps, InputField, type InputFieldProps, MarkdownField, type MarkdownFieldProps, NumberInputField, type NumberInputFieldProps, RadioGroupField, type RadioGroupFieldProps, type RadioOption, SelectField, type SelectFieldProps, SwitchField, type SwitchFieldProps, TextareaField, type TextareaFieldProps, type UseFieldDirtyOptions, useFieldDirty };
|
package/dist/forms/index.js
CHANGED
|
@@ -20,6 +20,7 @@ function FormField({
|
|
|
20
20
|
disabled,
|
|
21
21
|
readOnly,
|
|
22
22
|
actions,
|
|
23
|
+
showDirtyState = true,
|
|
23
24
|
children
|
|
24
25
|
}) {
|
|
25
26
|
const { control } = useFormContext();
|
|
@@ -38,6 +39,7 @@ function FormField({
|
|
|
38
39
|
helperText ? helperId : null,
|
|
39
40
|
fieldState.error ? errorId : null
|
|
40
41
|
].filter(Boolean).join(" ") || void 0;
|
|
42
|
+
const isDirty = Boolean(showDirtyState && fieldState.isDirty);
|
|
41
43
|
return /* @__PURE__ */ jsxs(
|
|
42
44
|
Field.Root,
|
|
43
45
|
{
|
|
@@ -45,12 +47,31 @@ function FormField({
|
|
|
45
47
|
required,
|
|
46
48
|
disabled,
|
|
47
49
|
readOnly,
|
|
50
|
+
"data-dirty": isDirty ? "true" : void 0,
|
|
48
51
|
children: [
|
|
49
52
|
label && (typeof label === "string" ? /* @__PURE__ */ jsxs(HStack, { children: [
|
|
50
|
-
/* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ jsxs(Field.Label, { flex: "1", htmlFor: name, children: [
|
|
54
|
+
label,
|
|
55
|
+
isDirty && /* @__PURE__ */ jsx(
|
|
56
|
+
Box,
|
|
57
|
+
{
|
|
58
|
+
as: "span",
|
|
59
|
+
display: "inline-block",
|
|
60
|
+
width: "6px",
|
|
61
|
+
height: "6px",
|
|
62
|
+
borderRadius: "full",
|
|
63
|
+
bg: "yellow.500",
|
|
64
|
+
ml: "2",
|
|
65
|
+
"aria-label": "ungespeicherte \xC4nderung"
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] }),
|
|
51
69
|
actions
|
|
52
70
|
] }) : label),
|
|
53
|
-
children(
|
|
71
|
+
children(
|
|
72
|
+
{ ...field, "aria-describedby": describedBy },
|
|
73
|
+
{ isDirty }
|
|
74
|
+
),
|
|
54
75
|
description && /* @__PURE__ */ jsx(Text, { id: descriptionId, fontSize: "xs", color: "muted", children: description }),
|
|
55
76
|
helperText && (typeof helperText === "string" ? /* @__PURE__ */ jsx(Field.HelperText, { id: helperId, children: helperText }) : /* @__PURE__ */ jsx("span", { id: helperId, children: helperText })),
|
|
56
77
|
fieldState.error && /* @__PURE__ */ jsx(Field.ErrorText, { id: errorId, "aria-live": "polite", children: fieldState.error.message })
|
|
@@ -73,30 +94,41 @@ function ArrayField(props) {
|
|
|
73
94
|
addLabel = "Add Field",
|
|
74
95
|
removeLabel = "Remove Item",
|
|
75
96
|
readOnly,
|
|
97
|
+
showDirtyState,
|
|
76
98
|
emptyState,
|
|
77
99
|
...rest
|
|
78
100
|
} = props;
|
|
79
|
-
return /* @__PURE__ */ jsx(
|
|
80
|
-
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
FormField,
|
|
81
103
|
{
|
|
82
104
|
name,
|
|
83
|
-
|
|
84
|
-
keyHeader,
|
|
85
|
-
addLabel,
|
|
86
|
-
removeLabel,
|
|
105
|
+
label,
|
|
87
106
|
readOnly,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
showDirtyState,
|
|
108
|
+
...rest,
|
|
109
|
+
children: () => /* @__PURE__ */ jsx(Box, { py: 4, px: 4, bg: "bg", rounded: "md", children: mode === "dynamic" ? /* @__PURE__ */ jsx(
|
|
110
|
+
DynamicArray,
|
|
111
|
+
{
|
|
112
|
+
name,
|
|
113
|
+
valueHeader,
|
|
114
|
+
keyHeader,
|
|
115
|
+
addLabel,
|
|
116
|
+
removeLabel,
|
|
117
|
+
readOnly,
|
|
118
|
+
emptyState
|
|
119
|
+
}
|
|
120
|
+
) : /* @__PURE__ */ jsx(
|
|
121
|
+
KeyedArray,
|
|
122
|
+
{
|
|
123
|
+
name,
|
|
124
|
+
valueHeader,
|
|
125
|
+
keyHeader,
|
|
126
|
+
keys,
|
|
127
|
+
readOnly
|
|
128
|
+
}
|
|
129
|
+
) })
|
|
98
130
|
}
|
|
99
|
-
)
|
|
131
|
+
);
|
|
100
132
|
}
|
|
101
133
|
ArrayField.displayName = "ArrayField";
|
|
102
134
|
var DynamicArray = React.memo((props) => {
|
|
@@ -184,17 +216,28 @@ var KeyedArray = React.memo((props) => {
|
|
|
184
216
|
});
|
|
185
217
|
KeyedArray.displayName = "KeyedArray";
|
|
186
218
|
function CheckboxField({
|
|
187
|
-
ref,
|
|
188
219
|
...props
|
|
189
220
|
}) {
|
|
190
|
-
const {
|
|
191
|
-
|
|
221
|
+
const {
|
|
222
|
+
name,
|
|
223
|
+
label,
|
|
224
|
+
value,
|
|
225
|
+
disabled,
|
|
226
|
+
showDirtyState,
|
|
227
|
+
helperText,
|
|
228
|
+
children,
|
|
229
|
+
...rest
|
|
230
|
+
} = props;
|
|
192
231
|
return /* @__PURE__ */ jsx(
|
|
193
|
-
|
|
232
|
+
FormField,
|
|
194
233
|
{
|
|
195
234
|
name,
|
|
196
|
-
|
|
197
|
-
|
|
235
|
+
label,
|
|
236
|
+
disabled,
|
|
237
|
+
showDirtyState,
|
|
238
|
+
helperText,
|
|
239
|
+
...rest,
|
|
240
|
+
children: (field) => {
|
|
198
241
|
const isArrayMode = value !== void 0;
|
|
199
242
|
const isChecked = isArrayMode ? Array.isArray(field.value) && field.value.includes(value) : !!field.value;
|
|
200
243
|
const handleCheckedChange = (details) => {
|
|
@@ -214,32 +257,24 @@ function CheckboxField({
|
|
|
214
257
|
}
|
|
215
258
|
};
|
|
216
259
|
const uniqueId = isArrayMode ? `${name}-${String(value)}` : name;
|
|
217
|
-
return /* @__PURE__ */ jsxs(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
children:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
children
|
|
236
|
-
] })
|
|
237
|
-
]
|
|
238
|
-
}
|
|
239
|
-
),
|
|
240
|
-
helperText && /* @__PURE__ */ jsx(Field.HelperText, { children: helperText }),
|
|
241
|
-
fieldState.error && /* @__PURE__ */ jsx(Field.ErrorText, { "aria-live": "polite", children: fieldState.error.message })
|
|
242
|
-
] });
|
|
260
|
+
return /* @__PURE__ */ jsxs(
|
|
261
|
+
Checkbox.Root,
|
|
262
|
+
{
|
|
263
|
+
id: uniqueId,
|
|
264
|
+
name: field.name,
|
|
265
|
+
value: isArrayMode ? String(value) : void 0,
|
|
266
|
+
checked: isChecked,
|
|
267
|
+
onCheckedChange: handleCheckedChange,
|
|
268
|
+
onBlur: field.onBlur,
|
|
269
|
+
disabled,
|
|
270
|
+
"aria-describedby": field["aria-describedby"],
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsx(Checkbox.HiddenInput, {}),
|
|
273
|
+
/* @__PURE__ */ jsx(Checkbox.Control, { children: /* @__PURE__ */ jsx(Checkbox.Indicator, {}) }),
|
|
274
|
+
(label || children) && /* @__PURE__ */ jsx(Checkbox.Label, { children })
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
);
|
|
243
278
|
}
|
|
244
279
|
}
|
|
245
280
|
);
|
|
@@ -429,6 +464,29 @@ function DatePickerField({
|
|
|
429
464
|
);
|
|
430
465
|
}
|
|
431
466
|
DatePickerField.displayName = "DatePickerField";
|
|
467
|
+
function DirtyCounter({
|
|
468
|
+
label = "{count} ungespeicherte \xC4nderungen",
|
|
469
|
+
hideWhenClean = true
|
|
470
|
+
}) {
|
|
471
|
+
const ctx = useFormContext();
|
|
472
|
+
const dirty = ctx ? ctx.formState.dirtyFields : {};
|
|
473
|
+
const count = Object.keys(dirty).length;
|
|
474
|
+
if (count === 0 && hideWhenClean) return null;
|
|
475
|
+
return /* @__PURE__ */ jsxs(HStack, { gap: "2", fontSize: "sm", color: "yellow.700", children: [
|
|
476
|
+
/* @__PURE__ */ jsx(
|
|
477
|
+
Box,
|
|
478
|
+
{
|
|
479
|
+
width: "6px",
|
|
480
|
+
height: "6px",
|
|
481
|
+
borderRadius: "full",
|
|
482
|
+
bg: "yellow.500",
|
|
483
|
+
"aria-hidden": true
|
|
484
|
+
}
|
|
485
|
+
),
|
|
486
|
+
/* @__PURE__ */ jsx(Text, { children: label.replace("{count}", String(count)) })
|
|
487
|
+
] });
|
|
488
|
+
}
|
|
489
|
+
DirtyCounter.displayName = "DirtyCounter";
|
|
432
490
|
var DirtyFormGuard = ({
|
|
433
491
|
title,
|
|
434
492
|
message,
|
|
@@ -669,6 +727,7 @@ function InputField({
|
|
|
669
727
|
inputProps,
|
|
670
728
|
readOnly,
|
|
671
729
|
disabled,
|
|
730
|
+
showDirtyState,
|
|
672
731
|
...rest
|
|
673
732
|
} = props;
|
|
674
733
|
return /* @__PURE__ */ jsx(
|
|
@@ -678,8 +737,9 @@ function InputField({
|
|
|
678
737
|
label,
|
|
679
738
|
readOnly,
|
|
680
739
|
disabled,
|
|
740
|
+
showDirtyState,
|
|
681
741
|
...rest,
|
|
682
|
-
children: (field) => /* @__PURE__ */ jsx(
|
|
742
|
+
children: (field, { isDirty }) => /* @__PURE__ */ jsx(
|
|
683
743
|
text_input_default,
|
|
684
744
|
{
|
|
685
745
|
...field,
|
|
@@ -692,6 +752,8 @@ function InputField({
|
|
|
692
752
|
readOnly,
|
|
693
753
|
disabled,
|
|
694
754
|
opacity: readOnly ? 0.8 : 1,
|
|
755
|
+
borderColor: isDirty ? "yellow.400" : void 0,
|
|
756
|
+
bg: isDirty ? "yellow.50" : void 0,
|
|
695
757
|
ref,
|
|
696
758
|
...inputProps
|
|
697
759
|
}
|
|
@@ -805,17 +867,34 @@ function NumberInputField2({
|
|
|
805
867
|
}
|
|
806
868
|
NumberInputField2.displayName = "NumberInputField";
|
|
807
869
|
function RadioGroupField(props) {
|
|
808
|
-
const {
|
|
809
|
-
|
|
810
|
-
|
|
870
|
+
const {
|
|
871
|
+
name,
|
|
872
|
+
label,
|
|
873
|
+
options,
|
|
874
|
+
showDirtyState,
|
|
875
|
+
radioGroupProps,
|
|
876
|
+
stackProps,
|
|
877
|
+
...rest
|
|
878
|
+
} = props;
|
|
879
|
+
return /* @__PURE__ */ jsx(
|
|
880
|
+
FormField,
|
|
811
881
|
{
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
...
|
|
816
|
-
children:
|
|
882
|
+
name,
|
|
883
|
+
label,
|
|
884
|
+
showDirtyState,
|
|
885
|
+
...rest,
|
|
886
|
+
children: (field) => /* @__PURE__ */ jsx(
|
|
887
|
+
RadioGroup,
|
|
888
|
+
{
|
|
889
|
+
value: String(field.value ?? ""),
|
|
890
|
+
onValueChange: (e) => field.onChange(e.value),
|
|
891
|
+
"aria-describedby": field["aria-describedby"],
|
|
892
|
+
...radioGroupProps,
|
|
893
|
+
children: /* @__PURE__ */ jsx(Stack, { direction: "row", ...stackProps, children: options.map((option) => /* @__PURE__ */ jsx(Radio, { value: option.value, children: option.label }, option.value)) })
|
|
894
|
+
}
|
|
895
|
+
)
|
|
817
896
|
}
|
|
818
|
-
)
|
|
897
|
+
);
|
|
819
898
|
}
|
|
820
899
|
RadioGroupField.displayName = "RadioGroupField";
|
|
821
900
|
function SelectField({
|
|
@@ -830,6 +909,7 @@ function SelectField({
|
|
|
830
909
|
children,
|
|
831
910
|
readOnly,
|
|
832
911
|
disabled,
|
|
912
|
+
showDirtyState,
|
|
833
913
|
...rest
|
|
834
914
|
} = props;
|
|
835
915
|
return /* @__PURE__ */ jsx(
|
|
@@ -839,8 +919,9 @@ function SelectField({
|
|
|
839
919
|
label,
|
|
840
920
|
readOnly,
|
|
841
921
|
disabled,
|
|
922
|
+
showDirtyState,
|
|
842
923
|
...rest,
|
|
843
|
-
children: (field) => /* @__PURE__ */ jsx(
|
|
924
|
+
children: (field, { isDirty }) => /* @__PURE__ */ jsx(
|
|
844
925
|
NativeSelect,
|
|
845
926
|
{
|
|
846
927
|
disabled: readOnly || disabled,
|
|
@@ -849,6 +930,8 @@ function SelectField({
|
|
|
849
930
|
value: String(field.value ?? ""),
|
|
850
931
|
id: name,
|
|
851
932
|
ref,
|
|
933
|
+
borderColor: isDirty ? "yellow.400" : void 0,
|
|
934
|
+
bg: isDirty ? "yellow.50" : void 0,
|
|
852
935
|
...selectProps,
|
|
853
936
|
children
|
|
854
937
|
}
|
|
@@ -861,7 +944,15 @@ function SwitchField({
|
|
|
861
944
|
ref,
|
|
862
945
|
...props
|
|
863
946
|
}) {
|
|
864
|
-
const {
|
|
947
|
+
const {
|
|
948
|
+
name,
|
|
949
|
+
label,
|
|
950
|
+
readOnly,
|
|
951
|
+
disabled,
|
|
952
|
+
showDirtyState,
|
|
953
|
+
switchProps,
|
|
954
|
+
...rest
|
|
955
|
+
} = props;
|
|
865
956
|
return /* @__PURE__ */ jsx(
|
|
866
957
|
FormField,
|
|
867
958
|
{
|
|
@@ -869,6 +960,7 @@ function SwitchField({
|
|
|
869
960
|
label,
|
|
870
961
|
readOnly,
|
|
871
962
|
disabled,
|
|
963
|
+
showDirtyState,
|
|
872
964
|
...rest,
|
|
873
965
|
children: (field) => /* @__PURE__ */ jsx(
|
|
874
966
|
Switch,
|
|
@@ -901,6 +993,7 @@ function TextareaField({
|
|
|
901
993
|
textareaProps,
|
|
902
994
|
readOnly,
|
|
903
995
|
disabled,
|
|
996
|
+
showDirtyState,
|
|
904
997
|
...rest
|
|
905
998
|
} = props;
|
|
906
999
|
return /* @__PURE__ */ jsx(
|
|
@@ -910,8 +1003,9 @@ function TextareaField({
|
|
|
910
1003
|
label,
|
|
911
1004
|
readOnly,
|
|
912
1005
|
disabled,
|
|
1006
|
+
showDirtyState,
|
|
913
1007
|
...rest,
|
|
914
|
-
children: (field) => /* @__PURE__ */ jsx(
|
|
1008
|
+
children: (field, { isDirty }) => /* @__PURE__ */ jsx(
|
|
915
1009
|
Textarea,
|
|
916
1010
|
{
|
|
917
1011
|
...field,
|
|
@@ -921,6 +1015,8 @@ function TextareaField({
|
|
|
921
1015
|
readOnly,
|
|
922
1016
|
disabled,
|
|
923
1017
|
opacity: readOnly ? 0.8 : 1,
|
|
1018
|
+
borderColor: isDirty ? "yellow.400" : void 0,
|
|
1019
|
+
bg: isDirty ? "yellow.50" : void 0,
|
|
924
1020
|
ref,
|
|
925
1021
|
...textareaProps
|
|
926
1022
|
}
|
|
@@ -929,7 +1025,14 @@ function TextareaField({
|
|
|
929
1025
|
);
|
|
930
1026
|
}
|
|
931
1027
|
TextareaField.displayName = "TextareaField";
|
|
1028
|
+
function useFieldDirty(name, opts = {}) {
|
|
1029
|
+
const ctx = useFormContext();
|
|
1030
|
+
const { showDirtyState = true } = opts;
|
|
1031
|
+
if (!showDirtyState || !ctx) return false;
|
|
1032
|
+
const dirty = ctx.formState.dirtyFields;
|
|
1033
|
+
return Boolean(dirty[name]);
|
|
1034
|
+
}
|
|
932
1035
|
|
|
933
|
-
export { ArrayField, CheckboxField, CodeField, ColorPickerField, ControlledFormField, DatePickerField, DirtyFormGuard, FileField, FormField, InlineEdit, InputField, MarkdownField, NumberInputField2 as NumberInputField, RadioGroupField, SelectField, SwitchField, TextareaField };
|
|
1036
|
+
export { ArrayField, CheckboxField, CodeField, ColorPickerField, ControlledFormField, DatePickerField, DirtyCounter, DirtyFormGuard, FileField, FormField, InlineEdit, InputField, MarkdownField, NumberInputField2 as NumberInputField, RadioGroupField, SelectField, SwitchField, TextareaField, useFieldDirty };
|
|
934
1037
|
//# sourceMappingURL=index.js.map
|
|
935
1038
|
//# sourceMappingURL=index.js.map
|