@ai-matrx/records-ui 0.101.34 → 0.101.35

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.d.cts CHANGED
@@ -6414,6 +6414,7 @@ interface EntitySourceState {
6414
6414
  /** A standard source's presented columns and one page of its rows, read as the person. */
6415
6415
  declare function useEntitySource(token: string, options?: {
6416
6416
  limit?: number;
6417
+ search?: string | null;
6417
6418
  }): EntitySourceState;
6418
6419
  /** The column that names a row: the door's first of name / display_name / title / subject, else its first text column. */
6419
6420
  declare function entityNameColumn(columns: readonly EntityColumn[]): EntityColumn | null;
@@ -6483,11 +6484,14 @@ interface EntityTablePageProps {
6483
6484
  /** The board's choice column (api_name). */
6484
6485
  groupBy?: string | undefined;
6485
6486
  onOpenRecord?: ((rowId: string) => void) | undefined;
6487
+ /** The viewer's own search, handed by the host; asked of the door. Never saved. */
6488
+ searchOverride?: string | null | undefined;
6489
+ onSearchChange?: ((search: string) => void) | undefined;
6486
6490
  /** Beside the title row's controls (the host's own). */
6487
6491
  actions?: ReactNode;
6488
6492
  className?: string | undefined;
6489
6493
  }
6490
- declare function EntityTablePage({ source, presentation, pageSize, layout: opened, onLayoutChange, groupBy, onOpenRecord, actions, className, }: EntityTablePageProps): react.JSX.Element;
6494
+ declare function EntityTablePage({ source, presentation, searchOverride, onSearchChange, pageSize, layout: opened, onLayoutChange, groupBy, onOpenRecord, actions, className, }: EntityTablePageProps): react.JSX.Element;
6491
6495
 
6492
6496
  type TablePageSource = {
6493
6497
  kind: "table";
package/dist/index.d.ts CHANGED
@@ -6414,6 +6414,7 @@ interface EntitySourceState {
6414
6414
  /** A standard source's presented columns and one page of its rows, read as the person. */
6415
6415
  declare function useEntitySource(token: string, options?: {
6416
6416
  limit?: number;
6417
+ search?: string | null;
6417
6418
  }): EntitySourceState;
6418
6419
  /** The column that names a row: the door's first of name / display_name / title / subject, else its first text column. */
6419
6420
  declare function entityNameColumn(columns: readonly EntityColumn[]): EntityColumn | null;
@@ -6483,11 +6484,14 @@ interface EntityTablePageProps {
6483
6484
  /** The board's choice column (api_name). */
6484
6485
  groupBy?: string | undefined;
6485
6486
  onOpenRecord?: ((rowId: string) => void) | undefined;
6487
+ /** The viewer's own search, handed by the host; asked of the door. Never saved. */
6488
+ searchOverride?: string | null | undefined;
6489
+ onSearchChange?: ((search: string) => void) | undefined;
6486
6490
  /** Beside the title row's controls (the host's own). */
6487
6491
  actions?: ReactNode;
6488
6492
  className?: string | undefined;
6489
6493
  }
6490
- declare function EntityTablePage({ source, presentation, pageSize, layout: opened, onLayoutChange, groupBy, onOpenRecord, actions, className, }: EntityTablePageProps): react.JSX.Element;
6494
+ declare function EntityTablePage({ source, presentation, searchOverride, onSearchChange, pageSize, layout: opened, onLayoutChange, groupBy, onOpenRecord, actions, className, }: EntityTablePageProps): react.JSX.Element;
6491
6495
 
6492
6496
  type TablePageSource = {
6493
6497
  kind: "table";
package/dist/index.js CHANGED
@@ -23169,8 +23169,10 @@ import { jsx as jsx69 } from "react/jsx-runtime";
23169
23169
  function useEntitySource(token, options = {}) {
23170
23170
  const client = useRecordsClient38();
23171
23171
  const limit = options.limit ?? 50;
23172
+ const search = (options.search ?? "").trim();
23172
23173
  const [tick, setTick] = useState60(0);
23173
23174
  const held = useRef30(0);
23175
+ const askedSearch = useRef30("");
23174
23176
  const [loadingMore, setLoadingMore] = useState60(false);
23175
23177
  const [state, setState] = useState60({
23176
23178
  label: null,
@@ -23183,8 +23185,12 @@ function useEntitySource(token, options = {}) {
23183
23185
  });
23184
23186
  useEffect48(() => {
23185
23187
  let cancelled = false;
23188
+ if (askedSearch.current !== search) {
23189
+ askedSearch.current = search;
23190
+ held.current = 0;
23191
+ }
23186
23192
  const source = { kind: "entity", token };
23187
- void Promise.all([client.drillDescribe({ source }), client.drillRows({ source, limit: Math.max(limit, held.current) })]).then(
23193
+ void Promise.all([client.drillDescribe({ source }), client.drillRows({ source, limit: Math.max(limit, held.current), ...search ? { search } : {} })]).then(
23188
23194
  ([def, page]) => {
23189
23195
  if (cancelled) return;
23190
23196
  if (!def.ok) return setState((s) => ({ ...s, loading: false, error: refusalSentence(def.error) || "This table could not be read." }));
@@ -23210,7 +23216,7 @@ function useEntitySource(token, options = {}) {
23210
23216
  return () => {
23211
23217
  cancelled = true;
23212
23218
  };
23213
- }, [client, token, limit, tick]);
23219
+ }, [client, token, limit, tick, search]);
23214
23220
  const reload = useCallback26(() => setTick((t) => t + 1), []);
23215
23221
  const write = useCallback26(
23216
23222
  async (rowId, apiName, value) => {
@@ -23240,7 +23246,7 @@ function useEntitySource(token, options = {}) {
23240
23246
  if (loadingMore) return;
23241
23247
  setLoadingMore(true);
23242
23248
  const source = { kind: "entity", token };
23243
- const next = await client.drillRows({ source, limit, offset: held.current });
23249
+ const next = await client.drillRows({ source, limit, offset: held.current, ...search ? { search } : {} });
23244
23250
  setLoadingMore(false);
23245
23251
  if (!next.ok) return;
23246
23252
  const more = next.data.rows ?? [];
@@ -23249,7 +23255,7 @@ function useEntitySource(token, options = {}) {
23249
23255
  const seen = new Set(s.rows.map((r) => r.id));
23250
23256
  return { ...s, rows: [...s.rows, ...more.filter((r) => !seen.has(r.id))] };
23251
23257
  });
23252
- }, [client, token, limit, loadingMore]);
23258
+ }, [client, token, limit, loadingMore, search]);
23253
23259
  const hasMore = !state.loading && state.total > state.rows.length;
23254
23260
  return { ...state, write, create, reload, loadMore, hasMore, loadingMore };
23255
23261
  }
@@ -47201,6 +47207,7 @@ function usePublicReadOnly(client, organizationId, tableId, table, rights) {
47201
47207
  }
47202
47208
 
47203
47209
  // src/entityViews.tsx
47210
+ import { TapTargetSearchGroup as TapTargetSearchGroup2, TooltipProvider } from "@ai-matrx/design-system";
47204
47211
  import { MatrxTableCardShowMore as MatrxTableCardShowMore2 } from "@ai-matrx/design-system/data-table";
47205
47212
  import { useEffect as useEffect110, useMemo as useMemo75, useState as useState132 } from "react";
47206
47213
  import { Button as Button106, ErrorBox as ErrorBox9, Input as Input12, cn as cn93 } from "@ai-matrx/design-system";
@@ -47345,6 +47352,8 @@ function EntityChartBlock({ source, kind, by, measure, title, where, organizatio
47345
47352
  function EntityTablePage({
47346
47353
  source,
47347
47354
  presentation = "page",
47355
+ searchOverride,
47356
+ onSearchChange,
47348
47357
  pageSize = presentation === "embedded" ? EMBEDDED_PAGE_SIZE : 100,
47349
47358
  layout: opened = "grid",
47350
47359
  onLayoutChange,
@@ -47353,7 +47362,9 @@ function EntityTablePage({
47353
47362
  actions,
47354
47363
  className
47355
47364
  }) {
47356
- const entity = useEntitySource(source.token, { limit: pageSize });
47365
+ const [typed2, setTyped] = useState132("");
47366
+ const term = searchOverride ?? typed2;
47367
+ const entity = useEntitySource(source.token, { limit: pageSize, search: term });
47357
47368
  const [layout, setLayout] = useState132(opened);
47358
47369
  useEffect110(() => setLayout(opened), [opened]);
47359
47370
  const choose = (next) => {
@@ -47430,6 +47441,17 @@ function EntityTablePage({
47430
47441
  ] }) : null,
47431
47442
  addRefused ? /* @__PURE__ */ jsx153(ErrorBox9, { className: "rounded border border-destructive/40 px-1.5 py-1 text-xs text-destructive", message: addRefused, operation: "Add a row", origin: "records-ui/entityViews" }) : null,
47432
47443
  entity.error ? /* @__PURE__ */ jsx153("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx153(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs141(Fragment62, { children: [
47444
+ presentation === "embedded" ? /* @__PURE__ */ jsx153("div", { className: "flex min-w-0 items-center justify-end", "data-records-entity-search": "", children: /* @__PURE__ */ jsx153(TooltipProvider, { children: /* @__PURE__ */ jsx153(
47445
+ TapTargetSearchGroup2,
47446
+ {
47447
+ placeholder: "Search",
47448
+ value: term,
47449
+ onValueChange: (next) => {
47450
+ setTyped(next);
47451
+ onSearchChange?.(next);
47452
+ }
47453
+ }
47454
+ ) }) }) : null,
47433
47455
  /* @__PURE__ */ jsx153(EntityGrid, { entity, pageSize, embedded: presentation === "embedded", ...drill ? { drill } : {} }),
47434
47456
  presentation === "embedded" && entity.hasMore ? /* @__PURE__ */ jsx153(
47435
47457
  MatrxTableCardShowMore2,
@@ -47456,6 +47478,8 @@ function TablePage2(props) {
47456
47478
  source,
47457
47479
  ...rest.presentation ? { presentation: rest.presentation } : {},
47458
47480
  ...rest.pageSize ? { pageSize: rest.pageSize } : {},
47481
+ ...rest.searchOverride !== void 0 ? { searchOverride: rest.searchOverride } : {},
47482
+ ...rest.onSearchChange ? { onSearchChange: rest.onSearchChange } : {},
47459
47483
  ...layout ? { layout } : {},
47460
47484
  ...onLayoutChange ? { onLayoutChange } : {},
47461
47485
  ...groupBy ? { groupBy } : {},