@sportsdataverse/sdvtables 0.1.0 → 0.2.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/README.md +70 -112
- package/data/table_themes.json +12136 -0
- package/data/table_themes.json.sha256 +1 -0
- package/dist/aggrid.d.ts +104 -0
- package/dist/aggrid.js +230 -0
- package/dist/aggrid.js.map +1 -0
- package/dist/chunk-3TJR7TKS.js +223 -0
- package/dist/chunk-3TJR7TKS.js.map +1 -0
- package/dist/{chunk-UCRLJGDL.js → chunk-R375P3MN.js} +963 -276
- package/dist/chunk-R375P3MN.js.map +1 -0
- package/dist/chunk-UTOVFIFT.js +15176 -0
- package/dist/chunk-UTOVFIFT.js.map +1 -0
- package/dist/{chunk-U6W6MWKW.js → chunk-VLF2S6VW.js} +7 -5
- package/dist/chunk-VLF2S6VW.js.map +1 -0
- package/dist/chunk-WBTFIGYK.js +189 -0
- package/dist/chunk-WBTFIGYK.js.map +1 -0
- package/dist/{engine-CkfxYXAL.d.ts → engine-BFIPJUlC.d.ts} +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +4 -3
- package/dist/export.js.map +1 -1
- package/dist/html.d.ts +8 -5
- package/dist/html.js +4 -3
- package/dist/index.d.ts +121 -8
- package/dist/index.js +51 -3
- package/dist/index.js.map +1 -1
- package/dist/mui.d.ts +134 -0
- package/dist/mui.js +193 -0
- package/dist/mui.js.map +1 -0
- package/dist/react.d.ts +2 -2
- package/dist/react.js +3 -2
- package/dist/react.js.map +1 -1
- package/dist/spec-A88vJX5A.d.ts +748 -0
- package/dist/tanstack-table.d.ts +113 -0
- package/dist/tanstack-table.js +98 -0
- package/dist/tanstack-table.js.map +1 -0
- package/dist/{tokens-CpYFsFtf.d.ts → tokens-CHwBt9gs.d.ts} +1 -1
- package/package.json +40 -3
- package/dist/chunk-4VKYHOHL.js +0 -2081
- package/dist/chunk-4VKYHOHL.js.map +0 -1
- package/dist/chunk-U6W6MWKW.js.map +0 -1
- package/dist/chunk-UCRLJGDL.js.map +0 -1
- package/dist/spec-BEhLDtj_.d.ts +0 -430
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as ColumnBase, C as ColumnSpec, N as NumericKey, T as TableSpec, D as Density, c as Decoration,
|
|
2
|
-
export { A as Align, d as
|
|
1
|
+
import { b as ColumnBase, C as ColumnSpec, N as NumericKey, P as Predicate, S as SeriesKey, T as TableSpec, D as Density, c as Decoration, R as RowSelector, a as ThemeRef } from './spec-A88vJX5A.js';
|
|
2
|
+
export { A as Align, B as BarTextPosition, d as ColorRefOpts, e as ColumnKind, f as DecorationType, F as FormatType, I as IconName, L as LegendIconDecoration, g as LegendIconShape, M as MarkOpts, h as NumberFormat, i as PredicateOp, j as SeriesBand, k as SeriesChartOpts, l as SeriesHighlight, m as SeriesPoint, n as SeriesStat, o as StringKey, p as TeamOpts, q as TextStyle } from './spec-A88vJX5A.js';
|
|
3
3
|
import { SdvplotError } from '@sportsdataverse/sdvplot';
|
|
4
4
|
export { RowFilter } from '@sportsdataverse/sdvplot';
|
|
5
|
-
import { a as ThemeDef, T as Theme } from './tokens-
|
|
6
|
-
export { D as DENSITY, G as GoogleFont, b as TOKEN_KEYS, c as ThemeTokens } from './tokens-
|
|
7
|
-
export { C as Comparator, F as FilterValue, N as NUMERIC_KINDS, S as Sort, b as SortDir, a as Table, T as TableCursor, d as TableEvent, e as TableOptions, f as TableSnapshot, g as TableState, V as ValuePredicate, h as applyFilters, i as applySort, j as comparatorFor, c as createTable, k as findColumn, l as isMissing, n as nextSortDir, p as paginate, w as withMissingLast } from './engine-
|
|
5
|
+
import { a as ThemeDef, T as Theme } from './tokens-CHwBt9gs.js';
|
|
6
|
+
export { D as DENSITY, G as GoogleFont, b as TOKEN_KEYS, c as ThemeTokens } from './tokens-CHwBt9gs.js';
|
|
7
|
+
export { C as Comparator, F as FilterValue, N as NUMERIC_KINDS, S as Sort, b as SortDir, a as Table, T as TableCursor, d as TableEvent, e as TableOptions, f as TableSnapshot, g as TableState, V as ValuePredicate, h as applyFilters, i as applySort, j as comparatorFor, c as createTable, k as findColumn, l as isMissing, n as nextSortDir, p as paginate, w as withMissingLast } from './engine-BFIPJUlC.js';
|
|
8
8
|
|
|
9
9
|
declare class TableSpecError extends SdvplotError {
|
|
10
10
|
}
|
|
@@ -31,12 +31,35 @@ interface ColumnFactory<Row> {
|
|
|
31
31
|
colorResults<K extends keyof Row & string>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "colorResults">, never>>): Col<Row, "colorResults">;
|
|
32
32
|
percentileBar<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "percentileBar">, never>>): Col<Row, "percentileBar">;
|
|
33
33
|
indicatorBox<K extends keyof Row & string>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "indicatorBox">, never>>): Col<Row, "indicatorBox">;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Mark the cells that match `when` (a predicate), or pass `"min"` / `"max"` / `"both"` to mark the column's extremes
|
|
36
|
+
* (reactablefmtr `highlight_min` / `highlight_max` / `highlight_min_max`: bold, red min and green max, no fill).
|
|
37
|
+
*/
|
|
38
|
+
highlight<K extends keyof Row & string>(key: K, when: Predicate<Row> | "min" | "max" | "both", o?: Base<Row, K> & Partial<Opt<Col<Row, "highlight">, "when" | "extreme">>): Col<Row, "highlight">;
|
|
35
39
|
highlightNa<K extends keyof Row & string>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "highlightNa">, never>>): Col<Row, "highlightNa">;
|
|
36
40
|
mergeStackTeamColor<K extends keyof Row & string>(key: K, stack: keyof Row & string, team: keyof Row & string, o: Base<Row, K> & Partialize<Opt<Col<Row, "mergeStackTeamColor">, "stack" | "team">, "league">): Col<Row, "mergeStackTeamColor">;
|
|
37
41
|
teamColorBar<K extends keyof Row & string>(key: K, o: Base<Row, K> & Partialize<Opt<Col<Row, "teamColorBar">, never>, "league">): Col<Row, "teamColorBar">;
|
|
38
42
|
teamColorBg<K extends keyof Row & string>(key: K, o: Base<Row, K> & Partialize<Opt<Col<Row, "teamColorBg">, never>, "league">): Col<Row, "teamColorBg">;
|
|
39
43
|
image<K extends keyof Row & string>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "image">, never>>): Col<Row, "image">;
|
|
44
|
+
/** reactablefmtr `data_bars` (defaults: fill `#15607A`, track `#EEEEEE`, text inside the bar's end, 18px bars). */
|
|
45
|
+
dataBar<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "dataBar">, never>>): Col<Row, "dataBar">;
|
|
46
|
+
/** reactablefmtr `icon_sets` (defaults: one circle, colours `#15607A` / `#B0B0B0` / `#FA8C00`, icon right, 16px). */
|
|
47
|
+
iconSet<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "iconSet">, never>>): Col<Row, "iconSet">;
|
|
48
|
+
/** reactablefmtr `icon_assign` (defaults: circles, fill `#15607A`, empty `#EEEEEE`, 16px, no value shown). */
|
|
49
|
+
iconAssign<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "iconAssign">, never>>): Col<Row, "iconAssign">;
|
|
50
|
+
/** reactablefmtr `merge_column`: `key` (14px bold) with `stack` (12px `#777`) to its right by default. */
|
|
51
|
+
mergeStack<K extends keyof Row & string>(key: K, stack: keyof Row & string, o?: Base<Row, K> & Partial<Opt<Col<Row, "mergeStack">, "stack">>): Col<Row, "mergeStack">;
|
|
52
|
+
/** reactablefmtr `bubble_grid` (defaults: circles, colours `#15607A` / `#FFFFFF` / `#FA8C00`, 100px at the max). */
|
|
53
|
+
bubble<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "bubble">, never>>): Col<Row, "bubble">;
|
|
54
|
+
/**
|
|
55
|
+
* reactablefmtr `react_sparkline` on an array column (defaults: `slategray`, 1.5px line, `chartWidth` 100 x 22px (taller with labels), not sortable;
|
|
56
|
+
* `statline` / `bandline` red, labels 0.8em with 0 decimals).
|
|
57
|
+
*/
|
|
58
|
+
sparkline<K extends SeriesKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "sparkline">, never>>): Col<Row, "sparkline">;
|
|
59
|
+
/** reactablefmtr `react_sparkbar` on an array column (defaults: `slategray` bars, 100 x 22px, not sortable). */
|
|
60
|
+
sparkbar<K extends SeriesKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "sparkbar">, never>>): Col<Row, "sparkbar">;
|
|
61
|
+
/** reactablefmtr `gauge_chart` (defaults: fill `#15607A`, track `#EEEEEE`, size 1 = 50px wide, scale 0 to max |value|). */
|
|
62
|
+
gauge<K extends NumericKey<Row>>(key: K, o?: Base<Row, K> & Partial<Opt<Col<Row, "gauge">, never>>): Col<Row, "gauge">;
|
|
40
63
|
/** gtUtils aliases — same objects, old names (see src/aliases.ts). */
|
|
41
64
|
fmtRank: ColumnFactory<Row>["rank"];
|
|
42
65
|
fmtTally: ColumnFactory<Row>["tally"];
|
|
@@ -86,6 +109,10 @@ declare class TableBuilder<Row> {
|
|
|
86
109
|
snake(o?: Partial<Omit<D<Row, "snake">, "type">>): TableBuilder<Row>;
|
|
87
110
|
tiers(levels: readonly string[], tierKey: keyof Row & string, imageColumns: readonly (keyof Row & string)[], o?: Partial<Omit<D<Row, "tiers">, "type" | "levels" | "tierKey" | "imageColumns">>): TableBuilder<Row>;
|
|
88
111
|
font(family: string, o?: Partial<Omit<D<Row, "font">, "type" | "family">>): TableBuilder<Row>;
|
|
112
|
+
/**
|
|
113
|
+
* reactablefmtr `add_icon_legend`: icons with labels, by default right-aligned below the table.
|
|
114
|
+
*/
|
|
115
|
+
legendIcon(o?: Partial<Omit<D<Row, "legendIcon">, "type">>): TableBuilder<Row>;
|
|
89
116
|
build(): TableSpec<Row>;
|
|
90
117
|
}
|
|
91
118
|
/**
|
|
@@ -129,6 +156,92 @@ declare const THEMES: Readonly<Record<string, ThemeDef>>;
|
|
|
129
156
|
declare const THEME_NAMES: readonly string[];
|
|
130
157
|
declare function resolveTheme(ref: ThemeRef): Theme;
|
|
131
158
|
|
|
159
|
+
/** The 27 reactablefmtr themes' sdvtables names (`fmtr-cerulean` ... `fmtr-void`), for `themePreview`. */
|
|
160
|
+
declare const FMTR_THEME_NAMES: readonly string[];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Resolve a surveyed registry theme (e.g. `datagolf`, `wikipedia`, `nejm`) by its source name.
|
|
164
|
+
*
|
|
165
|
+
* @param ref - theme name, density, and `options.mode` (`"light"` default, or `"dark"`).
|
|
166
|
+
* @returns the {@link Theme}; structure features with no token (heat, delta, spanners ...) are ignored here.
|
|
167
|
+
* @throws TableSpecError for an unknown name, or `mode: "dark"` on a light-only theme.
|
|
168
|
+
*/
|
|
169
|
+
declare function registryTheme(ref: ThemeRef): Theme;
|
|
170
|
+
/** The keys of a resolved registry palette: each a `#rrggbb` colour. */
|
|
171
|
+
type TableThemePaletteKey = "page" | "bg" | "text" | "muted" | "accent" | "rule" | "hline" | "labelBg" | "labelColor" | "stripe" | "summaryBg" | "link" | "pos" | "neg" | "posBg" | "negBg" | "heatLow" | "heatMid" | "heatHigh";
|
|
172
|
+
/**
|
|
173
|
+
* One registry theme resolved in one mode, as Python's `table_theme_spec` returns it (its `TableThemeSpec`, with
|
|
174
|
+
* `dark_policy` as `darkPolicy`): the surveyed fonts and sizes, the palette complete (a key the theme omits takes the
|
|
175
|
+
* shared default), and the structure with every `{key}` in its border strings taken from the palette.
|
|
176
|
+
*/
|
|
177
|
+
interface TableThemeSpec {
|
|
178
|
+
/** The registry id, e.g. "datagolf". */
|
|
179
|
+
readonly id: string;
|
|
180
|
+
/** The surveyed source's name, e.g. "DataGolf". */
|
|
181
|
+
readonly source: string;
|
|
182
|
+
/** "journal", "library", "finance", "news", "sports", "gov" or "periodical". */
|
|
183
|
+
readonly category: string;
|
|
184
|
+
/** The faces (Google Fonts families) and their weights. */
|
|
185
|
+
readonly fonts: {
|
|
186
|
+
readonly title: string;
|
|
187
|
+
readonly titleWeight: number;
|
|
188
|
+
readonly label: string;
|
|
189
|
+
readonly labelWeight: number;
|
|
190
|
+
readonly body: string;
|
|
191
|
+
readonly bodyWeight: number;
|
|
192
|
+
readonly numeric: string;
|
|
193
|
+
readonly subtitle: string;
|
|
194
|
+
readonly subtitleItalic: boolean;
|
|
195
|
+
};
|
|
196
|
+
/** Font sizes and cell padding, in px. */
|
|
197
|
+
readonly sizes: {
|
|
198
|
+
readonly title: number;
|
|
199
|
+
readonly subtitle: number;
|
|
200
|
+
readonly label: number;
|
|
201
|
+
readonly body: number;
|
|
202
|
+
readonly source: number;
|
|
203
|
+
readonly padY: number;
|
|
204
|
+
readonly padX: number;
|
|
205
|
+
};
|
|
206
|
+
/** The mode's colours, complete: a key the theme omits takes the shared default. */
|
|
207
|
+
readonly palette: Readonly<Record<TableThemePaletteKey, string>>;
|
|
208
|
+
/** Rules, borders, stripes, heat and the rest, as the registry has them, border strings substituted. */
|
|
209
|
+
readonly structure: Readonly<Record<string, unknown>>;
|
|
210
|
+
/** "native" (the site has a dark mode), "derived" (sdv's own dark palette) or "none" (light only). */
|
|
211
|
+
readonly darkPolicy: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolve a surveyed registry theme (e.g. `datagolf`, `wikipedia`, `nejm`) to its fonts, sizes, palette and structure,
|
|
215
|
+
* as Python's `table_theme_spec` does. Pass it, resolved in the same `mode`, as `perspectiveConfig`'s `theme`
|
|
216
|
+
* (`@sportsdataverse/sdvplot/perspective`).
|
|
217
|
+
*
|
|
218
|
+
* @param name - the theme id, as `listTableThemes()` lists it. "espn", "fivethirtyeight" and "pff" are reactablefmtr
|
|
219
|
+
* ports (the `fmtr-espn` theme and so on), not registry ids; the surveyed look of those sites is "espn-site" and so on.
|
|
220
|
+
* @param mode - "light" (default) or "dark".
|
|
221
|
+
* @returns a new spec on every call: changing one changes no other.
|
|
222
|
+
* @throws TableSpecError for an unknown `mode`, an unknown name (with up to 3 close matches), a reactablefmtr name, or
|
|
223
|
+
* "dark" on a light-only theme (naming three dark-capable themes in its category).
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { tableThemeSpec } from "@sportsdataverse/sdvtables";
|
|
228
|
+
*
|
|
229
|
+
* const spec = tableThemeSpec("datagolf", "dark");
|
|
230
|
+
* [spec.palette.bg, spec.fonts.body, spec.sizes.body];
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
declare function tableThemeSpec(name: string, mode?: "light" | "dark"): TableThemeSpec;
|
|
234
|
+
/** List registry themes, optionally only those usable in `mode` (non-`none` darkPolicy for dark) or in a `category`. */
|
|
235
|
+
declare function listTableThemes(filter?: {
|
|
236
|
+
mode?: "light" | "dark";
|
|
237
|
+
category?: string;
|
|
238
|
+
}): {
|
|
239
|
+
id: string;
|
|
240
|
+
source: string;
|
|
241
|
+
category: string;
|
|
242
|
+
darkPolicy: string;
|
|
243
|
+
}[];
|
|
244
|
+
|
|
132
245
|
/** sdvplotR .theme_secondary_on() (_marks.py:619-628): fg blended toward bg as far as still clears 4.5:1 (weights 0.45 + i*0.05, unrounded). */
|
|
133
246
|
declare function secondaryOn(bg: string, fg: string, target?: number): string;
|
|
134
247
|
|
|
@@ -138,7 +251,7 @@ interface Alias {
|
|
|
138
251
|
readonly status: "ported" | "phase-5" | "not-ported";
|
|
139
252
|
readonly note?: string;
|
|
140
253
|
}
|
|
141
|
-
/** sdvplotR/gtUtils function name → sdvtables equivalent. */
|
|
254
|
+
/** sdvplotR/gtUtils (and reactablefmtr) function name → sdvtables equivalent. */
|
|
142
255
|
declare const GT_ALIASES: Readonly<Record<string, Alias>>;
|
|
143
256
|
/** Look up the sdvtables equivalent of an sdvplotR/gtUtils function name. */
|
|
144
257
|
declare const aliasFor: (name: string) => Alias | undefined;
|
|
@@ -148,4 +261,4 @@ declare const PAL_MIDNIGHT: readonly string[];
|
|
|
148
261
|
/** The package version, injected from package.json at build time. */
|
|
149
262
|
declare const VERSION: string;
|
|
150
263
|
|
|
151
|
-
export { type Alias, ColumnBase, type ColumnFactory, ColumnSpec, Decoration, Density, GT_ALIASES, NumericKey, PAL_MIDNIGHT, Predicate, RANK_PALETTE, RowSelector, THEMES, THEME_NAMES, TableBuilder, TableSpec, TableSpecError, Theme, ThemeDef, ThemeRef, VERSION, aliasFor, columnFactory, defineTable, matches, resolveTheme, secondaryOn, selectRows, snakeAlign };
|
|
264
|
+
export { type Alias, ColumnBase, type ColumnFactory, ColumnSpec, Decoration, Density, FMTR_THEME_NAMES, GT_ALIASES, NumericKey, PAL_MIDNIGHT, Predicate, RANK_PALETTE, RowSelector, SeriesKey, THEMES, THEME_NAMES, TableBuilder, TableSpec, TableSpecError, type TableThemePaletteKey, type TableThemeSpec, Theme, ThemeDef, ThemeRef, VERSION, aliasFor, columnFactory, defineTable, listTableThemes, matches, registryTheme, resolveTheme, secondaryOn, selectRows, snakeAlign, tableThemeSpec };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DENSITY, NUMERIC_KINDS, RANK_PALETTE, THEMES, THEME_NAMES, TOKEN_KEYS, TableBuilder, TableSpecError, applyFilters, applySort, columnFactory, comparatorFor, createTable, defineTable, findColumn, isMissing, matches, nextSortDir, paginate, resolveTheme, secondaryOn, selectRows, snakeAlign, withMissingLast } from './chunk-
|
|
1
|
+
export { DENSITY, FMTR_THEME_NAMES, NUMERIC_KINDS, RANK_PALETTE, THEMES, THEME_NAMES, TOKEN_KEYS, TableBuilder, TableSpecError, applyFilters, applySort, columnFactory, comparatorFor, createTable, defineTable, findColumn, isMissing, listTableThemes, matches, nextSortDir, paginate, registryTheme, resolveTheme, secondaryOn, selectRows, snakeAlign, tableThemeSpec, withMissingLast } from './chunk-UTOVFIFT.js';
|
|
2
2
|
|
|
3
3
|
// src/aliases.ts
|
|
4
4
|
var T = (target, note) => note ? { target, status: "ported", note } : { target, status: "ported" };
|
|
@@ -80,13 +80,61 @@ var GT_ALIASES = {
|
|
|
80
80
|
reactable_sdv_headshots: T("c.headshot"),
|
|
81
81
|
reactable_sdv_cols_label: { target: "labelHtml", status: "not-ported", note: "as gt_sdv_cols_label" },
|
|
82
82
|
reactable_sdv_team_color_bar: T("c.teamColorBar"),
|
|
83
|
-
reactable_sdv_team_color_bg: T("c.teamColorBg")
|
|
83
|
+
reactable_sdv_team_color_bg: T("c.teamColorBg"),
|
|
84
|
+
// reactablefmtr 2.1.0 themes (its own function names) and add_icon_legend
|
|
85
|
+
cerulean: T("theme.fmtr-cerulean"),
|
|
86
|
+
clean: T("theme.fmtr-clean"),
|
|
87
|
+
cosmo: T("theme.fmtr-cosmo"),
|
|
88
|
+
cyborg: T("theme.fmtr-cyborg"),
|
|
89
|
+
dark: T("theme.fmtr-dark"),
|
|
90
|
+
darkly: T("theme.fmtr-darkly"),
|
|
91
|
+
default: T("theme.fmtr-default"),
|
|
92
|
+
espn: T("theme.fmtr-espn"),
|
|
93
|
+
fivethirtyeight: T("theme.fmtr-fivethirtyeight"),
|
|
94
|
+
flatly: T("theme.fmtr-flatly"),
|
|
95
|
+
hoverdark: T("theme.fmtr-hoverdark"),
|
|
96
|
+
hoverlight: T("theme.fmtr-hoverlight"),
|
|
97
|
+
journal: T("theme.fmtr-journal"),
|
|
98
|
+
lux: T("theme.fmtr-lux"),
|
|
99
|
+
midnight: T("theme.fmtr-midnight"),
|
|
100
|
+
midnightblue: T("theme.fmtr-midnightblue"),
|
|
101
|
+
minty: T("theme.fmtr-minty"),
|
|
102
|
+
no_lines: T("theme.fmtr-no-lines"),
|
|
103
|
+
nytimes: T("theme.fmtr-nytimes"),
|
|
104
|
+
pff: T("theme.fmtr-pff"),
|
|
105
|
+
sandstone: T("theme.fmtr-sandstone"),
|
|
106
|
+
sanfran: T("theme.fmtr-sanfran"),
|
|
107
|
+
slate: T("theme.fmtr-slate"),
|
|
108
|
+
spacelab: T("theme.fmtr-spacelab"),
|
|
109
|
+
sunrise: T("theme.fmtr-sunrise"),
|
|
110
|
+
superhero: T("theme.fmtr-superhero"),
|
|
111
|
+
void: T("theme.fmtr-void"),
|
|
112
|
+
add_icon_legend: T("builder.legendIcon", "SVG icons, no Font Awesome"),
|
|
113
|
+
// reactablefmtr 2.1.0 cell formatters (Tier 1 of the reactablefmtr parity spec)
|
|
114
|
+
data_bars: T("c.dataBar", "fill_color_ref -> colorRef or team + league; img -> mark"),
|
|
115
|
+
icon_sets: T("c.iconSet", "inline-SVG icons (ICON_NAMES), not Font Awesome"),
|
|
116
|
+
icon_assign: T("c.iconAssign", "inline-SVG icons (ICON_NAMES), not Font Awesome"),
|
|
117
|
+
merge_column: T("c.mergeStack", "merged_name -> stack; mark adds a logo, wordmark or headshot"),
|
|
118
|
+
bubble_grid: T("c.bubble"),
|
|
119
|
+
// reactablefmtr 2.1.0 in-cell charts (Tier 2): inline SVG, not the dataui htmlwidget
|
|
120
|
+
react_sparkline: T(
|
|
121
|
+
"c.sparkline",
|
|
122
|
+
"line_color_ref -> colorRef or team + league; straight segments, no per-point tooltips"
|
|
123
|
+
),
|
|
124
|
+
react_sparkbar: T("c.sparkbar", "fill_color_ref -> colorRef or team + league; bars rooted at zero"),
|
|
125
|
+
gauge_chart: T("c.gauge", "fill_color_ref -> colorRef or team + league; an SVG arc"),
|
|
126
|
+
color_tiles: T("c.colorRanks", "colorRef, bias, span, showText, evenBreaks"),
|
|
127
|
+
color_scales: T("c.colorRanks", "colorRanks fills the whole cell, as color_scales does"),
|
|
128
|
+
pill_buttons: T("c.colorPills", "colorRef or team for a per-row colour"),
|
|
129
|
+
highlight_min: T("c.highlight", 'when "min"'),
|
|
130
|
+
highlight_max: T("c.highlight", 'when "max"'),
|
|
131
|
+
highlight_min_max: T("c.highlight", 'when "both"')
|
|
84
132
|
};
|
|
85
133
|
var aliasFor = (name) => GT_ALIASES[name];
|
|
86
134
|
var PAL_MIDNIGHT = ["#5B8DEF", "#3FBF87", "#E8E9ED", "#9498A3", "#24272E"];
|
|
87
135
|
|
|
88
136
|
// src/index.ts
|
|
89
|
-
var VERSION = "0.
|
|
137
|
+
var VERSION = "0.2.0";
|
|
90
138
|
|
|
91
139
|
export { GT_ALIASES, PAL_MIDNIGHT, VERSION, aliasFor };
|
|
92
140
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/aliases.ts","../src/index.ts"],"names":[],"mappings":";;;AASA,IAAM,CAAA,GAAI,CAAC,MAAA,EAAgB,IAAA,KACzB,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAU,IAAA,EAAK,GAAI,EAAE,MAAA,EAAQ,QAAQ,QAAA,EAAS;AAElE,IAAM,UAAA,GAA8C;AAAA,EACzD,YAAA,EAAc,EAAE,QAAQ,CAAA;AAAA,EACxB,gBAAA,EAAkB,EAAE,YAAY,CAAA;AAAA,EAChC,gBAAA,EAAkB,EAAE,YAAY,CAAA;AAAA,EAChC,iBAAA,EAAmB;AAAA,IACjB,MAAA,EAAQ,WAAA;AAAA,IACR,MAAA,EAAQ,YAAA;AAAA,IACR,IAAA,EAAM;AAAA,GACR;AAAA,EACA,yBAAA,EAA2B,EAAE,uBAAuB,CAAA;AAAA,EACpD,YAAA,EAAc,EAAE,WAAW,CAAA;AAAA,EAC3B,iBAAA,EAAmB,EAAE,eAAe,CAAA;AAAA,EACpC,gBAAA,EAAkB,EAAE,eAAe,CAAA;AAAA,EACnC,iBAAA,EAAmB,EAAE,gBAAgB,CAAA;AAAA,EACrC,iBAAA,EAAmB,EAAE,gBAAgB,CAAA;AAAA,EACrC,mBAAA,EAAqB,EAAE,kBAAkB,CAAA;AAAA,EACzC,kBAAA,EAAoB,EAAE,iBAAiB,CAAA;AAAA,EACvC,eAAA,EAAiB,EAAE,cAAc,CAAA;AAAA,EACjC,gBAAA,EAAkB,EAAE,eAAe,CAAA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AAQ,YAAA,EAAc,QAAQ,SAAA,EAAU;AAAA,EACzD,cAAA,EAAgB,EAAE,MAAA,EAAQ,YAAA,EAAc,QAAQ,SAAA,EAAU;AAAA,EAC1D,OAAA,EAAS,EAAE,MAAA,EAAQ,YAAA,EAAc,QAAQ,SAAA,EAAU;AAAA,EACnD,eAAA,EAAiB,EAAE,MAAA,EAAQ,aAAA,EAAe,QAAQ,SAAA,EAAU;AAAA,EAC5D,mBAAA,EAAqB,EAAE,QAAQ,CAAA;AAAA,EAC/B,uBAAA,EAAyB,EAAE,YAAY,CAAA;AAAA,EACvC,uBAAA,EAAyB,EAAE,YAAY,CAAA;AAAA,EACvC,0BAA0B,EAAE,MAAA,EAAQ,aAAa,MAAA,EAAQ,YAAA,EAAc,MAAM,sBAAA,EAAuB;AAAA,EACpG,4BAAA,EAA8B,EAAE,gBAAgB,CAAA;AAAA,EAChD,2BAAA,EAA6B,EAAE,eAAe;AAChD;AAEO,IAAM,QAAA,GAAW,CAAC,IAAA,KAAoC,UAAA,CAAW,IAAI;AAErE,IAAM,eAAkC,CAAC,SAAA,EAAW,SAAA,EAAW,SAAA,EAAW,WAAW,SAAS;;;AC9F9F,IAAM,OAAA,GAAkB","file":"index.js","sourcesContent":["// src/aliases.ts — every sdvplotR gt_* / pal_* / reactable_sdv_* export (74, sdvplotR NAMESPACE) → its sdvtables target.\n// Target forms: \"c.<kind>\" (column factory), \"builder.<method>\" (TableBuilder), \"theme.<name>\" (THEME_NAMES),\n// \"html.<export>\" (the ./html subpath), a bare root export (\"snakeAlign\", \"PAL_MIDNIGHT\"), or a Phase 5 name.\n/** One sdvplotR/gtUtils name and where it lives in sdvtables. */\nexport interface Alias {\n readonly target: string;\n readonly status: \"ported\" | \"phase-5\" | \"not-ported\";\n readonly note?: string;\n}\nconst T = (target: string, note?: string): Alias =>\n note ? { target, status: \"ported\", note } : { target, status: \"ported\" };\n/** sdvplotR/gtUtils function name → sdvtables equivalent. */\nexport const GT_ALIASES: Readonly<Record<string, Alias>> = {\n gt_sdv_logos: T(\"c.logo\"),\n gt_sdv_wordmarks: T(\"c.wordmark\"),\n gt_sdv_headshots: T(\"c.headshot\"),\n gt_sdv_cols_label: {\n target: \"labelHtml\",\n status: \"not-ported\",\n note: \"labels are text in Phase 4; use .titleHeader() or subheader\",\n },\n gt_merge_stack_team_color: T(\"c.mergeStackTeamColor\"),\n gt_theme_sdv: T(\"theme.sdv\"),\n gt_theme_sdv_team: T(\"theme.sdvTeam\"),\n gt_theme_almanac: T(\"theme.almanac\"),\n gt_theme_athletic: T(\"theme.athletic\"),\n gt_theme_booktabs: T(\"theme.booktabs\"),\n gt_theme_broadsheet: T(\"theme.broadsheet\"),\n gt_theme_brutalist: T(\"theme.brutalist\"),\n gt_theme_drench: T(\"theme.drench\"),\n gt_theme_gtutils: T(\"theme.gtutils\"),\n gt_theme_kenpom: T(\"theme.kenpom\"),\n gt_theme_midnight: T(\"theme.midnight\"),\n gt_theme_ncaa: T(\"theme.ncaa\"),\n gt_theme_pl: T(\"theme.pl\"),\n gt_theme_savant: T(\"theme.savant\"),\n gt_theme_scoreboard: T(\"theme.scoreboard\"),\n gt_theme_sofa: T(\"theme.sofa\"),\n gt_theme_swiss: T(\"theme.swiss\"),\n gt_theme_terminal: T(\"theme.terminal\"),\n gt_theme_tier: T(\"theme.tier\"),\n gt_theme_tufte: T(\"theme.tufte\"),\n gt_theme_preview: T(\"html.themePreview\", \"a Record<name, html>, not a grid\"),\n pal_midnight: T(\"PAL_MIDNIGHT\"),\n gt_538_caption: T(\"builder.caption538\"),\n gt_bold_rows: T(\"builder.boldRows\"),\n gt_border_bars_top: T(\"builder.borderBars\"),\n gt_border_bars_bottom: T(\"builder.borderBars\"),\n gt_border_grid: T(\"builder.borderGrid\"),\n gt_color_pills: T(\"c.colorPills\"),\n gt_color_ranks: T(\"c.colorRanks\"),\n gt_color_results: T(\"c.colorResults\", \"a column kind (spec §6.1) that fills its row\"),\n gt_column_subheaders: T(\"builder.columns\", \"the per-column subheader option of every c.* kind\"),\n gt_cutline: T(\"builder.cutline\"),\n gt_delta: T(\"c.delta\"),\n gt_fmt_rank: T(\"c.rank\"),\n gt_fmt_tally: T(\"c.tally\"),\n gt_group_stripes: T(\"builder.groupStripes\"),\n gt_highlight_cells: T(\"c.highlight\", \"data predicate, not a formula\"),\n gt_highlight_na: T(\"c.highlightNa\"),\n gt_indicator_boxes: T(\"c.indicatorBox\", \"value list, not a rule\"),\n gt_legend_continuous: T(\"builder.legendContinuous\"),\n gt_legend_discrete: T(\"builder.legendDiscrete\"),\n gt_color_legend: T(\"builder.legendContinuous\", \"deprecated gtUtils name (sdvplotR deprecated.R:20)\"),\n gt_centered_legend: T(\"builder.legendDiscrete\", \"deprecated gtUtils name (sdvplotR deprecated.R:27)\"),\n gt_marginalia: T(\"builder.marginalia\"),\n gt_outliers: T(\"builder.outliers\"),\n gt_percentile_bar: T(\"c.percentileBar\"),\n gt_row_accent: T(\"builder.rowAccent\"),\n gt_scale_note: T(\"builder.scaleNote\"),\n gt_set_font: T(\"builder.font\"),\n gt_significance: T(\"builder.significance\"),\n gt_snake: T(\"builder.snake\"),\n gt_snake_align: T(\"snakeAlign\"),\n gt_social_tag: T(\"builder.socialTag\"),\n gt_spotlight: T(\"builder.spotlight\"),\n gt_tiers: T(\"builder.tiers\"),\n gt_title_header: T(\"builder.titleHeader\"),\n gt_watermark: T(\"builder.watermark\"),\n gt_wrap_labels: T(\"builder.wrapLabels\"),\n gt_save_crop: { target: \"tableToPNG\", status: \"phase-5\" },\n gt_save_batch: { target: \"tableToPNG\", status: \"phase-5\" },\n gt_social_crop: { target: \"socialCrop\", status: \"phase-5\" },\n gt_grid: { target: \"gridTables\", status: \"phase-5\" },\n gt_stack_tables: { target: \"stackTables\", status: \"phase-5\" },\n reactable_sdv_logos: T(\"c.logo\"),\n reactable_sdv_wordmarks: T(\"c.wordmark\"),\n reactable_sdv_headshots: T(\"c.headshot\"),\n reactable_sdv_cols_label: { target: \"labelHtml\", status: \"not-ported\", note: \"as gt_sdv_cols_label\" },\n reactable_sdv_team_color_bar: T(\"c.teamColorBar\"),\n reactable_sdv_team_color_bg: T(\"c.teamColorBg\"),\n};\n/** Look up the sdvtables equivalent of an sdvplotR/gtUtils function name. */\nexport const aliasFor = (name: string): Alias | undefined => GT_ALIASES[name];\n/** The five-colour midnight palette (same values as sdvplotR `pal_midnight()`). */\nexport const PAL_MIDNIGHT: readonly string[] = [\"#5B8DEF\", \"#3FBF87\", \"#E8E9ED\", \"#9498A3\", \"#24272E\"];\n","/** The package version, injected from package.json at build time. */\nexport const VERSION: string = __SDVTABLES_VERSION__;\n// The renderer, themePreview, styleSheet and prepare live under ./html.\nexport type * from \"./spec.js\";\nexport { TableSpecError } from \"./errors.js\";\nexport { type ColumnFactory, RANK_PALETTE, TableBuilder, columnFactory, defineTable } from \"./define.js\";\nexport { matches, selectRows } from \"./predicate.js\";\nexport { snakeAlign } from \"./snake.js\";\nexport { THEMES, THEME_NAMES, resolveTheme } from \"./themes/index.js\";\nexport type { GoogleFont, Theme, ThemeDef, ThemeTokens } from \"./themes/index.js\";\nexport { DENSITY, TOKEN_KEYS } from \"./themes/tokens.js\";\nexport { secondaryOn } from \"./themes/sdv.js\";\nexport { type Alias, GT_ALIASES, PAL_MIDNIGHT, aliasFor } from \"./aliases.js\";\nexport {\n NUMERIC_KINDS,\n applyFilters,\n applySort,\n comparatorFor,\n createTable,\n findColumn,\n isMissing,\n nextSortDir,\n paginate,\n withMissingLast,\n} from \"./engine.js\";\nexport type {\n Comparator,\n FilterValue,\n RowFilter,\n Sort,\n SortDir,\n Table,\n TableCursor,\n TableEvent,\n TableOptions,\n TableSnapshot,\n TableState,\n ValuePredicate,\n} from \"./engine.js\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/aliases.ts","../src/index.ts"],"names":[],"mappings":";;;AAUA,IAAM,CAAA,GAAI,CAAC,MAAA,EAAgB,IAAA,KACzB,OAAO,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA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AC/I9F,IAAM,OAAA,GAAkB","file":"index.js","sourcesContent":["// src/aliases.ts — every sdvplotR gt_* / pal_* / reactable_sdv_* export (74, sdvplotR NAMESPACE), and the reactablefmtr\n// cell formatters, themes and add_icon_legend → their sdvtables targets.\n// Target forms: \"c.<kind>\" (column factory), \"builder.<method>\" (TableBuilder), \"theme.<name>\" (THEME_NAMES),\n// \"html.<export>\" (the ./html subpath), a bare root export (\"snakeAlign\", \"PAL_MIDNIGHT\"), or a Phase 5 name.\n/** One sdvplotR/gtUtils name and where it lives in sdvtables. */\nexport interface Alias {\n readonly target: string;\n readonly status: \"ported\" | \"phase-5\" | \"not-ported\";\n readonly note?: string;\n}\nconst T = (target: string, note?: string): Alias =>\n note ? { target, status: \"ported\", note } : { target, status: \"ported\" };\n/** sdvplotR/gtUtils (and reactablefmtr) function name → sdvtables equivalent. */\nexport const GT_ALIASES: Readonly<Record<string, Alias>> = {\n gt_sdv_logos: T(\"c.logo\"),\n gt_sdv_wordmarks: T(\"c.wordmark\"),\n gt_sdv_headshots: T(\"c.headshot\"),\n gt_sdv_cols_label: {\n target: \"labelHtml\",\n status: \"not-ported\",\n note: \"labels are text in Phase 4; use .titleHeader() or subheader\",\n },\n gt_merge_stack_team_color: T(\"c.mergeStackTeamColor\"),\n gt_theme_sdv: T(\"theme.sdv\"),\n gt_theme_sdv_team: T(\"theme.sdvTeam\"),\n gt_theme_almanac: T(\"theme.almanac\"),\n gt_theme_athletic: T(\"theme.athletic\"),\n gt_theme_booktabs: T(\"theme.booktabs\"),\n gt_theme_broadsheet: T(\"theme.broadsheet\"),\n gt_theme_brutalist: T(\"theme.brutalist\"),\n gt_theme_drench: T(\"theme.drench\"),\n gt_theme_gtutils: T(\"theme.gtutils\"),\n gt_theme_kenpom: T(\"theme.kenpom\"),\n gt_theme_midnight: T(\"theme.midnight\"),\n gt_theme_ncaa: T(\"theme.ncaa\"),\n gt_theme_pl: T(\"theme.pl\"),\n gt_theme_savant: T(\"theme.savant\"),\n gt_theme_scoreboard: T(\"theme.scoreboard\"),\n gt_theme_sofa: T(\"theme.sofa\"),\n gt_theme_swiss: T(\"theme.swiss\"),\n gt_theme_terminal: T(\"theme.terminal\"),\n gt_theme_tier: T(\"theme.tier\"),\n gt_theme_tufte: T(\"theme.tufte\"),\n gt_theme_preview: T(\"html.themePreview\", \"a Record<name, html>, not a grid\"),\n pal_midnight: T(\"PAL_MIDNIGHT\"),\n gt_538_caption: T(\"builder.caption538\"),\n gt_bold_rows: T(\"builder.boldRows\"),\n gt_border_bars_top: T(\"builder.borderBars\"),\n gt_border_bars_bottom: T(\"builder.borderBars\"),\n gt_border_grid: T(\"builder.borderGrid\"),\n gt_color_pills: T(\"c.colorPills\"),\n gt_color_ranks: T(\"c.colorRanks\"),\n gt_color_results: T(\"c.colorResults\", \"a column kind (spec §6.1) that fills its row\"),\n gt_column_subheaders: T(\"builder.columns\", \"the per-column subheader option of every c.* kind\"),\n gt_cutline: T(\"builder.cutline\"),\n gt_delta: T(\"c.delta\"),\n gt_fmt_rank: T(\"c.rank\"),\n gt_fmt_tally: T(\"c.tally\"),\n gt_group_stripes: T(\"builder.groupStripes\"),\n gt_highlight_cells: T(\"c.highlight\", \"data predicate, not a formula\"),\n gt_highlight_na: T(\"c.highlightNa\"),\n gt_indicator_boxes: T(\"c.indicatorBox\", \"value list, not a rule\"),\n gt_legend_continuous: T(\"builder.legendContinuous\"),\n gt_legend_discrete: T(\"builder.legendDiscrete\"),\n gt_color_legend: T(\"builder.legendContinuous\", \"deprecated gtUtils name (sdvplotR deprecated.R:20)\"),\n gt_centered_legend: T(\"builder.legendDiscrete\", \"deprecated gtUtils name (sdvplotR deprecated.R:27)\"),\n gt_marginalia: T(\"builder.marginalia\"),\n gt_outliers: T(\"builder.outliers\"),\n gt_percentile_bar: T(\"c.percentileBar\"),\n gt_row_accent: T(\"builder.rowAccent\"),\n gt_scale_note: T(\"builder.scaleNote\"),\n gt_set_font: T(\"builder.font\"),\n gt_significance: T(\"builder.significance\"),\n gt_snake: T(\"builder.snake\"),\n gt_snake_align: T(\"snakeAlign\"),\n gt_social_tag: T(\"builder.socialTag\"),\n gt_spotlight: T(\"builder.spotlight\"),\n gt_tiers: T(\"builder.tiers\"),\n gt_title_header: T(\"builder.titleHeader\"),\n gt_watermark: T(\"builder.watermark\"),\n gt_wrap_labels: T(\"builder.wrapLabels\"),\n gt_save_crop: { target: \"tableToPNG\", status: \"phase-5\" },\n gt_save_batch: { target: \"tableToPNG\", status: \"phase-5\" },\n gt_social_crop: { target: \"socialCrop\", status: \"phase-5\" },\n gt_grid: { target: \"gridTables\", status: \"phase-5\" },\n gt_stack_tables: { target: \"stackTables\", status: \"phase-5\" },\n reactable_sdv_logos: T(\"c.logo\"),\n reactable_sdv_wordmarks: T(\"c.wordmark\"),\n reactable_sdv_headshots: T(\"c.headshot\"),\n reactable_sdv_cols_label: { target: \"labelHtml\", status: \"not-ported\", note: \"as gt_sdv_cols_label\" },\n reactable_sdv_team_color_bar: T(\"c.teamColorBar\"),\n reactable_sdv_team_color_bg: T(\"c.teamColorBg\"),\n // reactablefmtr 2.1.0 themes (its own function names) and add_icon_legend\n cerulean: T(\"theme.fmtr-cerulean\"),\n clean: T(\"theme.fmtr-clean\"),\n cosmo: T(\"theme.fmtr-cosmo\"),\n cyborg: T(\"theme.fmtr-cyborg\"),\n dark: T(\"theme.fmtr-dark\"),\n darkly: T(\"theme.fmtr-darkly\"),\n default: T(\"theme.fmtr-default\"),\n espn: T(\"theme.fmtr-espn\"),\n fivethirtyeight: T(\"theme.fmtr-fivethirtyeight\"),\n flatly: T(\"theme.fmtr-flatly\"),\n hoverdark: T(\"theme.fmtr-hoverdark\"),\n hoverlight: T(\"theme.fmtr-hoverlight\"),\n journal: T(\"theme.fmtr-journal\"),\n lux: T(\"theme.fmtr-lux\"),\n midnight: T(\"theme.fmtr-midnight\"),\n midnightblue: T(\"theme.fmtr-midnightblue\"),\n minty: T(\"theme.fmtr-minty\"),\n no_lines: T(\"theme.fmtr-no-lines\"),\n nytimes: T(\"theme.fmtr-nytimes\"),\n pff: T(\"theme.fmtr-pff\"),\n sandstone: T(\"theme.fmtr-sandstone\"),\n sanfran: T(\"theme.fmtr-sanfran\"),\n slate: T(\"theme.fmtr-slate\"),\n spacelab: T(\"theme.fmtr-spacelab\"),\n sunrise: T(\"theme.fmtr-sunrise\"),\n superhero: T(\"theme.fmtr-superhero\"),\n void: T(\"theme.fmtr-void\"),\n add_icon_legend: T(\"builder.legendIcon\", \"SVG icons, no Font Awesome\"),\n // reactablefmtr 2.1.0 cell formatters (Tier 1 of the reactablefmtr parity spec)\n data_bars: T(\"c.dataBar\", \"fill_color_ref -> colorRef or team + league; img -> mark\"),\n icon_sets: T(\"c.iconSet\", \"inline-SVG icons (ICON_NAMES), not Font Awesome\"),\n icon_assign: T(\"c.iconAssign\", \"inline-SVG icons (ICON_NAMES), not Font Awesome\"),\n merge_column: T(\"c.mergeStack\", \"merged_name -> stack; mark adds a logo, wordmark or headshot\"),\n bubble_grid: T(\"c.bubble\"),\n // reactablefmtr 2.1.0 in-cell charts (Tier 2): inline SVG, not the dataui htmlwidget\n react_sparkline: T(\n \"c.sparkline\",\n \"line_color_ref -> colorRef or team + league; straight segments, no per-point tooltips\",\n ),\n react_sparkbar: T(\"c.sparkbar\", \"fill_color_ref -> colorRef or team + league; bars rooted at zero\"),\n gauge_chart: T(\"c.gauge\", \"fill_color_ref -> colorRef or team + league; an SVG arc\"),\n color_tiles: T(\"c.colorRanks\", \"colorRef, bias, span, showText, evenBreaks\"),\n color_scales: T(\"c.colorRanks\", \"colorRanks fills the whole cell, as color_scales does\"),\n pill_buttons: T(\"c.colorPills\", \"colorRef or team for a per-row colour\"),\n highlight_min: T(\"c.highlight\", 'when \"min\"'),\n highlight_max: T(\"c.highlight\", 'when \"max\"'),\n highlight_min_max: T(\"c.highlight\", 'when \"both\"'),\n};\n/** Look up the sdvtables equivalent of an sdvplotR/gtUtils function name. */\nexport const aliasFor = (name: string): Alias | undefined => GT_ALIASES[name];\n/** The five-colour midnight palette (same values as sdvplotR `pal_midnight()`). */\nexport const PAL_MIDNIGHT: readonly string[] = [\"#5B8DEF\", \"#3FBF87\", \"#E8E9ED\", \"#9498A3\", \"#24272E\"];\n","/** The package version, injected from package.json at build time. */\nexport const VERSION: string = __SDVTABLES_VERSION__;\n// The renderer, themePreview, styleSheet and prepare live under ./html.\nexport type * from \"./spec.js\";\nexport { TableSpecError } from \"./errors.js\";\nexport { type ColumnFactory, RANK_PALETTE, TableBuilder, columnFactory, defineTable } from \"./define.js\";\nexport { matches, selectRows } from \"./predicate.js\";\nexport { snakeAlign } from \"./snake.js\";\nexport { FMTR_THEME_NAMES, THEMES, THEME_NAMES, resolveTheme } from \"./themes/index.js\";\nexport type { GoogleFont, Theme, ThemeDef, ThemeTokens } from \"./themes/index.js\";\nexport { listTableThemes, registryTheme, tableThemeSpec } from \"./themes/registry.js\";\nexport type { TableThemePaletteKey, TableThemeSpec } from \"./themes/registry.js\";\nexport { DENSITY, TOKEN_KEYS } from \"./themes/tokens.js\";\nexport { secondaryOn } from \"./themes/sdv.js\";\nexport { type Alias, GT_ALIASES, PAL_MIDNIGHT, aliasFor } from \"./aliases.js\";\nexport {\n NUMERIC_KINDS,\n applyFilters,\n applySort,\n comparatorFor,\n createTable,\n findColumn,\n isMissing,\n nextSortDir,\n paginate,\n withMissingLast,\n} from \"./engine.js\";\nexport type {\n Comparator,\n FilterValue,\n RowFilter,\n Sort,\n SortDir,\n Table,\n TableCursor,\n TableEvent,\n TableOptions,\n TableSnapshot,\n TableState,\n ValuePredicate,\n} from \"./engine.js\";\n"]}
|
package/dist/mui.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { League, Which, SeasonInput, IdSystem } from '@sportsdataverse/sdvplot';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { A as Align, T as TableSpec } from './spec-A88vJX5A.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The MUI X Data Grid adapter (`@mui/x-data-grid` 9, the MIT community package only): an sdvtables spec as a
|
|
7
|
+
* `<DataGrid>`'s props. Columns keep sdvtables' number formats, alignment and px widths; logo, wordmark and headshot
|
|
8
|
+
* columns draw their images through `renderCell`; team-coloured rows and cells take sdvplot's team palette with
|
|
9
|
+
* black or white text by contrast; the theme's tokens (fonts, colours, density, stripes) become the grid's `sx`.
|
|
10
|
+
* Pure: MUI is never imported (the props here are structural, read from `@mui/x-data-grid` 9.15 and checked against
|
|
11
|
+
* its own types); React's `createElement` builds the images, so the grid also renders on the server.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** What MUI hands a column's `renderCell` and `cellClassName`: the subset read here. */
|
|
15
|
+
interface GridCellParamsLike<Row> {
|
|
16
|
+
/** The row the cell is in. */
|
|
17
|
+
readonly row: Row;
|
|
18
|
+
/** The cell's value: `row[field]`. */
|
|
19
|
+
readonly value?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** What MUI hands `getRowClassName`: the subset read here. */
|
|
22
|
+
interface GridRowClassParamsLike<Row> {
|
|
23
|
+
/** The row. */
|
|
24
|
+
readonly row: Row;
|
|
25
|
+
/** The row's index on the current page, from 0: odd rows take the theme's stripe. */
|
|
26
|
+
readonly indexRelativeToCurrentPage: number;
|
|
27
|
+
}
|
|
28
|
+
/** One MUI `GridColDef`: the fields this adapter sets. */
|
|
29
|
+
interface SdvGridColDef<Row> {
|
|
30
|
+
/** The row key the column reads. */
|
|
31
|
+
field: string;
|
|
32
|
+
/** The column's label, as the HTML table writes it. */
|
|
33
|
+
headerName: string;
|
|
34
|
+
/** The spec's `subheader`, shown as the header's tooltip. */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** "number" for sdvtables' numeric kinds (MUI then sorts and filters as numbers). */
|
|
37
|
+
type?: "string" | "number";
|
|
38
|
+
align: Align;
|
|
39
|
+
headerAlign: Align;
|
|
40
|
+
/** The spec's px width as a number; other CSS widths are left to MUI (with one warning). */
|
|
41
|
+
width?: number;
|
|
42
|
+
sortable?: boolean;
|
|
43
|
+
filterable?: boolean;
|
|
44
|
+
/** "flex" for image cells, so MUI centres them vertically. */
|
|
45
|
+
display?: "text" | "flex";
|
|
46
|
+
/** Numeric kinds: the cell's number, `null` for a blank or unparseable value (so MUI never reads "" as 0). */
|
|
47
|
+
valueGetter?: (value: never) => number | null;
|
|
48
|
+
/** The cell's text through sdvtables' number formats. */
|
|
49
|
+
valueFormatter?: (value: never) => string;
|
|
50
|
+
/** sdvtables' own sort for the column (its `compare`, else by kind), missing values last in both directions. */
|
|
51
|
+
getSortComparator?: (direction: "asc" | "desc" | null | undefined) => ((a: unknown, b: unknown) => number) | undefined;
|
|
52
|
+
/** A logo, wordmark or headshot image, or a rank with a superscript suffix. */
|
|
53
|
+
renderCell?: (params: GridCellParamsLike<Row>) => ReactElement | string;
|
|
54
|
+
/** A team colour class (`teamColorBg`, `teamColorBar`) styled by the grid's `sx`. */
|
|
55
|
+
cellClassName?: (params: GridCellParamsLike<Row>) => string;
|
|
56
|
+
}
|
|
57
|
+
/** A nested `sx` style object: selectors map to CSS properties (and CSS variables). */
|
|
58
|
+
interface GridSx {
|
|
59
|
+
readonly [selectorOrProperty: string]: string | number | GridSx;
|
|
60
|
+
}
|
|
61
|
+
/** What `dataGridProps` returns: spread it onto `<DataGrid rows={rows} {...props} />`. */
|
|
62
|
+
interface SdvDataGridProps<Row> {
|
|
63
|
+
columns: SdvGridColDef<Row>[];
|
|
64
|
+
/** `String(row[spec.rowKey])`, else the row's index in `rows`; checked unique and not blank when built. */
|
|
65
|
+
getRowId: (row: Row) => string;
|
|
66
|
+
/** The row's team colour class (`teamRows`), else the theme's stripe on odd rows. */
|
|
67
|
+
getRowClassName: (params: GridRowClassParamsLike<Row>) => string;
|
|
68
|
+
/** The theme as MUI X Data Grid styles, plus the team colour classes. */
|
|
69
|
+
sx: GridSx;
|
|
70
|
+
/** The theme's density as MUI's: compact is "compact", comfortable is "standard" and social is "comfortable". */
|
|
71
|
+
density: "compact" | "standard" | "comfortable";
|
|
72
|
+
/** MUI's base row height (MUI multiplies it by the density's factor), tall enough for the tallest image. */
|
|
73
|
+
rowHeight: number;
|
|
74
|
+
}
|
|
75
|
+
/** `dataGridProps` options. */
|
|
76
|
+
interface DataGridPropsOptions<Row> {
|
|
77
|
+
/**
|
|
78
|
+
* Fill each row with its team's colour, from the row's `key` value (an abbreviation, a name or a numeric id).
|
|
79
|
+
* The colours are sdvplot's team palette for the theme's background (`teamColorPalette` from
|
|
80
|
+
* `@sportsdataverse/sdvplot/mui`: 3:1 against it, distinct between teams) laid over it at `alpha` (default 0.4),
|
|
81
|
+
* with black or white text, whichever reads better on the fill. A row whose team is not found keeps the theme.
|
|
82
|
+
*/
|
|
83
|
+
teamRows?: {
|
|
84
|
+
key: keyof Row & string;
|
|
85
|
+
league: League;
|
|
86
|
+
/** "primary" (default) or "secondary". */
|
|
87
|
+
which?: Which;
|
|
88
|
+
/** The fill's opacity over the theme's background, 0 to 1. Default 0.4 (as the `teamColorBg` column). */
|
|
89
|
+
alpha?: number;
|
|
90
|
+
season?: SeasonInput;
|
|
91
|
+
idSystem?: IdSystem;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* An sdvtables spec as MUI X Data Grid props: `<DataGrid rows={rows} {...dataGridProps(spec, rows)} />`.
|
|
96
|
+
*
|
|
97
|
+
* - **Columns**: one `GridColDef` per spec column, with the HTML table's label, alignment and px `width`; numbers
|
|
98
|
+
* (`num`, `int`, `pct`, `rank`) keep sdvtables' formats and sort as numbers.
|
|
99
|
+
* - **Images**: `logo`, `wordmark` and `headshot` columns draw `<img>` cells `height` px tall. A team or player with no
|
|
100
|
+
* image keeps its text, with one warning. Team values may be abbreviations, names or numeric ids.
|
|
101
|
+
* - **Team colours**: `teamColorBg` and `teamColorBar` columns, and whole rows with `teamRows`, take sdvplot's team
|
|
102
|
+
* palette for the theme's background, with black or white text by contrast.
|
|
103
|
+
* - **Theme**: the theme's fonts, colours, header style, rules and stripes as the grid's `sx`, its density as MUI's.
|
|
104
|
+
*
|
|
105
|
+
* Other column kinds (pills, bars, sparklines...) show their plain value, with one warning per kind. Synchronous: call
|
|
106
|
+
* `await prepare(spec)` (`@sportsdataverse/sdvtables/html`) first. Images and colours are worked out once, from
|
|
107
|
+
* `rows`: build the props again (or `useMemo` on `rows`) when the rows change. MIT `@mui/x-data-grid` only: nothing
|
|
108
|
+
* here needs the Pro or Premium packages.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* import { DataGrid } from "@mui/x-data-grid";
|
|
113
|
+
* import { defineTable } from "@sportsdataverse/sdvtables";
|
|
114
|
+
* import { prepare } from "@sportsdataverse/sdvtables/html";
|
|
115
|
+
* import { dataGridProps } from "@sportsdataverse/sdvtables/mui";
|
|
116
|
+
*
|
|
117
|
+
* // 2024 regular season, nflverse games
|
|
118
|
+
* const rows = [
|
|
119
|
+
* { team: "KC", wins: 15, pf: 385, pa: 326 },
|
|
120
|
+
* { team: "BUF", wins: 13, pf: 525, pa: 368 },
|
|
121
|
+
* { team: "LAC", wins: 11, pf: 402, pa: 301 },
|
|
122
|
+
* ];
|
|
123
|
+
* const spec = defineTable<(typeof rows)[number]>()
|
|
124
|
+
* .columns((c) => [c.logo("team", { league: "nfl", height: 28 }), c.int("wins"), c.int("pf"), c.int("pa")])
|
|
125
|
+
* .theme("sdv")
|
|
126
|
+
* .rowKey("team")
|
|
127
|
+
* .build();
|
|
128
|
+
* await prepare(spec);
|
|
129
|
+
* <DataGrid rows={rows} {...dataGridProps(spec, rows, { teamRows: { key: "team", league: "nfl" } })} />;
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare function dataGridProps<Row>(spec: TableSpec<Row>, rows: readonly Row[], o?: DataGridPropsOptions<Row>): SdvDataGridProps<Row>;
|
|
133
|
+
|
|
134
|
+
export { type DataGridPropsOptions, type GridCellParamsLike, type GridRowClassParamsLike, type GridSx, type SdvDataGridProps, type SdvGridColDef, dataGridProps };
|
package/dist/mui.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { opaque, scaleNotes, missingLast, pxWidth, formatterFor, unmapped, teamColorOf, value, checkHeight, headshotUrls, cell, logoMarks, rankParts, teamRowFills, rowIds, tint } from './chunk-WBTFIGYK.js';
|
|
2
|
+
import { alignOf, labelOf, teamNameSync } from './chunk-R375P3MN.js';
|
|
3
|
+
import { resolveTheme, NUMERIC_KINDS, toNumber } from './chunk-UTOVFIFT.js';
|
|
4
|
+
import { hex6, mix, onColor } from '@sportsdataverse/sdvplot';
|
|
5
|
+
import { teamColorPalette } from '@sportsdataverse/sdvplot/mui';
|
|
6
|
+
import { createElement, Fragment } from 'react';
|
|
7
|
+
|
|
8
|
+
var MUI_ROW_HEIGHT = 52;
|
|
9
|
+
var DENSITY = { compact: "compact", comfortable: "standard", social: "comfortable" };
|
|
10
|
+
var FACTOR = { compact: 0.7, standard: 1, comfortable: 1.3 };
|
|
11
|
+
var MUI = {
|
|
12
|
+
fn: "dataGridProps",
|
|
13
|
+
ns: "mui",
|
|
14
|
+
grid: "MUI X Data Grid",
|
|
15
|
+
short: "MUI",
|
|
16
|
+
built: "props"
|
|
17
|
+
};
|
|
18
|
+
var fillClass = (fill) => `sdvt-fill-${fill.slice(1)}`;
|
|
19
|
+
function image(src, alt, height, id, kind) {
|
|
20
|
+
return createElement("img", {
|
|
21
|
+
src,
|
|
22
|
+
alt,
|
|
23
|
+
height,
|
|
24
|
+
style: { height: `${height}px`, width: "auto" },
|
|
25
|
+
"data-sdv-id": id,
|
|
26
|
+
"data-sdv-kind": kind
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function dataGridProps(spec, rows, o = {}) {
|
|
30
|
+
const theme = resolveTheme(spec.theme);
|
|
31
|
+
const t = theme.tokens;
|
|
32
|
+
const bg = opaque(t);
|
|
33
|
+
const fills = /* @__PURE__ */ new Map();
|
|
34
|
+
const bars = /* @__PURE__ */ new Map();
|
|
35
|
+
let tallest = 0;
|
|
36
|
+
const { scaled, labelSuffix } = scaleNotes(spec);
|
|
37
|
+
const columns = spec.columns.map((col) => {
|
|
38
|
+
const align = alignOf(col);
|
|
39
|
+
const sortBy = missingLast(col, rows);
|
|
40
|
+
const def = {
|
|
41
|
+
field: col.key,
|
|
42
|
+
headerName: labelOf(col) + (labelSuffix.get(col.key) ?? ""),
|
|
43
|
+
getSortComparator: (dir) => dir === "asc" || dir === "desc" ? sortBy(dir) : void 0,
|
|
44
|
+
align,
|
|
45
|
+
headerAlign: align,
|
|
46
|
+
...col.subheader === void 0 ? {} : { description: col.subheader },
|
|
47
|
+
...col.sortable === void 0 ? {} : { sortable: col.sortable },
|
|
48
|
+
...col.filterable === void 0 ? {} : { filterable: col.filterable },
|
|
49
|
+
...NUMERIC_KINDS.has(col.kind) ? { type: "number", valueGetter: (v) => toNumber(v) } : {}
|
|
50
|
+
};
|
|
51
|
+
const width = pxWidth(col, MUI);
|
|
52
|
+
if (width !== void 0) def.width = width;
|
|
53
|
+
const format = formatterFor(col, scaled);
|
|
54
|
+
return { ...def, ...format === void 0 ? {} : { valueFormatter: format }, ...kindProps(col) };
|
|
55
|
+
});
|
|
56
|
+
function kindProps(col) {
|
|
57
|
+
switch (col.kind) {
|
|
58
|
+
case "text":
|
|
59
|
+
case "num":
|
|
60
|
+
case "int":
|
|
61
|
+
case "pct":
|
|
62
|
+
return {};
|
|
63
|
+
case "rank":
|
|
64
|
+
return col.superscript ? {
|
|
65
|
+
// the HTML table's superscript suffix: 1<sup>st</sup>
|
|
66
|
+
renderCell: ({ value: v }) => {
|
|
67
|
+
const r = rankParts(v);
|
|
68
|
+
if (r === null) return "";
|
|
69
|
+
const sup = createElement("sup", { style: { fontSize: col.suffixSize } }, r.suffix);
|
|
70
|
+
return createElement(Fragment, null, r.num, sup);
|
|
71
|
+
}
|
|
72
|
+
} : {};
|
|
73
|
+
case "logo":
|
|
74
|
+
case "wordmark": {
|
|
75
|
+
const h = checkHeight(col.height, col.kind);
|
|
76
|
+
tallest = Math.max(tallest, h);
|
|
77
|
+
const marks = logoMarks(col, rows);
|
|
78
|
+
const includeName = col.kind === "logo" && col.includeName;
|
|
79
|
+
const kind = col.kind;
|
|
80
|
+
return {
|
|
81
|
+
display: "flex",
|
|
82
|
+
renderCell: ({ value: raw }) => {
|
|
83
|
+
const text = cell(raw);
|
|
84
|
+
const m = marks.get(text);
|
|
85
|
+
if (m === void 0) return text;
|
|
86
|
+
const img = image(m.url, teamNameSync(col.league, m.id) ?? text, h, m.id, kind);
|
|
87
|
+
return includeName ? createElement(
|
|
88
|
+
"span",
|
|
89
|
+
{ style: { display: "inline-flex", alignItems: "center", gap: "0.4em" } },
|
|
90
|
+
img,
|
|
91
|
+
text
|
|
92
|
+
) : img;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case "headshot": {
|
|
97
|
+
const h = checkHeight(col.height, "headshot");
|
|
98
|
+
tallest = Math.max(tallest, h);
|
|
99
|
+
const urls = headshotUrls(col, rows, MUI);
|
|
100
|
+
return {
|
|
101
|
+
display: "flex",
|
|
102
|
+
renderCell: ({ value: raw }) => {
|
|
103
|
+
const text = cell(raw);
|
|
104
|
+
const url = urls.get(text);
|
|
105
|
+
return url === void 0 ? text : image(url, "", h, text, "headshot");
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
case "teamColorBg":
|
|
110
|
+
case "teamColorBar": {
|
|
111
|
+
const colorOf = teamColorOf(col, rows, bg, teamColorPalette);
|
|
112
|
+
const classOf = (raw) => {
|
|
113
|
+
const color = colorOf(raw);
|
|
114
|
+
if (col.kind === "teamColorBar") {
|
|
115
|
+
const c = hex6(color, { dropAlpha: true });
|
|
116
|
+
const name = `sdvt-bar-${col.barWidth}-${c.slice(1)}`;
|
|
117
|
+
bars.set(name, { width: col.barWidth, color: c });
|
|
118
|
+
return name;
|
|
119
|
+
}
|
|
120
|
+
const f = tint(color, col.alpha, bg);
|
|
121
|
+
fills.set(fillClass(f.fill), f);
|
|
122
|
+
return fillClass(f.fill);
|
|
123
|
+
};
|
|
124
|
+
for (const r of rows) classOf(value(r, col.key));
|
|
125
|
+
return { cellClassName: ({ value: raw }) => classOf(raw) };
|
|
126
|
+
}
|
|
127
|
+
default:
|
|
128
|
+
unmapped(col.kind, MUI);
|
|
129
|
+
return {};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const rowFill = /* @__PURE__ */ new Map();
|
|
133
|
+
if (o.teamRows)
|
|
134
|
+
for (const [v, f] of teamRowFills(rows, o.teamRows, bg, teamColorPalette)) {
|
|
135
|
+
fills.set(fillClass(f.fill), f);
|
|
136
|
+
rowFill.set(v, fillClass(f.fill));
|
|
137
|
+
}
|
|
138
|
+
const striped = t.stripe !== "transparent";
|
|
139
|
+
const getRowClassName = ({ row, indexRelativeToCurrentPage }) => {
|
|
140
|
+
const team = o.teamRows === void 0 ? void 0 : rowFill.get(cell(value(row, o.teamRows.key)));
|
|
141
|
+
return team ?? (striped && indexRelativeToCurrentPage % 2 === 1 ? "sdvt-stripe" : "");
|
|
142
|
+
};
|
|
143
|
+
const getRowId = rowIds(rows, spec.rowKey, MUI);
|
|
144
|
+
const density = DENSITY[spec.theme.density];
|
|
145
|
+
const rowHeight = Math.max(MUI_ROW_HEIGHT, Math.ceil((tallest + 8) / FACTOR[density]));
|
|
146
|
+
return { columns, getRowId, getRowClassName, sx: themeSx(t, fills, bars), density, rowHeight };
|
|
147
|
+
}
|
|
148
|
+
function themeSx(t, fills, bars) {
|
|
149
|
+
const set = (v) => v !== "transparent" && v !== "inherit" && v !== "none";
|
|
150
|
+
const bg = set(t.bg) ? t.bg : void 0;
|
|
151
|
+
const head = set(t.labelBg) ? t.labelBg : bg;
|
|
152
|
+
const vars = {
|
|
153
|
+
"--DataGrid-t-color-foreground-base": t.text,
|
|
154
|
+
"--DataGrid-t-color-foreground-muted": t.muted,
|
|
155
|
+
"--DataGrid-t-color-border-base": t.rule,
|
|
156
|
+
"--DataGrid-t-typography-font-family-base": t.fontBody,
|
|
157
|
+
"--DataGrid-t-typography-font-body": `${t.bodyWeight} ${t.bodySize} ${t.fontBody}`,
|
|
158
|
+
...bg === void 0 ? {} : { "--DataGrid-t-color-background-base": bg, "--DataGrid-t-cell-background-pinned": bg },
|
|
159
|
+
...head === void 0 ? {} : { "--DataGrid-t-header-background-base": head }
|
|
160
|
+
};
|
|
161
|
+
const sx = {
|
|
162
|
+
"&&": vars,
|
|
163
|
+
// MUI's material pieces (pager, icon buttons) read the MUI theme, not the grid's variables: give them the ink
|
|
164
|
+
"& .MuiTablePagination-root, & .MuiIconButton-root": { color: "inherit" },
|
|
165
|
+
"& .MuiDataGrid-columnHeaderTitle": {
|
|
166
|
+
fontFamily: t.fontLabel,
|
|
167
|
+
fontWeight: t.labelWeight,
|
|
168
|
+
fontSize: t.labelSize,
|
|
169
|
+
fontStyle: t.labelStyle,
|
|
170
|
+
textTransform: t.labelTransform,
|
|
171
|
+
letterSpacing: t.labelTracking
|
|
172
|
+
},
|
|
173
|
+
...set(t.labelColor) ? { "& .MuiDataGrid-columnHeader": { color: t.labelColor } } : {},
|
|
174
|
+
...t.stripe === "transparent" ? {} : { "& .MuiDataGrid-row.sdvt-stripe": { backgroundColor: t.stripe } }
|
|
175
|
+
};
|
|
176
|
+
for (const [name, f] of fills) {
|
|
177
|
+
sx[`& .${name}`] = { backgroundColor: f.fill, color: f.ink };
|
|
178
|
+
const shade = (t2) => {
|
|
179
|
+
const c = mix(f.fill, f.ink, t2);
|
|
180
|
+
return { backgroundColor: c, color: onColor(c) };
|
|
181
|
+
};
|
|
182
|
+
sx[`& .MuiDataGrid-row.${name}:hover`] = shade(0.06);
|
|
183
|
+
sx[`& .MuiDataGrid-row.${name}.Mui-selected`] = shade(0.1);
|
|
184
|
+
sx[`& .MuiDataGrid-row.${name}.Mui-selected:hover`] = shade(0.14);
|
|
185
|
+
}
|
|
186
|
+
for (const [name, b] of bars)
|
|
187
|
+
sx[`& .MuiDataGrid-cell.${name}`] = { borderLeft: `${b.width}px solid ${b.color}` };
|
|
188
|
+
return sx;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { dataGridProps };
|
|
192
|
+
//# sourceMappingURL=mui.js.map
|
|
193
|
+
//# sourceMappingURL=mui.js.map
|