@proveanything/smartlinks-utils-ui 0.12.15 → 0.12.17

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.
@@ -1908,8 +1908,10 @@ interface Props$9 {
1908
1908
  children: ReactNode;
1909
1909
  /** Which edge of the anchor the pill should hug. Defaults to `right`. */
1910
1910
  side?: 'left' | 'right';
1911
+ /** Which vertical position of the anchor the pill should hug. Defaults to `center`. */
1912
+ vAlign?: 'top' | 'center' | 'bottom';
1911
1913
  }
1912
- declare function PreviewReopenPill({ anchorRef, onClick, ariaLabel, title, children, side, }: Props$9): React$1.ReactPortal | null;
1914
+ declare function PreviewReopenPill({ anchorRef, onClick, ariaLabel, title, children, side, vAlign, }: Props$9): React$1.ReactPortal | null;
1913
1915
 
1914
1916
  declare const ScopeBreadcrumb: ({ scope }: {
1915
1917
  scope: ParsedRef;
@@ -2092,6 +2094,13 @@ interface UseRecordListArgs {
2092
2094
  };
2093
2095
  /** Page size requested from the SDK (default 100). */
2094
2096
  pageSize?: number;
2097
+ /**
2098
+ * Optional extra search corpus per record. Folded into the haystack
2099
+ * alongside `label` + `subtitle`. Used by the shell on the Rules tab
2100
+ * to make facet keys + value labels (the chips users actually see)
2101
+ * searchable.
2102
+ */
2103
+ searchCorpus?: (record: RecordSummary) => string | undefined | null;
2095
2104
  /**
2096
2105
  * Lifecycle values treated as "active". Defaults to `['active']`. Records
2097
2106
  * with a missing/empty `status` are always treated as active (legacy
@@ -912,6 +912,7 @@ var useRecordList = (args) => {
912
912
  scaffolder,
913
913
  contextScope,
914
914
  pageSize = 100,
915
+ searchCorpus,
915
916
  activeStatuses = DEFAULT_ACTIVE_STATUSES
916
917
  } = args;
917
918
  const queryClient = useQueryClient();
@@ -965,10 +966,13 @@ var useRecordList = (args) => {
965
966
  if (filter !== "all") out = out.filter((r) => r.status === filter);
966
967
  if (search.trim()) {
967
968
  const q = search.trim().toLowerCase();
968
- out = out.filter((r) => `${r.label} ${r.subtitle ?? ""}`.toLowerCase().includes(q));
969
+ out = out.filter((r) => {
970
+ const extra = searchCorpus?.(r) ?? "";
971
+ return `${r.label} ${r.subtitle ?? ""} ${extra}`.toLowerCase().includes(q);
972
+ });
969
973
  }
970
974
  return out;
971
- }, [items, filter, search]);
975
+ }, [items, filter, search, searchCorpus]);
972
976
  const counts = useMemo(() => ({
973
977
  all: items.length,
974
978
  configured: items.filter((r) => r.status === "configured").length,
@@ -1298,7 +1302,8 @@ function useShellBrowser(opts) {
1298
1302
  drillTab,
1299
1303
  classify: classify3,
1300
1304
  pageSize,
1301
- activeStatuses
1305
+ activeStatuses,
1306
+ searchCorpus
1302
1307
  } = opts;
1303
1308
  const [search, setSearch] = useState("");
1304
1309
  const [filter, setFilter] = useState("all");
@@ -1326,7 +1331,8 @@ function useShellBrowser(opts) {
1326
1331
  contextScope,
1327
1332
  enabled: recordListEnabled,
1328
1333
  pageSize,
1329
- activeStatuses
1334
+ activeStatuses,
1335
+ searchCorpus
1330
1336
  });
1331
1337
  const facetBrowse = useFacetBrowse({
1332
1338
  SL,
@@ -8831,15 +8837,18 @@ function PreviewReopenPill({
8831
8837
  ariaLabel,
8832
8838
  title,
8833
8839
  children,
8834
- side = "right"
8840
+ side = "right",
8841
+ vAlign = "center"
8835
8842
  }) {
8836
8843
  const [pos, setPos] = useState(null);
8837
8844
  const rafRef = useRef(null);
8838
8845
  useLayoutEffect(() => {
8839
8846
  const el = anchorRef.current;
8840
8847
  if (typeof window === "undefined") return;
8848
+ const TOP_INSET = 14;
8849
+ const fallbackTop = () => vAlign === "top" ? TOP_INSET : vAlign === "bottom" ? Math.max(0, window.innerHeight - TOP_INSET) : window.innerHeight / 2;
8841
8850
  if (!el) {
8842
- setPos({ top: window.innerHeight / 2, right: 8, left: 8 });
8851
+ setPos({ top: fallbackTop(), right: 8, left: 8 });
8843
8852
  return;
8844
8853
  }
8845
8854
  const measure = () => {
@@ -8847,11 +8856,11 @@ function PreviewReopenPill({
8847
8856
  rafRef.current = requestAnimationFrame(() => {
8848
8857
  const rect = el.getBoundingClientRect();
8849
8858
  if (rect.width === 0 && rect.height === 0) {
8850
- setPos({ top: window.innerHeight / 2, right: 8, left: 8 });
8851
8859
  return;
8852
8860
  }
8861
+ const top = vAlign === "top" ? rect.top + TOP_INSET : vAlign === "bottom" ? rect.bottom - TOP_INSET : rect.top + rect.height / 2;
8853
8862
  setPos({
8854
- top: rect.top + rect.height / 2,
8863
+ top,
8855
8864
  right: Math.max(0, window.innerWidth - rect.right),
8856
8865
  left: Math.max(0, rect.left)
8857
8866
  });
@@ -8869,13 +8878,14 @@ function PreviewReopenPill({
8869
8878
  window.removeEventListener("scroll", measure, true);
8870
8879
  if (rafRef.current != null) cancelAnimationFrame(rafRef.current);
8871
8880
  };
8872
- }, [anchorRef]);
8881
+ }, [anchorRef, vAlign]);
8873
8882
  if (typeof document === "undefined") return null;
8874
8883
  const effectivePos = pos ?? {
8875
- top: typeof window !== "undefined" ? window.innerHeight / 2 : 200,
8884
+ top: typeof window !== "undefined" ? vAlign === "top" ? 14 : vAlign === "bottom" ? window.innerHeight - 14 : window.innerHeight / 2 : 200,
8876
8885
  right: 8,
8877
8886
  left: 8
8878
8887
  };
8888
+ const translateY = vAlign === "center" ? "-50%" : "0";
8879
8889
  return createPortal(
8880
8890
  /* @__PURE__ */ jsx(
8881
8891
  "button",
@@ -8891,7 +8901,7 @@ function PreviewReopenPill({
8891
8901
  ...side === "right" ? { right: effectivePos.right } : { left: effectivePos.left },
8892
8902
  // Pull half the pill width out into the gutter so it visually
8893
8903
  // anchors *to* the editor edge rather than sitting inside it.
8894
- transform: side === "right" ? "translate(50%, -50%)" : "translate(-50%, -50%)"
8904
+ transform: side === "right" ? `translate(50%, ${translateY})` : `translate(-50%, ${translateY})`
8895
8905
  },
8896
8906
  children
8897
8907
  }
@@ -9461,6 +9471,27 @@ function RecordsAdminShellInner(props) {
9461
9471
  if (requested === "header" && !headerWillRender) return "footer";
9462
9472
  return requested;
9463
9473
  }, [intro?.reopenAffordance, headerWillRender]);
9474
+ const ruleLabelLookupRef = useRef(null);
9475
+ const ruleSearchCorpus = useCallback((r) => {
9476
+ const rule = r.facetRule;
9477
+ if (!rule?.all?.length) return "";
9478
+ const lookup = ruleLabelLookupRef.current;
9479
+ const parts = [];
9480
+ for (const clause of rule.all) {
9481
+ if (clause.facetKey) {
9482
+ parts.push(clause.facetKey);
9483
+ const fl = lookup?.facetLabel?.(clause.facetKey);
9484
+ if (fl) parts.push(fl);
9485
+ }
9486
+ for (const v of clause.anyOf ?? []) {
9487
+ if (!v) continue;
9488
+ parts.push(v);
9489
+ const vl = lookup?.valueLabel?.(clause.facetKey, v);
9490
+ if (vl) parts.push(vl);
9491
+ }
9492
+ }
9493
+ return parts.join(" ");
9494
+ }, []);
9464
9495
  const browser = useShellBrowser({
9465
9496
  ctx,
9466
9497
  SL,
@@ -9472,7 +9503,8 @@ function RecordsAdminShellInner(props) {
9472
9503
  drillTab,
9473
9504
  classify: classify3,
9474
9505
  pageSize: railPageSize,
9475
- activeStatuses
9506
+ activeStatuses,
9507
+ searchCorpus: ruleSearchCorpus
9476
9508
  });
9477
9509
  const {
9478
9510
  search,
@@ -10378,9 +10410,20 @@ function RecordsAdminShellInner(props) {
10378
10410
  );
10379
10411
  }
10380
10412
  return withNav(
10381
- /* @__PURE__ */ jsxs("div", { className: "relative h-full", children: [
10382
- baseEditor(
10383
- /* @__PURE__ */ jsx(PreviewToggleButton, { onClick: () => setDrawerOpen(true), label: i18n.openPreview })
10413
+ /* @__PURE__ */ jsxs("div", { className: "relative h-full", ref: previewAnchorRef, children: [
10414
+ baseEditor(),
10415
+ !drawerOpen && /* @__PURE__ */ jsxs(
10416
+ PreviewReopenPill,
10417
+ {
10418
+ anchorRef: previewAnchorRef,
10419
+ onClick: () => setDrawerOpen(true),
10420
+ ariaLabel: i18n.openPreview,
10421
+ title: i18n.openPreview,
10422
+ children: [
10423
+ /* @__PURE__ */ jsx(Eye, { "aria-hidden": "true" }),
10424
+ i18n.preview
10425
+ ]
10426
+ }
10384
10427
  ),
10385
10428
  /* @__PURE__ */ jsx(
10386
10429
  DrawerPreview,
@@ -10474,6 +10517,7 @@ function RecordsAdminShellInner(props) {
10474
10517
  valueLabel: (k, v) => map.get(k)?.values.get(v)
10475
10518
  };
10476
10519
  }, [facetBrowse.items]);
10520
+ ruleLabelLookupRef.current = ruleLabelLookup;
10477
10521
  const effectiveGroupBy = useMemo(() => {
10478
10522
  if (groupBy) return groupBy;
10479
10523
  if (isAllTab) return void 0;
@@ -11197,7 +11241,7 @@ function RecordsAdminShellInner(props) {
11197
11241
  ),
11198
11242
  !(isGlobalTab && !isCollection) && /* @__PURE__ */ jsxs(Fragment, { children: [
11199
11243
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
11200
- /* @__PURE__ */ jsxs("div", { className: "relative flex-1 min-w-0", children: [
11244
+ !isGlobalTab && /* @__PURE__ */ jsxs("div", { className: "relative flex-1 min-w-0", children: [
11201
11245
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 opacity-50" }),
11202
11246
  /* @__PURE__ */ jsx(
11203
11247
  "input",
@@ -11415,6 +11459,7 @@ function RecordsAdminShellInner(props) {
11415
11459
  {
11416
11460
  anchorRef: railReopenAnchorRef,
11417
11461
  side: "left",
11462
+ vAlign: "top",
11418
11463
  onClick: () => setRailOpen(true),
11419
11464
  ariaLabel: i18n.openList,
11420
11465
  title: i18n.openList,