@blueprintjs/labs 0.16.3 → 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 -1
- 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 +0 -7
- 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 -1
- package/lib/esnext/common/index.js +6 -4
- package/lib/esnext/common/index.js.map +1 -1
- 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 -1
- package/lib/esnext/components/index.js +5 -4
- package/lib/esnext/components/index.js.map +1 -1
- 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 +0 -7
- package/lib/esnext/index.js +5 -12
- package/lib/esnext/index.js.map +1 -1
- package/package.json +57 -45
- 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
|
@@ -0,0 +1,78 @@
|
|
|
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 { createRef } from "react";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
|
|
9
|
+
import { Classes } from "../../common";
|
|
10
|
+
import { Box } from "./box";
|
|
11
|
+
const NS = Classes.getClassNamespace();
|
|
12
|
+
describe("<Box>", () => {
|
|
13
|
+
it("should render content", () => {
|
|
14
|
+
render(_jsx(Box, { children: "Test" }));
|
|
15
|
+
const box = screen.getByText(/test/i);
|
|
16
|
+
expect(box).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
it("should render as a div by default", () => {
|
|
19
|
+
render(_jsx(Box, { children: "Test" }));
|
|
20
|
+
const box = screen.getByText(/test/i);
|
|
21
|
+
expect(box.tagName).toBe("DIV");
|
|
22
|
+
});
|
|
23
|
+
it("should pass through data attributes", () => {
|
|
24
|
+
render(_jsx(Box, { "data-test": "foo", children: "Test" }));
|
|
25
|
+
const box = screen.getByText(/test/i);
|
|
26
|
+
expect(box.dataset.test).toBe("foo");
|
|
27
|
+
});
|
|
28
|
+
it("should support className", () => {
|
|
29
|
+
render(_jsx(Box, { className: "foo", children: "Test" }));
|
|
30
|
+
const box = screen.getByText(/test/i);
|
|
31
|
+
expect(box).toHaveClass("foo");
|
|
32
|
+
});
|
|
33
|
+
it("should support style", () => {
|
|
34
|
+
render(_jsx(Box, { style: { fontWeight: 700 }, children: "Test" }));
|
|
35
|
+
const box = screen.getByText(/test/i);
|
|
36
|
+
expect(box).toHaveStyle({ fontWeight: 700 });
|
|
37
|
+
});
|
|
38
|
+
it("should support computed class names", () => {
|
|
39
|
+
render(_jsx(Box, { display: "flex", margin: 2, children: "Test" }));
|
|
40
|
+
const box = screen.getByText(/test/i);
|
|
41
|
+
expect(box).toHaveClass(`${NS}-flex`);
|
|
42
|
+
expect(box).toHaveClass(`${NS}-margin-2`);
|
|
43
|
+
});
|
|
44
|
+
it("should attach ref", () => {
|
|
45
|
+
const ref = createRef();
|
|
46
|
+
render(_jsx(Box, { ref: ref, children: "Test" }));
|
|
47
|
+
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
48
|
+
expect(ref.current).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
it("should not support unsupported/invalid props in types", () => {
|
|
51
|
+
// "foo" is not a valid HTML attribute
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
render(_jsx(Box, { foo: "bar", children: "Test" }));
|
|
54
|
+
const box = screen.getByText(/test/i);
|
|
55
|
+
expect(box).toHaveAttribute("foo", "bar");
|
|
56
|
+
});
|
|
57
|
+
describe("asChild", () => {
|
|
58
|
+
it("should render as child with asChild prop", () => {
|
|
59
|
+
render(_jsx(Box, { asChild: true, "data-test": "foo", children: _jsx(Button, { intent: "primary", children: "Test" }) }));
|
|
60
|
+
const button = screen.getByRole("button", { name: /test/i });
|
|
61
|
+
expect(button).toHaveClass(Classes.BOX);
|
|
62
|
+
expect(button).toHaveClass(CoreClasses.BUTTON);
|
|
63
|
+
expect(button).toHaveClass(CoreClasses.INTENT_PRIMARY);
|
|
64
|
+
expect(button).toHaveAttribute("data-test", "foo");
|
|
65
|
+
});
|
|
66
|
+
it("should merge styles with asChild prop", () => {
|
|
67
|
+
render(_jsx(Box, { asChild: true, style: { fontWeight: 700 }, children: _jsx(Button, { style: { color: "blue" }, children: "Test" }) }));
|
|
68
|
+
const button = screen.getByRole("button", { name: /test/i });
|
|
69
|
+
expect(button).toHaveStyle({ fontWeight: 700 });
|
|
70
|
+
});
|
|
71
|
+
it("should remove margin on wrapped component", () => {
|
|
72
|
+
render(_jsx(Box, { asChild: true, marginYEnd: 0, children: _jsx(H1, { children: "Test" }) }));
|
|
73
|
+
const h1 = screen.getByRole("heading", { name: /test/i });
|
|
74
|
+
expect(h1).toHaveClass(`${NS}-margin-block-end-0`);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=box.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.test.js","sourceRoot":"","sources":["../../../../src/components/box/box.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAA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C;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACjD,MAAM,CACF,KAAC,GAAG,IAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,YAC7B,KAAC,EAAE,uBAAU,GACX,CACT,CAAC;YACF,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAqB,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAE9E,MAAM,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,qBAAqB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop-type definitions for the <Box> component.
|
|
3
|
+
*
|
|
4
|
+
* The guiding idea behind <Box> is to provide a small, typed subset of the
|
|
5
|
+
* CSS box-model and flexbox APIs as *props* instead of requiring consumers to
|
|
6
|
+
* write custom styles or class names. We purposefully whitelist only a finite
|
|
7
|
+
* number of safe values (see the union literals below) so that:
|
|
8
|
+
*
|
|
9
|
+
* 1. Design-system-approved spacing / sizing tokens can be enforced at compile
|
|
10
|
+
* time.
|
|
11
|
+
* 2. We can consistently translate prop values into utility class names
|
|
12
|
+
* generated by `buildStyles`.
|
|
13
|
+
* 3. Invalid HTML attributes (e.g. `foo="bar"`) are rejected by TypeScript in
|
|
14
|
+
* user code, while *supported* DOM props such as `id`, `title`, etc. are
|
|
15
|
+
* still allowed through the generic overlay.
|
|
16
|
+
*/
|
|
17
|
+
import type * as React from "react";
|
|
18
|
+
/**
|
|
19
|
+
* The range of values for spacing tokens.
|
|
20
|
+
*/
|
|
21
|
+
type SpacingRange = 0 | 0.5 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
22
|
+
/**
|
|
23
|
+
* The range of values for size as a percentage.
|
|
24
|
+
*/
|
|
25
|
+
type SizeRange = 25 | 50 | 75 | 100;
|
|
26
|
+
/**
|
|
27
|
+
* The range of values for `gap`.
|
|
28
|
+
*
|
|
29
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/gap
|
|
30
|
+
*/
|
|
31
|
+
export type Gap = SpacingRange | `${SpacingRange}`;
|
|
32
|
+
/**
|
|
33
|
+
* The range of values for `margin`.
|
|
34
|
+
*
|
|
35
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin
|
|
36
|
+
*/
|
|
37
|
+
export type Margin = SpacingRange | `${SpacingRange}` | "auto";
|
|
38
|
+
/**
|
|
39
|
+
* The range of values for `padding`.
|
|
40
|
+
*
|
|
41
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
|
42
|
+
*/
|
|
43
|
+
export type Padding = SpacingRange | `${SpacingRange}`;
|
|
44
|
+
/**
|
|
45
|
+
* The range of values for `inset`.
|
|
46
|
+
*
|
|
47
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/inset
|
|
48
|
+
*/
|
|
49
|
+
export type Inset = SpacingRange | `${SpacingRange}`;
|
|
50
|
+
/**
|
|
51
|
+
* The range of values for `width`.
|
|
52
|
+
*
|
|
53
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/width
|
|
54
|
+
*/
|
|
55
|
+
export type Width = SizeRange | `${SizeRange}` | "auto";
|
|
56
|
+
/**
|
|
57
|
+
* The range of values for `height`.
|
|
58
|
+
*
|
|
59
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/height
|
|
60
|
+
*/
|
|
61
|
+
export type Height = SizeRange | `${SizeRange}` | "auto";
|
|
62
|
+
/**
|
|
63
|
+
* The range of values for `align-content`.
|
|
64
|
+
*
|
|
65
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
|
|
66
|
+
*/
|
|
67
|
+
export type AlignContent = "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly" | "stretch" | "normal" | "baseline";
|
|
68
|
+
/**
|
|
69
|
+
* The range of values for `align-items`.
|
|
70
|
+
*
|
|
71
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
|
|
72
|
+
*/
|
|
73
|
+
export type AlignItems = "start" | "end" | "center" | "baseline" | "stretch";
|
|
74
|
+
/**
|
|
75
|
+
* The range of values for `align-self`.
|
|
76
|
+
*
|
|
77
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/align-self
|
|
78
|
+
*/
|
|
79
|
+
export type AlignSelf = "auto" | "start" | "end" | "center" | "baseline" | "stretch";
|
|
80
|
+
/**
|
|
81
|
+
* The range of values for `display`.
|
|
82
|
+
*
|
|
83
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/display
|
|
84
|
+
*/
|
|
85
|
+
export type Display = "block" | "inline-block" | "inline" | "flex" | "inline-flex" | "grid" | "inline-grid" | "table" | "inline-table" | "table-cell" | "table-row" | "none";
|
|
86
|
+
/**
|
|
87
|
+
* The range of values for `flex`.
|
|
88
|
+
*
|
|
89
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex
|
|
90
|
+
*/
|
|
91
|
+
export type Flex = 1 | "1" | "auto" | "initial" | "none";
|
|
92
|
+
/**
|
|
93
|
+
* The range of values for `flex-direction`.
|
|
94
|
+
*
|
|
95
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
|
|
96
|
+
*/
|
|
97
|
+
export type FlexDirection = "row" | "row-reverse" | "column" | "column-reverse";
|
|
98
|
+
/**
|
|
99
|
+
* The range of values for `flex-wrap`.
|
|
100
|
+
*
|
|
101
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap
|
|
102
|
+
*/
|
|
103
|
+
export type FlexWrap = "nowrap" | "wrap" | "wrap-reverse";
|
|
104
|
+
/**
|
|
105
|
+
* The range of values for `justify-content`.
|
|
106
|
+
*
|
|
107
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
|
|
108
|
+
*/
|
|
109
|
+
export type JustifyContent = "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly" | "stretch" | "normal";
|
|
110
|
+
/**
|
|
111
|
+
* The range of values for `justify-items`.
|
|
112
|
+
*
|
|
113
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items
|
|
114
|
+
*/
|
|
115
|
+
export type JustifyItems = "start" | "end" | "center" | "stretch";
|
|
116
|
+
/**
|
|
117
|
+
* The range of values for `justify-self`.
|
|
118
|
+
*
|
|
119
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self
|
|
120
|
+
*/
|
|
121
|
+
export type JustifySelf = "auto" | "start" | "end" | "center" | "stretch";
|
|
122
|
+
/**
|
|
123
|
+
* The range of values for `overflow`.
|
|
124
|
+
*
|
|
125
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/overflow
|
|
126
|
+
*/
|
|
127
|
+
export type Overflow = "visible" | "hidden" | "scroll" | "auto";
|
|
128
|
+
/**
|
|
129
|
+
* The range of values for `position`.
|
|
130
|
+
*
|
|
131
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/position
|
|
132
|
+
*/
|
|
133
|
+
export type Position = "static" | "absolute" | "relative" | "fixed" | "sticky";
|
|
134
|
+
/**
|
|
135
|
+
* Props for the `<Box>` component.
|
|
136
|
+
*
|
|
137
|
+
* Extends standard HTML div props with Box-specific layout props.
|
|
138
|
+
*/
|
|
139
|
+
export interface BoxProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
140
|
+
/**
|
|
141
|
+
* When true, `<Box>` will **not** render an extra wrapper element. Instead, it will
|
|
142
|
+
* clone & enhance its single child element, merging class names and props.
|
|
143
|
+
*/
|
|
144
|
+
asChild?: boolean;
|
|
145
|
+
/** Shorthand for the CSS `gap` property (applies to flex and grid layouts). */
|
|
146
|
+
gap?: Gap;
|
|
147
|
+
/** CSS `margin` */
|
|
148
|
+
margin?: Margin;
|
|
149
|
+
/** CSS `margin-inline` */
|
|
150
|
+
marginX?: Margin;
|
|
151
|
+
/** CSS `margin-inline-start` */
|
|
152
|
+
marginXStart?: Margin;
|
|
153
|
+
/** CSS `margin-inline-end` */
|
|
154
|
+
marginXEnd?: Margin;
|
|
155
|
+
/** CSS `margin-block` */
|
|
156
|
+
marginY?: Margin;
|
|
157
|
+
/** CSS `margin-block-start` */
|
|
158
|
+
marginYStart?: Margin;
|
|
159
|
+
/** CSS `margin-block-end` */
|
|
160
|
+
marginYEnd?: Margin;
|
|
161
|
+
/** CSS `margin-top` */
|
|
162
|
+
marginTop?: Margin;
|
|
163
|
+
/** CSS `margin-right` */
|
|
164
|
+
marginRight?: Margin;
|
|
165
|
+
/** CSS `margin-bottom` */
|
|
166
|
+
marginBottom?: Margin;
|
|
167
|
+
/** CSS `margin-left` */
|
|
168
|
+
marginLeft?: Margin;
|
|
169
|
+
/** CSS `padding` */
|
|
170
|
+
padding?: Padding;
|
|
171
|
+
/** CSS `padding-inline` */
|
|
172
|
+
paddingX?: Padding;
|
|
173
|
+
/** CSS `padding-inline-start` */
|
|
174
|
+
paddingXStart?: Padding;
|
|
175
|
+
/** CSS `padding-inline-end` */
|
|
176
|
+
paddingXEnd?: Padding;
|
|
177
|
+
/** CSS `padding-block` */
|
|
178
|
+
paddingY?: Padding;
|
|
179
|
+
/** CSS `padding-block-start` */
|
|
180
|
+
paddingYStart?: Padding;
|
|
181
|
+
/** CSS `padding-block-end` */
|
|
182
|
+
paddingYEnd?: Padding;
|
|
183
|
+
/** CSS `padding-top` */
|
|
184
|
+
paddingTop?: Padding;
|
|
185
|
+
/** CSS `padding-right` */
|
|
186
|
+
paddingRight?: Padding;
|
|
187
|
+
/** CSS `padding-bottom` */
|
|
188
|
+
paddingBottom?: Padding;
|
|
189
|
+
/** CSS `padding-left` */
|
|
190
|
+
paddingLeft?: Padding;
|
|
191
|
+
/** CSS `inset` */
|
|
192
|
+
inset?: Inset;
|
|
193
|
+
/** CSS `inset-inline` */
|
|
194
|
+
insetX?: Inset;
|
|
195
|
+
/** CSS `inset-inline-start` */
|
|
196
|
+
insetXStart?: Inset;
|
|
197
|
+
/** CSS `inset-inline-end` */
|
|
198
|
+
insetXEnd?: Inset;
|
|
199
|
+
/** CSS `inset-block` */
|
|
200
|
+
insetY?: Inset;
|
|
201
|
+
/** CSS `inset-block-start` */
|
|
202
|
+
insetYStart?: Inset;
|
|
203
|
+
/** CSS `inset-block-end` */
|
|
204
|
+
insetYEnd?: Inset;
|
|
205
|
+
/** CSS `top` */
|
|
206
|
+
insetTop?: Inset;
|
|
207
|
+
/** CSS `right` */
|
|
208
|
+
insetRight?: Inset;
|
|
209
|
+
/** CSS `bottom` */
|
|
210
|
+
insetBottom?: Inset;
|
|
211
|
+
/** CSS `left` */
|
|
212
|
+
insetLeft?: Inset;
|
|
213
|
+
/** CSS `width` */
|
|
214
|
+
width?: Width;
|
|
215
|
+
/** CSS `height` */
|
|
216
|
+
height?: Height;
|
|
217
|
+
/** CSS `align-content` */
|
|
218
|
+
alignContent?: AlignContent;
|
|
219
|
+
/** CSS `align-items` */
|
|
220
|
+
alignItems?: AlignItems;
|
|
221
|
+
/** CSS `align-self` */
|
|
222
|
+
alignSelf?: AlignSelf;
|
|
223
|
+
/** CSS `display` */
|
|
224
|
+
display?: Display;
|
|
225
|
+
/** CSS `flex` (shorthand for `flex-grow`, `flex-shrink`, `flex-basis`) */
|
|
226
|
+
flex?: Flex;
|
|
227
|
+
/** CSS `flex-direction` */
|
|
228
|
+
flexDirection?: FlexDirection;
|
|
229
|
+
/** CSS `flex-wrap` */
|
|
230
|
+
flexWrap?: FlexWrap;
|
|
231
|
+
/** CSS `justify-content` */
|
|
232
|
+
justifyContent?: JustifyContent;
|
|
233
|
+
/** CSS `justify-items` */
|
|
234
|
+
justifyItems?: JustifyItems;
|
|
235
|
+
/** CSS `justify-self` */
|
|
236
|
+
justifySelf?: JustifySelf;
|
|
237
|
+
/** CSS `position` */
|
|
238
|
+
position?: Position;
|
|
239
|
+
/** CSS `overflow` */
|
|
240
|
+
overflow?: Overflow;
|
|
241
|
+
/** CSS `overflow-x` */
|
|
242
|
+
overflowX?: Overflow;
|
|
243
|
+
/** CSS `overflow-y` */
|
|
244
|
+
overflowY?: Overflow;
|
|
245
|
+
}
|
|
246
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxProps.js","sourceRoot":"","sources":["../../../../src/components/box/boxProps.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime helper that converts <Box> style-props into utility class names.
|
|
3
|
+
*
|
|
4
|
+
* The implementation is intentionally simple:
|
|
5
|
+
* 1. A prop key that exists in the `styles` map is considered a style prop.
|
|
6
|
+
* Its value is run through a converter (created via `appendValue` or
|
|
7
|
+
* `mapping`) which returns the corresponding class string, e.g.
|
|
8
|
+
* `display="flex"` → `"flex"`.
|
|
9
|
+
* 2. Any prop that is *not* in the map is assumed to be a valid intrinsic
|
|
10
|
+
* DOM attribute (e.g. `id`, `title`) or a component-specific prop and is
|
|
11
|
+
* therefore forwarded untouched.
|
|
12
|
+
*
|
|
13
|
+
* Returns an object with two pieces of information:
|
|
14
|
+
* • `generatedClassNames` – an array of class names to apply to the element.
|
|
15
|
+
* • `passThroughProps` – the remaining props to forward.
|
|
16
|
+
*
|
|
17
|
+
* @param props - The props object to convert.
|
|
18
|
+
* @returns An object with `generatedClassNames` and `passThroughProps`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildStyles<T extends Record<string, any>>(props: T): {
|
|
21
|
+
generatedClassNames: string[];
|
|
22
|
+
passThroughProps: Record<string, unknown>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/* eslint-disable sort-keys */
|
|
5
|
+
import { Classes } from "../../common";
|
|
6
|
+
const NS = Classes.getClassNamespace();
|
|
7
|
+
/**
|
|
8
|
+
* Runtime helper that converts <Box> style-props into utility class names.
|
|
9
|
+
*
|
|
10
|
+
* The implementation is intentionally simple:
|
|
11
|
+
* 1. A prop key that exists in the `styles` map is considered a style prop.
|
|
12
|
+
* Its value is run through a converter (created via `appendValue` or
|
|
13
|
+
* `mapping`) which returns the corresponding class string, e.g.
|
|
14
|
+
* `display="flex"` → `"flex"`.
|
|
15
|
+
* 2. Any prop that is *not* in the map is assumed to be a valid intrinsic
|
|
16
|
+
* DOM attribute (e.g. `id`, `title`) or a component-specific prop and is
|
|
17
|
+
* therefore forwarded untouched.
|
|
18
|
+
*
|
|
19
|
+
* Returns an object with two pieces of information:
|
|
20
|
+
* • `generatedClassNames` – an array of class names to apply to the element.
|
|
21
|
+
* • `passThroughProps` – the remaining props to forward.
|
|
22
|
+
*
|
|
23
|
+
* @param props - The props object to convert.
|
|
24
|
+
* @returns An object with `generatedClassNames` and `passThroughProps`.
|
|
25
|
+
*/
|
|
26
|
+
export function buildStyles(props) {
|
|
27
|
+
const classNames = new Set();
|
|
28
|
+
const passThroughProps = {};
|
|
29
|
+
for (const [key, value] of Object.entries(props)) {
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(styles, key)) {
|
|
31
|
+
const className = styles[key]?.(value);
|
|
32
|
+
if (className != null) {
|
|
33
|
+
classNames.add(className);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
passThroughProps[key] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { generatedClassNames: Array.from(classNames), passThroughProps };
|
|
41
|
+
}
|
|
42
|
+
function appendValue(prefix) {
|
|
43
|
+
return (value) => `${NS}-${prefix}-${value}`;
|
|
44
|
+
}
|
|
45
|
+
function mapping(styleMap) {
|
|
46
|
+
return (value) => `${NS}-${styleMap[value]}`;
|
|
47
|
+
}
|
|
48
|
+
const gap = appendValue("gap");
|
|
49
|
+
const margin = appendValue("margin");
|
|
50
|
+
const marginX = appendValue("margin-inline");
|
|
51
|
+
const marginXStart = appendValue("margin-inline-start");
|
|
52
|
+
const marginXEnd = appendValue("margin-inline-end");
|
|
53
|
+
const marginY = appendValue("margin-block");
|
|
54
|
+
const marginYStart = appendValue("margin-block-start");
|
|
55
|
+
const marginYEnd = appendValue("margin-block-end");
|
|
56
|
+
const marginTop = appendValue("margin-top");
|
|
57
|
+
const marginRight = appendValue("margin-right");
|
|
58
|
+
const marginBottom = appendValue("margin-bottom");
|
|
59
|
+
const marginLeft = appendValue("margin-left");
|
|
60
|
+
const padding = appendValue("padding");
|
|
61
|
+
const paddingX = appendValue("padding-inline");
|
|
62
|
+
const paddingXStart = appendValue("padding-inline-start");
|
|
63
|
+
const paddingXEnd = appendValue("padding-inline-end");
|
|
64
|
+
const paddingY = appendValue("padding-block");
|
|
65
|
+
const paddingYStart = appendValue("padding-block-start");
|
|
66
|
+
const paddingYEnd = appendValue("padding-block-end");
|
|
67
|
+
const paddingTop = appendValue("padding-top");
|
|
68
|
+
const paddingRight = appendValue("padding-right");
|
|
69
|
+
const paddingBottom = appendValue("padding-bottom");
|
|
70
|
+
const paddingLeft = appendValue("padding-left");
|
|
71
|
+
const width = mapping({
|
|
72
|
+
25: "width-25",
|
|
73
|
+
50: "width-50",
|
|
74
|
+
75: "width-75",
|
|
75
|
+
100: "width-100",
|
|
76
|
+
auto: "width-auto",
|
|
77
|
+
});
|
|
78
|
+
const height = mapping({
|
|
79
|
+
25: "height-25",
|
|
80
|
+
50: "height-50",
|
|
81
|
+
75: "height-75",
|
|
82
|
+
100: "height-100",
|
|
83
|
+
auto: "height-auto",
|
|
84
|
+
});
|
|
85
|
+
const inset = appendValue("inset");
|
|
86
|
+
const insetX = appendValue("inset-inline");
|
|
87
|
+
const insetXStart = appendValue("inset-inline-start");
|
|
88
|
+
const insetXEnd = appendValue("inset-inline-end");
|
|
89
|
+
const insetY = appendValue("inset-block");
|
|
90
|
+
const insetYStart = appendValue("inset-block-start");
|
|
91
|
+
const insetYEnd = appendValue("inset-block-end");
|
|
92
|
+
const insetTop = appendValue("inset-top");
|
|
93
|
+
const insetRight = appendValue("inset-right");
|
|
94
|
+
const insetBottom = appendValue("inset-bottom");
|
|
95
|
+
const insetLeft = appendValue("inset-left");
|
|
96
|
+
const alignContent = mapping({
|
|
97
|
+
start: "content-start",
|
|
98
|
+
center: "content-center",
|
|
99
|
+
end: "content-end",
|
|
100
|
+
"space-between": "content-between",
|
|
101
|
+
"space-around": "content-around",
|
|
102
|
+
"space-evenly": "content-evenly",
|
|
103
|
+
stretch: "content-stretch",
|
|
104
|
+
normal: "content-normal",
|
|
105
|
+
baseline: "content-baseline",
|
|
106
|
+
});
|
|
107
|
+
const alignItems = mapping({
|
|
108
|
+
start: "items-start",
|
|
109
|
+
end: "items-end",
|
|
110
|
+
center: "items-center",
|
|
111
|
+
baseline: "items-baseline",
|
|
112
|
+
stretch: "items-stretch",
|
|
113
|
+
});
|
|
114
|
+
const alignSelf = mapping({
|
|
115
|
+
auto: "self-auto",
|
|
116
|
+
start: "self-start",
|
|
117
|
+
end: "self-end",
|
|
118
|
+
center: "self-center",
|
|
119
|
+
baseline: "self-baseline",
|
|
120
|
+
stretch: "self-stretch",
|
|
121
|
+
});
|
|
122
|
+
const display = mapping({
|
|
123
|
+
block: "block",
|
|
124
|
+
"inline-block": "inline-block",
|
|
125
|
+
inline: "inline",
|
|
126
|
+
flex: "flex",
|
|
127
|
+
"inline-flex": "inline-flex",
|
|
128
|
+
grid: "grid",
|
|
129
|
+
"inline-grid": "inline-grid",
|
|
130
|
+
table: "table",
|
|
131
|
+
"inline-table": "inline-table",
|
|
132
|
+
"table-row": "table-row",
|
|
133
|
+
"table-cell": "table-cell",
|
|
134
|
+
none: "none",
|
|
135
|
+
});
|
|
136
|
+
const flex = mapping({
|
|
137
|
+
"1": "flex-1",
|
|
138
|
+
auto: "flex-auto",
|
|
139
|
+
initial: "flex-initial",
|
|
140
|
+
none: "flex-none",
|
|
141
|
+
});
|
|
142
|
+
const flexDirection = mapping({
|
|
143
|
+
row: "flex-row",
|
|
144
|
+
"row-reverse": "flex-row-reverse",
|
|
145
|
+
column: "flex-column",
|
|
146
|
+
"column-reverse": "flex-column-reverse",
|
|
147
|
+
});
|
|
148
|
+
const flexWrap = mapping({
|
|
149
|
+
nowrap: "flex-nowrap",
|
|
150
|
+
wrap: "flex-wrap",
|
|
151
|
+
"wrap-reverse": "flex-wrap-reverse",
|
|
152
|
+
});
|
|
153
|
+
const justifyContent = mapping({
|
|
154
|
+
start: "justify-start",
|
|
155
|
+
center: "justify-center",
|
|
156
|
+
end: "justify-end",
|
|
157
|
+
"space-between": "justify-between",
|
|
158
|
+
"space-around": "justify-around",
|
|
159
|
+
"space-evenly": "justify-evenly",
|
|
160
|
+
normal: "justify-normal",
|
|
161
|
+
stretch: "justify-stretch",
|
|
162
|
+
});
|
|
163
|
+
const justifyItems = mapping({
|
|
164
|
+
start: "justify-items-start",
|
|
165
|
+
end: "justify-items-end",
|
|
166
|
+
center: "justify-items-center",
|
|
167
|
+
stretch: "justify-items-stretch",
|
|
168
|
+
});
|
|
169
|
+
const justifySelf = mapping({
|
|
170
|
+
auto: "justify-self-auto",
|
|
171
|
+
start: "justify-self-start",
|
|
172
|
+
end: "justify-self-end",
|
|
173
|
+
center: "justify-self-center",
|
|
174
|
+
stretch: "justify-self-stretch",
|
|
175
|
+
});
|
|
176
|
+
const position = mapping({
|
|
177
|
+
static: "static",
|
|
178
|
+
relative: "relative",
|
|
179
|
+
absolute: "absolute",
|
|
180
|
+
fixed: "fixed",
|
|
181
|
+
sticky: "sticky",
|
|
182
|
+
});
|
|
183
|
+
const overflow = mapping({
|
|
184
|
+
visible: "overflow-visible",
|
|
185
|
+
hidden: "overflow-hidden",
|
|
186
|
+
scroll: "overflow-scroll",
|
|
187
|
+
auto: "overflow-auto",
|
|
188
|
+
});
|
|
189
|
+
const overflowX = mapping({
|
|
190
|
+
visible: "overflow-x-visible",
|
|
191
|
+
hidden: "overflow-x-hidden",
|
|
192
|
+
scroll: "overflow-x-scroll",
|
|
193
|
+
auto: "overflow-x-auto",
|
|
194
|
+
});
|
|
195
|
+
const overflowY = mapping({
|
|
196
|
+
visible: "overflow-y-visible",
|
|
197
|
+
hidden: "overflow-y-hidden",
|
|
198
|
+
scroll: "overflow-y-scroll",
|
|
199
|
+
auto: "overflow-y-auto",
|
|
200
|
+
});
|
|
201
|
+
// Look-up table of style-prop name → converter function
|
|
202
|
+
const styles = {
|
|
203
|
+
gap,
|
|
204
|
+
margin,
|
|
205
|
+
marginX,
|
|
206
|
+
marginXStart,
|
|
207
|
+
marginXEnd,
|
|
208
|
+
marginY,
|
|
209
|
+
marginYStart,
|
|
210
|
+
marginYEnd,
|
|
211
|
+
marginTop,
|
|
212
|
+
marginRight,
|
|
213
|
+
marginBottom,
|
|
214
|
+
marginLeft,
|
|
215
|
+
padding,
|
|
216
|
+
paddingX,
|
|
217
|
+
paddingXStart,
|
|
218
|
+
paddingXEnd,
|
|
219
|
+
paddingY,
|
|
220
|
+
paddingYStart,
|
|
221
|
+
paddingYEnd,
|
|
222
|
+
paddingTop,
|
|
223
|
+
paddingRight,
|
|
224
|
+
paddingBottom,
|
|
225
|
+
paddingLeft,
|
|
226
|
+
inset,
|
|
227
|
+
insetX,
|
|
228
|
+
insetXStart,
|
|
229
|
+
insetXEnd,
|
|
230
|
+
insetY,
|
|
231
|
+
insetYStart,
|
|
232
|
+
insetYEnd,
|
|
233
|
+
insetTop,
|
|
234
|
+
insetRight,
|
|
235
|
+
insetBottom,
|
|
236
|
+
insetLeft,
|
|
237
|
+
width,
|
|
238
|
+
height,
|
|
239
|
+
alignContent,
|
|
240
|
+
alignItems,
|
|
241
|
+
alignSelf,
|
|
242
|
+
display,
|
|
243
|
+
flex,
|
|
244
|
+
flexDirection,
|
|
245
|
+
flexWrap,
|
|
246
|
+
justifyContent,
|
|
247
|
+
justifyItems,
|
|
248
|
+
justifySelf,
|
|
249
|
+
position,
|
|
250
|
+
overflow,
|
|
251
|
+
overflowX,
|
|
252
|
+
overflowY,
|
|
253
|
+
};
|
|
254
|
+
//# sourceMappingURL=buildStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildStyles.js","sourceRoot":"","sources":["../../../../src/components/box/buildStyles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8BAA8B;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuBvC,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAgC,KAAQ;IAC/D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,gBAAgB,GAA4B,EAAE,CAAC;IAErD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;YACpD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACpB,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,gBAAgB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAClC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,WAAW,CAAI,MAAc;IAClC,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,OA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AAI,EAAE,iBAAiB;CAC1B,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,OAAO,CAAW;IAChC,OAAO,EAAE,oBAAoB;IAC7B,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE,mBAAmB;IAC3B,IAAI,EAAE,iBAAiB;CAC1B,CAAC,CAAC;AAEH,wDAAwD;AACxD,MAAM,MAAM,GAA2C;IACnD,GAAG;IAEH,MAAM;IACN,OAAO;IACP,YAAY;IACZ,UAAU;IACV,OAAO;IACP,YAAY;IACZ,UAAU;IACV,SAAS;IACT,WAAW;IACX,YAAY;IACZ,UAAU;IAEV,OAAO;IACP,QAAQ;IACR,aAAa;IACb,WAAW;IACX,QAAQ;IACR,aAAa;IACb,WAAW;IACX,UAAU;IACV,YAAY;IACZ,aAAa;IACb,WAAW;IAEX,KAAK;IACL,MAAM;IACN,WAAW;IACX,SAAS;IACT,MAAM;IACN,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,SAAS;IAET,KAAK;IACL,MAAM;IAEN,YAAY;IACZ,UAAU;IACV,SAAS;IACT,OAAO;IACP,IAAI;IACJ,aAAa;IACb,QAAQ;IACR,cAAc;IACd,YAAY;IACZ,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,SAAS;CACZ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from "../box/boxProps";
|
|
3
|
+
export type FlexProps = Omit<BoxProps, "display">;
|
|
4
|
+
/**
|
|
5
|
+
* Flex component.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Flex: import("react").ForwardRefExoticComponent<FlexProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* !
|
|
3
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import { DISPLAYNAME_PREFIX } from "../../common";
|
|
7
|
+
import { Box } from "../box/box";
|
|
8
|
+
/**
|
|
9
|
+
* Flex component.
|
|
10
|
+
*/
|
|
11
|
+
export const Flex = forwardRef(function Flex(props, ref) {
|
|
12
|
+
return _jsx(Box, { ...props, display: "flex", ref: ref });
|
|
13
|
+
});
|
|
14
|
+
Flex.displayName = `${DISPLAYNAME_PREFIX}.Flex`;
|
|
15
|
+
//# sourceMappingURL=flex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flex.js","sourceRoot":"","sources":["../../../../src/components/flex/flex.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAKjC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAA4B,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG;IAC9E,OAAO,KAAC,GAAG,OAAK,KAAK,EAAE,OAAO,EAAC,MAAM,EAAC,GAAG,EAAE,GAAG,GAAI,CAAC;AACvD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,WAAW,GAAG,GAAG,kBAAkB,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|