tailwind-styled-v4 5.1.20 → 5.1.21
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
CHANGED
|
@@ -182,7 +182,6 @@ interface StyledComponentProps {
|
|
|
182
182
|
className?: string;
|
|
183
183
|
as?: HtmlTagName;
|
|
184
184
|
children?: React.ReactNode;
|
|
185
|
-
[key: string]: unknown;
|
|
186
185
|
}
|
|
187
186
|
type SubComponentMap = Record<string, unknown>;
|
|
188
187
|
type TwSubComponentAccessor<Tag extends HtmlTagName = "span"> = React.FC<Omit<React.ComponentPropsWithoutRef<Tag>, "ref"> & {
|
|
@@ -200,19 +199,19 @@ type ExtractSubNames<T extends string> = T extends `${string}[${infer Name}]${st
|
|
|
200
199
|
type SubComponentKeys<S extends string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
201
200
|
[K in S]: TwSubComponentAccessor<K extends keyof TagMap ? (TagMap[K] extends HtmlTagName ? TagMap[K] : "span") : "span">;
|
|
202
201
|
};
|
|
203
|
-
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never
|
|
204
|
-
(props: StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
202
|
+
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never>, Tag extends HtmlTagName = HtmlTagName> = {
|
|
203
|
+
(props: React.ComponentPropsWithoutRef<Tag> & StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
205
204
|
displayName?: string;
|
|
206
205
|
extend: {
|
|
207
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap>;
|
|
206
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap, Tag>;
|
|
208
207
|
(config: {
|
|
209
208
|
classes?: string;
|
|
210
209
|
variants?: ComponentConfig["variants"];
|
|
211
210
|
defaultVariants?: ComponentConfig["defaultVariants"];
|
|
212
211
|
compoundVariants?: ComponentConfig["compoundVariants"];
|
|
213
|
-
}): TwStyledComponent<Config, S, TagMap>;
|
|
212
|
+
}): TwStyledComponent<Config, S, TagMap, Tag>;
|
|
214
213
|
};
|
|
215
|
-
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap>;
|
|
214
|
+
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap, Tag>;
|
|
216
215
|
/**
|
|
217
216
|
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
218
217
|
*
|
|
@@ -226,27 +225,27 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
226
225
|
* Button.footer // ✅ autocomplete
|
|
227
226
|
* Button.xyz // ❌ TypeScript error
|
|
228
227
|
*/
|
|
229
|
-
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap>;
|
|
230
|
-
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap>>;
|
|
228
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap, Tag>;
|
|
229
|
+
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap, Tag>>;
|
|
231
230
|
} & SubComponentKeys<S, TagMap>;
|
|
232
231
|
interface TwSubComponent<P = unknown> {
|
|
233
232
|
(props: P): React.ReactElement | null;
|
|
234
233
|
displayName?: string;
|
|
235
234
|
}
|
|
236
|
-
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
237
|
-
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T
|
|
238
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
239
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never
|
|
235
|
+
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig, Tag extends HtmlTagName = HtmlTagName> {
|
|
236
|
+
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>, Record<string, never>, Tag>;
|
|
237
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string, Record<string, never>, Tag>;
|
|
238
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never>, Tag>;
|
|
240
239
|
}
|
|
241
240
|
type TwTagFactory = {
|
|
242
|
-
[K in HtmlTagName]: TwTemplateFactory
|
|
241
|
+
[K in HtmlTagName]: TwTemplateFactory<ComponentConfig, K>;
|
|
243
242
|
};
|
|
244
243
|
type TwTagFactoryAny = {
|
|
245
244
|
[key: string]: TwTemplateFactory;
|
|
246
245
|
};
|
|
247
246
|
type TwComponentFactory<T extends React.ElementType = React.ElementType> = (tag: T) => TwTemplateFactory;
|
|
248
247
|
type TwServerObject = TwTagFactory & {
|
|
249
|
-
[K in HtmlTagName as `${K}`]: TwTemplateFactory
|
|
248
|
+
[K in HtmlTagName as `${K}`]: TwTemplateFactory<ComponentConfig, K>;
|
|
250
249
|
};
|
|
251
250
|
type TwObject = TwComponentFactory & TwTagFactory & {
|
|
252
251
|
server: TwServerObject;
|
package/dist/index.d.ts
CHANGED
|
@@ -182,7 +182,6 @@ interface StyledComponentProps {
|
|
|
182
182
|
className?: string;
|
|
183
183
|
as?: HtmlTagName;
|
|
184
184
|
children?: React.ReactNode;
|
|
185
|
-
[key: string]: unknown;
|
|
186
185
|
}
|
|
187
186
|
type SubComponentMap = Record<string, unknown>;
|
|
188
187
|
type TwSubComponentAccessor<Tag extends HtmlTagName = "span"> = React.FC<Omit<React.ComponentPropsWithoutRef<Tag>, "ref"> & {
|
|
@@ -200,19 +199,19 @@ type ExtractSubNames<T extends string> = T extends `${string}[${infer Name}]${st
|
|
|
200
199
|
type SubComponentKeys<S extends string, TagMap extends Record<string, string> = Record<string, never>> = {
|
|
201
200
|
[K in S]: TwSubComponentAccessor<K extends keyof TagMap ? (TagMap[K] extends HtmlTagName ? TagMap[K] : "span") : "span">;
|
|
202
201
|
};
|
|
203
|
-
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never
|
|
204
|
-
(props: StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
202
|
+
type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S extends string = string, TagMap extends Record<string, string> = Record<string, never>, Tag extends HtmlTagName = HtmlTagName> = {
|
|
203
|
+
(props: React.ComponentPropsWithoutRef<Tag> & StyledComponentProps & InferVariantProps<Config> & InferSizeProps<Config> & InferStatesProps<Config>): React.ReactElement | null;
|
|
205
204
|
displayName?: string;
|
|
206
205
|
extend: {
|
|
207
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap>;
|
|
206
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, S, TagMap, Tag>;
|
|
208
207
|
(config: {
|
|
209
208
|
classes?: string;
|
|
210
209
|
variants?: ComponentConfig["variants"];
|
|
211
210
|
defaultVariants?: ComponentConfig["defaultVariants"];
|
|
212
211
|
compoundVariants?: ComponentConfig["compoundVariants"];
|
|
213
|
-
}): TwStyledComponent<Config, S, TagMap>;
|
|
212
|
+
}): TwStyledComponent<Config, S, TagMap, Tag>;
|
|
214
213
|
};
|
|
215
|
-
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap>;
|
|
214
|
+
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S, TagMap, Tag>;
|
|
216
215
|
/**
|
|
217
216
|
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
218
217
|
*
|
|
@@ -226,27 +225,27 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
226
225
|
* Button.footer // ✅ autocomplete
|
|
227
226
|
* Button.xyz // ❌ TypeScript error
|
|
228
227
|
*/
|
|
229
|
-
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap>;
|
|
230
|
-
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap>>;
|
|
228
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS, TagMap, Tag>;
|
|
229
|
+
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S, TagMap, Tag>>;
|
|
231
230
|
} & SubComponentKeys<S, TagMap>;
|
|
232
231
|
interface TwSubComponent<P = unknown> {
|
|
233
232
|
(props: P): React.ReactElement | null;
|
|
234
233
|
displayName?: string;
|
|
235
234
|
}
|
|
236
|
-
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
237
|
-
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T
|
|
238
|
-
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
239
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never
|
|
235
|
+
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig, Tag extends HtmlTagName = HtmlTagName> {
|
|
236
|
+
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>, Record<string, never>, Tag>;
|
|
237
|
+
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string, Record<string, never>, Tag>;
|
|
238
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>, InferSubTagsFromConfig<C> extends Record<string, string> ? InferSubTagsFromConfig<C> : Record<string, never>, Tag>;
|
|
240
239
|
}
|
|
241
240
|
type TwTagFactory = {
|
|
242
|
-
[K in HtmlTagName]: TwTemplateFactory
|
|
241
|
+
[K in HtmlTagName]: TwTemplateFactory<ComponentConfig, K>;
|
|
243
242
|
};
|
|
244
243
|
type TwTagFactoryAny = {
|
|
245
244
|
[key: string]: TwTemplateFactory;
|
|
246
245
|
};
|
|
247
246
|
type TwComponentFactory<T extends React.ElementType = React.ElementType> = (tag: T) => TwTemplateFactory;
|
|
248
247
|
type TwServerObject = TwTagFactory & {
|
|
249
|
-
[K in HtmlTagName as `${K}`]: TwTemplateFactory
|
|
248
|
+
[K in HtmlTagName as `${K}`]: TwTemplateFactory<ComponentConfig, K>;
|
|
250
249
|
};
|
|
251
250
|
type TwObject = TwComponentFactory & TwTagFactory & {
|
|
252
251
|
server: TwServerObject;
|
|
Binary file
|
|
Binary file
|