@firecms/entity_history 3.0.1 → 3.1.0-canary.02232f4

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/index.umd.js CHANGED
@@ -51,59 +51,66 @@
51
51
  return t2;
52
52
  }, equal);
53
53
  function UserChip(t0) {
54
- const $ = reactCompilerRuntime.c(11);
54
+ const $ = reactCompilerRuntime.c(12);
55
55
  const {
56
56
  user
57
57
  } = t0;
58
+ const {
59
+ t
60
+ } = core.useTranslation();
58
61
  const t1 = user.email ?? user.uid;
59
62
  let t2;
60
- if ($[0] !== user.displayName || $[1] !== user.photoURL) {
61
- t2 = user.photoURL && /* @__PURE__ */ jsxRuntime.jsx("img", { className: "rounded-full w-6 h-6 mr-2", src: user.photoURL, alt: user.displayName ?? "User picture" });
62
- $[0] = user.displayName;
63
- $[1] = user.photoURL;
64
- $[2] = t2;
63
+ if ($[0] !== t || $[1] !== user.displayName || $[2] !== user.photoURL) {
64
+ t2 = user.photoURL && /* @__PURE__ */ jsxRuntime.jsx("img", { className: "rounded-full w-6 h-6 mr-2", src: user.photoURL, alt: user.displayName ?? t("user_picture") });
65
+ $[0] = t;
66
+ $[1] = user.displayName;
67
+ $[2] = user.photoURL;
68
+ $[3] = t2;
65
69
  } else {
66
- t2 = $[2];
70
+ t2 = $[3];
67
71
  }
68
72
  const t3 = user.displayName ?? user.email ?? user.uid;
69
73
  let t4;
70
- if ($[3] !== t3) {
74
+ if ($[4] !== t3) {
71
75
  t4 = /* @__PURE__ */ jsxRuntime.jsx("span", { children: t3 });
72
- $[3] = t3;
73
- $[4] = t4;
76
+ $[4] = t3;
77
+ $[5] = t4;
74
78
  } else {
75
- t4 = $[4];
79
+ t4 = $[5];
76
80
  }
77
81
  let t5;
78
- if ($[5] !== t2 || $[6] !== t4) {
82
+ if ($[6] !== t2 || $[7] !== t4) {
79
83
  t5 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Chip, { size: "small", className: "flex items-center", children: [
80
84
  t2,
81
85
  t4
82
86
  ] });
83
- $[5] = t2;
84
- $[6] = t4;
85
- $[7] = t5;
87
+ $[6] = t2;
88
+ $[7] = t4;
89
+ $[8] = t5;
86
90
  } else {
87
- t5 = $[7];
91
+ t5 = $[8];
88
92
  }
89
93
  let t6;
90
- if ($[8] !== t1 || $[9] !== t5) {
94
+ if ($[9] !== t1 || $[10] !== t5) {
91
95
  t6 = /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: t1, children: t5 });
92
- $[8] = t1;
93
- $[9] = t5;
94
- $[10] = t6;
96
+ $[9] = t1;
97
+ $[10] = t5;
98
+ $[11] = t6;
95
99
  } else {
96
- t6 = $[10];
100
+ t6 = $[11];
97
101
  }
98
102
  return t6;
99
103
  }
100
104
  function PreviousValueView(t0) {
101
- const $ = reactCompilerRuntime.c(12);
105
+ const $ = reactCompilerRuntime.c(18);
102
106
  const {
103
107
  previousValueInPath,
104
108
  childProperty,
105
109
  propertyKey
106
110
  } = t0;
111
+ const {
112
+ t
113
+ } = core.useTranslation();
107
114
  if (typeof previousValueInPath === "string" || typeof previousValueInPath === "number") {
108
115
  let t1;
109
116
  if ($[0] !== previousValueInPath) {
@@ -128,43 +135,61 @@
128
135
  return t2;
129
136
  } else {
130
137
  let t1;
131
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
132
- t1 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", children: "Previous value" });
133
- $[4] = t1;
138
+ if ($[4] !== t) {
139
+ t1 = t("entity_history_previous_value");
140
+ $[4] = t;
141
+ $[5] = t1;
134
142
  } else {
135
- t1 = $[4];
143
+ t1 = $[5];
136
144
  }
137
- const t2 = propertyKey;
138
- const t3 = childProperty;
139
- let t4;
140
- if ($[5] !== previousValueInPath || $[6] !== t2 || $[7] !== t3) {
141
- t4 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
142
- t1,
143
- /* @__PURE__ */ jsxRuntime.jsx(core.PropertyPreview, { propertyKey: t2, value: previousValueInPath, property: t3, size: "small" })
144
- ] });
145
- $[5] = previousValueInPath;
146
- $[6] = t2;
147
- $[7] = t3;
148
- $[8] = t4;
145
+ let t2;
146
+ if ($[6] !== t1) {
147
+ t2 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", children: t1 });
148
+ $[6] = t1;
149
+ $[7] = t2;
149
150
  } else {
150
- t4 = $[8];
151
+ t2 = $[7];
151
152
  }
153
+ const t3 = propertyKey;
154
+ const t4 = childProperty;
152
155
  let t5;
153
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
154
- t5 = /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardBackspaceIcon, { size: "smallest", color: "disabled", className: "mb-1" });
155
- $[9] = t5;
156
+ if ($[8] !== previousValueInPath || $[9] !== t3 || $[10] !== t4) {
157
+ t5 = /* @__PURE__ */ jsxRuntime.jsx(core.PropertyPreview, { propertyKey: t3, value: previousValueInPath, property: t4, size: "small" });
158
+ $[8] = previousValueInPath;
159
+ $[9] = t3;
160
+ $[10] = t4;
161
+ $[11] = t5;
156
162
  } else {
157
- t5 = $[9];
163
+ t5 = $[11];
158
164
  }
159
165
  let t6;
160
- if ($[10] !== t4) {
161
- t6 = /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { side: "left", title: t4, children: t5 });
162
- $[10] = t4;
163
- $[11] = t6;
166
+ if ($[12] !== t2 || $[13] !== t5) {
167
+ t6 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
168
+ t2,
169
+ t5
170
+ ] });
171
+ $[12] = t2;
172
+ $[13] = t5;
173
+ $[14] = t6;
174
+ } else {
175
+ t6 = $[14];
176
+ }
177
+ let t7;
178
+ if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
179
+ t7 = /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardBackspaceIcon, { size: "smallest", color: "disabled", className: "mb-1" });
180
+ $[15] = t7;
181
+ } else {
182
+ t7 = $[15];
183
+ }
184
+ let t8;
185
+ if ($[16] !== t6) {
186
+ t8 = /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { side: "left", title: t6, children: t7 });
187
+ $[16] = t6;
188
+ $[17] = t8;
164
189
  } else {
165
- t6 = $[11];
190
+ t8 = $[17];
166
191
  }
