@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.
Files changed (148) hide show
  1. package/LICENSE +153 -167
  2. package/README.md +1 -1
  3. package/lib/cjs/common/classes.d.ts +6 -0
  4. package/lib/cjs/common/classes.js +20 -0
  5. package/lib/cjs/common/classes.js.map +1 -0
  6. package/lib/cjs/common/index.d.ts +3 -1
  7. package/lib/cjs/common/index.js +9 -4
  8. package/lib/cjs/common/index.js.map +1 -1
  9. package/lib/cjs/common/props.d.ts +1 -0
  10. package/lib/cjs/common/props.js +10 -0
  11. package/lib/cjs/common/props.js.map +1 -0
  12. package/lib/cjs/components/box/box.d.ts +8 -0
  13. package/lib/cjs/components/box/box.js +25 -0
  14. package/lib/cjs/components/box/box.js.map +1 -0
  15. package/lib/cjs/components/box/box.test.d.ts +1 -0
  16. package/lib/cjs/components/box/box.test.js +80 -0
  17. package/lib/cjs/components/box/box.test.js.map +1 -0
  18. package/lib/cjs/components/box/boxProps.d.ts +246 -0
  19. package/lib/cjs/components/box/boxProps.js +6 -0
  20. package/lib/cjs/components/box/boxProps.js.map +1 -0
  21. package/lib/cjs/components/box/buildStyles.d.ts +23 -0
  22. package/lib/cjs/components/box/buildStyles.js +258 -0
  23. package/lib/cjs/components/box/buildStyles.js.map +1 -0
  24. package/lib/cjs/components/flex/flex.d.ts +7 -0
  25. package/lib/cjs/components/flex/flex.js +18 -0
  26. package/lib/cjs/components/flex/flex.js.map +1 -0
  27. package/lib/cjs/components/flex/flex.test.d.ts +1 -0
  28. package/lib/cjs/components/flex/flex.test.js +59 -0
  29. package/lib/cjs/components/flex/flex.test.js.map +1 -0
  30. package/lib/cjs/components/index.d.ts +3 -1
  31. package/lib/cjs/components/index.js +8 -4
  32. package/lib/cjs/components/index.js.map +1 -1
  33. package/lib/cjs/components/slot/slot.d.ts +7 -0
  34. package/lib/cjs/components/slot/slot.js +31 -0
  35. package/lib/cjs/components/slot/slot.js.map +1 -0
  36. package/lib/cjs/components/slot/slot.test.d.ts +1 -0
  37. package/lib/cjs/components/slot/slot.test.js +47 -0
  38. package/lib/cjs/components/slot/slot.test.js.map +1 -0
  39. package/lib/cjs/index.d.ts +0 -7
  40. package/lib/cjs/index.js +6 -15
  41. package/lib/cjs/index.js.map +1 -1
  42. package/lib/css/blueprint-labs.css +1630 -7
  43. package/lib/css/blueprint-labs.css.map +1 -10
  44. package/lib/esm/common/classes.d.ts +6 -0
  45. package/lib/esm/common/classes.js +16 -0
  46. package/lib/esm/common/classes.js.map +1 -0
  47. package/lib/esm/common/index.d.ts +3 -1
  48. package/lib/esm/common/index.js +6 -4
  49. package/lib/esm/common/index.js.map +1 -1
  50. package/lib/esm/common/props.d.ts +1 -0
  51. package/lib/esm/common/props.js +7 -0
  52. package/lib/esm/common/props.js.map +1 -0
  53. package/lib/esm/components/box/box.d.ts +8 -0
  54. package/lib/esm/components/box/box.js +21 -0
  55. package/lib/esm/components/box/box.js.map +1 -0
  56. package/lib/esm/components/box/box.test.d.ts +1 -0
  57. package/lib/esm/components/box/box.test.js +78 -0
  58. package/lib/esm/components/box/box.test.js.map +1 -0
  59. package/lib/esm/components/box/boxProps.d.ts +246 -0
  60. package/lib/esm/components/box/boxProps.js +5 -0
  61. package/lib/esm/components/box/boxProps.js.map +1 -0
  62. package/lib/esm/components/box/buildStyles.d.ts +23 -0
  63. package/lib/esm/components/box/buildStyles.js +254 -0
  64. package/lib/esm/components/box/buildStyles.js.map +1 -0
  65. package/lib/esm/components/flex/flex.d.ts +7 -0
  66. package/lib/esm/components/flex/flex.js +15 -0
  67. package/lib/esm/components/flex/flex.js.map +1 -0
  68. package/lib/esm/components/flex/flex.test.d.ts +1 -0
  69. package/lib/esm/components/flex/flex.test.js +57 -0
  70. package/lib/esm/components/flex/flex.test.js.map +1 -0
  71. package/lib/esm/components/index.d.ts +3 -1
  72. package/lib/esm/components/index.js +5 -4
  73. package/lib/esm/components/index.js.map +1 -1
  74. package/lib/esm/components/slot/slot.d.ts +7 -0
  75. package/lib/esm/components/slot/slot.js +27 -0
  76. package/lib/esm/components/slot/slot.js.map +1 -0
  77. package/lib/esm/components/slot/slot.test.d.ts +1 -0
  78. package/lib/esm/components/slot/slot.test.js +45 -0
  79. package/lib/esm/components/slot/slot.test.js.map +1 -0
  80. package/lib/esm/index.d.ts +2 -9
  81. package/lib/esm/index.js +5 -12
  82. package/lib/esm/index.js.map +1 -1
  83. package/lib/esnext/common/classes.d.ts +6 -0
  84. package/lib/esnext/common/classes.js +16 -0
  85. package/lib/esnext/common/classes.js.map +1 -0
  86. package/lib/esnext/common/index.d.ts +3 -0
  87. package/lib/esnext/common/index.js +8 -0
  88. package/lib/esnext/common/index.js.map +1 -0
  89. package/lib/esnext/common/props.d.ts +1 -0
  90. package/lib/esnext/common/props.js +7 -0
  91. package/lib/esnext/common/props.js.map +1 -0
  92. package/lib/esnext/components/box/box.d.ts +8 -0
  93. package/lib/esnext/components/box/box.js +21 -0
  94. package/lib/esnext/components/box/box.js.map +1 -0
  95. package/lib/esnext/components/box/box.test.d.ts +1 -0
  96. package/lib/esnext/components/box/box.test.js +78 -0
  97. package/lib/esnext/components/box/box.test.js.map +1 -0
  98. package/lib/esnext/components/box/boxProps.d.ts +246 -0
  99. package/lib/esnext/components/box/boxProps.js +5 -0
  100. package/lib/esnext/components/box/boxProps.js.map +1 -0
  101. package/lib/esnext/components/box/buildStyles.d.ts +23 -0
  102. package/lib/esnext/components/box/buildStyles.js +254 -0
  103. package/lib/esnext/components/box/buildStyles.js.map +1 -0
  104. package/lib/esnext/components/flex/flex.d.ts +7 -0
  105. package/lib/esnext/components/flex/flex.js +15 -0
  106. package/lib/esnext/components/flex/flex.js.map +1 -0
  107. package/lib/esnext/components/flex/flex.test.d.ts +1 -0
  108. package/lib/esnext/components/flex/flex.test.js +57 -0
  109. package/lib/esnext/components/flex/flex.test.js.map +1 -0
  110. package/lib/esnext/components/index.d.ts +3 -0
  111. package/lib/esnext/components/index.js +7 -0
  112. package/lib/esnext/components/index.js.map +1 -0
  113. package/lib/esnext/components/slot/slot.d.ts +7 -0
  114. package/lib/esnext/components/slot/slot.js +27 -0
  115. package/lib/esnext/components/slot/slot.js.map +1 -0
  116. package/lib/esnext/components/slot/slot.test.d.ts +1 -0
  117. package/lib/esnext/components/slot/slot.test.js +45 -0
  118. package/lib/esnext/components/slot/slot.test.js.map +1 -0
  119. package/lib/esnext/index.d.ts +2 -0
  120. package/lib/esnext/index.js +7 -0
  121. package/lib/esnext/index.js.map +1 -0
  122. package/package.json +59 -44
  123. package/src/_common.scss +9 -0
  124. package/src/blueprint-labs.scss +5 -7
  125. package/src/common/classes.ts +20 -0
  126. package/src/common/index.ts +7 -6
  127. package/src/common/props.ts +8 -0
  128. package/src/components/box/_box.scss +543 -0
  129. package/src/components/box/box.md +59 -0
  130. package/src/components/box/box.test.tsx +119 -0
  131. package/src/components/box/box.tsx +32 -0
  132. package/src/components/box/boxProps.ts +334 -0
  133. package/src/components/box/buildStyles.ts +307 -0
  134. package/src/components/flex/flex.md +52 -0
  135. package/src/components/flex/flex.test.tsx +93 -0
  136. package/src/components/flex/flex.tsx +20 -0
  137. package/src/components/index.ts +6 -6
  138. package/src/components/slot/slot.test.tsx +73 -0
  139. package/src/components/slot/slot.tsx +30 -0
  140. package/src/index.md +16 -5
  141. package/src/index.ts +3 -20
  142. package/src/tsconfig.json +5 -3
  143. package/src/vitest-env.d.ts +6 -0
  144. package/vitest.config.mts +17 -0
  145. package/vitest.setup.mts +13 -0
  146. package/dist/labs.bundle.js +0 -1
  147. package/src/components/_index.scss +0 -3
  148. package/src/tsconfig.cjs.json +0 -7
