@startsimpli/ui 0.4.114 → 0.4.115

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/ui",
3
- "version": "0.4.114",
3
+ "version": "0.4.115",
4
4
  "description": "Shared UI components package for StartSimpli applications",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Guards for the table's horizontal-scroll affordance (startsim-5pq7h).
3
+ *
4
+ * The defect these come from is PURELY VISUAL — "there is no sliding bar so it
5
+ * makes it difficult to see all the columns" — and jsdom has no layout, so
6
+ * NOTHING here proves a scrollbar is visible on screen. That claim is carried
7
+ * by browser measurement (headed Chrome + headed WebKit on macOS: 0px of
8
+ * scrollbar layout height before, 10px after, 0px when the table fits).
9
+ *
10
+ * What these DO guard is the two things a later edit can silently break:
11
+ * - the CSS that produces the bar, including the `scrollbar-width` rule that
12
+ * measurably DELETES it, and
13
+ * - the "no decoration when nothing overflows" contract.
14
+ */
15
+ import { render, screen } from '@testing-library/react'
16
+ import { renderHook, act } from '@testing-library/react'
17
+ import { useRef } from 'react'
18
+ import { Table, TableBody, TableCell, TableRow } from '../table'
19
+ import {
20
+ TABLE_SCROLL_CSS,
21
+ TABLE_SCROLL_STYLE_ID,
22
+ TABLE_SCROLLER_CLASS,
23
+ useScrollEdges,
24
+ } from '../table-scroll'
25
+
26
+ describe('TABLE_SCROLL_CSS', () => {
27
+ it('styles the webkit scrollbar, which is what gives the bar layout height', () => {
28
+ expect(TABLE_SCROLL_CSS).toContain(`.${TABLE_SCROLLER_CLASS}::-webkit-scrollbar`)
29
+ expect(TABLE_SCROLL_CSS).toMatch(/height:\s*10px/)
30
+ })
31
+
32
+ /**
33
+ * The finding this test exists for. MEASURED in headed Chrome on macOS:
34
+ *
35
+ * ::-webkit-scrollbar { height: 10px } -> 10px of layout height
36
+ * the same rule PLUS scrollbar-width / scrollbar-color -> 0px (overlay again)
37
+ *
38
+ * Chromium honours the standard properties instead of the custom scrollbar
39
+ * and reverts to a zero-height overlay bar. Every "cross-browser scrollbar"
40
+ * snippet on the web tells you to add them, and doing so here would silently
41
+ * undo the fix with no visible error anywhere. Firefox on macOS gains nothing
42
+ * from them either (measured 0px with the property confirmed applied), so
43
+ * there is no browser to trade away.
44
+ */
45
+ it('does NOT set scrollbar-width or scrollbar-color, which would revert Chromium to an overlay bar', () => {
46
+ expect(TABLE_SCROLL_CSS).not.toMatch(/scrollbar-width/)
47
+ expect(TABLE_SCROLL_CSS).not.toMatch(/scrollbar-color/)
48
+ })
49
+
50
+ /**
51
+ * `overflow: auto` is what makes the bar conditional on real overflow. Under
52
+ * `overflow: scroll` every narrow table in the fleet would grow a dead 10px
53
+ * bar — a regression, not a fix.
54
+ */
55
+ it('leaves the scroller on overflow:auto so the bar is conditional on real overflow', () => {
56
+ expect(TABLE_SCROLL_CSS).not.toMatch(/overflow\s*:\s*scroll/)
57
+ })
58
+ })
59
+
60
+ describe('Table', () => {
61
+ const renderTable = (props: Record<string, unknown> = {}) =>
62
+ render(
63
+ <Table {...props}>
64
+ <TableBody>
65
+ <TableRow>
66
+ <TableCell>cell</TableCell>
67
+ </TableRow>
68
+ </TableBody>
69
+ </Table>
70
+ )
71
+
72
+ it('marks its scroll container so the scrollbar rules can find it', () => {
73
+ renderTable()
74
+ const table = screen.getByRole('table')
75
+ expect(table.parentElement).toHaveClass(TABLE_SCROLLER_CLASS)
76
+ expect(table.parentElement).toHaveClass('overflow-auto')
77
+ })
78
+
79
+ it('injects the stylesheet once, however many tables are on the page', () => {
80
+ render(
81
+ <>
82
+ <Table />
83
+ <Table />
84
+ <Table />
85
+ </>
86
+ )
87
+ expect(document.querySelectorAll(`#${TABLE_SCROLL_STYLE_ID}`)).toHaveLength(1)
88
+ expect(document.getElementById(TABLE_SCROLL_STYLE_ID)?.textContent).toBe(
89
+ TABLE_SCROLL_CSS
90
+ )
91
+ })
92
+
93
+ it('sends containerClassName to the scrolling box and className to the table', () => {
94
+ renderTable({ containerClassName: 'max-h-96', className: 'my-table' })
95
+ const table = screen.getByRole('table')
96
+ expect(table).toHaveClass('my-table')
97
+ expect(table.parentElement).toHaveClass('max-h-96')
98
+ expect(table).not.toHaveClass('max-h-96')
99
+ })
100
+ })
101
+
102
+ describe('useScrollEdges', () => {
103
+ /** jsdom has no layout, so geometry has to be stated outright. */
104
+ const harness = (clientWidth: number, scrollWidth: number, scrollLeft: number) => {
105
+ const scroller = document.createElement('div')
106
+ const table = document.createElement('table')
107
+ scroller.appendChild(table)
108
+ document.body.appendChild(scroller)
109
+ Object.defineProperty(scroller, 'clientWidth', { value: clientWidth, configurable: true })
110
+ Object.defineProperty(scroller, 'scrollWidth', { value: scrollWidth, configurable: true })
111
+ scroller.scrollLeft = scrollLeft
112
+ return { scroller, table }
113
+ }
114
+
115
+ const run = (clientWidth: number, scrollWidth: number, scrollLeft = 0) => {
116
+ const { scroller, table } = harness(clientWidth, scrollWidth, scrollLeft)
117
+ const { result } = renderHook(() => {
118
+ const ref = useRef<HTMLTableElement | null>(table)
119
+ return useScrollEdges(ref)
120
+ })
121
+ return { edges: result.current, scroller, result }
122
+ }
123
+
124
+ it('reports no edge at all when the table fits — a hint under a table that fits is the same defect as a bar under one', () => {
125
+ expect(run(846, 846).edges).toEqual({ left: false, right: false })
126
+ })
127
+
128
+ it('ignores a sub-pixel overhang rather than decorating a table that visually fits', () => {
129
+ expect(run(846, 847).edges).toEqual({ left: false, right: false })
130
+ })
131
+
132
+ it('reports the right edge when columns are unreached to the right', () => {
133
+ expect(run(846, 1014).edges).toEqual({ left: false, right: true })
134
+ })
135
+
136
+ it('reports the left edge once scrolled away from the start', () => {
137
+ expect(run(846, 1014, 84).edges).toEqual({ left: true, right: true })
138
+ })
139
+
140
+ it('drops the right edge at the end of the scroll range', () => {
141
+ expect(run(846, 1014, 168).edges).toEqual({ left: true, right: false })
142
+ })
143
+
144
+ it('re-reads geometry when the scroller is scrolled', () => {
145
+ const { scroller, result } = run(846, 1014)
146
+ expect(result.current).toEqual({ left: false, right: true })
147
+ act(() => {
148
+ scroller.scrollLeft = 168
149
+ scroller.dispatchEvent(new Event('scroll'))
150
+ })
151
+ expect(result.current).toEqual({ left: true, right: false })
152
+ })
153
+ })
@@ -0,0 +1,157 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState, type RefObject } from 'react'
4
+
5
+ export const TABLE_SCROLL_STYLE_ID = 'ss-table-scroll-affordance'
6
+
7
+ /** The element that actually scrolls: the wrapper `Table` puts around `<table>`. */
8
+ export const TABLE_SCROLLER_CLASS = 'ss-table-scroller'
9
+ /** A non-scrolling box around the scroller, so the edge hints can be pinned to it. */
10
+ export const TABLE_SHELL_CLASS = 'ss-table-shell'
11
+ export const TABLE_EDGE_CLASS = 'ss-table-edge'
12
+ export const TABLE_EDGE_LEFT_CLASS = 'ss-table-edge-left'
13
+ export const TABLE_EDGE_RIGHT_CLASS = 'ss-table-edge-right'
14
+
15
+ /**
16
+ * Wide tables scroll, but on macOS nothing says so (startsim-5pq7h).
17
+ *
18
+ * A reviewer reported "there is no sliding bar so it makes it difficult to see
19
+ * all the columns". The container did scroll the whole time; macOS renders an
20
+ * OVERLAY scrollbar that occupies no layout height and is invisible at rest, so
21
+ * the affordance was missing, not the scrolling.
22
+ *
23
+ * MEASURED 2026-09-07, headed Google Chrome and headed WebKit on macOS, on a
24
+ * 400px box holding 900px of content (`offsetHeight - clientHeight`, borders
25
+ * subtracted):
26
+ *
27
+ * no scrollbar CSS 0px (overlay)
28
+ * scrollbar-width: thin 0px
29
+ * scrollbar-color: <thumb> <track> 0px
30
+ * ::-webkit-scrollbar { height: 10px } 10px <-- this one
31
+ * ::-webkit-scrollbar + scrollbar-width/-color 0px <-- see below
32
+ * ::-webkit-scrollbar, content NARROWER than the box 0px (no regression)
33
+ *
34
+ * TWO RESULTS THAT ARE EASY TO UNDO BY ACCIDENT:
35
+ *
36
+ * 1. DO NOT ADD `scrollbar-width` OR `scrollbar-color` HERE. Every snippet on
37
+ * the web pairs them with the -webkit- rules "for Firefox". Measured: when
38
+ * the standard properties are set at the same specificity, Chromium honours
39
+ * them INSTEAD of the custom scrollbar and reverts the element to a
40
+ * zero-height overlay bar — i.e. adding them silently deletes this fix.
41
+ * Firefox on macOS gains nothing from them anyway (measured 0px with
42
+ * `scrollbar-width: thin` applied and confirmed in the computed style), so
43
+ * there is no Firefox branch to lose. Firefox users are served by the edge
44
+ * hint below instead.
45
+ *
46
+ * 2. The bar costs layout height ONLY while the element overflows — that is
47
+ * `overflow: auto`, not something this stylesheet decides — so it never
48
+ * appears under a table that fits. Keep the scroller on `auto`, never
49
+ * `scroll`, or every narrow table in the fleet grows a dead bar.
50
+ *
51
+ * On Windows/Linux this REPLACES the ~15px classic bar with a 10px one; it does
52
+ * not reserve a second gutter, so no platform guard is needed. Nothing here
53
+ * animates or transitions, so `prefers-reduced-motion` has nothing to honour.
54
+ */
55
+ export const TABLE_SCROLL_CSS = `
56
+ .${TABLE_SCROLLER_CLASS}::-webkit-scrollbar {
57
+ height: 10px;
58
+ width: 10px;
59
+ }
60
+ .${TABLE_SCROLLER_CLASS}::-webkit-scrollbar-track {
61
+ background: transparent;
62
+ }
63
+ .${TABLE_SCROLLER_CLASS}::-webkit-scrollbar-thumb {
64
+ border-radius: 9999px;
65
+ background-color: color-mix(in srgb, currentColor 22%, transparent);
66
+ }
67
+ .${TABLE_SCROLLER_CLASS}::-webkit-scrollbar-thumb:hover {
68
+ background-color: color-mix(in srgb, currentColor 45%, transparent);
69
+ }
70
+ .${TABLE_SHELL_CLASS} {
71
+ position: relative;
72
+ }
73
+ .${TABLE_EDGE_CLASS} {
74
+ position: absolute;
75
+ top: 0;
76
+ bottom: 0;
77
+ width: 24px;
78
+ pointer-events: none;
79
+ }
80
+ .${TABLE_EDGE_RIGHT_CLASS} {
81
+ right: 0;
82
+ background-image: linear-gradient(to left, hsl(var(--background)), hsl(var(--background) / 0));
83
+ }
84
+ .${TABLE_EDGE_LEFT_CLASS} {
85
+ left: 0;
86
+ background-image: linear-gradient(to right, hsl(var(--background)), hsl(var(--background) / 0));
87
+ }
88
+ `.trim()
89
+
90
+ export interface ScrollEdges {
91
+ /** There is content scrolled off to the left. */
92
+ left: boolean
93
+ /** There is content still unreached to the right. */
94
+ right: boolean
95
+ }
96
+
97
+ /**
98
+ * Which horizontal edges of a table's scroller still hide content.
99
+ *
100
+ * The persistent scrollbar above sits at the bottom of the scroller, and the
101
+ * scroller is the FULL HEIGHT of the table — measured 3061-5698px below the
102
+ * fold on every content view of the marketing-agents tenant at 900px tall. So a
103
+ * reader looking at the header row never sees it, and needs a hint that travels
104
+ * with them. This drives that hint.
105
+ *
106
+ * Pass a ref to the `<table>`, not to the scroller: `Table` forwards its ref to
107
+ * the table element, and the scroller is its parent.
108
+ */
109
+ export function useScrollEdges(
110
+ tableRef: RefObject<HTMLTableElement | null>
111
+ ): ScrollEdges {
112
+ const [edges, setEdges] = useState<ScrollEdges>({ left: false, right: false })
113
+
114
+ useEffect(() => {
115
+ const table = tableRef.current
116
+ const scroller = table?.parentElement
117
+ if (!table || !scroller) return
118
+
119
+ const update = () => {
120
+ // 1px of slack: sub-pixel column widths leave scrollWidth a hair above
121
+ // clientWidth on tables that visually fit, and a hint under a table that
122
+ // fits is the same defect as a scrollbar under one.
123
+ const max = scroller.scrollWidth - scroller.clientWidth
124
+ const next: ScrollEdges = {
125
+ left: max > 1 && scroller.scrollLeft > 1,
126
+ right: max > 1 && scroller.scrollLeft < max - 1,
127
+ }
128
+ setEdges((prev) =>
129
+ prev.left === next.left && prev.right === next.right ? prev : next
130
+ )
131
+ }
132
+
133
+ update()
134
+ scroller.addEventListener('scroll', update, { passive: true })
135
+
136
+ let observer: ResizeObserver | undefined
137
+ if (typeof ResizeObserver !== 'undefined') {
138
+ // Observe the TABLE, not just the scroller. The scroller is `w-full`, so
139
+ // its own box does NOT change when a column is toggled, a filter narrows
140
+ // the data, or a page of rows re-sizes the auto-laid-out columns — only
141
+ // the table's box does. Watching the scroller alone misses every one of
142
+ // those and leaves the hint stale.
143
+ observer = new ResizeObserver(update)
144
+ observer.observe(table)
145
+ observer.observe(scroller)
146
+ }
147
+ window.addEventListener('resize', update)
148
+
149
+ return () => {
150
+ scroller.removeEventListener('scroll', update)
151
+ window.removeEventListener('resize', update)
152
+ observer?.disconnect()
153
+ }
154
+ }, [tableRef])
155
+
156
+ return edges
157
+ }
@@ -1,19 +1,49 @@
1
+ 'use client'
2
+
1
3
  import * as React from "react"
