tailwind-styled-v4 5.1.18 → 5.1.20
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.browser.mjs +8 -4
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +71 -48
- package/dist/index.d.ts +71 -48
- package/dist/index.js +31 -451
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -442
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -0
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +1 -0
- package/dist/runtime.mjs.map +1 -1
- package/dist/theme.d.mts +23 -76
- package/dist/theme.d.ts +23 -76
- package/dist/theme.js +4 -218
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +3 -205
- package/dist/theme.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -126,6 +126,42 @@ type InferSubFromConfig<C extends ComponentConfig> = C extends {
|
|
|
126
126
|
} ? {
|
|
127
127
|
[K in keyof S]: S[K] extends string ? K extends string ? ExtractSubName<K> : never : S[K] extends Record<infer N extends string, string> ? N : never;
|
|
128
128
|
}[keyof S] : never;
|
|
129
|
+
/**
|
|
130
|
+
* HTML tags yang otomatis dikenali sebagai tag dari bare sub-key (tanpa "tag:name" syntax).
|
|
131
|
+
* HARUS identik dengan SEMANTIC_HTML_TAGS di createComponent.ts (parseSubKey) — kalau
|
|
132
|
+
* drift, sub-component bisa di-tipe-kan dengan native attributes yang salah (tag yang
|
|
133
|
+
* benar2 di-render di runtime beda dari yang dipakai untuk inference type-nya).
|
|
134
|
+
*/
|
|
135
|
+
type SemanticSubTag = "article" | "aside" | "details" | "figcaption" | "figure" | "footer" | "header" | "main" | "mark" | "nav" | "section" | "summary" | "time" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "ul" | "ol" | "li" | "dl" | "dt" | "dd" | "table" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td" | "form" | "fieldset" | "legend" | "label" | "a" | "button" | "img" | "span" | "div" | "blockquote" | "pre" | "code" | "em" | "strong" | "small";
|
|
136
|
+
/**
|
|
137
|
+
* Resolve tag HTML dari satu sub-key string — mirror logic `parseSubKey()` runtime
|
|
138
|
+
* di createComponent.ts:
|
|
139
|
+
* - "a:link" → tag eksplisit sebelum colon ("a")
|
|
140
|
+
* - "header" → bare key, fallback ke key itu sendiri kalau termasuk SemanticSubTag
|
|
141
|
+
* - "icon" → bare key, bukan semantic tag → fallback "span" (default runtime)
|
|
142
|
+
*/
|
|
143
|
+
type ResolveSubTag<K extends string> = K extends `${infer Tag}:${string}` ? Tag extends HtmlTagName ? Tag : "span" : K extends SemanticSubTag ? K : "span";
|
|
144
|
+
/** Gabungkan union of object types jadi satu intersection — dipakai untuk merge per-key tag map. */
|
|
145
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
146
|
+
/**
|
|
147
|
+
* Infer mapping { subComponentName: htmlTag } dari config.sub — dipakai supaya setiap
|
|
148
|
+
* sub-component (Card.icon, Breadcrumb.link, dst) punya native HTML attributes yang
|
|
149
|
+
* SESUAI tag yang benar2 di-render (href untuk <a>, src untuk <img>, dst), bukan cuma
|
|
150
|
+
* `{ children?, className? }` generik.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* sub: { "a:link": "...", "span:sep": "..." } → { link: "a"; sep: "span" }
|
|
154
|
+
* sub: { header: { topBar: "..." } } → { topBar: "header" }
|
|
155
|
+
*/
|
|
156
|
+
type InferSubTagsFromConfig<C extends ComponentConfig> = C extends {
|
|
157
|
+
sub: infer S extends Record<string, SubValue>;
|
|
158
|
+
} ? UnionToIntersection<{
|
|
159
|
+
[K in keyof S]: K extends string ? S[K] extends string ? {
|
|
160
|
+
[N in ExtractSubName<K>]: ResolveSubTag<K>;
|
|
161
|
+
} : S[K] extends Record<string, string> ? {
|
|
162
|
+
[N in keyof S[K]]: K extends HtmlTagName ? K : "span";
|
|
163
|
+
} : never : never;
|
|
164
|
+
}[keyof S]> : Record<string, never>;
|
|
129
165
|
interface ContainerConfig {
|
|
130
166
|
base?: string;
|
|
131
167
|
queries?: Record<string, string>;
|
|
@@ -149,7 +185,7 @@ interface StyledComponentProps {
|
|
|
149
185
|
[key: string]: unknown;
|
|
150
186
|
}
|
|
151
187
|
type SubComponentMap = Record<string, unknown>;
|
|
152
|
-
type TwSubComponentAccessor = React.FC<{
|
|
188
|
+
type TwSubComponentAccessor<Tag extends HtmlTagName = "span"> = React.FC<Omit<React.ComponentPropsWithoutRef<Tag>, "ref"> & {
|
|
153
189
|
children?: React.ReactNode;
|
|
154
190
|
className?: string;
|
|
155
191
|
}>;
|
|
@@ -161,24 +197,22 @@ type TrimRight<S extends string> = S extends `${infer L} ` | `${infer L}
|
|
|
161
197
|
` ? TrimRight<L> : S;
|
|
162
198
|
type Trim<S extends string> = TrimLeft<TrimRight<S>>;
|
|
163
199
|
type ExtractSubNames<T extends string> = T extends `${string}[${infer Name}]${string}{${string}}${infer Rest}` ? Trim<Name> | ExtractSubNames<Rest> : T extends `${string}\n${infer Name}{${string}}${infer Rest}` ? (Trim<Name> extends "" ? never : Trim<Name>) | ExtractSubNames<Rest> : never;
|
|
164
|
-
type SubComponentKeys<S extends string> = string
|
|
165
|
-
[
|
|
166
|
-
} : {
|
|
167
|
-
[K in S]: TwSubComponentAccessor;
|
|
200
|
+
type SubComponentKeys<S extends string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
201
|
+
[K in S]: TwSubComponentAccessor<K extends keyof TagMap ? (TagMap[K] extends HtmlTagName ? TagMap[K] : "span") : "span">;
|
|
168
202
|
};
|
|
169
|
-
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string> = {
|
|
203
|
+
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
170
204
|
(props: StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
171
205
|
displayName?: string;
|
|
172
206
|
extend: {
|
|
173
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S>;
|
|
207
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap>;
|
|
174
208
|
(config: {
|
|
175
209
|
classes?: string;
|
|
176
210
|
variants?: ComponentConfig["variants"];
|
|
177
211
|
defaultVariants?: ComponentConfig["defaultVariants"];
|
|
178
212
|
compoundVariants?: ComponentConfig["compoundVariants"];
|
|
179
|
-
}): TwStyledComponent<Config, S>;
|
|
213
|
+
}): TwStyledComponent<Config, S, TagMap>;
|
|
180
214
|
};
|
|
181
|
-
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S>;
|
|
215
|
+
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap>;
|
|
182
216
|
/**
|
|
183
217
|
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
184
218
|
*
|
|
@@ -192,9 +226,9 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
192
226
|
* Button.footer // ✅ autocomplete
|
|
193
227
|
* Button.xyz // ❌ TypeScript error
|
|
194
228
|
*/
|
|
195
|
-
withSub<NewS extends string>(): TwStyledComponent<Config, NewS>;
|
|
196
|
-
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S>>;
|
|
197
|
-
} & SubComponentKeys<S>;
|
|
229
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap>;
|
|
230
|
+
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap>>;
|
|
231
|
+
} & SubComponentKeys<S, TagMap>;
|
|
198
232
|
interface TwSubComponent<P = unknown> {
|
|
199
233
|
(props: P): React.ReactElement | null;
|
|
200
234
|
displayName?: string;
|
|
@@ -202,7 +236,7 @@ interface TwSubComponent<P = unknown> {
|
|
|
202
236
|
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
203
237
|
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>>;
|
|
204
238
|
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
205
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>>;
|
|
239
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never>>;
|
|
206
240
|
}
|
|
207
241
|
type TwTagFactory = {
|
|
208
242
|
[K in HtmlTagName]: TwTemplateFactory;
|
|
@@ -700,40 +734,6 @@ declare const v4Tokens: {
|
|
|
700
734
|
readonly fontMono: string;
|
|
701
735
|
};
|
|
702
736
|
|
|
703
|
-
type TokenSubscriber = (tokens: TokenMap) => void;
|
|
704
|
-
interface LiveTokenSet {
|
|
705
|
-
vars: Record<string, string>;
|
|
706
|
-
get(name: string): string | undefined;
|
|
707
|
-
set(name: string, value: string): void;
|
|
708
|
-
setAll(tokens: TokenMap): void;
|
|
709
|
-
snapshot(): TokenMap;
|
|
710
|
-
}
|
|
711
|
-
interface LiveTokenEngineBridge {
|
|
712
|
-
getToken(name: string): string | undefined;
|
|
713
|
-
getTokens(): TokenMap;
|
|
714
|
-
setToken(name: string, value: string): void;
|
|
715
|
-
setTokens(tokens: TokenMap): void;
|
|
716
|
-
applyTokenSet(tokens: TokenMap): void;
|
|
717
|
-
subscribeTokens(fn: TokenSubscriber): () => void;
|
|
718
|
-
subscribe?(fn: TokenSubscriber): () => void;
|
|
719
|
-
}
|
|
720
|
-
declare function tokenVar(name: string): string;
|
|
721
|
-
declare function tokenRef(name: string): string;
|
|
722
|
-
declare function liveToken(tokens: TokenMap): LiveTokenSet;
|
|
723
|
-
declare function setToken(name: string, value: string): void;
|
|
724
|
-
declare function setTokens(tokens: TokenMap): void;
|
|
725
|
-
declare function applyTokenSet(tokens: TokenMap): void;
|
|
726
|
-
declare function getToken(name: string): string | undefined;
|
|
727
|
-
declare function getTokens(): TokenMap;
|
|
728
|
-
declare function subscribeTokens(fn: TokenSubscriber): () => void;
|
|
729
|
-
declare function generateTokenCssString(): string;
|
|
730
|
-
declare function createUseTokens(): () => TokenMap;
|
|
731
|
-
declare global {
|
|
732
|
-
interface Window {
|
|
733
|
-
__TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
737
|
interface SubComponentProps {
|
|
738
738
|
children?: React.ReactNode;
|
|
739
739
|
className?: string;
|
|
@@ -773,4 +773,27 @@ interface ThemeConfig {
|
|
|
773
773
|
raw: Record<string, string>;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
-
|
|
776
|
+
type TokenSubscriber = (tokens: TokenMap) => void;
|
|
777
|
+
interface LiveTokenSet {
|
|
778
|
+
vars: Record<string, string>;
|
|
779
|
+
get(name: string): string | undefined;
|
|
780
|
+
set(name: string, value: string): void;
|
|
781
|
+
setAll(tokens: TokenMap): void;
|
|
782
|
+
snapshot(): TokenMap;
|
|
783
|
+
}
|
|
784
|
+
interface LiveTokenEngineBridge {
|
|
785
|
+
getToken(name: string): string | undefined;
|
|
786
|
+
getTokens(): TokenMap;
|
|
787
|
+
setToken(name: string, value: string): void;
|
|
788
|
+
setTokens(tokens: TokenMap): void;
|
|
789
|
+
applyTokenSet(tokens: TokenMap): void;
|
|
790
|
+
subscribeTokens(fn: TokenSubscriber): () => void;
|
|
791
|
+
subscribe?(fn: TokenSubscriber): () => void;
|
|
792
|
+
}
|
|
793
|
+
declare global {
|
|
794
|
+
interface Window {
|
|
795
|
+
__TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,42 @@ type InferSubFromConfig<C extends ComponentConfig> = C extends {
|
|
|
126
126
|
} ? {
|
|
127
127
|
[K in keyof S]: S[K] extends string ? K extends string ? ExtractSubName<K> : never : S[K] extends Record<infer N extends string, string> ? N : never;
|
|
128
128
|
}[keyof S] : never;
|
|
129
|
+
/**
|
|
130
|
+
* HTML tags yang otomatis dikenali sebagai tag dari bare sub-key (tanpa "tag:name" syntax).
|
|
131
|
+
* HARUS identik dengan SEMANTIC_HTML_TAGS di createComponent.ts (parseSubKey) — kalau
|
|
132
|
+
* drift, sub-component bisa di-tipe-kan dengan native attributes yang salah (tag yang
|
|
133
|
+
* benar2 di-render di runtime beda dari yang dipakai untuk inference type-nya).
|
|
134
|
+
*/
|
|
135
|
+
type SemanticSubTag = "article" | "aside" | "details" | "figcaption" | "figure" | "footer" | "header" | "main" | "mark" | "nav" | "section" | "summary" | "time" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "ul" | "ol" | "li" | "dl" | "dt" | "dd" | "table" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td" | "form" | "fieldset" | "legend" | "label" | "a" | "button" | "img" | "span" | "div" | "blockquote" | "pre" | "code" | "em" | "strong" | "small";
|
|
136
|
+
/**
|
|
137
|
+
* Resolve tag HTML dari satu sub-key string — mirror logic `parseSubKey()` runtime
|
|
138
|
+
* di createComponent.ts:
|
|
139
|
+
* - "a:link" → tag eksplisit sebelum colon ("a")
|
|
140
|
+
* - "header" → bare key, fallback ke key itu sendiri kalau termasuk SemanticSubTag
|
|
141
|
+
* - "icon" → bare key, bukan semantic tag → fallback "span" (default runtime)
|
|
142
|
+
*/
|
|
143
|
+
type ResolveSubTag<K extends string> = K extends `${infer Tag}:${string}` ? Tag extends HtmlTagName ? Tag : "span" : K extends SemanticSubTag ? K : "span";
|
|
144
|
+
/** Gabungkan union of object types jadi satu intersection — dipakai untuk merge per-key tag map. */
|
|
145
|
+
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
146
|
+
/**
|
|
147
|
+
* Infer mapping { subComponentName: htmlTag } dari config.sub — dipakai supaya setiap
|
|
148
|
+
* sub-component (Card.icon, Breadcrumb.link, dst) punya native HTML attributes yang
|
|
149
|
+
* SESUAI tag yang benar2 di-render (href untuk <a>, src untuk <img>, dst), bukan cuma
|
|
150
|
+
* `{ children?, className? }` generik.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* sub: { "a:link": "...", "span:sep": "..." } → { link: "a"; sep: "span" }
|
|
154
|
+
* sub: { header: { topBar: "..." } } → { topBar: "header" }
|
|
155
|
+
*/
|
|
156
|
+
type InferSubTagsFromConfig<C extends ComponentConfig> = C extends {
|
|
157
|
+
sub: infer S extends Record<string, SubValue>;
|
|
158
|
+
} ? UnionToIntersection<{
|
|
159
|
+
[K in keyof S]: K extends string ? S[K] extends string ? {
|
|
160
|
+
[N in ExtractSubName<K>]: ResolveSubTag<K>;
|
|
161
|
+
} : S[K] extends Record<string, string> ? {
|
|
162
|
+
[N in keyof S[K]]: K extends HtmlTagName ? K : "span";
|
|
163
|
+
} : never : never;
|
|
164
|
+
}[keyof S]> : Record<string, never>;
|
|
129
165
|
interface ContainerConfig {
|
|
130
166
|
base?: string;
|
|
131
167
|
queries?: Record<string, string>;
|
|
@@ -149,7 +185,7 @@ interface StyledComponentProps {
|
|
|
149
185
|
[key: string]: unknown;
|
|
150
186
|
}
|
|
151
187
|
type SubComponentMap = Record<string, unknown>;
|
|
152
|
-
type TwSubComponentAccessor = React.FC<{
|
|
188
|
+
type TwSubComponentAccessor<Tag extends HtmlTagName = "span"> = React.FC<Omit<React.ComponentPropsWithoutRef<Tag>, "ref"> & {
|
|
153
189
|
children?: React.ReactNode;
|
|
154
190
|
className?: string;
|
|
155
191
|
}>;
|
|
@@ -161,24 +197,22 @@ type TrimRight<S extends string> = S extends `${infer L} ` | `${infer L}
|
|
|
161
197
|
` ? TrimRight<L> : S;
|
|
162
198
|
type Trim<S extends string> = TrimLeft<TrimRight<S>>;
|
|
163
199
|
type ExtractSubNames<T extends string> = T extends `${string}[${infer Name}]${string}{${string}}${infer Rest}` ? Trim<Name> | ExtractSubNames<Rest> : T extends `${string}\n${infer Name}{${string}}${infer Rest}` ? (Trim<Name> extends "" ? never : Trim<Name>) | ExtractSubNames<Rest> : never;
|
|
164
|
-
type SubComponentKeys<S extends string> = string
|
|
165
|
-
[
|
|
166
|
-
} : {
|
|
167
|
-
[K in S]: TwSubComponentAccessor;
|
|
200
|
+
type SubComponentKeys<S extends string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
201
|
+
[K in S]: TwSubComponentAccessor<K extends keyof TagMap ? (TagMap[K] extends HtmlTagName ? TagMap[K] : "span") : "span">;
|
|
168
202
|
};
|
|
169
|
-
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string> = {
|
|
203
|
+
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
170
204
|
(props: StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
171
205
|
displayName?: string;
|
|
172
206
|
extend: {
|
|
173
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S>;
|
|
207
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap>;
|
|
174
208
|
(config: {
|
|
175
209
|
classes?: string;
|
|
176
210
|
variants?: ComponentConfig["variants"];
|
|
177
211
|
defaultVariants?: ComponentConfig["defaultVariants"];
|
|
178
212
|
compoundVariants?: ComponentConfig["compoundVariants"];
|
|
179
|
-
}): TwStyledComponent<Config, S>;
|
|
213
|
+
}): TwStyledComponent<Config, S, TagMap>;
|
|
180
214
|
};
|
|
181
|
-
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S>;
|
|
215
|
+
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap>;
|
|
182
216
|
/**
|
|
183
217
|
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
184
218
|
*
|
|
@@ -192,9 +226,9 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
192
226
|
* Button.footer // ✅ autocomplete
|
|
193
227
|
* Button.xyz // ❌ TypeScript error
|
|
194
228
|
*/
|
|
195
|
-
withSub<NewS extends string>(): TwStyledComponent<Config, NewS>;
|
|
196
|
-
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S>>;
|
|
197
|
-
} & SubComponentKeys<S>;
|
|
229
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap>;
|
|
230
|
+
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap>>;
|
|
231
|
+
} & SubComponentKeys<S, TagMap>;
|
|
198
232
|
interface TwSubComponent<P = unknown> {
|
|
199
233
|
(props: P): React.ReactElement | null;
|
|
200
234
|
displayName?: string;
|
|
@@ -202,7 +236,7 @@ interface TwSubComponent<P = unknown> {
|
|
|
202
236
|
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
203
237
|
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>>;
|
|
204
238
|
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
205
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>>;
|
|
239
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never>>;
|
|
206
240
|
}
|
|
207
241
|
type TwTagFactory = {
|
|
208
242
|
[K in HtmlTagName]: TwTemplateFactory;
|
|
@@ -700,40 +734,6 @@ declare const v4Tokens: {
|
|
|
700
734
|
readonly fontMono: string;
|
|
701
735
|
};
|
|
702
736
|
|
|
703
|
-
type TokenSubscriber = (tokens: TokenMap) => void;
|
|
704
|
-
interface LiveTokenSet {
|
|
705
|
-
vars: Record<string, string>;
|
|
706
|
-
get(name: string): string | undefined;
|
|
707
|
-
set(name: string, value: string): void;
|
|
708
|
-
setAll(tokens: TokenMap): void;
|
|
709
|
-
snapshot(): TokenMap;
|
|
710
|
-
}
|
|
711
|
-
interface LiveTokenEngineBridge {
|
|
712
|
-
getToken(name: string): string | undefined;
|
|
713
|
-
getTokens(): TokenMap;
|
|
714
|
-
setToken(name: string, value: string): void;
|
|
715
|
-
setTokens(tokens: TokenMap): void;
|
|
716
|
-
applyTokenSet(tokens: TokenMap): void;
|
|
717
|
-
subscribeTokens(fn: TokenSubscriber): () => void;
|
|
718
|
-
subscribe?(fn: TokenSubscriber): () => void;
|
|
719
|
-
}
|
|
720
|
-
declare function tokenVar(name: string): string;
|
|
721
|
-
declare function tokenRef(name: string): string;
|
|
722
|
-
declare function liveToken(tokens: TokenMap): LiveTokenSet;
|
|
723
|
-
declare function setToken(name: string, value: string): void;
|
|
724
|
-
declare function setTokens(tokens: TokenMap): void;
|
|
725
|
-
declare function applyTokenSet(tokens: TokenMap): void;
|
|
726
|
-
declare function getToken(name: string): string | undefined;
|
|
727
|
-
declare function getTokens(): TokenMap;
|
|
728
|
-
declare function subscribeTokens(fn: TokenSubscriber): () => void;
|
|
729
|
-
declare function generateTokenCssString(): string;
|
|
730
|
-
declare function createUseTokens(): () => TokenMap;
|
|
731
|
-
declare global {
|
|
732
|
-
interface Window {
|
|
733
|
-
__TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
|
|
737
737
|
interface SubComponentProps {
|
|
738
738
|
children?: React.ReactNode;
|
|
739
739
|
className?: string;
|
|
@@ -773,4 +773,27 @@ interface ThemeConfig {
|
|
|
773
773
|
raw: Record<string, string>;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
-
|
|
776
|
+
type TokenSubscriber = (tokens: TokenMap) => void;
|
|
777
|
+
interface LiveTokenSet {
|
|
778
|
+
vars: Record<string, string>;
|
|
779
|
+
get(name: string): string | undefined;
|
|
780
|
+
set(name: string, value: string): void;
|
|
781
|
+
setAll(tokens: TokenMap): void;
|
|
782
|
+
snapshot(): TokenMap;
|
|
783
|
+
}
|
|
784
|
+
interface LiveTokenEngineBridge {
|
|
785
|
+
getToken(name: string): string | undefined;
|
|
786
|
+
getTokens(): TokenMap;
|
|
787
|
+
setToken(name: string, value: string): void;
|
|
788
|
+
setTokens(tokens: TokenMap): void;
|
|
789
|
+
applyTokenSet(tokens: TokenMap): void;
|
|
790
|
+
subscribeTokens(fn: TokenSubscriber): () => void;
|
|
791
|
+
subscribe?(fn: TokenSubscriber): () => void;
|
|
792
|
+
}
|
|
793
|
+
declare global {
|
|
794
|
+
interface Window {
|
|
795
|
+
__TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, registerVariantTable, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
|