@@ -0,0 +1,543 @@
1
+ /* !
2
+ * (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
3
+ */
4
+
5
+ @use "../../common" as bp;
6
+
7
+ $sizes: (
8
+ "0": 0,
9
+ "0\\.5": bp.$pt-spacing * 0.5,
10
+ "1": bp.$pt-spacing,
11
+ "2": bp.$pt-spacing * 2,
12
+ "3": bp.$pt-spacing * 3,
13
+ "4": bp.$pt-spacing * 4,
14
+ "5": bp.$pt-spacing * 5,
15
+ "6": bp.$pt-spacing * 6,
16
+ "7": bp.$pt-spacing * 7,
17
+ "8": bp.$pt-spacing * 8,
18
+ "9": bp.$pt-spacing * 9,
19
+ "10": bp.$pt-spacing * 10,
20
+ );
21
+
22
+ $relative-sizes: (
23
+ "25": 25%,
24
+ "50": 50%,
25
+ "75": 75%,
26
+ "100": 100%,
27
+ "auto": auto,
28
+ );
29
+
30
+ .#{bp.$ns}-box {
31
+ @each $i, $value in $sizes {
32
+ &.#{bp.$ns}-gap-#{$i} {
33
+ gap: $value;
34
+ }
35
+
36
+ &.#{bp.$ns}-margin-#{$i} {
37
+ margin: $value;
38
+ }
39
+
40
+ &.#{bp.$ns}-margin-inline-#{$i} {
41
+ margin-inline: $value;
42
+ }
43
+
44
+ &.#{bp.$ns}-margin-inline-start-#{$i} {
45
+ margin-inline-start: $value;
46
+ }
47
+
48
+ &.#{bp.$ns}-margin-inline-end-#{$i} {
49
+ margin-inline-end: $value;
50
+ }
51
+
52
+ &.#{bp.$ns}-margin-block-#{$i} {
53
+ margin-block: $value;
54
+ }
55
+
56
+ &.#{bp.$ns}-margin-block-start-#{$i} {
57
+ margin-block-start: $value;
58
+ }
59
+
60
+ &.#{bp.$ns}-margin-block-end-#{$i} {
61
+ margin-block-end: $value;
62
+ }
63
+
64
+ &.#{bp.$ns}-margin-top-#{$i} {
65
+ margin-top: $value;
66
+ }
67
+
68
+ &.#{bp.$ns}-margin-right-#{$i} {
69
+ margin-right: $value;
70
+ }
71
+
72
+ &.#{bp.$ns}-margin-bottom-#{$i} {
73
+ margin-bottom: $value;
74
+ }
75
+
76
+ &.#{bp.$ns}-margin-left-#{$i} {
77
+ margin-left: $value;
78
+ }
79
+
80
+ &.#{bp.$ns}-padding-#{$i} {
81
+ padding: $value;
82
+ }
83
+
84
+ &.#{bp.$ns}-padding-inline-#{$i} {
85
+ padding-inline: $value;
86
+ }
87
+
88
+ &.#{bp.$ns}-padding-inline-start-#{$i} {
89
+ padding-inline-start: $value;
90
+ }
91
+
92
+ &.#{bp.$ns}-padding-inline-end-#{$i} {
93
+ padding-inline-end: $value;
94
+ }
95
+
96
+ &.#{bp.$ns}-padding-block-#{$i} {
97
+ padding-block: $value;
98
+ }
99
+
100
+ &.#{bp.$ns}-padding-block-start-#{$i} {
101
+ padding-block-start: $value;
102
+ }
103
+
104
+ &.#{bp.$ns}-padding-block-end-#{$i} {
105
+ padding-block-end: $value;
106
+ }
107
+
108
+ &.#{bp.$ns}-padding-top-#{$i} {
109
+ padding-top: $value;
110
+ }
111
+
112
+ &.#{bp.$ns}-padding-right-#{$i} {
113
+ padding-right: $value;
114
+ }
115
+
116
+ &.#{bp.$ns}-padding-bottom-#{$i} {
117
+ padding-bottom: $value;
118
+ }
119
+
120
+ &.#{bp.$ns}-padding-left-#{$i} {
121
+ padding-left: $value;
122
+ }
123
+
124
+ &.#{bp.$ns}-inset-#{$i} {
125
+ inset: $value;
126
+ }
127
+
128
+ &.#{bp.$ns}-inset-inline-#{$i} {
129
+ inset-inline: $value;
130
+ }
131
+
132
+ &.#{bp.$ns}-inset-inline-start-#{$i} {
133
+ inset-inline-start: $value;
134
+ }
135
+
136
+ &.#{bp.$ns}-inset-inline-end-#{$i} {
137
+ inset-inline-end: $value;
138
+ }
139
+
140
+ &.#{bp.$ns}-inset-block-#{$i} {
141
+ inset-block: $value;
142
+ }
143
+
144
+ &.#{bp.$ns}-inset-block-start-#{$i} {
145
+ inset-block-start: $value;
146
+ }
147
+
148
+ &.#{bp.$ns}-inset-block-end-#{$i} {
149
+ inset-block-end: $value;
150
+ }
151
+
152
+ &.#{bp.$ns}-inset-top-#{$i} {
153
+ top: $value;
154
+ }
155
+
156
+ &.#{bp.$ns}-inset-right-#{$i} {
157
+ right: $value;
158
+ }
159
+
160
+ &.#{bp.$ns}-inset-bottom-#{$i} {
161
+ bottom: $value;
162
+ }
163
+
164
+ &.#{bp.$ns}-inset-left-#{$i} {
165
+ left: $value;
166
+ }
167
+ }
168
+
169
+ &.#{bp.$ns}-margin-auto {
170
+ margin: auto;
171
+ }
172
+
173
+ &.#{bp.$ns}-margin-inline-auto {
174
+ margin-inline: auto;
175
+ }
176
+
177
+ &.#{bp.$ns}-margin-inline-start-auto {
178
+ margin-inline-start: auto;
179
+ }
180
+
181
+ &.#{bp.$ns}-margin-inline-end-auto {
182
+ margin-inline-end: auto;
183
+ }
184
+
185
+ &.#{bp.$ns}-margin-block-auto {
186
+ margin-block: auto;
187
+ }
188
+
189
+ &.#{bp.$ns}-margin-block-start-auto {
190
+ margin-block-start: auto;
191
+ }
192
+
193
+ &.#{bp.$ns}-margin-block-end-auto {
194
+ margin-block-end: auto;
195
+ }
196
+
197
+ &.#{bp.$ns}-margin-top-auto {
198
+ margin-top: auto;
199
+ }
200
+
201
+ &.#{bp.$ns}-margin-right-auto {
202
+ margin-right: auto;
203
+ }
204
+
205
+ &.#{bp.$ns}-margin-bottom-auto {
206
+ margin-bottom: auto;
207
+ }
208
+
209
+ &.#{bp.$ns}-margin-left-auto {
210
+ margin-left: auto;
211
+ }
212
+
213
+ // width & height
214
+ @each $name, $size in $relative-sizes {
215
+ &.#{bp.$ns}-width-#{$name} {
216
+ width: $size;
217
+ }
218
+
219
+ &.#{bp.$ns}-height-#{$name} {
220
+ height: $size;
221
+ }
222
+ }
223
+
224
+ // align-content
225
+ &.#{bp.$ns}-content-start {
226
+ align-content: flex-start;
227
+ }
228
+
229
+ &.#{bp.$ns}-content-end {
230
+ align-content: flex-end;
231
+ }
232
+
233
+ &.#{bp.$ns}-content-center {
234
+ align-content: center;
235
+ }
236
+
237
+ &.#{bp.$ns}-content-between {
238
+ align-content: space-between;
239
+ }
240
+
241
+ &.#{bp.$ns}-content-around {
242
+ align-content: space-around;
243
+ }
244
+
245
+ &.#{bp.$ns}-content-evenly {
246
+ align-content: space-evenly;
247
+ }
248
+
249
+ &.#{bp.$ns}-content-normal {
250
+ align-content: normal;
251
+ }
252
+
253
+ &.#{bp.$ns}-content-baseline {
254
+ align-content: baseline;
255
+ }
256
+
257
+ &.#{bp.$ns}-content-stretch {
258
+ align-content: stretch;
259
+ }
260
+
261
+ // align-items
262
+ &.#{bp.$ns}-items-start {
263
+ align-items: flex-start;
264
+ }
265
+
266
+ &.#{bp.$ns}-items-end {
267
+ align-items: flex-end;
268
+ }
269
+
270
+ &.#{bp.$ns}-items-center {
271
+ align-items: center;
272
+ }
273
+
274
+ &.#{bp.$ns}-items-baseline {
275
+ align-items: baseline;
276
+ }
277
+
278
+ &.#{bp.$ns}-items-stretch {
279
+ align-items: stretch;
280
+ }
281
+
282
+ // align-self
283
+ &.#{bp.$ns}-self-auto {
284
+ align-self: auto;
285
+ }
286
+
287
+ &.#{bp.$ns}-self-start {
288
+ align-self: flex-start;
289
+ }
290
+
291
+ &.#{bp.$ns}-self-end {
292
+ align-self: flex-end;
293
+ }
294
+
295
+ &.#{bp.$ns}-self-center {
296
+ align-self: center;
297
+ }
298
+
299
+ &.#{bp.$ns}-self-baseline {
300
+ align-self: stretch;
301
+ }
302
+
303
+ &.#{bp.$ns}-self-stretch {
304
+ align-self: baseline;
305
+ }
306
+
307
+ // display
308
+ &.#{bp.$ns}-block {
309
+ display: block;
310
+ }
311
+
312
+ &.#{bp.$ns}-inline-block {
313
+ display: inline-block;
314
+ }
315
+
316
+ &.#{bp.$ns}-inline {
317
+ display: inline;
318
+ }
319
+
320
+ &.#{bp.$ns}-flex {
321
+ display: flex;
322
+ }
323
+
324
+ &.#{bp.$ns}-inline-flex {
325
+ display: inline-flex;
326
+ }
327
+
328
+ &.#{bp.$ns}-grid {
329
+ display: grid;
330
+ }
331
+
332
+ &.#{bp.$ns}-inline-grid {
333
+ display: inline-grid;
334
+ }
335
+
336
+ &.#{bp.$ns}-table {
337
+ display: table;
338
+ }
339
+
340
+ &.#{bp.$ns}-inline-table {
341
+ display: inline-table;
342
+ }
343
+
344
+ &.#{bp.$ns}-table-cell {
345
+ display: table-cell;
346
+ }
347
+
348
+ &.#{bp.$ns}-table-row {
349
+ display: table-row;
350
+ }
351
+
352
+ &.#{bp.$ns}-none {
353
+ display: none;
354
+ }
355
+
356
+ // flex
357
+ &.#{bp.$ns}-flex-1 {
358
+ flex: 1 1 0%;
359
+ }
360
+
361
+ &.#{bp.$ns}-flex-auto {
362
+ flex: 1 1 auto;
363
+ }
364
+
365
+ &.#{bp.$ns}-flex-initial {
366
+ flex: 0 1 auto;
367
+ }
368
+
369
+ &.#{bp.$ns}-flex-none {
370
+ flex: none;
371
+ }
372
+
373
+ // flex-direction
374
+ &.#{bp.$ns}-flex-row {
375
+ flex-direction: row;
376
+ }
377
+
378
+ &.#{bp.$ns}-flex-row-reverse {
379
+ flex-direction: row-reverse;
380
+ }
381
+
382
+ &.#{bp.$ns}-flex-column {
383
+ flex-direction: column;
384
+ }
385
+
386
+ &.#{bp.$ns}-flex-column-reverse {
387
+ flex-direction: column-reverse;
388
+ }
389
+
390
+ // flex-wrap
391
+ &.#{bp.$ns}-flex-nowrap {
392
+ flex-wrap: nowrap;
393
+ }
394
+
395
+ &.#{bp.$ns}-flex-wrap {
396
+ flex-wrap: wrap;
397
+ }
398
+
399
+ &.#{bp.$ns}-flex-wrap-reverse {
400
+ flex-wrap: wrap-reverse;
401
+ }
402
+
403
+ // justify-content
404
+ &.#{bp.$ns}-justify-start {
405
+ justify-content: flex-start;
406
+ }
407
+
408
+ &.#{bp.$ns}-justify-end {
409
+ justify-content: flex-end;
410
+ }
411
+
412
+ &.#{bp.$ns}-justify-center {
413
+ justify-content: center;
414
+ }
415
+
416
+ &.#{bp.$ns}-justify-between {
417
+ justify-content: space-between;
418
+ }
419
+
420
+ &.#{bp.$ns}-justify-around {
421
+ justify-content: space-around;
422
+ }
423
+
424
+ &.#{bp.$ns}-justify-evenly {
425
+ justify-content: space-evenly;
426
+ }
427
+
428
+ &.#{bp.$ns}-justify-normal {
429
+ justify-content: normal;
430
+ }
431
+
432
+ &.#{bp.$ns}-justify-stretch {
433
+ justify-content: stretch;
434
+ }
435
+
436
+ // justify-items
437
+ &.#{bp.$ns}-justify-items-start {
438
+ justify-items: start;
439
+ }
440
+
441
+ &.#{bp.$ns}-justify-items-end {
442
+ justify-items: end;
443
+ }
444
+
445
+ &.#{bp.$ns}-justify-items-center {
446
+ justify-items: center;
447
+ }
448
+
449
+ &.#{bp.$ns}-justify-items-stretch {
450
+ justify-items: stretch;
451
+ }
452
+
453
+ // justify-self
454
+ &.#{bp.$ns}-justify-self-auto {
455
+ justify-self: auto;
456
+ }
457
+
458
+ &.#{bp.$ns}-justify-self-start {
459
+ justify-self: start;
460
+ }
461
+
462
+ &.#{bp.$ns}-justify-self-end {
463
+ justify-self: end;
464
+ }
465
+
466
+ &.#{bp.$ns}-justify-self-center {
467
+ justify-self: center;
468
+ }
469
+
470
+ &.#{bp.$ns}-justify-self-stretch {
471
+ justify-self: stretch;
472
+ }
473
+
474
+ // position
475
+ &.#{bp.$ns}-static {
476
+ position: static;
477
+ }
478
+
479
+ &.#{bp.$ns}-fixed {
480
+ position: fixed;
481
+ }
482
+
483
+ &.#{bp.$ns}-absolute {
484
+ position: absolute;
485
+ }
486
+
487
+ &.#{bp.$ns}-relative {
488
+ position: relative;
489
+ }
490
+
491
+ &.#{bp.$ns}-sticky {
492
+ position: sticky;
493
+ }
494
+
495
+ // overflow
496
+ &.#{bp.$ns}-overflow-visible {
497
+ overflow: visible;
498
+ }
499
+
500
+ &.#{bp.$ns}-overflow-hidden {
501
+ overflow: hidden;
502
+ }
503
+
504
+ &.#{bp.$ns}-overflow-scroll {
505
+ overflow: scroll;
506
+ }
507
+
508
+ &.#{bp.$ns}-overflow-auto {
509
+ overflow: auto;
510
+ }
511
+
512
+ &.#{bp.$ns}-overflow-x-visible {
513
+ overflow-x: visible;
514
+ }
515
+
516
+ &.#{bp.$ns}-overflow-x-hidden {
517
+ overflow-x: hidden;
518
+ }
519
+
520
+ &.#{bp.$ns}-overflow-x-scroll {
521
+ overflow-x: scroll;
522
+ }
523
+
524
+ &.#{bp.$ns}-overflow-x-auto {
525
+ overflow-x: auto;
526
+ }
527
+
528
+ &.#{bp.$ns}-overflow-y-visible {
529
+ overflow-y: visible;
530
+ }
531
+
532
+ &.#{bp.$ns}-overflow-y-hidden {
533
+ overflow-y: hidden;
534
+ }
535
+
536
+ &.#{bp.$ns}-overflow-y-scroll {
537
+ overflow-y: scroll;
538
+ }
539
+
540
+ &.#{bp.$ns}-overflow-y-auto {
541
+ overflow-y: auto;
542
+ }
543
+ }
@@ -0,0 +1,59 @@
1
+ ---
2
+ tag: new
3
+ ---
4
+
5
+ @# Box
6
+
7
+ **Box** is a generic layout component that exposes a subset of the [CSS box-model](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Box_model) and [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_flexible_box_layout) APIs as props. It enables layout composition using Blueprint's spacing and sizing design tokens.
8
+
9
+ @## Import
10
+
11
+ ```tsx
12
+ import { Box } from "@blueprintjs/labs";
13
+ ```
14
+
15
+ @## Usage
16
+
17
+ Use **Box** to compose layouts with spacing, alignment, and sizing props.
18
+
19
+ @reactCodeExample BoxBasicExample
20
+
21
+ @## Composition with asChild
22
+
23
+ When `asChild` is set, `<Box>` will not render an extra wrapper element. Instead it clones and enhances its single child, merging class names and props.
24
+ This is useful for applying layout to existing components without adding an extra DOM node.
25
+
26
+ @reactCodeExample BoxAsChildExample
27
+
28
+ @## Layout props
29
+
30
+ Box supports a wide range of layout props that map to CSS properties:
31
+
32
+ - **Spacing**: `margin`, `padding` and their logical variants
33
+ - **Positioning**: `position`, `inset` and their logical variants
34
+ - **Sizing**: `width`, `height`
35
+ - **Flexbox**: `display`, `flex`, `flexDirection`, `flexWrap`, `gap`
36
+ - **Alignment**: `alignItems`, `alignContent`, `alignSelf`, `justifyContent`, `justifyItems`, `justifySelf`
37
+ - **Overflow**: `overflow`, `overflowX`, `overflowY`
38
+
39
+ Each prop accepts Blueprint token values to enforce consistent spacing and sizing.
40
+
41
+ @## Examples
42
+
43
+ @### Padding
44
+
45
+ @reactExample BoxPaddingExample
46
+
47
+ @### Margin
48
+
49
+ @reactExample BoxMarginExample
50
+
51
+ @### Object Card
52
+
53
+ A practical example demonstrating how to compose a card layout using Box with multiple layout props working together.
54
+
55
+ @reactExample BoxObjectCardExample
56
+
57
+ @## Props interface
58
+
59
+ @interface BoxProps
@@ -0,0 +1,119 @@
1
+ /* !
2
+ * (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
3
+ */
4
+
5
+ import { render, screen } from "@testing-library/react";
6
+ import { createRef } from "react";
7
+ import { describe, expect, it } from "vitest";
8
+
9
+ import { Button, Classes as CoreClasses, H1 } from "@blueprintjs/core";
10
+
11
+ import { Classes } from "../../common";
12
+
13
+ import { Box } from "./box";
14
+
15
+ const NS = Classes.getClassNamespace();
16
+
17
+ describe("<Box>", () => {
18
+ it("should render content", () => {
19
+ render(<Box>Test</Box>);
20
+ const box = screen.getByText<HTMLDivElement>(/test/i);
21
+
22
+ expect(box).toBeInTheDocument();
23
+ });
24
+
25
+ it("should render as a div by default", () => {
26
+ render(<Box>Test</Box>);
27
+ const box = screen.getByText<HTMLDivElement>(/test/i);
28
+
29
+ expect(box.tagName).toBe("DIV");
30
+ });
31
+
32
+ it("should pass through data attributes", () => {
33
+ render(<Box data-test="foo">Test</Box>);
34
+ const box = screen.getByText<HTMLDivElement>(/test/i);
35
+
36
+ expect(box.dataset.test).toBe("foo");
37
+ });
38
+
39
+ it("should support className", () => {
40
+ render(<Box className="foo">Test</Box>);
41
+ const box = screen.getByText<HTMLDivElement>(/test/i);
42
+
43
+ expect(box).toHaveClass("foo");
44
+ });
45
+
46
+ it("should support style", () => {
47
+ render(<Box style={{ fontWeight: 700 }}>Test</Box>);
48
+ const box = screen.getByText<HTMLDivElement>(/test/i);
49
+
50
+ expect(box).toHaveStyle({ fontWeight: 700 });
51
+ });
52
+
53
+ it("should support computed class names", () => {
54
+ render(
55
+ <Box display="flex" margin={2}>
56
+ Test
57
+ </Box>,
58
+ );
59
+ const box = screen.getByText<HTMLDivElement>(/test/i);
60
+
61
+ expect(box).toHaveClass(`${NS}-flex`);
62
+ expect(box).toHaveClass(`${NS}-margin-2`);
63
+ });
64
+
65
+ it("should attach ref", () => {
66
+ const ref = createRef<HTMLDivElement>();
67
+ render(<Box ref={ref}>Test</Box>);
68
+
69
+ expect(ref.current).toBeInstanceOf(HTMLDivElement);
70
+ expect(ref.current).toBeInTheDocument();
71
+ });
72
+
73
+ it("should not support unsupported/invalid props in types", () => {
74
+ // "foo" is not a valid HTML attribute
75
+ // @ts-expect-error
76
+ render(<Box foo="bar">Test</Box>);
77
+ const box = screen.getByText<HTMLDivElement>(/test/i);
78
+
79
+ expect(box).toHaveAttribute("foo", "bar");
80
+ });
81
+
82
+ describe("asChild", () => {
83
+ it("should render as child with asChild prop", () => {
84
+ render(
85
+ <Box asChild={true} data-test="foo">
86
+ <Button intent="primary">Test</Button>
87
+ </Box>,
88
+ );
89
+ const button = screen.getByRole<HTMLButtonElement>("button", { name: /test/i });
90
+
91
+ expect(button).toHaveClass(Classes.BOX);
92
+ expect(button).toHaveClass(CoreClasses.BUTTON);
93
+ expect(button).toHaveClass(CoreClasses.INTENT_PRIMARY);
94
+ expect(button).toHaveAttribute("data-test", "foo");
95
+ });
96
+
97
+ it("should merge styles with asChild prop", () => {
98
+ render(
99
+ <Box asChild={true} style={{ fontWeight: 700 }}>
100
+ <Button style={{ color: "blue" }}>Test</Button>
101
+ </Box>,
102
+ );
103
+ const button = screen.getByRole<HTMLButtonElement>("button", { name: /test/i });
104
+
105
+ expect(button).toHaveStyle({ fontWeight: 700 });
106
+ });
107
+
108
+ it("should remove margin on wrapped component", () => {
109
+ render(
110
+ <Box asChild={true} marginYEnd={0}>
111
+ <H1>Test</H1>
112
+ </Box>,
113
+ );
114
+ const h1 = screen.getByRole<HTMLHeadingElement>("heading", { name: /test/i });
115
+
116
+ expect(h1).toHaveClass(`${NS}-margin-block-end-0`);
117
+ });
118
+ });
119
+ });