@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,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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,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 {};
|
|
@@ -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,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,MAAM,CACF,KAA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
|
-
*
|
|
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
|
*/
|
|
5
|
+
export { Box } from "./box/box";
|
|
6
|
+
export { Flex } from "./flex/flex";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA
|
|
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,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QACxC,MAAM,CACF,KAAC,IAAI,iBAAW,KAAK,YACjB,iBAAQ,EAAE,EAAC,KAAK,qBAAc,GAC3B,CACV,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAoB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAEhF,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAClC,MAAM,CACF,KAAC,IAAI,IAAC,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,YAC9C,iBAAQ,SAAS,EAAC,OAAO,EAAC,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,qBAE/C,GACN,CACV,CAA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AAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAE/E,MAAM,CAAC,GAAG,EAAE;YACR,MAAM,CACF,MAAC,IAAI,eACD,qCAAsB,EACtB,sCAAuB,IACpB,CACV,CAAC;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;QAE3D,cAAc,CAAC,WAAW,EAAE,CAAC;QAC7B,eAAe,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export * from "./common";
|
|
2
|
-
export * from "./components";
|
|
3
|
-
import { Popover, Tooltip } from "@blueprintjs/core";
|
|
4
|
-
export declare const Popover2: typeof Popover;
|
|
5
|
-
export declare const Tooltip2: typeof Tooltip;
|
|
6
|
-
import { Omnibar } from "@blueprintjs/select";
|
|
7
|
-
export declare const Omnibox: typeof Omnibar;
|
|
8
|
-
export * from "@blueprintjs/select";
|
|
9
|
-
export { ITimezonePickerProps, ITimezonePickerState, TimezoneDisplayFormat, TimezonePicker } from "@blueprintjs/timezone";
|
|
1
|
+
export * from "./common";
|
|
2
|
+
export * from "./components";
|
package/lib/esm/index.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
export var Popover2 = Popover;
|
|
9
|
-
export var Tooltip2 = Tooltip;
|
|
10
|
-
import { Omnibar } from "@blueprintjs/select";
|
|
11
|
-
export var Omnibox = Omnibar;
|
|
12
|
-
export * from "@blueprintjs/select";
|
|
13
|
-
export { TimezoneDisplayFormat, TimezonePicker, } from "@blueprintjs/timezone";
|
|
5
|
+
export * from "./common";
|
|
6
|
+
export * from "./components";
|
|
14
7
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
*/
|
|
5
|
+
import { Classes } from "@blueprintjs/core";
|
|
6
|
+
const CORE_NS = Classes.getClassNamespace();
|
|
7
|
+
const NS = `${CORE_NS}-labs`;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the namespace prefix for all Blueprint CSS classes.
|
|
10
|
+
* Customize this namespace at build time by defining it with `webpack.DefinePlugin`.
|
|
11
|
+
*/
|
|
12
|
+
export function getClassNamespace() {
|
|
13
|
+
return NS;
|
|
14
|
+
}
|
|
15
|
+
export const BOX = `${NS}-box`;
|
|
16
|
+
//# sourceMappingURL=classes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.js","sourceRoot":"","sources":["../../../src/common/classes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAE5C,MAAM,EAAE,GAAG,GAAG,OAAO,OAAO,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC7B,OAAO,EAAE,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE,MAAM,CAAC"}
|
|
@@ -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
|
+
import * as Classes from "./classes";
|
|
6
|
+
export { DISPLAYNAME_PREFIX } from "./props";
|
|
7
|
+
export { Classes };
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DISPLAYNAME_PREFIX = "Blueprint6Labs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* !
|
|
2
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
*/
|
|
5
|
+
import { DISPLAYNAME_PREFIX as CORE_DISPLAYNAME_PREFIX } from "@blueprintjs/core";
|
|
6
|
+
export const DISPLAYNAME_PREFIX = `${CORE_DISPLAYNAME_PREFIX}Labs`;
|
|
7
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/common/props.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,IAAI,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAElF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,uBAAuB,MAAM,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from "./boxProps";
|
|
3
|
+
/**
|
|
4
|
+
* Box component.
|
|
5
|
+
*
|
|
6
|
+
* @see https://blueprintjs.com/docs/#labs/components/box
|
|
7
|
+
*/
|
|
8
|
+
export declare const Box: import("react").ForwardRefExoticComponent<BoxProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* !
|
|
3
|
+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import classNames from "classnames";
|
|
6
|
+
import { forwardRef, useMemo } from "react";
|
|
7
|
+
import { Classes, DISPLAYNAME_PREFIX } from "../../common";
|
|
8
|
+
import { Slot } from "../slot/slot";
|
|
9
|
+
import { buildStyles } from "./buildStyles";
|
|
10
|
+
/**
|
|
11
|
+
* Box component.
|
|
12
|
+
*
|
|
13
|
+
* @see https://blueprintjs.com/docs/#labs/components/box
|
|
14
|
+
*/
|
|
15
|
+
export const Box = forwardRef(function Box({ asChild, className, ...props }, ref) {
|
|
16
|
+
const Component = asChild ? Slot : "div";
|
|
17
|
+
const { generatedClassNames, passThroughProps } = useMemo(() => buildStyles(props), [props]);
|
|
18
|
+
return (_jsx(Component, { ...passThroughProps, className: classNames(className, Classes.BOX, generatedClassNames), ref: ref }));
|
|
19
|
+
});
|
|
20
|
+
Box.displayName = `${DISPLAYNAME_PREFIX}.Box`;
|
|
21
|
+
//# sourceMappingURL=box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.js","sourceRoot":"","sources":["../../../../src/components/box/box.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAA2B,SAAS,GAAG,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACtG,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzC,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAE7F,OAAO,CACH,KAAC,SAAS,OACF,gBAAgB,EACpB,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,EAClE,GAAG,EAAE,GAAG,GACV,CACL,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,WAAW,GAAG,GAAG,kBAAkB,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|