2
4
 
3
5
  import { cn } from "../../lib/utils"
6
+ import { useInjectedStyle } from "../../lib/injected-style"
7
+ import {
8
+ TABLE_SCROLLER_CLASS,
9
+ TABLE_SCROLL_CSS,
10
+ TABLE_SCROLL_STYLE_ID,
11
+ } from "./table-scroll"
4
12
 
5
- const Table = React.forwardRef<
6
- HTMLTableElement,
7
- React.HTMLAttributes<HTMLTableElement>
8
- >(({ className, ...props }, ref) => (
9
- <div className="relative w-full overflow-auto">
10
- <table
11
- ref={ref}
12
- className={cn("w-full caption-bottom text-sm", className)}
13
- {...props}
14
- />
15
- </div>
16
- ))
13
+ export interface TableProps extends React.HTMLAttributes<HTMLTableElement> {
14
+ /**
15
+ * Classes for the scroll container that wraps the `<table>`. This div — not
16
+ * the `<table>` — is the element that actually scrolls horizontally, so
17
+ * anything that needs to change the scrolling box (a max-height, a different
18
+ * overflow) belongs here rather than in `className`.
19
+ */
20
+ containerClassName?: string
21
+ }
22
+
23
+ const Table = React.forwardRef<HTMLTableElement, TableProps>(
24
+ ({ className, containerClassName, ...props }, ref) => {
25
+ // Gives the scroller a scrollbar that is actually visible while it
26
+ // overflows. See table-scroll.ts for the measurements — in particular why
27
+ // `scrollbar-width` must NOT be added alongside it.
28
+ useInjectedStyle(TABLE_SCROLL_STYLE_ID, TABLE_SCROLL_CSS)
29
+
30
+ return (
31
+ <div
32
+ className={cn(
33
+ "relative w-full overflow-auto",
34
+ TABLE_SCROLLER_CLASS,
35
+ containerClassName
36
+ )}
37
+ >
38
+ <table
39
+ ref={ref}
40
+ className={cn("w-full caption-bottom text-sm", className)}
41
+ {...props}
42
+ />
43
+ </div>
44
+ )
45
+ }
46
+ )
17
47
  Table.displayName = "Table"
