@ai-matrx/records-ui 0.102.21 → 0.103.0

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
@@ -2270,6 +2270,11 @@ interface GridProps {
2270
2270
  searchOverride?: string | null | undefined;
2271
2271
  /** Every change of the term, from the embedded magnifier or the override (a controlled host's echo). */
2272
2272
  onSearchChange?: ((search: string) => void) | undefined;
2273
+ /**
2274
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
2275
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
2276
+ */
2277
+ searchBox?: boolean | undefined;
2273
2278
  /** The new-row line's words ("New page"). Default "Add row". */
2274
2279
  newRowLabel?: string | undefined;
2275
2280
  /**
@@ -3980,6 +3985,11 @@ interface ViewSwitcherProps {
3980
3985
  /** The viewer's own search (`GridProps.searchOverride`): this viewer only, never saved, asked of the store. */
3981
3986
  searchOverride?: string | null | undefined;
3982
3987
  onSearchChange?: ((search: string) => void) | undefined;
3988
+ /**
3989
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
3990
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
3991
+ */
3992
+ searchBox?: boolean | undefined;
3983
3993
  /** The grid's new-row line words (`GridProps.newRowLabel`). */
3984
3994
  newRowLabel?: string | undefined;
3985
3995
  className?: string | undefined;
@@ -4011,7 +4021,7 @@ declare function useViewRecords(view: SavedViewSpec, pageSize?: number, filter?:
4011
4021
  */
4012
4022
  membership: string;
4013
4023
  };
4014
- declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, searchOverride, onSearchChange, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
4024
+ declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, searchOverride, onSearchChange, searchBox, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
4015
4025
 
4016
4026
  type CalendarMode = "month" | "week" | "day" | "list";
4017
4027
  interface CalendarViewProps {
@@ -6066,6 +6076,11 @@ interface TablePageProps$1 {
6066
6076
  */
6067
6077
  searchOverride?: string | null | undefined;
6068
6078
  onSearchChange?: ((search: string) => void) | undefined;
6079
+ /**
6080
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
6081
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
6082
+ */
6083
+ searchBox?: boolean | undefined;
6069
6084
  /** Rows per page for every layout. */
6070
6085
  pageSize?: number | undefined;
6071
6086
  /**
@@ -6544,6 +6559,11 @@ interface EntityTablePageProps {
6544
6559
  /** The viewer's own search, handed by the host; asked of the door. Never saved. */
6545
6560
  searchOverride?: string | null | undefined;
6546
6561
  onSearchChange?: ((search: string) => void) | undefined;
6562
+ /**
6563
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
6564
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
6565
+ */
6566
+ searchBox?: boolean | undefined;
6547
6567
  /** Beside the title row's controls (the host's own). */
6548
6568
  actions?: ReactNode;
6549
6569
  className?: string | undefined;
package/dist/index.d.ts CHANGED
@@ -2270,6 +2270,11 @@ interface GridProps {
2270
2270
  searchOverride?: string | null | undefined;
2271
2271
  /** Every change of the term, from the embedded magnifier or the override (a controlled host's echo). */
2272
2272
  onSearchChange?: ((search: string) => void) | undefined;
2273
+ /**
2274
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
2275
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
2276
+ */
2277
+ searchBox?: boolean | undefined;
2273
2278
  /** The new-row line's words ("New page"). Default "Add row". */
2274
2279
  newRowLabel?: string | undefined;
2275
2280
  /**
@@ -3980,6 +3985,11 @@ interface ViewSwitcherProps {
3980
3985
  /** The viewer's own search (`GridProps.searchOverride`): this viewer only, never saved, asked of the store. */
3981
3986
  searchOverride?: string | null | undefined;
3982
3987
  onSearchChange?: ((search: string) => void) | undefined;
3988
+ /**
3989
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
3990
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
3991
+ */
3992
+ searchBox?: boolean | undefined;
3983
3993
  /** The grid's new-row line words (`GridProps.newRowLabel`). */
3984
3994
  newRowLabel?: string | undefined;
3985
3995
  className?: string | undefined;
@@ -4011,7 +4021,7 @@ declare function useViewRecords(view: SavedViewSpec, pageSize?: number, filter?:
4011
4021
  */
4012
4022
  membership: string;
4013
4023
  };
4014
- declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, searchOverride, onSearchChange, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
4024
+ declare function ViewSwitcher({ view, onLayoutChange, onViewChange, onOpenRecord, openRecordId, onCloseRecord, onMoved, onNewRecordForm, onAskWhoChanged, pageSize: pageSizeAsked, titleField, filter, onClearFilter, hostLayout, onHostLayoutChange, chooser, openExport, viewId, onOrderPlaced, footer, embedded, sortOverride, searchOverride, onSearchChange, searchBox, newRowLabel, className, }: ViewSwitcherProps): react.JSX.Element;
4015
4025
 
4016
4026
  type CalendarMode = "month" | "week" | "day" | "list";
4017
4027
  interface CalendarViewProps {
@@ -6066,6 +6076,11 @@ interface TablePageProps$1 {
6066
6076
  */
6067
6077
  searchOverride?: string | null | undefined;
6068
6078
  onSearchChange?: ((search: string) => void) | undefined;
6079
+ /**
6080
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
6081
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
6082
+ */
6083
+ searchBox?: boolean | undefined;
6069
6084
  /** Rows per page for every layout. */
6070
6085
  pageSize?: number | undefined;
6071
6086
  /**
@@ -6544,6 +6559,11 @@ interface EntityTablePageProps {
6544
6559
  /** The viewer's own search, handed by the host; asked of the door. Never saved. */
6545
6560
  searchOverride?: string | null | undefined;
6546
6561
  onSearchChange?: ((search: string) => void) | undefined;
6562
+ /**
6563
+ * `false`: the embedded grid draws no magnifier of its own — the host draws one in its own toolbar
6564
+ * row and hands the term through `searchOverride` (Spaces N-19). Default `true`.
6565
+ */
6566
+ searchBox?: boolean | undefined;
6547
6567
  /** Beside the title row's controls (the host's own). */
6548
6568
  actions?: ReactNode;
6549
6569
  className?: string | undefined;
package/dist/index.js CHANGED
@@ -10046,8 +10046,29 @@ var MEASURE_LABEL = {
10046
10046
  median: "Median",
10047
10047
  filled: "Filled",
10048
10048
  empty: "Empty",
10049
- unique: "Unique"
10049
+ unique: "Unique",
10050
+ percent_empty: "Percent empty",
10051
+ percent_filled: "Percent filled",
10052
+ range: "Range"
10050
10053
  };
10054
+ var NOTION_CALCULATIONS = [
10055
+ { op: "count", menu: "Count all", footer: "Count" },
10056
+ { op: "unique", menu: "Count unique values", footer: "Unique" },
10057
+ { op: "empty", menu: "Count empty", footer: "Empty" },
10058
+ { op: "filled", menu: "Count not empty", footer: "Not empty" },
10059
+ { op: "percent_empty", menu: "Percent empty", footer: "Empty" },
10060
+ { op: "percent_filled", menu: "Percent not empty", footer: "Not empty" },
10061
+ { op: "sum", menu: "Sum", footer: "Sum" },
10062
+ { op: "avg", menu: "Average", footer: "Average" },
10063
+ { op: "median", menu: "Median", footer: "Median" },
10064
+ { op: "min", menu: "Min", footer: "Min" },
10065
+ { op: "max", menu: "Max", footer: "Max" },
10066
+ { op: "range", menu: "Range", footer: "Range" }
10067
+ ];
10068
+ function calculationsFor(field2, storeOps) {
10069
+ const offered = new Set(measuresFor(field2, storeOps, true));
10070
+ return NOTION_CALCULATIONS.filter((c) => offered.has(c.op));
10071
+ }
10051
10072
  var NUMERIC_ONLY = /* @__PURE__ */ new Set(["sum", "avg", "median"]);
10052
10073
  var ARITHMETIC2 = /* @__PURE__ */ new Set([
10053
10074
  "add",
@@ -10065,7 +10086,7 @@ var ARITHMETIC2 = /* @__PURE__ */ new Set([
10065
10086
  "ceiling",
10066
10087
  "floor"
10067
10088
  ]);
10068
- var ORDERED = /* @__PURE__ */ new Set(["min", "max"]);
10089
+ var ORDERED = /* @__PURE__ */ new Set(["min", "max", "range"]);
10069
10090
  function isNumericField(field2) {
10070
10091
  const kind = editorKindFor(field2);
10071
10092
  if (kind === "number" || kind === "currency" || kind === "percent" || kind === "rollup") return true;
@@ -13348,14 +13369,17 @@ function SummaryCell({
13348
13369
  value,
13349
13370
  rowCount,
13350
13371
  summaries,
13351
- onChoose
13372
+ onChoose,
13373
+ calculate = false
13352
13374
  }) {
13353
13375
  const offered = useMemo19(
13354
- () => summaries.operations ? measuresFor(field2, summaries.operations, firstColumn) : null,
13355
- [summaries.operations, field2, firstColumn]
13376
+ () => summaries.operations ? calculate ? calculationsFor(field2, summaries.operations).map((c) => c.op) : measuresFor(field2, summaries.operations, firstColumn) : null,
13377
+ [summaries.operations, field2, firstColumn, calculate]
13356
13378
  );
13357
- const label = chosen ? MEASURE_LABEL[chosen] ?? chosen : null;
13358
- const shown4 = chosen === void 0 ? null : summaries.loading && value === void 0 ? "\u2026" : value === null || value === void 0 ? "\u2014" : chosen === "count" || chosen === "filled" || chosen === "empty" || chosen === "unique" ? String(value) : null;
13379
+ const words2 = (op2, where) => calculate ? NOTION_CALCULATIONS.find((c) => c.op === op2)?.[where] ?? MEASURE_LABEL[op2] ?? op2 : MEASURE_LABEL[op2] ?? op2;
13380
+ const label = chosen ? words2(chosen, "footer") : null;
13381
+ const isDate4 = editorKindFor(field2) === "datetime";
13382
+ const shown4 = chosen === void 0 ? null : summaries.loading && value === void 0 ? "\u2026" : value === null || value === void 0 ? "\u2014" : chosen === "count" || chosen === "filled" || chosen === "empty" || chosen === "unique" ? String(value) : chosen === "percent_empty" || chosen === "percent_filled" ? `${Number(value.toFixed(2))}%` : chosen === "range" && isDate4 ? `${Math.round(value)} day${Math.round(value) === 1 ? "" : "s"}` : null;
13359
13383
  return /* @__PURE__ */ jsxs43(DropdownMenu, { onOpenChange: (open) => open ? summaries.askOperations() : void 0, children: [
13360
13384
  /* @__PURE__ */ jsx48(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx48(
13361
13385
  Button24,
@@ -13377,7 +13401,7 @@ function SummaryCell({
13377
13401
  // AGG-WITHHELD: the store withheld this column from her — say so, never a bare dash.
13378
13402
  /* @__PURE__ */ jsx48("span", { className: "font-medium", children: /* @__PURE__ */ jsx48(WithheldValue, { field: field2, notice: summaries.withheld[field2.key] }) })
13379
13403
  ) : shown4 !== null ? /* @__PURE__ */ jsx48("span", { className: "font-medium tabular-nums", children: shown4 }) : /* @__PURE__ */ jsx48("span", { className: "font-medium tabular-nums", children: /* @__PURE__ */ jsx48(RecordValue, { field: field2, value, format: formatForField(field2) }) })
13380
- ] }) : "Summarize"
13404
+ ] }) : calculate ? "Calculate" : "Summarize"
13381
13405
  }
13382
13406
  ) }),
13383
13407
  /* @__PURE__ */ jsxs43(DropdownMenuContent, { align: "start", children: [
@@ -13388,13 +13412,13 @@ function SummaryCell({
13388
13412
  "data-records-summary-choice": op2,
13389
13413
  onSelect: () => onChoose(op2),
13390
13414
  className: cn28(op2 === chosen && "font-medium"),
13391
- children: MEASURE_LABEL[op2] ?? op2
13415
+ children: words2(op2, "menu")
13392
13416
  },
13393
13417
  op2
13394
13418
  )),
13395
13419
  chosen ? /* @__PURE__ */ jsxs43(Fragment13, { children: [
13396
13420
  /* @__PURE__ */ jsx48(DropdownMenuSeparator, {}),
13397
- /* @__PURE__ */ jsx48(DropdownMenuItem, { onSelect: () => onChoose(null), children: "No summary" })
13421
+ /* @__PURE__ */ jsx48(DropdownMenuItem, { onSelect: () => onChoose(null), children: calculate ? "None" : "No summary" })
13398
13422
  ] }) : null
13399
13423
  ] })
13400
13424
  ] });
@@ -21476,7 +21500,8 @@ function GridBody({
21476
21500
  newRowLabel,
21477
21501
  sortOverride,
21478
21502
  searchOverride,
21479
- onSearchChange
21503
+ onSearchChange,
21504
+ searchBox = true
21480
21505
  }) {
21481
21506
  const toolbarSlot = useTableToolbarSlot();
21482
21507
  const tableCard = useMatrxTableCard();
@@ -22471,6 +22496,7 @@ function GridBody({
22471
22496
  value: summaries.values[columnId2],
22472
22497
  rowCount: summaries.rowCount,
22473
22498
  summaries,
22499
+ calculate: embedded,
22474
22500
  onChoose: (op2) => footerNow.current.choose(columnId2, op2)
22475
22501
  }
22476
22502
  );
@@ -22735,7 +22761,8 @@ function GridBody({
22735
22761
  [storePaged, query, queryTotal, classicInCard, records.data?.total]
22736
22762
  );
22737
22763
  const showAddLine = mayAddRow && rows.length > 0;
22738
- const showSummaryLine = rows.length > 0 && (embedded ? Object.keys(chosenSummaries).length > 0 : !merged || Object.keys(chosenSummaries).length > 0);
22764
+ const showSummaryLine = rows.length > 0 && (embedded || !merged || Object.keys(chosenSummaries).length > 0);
22765
+ const calculationChosen = Object.keys(chosenSummaries).length > 0;
22739
22766
  const footerFace = JSON.stringify([
22740
22767
  showAddLine ? added.busy : null,
22741
22768
  showSummaryLine ? [chosenSummaries, summaries.values, summaries.rowCount, summaries.loading] : null
@@ -22838,10 +22865,11 @@ function GridBody({
22838
22865
  search: !embedded,
22839
22866
  // EMBEDDED: Notion's magnifier — the design system's own search group, a button that
22840
22867
  // opens into a field. It is the same `query.search` the store's read asks.
22841
- ...embedded ? {
22868
+ ...embedded && searchBox ? {
22842
22869
  customSearch: /* @__PURE__ */ jsx70(
22843
22870
  TapTargetSearchGroup,
22844
22871
  {
22872
+ surface: "solid",
22845
22873
  placeholder: "Search",
22846
22874
  value: searchOverride ?? query.search,
22847
22875
  onValueChange: (term) => {
@@ -23053,7 +23081,8 @@ function GridBody({
23053
23081
  noun,
23054
23082
  embedded,
23055
23083
  searchOverride,
23056
- onSearchChange
23084
+ onSearchChange,
23085
+ searchBox
23057
23086
  ]
23058
23087
  );
23059
23088
  const labelOfField = useCallback26(
@@ -23275,7 +23304,7 @@ function GridBody({
23275
23304
  !look.wrap && "[&_tbody_td]:max-w-[28rem] [&_tbody_td]:overflow-hidden [&_tbody_td]:text-ellipsis [&_tbody_td]:whitespace-nowrap! [&_tbody_td_*]:whitespace-nowrap!",
23276
23305
  look.fit === "scroll" && "sm:[&>table]:w-max! sm:[&>table]:max-w-none! sm:[&>table]:min-w-full!",
23277
23306
  embedded && EMBEDDED_TABLE_CLASS,
23278
- embedded && !showSummaryLine && EMBEDDED_PLAIN_FOOTER_CLASS
23307
+ embedded && !calculationChosen && EMBEDDED_PLAIN_FOOTER_CLASS
23279
23308
  ),
23280
23309
  footerRows,
23281
23310
  ...embedded ? { copy: false } : copyConfig ? { copy: copyConfig } : {},
@@ -32732,6 +32761,7 @@ function ViewSwitcher({
32732
32761
  sortOverride,
32733
32762
  searchOverride,
32734
32763
  onSearchChange,
32764
+ searchBox,
32735
32765
  newRowLabel,
32736
32766
  className
32737
32767
  }) {
@@ -32799,6 +32829,7 @@ function ViewSwitcher({
32799
32829
  ...sortOverride !== void 0 ? { sortOverride } : {},
32800
32830
  ...searchOverride !== void 0 ? { searchOverride } : {},
32801
32831
  ...onSearchChange ? { onSearchChange } : {},
32832
+ ...searchBox === false ? { searchBox } : {},
32802
32833
  ...newRowLabel ? { newRowLabel } : {},
32803
32834
  ...filter ? { filter } : {},
32804
32835
  ...onClearFilter ? { onClearFilter } : {},
@@ -47577,6 +47608,7 @@ function TablePage({
47577
47608
  newRowLabel,
47578
47609
  searchOverride,
47579
47610
  onSearchChange,
47611
+ searchBox,
47580
47612
  pageSize: pageSizeAsked,
47581
47613
  seedViews,
47582
47614
  onLeave,
@@ -48466,6 +48498,7 @@ function TablePage({
48466
48498
  ...newRowLabel ? { newRowLabel } : {},
48467
48499
  ...searchOverride !== void 0 ? { searchOverride } : {},
48468
48500
  ...onSearchChange ? { onSearchChange } : {},
48501
+ ...searchBox === false ? { searchBox } : {},
48469
48502
  footer,
48470
48503
  openExport: () => setRail("export"),
48471
48504
  view: {
@@ -48772,6 +48805,7 @@ function EntityTablePageBody({
48772
48805
  presentation = "page",
48773
48806
  searchOverride,
48774
48807
  onSearchChange,
48808
+ searchBox = true,
48775
48809
  pageSize = presentation === "embedded" ? EMBEDDED_PAGE_SIZE : 100,
48776
48810
  layout: opened = "grid",
48777
48811
  onLayoutChange,
@@ -48859,9 +48893,10 @@ function EntityTablePageBody({
48859
48893
  ] }) : null,
48860
48894
  addRefused ? /* @__PURE__ */ jsx156(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,
48861
48895
  entity.error ? /* @__PURE__ */ jsx156("p", { className: "px-1 py-3 text-xs text-muted-foreground", children: `This table could not be read: ${entity.error}` }) : layout === "board" && boardable ? /* @__PURE__ */ jsx156(EntityBoard, { entity, groupBy, onOpenRecord }) : /* @__PURE__ */ jsxs145(Fragment65, { children: [
48862
- presentation === "embedded" ? /* @__PURE__ */ jsx156("div", { className: "flex min-w-0 items-center justify-end", "data-records-entity-search": "", children: /* @__PURE__ */ jsx156(TooltipProvider, { children: /* @__PURE__ */ jsx156(
48896
+ presentation === "embedded" && searchBox ? /* @__PURE__ */ jsx156("div", { className: "flex min-w-0 items-center justify-end", "data-records-entity-search": "", children: /* @__PURE__ */ jsx156(TooltipProvider, { children: /* @__PURE__ */ jsx156(
48863
48897
  TapTargetSearchGroup2,
48864
48898
  {
48899
+ surface: "solid",
48865
48900
  placeholder: "Search",
48866
48901
  value: term,
48867
48902
  onValueChange: (next) => {
@@ -48898,6 +48933,7 @@ function TablePage2(props) {
48898
48933
  ...rest.pageSize ? { pageSize: rest.pageSize } : {},
48899
48934
  ...rest.searchOverride !== void 0 ? { searchOverride: rest.searchOverride } : {},
48900
48935
  ...rest.onSearchChange ? { onSearchChange: rest.onSearchChange } : {},
48936
+ ...rest.searchBox === false ? { searchBox: false } : {},
48901
48937
  ...layout ? { layout } : {},
48902
48938
  ...onLayoutChange ? { onLayoutChange } : {},
48903
48939
  ...groupBy ? { groupBy } : {},