twico-ui 1.32.1 → 1.33.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
@@ -2235,6 +2235,24 @@ interface DatatableColumn<T = any> {
2235
2235
  copyType?: string;
2236
2236
  /** Fully custom cell renderer (badges, avatars, etc.). */
2237
2237
  renderCell?: (value: any, row: T) => React.ReactNode;
2238
+ /** #345: per-cell class hook — return a class name applied to the whole cell (`.twc-dt__td`, pinned cells
2239
+ * included), not just its content. Use for value/row-based tinting (e.g. a "changed" cell) via your own
2240
+ * stylesheet, without coupling to the internal class name. Because it participates in the CSS cascade, a
2241
+ * `cellClassName` tint co-exists with the built-in hover/selection/diff backgrounds (a plain class may even
2242
+ * lose to them by specificity — use a more specific selector, or `cellStyle`, to always win). Prefer this
2243
+ * over `cellStyle` when those state cues must stay visible on a tinted cell. Called `(value, row)` to match
2244
+ * `renderCell`/`valueFormatter`. */
2245
+ cellClassName?: (value: any, row: T) => string | undefined;
2246
+ /** #345: per-cell inline-style hook — return a style object applied to the whole cell (`.twc-dt__td`,
2247
+ * pinned cells included). The simplest way to tint an entire cell from the value/row with no stylesheet.
2248
+ * Pin positioning **and** stickiness are always preserved (don't set `position`/`inset-*`). Two caveats,
2249
+ * because an inline style wins over every built-in background: (1) on a **pinned** column the background
2250
+ * must be **opaque** — a translucent value lets the cells scrolling underneath the sticky cell bleed
2251
+ * through; composite over the surface, e.g. `color-mix(in srgb, var(--color-danger) 14%, var(--color-surface))`
2252
+ * rather than `…, transparent`. (2) it also overrides the hover / range-selection / edit-mode / diff
2253
+ * backgrounds on that cell — use `cellClassName` instead if those cues must remain visible. Called
2254
+ * `(value, row)` to match `renderCell`/`valueFormatter`. */
2255
+ cellStyle?: (value: any, row: T) => React.CSSProperties | undefined;
2238
2256
  /** Diff-mode (#239) per-column equality override — return true when the two values are equal.
2239
2257
  * Precedence: column.compare → diff.compare → valueGetter/=== → JSON compare. */
2240
2258
  compare?: (a: any, b: any) => boolean;
package/dist/index.d.ts CHANGED
@@ -2235,6 +2235,24 @@ interface DatatableColumn<T = any> {
2235
2235
  copyType?: string;
2236
2236
  /** Fully custom cell renderer (badges, avatars, etc.). */
2237
2237
  renderCell?: (value: any, row: T) => React.ReactNode;
2238
+ /** #345: per-cell class hook — return a class name applied to the whole cell (`.twc-dt__td`, pinned cells
2239
+ * included), not just its content. Use for value/row-based tinting (e.g. a "changed" cell) via your own
2240
+ * stylesheet, without coupling to the internal class name. Because it participates in the CSS cascade, a
2241
+ * `cellClassName` tint co-exists with the built-in hover/selection/diff backgrounds (a plain class may even
2242
+ * lose to them by specificity — use a more specific selector, or `cellStyle`, to always win). Prefer this
2243
+ * over `cellStyle` when those state cues must stay visible on a tinted cell. Called `(value, row)` to match
2244
+ * `renderCell`/`valueFormatter`. */
2245
+ cellClassName?: (value: any, row: T) => string | undefined;
2246
+ /** #345: per-cell inline-style hook — return a style object applied to the whole cell (`.twc-dt__td`,
2247
+ * pinned cells included). The simplest way to tint an entire cell from the value/row with no stylesheet.
2248
+ * Pin positioning **and** stickiness are always preserved (don't set `position`/`inset-*`). Two caveats,
2249
+ * because an inline style wins over every built-in background: (1) on a **pinned** column the background
2250
+ * must be **opaque** — a translucent value lets the cells scrolling underneath the sticky cell bleed
2251
+ * through; composite over the surface, e.g. `color-mix(in srgb, var(--color-danger) 14%, var(--color-surface))`
2252
+ * rather than `…, transparent`. (2) it also overrides the hover / range-selection / edit-mode / diff
2253
+ * backgrounds on that cell — use `cellClassName` instead if those cues must remain visible. Called
2254
+ * `(value, row)` to match `renderCell`/`valueFormatter`. */
2255
+ cellStyle?: (value: any, row: T) => React.CSSProperties | undefined;
2238
2256
  /** Diff-mode (#239) per-column equality override — return true when the two values are equal.
2239
2257
  * Precedence: column.compare → diff.compare → valueGetter/=== → JSON compare. */
2240
2258
  compare?: (a: any, b: any) => boolean;
package/dist/index.mjs CHANGED
@@ -11498,11 +11498,13 @@ function Datatable({
11498
11498
  const cellId = selectionMode === "cell" ? `${gridId}-${ri}-${ci}` : void 0;
11499
11499
  const display = c.valueFormatter ? c.valueFormatter(val, row) : val;
11500
11500
  const cellTitle = !isActions && !c.renderCell && !isEditing && (typeof display === "string" || typeof display === "number") ? String(display) : void 0;
11501
+ const cellClass = c.cellClassName ? c.cellClassName(val, row) : void 0;
11502
+ const cellSty = c.cellStyle ? c.cellStyle(val, row) : void 0;
11501
11503
  return /* @__PURE__ */ jsxs(
11502
11504
  "td",
11503
11505
  {
11504
11506
  id: cellId,
11505
- className: "twc-dt__td",
11507
+ className: cellClass ? `twc-dt__td ${cellClass}` : "twc-dt__td",
11506
11508
  role: "gridcell",
11507
11509
  "data-r": ri,
11508
11510
  "data-c": ci,
@@ -11519,7 +11521,7 @@ function Datatable({
11519
11521
  "data-wrap": effectiveWrapped.has(c.field) || void 0,
11520
11522
  "data-pin": st.pin,
11521
11523
  "data-pin-edge": st.edge,
11522
- style: { width: widthOf(c), ...st.style },
11524
+ style: { width: widthOf(c), ...cellSty, ...st.style, ...st.pin ? { position: "sticky", zIndex: 2 } : null },
11523
11525
  "data-ovtext": cellTitle,
11524
11526
  onClick: selectionMode === "cell" ? (e) => handleCellClick(e, k, row, c) : void 0,
11525
11527
  onFocus: () => setFocus((f) => f.r === ri && f.c === ci ? f : { r: ri, c: ci }),