18
48
 
19
49
  const TableHeader = React.forwardRef<
@@ -0,0 +1,99 @@
1
+ /**
2
+ * DataTableCore's edge hints (startsim-5pq7h).
3
+ *
4
+ * The persistent scrollbar restored on the `Table` primitive sits at the bottom
5
+ * of the scroller, and the scroller is as tall as the whole table — measured
6
+ * 3061-5698px BELOW THE FOLD on every content view of the marketing-agents
7
+ * tenant at a 900px-tall window. A reader at the header row never sees it, so
8
+ * the table also fades whichever edge still hides content.
9
+ *
10
+ * jsdom has no layout, so the geometry is stated outright below. These tests
11
+ * guard the WIRING and the "nothing overflows -> no decoration" contract; the
12
+ * visual claim is carried by browser measurement, not by them.
13
+ */
14
+ import { render, screen } from '@testing-library/react'
15
+ import { DataTableCore } from '../../components/DataTableCore'
16
+ import { ColumnConfig } from '../../types'
17
+ import { TABLE_EDGE_CLASS, TABLE_SHELL_CLASS } from '../../../ui/table-scroll'
18
+
19
+ interface Row {
20
+ id: string
21
+ name: string
22
+ }
23
+
24
+ const data: Row[] = [
25
+ { id: '1', name: 'Abu Dhabi Off-Plan Mortgage Guide' },
26
+ { id: '2', name: 'UAE Capital Markets Fee Changes' },
27
+ ]
28
+
29
+ const columns: ColumnConfig<Row>[] = [
30
+ { id: 'name', header: 'Name', accessorKey: 'name' },
31
+ ]
32
+
33
+ /** Force the scroll container's geometry, which jsdom otherwise reports as 0/0. */
34
+ function stubGeometry(clientWidth: number, scrollWidth: number) {
35
+ const original = {
36
+ clientWidth: Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'clientWidth'),
37
+ scrollWidth: Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollWidth'),
38
+ }
39
+ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
40
+ configurable: true,
41
+ get() {
42
+ return this.tagName === 'DIV' ? clientWidth : 0
43
+ },
44
+ })
45
+ Object.defineProperty(HTMLElement.prototype, 'scrollWidth', {
46
+ configurable: true,
47
+ get() {
48
+ return this.tagName === 'DIV' ? scrollWidth : 0
49
+ },
50
+ })
51
+ return () => {
52
+ if (original.clientWidth) Object.defineProperty(HTMLElement.prototype, 'clientWidth', original.clientWidth)
53
+ if (original.scrollWidth) Object.defineProperty(HTMLElement.prototype, 'scrollWidth', original.scrollWidth)
54
+ }
55
+ }
56
+
57
+ const edges = (container: HTMLElement) =>
58
+ container.querySelectorAll(`.${TABLE_EDGE_CLASS}`)
59
+
60
+ describe('DataTableCore horizontal-scroll affordance', () => {
61
+ let restore: () => void = () => {}
62
+ afterEach(() => restore())
63
+
64
+ it('gives the table a non-scrolling shell for the hints to pin to', () => {
65
+ restore = stubGeometry(846, 846)
66
+ const { container } = render(
67
+ <DataTableCore data={data} columns={columns} getRowId={(r) => r.id} />
68
+ )
69
+ const table = screen.getByRole('table')
70
+ // The shell is the OUTER box; the element that scrolls is Table's own
71
+ // wrapper inside it. Pinning the hints to the scroller would make them
72
+ // scroll away with the content.
73
+ expect(container.querySelector(`.${TABLE_SHELL_CLASS}`)).toBe(
74
+ table.parentElement?.parentElement
75
+ )
76
+ })
77
+
78
+ it('renders no edge hint at all when every column fits', () => {
79
+ restore = stubGeometry(846, 846)
80
+ const { container } = render(
81
+ <DataTableCore data={data} columns={columns} getRowId={(r) => r.id} />
82
+ )
83
+ expect(edges(container)).toHaveLength(0)
84
+ })
85
+
86
+ it('fades the right edge when columns are unreached to the right', () => {
87
+ // /t/topic at a 1152px window: 846 visible, 1014 needed.
88
+ restore = stubGeometry(846, 1014)
89
+ const { container } = render(
90
+ <DataTableCore data={data} columns={columns} getRowId={(r) => r.id} />
91
+ )
92
+ const found = edges(container)
93
+ expect(found).toHaveLength(1)
94
+ expect(found[0]).toHaveClass('ss-table-edge-right')
95
+ // Decoration only — it must never intercept a click meant for the cell or
96
+ // the row-action menu underneath.
97
+ expect(found[0]).toHaveAttribute('aria-hidden', 'true')
98
+ })
99
+ })
@@ -1,7 +1,14 @@
1
1
  'use client'