167
- return t6;
192
+ return t8;
168
193
  }
169
194
  }
170
195
  }
@@ -182,6 +207,9 @@
182
207
  const customizationController = core.useCustomizationController();
183
208
  const navigationController = core.useNavigationController();
184
209
  const sideEntityController = core.useSideEntityController();
210
+ const {
211
+ t
212
+ } = core.useTranslation();
185
213
  const collection = collectionProp ?? navigationController.getCollection(entity.path);
186
214
  const updatedOn = entity.values?.["__metadata"]?.["updated_on"];
187
215
  if (!collection) {
@@ -207,7 +235,7 @@
207
235
  ] }),
208
236
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("bg-white dark:bg-surface-900", "min-h-[44px]", "w-full", "items-center", hover ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800" : "", size === "small" ? "p-1" : "px-2 py-1", "flex border rounded-lg", onClick ? "cursor-pointer" : "", ui.defaultBorderMixin), children: [
209
237
  actions,
210
- entity && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "See details for this revision", className: "my-2 grow-0 shrink-0 self-start", children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { color: "inherit", className: "", onClick: (e) => {
238
+ entity && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: t("entity_history_see_details"), className: "my-2 grow-0 shrink-0 self-start", children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { color: "inherit", className: "", onClick: (e) => {
211
239
  sideEntityController.open({
212
240
  entityId: entity.id,
213
241
  path: entity.path,
@@ -230,7 +258,7 @@
230
258
  const childProperty = core.getPropertyInPath(resolvedCollection.properties, key);
231
259
  const valueInPath = core.getValueInPath(entity.values, key);
232
260
  const previousValueInPath = previousValues ? core.getValueInPath(previousValues, key) : void 0;
233
- const element = childProperty ? entity ? /* @__PURE__ */ jsxRuntime.jsx(core.PropertyPreview, { propertyKey: key, value: valueInPath, property: childProperty, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(core.SkeletonPropertyComponent, { property: childProperty, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "body2", children: typeof valueInPath === "string" ? valueInPath : JSON.stringify(valueInPath) });
261
+ const element = childProperty ? entity ? /* @__PURE__ */ jsxRuntime.jsx(core.PropertyPreview, { propertyKey: key, value: valueInPath, property: childProperty, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(core.SkeletonPropertyComponent, { property: childProperty, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "body2", children: typeof valueInPath === "string" ? valueInPath : JSON.stringify(valueInPath, core.jsonStringifyReplacer) });
234
262
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full my-1 items-center", children: [
235
263
  /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", className: "min-w-[140px] md:min-w-[200px] w-1/5 pr-8 overflow-hidden text-ellipsis text-right", children: key }),
236
264
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-4/5", children: [
@@ -243,7 +271,7 @@
243
271
  ] });
244
272
  }
245
273
  function EntityHistoryView(t0) {
246
- const $ = reactCompilerRuntime.c(62);
274
+ const $ = reactCompilerRuntime.c(78);
247
275
  const {
248
276
  entity,
249
277
  collection,
@@ -251,6 +279,9 @@
251
279
  } = t0;
252
280
  const authController = core.useAuthController();
253
281
  const snackbarController = core.useSnackbarController();
282
+ const {
283
+ t
284
+ } = core.useTranslation();
254
285
  const dirty = formContext?.formex.dirty;
255
286
  const dataSource = core.useDataSource();
256
287
  const pathAndId = entity ? entity?.path + "/" + entity?.id : void 0;
@@ -339,7 +370,7 @@
339
370
  const handleObserver = (entries) => {
340
371
  const target = entries[0];
341
372
  if (target.isIntersecting && hasMore && !isLoading) {
342
- setLimit(_temp);
373
+ setLimit(_temp$1);
343
374
  }
344
375
  };
345
376
  const observer = new IntersectionObserver(handleObserver, options);
@@ -371,16 +402,25 @@
371
402
  React.useEffect(t4, t5);
372
403
  if (!entity) {
373
404
  let t62;
374
- if ($[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
375
- t62 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "History is only available for existing entities" }) });
376
- $[17] = t62;
405
+ if ($[17] !== t) {
406
+ t62 = t("entity_history_only_existing");
407
+ $[17] = t;
408
+ $[18] = t62;
377
409
  } else {
378
- t62 = $[17];
410
+ t62 = $[18];
379
411
  }
380
- return t62;
412
+ let t72;
413
+ if ($[19] !== t62) {
414
+ t72 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: t62 }) });
415
+ $[19] = t62;
416
+ $[20] = t72;
417
+ } else {
418
+ t72 = $[20];
419
+ }
420
+ return t72;
381
421
  }
382
422
  let t6;
383
- if ($[18] !== authController || $[19] !== collection || $[20] !== dataSource || $[21] !== entity || $[22] !== formContext || $[23] !== snackbarController) {
423
+ if ($[21] !== authController || $[22] !== collection || $[23] !== dataSource || $[24] !== entity || $[25] !== formContext || $[26] !== snackbarController || $[27] !== t) {
384
424
  t6 = function doRevert2(revertVersion) {
385
425
  if (!entity) {
386
426
  throw new Error("No entity to revert");
@@ -414,64 +454,75 @@
414
454
  });
415
455
  setRevertVersionDialog(void 0);
416
456
  snackbarController.open({
417
- message: "Reverted version",
457
+ message: t("entity_history_reverted"),
418
458
  type: "info"
419
459
  });
420
460
  }).catch((error_0) => {
421
461
  console.error("Error reverting entity:", error_0);
422
462
  snackbarController.open({
423
- message: "Error reverting entity",
463
+ message: t("entity_history_error_reverting"),
424
464
  type: "error"
425
465
  });
426
466
  });
427
467
  };
428
- $[18] = authController;
429
- $[19] = collection;
430
- $[20] = dataSource;
431
- $[21] = entity;
432
- $[22] = formContext;
433
- $[23] = snackbarController;
434
- $[24] = t6;
468
+ $[21] = authController;
469
+ $[22] = collection;
470
+ $[23] = dataSource;
471
+ $[24] = entity;
472
+ $[25] = formContext;
473
+ $[26] = snackbarController;
474
+ $[27] = t;
475
+ $[28] = t6;
435
476
  } else {
436
- t6 = $[24];
477
+ t6 = $[28];
437
478
  }
