@stacksjs/components 0.2.855 → 0.2.857

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.
Files changed (100) hide show
  1. package/dist/ContextMenu-43g3w5tp.stx +188 -0
  2. package/dist/DataGrid-7rt7v865.stx +376 -0
  3. package/dist/GraphView-0t3t9mec.stx +320 -0
  4. package/dist/JsonTree-satc4010.stx +317 -0
  5. package/dist/PreviewFrame-erbgvzj8.stx +257 -0
  6. package/dist/SplitPane-7sqfdwqa.stx +159 -0
  7. package/dist/component-api/component-api.js +36 -0
  8. package/dist/context-menu/context-menu.js +575 -0
  9. package/dist/data-grid/data-grid.js +1244 -0
  10. package/dist/graph-view/graph-view.js +1408 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.js +22 -20
  13. package/dist/json-tree/json-tree.js +1121 -0
  14. package/dist/preview-frame/preview-frame.js +356 -0
  15. package/dist/split-pane/split-pane.js +364 -0
  16. package/dist/ui/context-menu/ContextMenu.d.ts +14 -0
  17. package/dist/ui/context-menu/context-menu.d.ts +8 -0
  18. package/dist/ui/context-menu/core.d.ts +74 -0
  19. package/dist/ui/context-menu/index.d.ts +11 -0
  20. package/dist/ui/context-menu/view.d.ts +36 -0
  21. package/dist/ui/data-grid/DataGrid.d.ts +30 -0
  22. package/dist/ui/data-grid/core.d.ts +141 -0
  23. package/dist/ui/data-grid/data-grid.d.ts +9 -0
  24. package/dist/ui/data-grid/index.d.ts +20 -0
  25. package/dist/ui/data-grid/view.d.ts +56 -0
  26. package/dist/ui/graph-view/GraphView.d.ts +21 -0
  27. package/dist/ui/graph-view/core/edges.d.ts +34 -0
  28. package/dist/ui/graph-view/core/force.d.ts +10 -0
  29. package/dist/ui/graph-view/core/graph.d.ts +83 -0
  30. package/dist/ui/graph-view/core/index.d.ts +5 -0
  31. package/dist/ui/graph-view/core/layered.d.ts +24 -0
  32. package/dist/ui/graph-view/core/viewport.d.ts +34 -0
  33. package/dist/ui/graph-view/graph-view.d.ts +9 -0
  34. package/dist/ui/graph-view/index.d.ts +21 -0
  35. package/dist/ui/graph-view/view.d.ts +51 -0
  36. package/dist/ui/json-tree/JsonTree.d.ts +18 -0
  37. package/dist/ui/json-tree/core.d.ts +108 -0
  38. package/dist/ui/json-tree/index.d.ts +18 -0
  39. package/dist/ui/json-tree/json-tree.d.ts +10 -0
  40. package/dist/ui/json-tree/tinker.d.ts +84 -0
  41. package/dist/ui/json-tree/view.d.ts +59 -0
  42. package/dist/ui/preview-frame/PreviewFrame.d.ts +44 -0
  43. package/dist/ui/preview-frame/core.d.ts +81 -0
  44. package/dist/ui/preview-frame/index.d.ts +19 -0
  45. package/dist/ui/preview-frame/preview-frame.d.ts +8 -0
  46. package/dist/ui/preview-frame/view.d.ts +37 -0
  47. package/dist/ui/split-pane/SplitPane.d.ts +18 -0
  48. package/dist/ui/split-pane/core.d.ts +58 -0
  49. package/dist/ui/split-pane/index.d.ts +15 -0
  50. package/dist/ui/split-pane/split-pane.d.ts +8 -0
  51. package/dist/ui/split-pane/view.d.ts +27 -0
  52. package/dist/ui/virtual-table/index.d.ts +6 -0
  53. package/dist/utils/component-api.d.ts +4 -0
  54. package/package.json +38 -3
  55. package/src/index.ts +8 -0
  56. package/src/ui/code-editor/README.md +2 -1
  57. package/src/ui/context-menu/ContextMenu.stx +188 -0
  58. package/src/ui/context-menu/README.md +117 -0
  59. package/src/ui/context-menu/context-menu.ts +8 -0
  60. package/src/ui/context-menu/core.ts +250 -0
  61. package/src/ui/context-menu/index.ts +16 -0
  62. package/src/ui/context-menu/view.ts +540 -0
  63. package/src/ui/data-grid/DataGrid.stx +376 -0
  64. package/src/ui/data-grid/README.md +204 -0
  65. package/src/ui/data-grid/core.ts +813 -0
  66. package/src/ui/data-grid/data-grid.ts +9 -0
  67. package/src/ui/data-grid/index.ts +34 -0
  68. package/src/ui/data-grid/view.ts +806 -0
  69. package/src/ui/graph-view/GraphView.stx +320 -0
  70. package/src/ui/graph-view/README.md +210 -0
  71. package/src/ui/graph-view/core/edges.ts +180 -0
  72. package/src/ui/graph-view/core/force.ts +237 -0
  73. package/src/ui/graph-view/core/graph.ts +277 -0
  74. package/src/ui/graph-view/core/index.ts +5 -0
  75. package/src/ui/graph-view/core/layered.ts +256 -0
  76. package/src/ui/graph-view/core/viewport.ts +141 -0
  77. package/src/ui/graph-view/graph-view.ts +9 -0
  78. package/src/ui/graph-view/index.ts +35 -0
  79. package/src/ui/graph-view/view.ts +809 -0
  80. package/src/ui/json-tree/JsonTree.stx +317 -0
  81. package/src/ui/json-tree/README.md +193 -0
  82. package/src/ui/json-tree/core.ts +588 -0
  83. package/src/ui/json-tree/index.ts +28 -0
  84. package/src/ui/json-tree/json-tree.ts +10 -0
  85. package/src/ui/json-tree/tinker.ts +349 -0
  86. package/src/ui/json-tree/view.ts +665 -0
  87. package/src/ui/preview-frame/PreviewFrame.stx +257 -0
  88. package/src/ui/preview-frame/README.md +107 -0
  89. package/src/ui/preview-frame/core.ts +195 -0
  90. package/src/ui/preview-frame/index.ts +31 -0
  91. package/src/ui/preview-frame/preview-frame.ts +8 -0
  92. package/src/ui/preview-frame/view.ts +336 -0
  93. package/src/ui/split-pane/README.md +87 -0
  94. package/src/ui/split-pane/SplitPane.stx +159 -0
  95. package/src/ui/split-pane/core.ts +200 -0
  96. package/src/ui/split-pane/index.ts +24 -0
  97. package/src/ui/split-pane/split-pane.ts +8 -0
  98. package/src/ui/split-pane/view.ts +305 -0
  99. package/src/ui/virtual-table/index.ts +6 -0
  100. package/src/utils/component-api.ts +72 -0
