@panneau/fields 5.0.0-alpha.6 → 5.0.0-alpha.7

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.
Files changed (67) hide show
  1. package/dist/boolean/BooleanField.js +78 -17
  2. package/dist/boolean/BooleanField.js.map +1 -1
  3. package/dist/color/ColorField.js.map +1 -1
  4. package/dist/date/DateField.js.map +1 -1
  5. package/dist/datetime/DateTimeField.js +107 -20
  6. package/dist/datetime/DateTimeField.js.map +1 -1
  7. package/dist/duration/DurationField.js +126 -41
  8. package/dist/duration/DurationField.js.map +1 -1
  9. package/dist/email/EmailField.js.map +1 -1
  10. package/dist/embed/EmbedField.js +185 -69
  11. package/dist/embed/EmbedField.js.map +1 -1
  12. package/dist/file/FileField.d.ts.map +1 -1
  13. package/dist/file/FileField.js +167 -77
  14. package/dist/file/FileField.js.map +1 -1
  15. package/dist/group/GroupField.js.map +1 -1
  16. package/dist/json/JsonField.js +104 -22
  17. package/dist/json/JsonField.js.map +1 -1
  18. package/dist/locales/index.js.map +1 -1
  19. package/dist/localized/LocalizedField.js.map +1 -1
  20. package/dist/location/LocationField.d.ts.map +1 -1
  21. package/dist/location/LocationField.js +351 -138
  22. package/dist/location/LocationField.js.map +1 -1
  23. package/dist/location/LocationMap.d.ts.map +1 -1
  24. package/dist/location/LocationMap.js +155 -65
  25. package/dist/location/LocationMap.js.map +1 -1
  26. package/dist/location/leafletCss.js.map +1 -1
  27. package/dist/location/nominatim.js.map +1 -1
  28. package/dist/missing/MissingField.d.ts +3 -2
  29. package/dist/missing/MissingField.d.ts.map +1 -1
  30. package/dist/missing/MissingField.js +3 -2
  31. package/dist/missing/MissingField.js.map +1 -1
  32. package/dist/number/NumberField.js.map +1 -1
  33. package/dist/range/RangeField.js +82 -11
  34. package/dist/range/RangeField.js.map +1 -1
  35. package/dist/relation/RelationField.js +485 -145
  36. package/dist/relation/RelationField.js.map +1 -1
  37. package/dist/repeater/RepeaterField.js +118 -34
  38. package/dist/repeater/RepeaterField.js.map +1 -1
  39. package/dist/select/SelectField.js.map +1 -1
  40. package/dist/shared/DefinitionField.js.map +1 -1
  41. package/dist/shared/builtIn.js.map +1 -1
  42. package/dist/shared/check.js.map +1 -1
  43. package/dist/shared/context.js.map +1 -1
  44. package/dist/shared/cx.js.map +1 -1
  45. package/dist/shared/dates.js.map +1 -1
  46. package/dist/shared/embed.js.map +1 -1
  47. package/dist/shared/entry.js.map +1 -1
  48. package/dist/shared/relation.js.map +1 -1
  49. package/dist/slug/SlugField.d.ts.map +1 -1
  50. package/dist/slug/SlugField.js +184 -36
  51. package/dist/slug/SlugField.js.map +1 -1
  52. package/dist/tags/TagsField.js.map +1 -1
  53. package/dist/tel/TelField.js.map +1 -1
  54. package/dist/text/TextField.js.map +1 -1
  55. package/dist/textarea/TextAreaField.js.map +1 -1
  56. package/dist/time/TimeField.js +64 -10
  57. package/dist/time/TimeField.js.map +1 -1
  58. package/dist/upload/FilePicker.js +107 -24
  59. package/dist/upload/FilePicker.js.map +1 -1
  60. package/dist/upload/UploadList.js.map +1 -1
  61. package/dist/upload/files.js.map +1 -1
  62. package/dist/upload/useRejectionMessage.js.map +1 -1
  63. package/dist/upload/useUploads.js.map +1 -1
  64. package/dist/uppy/uploader.js.map +1 -1
  65. package/dist/url/UrlField.js +69 -14
  66. package/dist/url/UrlField.js.map +1 -1
  67. package/package.json +4 -4