438
479
  const doRevert = t6;
439
480
  let t7;
440
- if ($[25] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
481
+ if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
441
482
  t7 = ui.cls("relative flex-1 h-full overflow-auto w-full flex flex-col gap-4 p-8");
442
- $[25] = t7;
483
+ $[29] = t7;
443
484
  } else {
444
- t7 = $[25];
485
+ t7 = $[29];
445
486
  }
446
487
  let t8;
447
- if ($[26] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
448
- t8 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "h5", className: "mt-24 ml-4", children: "History" });
449
- $[26] = t8;
488
+ if ($[30] !== t) {
489
+ t8 = t("history");
490
+ $[30] = t;
491
+ $[31] = t8;
450
492
  } else {
451
- t8 = $[26];
493
+ t8 = $[31];
452
494
  }
453
495
  let t9;
454
- if ($[27] !== revisions.length) {
455
- t9 = revisions.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
456
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "ml-4 mt-8", children: "No history available" }),
457
- /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "ml-4", children: "When you save an entity, a new version is created and stored in the history." })
458
- ] });
459
- $[27] = revisions.length;
460
- $[28] = t9;
496
+ if ($[32] !== t8) {
497
+ t9 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "h5", className: "mt-24 ml-4", children: t8 });
498
+ $[32] = t8;
499
+ $[33] = t9;
461
500
  } else {
462
- t9 = $[28];
501
+ t9 = $[33];
463
502
  }
464
503
  let t10;
465
- if ($[29] !== collection || $[30] !== dirty || $[31] !== revisions || $[32] !== snackbarController) {
466
- let t112;
467
- if ($[34] !== collection || $[35] !== dirty || $[36] !== snackbarController) {
468
- t112 = (revision, index) => {
504
+ if ($[34] !== revisions.length || $[35] !== t) {
505
+ t10 = revisions.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
506
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { className: "ml-4 mt-8", children: t("entity_history_no_history") }),
507
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "ml-4", children: t("entity_history_when_save") })
508
+ ] });
509
+ $[34] = revisions.length;
510
+ $[35] = t;
511
+ $[36] = t10;
512
+ } else {
513
+ t10 = $[36];
514
+ }
515
+ let t11;
516
+ if ($[37] !== collection || $[38] !== dirty || $[39] !== revisions || $[40] !== snackbarController || $[41] !== t) {
517
+ let t122;
518
+ if ($[43] !== collection || $[44] !== dirty || $[45] !== snackbarController || $[46] !== t) {
519
+ t122 = (revision, index) => {
469
520
  const previewKeys = revision.values?.__metadata?.changed_fields;
470
521
  const previousValues = revision.values?.__metadata?.previous_values;
471
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-cols gap-2 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(EntityHistoryEntry, { size: "large", entity: revision, collection, previewKeys, previousValues, actions: /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Revert to this version", className: "m-2 grow-0 self-start", children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { onClick: () => {
522
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-cols gap-2 w-full", children: /* @__PURE__ */ jsxRuntime.jsx(EntityHistoryEntry, { size: "large", entity: revision, collection, previewKeys, previousValues, actions: /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: t("entity_history_revert_tooltip"), className: "m-2 grow-0 self-start", children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { onClick: () => {
472
523
  if (dirty) {
473
524
  snackbarController.open({
474
- message: "Please save or discard your changes before reverting",
525
+ message: t("entity_history_please_save"),
475
526
  type: "warning"
476
527
  });
477
528
  } else {
@@ -479,113 +530,130 @@
479
530
  }
480
531
  }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.HistoryIcon, {}) }) }) }) }, index);
