@bamboocss/preset-base 1.30.1 → 1.32.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/dist/index.cjs CHANGED
@@ -117,9 +117,18 @@ const conditions = {
117
117
  function definePattern(config) {
118
118
  return config;
119
119
  }
120
- const box = definePattern({ transform(props) {
121
- return props;
122
- } });
120
+ /**
121
+ * The one flexbox pattern. `stack`, `vstack`, `hstack` and `wrap` were this with defaults frozen
122
+ * — `stack` added `direction: 'column'` and an 8px gap, the two axis-named ones additionally
123
+ * hard-coded `align: 'center'` and dropped `direction` from the props, and `wrap` set
124
+ * `flexWrap: 'wrap'`. Five names, one transform, and four of them a superset of the fifth only in
125
+ * what they assumed for you.
126
+ *
127
+ * `gap` is deliberately not listed here and does not need to be: anything absent from
128
+ * `properties` still arrives as an ordinary style prop, so `flex({ gap: '6' })` types and folds
129
+ * exactly as it did through `stack`. What goes with the old names is the implicit `gap: '8px'`,
130
+ * which was a design opinion no call site asked for.
131
+ */
123
132
  const flex = definePattern({
124
133
  properties: {
125
134
  align: {
@@ -166,144 +175,24 @@ const flex = definePattern({
166
175
  };
167
176
  }
168
177
  });
169
- const stack = definePattern({
170
- properties: {
171
- align: {
172
- type: "property",
173
- value: "alignItems"
174
- },
175
- justify: {
176
- type: "property",
177
- value: "justifyContent"
178
- },
179
- direction: {
180
- type: "property",
181
- value: "flexDirection"
182
- },
183
- gap: {
184
- type: "property",
185
- value: "gap"
186
- }
187
- },
188
- defaultValues: {
189
- direction: "column",
190
- gap: "8px"
191
- },
192
- transform(props) {
193
- const { align, justify, direction, gap, ...rest } = props;
194
- return {
195
- display: "flex",
196
- flexDirection: direction,
197
- alignItems: align,
198
- justifyContent: justify,
199
- gap,
200
- ...rest
201
- };
202
- }
203
- });
204
- const vstack = definePattern({
205
- properties: {
206
- justify: {
207
- type: "property",
208
- value: "justifyContent"
209
- },
210
- gap: {
211
- type: "property",
212
- value: "gap"
213
- }
214
- },
215
- defaultValues: { gap: "8px" },
216
- transform(props) {
217
- const { justify, gap, ...rest } = props;
218
- return {
219
- display: "flex",
220
- alignItems: "center",
221
- justifyContent: justify,
222
- gap,
223
- flexDirection: "column",
224
- ...rest
225
- };
226
- }
227
- });
228
- const hstack = definePattern({
229
- properties: {
230
- justify: {
231
- type: "property",
232
- value: "justifyContent"
233
- },
234
- gap: {
235
- type: "property",
236
- value: "gap"
237
- }
238
- },
239
- defaultValues: { gap: "8px" },
240
- transform(props) {
241
- const { justify, gap, ...rest } = props;
242
- return {
243
- display: "flex",
244
- alignItems: "center",
245
- justifyContent: justify,
246
- gap,
247
- flexDirection: "row",
248
- ...rest
249
- };
250
- }
251
- });
252
178
  const spacer = definePattern({
253
179
  properties: { size: {
254
180
  type: "token",
255
181
  value: "spacing"
256
182
  } },
257
- transform(props, { map, isCssUnit, isCssVar }) {
183
+ transform(props, { map, isCssUnit, isCssVar, token }) {
258
184
  const { size, ...rest } = props;
259
185
  return {
260
186
  alignSelf: "stretch",
261
187
  justifySelf: "stretch",
262
188
  flex: map(size, (v) => {
263
189
  if (v == null) return "1";
264
- return `0 0 ${isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`}`;
190
+ return `0 0 ${isCssUnit(v) || isCssVar(v) ? v : token(`spacing.${v}`, v)}`;
265
191
  }),
266
192
  ...rest
267
193
  };
268
194
  }
269
195
  });
270
- const circle = definePattern({
271
- properties: { size: {
272
- type: "property",
273
- value: "width"
274
- } },
275
- transform(props) {
276
- const { size, ...rest } = props;
277
- return {
278
- display: "flex",
279
- alignItems: "center",
280
- justifyContent: "center",
281
- flex: "0 0 auto",
282
- width: size,
283
- height: size,
284
- borderRadius: "9999px",
285
- ...rest
286
- };
287
- }
288
- });
289
- const square = definePattern({
290
- properties: { size: {
291
- type: "property",
292
- value: "width"
293
- } },
294
- transform(props) {
295
- const { size, ...rest } = props;
296
- return {
297
- display: "flex",
298
- alignItems: "center",
299
- justifyContent: "center",
300
- flex: "0 0 auto",
301
- width: size,
302
- height: size,
303
- ...rest
304
- };
305
- }
306
- });
307
196
  const grid = definePattern({
308
197
  properties: {
309
198
  gap: {
@@ -328,9 +217,9 @@ const grid = definePattern({
328
217
  defaultValues(props) {
329
218
  return { gap: props.columnGap || props.rowGap ? void 0 : "8px" };
330
219
  },
331
- transform(props, { map, isCssUnit }) {
220
+ transform(props, { map, isCssUnit, token }) {
332
221
  const { columnGap, rowGap, gap, columns, minChildWidth, ...rest } = props;
333
- const getValue = (v) => isCssUnit(v) ? v : `token(sizes.${v}, ${v})`;
222
+ const getValue = (v) => isCssUnit(v) ? v : token(`sizes.${v}`, v);
334
223
  return {
335
224
  display: "grid",
336
225
  gridTemplateColumns: columns != null ? map(columns, (v) => `repeat(${v}, minmax(0, 1fr))`) : minChildWidth != null ? map(minChildWidth, (v) => `repeat(auto-fit, minmax(${getValue(v)}, 1fr))`) : void 0,
@@ -364,43 +253,6 @@ const gridItem = definePattern({
364
253
  };
365
254
  }
366
255
  });
367
- const wrap = definePattern({
368
- properties: {
369
- gap: {
370
- type: "property",
371
- value: "gap"
372
- },
373
- rowGap: {
374
- type: "property",
375
- value: "gap"
376
- },
377
- columnGap: {
378
- type: "property",
379
- value: "gap"
380
- },
381
- align: {
382
- type: "property",
383
- value: "alignItems"
384
- },
385
- justify: {
386
- type: "property",
387
- value: "justifyContent"
388
- }
389
- },
390
- transform(props) {
391
- const { columnGap, rowGap, gap = columnGap || rowGap ? void 0 : "8px", align, justify, ...rest } = props;
392
- return {
393
- display: "flex",
394
- flexWrap: "wrap",
395
- alignItems: align,
396
- justifyContent: justify,
397
- gap,
398
- columnGap,
399
- rowGap,
400
- ...rest
401
- };
402
- }
403
- });
404
256
  const container$1 = definePattern({ transform(props) {
405
257
  return {
406
258
  position: "relative",
@@ -414,21 +266,41 @@ const container$1 = definePattern({ transform(props) {
414
266
  ...props
415
267
  };
416
268
  } });
269
+ /**
270
+ * Absorbs what `square` and `circle` used to be. `square({ size })` is `center({ size })`, and
271
+ * `circle({ size })` is `center({ size, borderRadius: 'full' })` — `borderRadius` is an ordinary
272
+ * style prop, so the rounded case needs nothing here beyond the size the square case already
273
+ * wanted. Three patterns whose transforms differed by one declaration is three names to learn
274
+ * and three places for `alignItems: center` to drift.
275
+ *
276
+ * `flex: '0 0 auto'` rides with `size` rather than being unconditional: it is what stops a sized
277
+ * box from being shrunk by a flex parent, so it is meaningless without one, and applying it to
278
+ * an unsized `center` would change how every existing call lays out inside a flex row.
279
+ */
417
280
  const center = definePattern({
418
- properties: { inline: { type: "boolean" } },
281
+ properties: {
282
+ inline: { type: "boolean" },
283
+ size: {
284
+ type: "property",
285
+ value: "width"
286
+ }
287
+ },
419
288
  transform(props) {
420
- const { inline, ...rest } = props;
289
+ const { inline, size, ...rest } = props;
421
290
  return {
422
291
  display: inline ? "inline-flex" : "flex",
423
292
  alignItems: "center",
424
293
  justifyContent: "center",
294
+ flex: size == null ? void 0 : "0 0 auto",
295
+ width: size,
296
+ height: size,
425
297
  ...rest
426
298
  };
427
299
  }
428
300
  });
429
301
  const aspectRatio = definePattern({
430
302
  properties: { ratio: { type: "number" } },
431
- blocklist: ["aspectRatio"],
303
+ cssProps: { except: ["aspectRatio"] },
432
304
  transform(props, { map }) {
433
305
  const { ratio = 4 / 3, ...rest } = props;
434
306
  return {
@@ -489,14 +361,8 @@ const divider = definePattern({
489
361
  }
490
362
  });
491
363
  const patterns = {
492
- box,
493
364
  flex,
494
- stack,
495
- vstack,
496
- hstack,
497
365
  spacer,
498
- square,
499
- circle,
500
366
  center,
501
367
  linkOverlay: definePattern({ transform(props) {
502
368
  return {
@@ -513,7 +379,6 @@ const patterns = {
513
379
  aspectRatio,
514
380
  grid,
515
381
  gridItem,
516
- wrap,
517
382
  container: container$1,
518
383
  divider,
519
384
  float: definePattern({
@@ -627,9 +492,9 @@ const patterns = {
627
492
  inline: "0",
628
493
  block: "0"
629
494
  },
630
- transform(props, { map, isCssUnit, isCssVar }) {
495
+ transform(props, { map, isCssUnit, isCssVar, token }) {
631
496
  const { inline, block, ...rest } = props;
632
- const valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`;
497
+ const valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : token(`spacing.${v}`, v);
633
498
  return {
634
499
  "--bleed-x": map(inline, valueFn),
635
500
  "--bleed-y": map(block, valueFn),
@@ -638,34 +503,6 @@ const patterns = {
638
503
  ...rest
639
504
  };
640
505
  }
641
- }),
642
- visuallyHidden: definePattern({ transform(props) {
643
- return {
644
- srOnly: true,
645
- ...props
646
- };
647
- } }),
648
- cq: definePattern({
649
- properties: {
650
- name: {
651
- type: "token",
652
- value: "containerNames",
653
- property: "containerName"
654
- },
655
- type: {
656
- type: "property",
657
- value: "containerType"
658
- }
659
- },
660
- defaultValues: { type: "inline-size" },
661
- transform(props) {
662
- const { name, type, ...rest } = props;
663
- return {
664
- containerType: type,
665
- containerName: name,
666
- ...rest
667
- };
668
- }
669
506
  })
670
507
  };
671
508
  //#endregion
@@ -1105,28 +942,10 @@ const cursor = { cursor: {
1105
942
  } };
1106
943
  //#endregion
1107
944
  //#region src/utilities/display.ts
1108
- const display = {
1109
- display: {
1110
- className: "d",
1111
- group: "Display"
1112
- },
1113
- hideFrom: {
1114
- className: "hide",
1115
- values: "breakpoints",
1116
- group: "Display",
1117
- transform(value, { raw, token }) {
1118
- return { [token.raw(`breakpoints.${raw}`) ? `@breakpoint ${raw}` : `@media (width >= ${value})`]: { display: "none" } };
1119
- }
1120
- },
1121
- hideBelow: {
1122
- className: "show",
1123
- values: "breakpoints",
1124
- group: "Display",
1125
- transform(value, { raw, token }) {
1126
- return { [token.raw(`breakpoints.${raw}`) ? `@breakpoint ${raw}Down` : `@media (width < ${value})`]: { display: "none" } };
1127
- }
1128
- }
1129
- };
945
+ const display = { display: {
946
+ className: "d",
947
+ group: "Display"
948
+ } };
1130
949
  //#endregion
1131
950
  //#region src/utilities/divide.ts
1132
951
  const divideColor = createColorMixTransform("borderColor");
package/dist/index.d.cts CHANGED
@@ -112,17 +112,6 @@ declare const preset: {
112
112
  };
113
113
  utilities: import("@bamboocss/types").UtilityConfig;
114
114
  patterns: {
115
- box: {
116
- transform(props: {
117
- [x: string]: any;
118
- [x: number]: any;
119
- [x: string & Record<never, never>]: any;
120
- }): {
121
- [x: string]: any;
122
- [x: number]: any;
123
- [x: string & Record<never, never>]: any;
124
- };
125
- };
126
115
  flex: {
127
116
  properties: {
128
117
  align: {
@@ -169,93 +158,6 @@ declare const preset: {
169
158
  flexShrink: any;
170
159
  };
171
160
  };
172
- stack: {
173
- properties: {
174
- align: {
175
- type: "property";
176
- value: "alignItems";
177
- };
178
- justify: {
179
- type: "property";
180
- value: "justifyContent";
181
- };
182
- direction: {
183
- type: "property";
184
- value: "flexDirection";
185
- };
186
- gap: {
187
- type: "property";
188
- value: "gap";
189
- };
190
- };
191
- defaultValues: {
192
- direction: string;
193
- gap: string;
194
- };
195
- transform(props: {
196
- [x: string]: any;
197
- [x: number]: any;
198
- [x: string & Record<never, never>]: any;
199
- }): {
200
- display: "flex";
201
- flexDirection: any;
202
- alignItems: any;
203
- justifyContent: any;
204
- gap: any;
205
- };
206
- };
207
- vstack: {
208
- properties: {
209
- justify: {
210
- type: "property";
211
- value: "justifyContent";
212
- };
213
- gap: {
214
- type: "property";
215
- value: "gap";
216
- };
217
- };
218
- defaultValues: {
219
- gap: string;
220
- };
221
- transform(props: {
222
- [x: string]: any;
223
- [x: number]: any;
224
- [x: string & Record<never, never>]: any;
225
- }): {
226
- display: "flex";
227
- alignItems: "center";
228
- justifyContent: any;
229
- gap: any;
230
- flexDirection: "column";
231
- };
232
- };
233
- hstack: {
234
- properties: {
235
- justify: {
236
- type: "property";
237
- value: "justifyContent";
238
- };
239
- gap: {
240
- type: "property";
241
- value: "gap";
242
- };
243
- };
244
- defaultValues: {
245
- gap: string;
246
- };
247
- transform(props: {
248
- [x: string]: any;
249
- [x: number]: any;
250
- [x: string & Record<never, never>]: any;
251
- }): {
252
- display: "flex";
253
- alignItems: "center";
254
- justifyContent: any;
255
- gap: any;
256
- flexDirection: "row";
257
- };
258
- };
259
161
  spacer: {
260
162
  properties: {
261
163
  size: {
@@ -270,35 +172,19 @@ declare const preset: {
270
172
  }, {
271
173
  map,
272
174
  isCssUnit,
273
- isCssVar
175
+ isCssVar,
176
+ token
274
177
  }: import("@bamboocss/types").PatternHelpers): {
275
178
  alignSelf: "stretch";
276
179
  justifySelf: "stretch";
277
180
  flex: any;
278
181
  };
279
182
  };
280
- square: {
183
+ center: {
281
184
  properties: {
282
- size: {
283
- type: "property";
284
- value: "width";
185
+ inline: {
186
+ type: "boolean";
285
187
  };
286
- };
287
- transform(props: {
288
- [x: string]: any;
289
- [x: number]: any;
290
- [x: string & Record<never, never>]: any;
291
- }): {
292
- display: "flex";
293
- alignItems: "center";
294
- justifyContent: "center";
295
- flex: "0 0 auto";
296
- width: any;
297
- height: any;
298
- };
299
- };
300
- circle: {
301
- properties: {
302
188
  size: {
303
189
  type: "property";
304
190
  value: "width";
@@ -309,29 +195,12 @@ declare const preset: {
309
195
  [x: number]: any;
310
196
  [x: string & Record<never, never>]: any;
311
197
  }): {
312
- display: "flex";
198
+ display: "flex" | "inline-flex";
313
199
  alignItems: "center";
314
200
  justifyContent: "center";
315
- flex: "0 0 auto";
201
+ flex: "0 0 auto" | undefined;
316
202
  width: any;
317
203
  height: any;
318
- borderRadius: "9999px";
319
- };
320
- };
321
- center: {
322
- properties: {
323
- inline: {
324
- type: "boolean";
325
- };
326
- };
327
- transform(props: {
328
- [x: string]: any;
329
- [x: number]: any;
330
- [x: string & Record<never, never>]: any;
331
- }): {
332
- display: "flex" | "inline-flex";
333
- alignItems: "center";
334
- justifyContent: "center";
335
204
  };
336
205
  };
337
206
  linkOverlay: {
@@ -349,7 +218,9 @@ declare const preset: {
349
218
  type: "number";
350
219
  };
351
220
  };
352
- blocklist: "aspectRatio"[];
221
+ cssProps: {
222
+ except: "aspectRatio"[];
223
+ };
353
224
  transform(props: {
354
225
  [x: string]: any;
355
226
  [x: number]: any;
@@ -415,7 +286,8 @@ declare const preset: {
415
286
  [x: string & Record<never, never>]: any;
416
287
  }, {
417
288
  map,
418
- isCssUnit
289
+ isCssUnit,
290
+ token
419
291
  }: import("@bamboocss/types").PatternHelpers): {
420
292
  display: "grid";
421
293
  gridTemplateColumns: any;
@@ -460,43 +332,6 @@ declare const preset: {
460
332
  gridRowEnd: any;
461
333
  };
462
334
  };
463
- wrap: {
464
- properties: {
465
- gap: {
466
- type: "property";
467
- value: "gap";
468
- };
469
- rowGap: {
470
- type: "property";
471
- value: "gap";
472
- };
473
- columnGap: {
474
- type: "property";
475
- value: "gap";
476
- };
477
- align: {
478
- type: "property";
479
- value: "alignItems";
480
- };
481
- justify: {
482
- type: "property";
483
- value: "justifyContent";
484
- };
485
- };
486
- transform(props: {
487
- [x: string]: any;
488
- [x: number]: any;
489
- [x: string & Record<never, never>]: any;
490
- }): {
491
- display: "flex";
492
- flexWrap: "wrap";
493
- alignItems: any;
494
- justifyContent: any;
495
- gap: any;
496
- columnGap: any;
497
- rowGap: any;
498
- };
499
- };
500
335
  container: {
501
336
  transform(props: {
502
337
  [x: string]: any;
@@ -621,7 +456,8 @@ declare const preset: {
621
456
  }, {
622
457
  map,
623
458
  isCssUnit,
624
- isCssVar
459
+ isCssVar,
460
+ token
625
461
  }: import("@bamboocss/types").PatternHelpers): {
626
462
  '--bleed-x': any;
627
463
  '--bleed-y': any;
@@ -629,39 +465,6 @@ declare const preset: {
629
465
  marginBlock: "calc(var(--bleed-y, 0) * -1)";
630
466
  };
631
467
  };
632
- visuallyHidden: {
633
- transform(props: {
634
- [x: string]: any;
635
- [x: number]: any;
636
- [x: string & Record<never, never>]: any;
637
- }): {
638
- srOnly: true;
639
- };
640
- };
641
- cq: {
642
- properties: {
643
- name: {
644
- type: "token";
645
- value: "containerNames";
646
- property: "containerName";
647
- };
648
- type: {
649
- type: "property";
650
- value: "containerType";
651
- };
652
- };
653
- defaultValues: {
654
- type: string;
655
- };
656
- transform(props: {
657
- [x: string]: any;
658
- [x: number]: any;
659
- [x: string & Record<never, never>]: any;
660
- }): {
661
- containerType: any;
662
- containerName: any;
663
- };
664
- };
665
468
  };
666
469
  };
667
470
  //#endregion
package/dist/index.d.mts CHANGED
@@ -112,17 +112,6 @@ declare const preset: {
112
112
  };
113
113
  utilities: import("@bamboocss/types").UtilityConfig;
114
114
  patterns: {
115
- box: {
116
- transform(props: {
117
- [x: string]: any;
118
- [x: number]: any;
119
- [x: string & Record<never, never>]: any;
120
- }): {
121
- [x: string]: any;
122
- [x: number]: any;
123
- [x: string & Record<never, never>]: any;
124
- };
125
- };
126
115
  flex: {
127
116
  properties: {
128
117
  align: {
@@ -169,93 +158,6 @@ declare const preset: {
169
158
  flexShrink: any;
170
159
  };
171
160
  };
172
- stack: {
173
- properties: {
174
- align: {
175
- type: "property";
176
- value: "alignItems";
177
- };
178
- justify: {
179
- type: "property";
180
- value: "justifyContent";
181
- };
182
- direction: {
183
- type: "property";
184
- value: "flexDirection";
185
- };
186
- gap: {
187
- type: "property";
188
- value: "gap";
189
- };
190
- };
191
- defaultValues: {
192
- direction: string;
193
- gap: string;
194
- };
195
- transform(props: {
196
- [x: string]: any;
197
- [x: number]: any;
198
- [x: string & Record<never, never>]: any;
199
- }): {
200
- display: "flex";
201
- flexDirection: any;
202
- alignItems: any;
203
- justifyContent: any;
204
- gap: any;
205
- };
206
- };
207
- vstack: {
208
- properties: {
209
- justify: {
210
- type: "property";
211
- value: "justifyContent";
212
- };
213
- gap: {
214
- type: "property";
215
- value: "gap";
216
- };
217
- };
218
- defaultValues: {
219
- gap: string;
220
- };
221
- transform(props: {
222
- [x: string]: any;
223
- [x: number]: any;
224
- [x: string & Record<never, never>]: any;
225
- }): {
226
- display: "flex";
227
- alignItems: "center";
228
- justifyContent: any;
229
- gap: any;
230
- flexDirection: "column";
231
- };
232
- };
233
- hstack: {
234
- properties: {
235
- justify: {
236
- type: "property";
237
- value: "justifyContent";
238
- };
239
- gap: {
240
- type: "property";
241
- value: "gap";
242
- };
243
- };
244
- defaultValues: {
245
- gap: string;
246
- };
247
- transform(props: {
248
- [x: string]: any;
249
- [x: number]: any;
250
- [x: string & Record<never, never>]: any;
251
- }): {
252
- display: "flex";
253
- alignItems: "center";
254
- justifyContent: any;
255
- gap: any;
256
- flexDirection: "row";
257
- };
258
- };
259
161
  spacer: {
260
162
  properties: {
261
163
  size: {
@@ -270,35 +172,19 @@ declare const preset: {
270
172
  }, {
271
173
  map,
272
174
  isCssUnit,
273
- isCssVar
175
+ isCssVar,
176
+ token
274
177
  }: import("@bamboocss/types").PatternHelpers): {
275
178
  alignSelf: "stretch";
276
179
  justifySelf: "stretch";
277
180
  flex: any;
278
181
  };
279
182
  };
280
- square: {
183
+ center: {
281
184
  properties: {
282
- size: {
283
- type: "property";
284
- value: "width";
185
+ inline: {
186
+ type: "boolean";
285
187
  };
286
- };
287
- transform(props: {
288
- [x: string]: any;
289
- [x: number]: any;
290
- [x: string & Record<never, never>]: any;
291
- }): {
292
- display: "flex";
293
- alignItems: "center";
294
- justifyContent: "center";
295
- flex: "0 0 auto";
296
- width: any;
297
- height: any;
298
- };
299
- };
300
- circle: {
301
- properties: {
302
188
  size: {
303
189
  type: "property";
304
190
  value: "width";
@@ -309,29 +195,12 @@ declare const preset: {
309
195
  [x: number]: any;
310
196
  [x: string & Record<never, never>]: any;
311
197
  }): {
312
- display: "flex";
198
+ display: "flex" | "inline-flex";
313
199
  alignItems: "center";
314
200
  justifyContent: "center";
315
- flex: "0 0 auto";
201
+ flex: "0 0 auto" | undefined;
316
202
  width: any;
317
203
  height: any;
318
- borderRadius: "9999px";
319
- };
320
- };
321
- center: {
322
- properties: {
323
- inline: {
324
- type: "boolean";
325
- };
326
- };
327
- transform(props: {
328
- [x: string]: any;
329
- [x: number]: any;
330
- [x: string & Record<never, never>]: any;
331
- }): {
332
- display: "flex" | "inline-flex";
333
- alignItems: "center";
334
- justifyContent: "center";
335
204
  };
336
205
  };
337
206
  linkOverlay: {
@@ -349,7 +218,9 @@ declare const preset: {
349
218
  type: "number";
350
219
  };
351
220
  };
352
- blocklist: "aspectRatio"[];
221
+ cssProps: {
222
+ except: "aspectRatio"[];
223
+ };
353
224
  transform(props: {
354
225
  [x: string]: any;
355
226
  [x: number]: any;
@@ -415,7 +286,8 @@ declare const preset: {
415
286
  [x: string & Record<never, never>]: any;
416
287
  }, {
417
288
  map,
418
- isCssUnit
289
+ isCssUnit,
290
+ token
419
291
  }: import("@bamboocss/types").PatternHelpers): {
420
292
  display: "grid";
421
293
  gridTemplateColumns: any;
@@ -460,43 +332,6 @@ declare const preset: {
460
332
  gridRowEnd: any;
461
333
  };
462
334
  };
463
- wrap: {
464
- properties: {
465
- gap: {
466
- type: "property";
467
- value: "gap";
468
- };
469
- rowGap: {
470
- type: "property";
471
- value: "gap";
472
- };
473
- columnGap: {
474
- type: "property";
475
- value: "gap";
476
- };
477
- align: {
478
- type: "property";
479
- value: "alignItems";
480
- };
481
- justify: {
482
- type: "property";
483
- value: "justifyContent";
484
- };
485
- };
486
- transform(props: {
487
- [x: string]: any;
488
- [x: number]: any;
489
- [x: string & Record<never, never>]: any;
490
- }): {
491
- display: "flex";
492
- flexWrap: "wrap";
493
- alignItems: any;
494
- justifyContent: any;
495
- gap: any;
496
- columnGap: any;
497
- rowGap: any;
498
- };
499
- };
500
335
  container: {
501
336
  transform(props: {
502
337
  [x: string]: any;
@@ -621,7 +456,8 @@ declare const preset: {
621
456
  }, {
622
457
  map,
623
458
  isCssUnit,
624
- isCssVar
459
+ isCssVar,
460
+ token
625
461
  }: import("@bamboocss/types").PatternHelpers): {
626
462
  '--bleed-x': any;
627
463
  '--bleed-y': any;
@@ -629,39 +465,6 @@ declare const preset: {
629
465
  marginBlock: "calc(var(--bleed-y, 0) * -1)";
630
466
  };
631
467
  };
632
- visuallyHidden: {
633
- transform(props: {
634
- [x: string]: any;
635
- [x: number]: any;
636
- [x: string & Record<never, never>]: any;
637
- }): {
638
- srOnly: true;
639
- };
640
- };
641
- cq: {
642
- properties: {
643
- name: {
644
- type: "token";
645
- value: "containerNames";
646
- property: "containerName";
647
- };
648
- type: {
649
- type: "property";
650
- value: "containerType";
651
- };
652
- };
653
- defaultValues: {
654
- type: string;
655
- };
656
- transform(props: {
657
- [x: string]: any;
658
- [x: number]: any;
659
- [x: string & Record<never, never>]: any;
660
- }): {
661
- containerType: any;
662
- containerName: any;
663
- };
664
- };
665
468
  };
666
469
  };
667
470
  //#endregion
package/dist/index.mjs CHANGED
@@ -113,9 +113,18 @@ const conditions = {
113
113
  function definePattern(config) {
114
114
  return config;
115
115
  }
116
- const box = definePattern({ transform(props) {
117
- return props;
118
- } });
116
+ /**
117
+ * The one flexbox pattern. `stack`, `vstack`, `hstack` and `wrap` were this with defaults frozen
118
+ * — `stack` added `direction: 'column'` and an 8px gap, the two axis-named ones additionally
119
+ * hard-coded `align: 'center'` and dropped `direction` from the props, and `wrap` set
120
+ * `flexWrap: 'wrap'`. Five names, one transform, and four of them a superset of the fifth only in
121
+ * what they assumed for you.
122
+ *
123
+ * `gap` is deliberately not listed here and does not need to be: anything absent from
124
+ * `properties` still arrives as an ordinary style prop, so `flex({ gap: '6' })` types and folds
125
+ * exactly as it did through `stack`. What goes with the old names is the implicit `gap: '8px'`,
126
+ * which was a design opinion no call site asked for.
127
+ */
119
128
  const flex = definePattern({
120
129
  properties: {
121
130
  align: {
@@ -162,144 +171,24 @@ const flex = definePattern({
162
171
  };
163
172
  }
164
173
  });
165
- const stack = definePattern({
166
- properties: {
167
- align: {
168
- type: "property",
169
- value: "alignItems"
170
- },
171
- justify: {
172
- type: "property",
173
- value: "justifyContent"
174
- },
175
- direction: {
176
- type: "property",
177
- value: "flexDirection"
178
- },
179
- gap: {
180
- type: "property",
181
- value: "gap"
182
- }
183
- },
184
- defaultValues: {
185
- direction: "column",
186
- gap: "8px"
187
- },
188
- transform(props) {
189
- const { align, justify, direction, gap, ...rest } = props;
190
- return {
191
- display: "flex",
192
- flexDirection: direction,
193
- alignItems: align,
194
- justifyContent: justify,
195
- gap,
196
- ...rest
197
- };
198
- }
199
- });
200
- const vstack = definePattern({
201
- properties: {
202
- justify: {
203
- type: "property",
204
- value: "justifyContent"
205
- },
206
- gap: {
207
- type: "property",
208
- value: "gap"
209
- }
210
- },
211
- defaultValues: { gap: "8px" },
212
- transform(props) {
213
- const { justify, gap, ...rest } = props;
214
- return {
215
- display: "flex",
216
- alignItems: "center",
217
- justifyContent: justify,
218
- gap,
219
- flexDirection: "column",
220
- ...rest
221
- };
222
- }
223
- });
224
- const hstack = definePattern({
225
- properties: {
226
- justify: {
227
- type: "property",
228
- value: "justifyContent"
229
- },
230
- gap: {
231
- type: "property",
232
- value: "gap"
233
- }
234
- },
235
- defaultValues: { gap: "8px" },
236
- transform(props) {
237
- const { justify, gap, ...rest } = props;
238
- return {
239
- display: "flex",
240
- alignItems: "center",
241
- justifyContent: justify,
242
- gap,
243
- flexDirection: "row",
244
- ...rest
245
- };
246
- }
247
- });
248
174
  const spacer = definePattern({
249
175
  properties: { size: {
250
176
  type: "token",
251
177
  value: "spacing"
252
178
  } },
253
- transform(props, { map, isCssUnit, isCssVar }) {
179
+ transform(props, { map, isCssUnit, isCssVar, token }) {
254
180
  const { size, ...rest } = props;
255
181
  return {
256
182
  alignSelf: "stretch",
257
183
  justifySelf: "stretch",
258
184
  flex: map(size, (v) => {
259
185
  if (v == null) return "1";
260
- return `0 0 ${isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`}`;
186
+ return `0 0 ${isCssUnit(v) || isCssVar(v) ? v : token(`spacing.${v}`, v)}`;
261
187
  }),
262
188
  ...rest
263
189
  };
264
190
  }
265
191
  });
266
- const circle = definePattern({
267
- properties: { size: {
268
- type: "property",
269
- value: "width"
270
- } },
271
- transform(props) {
272
- const { size, ...rest } = props;
273
- return {
274
- display: "flex",
275
- alignItems: "center",
276
- justifyContent: "center",
277
- flex: "0 0 auto",
278
- width: size,
279
- height: size,
280
- borderRadius: "9999px",
281
- ...rest
282
- };
283
- }
284
- });
285
- const square = definePattern({
286
- properties: { size: {
287
- type: "property",
288
- value: "width"
289
- } },
290
- transform(props) {
291
- const { size, ...rest } = props;
292
- return {
293
- display: "flex",
294
- alignItems: "center",
295
- justifyContent: "center",
296
- flex: "0 0 auto",
297
- width: size,
298
- height: size,
299
- ...rest
300
- };
301
- }
302
- });
303
192
  const grid = definePattern({
304
193
  properties: {
305
194
  gap: {
@@ -324,9 +213,9 @@ const grid = definePattern({
324
213
  defaultValues(props) {
325
214
  return { gap: props.columnGap || props.rowGap ? void 0 : "8px" };
326
215
  },
327
- transform(props, { map, isCssUnit }) {
216
+ transform(props, { map, isCssUnit, token }) {
328
217
  const { columnGap, rowGap, gap, columns, minChildWidth, ...rest } = props;
329
- const getValue = (v) => isCssUnit(v) ? v : `token(sizes.${v}, ${v})`;
218
+ const getValue = (v) => isCssUnit(v) ? v : token(`sizes.${v}`, v);
330
219
  return {
331
220
  display: "grid",
332
221
  gridTemplateColumns: columns != null ? map(columns, (v) => `repeat(${v}, minmax(0, 1fr))`) : minChildWidth != null ? map(minChildWidth, (v) => `repeat(auto-fit, minmax(${getValue(v)}, 1fr))`) : void 0,
@@ -360,43 +249,6 @@ const gridItem = definePattern({
360
249
  };
361
250
  }
362
251
  });
363
- const wrap = definePattern({
364
- properties: {
365
- gap: {
366
- type: "property",
367
- value: "gap"
368
- },
369
- rowGap: {
370
- type: "property",
371
- value: "gap"
372
- },
373
- columnGap: {
374
- type: "property",
375
- value: "gap"
376
- },
377
- align: {
378
- type: "property",
379
- value: "alignItems"
380
- },
381
- justify: {
382
- type: "property",
383
- value: "justifyContent"
384
- }
385
- },
386
- transform(props) {
387
- const { columnGap, rowGap, gap = columnGap || rowGap ? void 0 : "8px", align, justify, ...rest } = props;
388
- return {
389
- display: "flex",
390
- flexWrap: "wrap",
391
- alignItems: align,
392
- justifyContent: justify,
393
- gap,
394
- columnGap,
395
- rowGap,
396
- ...rest
397
- };
398
- }
399
- });
400
252
  const container$1 = definePattern({ transform(props) {
401
253
  return {
402
254
  position: "relative",
@@ -410,21 +262,41 @@ const container$1 = definePattern({ transform(props) {
410
262
  ...props
411
263
  };
412
264
  } });
265
+ /**
266
+ * Absorbs what `square` and `circle` used to be. `square({ size })` is `center({ size })`, and
267
+ * `circle({ size })` is `center({ size, borderRadius: 'full' })` — `borderRadius` is an ordinary
268
+ * style prop, so the rounded case needs nothing here beyond the size the square case already
269
+ * wanted. Three patterns whose transforms differed by one declaration is three names to learn
270
+ * and three places for `alignItems: center` to drift.
271
+ *
272
+ * `flex: '0 0 auto'` rides with `size` rather than being unconditional: it is what stops a sized
273
+ * box from being shrunk by a flex parent, so it is meaningless without one, and applying it to
274
+ * an unsized `center` would change how every existing call lays out inside a flex row.
275
+ */
413
276
  const center = definePattern({
414
- properties: { inline: { type: "boolean" } },
277
+ properties: {
278
+ inline: { type: "boolean" },
279
+ size: {
280
+ type: "property",
281
+ value: "width"
282
+ }
283
+ },
415
284
  transform(props) {
416
- const { inline, ...rest } = props;
285
+ const { inline, size, ...rest } = props;
417
286
  return {
418
287
  display: inline ? "inline-flex" : "flex",
419
288
  alignItems: "center",
420
289
  justifyContent: "center",
290
+ flex: size == null ? void 0 : "0 0 auto",
291
+ width: size,
292
+ height: size,
421
293
  ...rest
422
294
  };
423
295
  }
424
296
  });
425
297
  const aspectRatio = definePattern({
426
298
  properties: { ratio: { type: "number" } },
427
- blocklist: ["aspectRatio"],
299
+ cssProps: { except: ["aspectRatio"] },
428
300
  transform(props, { map }) {
429
301
  const { ratio = 4 / 3, ...rest } = props;
430
302
  return {
@@ -485,14 +357,8 @@ const divider = definePattern({
485
357
  }
486
358
  });
487
359
  const patterns = {
488
- box,
489
360
  flex,
490
- stack,
491
- vstack,
492
- hstack,
493
361
  spacer,
494
- square,
495
- circle,
496
362
  center,
497
363
  linkOverlay: definePattern({ transform(props) {
498
364
  return {
@@ -509,7 +375,6 @@ const patterns = {
509
375
  aspectRatio,
510
376
  grid,
511
377
  gridItem,
512
- wrap,
513
378
  container: container$1,
514
379
  divider,
515
380
  float: definePattern({
@@ -623,9 +488,9 @@ const patterns = {
623
488
  inline: "0",
624
489
  block: "0"
625
490
  },
626
- transform(props, { map, isCssUnit, isCssVar }) {
491
+ transform(props, { map, isCssUnit, isCssVar, token }) {
627
492
  const { inline, block, ...rest } = props;
628
- const valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`;
493
+ const valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : token(`spacing.${v}`, v);
629
494
  return {
630
495
  "--bleed-x": map(inline, valueFn),
631
496
  "--bleed-y": map(block, valueFn),
@@ -634,34 +499,6 @@ const patterns = {
634
499
  ...rest
635
500
  };
636
501
  }
637
- }),
638
- visuallyHidden: definePattern({ transform(props) {
639
- return {
640
- srOnly: true,
641
- ...props
642
- };
643
- } }),
644
- cq: definePattern({
645
- properties: {
646
- name: {
647
- type: "token",
648
- value: "containerNames",
649
- property: "containerName"
650
- },
651
- type: {
652
- type: "property",
653
- value: "containerType"
654
- }
655
- },
656
- defaultValues: { type: "inline-size" },
657
- transform(props) {
658
- const { name, type, ...rest } = props;
659
- return {
660
- containerType: type,
661
- containerName: name,
662
- ...rest
663
- };
664
- }
665
502
  })
666
503
  };
667
504
  //#endregion
@@ -1101,28 +938,10 @@ const cursor = { cursor: {
1101
938
  } };
1102
939
  //#endregion
1103
940
  //#region src/utilities/display.ts
1104
- const display = {
1105
- display: {
1106
- className: "d",
1107
- group: "Display"
1108
- },
1109
- hideFrom: {
1110
- className: "hide",
1111
- values: "breakpoints",
1112
- group: "Display",
1113
- transform(value, { raw, token }) {
1114
- return { [token.raw(`breakpoints.${raw}`) ? `@breakpoint ${raw}` : `@media (width >= ${value})`]: { display: "none" } };
1115
- }
1116
- },
1117
- hideBelow: {
1118
- className: "show",
1119
- values: "breakpoints",
1120
- group: "Display",
1121
- transform(value, { raw, token }) {
1122
- return { [token.raw(`breakpoints.${raw}`) ? `@breakpoint ${raw}Down` : `@media (width < ${value})`]: { display: "none" } };
1123
- }
1124
- }
1125
- };
941
+ const display = { display: {
942
+ className: "d",
943
+ group: "Display"
944
+ } };
1126
945
  //#endregion
1127
946
  //#region src/utilities/divide.ts
1128
947
  const divideColor = createColorMixTransform("borderColor");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/preset-base",
3
- "version": "1.30.1",
3
+ "version": "1.32.0",
4
4
  "description": "The base preset for Bamboo CSS that contains the conditions and utilities",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@bamboocss/types": "1.30.1"
36
+ "@bamboocss/types": "1.32.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsdown src/index.ts --format=esm,cjs --dts",