@payloadcms/ui 3.0.0-beta.133 → 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/RelationshipTable/index.d.ts +1 -0
- package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
- package/dist/elements/RelationshipTable/index.js +3 -2
- package/dist/elements/RelationshipTable/index.js.map +1 -1
- 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 +5 -2
- 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/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +3 -3
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Submit/index.d.ts.map +1 -1
- package/dist/forms/Submit/index.js +7 -2
- package/dist/forms/Submit/index.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js +3 -0
- package/dist/forms/fieldSchemasToFormState/addFieldStatePromise.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/renderField.js +40 -9
- package/dist/forms/fieldSchemasToFormState/renderField.js.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts +4 -1
- package/dist/forms/fieldSchemasToFormState/types.d.ts.map +1 -1
- package/dist/forms/fieldSchemasToFormState/types.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 +7 -4
- package/dist/utilities/buildTableState.js.map +1 -1
- package/package.json +15 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","RenderCustomComponent","FieldDescription","FieldError","useForm","useField","withCondition","useEditDepth","generateFieldID","mergeFieldStyles","fieldBaseClass","CheckboxInput","baseClass","CheckboxFieldComponent","props","id","checked","checkedFromProps","disableFormData","field","admin","className","description","label","required","onChange","onChangeFromProps","partialChecked","path","readOnly","validate","uuid","editDepth","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","setValue","showError","onToggle","Boolean","fieldID","styles","_jsxs","filter","join","style","_jsx","CustomComponent","Fallback","inputRef","name","CheckboxField"],"sources":["../../../src/fields/Checkbox/index.tsx"],"sourcesContent":["'use client'\nimport type {\n CheckboxFieldClientComponent,\n CheckboxFieldClientProps,\n CheckboxFieldValidation,\n} from 'payload'\n\nimport React, { useCallback, useMemo } from 'react'\n\nimport type { CheckboxInputProps } from './Input.js'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { useForm } from '../../forms/Form/context.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useEditDepth } from '../../providers/EditDepth/index.js'\nimport { generateFieldID } from '../../utilities/generateFieldID.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { CheckboxInput } from './Input.js'\n\nconst baseClass = 'checkbox'\n\nexport { CheckboxFieldClientProps, CheckboxInput, type CheckboxInputProps }\n\nconst CheckboxFieldComponent: CheckboxFieldClientComponent = (props) => {\n const {\n id,\n checked: checkedFromProps,\n disableFormData,\n field,\n field: {\n admin: { className, description } = {} as CheckboxFieldClientProps['field']['admin'],\n label,\n required,\n } = {} as CheckboxFieldClientProps['field'],\n onChange: onChangeFromProps,\n partialChecked,\n path,\n readOnly,\n validate,\n } = props\n\n const { uuid } = useForm()\n\n const editDepth = useEditDepth()\n\n const memoizedValidate: CheckboxFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n setValue,\n showError,\n value,\n } = useField({\n disableFormData,\n path,\n validate: memoizedValidate,\n })\n\n const onToggle = useCallback(() => {\n if (!readOnly) {\n setValue(!value)\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(!value)\n }\n }\n }, [onChangeFromProps, readOnly, setValue, value])\n\n const checked = checkedFromProps || Boolean(value)\n\n const fieldID = id || generateFieldID(path, editDepth, uuid)\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n showError && 'error',\n className,\n value && `${baseClass}--checked`,\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 <CheckboxInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n checked={checked}\n id={fieldID}\n inputRef={null}\n Label={Label}\n label={label}\n name={path}\n onToggle={onToggle}\n partialChecked={partialChecked}\n readOnly={readOnly}\n required={required}\n />\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const CheckboxField = withCondition(CheckboxFieldComponent)\n"],"mappings":"AAAA;;;AAOA,OAAOA,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAI5C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,OAAO,QAAQ;AACxB,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,YAAY,QAAQ;AAC7B,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAE9B,MAAMC,SAAA,GAAY;AAElB,SAAmCD,aAAa;AAEhD,MAAME,sBAAA,GAAwDC,KAAA;EAC5D,MAAM;IACJC,EAAE;IACFC,OAAA,EAASC,gBAAgB;IACzBC,eAAe;IACfC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC;MAAW,CAAE,GAAG,CAAC,CAA+C;MACpFC,KAAK;MACLC;IAAQ,CACT,GAAG,CAAC,CAAsC;IAC3CC,QAAA,EAAUC,iBAAiB;IAC3BC,cAAc;IACdC,IAAI;IACJC,QAAQ;IACRC;EAAQ,CACT,GAAGhB,KAAA;EAEJ,MAAM;IAAEiB;EAAI,CAAE,GAAG3B,OAAA;EAEjB,MAAM4B,SAAA,GAAYzB,YAAA;EAElB,MAAM0B,gBAAA,GAA4ClC,WAAA,CAChD,CAACmC,KAAA,EAAOC,OAAA;IACN,IAAI,OAAOL,QAAA,KAAa,YAAY;MAClC,OAAOA,QAAA,CAASI,KAAA,EAAO;QAAE,GAAGC,OAAO;QAAEX;MAAS;IAChD;EACF,GACA,CAACM,QAAA,EAAU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,UAAA;MACZC,WAAA,EAAaA,WAAA;MACbtB,OAAA,EAASA,OAAA;MACTD,EAAA,EAAI+B,OAAA;MACJS,QAAA,EAAU;MACVd,KAAA,EAAOA,KAAA;MACPlB,KAAA,EAAOA,KAAA;MACPiC,IAAA,EAAM5B,IAAA;MACNgB,QAAA,EAAUA,QAAA;MACVjB,cAAA,EAAgBA,cAAA;MAChBE,QAAA,EAAUA,QAAA;MACVL,QAAA,EAAUA;qBAEZ4B,IAAA,CAACnD,qBAAA;MACCoD,eAAA,EAAiBd,WAAA;MACjBe,QAAA,eAAUF,IAAA,CAAClD,gBAAA;QAAiBoB,WAAA,EAAaA,WAAA;QAAaM,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM6B,aAAA,GAAgBnD,aAAA,CAAcO,sBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Code/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA+B,MAAM,OAAO,CAAA;AAUnD,OAAO,cAAc,CAAA;AAuFrB,eAAO,MAAM,SAAS;;;;;;+EAAoC,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
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
|
-
import React, { useCallback } from 'react';
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
6
5
|
import { CodeEditor } from '../../elements/CodeEditor/index.js';
|
|
7
6
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
8
7
|
import { FieldDescription } from '../../fields/FieldDescription/index.js';
|
|
@@ -10,191 +9,90 @@ import { FieldError } from '../../fields/FieldError/index.js';
|
|
|
10
9
|
import { FieldLabel } from '../../fields/FieldLabel/index.js';
|
|
11
10
|
import { useField } from '../../forms/useField/index.js';
|
|
12
11
|
import { withCondition } from '../../forms/withCondition/index.js';
|
|
13
|
-
import {
|
|
12
|
+
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
14
13
|
import './index.scss';
|
|
14
|
+
import { fieldBaseClass } from '../shared/index.js';
|
|
15
15
|
const prismToMonacoLanguageMap = {
|
|
16
16
|
js: 'javascript',
|
|
17
17
|
ts: 'typescript'
|
|
18
18
|
};
|
|
19
19
|
const baseClass = 'code-field';
|
|
20
20
|
const CodeFieldComponent = props => {
|
|
21
|
-
const $ = _c(39);
|
|
22
21
|
const {
|
|
23
|
-
field
|
|
22
|
+
field,
|
|
23
|
+
field: {
|
|
24
|
+
admin: {
|
|
25
|
+
className,
|
|
26
|
+
description,
|
|
27
|
+
editorOptions = {},
|
|
28
|
+
language = 'javascript'
|
|
29
|
+
} = {},
|
|
30
|
+
label,
|
|
31
|
+
localized,
|
|
32
|
+
required
|
|
33
|
+
},
|
|
24
34
|
path,
|
|
25
35
|
readOnly,
|
|
26
36
|
validate
|
|
27
37
|
} = props;
|
|
38
|
+
const memoizedValidate = useCallback((value, options) => {
|
|
39
|
+
if (typeof validate === 'function') {
|
|
40
|
+
return validate(value, {
|
|
41
|
+
...options,
|
|
42
|
+
required
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [validate, required]);
|
|
28
46
|
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
t2 = t1 === undefined ? {} : t1;
|
|
37
|
-
$[0] = t1;
|
|
38
|
-
$[1] = t2;
|
|
39
|
-
} else {
|
|
40
|
-
t2 = $[1];
|
|
41
|
-
}
|
|
42
|
-
const {
|
|
43
|
-
className,
|
|
44
|
-
description,
|
|
45
|
-
editorOptions: t3,
|
|
46
|
-
language: t4,
|
|
47
|
-
style,
|
|
48
|
-
width
|
|
49
|
-
} = t2;
|
|
50
|
-
let t5;
|
|
51
|
-
if ($[2] !== t3) {
|
|
52
|
-
t5 = t3 === undefined ? {} : t3;
|
|
53
|
-
$[2] = t3;
|
|
54
|
-
$[3] = t5;
|
|
55
|
-
} else {
|
|
56
|
-
t5 = $[3];
|
|
57
|
-
}
|
|
58
|
-
const editorOptions = t5;
|
|
59
|
-
const language = t4 === undefined ? "javascript" : t4;
|
|
60
|
-
let t6;
|
|
61
|
-
if ($[4] !== validate || $[5] !== required) {
|
|
62
|
-
t6 = (value, options) => {
|
|
63
|
-
if (typeof validate === "function") {
|
|
64
|
-
return validate(value, {
|
|
65
|
-
...options,
|
|
66
|
-
required
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
$[4] = validate;
|
|
71
|
-
$[5] = required;
|
|
72
|
-
$[6] = t6;
|
|
73
|
-
} else {
|
|
74
|
-
t6 = $[6];
|
|
75
|
-
}
|
|
76
|
-
const memoizedValidate = t6;
|
|
77
|
-
let t7;
|
|
78
|
-
if ($[7] !== path || $[8] !== memoizedValidate) {
|
|
79
|
-
t7 = {
|
|
80
|
-
path,
|
|
81
|
-
validate: memoizedValidate
|
|
82
|
-
};
|
|
83
|
-
$[7] = path;
|
|
84
|
-
$[8] = memoizedValidate;
|
|
85
|
-
$[9] = t7;
|
|
86
|
-
} else {
|
|
87
|
-
t7 = $[9];
|
|
88
|
-
}
|
|
89
|
-
const {
|
|
90
|
-
customComponents: t8,
|
|
47
|
+
customComponents: {
|
|
48
|
+
AfterInput,
|
|
49
|
+
BeforeInput,
|
|
50
|
+
Description,
|
|
51
|
+
Error,
|
|
52
|
+
Label
|
|
53
|
+
} = {},
|
|
91
54
|
setValue,
|
|
92
55
|
showError,
|
|
93
56
|
value: value_0
|
|
94
|
-
} = useField(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
$[14] = t11;
|
|
118
|
-
$[15] = t12;
|
|
119
|
-
} else {
|
|
120
|
-
t12 = $[15];
|
|
121
|
-
}
|
|
122
|
-
const t13 = t12.join(" ");
|
|
123
|
-
let t14;
|
|
124
|
-
if ($[16] !== style || $[17] !== width || $[18] !== label || $[19] !== localized || $[20] !== path || $[21] !== required || $[22] !== Label || $[23] !== showError || $[24] !== Error || $[25] !== language || $[26] !== readOnly || $[27] !== setValue || $[28] !== value_0 || $[29] !== editorOptions || $[30] !== BeforeInput || $[31] !== AfterInput || $[32] !== description || $[33] !== Description || $[34] !== t13) {
|
|
125
|
-
let t15;
|
|
126
|
-
if ($[36] !== readOnly || $[37] !== setValue) {
|
|
127
|
-
t15 = readOnly ? _temp : val => setValue(val);
|
|
128
|
-
$[36] = readOnly;
|
|
129
|
-
$[37] = setValue;
|
|
130
|
-
$[38] = t15;
|
|
131
|
-
} else {
|
|
132
|
-
t15 = $[38];
|
|
133
|
-
}
|
|
134
|
-
t14 = _jsxs("div", {
|
|
135
|
-
className: t13,
|
|
136
|
-
style: {
|
|
137
|
-
...style,
|
|
138
|
-
width
|
|
139
|
-
},
|
|
140
|
-
children: [_jsx(RenderCustomComponent, {
|
|
141
|
-
CustomComponent: Label,
|
|
142
|
-
Fallback: _jsx(FieldLabel, {
|
|
143
|
-
label,
|
|
144
|
-
localized,
|
|
145
|
-
path,
|
|
146
|
-
required
|
|
147
|
-
})
|
|
148
|
-
}), _jsxs("div", {
|
|
149
|
-
className: `${fieldBaseClass}__wrap`,
|
|
150
|
-
children: [_jsx(RenderCustomComponent, {
|
|
151
|
-
CustomComponent: Error,
|
|
152
|
-
Fallback: _jsx(FieldError, {
|
|
153
|
-
path,
|
|
154
|
-
showError
|
|
155
|
-
})
|
|
156
|
-
}), BeforeInput, _jsx(CodeEditor, {
|
|
157
|
-
defaultLanguage: prismToMonacoLanguageMap[language] || language,
|
|
158
|
-
onChange: t15,
|
|
159
|
-
options: editorOptions,
|
|
160
|
-
readOnly,
|
|
161
|
-
value: value_0 || ""
|
|
162
|
-
}), AfterInput]
|
|
163
|
-
}), _jsx(RenderCustomComponent, {
|
|
164
|
-
CustomComponent: Description,
|
|
165
|
-
Fallback: _jsx(FieldDescription, {
|
|
166
|
-
description,
|
|
167
|
-
path
|
|
57
|
+
} = useField({
|
|
58
|
+
path,
|
|
59
|
+
validate: memoizedValidate
|
|
60
|
+
});
|
|
61
|
+
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
62
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
63
|
+
className: [fieldBaseClass, baseClass, className, showError && 'error', readOnly && 'read-only'].filter(Boolean).join(' '),
|
|
64
|
+
style: styles,
|
|
65
|
+
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
66
|
+
CustomComponent: Label,
|
|
67
|
+
Fallback: /*#__PURE__*/_jsx(FieldLabel, {
|
|
68
|
+
label: label,
|
|
69
|
+
localized: localized,
|
|
70
|
+
path: path,
|
|
71
|
+
required: required
|
|
72
|
+
})
|
|
73
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
74
|
+
className: `${fieldBaseClass}__wrap`,
|
|
75
|
+
children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
76
|
+
CustomComponent: Error,
|
|
77
|
+
Fallback: /*#__PURE__*/_jsx(FieldError, {
|
|
78
|
+
path: path,
|
|
79
|
+
showError: showError
|
|
168
80
|
})
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
$[29] = editorOptions;
|
|
185
|
-
$[30] = BeforeInput;
|
|
186
|
-
$[31] = AfterInput;
|
|
187
|
-
$[32] = description;
|
|
188
|
-
$[33] = Description;
|
|
189
|
-
$[34] = t13;
|
|
190
|
-
$[35] = t14;
|
|
191
|
-
} else {
|
|
192
|
-
t14 = $[35];
|
|
193
|
-
}
|
|
194
|
-
return t14;
|
|
81
|
+
}), BeforeInput, /*#__PURE__*/_jsx(CodeEditor, {
|
|
82
|
+
defaultLanguage: prismToMonacoLanguageMap[language] || language,
|
|
83
|
+
onChange: readOnly ? () => null : val => setValue(val),
|
|
84
|
+
options: editorOptions,
|
|
85
|
+
readOnly: readOnly,
|
|
86
|
+
value: value_0 || ''
|
|
87
|
+
}), AfterInput]
|
|
88
|
+
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
89
|
+
CustomComponent: Description,
|
|
90
|
+
Fallback: /*#__PURE__*/_jsx(FieldDescription, {
|
|
91
|
+
description: description,
|
|
92
|
+
path: path
|
|
93
|
+
})
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
195
96
|
};
|
|
196
97
|
export const CodeField = withCondition(CodeFieldComponent);
|
|
197
|
-
function _temp() {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useCallback","useMemo","CodeEditor","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","mergeFieldStyles","fieldBaseClass","prismToMonacoLanguageMap","js","ts","baseClass","CodeFieldComponent","props","field","admin","className","description","editorOptions","language","label","localized","required","path","readOnly","validate","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","setValue","showError","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","defaultLanguage","onChange","val","CodeField"],"sources":["../../../src/fields/Code/index.tsx"],"sourcesContent":["'use client'\nimport type { CodeFieldClientComponent } from 'payload'\n\nimport React, { useCallback, useMemo } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\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 { 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'\n\nconst prismToMonacoLanguageMap = {\n js: 'javascript',\n ts: 'typescript',\n}\n\nconst baseClass = 'code-field'\n\nconst CodeFieldComponent: CodeFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, editorOptions = {}, language = 'javascript' } = {},\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n setValue,\n showError,\n value,\n } = useField({\n path,\n validate: memoizedValidate,\n })\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 path={path} showError={showError} />}\n />\n {BeforeInput}\n <CodeEditor\n defaultLanguage={prismToMonacoLanguageMap[language] || language}\n onChange={readOnly ? () => null : (val) => setValue(val)}\n options={editorOptions}\n readOnly={readOnly}\n value={(value as string) || ''}\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 CodeField = withCondition(CodeFieldComponent)\n"],"mappings":"AAAA;;;AAGA,OAAOA,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAE5C,SAASC,UAAU,QAAQ;AAC3B,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AACP,SAASC,cAAc,QAAQ;AAE/B,MAAMC,wBAAA,GAA2B;EAC/BC,EAAA,EAAI;EACJC,EAAA,EAAI;AACN;AAEA,MAAMC,SAAA,GAAY;AAElB,MAAMC,kBAAA,GAAgDC,KAAA;EACpD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,aAAA,GAAgB,CAAC,CAAC;QAAEC,QAAA,GAAW;MAAY,CAAE,GAAG,CAAC,CAAC;MACnFC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAI;IACJC,QAAQ;IACRC;EAAQ,CACT,GAAGZ,KAAA;EAEJ,MAAMa,gBAAA,GAAmB7B,WAAA,CACvB,CAAC8B,KAAA,EAAOC,OAAA;IACN,IAAI,OAAOH,QAAA,KAAa,YAAY;MAClC,OAAOA,QAAA,CAASE,KAAA,EAAO;QAAE,GAAGC,OAAO;QAAEN;MAAS;IAChD;EACF,GACA,CAACG,QAAA,EAAUH,QAAA,CAAS;EAGtB,MAAM;IACJO,gBAAA,EAAkB;MAAEC,UAAU;MAAEC,WAAW;MAAEC,WAAW;MAAEC,KAAK;MAAEC;IAAK,CAAE,GAAG,CAAC,CAAC;IAC7EC,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A,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM0B,SAAA,GAAY5C,aAAA,CAAcO,kBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Collapsible/index.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Collapsible/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8D,MAAM,OAAO,CAAA;AAelF,OAAO,cAAc,CAAA;AAsIrB,eAAO,MAAM,gBAAgB;;+EAA2C,CAAA"}
|