@rebasepro/ui 0.20.0 → 0.21.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.
@@ -14,4 +14,4 @@ import { VirtualTableProps } from "./VirtualTableProps.js";
14
14
  * implementation always had. Runtime behaviour is unchanged — this is the same
15
15
  * memoized component under a type that describes it.
16
16
  */
17
- export declare const VirtualTable: <T extends Record<string, unknown>>(props: VirtualTableProps<T>) => React.ReactElement | null;
17
+ export declare const VirtualTable: <T extends object>(props: VirtualTableProps<T>) => React.ReactElement | null;
@@ -8,7 +8,7 @@ export type FilterFormFieldProps<CustomProps> = {
8
8
  hidden: boolean;
9
9
  setHidden: (hidden: boolean) => void;
10
10
  };
11
- type VirtualTableHeaderProps<M extends Record<string, unknown>> = {
11
+ type VirtualTableHeaderProps<M extends object> = {
12
12
  resizeHandleRef: React.Ref<HTMLDivElement>;
13
13
  columnIndex: number;
14
14
  isResizingIndex: number;
@@ -11,7 +11,7 @@ import type { FilterFormFieldProps } from "./VirtualTableHeader.js";
11
11
  * order through no longer has to strip it.
12
12
  */
13
13
  export type VirtualTableSortKey = [string, "asc" | "desc", ("first" | "last")?];
14
- export type OnRowClickParams<T extends Record<string, unknown>> = {
14
+ export type OnRowClickParams<T extends object> = {
15
15
  rowData: T;
16
16
  rowIndex: number;
17
17
  event: React.SyntheticEvent;
@@ -20,7 +20,7 @@ export type OnRowClickParams<T extends Record<string, unknown>> = {
20
20
  * @see Table
21
21
  * @group Components
22
22
  */
23
- export interface VirtualTableProps<T extends Record<string, unknown>> {
23
+ export interface VirtualTableProps<T extends object> {
24
24
  /**
25
25
  * Array of arbitrary data
26
26
  */
@@ -1,3 +1,11 @@
1
1
  import React from "react";
2
2
  import { VirtualTableRowProps } from "./types.js";
3
- export declare const VirtualTableRow: React.NamedExoticComponent<VirtualTableRowProps<Record<string, unknown>>>;
3
+ /**
4
+ * The same fix `VirtualTable` carries, one level down: `React.memo` takes the
5
+ * props type as its own type argument, so the annotation on the call pins the
6
+ * row type at the boundary and discards the `<T>` the inner function declares.
7
+ * Pinned, the row a caller passes in and the row its `onRowClick` and
8
+ * `rowClassName` receive were unrelated types, which is what every consumer was
9
+ * paying for with a cast.
10
+ */
11
+ export declare const VirtualTableRow: <T extends object>(props: VirtualTableRowProps<T>) => React.ReactElement | null;
@@ -1,18 +1,27 @@
1
1
  import React from "react";
2
2
  import { CellRendererParams, OnRowClickParams, OnVirtualTableColumnResizeParams, VirtualTableColumn, VirtualTableFilterValues, VirtualTableWhereFilterOp } from "./VirtualTableProps.js";
3
3
  import { FilterFormFieldProps } from "./VirtualTableHeader.js";
4
- export type VirtualTableRowProps<T extends Record<string, unknown>> = {
4
+ export type VirtualTableRowProps<T extends object> = {
5
5
  style: React.CSSProperties;
6
6
  rowHeight: number;
7
- rowData: T;
7
+ /**
8
+ * Absent while the window is scrolled past what has loaded — the row still
9
+ * has to occupy its slot, so it renders empty rather than not at all.
10
+ *
11
+ * Declared, because it happens. `VirtualTable` used to assert it away with
12
+ * `as Record<string, unknown>` on the way in, and this component then
13
+ * guarded `rowData &&` on the way out — the guard and the type disagreeing
14
+ * about the same value, in the same render.
15
+ */
16
+ rowData: T | undefined;
8
17
  rowIndex: number;
9
- onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
18
+ onRowClick?: (props: OnRowClickParams<T>) => void;
10
19
  children: React.ReactNode[];
11
20
  columns: VirtualTableColumn[];
12
21
  hoverRow?: boolean;
13
22
  rowClassName?: (rowData: T) => string | undefined;
14
23
  };
15
- export type VirtualTableContextProps<T> = {
24
+ export type VirtualTableContextProps<T extends object> = {
16
25
  data?: T[];
17
26
  rowHeight?: number;
18
27
  headerHeight?: number;
@@ -24,7 +33,7 @@ export type VirtualTableContextProps<T> = {
24
33
  position: number;
25
34
  }>;
26
35
  filter?: VirtualTableFilterValues<string>;
27
- onRowClick?: (props: OnRowClickParams<Record<string, unknown>>) => void;
36
+ onRowClick?: (props: OnRowClickParams<T>) => void;
28
37
  onColumnSort: (key: string, additive?: boolean) => void;
29
38
  onColumnResize: (params: OnVirtualTableColumnResizeParams) => void;
30
39
  onColumnResizeEnd: (params: OnVirtualTableColumnResizeParams) => void;
package/dist/index.es.js CHANGED
@@ -4364,7 +4364,7 @@ function FileUpload({ accept, onFilesAdded, onFilesRejected, maxSize, disabled,
4364
4364
  role: "button",
4365
4365
  "aria-label": typeof title === "string" ? title : typeof uploadDescription === "string" ? uploadDescription : "Upload file",
4366
4366
  "aria-disabled": disabled || void 0,
4367
- className: cls(fieldBackgroundMixin, "flex gap-2", "p-4 box-border relative items-center border-2 border-solid border-transparent outline-hidden rounded-lg duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid", {
4367
+ className: cls(fieldBackgroundMixin, "flex gap-2", "p-4 box-border relative items-center border-2 border-solid border-transparent outline-hidden rounded-lg duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary", {
4368
4368
  "h-44": size === "large",
4369
4369
  "h-28": size === "medium",
4370
4370
  "h-16": size === "small",
@@ -6061,7 +6061,7 @@ var VirtualTableHeader = React.memo(function VirtualTableHeader({ resizeHandleRe
6061
6061
  }, [column, onFilterUpdate]);
6062
6062
  const hovered = !(isResizingIndex !== columnIndex && isResizingIndex > 0) && (onHover || isResizingIndex === columnIndex);
6063
6063
  return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs("div", {
6064
- className: cls("flex py-0 px-3 h-full text-xs uppercase font-semibold relative select-none items-center", isDragging ? "bg-primary-bg dark:bg-primary-bg-dark" : "bg-surface-sheet", "text-text-secondary hover:text-text-primary dark:text-text-secondary-dark dark:hover:text-text-primary-dark", !isDragging && "hover:bg-surface-hover", column.frozen ? "sticky left-0 z-10" : "relative z-0", isDraggable && "cursor-grab"),
6064
+ className: cls("flex py-0 px-3 h-full text-xs uppercase font-semibold relative select-none items-center", isDragging ? "bg-primary-bg" : "bg-surface-sheet", "text-text-secondary hover:text-text-primary dark:text-text-secondary-dark dark:hover:text-text-primary-dark", !isDragging && "hover:bg-surface-hover", column.frozen ? "sticky left-0 z-10" : "relative z-0", isDraggable && "cursor-grab"),
6065
6065
  style: {
6066
6066
  left: column.frozen ? 0 : void 0,
6067
6067
  minWidth: column.width,
@@ -6383,11 +6383,17 @@ var VirtualTableHeaderRow = ({ columns, sortIndex, onColumnSort, onFilterUpdate,
6383
6383
  }), AddColumnComponent && /* @__PURE__ */ jsx(AddColumnComponent, {})]
6384
6384
  }) });
6385
6385
  };
6386
- //#endregion
6387
- //#region src/components/VirtualTable/VirtualTableRow.tsx
6386
+ /**
6387
+ * The same fix `VirtualTable` carries, one level down: `React.memo` takes the
6388
+ * props type as its own type argument, so the annotation on the call pins the
6389
+ * row type at the boundary and discards the `<T>` the inner function declares.
6390
+ * Pinned, the row a caller passes in and the row its `onRowClick` and
6391
+ * `rowClassName` receive were unrelated types, which is what every consumer was
6392
+ * paying for with a cast.
6393
+ */
6388
6394
  var VirtualTableRow = React.memo(function VirtualTableRow({ rowData, rowIndex, children, onRowClick, rowHeight, style, hoverRow, rowClassName }) {
6389
6395
  const onClick = useCallback((event) => {
6390
- if (onRowClick) onRowClick({
6396
+ if (onRowClick && rowData) onRowClick({
6391
6397
  rowData,
6392
6398
  rowIndex,
6393
6399
  event
@@ -6398,7 +6404,7 @@ var VirtualTableRow = React.memo(function VirtualTableRow({ rowData, rowIndex, c
6398
6404
  rowIndex
6399
6405
  ]);
6400
6406
  return /* @__PURE__ */ jsx("div", {
6401
- className: cls("group flex min-w-full text-sm border-b border-hairline bg-surface-card", rowClassName ? rowClassName(rowData) : "", {
6407
+ className: cls("group flex min-w-full text-sm border-b border-hairline bg-surface-card", rowClassName && rowData ? rowClassName(rowData) : "", {
6402
6408
  "hover:!bg-surface-card-hover": hoverRow,
6403
6409
  "cursor-pointer ": onRowClick
6404
6410
  }),
@@ -7458,7 +7464,7 @@ function CardView({ data, dataLoading = false, noMoreToLoad = false, dataLoading
7458
7464
  const selected = selectedIds?.has(id) ?? false;
7459
7465
  const highlighted = highlightedIds?.has(id) ?? false;
7460
7466
  const handleClick = (e) => {
7461
- if ((e.metaKey || e.ctrlKey) && selectionEnabled) {
7467
+ if (e && (e.metaKey || e.ctrlKey) && selectionEnabled) {
7462
7468
  e.preventDefault();
7463
7469
  onSelectionChange?.(item, !selected);
7464
7470
  return;
@@ -8781,7 +8787,7 @@ function CollectionListView({ dataController, properties, propertiesOrder, idPro
8781
8787
  const titleValue = getValueInPath(item, titlePropertyKey);
8782
8788
  return /* @__PURE__ */ jsxs("div", {
8783
8789
  style,
8784
- className: cls("flex items-center gap-3 px-4 cursor-pointer", "hover:bg-surface-hover", "transition-colors duration-100", selected && "bg-primary-50 dark:bg-primary-900/20", highlighted && "bg-surface-raised", rowClassName),
8790
+ className: cls("flex items-center gap-3 px-4 cursor-pointer", "hover:bg-surface-hover", "transition-colors duration-100", selected && "bg-primary-bg", highlighted && "bg-surface-raised", rowClassName),
8785
8791
  onClick,
8786
8792
  children: [selectionEnabled && /* @__PURE__ */ jsx("div", {
8787
8793
  className: "flex-shrink-0",