@payloadcms/ui 3.5.0 → 3.5.1-canary.4044ffb
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/elements/CodeEditor/CodeEditor.js +39 -32
- package/dist/elements/CodeEditor/CodeEditor.js.map +1 -1
- package/dist/elements/CodeEditor/types.d.ts +4 -0
- package/dist/elements/CodeEditor/types.d.ts.map +1 -1
- package/dist/elements/CodeEditor/types.js.map +1 -1
- package/dist/elements/EditMany/index.d.ts.map +1 -1
- package/dist/elements/EditMany/index.js +66 -44
- package/dist/elements/EditMany/index.js.map +1 -1
- package/dist/elements/FieldSelect/index.d.ts +2 -2
- package/dist/elements/FieldSelect/index.d.ts.map +1 -1
- package/dist/elements/FieldSelect/index.js.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js +2 -3
- package/dist/elements/ListControls/getTextFieldsToBeSearched.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts +3 -3
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +6 -7
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/TableColumns/filterFields.d.ts +4 -0
- package/dist/elements/TableColumns/filterFields.d.ts.map +1 -1
- package/dist/elements/TableColumns/filterFields.js +11 -6
- package/dist/elements/TableColumns/filterFields.js.map +1 -1
- package/dist/elements/TableColumns/getInitialColumns.d.ts +7 -2
- package/dist/elements/TableColumns/getInitialColumns.d.ts.map +1 -1
- package/dist/elements/TableColumns/getInitialColumns.js +5 -0
- package/dist/elements/TableColumns/getInitialColumns.js.map +1 -1
- package/dist/elements/TableColumns/index.d.ts.map +1 -1
- package/dist/elements/TableColumns/index.js +5 -2
- package/dist/elements/TableColumns/index.js.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/index.js +100 -259
- package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
- package/dist/elements/WhereBuilder/reduceClientFields.js +1 -1
- package/dist/elements/WhereBuilder/reduceClientFields.js.map +1 -1
- package/dist/exports/client/{CodeEditor-FR4GQI3P.js → CodeEditor-W7RSWONH.js} +2 -2
- package/dist/exports/client/{chunk-RO7ZK4KN.js → chunk-3MXUY6XL.js} +6 -6
- package/dist/exports/client/chunk-3MXUY6XL.js.map +8 -0
- package/dist/exports/client/index.d.ts +4 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +3 -3
- package/dist/fields/Tabs/index.d.ts +15 -0
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +2 -2
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/forms/Form/index.d.ts.map +1 -1
- package/dist/forms/Form/index.js +25 -14
- package/dist/forms/Form/index.js.map +1 -1
- package/dist/forms/Form/types.d.ts +9 -2
- package/dist/forms/Form/types.d.ts.map +1 -1
- package/dist/forms/Form/types.js.map +1 -1
- package/dist/hooks/useUseAsTitle.d.ts.map +1 -1
- package/dist/hooks/useUseAsTitle.js +2 -2
- package/dist/hooks/useUseAsTitle.js.map +1 -1
- package/dist/providers/ListQuery/index.d.ts.map +1 -1
- package/dist/providers/ListQuery/index.js +1 -1
- package/dist/providers/ListQuery/index.js.map +1 -1
- package/dist/utilities/buildTableState.d.ts.map +1 -1
- package/dist/utilities/buildTableState.js +3 -4
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/renderTable.d.ts +4 -4
- package/dist/utilities/renderTable.d.ts.map +1 -1
- package/dist/utilities/renderTable.js +6 -5
- package/dist/utilities/renderTable.js.map +1 -1
- package/package.json +4 -4
- package/dist/exports/client/chunk-RO7ZK4KN.js.map +0 -8
- package/dist/utilities/flattenFieldMap.d.ts +0 -10
- package/dist/utilities/flattenFieldMap.d.ts.map +0 -1
- package/dist/utilities/flattenFieldMap.js +0 -26
- package/dist/utilities/flattenFieldMap.js.map +0 -1
- /package/dist/exports/client/{CodeEditor-FR4GQI3P.js.map → CodeEditor-W7RSWONH.js.map} +0 -0
|
@@ -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, { useEffect, useState } from 'react';
|
|
4
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
6
5
|
import { useDebounce } from '../../../hooks/useDebounce.js';
|
|
7
6
|
import { useTranslation } from '../../../providers/Translation/index.js';
|
|
8
7
|
import { Button } from '../../Button/index.js';
|
|
@@ -11,7 +10,6 @@ import { DefaultFilter } from './DefaultFilter/index.js';
|
|
|
11
10
|
import './index.scss';
|
|
12
11
|
const baseClass = 'condition';
|
|
13
12
|
export const Condition = props => {
|
|
14
|
-
const $ = _c(68);
|
|
15
13
|
const {
|
|
16
14
|
addCondition,
|
|
17
15
|
andIndex,
|
|
@@ -24,272 +22,115 @@ export const Condition = props => {
|
|
|
24
22
|
RenderedFilter,
|
|
25
23
|
updateCondition
|
|
26
24
|
} = props;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} else {
|
|
34
|
-
t0 = $[2];
|
|
35
|
-
}
|
|
36
|
-
const [internalField, setInternalField] = useState(t0);
|
|
25
|
+
const options = useMemo(() => {
|
|
26
|
+
return fields.filter(({
|
|
27
|
+
field
|
|
28
|
+
}) => !field.admin.disableListFilter);
|
|
29
|
+
}, [fields]);
|
|
30
|
+
const [internalField, setInternalField] = useState(() => fields.find(field_0 => fieldName === field_0.value));
|
|
37
31
|
const {
|
|
38
32
|
t
|
|
39
33
|
} = useTranslation();
|
|
40
34
|
const [internalOperatorOption, setInternalOperatorOption] = useState(operator);
|
|
41
35
|
const [internalQueryValue, setInternalQueryValue] = useState(initialValue);
|
|
42
36
|
const debouncedValue = useDebounce(internalQueryValue, 300);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
updateCondition({
|
|
48
|
-
andIndex,
|
|
49
|
-
fieldName: internalField.value,
|
|
50
|
-
operator: internalOperatorOption,
|
|
51
|
-
orIndex,
|
|
52
|
-
value: debouncedValue
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
$[3] = andIndex;
|
|
57
|
-
$[4] = debouncedValue;
|
|
58
|
-
$[5] = internalField;
|
|
59
|
-
$[6] = internalOperatorOption;
|
|
60
|
-
$[7] = orIndex;
|
|
61
|
-
$[8] = updateCondition;
|
|
62
|
-
$[9] = t1;
|
|
63
|
-
} else {
|
|
64
|
-
t1 = $[9];
|
|
65
|
-
}
|
|
66
|
-
const t2 = internalField?.value;
|
|
67
|
-
let t3;
|
|
68
|
-
if ($[10] !== andIndex || $[11] !== debouncedValue || $[12] !== internalOperatorOption || $[13] !== operator || $[14] !== orIndex || $[15] !== t2 || $[16] !== updateCondition) {
|
|
69
|
-
t3 = [debouncedValue, andIndex, t2, internalOperatorOption, orIndex, updateCondition, operator];
|
|
70
|
-
$[10] = andIndex;
|
|
71
|
-
$[11] = debouncedValue;
|
|
72
|
-
$[12] = internalOperatorOption;
|
|
73
|
-
$[13] = operator;
|
|
74
|
-
$[14] = orIndex;
|
|
75
|
-
$[15] = t2;
|
|
76
|
-
$[16] = updateCondition;
|
|
77
|
-
$[17] = t3;
|
|
78
|
-
} else {
|
|
79
|
-
t3 = $[17];
|
|
80
|
-
}
|
|
81
|
-
useEffect(t1, t3);
|
|
82
|
-
let t4;
|
|
83
|
-
if ($[18] !== internalField?.field?.type || $[19] !== internalOperatorOption) {
|
|
84
|
-
t4 = ["exists"].includes(internalOperatorOption) || internalField?.field?.type === "checkbox";
|
|
85
|
-
$[18] = internalField?.field?.type;
|
|
86
|
-
$[19] = internalOperatorOption;
|
|
87
|
-
$[20] = t4;
|
|
88
|
-
} else {
|
|
89
|
-
t4 = $[20];
|
|
90
|
-
}
|
|
91
|
-
const booleanSelect = t4;
|
|
92
|
-
let valueOptions;
|
|
93
|
-
if (booleanSelect) {
|
|
94
|
-
let t5;
|
|
95
|
-
if ($[21] !== t) {
|
|
96
|
-
t5 = t("general:true");
|
|
97
|
-
$[21] = t;
|
|
98
|
-
$[22] = t5;
|
|
99
|
-
} else {
|
|
100
|
-
t5 = $[22];
|
|
101
|
-
}
|
|
102
|
-
let t6;
|
|
103
|
-
if ($[23] !== t5) {
|
|
104
|
-
t6 = {
|
|
105
|
-
label: t5,
|
|
106
|
-
value: "true"
|
|
107
|
-
};
|
|
108
|
-
$[23] = t5;
|
|
109
|
-
$[24] = t6;
|
|
110
|
-
} else {
|
|
111
|
-
t6 = $[24];
|
|
112
|
-
}
|
|
113
|
-
let t7;
|
|
114
|
-
if ($[25] !== t) {
|
|
115
|
-
t7 = t("general:false");
|
|
116
|
-
$[25] = t;
|
|
117
|
-
$[26] = t7;
|
|
118
|
-
} else {
|
|
119
|
-
t7 = $[26];
|
|
120
|
-
}
|
|
121
|
-
let t8;
|
|
122
|
-
if ($[27] !== t7) {
|
|
123
|
-
t8 = {
|
|
124
|
-
label: t7,
|
|
125
|
-
value: "false"
|
|
126
|
-
};
|
|
127
|
-
$[27] = t7;
|
|
128
|
-
$[28] = t8;
|
|
129
|
-
} else {
|
|
130
|
-
t8 = $[28];
|
|
131
|
-
}
|
|
132
|
-
let t9;
|
|
133
|
-
if ($[29] !== t6 || $[30] !== t8) {
|
|
134
|
-
t9 = [t6, t8];
|
|
135
|
-
$[29] = t6;
|
|
136
|
-
$[30] = t8;
|
|
137
|
-
$[31] = t9;
|
|
138
|
-
} else {
|
|
139
|
-
t9 = $[31];
|
|
140
|
-
}
|
|
141
|
-
valueOptions = t9;
|
|
142
|
-
} else {
|
|
143
|
-
if (internalField?.field && "options" in internalField.field) {
|
|
144
|
-
valueOptions = internalField.field.options;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
let t5;
|
|
148
|
-
if ($[32] !== fields) {
|
|
149
|
-
t5 = field_0 => {
|
|
150
|
-
setInternalField(fields.find(f => f.value === field_0.value));
|
|
151
|
-
setInternalOperatorOption(undefined);
|
|
152
|
-
setInternalQueryValue(undefined);
|
|
153
|
-
};
|
|
154
|
-
$[32] = fields;
|
|
155
|
-
$[33] = t5;
|
|
156
|
-
} else {
|
|
157
|
-
t5 = $[33];
|
|
158
|
-
}
|
|
159
|
-
let t6;
|
|
160
|
-
if ($[34] !== fields || $[35] !== internalField?.value) {
|
|
161
|
-
t6 = fields.find(field_1 => internalField?.value === field_1.value) || fields[0];
|
|
162
|
-
$[34] = fields;
|
|
163
|
-
$[35] = internalField?.value;
|
|
164
|
-
$[36] = t6;
|
|
165
|
-
} else {
|
|
166
|
-
t6 = $[36];
|
|
167
|
-
}
|
|
168
|
-
let t7;
|
|
169
|
-
if ($[37] !== RenderedFilter || $[38] !== addCondition || $[39] !== andIndex || $[40] !== booleanSelect || $[41] !== fields || $[42] !== internalField || $[43] !== internalOperatorOption || $[44] !== internalQueryValue || $[45] !== orIndex || $[46] !== removeCondition || $[47] !== t5 || $[48] !== t6 || $[49] !== valueOptions) {
|
|
170
|
-
let t8;
|
|
171
|
-
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
172
|
-
t8 = operator_0 => {
|
|
173
|
-
setInternalOperatorOption(operator_0.value);
|
|
174
|
-
};
|
|
175
|
-
$[51] = t8;
|
|
176
|
-
} else {
|
|
177
|
-
t8 = $[51];
|
|
178
|
-
}
|
|
179
|
-
let t9;
|
|
180
|
-
if ($[52] !== RenderedFilter || $[53] !== booleanSelect || $[54] !== internalField || $[55] !== internalOperatorOption || $[56] !== internalQueryValue || $[57] !== valueOptions) {
|
|
181
|
-
t9 = RenderedFilter || _jsx(DefaultFilter, {
|
|
182
|
-
booleanSelect,
|
|
183
|
-
disabled: !internalOperatorOption,
|
|
184
|
-
internalField,
|
|
185
|
-
onChange: setInternalQueryValue,
|
|
186
|
-
operator: internalOperatorOption,
|
|
187
|
-
options: valueOptions,
|
|
188
|
-
value: internalQueryValue ?? ""
|
|
189
|
-
});
|
|
190
|
-
$[52] = RenderedFilter;
|
|
191
|
-
$[53] = booleanSelect;
|
|
192
|
-
$[54] = internalField;
|
|
193
|
-
$[55] = internalOperatorOption;
|
|
194
|
-
$[56] = internalQueryValue;
|
|
195
|
-
$[57] = valueOptions;
|
|
196
|
-
$[58] = t9;
|
|
197
|
-
} else {
|
|
198
|
-
t9 = $[58];
|
|
199
|
-
}
|
|
200
|
-
let t10;
|
|
201
|
-
if ($[59] !== andIndex || $[60] !== orIndex || $[61] !== removeCondition) {
|
|
202
|
-
t10 = () => removeCondition({
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
// This is to trigger changes when the debounced value changes
|
|
39
|
+
if ((internalField?.value || typeof internalField?.value === 'number') && internalOperatorOption && ![null, undefined].includes(debouncedValue)) {
|
|
40
|
+
updateCondition({
|
|
203
41
|
andIndex,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
$[59] = andIndex;
|
|
207
|
-
$[60] = orIndex;
|
|
208
|
-
$[61] = removeCondition;
|
|
209
|
-
$[62] = t10;
|
|
210
|
-
} else {
|
|
211
|
-
t10 = $[62];
|
|
212
|
-
}
|
|
213
|
-
let t11;
|
|
214
|
-
if ($[63] !== addCondition || $[64] !== andIndex || $[65] !== fields || $[66] !== orIndex) {
|
|
215
|
-
t11 = () => addCondition({
|
|
216
|
-
andIndex: andIndex + 1,
|
|
217
|
-
fieldName: fields[0].value,
|
|
42
|
+
fieldName: internalField.value,
|
|
43
|
+
operator: internalOperatorOption,
|
|
218
44
|
orIndex,
|
|
219
|
-
|
|
45
|
+
value: debouncedValue
|
|
220
46
|
});
|
|
221
|
-
$[63] = addCondition;
|
|
222
|
-
$[64] = andIndex;
|
|
223
|
-
$[65] = fields;
|
|
224
|
-
$[66] = orIndex;
|
|
225
|
-
$[67] = t11;
|
|
226
|
-
} else {
|
|
227
|
-
t11 = $[67];
|
|
228
47
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
})
|
|
243
|
-
}), _jsx("div", {
|
|
244
|
-
className: `${baseClass}__operator`,
|
|
245
|
-
children: _jsx(ReactSelect, {
|
|
246
|
-
disabled: !internalField?.value && typeof internalField?.value !== "number",
|
|
247
|
-
isClearable: false,
|
|
248
|
-
onChange: t8,
|
|
249
|
-
options: internalField?.operators,
|
|
250
|
-
value: internalField?.operators.find(operator_1 => internalOperatorOption === operator_1.value) || null
|
|
251
|
-
})
|
|
252
|
-
}), _jsx("div", {
|
|
253
|
-
className: `${baseClass}__value`,
|
|
254
|
-
children: t9
|
|
255
|
-
})]
|
|
256
|
-
}), _jsxs("div", {
|
|
257
|
-
className: `${baseClass}__actions`,
|
|
258
|
-
children: [_jsx(Button, {
|
|
259
|
-
buttonStyle: "icon-label",
|
|
260
|
-
className: `${baseClass}__actions-remove`,
|
|
261
|
-
icon: "x",
|
|
262
|
-
iconStyle: "with-border",
|
|
263
|
-
onClick: t10,
|
|
264
|
-
round: true
|
|
265
|
-
}), _jsx(Button, {
|
|
266
|
-
buttonStyle: "icon-label",
|
|
267
|
-
className: `${baseClass}__actions-add`,
|
|
268
|
-
icon: "plus",
|
|
269
|
-
iconStyle: "with-border",
|
|
270
|
-
onClick: t11,
|
|
271
|
-
round: true
|
|
272
|
-
})]
|
|
273
|
-
})]
|
|
274
|
-
})
|
|
275
|
-
});
|
|
276
|
-
$[37] = RenderedFilter;
|
|
277
|
-
$[38] = addCondition;
|
|
278
|
-
$[39] = andIndex;
|
|
279
|
-
$[40] = booleanSelect;
|
|
280
|
-
$[41] = fields;
|
|
281
|
-
$[42] = internalField;
|
|
282
|
-
$[43] = internalOperatorOption;
|
|
283
|
-
$[44] = internalQueryValue;
|
|
284
|
-
$[45] = orIndex;
|
|
285
|
-
$[46] = removeCondition;
|
|
286
|
-
$[47] = t5;
|
|
287
|
-
$[48] = t6;
|
|
288
|
-
$[49] = valueOptions;
|
|
289
|
-
$[50] = t7;
|
|
290
|
-
} else {
|
|
291
|
-
t7 = $[50];
|
|
48
|
+
}, [debouncedValue, andIndex, internalField?.value, internalOperatorOption, orIndex, updateCondition, operator]);
|
|
49
|
+
const booleanSelect = ['exists'].includes(internalOperatorOption) || internalField?.field?.type === 'checkbox';
|
|
50
|
+
let valueOptions;
|
|
51
|
+
if (booleanSelect) {
|
|
52
|
+
valueOptions = [{
|
|
53
|
+
label: t('general:true'),
|
|
54
|
+
value: 'true'
|
|
55
|
+
}, {
|
|
56
|
+
label: t('general:false'),
|
|
57
|
+
value: 'false'
|
|
58
|
+
}];
|
|
59
|
+
} else if (internalField?.field && 'options' in internalField.field) {
|
|
60
|
+
valueOptions = internalField.field.options;
|
|
292
61
|
}
|
|
293
|
-
|
|
62
|
+
const disabled = !internalField?.value && typeof internalField?.value !== 'number' || internalField?.field?.admin?.disableListFilter;
|
|
63
|
+
return /*#__PURE__*/_jsx("div", {
|
|
64
|
+
className: baseClass,
|
|
65
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
66
|
+
className: `${baseClass}__wrap`,
|
|
67
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
68
|
+
className: `${baseClass}__inputs`,
|
|
69
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
70
|
+
className: `${baseClass}__field`,
|
|
71
|
+
children: /*#__PURE__*/_jsx(ReactSelect, {
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
isClearable: false,
|
|
74
|
+
onChange: field_1 => {
|
|
75
|
+
setInternalField(fields.find(f => f.value === field_1.value));
|
|
76
|
+
setInternalOperatorOption(undefined);
|
|
77
|
+
setInternalQueryValue(undefined);
|
|
78
|
+
},
|
|
79
|
+
options: options,
|
|
80
|
+
value: fields.find(field_2 => internalField?.value === field_2.value) || {
|
|
81
|
+
value: internalField?.value
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
85
|
+
className: `${baseClass}__operator`,
|
|
86
|
+
children: /*#__PURE__*/_jsx(ReactSelect, {
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
isClearable: false,
|
|
89
|
+
onChange: operator_0 => {
|
|
90
|
+
setInternalOperatorOption(operator_0.value);
|
|
91
|
+
},
|
|
92
|
+
options: internalField?.operators,
|
|
93
|
+
value: internalField?.operators.find(operator_1 => internalOperatorOption === operator_1.value) || null
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
96
|
+
className: `${baseClass}__value`,
|
|
97
|
+
children: RenderedFilter || /*#__PURE__*/_jsx(DefaultFilter, {
|
|
98
|
+
booleanSelect: booleanSelect,
|
|
99
|
+
disabled: !internalOperatorOption || internalField?.field?.admin?.disableListFilter,
|
|
100
|
+
internalField: internalField,
|
|
101
|
+
onChange: setInternalQueryValue,
|
|
102
|
+
operator: internalOperatorOption,
|
|
103
|
+
options: valueOptions,
|
|
104
|
+
value: internalQueryValue ?? ''
|
|
105
|
+
})
|
|
106
|
+
})]
|
|
107
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
108
|
+
className: `${baseClass}__actions`,
|
|
109
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
110
|
+
buttonStyle: "icon-label",
|
|
111
|
+
className: `${baseClass}__actions-remove`,
|
|
112
|
+
icon: "x",
|
|
113
|
+
iconStyle: "with-border",
|
|
114
|
+
onClick: () => removeCondition({
|
|
115
|
+
andIndex,
|
|
116
|
+
orIndex
|
|
117
|
+
}),
|
|
118
|
+
round: true
|
|
119
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
120
|
+
buttonStyle: "icon-label",
|
|
121
|
+
className: `${baseClass}__actions-add`,
|
|
122
|
+
icon: "plus",
|
|
123
|
+
iconStyle: "with-border",
|
|
124
|
+
onClick: () => addCondition({
|
|
125
|
+
andIndex: andIndex + 1,
|
|
126
|
+
fieldName: fields[0].value,
|
|
127
|
+
orIndex,
|
|
128
|
+
relation: 'and'
|
|
129
|
+
}),
|
|
130
|
+
round: true
|
|
131
|
+
})]
|
|
132
|
+
})]
|
|
133
|
+
})
|
|
134
|
+
});
|
|
294
135
|
};
|
|
295
136
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","useEffect","useState","useDebounce","useTranslation","Button","ReactSelect","DefaultFilter","baseClass","Condition","props","$","addCondition","andIndex","fieldName","fields","initialValue","operator","orIndex","removeCondition","RenderedFilter","updateCondition","t0","find","field","value","internalField","setInternalField","t","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","t1","undefined","includes","t2","t3","t4","type","booleanSelect","valueOptions","t5","t6","label","t7","t8","t9","options","field_0","f","field_1","Symbol","for","operator_0","_jsx","disabled","onChange","t10","t11","relation","className","children","_jsxs","isClearable","operators","operator_1","buttonStyle","icon","iconStyle","onClick","round"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n readonly andIndex: number\n readonly fieldName: string\n readonly fields: FieldCondition[]\n readonly initialValue: string\n readonly operator: Operator\n readonly orIndex: number\n readonly removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n fields,\n initialValue,\n operator,\n orIndex,\n removeCondition,\n RenderedFilter,\n updateCondition,\n } = props\n const [internalField, setInternalField] = useState<FieldCondition>(() =>\n fields.find((field) => fieldName === field.value),\n )\n\n const { t } = useTranslation()\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (internalField?.value || typeof internalField?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: internalField.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n internalField?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || internalField?.field?.type === 'checkbox'\n\n let valueOptions\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (internalField?.field && 'options' in internalField.field) {\n valueOptions = internalField.field.options\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n isClearable={false}\n onChange={(field: Option) => {\n setInternalField(fields.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={fields}\n value={fields.find((field) => internalField?.value === field.value) || fields[0]}\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={!internalField?.value && typeof internalField?.value !== 'number'}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={internalField?.operators}\n value={\n internalField?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={!internalOperatorOption}\n internalField={internalField}\n onChange={setInternalQueryValue}\n operator={internalOperatorOption}\n options={valueOptions}\n value={internalQueryValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n fieldName: fields[0].value,\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AA2C3C,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA6BC,KAAA;EAAA,MAAAC,CAAA,GAAAZ,EAAA;EACx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YAAA6D,IAAA,EACpC;YAAAC,SAAA,EACK;YAAAC,OAAA,EACDZ,GAIP;YAAAa,KAAA;UAAA,C,GAIJhB,IAAA,CAAAnD,MAAA;YAAA+D,WAAA,EACc;YAAAN,SAAA,EACD,GAAAtD,SAAA,eAA2B;YAAA6D,IAAA,EACjC;YAAAC,SAAA,EACK;YAAAC,OAAA,EACDX,GAMP;YAAAY,KAAA;UAAA,C;;;;;;;;;;;;;;;;;;;;;SArEV1B,E;CA6EJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","useEffect","useMemo","useState","useDebounce","useTranslation","Button","ReactSelect","DefaultFilter","baseClass","Condition","props","addCondition","andIndex","fieldName","fields","initialValue","operator","orIndex","removeCondition","RenderedFilter","updateCondition","options","filter","field","admin","disableListFilter","internalField","setInternalField","find","value","t","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","undefined","includes","booleanSelect","type","valueOptions","label","disabled","_jsx","className","_jsxs","isClearable","onChange","f","operators","buttonStyle","icon","iconStyle","onClick","round","relation"],"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n readonly addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n readonly andIndex: number\n readonly fieldName: string\n readonly fields: FieldCondition[]\n readonly initialValue: string\n readonly operator: Operator\n readonly orIndex: number\n readonly removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n readonly RenderedFilter: React.ReactNode\n readonly updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DefaultFilter } from './DefaultFilter/index.js'\nimport './index.scss'\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n fields,\n initialValue,\n operator,\n orIndex,\n removeCondition,\n RenderedFilter,\n updateCondition,\n } = props\n\n const options = useMemo(() => {\n return fields.filter(({ field }) => !field.admin.disableListFilter)\n }, [fields])\n\n const [internalField, setInternalField] = useState<FieldCondition>(() =>\n fields.find((field) => fieldName === field.value),\n )\n\n const { t } = useTranslation()\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (internalField?.value || typeof internalField?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: internalField.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n internalField?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || internalField?.field?.type === 'checkbox'\n\n let valueOptions\n\n if (booleanSelect) {\n valueOptions = [\n { label: t('general:true'), value: 'true' },\n { label: t('general:false'), value: 'false' },\n ]\n } else if (internalField?.field && 'options' in internalField.field) {\n valueOptions = internalField.field.options\n }\n\n const disabled =\n (!internalField?.value && typeof internalField?.value !== 'number') ||\n internalField?.field?.admin?.disableListFilter\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={(field: Option) => {\n setInternalField(fields.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={options}\n value={\n fields.find((field) => internalField?.value === field.value) || {\n value: internalField?.value,\n }\n }\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={disabled}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={internalField?.operators}\n value={\n internalField?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n {RenderedFilter || (\n <DefaultFilter\n booleanSelect={booleanSelect}\n disabled={!internalOperatorOption || internalField?.field?.admin?.disableListFilter}\n internalField={internalField}\n onChange={setInternalQueryValue}\n operator={internalOperatorOption}\n options={valueOptions}\n value={internalQueryValue ?? ''}\n />\n )}\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n fieldName: fields[0].value,\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,IAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AA2CpD,SAASC,WAAW,QAAQ;AAC5B,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,QAAQ;AACvB,SAASC,WAAW,QAAQ;AAC5B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,SAAA,GAA8BC,KAAA;EACzC,MAAM;IACJC,YAAY;IAC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AM,CAAC,EAAE,CAACe,KAAK;YAC1BZ,OAAA;YACAsC,QAAA,EAAU;UACZ;UAEFD,KAAK;;;;;AAMjB","ignoreList":[]}
|
|
@@ -16,7 +16,7 @@ export const reduceClientFields = ({
|
|
|
16
16
|
pathPrefix
|
|
17
17
|
}) => {
|
|
18
18
|
return fields.reduce((reduced, field) => {
|
|
19
|
-
if (
|
|
19
|
+
if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {
|
|
20
20
|
return reduced;
|
|
21
21
|
}
|
|
22
22
|
if (field.type === 'tabs' && 'tabs' in field) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceClientFields.js","names":["getTranslation","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","createNestedClientFieldPath","combineLabel","fieldTypes","reduceClientFields","fields","i18n","labelPrefix","pathPrefix","reduce","reduced","field","
|
|
1
|
+
{"version":3,"file":"reduceClientFields.js","names":["getTranslation","fieldIsHiddenOrDisabled","fieldIsID","tabHasName","createNestedClientFieldPath","combineLabel","fieldTypes","reduceClientFields","fields","i18n","labelPrefix","pathPrefix","reduce","reduced","field","type","tabs","forEach","tab","label","localizedTabLabel","labelWithPrefix","tabPathPrefix","name","push","translatedLabel","pathWithPrefix","operatorKeys","Set","operators","acc","operator","has","value","add","operatorKey","t","localizedLabel","formattedLabel","prefix","formattedValue","formattedField"],"sources":["../../../src/elements/WhereBuilder/reduceClientFields.tsx"],"sourcesContent":["'use client'\nimport type { ClientTranslationKeys, I18nClient } from '@payloadcms/translations'\nimport type { ClientField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { fieldIsHiddenOrDisabled, fieldIsID, tabHasName } from 'payload/shared'\n\nimport type { FieldCondition } from './types.js'\n\nimport { createNestedClientFieldPath } from '../../forms/Form/createNestedClientFieldPath.js'\nimport { combineLabel } from '../FieldSelect/index.js'\nimport fieldTypes from './field-types.js'\n\nexport type ReduceClientFieldsArgs = {\n fields: ClientField[]\n i18n: I18nClient\n labelPrefix?: string\n pathPrefix?: string\n}\n\n/**\n * Reduces a field map to a flat array of fields with labels and values.\n * Used in the WhereBuilder component to render the fields in the dropdown.\n */\nexport const reduceClientFields = ({\n fields,\n i18n,\n labelPrefix,\n pathPrefix,\n}: ReduceClientFieldsArgs): FieldCondition[] => {\n return fields.reduce((reduced, field) => {\n if (fieldIsHiddenOrDisabled(field) && !fieldIsID(field)) {\n return reduced\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n const tabs = field.tabs\n\n tabs.forEach((tab) => {\n if (typeof tab.label !== 'boolean') {\n const localizedTabLabel = getTranslation(tab.label, i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n // Make sure we handle nested tabs\n const tabPathPrefix =\n tabHasName(tab) && tab.name\n ? pathPrefix\n ? pathPrefix + '.' + tab.name\n : tab.name\n : pathPrefix\n\n if (typeof localizedTabLabel === 'string') {\n reduced.push(\n ...reduceClientFields({\n fields: tab.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: tabPathPrefix,\n }),\n )\n }\n }\n })\n return reduced\n }\n\n // Rows cant have labels, so we need to handle them differently\n if (field.type === 'row' && 'fields' in field) {\n reduced.push(\n ...reduceClientFields({\n fields: field.fields,\n i18n,\n labelPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'collapsible' && 'fields' in field) {\n const localizedTabLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? labelPrefix + ' > ' + localizedTabLabel\n : localizedTabLabel\n\n reduced.push(\n ...reduceClientFields({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix,\n }),\n )\n return reduced\n }\n\n if (field.type === 'group' && 'fields' in field) {\n const translatedLabel = getTranslation(field.label || '', i18n)\n\n const labelWithPrefix = labelPrefix\n ? translatedLabel\n ? labelPrefix + ' > ' + translatedLabel\n : labelPrefix\n : translatedLabel\n\n // Make sure we handle deeply nested groups\n const pathWithPrefix = field.name\n ? pathPrefix\n ? pathPrefix + '.' + field.name\n : field.name\n : pathPrefix\n\n reduced.push(\n ...reduceClientFields({\n fields: field.fields,\n i18n,\n labelPrefix: labelWithPrefix,\n pathPrefix: pathWithPrefix,\n }),\n )\n return reduced\n }\n\n if (typeof fieldTypes[field.type] === 'object') {\n const operatorKeys = new Set()\n const operators = fieldTypes[field.type].operators.reduce((acc, operator) => {\n if (!operatorKeys.has(operator.value)) {\n operatorKeys.add(operator.value)\n const operatorKey = `operators:${operator.label}` as ClientTranslationKeys\n acc.push({\n ...operator,\n label: i18n.t(operatorKey),\n })\n }\n return acc\n }, [])\n\n const localizedLabel = getTranslation(field.label || '', i18n)\n\n const formattedLabel = labelPrefix\n ? combineLabel({\n field,\n prefix: labelPrefix,\n })\n : localizedLabel\n\n const formattedValue = pathPrefix\n ? createNestedClientFieldPath(pathPrefix, field)\n : field.name\n\n const formattedField: FieldCondition = {\n label: formattedLabel,\n value: formattedValue,\n ...fieldTypes[field.type],\n field,\n operators,\n }\n\n reduced.push(formattedField)\n return reduced\n }\n return reduced\n }, [])\n}\n"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ;AAC/B,SAASC,uBAAuB,EAAEC,SAAS,EAAEC,UAAU,QAAQ;AAI/D,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,YAAY,QAAQ;AAC7B,OAAOC,UAAA,MAAgB;AASvB;;;;AAIA,OAAO,MAAMC,kBAAA,GAAqBA,CAAC;EACjCC,MAAM;EACNC,IAAI;EACJC,WAAW;EACXC;AAAU,CACa;EACvB,OAAOH,MAAA,CAAOI,MAAM,CAAC,CAACC,OAAA,EAASC,KAAA;IAC7B,IAAIb,uBAAA,CAAwBa,KAAA,KAAU,CAACZ,SAAA,CAAUY,KAAA,GAAQ;MACvD,OAAOD,OAAA;IACT;IAEA,IAAIC,KAAA,CAAMC,IAAI,KAAK,UAAU,UAAUD,KAAA,EAAO;MAC5C,MAA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iBrC,cAAA,CAAec,KAAA,CAAMK,KAAK,IAAI,IAAIV,IAAA;MAEzD,MAAM6B,cAAA,GAAiB5B,WAAA,GACnBL,YAAA,CAAa;QACXS,KAAA;QACAyB,MAAA,EAAQ7B;MACV,KACA2B,cAAA;MAEJ,MAAMG,cAAA,GAAiB7B,UAAA,GACnBP,2BAAA,CAA4BO,UAAA,EAAYG,KAAA,IACxCA,KAAA,CAAMS,IAAI;MAEd,MAAMkB,cAAA,GAAiC;QACrCtB,KAAA,EAAOmB,cAAA;QACPL,KAAA,EAAOO,cAAA;QACP,GAAGlC,UAAU,CAACQ,KAAA,CAAMC,IAAI,CAAC;QACzBD,KAAA;QACAe;MACF;MAEAhB,OAAA,CAAQW,IAAI,CAACiB,cAAA;MACb,OAAO5B,OAAA;IACT;IACA,OAAOA,OAAA;EACT,GAAG,EAAE;AACP","ignoreList":[]}
|
|
@@ -10,5 +10,5 @@ function require(m) {
|
|
|
10
10
|
}
|
|
11
11
|
// Workaround end
|
|
12
12
|
|
|
13
|
-
import{i as a}from"./chunk-
|
|
14
|
-
//# sourceMappingURL=CodeEditor-
|
|
13
|
+
import{i as a}from"./chunk-3MXUY6XL.js";import"./chunk-5LKBKI4T.js";export{a as default};
|
|
14
|
+
//# sourceMappingURL=CodeEditor-W7RSWONH.js.map
|
|
@@ -10,8 +10,8 @@ function require(m) {
|
|
|
10
10
|
}
|
|
11
11
|
// Workaround end
|
|
12
12
|
|
|
13
|
-
import{c as Mr}from"react/compiler-runtime";import{jsx as
|
|
14
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ge(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(r),!0).forEach(function(n){Je(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Qe(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(n){return e.reduceRight(function(o,i){return i(o)},n)}}function W(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}function G(t){return{}.toString.call(t).includes("Object")}function Xe(t){return!Object.keys(t).length}function
|
|
13
|
+
import{c as Mr}from"react/compiler-runtime";import{jsx as Fe}from"react/jsx-runtime";function Ue(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function le(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function re(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?le(Object(r),!0).forEach(function(n){Ue(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function qe(t,e){if(t==null)return{};var r={},n=Object.keys(t),o,i;for(i=0;i<n.length;i++)o=n[i],!(e.indexOf(o)>=0)&&(r[o]=t[o]);return r}function de(t,e){if(t==null)return{};var r=qe(t,e),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function me(t,e){return Be(t)||Ke(t,e)||Ge(t,e)||Ye()}function Be(t){if(Array.isArray(t))return t}function Ke(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,o=!1,i=void 0;try{for(var a=t[Symbol.iterator](),c;!(n=(c=a.next()).done)&&(r.push(c.value),!(e&&r.length===e));n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return!=null&&a.return()}finally{if(o)throw i}}return r}}function Ge(t,e){if(t){if(typeof t=="string")return fe(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fe(t,e)}}function fe(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Ye(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
14
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function ge(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?pe(Object(r),!0).forEach(function(n){Je(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pe(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Qe(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(n){return e.reduceRight(function(o,i){return i(o)},n)}}function W(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}function G(t){return{}.toString.call(t).includes("Object")}function Xe(t){return!Object.keys(t).length}function H(t){return typeof t=="function"}function Ze(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function et(t,e){return G(e)||A("changeType"),Object.keys(e).some(function(r){return!Ze(t,r)})&&A("changeField"),e}function tt(t){H(t)||A("selectorType")}function rt(t){H(t)||G(t)||A("handlerType"),G(t)&&Object.values(t).some(function(e){return!H(e)})&&A("handlersType")}function nt(t){t||A("initialIsRequired"),G(t)||A("initialType"),Xe(t)&&A("initialContent")}function ot(t,e){throw new Error(t[e]||t.default)}var it={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},A=W(ot)(it),K={changes:et,selector:tt,handler:rt,initial:nt};function at(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};K.initial(t),K.handler(e);var r={current:t},n=W(st)(r,e),o=W(ut)(r),i=W(K.changes)(t),a=W(ct)(r);function c(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return K.selector(s),s(r.current)}function u(s){Qe(n,o,i,a)(s)}return[c,u]}function ct(t,e){return H(e)?e(t.current):e}function ut(t,e){return t.current=ge(ge({},t.current),e),e}function st(t,e,r){return H(e)?e(t.current):Object.keys(r).forEach(function(n){var o;return(o=e[n])===null||o===void 0?void 0:o.call(e,t.current[n])}),r}var lt={create:at},he=lt;var ft={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"}},ve=ft;function dt(t){return function e(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=t.length?t.apply(this,o):function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e.apply(r,[].concat(o,c))}}}var ye=dt;function mt(t){return{}.toString.call(t).includes("Object")}var be=mt;function pt(t){return t||we("configIsRequired"),be(t)||we("configType"),t.urls?(gt(),{paths:{vs:t.urls.monacoBase}}):t}function gt(){console.warn(Oe.deprecation)}function ht(t,e){throw new Error(t[e]||t.default)}var Oe={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
15
15
|
You are using deprecated way of configuration.
|
|
16
16
|
|
|
17
17
|
Instead of using
|
|
@@ -20,7 +20,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
20
20
|
monaco.config({ paths: { vs: '...' } })
|
|
21
21
|
|
|
22
22
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
23
|
-
`},we=ye(ht)(Oe),vt={config:pt},je=vt;var yt=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,a){return a(i)},o)}},Me=yt;function xe(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],xe(t[r],e[r]))}),re(re({},t),e)}var Se=xe;var bt={type:"cancelation",msg:"operation is manually canceled"};function wt(t){var e=!1,r=new Promise(function(n,o){t.then(function(i){return e?o(bt):n(i)}),t.catch(o)});return r.cancel=function(){return e=!0},r}var Y=wt;var Ot=he.create({config:ve,isInitialized:!1,resolve:null,reject:null,monaco:null}),Pe=me(Ot,2),H=Pe[0],J=Pe[1];function jt(t){var e=je.config(t),r=e.monaco,n=de(e,["monaco"]);J(function(o){return{config:Se(o.config,n),monaco:r}})}function Mt(){var t=H(function(e){var r=e.monaco,n=e.isInitialized,o=e.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!t.isInitialized){if(J({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Y(ne);if(window.monaco&&window.monaco.editor)return Ce(window.monaco),t.resolve(window.monaco),Y(ne);Me(xt,Pt)(Ct)}return Y(ne)}function xt(t){return document.body.appendChild(t)}function St(t){var e=document.createElement("script");return t&&(e.src=t),e}function Pt(t){var e=H(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=St("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function Ct(){var t=H(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){Ce(r),t.resolve(r)},function(r){t.reject(r)})}function Ce(t){H().monaco||J({monaco:t})}function Et(){return H(function(t){var e=t.monaco;return e})}var ne=new Promise(function(t,e){return J({resolve:t,reject:e})}),Tt={config:jt,init:Mt,__getMonacoInstance:Et},R=Tt;import{memo as It}from"react";import Rt,{useState as Ee,useRef as D,useCallback as Te,useEffect as Ie}from"react";import{memo as At}from"react";import oe from"react";import Lt from"react";import{useEffect as Ht}from"react";import{useEffect as Ut,useRef as qt}from"react";import{useState as ln}from"react";import{memo as Qt}from"react";import Xt,{useState as Re,useEffect as Q,useRef as E,useCallback as Zt}from"react";import{useEffect as er,useRef as tr}from"react";var Dt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ie=Dt,kt={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},_t=kt;function $t({children:t}){return Lt.createElement("div",{style:_t.container},t)}var Nt=$t,Vt=Nt;function Wt({width:t,height:e,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:a}){return oe.createElement("section",{style:{...ie.wrapper,width:t,height:e},...a},!r&&oe.createElement(Vt,null,n),oe.createElement("div",{ref:o,style:{...ie.fullWidth,...!r&&ie.hide},className:i}))}var Ft=Wt,Ae=At(Ft);function zt(t){Ht(t,[])}var De=zt;function Bt(t,e,r=!0){let n=qt(!0);Ut(n.current||!r?()=>{n.current=!1}:t,e)}var C=Bt;function z(){}function L(t,e,r,n){return Kt(t,n)||Gt(t,e,r,n)}function Kt(t,e){return t.editor.getModel(Le(t,e))}function Gt(t,e,r,n){return t.editor.createModel(e,r,n?Le(t,n):void 0)}function Le(t,e){return t.Uri.parse(e)}function Yt({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:s="light",loading:f="Loading...",options:l={},height:h="100%",width:p="100%",className:b,wrapperProps:O={},beforeMount:v=z,onMount:P=z}){let[y,_]=Ee(!1),[$,w]=Ee(!0),j=D(null),g=D(null),N=D(null),x=D(P),d=D(v),A=D(!1);De(()=>{let m=R.init();return m.then(M=>(g.current=M)&&w(!1)).catch(M=>M?.type!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>j.current?V():m.cancel()}),C(()=>{if(j.current&&g.current){let m=j.current.getOriginalEditor(),M=L(g.current,t||"",n||r||"text",i||"");M!==m.getModel()&&m.setModel(M)}},[i],y),C(()=>{if(j.current&&g.current){let m=j.current.getModifiedEditor(),M=L(g.current,e||"",o||r||"text",a||"");M!==m.getModel()&&m.setModel(M)}},[a],y),C(()=>{let m=j.current.getModifiedEditor();m.getOption(g.current.editor.EditorOption.readOnly)?m.setValue(e||""):e!==m.getValue()&&(m.executeEdits("",[{range:m.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),m.pushUndoStop())},[e],y),C(()=>{j.current?.getModel()?.original.setValue(t||"")},[t],y),C(()=>{let{original:m,modified:M}=j.current.getModel();g.current.editor.setModelLanguage(m,n||r||"text"),g.current.editor.setModelLanguage(M,o||r||"text")},[r,n,o],y),C(()=>{g.current?.editor.setTheme(s)},[s],y),C(()=>{j.current?.updateOptions(l)},[l],y);let q=Te(()=>{if(!g.current)return;d.current(g.current);let m=L(g.current,t||"",n||r||"text",i||""),M=L(g.current,e||"",o||r||"text",a||"");j.current?.setModel({original:m,modified:M})},[r,e,o,t,n,i,a]),B=Te(()=>{!A.current&&N.current&&(j.current=g.current.editor.createDiffEditor(N.current,{automaticLayout:!0,...l}),q(),g.current?.editor.setTheme(s),_(!0),A.current=!0)},[l,s,q]);Ie(()=>{y&&x.current(j.current,g.current)},[y]),Ie(()=>{!$&&!y&&B()},[$,y,B]);function V(){let m=j.current?.getModel();c||m?.original?.dispose(),u||m?.modified?.dispose(),j.current?.dispose()}return Rt.createElement(Ae,{width:p,height:h,isEditorReady:y,loading:f,_ref:N,className:b,wrapperProps:O})}var Jt=Yt,un=It(Jt);function rr(t){let e=tr();return er(()=>{e.current=t},[t]),e.current}var nr=rr,X=new Map;function or({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:o,path:i,theme:a="light",line:c,loading:u="Loading...",options:s={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:h=!1,width:p="100%",height:b="100%",className:O,wrapperProps:v={},beforeMount:P=z,onMount:y=z,onChange:_,onValidate:$=z}){let[w,j]=Re(!1),[g,N]=Re(!0),x=E(null),d=E(null),A=E(null),q=E(y),B=E(P),V=E(),m=E(n),M=nr(i),ue=E(!1),Z=E(!1);De(()=>{let S=R.init();return S.then(T=>(x.current=T)&&N(!1)).catch(T=>T?.type!=="cancelation"&&console.error("Monaco initialization: error:",T)),()=>d.current?ze():S.cancel()}),C(()=>{let S=L(x.current,t||n||"",e||o||"",i||r||"");S!==d.current?.getModel()&&(l&&X.set(M,d.current?.saveViewState()),d.current?.setModel(S),l&&d.current?.restoreViewState(X.get(i)))},[i],w),C(()=>{d.current?.updateOptions(s)},[s],w),C(()=>{!d.current||n===void 0||(d.current.getOption(x.current.editor.EditorOption.readOnly)?d.current.setValue(n):n!==d.current.getValue()&&(Z.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),d.current.pushUndoStop(),Z.current=!1))},[n],w),C(()=>{let S=d.current?.getModel();S&&o&&x.current?.editor.setModelLanguage(S,o)},[o],w),C(()=>{c!==void 0&&d.current?.revealLine(c)},[c],w),C(()=>{x.current?.editor.setTheme(a)},[a],w);let se=Zt(()=>{if(!(!A.current||!x.current)&&!ue.current){B.current(x.current);let S=i||r,T=L(x.current,n||t||"",e||o||"",S||"");d.current=x.current?.editor.create(A.current,{model:T,automaticLayout:!0,...s},f),l&&d.current.restoreViewState(X.get(S)),x.current.editor.setTheme(a),c!==void 0&&d.current.revealLine(c),j(!0),ue.current=!0}},[t,e,r,n,o,i,s,f,l,a,c]);Q(()=>{w&&q.current(d.current,x.current)},[w]),Q(()=>{!g&&!w&&se()},[g,w,se]),m.current=n,Q(()=>{w&&_&&(V.current?.dispose(),V.current=d.current?.onDidChangeModelContent(S=>{Z.current||_(d.current.getValue(),S)}))},[w,_]),Q(()=>{if(w){let S=x.current.editor.onDidChangeMarkers(T=>{let ee=d.current.getModel()?.uri;if(ee&&T.find(te=>te.path===ee.path)){let te=x.current.editor.getModelMarkers({resource:ee});$?.(te)}});return()=>{S?.dispose()}}return()=>{}},[w,$]);function ze(){V.current?.dispose(),h?l&&X.set(i,d.current.saveViewState()):d.current.getModel()?.dispose(),d.current.dispose()}return Xt.createElement(Ae,{width:p,height:b,isEditorReady:w,loading:u,_ref:A,className:O,wrapperProps:v})}var ir=or,ar=Qt(ir),ae=ar;import{useState as xr}from"react";import{c as mr}from"react/compiler-runtime";import{jsx as pr}from"react/jsx-runtime";import{createContext as gr,useContext as hr,useEffect as vr,useState as $e}from"react";import{c as cr}from"react/compiler-runtime";import{jsx as ur}from"react/jsx-runtime";import{createContext as sr,useContext as lr,useEffect as fr,useState as dr}from"react";var ke=sr(void 0),jn=t=>{let e=cr(9),{children:r,config:n}=t,[o,i]=dr(n),a,c;e[0]!==n?(a=()=>{i(n)},c=[n],e[0]=n,e[1]=a,e[2]=c):(a=e[1],c=e[2]),fr(a,c);let u;e[3]!==o?(u=l=>{let{collectionSlug:h,globalSlug:p}=l;return h?o.collections.find(b=>b.slug===h):p?o.globals.find(b=>b.slug===p):null},e[3]=o,e[4]=u):u=e[4];let s=u,f;return e[5]!==r||e[6]!==o||e[7]!==s?(f=ur(ke.Provider,{value:{config:o,getEntityConfig:s,setConfig:i},children:r}),e[5]=r,e[6]=o,e[7]=s,e[8]=f):f=e[8],f},_e=()=>lr(ke);var yr={autoMode:!0,setTheme:()=>null,theme:"light"},Ve=gr(yr);function Ne(t,e,r){let n=new Date;n.setTime(n.getTime()+r*24*60*60*1e3);let o="expires="+n.toUTCString();document.cookie=t+"="+e+";"+o+";path=/"}var br=t=>{let e,r=window.document.cookie.split("; ").find(n=>n.startsWith(`${t}=`))?.split("=")[1];return r==="light"||r==="dark"?e=r:e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e),{theme:e,themeFromCookies:r}},wr="light",In=t=>{let e=mr(11),{children:r,theme:n}=t,{config:o}=_e(),i=o.admin.theme,a=`${o.cookiePrefix||"payload"}-theme`,[c,u]=$e(n||wr),[s,f]=$e(),l,h;e[0]!==a||e[1]!==i?(l=()=>{if(i!=="all")return;let{theme:v,themeFromCookies:P}=br(a);u(v),f(!P)},h=[i,a],e[0]=a,e[1]=i,e[2]=l,e[3]=h):(l=e[2],h=e[3]),vr(l,h);let p;e[4]!==a?(p=v=>{if(v==="light"||v==="dark")u(v),f(!1),Ne(a,v,365),document.documentElement.setAttribute("data-theme",v);else if(v==="auto"){Ne(a,v,-1);let P=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",P),f(!0),u(P)}},e[4]=a,e[5]=p):p=e[5];let b=p,O;return e[6]!==s||e[7]!==r||e[8]!==b||e[9]!==c?(O=pr(Ve.Provider,{value:{autoMode:s,setTheme:b,theme:c},children:r}),e[6]=s,e[7]=r,e[8]=b,e[9]=c,e[10]=O):O=e[10],O},We=()=>hr(Ve);import{c as jr}from"react/compiler-runtime";import{jsx as U}from"react/jsx-runtime";import"react";import{c as Or}from"react/compiler-runtime";import*as k from"react";var Fe=(t,e)=>{let r=Or(9),n=e===void 0?!1:e,[o,i]=k.useState(!1),a=k.useRef(void 0),c;r[0]!==t?(c=()=>(i(!1),clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{clearTimeout(a.current)}),r[0]=t,r[1]=c):c=r[1];let u=c,s,f;r[2]!==u||r[3]!==n?(s=()=>{n&&u()},f=[u,n],r[2]=u,r[3]=n,r[4]=s,r[5]=f):(s=r[4],f=r[5]),k.useEffect(s,f);let l;return r[6]!==o||r[7]!==u?(l=[o,u],r[6]=o,r[7]=u,r[8]=l):l=r[8],l};var ce=({animationDelay:t="0ms",height:e="60px",width:r="100%"})=>U("div",{className:"shimmer-effect",style:{height:typeof e=="number"?`${e}px`:e,width:typeof r=="number"?`${r}px`:r},children:U("div",{className:"shimmer-effect__shine",style:{animationDelay:t}})}),Nn=t=>{let e=jr(7),{className:r,count:n,height:o,renderDelay:i,shimmerDelay:a,shimmerItemClassName:c,width:u}=t,s=i===void 0?500:i,f=a===void 0?25:a,l=typeof f=="number"?`${f}ms`:f,[h]=Fe(s,!0);if(!h)return null;let p;return e[0]!==r||e[1]!==n||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==u?(p=U("div",{className:r,children:[...Array(n)].map((b,O)=>U("div",{className:c,children:U(ce,{animationDelay:`calc(${O} * ${l})`,height:o,width:u})},O))}),e[0]=r,e[1]=n,e[2]=o,e[3]=l,e[4]=c,e[5]=u,e[6]=p):p=e[6],p};var Sr=ae.default||ae,Pr="code-editor",Cr=t=>{let e=Mr(21),r,n,o,i,a;e[0]!==t?({className:r,maxHeight:n,options:o,readOnly:i,...a}=t,e[0]=t,e[1]=r,e[2]=n,e[3]=o,e[4]=i,e[5]=a):(r=e[1],n=e[2],o=e[3],i=e[4],a=e[5]);let[c,u]=xr(20),{theme:s}=We(),f=a?.defaultLanguage?`language--${a.defaultLanguage}`:"",l=i&&"read-only",h;e[6]!==r||e[7]!==f||e[8]!==l?(h=[Pr,r,f,l].filter(Boolean),e[6]=r,e[7]=f,e[8]=l,e[9]=h):h=e[9];let p=h.join(" "),b;if(e[10]!==p||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==i||e[15]!==a||e[16]!==s){let O,v;e[18]!==a?(O=(P,y)=>{a.onChange?.(P,y),u(Math.max(56,P.split(`
|
|
24
|
-
`).length*18+2))},
|
|
25
|
-
`).length*18+2))},e[
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
23
|
+
`},we=ye(ht)(Oe),vt={config:pt},je=vt;var yt=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,a){return a(i)},o)}},Me=yt;function xe(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],xe(t[r],e[r]))}),re(re({},t),e)}var Se=xe;var bt={type:"cancelation",msg:"operation is manually canceled"};function wt(t){var e=!1,r=new Promise(function(n,o){t.then(function(i){return e?o(bt):n(i)}),t.catch(o)});return r.cancel=function(){return e=!0},r}var Y=wt;var Ot=he.create({config:ve,isInitialized:!1,resolve:null,reject:null,monaco:null}),Pe=me(Ot,2),F=Pe[0],J=Pe[1];function jt(t){var e=je.config(t),r=e.monaco,n=de(e,["monaco"]);J(function(o){return{config:Se(o.config,n),monaco:r}})}function Mt(){var t=F(function(e){var r=e.monaco,n=e.isInitialized,o=e.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!t.isInitialized){if(J({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Y(ne);if(window.monaco&&window.monaco.editor)return Ce(window.monaco),t.resolve(window.monaco),Y(ne);Me(xt,Pt)(Ct)}return Y(ne)}function xt(t){return document.body.appendChild(t)}function St(t){var e=document.createElement("script");return t&&(e.src=t),e}function Pt(t){var e=F(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=St("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function Ct(){var t=F(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){Ce(r),t.resolve(r)},function(r){t.reject(r)})}function Ce(t){F().monaco||J({monaco:t})}function Et(){return F(function(t){var e=t.monaco;return e})}var ne=new Promise(function(t,e){return J({resolve:t,reject:e})}),Tt={config:jt,init:Mt,__getMonacoInstance:Et},D=Tt;import{memo as It}from"react";import Rt,{useState as Ee,useRef as _,useCallback as Te,useEffect as Ie}from"react";import{memo as At}from"react";import oe from"react";import Lt from"react";import{useEffect as Ft}from"react";import{useEffect as Ut,useRef as qt}from"react";import{useState as ln}from"react";import{memo as Qt}from"react";import Xt,{useState as Re,useEffect as Q,useRef as I,useCallback as Zt}from"react";import{useEffect as er,useRef as tr}from"react";var Dt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ie=Dt,_t={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},kt=_t;function $t({children:t}){return Lt.createElement("div",{style:kt.container},t)}var Nt=$t,Vt=Nt;function Wt({width:t,height:e,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:a}){return oe.createElement("section",{style:{...ie.wrapper,width:t,height:e},...a},!r&&oe.createElement(Vt,null,n),oe.createElement("div",{ref:o,style:{...ie.fullWidth,...!r&&ie.hide},className:i}))}var Ht=Wt,Ae=At(Ht);function zt(t){Ft(t,[])}var De=zt;function Bt(t,e,r=!0){let n=qt(!0);Ut(n.current||!r?()=>{n.current=!1}:t,e)}var C=Bt;function z(){}function k(t,e,r,n){return Kt(t,n)||Gt(t,e,r,n)}function Kt(t,e){return t.editor.getModel(Le(t,e))}function Gt(t,e,r,n){return t.editor.createModel(e,r,n?Le(t,n):void 0)}function Le(t,e){return t.Uri.parse(e)}function Yt({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:u=!1,theme:s="light",loading:f="Loading...",options:l={},height:y="100%",width:p="100%",className:b,wrapperProps:M={},beforeMount:v=z,onMount:P=z}){let[g,E]=Ee(!1),[T,w]=Ee(!0),O=_(null),h=_(null),N=_(null),x=_(P),d=_(v),L=_(!1);De(()=>{let m=D.init();return m.then(j=>(h.current=j)&&w(!1)).catch(j=>j?.type!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>O.current?V():m.cancel()}),C(()=>{if(O.current&&h.current){let m=O.current.getOriginalEditor(),j=k(h.current,t||"",n||r||"text",i||"");j!==m.getModel()&&m.setModel(j)}},[i],g),C(()=>{if(O.current&&h.current){let m=O.current.getModifiedEditor(),j=k(h.current,e||"",o||r||"text",a||"");j!==m.getModel()&&m.setModel(j)}},[a],g),C(()=>{let m=O.current.getModifiedEditor();m.getOption(h.current.editor.EditorOption.readOnly)?m.setValue(e||""):e!==m.getValue()&&(m.executeEdits("",[{range:m.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),m.pushUndoStop())},[e],g),C(()=>{O.current?.getModel()?.original.setValue(t||"")},[t],g),C(()=>{let{original:m,modified:j}=O.current.getModel();h.current.editor.setModelLanguage(m,n||r||"text"),h.current.editor.setModelLanguage(j,o||r||"text")},[r,n,o],g),C(()=>{h.current?.editor.setTheme(s)},[s],g),C(()=>{O.current?.updateOptions(l)},[l],g);let q=Te(()=>{if(!h.current)return;d.current(h.current);let m=k(h.current,t||"",n||r||"text",i||""),j=k(h.current,e||"",o||r||"text",a||"");O.current?.setModel({original:m,modified:j})},[r,e,o,t,n,i,a]),B=Te(()=>{!L.current&&N.current&&(O.current=h.current.editor.createDiffEditor(N.current,{automaticLayout:!0,...l}),q(),h.current?.editor.setTheme(s),E(!0),L.current=!0)},[l,s,q]);Ie(()=>{g&&x.current(O.current,h.current)},[g]),Ie(()=>{!T&&!g&&B()},[T,g,B]);function V(){let m=O.current?.getModel();c||m?.original?.dispose(),u||m?.modified?.dispose(),O.current?.dispose()}return Rt.createElement(Ae,{width:p,height:y,isEditorReady:g,loading:f,_ref:N,className:b,wrapperProps:M})}var Jt=Yt,un=It(Jt);function rr(t){let e=tr();return er(()=>{e.current=t},[t]),e.current}var nr=rr,X=new Map;function or({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:o,path:i,theme:a="light",line:c,loading:u="Loading...",options:s={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:y=!1,width:p="100%",height:b="100%",className:M,wrapperProps:v={},beforeMount:P=z,onMount:g=z,onChange:E,onValidate:T=z}){let[w,O]=Re(!1),[h,N]=Re(!0),x=I(null),d=I(null),L=I(null),q=I(g),B=I(P),V=I(),m=I(n),j=nr(i),ue=I(!1),Z=I(!1);De(()=>{let S=D.init();return S.then(R=>(x.current=R)&&N(!1)).catch(R=>R?.type!=="cancelation"&&console.error("Monaco initialization: error:",R)),()=>d.current?ze():S.cancel()}),C(()=>{let S=k(x.current,t||n||"",e||o||"",i||r||"");S!==d.current?.getModel()&&(l&&X.set(j,d.current?.saveViewState()),d.current?.setModel(S),l&&d.current?.restoreViewState(X.get(i)))},[i],w),C(()=>{d.current?.updateOptions(s)},[s],w),C(()=>{!d.current||n===void 0||(d.current.getOption(x.current.editor.EditorOption.readOnly)?d.current.setValue(n):n!==d.current.getValue()&&(Z.current=!0,d.current.executeEdits("",[{range:d.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),d.current.pushUndoStop(),Z.current=!1))},[n],w),C(()=>{let S=d.current?.getModel();S&&o&&x.current?.editor.setModelLanguage(S,o)},[o],w),C(()=>{c!==void 0&&d.current?.revealLine(c)},[c],w),C(()=>{x.current?.editor.setTheme(a)},[a],w);let se=Zt(()=>{if(!(!L.current||!x.current)&&!ue.current){B.current(x.current);let S=i||r,R=k(x.current,n||t||"",e||o||"",S||"");d.current=x.current?.editor.create(L.current,{model:R,automaticLayout:!0,...s},f),l&&d.current.restoreViewState(X.get(S)),x.current.editor.setTheme(a),c!==void 0&&d.current.revealLine(c),O(!0),ue.current=!0}},[t,e,r,n,o,i,s,f,l,a,c]);Q(()=>{w&&q.current(d.current,x.current)},[w]),Q(()=>{!h&&!w&&se()},[h,w,se]),m.current=n,Q(()=>{w&&E&&(V.current?.dispose(),V.current=d.current?.onDidChangeModelContent(S=>{Z.current||E(d.current.getValue(),S)}))},[w,E]),Q(()=>{if(w){let S=x.current.editor.onDidChangeMarkers(R=>{let ee=d.current.getModel()?.uri;if(ee&&R.find(te=>te.path===ee.path)){let te=x.current.editor.getModelMarkers({resource:ee});T?.(te)}});return()=>{S?.dispose()}}return()=>{}},[w,T]);function ze(){V.current?.dispose(),y?l&&X.set(i,d.current.saveViewState()):d.current.getModel()?.dispose(),d.current.dispose()}return Xt.createElement(Ae,{width:p,height:b,isEditorReady:w,loading:u,_ref:L,className:M,wrapperProps:v})}var ir=or,ar=Qt(ir),ae=ar;import{useState as xr}from"react";import{c as mr}from"react/compiler-runtime";import{jsx as pr}from"react/jsx-runtime";import{createContext as gr,useContext as hr,useEffect as vr,useState as $e}from"react";import{c as cr}from"react/compiler-runtime";import{jsx as ur}from"react/jsx-runtime";import{createContext as sr,useContext as lr,useEffect as fr,useState as dr}from"react";var _e=sr(void 0),jn=t=>{let e=cr(9),{children:r,config:n}=t,[o,i]=dr(n),a,c;e[0]!==n?(a=()=>{i(n)},c=[n],e[0]=n,e[1]=a,e[2]=c):(a=e[1],c=e[2]),fr(a,c);let u;e[3]!==o?(u=l=>{let{collectionSlug:y,globalSlug:p}=l;return y?o.collections.find(b=>b.slug===y):p?o.globals.find(b=>b.slug===p):null},e[3]=o,e[4]=u):u=e[4];let s=u,f;return e[5]!==r||e[6]!==o||e[7]!==s?(f=ur(_e.Provider,{value:{config:o,getEntityConfig:s,setConfig:i},children:r}),e[5]=r,e[6]=o,e[7]=s,e[8]=f):f=e[8],f},ke=()=>lr(_e);var yr={autoMode:!0,setTheme:()=>null,theme:"light"},Ve=gr(yr);function Ne(t,e,r){let n=new Date;n.setTime(n.getTime()+r*24*60*60*1e3);let o="expires="+n.toUTCString();document.cookie=t+"="+e+";"+o+";path=/"}var br=t=>{let e,r=window.document.cookie.split("; ").find(n=>n.startsWith(`${t}=`))?.split("=")[1];return r==="light"||r==="dark"?e=r:e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e),{theme:e,themeFromCookies:r}},wr="light",In=t=>{let e=mr(11),{children:r,theme:n}=t,{config:o}=ke(),i=o.admin.theme,a=`${o.cookiePrefix||"payload"}-theme`,[c,u]=$e(n||wr),[s,f]=$e(),l,y;e[0]!==a||e[1]!==i?(l=()=>{if(i!=="all")return;let{theme:v,themeFromCookies:P}=br(a);u(v),f(!P)},y=[i,a],e[0]=a,e[1]=i,e[2]=l,e[3]=y):(l=e[2],y=e[3]),vr(l,y);let p;e[4]!==a?(p=v=>{if(v==="light"||v==="dark")u(v),f(!1),Ne(a,v,365),document.documentElement.setAttribute("data-theme",v);else if(v==="auto"){Ne(a,v,-1);let P=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",P),f(!0),u(P)}},e[4]=a,e[5]=p):p=e[5];let b=p,M;return e[6]!==s||e[7]!==r||e[8]!==b||e[9]!==c?(M=pr(Ve.Provider,{value:{autoMode:s,setTheme:b,theme:c},children:r}),e[6]=s,e[7]=r,e[8]=b,e[9]=c,e[10]=M):M=e[10],M},We=()=>hr(Ve);import{c as jr}from"react/compiler-runtime";import{jsx as U}from"react/jsx-runtime";import"react";import{c as Or}from"react/compiler-runtime";import*as $ from"react";var He=(t,e)=>{let r=Or(9),n=e===void 0?!1:e,[o,i]=$.useState(!1),a=$.useRef(void 0),c;r[0]!==t?(c=()=>(i(!1),clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{clearTimeout(a.current)}),r[0]=t,r[1]=c):c=r[1];let u=c,s,f;r[2]!==u||r[3]!==n?(s=()=>{n&&u()},f=[u,n],r[2]=u,r[3]=n,r[4]=s,r[5]=f):(s=r[4],f=r[5]),$.useEffect(s,f);let l;return r[6]!==o||r[7]!==u?(l=[o,u],r[6]=o,r[7]=u,r[8]=l):l=r[8],l};var ce=({animationDelay:t="0ms",height:e="60px",width:r="100%"})=>U("div",{className:"shimmer-effect",style:{height:typeof e=="number"?`${e}px`:e,width:typeof r=="number"?`${r}px`:r},children:U("div",{className:"shimmer-effect__shine",style:{animationDelay:t}})}),Nn=t=>{let e=jr(7),{className:r,count:n,height:o,renderDelay:i,shimmerDelay:a,shimmerItemClassName:c,width:u}=t,s=i===void 0?500:i,f=a===void 0?25:a,l=typeof f=="number"?`${f}ms`:f,[y]=He(s,!0);if(!y)return null;let p;return e[0]!==r||e[1]!==n||e[2]!==o||e[3]!==l||e[4]!==c||e[5]!==u?(p=U("div",{className:r,children:[...Array(n)].map((b,M)=>U("div",{className:c,children:U(ce,{animationDelay:`calc(${M} * ${l})`,height:o,width:u})},M))}),e[0]=r,e[1]=n,e[2]=o,e[3]=l,e[4]=c,e[5]=u,e[6]=p):p=e[6],p};var Sr=ae.default||ae,Pr="code-editor",Cr=t=>{let e=Mr(24),r,n,o,i,a,c;e[0]!==t?({className:r,maxHeight:n,minHeight:o,options:i,readOnly:a,...c}=t,e[0]=t,e[1]=r,e[2]=n,e[3]=o,e[4]=i,e[5]=a,e[6]=c):(r=e[1],n=e[2],o=e[3],i=e[4],a=e[5],c=e[6]);let u=o??56,[s,f]=xr(u),{theme:l}=We(),y=c?.defaultLanguage?`language--${c.defaultLanguage}`:"",p=a&&"read-only",b;e[7]!==r||e[8]!==y||e[9]!==p?(b=[Pr,r,y,p].filter(Boolean),e[7]=r,e[8]=y,e[9]=p,e[10]=b):b=e[10];let M=b.join(" "),v;if(e[11]!==u||e[12]!==M||e[13]!==s||e[14]!==n||e[15]!==i||e[16]!==a||e[17]!==c||e[18]!==l){let P,g;e[20]!==u||e[21]!==c?(P=(E,T)=>{c.onChange?.(E,T),f(Math.max(u,E.split(`
|
|
24
|
+
`).length*18+2))},g=(E,T)=>{c.onMount?.(E,T),f(Math.max(u,E.getValue().split(`
|
|
25
|
+
`).length*18+2))},e[20]=u,e[21]=c,e[22]=P,e[23]=g):(P=e[22],g=e[23]),v=Fe(Sr,{className:M,loading:Fe(ce,{height:s}),options:{detectIndentation:!0,hideCursorInOverviewRuler:!0,minimap:{enabled:!1},overviewRulerBorder:!1,readOnly:!!a,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",...i},theme:l==="dark"?"vs-dark":"vs",...c,height:n?Math.min(s,n):s,onChange:P,onMount:g}),e[11]=u,e[12]=M,e[13]=s,e[14]=n,e[15]=i,e[16]=a,e[17]=c,e[18]=l,e[19]=v}else v=e[19];return v},Kn=Cr;export{jn as a,ke as b,He as c,ce as d,Nn as e,wr as f,In as g,We as h,Kn as i};
|
|
26
|
+
//# sourceMappingURL=chunk-3MXUY6XL.js.map
|