@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 { getTranslation } from '@payloadcms/translations';
|
|
6
|
-
import React from 'react';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
7
6
|
import { useCollapsible } from '../../elements/Collapsible/provider.js';
|
|
8
7
|
import { ErrorPill } from '../../elements/ErrorPill/index.js';
|
|
9
8
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
@@ -14,42 +13,31 @@ import { RenderFields } from '../../forms/RenderFields/index.js';
|
|
|
14
13
|
import { useField } from '../../forms/useField/index.js';
|
|
15
14
|
import { withCondition } from '../../forms/withCondition/index.js';
|
|
16
15
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
16
|
+
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
17
17
|
import { useRow } from '../Row/provider.js';
|
|
18
18
|
import { fieldBaseClass } from '../shared/index.js';
|
|
19
|
-
import { useTabs } from '../Tabs/provider.js';
|
|
20
19
|
import './index.scss';
|
|
20
|
+
import { useTabs } from '../Tabs/provider.js';
|
|
21
21
|
import { GroupProvider, useGroup } from './provider.js';
|
|
22
22
|
const baseClass = 'group-field';
|
|
23
23
|
export const GroupFieldComponent = props => {
|
|
24
|
-
const $ = _c(36);
|
|
25
24
|
const {
|
|
26
|
-
field
|
|
25
|
+
field,
|
|
26
|
+
field: {
|
|
27
|
+
name,
|
|
28
|
+
admin: {
|
|
29
|
+
className,
|
|
30
|
+
description,
|
|
31
|
+
hideGutter
|
|
32
|
+
} = {},
|
|
33
|
+
fields,
|
|
34
|
+
label
|
|
35
|
+
},
|
|
27
36
|
path,
|
|
28
37
|
permissions,
|
|
29
38
|
readOnly,
|
|
30
39
|
schemaPath: schemaPathFromProps
|
|
31
40
|
} = props;
|
|
32
|
-
const {
|
|
33
|
-
name,
|
|
34
|
-
admin: t1,
|
|
35
|
-
fields,
|
|
36
|
-
label
|
|
37
|
-
} = t0;
|
|
38
|
-
let t2;
|
|
39
|
-
if ($[0] !== t1) {
|
|
40
|
-
t2 = t1 === undefined ? {} : t1;
|
|
41
|
-
$[0] = t1;
|
|
42
|
-
$[1] = t2;
|
|
43
|
-
} else {
|
|
44
|
-
t2 = $[1];
|
|
45
|
-
}
|
|
46
|
-
const {
|
|
47
|
-
className,
|
|
48
|
-
description,
|
|
49
|
-
hideGutter,
|
|
50
|
-
style,
|
|
51
|
-
width
|
|
52
|
-
} = t2;
|
|
53
41
|
const schemaPath = schemaPathFromProps ?? name;
|
|
54
42
|
const {
|
|
55
43
|
i18n
|
|
@@ -60,141 +48,65 @@ export const GroupFieldComponent = props => {
|
|
|
60
48
|
const isWithinGroup = useGroup();
|
|
61
49
|
const isWithinRow = useRow();
|
|
62
50
|
const isWithinTab = useTabs();
|
|
63
|
-
let t3;
|
|
64
|
-
if ($[2] !== path) {
|
|
65
|
-
t3 = {
|
|
66
|
-
path
|
|
67
|
-
};
|
|
68
|
-
$[2] = path;
|
|
69
|
-
$[3] = t3;
|
|
70
|
-
} else {
|
|
71
|
-
t3 = $[3];
|
|
72
|
-
}
|
|
73
51
|
const {
|
|
74
|
-
customComponents:
|
|
52
|
+
customComponents: {
|
|
53
|
+
Description,
|
|
54
|
+
Label
|
|
55
|
+
} = {},
|
|
75
56
|
errorPaths
|
|
76
|
-
} = useField(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
t5 = t4 === undefined ? {} : t4;
|
|
80
|
-
$[4] = t4;
|
|
81
|
-
$[5] = t5;
|
|
82
|
-
} else {
|
|
83
|
-
t5 = $[5];
|
|
84
|
-
}
|
|
85
|
-
const {
|
|
86
|
-
Description,
|
|
87
|
-
Label
|
|
88
|
-
} = t5;
|
|
57
|
+
} = useField({
|
|
58
|
+
path
|
|
59
|
+
});
|
|
89
60
|
const submitted = useFormSubmitted();
|
|
90
61
|
const errorCount = errorPaths.length;
|
|
91
62
|
const fieldHasErrors = submitted && errorCount > 0;
|
|
92
63
|
const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow);
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
t13 = $[14];
|
|
114
|
-
}
|
|
115
|
-
const t14 = t13.join(" ");
|
|
116
|
-
const t15 = `field-${path?.replace(/\./g, "__")}`;
|
|
117
|
-
let t16;
|
|
118
|
-
if ($[15] !== style || $[16] !== width || $[17] !== Label || $[18] !== Description || $[19] !== label || $[20] !== i18n || $[21] !== path || $[22] !== description || $[23] !== fieldHasErrors || $[24] !== errorCount || $[25] !== permissions || $[26] !== fields || $[27] !== schemaPath || $[28] !== readOnly || $[29] !== t14 || $[30] !== t15) {
|
|
119
|
-
let t17;
|
|
120
|
-
if ($[32] !== fieldHasErrors || $[33] !== errorCount || $[34] !== i18n) {
|
|
121
|
-
t17 = fieldHasErrors && _jsx(ErrorPill, {
|
|
122
|
-
count: errorCount,
|
|
123
|
-
i18n,
|
|
124
|
-
withMessage: true
|
|
125
|
-
});
|
|
126
|
-
$[32] = fieldHasErrors;
|
|
127
|
-
$[33] = errorCount;
|
|
128
|
-
$[34] = i18n;
|
|
129
|
-
$[35] = t17;
|
|
130
|
-
} else {
|
|
131
|
-
t17 = $[35];
|
|
132
|
-
}
|
|
133
|
-
t16 = _jsx("div", {
|
|
134
|
-
className: t14,
|
|
135
|
-
id: t15,
|
|
136
|
-
style: {
|
|
137
|
-
...style,
|
|
138
|
-
width
|
|
139
|
-
},
|
|
140
|
-
children: _jsx(GroupProvider, {
|
|
141
|
-
children: _jsxs("div", {
|
|
142
|
-
className: `${baseClass}__wrap`,
|
|
143
|
-
children: [_jsxs("div", {
|
|
144
|
-
className: `${baseClass}__header`,
|
|
145
|
-
children: [Boolean(Label || Description || label) && _jsxs("header", {
|
|
146
|
-
children: [_jsx(RenderCustomComponent, {
|
|
147
|
-
CustomComponent: Label,
|
|
148
|
-
Fallback: _jsx("h3", {
|
|
149
|
-
className: `${baseClass}__title`,
|
|
150
|
-
children: _jsx(FieldLabel, {
|
|
151
|
-
label: getTranslation(label, i18n),
|
|
152
|
-
localized: false,
|
|
153
|
-
path,
|
|
154
|
-
required: false
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
}), _jsx(RenderCustomComponent, {
|
|
158
|
-
CustomComponent: Description,
|
|
159
|
-
Fallback: _jsx(FieldDescription, {
|
|
160
|
-
description,
|
|
161
|
-
path
|
|
64
|
+
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
65
|
+
return /*#__PURE__*/_jsx("div", {
|
|
66
|
+
className: [fieldBaseClass, baseClass, isTopLevel && `${baseClass}--top-level`, isWithinCollapsible && `${baseClass}--within-collapsible`, isWithinGroup && `${baseClass}--within-group`, isWithinRow && `${baseClass}--within-row`, isWithinTab && `${baseClass}--within-tab`, !hideGutter && isWithinGroup && `${baseClass}--gutter`, fieldHasErrors && `${baseClass}--has-error`, className].filter(Boolean).join(' '),
|
|
67
|
+
id: `field-${path?.replace(/\./g, '__')}`,
|
|
68
|
+
style: styles,
|
|
69
|
+
children: /*#__PURE__*/_jsx(GroupProvider, {
|
|
70
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
71
|
+
className: `${baseClass}__wrap`,
|
|
72
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
73
|
+
className: `${baseClass}__header`,
|
|
74
|
+
children: [Boolean(Label || Description || label) && /*#__PURE__*/_jsxs("header", {
|
|
75
|
+
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
76
|
+
CustomComponent: Label,
|
|
77
|
+
Fallback: /*#__PURE__*/_jsx("h3", {
|
|
78
|
+
className: `${baseClass}__title`,
|
|
79
|
+
children: /*#__PURE__*/_jsx(FieldLabel, {
|
|
80
|
+
label: getTranslation(label, i18n),
|
|
81
|
+
localized: false,
|
|
82
|
+
path: path,
|
|
83
|
+
required: false
|
|
162
84
|
})
|
|
163
|
-
})
|
|
164
|
-
}),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
85
|
+
})
|
|
86
|
+
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
87
|
+
CustomComponent: Description,
|
|
88
|
+
Fallback: /*#__PURE__*/_jsx(FieldDescription, {
|
|
89
|
+
description: description,
|
|
90
|
+
path: path
|
|
91
|
+
})
|
|
92
|
+
})]
|
|
93
|
+
}), fieldHasErrors && /*#__PURE__*/_jsx(ErrorPill, {
|
|
94
|
+
count: errorCount,
|
|
95
|
+
i18n: i18n,
|
|
96
|
+
withMessage: true
|
|
173
97
|
})]
|
|
174
|
-
})
|
|
98
|
+
}), /*#__PURE__*/_jsx(RenderFields, {
|
|
99
|
+
fields: fields,
|
|
100
|
+
margins: "small",
|
|
101
|
+
parentIndexPath: "",
|
|
102
|
+
parentPath: path,
|
|
103
|
+
parentSchemaPath: schemaPath,
|
|
104
|
+
permissions: permissions === true ? permissions : permissions?.fields,
|
|
105
|
+
readOnly: readOnly
|
|
106
|
+
})]
|
|
175
107
|
})
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
$[16] = width;
|
|
179
|
-
$[17] = Label;
|
|
180
|
-
$[18] = Description;
|
|
181
|
-
$[19] = label;
|
|
182
|
-
$[20] = i18n;
|
|
183
|
-
$[21] = path;
|
|
184
|
-
$[22] = description;
|
|
185
|
-
$[23] = fieldHasErrors;
|
|
186
|
-
$[24] = errorCount;
|
|
187
|
-
$[25] = permissions;
|
|
188
|
-
$[26] = fields;
|
|
189
|
-
$[27] = schemaPath;
|
|
190
|
-
$[28] = readOnly;
|
|
191
|
-
$[29] = t14;
|
|
192
|
-
$[30] = t15;
|
|
193
|
-
$[31] = t16;
|
|
194
|
-
} else {
|
|
195
|
-
t16 = $[31];
|
|
196
|
-
}
|
|
197
|
-
return t16;
|
|
108
|
+
})
|
|
109
|
+
});
|
|
198
110
|
};
|
|
199
111
|
export { GroupProvider, useGroup };
|
|
200
112
|
export const GroupField = withCondition(GroupFieldComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","React","useMemo","useCollapsible","ErrorPill","RenderCustomComponent","FieldDescription","FieldLabel","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","mergeFieldStyles","useRow","fieldBaseClass","useTabs","GroupProvider","useGroup","baseClass","GroupFieldComponent","props","field","name","admin","className","description","hideGutter","fields","label","path","permissions","readOnly","schemaPath","schemaPathFromProps","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","customComponents","Description","Label","errorPaths","submitted","errorCount","length","fieldHasErrors","isTopLevel","styles","_jsx","filter","Boolean","join","id","replace","style","_jsxs","CustomComponent","Fallback","localized","required","count","withMessage","margins","parentIndexPath","parentPath","parentSchemaPath","GroupField"],"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport type { GroupFieldClientComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useMemo } from 'react'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useFormSubmitted } from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { useRow } from '../Row/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { useTabs } from '../Tabs/provider.js'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport const GroupFieldComponent: GroupFieldClientComponent = (props) => {\n const {\n field,\n field: { name, admin: { className, description, hideGutter } = {}, fields, label },\n path,\n permissions,\n readOnly,\n schemaPath: schemaPathFromProps,\n } = props\n const schemaPath = schemaPathFromProps ?? name\n\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { customComponents: { Description, Label } = {}, errorPaths } = useField({ path })\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={styles}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {Boolean(Label || Description || label) && (\n <header>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <h3 className={`${baseClass}__title`}>\n <FieldLabel\n label={getTranslation(label, i18n)}\n localized={false}\n path={path}\n required={false}\n />\n </h3>\n }\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fields={fields}\n margins=\"small\"\n parentIndexPath=\"\"\n parentPath={path}\n parentSchemaPath={schemaPath}\n permissions={permissions === true ? permissions : permissions?.fields}\n readOnly={readOnly}\n />\n </div>\n </GroupProvider>\n </div>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(GroupFieldComponent)\n"],"mappings":"AAAA;;;AAIA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,QAAQ;AACvB,SAASC,cAAc,QAAQ;AAC/B,OAAO;AACP,SAASC,OAAO,QAAQ;AACxB,SAASC,aAAa,EAAEC,QAAQ,QAAQ;AAExC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,mBAAA,GAAkDC,KAAA;EAC7D,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MAAEC,IAAI;MAAEC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC;MAAU,CAAE,GAAG,CAAC,CAAC;MAAEC,MAAM;MAAEC;IAAK,CAAE;IAClFC,IAAI;IACJC,WAAW;IACXC,QAAQ;IACRC,UAAA,EAAYC;EAAmB,CAChC,GAAGb,KAAA;EACJ,MAAMY,UAAA,GAAaC,mBAAA,IAAuBX,IAAA;EAE1C,MAAM;IAAEY;EAAI,CAAE,GAAGvB,cAAA;EACjB,MAAM;IAAEwB;EAAmB,CAAE,GAAGjC,cAAA;EAChC,MAAMkC,aAAA,GAAgBnB,QAAA;EACtB,MAAMoB,WAAA,GAAcxB,MAAA;EACpB,MAAMyB,WAAA,GAAcvB,OAAA;EAC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,IAAA,CAAC7C,qBAAA;cACCqD,eAAA,EAAiBhB,KAAA;cACjBiB,QAAA,eACET,IAAA,CAAC;gBAAGzB,SAAA,EAAW,GAAGN,SAAA,SAAkB;0BAClC,aAAA+B,IAAA,CAAC3C,UAAA;kBACCsB,KAAA,EAAO7B,cAAA,CAAe6B,KAAA,EAAOM,IAAA;kBAC7ByB,SAAA,EAAW;kBACX9B,IAAA,EAAMA,IAAA;kBACN+B,QAAA,EAAU;;;6BAKlBX,IAAA,CAAC7C,qBAAA;cACCqD,eAAA,EAAiBjB,WAAA;cACjBkB,QAAA,eAAUT,IAAA,CAAC5C,gBAAA;gBAAiBoB,WAAA,EAAaA,WAAA;gBAAaI,IAAA,EAAMA;;;cAIjEiB,cAAA,iBAAkBG,IAAA,CAAC9C,SAAA;YAAU0D,KAAA,EAAOjB,UAAA;YAAYV,IAAA,EAAMA,IAAA;YAAM4B,WAAW;;yBAE1Eb,IAAA,CAACzC,YAAA;UACCmB,MAAA,EAAQA,MAAA;UACRoC,OAAA,EAAQ;UACRC,eAAA,EAAgB;UAChBC,UAAA,EAAYpC,IAAA;UACZqC,gBAAA,EAAkBlC,UAAA;UAClBF,WAAA,EAAaA,WAAA,KAAgB,OAAOA,WAAA,GAAcA,WAAA,EAAaH,MAAA;UAC/DI,QAAA,EAAUA;;;;;AAMtB;AAEA,SAASf,aAAa,EAAEC,QAAQ;AAEhC,OAAO,MAAMkD,UAAA,GAAazD,aAAA,CAAcS,mBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAUxE,OAAO,cAAc,CAAA;AA6IrB,eAAO,MAAM,SAAS;;;;;+EAAoC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { CodeEditor } from '../../elements/CodeEditor/index.js';
|
|
6
6
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
7
7
|
import { useField } from '../../forms/useField/index.js';
|
|
@@ -9,20 +9,19 @@ import { withCondition } from '../../forms/withCondition/index.js';
|
|
|
9
9
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
10
10
|
import { FieldError } from '../FieldError/index.js';
|
|
11
11
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
12
|
-
import {
|
|
12
|
+
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
13
13
|
import './index.scss';
|
|
14
|
+
import { fieldBaseClass } from '../shared/index.js';
|
|
14
15
|
const baseClass = 'json-field';
|
|
15
16
|
const JSONFieldComponent = props => {
|
|
16
17
|
const {
|
|
18
|
+
field,
|
|
17
19
|
field: {
|
|
18
|
-
name,
|
|
19
20
|
admin: {
|
|
20
21
|
className,
|
|
21
22
|
description,
|
|
22
23
|
editorOptions,
|
|
23
|
-
maxHeight
|
|
24
|
-
style,
|
|
25
|
-
width
|
|
24
|
+
maxHeight
|
|
26
25
|
} = {},
|
|
27
26
|
jsonSchema,
|
|
28
27
|
label,
|
|
@@ -95,12 +94,10 @@ const JSONFieldComponent = props => {
|
|
|
95
94
|
setStringValue(value_0 || initialValue ? JSON.stringify(value_0 ? value_0 : initialValue, null, 2) : '');
|
|
96
95
|
setHasLoadedValue(true);
|
|
97
96
|
}, [initialValue, value_0, hasLoadedValue]);
|
|
97
|
+
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
98
98
|
return /*#__PURE__*/_jsxs("div", {
|
|
99
99
|
className: [fieldBaseClass, baseClass, className, showError && 'error', readOnly && 'read-only'].filter(Boolean).join(' '),
|
|
100
|
-
style:
|
|
101
|
-
...style,
|
|
102
|
-
width
|
|
103
|
-
},
|
|
100
|
+
style: styles,
|
|
104
101
|
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
105
102
|
CustomComponent: Label,
|
|
106
103
|
Fallback: /*#__PURE__*/_jsx(FieldLabel, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useState","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","fieldBaseClass","baseClass","JSONFieldComponent","props","field","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useEffect","useMemo","useState","CodeEditor","RenderCustomComponent","useField","withCondition","FieldDescription","FieldError","FieldLabel","mergeFieldStyles","fieldBaseClass","baseClass","JSONFieldComponent","props","field","admin","className","description","editorOptions","maxHeight","jsonSchema","label","localized","required","path","readOnly","validate","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","initialValue","setValue","showError","handleMount","editor","monaco","existingSchemas","languages","json","jsonDefaults","diagnosticsOptions","schemas","modelUri","Uri","parse","uri","model","createModel","JSON","stringify","setDiagnosticsOptions","enableSchemaRequest","setModel","handleChange","val","undefined","e","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","message","defaultLanguage","onChange","onMount","JSONField"],"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { JSONFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\n\nconst baseClass = 'json-field'\n\nconst JSONFieldComponent: JSONFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions, maxHeight } = {},\n jsonSchema,\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, jsonError, required })\n }\n },\n [validate, required, jsonError],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n initialValue,\n setValue,\n showError,\n value,\n } = useField<string>({\n path,\n validate: memoizedValidate,\n })\n\n const handleMount = useCallback(\n (editor, monaco) => {\n if (!jsonSchema) {\n return\n }\n\n const existingSchemas = monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []\n const modelUri = monaco.Uri.parse(jsonSchema.uri)\n\n const model = monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', modelUri)\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [...existingSchemas, jsonSchema],\n validate: true,\n })\n\n editor.setModel(model)\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (readOnly) {\n return\n }\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [readOnly, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue || value === undefined) {\n return\n }\n\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\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 <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError message={jsonError} path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n maxHeight={maxHeight}\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={readOnly}\n value={stringValue}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const JSONField = withCondition(JSONFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AACP,SAASC,cAAc,QAAQ;AAE/B,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAa;QAAEC;MAAS,CAAE,GAAG,CAAC,CAAC;MAChEC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAI;IACJC,QAAQ;IACRC;EAAQ,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,CAACnE,UAAA;QAAWa,KAAA,EAAOA,KAAA;QAAOC,SAAA,EAAWA,SAAA;QAAWE,IAAA,EAAMA,IAAA;QAAMD,QAAA,EAAUA;;qBAG1E+C,KAAA,CAAC;MAAItD,SAAA,EAAW,GAAGN,cAAA,QAAsB;8BACvCiE,IAAA,CAACxE,qBAAA;QACCyE,eAAA,EAAiBpC,KAAA;QACjBqC,QAAA,eAAUF,IAAA,CAACpE,UAAA;UAAWuE,OAAA,EAASjD,SAAA;UAAWL,IAAA,EAAMA,IAAA;UAAMoB,SAAA,EAAWA;;UAElEN,WAAA,E,aACDqC,IAAA,CAACzE,UAAA;QACC6E,eAAA,EAAgB;QAChB5D,SAAA,EAAWA,SAAA;QACX6D,QAAA,EAAUf,YAAA;QACVgB,OAAA,EAASpC,WAAA;QACTV,OAAA,EAASjB,aAAA;QACTO,QAAA,EAAUA,QAAA;QACVS,KAAA,EAAOP;UAERU,UAAA;qBAEHsC,IAAA,CAACxE,qBAAA;MACCyE,eAAA,EAAiBrC,WAAA;MACjBsC,QAAA,eAAUF,IAAA,CAACrE,gBAAA;QAAiBW,WAAA,EAAaA,WAAA;QAAaO,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM0D,SAAA,GAAY7E,aAAA,CAAcO,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAkD,MAAM,SAAS,CAAA;AAE9F,OAAO,KAAkB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Join/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAkD,MAAM,SAAS,CAAA;AAE9F,OAAO,KAAkB,MAAM,OAAO,CAAA;AA4EtC,eAAO,MAAM,SAAS;;;;+EAAoC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","useMemo","RelationshipTable","useField","withCondition","useDocumentInfo","FieldLabel","fieldBaseClass","JoinFieldComponent","props","field","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useMemo","RelationshipTable","useField","withCondition","useDocumentInfo","FieldLabel","fieldBaseClass","JoinFieldComponent","props","field","admin","allowCreate","collection","label","localized","on","required","path","id","docID","customComponents","AfterInput","BeforeInput","Label","value","filterOptions","where","equals","and","_jsxs","className","filter","Boolean","join","_jsx","disableTable","initialData","docs","initialDrawerData","style","margin","relationTo","JoinField"],"sources":["../../../src/fields/Join/index.tsx"],"sourcesContent":["'use client'\n\nimport type { JoinFieldClient, JoinFieldClientComponent, PaginatedDocs, Where } from 'payload'\n\nimport React, { useMemo } from 'react'\n\nimport { RelationshipTable } from '../../elements/RelationshipTable/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useDocumentInfo } from '../../providers/DocumentInfo/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../index.js'\n\nconst JoinFieldComponent: JoinFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { allowCreate },\n collection,\n label,\n localized,\n on,\n required,\n },\n path,\n } = props\n\n const { id: docID } = useDocumentInfo()\n\n const { customComponents: { AfterInput, BeforeInput, Label } = {}, value } =\n useField<PaginatedDocs>({\n path,\n })\n\n const filterOptions: null | Where = useMemo(() => {\n if (!docID) {\n return null\n }\n\n const where = {\n [on]: {\n equals: docID,\n },\n }\n\n if (field.where) {\n return {\n and: [where, field.where],\n }\n }\n\n return where\n }, [docID, on, field.where])\n\n return (\n <div className={[fieldBaseClass, 'join'].filter(Boolean).join(' ')}>\n {BeforeInput}\n <RelationshipTable\n allowCreate={typeof docID !== 'undefined' && allowCreate}\n disableTable={filterOptions === null}\n field={field as JoinFieldClient}\n filterOptions={filterOptions}\n initialData={docID && value ? value : ({ docs: [] } as PaginatedDocs)}\n initialDrawerData={{\n [on]: docID,\n }}\n Label={\n <h4 style={{ margin: 0 }}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n </h4>\n }\n relationTo={collection}\n />\n {AfterInput}\n </div>\n )\n}\n\nexport const JoinField = withCondition(JoinFieldComponent)\n"],"mappings":"AAAA;;;AAIA,OAAOA,KAAA,IAASC,OAAO,QAAQ;AAE/B,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAC3B,SAASC,cAAc,QAAQ;AAE/B,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC;MAAW,CAAE;MACtBC,UAAU;MACVC,KAAK;MACLC,SAAS;MACTC,EAAE;MACFC;IAAQ,CACT;IACDC;EAAI,CACL,GAAGT,KAAA;EAEJ,MAAM;IAAEU,EAAA,EAAIC;EAAK,CAAE,GAAGf,eAAA;EAEtB,MAAM;IAAEgB,gBAAA,EAAkB;MAAEC,UAAU;MAAEC,WAAW;MAAEC;IAAK,CAAE,GAAG,CAAC,CAAC;IAAEC;EAAK,CAAE,GACxEtB,QAAA,CAAwB;IACtBe;EACF;EAEF,MAAMQ,aAAA,GAA8BzB,OAAA,CAAQ;IAC1C,IAAI,CAACmB,KAAA,EAAO;MACV,OAAO;IACT;IAEA,MAAMO,KAAA,GAAQ;MACZ,CAACX,EAAA,GAAK;QACJY,MAAA,EAAQR;MACV;IACF;IAEA,IAAIV,KAAA,CAAMiB,KAAK,EAAE;MACf,OAAO;QACLE,GAAA,EAAK,CAACF,KAAA,EAAOjB,KAAA,CAAMiB,KAAK;MAC1B;IACF;IAEA,OAAOA,KAAA;EACT,GAAG,CAACP,KAAA,EAAOJ,EAAA,EAAIN,KAAA,CAAMiB,KAAK,CAAC;EAE3B,oBACEG,KAAA,CAAC;IAAIC,SAAA,EAAW,CAACxB,cAAA,EAAgB,OAAO,CAACyB,MAAM,CAACC,OAAA,EAASC,IAAI,CAAC;eAC3DX,WAAA,E,aACDY,IAAA,CAACjC,iBAAA;MACCU,WAAA,EAAa,OAAOQ,KAAA,KAAU,eAAeR,WAAA;MAC7CwB,YAAA,EAAcV,aAAA,KAAkB;MAChChB,KAAA,EAAOA,KAAA;MACPgB,aAAA,EAAeA,aAAA;MACfW,WAAA,EAAajB,KAAA,IAASK,KAAA,GAAQA,KAAA,GAAS;QAAEa,IAAA,EAAM;MAAG;MAClDC,iBAAA,EAAmB;QACjB,CAACvB,EAAA,GAAKI;MACR;MACAI,KAAA,eACEW,IAAA,CAAC;QAAGK,KAAA,EAAO;UAAEC,MAAA,EAAQ;QAAE;kBACpBjB,KAAA,iBACCW,IAAA,CAAC7B,UAAA;UAAWQ,KAAA,EAAOA,KAAA;UAAOC,SAAA,EAAWA,SAAA;UAAWG,IAAA,EAAMA,IAAA;UAAMD,QAAA,EAAUA;;;MAI5EyB,UAAA,EAAY7B;QAEbS,UAAA;;AAGP;AAEA,OAAO,MAAMqB,SAAA,GAAYvC,aAAA,CAAcI,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAaxE,OAAO,cAAc,CAAA;AA8LrB,eAAO,MAAM,WAAW;;;;;;+EAAsC,CAAA"}
|