@@ -0,0 +1,188 @@
1
+ <script server>
2
+ /*
3
+ * The items, when they arrive as a plain prop. A bound list (`:items="list()"`)
4
+ * or a function that builds one for the element clicked on (`:items="menuFor"`)
5
+ * is read live by the client script.
6
+ */
7
+ export const items = Array.isArray($props.items) ? $props.items : []
8
+ export const label = $props.label || 'Context menu'
9
+ export const disabled = $bool($props.disabled)
10
+ export const className = $props.className || ''
11
+ export const menuId = $props.id || `context-menu-${$uid}`
12
+ </script>
13
+
14
+ <script client>
15
+ /*
16
+ * <ContextMenu>: wraps the content it is the menu for. A right click inside,
17
+ * the menu key or Shift+F10 opens it; `open()` opens it from anywhere.
18
+ *
19
+ * What a menu is and how it is moved through is in ./core, the DOM in ./view.
20
+ */
21
+ import { ContextMenuView } from './view'
22
+
23
+ const emit = defineEmits(['select', 'open', 'close'])
24
+
25
+ function asBoolean(value) {
26
+ if (value == null) return false
27
+ if (typeof value === 'string') return !['false', '0', 'off', 'no'].includes(value.trim().toLowerCase())
28
+ return Boolean(value)
29
+ }
30
+ // An array, a function that returns one, or JSON from a plain attribute.
31
+ function asItems(value) {
32
+ if (Array.isArray(value) || typeof value === 'function') return value
33
+ if (typeof value === 'string' && value.charAt(0) === '[') {
34
+ try { return JSON.parse(value) }
35
+ catch (e) { return [] }
36
+ }
37
+ return []
38
+ }
39
+
40
+ const liveItems = useReactiveProp('items', {{ items }}, { parse: asItems })
41
+ const liveDisabled = useReactiveProp('disabled', {{ disabled }}, { parse: asBoolean })
42
+
43
+ const rootRef = useRef('context-menu')
44
+ let menu = null
45
+
46
+ onMount(() => {
47
+ const root = rootRef()
48
+ if (!root) return
49
+
50
+ menu = new ContextMenuView(root, {
51
+ items: asItems(liveItems()),
52
+ label: {{ label }},
53
+ disabled: asBoolean(liveDisabled()),
54
+ }, {
55
+ onSelect(detail) { emit('select', detail) },
56
+ onOpen(detail) { emit('open', detail) },
57
+ onClose(detail) { emit('close', detail) },
58
+ })
59
+
60
+ effect(() => menu.setItems(asItems(liveItems())))
61
+ effect(() => menu.setDisabled(asBoolean(liveDisabled())))
62
+ })
63
+
64
+ onDestroy(() => {
65
+ if (menu) menu.destroy()
66
+ menu = null
67
+ })
68
+
69
+ defineExpose({
70
+ open: (at, items, options) => (menu ? menu.open(at, items || null, options || {}) : false),
71
+ close: () => { if (menu) menu.close('api') },
72
+ isOpen: () => (menu ? menu.isOpen : false),
73
+ })
74
+ </script>
75
+
76
+ {{-- The wrapper takes no box of its own: the content lays out as if the menu
77
+ were not there. --}}
78
+ <div ref="context-menu" id="{{ menuId }}" data-stx-context-menu class="{{ className }}" style="display: contents">
79
+ <slot />
80
+ </div>
81
+
82
+ <style>
83
+ /*
84
+ * The menus live in one layer. Where the browser has a top layer the layer is
85
+ * a popover, and its own box must not paint or catch the pointer.
86
+ */
87
+ :where([data-stx-context-menu]) {
88
+ --stx-menu-bg: var(--stx-panel, #ffffff);
89
+ --stx-menu-fg: var(--stx-fg, #171717);
90
+ --stx-menu-fg-soft: var(--stx-fg-soft, #737373);
91
+ --stx-menu-line: var(--stx-line, #e5e5e5);
92
+ --stx-menu-active: var(--stx-accent-solid, #2563eb);
93
+ --stx-menu-active-fg: var(--stx-accent-ink, #ffffff);
94
+ --stx-menu-danger: var(--stx-danger, #dc2626);
95
+ --stx-menu-radius: 8px;
96
+ --stx-menu-item-radius: 5px;
97
+ --stx-menu-font-size: 13px;
98
+ --stx-menu-min-width: 11rem;
99
+ }
100
+
101
+ [data-stx-context-menu] > .stx-menu-layer {
102
+ position: fixed;
103
+ inset: 0;
104
+ z-index: 1000;
105
+ width: auto;
106
+ height: auto;
107
+ max-width: none;
108
+ max-height: none;
109
+ margin: 0;
110
+ padding: 0;
111
+ border: 0;
112
+ overflow: visible;
113
+ background: transparent;
114
+ color: inherit;
115
+ pointer-events: none;
116
+ }
117
+ [data-stx-context-menu] > .stx-menu-layer:where([hidden]) { display: none; }
118
+
119
+ .stx-menu-layer > .stx-menu {
120
+ position: fixed;
121
+ top: 0;
122
+ left: 0;
123
+ box-sizing: border-box;
124
+ min-width: var(--stx-menu-min-width);
125
+ max-width: min(24rem, calc(100vw - 16px));
126
+ max-height: calc(100vh - 16px);
127
+ overflow-y: auto;
128
+ padding: 4px;
129
+ border: 1px solid var(--stx-menu-line);
130
+ border-radius: var(--stx-menu-radius);
131
+ background: var(--stx-menu-bg);
132
+ color: var(--stx-menu-fg);
133
+ box-shadow: 0 10px 30px rgb(0 0 0 / 0.16), 0 2px 6px rgb(0 0 0 / 0.08);
134
+ font-size: var(--stx-menu-font-size);
135
+ line-height: 1.35;
136
+ outline: none;
137
+ pointer-events: auto;
138
+ user-select: none;
139
+ -webkit-user-select: none;
140
+ }
141
+
142
+ .stx-menu > .stx-menu-item {
143
+ display: grid;
144
+ grid-template-columns: 1rem 1fr auto;
145
+ align-items: center;
146
+ column-gap: 6px;
147
+ padding: 4px 8px 4px 4px;
148
+ border-radius: var(--stx-menu-item-radius);
149
+ cursor: default;
150
+ outline: none;
151
+ white-space: nowrap;
152
+ }
153
+ .stx-menu > .stx-menu-item:focus {
154
+ background: var(--stx-menu-active);
155
+ color: var(--stx-menu-active-fg);
156
+ }
157
+ .stx-menu > .stx-menu-item[aria-expanded="true"]:not(:focus) {
158
+ background: color-mix(in srgb, var(--stx-menu-fg) 10%, transparent);
159
+ }
160
+ .stx-menu > .stx-menu-item[data-danger]:not(:focus) { color: var(--stx-menu-danger); }
161
+ .stx-menu > .stx-menu-item[data-danger]:focus { background: var(--stx-menu-danger); color: #ffffff; }
162
+
163
+ /* A disabled item can still be reached and read, so it shows where focus is without looking available. */
164
+ .stx-menu > .stx-menu-item[aria-disabled="true"] { color: var(--stx-menu-fg-soft); opacity: 0.6; }
165
+ .stx-menu > .stx-menu-item[aria-disabled="true"]:focus {
166
+ background: color-mix(in srgb, var(--stx-menu-fg) 8%, transparent);
167
+ color: var(--stx-menu-fg-soft);
168
+ }
169
+
170
+ .stx-menu .stx-menu-check { text-align: center; font-size: 0.85em; }
171
+ .stx-menu .stx-menu-label { overflow: hidden; text-overflow: ellipsis; }
172
+ .stx-menu :is(.stx-menu-shortcut, .stx-menu-arrow) {
173
+ margin-left: 1.5rem;
174
+ color: var(--stx-menu-fg-soft);
175
+ font-variant-numeric: tabular-nums;
176
+ }
177
+ .stx-menu > .stx-menu-item:focus:not([aria-disabled="true"]) :is(.stx-menu-shortcut, .stx-menu-arrow) { color: inherit; opacity: 0.85; }
178
+
179
+ .stx-menu > .stx-menu-separator {
180
+ height: 1px;
181
+ margin: 4px 6px;
182
+ background: var(--stx-menu-line);
183
+ }
184
+
185
+ @media (forced-colors: active) {
186
+ .stx-menu > .stx-menu-item:focus { outline: 2px solid Highlight; outline-offset: -2px; }
187
+ }
188
+ </style>
@@ -0,0 +1,376 @@
1
+ <script server>
2
+ /*
3
+ * Rows written into the page as a plain prop. A bound one (`:rows="rows()"`)
4
+ * is read live by the client script; this is what it starts from.
5
+ */
6
+ export const rows = Array.isArray($props.rows) ? $props.rows : []
7
+ export const columns = Array.isArray($props.columns) ? $props.columns : []
8
+ export const rowHeight = $num($props.rowHeight) || 28
9
+ export const headerHeight = $num($props.headerHeight) || 32
10
+ /* A CSS length. `100%` fills a sized parent, which is what a pane wants. */
11
+ export const height = $props.height || '24rem'
12
+ export const filterable = $bool($props.filterable, true)
13
+ export const exportable = $bool($props.exportable, true)
14
+ export const selectable = $bool($props.selectable, true)
15
+ export const contextMenu = $bool($props.contextMenu)
16
+ export const filter = typeof $props.filter === 'string' ? $props.filter : ''
17
+ export const label = $props.label || 'Data'
18
+ export const fileName = $props.fileName || 'data'
19
+ export const className = $props.className || ''
20
+ /*
21
+ * Ids unique to this instance: the grid, its filter and its status line all
22
+ * have to be findable when two grids share a page.
23
+ */
24
+ export const gridId = $props.id || `data-grid-${$uid}`
25
+ export const filterId = `${gridId}-filter`
26
+ export const statusId = `${gridId}-status`
27
+ export const hasToolbar = filterable || exportable
28
+ </script>
29
+
30
+ <script client>
31
+ /*
32
+ * <DataGrid>: rows and columns, sorted, filtered, selected and exported.
33
+ *
34
+ * This script is the wiring: props in, events out. What a sort or a filter
35
+ * does is in ./core, and what is drawn is in ./view.
36
+ */
37
+ import { DataGridView } from './view'
38
+
39
+ const emit = defineEmits(['sort', 'filter', 'select', 'cell', 'activate', 'copy', 'export', 'context'])
40
+
41
+ function asList(value) {
42
+ if (Array.isArray(value)) return value
43
+ if (typeof value === 'string' && value.charAt(0) === '[') {
44
+ try { return JSON.parse(value) }
45
+ catch (e) { return [] }
46
+ }
47
+ return []
48
+ }
49
+ function asText(value) { return value == null ? '' : String(value) }
50
+
51
+ const liveRows = useReactiveProp('rows', {{ rows }}, { parse: asList })
52
+ const liveColumns = useReactiveProp('columns', {{ columns }}, { parse: asList })
53
+ const liveFilter = useReactiveProp('filter', {{ filter }}, { parse: asText })
54
+ const liveFileName = useReactiveProp('fileName', {{ fileName }}, { parse: asText })
55
+
56
+ const rootRef = useRef('data-grid')
57
+ let grid = null
58
+
59
+ onMount(() => {
60
+ const root = rootRef()
61
+ if (!root) return
62
+
63
+ const firstColumns = asList(liveColumns())
64
+ grid = new DataGridView(root, {
65
+ rows: asList(liveRows()),
66
+ columns: firstColumns.length ? firstColumns : null,
67
+ rowHeight: {{ rowHeight }},
68
+ headerHeight: {{ headerHeight }},
69
+ selectable: {{ selectable }},
70
+ contextMenu: {{ contextMenu }},
71
+ filter: asText(liveFilter()),
72
+ fileName: asText(liveFileName()),
73
+ }, {
74
+ onSort(sort) { emit('sort', sort) },
75
+ onFilter(detail) { emit('filter', detail) },
76
+ onSelect(detail) { emit('select', detail) },
77
+ onCell(detail) { emit('cell', detail) },
78
+ onActivate(detail) { emit('activate', detail) },
79
+ onCopy(detail) { emit('copy', detail) },
80
+ onExport(detail) { emit('export', detail) },
81
+ onContext(detail) { emit('context', detail) },
82
+ })
83
+
84
+ // The first run of each finds what the view was just built with. Only a
85
+ // later change is news, and rows handed over with setRows() must not be
86
+ // replaced by a prop that has not changed.
87
+ let rowsSeen = false
88
+ effect(() => {
89
+ const next = asList(liveRows())
90
+ if (rowsSeen) grid.setRows(next)
91
+ rowsSeen = true
92
+ })
93
+ let columnsSeen = false
94
+ effect(() => {
95
+ const next = asList(liveColumns())
96
+ if (columnsSeen) grid.setColumns(next.length ? next : null)
97
+ columnsSeen = true
98
+ })
99
+ let filterSeen = false
100
+ effect(() => {
101
+ const next = asText(liveFilter())
102
+ if (filterSeen) grid.setFilter(next)
103
+ filterSeen = true
104
+ })
105
+ effect(() => grid.setFileName(asText(liveFileName())))
106
+ })
107
+
108
+ onDestroy(() => {
109
+ if (grid) grid.destroy()
110
+ grid = null
111
+ })
112
+
113
+ defineExpose({
114
+ setRows: (next) => { if (grid) grid.setRows(asList(next)) },
115
+ setColumns: (next) => { if (grid) grid.setColumns(Array.isArray(next) && next.length ? next : null) },
116
+ getView: () => (grid ? grid.getView() : []),
117
+ getSelection: () => (grid ? grid.getSelection() : { rows: [], indices: [] }),
118
+ clearSelection: () => { if (grid) grid.clearSelection() },
119
+ setFilter: (text) => { if (grid) grid.setFilter(asText(text)) },
120
+ setSort: (sort) => { if (grid) grid.setSort(asList(sort)) },
121
+ exportCsv: () => (grid ? grid.exportCsv() : ''),
122
+ exportJson: () => (grid ? grid.exportJson() : '[]'),
123
+ download: format => (grid ? grid.download(format === 'json' ? 'json' : 'csv') : ''),
124
+ scrollToRow: (index) => { if (grid) grid.scrollToRow(index) },
125
+ focus: () => { if (grid) grid.focus() },
126
+ grid: () => grid,
127
+ })
128
+ </script>
129
+
130
+ <div
131
+ ref="data-grid"
132
+ data-stx-data-grid
133
+ class="stx-dg {{ className }}"
134
+ style="height: {{ height }}"
135
+ @if(selectable)data-selectable@endif
136
+ >
137
+ @if(hasToolbar)
138
+ <div data-dg="toolbar" class="stx-dg-toolbar">
139
+ @if(filterable)
140
+ <label for="{{ filterId }}" class="sr-only">Filter {{ label }}</label>
141
+ <input
142
+ data-dg="filter"
143
+ id="{{ filterId }}"
144
+ type="search"
145
+ class="stx-dg-filter"
146
+ placeholder="Filter rows"
147
+ autocomplete="off"
148
+ spellcheck="false"
149
+ aria-controls="{{ gridId }}"
150
+ value="{{ filter }}"
151
+ >
152
+ @endif
153
+ <span data-dg="status" id="{{ statusId }}" role="status" aria-live="polite" class="stx-dg-status"></span>
154
+ @if(exportable)
155
+ <button type="button" data-dg="export-csv" class="stx-dg-button" aria-label="Export {{ label }} as CSV">CSV</button>
156
+ <button type="button" data-dg="export-json" class="stx-dg-button" aria-label="Export {{ label }} as JSON">JSON</button>
157
+ @endif
158
+ </div>
159
+ @else
160
+ <span data-dg="status" id="{{ statusId }}" role="status" aria-live="polite" class="sr-only"></span>
161
+ @endif
162
+
163
+ {{-- The one scroll container, and the grid itself: focus stays here and the
164
+ active cell is named, since the cells under it come and go. --}}
165
+ <div
166
+ data-dg="scroller"
167
+ id="{{ gridId }}"
168
+ role="grid"
169
+ tabindex="0"
170
+ aria-label="{{ label }}"
171
+ aria-describedby="{{ statusId }}"
172
+ @if(selectable)aria-multiselectable="true"@endif
173
+ class="stx-dg-scroller"
174
+ >
175
+ <div data-dg="content" role="presentation" class="stx-dg-content">
176
+ <div data-dg="header" role="row" aria-rowindex="1" class="stx-dg-header"></div>
177
+ <div data-dg="body" role="rowgroup" class="stx-dg-body"></div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <style>
183
+ /*
184
+ * Everything the grid is drawn with is a custom property, each falling back to
185
+ * one of the library's role tokens, so an app that has themed its roles has a
186
+ * matching grid, in light and in dark.
187
+ *
188
+ * The row and header heights are set by the view, in pixels: the arithmetic
189
+ * that decides which rows exist depends on every row being exactly that tall.
190
+ */
191
+ :where([data-stx-data-grid]) {
192
+ --stx-grid-font: inherit;
193
+ --stx-grid-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
194
+ --stx-grid-font-size: 13px;
195
+ --stx-grid-row-height: 28px;
196
+ --stx-grid-header-height: 32px;
197
+ --stx-grid-cell-padding: 12px;
198
+ --stx-grid-bg: var(--stx-panel, #ffffff);
199
+ --stx-grid-fg: var(--stx-fg, #171717);
200
+ --stx-grid-header-bg: var(--stx-surface, #fafafa);
201
+ --stx-grid-header-fg: var(--stx-fg-muted, #525252);
202
+ --stx-grid-line: var(--stx-line, #e5e5e5);
203
+ --stx-grid-empty-fg: var(--stx-fg-subtle, #a3a3a3);
204
+ --stx-grid-hover: color-mix(in srgb, var(--stx-fg, #171717) 4%, transparent);
205
+ --stx-grid-selected: color-mix(in srgb, var(--stx-accent, #2563eb) 14%, transparent);
206
+ --stx-grid-accent: var(--stx-accent, #2563eb);
207
+ --stx-grid-number: var(--stx-grid-fg);
208
+ --stx-grid-boolean: var(--stx-info, #0891b2);
209
+ display: flex;
210
+ flex-direction: column;
211
+ min-width: 0;
212
+ min-height: 0;
213
+ overflow: hidden;
214
+ border: 1px solid var(--stx-grid-line);
215
+ border-radius: var(--stx-radius-panel, 8px);
216
+ background: var(--stx-grid-bg);
217
+ color: var(--stx-grid-fg);
218
+ font-family: var(--stx-grid-font);
219
+ font-size: var(--stx-grid-font-size);
220
+ }
221
+
222
+ [data-stx-data-grid] .stx-dg-toolbar {
223
+ display: flex;
224
+ flex: 0 0 auto;
225
+ align-items: center;
226
+ gap: 8px;
227
+ padding: 6px 8px;
228
+ border-bottom: 1px solid var(--stx-grid-line);
229
+ background: var(--stx-grid-header-bg);
230
+ }
231
+ [data-stx-data-grid] .stx-dg-filter {
232
+ flex: 0 1 16rem;
233
+ min-width: 6rem;
234
+ height: 26px;
235
+ padding: 0 8px;
236
+ border: 1px solid var(--stx-grid-line);
237
+ border-radius: var(--stx-radius-control, 6px);
238
+ background: var(--stx-field, var(--stx-grid-bg));
239
+ color: inherit;
240
+ font: inherit;
241
+ }
242
+ [data-stx-data-grid] .stx-dg-filter:focus-visible,
243
+ [data-stx-data-grid] .stx-dg-button:focus-visible {
244
+ outline: 2px solid var(--stx-grid-accent);
245
+ outline-offset: 1px;
246
+ }
247
+ [data-stx-data-grid] .stx-dg-status {
248
+ flex: 1 1 auto;
249
+ min-width: 0;
250
+ overflow: hidden;
251
+ color: var(--stx-grid-header-fg);
252
+ font-variant-numeric: tabular-nums;
253
+ text-overflow: ellipsis;
254
+ white-space: nowrap;
255
+ }
256
+ [data-stx-data-grid] .stx-dg-button {
257
+ flex: 0 0 auto;
258
+ height: 26px;
259
+ padding: 0 10px;
260
+ border: 1px solid var(--stx-grid-line);
261
+ border-radius: var(--stx-radius-control, 6px);
262
+ background: var(--stx-grid-bg);
263
+ color: inherit;
264
+ font: inherit;
265
+ font-size: 12px;
266
+ cursor: pointer;
267
+ }
268
+ [data-stx-data-grid] .stx-dg-button:hover { background: var(--stx-grid-hover); }
269
+
270
+ [data-stx-data-grid] .stx-dg-scroller {
271
+ position: relative;
272
+ flex: 1 1 auto;
273
+ min-height: 0;
274
+ overflow: auto;
275
+ outline: none;
276
+ /* The scroller is its own layer, so a scroll repaints nothing outside it. */
277
+ contain: strict;
278
+ }
279
+ [data-stx-data-grid] .stx-dg-scroller:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--stx-grid-accent) 55%, transparent); }
280
+ [data-stx-data-grid] .stx-dg-content { position: relative; min-width: 100%; }
281
+
282
+ [data-stx-data-grid] .stx-dg-header {
283
+ position: sticky;
284
+ top: 0;
285
+ z-index: 2;
286
+ min-width: 100%;
287
+ height: var(--stx-grid-header-height);
288
+ border-bottom: 1px solid var(--stx-grid-line);
289
+ background: var(--stx-grid-header-bg);
290
+ color: var(--stx-grid-header-fg);
291
+ box-sizing: border-box;
292
+ }
293
+ [data-stx-data-grid] .stx-dg-head {
294
+ position: absolute;
295
+ top: 0;
296
+ display: flex;
297
+ align-items: center;
298
+ gap: 4px;
299
+ height: 100%;
300
+ padding: 0 var(--stx-grid-cell-padding);
301
+ box-sizing: border-box;
302
+ border-right: 1px solid var(--stx-grid-line);
303
+ font-weight: 600;
304
+ white-space: nowrap;
305
+ user-select: none;
306
+ -webkit-user-select: none;
307
+ }
308
+ [data-stx-data-grid] .stx-dg-head[data-sortable] { cursor: pointer; }
309
+ [data-stx-data-grid] .stx-dg-head[data-align="right"] { flex-direction: row-reverse; }
310
+ [data-stx-data-grid] .stx-dg-head[data-align="center"] { justify-content: center; }
311
+ [data-stx-data-grid] .stx-dg-head-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
312
+ [data-stx-data-grid] .stx-dg-sort { flex: 0 0 auto; color: var(--stx-grid-accent); font-size: 9px; font-variant-numeric: tabular-nums; }
313
+ [data-stx-data-grid] .stx-dg-resize {
314
+ position: absolute;
315
+ top: 0;
316
+ right: -4px;
317
+ z-index: 1;
318
+ width: 9px;
319
+ height: 100%;
320
+ cursor: col-resize;
321
+ touch-action: none;
322
+ }
323
+ [data-stx-data-grid] .stx-dg-resize:hover,
324
+ [data-stx-data-grid][data-resizing] .stx-dg-resize:hover { background: linear-gradient(to right, transparent 3px, var(--stx-grid-accent) 3px, var(--stx-grid-accent) 5px, transparent 5px); }
325
+ [data-stx-data-grid][data-resizing] { cursor: col-resize; user-select: none; -webkit-user-select: none; }
326
+
327
+ [data-stx-data-grid] .stx-dg-body { position: relative; min-width: 100%; }
328
+ [data-stx-data-grid] .stx-dg-row {
329
+ position: absolute;
330
+ top: 0;
331
+ left: 0;
332
+ right: 0;
333
+ height: var(--stx-grid-row-height);
334
+ border-bottom: 1px solid var(--stx-grid-line);
335
+ box-sizing: border-box;
336
+ contain: layout style;
337
+ }
338
+ [data-stx-data-grid] .stx-dg-row:hover { background: var(--stx-grid-hover); }
339
+ [data-stx-data-grid] .stx-dg-row[aria-selected="true"] { background: var(--stx-grid-selected); }
340
+
341
+ [data-stx-data-grid] .stx-dg-cell {
342
+ position: absolute;
343
+ top: 0;
344
+ height: 100%;
345
+ padding: 0 var(--stx-grid-cell-padding);
346
+ box-sizing: border-box;
347
+ overflow: hidden;
348
+ line-height: calc(var(--stx-grid-row-height) - 1px);
349
+ text-overflow: ellipsis;
350
+ white-space: pre;
351
+ cursor: default;
352
+ }
353
+ [data-stx-data-grid] .stx-dg-cell[data-align="right"] { text-align: right; }
354
+ [data-stx-data-grid] .stx-dg-cell[data-align="center"] { text-align: center; }
355
+ /* Figures in one column line up digit under digit. */
356
+ [data-stx-data-grid] .stx-dg-cell[data-type="number"] { color: var(--stx-grid-number); font-variant-numeric: tabular-nums; }
357
+ [data-stx-data-grid] .stx-dg-cell[data-type="date"] { font-variant-numeric: tabular-nums; }
358
+ [data-stx-data-grid] .stx-dg-cell[data-type="boolean"] { color: var(--stx-grid-boolean); }
359
+ [data-stx-data-grid] .stx-dg-cell[data-type="json"] { font-family: var(--stx-grid-mono); font-size: 12px; }
360
+ [data-stx-data-grid] .stx-dg-cell[data-empty] { color: var(--stx-grid-empty-fg); font-style: italic; }
361
+
362
+ /* The active cell is only marked while the grid has the keyboard. */
363
+ [data-stx-data-grid] .stx-dg-scroller:focus :is(.stx-dg-cell, .stx-dg-head)[data-active] {
364
+ outline: 2px solid var(--stx-grid-accent);
365
+ outline-offset: -2px;
366
+ }
367
+
368
+ [data-stx-data-grid][data-empty] .stx-dg-body::after {
369
+ content: 'No rows';
370
+ position: sticky;
371
+ left: 0;
372
+ display: block;
373
+ padding: 16px var(--stx-grid-cell-padding);
374
+ color: var(--stx-grid-empty-fg);
375
+ }
376
+ </style>