@payloadcms/ui 3.0.0-beta.134 → 3.0.0-beta.135
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/assets/payload-favicon-dark.png +0 -0
- package/dist/assets/payload-favicon-light.png +0 -0
- package/dist/assets/payload-favicon.svg +4 -4
- package/dist/assets/payload-logo-dark.svg +1 -23
- package/dist/assets/payload-logo-light.svg +1 -23
- package/dist/assets/static-og-image.png +0 -0
- package/dist/elements/RenderServerComponent/index.d.ts +0 -6
- package/dist/elements/RenderServerComponent/index.d.ts.map +1 -1
- package/dist/elements/RenderServerComponent/index.js +1 -24
- package/dist/elements/RenderServerComponent/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js +1 -1
- package/dist/elements/WhereBuilder/Condition/DefaultFilter/index.js.map +1 -1
- package/dist/exports/client/index.js +22 -22
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +1 -0
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +71 -183
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +68 -170
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +100 -207
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +72 -162
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +72 -161
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +64 -152
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +7 -10
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Join/index.d.ts.map +1 -1
- package/dist/fields/Join/index.js +0 -1
- package/dist/fields/Join/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +143 -275
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +79 -166
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +110 -235
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +93 -209
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +7 -10
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Select/Input.d.ts +0 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +45 -50
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +7 -7
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Text/Input.d.ts.map +1 -1
- package/dist/fields/Text/Input.js +31 -36
- package/dist/fields/Text/Input.js.map +1 -1
- package/dist/fields/Text/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +93 -171
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Text/types.d.ts +0 -1
- package/dist/fields/Text/types.d.ts.map +1 -1
- package/dist/fields/Text/types.js.map +1 -1
- package/dist/fields/Textarea/Input.d.ts.map +1 -1
- package/dist/fields/Textarea/Input.js +26 -31
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +62 -112
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Textarea/types.d.ts +0 -1
- package/dist/fields/Textarea/types.d.ts.map +1 -1
- package/dist/fields/Textarea/types.js.map +1 -1
- package/dist/fields/Upload/Input.d.ts +0 -1
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +41 -46
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +63 -135
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/mergeFieldStyles.d.ts +3 -0
- package/dist/fields/mergeFieldStyles.d.ts.map +1 -0
- package/dist/fields/mergeFieldStyles.js +13 -0
- package/dist/fields/mergeFieldStyles.js.map +1 -0
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +10 -8
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/graphics/Icon/index.d.ts.map +1 -1
- package/dist/graphics/Icon/index.js +2 -2
- package/dist/graphics/Icon/index.js.map +1 -1
- package/dist/graphics/Logo/index.d.ts.map +1 -1
- package/dist/graphics/Logo/index.js +30 -21
- package/dist/graphics/Logo/index.js.map +1 -1
- package/dist/utilities/buildFormState.d.ts +0 -4
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js +1 -15
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts +2 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +6 -3
- package/dist/utilities/buildTableState.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { c as _c } from "react/compiler-runtime";
|
|
4
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { optionIsObject } from 'payload/shared';
|
|
6
|
-
import React, { useCallback } from 'react';
|
|
5
|
+
import React, { useCallback, useMemo } from 'react';
|
|
7
6
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
8
7
|
import { FieldDescription } from '../../fields/FieldDescription/index.js';
|
|
9
8
|
import { FieldError } from '../../fields/FieldError/index.js';
|
|
@@ -11,236 +10,121 @@ import { FieldLabel } from '../../fields/FieldLabel/index.js';
|
|
|
11
10
|
import { useForm } from '../../forms/Form/context.js';
|
|
12
11
|
import { useField } from '../../forms/useField/index.js';
|
|
13
12
|
import { withCondition } from '../../forms/withCondition/index.js';
|
|
14
|
-
import {
|
|
13
|
+
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
15
14
|
import './index.scss';
|
|
15
|
+
import { fieldBaseClass } from '../shared/index.js';
|
|
16
16
|
import { Radio } from './Radio/index.js';
|
|
17
17
|
const baseClass = 'radio-group';
|
|
18
18
|
const RadioGroupFieldComponent = props => {
|
|
19
|
-
const $ = _c(48);
|
|
20
19
|
const {
|
|
21
20
|
disableModifyingForm: disableModifyingFormFromProps,
|
|
22
|
-
field
|
|
21
|
+
field,
|
|
22
|
+
field: {
|
|
23
|
+
admin: {
|
|
24
|
+
className,
|
|
25
|
+
description,
|
|
26
|
+
layout = 'horizontal'
|
|
27
|
+
} = {},
|
|
28
|
+
label,
|
|
29
|
+
localized,
|
|
30
|
+
options = [],
|
|
31
|
+
required
|
|
32
|
+
} = {},
|
|
23
33
|
onChange: onChangeFromProps,
|
|
24
34
|
path,
|
|
25
35
|
readOnly,
|
|
26
36
|
validate,
|
|
27
37
|
value: valueFromProps
|
|
28
38
|
} = props;
|
|
29
|
-
let t1;
|
|
30
|
-
if ($[0] !== t0) {
|
|
31
|
-
t1 = t0 === undefined ? {} : t0;
|
|
32
|
-
$[0] = t0;
|
|
33
|
-
$[1] = t1;
|
|
34
|
-
} else {
|
|
35
|
-
t1 = $[1];
|
|
36
|
-
}
|
|
37
|
-
const {
|
|
38
|
-
admin: t2,
|
|
39
|
-
label,
|
|
40
|
-
localized,
|
|
41
|
-
options: t3,
|
|
42
|
-
required
|
|
43
|
-
} = t1;
|
|
44
|
-
let t4;
|
|
45
|
-
if ($[2] !== t2) {
|
|
46
|
-
t4 = t2 === undefined ? {} : t2;
|
|
47
|
-
$[2] = t2;
|
|
48
|
-
$[3] = t4;
|
|
49
|
-
} else {
|
|
50
|
-
t4 = $[3];
|
|
51
|
-
}
|
|
52
|
-
const {
|
|
53
|
-
className,
|
|
54
|
-
description,
|
|
55
|
-
layout: t5,
|
|
56
|
-
style,
|
|
57
|
-
width
|
|
58
|
-
} = t4;
|
|
59
|
-
const layout = t5 === undefined ? "horizontal" : t5;
|
|
60
|
-
let t6;
|
|
61
|
-
if ($[4] !== t3) {
|
|
62
|
-
t6 = t3 === undefined ? [] : t3;
|
|
63
|
-
$[4] = t3;
|
|
64
|
-
$[5] = t6;
|
|
65
|
-
} else {
|
|
66
|
-
t6 = $[5];
|
|
67
|
-
}
|
|
68
|
-
const options = t6;
|
|
69
39
|
const {
|
|
70
40
|
uuid
|
|
71
41
|
} = useForm();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
$[6] = validate;
|
|
84
|
-
$[7] = options;
|
|
85
|
-
$[8] = required;
|
|
86
|
-
$[9] = t7;
|
|
87
|
-
} else {
|
|
88
|
-
t7 = $[9];
|
|
89
|
-
}
|
|
90
|
-
const memoizedValidate = t7;
|
|
91
|
-
let t8;
|
|
92
|
-
if ($[10] !== path || $[11] !== memoizedValidate) {
|
|
93
|
-
t8 = {
|
|
94
|
-
path,
|
|
95
|
-
validate: memoizedValidate
|
|
96
|
-
};
|
|
97
|
-
$[10] = path;
|
|
98
|
-
$[11] = memoizedValidate;
|
|
99
|
-
$[12] = t8;
|
|
100
|
-
} else {
|
|
101
|
-
t8 = $[12];
|
|
102
|
-
}
|
|
42
|
+
const memoizedValidate = useCallback((value, validationOptions) => {
|
|
43
|
+
if (typeof validate === 'function') {
|
|
44
|
+
return validate(value, {
|
|
45
|
+
...validationOptions,
|
|
46
|
+
options,
|
|
47
|
+
required
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, [validate, options, required]);
|
|
103
51
|
const {
|
|
104
|
-
customComponents:
|
|
52
|
+
customComponents: {
|
|
53
|
+
Description,
|
|
54
|
+
Error,
|
|
55
|
+
Label
|
|
56
|
+
} = {},
|
|
105
57
|
setValue,
|
|
106
58
|
showError,
|
|
107
59
|
value: valueFromContext
|
|
108
|
-
} = useField(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
$[13] = t9;
|
|
113
|
-
$[14] = t10;
|
|
114
|
-
} else {
|
|
115
|
-
t10 = $[14];
|
|
116
|
-
}
|
|
117
|
-
const {
|
|
118
|
-
Description,
|
|
119
|
-
Error,
|
|
120
|
-
Label
|
|
121
|
-
} = t10;
|
|
60
|
+
} = useField({
|
|
61
|
+
path,
|
|
62
|
+
validate: memoizedValidate
|
|
63
|
+
});
|
|
122
64
|
const value_0 = valueFromContext || valueFromProps;
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
$[42] = uuid;
|
|
177
|
-
$[43] = onChangeFromProps;
|
|
178
|
-
$[44] = readOnly;
|
|
179
|
-
$[45] = setValue;
|
|
180
|
-
$[46] = disableModifyingFormFromProps;
|
|
181
|
-
$[47] = t17;
|
|
182
|
-
} else {
|
|
183
|
-
t17 = $[47];
|
|
184
|
-
}
|
|
185
|
-
t16 = _jsxs("div", {
|
|
186
|
-
className: t15,
|
|
187
|
-
style: {
|
|
188
|
-
...style,
|
|
189
|
-
width
|
|
190
|
-
},
|
|
191
|
-
children: [_jsx(RenderCustomComponent, {
|
|
192
|
-
CustomComponent: Error,
|
|
193
|
-
Fallback: _jsx(FieldError, {
|
|
194
|
-
path,
|
|
195
|
-
showError
|
|
65
|
+
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
66
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
67
|
+
className: [fieldBaseClass, baseClass, className, `${baseClass}--layout-${layout}`, showError && 'error', readOnly && `${baseClass}--read-only`].filter(Boolean).join(' '),
|
|
68
|
+
style: styles,
|
|
69
|
+
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
70
|
+
CustomComponent: Error,
|
|
71
|
+
Fallback: /*#__PURE__*/_jsx(FieldError, {
|
|
72
|
+
path: path,
|
|
73
|
+
showError: showError
|
|
74
|
+
})
|
|
75
|
+
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
76
|
+
CustomComponent: Label,
|
|
77
|
+
Fallback: /*#__PURE__*/_jsx(FieldLabel, {
|
|
78
|
+
label: label,
|
|
79
|
+
localized: localized,
|
|
80
|
+
path: path,
|
|
81
|
+
required: required
|
|
82
|
+
})
|
|
83
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
84
|
+
className: `${fieldBaseClass}__wrap`,
|
|
85
|
+
children: [/*#__PURE__*/_jsx("ul", {
|
|
86
|
+
className: `${baseClass}--group`,
|
|
87
|
+
id: `field-${path.replace(/\./g, '__')}`,
|
|
88
|
+
children: options.map(option => {
|
|
89
|
+
let optionValue = '';
|
|
90
|
+
if (optionIsObject(option)) {
|
|
91
|
+
optionValue = option.value;
|
|
92
|
+
} else {
|
|
93
|
+
optionValue = option;
|
|
94
|
+
}
|
|
95
|
+
const isSelected = String(optionValue) === String(value_0);
|
|
96
|
+
const id = `field-${path}-${optionValue}${uuid ? `-${uuid}` : ''}`;
|
|
97
|
+
return /*#__PURE__*/_jsx("li", {
|
|
98
|
+
children: /*#__PURE__*/_jsx(Radio, {
|
|
99
|
+
id: id,
|
|
100
|
+
isSelected: isSelected,
|
|
101
|
+
onChange: () => {
|
|
102
|
+
if (typeof onChangeFromProps === 'function') {
|
|
103
|
+
onChangeFromProps(optionValue);
|
|
104
|
+
}
|
|
105
|
+
if (!readOnly) {
|
|
106
|
+
setValue(optionValue, !!disableModifyingFormFromProps);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
option: optionIsObject(option) ? option : {
|
|
110
|
+
label: option,
|
|
111
|
+
value: option
|
|
112
|
+
},
|
|
113
|
+
path: path,
|
|
114
|
+
readOnly: readOnly,
|
|
115
|
+
uuid: uuid
|
|
116
|
+
})
|
|
117
|
+
}, `${path} - ${optionValue}`);
|
|
196
118
|
})
|
|
197
|
-
}), _jsx(RenderCustomComponent, {
|
|
198
|
-
CustomComponent:
|
|
199
|
-
Fallback: _jsx(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
path,
|
|
203
|
-
required
|
|
119
|
+
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
120
|
+
CustomComponent: Description,
|
|
121
|
+
Fallback: /*#__PURE__*/_jsx(FieldDescription, {
|
|
122
|
+
description: description,
|
|
123
|
+
path: path
|
|
204
124
|
})
|
|
205
|
-
}), _jsxs("div", {
|
|
206
|
-
className: `${fieldBaseClass}__wrap`,
|
|
207
|
-
children: [_jsx("ul", {
|
|
208
|
-
className: `${baseClass}--group`,
|
|
209
|
-
id: `field-${path.replace(/\./g, "__")}`,
|
|
210
|
-
children: options.map(t17)
|
|
211
|
-
}), _jsx(RenderCustomComponent, {
|
|
212
|
-
CustomComponent: Description,
|
|
213
|
-
Fallback: _jsx(FieldDescription, {
|
|
214
|
-
description,
|
|
215
|
-
path
|
|
216
|
-
})
|
|
217
|
-
})]
|
|
218
125
|
})]
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
$[21] = width;
|
|
222
|
-
$[22] = path;
|
|
223
|
-
$[23] = showError;
|
|
224
|
-
$[24] = Error;
|
|
225
|
-
$[25] = label;
|
|
226
|
-
$[26] = localized;
|
|
227
|
-
$[27] = required;
|
|
228
|
-
$[28] = Label;
|
|
229
|
-
$[29] = value_0;
|
|
230
|
-
$[30] = uuid;
|
|
231
|
-
$[31] = onChangeFromProps;
|
|
232
|
-
$[32] = readOnly;
|
|
233
|
-
$[33] = setValue;
|
|
234
|
-
$[34] = disableModifyingFormFromProps;
|
|
235
|
-
$[35] = options;
|
|
236
|
-
$[36] = description;
|
|
237
|
-
$[37] = Description;
|
|
238
|
-
$[38] = t15;
|
|
239
|
-
$[39] = t16;
|
|
240
|
-
} else {
|
|
241
|
-
t16 = $[39];
|
|
242
|
-
}
|
|
243
|
-
return t16;
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
244
128
|
};
|
|
245
129
|
export const RadioGroupField = withCondition(RadioGroupFieldComponent);
|
|
246
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","optionIsObject","React","useCallback","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useForm","useField","withCondition","fieldBaseClass","Radio","baseClass","RadioGroupFieldComponent","props","$","disableModifyingForm","disableModifyingFormFromProps","field","t0","onChange","onChangeFromProps","path","readOnly","validate","value","valueFromProps","t1","undefined","admin","t2","label","localized","options","t3","required","t4","className","description","layout","t5","style","width","t6","uuid","t7","validationOptions","memoizedValidate","t8","customComponents","t9","setValue","showError","valueFromContext","t10","Description","Error","Label","value_0","t11","t12","t13","t14","filter","Boolean","t15","join","t16","t17","option","optionValue","isSelected","String","id","_jsx","children","_jsxs","CustomComponent","Fallback","replace","map","RadioGroupField"],"sources":["../../../src/fields/RadioGroup/index.tsx"],"sourcesContent":["'use client'\nimport type { RadioFieldClientComponent, RadioFieldClientProps } from 'payload'\n\nimport { optionIsObject } from 'payload/shared'\nimport React, { useCallback } from 'react'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useForm } from '../../forms/Form/context.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { Radio } from './Radio/index.js'\n\nconst baseClass = 'radio-group'\n\nconst RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {\n const {\n disableModifyingForm: disableModifyingFormFromProps,\n field: {\n admin: {\n className,\n description,\n layout = 'horizontal',\n style,\n width,\n } = {} as RadioFieldClientProps['field']['admin'],\n label,\n localized,\n options = [],\n required,\n } = {} as RadioFieldClientProps['field'],\n onChange: onChangeFromProps,\n path,\n readOnly,\n validate,\n value: valueFromProps,\n } = props\n\n const { uuid } = useForm()\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, options, required })\n }\n },\n [validate, options, required],\n )\n\n const {\n customComponents: { Description, Error, Label } = {},\n setValue,\n showError,\n value: valueFromContext,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const value = valueFromContext || valueFromProps\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n `${baseClass}--layout-${layout}`,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <ul className={`${baseClass}--group`} id={`field-${path.replace(/\\./g, '__')}`}>\n {options.map((option) => {\n let optionValue = ''\n\n if (optionIsObject(option)) {\n optionValue = option.value\n } else {\n optionValue = option\n }\n\n const isSelected = String(optionValue) === String(value)\n\n const id = `field-${path}-${optionValue}${uuid ? `-${uuid}` : ''}`\n\n return (\n <li key={`${path} - ${optionValue}`}>\n <Radio\n id={id}\n isSelected={isSelected}\n onChange={() => {\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(optionValue)\n }\n\n if (!readOnly) {\n setValue(optionValue, !!disableModifyingFormFromProps)\n }\n }}\n option={optionIsObject(option) ? option : { label: option, value: option }}\n path={path}\n readOnly={readOnly}\n uuid={uuid}\n />\n </li>\n )\n })}\n </ul>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nexport const RadioGroupField = withCondition(RadioGroupFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAEnC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,S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AAA,OAAAQ,QAAA;MAAAR,CAAA,OAAAoC,QAAA;MAAApC,CAAA,OAAAE,6BAAA;MAAAF,CAAA,OAAAqD,GAAA;IAAA;MAAAA,GAAA,GAAArD,CAAA;IAAA;IA9DNoD,GAAA,GAAAS,KAAA,CAAC;MAAAvC,SAAA,EACY4B,GASH;MAAAxB,KAAA;QAAA,GAEHA,KAAK;QAAAC;MAAA;MAAAiC,QAAA,GAIVD,IAAA,CAAAvE,qBAAA;QAAA0E,eAAA,EACmBrB,KAAA;QAAAsB,QAAA,EACPJ,IAAA,CAAArE,UAAA;UAAAiB,IAAA;UAAA8B;QAAA,C;UAEZsB,IAAA,CAAAvE,qBAAA;QAAA0E,eAAA,EACmBpB,KAAA;QAAAqB,QAAA,EAEfJ,IAAA,CAAApE,UAAA;UAAAyB,KAAA;UAAAC,SAAA;UAAAV,IAAA;UAAAa;QAAA,C;UAGJyC,KAAA,CAAC;QAAAvC,SAAA,EAAe,GAAA3B,cAAA,QAAyB;QAAAiE,QAAA,GACvCD,IAAA,CAAC;UAAArC,SAAA,EAAc,GAAAzB,SAAA,SAAqB;UAAA6D,EAAA,EAAM,SAASnD,IAAA,CAAAyD,OAAA,QAAoB,OAAO;UAAAJ,QAAA,EAC3E1C,OAAA,CAAA+C,GAAA,CAAYZ,GAkCb;QAAA,C,GAEFM,IAAA,CAAAvE,qBAAA;UAAA0E,eAAA,EACmBtB,WAAA;UAAAuB,QAAA,EACPJ,IAAA,CAAAtE,gBAAA;YAAAkC,WAAA;YAAAhB;UAAA,C;;;;;;;;;;;;;;;;;;;;;;;;;;;SAlEhB6C,G;CAuEJ;AAEA,OAAO,MAAMc,eAAA,GAAkBxE,aAAA,CAAcI,wBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["optionIsObject","React","useCallback","useMemo","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useForm","useField","withCondition","mergeFieldStyles","fieldBaseClass","Radio","baseClass","RadioGroupFieldComponent","props","disableModifyingForm","disableModifyingFormFromProps","field","admin","className","description","layout","label","localized","options","required","onChange","onChangeFromProps","path","readOnly","validate","value","valueFromProps","uuid","memoizedValidate","validationOptions","customComponents","Description","Error","Label","setValue","showError","valueFromContext","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","id","replace","map","option","optionValue","isSelected","String","RadioGroupField"],"sources":["../../../src/fields/RadioGroup/index.tsx"],"sourcesContent":["'use client'\nimport type { RadioFieldClientComponent, RadioFieldClientProps } from 'payload'\n\nimport { optionIsObject } from 'payload/shared'\nimport React, { useCallback, useMemo } from 'react'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useForm } from '../../forms/Form/context.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { Radio } from './Radio/index.js'\n\nconst baseClass = 'radio-group'\n\nconst RadioGroupFieldComponent: RadioFieldClientComponent = (props) => {\n const {\n disableModifyingForm: disableModifyingFormFromProps,\n field,\n field: {\n admin: {\n className,\n description,\n layout = 'horizontal',\n } = {} as RadioFieldClientProps['field']['admin'],\n label,\n localized,\n options = [],\n required,\n } = {} as RadioFieldClientProps['field'],\n onChange: onChangeFromProps,\n path,\n readOnly,\n validate,\n value: valueFromProps,\n } = props\n\n const { uuid } = useForm()\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n return validate(value, { ...validationOptions, options, required })\n }\n },\n [validate, options, required],\n )\n\n const {\n customComponents: { Description, Error, Label } = {},\n setValue,\n showError,\n value: valueFromContext,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const value = valueFromContext || valueFromProps\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n `${baseClass}--layout-${layout}`,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n }\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <ul className={`${baseClass}--group`} id={`field-${path.replace(/\\./g, '__')}`}>\n {options.map((option) => {\n let optionValue = ''\n\n if (optionIsObject(option)) {\n optionValue = option.value\n } else {\n optionValue = option\n }\n\n const isSelected = String(optionValue) === String(value)\n\n const id = `field-${path}-${optionValue}${uuid ? `-${uuid}` : ''}`\n\n return (\n <li key={`${path} - ${optionValue}`}>\n <Radio\n id={id}\n isSelected={isSelected}\n onChange={() => {\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(optionValue)\n }\n\n if (!readOnly) {\n setValue(optionValue, !!disableModifyingFormFromProps)\n }\n }}\n option={optionIsObject(option) ? option : { label: option, value: option }}\n path={path}\n readOnly={readOnly}\n uuid={uuid}\n />\n </li>\n )\n })}\n </ul>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nexport const RadioGroupField = withCondition(RadioGroupFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAE5C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ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A,EAAUA,CAAA;gBACR,IAAI,OAAOC,iBAAA,KAAsB,YAAY;kBAC3CA,iBAAA,CAAkB6B,WAAA;gBACpB;gBAEA,IAAI,CAAC3B,QAAA,EAAU;kBACbW,QAAA,CAASgB,WAAA,EAAa,CAAC,CAACxC,6BAAA;gBAC1B;cACF;cACAuC,MAAA,EAAQzD,cAAA,CAAeyD,MAAA,IAAUA,MAAA,GAAS;gBAAEjC,KAAA,EAAOiC,MAAA;gBAAQxB,KAAA,EAAOwB;cAAO;cACzE3B,IAAA,EAAMA,IAAA;cACNC,QAAA,EAAUA,QAAA;cACVI,IAAA,EAAMA;;aAhBD,GAAGL,IAAA,MAAU4B,WAAA,EAAa;QAoBvC;uBAEFP,IAAA,CAAC/C,qBAAA;QACCgD,eAAA,EAAiBb,WAAA;QACjBc,QAAA,eAAUF,IAAA,CAAC9C,gBAAA;UAAiBiB,WAAA,EAAaA,WAAA;UAAaQ,IAAA,EAAMA;;;;;AAKtE;AAEA,OAAO,MAAM+B,eAAA,GAAkBnD,aAAA,CAAcK,wBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Relationship/index.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Relationship/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAwE,MAAM,OAAO,CAAA;AAwB5F,OAAO,cAAc,CAAA;AAorBrB,eAAO,MAAM,iBAAiB;;;;;+EAA4C,CAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { wordBoundariesRegex } from 'payload/shared';
|
|
5
5
|
import * as qs from 'qs-esm';
|
|
6
|
-
import React, { useCallback, useEffect, useReducer, useRef, useState } from 'react';
|
|
6
|
+
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
7
7
|
import { AddNewRelation } from '../../elements/AddNewRelation/index.js';
|
|
8
8
|
import { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js';
|
|
9
9
|
import { ReactSelect } from '../../elements/ReactSelect/index.js';
|
|
@@ -19,10 +19,11 @@ import { useAuth } from '../../providers/Auth/index.js';
|
|
|
19
19
|
import { useConfig } from '../../providers/Config/index.js';
|
|
20
20
|
import { useLocale } from '../../providers/Locale/index.js';
|
|
21
21
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
22
|
+
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
22
23
|
import { fieldBaseClass } from '../shared/index.js';
|
|
23
24
|
import { createRelationMap } from './createRelationMap.js';
|
|
24
|
-
import { findOptionsByValue } from './findOptionsByValue.js';
|
|
25
25
|
import './index.scss';
|
|
26
|
+
import { findOptionsByValue } from './findOptionsByValue.js';
|
|
26
27
|
import { optionsReducer } from './optionsReducer.js';
|
|
27
28
|
import { MultiValueLabel } from './select-components/MultiValueLabel/index.js';
|
|
28
29
|
import { SingleValue } from './select-components/SingleValue/index.js';
|
|
@@ -30,17 +31,15 @@ const maxResultsPerRequest = 10;
|
|
|
30
31
|
const baseClass = 'relationship';
|
|
31
32
|
const RelationshipFieldComponent = props => {
|
|
32
33
|
const {
|
|
34
|
+
field,
|
|
33
35
|
field: {
|
|
34
|
-
name,
|
|
35
36
|
admin: {
|
|
36
37
|
allowCreate = true,
|
|
37
38
|
allowEdit = true,
|
|
38
39
|
className,
|
|
39
40
|
description,
|
|
40
41
|
isSortable = true,
|
|
41
|
-
sortOptions
|
|
42
|
-
style,
|
|
43
|
-
width
|
|
42
|
+
sortOptions
|
|
44
43
|
} = {},
|
|
45
44
|
hasMany,
|
|
46
45
|
label,
|
|
@@ -459,13 +458,11 @@ const RelationshipFieldComponent = props => {
|
|
|
459
458
|
if (!Array.isArray(valueToRender) && valueToRender?.value === 'null') {
|
|
460
459
|
valueToRender.value = null;
|
|
461
460
|
}
|
|
461
|
+
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
462
462
|
return /*#__PURE__*/_jsxs("div", {
|
|
463
463
|
className: [fieldBaseClass, baseClass, className, showError && 'error', errorLoading && 'error-loading', readOnly && `${baseClass}--read-only`, !readOnly && allowCreate && `${baseClass}--allow-create`].filter(Boolean).join(' '),
|
|
464
464
|
id: `field-${path.replace(/\./g, '__')}`,
|
|
465
|
-
style:
|
|
466
|
-
...style,
|
|
467
|
-
width
|
|
468
|
-
},
|
|
465
|
+
style: styles,
|
|
469
466
|
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
470
467
|
CustomComponent: Label,
|
|
471
468
|
Fallback: /*#__PURE__*/_jsx(FieldLabel, {
|