@tokenami/config 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +239 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +32 -0
- package/dist/index.mjs +30 -0
- package/package.json +2 -2
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
declare const defaultConfig: {
|
|
4
|
+
readonly include: readonly never[];
|
|
5
|
+
readonly grid: string;
|
|
6
|
+
readonly responsive: {};
|
|
7
|
+
readonly theme: {};
|
|
8
|
+
readonly aliases: {};
|
|
9
|
+
readonly selectors: {
|
|
10
|
+
readonly active: string;
|
|
11
|
+
readonly after: string;
|
|
12
|
+
readonly before: string;
|
|
13
|
+
readonly disabled: string;
|
|
14
|
+
readonly even: string;
|
|
15
|
+
readonly 'first-child': string;
|
|
16
|
+
readonly focus: string;
|
|
17
|
+
readonly 'focus-visible': string;
|
|
18
|
+
readonly 'focus-within': string;
|
|
19
|
+
readonly hover: string;
|
|
20
|
+
readonly 'last-child': string;
|
|
21
|
+
readonly odd: string;
|
|
22
|
+
readonly placeholder: string;
|
|
23
|
+
};
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly 'accent-color': readonly "color"[];
|
|
26
|
+
readonly animation: readonly "anim"[];
|
|
27
|
+
readonly 'animation-timing-function': readonly "ease"[];
|
|
28
|
+
readonly background: readonly ("color" | "surface")[];
|
|
29
|
+
readonly 'background-color': readonly "color"[];
|
|
30
|
+
readonly 'background-image': readonly "surface"[];
|
|
31
|
+
readonly 'background-position': readonly "grid"[];
|
|
32
|
+
readonly 'background-position-x': readonly "grid"[];
|
|
33
|
+
readonly 'background-position-y': readonly "grid"[];
|
|
34
|
+
readonly 'block-size': readonly ("grid" | "size")[];
|
|
35
|
+
readonly border: readonly "border"[];
|
|
36
|
+
readonly 'border-block': readonly "border"[];
|
|
37
|
+
readonly 'border-block-color': readonly "color"[];
|
|
38
|
+
readonly 'border-block-end': readonly "border"[];
|
|
39
|
+
readonly 'border-block-end-color': readonly "color"[];
|
|
40
|
+
readonly 'border-block-end-style': readonly "line-style"[];
|
|
41
|
+
readonly 'border-block-end-width': readonly "grid"[];
|
|
42
|
+
readonly 'border-block-start': readonly "border"[];
|
|
43
|
+
readonly 'border-block-start-color': readonly "color"[];
|
|
44
|
+
readonly 'border-block-start-style': readonly "line-style"[];
|
|
45
|
+
readonly 'border-block-start-width': readonly "grid"[];
|
|
46
|
+
readonly 'border-block-style': readonly "line-style"[];
|
|
47
|
+
readonly 'border-block-width': readonly "grid"[];
|
|
48
|
+
readonly 'border-bottom': readonly "border"[];
|
|
49
|
+
readonly 'border-bottom-color': readonly "color"[];
|
|
50
|
+
readonly 'border-bottom-left-radius': readonly "radii"[];
|
|
51
|
+
readonly 'border-bottom-right-radius': readonly "radii"[];
|
|
52
|
+
readonly 'border-bottom-style': readonly "line-style"[];
|
|
53
|
+
readonly 'border-bottom-width': readonly "grid"[];
|
|
54
|
+
readonly 'border-color': readonly "color"[];
|
|
55
|
+
readonly 'border-end-end-radius': readonly "radii"[];
|
|
56
|
+
readonly 'border-end-start-radius': readonly "radii"[];
|
|
57
|
+
readonly 'border-inline': readonly "border"[];
|
|
58
|
+
readonly 'border-inline-color': readonly "color"[];
|
|
59
|
+
readonly 'border-inline-end': readonly "border"[];
|
|
60
|
+
readonly 'border-inline-end-color': readonly "color"[];
|
|
61
|
+
readonly 'border-inline-end-style': readonly "line-style"[];
|
|
62
|
+
readonly 'border-inline-end-width': readonly "grid"[];
|
|
63
|
+
readonly 'border-inline-start': readonly "border"[];
|
|
64
|
+
readonly 'border-inline-start-color': readonly "color"[];
|
|
65
|
+
readonly 'border-inline-start-style': readonly "line-style"[];
|
|
66
|
+
readonly 'border-inline-start-width': readonly "grid"[];
|
|
67
|
+
readonly 'border-inline-style': readonly "line-style"[];
|
|
68
|
+
readonly 'border-inline-width': readonly "grid"[];
|
|
69
|
+
readonly 'border-left': readonly "border"[];
|
|
70
|
+
readonly 'border-left-color': readonly "color"[];
|
|
71
|
+
readonly 'border-left-style': readonly "line-style"[];
|
|
72
|
+
readonly 'border-left-width': readonly "grid"[];
|
|
73
|
+
readonly 'border-radius': readonly "radii"[];
|
|
74
|
+
readonly 'border-right': readonly "border"[];
|
|
75
|
+
readonly 'border-right-color': readonly "color"[];
|
|
76
|
+
readonly 'border-right-style': readonly "line-style"[];
|
|
77
|
+
readonly 'border-right-width': readonly "grid"[];
|
|
78
|
+
readonly 'border-start-end-radius': readonly "radii"[];
|
|
79
|
+
readonly 'border-start-start-radius': readonly "radii"[];
|
|
80
|
+
readonly 'border-style': readonly "line-style"[];
|
|
81
|
+
readonly 'border-top': readonly "border"[];
|
|
82
|
+
readonly 'border-top-color': readonly "color"[];
|
|
83
|
+
readonly 'border-top-left-radius': readonly "radii"[];
|
|
84
|
+
readonly 'border-top-right-radius': readonly "radii"[];
|
|
85
|
+
readonly 'border-top-style': readonly "line-style"[];
|
|
86
|
+
readonly 'border-top-width': readonly "grid"[];
|
|
87
|
+
readonly 'border-width': readonly "grid"[];
|
|
88
|
+
readonly bottom: readonly "grid"[];
|
|
89
|
+
readonly 'box-shadow': readonly "shadow"[];
|
|
90
|
+
readonly 'caret-color': readonly "color"[];
|
|
91
|
+
readonly color: readonly "color"[];
|
|
92
|
+
readonly 'column-gap': readonly "grid"[];
|
|
93
|
+
readonly 'column-rule-color': readonly "color"[];
|
|
94
|
+
readonly 'column-rule-width': readonly "grid"[];
|
|
95
|
+
readonly 'column-width': readonly ("grid" | "size")[];
|
|
96
|
+
readonly 'flex-basis': readonly ("grid" | "size")[];
|
|
97
|
+
readonly 'font-family': readonly "font"[];
|
|
98
|
+
readonly 'font-size': readonly "font-size"[];
|
|
99
|
+
readonly 'font-weight': readonly "weight"[];
|
|
100
|
+
readonly gap: readonly "grid"[];
|
|
101
|
+
readonly height: readonly ("grid" | "size")[];
|
|
102
|
+
readonly 'inline-size': readonly ("grid" | "size")[];
|
|
103
|
+
readonly inset: readonly "grid"[];
|
|
104
|
+
readonly 'inset-block': readonly "grid"[];
|
|
105
|
+
readonly 'inset-block-end': readonly "grid"[];
|
|
106
|
+
readonly 'inset-block-start': readonly "grid"[];
|
|
107
|
+
readonly 'inset-inline': readonly "grid"[];
|
|
108
|
+
readonly 'inset-inline-end': readonly "grid"[];
|
|
109
|
+
readonly 'inset-inline-start': readonly "grid"[];
|
|
110
|
+
readonly left: readonly "grid"[];
|
|
111
|
+
readonly 'letter-spacing': readonly "tracking"[];
|
|
112
|
+
readonly 'line-height': readonly "leading"[];
|
|
113
|
+
readonly margin: readonly "grid"[];
|
|
114
|
+
readonly 'margin-block': readonly "grid"[];
|
|
115
|
+
readonly 'margin-block-end': readonly "grid"[];
|
|
116
|
+
readonly 'margin-block-start': readonly "grid"[];
|
|
117
|
+
readonly 'margin-bottom': readonly "grid"[];
|
|
118
|
+
readonly 'margin-inline': readonly "grid"[];
|
|
119
|
+
readonly 'margin-inline-end': readonly "grid"[];
|
|
120
|
+
readonly 'margin-inline-start': readonly "grid"[];
|
|
121
|
+
readonly 'margin-left': readonly "grid"[];
|
|
122
|
+
readonly 'margin-right': readonly "grid"[];
|
|
123
|
+
readonly 'margin-top': readonly "grid"[];
|
|
124
|
+
readonly 'max-block-size': readonly ("grid" | "size")[];
|
|
125
|
+
readonly 'max-height': readonly ("grid" | "size")[];
|
|
126
|
+
readonly 'max-inline-size': readonly ("grid" | "size")[];
|
|
127
|
+
readonly 'max-width': readonly ("grid" | "size")[];
|
|
128
|
+
readonly 'min-block-size': readonly ("grid" | "size")[];
|
|
129
|
+
readonly 'min-height': readonly ("grid" | "size")[];
|
|
130
|
+
readonly 'min-inline-size': readonly ("grid" | "size")[];
|
|
131
|
+
readonly 'min-width': readonly ("grid" | "size")[];
|
|
132
|
+
readonly opacity: readonly "alpha"[];
|
|
133
|
+
readonly 'outline-color': readonly "color"[];
|
|
134
|
+
readonly padding: readonly "grid"[];
|
|
135
|
+
readonly 'padding-block': readonly "grid"[];
|
|
136
|
+
readonly 'padding-block-end': readonly "grid"[];
|
|
137
|
+
readonly 'padding-block-start': readonly "grid"[];
|
|
138
|
+
readonly 'padding-bottom': readonly "grid"[];
|
|
139
|
+
readonly 'padding-inline': readonly "grid"[];
|
|
140
|
+
readonly 'padding-inline-end': readonly "grid"[];
|
|
141
|
+
readonly 'padding-inline-start': readonly "grid"[];
|
|
142
|
+
readonly 'padding-left': readonly "grid"[];
|
|
143
|
+
readonly 'padding-right': readonly "grid"[];
|
|
144
|
+
readonly 'padding-top': readonly "grid"[];
|
|
145
|
+
readonly right: readonly "grid"[];
|
|
146
|
+
readonly 'row-gap': readonly "grid"[];
|
|
147
|
+
readonly 'scroll-margin': readonly "grid"[];
|
|
148
|
+
readonly 'scroll-margin-bottom': readonly "grid"[];
|
|
149
|
+
readonly 'scroll-margin-left': readonly "grid"[];
|
|
150
|
+
readonly 'scroll-margin-right': readonly "grid"[];
|
|
151
|
+
readonly 'scroll-margin-top': readonly "grid"[];
|
|
152
|
+
readonly 'scroll-padding': readonly "grid"[];
|
|
153
|
+
readonly 'scroll-padding-bottom': readonly "grid"[];
|
|
154
|
+
readonly 'scroll-padding-left': readonly "grid"[];
|
|
155
|
+
readonly 'scroll-padding-right': readonly "grid"[];
|
|
156
|
+
readonly 'scroll-padding-top': readonly "grid"[];
|
|
157
|
+
readonly 'text-decoration-color': readonly "color"[];
|
|
158
|
+
readonly 'text-shadow': readonly "shadow"[];
|
|
159
|
+
readonly top: readonly "grid"[];
|
|
160
|
+
readonly transition: readonly "transition"[];
|
|
161
|
+
readonly 'transition-timing-function': readonly "ease"[];
|
|
162
|
+
readonly width: readonly ("grid" | "size")[];
|
|
163
|
+
readonly 'z-index': readonly "z"[];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
type DefaultConfig = typeof defaultConfig;
|
|
167
|
+
|
|
168
|
+
declare const properties: readonly ["-webkit-line-clamp", "accent-color", "align-tracks", "all", "animation", "animation-composition", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timeline", "animation-timing-function", "appearance", "aspect-ratio", "backdrop-filter", "backface-visibility", "background", "background-attachment", "background-blend-mode", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-position-x", "background-position-y", "background-repeat", "background-size", "block-overflow", "block-size", "border", "border-style", "border-color", "border-width", "border-top", "border-top-color", "border-top-style", "border-top-width", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-bottom", "border-bottom-color", "border-bottom-style", "border-bottom-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-block", "border-block-width", "border-block-style", "border-block-color", "border-block-start", "border-block-end", "border-block-start-color", "border-block-start-style", "border-block-start-width", "border-block-end-color", "border-block-end-style", "border-block-end-width", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-inline", "border-inline-color", "border-inline-style", "border-inline-width", "border-inline-start", "border-inline-end", "border-inline-start-color", "border-inline-start-style", "border-inline-start-width", "border-inline-end-color", "border-inline-end-style", "border-inline-end-width", "border-radius", "border-top-left-radius", "border-top-right-radius", "border-bottom-left-radius", "border-bottom-right-radius", "border-start-end-radius", "border-start-start-radius", "border-end-end-radius", "border-end-start-radius", "border-collapse", "border-spacing", "box-decoration-break", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "caret", "caret-color", "caret-shape", "clear", "clip", "clip-path", "color", "color-scheme", "column-fill", "column-span", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "columns", "column-count", "column-width", "contain", "contain-intrinsic-block-size", "contain-intrinsic-height", "contain-intrinsic-inline-size", "contain-intrinsic-size", "contain-intrinsic-width", "container", "container-name", "container-type", "content", "content-visibility", "counter-increment", "counter-reset", "counter-set", "cursor", "direction", "display", "empty-cells", "filter", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", "font", "font-family", "font-feature-settings", "font-kerning", "font-language-override", "font-optical-sizing", "font-palette", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-synthesis", "font-variant", "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", "font-variant-emoji", "font-variant-ligatures", "font-variant-numeric", "font-variant-position", "font-variation-settings", "font-weight", "forced-color-adjust", "gap", "row-gap", "column-gap", "grid", "grid-area", "grid-auto-rows", "grid-auto-columns", "grid-auto-flow", "grid-column", "grid-column-end", "grid-column-start", "grid-row", "grid-row-end", "grid-row-start", "grid-template", "grid-template-rows", "grid-template-columns", "grid-template-areas", "hanging-punctuation", "height", "hyphenate-character", "hyphenate-limit-chars", "hyphens", "image-orientation", "image-rendering", "image-resolution", "initial-letter", "inline-size", "input-security", "inset", "top", "right", "bottom", "left", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", "inset-inline-end", "inset-inline-start", "isolation", "justify-tracks", "letter-spacing", "line-break", "line-clamp", "line-height", "line-height-step", "list-style", "list-style-image", "list-style-position", "list-style-type", "margin", "margin-top", "margin-right", "margin-bottom", "margin-left", "margin-block", "margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", "margin-inline-start", "margin-trim", "mask", "mask-border", "mask-border-mode", "mask-border-outset", "mask-border-repeat", "mask-border-slice", "mask-border-source", "mask-border-width", "mask-clip", "mask-composite", "mask-image", "mask-mode", "mask-origin", "mask-position", "mask-repeat", "mask-size", "mask-type", "math-depth", "math-shift", "math-style", "max-block-size", "max-height", "max-inline-size", "max-lines", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "mix-blend-mode", "object-fit", "object-position", "offset", "offset-anchor", "offset-distance", "offset-path", "offset-position", "offset-rotate", "opacity", "order", "orphans", "outline", "outline-color", "outline-offset", "outline-style", "outline-width", "overflow", "overflow-anchor", "overflow-block", "overflow-clip-margin", "overflow-inline", "overflow-wrap", "overflow-x", "overflow-y", "overscroll-behavior", "overscroll-behavior-block", "overscroll-behavior-inline", "overscroll-behavior-x", "overscroll-behavior-y", "padding", "padding-top", "padding-right", "padding-bottom", "padding-left", "padding-block", "padding-block-end", "padding-block-start", "padding-inline", "padding-inline-end", "padding-inline-start", "page", "page-break-after", "page-break-before", "page-break-inside", "paint-order", "perspective", "perspective-origin", "place-content", "align-content", "justify-content", "place-items", "align-items", "justify-items", "place-self", "align-self", "justify-self", "pointer-events", "position", "print-color-adjust", "quotes", "resize", "rotate", "ruby-align", "ruby-merge", "ruby-position", "scale", "scroll-behavior", "scroll-margin", "scroll-margin-top", "scroll-margin-right", "scroll-margin-bottom", "scroll-margin-left", "scroll-margin-block", "scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-inline", "scroll-margin-inline-end", "scroll-margin-inline-start", "scroll-padding", "scroll-padding-top", "scroll-padding-right", "scroll-padding-bottom", "scroll-padding-left", "scroll-padding-block", "scroll-padding-block-end", "scroll-padding-block-start", "scroll-padding-inline", "scroll-padding-inline-end", "scroll-padding-inline-start", "scroll-snap-align", "scroll-snap-stop", "scroll-snap-type", "scroll-timeline", "scroll-timeline-axis", "scroll-timeline-name", "scrollbar-color", "scrollbar-gutter", "scrollbar-width", "shape-image-threshold", "shape-margin", "shape-outside", "tab-size", "table-layout", "text-align", "text-align-last", "text-combine-upright", "text-decoration", "text-decoration-color", "text-decoration-line", "text-decoration-style", "text-decoration-thickness", "text-decoration-skip-ink", "text-emphasis", "text-emphasis-color", "text-emphasis-position", "text-emphasis-style", "text-indent", "text-justify", "text-orientation", "text-overflow", "text-rendering", "text-shadow", "text-size-adjust", "text-transform", "text-underline-offset", "text-underline-position", "touch-action", "transform", "transform-box", "transform-origin", "transform-style", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "unicode-bidi", "user-select", "vertical-align", "view-transition-name", "visibility", "white-space", "widows", "width", "will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index", "zoom"];
|
|
169
|
+
type CSSProperty = (typeof properties)[number];
|
|
170
|
+
|
|
171
|
+
declare function tokenProperty(name: string): TokenProperty;
|
|
172
|
+
declare function variantProperty(variant: string, name: string): TokenProperty;
|
|
173
|
+
declare function tokenValue<TK extends string, N extends string>(themeKey: TK, name: N): TokenValue<TK, N>;
|
|
174
|
+
declare function arbitraryValue(value: string): ArbitraryValue;
|
|
175
|
+
declare const gridValueSchema: v.NumberSchema<number>;
|
|
176
|
+
type GridValue = v.Output<typeof gridValueSchema>;
|
|
177
|
+
declare const GridValue: {
|
|
178
|
+
safeParse: (input: unknown) => v.SafeParseResult<v.NumberSchema<number>>;
|
|
179
|
+
};
|
|
180
|
+
type TokenProperty<P extends string = string> = `--${P}`;
|
|
181
|
+
declare const TokenProperty: {
|
|
182
|
+
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`--${string}`>>;
|
|
183
|
+
};
|
|
184
|
+
type VariantProperty<P extends string = string, V extends string = string> = `--${V}_${P}`;
|
|
185
|
+
declare const VariantProperty: {
|
|
186
|
+
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`--${string}_${string}`>>;
|
|
187
|
+
};
|
|
188
|
+
type TokenValue<TK extends string = string, V extends string = string> = `var(--${TK}_${V})`;
|
|
189
|
+
declare const TokenValue: {
|
|
190
|
+
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`var(--${string}_${string})`>>;
|
|
191
|
+
};
|
|
192
|
+
type ArbitraryValue = `var(---,${string})`;
|
|
193
|
+
declare const ArbitraryValue: v.StringSchema<string>;
|
|
194
|
+
type ThemeKey = 'alpha' | 'border' | 'color' | 'ease' | 'font-size' | 'leading' | 'line-style' | 'radii' | 'size' | 'shadow' | 'tracking' | 'transition' | 'weight' | 'z' | (string & {});
|
|
195
|
+
type ThemeValues = Record<string, string | number>;
|
|
196
|
+
type Theme = Partial<Record<ThemeKey, ThemeValues>>;
|
|
197
|
+
type Aliases = Record<string, readonly (CSSProperty | (string & {}))[]>;
|
|
198
|
+
type PropertiesOptions = readonly ('grid' | ThemeKey)[];
|
|
199
|
+
type DeepReadonly<T> = {
|
|
200
|
+
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
|
|
201
|
+
};
|
|
202
|
+
type Exact<T, V extends T> = Exclude<keyof V, keyof T> extends never ? V : T;
|
|
203
|
+
interface Config extends DeepReadonly<{
|
|
204
|
+
include: string[];
|
|
205
|
+
exclude?: string[];
|
|
206
|
+
grid?: string;
|
|
207
|
+
responsive?: {
|
|
208
|
+
[atRule: string]: string;
|
|
209
|
+
};
|
|
210
|
+
selectors?: {
|
|
211
|
+
[name: string]: string | string[];
|
|
212
|
+
};
|
|
213
|
+
keyframes?: {
|
|
214
|
+
[name: string]: {
|
|
215
|
+
[step: string]: {
|
|
216
|
+
[cssProperty: string]: string;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
aliases?: Aliases;
|
|
221
|
+
theme: Theme;
|
|
222
|
+
properties?: Partial<Record<CSSProperty, PropertiesOptions>>;
|
|
223
|
+
}> {
|
|
224
|
+
}
|
|
225
|
+
declare const createConfig: <T extends Config>(obj: Exact<Config, T>) => DeepReadonly<T>;
|
|
226
|
+
declare function getTokenPropertyName(tokenProperty: TokenProperty): string;
|
|
227
|
+
type Parts = {
|
|
228
|
+
name: string;
|
|
229
|
+
alias: string;
|
|
230
|
+
responsive?: string;
|
|
231
|
+
selector?: string;
|
|
232
|
+
};
|
|
233
|
+
declare function getTokenPropertyParts(tokenProperty: TokenProperty, config: Config): Parts | null;
|
|
234
|
+
declare function getTokenValueParts(tokenValue: TokenValue): {
|
|
235
|
+
themeKey: string;
|
|
236
|
+
token: string;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export { type Aliases, ArbitraryValue, type CSSProperty, type Config, type DefaultConfig, GridValue, type Theme, TokenProperty, TokenValue, VariantProperty, arbitraryValue, createConfig, defaultConfig, getTokenPropertyName, getTokenPropertyParts, getTokenValueParts, properties, tokenProperty, tokenValue, variantProperty };
|
package/dist/index.d.ts
CHANGED
|
@@ -181,6 +181,10 @@ type TokenProperty<P extends string = string> = `--${P}`;
|
|
|
181
181
|
declare const TokenProperty: {
|
|
182
182
|
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`--${string}`>>;
|
|
183
183
|
};
|
|
184
|
+
type VariantProperty<P extends string = string, V extends string = string> = `--${V}_${P}`;
|
|
185
|
+
declare const VariantProperty: {
|
|
186
|
+
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`--${string}_${string}`>>;
|
|
187
|
+
};
|
|
184
188
|
type TokenValue<TK extends string = string, V extends string = string> = `var(--${TK}_${V})`;
|
|
185
189
|
declare const TokenValue: {
|
|
186
190
|
safeParse: (input: unknown) => v.SafeParseResult<v.StringSchema<`var(--${string}_${string})`>>;
|
|
@@ -220,9 +224,16 @@ interface Config extends DeepReadonly<{
|
|
|
220
224
|
}
|
|
221
225
|
declare const createConfig: <T extends Config>(obj: Exact<Config, T>) => DeepReadonly<T>;
|
|
222
226
|
declare function getTokenPropertyName(tokenProperty: TokenProperty): string;
|
|
227
|
+
type Parts = {
|
|
228
|
+
name: string;
|
|
229
|
+
alias: string;
|
|
230
|
+
responsive?: string;
|
|
231
|
+
selector?: string;
|
|
232
|
+
};
|
|
233
|
+
declare function getTokenPropertyParts(tokenProperty: TokenProperty, config: Config): Parts | null;
|
|
223
234
|
declare function getTokenValueParts(tokenValue: TokenValue): {
|
|
224
235
|
themeKey: string;
|
|
225
236
|
token: string;
|
|
226
237
|
};
|
|
227
238
|
|
|
228
|
-
export { Aliases, ArbitraryValue, CSSProperty, Config, DefaultConfig, GridValue, Theme, TokenProperty, TokenValue, arbitraryValue, createConfig, defaultConfig, getTokenPropertyName, getTokenValueParts, properties, tokenProperty, tokenValue, variantProperty };
|
|
239
|
+
export { type Aliases, ArbitraryValue, type CSSProperty, type Config, type DefaultConfig, GridValue, type Theme, TokenProperty, TokenValue, VariantProperty, arbitraryValue, createConfig, defaultConfig, getTokenPropertyName, getTokenPropertyParts, getTokenValueParts, properties, tokenProperty, tokenValue, variantProperty };
|
package/dist/index.js
CHANGED
|
@@ -34,10 +34,12 @@ __export(src_exports, {
|
|
|
34
34
|
GridValue: () => GridValue,
|
|
35
35
|
TokenProperty: () => TokenProperty,
|
|
36
36
|
TokenValue: () => TokenValue,
|
|
37
|
+
VariantProperty: () => VariantProperty,
|
|
37
38
|
arbitraryValue: () => arbitraryValue,
|
|
38
39
|
createConfig: () => createConfig,
|
|
39
40
|
defaultConfig: () => config_default_default,
|
|
40
41
|
getTokenPropertyName: () => getTokenPropertyName,
|
|
42
|
+
getTokenPropertyParts: () => getTokenPropertyParts,
|
|
41
43
|
getTokenValueParts: () => getTokenValueParts,
|
|
42
44
|
properties: () => properties,
|
|
43
45
|
tokenProperty: () => tokenProperty,
|
|
@@ -61,6 +63,7 @@ function arbitraryValue(value) {
|
|
|
61
63
|
return `var(---,${value})`;
|
|
62
64
|
}
|
|
63
65
|
var tokenPropertyRegex = /(?<!var\()--((\w)([\w-]+)?)/;
|
|
66
|
+
var variantPropertyRegex = /(?<!var\()--((\w)([\w-]+)_([\w-]+))/;
|
|
64
67
|
var tokenValueRegex = /var\(--([\w-]+)_([\w-]+)\)/;
|
|
65
68
|
var aritraryValueRegex = /var\(---,(.+)\)/;
|
|
66
69
|
var gridValueSchema = v.number();
|
|
@@ -68,6 +71,13 @@ var GridValue = { safeParse: (input) => v.safeParse(gridValueSchema, input) };
|
|
|
68
71
|
var tokenPropertyRegexSchema = v.regex(tokenPropertyRegex);
|
|
69
72
|
var tokenPropertySchema = v.string([tokenPropertyRegexSchema]);
|
|
70
73
|
var TokenProperty = { safeParse: (input) => v.safeParse(tokenPropertySchema, input) };
|
|
74
|
+
var variantPropertyRegexSchema = v.regex(variantPropertyRegex);
|
|
75
|
+
var variantPropertySchema = v.string([
|
|
76
|
+
variantPropertyRegexSchema
|
|
77
|
+
]);
|
|
78
|
+
var VariantProperty = {
|
|
79
|
+
safeParse: (input) => v.safeParse(variantPropertySchema, input)
|
|
80
|
+
};
|
|
71
81
|
var tokenValueRegexSchema = v.regex(tokenValueRegex);
|
|
72
82
|
var tokenValueSchema = v.string([tokenValueRegexSchema]);
|
|
73
83
|
var TokenValue = { safeParse: (input) => v.safeParse(tokenValueSchema, input) };
|
|
@@ -78,6 +88,26 @@ var createConfig = (obj) => {
|
|
|
78
88
|
function getTokenPropertyName(tokenProperty2) {
|
|
79
89
|
return tokenProperty2.replace(tokenPropertyRegex, "$1");
|
|
80
90
|
}
|
|
91
|
+
function getTokenPropertyParts(tokenProperty2, config) {
|
|
92
|
+
const name = getTokenPropertyName(tokenProperty2);
|
|
93
|
+
const [alias, ...variants] = name.split("_").reverse();
|
|
94
|
+
const responsiveVariants = variants.filter((variant) => {
|
|
95
|
+
var _a;
|
|
96
|
+
return (_a = config.responsive) == null ? void 0 : _a[variant];
|
|
97
|
+
});
|
|
98
|
+
const selectorVariants = variants.filter((variant) => {
|
|
99
|
+
var _a;
|
|
100
|
+
return (_a = config.selectors) == null ? void 0 : _a[variant];
|
|
101
|
+
});
|
|
102
|
+
const validVariants = responsiveVariants.concat(selectorVariants);
|
|
103
|
+
const isValidResponsive = responsiveVariants.length <= 1;
|
|
104
|
+
const isValidSelector = selectorVariants.length <= 1;
|
|
105
|
+
const isValidVariants = variants.length === validVariants.length;
|
|
106
|
+
const isValid = isValidResponsive && isValidSelector && isValidVariants;
|
|
107
|
+
const [responsive] = responsiveVariants;
|
|
108
|
+
const [selector] = selectorVariants;
|
|
109
|
+
return isValid ? { name, alias, responsive, selector } : null;
|
|
110
|
+
}
|
|
81
111
|
function getTokenValueParts(tokenValue2) {
|
|
82
112
|
const [, key, token] = tokenValue2.split(tokenValueRegex);
|
|
83
113
|
return { themeKey: key, token };
|
|
@@ -671,10 +701,12 @@ var properties = [
|
|
|
671
701
|
GridValue,
|
|
672
702
|
TokenProperty,
|
|
673
703
|
TokenValue,
|
|
704
|
+
VariantProperty,
|
|
674
705
|
arbitraryValue,
|
|
675
706
|
createConfig,
|
|
676
707
|
defaultConfig,
|
|
677
708
|
getTokenPropertyName,
|
|
709
|
+
getTokenPropertyParts,
|
|
678
710
|
getTokenValueParts,
|
|
679
711
|
properties,
|
|
680
712
|
tokenProperty,
|
package/dist/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ function arbitraryValue(value) {
|
|
|
13
13
|
return `var(---,${value})`;
|
|
14
14
|
}
|
|
15
15
|
var tokenPropertyRegex = /(?<!var\()--((\w)([\w-]+)?)/;
|
|
16
|
+
var variantPropertyRegex = /(?<!var\()--((\w)([\w-]+)_([\w-]+))/;
|
|
16
17
|
var tokenValueRegex = /var\(--([\w-]+)_([\w-]+)\)/;
|
|
17
18
|
var aritraryValueRegex = /var\(---,(.+)\)/;
|
|
18
19
|
var gridValueSchema = v.number();
|
|
@@ -20,6 +21,13 @@ var GridValue = { safeParse: (input) => v.safeParse(gridValueSchema, input) };
|
|
|
20
21
|
var tokenPropertyRegexSchema = v.regex(tokenPropertyRegex);
|
|
21
22
|
var tokenPropertySchema = v.string([tokenPropertyRegexSchema]);
|
|
22
23
|
var TokenProperty = { safeParse: (input) => v.safeParse(tokenPropertySchema, input) };
|
|
24
|
+
var variantPropertyRegexSchema = v.regex(variantPropertyRegex);
|
|
25
|
+
var variantPropertySchema = v.string([
|
|
26
|
+
variantPropertyRegexSchema
|
|
27
|
+
]);
|
|
28
|
+
var VariantProperty = {
|
|
29
|
+
safeParse: (input) => v.safeParse(variantPropertySchema, input)
|
|
30
|
+
};
|
|
23
31
|
var tokenValueRegexSchema = v.regex(tokenValueRegex);
|
|
24
32
|
var tokenValueSchema = v.string([tokenValueRegexSchema]);
|
|
25
33
|
var TokenValue = { safeParse: (input) => v.safeParse(tokenValueSchema, input) };
|
|
@@ -30,6 +38,26 @@ var createConfig = (obj) => {
|
|
|
30
38
|
function getTokenPropertyName(tokenProperty2) {
|
|
31
39
|
return tokenProperty2.replace(tokenPropertyRegex, "$1");
|
|
32
40
|
}
|
|
41
|
+
function getTokenPropertyParts(tokenProperty2, config) {
|
|
42
|
+
const name = getTokenPropertyName(tokenProperty2);
|
|
43
|
+
const [alias, ...variants] = name.split("_").reverse();
|
|
44
|
+
const responsiveVariants = variants.filter((variant) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = config.responsive) == null ? void 0 : _a[variant];
|
|
47
|
+
});
|
|
48
|
+
const selectorVariants = variants.filter((variant) => {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = config.selectors) == null ? void 0 : _a[variant];
|
|
51
|
+
});
|
|
52
|
+
const validVariants = responsiveVariants.concat(selectorVariants);
|
|
53
|
+
const isValidResponsive = responsiveVariants.length <= 1;
|
|
54
|
+
const isValidSelector = selectorVariants.length <= 1;
|
|
55
|
+
const isValidVariants = variants.length === validVariants.length;
|
|
56
|
+
const isValid = isValidResponsive && isValidSelector && isValidVariants;
|
|
57
|
+
const [responsive] = responsiveVariants;
|
|
58
|
+
const [selector] = selectorVariants;
|
|
59
|
+
return isValid ? { name, alias, responsive, selector } : null;
|
|
60
|
+
}
|
|
33
61
|
function getTokenValueParts(tokenValue2) {
|
|
34
62
|
const [, key, token] = tokenValue2.split(tokenValueRegex);
|
|
35
63
|
return { themeKey: key, token };
|
|
@@ -622,10 +650,12 @@ export {
|
|
|
622
650
|
GridValue,
|
|
623
651
|
TokenProperty,
|
|
624
652
|
TokenValue,
|
|
653
|
+
VariantProperty,
|
|
625
654
|
arbitraryValue,
|
|
626
655
|
createConfig,
|
|
627
656
|
config_default_default as defaultConfig,
|
|
628
657
|
getTokenPropertyName,
|
|
658
|
+
getTokenPropertyParts,
|
|
629
659
|
getTokenValueParts,
|
|
630
660
|
properties,
|
|
631
661
|
tokenProperty,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"csstype": "^3.1.2",
|
|
18
18
|
"tsup": "^7.0.0",
|
|
19
19
|
"typescript": "^5.1.3",
|
|
20
|
-
"@tokenami/dev": "0.0.
|
|
20
|
+
"@tokenami/dev": "0.0.16"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsup src/index.ts --format=esm,cjs --dts",
|