@tenphi/tasty 0.0.0-snapshot.d2dcdeb → 0.0.0-snapshot.d4ccea8
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/README.md +181 -131
- package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +2 -2
- package/dist/async-storage-DKK-wTD4.js.map +1 -0
- package/dist/babel-eMs_zZjM.d.ts +83 -0
- package/dist/{ssr/collector.js → collector-BjkQEtbh.js} +111 -38
- package/dist/collector-BjkQEtbh.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-DzeNxHOq.d.ts} +58 -7
- package/dist/config-DMslHK_e.d.ts +1298 -0
- package/dist/config-DX126v_w.js +12318 -0
- package/dist/config-DX126v_w.js.map +1 -0
- package/dist/{ssr/context.js → context-CA8YKeMn.js} +11 -3
- package/dist/context-CA8YKeMn.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +6 -27
- package/dist/core-CMn-Tj2X.js +1573 -0
- package/dist/core-CMn-Tj2X.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-C8ShXK5R.js} +148 -24
- package/dist/css-writer-C8ShXK5R.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +2 -2
- package/dist/format-global-rules-DklyaXv-.js.map +1 -0
- package/dist/{ssr/format-rules.js → format-rules-BkstDvlN.js} +59 -2
- package/dist/format-rules-BkstDvlN.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-DXXWZgm0.js} +4 -12
- package/dist/hydrate-DXXWZgm0.js.map +1 -0
- package/dist/index-BcsaHo8x.d.ts +1568 -0
- package/dist/index-CC0wykKn.d.ts +1909 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +922 -36
- package/dist/index.js.map +1 -0
- package/dist/keyframes-Z0YLVOWq.js +493 -0
- package/dist/keyframes-Z0YLVOWq.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-BTFAkYSD.d.ts} +3 -3
- package/dist/{utils/merge-styles.js → merge-styles-Dpueyn82.js} +3 -4
- package/dist/merge-styles-Dpueyn82.js.map +1 -0
- package/dist/{utils/resolve-recipes.js → resolve-recipes-B2Vjr7ET.js} +4 -6
- package/dist/resolve-recipes-B2Vjr7ET.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +16 -0
- package/dist/ssr/astro-middleware-static.js +18 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +8 -6
- package/dist/ssr/astro-middleware.js +10 -10
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +2 -17
- package/dist/ssr/astro.js +29 -21
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +37 -4
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next.d.ts +2 -3
- package/dist/ssr/next.js +7 -8
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.js.map +1 -1
- package/dist/zero/babel.d.ts +2 -81
- package/dist/zero/babel.js +45 -29
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +81 -3
- package/dist/zero/index.js +2 -3
- package/dist/zero/next.d.ts +1 -1
- package/dist/zero/next.js +1 -1
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +18 -10
- package/docs/adoption.md +56 -31
- package/docs/ai-agents.md +224 -0
- package/docs/comparison.md +69 -40
- package/docs/configuration.md +501 -72
- package/docs/debug.md +22 -18
- package/docs/design-system.md +43 -24
- package/docs/dsl.md +512 -179
- package/docs/getting-started.md +60 -39
- package/docs/injector.md +110 -32
- package/docs/methodology.md +68 -36
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +741 -0
- package/docs/plugins.md +353 -0
- package/docs/react-api.md +164 -40
- package/docs/runtime-benchmarks.md +216 -0
- package/docs/ssr.md +92 -81
- package/docs/styles.md +65 -16
- package/docs/tasty-static.md +149 -99
- package/package.json +49 -21
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -335
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -587
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -230
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -708
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1103
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -515
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -564
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
- package/docs/PIPELINE.md +0 -519
|
@@ -0,0 +1,1568 @@
|
|
|
1
|
+
import { Properties } from "csstype";
|
|
2
|
+
|
|
3
|
+
//#region src/properties/property-type-resolver.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* PropertyTypeResolver
|
|
6
|
+
*
|
|
7
|
+
* Automatically infers CSS @property types from custom property values.
|
|
8
|
+
* Supports deferred resolution for var() reference chains of arbitrary depth.
|
|
9
|
+
*/
|
|
10
|
+
declare class PropertyTypeResolver {
|
|
11
|
+
/** propName → the prop it depends on */
|
|
12
|
+
private pendingDeps;
|
|
13
|
+
/** propName → list of props waiting on it */
|
|
14
|
+
private reverseDeps;
|
|
15
|
+
/**
|
|
16
|
+
* Scan CSS declarations and auto-register @property for custom properties
|
|
17
|
+
* whose types can be inferred from their values.
|
|
18
|
+
*/
|
|
19
|
+
scanDeclarations(declarations: string, isPropertyDefined: (name: string) => boolean, registerProperty: (name: string, syntax: string, initialValue: string) => void): void;
|
|
20
|
+
private addDependency;
|
|
21
|
+
private resolve;
|
|
22
|
+
private isComplexValue;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/injector/batch.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Deferred CSSOM writes ("batched injection").
|
|
28
|
+
*
|
|
29
|
+
* Every `insertRule()` on a live stylesheet invalidates style for the sheet's
|
|
30
|
+
* scope, so Blink recalculates style the next time anything reads layout or
|
|
31
|
+
* computed style. When components inject during React's render phase and other
|
|
32
|
+
* components read layout in the same pass, the two interleave:
|
|
33
|
+
*
|
|
34
|
+
* inject -> read (forced recalc) -> inject -> read (forced recalc) -> ...
|
|
35
|
+
*
|
|
36
|
+
* Batching moves every sheet write out from between those reads. Writes are
|
|
37
|
+
* queued in FIFO order and drained in one go, so the tree is invalidated once
|
|
38
|
+
* per flush instead of once per component.
|
|
39
|
+
*
|
|
40
|
+
* ## Ordering
|
|
41
|
+
*
|
|
42
|
+
* A single queue holds *all* writes — component rules, global rules, keyframes,
|
|
43
|
+
* `@property`, `@font-face`, `@counter-style`, `@function` and raw CSS. Draining
|
|
44
|
+
* it in insertion order keeps the sheet byte-identical to unbatched output,
|
|
45
|
+
* which matters because equal-specificity rules resolve by document order.
|
|
46
|
+
*
|
|
47
|
+
* ## Batch windows — why queuing is safe
|
|
48
|
+
*
|
|
49
|
+
* Deferring a write past React's layout phase would let a `useLayoutEffect`
|
|
50
|
+
* measure an element whose rules are not in the sheet yet, reading the unstyled
|
|
51
|
+
* box. `<TastyBatchProvider>` closes that hole by opening a *window* during its
|
|
52
|
+
* render and closing it — flushing — in its `useInsertionEffect`, which React
|
|
53
|
+
* runs in the mutation phase, before any layout effect:
|
|
54
|
+
*
|
|
55
|
+
* provider renders -> window OPEN
|
|
56
|
+
* children render -> injections queued
|
|
57
|
+
* provider insertionEffect -> FLUSH, window CLOSED
|
|
58
|
+
* layout effects run -> rules are in the sheet
|
|
59
|
+
*
|
|
60
|
+
* So in the default (`batchInjection: true`) mode a write is only ever queued
|
|
61
|
+
* inside a commit whose flush is already guaranteed by that same commit. Every
|
|
62
|
+
* injection outside a window — a deep update the provider did not re-render
|
|
63
|
+
* for, a `useLayoutEffect` that injects, an event handler, an async callback —
|
|
64
|
+
* is written straight through, exactly as with batching off.
|
|
65
|
+
*
|
|
66
|
+
* `batchInjection: 'always'` opts out of the gate and queues unconditionally.
|
|
67
|
+
* That wins on more commits, at the cost of the measurement hazard above.
|
|
68
|
+
*
|
|
69
|
+
* ## Flush points (earliest wins)
|
|
70
|
+
*
|
|
71
|
+
* 1. `<TastyBatchProvider>`'s `useInsertionEffect` — closes the window.
|
|
72
|
+
* 2. A microtask — a backstop for a render that was aborted or suspended and
|
|
73
|
+
* therefore never reached its insertion effect. An aborted render mounts
|
|
74
|
+
* nothing, so nothing can measure what it queued. Microtasks also always
|
|
75
|
+
* drain before paint, so styles are never visually missing.
|
|
76
|
+
* 3. `flushStyles()` — explicit, and called internally by every injector read
|
|
77
|
+
* API (`getCSSText`, `cleanup`, `gc`, `destroy`, ...).
|
|
78
|
+
*/
|
|
79
|
+
interface QueuedWrite {
|
|
80
|
+
/** Perform the deferred sheet write. */
|
|
81
|
+
run: () => void;
|
|
82
|
+
/** Set when the owner disposed before the write happened. */
|
|
83
|
+
cancelled: boolean;
|
|
84
|
+
/** Set once the write has been applied (or skipped as cancelled). */
|
|
85
|
+
done: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Whether any write is still waiting to hit a stylesheet. */
|
|
88
|
+
declare function hasPendingStyleWrites(): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Drain every pending sheet write, in insertion order.
|
|
91
|
+
*
|
|
92
|
+
* Safe to call when the queue is empty (the common case, so the guard comes
|
|
93
|
+
* first) and safe to call re-entrantly: a nested `flushStyles()` is a no-op,
|
|
94
|
+
* and work a draining write triggers is written in place by
|
|
95
|
+
* `enqueueStyleWrite` rather than queued behind the rest of the batch.
|
|
96
|
+
*/
|
|
97
|
+
declare function flushStyles(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Drop every pending write without applying it. Test helper — production code
|
|
100
|
+
* should call `flushStyles()` instead.
|
|
101
|
+
*/
|
|
102
|
+
declare function resetStyleBatch(): void;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/injector/types.d.ts
|
|
105
|
+
declare global {
|
|
106
|
+
interface Window {
|
|
107
|
+
__TASTY__?: string[];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
interface InjectResult {
|
|
111
|
+
className: string;
|
|
112
|
+
dispose: () => void;
|
|
113
|
+
}
|
|
114
|
+
interface GlobalInjectResult {
|
|
115
|
+
dispose: () => void;
|
|
116
|
+
}
|
|
117
|
+
type DisposeFunction = () => void;
|
|
118
|
+
interface StyleInjectorConfig {
|
|
119
|
+
nonce?: string;
|
|
120
|
+
maxRulesPerSheet?: number;
|
|
121
|
+
forceTextInjection?: boolean;
|
|
122
|
+
/** Enable development mode features: performance metrics and debug information storage */
|
|
123
|
+
devMode?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Global predefined states for advanced state mapping.
|
|
126
|
+
* These are state aliases that can be used in any component.
|
|
127
|
+
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
128
|
+
*/
|
|
129
|
+
states?: Record<string, string>;
|
|
130
|
+
/**
|
|
131
|
+
* Automatically infer and register CSS @property declarations
|
|
132
|
+
* from custom property values. When false, only explicit @property are used.
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
|
+
autoPropertyTypes?: boolean;
|
|
136
|
+
/** Garbage collection configuration for unused styles */
|
|
137
|
+
gc?: GCConfig;
|
|
138
|
+
/**
|
|
139
|
+
* Prefix prepended to every generated identifier.
|
|
140
|
+
* Mirrors the `namePrefix` field on the public `TastyConfig` so that
|
|
141
|
+
* standalone injector consumers can configure it directly.
|
|
142
|
+
* @default 't'
|
|
143
|
+
*/
|
|
144
|
+
namePrefix?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Defer stylesheet writes and apply them in one batch instead of one
|
|
147
|
+
* `insertRule()` per component. Mirrors `batchInjection` on the public
|
|
148
|
+
* `TastyConfig`.
|
|
149
|
+
* @default false
|
|
150
|
+
*/
|
|
151
|
+
batchInjection?: boolean | 'always';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Per-className usage tracking for GC.
|
|
155
|
+
*/
|
|
156
|
+
interface StyleUsage {
|
|
157
|
+
lastTouchedAt: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for the style garbage collector.
|
|
161
|
+
*
|
|
162
|
+
* GC is triggered by touch count rather than timers: every `touchInterval`
|
|
163
|
+
* touches, an idle callback is scheduled to evict unused styles above
|
|
164
|
+
* `capacity`, oldest first.
|
|
165
|
+
*/
|
|
166
|
+
interface GCConfig {
|
|
167
|
+
/**
|
|
168
|
+
* Sweep automatically as rendering goes, instead of only when `gc()` or
|
|
169
|
+
* `cleanup()` is called (default `false`).
|
|
170
|
+
*
|
|
171
|
+
* **Unsafe, by name and in fact.** A sweep decides what is finished by
|
|
172
|
+
* scanning the DOM, and rendering is not commit-aware: a concurrent render
|
|
173
|
+
* can yield between the `inject()` that creates a class and the commit that
|
|
174
|
+
* attaches it. A sweep landing in that window sees no element carrying the
|
|
175
|
+
* class and deletes rules the pending render is about to use, so the element
|
|
176
|
+
* commits unstyled until something re-renders it. A pending render is
|
|
177
|
+
* indistinguishable from one that already committed and unmounted — React
|
|
178
|
+
* reports neither commit nor discard for a class name handed out during
|
|
179
|
+
* render — so no heuristic closes this; only a real commit signal would.
|
|
180
|
+
*
|
|
181
|
+
* Prefer `gc()` or `cleanup()` at a moment of your choosing: a route change,
|
|
182
|
+
* an idle callback of your own, test teardown.
|
|
183
|
+
*/
|
|
184
|
+
unsafeAutoCollect?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* With `unsafeAutoCollect`, schedule the sweep with a timeout where
|
|
187
|
+
* `requestIdleCallback` is missing (default `false`).
|
|
188
|
+
*
|
|
189
|
+
* Collection is a background chore, so it otherwise only ever runs in idle
|
|
190
|
+
* time: where the engine cannot offer idle time, nothing is collected
|
|
191
|
+
* automatically at all. Opt in to give those engines automatic collection
|
|
192
|
+
* anyway, at the cost of a sweep that competes with whatever else the page is
|
|
193
|
+
* doing.
|
|
194
|
+
*/
|
|
195
|
+
timeoutFallback?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Number of touch events between automatic GC cycles.
|
|
198
|
+
* Only used with `unsafeAutoCollect`.
|
|
199
|
+
* @default 1000
|
|
200
|
+
*/
|
|
201
|
+
touchInterval?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Maximum number of unused styles to retain.
|
|
204
|
+
* GC evicts the oldest unused styles when this limit is exceeded.
|
|
205
|
+
* Pinned styles and DOM-live styles
|
|
206
|
+
* do not count against this limit.
|
|
207
|
+
* @default 1000
|
|
208
|
+
*/
|
|
209
|
+
capacity?: number;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Per-call options for inject().
|
|
213
|
+
*/
|
|
214
|
+
interface InjectOptions {
|
|
215
|
+
root?: Document | ShadowRoot;
|
|
216
|
+
/** Reuse the class already injected for this key instead of writing again. */
|
|
217
|
+
cacheKey?: string;
|
|
218
|
+
/**
|
|
219
|
+
* Pin the injected class (default `true`). A pinned class is never evicted by
|
|
220
|
+
* `gc()`, and the returned `dispose()` releases the pin. Pass `false` when the
|
|
221
|
+
* caller keeps no handle and the DOM is the only record that the class is in
|
|
222
|
+
* use — the render path does this, because a hook-free render has no unmount
|
|
223
|
+
* signal to dispose on.
|
|
224
|
+
*/
|
|
225
|
+
pin?: boolean;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Per-call options for gc().
|
|
229
|
+
*/
|
|
230
|
+
interface GCOptions {
|
|
231
|
+
root?: Document | ShadowRoot;
|
|
232
|
+
/** Bypass capacity threshold and remove ALL unused styles. */
|
|
233
|
+
force?: boolean;
|
|
234
|
+
}
|
|
235
|
+
interface RuleInfo {
|
|
236
|
+
className: string;
|
|
237
|
+
ruleIndex: number;
|
|
238
|
+
sheetIndex: number;
|
|
239
|
+
/** Dev-only: full CSS texts inserted for this class; omitted in production */
|
|
240
|
+
cssText?: string[];
|
|
241
|
+
/** Inclusive end index of the contiguous block of inserted rules for this className */
|
|
242
|
+
endRuleIndex?: number;
|
|
243
|
+
/** NEW: exact indices of all inserted rules for this className */
|
|
244
|
+
indices?: number[];
|
|
245
|
+
}
|
|
246
|
+
type InjectionMode = 'style-element' | 'adopted';
|
|
247
|
+
interface SheetInfo {
|
|
248
|
+
/** HTMLStyleElement used in style-element mode; null in adopted mode. */
|
|
249
|
+
sheet: HTMLStyleElement | null;
|
|
250
|
+
/** Constructable CSSStyleSheet used in adopted mode (ShadowRoot targets) */
|
|
251
|
+
constructableSheet?: CSSStyleSheet;
|
|
252
|
+
ruleCount: number;
|
|
253
|
+
holes: number[];
|
|
254
|
+
/**
|
|
255
|
+
* True when this sheet is written through `textContent` instead of CSSOM.
|
|
256
|
+
* Decided once at sheet creation so a sheet is never half CSSOM / half text.
|
|
257
|
+
*/
|
|
258
|
+
textMode?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Inserted rule texts in rule-index order. Maintained only in text mode —
|
|
261
|
+
* it is what makes deletion possible there, since `textContent` cannot be
|
|
262
|
+
* edited rule-by-rule and has to be rebuilt.
|
|
263
|
+
*/
|
|
264
|
+
textRules?: string[];
|
|
265
|
+
}
|
|
266
|
+
interface CleanupStats {
|
|
267
|
+
timestamp: number;
|
|
268
|
+
classesDeleted: number;
|
|
269
|
+
cssSize: number;
|
|
270
|
+
rulesDeleted: number;
|
|
271
|
+
}
|
|
272
|
+
interface CacheMetrics {
|
|
273
|
+
hits: number;
|
|
274
|
+
misses: number;
|
|
275
|
+
bulkCleanups: number;
|
|
276
|
+
totalInsertions: number;
|
|
277
|
+
totalUnused: number;
|
|
278
|
+
stylesCleanedUp: number;
|
|
279
|
+
cleanupHistory: CleanupStats[];
|
|
280
|
+
startTime: number;
|
|
281
|
+
unusedHits?: number;
|
|
282
|
+
}
|
|
283
|
+
interface RootRegistry {
|
|
284
|
+
sheets: SheetInfo[];
|
|
285
|
+
/** className -> outstanding `inject()` references; 0 means nobody holds a handle */
|
|
286
|
+
pinCounts: Map<string, number>;
|
|
287
|
+
rules: Map<string, RuleInfo>;
|
|
288
|
+
/** Cache key to className mapping to avoid dual storage of RuleInfo objects */
|
|
289
|
+
cacheKeyToClassName: Map<string, string>;
|
|
290
|
+
/** Deduplication set of fully materialized CSS rules inserted into sheets */
|
|
291
|
+
ruleTextSet: Set<string>;
|
|
292
|
+
/** Performance metrics (optional) */
|
|
293
|
+
metrics?: CacheMetrics;
|
|
294
|
+
/** Keyframes cache by content hash -> entry */
|
|
295
|
+
keyframesCache: Map<string, KeyframesCacheEntry>;
|
|
296
|
+
/** Keyframes name to content hash mapping for collision detection */
|
|
297
|
+
keyframesNameToContent: Map<string, string>;
|
|
298
|
+
/** Counter for generating keyframes names like k0, k1, k2... */
|
|
299
|
+
keyframesCounter: number;
|
|
300
|
+
/** Map of injected @property names to their normalized declarations for tracking */
|
|
301
|
+
injectedProperties: Map<string, string>;
|
|
302
|
+
/** Content hashes of injected @font-face rules for deduplication */
|
|
303
|
+
injectedFontFaces: Set<string>;
|
|
304
|
+
/**
|
|
305
|
+
* Injected @counter-style rules. Maps the name to whether it was injected
|
|
306
|
+
* "strong" (`true`, the default — overrides) or "weak" (`false`, global
|
|
307
|
+
* `configure()` definitions that never clobber an existing rule).
|
|
308
|
+
*/
|
|
309
|
+
injectedCounterStyles: Map<string, boolean>;
|
|
310
|
+
/**
|
|
311
|
+
* Injected @function rules. Maps the CSS function name to whether it was
|
|
312
|
+
* injected "strong" (`true`, the default — overrides) or "weak" (`false`,
|
|
313
|
+
* global `configure()` definitions that never clobber an existing rule).
|
|
314
|
+
*/
|
|
315
|
+
injectedFunctions: Map<string, boolean>;
|
|
316
|
+
/** Global rules tracking for index adjustment */
|
|
317
|
+
globalRules: Map<string, RuleInfo>;
|
|
318
|
+
/** Resolver for auto-inferring @property types from declaration values */
|
|
319
|
+
propertyTypeResolver: PropertyTypeResolver;
|
|
320
|
+
/** Per-className usage tracking for GC */
|
|
321
|
+
usageMap: Map<string, StyleUsage>;
|
|
322
|
+
/** Touch counter for scheduling GC (per-root) */
|
|
323
|
+
touchCount: number;
|
|
324
|
+
/**
|
|
325
|
+
* Millisecond that `touchedTick` refers to. `touch()` only ever stamps
|
|
326
|
+
* `lastTouchedAt` with the current millisecond, so a repeat touch of the same
|
|
327
|
+
* class name inside one millisecond is a no-op worth skipping.
|
|
328
|
+
*/
|
|
329
|
+
touchTick: number;
|
|
330
|
+
/** Class-name strings already touched during `touchTick`. */
|
|
331
|
+
touchedTick: Set<string>;
|
|
332
|
+
/** How many entries from `window.__TASTY__` have been synced into this registry */
|
|
333
|
+
serverClassSyncIndex: number;
|
|
334
|
+
/** Whether `<style data-tasty-rsc>` tags have been scanned for class names */
|
|
335
|
+
rscStylesScanned: boolean;
|
|
336
|
+
/** Whether this root uses adoptedStyleSheets or <style> elements */
|
|
337
|
+
injectionMode: InjectionMode;
|
|
338
|
+
/**
|
|
339
|
+
* Lazy feature-test for `@property` support, cached per registry.
|
|
340
|
+
* - `undefined`: not yet probed.
|
|
341
|
+
* - `true`: engine supports `@property`; rejections indicate user-authored
|
|
342
|
+
* invalid rules and should warn.
|
|
343
|
+
* - `false`: engine doesn't support `@property` (e.g., jsdom); rejections
|
|
344
|
+
* are expected and warnings are suppressed.
|
|
345
|
+
*/
|
|
346
|
+
atPropertySupported?: boolean;
|
|
347
|
+
}
|
|
348
|
+
type StyleRule = StyleResult;
|
|
349
|
+
interface KeyframesInfo {
|
|
350
|
+
name: string;
|
|
351
|
+
sheetIndex: number;
|
|
352
|
+
ruleIndex: number;
|
|
353
|
+
/** Dev-only: full CSS text of the @keyframes rule; omitted in production */
|
|
354
|
+
cssText?: string;
|
|
355
|
+
}
|
|
356
|
+
type KeyframeStep = string | Record<string, string | number>;
|
|
357
|
+
type KeyframesSteps = Record<string, KeyframeStep>;
|
|
358
|
+
interface KeyframesResult {
|
|
359
|
+
toString(): string;
|
|
360
|
+
dispose: () => void;
|
|
361
|
+
}
|
|
362
|
+
interface KeyframesCacheEntry {
|
|
363
|
+
name: string;
|
|
364
|
+
refCount: number;
|
|
365
|
+
info: KeyframesInfo;
|
|
366
|
+
/**
|
|
367
|
+
* Queued sheet write, when `batchInjection` deferred the insertion. Present
|
|
368
|
+
* only between `keyframes()` and the flush; disposing in that window cancels
|
|
369
|
+
* the write instead of deleting a rule that was never inserted.
|
|
370
|
+
*/
|
|
371
|
+
pending?: QueuedWrite;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Definition for a CSS @property at-rule.
|
|
375
|
+
* Used to define custom property syntax, inheritance, and initial value.
|
|
376
|
+
*/
|
|
377
|
+
interface PropertyDefinition {
|
|
378
|
+
/** CSS syntax string (e.g., '<color>', '<angle>', '<number>') */
|
|
379
|
+
syntax?: string;
|
|
380
|
+
/** Whether the property inherits (default: true) */
|
|
381
|
+
inherits?: boolean;
|
|
382
|
+
/** Initial value for the property */
|
|
383
|
+
initialValue?: string | number;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Options for registering a CSS `@property`.
|
|
387
|
+
* Extends {@link PropertyDefinition} with an optional injection root.
|
|
388
|
+
*/
|
|
389
|
+
interface PropertyOptions extends PropertyDefinition {
|
|
390
|
+
/** Shadow root or document to inject into */
|
|
391
|
+
root?: Document | ShadowRoot;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* A single parameter for a CSS @function at-rule.
|
|
395
|
+
*
|
|
396
|
+
* - `true` — a bare parameter with no type or default.
|
|
397
|
+
* - `string` — a CSS type shorthand (e.g. `'<length>'`, `'<color>'`).
|
|
398
|
+
* - object — full form with optional `syntax` (type) and `default` value.
|
|
399
|
+
*/
|
|
400
|
+
type FunctionParameter = true | string | {
|
|
401
|
+
syntax?: string;
|
|
402
|
+
default?: string | number;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Definition for a CSS @function at-rule (custom function).
|
|
406
|
+
*
|
|
407
|
+
* The descriptor body reads like a mini styles object: any `$name` key declares
|
|
408
|
+
* a local variable (`--name`) whose value is parsed through the Tasty DSL.
|
|
409
|
+
* `result` is the only required field.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* // @function --negative(--value) { result: calc(-1 * var(--value)); }
|
|
414
|
+
* { args: ['$value'], result: '(-1 * $value)' }
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
interface FunctionDefinition {
|
|
418
|
+
/**
|
|
419
|
+
* Ordered parameters. Array form lists bare parameter names (`['$value']`);
|
|
420
|
+
* object form maps each parameter name to its type/default.
|
|
421
|
+
*/
|
|
422
|
+
args?: string[] | Record<string, FunctionParameter>;
|
|
423
|
+
/** Optional return type, e.g. `'<color>'`. */
|
|
424
|
+
returns?: string;
|
|
425
|
+
/** The `result:` descriptor value (parsed through the Tasty DSL). Required. */
|
|
426
|
+
result: string;
|
|
427
|
+
/** Local variables: any `$name` key declares `--name` in the body. */
|
|
428
|
+
[localVar: `$${string}`]: string | number | undefined;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Descriptors for a CSS @font-face at-rule.
|
|
432
|
+
*/
|
|
433
|
+
interface FontFaceDescriptors {
|
|
434
|
+
/** Required. URL(s) to the font file(s). */
|
|
435
|
+
src: string;
|
|
436
|
+
/** Font weight or range. Default: 'normal'. */
|
|
437
|
+
fontWeight?: string | number;
|
|
438
|
+
/** Font style. Default: 'normal'. */
|
|
439
|
+
fontStyle?: 'normal' | 'italic' | 'oblique' | (string & {});
|
|
440
|
+
/** Font stretch. Default: 'normal'. */
|
|
441
|
+
fontStretch?: string;
|
|
442
|
+
/** Loading behavior. Default: 'auto'. */
|
|
443
|
+
fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
|
|
444
|
+
/** Unicode range to cover. */
|
|
445
|
+
unicodeRange?: string;
|
|
446
|
+
/** Ascent metric override. */
|
|
447
|
+
ascentOverride?: string;
|
|
448
|
+
/** Descent metric override. */
|
|
449
|
+
descentOverride?: string;
|
|
450
|
+
/** Line gap metric override. */
|
|
451
|
+
lineGapOverride?: string;
|
|
452
|
+
/** Size adjustment factor. */
|
|
453
|
+
sizeAdjust?: string;
|
|
454
|
+
/** OpenType feature settings. */
|
|
455
|
+
fontFeatureSettings?: string;
|
|
456
|
+
/** Font variation axis settings. */
|
|
457
|
+
fontVariationSettings?: string;
|
|
458
|
+
}
|
|
459
|
+
/** Single descriptor or array of descriptors for multiple weights/styles. */
|
|
460
|
+
type FontFaceInput = FontFaceDescriptors | FontFaceDescriptors[];
|
|
461
|
+
/**
|
|
462
|
+
* Descriptors for a CSS @counter-style at-rule.
|
|
463
|
+
*/
|
|
464
|
+
interface CounterStyleDescriptors {
|
|
465
|
+
/** Required. Numbering algorithm. */
|
|
466
|
+
system: 'cyclic' | 'numeric' | 'alphabetic' | 'symbolic' | 'additive' | 'fixed' | (string & {});
|
|
467
|
+
/** Symbols for non-additive systems. */
|
|
468
|
+
symbols?: string;
|
|
469
|
+
/** Symbol-value pairs for additive system. */
|
|
470
|
+
additiveSymbols?: string;
|
|
471
|
+
/** String prepended to the marker. Default: "". */
|
|
472
|
+
prefix?: string;
|
|
473
|
+
/** String appended to the marker. Default: ". ". */
|
|
474
|
+
suffix?: string;
|
|
475
|
+
/** Negative-value wrapping (e.g., '"(" ")"'). */
|
|
476
|
+
negative?: string;
|
|
477
|
+
/** Counter range (e.g., 'infinite infinite'). */
|
|
478
|
+
range?: string;
|
|
479
|
+
/** Minimum marker width and pad symbol (e.g., '3 "0"'). */
|
|
480
|
+
pad?: string;
|
|
481
|
+
/** Fallback counter style name. */
|
|
482
|
+
fallback?: string;
|
|
483
|
+
/** Speech synthesis hint. */
|
|
484
|
+
speakAs?: string;
|
|
485
|
+
}
|
|
486
|
+
interface RawCSSResult {
|
|
487
|
+
dispose: () => void;
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/utils/css-types.d.ts
|
|
491
|
+
interface CSSProperties extends Properties<string | number> {}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/parser/types.d.ts
|
|
494
|
+
/**
|
|
495
|
+
* A part within a group, representing a slash-separated segment.
|
|
496
|
+
* For example, in `'2px solid #red / 4px'`, there are two parts:
|
|
497
|
+
* - Part 0: `2px solid #red`
|
|
498
|
+
* - Part 1: `4px`
|
|
499
|
+
*/
|
|
500
|
+
interface StyleDetailsPart {
|
|
501
|
+
mods: string[];
|
|
502
|
+
values: string[];
|
|
503
|
+
colors: string[];
|
|
504
|
+
all: string[];
|
|
505
|
+
output: string;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* A group of style details, representing a comma-separated segment.
|
|
509
|
+
* Contains aggregated values from all parts for backward compatibility,
|
|
510
|
+
* plus the structured `parts` array for handlers that need slash separation.
|
|
511
|
+
*/
|
|
512
|
+
interface StyleDetails {
|
|
513
|
+
input: string;
|
|
514
|
+
output: string;
|
|
515
|
+
/** Aggregated mods from all parts (backward compatible) */
|
|
516
|
+
mods: string[];
|
|
517
|
+
/** Aggregated values from all parts (backward compatible) */
|
|
518
|
+
values: string[];
|
|
519
|
+
/** Aggregated colors from all parts (backward compatible) */
|
|
520
|
+
colors: string[];
|
|
521
|
+
/** Aggregated all tokens from all parts (backward compatible) */
|
|
522
|
+
all: string[];
|
|
523
|
+
/** Slash-separated parts within this group */
|
|
524
|
+
parts: StyleDetailsPart[];
|
|
525
|
+
}
|
|
526
|
+
interface ProcessedStyle {
|
|
527
|
+
output: string;
|
|
528
|
+
groups: StyleDetails[];
|
|
529
|
+
}
|
|
530
|
+
type UnitHandler = (scalar: number) => string;
|
|
531
|
+
interface ParserOptions {
|
|
532
|
+
functions?: Record<string, (parsed: StyleDetails[]) => string>;
|
|
533
|
+
units?: Record<string, string | UnitHandler>;
|
|
534
|
+
cacheSize?: number;
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/parser/parser.d.ts
|
|
538
|
+
declare class StyleParser {
|
|
539
|
+
private opts;
|
|
540
|
+
private cache;
|
|
541
|
+
constructor(opts?: ParserOptions);
|
|
542
|
+
process(src: string): ProcessedStyle;
|
|
543
|
+
setFunctions(functions: Required<ParserOptions>['functions']): void;
|
|
544
|
+
setUnits(units: Required<ParserOptions>['units']): void;
|
|
545
|
+
updateOptions(patch: Partial<ParserOptions>): void;
|
|
546
|
+
/**
|
|
547
|
+
* Clear the parser cache.
|
|
548
|
+
* Call this when external state that affects parsing results has changed
|
|
549
|
+
* (e.g., predefined tokens).
|
|
550
|
+
*/
|
|
551
|
+
clearCache(): void;
|
|
552
|
+
/**
|
|
553
|
+
* Get the current units configuration.
|
|
554
|
+
*/
|
|
555
|
+
getUnits(): ParserOptions['units'];
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region src/utils/color-math.d.ts
|
|
559
|
+
/**
|
|
560
|
+
* Consolidated color conversion math.
|
|
561
|
+
*
|
|
562
|
+
* Single source of truth for all color space conversions used across the
|
|
563
|
+
* library: sRGB gamma, HSL, OKLab, OKLCH, OKHSL, hex parsing, named
|
|
564
|
+
* colors, and CSS string converters.
|
|
565
|
+
*
|
|
566
|
+
* This module has zero internal imports — it is a leaf dependency.
|
|
567
|
+
*
|
|
568
|
+
* Reference: https://bottosson.github.io/posts/oklab/
|
|
569
|
+
*/
|
|
570
|
+
type Vec3 = [number, number, number];
|
|
571
|
+
/**
|
|
572
|
+
* sRGB gamma to linear. Only the sRGB-to-OKLab direction needs it, so this is
|
|
573
|
+
* test-only for the same reason as {@link srgbToOkhsl} — the forward path goes
|
|
574
|
+
* through {@link srgbLinearToGamma} instead.
|
|
575
|
+
*/
|
|
576
|
+
/**
|
|
577
|
+
* HSL to RGB.
|
|
578
|
+
* Algorithm from CSS Color 4 spec.
|
|
579
|
+
*
|
|
580
|
+
* @param h - Hue in degrees (0-360)
|
|
581
|
+
* @param s - Saturation (0-1)
|
|
582
|
+
* @param l - Lightness (0-1)
|
|
583
|
+
* @returns RGB values in 0-255 range (may have fractional values)
|
|
584
|
+
*/
|
|
585
|
+
declare function hslToRgbValues(h: number, s: number, l: number): Vec3;
|
|
586
|
+
declare function getNamedColorHex(): Map<string, string>;
|
|
587
|
+
/**
|
|
588
|
+
* Convert hex color string to `rgb()` CSS string.
|
|
589
|
+
* Supports 3, 4, 6, and 8 character hex values (with or without `#`).
|
|
590
|
+
*/
|
|
591
|
+
declare function hexToRgb(hex: string): string | null;
|
|
592
|
+
/**
|
|
593
|
+
* Extract RGB values from an `rgb()`/`rgba()` string.
|
|
594
|
+
* Supports comma-separated, space-separated, fractional, percentage,
|
|
595
|
+
* and slash alpha notation.
|
|
596
|
+
*
|
|
597
|
+
* @returns Array of RGB values (0-255 range), converting percentages as needed.
|
|
598
|
+
*/
|
|
599
|
+
declare function getRgbValuesFromRgbaString(str: string): number[];
|
|
600
|
+
/**
|
|
601
|
+
* Convert any recognized color string to an `rgb()` CSS string.
|
|
602
|
+
* Handles hex, `okhsl()`, `okhst()`, `hsl()`/`hsla()`, named CSS colors,
|
|
603
|
+
* and `rgb()`/`rgba()` pass-through.
|
|
604
|
+
*/
|
|
605
|
+
declare function strToRgb(color: string, _ignoreAlpha?: boolean): string | null | undefined;
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/utils/styles.d.ts
|
|
608
|
+
type StyleValue<T = string> = T | boolean | number | null | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* Normalize a color token value.
|
|
611
|
+
* - Boolean `true` is converted to `'transparent'`
|
|
612
|
+
* - Boolean `false` returns `null` (signals the token should be skipped)
|
|
613
|
+
* - Other values are returned as-is
|
|
614
|
+
*
|
|
615
|
+
* @param value - The raw token value
|
|
616
|
+
* @returns Normalized value or null if the token should be skipped
|
|
617
|
+
*/
|
|
618
|
+
declare function normalizeColorTokenValue<T>(value: T | boolean): T | 'transparent' | null;
|
|
619
|
+
type StyleValueStateMap<T = string> = Record<string, StyleValue<T> | '@inherit'>;
|
|
620
|
+
/**
|
|
621
|
+
* Combined type for style values that can be either a direct value or a state map.
|
|
622
|
+
* Use this for component props that accept style values.
|
|
623
|
+
*/
|
|
624
|
+
type StylePropValue<T = string> = StyleValue<T> | StyleValueStateMap<T>;
|
|
625
|
+
/**
|
|
626
|
+
* One dependency value as a style handler receives it: already resolved for a
|
|
627
|
+
* single state, but still the **raw authored DSL string** (`'2x'`, `'#purple.5'`).
|
|
628
|
+
* Handlers parse it themselves via {@link parseStyle} / {@link parseColor}.
|
|
629
|
+
*/
|
|
630
|
+
type ResolvedStyleValue = StyleValue<string>;
|
|
631
|
+
/**
|
|
632
|
+
* The dependency map a handler receives — one resolved value per style name in
|
|
633
|
+
* its `__lookupStyles`.
|
|
634
|
+
*/
|
|
635
|
+
type StyleHandlerProps<TDeps extends string = string> = Partial<Record<TDeps, ResolvedStyleValue>>;
|
|
636
|
+
/**
|
|
637
|
+
* One set of CSS declarations returned by a style handler.
|
|
638
|
+
*
|
|
639
|
+
* Keys are **kebab-case** CSS property names (`'background-color'`, not
|
|
640
|
+
* `backgroundColor`) or `--custom-property` names. Values are stringified, so
|
|
641
|
+
* numbers are accepted. `$` is reserved as a selector suffix.
|
|
642
|
+
*/
|
|
643
|
+
type CSSMap = {
|
|
644
|
+
/** Selector suffix (or suffixes) these declarations apply to, e.g. `'& > *'`. */$?: string | string[];
|
|
645
|
+
} & Record<string, string | number | (string | number)[] | undefined>;
|
|
646
|
+
type StyleHandlerResult = CSSMap | CSSMap[] | null | void;
|
|
647
|
+
type RawStyleHandler<TProps extends object = StyleHandlerProps> = (props: TProps) => StyleHandlerResult;
|
|
648
|
+
type StyleHandler<TProps extends object = StyleHandlerProps> = RawStyleHandler<TProps> & {
|
|
649
|
+
__lookupStyles: string[];
|
|
650
|
+
};
|
|
651
|
+
/**
|
|
652
|
+
* The handler type used by the registry (`STYLE_HANDLER_MAP`), with parameter
|
|
653
|
+
* variance erased.
|
|
654
|
+
*
|
|
655
|
+
* Handlers declare narrow, hand-written dependency types — `({ fill }: { fill?:
|
|
656
|
+
* string }) => …` — which under `strictFunctionTypes` are not assignable to a
|
|
657
|
+
* wider parameter type. The registry stores handlers of many different dependency
|
|
658
|
+
* shapes together, so it needs the erased form. Prefer {@link StyleHandler} (or
|
|
659
|
+
* {@link defineHandler}) when writing a handler; this type is for code that
|
|
660
|
+
* inspects the registry.
|
|
661
|
+
*/
|
|
662
|
+
type AnyStyleHandler = ((props: any) => StyleHandlerResult) & {
|
|
663
|
+
__lookupStyles: string[];
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Handler definition forms for configure() and plugins.
|
|
667
|
+
* - Function only: lookup styles inferred from key name
|
|
668
|
+
* - Single property tuple: ['styleName', handler]
|
|
669
|
+
* - Multi-property tuple: [['style1', 'style2'], handler]
|
|
670
|
+
*
|
|
671
|
+
* Use {@link defineHandler} to have the dependency names inferred into the
|
|
672
|
+
* handler's parameter type instead of annotating it by hand.
|
|
673
|
+
*/
|
|
674
|
+
type StyleHandlerDefinition<TDeps extends string = string> = RawStyleHandler<StyleHandlerProps<TDeps>> | [TDeps, RawStyleHandler<StyleHandlerProps<TDeps>>] | [readonly TDeps[], RawStyleHandler<StyleHandlerProps<TDeps>>];
|
|
675
|
+
interface ParsedColor {
|
|
676
|
+
color?: string;
|
|
677
|
+
name?: string;
|
|
678
|
+
opacity?: number;
|
|
679
|
+
}
|
|
680
|
+
type StyleMap = Record<string, StyleValue | StyleValueStateMap>;
|
|
681
|
+
declare const CUSTOM_UNITS: {
|
|
682
|
+
r: string;
|
|
683
|
+
cr: string;
|
|
684
|
+
bw: string;
|
|
685
|
+
ow: string;
|
|
686
|
+
x: string;
|
|
687
|
+
sf: (num: number) => string;
|
|
688
|
+
};
|
|
689
|
+
declare const DIRECTIONS: string[];
|
|
690
|
+
/**
|
|
691
|
+
* Get the global StyleParser instance.
|
|
692
|
+
* Used by configure() to apply parser configuration.
|
|
693
|
+
*/
|
|
694
|
+
declare function getGlobalParser(): StyleParser;
|
|
695
|
+
/**
|
|
696
|
+
* Get the current global predefined tokens.
|
|
697
|
+
* Returns null if no tokens are configured.
|
|
698
|
+
*/
|
|
699
|
+
declare function getGlobalPredefinedTokens(): Record<string, string> | null;
|
|
700
|
+
/**
|
|
701
|
+
*
|
|
702
|
+
* @param {String} value
|
|
703
|
+
* @param {Number} mode
|
|
704
|
+
* @returns {Object<String,String|Array>}
|
|
705
|
+
*/
|
|
706
|
+
declare function parseStyle(value: StyleValue): ProcessedStyle;
|
|
707
|
+
/**
|
|
708
|
+
* Parse color. Find it value, name and opacity.
|
|
709
|
+
* Optimized to avoid heavy parseStyle calls for simple color patterns.
|
|
710
|
+
*/
|
|
711
|
+
declare function parseColor(val: string, ignoreError?: boolean): ParsedColor;
|
|
712
|
+
declare function filterMods(mods: string[], allowedMods: string[]): string[];
|
|
713
|
+
declare function stringifyStyles(styles: unknown): string;
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/styles/types.d.ts
|
|
716
|
+
/**
|
|
717
|
+
* Extensible interface for named color tokens.
|
|
718
|
+
* Augment this interface to register project-specific color names
|
|
719
|
+
* for autocomplete in `fill`, `color`, `svgFill`, and other color style props.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```typescript
|
|
723
|
+
* declare module '@tenphi/tasty' {
|
|
724
|
+
* interface TastyNamedColors {
|
|
725
|
+
* primary: true;
|
|
726
|
+
* danger: true;
|
|
727
|
+
* }
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
interface TastyNamedColors {}
|
|
732
|
+
type NamedColorKey = Extract<keyof TastyNamedColors, string>;
|
|
733
|
+
type NamedColor = [NamedColorKey] extends [never] ? string : NamedColorKey;
|
|
734
|
+
/**
|
|
735
|
+
* Extensible interface for typography preset names.
|
|
736
|
+
* Augment this interface to register project-specific preset names for autocomplete.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```typescript
|
|
740
|
+
* declare module '@tenphi/tasty' {
|
|
741
|
+
* interface TastyPresetNames {
|
|
742
|
+
* h1: true;
|
|
743
|
+
* t3: true;
|
|
744
|
+
* }
|
|
745
|
+
* }
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
interface TastyPresetNames {}
|
|
749
|
+
type PresetNameKey = Extract<keyof TastyPresetNames, string>;
|
|
750
|
+
type PresetName = [PresetNameKey] extends [never] ? string : PresetNameKey;
|
|
751
|
+
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
752
|
+
type OpaquePercentage = '' | `.${Digit}` | `.${Digit}${Digit}` | '.100';
|
|
753
|
+
type ColorValue = `#${NamedColor}${OpaquePercentage}` | `rgb(${string})` | `hsl(${string})` | `okhsl(${string})` | `oklch(${string})` | (string & {});
|
|
754
|
+
type NoType = false | null | undefined;
|
|
755
|
+
interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font' | 'outline' | 'type' | 'gap' | 'padding' | 'margin' | 'width' | 'height' | 'border' | 'transition' | 'placeContent' | 'placeItems' | 'scrollMargin' | 'scrollMarginTop' | 'scrollMarginRight' | 'scrollMarginBottom' | 'scrollMarginLeft' | 'scrollMarginBlock' | 'scrollMarginInline'> {
|
|
756
|
+
/**
|
|
757
|
+
* @deprecated Use `flow` style instead.
|
|
758
|
+
*/
|
|
759
|
+
flexDirection: CSSProperties['flexDirection'];
|
|
760
|
+
/**
|
|
761
|
+
* @deprecated Use `placeContent`, `placeItems`, `gridColumns`, `gridRows`, and `gridTemplate` styles instead.
|
|
762
|
+
*/
|
|
763
|
+
grid: CSSProperties['grid'];
|
|
764
|
+
/**
|
|
765
|
+
* @deprecated Use `flexShrink`, `flexGrow`, and `flexBasis` styles instead.
|
|
766
|
+
*/
|
|
767
|
+
flex: CSSProperties['flex'];
|
|
768
|
+
/**
|
|
769
|
+
* Set the background color of the element. Shortcut for `background-color` with enhanced support for Tasty color tokens and syntaxes.
|
|
770
|
+
*
|
|
771
|
+
* Supports double-color syntax: the second color is applied as a foreground overlay via a CSS custom property.
|
|
772
|
+
*
|
|
773
|
+
* Examples:
|
|
774
|
+
* - `fill="#purple.10"` // purple background with 10% opacity
|
|
775
|
+
* - `fill="#danger"` // danger theme color
|
|
776
|
+
* - `fill="rgb(255 128 0)"` // custom RGB color
|
|
777
|
+
* - `fill="rgb(255 128 0 / 0.5)"` // RGB with opacity
|
|
778
|
+
* - `fill="hsl(200 100% 50%)"` // HSL color
|
|
779
|
+
* - `fill="okhsl(200 100% 50%)"` // perceptually uniform OKHSL color
|
|
780
|
+
* - `fill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
781
|
+
* - `fill="#primary #secondary"` // double color (second as foreground overlay)
|
|
782
|
+
* - `fill={true}` // default fill color
|
|
783
|
+
*/
|
|
784
|
+
fill?: ColorValue | boolean;
|
|
785
|
+
/**
|
|
786
|
+
* @deprecated Use `fill` instead.
|
|
787
|
+
*/
|
|
788
|
+
backgroundColor?: CSSProperties['backgroundColor'];
|
|
789
|
+
/**
|
|
790
|
+
* Set the background image of the element. Shortcut for `background-image` with enhanced support for Tasty tokens.
|
|
791
|
+
*
|
|
792
|
+
* Examples:
|
|
793
|
+
* - `image="url(/path/to/image.png)"` // image from URL
|
|
794
|
+
* - `image="linear-gradient(to right, #purple, #danger)"` // gradient
|
|
795
|
+
*/
|
|
796
|
+
image?: CSSProperties['backgroundImage'];
|
|
797
|
+
/**
|
|
798
|
+
* @deprecated Use `image` instead.
|
|
799
|
+
*/
|
|
800
|
+
backgroundImage?: CSSProperties['backgroundImage'];
|
|
801
|
+
/**
|
|
802
|
+
* @deprecated Use separate background styles (`fill`, `image`, `backgroundSize`, etc.) instead.
|
|
803
|
+
* When set, overrides all other background-related styles.
|
|
804
|
+
*/
|
|
805
|
+
background?: CSSProperties['background'];
|
|
806
|
+
/**
|
|
807
|
+
* Set the fill color of SVG elements. Outputs the native CSS `fill` property with enhanced support for Tasty color tokens and syntaxes.
|
|
808
|
+
*
|
|
809
|
+
* Examples:
|
|
810
|
+
* - `svgFill="#purple.10"` // purple fill with 10% opacity
|
|
811
|
+
* - `svgFill="#danger"` // danger theme color
|
|
812
|
+
* - `svgFill="rgb(255 128 0)"` // custom RGB color
|
|
813
|
+
* - `svgFill="hsl(200 100% 50%)"` // HSL color
|
|
814
|
+
* - `svgFill="okhsl(200 100% 50%)"` // OKHSL color
|
|
815
|
+
* - `svgFill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
816
|
+
* - `svgFill="currentColor"` // inherit from parent color
|
|
817
|
+
*/
|
|
818
|
+
svgFill?: ColorValue;
|
|
819
|
+
/**
|
|
820
|
+
* Set the text (current) color of the element. Shortcut for `color` with enhanced support for Tasty color tokens and syntaxes.
|
|
821
|
+
*
|
|
822
|
+
* Examples:
|
|
823
|
+
* - `color="#purple"` // purple text color
|
|
824
|
+
* - `color="#danger.6"` // danger color with 60% opacity
|
|
825
|
+
* - `color="rgb(255 128 0)"` // custom RGB color
|
|
826
|
+
* - `color="hsl(200 100% 50%)"` // HSL color
|
|
827
|
+
* - `color="okhsl(200 100% 50%)"` // OKHSL color
|
|
828
|
+
* - `color="oklch(0.7 0.15 200)"` // OKLCH color
|
|
829
|
+
* - `color="red"` // CSS color name
|
|
830
|
+
* - `color={true}` // currentColor
|
|
831
|
+
*/
|
|
832
|
+
color?: ColorValue | boolean;
|
|
833
|
+
/**
|
|
834
|
+
* The fade style applies gradient-based fading masks to the edges of an element. Replaces complex CSS mask gradients with a simple, declarative API.
|
|
835
|
+
*
|
|
836
|
+
* Syntax: `[width] [direction...] [#from-color] [#to-color]`
|
|
837
|
+
*
|
|
838
|
+
* Multiple groups can be separated by commas to specify different widths and
|
|
839
|
+
* colors per direction. A group that names edges takes a single width, applied
|
|
840
|
+
* to every edge it names; a group that names none covers all four edges and
|
|
841
|
+
* keeps plain CSS shorthand order.
|
|
842
|
+
*
|
|
843
|
+
* Color tokens (optional):
|
|
844
|
+
* - First color: transparent start of gradient (default: `rgb(0 0 0 / 0)`)
|
|
845
|
+
* - Second color: opaque end of gradient (default: `rgb(0 0 0 / 1)`)
|
|
846
|
+
*
|
|
847
|
+
* Examples:
|
|
848
|
+
* - `fade="top"` // fade only top edge with default width
|
|
849
|
+
* - `fade="2x left right"` // fade left and right edges with 2x width
|
|
850
|
+
* - `fade={true}` // all edges at the design-system default width
|
|
851
|
+
* - `fade="1x top"` // fade only top edge with 1x width
|
|
852
|
+
* - `fade="3x 1x"` // all edges: top/bottom 3x, left/right 1x
|
|
853
|
+
* - `fade="3x top, 1x bottom"` // top: 3x width, bottom: 1x width
|
|
854
|
+
* - `fade="2x #transparent #dark"` // custom colors for gradient mask
|
|
855
|
+
* - `fade="1x top #clear #solid"` // top edge with custom mask colors
|
|
856
|
+
* - `fade="top #red #blue, bottom #green #yellow"` // different colors per direction
|
|
857
|
+
* - `fade="2x top #a #b, 1x bottom #c #d"` // different widths and colors per direction
|
|
858
|
+
*/
|
|
859
|
+
fade?: 'top' | 'right' | 'bottom' | 'left' | string | boolean;
|
|
860
|
+
/**
|
|
861
|
+
* Scrollbar styling using standard CSS properties (`scrollbar-width`, `scrollbar-color`, `scrollbar-gutter`).
|
|
862
|
+
*
|
|
863
|
+
* Syntax: `[width] [modifiers...] [thumb-color] [track-color]`
|
|
864
|
+
*
|
|
865
|
+
* Width values: `thin` (default), `auto`, `none`
|
|
866
|
+
* Modifiers: `stable`, `both-edges`, `always`
|
|
867
|
+
*
|
|
868
|
+
* Examples:
|
|
869
|
+
* - `scrollbar={true}` // thin scrollbar, default colors
|
|
870
|
+
* - `scrollbar="thin #purple.40 #dark.04"`
|
|
871
|
+
* - `scrollbar="auto #red #blue"`
|
|
872
|
+
* - `scrollbar="none"`
|
|
873
|
+
* - `scrollbar="always #primary.50 #white.02"`
|
|
874
|
+
* - `scrollbar="thin stable #red #blue"`
|
|
875
|
+
*/
|
|
876
|
+
scrollbar?: string | boolean;
|
|
877
|
+
/**
|
|
878
|
+
* Set font weight for bold texts.
|
|
879
|
+
*/
|
|
880
|
+
boldFontWeight?: number;
|
|
881
|
+
/**
|
|
882
|
+
* The gap style is a powerful, cross-layout shorthand for spacing between child elements. Works with flex, grid, and block layouts.
|
|
883
|
+
*
|
|
884
|
+
* For flex/grid: sets native `gap` property
|
|
885
|
+
* For block layouts: emulated using margin on children
|
|
886
|
+
*
|
|
887
|
+
* Examples:
|
|
888
|
+
* - `gap="2x"` // gap: 2x (or margin-bottom: 2x for block)
|
|
889
|
+
* - `gap="1x 2x"` // row gap: 1x, column gap: 2x
|
|
890
|
+
* - `gap={true}` // default gap (1x)
|
|
891
|
+
*/
|
|
892
|
+
gap?: CSSProperties['gap'] | string | boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Shorthand for element padding. Supports custom units, directional modifiers, and design-system-driven defaults.
|
|
895
|
+
*
|
|
896
|
+
* A group that names directions takes a single value, applied to every
|
|
897
|
+
* direction it names — use comma groups for per-side values.
|
|
898
|
+
*
|
|
899
|
+
* Examples:
|
|
900
|
+
* - `padding="2x 1x"` // top/bottom: 2x, left/right: 1x
|
|
901
|
+
* - `padding="2x top"` // only top padding: 2x
|
|
902
|
+
* - `padding="1x left right"` // left and right padding: 1x
|
|
903
|
+
* - `padding="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: 0
|
|
904
|
+
* - `padding={true}` // default padding on all sides
|
|
905
|
+
*/
|
|
906
|
+
padding?: CSSProperties['padding'] | string | boolean;
|
|
907
|
+
/**
|
|
908
|
+
* Shorthand for element margin. Supports custom units, directional modifiers, and design-system-driven defaults.
|
|
909
|
+
*
|
|
910
|
+
* A group that names directions takes a single value, applied to every
|
|
911
|
+
* direction it names — use comma groups for per-side values.
|
|
912
|
+
*
|
|
913
|
+
* Examples:
|
|
914
|
+
* - `margin="2x 1x"` // top/bottom: 2x, left/right: 1x
|
|
915
|
+
* - `margin="2x top"` // only top margin: 2x
|
|
916
|
+
* - `margin="1x left right"` // left and right margin: 1x
|
|
917
|
+
* - `margin="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: 0
|
|
918
|
+
* - `margin={true}` // default margin on all sides
|
|
919
|
+
*/
|
|
920
|
+
margin?: CSSProperties['margin'] | string | boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Concise shorthand for setting element width, including min-width and max-width. Supports custom units and advanced sizing keywords.
|
|
923
|
+
*
|
|
924
|
+
* Syntax: `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
|
|
925
|
+
*
|
|
926
|
+
* Modifiers: `min`, `max`
|
|
927
|
+
* Keywords: `stretch`, `max-content`, `min-content`, `fit-content`
|
|
928
|
+
*
|
|
929
|
+
* Examples:
|
|
930
|
+
* - `width="10x"` // width: 10x
|
|
931
|
+
* - `width="1x 10x"` // min-width: 1x; max-width: 10x
|
|
932
|
+
* - `width="min 2x"` // min-width: 2x
|
|
933
|
+
* - `width="stretch"` // width: stretch (fill-available)
|
|
934
|
+
* - `width={true}` // width: auto
|
|
935
|
+
*/
|
|
936
|
+
width?: CSSProperties['width'] | string | boolean;
|
|
937
|
+
/**
|
|
938
|
+
* Concise shorthand for setting element height, including min-height and max-height. Supports custom units and advanced sizing keywords.
|
|
939
|
+
*
|
|
940
|
+
* Syntax: `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
|
|
941
|
+
*
|
|
942
|
+
* Modifiers: `min`, `max`
|
|
943
|
+
* Keywords: `stretch`, `max-content`, `min-content`, `fit-content`
|
|
944
|
+
*
|
|
945
|
+
* Examples:
|
|
946
|
+
* - `height="100px"` // height: 100px
|
|
947
|
+
* - `height="1x 5x 10x"` // min-height: 1x; height: 5x; max-height: 10x
|
|
948
|
+
* - `height="min 2x"` // min-height: 2x
|
|
949
|
+
* - `height={true}` // height: auto
|
|
950
|
+
*/
|
|
951
|
+
height?: CSSProperties['height'] | string | boolean;
|
|
952
|
+
/**
|
|
953
|
+
* Shorthand for border width, style, and color. Supports directional modifiers and design-system defaults.
|
|
954
|
+
*
|
|
955
|
+
* Syntax: `[width] [style] [color] [directions]` | `[directions]` | `true`
|
|
956
|
+
*
|
|
957
|
+
* Multiple groups can be separated by commas. Later groups override earlier groups for conflicting directions.
|
|
958
|
+
*
|
|
959
|
+
* Examples:
|
|
960
|
+
* - `border={true}` // default border on all sides (1bw solid)
|
|
961
|
+
* - `border="2bw dashed #purple"` // 2bw dashed purple border
|
|
962
|
+
* - `border="2bw top"` // only top border: 2bw solid
|
|
963
|
+
* - `border="dotted #danger left right"` // left/right: 1bw dotted danger
|
|
964
|
+
* - `border="1bw #red, 2bw #blue top"` // all sides red 1bw, top overridden to blue 2bw
|
|
965
|
+
* - `border="1bw, dashed top bottom, #purple left right"` // base 1bw, dashed on top/bottom, purple on left/right
|
|
966
|
+
* - `border="1bw $my-style"` // custom property in the style slot
|
|
967
|
+
*
|
|
968
|
+
* A `$name` reference fills the first free slot — width, then style, then
|
|
969
|
+
* color. Colors are authored as `#name`; to point the color slot at a raw
|
|
970
|
+
* custom property directly, name it `$name-color`.
|
|
971
|
+
*/
|
|
972
|
+
border?: CSSProperties['border'] | string | boolean;
|
|
973
|
+
/**
|
|
974
|
+
* Powerful shorthand for CSS transitions using semantic names and design tokens. Supports grouped transitions for common UI effects.
|
|
975
|
+
*
|
|
976
|
+
* Semantic names: `fade`, `fill`, `border`, `radius`, `shadow`, `preset`, `gap`, `theme`
|
|
977
|
+
* Multiple transitions: separated by commas
|
|
978
|
+
*
|
|
979
|
+
* Examples:
|
|
980
|
+
* - `transition="fill 0.2s, radius 0.3s"` // transitions background-color and border-radius
|
|
981
|
+
* - `transition="fade 0.15s ease-in"` // transitions mask with easing
|
|
982
|
+
* - `transition="theme 0.3s"` // transitions all theme-related properties
|
|
983
|
+
* - `transition="preset 0.2s"` // transitions typography properties
|
|
984
|
+
*/
|
|
985
|
+
transition?: CSSProperties['transition'] | string;
|
|
986
|
+
/**
|
|
987
|
+
* Whether the element is hidden using `display: none`. Boolean shortcut for conditional element visibility.
|
|
988
|
+
*
|
|
989
|
+
* Examples:
|
|
990
|
+
* - `hide={true}` // display: none
|
|
991
|
+
* - `hide={false}` // element remains visible
|
|
992
|
+
*/
|
|
993
|
+
hide?: boolean;
|
|
994
|
+
/**
|
|
995
|
+
* The shadow style adds shadow effects around an element's frame. Supports multiple effects separated by commas with X/Y offsets, blur, spread radius, and color.
|
|
996
|
+
*
|
|
997
|
+
* Examples:
|
|
998
|
+
* - `shadow="1x .5x .5x #dark.50"` // custom shadow with Tasty units and colors
|
|
999
|
+
* - `shadow="0 1x 2x #dark.20"` // standard shadow syntax
|
|
1000
|
+
* - `shadow={true}` // default shadow from design system
|
|
1001
|
+
*/
|
|
1002
|
+
shadow?: string | boolean;
|
|
1003
|
+
/**
|
|
1004
|
+
* The radius style rounds the corners of an element's outer border edge. Supports custom units, advanced shapes, and directional modifiers.
|
|
1005
|
+
*
|
|
1006
|
+
* Syntax: `[value] [modifiers]` | `[shape]` | `true`
|
|
1007
|
+
*
|
|
1008
|
+
* Shapes: `round` (fully rounded), `ellipse` (50%), `leaf`, `backleaf` (asymmetric), `inherit` (inherit from parent)
|
|
1009
|
+
* Edge modifiers: `top`, `right`, `bottom`, `left` — the corner pair along that edge
|
|
1010
|
+
* Corner modifiers: `top-left`, `top-right`, `bottom-right`, `bottom-left` — a single corner
|
|
1011
|
+
*
|
|
1012
|
+
* Examples:
|
|
1013
|
+
* - `radius="2r"` // border-radius: calc(var(--radius) * 2)
|
|
1014
|
+
* - `radius={true}` // default radius (1r)
|
|
1015
|
+
* - `radius="round"` // fully rounded (9999rem)
|
|
1016
|
+
* - `radius="leaf"` // asymmetric leaf shape
|
|
1017
|
+
* - `radius="1r top"` // round both top corners
|
|
1018
|
+
* - `radius="top-right"` // round only the top-right corner (1r)
|
|
1019
|
+
* - `radius="4px top-left"` // round only the top-left corner
|
|
1020
|
+
* - `radius="inherit"` // inherit border-radius from parent
|
|
1021
|
+
* - `radius="inherit right"` // inherit only right corners (uses longhand properties)
|
|
1022
|
+
*/
|
|
1023
|
+
radius?: 'round' | 'ellipse' | 'leaf' | 'backleaf' | 'inherit' | string | true;
|
|
1024
|
+
/**
|
|
1025
|
+
* The flow style is a unified shorthand for controlling layout direction and wrapping in both flex and grid containers. Replaces `flexDirection` and `gridAutoFlow`.
|
|
1026
|
+
*
|
|
1027
|
+
* For flex: sets `flex-flow` (direction + wrapping)
|
|
1028
|
+
* For grid: sets `grid-auto-flow` (direction + density)
|
|
1029
|
+
* For block: determines gap direction (row/column)
|
|
1030
|
+
*
|
|
1031
|
+
* Syntax: `[direction] [wrap|dense]`
|
|
1032
|
+
*
|
|
1033
|
+
* Examples:
|
|
1034
|
+
* - `flow="row wrap"` // flex-flow: row wrap
|
|
1035
|
+
* - `flow="column dense"` // grid-auto-flow: column dense
|
|
1036
|
+
* - `flow="row"` // primary axis direction
|
|
1037
|
+
*/
|
|
1038
|
+
flow?: CSSProperties['flexFlow'] | CSSProperties['gridAutoFlow'] | string;
|
|
1039
|
+
/**
|
|
1040
|
+
* The gridAreas style specifies named grid areas, establishing cells in the grid and assigning them names.
|
|
1041
|
+
*
|
|
1042
|
+
* Examples:
|
|
1043
|
+
* - `gridAreas='"header header" "sidebar content" "footer footer"'`
|
|
1044
|
+
*/
|
|
1045
|
+
gridAreas?: CSSProperties['gridTemplateAreas'];
|
|
1046
|
+
/**
|
|
1047
|
+
* The gridColumns style defines line names and track sizing functions of grid columns.
|
|
1048
|
+
*
|
|
1049
|
+
* Examples:
|
|
1050
|
+
* - `gridColumns="1fr 2fr 1fr"` // three columns with flex ratios
|
|
1051
|
+
* - `gridColumns={3}` // three equal columns (shorthand)
|
|
1052
|
+
* - `gridColumns="repeat(auto-fit, minmax(200px, 1fr))"` // responsive columns
|
|
1053
|
+
*/
|
|
1054
|
+
gridColumns?: CSSProperties['gridTemplateColumns'] | number;
|
|
1055
|
+
/**
|
|
1056
|
+
* The gridRows style defines line names and track sizing functions of grid rows.
|
|
1057
|
+
*
|
|
1058
|
+
* Examples:
|
|
1059
|
+
* - `gridRows="auto 1fr auto"` // header, content, footer layout
|
|
1060
|
+
* - `gridRows={4}` // four equal rows (shorthand)
|
|
1061
|
+
* - `gridRows="repeat(3, 100px)"` // three 100px rows
|
|
1062
|
+
*/
|
|
1063
|
+
gridRows?: CSSProperties['gridTemplateRows'] | number;
|
|
1064
|
+
/**
|
|
1065
|
+
* The gridTemplate style is a shorthand property for defining grid columns, rows, and areas simultaneously.
|
|
1066
|
+
*
|
|
1067
|
+
* Examples:
|
|
1068
|
+
* - `gridTemplate='"header header" auto "content sidebar" 1fr / 2fr 1fr'`
|
|
1069
|
+
*/
|
|
1070
|
+
gridTemplate?: CSSProperties['gridTemplate'];
|
|
1071
|
+
/**
|
|
1072
|
+
* The font style specifies a prioritized list of font family names with design-system-driven defaults and fallbacks.
|
|
1073
|
+
*
|
|
1074
|
+
* Examples:
|
|
1075
|
+
* - `font="monospace"` // monospace font stack
|
|
1076
|
+
* - `font="Helvetica, Arial, sans-serif"` // custom font list
|
|
1077
|
+
* - `font={true}` // default design system font
|
|
1078
|
+
*/
|
|
1079
|
+
font?: CSSProperties['fontFamily'] | boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* The outline style sets the outline for the element.
|
|
1082
|
+
*
|
|
1083
|
+
* Syntax: `[width] [style] [color] / [offset]` | `true`
|
|
1084
|
+
*
|
|
1085
|
+
* Examples:
|
|
1086
|
+
* - `outline="2ow dashed #purple"` // 2ow dashed purple outline
|
|
1087
|
+
* - `outline="2ow #danger / 1x"` // 2ow solid danger outline, 1x offset
|
|
1088
|
+
* - `outline={true}` // default outline (1ow solid)
|
|
1089
|
+
* - `outline="2ow $my-style"` // custom property in the style slot
|
|
1090
|
+
*
|
|
1091
|
+
* A `$name` reference fills the first free slot — width, then style, then
|
|
1092
|
+
* color. Colors are authored as `#name`; to point the color slot at a raw
|
|
1093
|
+
* custom property directly, name it `$name-color`.
|
|
1094
|
+
*/
|
|
1095
|
+
outline?: string | boolean;
|
|
1096
|
+
/**
|
|
1097
|
+
* The outline offset style sets the offset of the outline.
|
|
1098
|
+
*
|
|
1099
|
+
* Examples:
|
|
1100
|
+
* - `outlineOffset="4px"` // 4px offset
|
|
1101
|
+
* - `outlineOffset="1x"` // 1x (8px) offset
|
|
1102
|
+
*/
|
|
1103
|
+
outlineOffset?: string | number;
|
|
1104
|
+
/**
|
|
1105
|
+
* The preset style sets base text settings according to named presets. Affects `font-size`, `line-height`, `letter-spacing`, `font-weight`, and `text-transform`.
|
|
1106
|
+
*
|
|
1107
|
+
* Syntax: `name`, `name / modifier...`, or `modifier...` (shorthand, name defaults to `inherit`).
|
|
1108
|
+
* Multiple modifiers are space-separated and combine freely (e.g. `strong italic tight`).
|
|
1109
|
+
* Preset names are project-specific. Augment `TastyPresetNames` to register them for autocomplete.
|
|
1110
|
+
*
|
|
1111
|
+
* Examples:
|
|
1112
|
+
* - `preset="h1"` // heading 1 typography
|
|
1113
|
+
* - `preset="h2 / strong"` // bold heading 2
|
|
1114
|
+
* - `preset="h2 / strong italic"` // bold + italic heading 2
|
|
1115
|
+
* - `preset="t2 / strong tight"` // bold text 2 with tight line-height
|
|
1116
|
+
* - `preset="bold"` // inherit with bold (shorthand)
|
|
1117
|
+
* - `preset="bold italic"` // inherit with bold + italic (shorthand)
|
|
1118
|
+
* - `preset="t3"` // text size 3
|
|
1119
|
+
*/
|
|
1120
|
+
preset?: PresetName | (string & {});
|
|
1121
|
+
/**
|
|
1122
|
+
* Shorthand for `align-items` and `align-content`. Sets both properties for unified vertical alignment in flex/grid layouts.
|
|
1123
|
+
*
|
|
1124
|
+
* Examples:
|
|
1125
|
+
* - `align="center"` // align-items: center; align-content: center
|
|
1126
|
+
* - `align="flex-start"` // align both to start
|
|
1127
|
+
* - `align="space-between"` // distribute space between items
|
|
1128
|
+
*/
|
|
1129
|
+
align?: CSSProperties['alignItems'] | CSSProperties['alignContent'];
|
|
1130
|
+
/**
|
|
1131
|
+
* Shorthand for `justify-items` and `justify-content`. Sets both properties for unified horizontal alignment in flex/grid layouts.
|
|
1132
|
+
*
|
|
1133
|
+
* Examples:
|
|
1134
|
+
* - `justify="center"` // justify-items: center; justify-content: center
|
|
1135
|
+
* - `justify="space-between"` // distribute space between items
|
|
1136
|
+
* - `justify="flex-end"` // align both to end
|
|
1137
|
+
*/
|
|
1138
|
+
justify?: CSSProperties['justifyItems'] | CSSProperties['justifyContent'];
|
|
1139
|
+
/**
|
|
1140
|
+
* Shorthand for all placement properties. Sets all 4 longhands: align-items, justify-items, align-content, justify-content.
|
|
1141
|
+
*
|
|
1142
|
+
* Examples:
|
|
1143
|
+
* - `place="center"` // all 4 longhands: center
|
|
1144
|
+
* - `place="start end"` // align-*: start; justify-*: end
|
|
1145
|
+
* - `place="stretch"` // all 4 longhands: stretch
|
|
1146
|
+
*/
|
|
1147
|
+
place?: CSSProperties['placeItems'] | CSSProperties['placeContent'] | string;
|
|
1148
|
+
/**
|
|
1149
|
+
* Sets `place-content` property for aligning and distributing content in grid/flex containers.
|
|
1150
|
+
*
|
|
1151
|
+
* Examples:
|
|
1152
|
+
* - `placeContent="center"` // center content in both axes
|
|
1153
|
+
* - `placeContent="space-between"` // distribute content with space between
|
|
1154
|
+
*/
|
|
1155
|
+
placeContent?: CSSProperties['placeContent'];
|
|
1156
|
+
/**
|
|
1157
|
+
* Sets `place-items` property for aligning items in grid/flex containers.
|
|
1158
|
+
*
|
|
1159
|
+
* Examples:
|
|
1160
|
+
* - `placeItems="center"` // center items in both axes
|
|
1161
|
+
* - `placeItems="start end"` // start on block axis, end on inline axis
|
|
1162
|
+
*/
|
|
1163
|
+
placeItems?: CSSProperties['placeItems'];
|
|
1164
|
+
/**
|
|
1165
|
+
* Shorthand for scroll-margin on all sides. Supports custom units and directional modifiers.
|
|
1166
|
+
*
|
|
1167
|
+
* Examples:
|
|
1168
|
+
* - `scrollMargin="2x"` // scroll-margin on all sides: 2x
|
|
1169
|
+
* - `scrollMargin="2x top"` // only top scroll-margin: 2x
|
|
1170
|
+
* - `scrollMargin="2x top, 4x bottom"` // top: 2x, bottom: 4x
|
|
1171
|
+
* - `scrollMargin={true}` // default scroll-margin on all sides
|
|
1172
|
+
*/
|
|
1173
|
+
scrollMargin?: CSSProperties['scrollMargin'] | string | boolean;
|
|
1174
|
+
scrollMarginTop?: string | number | boolean;
|
|
1175
|
+
scrollMarginRight?: string | number | boolean;
|
|
1176
|
+
scrollMarginBottom?: string | number | boolean;
|
|
1177
|
+
scrollMarginLeft?: string | number | boolean;
|
|
1178
|
+
scrollMarginBlock?: string | number | boolean;
|
|
1179
|
+
scrollMarginInline?: string | number | boolean;
|
|
1180
|
+
/**
|
|
1181
|
+
* Shorthand for `top`, `right`, `bottom`, and `left` offsets. Supports custom units, directional modifiers, and positioning.
|
|
1182
|
+
*
|
|
1183
|
+
* Examples:
|
|
1184
|
+
* - `inset="0"` // all sides: 0
|
|
1185
|
+
* - `inset="2x top"` // only top offset: 2x
|
|
1186
|
+
* - `inset="1x left right"` // left and right offsets: 1x
|
|
1187
|
+
* - `inset="2x top, 4x right"` // top: 2x, right: 4x, bottom/left: auto
|
|
1188
|
+
* - `inset="bottom dock"` // bottom-anchored, full width: auto 0 0 0
|
|
1189
|
+
* - `inset={true}` // all sides: 0
|
|
1190
|
+
*
|
|
1191
|
+
* A group that names directions takes a single value, applied to every
|
|
1192
|
+
* direction it names — use comma groups for per-side values.
|
|
1193
|
+
*
|
|
1194
|
+
* The `dock` modifier pins the named edge and spans its full length, applying
|
|
1195
|
+
* the value to the two perpendicular sides as well. `dock` is the one case
|
|
1196
|
+
* where a directional group takes two values: the second applies to those
|
|
1197
|
+
* spanned sides, so `inset="2x 4x bottom dock"` pins the bottom at `2x` and
|
|
1198
|
+
* insets the sides by `4x`. Without `dock` a second value is ignored.
|
|
1199
|
+
*/
|
|
1200
|
+
inset?: 'top' | 'right' | 'bottom' | 'left' | 'dock' | string | CSSProperties['inset'];
|
|
1201
|
+
/**
|
|
1202
|
+
* Local keyframes definitions for this component.
|
|
1203
|
+
* Keys are animation names, values are keyframes step definitions.
|
|
1204
|
+
* Local keyframes override global keyframes with the same name.
|
|
1205
|
+
*
|
|
1206
|
+
* Examples:
|
|
1207
|
+
* - `'@keyframes': { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }`
|
|
1208
|
+
* - `'@keyframes': { pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } } }`
|
|
1209
|
+
*/
|
|
1210
|
+
'@keyframes'?: Record<string, KeyframesSteps>;
|
|
1211
|
+
/**
|
|
1212
|
+
* CSS @property definitions for custom properties using tasty token syntax.
|
|
1213
|
+
* Properties are registered once and are permanent (never removed).
|
|
1214
|
+
*
|
|
1215
|
+
* Token formats:
|
|
1216
|
+
* - `$name` for regular properties → `--name` (requires syntax to be specified)
|
|
1217
|
+
* - `#name` for color properties → `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
|
|
1218
|
+
*
|
|
1219
|
+
* Examples:
|
|
1220
|
+
* - `'@property': { '$rotation': { syntax: '<angle>', inherits: false, initialValue: '45deg' } }`
|
|
1221
|
+
* - `'@property': { '#theme': { initialValue: 'purple' } }` // syntax: '<color>' is auto-set
|
|
1222
|
+
*/
|
|
1223
|
+
'@property'?: Record<string, PropertyDefinition>;
|
|
1224
|
+
/**
|
|
1225
|
+
* Local @font-face definitions for this component.
|
|
1226
|
+
* Keys are font-family names, values are descriptors or arrays of descriptors
|
|
1227
|
+
* (for multiple weights/styles of the same family).
|
|
1228
|
+
*
|
|
1229
|
+
* Examples:
|
|
1230
|
+
* - `'@font-face': { Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' } }`
|
|
1231
|
+
* - `'@font-face': { 'Brand Sans': [{ src: '...', fontWeight: 400 }, { src: '...', fontWeight: 700 }] }`
|
|
1232
|
+
*/
|
|
1233
|
+
'@font-face'?: Record<string, FontFaceInput>;
|
|
1234
|
+
/**
|
|
1235
|
+
* Local @counter-style definitions for this component.
|
|
1236
|
+
* Keys are counter-style names, values are descriptor objects.
|
|
1237
|
+
*
|
|
1238
|
+
* Examples:
|
|
1239
|
+
* - `'@counter-style': { thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' } }`
|
|
1240
|
+
*/
|
|
1241
|
+
'@counter-style'?: Record<string, CounterStyleDescriptors>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Local @function definitions (CSS custom functions) for this component.
|
|
1244
|
+
* Keys are function names using `$$name` (the literal callable `--name`),
|
|
1245
|
+
* matching the call site `$$name(...)`. Values are function definitions.
|
|
1246
|
+
*
|
|
1247
|
+
* Local variables are declared directly as `$name` keys on the descriptor;
|
|
1248
|
+
* `result`, local-var values, and parameter defaults are parsed through the
|
|
1249
|
+
* Tasty DSL (units, color tokens, auto-calc, fallbacks).
|
|
1250
|
+
*
|
|
1251
|
+
* Examples:
|
|
1252
|
+
* - `'@function': { '$$negative': { args: ['$value'], result: '(-1 * $value)' } }`
|
|
1253
|
+
* - `'@function': { '$$shadow': { args: { '$color': { syntax: '<color>', default: 'inherit' } }, returns: '<color>', '$offset': '2px', result: '$offset $offset ($color, black)' } }`
|
|
1254
|
+
*/
|
|
1255
|
+
'@function'?: Record<string, FunctionDefinition>;
|
|
1256
|
+
/**
|
|
1257
|
+
* Apply one or more predefined style recipes by name.
|
|
1258
|
+
* Recipes are defined globally via `configure({ recipes: { ... } })`.
|
|
1259
|
+
* Multiple recipes are space-separated. Use `/` to separate base recipes
|
|
1260
|
+
* (applied before component styles) from post recipes (applied after, via mergeStyles).
|
|
1261
|
+
* Use `none` to explicitly skip base recipes.
|
|
1262
|
+
*
|
|
1263
|
+
* Examples:
|
|
1264
|
+
* - `recipe: 'card'` // Apply the 'card' recipe
|
|
1265
|
+
* - `recipe: 'card elevated'` // Apply 'card' then 'elevated', then component styles
|
|
1266
|
+
* - `recipe: 'reset input / input-autofill'` // Base recipes, then post recipe
|
|
1267
|
+
* - `recipe: 'none / disabled'` // No base recipes, only post recipe
|
|
1268
|
+
* - `recipe: ''` // Clear recipes from base styles when extending
|
|
1269
|
+
*/
|
|
1270
|
+
recipe?: string;
|
|
1271
|
+
}
|
|
1272
|
+
type SuffixForSelector = '&' | '.' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
|
|
1273
|
+
type Selector = `${SuffixForSelector}${string}`;
|
|
1274
|
+
type NotSelector = Exclude<string, Selector | keyof StylesInterface>;
|
|
1275
|
+
/** Special style keys that should not be wrapped in StyleValue/StyleValueStateMap */
|
|
1276
|
+
type SpecialStyleKeys = '@keyframes' | '@property' | '@font-face' | '@counter-style' | '@function' | 'recipe';
|
|
1277
|
+
type StylesWithoutSelectors = { [key in keyof StylesInterface as key extends SpecialStyleKeys ? never : key]?: StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]> };
|
|
1278
|
+
/**
|
|
1279
|
+
* Index signature for recipe-specific arbitrary keys.
|
|
1280
|
+
* Supports local predefined states (`@name`), vendor-prefixed CSS properties (`-webkit-*`),
|
|
1281
|
+
* CSS custom properties (`$name`), and color tokens (`#name`).
|
|
1282
|
+
* Unlike StylesIndexSignature, does NOT allow sub-element selectors (recipes are flat).
|
|
1283
|
+
*/
|
|
1284
|
+
type RecipeIndexSignature = Record<string, StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined>>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Style type for recipe definitions.
|
|
1287
|
+
* Like StylesWithoutSelectors but also allows `@keyframes`, `@property`,
|
|
1288
|
+
* local predefined states, and vendor-prefixed CSS properties.
|
|
1289
|
+
* Excludes `recipe` to prevent recursive references.
|
|
1290
|
+
*/
|
|
1291
|
+
type RecipeStyles = StylesWithoutSelectors & RecipeIndexSignature & {
|
|
1292
|
+
'@keyframes'?: StylesInterface['@keyframes'];
|
|
1293
|
+
'@property'?: StylesInterface['@property'];
|
|
1294
|
+
'@font-face'?: StylesInterface['@font-face'];
|
|
1295
|
+
'@counter-style'?: StylesInterface['@counter-style'];
|
|
1296
|
+
'@function'?: StylesInterface['@function'];
|
|
1297
|
+
};
|
|
1298
|
+
/** Special properties that are not regular style values */
|
|
1299
|
+
interface SpecialStyleProperties {
|
|
1300
|
+
'@keyframes'?: StylesInterface['@keyframes'];
|
|
1301
|
+
'@property'?: StylesInterface['@property'];
|
|
1302
|
+
'@font-face'?: StylesInterface['@font-face'];
|
|
1303
|
+
'@counter-style'?: StylesInterface['@counter-style'];
|
|
1304
|
+
'@function'?: StylesInterface['@function'];
|
|
1305
|
+
recipe?: StylesInterface['recipe'];
|
|
1306
|
+
}
|
|
1307
|
+
/** Index signature for arbitrary style keys (sub-elements, CSS variables, etc.) */
|
|
1308
|
+
interface StylesIndexSignature {
|
|
1309
|
+
[key: string]: StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined> | Styles | false | StylesInterface['@keyframes'] | StylesInterface['@property'] | StylesInterface['@font-face'] | StylesInterface['@counter-style'] | StylesInterface['@function'];
|
|
1310
|
+
/**
|
|
1311
|
+
* Selector combinator: `undefined` (descendant, default), `'>'` (child), `'+'` (adjacent), `'~'` (sibling).
|
|
1312
|
+
* Can chain with capitalized names: `'> Body > Row >'`. Spaces required around combinators.
|
|
1313
|
+
*/
|
|
1314
|
+
$?: string;
|
|
1315
|
+
}
|
|
1316
|
+
type Styles = StylesWithoutSelectors & SpecialStyleProperties & StylesIndexSignature;
|
|
1317
|
+
/**
|
|
1318
|
+
* Value type for design tokens passed to `configure({ tokens })`.
|
|
1319
|
+
* Can be a direct value or a state map for responsive/theme-aware tokens.
|
|
1320
|
+
*/
|
|
1321
|
+
type ConfigTokenValue = string | number | boolean | Record<string, string | number | boolean | undefined | null | '@inherit'>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
1324
|
+
* Keys must start with `$` (value tokens) or `#` (color tokens).
|
|
1325
|
+
*
|
|
1326
|
+
* - `$name` keys become `--name` CSS custom properties
|
|
1327
|
+
* - `#name` keys become `--name-color` properties
|
|
1328
|
+
*/
|
|
1329
|
+
type ConfigTokens = Record<`$${string}` | `#${string}`, ConfigTokenValue>;
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/pipeline/conditions.d.ts
|
|
1332
|
+
/**
|
|
1333
|
+
* ConditionNode Types and Helpers
|
|
1334
|
+
*
|
|
1335
|
+
* Core data structures for representing style conditions as an abstract syntax tree.
|
|
1336
|
+
* Used throughout the pipeline for parsing, simplification, and CSS generation.
|
|
1337
|
+
*/
|
|
1338
|
+
/**
|
|
1339
|
+
* Base interface for all state conditions (leaf nodes)
|
|
1340
|
+
*/
|
|
1341
|
+
interface BaseStateCondition {
|
|
1342
|
+
kind: 'state';
|
|
1343
|
+
negated: boolean;
|
|
1344
|
+
raw: string;
|
|
1345
|
+
uniqueId: string;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Modifier condition: [data-attr] or [data-attr="value"]
|
|
1349
|
+
*/
|
|
1350
|
+
interface ModifierCondition extends BaseStateCondition {
|
|
1351
|
+
type: 'modifier';
|
|
1352
|
+
attribute: string;
|
|
1353
|
+
value?: string;
|
|
1354
|
+
operator?: '=' | '^=' | '$=' | '*=';
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Pseudo-class condition: :hover, :focus-visible
|
|
1358
|
+
*/
|
|
1359
|
+
interface PseudoCondition extends BaseStateCondition {
|
|
1360
|
+
type: 'pseudo';
|
|
1361
|
+
pseudo: string;
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Numeric bound for dimension queries
|
|
1365
|
+
*/
|
|
1366
|
+
interface NumericBound {
|
|
1367
|
+
value: string;
|
|
1368
|
+
valueNumeric: number | null;
|
|
1369
|
+
inclusive: boolean;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Media query condition
|
|
1373
|
+
*/
|
|
1374
|
+
interface MediaCondition extends BaseStateCondition {
|
|
1375
|
+
type: 'media';
|
|
1376
|
+
subtype: 'dimension' | 'feature' | 'type';
|
|
1377
|
+
dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
|
|
1378
|
+
lowerBound?: NumericBound;
|
|
1379
|
+
upperBound?: NumericBound;
|
|
1380
|
+
feature?: string;
|
|
1381
|
+
featureValue?: string;
|
|
1382
|
+
mediaType?: 'print' | 'screen' | 'all' | 'speech';
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Container query condition
|
|
1386
|
+
*/
|
|
1387
|
+
interface ContainerCondition extends BaseStateCondition {
|
|
1388
|
+
type: 'container';
|
|
1389
|
+
subtype: 'dimension' | 'style' | 'raw';
|
|
1390
|
+
containerName?: string;
|
|
1391
|
+
dimension?: 'width' | 'height' | 'inline-size' | 'block-size';
|
|
1392
|
+
lowerBound?: NumericBound;
|
|
1393
|
+
upperBound?: NumericBound;
|
|
1394
|
+
property?: string;
|
|
1395
|
+
propertyValue?: string;
|
|
1396
|
+
rawCondition?: string;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Root state condition: @root(theme=dark)
|
|
1400
|
+
*/
|
|
1401
|
+
interface RootCondition extends BaseStateCondition {
|
|
1402
|
+
type: 'root';
|
|
1403
|
+
innerCondition: ConditionNode;
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Parent state condition: @parent(hovered), @parent(theme=dark, >)
|
|
1407
|
+
*/
|
|
1408
|
+
interface ParentCondition extends BaseStateCondition {
|
|
1409
|
+
type: 'parent';
|
|
1410
|
+
innerCondition: ConditionNode;
|
|
1411
|
+
direct: boolean;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Own state condition: @own(hovered)
|
|
1415
|
+
*/
|
|
1416
|
+
interface OwnCondition extends BaseStateCondition {
|
|
1417
|
+
type: 'own';
|
|
1418
|
+
innerCondition: ConditionNode;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Starting style condition: @starting
|
|
1422
|
+
*/
|
|
1423
|
+
interface StartingCondition extends BaseStateCondition {
|
|
1424
|
+
type: 'starting';
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Supports query condition: @supports(display: grid), @supports($, :has(*))
|
|
1428
|
+
*/
|
|
1429
|
+
interface SupportsCondition extends BaseStateCondition {
|
|
1430
|
+
type: 'supports';
|
|
1431
|
+
subtype: 'feature' | 'selector';
|
|
1432
|
+
condition: string;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Union of all state condition types
|
|
1436
|
+
*/
|
|
1437
|
+
type StateCondition = ModifierCondition | PseudoCondition | MediaCondition | ContainerCondition | RootCondition | ParentCondition | OwnCondition | StartingCondition | SupportsCondition;
|
|
1438
|
+
/**
|
|
1439
|
+
* Compound node: combines conditions with AND/OR
|
|
1440
|
+
*/
|
|
1441
|
+
interface CompoundCondition {
|
|
1442
|
+
kind: 'compound';
|
|
1443
|
+
operator: 'AND' | 'OR';
|
|
1444
|
+
children: ConditionNode[];
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* True condition (matches everything)
|
|
1448
|
+
*/
|
|
1449
|
+
interface TrueCondition {
|
|
1450
|
+
kind: 'true';
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* False condition (matches nothing - skip this rule)
|
|
1454
|
+
*/
|
|
1455
|
+
interface FalseCondition {
|
|
1456
|
+
kind: 'false';
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Union of all condition node types
|
|
1460
|
+
*/
|
|
1461
|
+
type ConditionNode = StateCondition | CompoundCondition | TrueCondition | FalseCondition;
|
|
1462
|
+
//#endregion
|
|
1463
|
+
//#region src/states/index.d.ts
|
|
1464
|
+
/**
|
|
1465
|
+
* Parsed advanced state information
|
|
1466
|
+
*/
|
|
1467
|
+
interface ParsedAdvancedState {
|
|
1468
|
+
type: 'media' | 'container' | 'root' | 'parent' | 'own' | 'starting' | 'predefined' | 'modifier';
|
|
1469
|
+
condition: string;
|
|
1470
|
+
containerName?: string;
|
|
1471
|
+
raw: string;
|
|
1472
|
+
mediaType?: string;
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Context for state parsing operations
|
|
1476
|
+
*/
|
|
1477
|
+
interface StateParserContext {
|
|
1478
|
+
localPredefinedStates: Record<string, string>;
|
|
1479
|
+
globalPredefinedStates: Record<string, string>;
|
|
1480
|
+
isSubElement?: boolean;
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* At-rule context for CSS generation
|
|
1484
|
+
*/
|
|
1485
|
+
interface AtRuleContext {
|
|
1486
|
+
media?: string[];
|
|
1487
|
+
container?: {
|
|
1488
|
+
name?: string;
|
|
1489
|
+
condition: string;
|
|
1490
|
+
}[];
|
|
1491
|
+
startingStyle?: boolean;
|
|
1492
|
+
rootStates?: string[];
|
|
1493
|
+
negatedRootStates?: string[];
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Configure global predefined states
|
|
1497
|
+
*/
|
|
1498
|
+
declare function setGlobalPredefinedStates(states: Record<string, string>): void;
|
|
1499
|
+
/**
|
|
1500
|
+
* Get global predefined states
|
|
1501
|
+
*/
|
|
1502
|
+
declare function getGlobalPredefinedStates(): Record<string, string>;
|
|
1503
|
+
/**
|
|
1504
|
+
* Create a state parser context from styles
|
|
1505
|
+
*/
|
|
1506
|
+
declare function createStateParserContext(styles?: Styles, isSubElement?: boolean): StateParserContext;
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region src/pipeline/parseStateKey.d.ts
|
|
1509
|
+
interface ParseStateKeyOptions {
|
|
1510
|
+
context?: StateParserContext;
|
|
1511
|
+
isSubElement?: boolean;
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Parse a state key string into a ConditionNode
|
|
1515
|
+
*/
|
|
1516
|
+
declare function parseStateKey(stateKey: string, options?: ParseStateKeyOptions): ConditionNode;
|
|
1517
|
+
//#endregion
|
|
1518
|
+
//#region src/pipeline/index.d.ts
|
|
1519
|
+
/**
|
|
1520
|
+
* Matches the old StyleResult interface for backward compatibility
|
|
1521
|
+
*/
|
|
1522
|
+
interface StyleResult {
|
|
1523
|
+
selector: string;
|
|
1524
|
+
declarations: string;
|
|
1525
|
+
atRules?: string[];
|
|
1526
|
+
needsClassName?: boolean;
|
|
1527
|
+
rootPrefix?: string;
|
|
1528
|
+
/** When true, declarations are wrapped in @starting-style { ... } inside the selector rule */
|
|
1529
|
+
startingStyle?: boolean;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Matches the old RenderResult interface for backward compatibility
|
|
1533
|
+
*/
|
|
1534
|
+
interface RenderResult {
|
|
1535
|
+
rules: StyleResult[];
|
|
1536
|
+
className?: string;
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Check if a key is a CSS selector
|
|
1540
|
+
*/
|
|
1541
|
+
declare function isSelector(key: string): boolean;
|
|
1542
|
+
/**
|
|
1543
|
+
* Options for renderStyles when using direct selector mode.
|
|
1544
|
+
*/
|
|
1545
|
+
interface RenderStylesOptions {
|
|
1546
|
+
/**
|
|
1547
|
+
* Whether to double the class selector for increased specificity.
|
|
1548
|
+
* When true, `.myClass` becomes `.myClass.myClass` for higher specificity.
|
|
1549
|
+
*
|
|
1550
|
+
* @default false - User-provided selectors are not doubled.
|
|
1551
|
+
*
|
|
1552
|
+
* Note: This only applies when a classNameOrSelector is provided.
|
|
1553
|
+
* When renderStyles returns RenderResult with needsClassName=true,
|
|
1554
|
+
* the injector handles doubling automatically.
|
|
1555
|
+
*/
|
|
1556
|
+
doubleSelector?: boolean;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Render styles to CSS rules.
|
|
1560
|
+
*
|
|
1561
|
+
* When called without classNameOrSelector, returns RenderResult with needsClassName=true.
|
|
1562
|
+
* When called with a selector/className string, returns StyleResult[] for direct injection.
|
|
1563
|
+
*/
|
|
1564
|
+
declare function renderStyles(styles?: Styles, classNameOrSelector?: undefined, options?: undefined, pipelineCacheKey?: string): RenderResult;
|
|
1565
|
+
declare function renderStyles(styles: Styles | undefined, classNameOrSelector: string, options?: RenderStylesOptions): StyleResult[];
|
|
1566
|
+
//#endregion
|
|
1567
|
+
export { StyleParser as $, ParsedColor as A, StyleRule as At, StyleValueStateMap as B, SuffixForSelector as C, PropertyDefinition as Ct, CSSMap as D, RuleInfo as Dt, AnyStyleHandler as E, RootRegistry as Et, StyleHandlerProps as F, resetStyleBatch as Ft, parseColor as G, getGlobalParser as H, StyleHandlerResult as I, getNamedColorHex as J, parseStyle as K, StyleMap as L, ResolvedStyleValue as M, QueuedWrite as Mt, StyleHandler as N, flushStyles as Nt, CUSTOM_UNITS as O, SheetInfo as Ot, StyleHandlerDefinition as P, hasPendingStyleWrites as Pt, strToRgb as Q, StylePropValue as R, StylesWithoutSelectors as S, KeyframesSteps as St, TastyPresetNames as T, RawCSSResult as Tt, getGlobalPredefinedTokens as U, filterMods as V, normalizeColorTokenValue as W, hexToRgb as X, getRgbValuesFromRgbaString as Y, hslToRgbValues as Z, NotSelector as _, InjectResult as _t, ParseStateKeyOptions as a, CSSProperties as at, Styles as b, KeyframesInfo as bt, ParsedAdvancedState as c, DisposeFunction as ct, getGlobalPredefinedStates as d, FunctionDefinition as dt, ParserOptions as et, setGlobalPredefinedStates as f, FunctionParameter as ft, NoType as g, InjectOptions as gt, ConfigTokens as h, GlobalInjectResult as ht, renderStyles as i, UnitHandler as it, RawStyleHandler as j, StyleUsage as jt, DIRECTIONS as k, StyleInjectorConfig as kt, StateParserContext as l, FontFaceDescriptors as lt, ConfigTokenValue as m, GCOptions as mt, StyleResult as n, StyleDetails as nt, parseStateKey as o, CacheMetrics as ot, ConditionNode as p, GCConfig as pt, stringifyStyles as q, isSelector as r, StyleDetailsPart as rt, AtRuleContext as s, CounterStyleDescriptors as st, RenderResult as t, ProcessedStyle as tt, createStateParserContext as u, FontFaceInput as ut, RecipeStyles as v, InjectionMode as vt, TastyNamedColors as w, PropertyOptions as wt, StylesInterface as x, KeyframesResult as xt, Selector as y, KeyframesCacheEntry as yt, StyleValue as z };
|
|
1568
|
+
//# sourceMappingURL=index-BcsaHo8x.d.ts.map
|