2
2
 
3
- import { ReactNode, useState, useCallback } from 'react'
3
+ import { ReactNode, useState, useCallback, useRef } from 'react'
4
4
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '../../../ui/table'
5
+ import {
6
+ useScrollEdges,
7
+ TABLE_SHELL_CLASS,
8
+ TABLE_EDGE_CLASS,
9
+ TABLE_EDGE_LEFT_CLASS,
10
+ TABLE_EDGE_RIGHT_CLASS,
11
+ } from '../../../ui/table-scroll'
5
12
  import { Checkbox } from '../../../ui/checkbox'
6
13
  import { Button } from '../../../ui/button'
7
14
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger } from '../../../ui/dropdown-menu'
@@ -91,6 +98,14 @@ export function DataTableCore<TData>({
91
98
  // State for tracking if a column is being dragged (to disable sorting during drag)
92
99
  const [isDraggingColumn, setIsDraggingColumn] = useState(false)
93
100
 
101
+ // The scrollbar restored in `Table` sits at the bottom of the scroller, and
102
+ // the scroller is as tall as the whole table — thousands of pixels below the
103
+ // fold on a full page of rows. These flags drive a fade at whichever edge
104
+ // still hides content, so the reader is told at the header row, not only at
105
+ // the very bottom of the page (startsim-5pq7h).
106
+ const tableRef = useRef<HTMLTableElement>(null)
107
+ const scrollEdges = useScrollEdges(tableRef)
108
+
94
109
  // Drag handlers
95
110
  const handleDragStart = useCallback((_: DragStart) => {
96
111
  setIsDraggingColumn(true)
@@ -334,8 +349,13 @@ export function DataTableCore<TData>({
334
349
  return (
335
350
  // overflow-x-auto: a wide table scrolls horizontally inside its own border
336
351
  // instead of overflowing the page to the right (startsim column-overflow).
337
- <div className={cn('rounded-md border border-border overflow-x-auto', className)}>
338
- <Table>
352
+ // NOTE: this div is not the element that ends up scrolling — `Table`'s own
353
+ // `overflow-auto` wrapper inside it is, because that wrapper is `w-full`
354
+ // and so never makes this one overflow. That is why the scrollbar styling
355
+ // and the ref below both target the inner wrapper. This div stays as the
356
+ // non-scrolling shell the edge hints are pinned to.
357
+ <div className={cn('rounded-md border border-border overflow-x-auto', TABLE_SHELL_CLASS, className)}>
358
+ <Table ref={tableRef}>
339
359
  {renderColumnHeaders()}
340
360
 
341
361
  <TableBody>
@@ -474,6 +494,17 @@ export function DataTableCore<TData>({
474
494
  )}
475
495
  </TableBody>
476
496
  </Table>
497
+
498
+ {/* Edge hints. Rendered only while that side actually hides something, so
499
+ a table that fits gets no decoration at all. `pointer-events: none`
500
+ keeps the rightmost column's cells and the row-action menu clickable
501
+ underneath. */}
502
+ {scrollEdges.left && (
503
+ <div aria-hidden="true" className={cn(TABLE_EDGE_CLASS, TABLE_EDGE_LEFT_CLASS)} />
504
+ )}
505
+ {scrollEdges.right && (
506
+ <div aria-hidden="true" className={cn(TABLE_EDGE_CLASS, TABLE_EDGE_RIGHT_CLASS)} />
507
+ )}
477
508
  </div>
478
509
  )
479
510
  }
@@ -0,0 +1,41 @@
1
+ import { useEffect } from 'react'
2
+
3
+ /**
4
+ * Append a stylesheet to <head> exactly once per document, keyed by `id`.
5
+ *
6
+ * WHY THIS EXISTS instead of a .css file or Tailwind classes (startsim-5pq7h):
7
+ *
8
+ * - @startsimpli/ui ships SOURCE (`main: ./src/index.ts`), and each consuming
9
+ * app decides for itself whether Tailwind scans it. Four of the eleven apps
10
+ * — crochet, recipe, workflows and raise — have no
11
+ * `@source ".../@startsimpli/ui/src/**"` line in their globals.css, so a
12
+ * Tailwind class written in this package emits no rule at all over there.
13
+ * - The subpath CSS exports (`./gantt/styles`, `./workflows/styles`) only take
14
+ * effect once the app adds an `@import`, which is a change in eleven repos.
15
+ * - Pseudo-element rules (`::-webkit-scrollbar`) cannot be expressed as an
16
+ * inline `style` prop.
17
+ *
18
+ * Injecting from the component is the only delivery that reaches every place
19
+ * the component actually renders.
20
+ */
21
+ export function ensureInjectedStyle(id: string, css: string): void {
22
+ if (typeof document === 'undefined') return
23
+
24
+ const existing = document.getElementById(id)
25
+ if (existing) {
26
+ if (existing.textContent !== css) existing.textContent = css
27
+ return
28
+ }
29
+
30
+ const el = document.createElement('style')
31
+ el.id = id
32
+ el.textContent = css
33
+ document.head.appendChild(el)
34
+ }
35
+
36
+ /** React wrapper for {@link ensureInjectedStyle}. Safe to call from every instance. */
37
+ export function useInjectedStyle(id: string, css: string): void {
38
+ useEffect(() => {
39
+ ensureInjectedStyle(id, css)
40
+ }, [id, css])
41
+ }