@pretable/ui 0.10.0 → 0.12.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 +1 -1
- package/dist/index.cjs +57 -24
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -3
- package/dist/index.d.cts.map +1 -0
- package/dist/{index.d.ts → index.d.mts} +5 -3
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +56 -22
- package/dist/index.mjs.map +1 -0
- package/{dist/grid.css → grid.css} +958 -14
- package/package.json +26 -18
- /package/{dist/grid.css.d.ts → grid.css.d.ts} +0 -0
- /package/{dist/tailwind.css → tailwind.css} +0 -0
- /package/{dist/tailwind.css.d.ts → tailwind.css.d.ts} +0 -0
- /package/{dist/themes → themes}/excel.css +0 -0
- /package/{dist/themes → themes}/excel.css.d.ts +0 -0
- /package/{dist/themes → themes}/material.css +0 -0
- /package/{dist/themes → themes}/material.css.d.ts +0 -0
- /package/{dist/themes → themes}/pretable.css +0 -0
- /package/{dist/themes → themes}/pretable.css.d.ts +0 -0
- /package/{dist/tokens.css → tokens.css} +0 -0
- /package/{dist/tokens.css.d.ts → tokens.css.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The fallbacks are hard-coded in [`src/density.ts`](./src/density.ts) and apply o
|
|
|
61
61
|
|
|
62
62
|
`@pretable/react` reads a third token in JS, `--pretable-group-panel-height`, and only while the drag-to-group panel is enabled. `getDensityHeights` does not cover it; the remaining 47 tokens never enter JavaScript at all.
|
|
63
63
|
|
|
64
|
-
The full 50-token set is defined by the theme files in [`
|
|
64
|
+
The full 50-token set is defined by the package-root theme files in [`themes/`](./themes/); the [token reference](https://pretable.ai/docs/theming/token-reference) lists every name with its per-theme value. Override any token at `:root` or on a scoped element to change the look.
|
|
65
65
|
|
|
66
66
|
### Data-attribute hooks
|
|
67
67
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,30 +1,63 @@
|
|
|
1
|
-
'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var FALLBACK_HEADER_HEIGHT = 36;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region src/density.ts
|
|
3
|
+
const FALLBACK_ROW_HEIGHT = 32;
|
|
4
|
+
const FALLBACK_HEADER_HEIGHT = 36;
|
|
6
5
|
function parsePx(value) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return match ? parseFloat(match[1]) : null;
|
|
6
|
+
const match = value.trim().match(/^([\d.]+)px$/);
|
|
7
|
+
return match ? parseFloat(match[1]) : null;
|
|
10
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Synchronous snapshot of the resolved density-related CSS variables, read
|
|
11
|
+
* from `element` — or from `document.documentElement` when none is given.
|
|
12
|
+
*
|
|
13
|
+
* Returns `{ rowHeight, headerHeight }` parsed from `--pretable-row-height`
|
|
14
|
+
* and `--pretable-header-height`. Falls back to 32 / 36 when a variable is
|
|
15
|
+
* unset, empty, or not parseable as a `<number>px` value.
|
|
16
|
+
*
|
|
17
|
+
* ## Which element to pass
|
|
18
|
+
*
|
|
19
|
+
* These are CSS custom properties, so they INHERIT. Passing an element resolves
|
|
20
|
+
* the value that element actually paints under, which is what a `data-density`
|
|
21
|
+
* scoped to a wrapper (`<div data-density="compact">…`) sets — the root's own
|
|
22
|
+
* computed style never sees it. Passing nothing reads the root, which is right
|
|
23
|
+
* only when the density attribute lives on `<html>`.
|
|
24
|
+
*
|
|
25
|
+
* Pass the element whose geometry you are computing — the grid's own DOM node,
|
|
26
|
+
* or any descendant of the scoping wrapper. `@pretable/react` passes the grid's
|
|
27
|
+
* scroll viewport, so a wrapper-scoped grid measures at the density it paints
|
|
28
|
+
* at.
|
|
29
|
+
*
|
|
30
|
+
* A detached element resolves nothing in most browsers; read it after mount.
|
|
31
|
+
*
|
|
32
|
+
* SSR-safe: returns the fallback values when `document` is undefined, and when
|
|
33
|
+
* `element` is `null` or `undefined` and there is no document to fall back to.
|
|
34
|
+
*
|
|
35
|
+
* For non-React consumers, tests, custom virtualizers, and power users. This
|
|
36
|
+
* is the only public way to read density into JavaScript: `@pretable/react`'s
|
|
37
|
+
* reactive equivalent is internal, so a React caller that needs the values to
|
|
38
|
+
* follow a theme or density swap wraps this in its own `useSyncExternalStore`
|
|
39
|
+
* — the docs at `/docs/grid/density-helpers` carry the recipe.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
11
43
|
function getDensityHeights(element) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
44
|
+
var _parsePx, _parsePx2;
|
|
45
|
+
const target = element !== null && element !== void 0 ? element : typeof document === "undefined" ? null : document.documentElement;
|
|
46
|
+
if (target === null || typeof getComputedStyle !== "function") return {
|
|
47
|
+
rowHeight: FALLBACK_ROW_HEIGHT,
|
|
48
|
+
headerHeight: FALLBACK_HEADER_HEIGHT
|
|
49
|
+
};
|
|
50
|
+
const styles = getComputedStyle(target);
|
|
51
|
+
const read = (name) => {
|
|
52
|
+
if (typeof (styles === null || styles === void 0 ? void 0 : styles.getPropertyValue) !== "function") return "";
|
|
53
|
+
return styles.getPropertyValue(name);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
rowHeight: (_parsePx = parsePx(read("--pretable-row-height"))) !== null && _parsePx !== void 0 ? _parsePx : FALLBACK_ROW_HEIGHT,
|
|
57
|
+
headerHeight: (_parsePx2 = parsePx(read("--pretable-header-height"))) !== null && _parsePx2 !== void 0 ? _parsePx2 : FALLBACK_HEADER_HEIGHT
|
|
58
|
+
};
|
|
28
59
|
}
|
|
29
60
|
|
|
61
|
+
//#endregion
|
|
30
62
|
exports.getDensityHeights = getDensityHeights;
|
|
63
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/density.ts"],"sourcesContent":["const FALLBACK_ROW_HEIGHT = 32;\nconst FALLBACK_HEADER_HEIGHT = 36;\n\n/**\n * Density-related heights (in CSS pixels) read from the active theme.\n *\n * @public\n */\nexport interface DensityHeights {\n rowHeight: number;\n headerHeight: number;\n}\n\nfunction parsePx(value: string): number | null {\n const trimmed = value.trim();\n const match = trimmed.match(/^([\\d.]+)px$/);\n return match ? parseFloat(match[1]) : null;\n}\n\n/**\n * Synchronous snapshot of the resolved density-related CSS variables, read\n * from `element` — or from `document.documentElement` when none is given.\n *\n * Returns `{ rowHeight, headerHeight }` parsed from `--pretable-row-height`\n * and `--pretable-header-height`. Falls back to 32 / 36 when a variable is\n * unset, empty, or not parseable as a `<number>px` value.\n *\n * ## Which element to pass\n *\n * These are CSS custom properties, so they INHERIT. Passing an element resolves\n * the value that element actually paints under, which is what a `data-density`\n * scoped to a wrapper (`<div data-density=\"compact\">…`) sets — the root's own\n * computed style never sees it. Passing nothing reads the root, which is right\n * only when the density attribute lives on `<html>`.\n *\n * Pass the element whose geometry you are computing — the grid's own DOM node,\n * or any descendant of the scoping wrapper. `@pretable/react` passes the grid's\n * scroll viewport, so a wrapper-scoped grid measures at the density it paints\n * at.\n *\n * A detached element resolves nothing in most browsers; read it after mount.\n *\n * SSR-safe: returns the fallback values when `document` is undefined, and when\n * `element` is `null` or `undefined` and there is no document to fall back to.\n *\n * For non-React consumers, tests, custom virtualizers, and power users. This\n * is the only public way to read density into JavaScript: `@pretable/react`'s\n * reactive equivalent is internal, so a React caller that needs the values to\n * follow a theme or density swap wraps this in its own `useSyncExternalStore`\n * — the docs at `/docs/grid/density-helpers` carry the recipe.\n *\n * @public\n */\nexport function getDensityHeights(element?: Element | null): DensityHeights {\n const target =\n element ??\n (typeof document === \"undefined\" ? null : document.documentElement);\n if (target === null || typeof getComputedStyle !== \"function\") {\n return {\n rowHeight: FALLBACK_ROW_HEIGHT,\n headerHeight: FALLBACK_HEADER_HEIGHT,\n };\n }\n const styles = getComputedStyle(target);\n // Defensive: some test environments mock getComputedStyle with plain\n // objects that don't implement getPropertyValue. Treat that as \"unset\"\n // and fall back, instead of throwing.\n const read = (name: string): string => {\n if (typeof styles?.getPropertyValue !== \"function\") return \"\";\n return styles.getPropertyValue(name);\n };\n return {\n rowHeight: parsePx(read(\"--pretable-row-height\")) ?? FALLBACK_ROW_HEIGHT,\n headerHeight:\n parsePx(read(\"--pretable-header-height\")) ?? FALLBACK_HEADER_HEIGHT,\n };\n}\n"],"mappings":";;AAAA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAY/B,SAAS,QAAQ,OAA8B;CAE7C,MAAM,QADU,MAAM,KACF,CAAC,CAAC,MAAM,cAAc;CAC1C,OAAO,QAAQ,WAAW,MAAM,EAAE,IAAI;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,SAA0C;;CAC1E,MAAM,SACJ,mDACC,OAAO,aAAa,cAAc,OAAO,SAAS;CACrD,IAAI,WAAW,QAAQ,OAAO,qBAAqB,YACjD,OAAO;EACL,WAAW;EACX,cAAc;CAChB;CAEF,MAAM,SAAS,iBAAiB,MAAM;CAItC,MAAM,QAAQ,SAAyB;EACrC,IAAI,wDAAO,OAAQ,sBAAqB,YAAY,OAAO;EAC3D,OAAO,OAAO,iBAAiB,IAAI;CACrC;CACA,OAAO;EACL,uBAAW,QAAQ,KAAK,uBAAuB,CAAC,gDAAK;EACrD,2BACE,QAAQ,KAAK,0BAA0B,CAAC,kDAAK;CACjD;AACF"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
//#region src/density.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Density-related heights (in CSS pixels) read from the active theme.
|
|
3
4
|
*
|
|
4
5
|
* @public
|
|
5
6
|
*/
|
|
6
7
|
interface DensityHeights {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
rowHeight: number;
|
|
9
|
+
headerHeight: number;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Synchronous snapshot of the resolved density-related CSS variables, read
|
|
@@ -42,5 +43,6 @@ interface DensityHeights {
|
|
|
42
43
|
* @public
|
|
43
44
|
*/
|
|
44
45
|
declare function getDensityHeights(element?: Element | null): DensityHeights;
|
|
45
|
-
|
|
46
|
+
//#endregion
|
|
46
47
|
export { type DensityHeights, getDensityHeights };
|
|
48
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/density.ts"],"mappings":";;;;;;UAQiB;EACf;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Cc,kBAAkB,UAAU,iBAAiB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
//#region src/density.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Density-related heights (in CSS pixels) read from the active theme.
|
|
3
4
|
*
|
|
4
5
|
* @public
|
|
5
6
|
*/
|
|
6
7
|
interface DensityHeights {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
rowHeight: number;
|
|
9
|
+
headerHeight: number;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Synchronous snapshot of the resolved density-related CSS variables, read
|
|
@@ -42,5 +43,6 @@ interface DensityHeights {
|
|
|
42
43
|
* @public
|
|
43
44
|
*/
|
|
44
45
|
declare function getDensityHeights(element?: Element | null): DensityHeights;
|
|
45
|
-
|
|
46
|
+
//#endregion
|
|
46
47
|
export { type DensityHeights, getDensityHeights };
|
|
48
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/density.ts"],"mappings":";;;;;;UAQiB;EACf;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2Cc,kBAAkB,UAAU,iBAAiB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/density.ts
|
|
2
|
+
const FALLBACK_ROW_HEIGHT = 32;
|
|
3
|
+
const FALLBACK_HEADER_HEIGHT = 36;
|
|
4
4
|
function parsePx(value) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return match ? parseFloat(match[1]) : null;
|
|
5
|
+
const match = value.trim().match(/^([\d.]+)px$/);
|
|
6
|
+
return match ? parseFloat(match[1]) : null;
|
|
8
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Synchronous snapshot of the resolved density-related CSS variables, read
|
|
10
|
+
* from `element` — or from `document.documentElement` when none is given.
|
|
11
|
+
*
|
|
12
|
+
* Returns `{ rowHeight, headerHeight }` parsed from `--pretable-row-height`
|
|
13
|
+
* and `--pretable-header-height`. Falls back to 32 / 36 when a variable is
|
|
14
|
+
* unset, empty, or not parseable as a `<number>px` value.
|
|
15
|
+
*
|
|
16
|
+
* ## Which element to pass
|
|
17
|
+
*
|
|
18
|
+
* These are CSS custom properties, so they INHERIT. Passing an element resolves
|
|
19
|
+
* the value that element actually paints under, which is what a `data-density`
|
|
20
|
+
* scoped to a wrapper (`<div data-density="compact">…`) sets — the root's own
|
|
21
|
+
* computed style never sees it. Passing nothing reads the root, which is right
|
|
22
|
+
* only when the density attribute lives on `<html>`.
|
|
23
|
+
*
|
|
24
|
+
* Pass the element whose geometry you are computing — the grid's own DOM node,
|
|
25
|
+
* or any descendant of the scoping wrapper. `@pretable/react` passes the grid's
|
|
26
|
+
* scroll viewport, so a wrapper-scoped grid measures at the density it paints
|
|
27
|
+
* at.
|
|
28
|
+
*
|
|
29
|
+
* A detached element resolves nothing in most browsers; read it after mount.
|
|
30
|
+
*
|
|
31
|
+
* SSR-safe: returns the fallback values when `document` is undefined, and when
|
|
32
|
+
* `element` is `null` or `undefined` and there is no document to fall back to.
|
|
33
|
+
*
|
|
34
|
+
* For non-React consumers, tests, custom virtualizers, and power users. This
|
|
35
|
+
* is the only public way to read density into JavaScript: `@pretable/react`'s
|
|
36
|
+
* reactive equivalent is internal, so a React caller that needs the values to
|
|
37
|
+
* follow a theme or density swap wraps this in its own `useSyncExternalStore`
|
|
38
|
+
* — the docs at `/docs/grid/density-helpers` carry the recipe.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
9
42
|
function getDensityHeights(element) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
43
|
+
var _parsePx, _parsePx2;
|
|
44
|
+
const target = element !== null && element !== void 0 ? element : typeof document === "undefined" ? null : document.documentElement;
|
|
45
|
+
if (target === null || typeof getComputedStyle !== "function") return {
|
|
46
|
+
rowHeight: FALLBACK_ROW_HEIGHT,
|
|
47
|
+
headerHeight: FALLBACK_HEADER_HEIGHT
|
|
48
|
+
};
|
|
49
|
+
const styles = getComputedStyle(target);
|
|
50
|
+
const read = (name) => {
|
|
51
|
+
if (typeof (styles === null || styles === void 0 ? void 0 : styles.getPropertyValue) !== "function") return "";
|
|
52
|
+
return styles.getPropertyValue(name);
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
rowHeight: (_parsePx = parsePx(read("--pretable-row-height"))) !== null && _parsePx !== void 0 ? _parsePx : FALLBACK_ROW_HEIGHT,
|
|
56
|
+
headerHeight: (_parsePx2 = parsePx(read("--pretable-header-height"))) !== null && _parsePx2 !== void 0 ? _parsePx2 : FALLBACK_HEADER_HEIGHT
|
|
57
|
+
};
|
|
26
58
|
}
|
|
27
59
|
|
|
60
|
+
//#endregion
|
|
28
61
|
export { getDensityHeights };
|
|
62
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/density.ts"],"sourcesContent":["const FALLBACK_ROW_HEIGHT = 32;\nconst FALLBACK_HEADER_HEIGHT = 36;\n\n/**\n * Density-related heights (in CSS pixels) read from the active theme.\n *\n * @public\n */\nexport interface DensityHeights {\n rowHeight: number;\n headerHeight: number;\n}\n\nfunction parsePx(value: string): number | null {\n const trimmed = value.trim();\n const match = trimmed.match(/^([\\d.]+)px$/);\n return match ? parseFloat(match[1]) : null;\n}\n\n/**\n * Synchronous snapshot of the resolved density-related CSS variables, read\n * from `element` — or from `document.documentElement` when none is given.\n *\n * Returns `{ rowHeight, headerHeight }` parsed from `--pretable-row-height`\n * and `--pretable-header-height`. Falls back to 32 / 36 when a variable is\n * unset, empty, or not parseable as a `<number>px` value.\n *\n * ## Which element to pass\n *\n * These are CSS custom properties, so they INHERIT. Passing an element resolves\n * the value that element actually paints under, which is what a `data-density`\n * scoped to a wrapper (`<div data-density=\"compact\">…`) sets — the root's own\n * computed style never sees it. Passing nothing reads the root, which is right\n * only when the density attribute lives on `<html>`.\n *\n * Pass the element whose geometry you are computing — the grid's own DOM node,\n * or any descendant of the scoping wrapper. `@pretable/react` passes the grid's\n * scroll viewport, so a wrapper-scoped grid measures at the density it paints\n * at.\n *\n * A detached element resolves nothing in most browsers; read it after mount.\n *\n * SSR-safe: returns the fallback values when `document` is undefined, and when\n * `element` is `null` or `undefined` and there is no document to fall back to.\n *\n * For non-React consumers, tests, custom virtualizers, and power users. This\n * is the only public way to read density into JavaScript: `@pretable/react`'s\n * reactive equivalent is internal, so a React caller that needs the values to\n * follow a theme or density swap wraps this in its own `useSyncExternalStore`\n * — the docs at `/docs/grid/density-helpers` carry the recipe.\n *\n * @public\n */\nexport function getDensityHeights(element?: Element | null): DensityHeights {\n const target =\n element ??\n (typeof document === \"undefined\" ? null : document.documentElement);\n if (target === null || typeof getComputedStyle !== \"function\") {\n return {\n rowHeight: FALLBACK_ROW_HEIGHT,\n headerHeight: FALLBACK_HEADER_HEIGHT,\n };\n }\n const styles = getComputedStyle(target);\n // Defensive: some test environments mock getComputedStyle with plain\n // objects that don't implement getPropertyValue. Treat that as \"unset\"\n // and fall back, instead of throwing.\n const read = (name: string): string => {\n if (typeof styles?.getPropertyValue !== \"function\") return \"\";\n return styles.getPropertyValue(name);\n };\n return {\n rowHeight: parsePx(read(\"--pretable-row-height\")) ?? FALLBACK_ROW_HEIGHT,\n headerHeight:\n parsePx(read(\"--pretable-header-height\")) ?? FALLBACK_HEADER_HEIGHT,\n };\n}\n"],"mappings":";AAAA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAY/B,SAAS,QAAQ,OAA8B;CAE7C,MAAM,QADU,MAAM,KACF,CAAC,CAAC,MAAM,cAAc;CAC1C,OAAO,QAAQ,WAAW,MAAM,EAAE,IAAI;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,SAA0C;;CAC1E,MAAM,SACJ,mDACC,OAAO,aAAa,cAAc,OAAO,SAAS;CACrD,IAAI,WAAW,QAAQ,OAAO,qBAAqB,YACjD,OAAO;EACL,WAAW;EACX,cAAc;CAChB;CAEF,MAAM,SAAS,iBAAiB,MAAM;CAItC,MAAM,QAAQ,SAAyB;EACrC,IAAI,wDAAO,OAAQ,sBAAqB,YAAY,OAAO;EAC3D,OAAO,OAAO,iBAAiB,IAAI;CACrC;CACA,OAAO;EACL,uBAAW,QAAQ,KAAK,uBAAuB,CAAC,gDAAK;EACrD,2BACE,QAAQ,KAAK,0BAA0B,CAAC,kDAAK;CACjD;AACF"}
|