481
532
  };
482
- $[34] = collection;
483
- $[35] = dirty;
484
- $[36] = snackbarController;
485
- $[37] = t112;
533
+ $[43] = collection;
534
+ $[44] = dirty;
535
+ $[45] = snackbarController;
536
+ $[46] = t;
537
+ $[47] = t122;
486
538
  } else {
487
- t112 = $[37];
539
+ t122 = $[47];
488
540
  }
489
- t10 = revisions.map(t112);
490
- $[29] = collection;
491
- $[30] = dirty;
492
- $[31] = revisions;
493
- $[32] = snackbarController;
494
- $[33] = t10;
541
+ t11 = revisions.map(t122);
542
+ $[37] = collection;
543
+ $[38] = dirty;
544
+ $[39] = revisions;
545
+ $[40] = snackbarController;
546
+ $[41] = t;
547
+ $[42] = t11;
495
548
  } else {
496
- t10 = $[33];
549
+ t11 = $[42];
497
550
  }
498
- let t11;
499
- if ($[38] !== hasMore || $[39] !== isLoading || $[40] !== revisions.length) {
500
- t11 = revisions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: loadMoreRef, className: "py-4 text-center", children: [
501
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Loading more..." }),
502
- !hasMore && revisions.length > 5 && /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "No more history available" })
551
+ let t12;
552
+ if ($[48] !== hasMore || $[49] !== isLoading || $[50] !== revisions.length || $[51] !== t) {
553
+ t12 = revisions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: loadMoreRef, className: "py-4 text-center", children: [
554
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: t("loading_more") }),
555
+ !hasMore && revisions.length > 5 && /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: t("entity_history_no_more") })
503
556
  ] });
504
- $[38] = hasMore;
505
- $[39] = isLoading;
506
- $[40] = revisions.length;
507
- $[41] = t11;
557
+ $[48] = hasMore;
558
+ $[49] = isLoading;
559
+ $[50] = revisions.length;
560
+ $[51] = t;
561
+ $[52] = t12;
508
562
  } else {
509
- t11 = $[41];
563
+ t12 = $[52];
510
564
  }
511
- let t12;
512
- if ($[42] !== t10 || $[43] !== t11 || $[44] !== t9) {
513
- t12 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 max-w-6xl mx-auto w-full", children: [
514
- t8,
565
+ let t13;
566
+ if ($[53] !== t10 || $[54] !== t11 || $[55] !== t12 || $[56] !== t9) {
567
+ t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 max-w-6xl mx-auto w-full", children: [
515
568
  t9,
516
569
  t10,
517
- t11
570
+ t11,
571
+ t12
518
572
  ] });
519
- $[42] = t10;
520
- $[43] = t11;
521
- $[44] = t9;
522
- $[45] = t12;
573
+ $[53] = t10;
574
+ $[54] = t11;
575
+ $[55] = t12;
576
+ $[56] = t9;
577
+ $[57] = t13;
523
578
  } else {
524
- t12 = $[45];
579
+ t13 = $[57];
525
580
  }