@@ -13,52 +13,92 @@ import { X } from "lucide-react";
13
13
  /** The id of the "Create “…”" option of the picker. */
14
14
  var CREATE_ID = "\0create";
15
15
  /** Results of a search in a relation source, as it types. */
16
- function useRelationSearch(source, resource, query, { enabled = true, delay = 250 } = {}) {
17
- const [state, setState] = useState({
18
- key: "",
19
- items: [],
20
- isLoading: false
21
- });
16
+ function useRelationSearch(source, resource, query, t0) {
17
+ const $ = c(14);
18
+ let t1;
19
+ if ($[0] !== t0) {
20
+ t1 = t0 === void 0 ? {} : t0;
21
+ $[0] = t0;
22
+ $[1] = t1;
23
+ } else t1 = $[1];
24
+ const { enabled: t2, delay: t3 } = t1;
25
+ const enabled = t2 === void 0 ? true : t2;
26
+ const delay = t3 === void 0 ? 250 : t3;
27
+ let t4;
28
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
29
+ t4 = {
30
+ key: "",
31
+ items: [],
32
+ isLoading: false
33
+ };
34
+ $[2] = t4;
35
+ } else t4 = $[2];
36
+ const [state, setState] = useState(t4);
22
37
  const key = `${resource}\u0000${query}`;
23
- useEffect(() => {
24
- if (source === null || !enabled) return;
25
- const controller = new AbortController();
26
- const timer = setTimeout(() => {
27
- setState((current) => ({
28
- ...current,
29
- key,
30
- isLoading: true
31
- }));
32
- source.search(resource, query, { signal: controller.signal }).then((items) => {
33
- if (!controller.signal.aborted) setState({
34
- key,
35
- items,
36
- isLoading: false
37
- });
38
- }).catch(() => {
39
- if (!controller.signal.aborted) setState({
38
+ let t5;
39
+ let t6;
40
+ if ($[3] !== delay || $[4] !== enabled || $[5] !== key || $[6] !== query || $[7] !== resource || $[8] !== source) {
41
+ t5 = () => {
42
+ if (source === null || !enabled) return;
43
+ const controller = new AbortController();
44
+ const timer = setTimeout(() => {
45
+ setState((current) => ({
46
+ ...current,
40
47
  key,
41
- items: [],
42
- isLoading: false
48
+ isLoading: true
49
+ }));
50
+ source.search(resource, query, { signal: controller.signal }).then((items) => {
51
+ if (!controller.signal.aborted) setState({
52
+ key,
53
+ items,
54
+ isLoading: false
55
+ });
56
+ }).catch(() => {
57
+ if (!controller.signal.aborted) setState({
58
+ key,
59
+ items: [],
60
+ isLoading: false
61
+ });
43
62
  });
44
- });
45
- }, delay);
46
- return () => {
47
- clearTimeout(timer);
48
- controller.abort();
63
+ }, delay);
64
+ return () => {
65
+ clearTimeout(timer);
66
+ controller.abort();
67
+ };
49
68
  };
50
- }, [
51
- source,
52
- resource,
53
- query,
54
- key,
55
- enabled,
56
- delay
57
- ]);
58
- return {
59
- items: state.items,
60
- isLoading: state.isLoading || state.key !== key
61
- };
69
+ t6 = [
70
+ source,
71
+ resource,
72
+ query,
73
+ key,
74
+ enabled,
75
+ delay
76
+ ];
77
+ $[3] = delay;
78
+ $[4] = enabled;
79
+ $[5] = key;
80
+ $[6] = query;
81
+ $[7] = resource;
82
+ $[8] = source;
83
+ $[9] = t5;
84
+ $[10] = t6;
85
+ } else {
86
+ t5 = $[9];
87
+ t6 = $[10];
88
+ }
89
+ useEffect(t5, t6);
90
+ const t7 = state.isLoading || state.key !== key;
91
+ let t8;
92
+ if ($[11] !== state.items || $[12] !== t7) {
93
+ t8 = {
94
+ items: state.items,
95
+ isLoading: t7
96
+ };
97
+ $[11] = state.items;
98
+ $[12] = t7;
99
+ $[13] = t8;
100
+ } else t8 = $[13];
101
+ return t8;
62
102
  }
63
103
  function References(t0) {
64
104
  const $ = c(12);
@@ -117,81 +157,216 @@ function References(t0) {
117
157
  * references and can't change them.
118
158
  */
119
159
  function RelationField(props) {
160
+ const $ = c(143);
120
161
  const intl = usePanneauIntl();
121
162
  const context = useFieldsContext();
122
163
  const source = props.source === void 0 ? context.relationSource : props.source;
123
- const { resource, label, description, errors, disabled, readOnly, required, placeholder = intl.formatMessage(messages.search), onBlur, name, id, className, labelClassName, descriptionClassName, errorsClassName, controlClassName } = props;
124
- const selected = useRelationReferences(source, resource, toReferences(props.value));
164
+ const { resource, label, description, errors, disabled, readOnly, required, onBlur, name, id, className, labelClassName, descriptionClassName, errorsClassName, controlClassName } = props;
165
+ let t0;
166
+ if ($[0] !== intl || $[1] !== props.placeholder) {
167
+ t0 = props.placeholder ?? intl.formatMessage(messages.search);
168
+ $[0] = intl;
169
+ $[1] = props.placeholder;
170
+ $[2] = t0;
171
+ } else t0 = $[2];
172
+ const placeholder = t0;
173
+ let t1;
174
+ if ($[3] !== props.value) {
175
+ t1 = toReferences(props.value);
176
+ $[3] = props.value;
177
+ $[4] = t1;
178
+ } else t1 = $[4];
179
+ const selected = useRelationReferences(source, resource, t1);
125
180
  const [query, setQuery] = useState(null);
126
181
  const [creating, setCreating] = useState(false);
127
182
  const [createError, setCreateError] = useState(null);
128
183
  const editable = source !== null && disabled !== true && readOnly !== true;
129
- const { items: found, isLoading: searching } = useRelationSearch(source, resource, query ?? "", { enabled: editable });
184
+ let t2;
185
+ if ($[5] !== editable) {
186
+ t2 = { enabled: editable };
187
+ $[5] = editable;
188
+ $[6] = t2;
189
+ } else t2 = $[6];
190
+ const { items: found, isLoading: searching } = useRelationSearch(source, resource, query ?? "", t2);
130
191
  const sourceCreate = source?.create;
131
- const create = props.onCreate !== void 0 ? props.onCreate : sourceCreate !== void 0 && source?.canCreate?.(resource) !== false ? (text) => sourceCreate.call(source, resource, text) : null;
132
- const text_0 = (query ?? "").trim();
133
- const items = create !== null && text_0 !== "" && !searching && ![...found, ...selected].some((item) => item.label.toLocaleLowerCase(intl.locale) === text_0.toLocaleLowerCase(intl.locale)) ? [...found, {
134
- id: CREATE_ID,
135
- label: intl.formatMessage(messages.createRelation, { text: text_0 })
136
- }] : found;
137
- const isLoading = searching || creating;
138
- const allErrors = createError !== null ? [...errors ?? [], createError] : errors;
139
- /** Creates an item from the text, then adds its reference with `add`. */
140
- const createFrom = (add) => {
141
- if (create === null) return;
142
- setCreating(true);
143
- setCreateError(null);
144
- create(text_0).then((reference) => {
145
- if (reference !== null) {
146
- add(reference);
147
- setQuery(null);
192
+ let t3;
193
+ if ($[7] !== props.onCreate || $[8] !== resource || $[9] !== source || $[10] !== sourceCreate) {
194
+ t3 = props.onCreate !== void 0 ? props.onCreate : sourceCreate !== void 0 && source?.canCreate?.(resource) !== false ? (text) => sourceCreate.call(source, resource, text) : null;
195
+ $[7] = props.onCreate;
196
+ $[8] = resource;
197
+ $[9] = source;
198
+ $[10] = sourceCreate;
199
+ $[11] = t3;
200
+ } else t3 = $[11];
201
+ const create = t3;
202
+ const t4 = query ?? "";
203
+ let allErrors;
204
+ let createFrom;
205
+ let isLoading;
206
+ let items;
207
+ let t5;
208
+ if ($[12] !== className || $[13] !== controlClassName || $[14] !== create || $[15] !== createError || $[16] !== creating || $[17] !== description || $[18] !== descriptionClassName || $[19] !== disabled || $[20] !== editable || $[21] !== errors || $[22] !== errorsClassName || $[23] !== found || $[24] !== id || $[25] !== intl || $[26] !== label || $[27] !== labelClassName || $[28] !== name || $[29] !== onBlur || $[30] !== placeholder || $[31] !== props || $[32] !== query || $[33] !== readOnly || $[34] !== required || $[35] !== searching || $[36] !== selected || $[37] !== source || $[38] !== t4) {
209
+ t5 = Symbol.for("react.early_return_sentinel");
210
+ bb0: {
211
+ const text_0 = t4.trim();
212
+ items = create !== null && text_0 !== "" && !searching && ![...found, ...selected].some((item) => item.label.toLocaleLowerCase(intl.locale) === text_0.toLocaleLowerCase(intl.locale)) ? [...found, {
213
+ id: CREATE_ID,
214
+ label: intl.formatMessage(messages.createRelation, { text: text_0 })
215
+ }] : found;
216
+ isLoading = searching || creating;
217
+ let t6;
218
+ if ($[44] !== createError || $[45] !== errors) {
219
+ t6 = createError !== null ? [...errors ?? [], createError] : errors;
220
+ $[44] = createError;
221
+ $[45] = errors;
222
+ $[46] = t6;
223
+ } else t6 = $[46];
224
+ allErrors = t6;
225
+ createFrom = (add) => {
226
+ if (create === null) return;
227
+ setCreating(true);
228
+ setCreateError(null);
229
+ create(text_0).then((reference) => {
230
+ if (reference !== null) {
231
+ add(reference);
232
+ setQuery(null);
233
+ }
234
+ }).catch(() => setCreateError(intl.formatMessage(messages.createRelationFailed, { text: text_0 }))).finally(() => setCreating(false));
235
+ };
236
+ let t7;
237
+ if ($[47] !== intl) {
238
+ t7 = (reference_0) => `${intl.formatMessage(messages.remove)} ${reference_0.label}`;
239
+ $[47] = intl;
240
+ $[48] = t7;
241
+ } else t7 = $[48];
242
+ const removeLabel = t7;
243
+ let t8;
244
+ if ($[49] !== allErrors || $[50] !== className || $[51] !== descriptionClassName || $[52] !== errorsClassName || $[53] !== label || $[54] !== labelClassName || $[55] !== required) {
245
+ t8 = {
246
+ legend: label,
247
+ errors: allErrors,
248
+ isRequired: required,
249
+ className,
250
+ legendClassName: labelClassName,
251
+ descriptionClassName,
252
+ errorsClassName
253
+ };
254
+ $[49] = allErrors;
255
+ $[50] = className;
256
+ $[51] = descriptionClassName;
257
+ $[52] = errorsClassName;
258
+ $[53] = label;
259
+ $[54] = labelClassName;
260
+ $[55] = required;
261
+ $[56] = t8;
262
+ } else t8 = $[56];
263
+ const chrome = t8;
264
+ if (!editable) {
265
+ let t9;
266
+ if ($[57] !== description || $[58] !== disabled || $[59] !== intl || $[60] !== readOnly || $[61] !== source) {
267
+ t9 = source === null && disabled !== true && readOnly !== true ? /* @__PURE__ */ jsxs(Fragment, { children: [
268
+ description,
269
+ " ",
270
+ intl.formatMessage(messages.relationUnavailable)
271
+ ] }) : description;
272
+ $[57] = description;
273
+ $[58] = disabled;
274
+ $[59] = intl;
275
+ $[60] = readOnly;
276
+ $[61] = source;
277
+ $[62] = t9;
278
+ } else t9 = $[62];
279
+ let t10;
280
+ if ($[63] !== intl || $[64] !== removeLabel || $[65] !== selected) {
281
+ t10 = selected.length > 0 ? /* @__PURE__ */ jsx(References, {
282
+ references: selected,
283
+ removeLabel
284
+ }) : /* @__PURE__ */ jsx("span", {
285
+ className: RelationField_module_default.none,
286
+ children: intl.formatMessage(messages.noRelation)
287
+ });
288
+ $[63] = intl;
289
+ $[64] = removeLabel;
290
+ $[65] = selected;
291
+ $[66] = t10;
292
+ } else t10 = $[66];
293
+ let t11;
294
+ if ($[67] !== chrome || $[68] !== t10 || $[69] !== t9) {
295
+ t11 = /* @__PURE__ */ jsx(Fieldset, {
296
+ ...chrome,
297
+ description: t9,
298
+ children: t10
299
+ });
300
+ $[67] = chrome;
301
+ $[68] = t10;
302
+ $[69] = t9;
303
+ $[70] = t11;
304
+ } else t11 = $[70];
305
+ t5 = t11;
306
+ break bb0;
148
307
  }
149
- }).catch(() => setCreateError(intl.formatMessage(messages.createRelationFailed, { text: text_0 }))).finally(() => setCreating(false));
150
- };
151
- const removeLabel = (reference_0) => `${intl.formatMessage(messages.remove)} ${reference_0.label}`;
152
- const chrome = {
153
- legend: label,
154
- errors: allErrors,
155
- isRequired: required,
156
- className,
157
- legendClassName: labelClassName,
158
- descriptionClassName,
159
- errorsClassName
160
- };
161
- if (!editable) return /* @__PURE__ */ jsx(Fieldset, {
162
- ...chrome,
163
- description: source === null && disabled !== true && readOnly !== true ? /* @__PURE__ */ jsxs(Fragment, { children: [
164
- description,
165
- " ",
166
- intl.formatMessage(messages.relationUnavailable)
167
- ] }) : description,
168
- children: selected.length > 0 ? /* @__PURE__ */ jsx(References, {
169
- references: selected,
170
- removeLabel
171
- }) : /* @__PURE__ */ jsx("span", {
172
- className: RelationField_module_default.none,
173
- children: intl.formatMessage(messages.noRelation)
174
- })
175
- });
176
- const comboLabel = typeof label === "string" ? label : props["aria-label"];
177
- if (props.multiple === true) {
178
- const { onChange } = props;
179
- const set = (next) => onChange?.(next.length > 0 ? next : null);
180
- return /* @__PURE__ */ jsx(Fieldset, {
181
- ...chrome,
182
- description,
183
- children: /* @__PURE__ */ jsxs("div", {
184
- className: RelationField_module_default.multiple,
185
- children: [selected.length > 0 ? /* @__PURE__ */ jsx(References, {
186
- references: selected,
187
- removeLabel,
188
- onRemove: (reference_1) => set(selected.filter((entry) => entry.id !== reference_1.id))
189
- }) : null, /* @__PURE__ */ jsx(ComboBox, {
308
+ const comboLabel = typeof label === "string" ? label : props["aria-label"];
309
+ if (props.multiple === true) {
310
+ const { onChange } = props;
311
+ let t9;
312
+ if ($[71] !== onChange) {
313
+ t9 = (next) => onChange?.(next.length > 0 ? next : null);
314
+ $[71] = onChange;
315
+ $[72] = t9;
316
+ } else t9 = $[72];
317
+ const set = t9;
318
+ let t10;
319
+ if ($[73] !== removeLabel || $[74] !== selected || $[75] !== set) {
320
+ t10 = selected.length > 0 ? /* @__PURE__ */ jsx(References, {
321
+ references: selected,
322
+ removeLabel,
323
+ onRemove: (reference_1) => set(selected.filter((entry) => entry.id !== reference_1.id))
324
+ }) : null;
325
+ $[73] = removeLabel;
326
+ $[74] = selected;
327
+ $[75] = set;
328
+ $[76] = t10;
329
+ } else t10 = $[76];
330
+ let t11;
331
+ if ($[77] !== selected) {
332
+ t11 = (item_0) => !selected.some((entry_0) => entry_0.id === item_0.id);
333
+ $[77] = selected;
334
+ $[78] = t11;
335
+ } else t11 = $[78];
336
+ const t12 = items.filter(t11).map(_temp);
337
+ let t13;
338
+ if ($[79] !== intl) {
339
+ t13 = intl.formatMessage(messages.noResults);
340
+ $[79] = intl;
341
+ $[80] = t13;
342
+ } else t13 = $[80];
343
+ let t14;
344
+ if ($[81] !== onBlur) {
345
+ t14 = onBlur !== void 0 ? { onBlur: () => onBlur() } : {};
346
+ $[81] = onBlur;
347
+ $[82] = t14;
348
+ } else t14 = $[82];
349
+ let t15;
350
+ if ($[83] !== name) {
351
+ t15 = name !== void 0 ? { name } : {};
352
+ $[83] = name;
353
+ $[84] = t15;
354
+ } else t15 = $[84];
355
+ let t16;
356
+ if ($[85] !== id) {
357
+ t16 = id !== void 0 ? { id } : {};
358
+ $[85] = id;
359
+ $[86] = t16;
360
+ } else t16 = $[86];
361
+ let t17;
362
+ if ($[87] !== controlClassName) {
363
+ t17 = controlClassName !== void 0 ? { controlClassName } : {};
364
+ $[87] = controlClassName;
365
+ $[88] = t17;
366
+ } else t17 = $[88];
367
+ const t18 = /* @__PURE__ */ jsx(ComboBox, {
190
368
  "aria-label": comboLabel,
191
- items: items.filter((item_0) => !selected.some((entry_0) => entry_0.id === item_0.id)).map((item_1) => ({
192
- id: item_1.id,
193
- label: item_1.label
194
- })),
369
+ items: t12,
195
370
  value: null,
196
371
  inputValue: query ?? "",
197
372
  onInputChange: setQuery,
@@ -208,40 +383,121 @@ function RelationField(props) {
208
383
  },
209
384
  isLoading,
210
385
  placeholder,
211
- emptyMessage: intl.formatMessage(messages.noResults),
212
- ...onBlur !== void 0 ? { onBlur: () => onBlur() } : {},
213
- ...name !== void 0 ? { name } : {},
214
- ...id !== void 0 ? { id } : {},
215
- ...controlClassName !== void 0 ? { controlClassName } : {}
216
- })]
217
- })
218
- });
386
+ emptyMessage: t13,
387
+ ...t14,
388
+ ...t15,
389
+ ...t16,
390
+ ...t17
391
+ });
392
+ let t19;
393
+ if ($[89] !== t10 || $[90] !== t18) {
394
+ t19 = /* @__PURE__ */ jsxs("div", {
395
+ className: RelationField_module_default.multiple,
396
+ children: [t10, t18]
397
+ });
398
+ $[89] = t10;
399
+ $[90] = t18;
400
+ $[91] = t19;
401
+ } else t19 = $[91];
402
+ let t20;
403
+ if ($[92] !== chrome || $[93] !== description || $[94] !== t19) {
404
+ t20 = /* @__PURE__ */ jsx(Fieldset, {
405
+ ...chrome,
406
+ description,
407
+ children: t19
408
+ });
409
+ $[92] = chrome;
410
+ $[93] = description;
411
+ $[94] = t19;
412
+ $[95] = t20;
413
+ } else t20 = $[95];
414
+ t5 = t20;
415
+ break bb0;
416
+ }
417
+ }
418
+ $[12] = className;
419
+ $[13] = controlClassName;
420
+ $[14] = create;
421
+ $[15] = createError;
422
+ $[16] = creating;
423
+ $[17] = description;
424
+ $[18] = descriptionClassName;
425
+ $[19] = disabled;
426
+ $[20] = editable;
427
+ $[21] = errors;
428
+ $[22] = errorsClassName;
429
+ $[23] = found;
430
+ $[24] = id;
431
+ $[25] = intl;
432
+ $[26] = label;
433
+ $[27] = labelClassName;
434
+ $[28] = name;
435
+ $[29] = onBlur;
436
+ $[30] = placeholder;
437
+ $[31] = props;
438
+ $[32] = query;
439
+ $[33] = readOnly;
440
+ $[34] = required;
441
+ $[35] = searching;
442
+ $[36] = selected;
443
+ $[37] = source;
444
+ $[38] = t4;
445
+ $[39] = allErrors;
446
+ $[40] = createFrom;
447
+ $[41] = isLoading;
448
+ $[42] = items;
449
+ $[43] = t5;
450
+ } else {
451
+ allErrors = $[39];
452
+ createFrom = $[40];
453
+ isLoading = $[41];
454
+ items = $[42];
455
+ t5 = $[43];
219
456
  }
457
+ if (t5 !== Symbol.for("react.early_return_sentinel")) return t5;
220
458
  const { onChange: onChange_0 } = props;
221
459
  const current = selected[0] ?? null;
222
- const shown = current !== null && !items.some((item_3) => item_3.id === current.id) ? [current, ...items] : items;
223
- return /* @__PURE__ */ jsx(ComboBox, {
224
- label,
225
- description,
226
- errors: allErrors,
227
- isRequired: required,
228
- className,
229
- labelClassName,
230
- descriptionClassName,
231
- errorsClassName,
232
- ...controlClassName !== void 0 ? { controlClassName } : {},
233
- ...props["aria-label"] !== void 0 ? { "aria-label": props["aria-label"] } : {},
234
- items: shown.map((item_4) => ({
235
- id: item_4.id,
236
- label: item_4.label
237
- })),
238
- value: current?.id ?? null,
239
- inputValue: query ?? current?.label ?? "",
240
- onInputChange: (text_1) => {
460
+ let t6;
461
+ if ($[96] !== current || $[97] !== items) {
462
+ t6 = current !== null && !items.some((item_3) => item_3.id === current.id) ? [current, ...items] : items;
463
+ $[96] = current;
464
+ $[97] = items;
465
+ $[98] = t6;
466
+ } else t6 = $[98];
467
+ const shown = t6;
468
+ let t7;
469
+ if ($[99] !== controlClassName) {
470
+ t7 = controlClassName !== void 0 ? { controlClassName } : {};
471
+ $[99] = controlClassName;
472
+ $[100] = t7;
473
+ } else t7 = $[100];
474
+ let t8;
475
+ if ($[101] !== props) {
476
+ t8 = props["aria-label"] !== void 0 ? { "aria-label": props["aria-label"] } : {};
477
+ $[101] = props;
478
+ $[102] = t8;
479
+ } else t8 = $[102];
480
+ let t9;
481
+ if ($[103] !== shown) {
482
+ t9 = shown.map(_temp2);
483
+ $[103] = shown;
484
+ $[104] = t9;
485
+ } else t9 = $[104];
486
+ const t10 = current?.id ?? null;
487
+ const t11 = query ?? current?.label ?? "";
488
+ let t12;
489
+ if ($[105] !== current || $[106] !== onChange_0) {
490
+ t12 = (text_1) => {
241
491
  setQuery(text_1);
242
492
  if (text_1 === "" && current !== null) onChange_0?.(null);
243
- },
244
- onChange: (itemId_0) => {
493
+ };
494
+ $[105] = current;
495
+ $[106] = onChange_0;
496
+ $[107] = t12;
497
+ } else t12 = $[107];
498
+ let t13;
499
+ if ($[108] !== createFrom || $[109] !== current?.id || $[110] !== onChange_0 || $[111] !== shown) {
500
+ t13 = (itemId_0) => {
245
501
  if (itemId_0 === CREATE_ID) {
246
502
  createFrom((reference_4) => onChange_0?.(reference_4));
247
503
  return;
@@ -250,19 +506,103 @@ function RelationField(props) {
250
506
  if (itemId_0 === null) return;
251
507
  const reference_5 = shown.find((item_5) => item_5.id === itemId_0) ?? null;
252
508
  if (reference_5?.id !== current?.id) onChange_0?.(reference_5);
253
- },
254
- isLoading,
255
- placeholder,
256
- emptyMessage: intl.formatMessage(messages.noResults),
257
- ...onBlur !== void 0 ? { onBlur: () => {
509
+ };
510
+ $[108] = createFrom;
511
+ $[109] = current?.id;
512
+ $[110] = onChange_0;
513
+ $[111] = shown;
514
+ $[112] = t13;
515
+ } else t13 = $[112];
516
+ let t14;
517
+ if ($[113] !== intl) {
518
+ t14 = intl.formatMessage(messages.noResults);
519
+ $[113] = intl;
520
+ $[114] = t14;
521
+ } else t14 = $[114];
522
+ let t15;
523
+ if ($[115] !== onBlur) {
524
+ t15 = onBlur !== void 0 ? { onBlur: () => {
258
525
  setQuery(null);
259
526
  onBlur();
260
- } } : { onBlur: () => setQuery(null) },
261
- ...name !== void 0 ? { name } : {},
262
- ...id !== void 0 ? { id } : {}
263
- });
527
+ } } : { onBlur: () => setQuery(null) };
528
+ $[115] = onBlur;
529
+ $[116] = t15;
530
+ } else t15 = $[116];
531
+ let t16;
532
+ if ($[117] !== name) {
533
+ t16 = name !== void 0 ? { name } : {};
534
+ $[117] = name;
535
+ $[118] = t16;
536
+ } else t16 = $[118];
537
+ let t17;
538
+ if ($[119] !== id) {
539
+ t17 = id !== void 0 ? { id } : {};
540
+ $[119] = id;
541
+ $[120] = t17;
542
+ } else t17 = $[120];
543
+ let t18;
544
+ if ($[121] !== allErrors || $[122] !== className || $[123] !== description || $[124] !== descriptionClassName || $[125] !== errorsClassName || $[126] !== isLoading || $[127] !== label || $[128] !== labelClassName || $[129] !== placeholder || $[130] !== required || $[131] !== t10 || $[132] !== t11 || $[133] !== t12 || $[134] !== t13 || $[135] !== t14 || $[136] !== t15 || $[137] !== t16 || $[138] !== t17 || $[139] !== t7 || $[140] !== t8 || $[141] !== t9) {
545
+ t18 = /* @__PURE__ */ jsx(ComboBox, {
546
+ label,
547
+ description,
548
+ errors: allErrors,
549
+ isRequired: required,
550
+ className,
551
+ labelClassName,
552
+ descriptionClassName,
553
+ errorsClassName,
554
+ ...t7,
555
+ ...t8,
556
+ items: t9,
557
+ value: t10,
558
+ inputValue: t11,
559
+ onInputChange: t12,
560
+ onChange: t13,
561
+ isLoading,
562
+ placeholder,
563
+ emptyMessage: t14,
564
+ ...t15,
565
+ ...t16,
566
+ ...t17
567
+ });
568
+ $[121] = allErrors;
569
+ $[122] = className;
570
+ $[123] = description;
571
+ $[124] = descriptionClassName;
572
+ $[125] = errorsClassName;
573
+ $[126] = isLoading;
574
+ $[127] = label;
575
+ $[128] = labelClassName;
576
+ $[129] = placeholder;
577
+ $[130] = required;
578
+ $[131] = t10;
579
+ $[132] = t11;
580
+ $[133] = t12;
581
+ $[134] = t13;
582
+ $[135] = t14;
583
+ $[136] = t15;
584
+ $[137] = t16;
585
+ $[138] = t17;
586
+ $[139] = t7;
587
+ $[140] = t8;
588
+ $[141] = t9;
589
+ $[142] = t18;
590
+ } else t18 = $[142];
591
+ return t18;
264
592
  }
265
593
  /** The `relation` type: `resource` and `multiple`. Items search the fields context's source. */
594
+ function _temp2(item_4) {
595
+ return {
596
+ id: item_4.id,
597
+ label: item_4.label
598
+ };
599
+ }
600
+ function _temp(item_1) {
601
+ return {
602
+ id: item_1.id,
603
+ label: item_1.label
604
+ };
605
+ }
266
606
  function RelationFieldEntry(props) {
267
607
  const $ = c(15);
268
608
  const { field } = props;