@proveanything/smartlinks-utils-ui 0.12.11 → 0.12.13

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.
@@ -137,6 +137,48 @@ function removeRecordFromScopeCounts(queryClient, ctx, recordId) {
137
137
  });
138
138
  }
139
139
  }
140
+ function patchRecordStatusInCaches(queryClient, ctx, recordId, status) {
141
+ if (!recordId) return;
142
+ const lists = [
143
+ ...queryClient.getQueriesData({ queryKey: RECORD_LIST_QK }),
144
+ ...queryClient.getQueriesData({ queryKey: COLLECTION_ITEMS_QK })
145
+ ];
146
+ for (const [key, cache] of lists) {
147
+ if (!cache || !Array.isArray(cache.pages)) continue;
148
+ const prefix = key[0] === RECORD_LIST_QK[0] && key[1] === RECORD_LIST_QK[1] ? RECORD_LIST_QK : COLLECTION_ITEMS_QK;
149
+ if (!matchesCtx(key, prefix, ctx)) continue;
150
+ queryClient.setQueryData(key, (prev) => {
151
+ if (!prev || !Array.isArray(prev.pages)) return prev;
152
+ let touched = false;
153
+ const pages = prev.pages.map((p) => ({
154
+ ...p,
155
+ data: p.data.map((r) => {
156
+ if (r.id !== recordId) return r;
157
+ touched = true;
158
+ return { ...r, status };
159
+ })
160
+ }));
161
+ return touched ? { ...prev, pages } : prev;
162
+ });
163
+ }
164
+ const counts = queryClient.getQueriesData({
165
+ queryKey: SCOPE_COUNTS_QK
166
+ });
167
+ for (const [key, cache] of counts) {
168
+ if (!cache || !Array.isArray(cache.records)) continue;
169
+ if (!matchesScopeCountsCtx(key, ctx)) continue;
170
+ queryClient.setQueryData(key, (prev) => {
171
+ if (!prev || !Array.isArray(prev.records)) return prev;
172
+ let touched = false;
173
+ const records = prev.records.map((r) => {
174
+ if (r.id !== recordId) return r;
175
+ touched = true;
176
+ return { ...r, status };
177
+ });
178
+ return touched ? { ...prev, records } : prev;
179
+ });
180
+ }
181
+ }
140
182
  function removeRecordFromCaches(queryClient, ctx, recordId) {
141
183
  if (!recordId) return;
142
184
  const all = [
@@ -7143,11 +7185,12 @@ function ItemListView({
7143
7185
  const def = resolveLifecycleStatus(item, lifecycle);
7144
7186
  const existing = map.get(def.value);
7145
7187
  if (existing) existing.items.push(item);
7146
- else map.set(def.value, { label: def.label, items: [item] });
7188
+ else map.set(def.value, { label: def.label, tone: def.tone ?? "default", items: [item] });
7147
7189
  }
7148
7190
  return Array.from(map.entries()).map(([key, v]) => ({
7149
7191
  key,
7150
7192
  label: v.label,
7193
+ tone: v.tone,
7151
7194
  items: v.items,
7152
7195
  isActive: activeValues.includes(key)
7153
7196
  })).sort((a, b) => compareLifecycleBuckets(a.key, b.key)).filter((b) => b.items.length > 0);
@@ -7315,11 +7358,13 @@ function ItemListView({
7315
7358
  } else if (buckets && buckets.length > 0) {
7316
7359
  body = /* @__PURE__ */ jsx("div", { className: "ra-item-buckets", children: buckets.map((bucket) => {
7317
7360
  const open = bucket.isActive || !collapsedBuckets.has(bucket.key);
7361
+ const toneVar = bucket.tone === "success" ? "var(--ra-success)" : bucket.tone === "warning" ? "var(--ra-warning)" : bucket.tone === "danger" ? "var(--ra-danger)" : bucket.tone === "info" ? "var(--ra-info)" : "var(--ra-status-missing)";
7318
7362
  return /* @__PURE__ */ jsxs(
7319
7363
  "section",
7320
7364
  {
7321
7365
  className: "ra-item-bucket",
7322
7366
  "data-bucket": bucket.key,
7367
+ style: { borderLeft: `3px solid hsl(${toneVar} / 0.55)` },
7323
7368
  children: [
7324
7369
  /* @__PURE__ */ jsxs(
7325
7370
  "button",
@@ -7335,7 +7380,7 @@ function ItemListView({
7335
7380
  gap: "6px",
7336
7381
  width: "100%",
7337
7382
  padding: "6px 12px",
7338
- background: "transparent",
7383
+ background: `hsl(${toneVar} / 0.06)`,
7339
7384
  border: 0,
7340
7385
  borderTop: "1px solid hsl(var(--ra-border))",
7341
7386
  font: "inherit",
@@ -7343,13 +7388,40 @@ function ItemListView({
7343
7388
  fontWeight: 600,
7344
7389
  textTransform: "uppercase",
7345
7390
  letterSpacing: "0.04em",
7346
- color: "hsl(var(--ra-muted-text))",
7391
+ color: `hsl(${toneVar})`,
7347
7392
  cursor: bucket.isActive ? "default" : "pointer"
7348
7393
  },
7349
7394
  children: [
7350
7395
  !bucket.isActive ? open ? /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "w-3 h-3", "aria-hidden": "true" }) : null,
7396
+ /* @__PURE__ */ jsx(
7397
+ "span",
7398
+ {
7399
+ "aria-hidden": "true",
7400
+ style: {
7401
+ width: 8,
7402
+ height: 8,
7403
+ borderRadius: 9999,
7404
+ background: `hsl(${toneVar})`,
7405
+ flexShrink: 0
7406
+ }
7407
+ }
7408
+ ),
7351
7409
  /* @__PURE__ */ jsx("span", { children: bucket.label }),
7352
- /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto", fontWeight: 500 }, children: bucket.items.length })
7410
+ /* @__PURE__ */ jsx(
7411
+ "span",
7412
+ {
7413
+ style: {
7414
+ marginLeft: "auto",
7415
+ fontWeight: 600,
7416
+ fontSize: "10px",
7417
+ padding: "1px 7px",
7418
+ borderRadius: 9999,
7419
+ background: `hsl(${toneVar} / 0.12)`,
7420
+ color: `hsl(${toneVar})`
7421
+ },
7422
+ children: bucket.items.length
7423
+ }
7424
+ )
7353
7425
  ]
7354
7426
  }
7355
7427
  ),
@@ -10009,6 +10081,7 @@ function RecordsAdminShellInner(props) {
10009
10081
  onAction: async () => {
10010
10082
  try {
10011
10083
  const updated = await SL.app.records.update(collectionId, appId, record.id, { status: next }, true);
10084
+ patchRecordStatusInCaches(queryClient, ctx, record.id, next);
10012
10085
  if (updated) {
10013
10086
  patchRecordIntoCaches(queryClient, ctx, updated);
10014
10087
  queryClient.invalidateQueries({
@@ -10129,6 +10202,7 @@ function RecordsAdminShellInner(props) {
10129
10202
  current: selectedSummary.lifecycleStatus,
10130
10203
  i18n,
10131
10204
  onChanged: (_next, updated) => {
10205
+ patchRecordStatusInCaches(queryClient, ctx, selectedSummary.id, _next);
10132
10206
  if (updated) {
10133
10207
  patchRecordIntoCaches(queryClient, ctx, updated);
10134
10208
  queryClient.invalidateQueries({
@@ -10158,6 +10232,7 @@ function RecordsAdminShellInner(props) {
10158
10232
  to: e.to
10159
10233
  }),
10160
10234
  onChanged: (_next, updated) => {
10235
+ patchRecordStatusInCaches(queryClient, ctx, selectedSummary.id, _next);
10161
10236
  if (updated) {
10162
10237
  patchRecordIntoCaches(queryClient, ctx, updated);
10163
10238
  queryClient.invalidateQueries({
@@ -10589,6 +10664,17 @@ function RecordsAdminShellInner(props) {
10589
10664
  label: i18n.lifecycleBadgeArchived.replace("{n}", String(lc.archived)),
10590
10665
  tone: "neutral"
10591
10666
  });
10667
+ let rowStatus = rep.status;
10668
+ let rowTone;
10669
+ if (lc.active > 0) {
10670
+ rowStatus = "configured";
10671
+ } else if (lc.draft === 0 && lc.archived > 0 && lc.other === 0) {
10672
+ rowStatus = "partial";
10673
+ rowTone = "muted";
10674
+ } else if (lc.draft > 0 || lc.other > 0 || lc.archived > 0) {
10675
+ rowStatus = "partial";
10676
+ rowTone = "warning";
10677
+ }
10592
10678
  return {
10593
10679
  ...rep,
10594
10680
  // Title carries the count + identity; the rule chips below render
@@ -10596,6 +10682,8 @@ function RecordsAdminShellInner(props) {
10596
10682
  // repeat the same information in two places.
10597
10683
  label: `${count} ${itemNoun}${count === 1 ? "" : "s"}`,
10598
10684
  subtitle: void 0,
10685
+ status: rowStatus,
10686
+ toneHint: rowTone,
10599
10687
  badges: [...rep.badges ?? [], ...lifecycleBadges],
10600
10688
  // Stash counts on the row for the sort comparator below.
10601
10689
  __lifecycleCounts: lc
@@ -11219,6 +11307,7 @@ function RecordsAdminShellInner(props) {
11219
11307
  for (const id of ids) {
11220
11308
  try {
11221
11309
  const updated = await SL.app.records.update(collectionId, appId, id, { status: archivedStatusValue }, true);
11310
+ patchRecordStatusInCaches(queryClient, ctx, id, archivedStatusValue);
11222
11311
  if (updated) patchRecordIntoCaches(queryClient, ctx, updated);
11223
11312
  onTelemetry?.({
11224
11313
  type: "recordAction.invoke",