@blueprintjs/labs 6.1.7 → 6.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/lib/cjs/components/box/box.test.js +19 -12
- package/lib/cjs/components/box/box.test.js.map +1 -1
- package/lib/cjs/components/box/boxProps.d.ts +28 -0
- package/lib/cjs/components/box/buildStyles.js +6 -0
- package/lib/cjs/components/box/buildStyles.js.map +1 -1
- package/lib/cjs/components/flex/flex.test.js +8 -8
- package/lib/cjs/components/flex/flex.test.js.map +1 -1
- package/lib/cjs/components/slot/slot.test.js +6 -6
- package/lib/cjs/components/slot/slot.test.js.map +1 -1
- package/lib/css/blueprint-labs.css +30 -0
- package/lib/css/blueprint-labs.css.map +1 -1
- package/lib/esm/components/box/box.test.js +19 -12
- package/lib/esm/components/box/box.test.js.map +1 -1
- package/lib/esm/components/box/boxProps.d.ts +28 -0
- package/lib/esm/components/box/buildStyles.js +6 -0
- package/lib/esm/components/box/buildStyles.js.map +1 -1
- package/lib/esm/components/flex/flex.test.js +8 -8
- package/lib/esm/components/flex/flex.test.js.map +1 -1
- package/lib/esm/components/slot/slot.test.js +6 -6
- package/lib/esm/components/slot/slot.test.js.map +1 -1
- package/lib/esnext/components/box/box.test.js +19 -12
- package/lib/esnext/components/box/box.test.js.map +1 -1
- package/lib/esnext/components/box/boxProps.d.ts +28 -0
- package/lib/esnext/components/box/buildStyles.js +6 -0
- package/lib/esnext/components/box/buildStyles.js.map +1 -1
- package/lib/esnext/components/flex/flex.test.js +8 -8
- package/lib/esnext/components/flex/flex.test.js.map +1 -1
- package/lib/esnext/components/slot/slot.test.js +6 -6
- package/lib/esnext/components/slot/slot.test.js.map +1 -1
- package/package.json +8 -9
- package/src/components/box/_box.scss +43 -0
- package/src/components/box/box.md +1 -1
- package/src/components/box/box.test.tsx +25 -12
- package/src/components/box/boxProps.ts +32 -0
- package/src/components/box/buildStyles.ts +10 -0
- package/src/components/flex/flex.md +1 -1
- package/src/components/flex/flex.test.tsx +8 -8
- package/src/components/slot/slot.test.tsx +7 -6
- package/vitest.config.mts +2 -1
- package/vitest.setup.mts +0 -13
|
@@ -4,16 +4,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect,
|
|
7
|
+
import { describe, expect, test, vi } from "@blueprintjs/test-commons/vitest";
|
|
8
8
|
import { Slot } from "./slot";
|
|
9
9
|
describe("<Slot>", () => {
|
|
10
|
-
|
|
10
|
+
test("merges props into a single child", () => {
|
|
11
11
|
render(_jsx(Slot, { "data-test": "bar", children: _jsx("button", { id: "foo", children: "Test" }) }));
|
|
12
12
|
const button = screen.getByRole("button", { name: /test/i });
|
|
13
13
|
expect(button).toHaveAttribute("id", "foo");
|
|
14
14
|
expect(button).toHaveAttribute("data-test", "bar");
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
test("merges className and style", () => {
|
|
17
17
|
render(_jsx(Slot, { className: "outer", style: { fontWeight: 700 }, children: _jsx("button", { className: "inner", style: { fontStyle: "italic" }, children: "Test" }) }));
|
|
18
18
|
const button = screen.getByRole("button", { name: /test/i });
|
|
19
19
|
expect(button).toHaveClass("outer");
|
|
@@ -21,17 +21,17 @@ describe("<Slot>", () => {
|
|
|
21
21
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
22
22
|
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
test("forwards ref to the child", () => {
|
|
25
25
|
const ref = createRef();
|
|
26
26
|
render(_jsx(Slot, { ref: ref, children: _jsx("button", { children: "Test" }) }));
|
|
27
27
|
expect(ref.current).toBeInstanceOf(HTMLButtonElement);
|
|
28
28
|
expect(ref.current).toBeInTheDocument();
|
|
29
29
|
});
|
|
30
|
-
|
|
30
|
+
test("returns null if no children are provided", () => {
|
|
31
31
|
const { container } = render(_jsx(Slot, {}));
|
|
32
32
|
expect(container.firstChild).toBeNull();
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
test("throws an error when multiple children are provided", () => {
|
|
35
35
|
// suppress error logging to keep test output clean
|
|
36
36
|
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
37
37
|
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueprintjs/labs",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Incubator for unstable and in-development Blueprint components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"classnames": "^2.3.1",
|
|
12
12
|
"tslib": "~2.6.2",
|
|
13
|
-
"@blueprintjs/colors": "^5.1.
|
|
14
|
-
"@blueprintjs/core": "^6.
|
|
13
|
+
"@blueprintjs/colors": "^5.1.14",
|
|
14
|
+
"@blueprintjs/core": "^6.8.1"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@types/react": "18",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@testing-library/dom": "^10.4.
|
|
27
|
+
"@testing-library/dom": "^10.4.0",
|
|
28
28
|
"@testing-library/jest-dom": "^6.9.1",
|
|
29
|
-
"@testing-library/react": "^16.
|
|
29
|
+
"@testing-library/react": "^16.1.0",
|
|
30
30
|
"@testing-library/user-event": "^14.6.1",
|
|
31
31
|
"@vitejs/plugin-react": "^5.1.0",
|
|
32
32
|
"jsdom": "^27.1.0",
|
|
@@ -34,11 +34,10 @@
|
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
36
36
|
"typescript": "~5.3.3",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"vitest": "4.0.7",
|
|
38
|
+
"@blueprintjs/node-build-scripts": "^9.3.1",
|
|
39
|
+
"@blueprintjs/stylelint-plugin": "^5.2.0",
|
|
39
40
|
"@blueprintjs/test-commons": "^4.0.4",
|
|
40
|
-
"@blueprintjs/stylelint-plugin": "^5.1.5",
|
|
41
|
-
"@blueprintjs/node-build-scripts": "^9.3.0",
|
|
42
41
|
"@blueprintjs/webpack-build-scripts": "^6.2.16"
|
|
43
42
|
},
|
|
44
43
|
"repository": {
|
|
@@ -370,6 +370,49 @@ $relative-sizes: (
|
|
|
370
370
|
flex: none;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
// flex-grow
|
|
374
|
+
&.#{bp.$ns}-flex-grow-0 {
|
|
375
|
+
flex-grow: 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
&.#{bp.$ns}-flex-grow-1 {
|
|
379
|
+
flex-grow: 1;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// flex-shrink
|
|
383
|
+
&.#{bp.$ns}-flex-shrink-0 {
|
|
384
|
+
flex-shrink: 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
&.#{bp.$ns}-flex-shrink-1 {
|
|
388
|
+
flex-shrink: 1;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// flex-basis
|
|
392
|
+
&.#{bp.$ns}-flex-basis-auto {
|
|
393
|
+
flex-basis: auto;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
&.#{bp.$ns}-flex-basis-0 {
|
|
397
|
+
flex-basis: 0%;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
&.#{bp.$ns}-flex-basis-25 {
|
|
401
|
+
flex-basis: 25%;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
&.#{bp.$ns}-flex-basis-50 {
|
|
405
|
+
flex-basis: 50%;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
&.#{bp.$ns}-flex-basis-75 {
|
|
409
|
+
flex-basis: 75%;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
&.#{bp.$ns}-flex-basis-100 {
|
|
413
|
+
flex-basis: 100%;
|
|
414
|
+
}
|
|
415
|
+
|
|
373
416
|
// flex-direction
|
|
374
417
|
&.#{bp.$ns}-flex-row {
|
|
375
418
|
flex-direction: row;
|
|
@@ -32,7 +32,7 @@ Box supports a wide range of layout props that map to CSS properties:
|
|
|
32
32
|
- **Spacing**: `margin`, `padding` and their logical variants
|
|
33
33
|
- **Positioning**: `position`, `inset` and their logical variants
|
|
34
34
|
- **Sizing**: `width`, `height`
|
|
35
|
-
- **Flexbox**: `display`, `flex`, `flexDirection`, `flexWrap`, `gap`
|
|
35
|
+
- **Flexbox**: `display`, `flex`, `flexGrow`, `flexShrink`, `flexBasis`, `flexDirection`, `flexWrap`, `gap`
|
|
36
36
|
- **Alignment**: `alignItems`, `alignContent`, `alignSelf`, `justifyContent`, `justifyItems`, `justifySelf`
|
|
37
37
|
- **Overflow**: `overflow`, `overflowX`, `overflowY`
|
|
38
38
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
import { describe, expect, it } from "vitest";
|
|
8
7
|
|
|
9
8
|
import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
|
|
9
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
10
10
|
|
|
11
11
|
import { Classes } from "../../common";
|
|
12
12
|
|
|
@@ -15,42 +15,42 @@ import { Box } from "./box";
|
|
|
15
15
|
const NS = Classes.getClassNamespace();
|
|
16
16
|
|
|
17
17
|
describe("<Box>", () => {
|
|
18
|
-
|
|
18
|
+
test("should render content", () => {
|
|
19
19
|
render(<Box>Test</Box>);
|
|
20
20
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
21
21
|
|
|
22
22
|
expect(box).toBeInTheDocument();
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
test("should render as a div by default", () => {
|
|
26
26
|
render(<Box>Test</Box>);
|
|
27
27
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
28
28
|
|
|
29
29
|
expect(box.tagName).toBe("DIV");
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
test("should pass through data attributes", () => {
|
|
33
33
|
render(<Box data-test="foo">Test</Box>);
|
|
34
34
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
35
35
|
|
|
36
36
|
expect(box.dataset.test).toBe("foo");
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
test("should support className", () => {
|
|
40
40
|
render(<Box className="foo">Test</Box>);
|
|
41
41
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
42
42
|
|
|
43
43
|
expect(box).toHaveClass("foo");
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
test("should support style", () => {
|
|
47
47
|
render(<Box style={{ fontWeight: 700 }}>Test</Box>);
|
|
48
48
|
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
49
49
|
|
|
50
50
|
expect(box).toHaveStyle({ fontWeight: 700 });
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
test("should support computed class names", () => {
|
|
54
54
|
render(
|
|
55
55
|
<Box display="flex" margin={2}>
|
|
56
56
|
Test
|
|
@@ -62,7 +62,20 @@ describe("<Box>", () => {
|
|
|
62
62
|
expect(box).toHaveClass(`${NS}-margin-2`);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
test("should support flexGrow, flexShrink, and flexBasis props", () => {
|
|
66
|
+
render(
|
|
67
|
+
<Box flexGrow={1} flexShrink={0} flexBasis={0}>
|
|
68
|
+
Test
|
|
69
|
+
</Box>,
|
|
70
|
+
);
|
|
71
|
+
const box = screen.getByText<HTMLDivElement>(/test/i);
|
|
72
|
+
|
|
73
|
+
expect(box).toHaveClass(`${NS}-flex-grow-1`);
|
|
74
|
+
expect(box).toHaveClass(`${NS}-flex-shrink-0`);
|
|
75
|
+
expect(box).toHaveClass(`${NS}-flex-basis-0`);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("should attach ref", () => {
|
|
66
79
|
const ref = createRef<HTMLDivElement>();
|
|
67
80
|
render(<Box ref={ref}>Test</Box>);
|
|
68
81
|
|
|
@@ -70,7 +83,7 @@ describe("<Box>", () => {
|
|
|
70
83
|
expect(ref.current).toBeInTheDocument();
|
|
71
84
|
});
|
|
72
85
|
|
|
73
|
-
|
|
86
|
+
test("should not support unsupported/invalid props in types", () => {
|
|
74
87
|
// "foo" is not a valid HTML attribute
|
|
75
88
|
// @ts-expect-error
|
|
76
89
|
render(<Box foo="bar">Test</Box>);
|
|
@@ -80,7 +93,7 @@ describe("<Box>", () => {
|
|
|
80
93
|
});
|
|
81
94
|
|
|
82
95
|
describe("asChild", () => {
|
|
83
|
-
|
|
96
|
+
test("should render as child with asChild prop", () => {
|
|
84
97
|
render(
|
|
85
98
|
<Box asChild={true} data-test="foo">
|
|
86
99
|
<Button intent="primary">Test</Button>
|
|
@@ -94,7 +107,7 @@ describe("<Box>", () => {
|
|
|
94
107
|
expect(button).toHaveAttribute("data-test", "foo");
|
|
95
108
|
});
|
|
96
109
|
|
|
97
|
-
|
|
110
|
+
test("should merge styles with asChild prop", () => {
|
|
98
111
|
render(
|
|
99
112
|
<Box asChild={true} style={{ fontWeight: 700 }}>
|
|
100
113
|
<Button style={{ color: "blue" }}>Test</Button>
|
|
@@ -105,7 +118,7 @@ describe("<Box>", () => {
|
|
|
105
118
|
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
106
119
|
});
|
|
107
120
|
|
|
108
|
-
|
|
121
|
+
test("should remove margin on wrapped component", () => {
|
|
109
122
|
render(
|
|
110
123
|
<Box asChild={true} marginYEnd={0}>
|
|
111
124
|
<H1>Test</H1>
|
|
@@ -129,6 +129,32 @@ export type Display =
|
|
|
129
129
|
*/
|
|
130
130
|
export type Flex = 1 | "1" | "auto" | "initial" | "none";
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The range of values shared by `flex-grow` and `flex-shrink`.
|
|
134
|
+
*/
|
|
135
|
+
type FlexGrowShrinkRange = 0 | 1;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The range of values for `flex-grow`.
|
|
139
|
+
*
|
|
140
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow
|
|
141
|
+
*/
|
|
142
|
+
export type FlexGrow = FlexGrowShrinkRange | `${FlexGrowShrinkRange}`;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The range of values for `flex-shrink`.
|
|
146
|
+
*
|
|
147
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink
|
|
148
|
+
*/
|
|
149
|
+
export type FlexShrink = FlexGrowShrinkRange | `${FlexGrowShrinkRange}`;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The range of values for `flex-basis`.
|
|
153
|
+
*
|
|
154
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis
|
|
155
|
+
*/
|
|
156
|
+
export type FlexBasis = "auto" | 0 | "0" | SizeRange | `${SizeRange}`;
|
|
157
|
+
|
|
132
158
|
/**
|
|
133
159
|
* The range of values for `flex-direction`.
|
|
134
160
|
*
|
|
@@ -306,6 +332,12 @@ export interface BoxProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
|
306
332
|
display?: Display;
|
|
307
333
|
/** CSS `flex` (shorthand for `flex-grow`, `flex-shrink`, `flex-basis`) */
|
|
308
334
|
flex?: Flex;
|
|
335
|
+
/** CSS `flex-grow` */
|
|
336
|
+
flexGrow?: FlexGrow;
|
|
337
|
+
/** CSS `flex-shrink` */
|
|
338
|
+
flexShrink?: FlexShrink;
|
|
339
|
+
/** CSS `flex-basis` */
|
|
340
|
+
flexBasis?: FlexBasis;
|
|
309
341
|
/** CSS `flex-direction` */
|
|
310
342
|
flexDirection?: FlexDirection;
|
|
311
343
|
/** CSS `flex-wrap` */
|
|
@@ -12,7 +12,10 @@ import type {
|
|
|
12
12
|
AlignSelf,
|
|
13
13
|
Display,
|
|
14
14
|
Flex,
|
|
15
|
+
FlexBasis,
|
|
15
16
|
FlexDirection,
|
|
17
|
+
FlexGrow,
|
|
18
|
+
FlexShrink,
|
|
16
19
|
FlexWrap,
|
|
17
20
|
Gap,
|
|
18
21
|
Height,
|
|
@@ -179,6 +182,10 @@ const flex = mapping<Flex>({
|
|
|
179
182
|
none: "flex-none",
|
|
180
183
|
});
|
|
181
184
|
|
|
185
|
+
const flexGrow = appendValue<FlexGrow>("flex-grow");
|
|
186
|
+
const flexShrink = appendValue<FlexShrink>("flex-shrink");
|
|
187
|
+
const flexBasis = appendValue<FlexBasis>("flex-basis");
|
|
188
|
+
|
|
182
189
|
const flexDirection = mapping<FlexDirection>({
|
|
183
190
|
row: "flex-row",
|
|
184
191
|
"row-reverse": "flex-row-reverse",
|
|
@@ -295,6 +302,9 @@ const styles: Record<string, (value: any) => string> = {
|
|
|
295
302
|
alignSelf,
|
|
296
303
|
display,
|
|
297
304
|
flex,
|
|
305
|
+
flexGrow,
|
|
306
|
+
flexShrink,
|
|
307
|
+
flexBasis,
|
|
298
308
|
flexDirection,
|
|
299
309
|
flexWrap,
|
|
300
310
|
justifyContent,
|
|
@@ -23,7 +23,7 @@ Flex supports all Box props except `display`, with common flexbox patterns:
|
|
|
23
23
|
- **Direction & Wrap**: `flexDirection`, `flexWrap`
|
|
24
24
|
- **Alignment**: `alignItems`, `alignContent`, `justifyContent`
|
|
25
25
|
- **Gap**: `gap` for spacing between items
|
|
26
|
-
- **Child control**: `flex`
|
|
26
|
+
- **Child control**: `flex` shorthand, or individual `flexGrow`, `flexShrink`, `flexBasis`
|
|
27
27
|
|
|
28
28
|
Each prop accepts Blueprint token values for consistent spacing and sizing.
|
|
29
29
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
|
-
import { describe, expect, it } from "vitest";
|
|
7
6
|
|
|
8
7
|
import { Button, Classes as CoreClasses } from "@blueprintjs/core";
|
|
8
|
+
import { describe, expect, test } from "@blueprintjs/test-commons/vitest";
|
|
9
9
|
|
|
10
10
|
import { Classes } from "../../common";
|
|
11
11
|
|
|
@@ -14,21 +14,21 @@ import { Flex } from "./flex";
|
|
|
14
14
|
const NS = Classes.getClassNamespace();
|
|
15
15
|
|
|
16
16
|
describe("<Flex>", () => {
|
|
17
|
-
|
|
17
|
+
test("should render content", () => {
|
|
18
18
|
render(<Flex>Test</Flex>);
|
|
19
19
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
20
20
|
|
|
21
21
|
expect(flex).toBeInTheDocument();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
test("should always set display flex", () => {
|
|
25
25
|
render(<Flex>Test</Flex>);
|
|
26
26
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
27
27
|
|
|
28
28
|
expect(flex).toHaveClass(`${NS}-flex`);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
test("should pass through Box props", () => {
|
|
32
32
|
render(
|
|
33
33
|
<Flex gap={2} flexDirection="column" data-testid="flex-test">
|
|
34
34
|
Test
|
|
@@ -40,7 +40,7 @@ describe("<Flex>", () => {
|
|
|
40
40
|
expect(flex).toHaveClass(`${NS}-flex-column`);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
test("should support className", () => {
|
|
44
44
|
render(<Flex className="custom-class">Test</Flex>);
|
|
45
45
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
46
46
|
|
|
@@ -48,14 +48,14 @@ describe("<Flex>", () => {
|
|
|
48
48
|
expect(flex).toHaveClass(Classes.BOX);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
test("should support style prop", () => {
|
|
52
52
|
render(<Flex style={{ fontWeight: 700 }}>Test</Flex>);
|
|
53
53
|
const flex = screen.getByText<HTMLDivElement>(/test/i);
|
|
54
54
|
|
|
55
55
|
expect(flex).toHaveStyle({ fontWeight: 700 });
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
test("should support asChild prop", () => {
|
|
59
59
|
render(
|
|
60
60
|
<Flex asChild={true} gap={2}>
|
|
61
61
|
<Button intent="primary">Test</Button>
|
|
@@ -69,7 +69,7 @@ describe("<Flex>", () => {
|
|
|
69
69
|
expect(button).toHaveClass(`${NS}-gap-2`);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
test("should support all flex-related props", () => {
|
|
73
73
|
render(
|
|
74
74
|
<Flex
|
|
75
75
|
flexDirection="row"
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { render, screen } from "@testing-library/react";
|
|
6
6
|
import { createRef } from "react";
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import { describe, expect, test, vi } from "@blueprintjs/test-commons/vitest";
|
|
8
9
|
|
|
9
10
|
import { Slot } from "./slot";
|
|
10
11
|
|
|
11
12
|
describe("<Slot>", () => {
|
|
12
|
-
|
|
13
|
+
test("merges props into a single child", () => {
|
|
13
14
|
render(
|
|
14
15
|
<Slot data-test="bar">
|
|
15
16
|
<button id="foo">Test</button>
|
|
@@ -21,7 +22,7 @@ describe("<Slot>", () => {
|
|
|
21
22
|
expect(button).toHaveAttribute("data-test", "bar");
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
test("merges className and style", () => {
|
|
25
26
|
render(
|
|
26
27
|
<Slot className="outer" style={{ fontWeight: 700 }}>
|
|
27
28
|
<button className="inner" style={{ fontStyle: "italic" }}>
|
|
@@ -37,7 +38,7 @@ describe("<Slot>", () => {
|
|
|
37
38
|
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
test("forwards ref to the child", () => {
|
|
41
42
|
const ref = createRef<HTMLButtonElement>();
|
|
42
43
|
render(
|
|
43
44
|
<Slot ref={ref}>
|
|
@@ -48,12 +49,12 @@ describe("<Slot>", () => {
|
|
|
48
49
|
expect(ref.current).toBeInTheDocument();
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
test("returns null if no children are provided", () => {
|
|
52
53
|
const { container } = render(<Slot />);
|
|
53
54
|
expect(container.firstChild).toBeNull();
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
test("throws an error when multiple children are provided", () => {
|
|
57
58
|
// suppress error logging to keep test output clean
|
|
58
59
|
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
59
60
|
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
package/vitest.config.mts
CHANGED
|
@@ -9,9 +9,10 @@ import { defineConfig } from "vitest/config";
|
|
|
9
9
|
export default defineConfig({
|
|
10
10
|
plugins: [react()],
|
|
11
11
|
test: {
|
|
12
|
+
name: "labs",
|
|
12
13
|
environment: "jsdom",
|
|
13
14
|
exclude: ["lib/**", "node_modules/**"],
|
|
14
15
|
include: ["src/**/*.{test,spec}.{ts,tsx}"],
|
|
15
|
-
setupFiles: "
|
|
16
|
+
setupFiles: "@blueprintjs/test-commons/vitest-setup-no-enzyme",
|
|
16
17
|
},
|
|
17
18
|
});
|
package/vitest.setup.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* !
|
|
2
|
-
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom/vitest";
|
|
7
|
-
import { cleanup } from "@testing-library/react";
|
|
8
|
-
import { afterEach } from "vitest";
|
|
9
|
-
|
|
10
|
-
// Cleanup after each test
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
cleanup();
|
|
13
|
-
});
|