@aduptive/strapi-blockscene 2.0.0-alpha.13 → 2.0.0-alpha.14

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/admin.cjs CHANGED
@@ -9244,7 +9244,7 @@ var Drawer = import_styled_components7.default.aside`
9244
9244
  var Entry = import_styled_components7.default.button`
9245
9245
  display: block; width: 100%; text-align: left; padding: 12px; margin: 4px 0;
9246
9246
  border: 1px solid ${({ theme }) => theme.colors.neutral200}; border-radius: 4px;
9247
- background: ${({ theme }) => theme.colors.neutral0}; cursor: pointer;
9247
+ background: ${({ theme }) => theme.colors.neutral0}; color: ${({ theme }) => theme.colors.neutral800}; cursor: pointer;
9248
9248
  &[aria-pressed="true"] { background: ${({ theme }) => theme.colors.primary100}; border-color: ${({ theme }) => theme.colors.primary600}; }
9249
9249
  &:focus-visible { outline: 2px solid ${({ theme }) => theme.colors.primary600}; outline-offset: 2px; }
9250
9250
  &:disabled { cursor: default; opacity: .65; }
@@ -9384,6 +9384,7 @@ function useVersions(host, config2) {
9384
9384
  const day = when2(event.at, true), heading = day !== previousDay;
9385
9385
  previousDay = day;
9386
9386
  const blocks = event.summary?.blocks;
9387
+ const actions = (Array.isArray(event.actions) && event.actions.length ? event.actions : [event.action]).map((action) => t.historyActions[action] || action).join(" \xB7 ");
9387
9388
  const counted = ["total", "added", "removed", "changed"].every((key) => Number.isInteger(blocks?.[key]));
9388
9389
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(React11.Fragment, { children: [
9389
9390
  heading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_design_system7.Typography, { tag: "h3", variant: "omega", fontWeight: "bold", style: { marginTop: 12 }, children: day }),
@@ -9400,7 +9401,7 @@ function useVersions(host, config2) {
9400
9401
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_design_system7.Typography, { tag: "p", variant: "pi", children: [
9401
9402
  when2(event.at),
9402
9403
  " \xB7 ",
9403
- t.historyActions[event.action] || event.action
9404
+ actions
9404
9405
  ] }),
9405
9406
  counted ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
9406
9407
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_design_system7.Typography, { tag: "p", variant: "pi", textColor: "neutral600", children: t.f("versionsCounts", blocks) }),
package/dist/admin.mjs CHANGED
@@ -9274,7 +9274,7 @@ var Drawer = styled7.aside`
9274
9274
  var Entry = styled7.button`
9275
9275
  display: block; width: 100%; text-align: left; padding: 12px; margin: 4px 0;
9276
9276
  border: 1px solid ${({ theme }) => theme.colors.neutral200}; border-radius: 4px;
9277
- background: ${({ theme }) => theme.colors.neutral0}; cursor: pointer;
9277
+ background: ${({ theme }) => theme.colors.neutral0}; color: ${({ theme }) => theme.colors.neutral800}; cursor: pointer;
9278
9278
  &[aria-pressed="true"] { background: ${({ theme }) => theme.colors.primary100}; border-color: ${({ theme }) => theme.colors.primary600}; }
9279
9279
  &:focus-visible { outline: 2px solid ${({ theme }) => theme.colors.primary600}; outline-offset: 2px; }
9280
9280
  &:disabled { cursor: default; opacity: .65; }
@@ -9414,6 +9414,7 @@ function useVersions(host, config2) {
9414
9414
  const day = when2(event.at, true), heading = day !== previousDay;
9415
9415
  previousDay = day;
9416
9416
  const blocks = event.summary?.blocks;
9417
+ const actions = (Array.isArray(event.actions) && event.actions.length ? event.actions : [event.action]).map((action) => t.historyActions[action] || action).join(" \xB7 ");
9417
9418
  const counted = ["total", "added", "removed", "changed"].every((key) => Number.isInteger(blocks?.[key]));
9418
9419
  return /* @__PURE__ */ jsxs9(React11.Fragment, { children: [
9419
9420
  heading && /* @__PURE__ */ jsx12(Typography7, { tag: "h3", variant: "omega", fontWeight: "bold", style: { marginTop: 12 }, children: day }),
@@ -9430,7 +9431,7 @@ function useVersions(host, config2) {
9430
9431
  /* @__PURE__ */ jsxs9(Typography7, { tag: "p", variant: "pi", children: [
9431
9432
  when2(event.at),
9432
9433
  " \xB7 ",
9433
- t.historyActions[event.action] || event.action
9434
+ actions
9434
9435
  ] }),
9435
9436
  counted ? /* @__PURE__ */ jsxs9(Fragment10, { children: [
9436
9437
  /* @__PURE__ */ jsx12(Typography7, { tag: "p", variant: "pi", textColor: "neutral600", children: t.f("versionsCounts", blocks) }),
package/dist/server.cjs CHANGED
@@ -1460,6 +1460,18 @@ var require_history = __commonJS({
1460
1460
  var hashOf = (text) => createHash("sha256").update(text).digest("hex");
1461
1461
  var covers2 = (history, uid) => Boolean(history?.enabled) && uid.startsWith("api::") && (history.contentTypes === "all" || Array.isArray(history.contentTypes) && history.contentTypes.includes(uid));
1462
1462
  var retention = ({ retentionDays, eventDays }, now = Date.now()) => ({ snapshotsBefore: new Date(now - retentionDays * DAY), eventsBefore: new Date(now - eventDays * DAY) });
1463
+ var hasChanges = (summary) => Boolean(summary?.initial || summary?.fields?.length || ["added", "removed", "changed"].some((key) => summary?.blocks?.[key] > 0));
1464
+ function collapseVersions(events) {
1465
+ const versions = [];
1466
+ for (const event of events) {
1467
+ const previous = versions[versions.length - 1];
1468
+ if (event.hash && previous?.hash === event.hash) {
1469
+ if (!previous.actions.includes(event.action)) previous.actions.push(event.action);
1470
+ if (!hasChanges(previous.summary) && hasChanges(event.summary)) previous.summary = event.summary;
1471
+ } else versions.push({ ...event, actions: [event.action] });
1472
+ }
1473
+ return versions;
1474
+ }
1463
1475
  function actorOf(strapi) {
1464
1476
  let ctx;
1465
1477
  try {
@@ -1561,12 +1573,14 @@ var require_history = __commonJS({
1561
1573
  async list({ uid, documentId, locale, actor = "", page = 1, pageSize = 25 }) {
1562
1574
  const scope2 = { contentType: uid, relatedDocumentId: documentId, locale: locale || null };
1563
1575
  const where = { ...scope2, ...actor && { actor } };
1564
- const [list, kept, total, people] = await Promise.all([
1565
- events().findMany({ select: ["id", "action", "actor", "actorName", "at", "summary", "hash", "size"], where, orderBy: [{ at: "desc" }, { id: "desc" }], offset: (page - 1) * pageSize, limit: pageSize }),
1576
+ const [timeline, kept, people] = await Promise.all([
1577
+ events().findMany({ select: ["id", "action", "actor", "actorName", "at", "summary", "hash", "size"], where, orderBy: [{ at: "desc" }, { id: "desc" }] }),
1566
1578
  events().findMany({ select: ["hash"], where: { ...scope2, size: { $gt: 0 } } }),
1567
- events().count({ where }),
1568
1579
  events().findMany({ select: ["actor", "actorName"], where: scope2, orderBy: [{ at: "desc" }, { id: "desc" }] })
1569
1580
  ]);
1581
+ const versions = collapseVersions(timeline);
1582
+ const total = versions.length;
1583
+ const list = versions.slice((page - 1) * pageSize, page * pageSize);
1570
1584
  const hashes = new Set(kept.map((row) => row.hash));
1571
1585
  const actors2 = [...new Map(people.slice().reverse().map(({ actor: actor2, actorName }) => [actor2, { actor: actor2, actorName }])).values()];
1572
1586
  return {
@@ -1814,7 +1828,7 @@ var require_history = __commonJS({
1814
1828
  };
1815
1829
  }
1816
1830
  });
1817
- module2.exports = { EVENT_UID, ACTIONS, CAPTURED, CRON: CRON2, BATCH, eventContentType: eventContentType2, covers: covers2, retention, actorOf, refsOf, can, readableTypes, historyService: historyService2, registerHistory: registerHistory2, registerPurge: registerPurge2, historyController: historyController2 };
1831
+ module2.exports = { EVENT_UID, ACTIONS, CAPTURED, CRON: CRON2, BATCH, eventContentType: eventContentType2, covers: covers2, retention, actorOf, refsOf, collapseVersions, can, readableTypes, historyService: historyService2, registerHistory: registerHistory2, registerPurge: registerPurge2, historyController: historyController2 };
1818
1832
  }
1819
1833
  });
1820
1834
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aduptive/strapi-blockscene",
3
- "version": "2.0.0-alpha.13",
3
+ "version": "2.0.0-alpha.14",
4
4
  "description": "Visual component gallery for native Strapi dynamic zones.",
5
5
  "license": "MIT",
6
6
  "author": "Andrea Scarpello <aduptive@gmail.com>",