526
- const t13 = Boolean(revertVersionDialog);
527
- let t14;
528
- if ($[46] !== doRevert || $[47] !== revertVersionDialog) {
529
- t14 = function() {
581
+ const t14 = Boolean(revertVersionDialog);
582
+ let t15;
583
+ if ($[58] !== doRevert || $[59] !== revertVersionDialog) {
584
+ t15 = function() {
530
585
  if (!revertVersionDialog) {
531
586
  return;
532
587
  }
533
588
  doRevert(revertVersionDialog);
534
589
  };
535
- $[46] = doRevert;
536
- $[47] = revertVersionDialog;
537
- $[48] = t14;
590
+ $[58] = doRevert;
591
+ $[59] = revertVersionDialog;
592
+ $[60] = t15;
538
593
  } else {
539
- t14 = $[48];
594
+ t15 = $[60];
540
595
  }
541
- let t15;
542
596
  let t16;
543
- if ($[49] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
544
- t15 = function() {
597
+ if ($[61] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
598
+ t16 = function() {
545
599
  setRevertVersionDialog(void 0);
546
600
  };
547
- t16 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "subtitle2", children: "Revert data to this version?" });
548
- $[49] = t15;
549
- $[50] = t16;
601
+ $[61] = t16;
550
602
  } else {
551
- t15 = $[49];
552
- t16 = $[50];
603
+ t16 = $[61];
553
604
  }
554
605
  let t17;
555
- if ($[51] !== collection || $[52] !== entity?.path || $[53] !== revertVersionDialog) {
556
- t17 = revertVersionDialog ? /* @__PURE__ */ jsxRuntime.jsx(core.EntityView, { entity: revertVersionDialog, collection, path: entity?.path }) : null;
557
- $[51] = collection;
558
- $[52] = entity?.path;
559
- $[53] = revertVersionDialog;
560
- $[54] = t17;
606
+ if ($[62] !== t) {
607
+ t17 = t("entity_history_revert_dialog_title");
608
+ $[62] = t;
609
+ $[63] = t17;
561
610
  } else {
562
- t17 = $[54];
611
+ t17 = $[63];
563
612
  }
564
613
  let t18;
565
- if ($[55] !== t13 || $[56] !== t14 || $[57] !== t17) {
566
- t18 = /* @__PURE__ */ jsxRuntime.jsx(core.ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(core.ConfirmationDialog, { open: t13, onAccept: t14, onCancel: t15, title: t16, body: t17 }) });
567
- $[55] = t13;
568
- $[56] = t14;
569
- $[57] = t17;
570
- $[58] = t18;
614
+ if ($[64] !== t17) {
615
+ t18 = /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "subtitle2", children: t17 });
616
+ $[64] = t17;
617
+ $[65] = t18;
571
618
  } else {
572
- t18 = $[58];
619
+ t18 = $[65];
573
620
  }
574
621
  let t19;
575
- if ($[59] !== t12 || $[60] !== t18) {
576
- t19 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: t7, children: [
577
- t12,
578
- t18
622
+ if ($[66] !== collection || $[67] !== entity?.path || $[68] !== revertVersionDialog) {
623
+ t19 = revertVersionDialog ? /* @__PURE__ */ jsxRuntime.jsx(core.EntityView, { entity: revertVersionDialog, collection, path: entity?.path }) : null;
624
+ $[66] = collection;
625
+ $[67] = entity?.path;
626
+ $[68] = revertVersionDialog;
627
+ $[69] = t19;
628
+ } else {
629
+ t19 = $[69];
630
+ }
631
+ let t20;
632
+ if ($[70] !== t14 || $[71] !== t15 || $[72] !== t18 || $[73] !== t19) {
633
+ t20 = /* @__PURE__ */ jsxRuntime.jsx(core.ErrorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsx(core.ConfirmationDialog, { open: t14, onAccept: t15, onCancel: t16, title: t18, body: t19 }) });
634
+ $[70] = t14;
635
+ $[71] = t15;
636
+ $[72] = t18;
637
+ $[73] = t19;
638
+ $[74] = t20;
639
+ } else {
640
+ t20 = $[74];
641
+ }
642
+ let t21;
643
+ if ($[75] !== t13 || $[76] !== t20) {
644
+ t21 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: t7, children: [
645
+ t13,
646
+ t20
579
647
  ] });
580
- $[59] = t12;
581
- $[60] = t18;
582
- $[61] = t19;
648
+ $[75] = t13;
649
+ $[76] = t20;
650
+ $[77] = t21;
583
651
  } else {
584
- t19 = $[61];
652
+ t21 = $[77];
585
653
  }
586
- return t19;
654
+ return t21;
587
655
  }
