@zazz-ui/core 0.6.3 → 0.7.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/AUTHORING.md +2 -2
- package/CHANGELOG.md +13 -0
- package/README.md +2 -2
- package/dist/sri.json +48 -46
- package/dist/zazz.css +1 -1
- package/editor/zazz.css-data.json +312 -24
- package/editor/zazz.language-data.json +9 -9
- package/editor/zazz.lint-data.json +2028 -0
- package/package.json +1 -1
- package/src/base/_defaults.css +367 -0
- package/src/base/_layers.css +6 -2
- package/src/base/_properties-2xl.css +8 -2
- package/src/base/_properties-active.css +12 -0
- package/src/base/_properties-checked.css +12 -0
- package/src/base/_properties-current.css +12 -0
- package/src/base/_properties-disabled.css +12 -0
- package/src/base/_properties-focus-visible.css +12 -0
- package/src/base/_properties-focus-within.css +12 -0
- package/src/base/_properties-hover.css +12 -0
- package/src/base/_properties-lg.css +8 -2
- package/src/base/_properties-md.css +8 -2
- package/src/base/_properties-open.css +12 -0
- package/src/base/_properties-sm.css +8 -2
- package/src/base/_properties-starting.css +6 -0
- package/src/base/_properties-stuck.css +6 -0
- package/src/base/_properties-xl.css +8 -2
- package/src/base/_properties.css +12 -3
- package/src/base/_utilities-box.css +0 -15
- package/src/base/_utilities-color.css +0 -3
- package/src/base/_utilities-effects.css +0 -15
- package/src/base/_utilities-flow.css +79 -68
- package/src/base/_utilities-grid.css +20 -32
- package/src/base/_utilities-sizing.css +0 -3
- package/src/base/_utilities-spacing.css +24 -34
- package/src/base/_utilities-tier-2xl.css +4 -1
- package/src/base/_utilities-tier-active.css +6 -0
- package/src/base/_utilities-tier-checked.css +6 -0
- package/src/base/_utilities-tier-current.css +6 -0
- package/src/base/_utilities-tier-disabled.css +6 -0
- package/src/base/_utilities-tier-focus-visible.css +6 -0
- package/src/base/_utilities-tier-focus-within.css +6 -0
- package/src/base/_utilities-tier-hover.css +6 -0
- package/src/base/_utilities-tier-lg.css +4 -1
- package/src/base/_utilities-tier-md.css +4 -1
- package/src/base/_utilities-tier-open.css +6 -0
- package/src/base/_utilities-tier-sm.css +4 -1
- package/src/base/_utilities-tier-starting.css +3 -0
- package/src/base/_utilities-tier-stuck.css +3 -0
- package/src/base/_utilities-tier-xl.css +4 -1
- package/src/base/_utilities-typography.css +0 -9
- package/src/base/kit-styling.d.ts +11 -0
- package/src/base/kit-styling.d.ts.map +1 -0
- package/src/base/kit-styling.js +467 -0
- package/src/base/kit-styling.ts +470 -0
- package/src/base/utilities.d.ts +14 -6
- package/src/base/utilities.d.ts.map +1 -1
- package/src/base/utilities.js +65 -31
- package/src/base/utilities.ts +69 -37
- package/src/index.css +1 -0
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +2 -1
- package/src/manifest.ts +2 -1
- package/src/primitives/debug/audit-core.d.ts +8 -0
- package/src/primitives/debug/audit-core.d.ts.map +1 -1
- package/src/primitives/debug/audit-core.js +24 -4
- package/src/primitives/debug/audit-core.ts +42 -3
- package/src/primitives/debug/debug.d.ts +0 -15
- package/src/primitives/debug/debug.d.ts.map +1 -1
- package/src/primitives/debug/debug.js +11 -2
- package/src/primitives/debug/debug.ts +12 -1
package/src/base/utilities.js
CHANGED
|
@@ -103,6 +103,35 @@ export const FAMILY_TIERS = {
|
|
|
103
103
|
effects: "states",
|
|
104
104
|
box: "none",
|
|
105
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* The utilities that compose into one `box-shadow` (ring and shadow): the
|
|
108
|
+
* composite's chains all end in a literal, so a tier alone works on them, like
|
|
109
|
+
* a no-base utility.
|
|
110
|
+
*/
|
|
111
|
+
export const BOX_SHADOW_COMPOSITE = [
|
|
112
|
+
"shadow",
|
|
113
|
+
"ring",
|
|
114
|
+
"ring-color",
|
|
115
|
+
"ring-offset",
|
|
116
|
+
"ring-offset-color",
|
|
117
|
+
];
|
|
118
|
+
/**
|
|
119
|
+
* The shorthands whose base a longhand's tier overrides, nearest first: `--p: 4;
|
|
120
|
+
* --px--md: 1` pads 4 below md and 1 inline from md. A shorthand's base is a
|
|
121
|
+
* base for its longhands' tiers.
|
|
122
|
+
*/
|
|
123
|
+
export const SHORTHAND_OF = {
|
|
124
|
+
px: ["p"],
|
|
125
|
+
py: ["p"],
|
|
126
|
+
pt: ["py", "p"],
|
|
127
|
+
pb: ["py", "p"],
|
|
128
|
+
pl: ["px", "p"],
|
|
129
|
+
pr: ["px", "p"],
|
|
130
|
+
"gap-x": ["gap"],
|
|
131
|
+
"gap-y": ["gap"],
|
|
132
|
+
basis: ["flex"],
|
|
133
|
+
shrink: ["flex"],
|
|
134
|
+
};
|
|
106
135
|
/** Gradient types: `--bg-<type>` emits `<type>-gradient(<prelude>, <--bg-stops>)`. */
|
|
107
136
|
export const GRADIENT_TYPES = ["linear", "radial", "conic"];
|
|
108
137
|
/** The size scale shared by the token keywords (`--shadow: md`). */
|
|
@@ -177,24 +206,6 @@ export const BORDER_SIDES = [
|
|
|
177
206
|
/** The four sizing keywords. Margin takes only `auto`. */
|
|
178
207
|
export const SIZING_KEYWORDS = ["auto", "fit-content", "min-content", "max-content"];
|
|
179
208
|
export const MARGIN_KEYWORDS = ["auto"];
|
|
180
|
-
/** A layout places its children; a tier-only column utility there keeps the band below the tier. */
|
|
181
|
-
const LAYOUT_CHILDREN = ["ui-layout > *", '[data-ui~="layout"] > *'];
|
|
182
|
-
/**
|
|
183
|
-
* Elements the reset or the prose scope pads (a prose list's indent, a quote's
|
|
184
|
-
* inset, inline code, form controls): a tier-only padding utility there would
|
|
185
|
-
* zero that padding below the tier, so they keep the base requirement.
|
|
186
|
-
*/
|
|
187
|
-
const BASE_PADDED = [
|
|
188
|
-
'[data-ui~="prose"] :is(ul, ol, dd, blockquote, cite)',
|
|
189
|
-
"code",
|
|
190
|
-
"button",
|
|
191
|
-
"input",
|
|
192
|
-
"select",
|
|
193
|
-
"textarea",
|
|
194
|
-
"optgroup",
|
|
195
|
-
];
|
|
196
|
-
/** Elements the reset paints: a tier-only `--bg` there would clear the paint below the tier. */
|
|
197
|
-
const BASE_PAINTED = ["code", "hr"];
|
|
198
209
|
/**
|
|
199
210
|
* Track-list keywords `--grid-cols` / `--grid-rows` take besides a count. `none`
|
|
200
211
|
* is not one: `--template-cols: none` says the same, and every keyword
|
|
@@ -214,6 +225,37 @@ export const UTILITIES = [
|
|
|
214
225
|
family: "flow",
|
|
215
226
|
noBase: "static",
|
|
216
227
|
},
|
|
228
|
+
// anchor positioning: states and breakpoints, so the hovered (or open, or
|
|
229
|
+
// current) element can claim the anchor a toolbar or popover is tethered to.
|
|
230
|
+
// `normal` is position-anchor's initial value. Engines on the older draft
|
|
231
|
+
// don't know it, so the declaration is invalid at computed-value time and
|
|
232
|
+
// falls back to their initial value, `auto`.
|
|
233
|
+
{
|
|
234
|
+
name: "anchor-name",
|
|
235
|
+
properties: ["anchor-name"],
|
|
236
|
+
mode: "raw",
|
|
237
|
+
family: "flow",
|
|
238
|
+
tiers: "both",
|
|
239
|
+
noBase: "none",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "position-anchor",
|
|
243
|
+
properties: ["position-anchor"],
|
|
244
|
+
mode: "raw",
|
|
245
|
+
family: "flow",
|
|
246
|
+
tiers: "both",
|
|
247
|
+
noBase: "normal",
|
|
248
|
+
},
|
|
249
|
+
// where the tethered element sits on its anchor's 3×3 grid (`block-start
|
|
250
|
+
// span-inline-end`); a popover keeps its own area under a tier alone
|
|
251
|
+
{
|
|
252
|
+
name: "position-area",
|
|
253
|
+
properties: ["position-area"],
|
|
254
|
+
mode: "raw",
|
|
255
|
+
family: "flow",
|
|
256
|
+
tiers: "both",
|
|
257
|
+
noBase: "none",
|
|
258
|
+
},
|
|
217
259
|
{
|
|
218
260
|
name: "flex-wrap",
|
|
219
261
|
properties: ["flex-wrap"],
|
|
@@ -221,7 +263,6 @@ export const UTILITIES = [
|
|
|
221
263
|
family: "flow",
|
|
222
264
|
noBase: "nowrap",
|
|
223
265
|
},
|
|
224
|
-
{ name: "shrink", properties: ["flex-shrink"], mode: "raw", family: "flow", noBase: "1" },
|
|
225
266
|
{
|
|
226
267
|
name: "grid-flow",
|
|
227
268
|
properties: ["grid-auto-flow"],
|
|
@@ -268,6 +309,8 @@ export const UTILITIES = [
|
|
|
268
309
|
},
|
|
269
310
|
{ name: "self", properties: ["align-self"], mode: "keyword", family: "flow", noBase: "auto" },
|
|
270
311
|
{ name: "flex", properties: ["flex"], mode: "raw", family: "flow", noBase: "0 1 auto" },
|
|
312
|
+
// after --flex, so its base beats the shorthand's
|
|
313
|
+
{ name: "shrink", properties: ["flex-shrink"], mode: "raw", family: "flow", noBase: "1" },
|
|
271
314
|
{ name: "basis", properties: ["flex-basis"], mode: "raw", family: "flow", noBase: "auto" },
|
|
272
315
|
{ name: "order", properties: ["order"], mode: "raw", family: "flow", noBase: "0" },
|
|
273
316
|
// a layout child's band (`layout-md`); any grid-column value works
|
|
@@ -277,7 +320,6 @@ export const UTILITIES = [
|
|
|
277
320
|
mode: "raw",
|
|
278
321
|
family: "flow",
|
|
279
322
|
noBase: "auto",
|
|
280
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
281
323
|
},
|
|
282
324
|
// Tailwind's col-span / col-start / col-end (and row-*): span is a count,
|
|
283
325
|
// start and end are line numbers; start and end follow span so they combine
|
|
@@ -288,7 +330,6 @@ export const UTILITIES = [
|
|
|
288
330
|
family: "flow",
|
|
289
331
|
emit: "span",
|
|
290
332
|
noBase: "1",
|
|
291
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
292
333
|
},
|
|
293
334
|
{
|
|
294
335
|
name: "col-start",
|
|
@@ -296,7 +337,6 @@ export const UTILITIES = [
|
|
|
296
337
|
mode: "raw",
|
|
297
338
|
family: "flow",
|
|
298
339
|
noBase: "auto",
|
|
299
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
300
340
|
},
|
|
301
341
|
{
|
|
302
342
|
name: "col-end",
|
|
@@ -304,7 +344,6 @@ export const UTILITIES = [
|
|
|
304
344
|
mode: "raw",
|
|
305
345
|
family: "flow",
|
|
306
346
|
noBase: "auto",
|
|
307
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
308
347
|
},
|
|
309
348
|
{
|
|
310
349
|
name: "row-span",
|
|
@@ -367,7 +406,7 @@ export const UTILITIES = [
|
|
|
367
406
|
emit: "grid-fit",
|
|
368
407
|
},
|
|
369
408
|
// spacing: dual mode; padding and gap are on the no-base allowlist (the reset
|
|
370
|
-
// zeroes padding, so `--px--md: 8` alone pads from md)
|
|
409
|
+
// zeroes padding, so `--px--md: 8` alone pads from md)
|
|
371
410
|
...[
|
|
372
411
|
["p", "padding"],
|
|
373
412
|
["px", "padding-inline"],
|
|
@@ -383,7 +422,6 @@ export const UTILITIES = [
|
|
|
383
422
|
mode: "dual",
|
|
384
423
|
family: "spacing",
|
|
385
424
|
noBase: "0",
|
|
386
|
-
noBaseExclude: BASE_PADDED,
|
|
387
425
|
})),
|
|
388
426
|
{ name: "gap", properties: ["gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
389
427
|
{ name: "gap-x", properties: ["column-gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
@@ -580,7 +618,6 @@ export const UTILITIES = [
|
|
|
580
618
|
emit: "bg",
|
|
581
619
|
pseudo: true,
|
|
582
620
|
noBase: "transparent",
|
|
583
|
-
noBaseExclude: BASE_PAINTED,
|
|
584
621
|
},
|
|
585
622
|
{ name: "bg-alpha", properties: [], mode: "raw", family: "color", emit: "none" },
|
|
586
623
|
// gradients: the type utility carries the prelude (direction, shape, position,
|
|
@@ -740,22 +777,19 @@ export const UTILITIES = [
|
|
|
740
777
|
mode: "raw",
|
|
741
778
|
family: "box",
|
|
742
779
|
pseudo: true,
|
|
743
|
-
noBase: "0",
|
|
744
780
|
},
|
|
745
|
-
{ name: "overflow", properties: ["overflow"], mode: "keyword", family: "box"
|
|
781
|
+
{ name: "overflow", properties: ["overflow"], mode: "keyword", family: "box" },
|
|
746
782
|
{
|
|
747
783
|
name: "overflow-x",
|
|
748
784
|
properties: ["overflow-x"],
|
|
749
785
|
mode: "keyword",
|
|
750
786
|
family: "box",
|
|
751
|
-
noBase: "visible",
|
|
752
787
|
},
|
|
753
788
|
{
|
|
754
789
|
name: "overflow-y",
|
|
755
790
|
properties: ["overflow-y"],
|
|
756
791
|
mode: "keyword",
|
|
757
792
|
family: "box",
|
|
758
|
-
noBase: "visible",
|
|
759
793
|
},
|
|
760
794
|
{ name: "outline", pseudo: true, properties: ["outline"], mode: "raw", family: "box" },
|
|
761
795
|
{ name: "cursor", properties: ["cursor"], mode: "keyword", family: "box" },
|
|
@@ -767,7 +801,7 @@ export const UTILITIES = [
|
|
|
767
801
|
family: "box",
|
|
768
802
|
},
|
|
769
803
|
{ name: "visibility", pseudo: true, properties: ["visibility"], mode: "keyword", family: "box" },
|
|
770
|
-
{ name: "z", pseudo: true, properties: ["z-index"], mode: "raw", family: "box"
|
|
804
|
+
{ name: "z", pseudo: true, properties: ["z-index"], mode: "raw", family: "box" },
|
|
771
805
|
{ name: "object-fit", properties: ["object-fit"], mode: "keyword", family: "box" },
|
|
772
806
|
{ name: "object-position", properties: ["object-position"], mode: "raw", family: "box" },
|
|
773
807
|
// the divider between children for the divide-x / divide-y switches: the
|
package/src/base/utilities.ts
CHANGED
|
@@ -171,14 +171,10 @@ export interface Utility {
|
|
|
171
171
|
inherits?: true;
|
|
172
172
|
/**
|
|
173
173
|
* No-base allowlist: the CSS initial value as a literal. A utility with
|
|
174
|
-
* `noBase` applies a tier
|
|
174
|
+
* `noBase` applies a tier without a base value wherever no kit rule sets its
|
|
175
|
+
* property (the tier-only rule is in `@layer defaults`, which they beat).
|
|
175
176
|
*/
|
|
176
177
|
noBase?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Extra selectors excluded from the no-base rule: elements whose
|
|
179
|
-
* placement chain a primitive owns, e.g. a layout's children for `--band`.
|
|
180
|
-
*/
|
|
181
|
-
noBaseExclude?: readonly string[];
|
|
182
178
|
/**
|
|
183
179
|
* Keywords the typed emission (the dual pair, or an integer's `repeat()`)
|
|
184
180
|
* cannot carry. A utility written with one of its keywords, at the base or
|
|
@@ -202,6 +198,37 @@ export interface Utility {
|
|
|
202
198
|
aliases?: Readonly<Record<string, string>>;
|
|
203
199
|
}
|
|
204
200
|
|
|
201
|
+
/**
|
|
202
|
+
* The utilities that compose into one `box-shadow` (ring and shadow): the
|
|
203
|
+
* composite's chains all end in a literal, so a tier alone works on them, like
|
|
204
|
+
* a no-base utility.
|
|
205
|
+
*/
|
|
206
|
+
export const BOX_SHADOW_COMPOSITE = [
|
|
207
|
+
"shadow",
|
|
208
|
+
"ring",
|
|
209
|
+
"ring-color",
|
|
210
|
+
"ring-offset",
|
|
211
|
+
"ring-offset-color",
|
|
212
|
+
] as const;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The shorthands whose base a longhand's tier overrides, nearest first: `--p: 4;
|
|
216
|
+
* --px--md: 1` pads 4 below md and 1 inline from md. A shorthand's base is a
|
|
217
|
+
* base for its longhands' tiers.
|
|
218
|
+
*/
|
|
219
|
+
export const SHORTHAND_OF: Readonly<Record<string, readonly string[]>> = {
|
|
220
|
+
px: ["p"],
|
|
221
|
+
py: ["p"],
|
|
222
|
+
pt: ["py", "p"],
|
|
223
|
+
pb: ["py", "p"],
|
|
224
|
+
pl: ["px", "p"],
|
|
225
|
+
pr: ["px", "p"],
|
|
226
|
+
"gap-x": ["gap"],
|
|
227
|
+
"gap-y": ["gap"],
|
|
228
|
+
basis: ["flex"],
|
|
229
|
+
shrink: ["flex"],
|
|
230
|
+
};
|
|
231
|
+
|
|
205
232
|
/** Gradient types: `--bg-<type>` emits `<type>-gradient(<prelude>, <--bg-stops>)`. */
|
|
206
233
|
export const GRADIENT_TYPES = ["linear", "radial", "conic"] as const;
|
|
207
234
|
|
|
@@ -284,24 +311,6 @@ export const BORDER_SIDES = [
|
|
|
284
311
|
/** The four sizing keywords. Margin takes only `auto`. */
|
|
285
312
|
export const SIZING_KEYWORDS = ["auto", "fit-content", "min-content", "max-content"] as const;
|
|
286
313
|
export const MARGIN_KEYWORDS = ["auto"] as const;
|
|
287
|
-
/** A layout places its children; a tier-only column utility there keeps the band below the tier. */
|
|
288
|
-
const LAYOUT_CHILDREN = ["ui-layout > *", '[data-ui~="layout"] > *'] as const;
|
|
289
|
-
/**
|
|
290
|
-
* Elements the reset or the prose scope pads (a prose list's indent, a quote's
|
|
291
|
-
* inset, inline code, form controls): a tier-only padding utility there would
|
|
292
|
-
* zero that padding below the tier, so they keep the base requirement.
|
|
293
|
-
*/
|
|
294
|
-
const BASE_PADDED = [
|
|
295
|
-
'[data-ui~="prose"] :is(ul, ol, dd, blockquote, cite)',
|
|
296
|
-
"code",
|
|
297
|
-
"button",
|
|
298
|
-
"input",
|
|
299
|
-
"select",
|
|
300
|
-
"textarea",
|
|
301
|
-
"optgroup",
|
|
302
|
-
] as const;
|
|
303
|
-
/** Elements the reset paints: a tier-only `--bg` there would clear the paint below the tier. */
|
|
304
|
-
const BASE_PAINTED = ["code", "hr"] as const;
|
|
305
314
|
|
|
306
315
|
/**
|
|
307
316
|
* Track-list keywords `--grid-cols` / `--grid-rows` take besides a count. `none`
|
|
@@ -323,6 +332,37 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
323
332
|
family: "flow",
|
|
324
333
|
noBase: "static",
|
|
325
334
|
},
|
|
335
|
+
// anchor positioning: states and breakpoints, so the hovered (or open, or
|
|
336
|
+
// current) element can claim the anchor a toolbar or popover is tethered to.
|
|
337
|
+
// `normal` is position-anchor's initial value. Engines on the older draft
|
|
338
|
+
// don't know it, so the declaration is invalid at computed-value time and
|
|
339
|
+
// falls back to their initial value, `auto`.
|
|
340
|
+
{
|
|
341
|
+
name: "anchor-name",
|
|
342
|
+
properties: ["anchor-name"],
|
|
343
|
+
mode: "raw",
|
|
344
|
+
family: "flow",
|
|
345
|
+
tiers: "both",
|
|
346
|
+
noBase: "none",
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "position-anchor",
|
|
350
|
+
properties: ["position-anchor"],
|
|
351
|
+
mode: "raw",
|
|
352
|
+
family: "flow",
|
|
353
|
+
tiers: "both",
|
|
354
|
+
noBase: "normal",
|
|
355
|
+
},
|
|
356
|
+
// where the tethered element sits on its anchor's 3×3 grid (`block-start
|
|
357
|
+
// span-inline-end`); a popover keeps its own area under a tier alone
|
|
358
|
+
{
|
|
359
|
+
name: "position-area",
|
|
360
|
+
properties: ["position-area"],
|
|
361
|
+
mode: "raw",
|
|
362
|
+
family: "flow",
|
|
363
|
+
tiers: "both",
|
|
364
|
+
noBase: "none",
|
|
365
|
+
},
|
|
326
366
|
{
|
|
327
367
|
name: "flex-wrap",
|
|
328
368
|
properties: ["flex-wrap"],
|
|
@@ -330,7 +370,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
330
370
|
family: "flow",
|
|
331
371
|
noBase: "nowrap",
|
|
332
372
|
},
|
|
333
|
-
{ name: "shrink", properties: ["flex-shrink"], mode: "raw", family: "flow", noBase: "1" },
|
|
334
373
|
{
|
|
335
374
|
name: "grid-flow",
|
|
336
375
|
properties: ["grid-auto-flow"],
|
|
@@ -377,6 +416,8 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
377
416
|
},
|
|
378
417
|
{ name: "self", properties: ["align-self"], mode: "keyword", family: "flow", noBase: "auto" },
|
|
379
418
|
{ name: "flex", properties: ["flex"], mode: "raw", family: "flow", noBase: "0 1 auto" },
|
|
419
|
+
// after --flex, so its base beats the shorthand's
|
|
420
|
+
{ name: "shrink", properties: ["flex-shrink"], mode: "raw", family: "flow", noBase: "1" },
|
|
380
421
|
{ name: "basis", properties: ["flex-basis"], mode: "raw", family: "flow", noBase: "auto" },
|
|
381
422
|
{ name: "order", properties: ["order"], mode: "raw", family: "flow", noBase: "0" },
|
|
382
423
|
// a layout child's band (`layout-md`); any grid-column value works
|
|
@@ -386,7 +427,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
386
427
|
mode: "raw",
|
|
387
428
|
family: "flow",
|
|
388
429
|
noBase: "auto",
|
|
389
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
390
430
|
},
|
|
391
431
|
// Tailwind's col-span / col-start / col-end (and row-*): span is a count,
|
|
392
432
|
// start and end are line numbers; start and end follow span so they combine
|
|
@@ -397,7 +437,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
397
437
|
family: "flow",
|
|
398
438
|
emit: "span",
|
|
399
439
|
noBase: "1",
|
|
400
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
401
440
|
},
|
|
402
441
|
{
|
|
403
442
|
name: "col-start",
|
|
@@ -405,7 +444,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
405
444
|
mode: "raw",
|
|
406
445
|
family: "flow",
|
|
407
446
|
noBase: "auto",
|
|
408
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
409
447
|
},
|
|
410
448
|
{
|
|
411
449
|
name: "col-end",
|
|
@@ -413,7 +451,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
413
451
|
mode: "raw",
|
|
414
452
|
family: "flow",
|
|
415
453
|
noBase: "auto",
|
|
416
|
-
noBaseExclude: LAYOUT_CHILDREN,
|
|
417
454
|
},
|
|
418
455
|
{
|
|
419
456
|
name: "row-span",
|
|
@@ -476,7 +513,7 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
476
513
|
emit: "grid-fit",
|
|
477
514
|
},
|
|
478
515
|
// spacing: dual mode; padding and gap are on the no-base allowlist (the reset
|
|
479
|
-
// zeroes padding, so `--px--md: 8` alone pads from md)
|
|
516
|
+
// zeroes padding, so `--px--md: 8` alone pads from md)
|
|
480
517
|
...(
|
|
481
518
|
[
|
|
482
519
|
["p", "padding"],
|
|
@@ -495,7 +532,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
495
532
|
mode: "dual",
|
|
496
533
|
family: "spacing",
|
|
497
534
|
noBase: "0",
|
|
498
|
-
noBaseExclude: BASE_PADDED,
|
|
499
535
|
}),
|
|
500
536
|
),
|
|
501
537
|
{ name: "gap", properties: ["gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
@@ -693,7 +729,6 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
693
729
|
emit: "bg",
|
|
694
730
|
pseudo: true,
|
|
695
731
|
noBase: "transparent",
|
|
696
|
-
noBaseExclude: BASE_PAINTED,
|
|
697
732
|
},
|
|
698
733
|
{ name: "bg-alpha", properties: [], mode: "raw", family: "color", emit: "none" },
|
|
699
734
|
// gradients: the type utility carries the prelude (direction, shape, position,
|
|
@@ -857,22 +892,19 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
857
892
|
mode: "raw",
|
|
858
893
|
family: "box",
|
|
859
894
|
pseudo: true,
|
|
860
|
-
noBase: "0",
|
|
861
895
|
},
|
|
862
|
-
{ name: "overflow", properties: ["overflow"], mode: "keyword", family: "box"
|
|
896
|
+
{ name: "overflow", properties: ["overflow"], mode: "keyword", family: "box" },
|
|
863
897
|
{
|
|
864
898
|
name: "overflow-x",
|
|
865
899
|
properties: ["overflow-x"],
|
|
866
900
|
mode: "keyword",
|
|
867
901
|
family: "box",
|
|
868
|
-
noBase: "visible",
|
|
869
902
|
},
|
|
870
903
|
{
|
|
871
904
|
name: "overflow-y",
|
|
872
905
|
properties: ["overflow-y"],
|
|
873
906
|
mode: "keyword",
|
|
874
907
|
family: "box",
|
|
875
|
-
noBase: "visible",
|
|
876
908
|
},
|
|
877
909
|
{ name: "outline", pseudo: true, properties: ["outline"], mode: "raw", family: "box" },
|
|
878
910
|
{ name: "cursor", properties: ["cursor"], mode: "keyword", family: "box" },
|
|
@@ -884,7 +916,7 @@ export const UTILITIES: readonly Utility[] = [
|
|
|
884
916
|
family: "box",
|
|
885
917
|
},
|
|
886
918
|
{ name: "visibility", pseudo: true, properties: ["visibility"], mode: "keyword", family: "box" },
|
|
887
|
-
{ name: "z", pseudo: true, properties: ["z-index"], mode: "raw", family: "box"
|
|
919
|
+
{ name: "z", pseudo: true, properties: ["z-index"], mode: "raw", family: "box" },
|
|
888
920
|
{ name: "object-fit", properties: ["object-fit"], mode: "keyword", family: "box" },
|
|
889
921
|
{ name: "object-position", properties: ["object-position"], mode: "raw", family: "box" },
|
|
890
922
|
// the divider between children for the divide-x / divide-y switches: the
|
package/src/index.css
CHANGED
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
@import "./base/_utilities-effects.css";
|
|
117
117
|
@import "./base/_utilities-box.css";
|
|
118
118
|
@import "./base/_utilities-pseudo.css";
|
|
119
|
+
@import "./base/_defaults.css";
|
|
119
120
|
@import "./base/_switches.css";
|
|
120
121
|
|
|
121
122
|
/* Migration shims: beat all other legacy sublayers; Zazz still wins. */
|
package/src/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["manifest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,qDAAqD;IACrD,EAAE,EAAE,MAAM,EAAE,CAAC;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA8erD,CAAC;AAIF;;;;;;GAMG;AACH;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,EAOhC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["manifest.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,qDAAqD;IACrD,EAAE,EAAE,MAAM,EAAE,CAAC;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uDAAuD;IACvD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uGAAuG;IACvG,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA8erD,CAAC;AAIF;;;;;;GAMG;AACH;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,EAOhC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,aAAa,EAAE,MAAM,EA4CjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,EAMhC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;CAC7C;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,eAAe,EAE3C,CAAC;AAEF,yGAAyG;AACzG,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;OAIG;IACH,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,eAAe,EAE3C,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,SAAS,EAAE,MAAM,EAErB,CAAC;AAEV,eAAO,MAAM,iBAAiB,EAAE,MAAM,EA0CrC,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAoBxD;AAID,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,UAAU,GACV,SAAS,GACT,iBAAiB,GACjB,OAAO,GACP,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GACV,MAAM,GACN,aAAa,GACb,KAAK,GACL,UAAU,GACV,MAAM,GACN,SAAS,CAAC;AAEd;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC,CAmC/E,CAAC"}
|
package/src/manifest.js
CHANGED
|
@@ -180,7 +180,7 @@ export const PRIMITIVES = {
|
|
|
180
180
|
debug: {
|
|
181
181
|
css: [],
|
|
182
182
|
js: ["primitives/debug/audit-core.js", "primitives/debug/debug.js"],
|
|
183
|
-
base: ["base/utilities.js"],
|
|
183
|
+
base: ["base/kit-styling.js", "base/utilities.js"],
|
|
184
184
|
primitives: [],
|
|
185
185
|
bare: [],
|
|
186
186
|
examples: [],
|
|
@@ -599,6 +599,7 @@ export const BASE_CSS_POST = [
|
|
|
599
599
|
"base/_utilities-effects.css",
|
|
600
600
|
"base/_utilities-box.css",
|
|
601
601
|
"base/_utilities-pseudo.css",
|
|
602
|
+
"base/_defaults.css",
|
|
602
603
|
"base/_switches.css",
|
|
603
604
|
];
|
|
604
605
|
/**
|
package/src/manifest.ts
CHANGED
|
@@ -216,7 +216,7 @@ export const PRIMITIVES: Record<string, PrimitiveEntry> = {
|
|
|
216
216
|
debug: {
|
|
217
217
|
css: [],
|
|
218
218
|
js: ["primitives/debug/audit-core.js", "primitives/debug/debug.js"],
|
|
219
|
-
base: ["base/utilities.js"],
|
|
219
|
+
base: ["base/kit-styling.js", "base/utilities.js"],
|
|
220
220
|
primitives: [],
|
|
221
221
|
bare: [],
|
|
222
222
|
examples: [],
|
|
@@ -638,6 +638,7 @@ export const BASE_CSS_POST: string[] = [
|
|
|
638
638
|
"base/_utilities-effects.css",
|
|
639
639
|
"base/_utilities-box.css",
|
|
640
640
|
"base/_utilities-pseudo.css",
|
|
641
|
+
"base/_defaults.css",
|
|
641
642
|
"base/_switches.css",
|
|
642
643
|
];
|
|
643
644
|
|
|
@@ -25,12 +25,18 @@ export interface AuditNode {
|
|
|
25
25
|
getAttributeNames(): string[];
|
|
26
26
|
/** True when this node or an ancestor carries the identity `name` (see {@link carriesIdentity}). */
|
|
27
27
|
withinIdentity(name: string, identities: readonly string[]): boolean;
|
|
28
|
+
/** `Element.matches`, for the selectors in `reads` and `blocks`. */
|
|
29
|
+
matches(selector: string): boolean;
|
|
28
30
|
}
|
|
29
31
|
export interface AuditContext {
|
|
30
32
|
/** State-bearing hooks per identity as `<utility>--<state>` (`bg--hover`). */
|
|
31
33
|
hooks: Record<string, string[]>;
|
|
32
34
|
/** Identity tokens the kit declares (`button`, `field-group`). */
|
|
33
35
|
identities: readonly string[];
|
|
36
|
+
/** For each utility, the elements the kit reads it on through its own chain, as selectors. */
|
|
37
|
+
reads: Readonly<Record<string, readonly string[]>>;
|
|
38
|
+
/** For each tier-only utility, the elements a kit rule above `@layer defaults` sets its property on. */
|
|
39
|
+
blocks: Readonly<Record<string, readonly string[]>>;
|
|
34
40
|
/** True when `value` is a color identifier (`red`, `currentcolor`); the browser asks `CSS.supports`. */
|
|
35
41
|
isColor: (value: string) => boolean;
|
|
36
42
|
}
|
|
@@ -40,6 +46,8 @@ export interface AuditContext {
|
|
|
40
46
|
* (`field-group` and `<ui-toggle-group>` carry `field` and `toggle`).
|
|
41
47
|
*/
|
|
42
48
|
export declare function carriesIdentity(tagName: string, dataUi: string | null, name: string, identities: readonly string[]): boolean;
|
|
49
|
+
/** `reads` / `blocks` as generated (indices into `selectors`), back as selector lists for {@link AuditContext}. */
|
|
50
|
+
export declare function expandStyling(selectors: readonly string[], record: Readonly<Record<string, readonly number[]>>): Record<string, string[]>;
|
|
43
51
|
/** Audits one element's `style` and `data-*` attributes. */
|
|
44
52
|
export declare function auditNode(node: AuditNode, context: AuditContext): Finding[];
|
|
45
53
|
export interface PersistFinding<T> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-core.d.ts","sourceRoot":"","sources":["audit-core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"audit-core.d.ts","sourceRoot":"","sources":["audit-core.ts"],"names":[],"mappings":"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"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* where it can, the span of the declaration it is about (offsets into the
|
|
8
8
|
* `style` attribute) and a suggested rewrite.
|
|
9
9
|
*/
|
|
10
|
-
import { BORDER_SHORTHANDS, DISPLAY_SHORTHANDS, GRADIENT_TYPES, UTILITIES, PSEUDO_ONLY, FONT_WEIGHT_NAMES, STUCK_STATE, STATES, parseUtilityName, tiersOf, } from "../../base/utilities.js";
|
|
10
|
+
import { BORDER_SHORTHANDS, BOX_SHADOW_COMPOSITE, SHORTHAND_OF, DISPLAY_SHORTHANDS, GRADIENT_TYPES, UTILITIES, PSEUDO_ONLY, FONT_WEIGHT_NAMES, STUCK_STATE, STATES, parseUtilityName, tiersOf, } from "../../base/utilities.js";
|
|
11
11
|
export const RULE_IDS = [
|
|
12
12
|
"unknown-utility",
|
|
13
13
|
"pseudo-form",
|
|
@@ -109,6 +109,10 @@ export function carriesIdentity(tagName, dataUi, name, identities) {
|
|
|
109
109
|
const tokens = (dataUi ?? "").split(/\s+/).filter(Boolean);
|
|
110
110
|
return tokens.some((token) => identities.includes(token) && (token === name || token.startsWith(`${name}-`)));
|
|
111
111
|
}
|
|
112
|
+
/** `reads` / `blocks` as generated (indices into `selectors`), back as selector lists for {@link AuditContext}. */
|
|
113
|
+
export function expandStyling(selectors, record) {
|
|
114
|
+
return Object.fromEntries(Object.entries(record).map(([name, indices]) => [name, indices.map((i) => selectors[i])]));
|
|
115
|
+
}
|
|
112
116
|
/** Audits one element's `style` and `data-*` attributes. */
|
|
113
117
|
export function auditNode(node, context) {
|
|
114
118
|
const found = [];
|
|
@@ -240,9 +244,25 @@ export function auditNode(node, context) {
|
|
|
240
244
|
// a border shorthand is the base a border longhand's tier overrides
|
|
241
245
|
const borderBase = /^border-(?:width|color|style)$/.test(baseName) &&
|
|
242
246
|
BORDER_SHORTHANDS.some((name) => bases.has(name));
|
|
243
|
-
// a
|
|
244
|
-
const
|
|
245
|
-
|
|
247
|
+
// a shorthand's base is the base its longhand's tier overrides (`--p: 4; --px--md: 1`)
|
|
248
|
+
const shorthandBase = (SHORTHAND_OF[baseName] ?? []).some((name) => bases.has(name));
|
|
249
|
+
// the box-shadow composite (ring, shadow) works tier-only like a no-base utility;
|
|
250
|
+
// the other feeds (`--bg-alpha`, `--focus-ring`, `--shadow-angle`) reach the
|
|
251
|
+
// element through another utility or a token, and are not checked here
|
|
252
|
+
const composite = BOX_SHADOW_COMPOSITE.includes(utility.name);
|
|
253
|
+
const feedsComposite = !composite && (utility.emit === "none" || utility.emit === "px");
|
|
254
|
+
// a tier alone works where the kit reads the utility through its own chain,
|
|
255
|
+
// or where the tier-only rule (`@layer defaults`) applies: a no-base utility
|
|
256
|
+
// whose property no kit rule above that layer sets on this element
|
|
257
|
+
const readByKit = (context.reads[utility.name] ?? []).some((selector) => node.matches(selector));
|
|
258
|
+
const noBase = (utility.noBase !== undefined || composite) &&
|
|
259
|
+
!(context.blocks[utility.name] ?? []).some((selector) => node.matches(selector));
|
|
260
|
+
if (!readByKit &&
|
|
261
|
+
!noBase &&
|
|
262
|
+
!bases.has(baseName) &&
|
|
263
|
+
!borderBase &&
|
|
264
|
+
!shorthandBase &&
|
|
265
|
+
!feedsComposite) {
|
|
246
266
|
warn("tier-without-base", `\`${name}\` has no base \`--${baseName}\`; the tier only overrides a base.`);
|
|
247
267
|
}
|
|
248
268
|
continue;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
BORDER_SHORTHANDS,
|
|
14
|
+
BOX_SHADOW_COMPOSITE,
|
|
15
|
+
SHORTHAND_OF,
|
|
14
16
|
DISPLAY_SHORTHANDS,
|
|
15
17
|
GRADIENT_TYPES,
|
|
16
18
|
UTILITIES,
|
|
@@ -95,6 +97,8 @@ export interface AuditNode {
|
|
|
95
97
|
getAttributeNames(): string[];
|
|
96
98
|
/** True when this node or an ancestor carries the identity `name` (see {@link carriesIdentity}). */
|
|
97
99
|
withinIdentity(name: string, identities: readonly string[]): boolean;
|
|
100
|
+
/** `Element.matches`, for the selectors in `reads` and `blocks`. */
|
|
101
|
+
matches(selector: string): boolean;
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
export interface AuditContext {
|
|
@@ -102,6 +106,10 @@ export interface AuditContext {
|
|
|
102
106
|
hooks: Record<string, string[]>;
|
|
103
107
|
/** Identity tokens the kit declares (`button`, `field-group`). */
|
|
104
108
|
identities: readonly string[];
|
|
109
|
+
/** For each utility, the elements the kit reads it on through its own chain, as selectors. */
|
|
110
|
+
reads: Readonly<Record<string, readonly string[]>>;
|
|
111
|
+
/** For each tier-only utility, the elements a kit rule above `@layer defaults` sets its property on. */
|
|
112
|
+
blocks: Readonly<Record<string, readonly string[]>>;
|
|
105
113
|
/** True when `value` is a color identifier (`red`, `currentcolor`); the browser asks `CSS.supports`. */
|
|
106
114
|
isColor: (value: string) => boolean;
|
|
107
115
|
}
|
|
@@ -212,6 +220,16 @@ export function carriesIdentity(
|
|
|
212
220
|
);
|
|
213
221
|
}
|
|
214
222
|
|
|
223
|
+
/** `reads` / `blocks` as generated (indices into `selectors`), back as selector lists for {@link AuditContext}. */
|
|
224
|
+
export function expandStyling(
|
|
225
|
+
selectors: readonly string[],
|
|
226
|
+
record: Readonly<Record<string, readonly number[]>>,
|
|
227
|
+
): Record<string, string[]> {
|
|
228
|
+
return Object.fromEntries(
|
|
229
|
+
Object.entries(record).map(([name, indices]) => [name, indices.map((i) => selectors[i]!)]),
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
215
233
|
/** Audits one element's `style` and `data-*` attributes. */
|
|
216
234
|
export function auditNode(node: AuditNode, context: AuditContext): Finding[] {
|
|
217
235
|
const found: Finding[] = [];
|
|
@@ -380,9 +398,30 @@ export function auditNode(node: AuditNode, context: AuditContext): Finding[] {
|
|
|
380
398
|
const borderBase =
|
|
381
399
|
/^border-(?:width|color|style)$/.test(baseName) &&
|
|
382
400
|
BORDER_SHORTHANDS.some((name) => bases.has(name));
|
|
383
|
-
// a
|
|
384
|
-
const
|
|
385
|
-
|
|
401
|
+
// a shorthand's base is the base its longhand's tier overrides (`--p: 4; --px--md: 1`)
|
|
402
|
+
const shorthandBase = (SHORTHAND_OF[baseName] ?? []).some((name) => bases.has(name));
|
|
403
|
+
// the box-shadow composite (ring, shadow) works tier-only like a no-base utility;
|
|
404
|
+
// the other feeds (`--bg-alpha`, `--focus-ring`, `--shadow-angle`) reach the
|
|
405
|
+
// element through another utility or a token, and are not checked here
|
|
406
|
+
const composite = (BOX_SHADOW_COMPOSITE as readonly string[]).includes(utility.name);
|
|
407
|
+
const feedsComposite = !composite && (utility.emit === "none" || utility.emit === "px");
|
|
408
|
+
// a tier alone works where the kit reads the utility through its own chain,
|
|
409
|
+
// or where the tier-only rule (`@layer defaults`) applies: a no-base utility
|
|
410
|
+
// whose property no kit rule above that layer sets on this element
|
|
411
|
+
const readByKit = (context.reads[utility.name] ?? []).some((selector) =>
|
|
412
|
+
node.matches(selector),
|
|
413
|
+
);
|
|
414
|
+
const noBase =
|
|
415
|
+
(utility.noBase !== undefined || composite) &&
|
|
416
|
+
!(context.blocks[utility.name] ?? []).some((selector) => node.matches(selector));
|
|
417
|
+
if (
|
|
418
|
+
!readByKit &&
|
|
419
|
+
!noBase &&
|
|
420
|
+
!bases.has(baseName) &&
|
|
421
|
+
!borderBase &&
|
|
422
|
+
!shorthandBase &&
|
|
423
|
+
!feedsComposite
|
|
424
|
+
) {
|
|
386
425
|
warn(
|
|
387
426
|
"tier-without-base",
|
|
388
427
|
`\`${name}\` has no base \`--${baseName}\`; the tier only overrides a base.`,
|