@olenbetong/appframe-ds 1.9.1 → 1.9.2
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/scripts/copyAssets.mjs +27 -27
- package/src/AfLookup/LookupGrid.tsx +2 -2
- package/src/grid/index.css +27 -5
- package/src/grid/useAfSizeMode.ts +5 -4
- package/tsconfig.build.json +9 -9
- package/tsconfig.json +8 -8
- package/vitest.config.ts +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @olenbetong/appframe-ds
|
|
2
2
|
|
|
3
|
+
## 1.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2f1516a: AfGrid and the lookup grid take their row height from `--ds-size-11` instead of `--ds-size-10`, so the text no longer crowds the row (about 34px at sm, 28px at xs). AfGrid's text is one step below the size mode's body text, as MUI's compact grid was, except at xs, and inputs in the grid follow it.
|
|
8
|
+
|
|
3
9
|
## 1.9.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/scripts/copyAssets.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* tsc emits the JavaScript into es/ but not the stylesheets the components import next to
|
|
3
|
-
* themselves. Copy every .css under src/ to the same path under es/, so a new component's
|
|
4
|
-
* stylesheet is published without anyone remembering a list.
|
|
5
|
-
*/
|
|
6
|
-
import { cpSync, mkdirSync, readdirSync } from "node:fs";
|
|
7
|
-
import { dirname, join, relative } from "node:path";
|
|
8
|
-
|
|
9
|
-
function* cssFiles(dir) {
|
|
10
|
-
for (let entry of readdirSync(dir, { withFileTypes: true })) {
|
|
11
|
-
let path = join(dir, entry.name);
|
|
12
|
-
if (entry.isDirectory()) {
|
|
13
|
-
yield* cssFiles(path);
|
|
14
|
-
} else if (entry.name.endsWith(".css")) {
|
|
15
|
-
yield path;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let count = 0;
|
|
21
|
-
for (let src of cssFiles("src")) {
|
|
22
|
-
let dest = join("es", relative("src", src));
|
|
23
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
24
|
-
cpSync(src, dest);
|
|
25
|
-
count++;
|
|
26
|
-
}
|
|
27
|
-
console.log(`Copied ${count} stylesheets from src/ to es/`);
|
|
1
|
+
/*
|
|
2
|
+
* tsc emits the JavaScript into es/ but not the stylesheets the components import next to
|
|
3
|
+
* themselves. Copy every .css under src/ to the same path under es/, so a new component's
|
|
4
|
+
* stylesheet is published without anyone remembering a list.
|
|
5
|
+
*/
|
|
6
|
+
import { cpSync, mkdirSync, readdirSync } from "node:fs";
|
|
7
|
+
import { dirname, join, relative } from "node:path";
|
|
8
|
+
|
|
9
|
+
function* cssFiles(dir) {
|
|
10
|
+
for (let entry of readdirSync(dir, { withFileTypes: true })) {
|
|
11
|
+
let path = join(dir, entry.name);
|
|
12
|
+
if (entry.isDirectory()) {
|
|
13
|
+
yield* cssFiles(path);
|
|
14
|
+
} else if (entry.name.endsWith(".css")) {
|
|
15
|
+
yield path;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let count = 0;
|
|
21
|
+
for (let src of cssFiles("src")) {
|
|
22
|
+
let dest = join("es", relative("src", src));
|
|
23
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
24
|
+
cpSync(src, dest);
|
|
25
|
+
count++;
|
|
26
|
+
}
|
|
27
|
+
console.log(`Copied ${count} stylesheets from src/ to es/`);
|
|
@@ -9,7 +9,7 @@ import { List, type RowComponentProps, useListRef } from "react-window";
|
|
|
9
9
|
import { getLocalizedString } from "../i18n.js";
|
|
10
10
|
import { useDsSize } from "../theme/sizeMode.js";
|
|
11
11
|
|
|
12
|
-
/** The row and header height until `--ds-size-
|
|
12
|
+
/** The row and header height until `--ds-size-11` is measured, which follows the size mode like AfGrid's rows. */
|
|
13
13
|
const ROW_HEIGHT = 40;
|
|
14
14
|
/** Narrowest a column can be made, and what a flexible column counts for in the minimum width */
|
|
15
15
|
const MIN_COLUMN_WIDTH = 80;
|
|
@@ -192,7 +192,7 @@ export function LookupGrid<T extends Record<string, unknown>>({
|
|
|
192
192
|
let listRef = useListRef(null);
|
|
193
193
|
let headerRowRef = useRef<HTMLDivElement>(null);
|
|
194
194
|
let rootRef = useRef<HTMLDivElement>(null);
|
|
195
|
-
let rowHeight = useDsSize(rootRef,
|
|
195
|
+
let rowHeight = useDsSize(rootRef, 11, ROW_HEIGHT);
|
|
196
196
|
let [resizedWidths, setResizedWidths] = useState<Partial<Record<string, number>>>({});
|
|
197
197
|
let [resizing, setResizing] = useState<{ field: string; startWidth: number } | null>(null);
|
|
198
198
|
let [listInnerWidth, setListInnerWidth] = useState<number>();
|
package/src/grid/index.css
CHANGED
|
@@ -4,11 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* The grid follows the Designsystemet size mode it sits in instead of MUI's density and type
|
|
7
|
-
* scale
|
|
8
|
-
*
|
|
7
|
+
* scale, and its row and header heights come from the same mode (`useAfSizeMode`). Its text is
|
|
8
|
+
* one step below the mode's body text - at sm that is MUI's compact grid text - except at xs,
|
|
9
|
+
* where the body text is already that small. The size is picked on the element that sets the
|
|
10
|
+
* mode, so the closest one wins; the components that use `data-size` for a variant of their own
|
|
11
|
+
* are left out, as in `getSizeMode`. Without a size mode the grid inherits the page's text.
|
|
9
12
|
*/
|
|
13
|
+
[data-size]:not(.ds-heading, .ds-paragraph, .ds-spinner, .ds-avatar) {
|
|
14
|
+
--AfGrid-font-size: var(--ds-body-sm-font-size);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-size="xs"]:not(.ds-heading, .ds-paragraph, .ds-spinner, .ds-avatar) {
|
|
18
|
+
--AfGrid-font-size: var(--ds-body-md-font-size);
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
.AfGrid-root .MuiDataGrid-root {
|
|
11
|
-
font-size: inherit;
|
|
22
|
+
font-size: var(--AfGrid-font-size, inherit);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Inputs in the grid - cell editors, header filters - take the grid's text size rather than the
|
|
27
|
+
* mode's body text. Only where there is a mouse, so a touch device keeps Designsystemet's floor
|
|
28
|
+
* that stops iOS zooming in on a focused field (see the site's xs rule).
|
|
29
|
+
*/
|
|
30
|
+
@media (hover: hover) and (pointer: fine) {
|
|
31
|
+
.AfGrid-root .MuiDataGrid-root .ds-input {
|
|
32
|
+
--dsc-input-font-size: 1em;
|
|
33
|
+
}
|
|
12
34
|
}
|
|
13
35
|
|
|
14
36
|
/*
|
|
@@ -30,13 +52,13 @@
|
|
|
30
52
|
|
|
31
53
|
/*
|
|
32
54
|
* Controls in a data cell - editors, lookup buttons, the row's action buttons - fit the row, which
|
|
33
|
-
* is `--ds-size-
|
|
55
|
+
* is `--ds-size-11` tall, rather than taking Designsystemet's `--ds-size-12` control height, which
|
|
34
56
|
* would overflow it at every size. The custom properties are set on the components themselves,
|
|
35
57
|
* so they are overridden there and not on the cell.
|
|
36
58
|
*/
|
|
37
59
|
.AfGrid-root .MuiDataGrid-cell {
|
|
38
60
|
.ds-input {
|
|
39
|
-
--dsc-input-size: var(--ds-size-
|
|
61
|
+
--dsc-input-size: var(--ds-size-11, 2.25rem);
|
|
40
62
|
--dsc-input-padding-block: 0;
|
|
41
63
|
}
|
|
42
64
|
|
|
@@ -7,13 +7,14 @@ const FALLBACK_HEIGHT = 36;
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Row and header heights from the Designsystemet size mode the grid sits in, in place of MUI's
|
|
10
|
-
* density: `--ds-size-
|
|
11
|
-
* site's 14px root
|
|
12
|
-
*
|
|
10
|
+
* density: `--ds-size-11`, which is about 28px at xs, 34px at sm, 39px at md and 45px at lg with
|
|
11
|
+
* the site's 14px root - close to Designsystemet's own table at each size. `--ds-size-10` left the
|
|
12
|
+
* text crowded in its row. The grid renders at the standard density, so these are the heights as
|
|
13
|
+
* they are. The text, toolbar and footer follow the same size mode through the stylesheet and by
|
|
13
14
|
* inheriting `data-size`.
|
|
14
15
|
*/
|
|
15
16
|
export function useAfSizeMode(rootRef: RefObject<HTMLElement | null>) {
|
|
16
|
-
let height = useDsSize(rootRef,
|
|
17
|
+
let height = useDsSize(rootRef, 11, FALLBACK_HEIGHT);
|
|
17
18
|
|
|
18
19
|
return { rowHeight: height, columnHeaderHeight: height };
|
|
19
20
|
}
|
package/tsconfig.build.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.build.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./es"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src"],
|
|
8
|
-
"exclude": ["es", "node_modules"]
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.build.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./es"
|
|
6
|
+
},
|
|
7
|
+
"include": ["src"],
|
|
8
|
+
"exclude": ["es", "node_modules"]
|
|
9
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.build.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./es"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src"]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.build.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./es"
|
|
6
|
+
},
|
|
7
|
+
"include": ["src"]
|
|
8
|
+
}
|
package/vitest.config.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
include: ["src/**/*.test.tsx", "src/**/*.test.ts"],
|
|
6
|
-
environment: "happy-dom",
|
|
7
|
-
setupFiles: ["src/test/setup.ts"],
|
|
8
|
-
env: { NODE_ENV: "test" },
|
|
9
|
-
},
|
|
10
|
-
});
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
include: ["src/**/*.test.tsx", "src/**/*.test.ts"],
|
|
6
|
+
environment: "happy-dom",
|
|
7
|
+
setupFiles: ["src/test/setup.ts"],
|
|
8
|
+
env: { NODE_ENV: "test" },
|
|
9
|
+
},
|
|
10
|
+
});
|