@teacss/preset-standard 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
4
+ Copyright (c) 2026-PRESENT Billgo <hi@billgo.me>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,271 @@
1
+ # @teacss/preset-standard
2
+
3
+ **The standard TeaCSS vocabulary.**
4
+
5
+ ## Purpose
6
+
7
+ `@teacss/preset-standard` is the official general-purpose vocabulary for
8
+ application authors who want TeaCSS utilities for layout, spacing, sizing,
9
+ typography, color, interaction, and related everyday CSS. It provides the
10
+ preset factory, theme defaults, condition aliases, shortcuts, preflights,
11
+ public value constants, and Standard-specific class-merge metadata.
12
+
13
+ This package defines vocabulary and preset behavior, not the engine or config
14
+ loader: `@teacss/core` owns parsing, rule matching, and CSS generation, while
15
+ `@teacss/config` resolves CSS-entry directives for integrations. The
16
+ `article:base` long-form content utility and the
17
+ `icon:<collection>-<icon>` vocabulary remain opt-in features of
18
+ `@teacss/preset-articles` and `@teacss/preset-icons`; this preset does not
19
+ bundle either one.
20
+
21
+ ## Usage
22
+
23
+ ```sh
24
+ bun add @teacss/preset-standard
25
+ ```
26
+
27
+ ```css
28
+ @preset "standard";
29
+ @source "./src/**/*.{ts,tsx}";
30
+ @teacss;
31
+ ```
32
+
33
+ ```ts
34
+ import { cn } from "@teacss/preset-standard/merge";
35
+
36
+ cn("p:4 d:flex", "p:8"); // "d:flex p:8"
37
+ cn("p:4", "p:invalid"); // "p:invalid"
38
+ cn("reset:li", "reset:ul"); // "reset:ul"
39
+ cn("float:left", "reset:li"); // "float:left reset:li"
40
+ cn("reset:li", "float:left"); // "reset:li float:left"
41
+ ```
42
+
43
+ Property value constants are available from the dedicated public entry:
44
+
45
+ ```ts
46
+ import { boxDecorationValues, globalKeywords, multiplierKeywords } from "@teacss/preset-standard/constants";
47
+ ```
48
+
49
+ Each `*Values` export contains only the property's common values.
50
+ `globalKeywords` is exported separately; the preset's rule layer adds those
51
+ CSS-wide keywords centrally at runtime. `multiplierKeywords` is the supported
52
+ name for the `1x` through `9x` scale; the misspelled `multiplerKeywords` export
53
+ remains as a deprecated compatibility alias.
54
+
55
+ ## Layout Shortcuts
56
+
57
+ Official preset-owned shortcuts use bare class names without `:`. This preset
58
+ includes four fixed, theme-neutral flexbox shortcuts:
59
+
60
+ | Shortcut | Expansion |
61
+ | --- | --- |
62
+ | `hstack` | `d:flex flex-direction:row align-items:center` |
63
+ | `vstack` | `d:flex flex-direction:column` |
64
+ | `center` | `d:flex align-items:center justify-content:center` |
65
+ | `inline-center` | `d:inline-flex align-items:center justify-content:center` |
66
+
67
+ They emit in the built-in `shortcuts` layer. Compose spacing, sizing, wrapping,
68
+ and responsive changes with ordinary utilities; the later `utilities` layer can
69
+ override a shortcut default:
70
+
71
+ ```html
72
+ <div class="hstack gap:3x flex-direction:column@sm">
73
+ ...
74
+ </div>
75
+ ```
76
+
77
+ The four layout shortcuts are one mutually exclusive merge family when their
78
+ conditions and importance are equal. They add no gap, size, wrapping, theme, or
79
+ component styling.
80
+
81
+ ## Text Shortcut
82
+
83
+ `truncate` is the fixed single-line truncation Shortcut:
84
+
85
+ ```txt
86
+ truncate -> overflow:hidden text-overflow:ellipsis white-space:nowrap
87
+ ```
88
+
89
+ It emits in the built-in `shortcuts` layer, so later ordinary utilities can
90
+ override any default. The existing `text-overflow:truncate` utilities-layer
91
+ composite utility remains supported.
92
+
93
+ ## Skeleton Shortcut
94
+
95
+ `skeleton` is the fixed visual loading-placeholder Shortcut. It has this exact
96
+ TeaCSS expansion:
97
+
98
+ ```txt
99
+ radius:1x
100
+ border-style:none!
101
+ bg-image:none!
102
+ bg-clip:border-box!
103
+ shadow:none!
104
+ box-decoration-break:clone!
105
+ text-color:transparent!
106
+ outline-style:none!
107
+ user-select:none!
108
+ pointer-events:none!
109
+ cursor:default!
110
+ animation:skeleton!
111
+
112
+ vis:hidden!@::after
113
+ vis:hidden!@::before
114
+ vis:hidden!@>*
115
+
116
+ d:block@empty
117
+ h:3x@empty
118
+
119
+ radius-l:inherit@[:where(:first-child)]
120
+ radius-r:inherit@[:where(:nth-last-child(2))]
121
+
122
+ line-height:1@[:where([data-inline-skeleton])]
123
+ font-family:sans@[:where([data-inline-skeleton])]
124
+ ```
125
+
126
+ Use the bare class on an empty block placeholder or on an inline placeholder
127
+ whose text supplies its shape:
128
+
129
+ ```html
130
+ <div class="skeleton" aria-hidden="true"></div>
131
+ <span class="skeleton" data-inline-skeleton aria-hidden="true">Loading</span>
132
+ ```
133
+
134
+ Empty skeletons become blocks with a `3x` height. Direct children and the two
135
+ pseudo-elements are hidden, and `data-inline-skeleton` applies a direct line
136
+ height of `1` plus the standard sans family. The structural conditions inherit
137
+ the left radius on a first child and the right radius on a second-to-last
138
+ child. `animation:skeleton!` reuses the standard gray skeleton animation.
139
+ Core emits these components in rule-priority order, so the generated CSS uses
140
+ several `.skeleton` rules instead of one contiguous block. The
141
+ `@keyframes skeleton` rule remains top-level and unconditional: outer
142
+ conditions and `!` apply only to the shortcut declarations, and later
143
+ interaction-reset rules may appear after the keyframes.
144
+
145
+ The Shortcut emits in the built-in `shortcuts` layer. Its important visual
146
+ reset declarations intentionally resist ordinary non-important utilities;
147
+ non-important radius, empty sizing, and inline typography declarations retain
148
+ normal layer precedence. CSS does not add loading or accessibility semantics,
149
+ so components remain responsible for `aria-busy`, `aria-hidden`, `inert`, and
150
+ replacement-content behavior where appropriate. There are no `skeleton:*`
151
+ variants or compatibility aliases.
152
+
153
+ ## Preflight
154
+
155
+ The standard preset emits a low-specificity foundational reset and its theme
156
+ CSS variables by default. The reset applies `border-box` sizing to every
157
+ element, its `::before` and `::after` pseudo-elements, and `::backdrop`; it also
158
+ sets every element's margin and padding to zero and establishes a zero-width
159
+ solid border. The document root and shadow host receive a `1.5` line height,
160
+ text-size and tab normalization, the configurable `--font-family-sans` stack,
161
+ normal font feature and variation settings, and a transparent tap highlight. In
162
+ the programmatic preset API,
163
+ `preflight: false` disables both. `preflight: "on-demand"` keeps the foundational
164
+ reset while limiting theme variables to keys referenced by generated utilities
165
+ or by the reset itself.
166
+
167
+ The `reset:*` utilities apply explicit element-specific deltas on top of that
168
+ foundational preflight. They cover headings (`reset:h1` through `reset:h6`),
169
+ links and controls
170
+ (`reset:a|button|select|input-text|textarea`), and lists
171
+ (`reset:li|ol|ul|menu`). The deltas remove selected browser defaults with
172
+ explicit declarations without repeating the preflight's shared box-model,
173
+ spacing, border, or inherited tap-highlight baseline. They do not expose a
174
+ generic CSS `all` reset, emit
175
+ focus/state/placeholder selector rules, or reset `outline`. Use
176
+ `reset:input-text` only on text-like inputs, and use `reset:button` for
177
+ button-like input types. A generic `reset:input` is intentionally unsupported so
178
+ callers do not apply one broad profile across checkboxes, radios, file inputs,
179
+ and other specialized controls.
180
+
181
+ This is a TeaCSS-specific subset inspired by the
182
+ [Radix Themes 3.3.0 Reset](https://github.com/radix-ui/themes/blob/3.3.0/packages/radix-ui-themes/src/components/reset.css),
183
+ adapted to named atomic profiles and TeaCSS merge semantics rather than copied
184
+ as a component class. These element-specific rules are not emitted by the
185
+ preflight. They still generate when `preflight: false` disables the automatic
186
+ baseline, but then emit only the element-specific delta; provide an equivalent
187
+ baseline when a complete reset is required. Root and shadow-host defaults are
188
+ preflight-only.
189
+
190
+ The merger uses parsed utility shape and declared footprints; it does not ask
191
+ the generator whether a value is supported. An unsupported or empty later value
192
+ can therefore replace an earlier token and then emit no CSS. Reset profiles form
193
+ one opaque merge family: one `reset:*` can replace another, but the merger does
194
+ not expand their declarations into conflicts with unrelated utilities. An
195
+ important utility removes a non-important overlap only when its footprint fully
196
+ covers the token being removed; partial shorthand/longhand overlaps survive.
197
+
198
+ The `/merge` entry exports the self-contained `pluginStandard`, a lazy
199
+ standard-only `cn`, and the compatibility `createStandardMerger()` factory.
200
+ `pluginStandard` publishes resolver-family scope metadata so unrelated repeated
201
+ static prefixes stay on the linear merge path.
202
+ Compose official plugins directly when building a unified merger:
203
+
204
+ ```sh
205
+ bun add @teacss/classes @teacss/preset-icons
206
+ ```
207
+
208
+ ```ts
209
+ import { createMerger } from "@teacss/classes";
210
+ import { pluginIcon } from "@teacss/preset-icons/merge";
211
+ import { pluginStandard } from "@teacss/preset-standard/merge";
212
+
213
+ const cn = createMerger({ plugins: [pluginStandard, pluginIcon] });
214
+ ```
215
+
216
+ Existing code may still use
217
+ `createStandardMerger({ plugins: [pluginIcon] })`; it delegates to that
218
+ same direct plugin composition without hidden transforms or metadata. The
219
+ zero-config `cn` from this package remains standard-only. The application
220
+ `cn` from `teacss` includes the official icon plugin by default.
221
+
222
+ ## Vocabulary
223
+
224
+ The preset covers layout, spacing, sizing, positioning, typography, color,
225
+ border, shadow, transform, transition, animation, SVG, accessibility, and
226
+ interaction utilities.
227
+
228
+ Bare keywords are a closed standard-preset vocabulary:
229
+
230
+ ```txt
231
+ static relative absolute fixed sticky
232
+ hstack vstack center inline-center
233
+ truncate skeleton
234
+ mask-g-linear mask-g-radial mask-g-conic
235
+ divide-x divide-y
236
+ backdrop-grayscale backdrop-invert backdrop-sepia
237
+ space-x-reverse space-y-reverse space-a-reverse space-c-reverse
238
+ ```
239
+
240
+ The five position keywords are direct utilities; their `position:*` forms
241
+ remain supported and share the same merge footprint. The layout keywords are
242
+ fixed shortcuts. `truncate` is the fixed single-line text Shortcut, and
243
+ `skeleton` is the fixed visual loading-placeholder Shortcut. The mask keywords
244
+ activate additive generated-mask families. The divide keywords create `1px`
245
+ physical separators. The backdrop keywords apply their filter at `100%`. The
246
+ spacing keywords are independent reverse modifiers that coexist with
247
+ `space-*:<size>`. Do not infer other bare utilities from CSS keywords.
248
+
249
+ Withdrawn draft property names are not retained as compatibility utilities.
250
+ Use `scroll-initial-target:*`, not `scroll-start-target:*`; the removed Grid 3
251
+ proposal names `item-direction:*`, `item-track:*`, `item-wrap:*`,
252
+ `item-cross:*`, and `item-pack:*` generate no CSS.
253
+
254
+ Values support theme references, arbitrary values, CSS-wide keywords, the
255
+ trailing `!` important marker, and stacked `@` conditions.
256
+ Conditions are suffix-only: write `p:4@hover` or `content:empty@::before`, not
257
+ property-side forms such as `hover:p:4` or `before:content:empty`.
258
+ Representable suffix/self conditions, query-bearing at-rule parents, and media
259
+ types such as `@!print` support `@!` negation. Prefix relations/direction, target
260
+ combinators, pseudo-elements, and at-rules without a negatable prelude such as
261
+ `@starting-style` remain unmatched when negated.
262
+
263
+ Color theme data is split into `colors` for stepped palette tokens such
264
+ as `--color-red-500` and `semanticColors` for role tokens such as
265
+ `--color-background`, `--color-foreground`, `--color-border`, and
266
+ `--color-emphasis`. Mode
267
+ overrides can define either namespace.
268
+
269
+ ## Status
270
+
271
+ Pre-1.0. Keep tests and docs aligned when adding or changing utilities.
@@ -0,0 +1 @@
1
+ const e=[`inherit`,`initial`,`revert`,`revert-layer`,`unset`],t=`px.pt.pc.in.cm.mm.q.rpx.%.em.rem.ex.rex.ch.rch.cap.rcap.ic.ric.lh.rlh.vw.vh.vi.vb.vmin.vmax.svw.svh.svi.svb.svmin.svmax.lvw.lvh.lvi.lvb.lvmin.lvmax.dvw.dvh.dvi.dvb.dvmin.dvmax.cqw.cqh.cqi.cqb.cqmin.cqmax`.split(`.`),n=`(?:${t.filter(e=>e!==`rpx`&&e!==`%`).join(`|`)})`,r=`(?:%|${t.filter(e=>e!==`rpx`&&e!==`%`).join(`|`)})`,i=new Set(`transparent.aliceblue.antiquewhite.aqua.aquamarine.azure.beige.bisque.black.blanchedalmond.blue.blueviolet.brown.burlywood.cadetblue.chartreuse.chocolate.coral.cornflowerblue.cornsilk.crimson.cyan.darkblue.darkcyan.darkgoldenrod.darkgray.darkgreen.darkgrey.darkkhaki.darkmagenta.darkolivegreen.darkorange.darkorchid.darkred.darksalmon.darkseagreen.darkslateblue.darkslategray.darkslategrey.darkturquoise.darkviolet.deeppink.deepskyblue.dimgray.dimgrey.dodgerblue.firebrick.floralwhite.forestgreen.fuchsia.gainsboro.ghostwhite.gold.goldenrod.gray.green.greenyellow.grey.honeydew.hotpink.indianred.indigo.ivory.khaki.lavender.lavenderblush.lawngreen.lemonchiffon.lightblue.lightcoral.lightcyan.lightgoldenrodyellow.lightgray.lightgreen.lightgrey.lightpink.lightsalmon.lightseagreen.lightskyblue.lightslategray.lightslategrey.lightsteelblue.lightyellow.lime.limegreen.linen.magenta.maroon.mediumaquamarine.mediumblue.mediumorchid.mediumpurple.mediumseagreen.mediumslateblue.mediumspringgreen.mediumturquoise.mediumvioletred.midnightblue.mintcream.mistyrose.moccasin.navajowhite.navy.oldlace.olive.olivedrab.orange.orangered.orchid.palegoldenrod.palegreen.paleturquoise.palevioletred.papayawhip.peachpuff.peru.pink.plum.powderblue.purple.rebeccapurple.red.rosybrown.royalblue.saddlebrown.salmon.sandybrown.seagreen.seashell.sienna.silver.skyblue.slateblue.slategray.slategrey.snow.springgreen.steelblue.tan.teal.thistle.tomato.turquoise.violet.wheat.white.whitesmoke.yellow.yellowgreen`.split(`.`));export{e as a,i,n,t as r,r as t};