@blueprintjs/labs 0.16.2 → 6.1.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/LICENSE +153 -167
- package/README.md +1 -1
- package/lib/cjs/common/classes.d.ts +6 -0
- package/lib/cjs/common/classes.js +20 -0
- package/lib/cjs/common/classes.js.map +1 -0
- package/lib/cjs/common/index.d.ts +3 -1
- package/lib/cjs/common/index.js +9 -4
- package/lib/cjs/common/index.js.map +1 -1
- package/lib/cjs/common/props.d.ts +1 -0
- package/lib/cjs/common/props.js +10 -0
- package/lib/cjs/common/props.js.map +1 -0
- package/lib/cjs/components/box/box.d.ts +8 -0
- package/lib/cjs/components/box/box.js +25 -0
- package/lib/cjs/components/box/box.js.map +1 -0
- package/lib/cjs/components/box/box.test.d.ts +1 -0
- package/lib/cjs/components/box/box.test.js +80 -0
- package/lib/cjs/components/box/box.test.js.map +1 -0
- package/lib/cjs/components/box/boxProps.d.ts +246 -0
- package/lib/cjs/components/box/boxProps.js +6 -0
- package/lib/cjs/components/box/boxProps.js.map +1 -0
- package/lib/cjs/components/box/buildStyles.d.ts +23 -0
- package/lib/cjs/components/box/buildStyles.js +258 -0
- package/lib/cjs/components/box/buildStyles.js.map +1 -0
- package/lib/cjs/components/flex/flex.d.ts +7 -0
- package/lib/cjs/components/flex/flex.js +18 -0
- package/lib/cjs/components/flex/flex.js.map +1 -0
- package/lib/cjs/components/flex/flex.test.d.ts +1 -0
- package/lib/cjs/components/flex/flex.test.js +59 -0
- package/lib/cjs/components/flex/flex.test.js.map +1 -0
- package/lib/cjs/components/index.d.ts +3 -1
- package/lib/cjs/components/index.js +8 -4
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/slot/slot.d.ts +7 -0
- package/lib/cjs/components/slot/slot.js +31 -0
- package/lib/cjs/components/slot/slot.js.map +1 -0
- package/lib/cjs/components/slot/slot.test.d.ts +1 -0
- package/lib/cjs/components/slot/slot.test.js +47 -0
- package/lib/cjs/components/slot/slot.test.js.map +1 -0
- package/lib/cjs/index.d.ts +0 -7
- package/lib/cjs/index.js +6 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/css/blueprint-labs.css +1630 -7
- package/lib/css/blueprint-labs.css.map +1 -10
- package/lib/esm/common/classes.d.ts +6 -0
- package/lib/esm/common/classes.js +16 -0
- package/lib/esm/common/classes.js.map +1 -0
- package/lib/esm/common/index.d.ts +3 -1
- package/lib/esm/common/index.js +6 -4
- package/lib/esm/common/index.js.map +1 -1
- package/lib/esm/common/props.d.ts +1 -0
- package/lib/esm/common/props.js +7 -0
- package/lib/esm/common/props.js.map +1 -0
- package/lib/esm/components/box/box.d.ts +8 -0
- package/lib/esm/components/box/box.js +21 -0
- package/lib/esm/components/box/box.js.map +1 -0
- package/lib/esm/components/box/box.test.d.ts +1 -0
- package/lib/esm/components/box/box.test.js +78 -0
- package/lib/esm/components/box/box.test.js.map +1 -0
- package/lib/esm/components/box/boxProps.d.ts +246 -0
- package/lib/esm/components/box/boxProps.js +5 -0
- package/lib/esm/components/box/boxProps.js.map +1 -0
- package/lib/esm/components/box/buildStyles.d.ts +23 -0
- package/lib/esm/components/box/buildStyles.js +254 -0
- package/lib/esm/components/box/buildStyles.js.map +1 -0
- package/lib/esm/components/flex/flex.d.ts +7 -0
- package/lib/esm/components/flex/flex.js +15 -0
- package/lib/esm/components/flex/flex.js.map +1 -0
- package/lib/esm/components/flex/flex.test.d.ts +1 -0
- package/lib/esm/components/flex/flex.test.js +57 -0
- package/lib/esm/components/flex/flex.test.js.map +1 -0
- package/lib/esm/components/index.d.ts +3 -1
- package/lib/esm/components/index.js +5 -4
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/slot/slot.d.ts +7 -0
- package/lib/esm/components/slot/slot.js +27 -0
- package/lib/esm/components/slot/slot.js.map +1 -0
- package/lib/esm/components/slot/slot.test.d.ts +1 -0
- package/lib/esm/components/slot/slot.test.js +45 -0
- package/lib/esm/components/slot/slot.test.js.map +1 -0
- package/lib/esm/index.d.ts +2 -9
- package/lib/esm/index.js +5 -12
- package/lib/esm/index.js.map +1 -1
- package/lib/esnext/common/classes.d.ts +6 -0
- package/lib/esnext/common/classes.js +16 -0
- package/lib/esnext/common/classes.js.map +1 -0
- package/lib/esnext/common/index.d.ts +3 -0
- package/lib/esnext/common/index.js +8 -0
- package/lib/esnext/common/index.js.map +1 -0
- package/lib/esnext/common/props.d.ts +1 -0
- package/lib/esnext/common/props.js +7 -0
- package/lib/esnext/common/props.js.map +1 -0
- package/lib/esnext/components/box/box.d.ts +8 -0
- package/lib/esnext/components/box/box.js +21 -0
- package/lib/esnext/components/box/box.js.map +1 -0
- package/lib/esnext/components/box/box.test.d.ts +1 -0
- package/lib/esnext/components/box/box.test.js +78 -0
- package/lib/esnext/components/box/box.test.js.map +1 -0
- package/lib/esnext/components/box/boxProps.d.ts +246 -0
- package/lib/esnext/components/box/boxProps.js +5 -0
- package/lib/esnext/components/box/boxProps.js.map +1 -0
- package/lib/esnext/components/box/buildStyles.d.ts +23 -0
- package/lib/esnext/components/box/buildStyles.js +254 -0
- package/lib/esnext/components/box/buildStyles.js.map +1 -0
- package/lib/esnext/components/flex/flex.d.ts +7 -0
- package/lib/esnext/components/flex/flex.js +15 -0
- package/lib/esnext/components/flex/flex.js.map +1 -0
- package/lib/esnext/components/flex/flex.test.d.ts +1 -0
- package/lib/esnext/components/flex/flex.test.js +57 -0
- package/lib/esnext/components/flex/flex.test.js.map +1 -0
- package/lib/esnext/components/index.d.ts +3 -0
- package/lib/esnext/components/index.js +7 -0
- package/lib/esnext/components/index.js.map +1 -0
- package/lib/esnext/components/slot/slot.d.ts +7 -0
- package/lib/esnext/components/slot/slot.js +27 -0
- package/lib/esnext/components/slot/slot.js.map +1 -0
- package/lib/esnext/components/slot/slot.test.d.ts +1 -0
- package/lib/esnext/components/slot/slot.test.js +45 -0
- package/lib/esnext/components/slot/slot.test.js.map +1 -0
- package/lib/esnext/index.d.ts +2 -0
- package/lib/esnext/index.js +7 -0
- package/lib/esnext/index.js.map +1 -0
- package/package.json +59 -44
- package/src/_common.scss +9 -0
- package/src/blueprint-labs.scss +5 -7
- package/src/common/classes.ts +20 -0
- package/src/common/index.ts +7 -6
- package/src/common/props.ts +8 -0
- package/src/components/box/_box.scss +543 -0
- package/src/components/box/box.md +59 -0
- package/src/components/box/box.test.tsx +119 -0
- package/src/components/box/box.tsx +32 -0
- package/src/components/box/boxProps.ts +334 -0
- package/src/components/box/buildStyles.ts +307 -0
- package/src/components/flex/flex.md +52 -0
- package/src/components/flex/flex.test.tsx +93 -0
- package/src/components/flex/flex.tsx +20 -0
- package/src/components/index.ts +6 -6
- package/src/components/slot/slot.test.tsx +73 -0
- package/src/components/slot/slot.tsx +30 -0
- package/src/index.md +16 -5
- package/src/index.ts +3 -20
- package/src/tsconfig.json +5 -3
- package/src/vitest-env.d.ts +6 -0
- package/vitest.config.mts +17 -0
- package/vitest.setup.mts +13 -0
- package/dist/labs.bundle.js +0 -1
- package/src/components/_index.scss +0 -3
- package/src/tsconfig.cjs.json +0 -7
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* !
|
|
3
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { render, screen } from "@testing-library/react";
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { Button, Classes as CoreClasses } from "@blueprintjs/core";
|
|
8
|
+
import { Classes } from "../../common";
|
|
9
|
+
import { Flex } from "./flex";
|
|
10
|
+
const NS = Classes.getClassNamespace();
|
|
11
|
+
describe("<Flex>", () => {
|
|
12
|
+
it("should render content", () => {
|
|
13
|
+
render(_jsx(Flex, { children: "Test" }));
|
|
14
|
+
const flex = screen.getByText(/test/i);
|
|
15
|
+
expect(flex).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
it("should always set display flex", () => {
|
|
18
|
+
render(_jsx(Flex, { children: "Test" }));
|
|
19
|
+
const flex = screen.getByText(/test/i);
|
|
20
|
+
expect(flex).toHaveClass(`${NS}-flex`);
|
|
21
|
+
});
|
|
22
|
+
it("should pass through Box props", () => {
|
|
23
|
+
render(_jsx(Flex, { gap: 2, flexDirection: "column", "data-testid": "flex-test", children: "Test" }));
|
|
24
|
+
const flex = screen.getByTestId("flex-test");
|
|
25
|
+
expect(flex).toHaveClass(`${NS}-gap-2`);
|
|
26
|
+
expect(flex).toHaveClass(`${NS}-flex-column`);
|
|
27
|
+
});
|
|
28
|
+
it("should support className", () => {
|
|
29
|
+
render(_jsx(Flex, { className: "custom-class", children: "Test" }));
|
|
30
|
+
const flex = screen.getByText(/test/i);
|
|
31
|
+
expect(flex).toHaveClass("custom-class");
|
|
32
|
+
expect(flex).toHaveClass(Classes.BOX);
|
|
33
|
+
});
|
|
34
|
+
it("should support style prop", () => {
|
|
35
|
+
render(_jsx(Flex, { style: { fontWeight: 700 }, children: "Test" }));
|
|
36
|
+
const flex = screen.getByText(/test/i);
|
|
37
|
+
expect(flex).toHaveStyle({ fontWeight: 700 });
|
|
38
|
+
});
|
|
39
|
+
it("should support asChild prop", () => {
|
|
40
|
+
render(_jsx(Flex, { asChild: true, gap: 2, children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
41
|
+
const button = screen.getByRole("button", { name: /test/i });
|
|
42
|
+
expect(button).toHaveClass(Classes.BOX);
|
|
43
|
+
expect(button).toHaveClass(CoreClasses.BUTTON);
|
|
44
|
+
expect(button).toHaveClass(`${NS}-flex`);
|
|
45
|
+
expect(button).toHaveClass(`${NS}-gap-2`);
|
|
46
|
+
});
|
|
47
|
+
it("should support all flex-related props", () => {
|
|
48
|
+
render(_jsx(Flex, { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", alignItems: "center", gap: 3, "data-testid": "flex-all-props", children: "Test" }));
|
|
49
|
+
const flex = screen.getByTestId("flex-all-props");
|
|
50
|
+
expect(flex).toHaveClass(`${NS}-flex-row`);
|
|
51
|
+
expect(flex).toHaveClass(`${NS}-flex-wrap`);
|
|
52
|
+
expect(flex).toHaveClass(`${NS}-justify-center`);
|
|
53
|
+
expect(flex).toHaveClass(`${NS}-items-center`);
|
|
54
|
+
expect(flex).toHaveClass(`${NS}-gap-3`);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=flex.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flex.test.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,KAAC,IAAI,uBAAY,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAiB,OAAO,CAAC,CAAC;QAEvD,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,KAAC,IAAI,uBAAY,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAiB,OAAO,CAAC,CAAC;QAEvD,MAAM,CAAC,IAAI,CAAC,CAAC,WAA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AAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import { Children, cloneElement, forwardRef, isValidElement } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* Slot component.
|
|
8
|
+
*/
|
|
9
|
+
export const Slot = forwardRef(function Slot({ children, ...props }, ref) {
|
|
10
|
+
if (isValidElement(children)) {
|
|
11
|
+
return cloneElement(children, {
|
|
12
|
+
...props,
|
|
13
|
+
...children.props,
|
|
14
|
+
className: classNames(props.className, children.props.className),
|
|
15
|
+
ref,
|
|
16
|
+
style: {
|
|
17
|
+
...props.style,
|
|
18
|
+
...children.props.style,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (Children.count(children) > 1) {
|
|
23
|
+
throw new TypeError("Only single element child is allowed in Slot");
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=slot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3E;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC1B,SAAS,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACrC,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC,QAAQ,EAAE;YAC1B,GAAG,KAAK;YACR,GAAG,QAAQ,CAAC,KAAK;YACjB,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;YAChE,GAAG;YACH,KAAK,EAAE;gBACH,GAAG,KAAK,CAAC,KAAK;gBACd,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK;aAC1B;SACJ,CAAC,CAAC;IACP,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* !
|
|
3
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { render, screen } from "@testing-library/react";
|
|
6
|
+
import { createRef } from "react";
|
|
7
|
+
import { describe, expect, it, vi } from "vitest";
|
|
8
|
+
import { Slot } from "./slot";
|
|
9
|
+
describe("<Slot>", () => {
|
|
10
|
+
it("merges props into a single child", () => {
|
|
11
|
+
render(_jsx(Slot, { "data-test": "bar", children: _jsx("button", { id: "foo", children: "Test" }) }));
|
|
12
|
+
const button = screen.getByRole("button", { name: /test/i });
|
|
13
|
+
expect(button).toHaveAttribute("id", "foo");
|
|
14
|
+
expect(button).toHaveAttribute("data-test", "bar");
|
|
15
|
+
});
|
|
16
|
+
it("merges className and style", () => {
|
|
17
|
+
render(_jsx(Slot, { className: "outer", style: { fontWeight: 700 }, children: _jsx("button", { className: "inner", style: { fontStyle: "italic" }, children: "Test" }) }));
|
|
18
|
+
const button = screen.getByRole("button", { name: /test/i });
|
|
19
|
+
expect(button).toHaveClass("outer");
|
|
20
|
+
expect(button).toHaveClass("inner");
|
|
21
|
+
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
22
|
+
expect(button).toHaveStyle({ fontStyle: "italic" });
|
|
23
|
+
});
|
|
24
|
+
it("forwards ref to the child", () => {
|
|
25
|
+
const ref = createRef();
|
|
26
|
+
render(_jsx(Slot, { ref: ref, children: _jsx("button", { children: "Test" }) }));
|
|
27
|
+
expect(ref.current).toBeInstanceOf(HTMLButtonElement);
|
|
28
|
+
expect(ref.current).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
it("returns null if no children are provided", () => {
|
|
31
|
+
const { container } = render(_jsx(Slot, {}));
|
|
32
|
+
expect(container.firstChild).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
it("throws an error when multiple children are provided", () => {
|
|
35
|
+
// suppress error logging to keep test output clean
|
|
36
|
+
const stderrWriteSpy = vi.spyOn(process.stderr, "write").mockImplementation(vi.fn());
|
|
37
|
+
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(vi.fn());
|
|
38
|
+
expect(() => {
|
|
39
|
+
render(_jsxs(Slot, { children: [_jsx("button", { children: "First" }), _jsx("button", { children: "Second" })] }));
|
|
40
|
+
}).toThrow("Only single element child is allowed in Slot");
|
|
41
|
+
stderrWriteSpy.mockRestore();
|
|
42
|
+
consoleErrorSpy.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=slot.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slot.test.js","sourceRoot":"","sources":["../../../../src/components/slot/slot.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,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AAW,EAAE,CAAC;QAC7B,eAAe,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blueprintjs/labs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.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",
|
|
7
|
+
"esnext": "lib/esnext/index.js",
|
|
7
8
|
"typings": "lib/esm/index.d.ts",
|
|
8
9
|
"style": "lib/css/blueprint-labs.css",
|
|
9
|
-
"unpkg": "dist/labs.bundle.js",
|
|
10
|
-
"sideEffects": [
|
|
11
|
-
"*.css"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"clean": "rm -rf dist/* && rm -rf lib/*",
|
|
15
|
-
"compile": "run-p \"compile:*\"",
|
|
16
|
-
"compile:esm": "tsc -p ./src",
|
|
17
|
-
"compile:cjs": "tsc -p ./src/tsconfig.cjs.json",
|
|
18
|
-
"compile:css": "sass-compile ./src",
|
|
19
|
-
"dev": "run-p \"compile:esm -- --watch\" \"compile:css -- --watch\"",
|
|
20
|
-
"dist": "run-s \"dist:*\"",
|
|
21
|
-
"dist:bundle": "cross-env NODE_ENV=production webpack",
|
|
22
|
-
"dist:css": "css-dist lib/css/*.css",
|
|
23
|
-
"dist:verify": "assert-package-layout",
|
|
24
|
-
"lint": "run-p lint:scss lint:ts",
|
|
25
|
-
"lint:scss": "sass-lint",
|
|
26
|
-
"lint:ts": "ts-lint",
|
|
27
|
-
"lint-fix": "ts-lint --fix",
|
|
28
|
-
"test": "run-s test:pre test:karma",
|
|
29
|
-
"test:pre": "tsc -p ./test",
|
|
30
|
-
"test:karma": "karma start",
|
|
31
|
-
"test:karma:debug": "karma start --single-run=false --reporters=mocha --debug",
|
|
32
|
-
"verify": "npm-run-all compile -p dist test lint"
|
|
33
|
-
},
|
|
34
10
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@blueprintjs/
|
|
38
|
-
"
|
|
39
|
-
|
|
11
|
+
"classnames": "^2.3.1",
|
|
12
|
+
"tslib": "~2.6.2",
|
|
13
|
+
"@blueprintjs/colors": "^5.1.10",
|
|
14
|
+
"@blueprintjs/core": "^6.3.3"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@types/react": "18",
|
|
18
|
+
"react": "18",
|
|
19
|
+
"react-dom": "18"
|
|
20
|
+
},
|
|
21
|
+
"peerDependenciesMeta": {
|
|
22
|
+
"@types/react": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
40
25
|
},
|
|
41
26
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"react
|
|
50
|
-
"
|
|
51
|
-
"
|
|
27
|
+
"@testing-library/dom": "^10.4.1",
|
|
28
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
29
|
+
"@testing-library/react": "^16.3.0",
|
|
30
|
+
"@testing-library/user-event": "^14.6.1",
|
|
31
|
+
"@vitejs/plugin-react": "^5.1.0",
|
|
32
|
+
"jsdom": "^27.1.0",
|
|
33
|
+
"npm-run-all": "^4.1.5",
|
|
34
|
+
"react": "^18.3.1",
|
|
35
|
+
"react-dom": "^18.3.1",
|
|
36
|
+
"typescript": "~5.3.3",
|
|
37
|
+
"vite": "^7.1.2",
|
|
38
|
+
"vitest": "^4.0.7",
|
|
39
|
+
"@blueprintjs/node-build-scripts": "^9.2.9",
|
|
40
|
+
"@blueprintjs/stylelint-plugin": "^5.1.1",
|
|
41
|
+
"@blueprintjs/test-commons": "^4.0.2",
|
|
42
|
+
"@blueprintjs/webpack-build-scripts": "^6.2.14"
|
|
52
43
|
},
|
|
53
44
|
"repository": {
|
|
54
45
|
"type": "git",
|
|
55
|
-
"url": "git@github.com
|
|
46
|
+
"url": "git+ssh://git@github.com/palantir/blueprint.git",
|
|
47
|
+
"directory": "packages/labs"
|
|
56
48
|
},
|
|
57
49
|
"keywords": [
|
|
58
50
|
"palantir",
|
|
@@ -61,5 +53,28 @@
|
|
|
61
53
|
"labs"
|
|
62
54
|
],
|
|
63
55
|
"author": "Palantir Technologies",
|
|
64
|
-
"license": "
|
|
65
|
-
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/palantir/blueprint/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/palantir/blueprint#readme",
|
|
61
|
+
"scripts": {
|
|
62
|
+
"clean": "rm -rf lib/* || true",
|
|
63
|
+
"compile": "run-p \"compile:*\"",
|
|
64
|
+
"compile:esm": "tsc -p ./src",
|
|
65
|
+
"compile:cjs": "tsc -p ./src -m commonjs --verbatimModuleSyntax false --outDir lib/cjs",
|
|
66
|
+
"compile:esnext": "tsc -p ./src -t esnext --outDir lib/esnext",
|
|
67
|
+
"compile:css": "sass-compile ./src",
|
|
68
|
+
"dev": "run-p \"compile:esm --watch\" \"compile:css --watch\"",
|
|
69
|
+
"dist": "run-s \"dist:*\"",
|
|
70
|
+
"dist:css": "css-dist lib/css",
|
|
71
|
+
"lint": "run-p lint:scss lint:es",
|
|
72
|
+
"lint:es": "es-lint",
|
|
73
|
+
"lint:scss": "sass-lint",
|
|
74
|
+
"lint-fix": "es-lint --fix && sass-lint --fix",
|
|
75
|
+
"start": "pnpm dev",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:watch": "vitest watch",
|
|
78
|
+
"verify": "npm-run-all compile -p dist test lint"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/_common.scss
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 "@blueprintjs/colors/lib/scss/colors";
|
|
7
|
+
@import "@blueprintjs/core/src/common/variables";
|
|
8
|
+
|
|
9
|
+
$ns: #{$ns}-labs;
|
package/src/blueprint-labs.scss
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
*/
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
Licensed under the terms of the LICENSE file distributed with this project.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
@import "./components/index";
|
|
6
|
+
@forward "components/box/box";
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { Classes } from "@blueprintjs/core";
|
|
7
|
+
|
|
8
|
+
const CORE_NS = Classes.getClassNamespace();
|
|
9
|
+
|
|
10
|
+
const NS = `${CORE_NS}-labs`;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns the namespace prefix for all Blueprint CSS classes.
|
|
14
|
+
* Customize this namespace at build time by defining it with `webpack.DefinePlugin`.
|
|
15
|
+
*/
|
|
16
|
+
export function getClassNamespace() {
|
|
17
|
+
return NS;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const BOX = `${NS}-box`;
|
package/src/common/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the terms of the LICENSE file distributed with this project.
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import * as Classes from "./classes";
|
|
7
|
+
|
|
8
|
+
export { DISPLAYNAME_PREFIX } from "./props";
|
|
9
|
+
export { Classes };
|
|
@@ -0,0 +1,8 @@
|
|
|
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 { DISPLAYNAME_PREFIX as CORE_DISPLAYNAME_PREFIX } from "@blueprintjs/core";
|
|
7
|
+
|
|
8
|
+
export const DISPLAYNAME_PREFIX = `${CORE_DISPLAYNAME_PREFIX}Labs`;
|