@tenphi/tasty 0.0.0-snapshot.08a6610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +666 -0
- package/dist/_virtual/_rolldown/runtime.js +8 -0
- package/dist/chunks/cacheKey.js +70 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +259 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/renderChunk.js +61 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/config.d.ts +311 -0
- package/dist/config.js +458 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +32 -0
- package/dist/core/index.js +26 -0
- package/dist/debug.d.ts +204 -0
- package/dist/debug.js +733 -0
- package/dist/debug.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +30 -0
- package/dist/hooks/useGlobalStyles.js +83 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +56 -0
- package/dist/hooks/useKeyframes.js +69 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +79 -0
- package/dist/hooks/useProperty.js +114 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +53 -0
- package/dist/hooks/useRawCSS.js +40 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +45 -0
- package/dist/hooks/useStyles.js +248 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +33 -0
- package/dist/injector/index.d.ts +165 -0
- package/dist/injector/index.js +162 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +148 -0
- package/dist/injector/injector.js +430 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/sheet-manager.d.ts +136 -0
- package/dist/injector/sheet-manager.js +729 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/types.d.ts +144 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/const.js +33 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +116 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/types.d.ts +51 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/pipeline/conditions.d.ts +134 -0
- package/dist/pipeline/conditions.js +406 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/exclusive.js +231 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.js +660 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/materialize.js +856 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +15 -0
- package/dist/pipeline/parseStateKey.js +451 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/simplify.js +516 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +371 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +76 -0
- package/dist/properties/index.js +236 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +91 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/ssr/astro.d.ts +29 -0
- package/dist/ssr/astro.js +65 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +35 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +40 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +85 -0
- package/dist/ssr/collector.js +183 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.d.ts +8 -0
- package/dist/ssr/context.js +14 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +70 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +48 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +70 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +22 -0
- package/dist/ssr/hydrate.js +50 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.js +12 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +45 -0
- package/dist/ssr/next.js +71 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +12 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.d.ts +49 -0
- package/dist/states/index.js +416 -0
- package/dist/states/index.js.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +5 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +31 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/align.d.ts +15 -0
- package/dist/styles/align.js +14 -0
- package/dist/styles/align.js.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +114 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +23 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/createStyle.js +77 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/dimension.js +97 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/display.d.ts +37 -0
- package/dist/styles/display.js +67 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +58 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fill.d.ts +42 -0
- package/dist/styles/fill.js +52 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +37 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +20 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +9 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/inset.d.ts +52 -0
- package/dist/styles/inset.js +150 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/justify.d.ts +15 -0
- package/dist/styles/justify.js +14 -0
- package/dist/styles/justify.js.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +98 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +24 -0
- package/dist/styles/margin.js +104 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +65 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/padding.d.ts +24 -0
- package/dist/styles/padding.js +104 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/predefined.d.ts +71 -0
- package/dist/styles/predefined.js +238 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/preset.d.ts +47 -0
- package/dist/styles/preset.js +126 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/radius.d.ts +14 -0
- package/dist/styles/radius.js +51 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +25 -0
- package/dist/styles/scrollbar.js +48 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +24 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +158 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/types.d.ts +508 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +20 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/tasty.d.ts +981 -0
- package/dist/tasty.js +206 -0
- package/dist/tasty.js.map +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/cache-wrapper.js +26 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +9 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/css-types.d.ts +7 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/hsl-to-rgb.js +38 -0
- package/dist/utils/hsl-to-rgb.js.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-valid-element-type.js +15 -0
- package/dist/utils/is-valid-element-type.js.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +146 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/mod-attrs.d.ts +8 -0
- package/dist/utils/mod-attrs.js +21 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/okhsl-to-rgb.js +296 -0
- package/dist/utils/okhsl-to-rgb.js.map +1 -0
- package/dist/utils/process-tokens.d.ts +31 -0
- package/dist/utils/process-tokens.js +171 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +147 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/styles.d.ts +177 -0
- package/dist/utils/styles.js +730 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/typography.d.ts +47 -0
- package/dist/utils/typography.js +43 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.ts +147 -0
- package/dist/zero/babel.js +331 -0
- package/dist/zero/babel.js.map +1 -0
- package/dist/zero/css-writer.d.ts +45 -0
- package/dist/zero/css-writer.js +74 -0
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/zero/extractor.d.ts +24 -0
- package/dist/zero/extractor.js +215 -0
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/index.js +4 -0
- package/dist/zero/next.d.ts +74 -0
- package/dist/zero/next.js +129 -0
- package/dist/zero/next.js.map +1 -0
- package/docs/adoption.md +286 -0
- package/docs/comparison.md +413 -0
- package/docs/configuration.md +242 -0
- package/docs/debug.md +505 -0
- package/docs/design-system.md +401 -0
- package/docs/dsl.md +540 -0
- package/docs/getting-started.md +201 -0
- package/docs/injector.md +528 -0
- package/docs/methodology.md +501 -0
- package/docs/runtime.md +291 -0
- package/docs/ssr.md +382 -0
- package/docs/styles.md +574 -0
- package/docs/tasty-static.md +421 -0
- package/package.json +209 -0
- package/tasty.config.ts +14 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { KeyframesSteps, PropertyDefinition } from "./injector/types.js";
|
|
2
|
+
import { StyleDetails, UnitHandler } from "./parser/types.js";
|
|
3
|
+
import { StyleHandlerDefinition } from "./utils/styles.js";
|
|
4
|
+
import { ConfigTokens, RecipeStyles } from "./styles/types.js";
|
|
5
|
+
import { StyleInjector } from "./injector/injector.js";
|
|
6
|
+
import { TastyPlugin } from "./plugins/types.js";
|
|
7
|
+
|
|
8
|
+
//#region src/config.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for the Tasty style system
|
|
11
|
+
*/
|
|
12
|
+
interface TastyConfig {
|
|
13
|
+
/** CSP nonce for style elements */
|
|
14
|
+
nonce?: string;
|
|
15
|
+
/** Maximum rules per stylesheet (default: 8192) */
|
|
16
|
+
maxRulesPerSheet?: number;
|
|
17
|
+
/** Threshold for bulk cleanup of unused styles (default: 500) */
|
|
18
|
+
unusedStylesThreshold?: number;
|
|
19
|
+
/** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
|
|
20
|
+
bulkCleanupDelay?: number;
|
|
21
|
+
/** Use requestIdleCallback for cleanup when available (default: true) */
|
|
22
|
+
idleCleanup?: boolean;
|
|
23
|
+
/** Force text injection mode, auto-detected in test environments (default: auto) */
|
|
24
|
+
forceTextInjection?: boolean;
|
|
25
|
+
/** Enable development mode features: performance metrics and debug info (default: auto) */
|
|
26
|
+
devMode?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Ratio of unused styles to delete per bulk cleanup run (0..1).
|
|
29
|
+
* Defaults to 0.5 (oldest half) to reduce risk of removing styles
|
|
30
|
+
* that may be restored shortly after being marked unused.
|
|
31
|
+
*/
|
|
32
|
+
bulkCleanupBatchRatio?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Minimum age (in ms) a style must remain unused before eligible for deletion.
|
|
35
|
+
* Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
|
|
36
|
+
*/
|
|
37
|
+
unusedStylesMinAgeMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Global predefined states for advanced state mapping.
|
|
40
|
+
* These are state aliases that can be used in any component.
|
|
41
|
+
* Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
|
|
42
|
+
*/
|
|
43
|
+
states?: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Parser LRU cache size (default: 1000).
|
|
46
|
+
* Larger values improve performance for apps with many unique style values.
|
|
47
|
+
*/
|
|
48
|
+
parserCacheSize?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Custom units for the style parser (merged with built-in units).
|
|
51
|
+
* Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
|
|
52
|
+
* @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
|
|
53
|
+
*/
|
|
54
|
+
units?: Record<string, string | UnitHandler>;
|
|
55
|
+
/**
|
|
56
|
+
* Custom functions for the style parser (merged with existing).
|
|
57
|
+
* Functions process parsed style groups and return CSS values.
|
|
58
|
+
* @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
|
|
59
|
+
*/
|
|
60
|
+
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
61
|
+
/**
|
|
62
|
+
* Automatically infer and register CSS @property declarations
|
|
63
|
+
* from custom property values found in styles, keyframes, and global config.
|
|
64
|
+
* Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
|
|
65
|
+
* When false, only explicitly declared @properties are registered.
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
autoPropertyTypes?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Plugins that extend tasty with custom functions, units, or states.
|
|
71
|
+
* Plugins are processed in order, with later plugins overriding earlier ones.
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { okhslPlugin } from '@tenphi/tasty';
|
|
75
|
+
*
|
|
76
|
+
* configure({
|
|
77
|
+
* plugins: [okhslPlugin()],
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
plugins?: TastyPlugin[];
|
|
82
|
+
/**
|
|
83
|
+
* Global keyframes definitions that can be referenced by animation names in styles.
|
|
84
|
+
* Keys are animation names, values are keyframes step definitions.
|
|
85
|
+
* Keyframes are only injected when actually used in styles.
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* configure({
|
|
89
|
+
* keyframes: {
|
|
90
|
+
* fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
|
|
91
|
+
* pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
|
|
92
|
+
* },
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
keyframes?: Record<string, KeyframesSteps>;
|
|
97
|
+
/**
|
|
98
|
+
* Global CSS @property definitions for custom properties.
|
|
99
|
+
* Keys use tasty token syntax ($name for properties, #name for colors).
|
|
100
|
+
* Properties are only injected when the component using them is rendered.
|
|
101
|
+
*
|
|
102
|
+
* For color tokens (#name), `syntax: '<color>'` is auto-set and
|
|
103
|
+
* `initialValue` defaults to `'transparent'` if not specified.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* configure({
|
|
108
|
+
* properties: {
|
|
109
|
+
* '$rotation': { syntax: '<angle>', initialValue: '0deg' },
|
|
110
|
+
* '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
|
|
111
|
+
* '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
|
|
112
|
+
* },
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Now use in styles - properties are registered when component renders:
|
|
116
|
+
* const Spinner = tasty({
|
|
117
|
+
* styles: {
|
|
118
|
+
* transform: 'rotate($rotation)',
|
|
119
|
+
* transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
|
|
120
|
+
* },
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
properties?: Record<string, PropertyDefinition>;
|
|
125
|
+
/**
|
|
126
|
+
* Custom style handlers that transform style properties into CSS declarations.
|
|
127
|
+
* Handlers replace built-in handlers for the same style name.
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { styleHandlers } from '@tenphi/tasty';
|
|
131
|
+
*
|
|
132
|
+
* configure({
|
|
133
|
+
* handlers: {
|
|
134
|
+
* // Override fill with custom behavior
|
|
135
|
+
* fill: ({ fill }) => {
|
|
136
|
+
* if (fill?.startsWith('gradient:')) {
|
|
137
|
+
* return { background: fill.slice(9) };
|
|
138
|
+
* }
|
|
139
|
+
* return styleHandlers.fill({ fill });
|
|
140
|
+
* },
|
|
141
|
+
* // Add new custom style
|
|
142
|
+
* elevation: ({ elevation }) => {
|
|
143
|
+
* const level = parseInt(elevation) || 1;
|
|
144
|
+
* return {
|
|
145
|
+
* 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
|
|
146
|
+
* 'z-index': String(level * 100),
|
|
147
|
+
* };
|
|
148
|
+
* },
|
|
149
|
+
* },
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
handlers?: Record<string, StyleHandlerDefinition>;
|
|
154
|
+
/**
|
|
155
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
156
|
+
* Values are parsed through the Tasty DSL. Supports state maps
|
|
157
|
+
* for responsive/theme-aware tokens.
|
|
158
|
+
*
|
|
159
|
+
* - `$name` keys become `--name` CSS custom properties
|
|
160
|
+
* - `#name` keys become `--name-color` and `--name-color-rgb` properties
|
|
161
|
+
*
|
|
162
|
+
* Tokens are injected once when the first style is rendered.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* configure({
|
|
167
|
+
* tokens: {
|
|
168
|
+
* '$gap': '4px',
|
|
169
|
+
* '#primary': {
|
|
170
|
+
* '': '#purple',
|
|
171
|
+
* '@dark': '#light-purple',
|
|
172
|
+
* },
|
|
173
|
+
* },
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
tokens?: ConfigTokens;
|
|
178
|
+
/**
|
|
179
|
+
* Predefined tokens that are replaced during style parsing (parse-time substitution).
|
|
180
|
+
* Use `$name` for custom properties and `#name` for color tokens.
|
|
181
|
+
* Values are substituted inline before CSS generation, unlike `tokens` which
|
|
182
|
+
* inject CSS custom properties on `:root`.
|
|
183
|
+
*
|
|
184
|
+
* For color tokens (#name), boolean `true` is converted to `transparent`.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* configure({
|
|
189
|
+
* replaceTokens: {
|
|
190
|
+
* $spacing: '2x',
|
|
191
|
+
* '#accent': '#purple',
|
|
192
|
+
* '#overlay': true, // → transparent
|
|
193
|
+
* },
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* // Now use in styles - tokens are replaced at parse time:
|
|
197
|
+
* const Card = tasty({
|
|
198
|
+
* styles: {
|
|
199
|
+
* padding: '$spacing', // → calc(2 * var(--gap))
|
|
200
|
+
* fill: '#accent', // → var(--purple-color)
|
|
201
|
+
* },
|
|
202
|
+
* });
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
|
|
206
|
+
/**
|
|
207
|
+
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
208
|
+
* Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
|
|
209
|
+
* tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
|
|
210
|
+
*
|
|
211
|
+
* Components reference recipes via: `recipe: 'name1 name2'` in their styles.
|
|
212
|
+
* Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
|
|
213
|
+
* Use `none` to skip base recipes: `recipe: 'none / post1'`.
|
|
214
|
+
* Resolution order: `base_recipes → component styles → post_recipes`.
|
|
215
|
+
*
|
|
216
|
+
* Recipes cannot reference other recipes.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* configure({
|
|
221
|
+
* recipes: {
|
|
222
|
+
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
223
|
+
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
224
|
+
* },
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* // Usage in styles:
|
|
228
|
+
* const Card = tasty({
|
|
229
|
+
* styles: {
|
|
230
|
+
* recipe: 'card elevated',
|
|
231
|
+
* color: '#text', // Overrides recipe values
|
|
232
|
+
* },
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
recipes?: Record<string, RecipeStyles>;
|
|
237
|
+
}
|
|
238
|
+
declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
|
|
239
|
+
declare global {
|
|
240
|
+
interface Window {
|
|
241
|
+
[GLOBAL_INJECTOR_KEY]?: StyleInjector;
|
|
242
|
+
}
|
|
243
|
+
var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Detect if we're running in a test environment
|
|
247
|
+
*/
|
|
248
|
+
declare function isTestEnvironment(): boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Check if styles have been generated (configuration is locked)
|
|
251
|
+
*/
|
|
252
|
+
declare function hasStylesGenerated(): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Check if any global keyframes are configured.
|
|
255
|
+
* Fast path: returns false if no keyframes were ever set.
|
|
256
|
+
*/
|
|
257
|
+
declare function hasGlobalKeyframes(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Get global keyframes configuration.
|
|
260
|
+
* Returns null if no keyframes configured (fast path for zero-overhead).
|
|
261
|
+
*/
|
|
262
|
+
declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
|
|
263
|
+
/**
|
|
264
|
+
* Check if any global recipes are configured.
|
|
265
|
+
* Fast path: returns false if no recipes were ever set.
|
|
266
|
+
*/
|
|
267
|
+
declare function hasGlobalRecipes(): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Get global recipes configuration.
|
|
270
|
+
* Returns null if no recipes configured (fast path for zero-overhead).
|
|
271
|
+
*/
|
|
272
|
+
declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
|
|
273
|
+
/**
|
|
274
|
+
* Check if configuration is locked (styles have been generated)
|
|
275
|
+
*/
|
|
276
|
+
declare function isConfigLocked(): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Configure the Tasty style system.
|
|
279
|
+
*
|
|
280
|
+
* Must be called BEFORE any styles are generated (before first render that uses tasty).
|
|
281
|
+
* After styles are generated, configuration is locked and calls to configure() will
|
|
282
|
+
* emit a warning and be ignored.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* import { configure } from '@tenphi/tasty';
|
|
287
|
+
*
|
|
288
|
+
* // Configure before app renders
|
|
289
|
+
* configure({
|
|
290
|
+
* nonce: 'abc123',
|
|
291
|
+
* states: {
|
|
292
|
+
* '@mobile': '@media(w < 768px)',
|
|
293
|
+
* '@dark': '@root(theme=dark)',
|
|
294
|
+
* },
|
|
295
|
+
* });
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
declare function configure(config?: Partial<TastyConfig>): void;
|
|
299
|
+
/**
|
|
300
|
+
* Get the current configuration.
|
|
301
|
+
* If not configured, returns default configuration.
|
|
302
|
+
*/
|
|
303
|
+
declare function getConfig(): TastyConfig;
|
|
304
|
+
/**
|
|
305
|
+
* Reset configuration (for testing only).
|
|
306
|
+
* Clears the global injector and allows reconfiguration.
|
|
307
|
+
*/
|
|
308
|
+
declare function resetConfig(): void;
|
|
309
|
+
//#endregion
|
|
310
|
+
export { TastyConfig, configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig };
|
|
311
|
+
//# sourceMappingURL=config.d.ts.map
|