588
- function _temp(prev) {
656
+ function _temp$1(prev) {
589
657
  return prev + 5;
590
658
  }
591
659
  function createHistoryEntry({
@@ -675,6 +743,314 @@
675
743
  }
676
744
  return changedFields;
677
745
  }
746
+ function getRelativeTimeString(date, t) {
747
+ const now = /* @__PURE__ */ new Date();
748
+ const diffMs = now.getTime() - date.getTime();
749
+ const diffSeconds = Math.floor(diffMs / 1e3);
750
+ const diffMinutes = Math.floor(diffSeconds / 60);
751
+ const diffHours = Math.floor(diffMinutes / 60);
752
+ const diffDays = Math.floor(diffHours / 24);
753
+ if (diffSeconds < 60) return t("entity_history_just_now");
754
+ if (diffMinutes < 60) return t("entity_history_minutes_ago", {
755
+ minutes: diffMinutes
756
+ });
757
+ if (diffHours < 24) return t("entity_history_hours_ago", {
758
+ hours: diffHours
759
+ });
760
+ if (diffDays < 30) return t("entity_history_days_ago", {
761
+ days: diffDays
762
+ });
763
+ return date.toLocaleDateString();
764
+ }
765
+ function LastEditedByIndicator(t0) {
766
+ const $ = reactCompilerRuntime.c(24);
767
+ const {
768
+ path,
769
+ entityId,
770
+ collection
771
+ } = t0;
772
+ const {
773
+ t
774
+ } = core.useTranslation();
775
+ const {
776
+ getUser
777
+ } = useHistoryController();
778
+ const dataSource = core.useDataSource();
779
+ const [latestEntry, setLatestEntry] = React.useState();
780
+ let t1;
781
+ if ($[0] !== collection || $[1] !== dataSource || $[2] !== entityId || $[3] !== path) {
782
+ t1 = () => {
783
+ if (!path || !entityId) {
784
+ return;
785
+ }
786
+ const historyPath = `${path}/${entityId}/__history`;
787
+ const unsubscribe = dataSource.listenCollection?.({
788
+ path: historyPath,
789
+ collection,
790
+ orderBy: "__metadata.updated_on",
791
+ order: "desc",
792
+ limit: 1,
793
+ onUpdate: (entities) => {
794
+ setLatestEntry(entities[0]);
795
+ },
796
+ onError: _temp
797
+ });
798
+ return () => {
799
+ if (typeof unsubscribe === "function") {
800
+ unsubscribe();
801
+ }
802
+ };
803
+ };
804
+ $[0] = collection;
805
+ $[1] = dataSource;
806
+ $[2] = entityId;
807
+ $[3] = path;
808
+ $[4] = t1;
809
+ } else {
810
+ t1 = $[4];
811
+ }
812
+ let t2;
813
+ if ($[5] !== dataSource || $[6] !== entityId || $[7] !== path) {
814
+ t2 = [path, entityId, dataSource];
815
+ $[5] = dataSource;
816
+ $[6] = entityId;
817
+ $[7] = path;
818
+ $[8] = t2;
819
+ } else {
820
+ t2 = $[8];
821
+ }
822
+ React.useEffect(t1, t2);
823
+ const metadata = latestEntry?.values?.__metadata;
824
+ const uid = metadata?.updated_by;
825
+ const editedOn = metadata?.updated_on;
826
+ const hasData = Boolean(uid || editedOn);
827
+ let t3;
828
+ if ($[9] !== getUser || $[10] !== uid) {
829
+ t3 = uid ? getUser?.(uid) : void 0;
830
+ $[9] = getUser;
831
+ $[10] = uid;
832
+ $[11] = t3;
833
+ } else {
834
+ t3 = $[11];
835
+ }
836
+ const user = t3;
837
+ let t4;
838
+ if ($[12] !== editedOn) {
839
+ t4 = editedOn instanceof Date ? editedOn : editedOn?.toDate ? editedOn.toDate() : null;
840
+ $[12] = editedOn;
841
+ $[13] = t4;
842
+ } else {
843
+ t4 = $[13];
844
+ }
845
+ const date = t4;
846
+ let t5;
847
+ if ($[14] !== date || $[15] !== t) {
848
+ t5 = date ? getRelativeTimeString(date, t) : null;
849
+ $[14] = date;
850
+ $[15] = t;
851
+ $[16] = t5;
852
+ } else {
853
+ t5 = $[16];
854
+ }
855
+ const timeString = t5;
856
+ const displayName = user?.displayName ?? user?.email ?? uid;
857
+ const photoURL = user?.photoURL;
858
+ let t6;
859
+ if ($[17] !== displayName || $[18] !== hasData || $[19] !== photoURL || $[20] !== timeString) {
860
+ t6 = hasData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
861
+ photoURL ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: photoURL, alt: displayName ?? "User", className: "rounded-full object-cover w-6 h-6" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-full bg-primary/10 dark:bg-primary-dark/20 flex items-center justify-center text-primary dark:text-primary-dark font-medium w-6 h-6 text-xs", children: (displayName ?? "?").charAt(0).toUpperCase() }),
862
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
863
+ displayName,
864
+ timeString ? ` · ${timeString}` : ""
865
+ ] })
866
+ ] });
867
+ $[17] = displayName;
868
+ $[18] = hasData;
869
+ $[19] = photoURL;
870
+ $[20] = timeString;
871
+ $[21] = t6;
872
+ } else {
873
+ t6 = $[21];
874
+ }
875
+ let t7;
876
+ if ($[22] !== t6) {
877
+ t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 text-xs text-text-secondary dark:text-text-secondary-dark min-h-6", children: t6 });
878
+ $[22] = t6;
879
+ $[23] = t7;
880
+ } else {
881
+ t7 = $[23];
882
+ }
883
+ return t7;
884
+ }
885
+ function _temp(error) {
886
+ console.error("Error fetching latest history entry:", error);
887
+ }
888
+ function LastEditedByFormAction(t0) {
889
+ const $ = reactCompilerRuntime.c(4);
890
+ const {
891
+ entityId,
892
+ path,
893
+ status,
894
+ collection
895
+ } = t0;
896
+ if (status === "new" || status === "copy" || !entityId) {
897
+ return null;
898
+ }
899
+ if (!collection.history) {
900
+ return null;
901
+ }
902
+ let t1;
903
+ if ($[0] !== collection || $[1] !== entityId || $[2] !== path) {
904
+ t1 = /* @__PURE__ */ jsxRuntime.jsx(LastEditedByIndicator, { path, entityId, collection });
905
+ $[0] = collection;
906
+ $[1] = entityId;
907
+ $[2] = path;
908
+ $[3] = t1;
909
+ } else {
910
+ t1 = $[3];
911
+ }
912
+ return t1;
913
+ }
914
+ const entityHistoryTranslationsEn = {
915
+ history: "History",
916
+ entity_history_only_existing: "History is only available for existing entities",
917
+ entity_history_reverted: "Reverted version",
918
+ entity_history_error_reverting: "Error reverting entity",
919
+ entity_history_no_history: "No history available",
920
+ entity_history_when_save: "When you save an entity, a new version is created and stored in the history.",
921
+ entity_history_revert_tooltip: "Revert to this version",
922
+ entity_history_please_save: "Please save or discard your changes before reverting",
923
+ loading_more: "Loading more...",
924
+ entity_history_no_more: "No more history available",
925
+ entity_history_revert_dialog_title: "Revert data to this version?",
926
+ entity_history_previous_value: "Previous value",
927
+ entity_history_see_details: "See details for this revision",
928
+ entity_history_just_now: "just now",
929
+ entity_history_minutes_ago: "{{minutes}}m ago",
930
+ entity_history_hours_ago: "{{hours}}h ago",
931
+ entity_history_days_ago: "{{days}}d ago",
932
+ user_picture: "User picture"
933
+ };
934
+ const entityHistoryTranslationsEs = {
935
+ history: "Historial",
936
+ entity_history_only_existing: "El historial solo está disponible para entidades existentes",
937
+ entity_history_reverted: "Versión revertida",
938
+ entity_history_error_reverting: "Error al revertir la entidad",
939
+ entity_history_no_history: "No hay historial disponible",
940
+ entity_history_when_save: "Cuando guardas una entidad, se crea una nueva versión y se almacena en el historial.",
941
+ entity_history_revert_tooltip: "Revertir a esta versión",
942
+ entity_history_please_save: "Por favor, guarda o descarta tus cambios antes de revertir",
943
+ loading_more: "Cargando más...",
944
+ entity_history_no_more: "No hay más historial disponible",
945
+ entity_history_revert_dialog_title: "¿Revertir datos a esta versión?",
946
+ entity_history_previous_value: "Valor anterior",
947
+ entity_history_see_details: "Ver detalles de esta revisión",
948
+ entity_history_just_now: "justo ahora",
949
+ entity_history_minutes_ago: "hace {{minutes}}m",
950
+ entity_history_hours_ago: "hace {{hours}}h",
951
+ entity_history_days_ago: "hace {{days}}d",
952
+ user_picture: "Foto de usuario"
953
+ };
954
+ const entityHistoryTranslationsDe = {
955
+ history: "Verlauf",
956
+ entity_history_only_existing: "Verlauf ist nur für vorhandene Entitäten verfügbar",
957
+ entity_history_reverted: "Wiederhergestellte Version",
958
+ entity_history_error_reverting: "Fehler beim Wiederherstellen der Entität",
959
+ entity_history_no_history: "Kein Verlauf verfügbar",
960
+ entity_history_when_save: "Wenn Sie eine Entität speichern, wird eine neue Version erstellt und im Verlauf gespeichert.",
961
+ entity_history_revert_tooltip: "Zu dieser Version zurückkehren",
962
+ entity_history_please_save: "Bitte speichern oder verwerfen Sie Ihre Änderungen vor der Wiederherstellung",
963
+ loading_more: "Mehr laden...",
964
+ entity_history_no_more: "Kein weiterer Verlauf verfügbar",
965
+ entity_history_revert_dialog_title: "Daten auf diese Version zurücksetzen?",
966
+ entity_history_previous_value: "Vorheriger Wert",
967
+ entity_history_see_details: "Details zu dieser Überarbeitung anzeigen",
968
+ entity_history_just_now: "gerade eben",
969
+ entity_history_minutes_ago: "vor {{minutes}}m",
970
+ entity_history_hours_ago: "vor {{hours}}h",
971
+ entity_history_days_ago: "vor {{days}}d",
972
+ user_picture: "Benutzerbild"
973
+ };
974
+ const entityHistoryTranslationsFr = {
975
+ history: "Historique",
976
+ entity_history_only_existing: "L'historique n'est disponible que pour les entités existantes",
977
+ entity_history_reverted: "Version restaurée",
978
+ entity_history_error_reverting: "Erreur lors de la restauration de l'entité",
979
+ entity_history_no_history: "Aucun historique disponible",
980
+ entity_history_when_save: "Lorsque vous enregistrez une entité, une nouvelle version est créée et stockée dans l'historique.",
981
+ entity_history_revert_tooltip: "Revenir à cette version",
982
+ entity_history_please_save: "Veuillez enregistrer ou annuler vos modifications avant de restaurer",
983
+ loading_more: "Chargement en cours...",
984
+ entity_history_no_more: "Aucun autre historique disponible",
985
+ entity_history_revert_dialog_title: "Restaurer les données à cette version ?",
986
+ entity_history_previous_value: "Valeur précédente",
987
+ entity_history_see_details: "Voir les détails de cette révision",
988
+ entity_history_just_now: "à l'instant",
989
+ entity_history_minutes_ago: "il y a {{minutes}}m",
990
+ entity_history_hours_ago: "il y a {{hours}}h",
991
+ entity_history_days_ago: "il y a {{days}}j",
992
+ user_picture: "Photo de l'utilisateur"
993
+ };
994
+ const entityHistoryTranslationsIt = {
995
+ history: "Cronologia",
996
+ entity_history_only_existing: "La cronologia è disponibile solo per le entità esistenti",
997
+ entity_history_reverted: "Versione ripristinata",
998
+ entity_history_error_reverting: "Errore durante il ripristino dell'entità",
999
+ entity_history_no_history: "Nessuna cronologia disponibile",
1000
+ entity_history_when_save: "Quando salvi un'entità, viene creata una nuova versione e memorizzata nella cronologia.",
1001
+ entity_history_revert_tooltip: "Ripristina a questa versione",
1002
+ entity_history_please_save: "Salva o annulla le modifiche prima del ripristino",
1003
+ loading_more: "Caricamento in corso...",
1004
+ entity_history_no_more: "Nessuna ulteriore cronologia disponibile",
1005
+ entity_history_revert_dialog_title: "Vuoi ripristinare i dati a questa versione?",
1006
+ entity_history_previous_value: "Valore precedente",
1007
+ entity_history_see_details: "Vedi i dettagli per questa revisione",
1008
+ entity_history_just_now: "proprio adesso",
1009
+ entity_history_minutes_ago: "{{minutes}} min fa",
1010
+ entity_history_hours_ago: "{{hours}} h fa",
1011
+ entity_history_days_ago: "{{days}} g fa",
1012
+ user_picture: "Immagine utente"
1013
+ };
1014
+ const entityHistoryTranslationsHi = {
1015
+ history: "इतिहास",
1016
+ entity_history_only_existing: "इतिहास केवल मौजूद संस्थाओं के लिए उपलब्ध है",
1017
+ entity_history_reverted: "परिवर्तित संस्करण",
1018
+ entity_history_error_reverting: "संस्था को वापस लाने में त्रुटि",
1019
+ entity_history_no_history: "कोई इतिहास उपलब्ध नहीं",
1020
+ entity_history_when_save: "जब आप किसी संस्था को सहेजते हैं, तो एक नया संस्करण बनाया जाता है और इतिहास में संग्रहीत किया जाता है।",
1021
+ entity_history_revert_tooltip: "इस संस्करण पर वापस जाएं",
1022
+ entity_history_please_save: "कृपया वापस जाने से पहले अपने परिवर्तनों को सहेजें या हटा दें",
1023
+ loading_more: "और लोड हो रहा है...",
1024
+ entity_history_no_more: "कोई और इतिहास उपलब्ध नहीं",
1025
+ entity_history_revert_dialog_title: "डेटा को इस संस्करण में वापस लाएँ?",
1026
+ entity_history_previous_value: "पिछला मान",
1027
+ entity_history_see_details: "इस संशोधन के लिए विवरण यहाँ देखें",
1028
+ entity_history_just_now: "अभी-अभी",
1029
+ entity_history_minutes_ago: "{{minutes}}m पहले",
1030
+ entity_history_hours_ago: "{{hours}}h पहले",
1031
+ entity_history_days_ago: "{{days}}d पहले",
1032
+ user_picture: "उपयोगकर्ता चित्र"
1033
+ };
1034
+ const entityHistoryTranslationsPt = {
1035
+ history: "Histórico",
1036
+ entity_history_only_existing: "O histórico está disponível apenas para entidades existentes",
1037
+ entity_history_reverted: "Versão revertida",
1038
+ entity_history_error_reverting: "Erro ao reverter entidade",
1039
+ entity_history_no_history: "Sem histórico disponível",
1040
+ entity_history_when_save: "Quando guarda uma entidade, é criada uma nova versão e armazenada no histórico.",
1041
+ entity_history_revert_tooltip: "Reverter para esta versão",
1042
+ entity_history_please_save: "Por favor guarde ou descarte as suas alterações antes de reverter",
1043
+ loading_more: "A carregar mais...",
1044
+ entity_history_no_more: "Sem mais histórico disponível",
1045
+ entity_history_revert_dialog_title: "Reverter dados para esta versão?",
1046
+ entity_history_previous_value: "Valor anterior",
1047
+ entity_history_see_details: "Ver detalhes desta revisão",
1048
+ entity_history_just_now: "agora mesmo",
1049
+ entity_history_minutes_ago: "há {{minutes}}m",
1050
+ entity_history_hours_ago: "há {{hours}}h",
1051
+ entity_history_days_ago: "há {{days}}d",
1052
+ user_picture: "Foto do utilizador"
1053
+ };
678
1054
  function useEntityHistoryPlugin(props) {
679
1055
  const {
680
1056
  defaultEnabled = false
@@ -683,6 +1059,7 @@
683
1059
  if (collection.history === true || defaultEnabled && collection.history !== false) {
684
1060
  return {
685
1061
  ...collection,
1062
+ history: true,
686
1063
  entityViews: [...collection.entityViews ?? [], {
687
1064
  key: "__history",
688
1065
  name: "History",
@@ -703,13 +1080,26 @@
703
1080
  getUser: props?.getUser
704
1081
  }
705
1082
  },
1083
+ form: {
1084
+ BeforeTitle: LastEditedByFormAction
1085
+ },
706
1086
  collection: {
707
1087
  modifyCollection
1088
+ },
1089
+ i18n: {
1090
+ en: entityHistoryTranslationsEn,
1091
+ es: entityHistoryTranslationsEs,
1092
+ de: entityHistoryTranslationsDe,
1093
+ fr: entityHistoryTranslationsFr,
1094
+ it: entityHistoryTranslationsIt,
1095
+ hi: entityHistoryTranslationsHi,
1096
+ pt: entityHistoryTranslationsPt
708
1097
  }
709
1098
  }), [props]);
710
1099
  }
711
1100
  exports2.HistoryControllerContext = HistoryControllerContext;
712
1101
  exports2.HistoryControllerProvider = HistoryControllerProvider;
1102
+ exports2.LastEditedByIndicator = LastEditedByIndicator;
713
1103
  exports2.createHistoryEntry = createHistoryEntry;
714
1104
  exports2.useEntityHistoryPlugin = useEntityHistoryPlugin;
715
1105
  exports2.useHistoryController = useHistoryController;