tailwind-styled-v4 5.0.8 → 5.0.10
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/CHANGELOG.md +204 -416
- package/README.md +45 -15
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +63 -32
- package/dist/index.d.ts +63 -32
- package/dist/index.js +335 -169
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -169
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.d.mts +10 -4
- package/dist/next.d.ts +10 -4
- package/dist/next.js +32 -45
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +30 -43
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +84 -126
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +68 -124
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +69 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +49 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
|
@@ -63,10 +63,12 @@ interface LoadNativeBindingResult<T> {
|
|
|
63
63
|
}
|
|
64
64
|
declare function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T>;
|
|
65
65
|
interface ResolveCandidatesOptions {
|
|
66
|
-
runtimeDir
|
|
66
|
+
runtimeDir?: string;
|
|
67
67
|
envVarNames?: string[];
|
|
68
68
|
includeDefaultCandidates?: boolean;
|
|
69
69
|
enforceNodeExtensionForEnvPath?: boolean;
|
|
70
|
+
/** @deprecated — ignored, kept for backward compat */
|
|
71
|
+
packageName?: string;
|
|
70
72
|
}
|
|
71
73
|
declare function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[];
|
|
72
74
|
declare function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string;
|
|
@@ -63,10 +63,12 @@ interface LoadNativeBindingResult<T> {
|
|
|
63
63
|
}
|
|
64
64
|
declare function loadNativeBinding<T>(options: LoadNativeBindingOptions<T>): LoadNativeBindingResult<T>;
|
|
65
65
|
interface ResolveCandidatesOptions {
|
|
66
|
-
runtimeDir
|
|
66
|
+
runtimeDir?: string;
|
|
67
67
|
envVarNames?: string[];
|
|
68
68
|
includeDefaultCandidates?: boolean;
|
|
69
69
|
enforceNodeExtensionForEnvPath?: boolean;
|
|
70
|
+
/** @deprecated — ignored, kept for backward compat */
|
|
71
|
+
packageName?: string;
|
|
70
72
|
}
|
|
71
73
|
declare function resolveNativeBindingCandidates(options: ResolveCandidatesOptions): string[];
|
|
72
74
|
declare function resolveRuntimeDir(dir: string | undefined, importMetaUrl: string): string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { a as AnimateOptions } from './types-DXr2PmGP.mjs';
|
|
3
|
-
import { H as HtmlTagName } from './index-
|
|
4
|
-
export { T as TokenMap } from './index-
|
|
5
|
-
export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-
|
|
3
|
+
import { H as HtmlTagName } from './index-NDINUhLN.mjs';
|
|
4
|
+
export { T as TokenMap } from './index-NDINUhLN.mjs';
|
|
5
|
+
export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-DKoWRtqH.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* tailwind-styled-v4 — Core Types
|
|
@@ -26,7 +26,12 @@ interface ComponentConfig {
|
|
|
26
26
|
state?: Record<string, Record<string, string>>;
|
|
27
27
|
container?: Record<string, string>;
|
|
28
28
|
containerName?: string;
|
|
29
|
+
/** Sub-component definitions — keys di-infer otomatis oleh TypeScript */
|
|
30
|
+
sub?: Record<string, string>;
|
|
29
31
|
}
|
|
32
|
+
type InferSubFromConfig<C extends ComponentConfig> = C extends {
|
|
33
|
+
sub: Record<infer K extends string, string>;
|
|
34
|
+
} ? K : never;
|
|
30
35
|
interface ContainerConfig {
|
|
31
36
|
base?: string;
|
|
32
37
|
queries?: Record<string, string>;
|
|
@@ -61,7 +66,7 @@ type TrimRight<S extends string> = S extends `${infer L} ` | `${infer L}
|
|
|
61
66
|
` | `${infer L} ` | `${infer L}
|
|
62
67
|
` ? TrimRight<L> : S;
|
|
63
68
|
type Trim<S extends string> = TrimLeft<TrimRight<S>>;
|
|
64
|
-
type ExtractSubNames<T extends string> = T extends `${
|
|
69
|
+
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;
|
|
65
70
|
type SubComponentKeys<S extends string> = string extends S ? {
|
|
66
71
|
[key: string]: TwSubComponentAccessor;
|
|
67
72
|
} : {
|
|
@@ -80,7 +85,20 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
80
85
|
}): TwStyledComponent<Config, S>;
|
|
81
86
|
};
|
|
82
87
|
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S>;
|
|
83
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* export const Button = tw.button`
|
|
93
|
+
* flex h-12 ...
|
|
94
|
+
* icon { flex h-4 }
|
|
95
|
+
* `.withSub<"icon" | "footer">()
|
|
96
|
+
*
|
|
97
|
+
* Button.icon // ✅ autocomplete
|
|
98
|
+
* Button.footer // ✅ autocomplete
|
|
99
|
+
* Button.xyz // ❌ TypeScript error
|
|
100
|
+
*/
|
|
101
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS>;
|
|
84
102
|
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S>>;
|
|
85
103
|
} & SubComponentKeys<S>;
|
|
86
104
|
interface TwSubComponent<P = unknown> {
|
|
@@ -88,9 +106,9 @@ interface TwSubComponent<P = unknown> {
|
|
|
88
106
|
displayName?: string;
|
|
89
107
|
}
|
|
90
108
|
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
91
|
-
<const T extends string>(strings: readonly [T
|
|
109
|
+
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>>;
|
|
92
110
|
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
93
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C,
|
|
111
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>>;
|
|
94
112
|
}
|
|
95
113
|
type TwTagFactory = {
|
|
96
114
|
[K in HtmlTagName]: TwTemplateFactory;
|
|
@@ -155,6 +173,12 @@ interface ContainerQueryResult {
|
|
|
155
173
|
hasContainer: true;
|
|
156
174
|
}
|
|
157
175
|
declare function processContainer(tag: string, container: ContainerConfig, containerName?: string): ContainerQueryResult;
|
|
176
|
+
/**
|
|
177
|
+
* Generate @container CSS rules dari breakpoint config.
|
|
178
|
+
*
|
|
179
|
+
* Native-first: Rust string building tanpa intermediate allocations.
|
|
180
|
+
* JS fallback: `buildContainerRules()` loop.
|
|
181
|
+
*/
|
|
158
182
|
declare function generateContainerCss(tag: string, container: ContainerConfig, containerName?: string): string;
|
|
159
183
|
declare function getContainerRegistry(): Map<string, ContainerEntry>;
|
|
160
184
|
|
|
@@ -163,13 +187,13 @@ declare function createComponent<P extends object = Record<string, unknown>>(tag
|
|
|
163
187
|
/**
|
|
164
188
|
* tailwind-styled-v4 — cv()
|
|
165
189
|
*
|
|
166
|
-
* Runtime:
|
|
190
|
+
* Runtime: native-first with fallback to generated variant tables.
|
|
167
191
|
*
|
|
168
192
|
* Dua mode:
|
|
169
193
|
* 1. GENERATED (optimal) — import dari variants.generated.ts hasil `npx tw compile-variants`
|
|
170
194
|
* → O(1) lookup, static, zero runtime computation
|
|
171
|
-
* 2. RUNTIME (fallback) — compute on-the-fly
|
|
172
|
-
* →
|
|
195
|
+
* 2. RUNTIME (fallback) — compute on-the-fly via native binding
|
|
196
|
+
* → Requires native Rust binding for variant resolution
|
|
173
197
|
*/
|
|
174
198
|
|
|
175
199
|
declare function cv<C extends ComponentConfig>(config: C, componentId?: string): CvFn<C>;
|
|
@@ -177,39 +201,32 @@ declare function cv<C extends ComponentConfig>(config: C, componentId?: string):
|
|
|
177
201
|
/**
|
|
178
202
|
* tailwind-styled-v4 v2 — cx / cn
|
|
179
203
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* cxm() → twMerge, correct — but obscure name
|
|
185
|
-
*
|
|
186
|
-
* AFTER:
|
|
187
|
-
* cn() → simple join (for cases where you know there's no conflict)
|
|
188
|
-
* cx() → twMerge-powered, conflict-aware (recommended for most use cases)
|
|
189
|
-
* cxm() → kept as alias for cx() for backward compat
|
|
204
|
+
* Native-first:
|
|
205
|
+
* cn() → simple join (no conflict resolution) — delegates ke Rust `resolve_class_names`
|
|
206
|
+
* cx() → conflict-aware merge — delegates ke Rust `tw_merge` (required)
|
|
207
|
+
* cxm() → alias cx() untuk backward compat
|
|
190
208
|
*/
|
|
191
209
|
type ClassValue = string | undefined | null | false | 0;
|
|
192
210
|
/**
|
|
193
211
|
* cn — simple class name joiner (no conflict resolution).
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* FIX #09: Previously named `cx`. Renamed to `cn` for clarity.
|
|
212
|
+
* Native-first: delegates ke Rust `resolve_class_names` yang filter+join
|
|
213
|
+
* dalam satu pass tanpa intermediate allocations.
|
|
197
214
|
*
|
|
198
215
|
* @example cn("p-4", isActive && "opacity-100") → "p-4 opacity-100"
|
|
199
216
|
*/
|
|
200
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
217
|
+
declare function cn(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
201
218
|
/**
|
|
202
|
-
* cx — conflict-aware class merger
|
|
203
|
-
*
|
|
219
|
+
* cx — conflict-aware class merger.
|
|
220
|
+
* Native-first: delegates ke Rust `tw_merge` (required).
|
|
221
|
+
* Mendukung array inputs — flatten sebelum di-pass ke native.
|
|
204
222
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* @example cx("
|
|
208
|
-
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
|
223
|
+
* @example cx("p-4 p-8") → "p-8"
|
|
224
|
+
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
|
225
|
+
* @example cx(["flex", "items-center"], "px-4") → "flex items-center px-4"
|
|
209
226
|
*/
|
|
210
|
-
declare function cx(...inputs: ClassValue[]): string;
|
|
227
|
+
declare function cx(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
211
228
|
/**
|
|
212
|
-
* cxm — alias
|
|
229
|
+
* cxm — alias untuk cx(), kept for backward compatibility.
|
|
213
230
|
* @deprecated Use cx() instead.
|
|
214
231
|
*/
|
|
215
232
|
declare const cxm: typeof cx;
|
|
@@ -223,11 +240,25 @@ interface ThemeConfig$1 {
|
|
|
223
240
|
raw: Record<string, string>;
|
|
224
241
|
}
|
|
225
242
|
|
|
243
|
+
/**
|
|
244
|
+
* tailwind-styled-v4 — createTwMerge()
|
|
245
|
+
*
|
|
246
|
+
* Native-only: uses Rust `tw_merge_many`; requires native binding.
|
|
247
|
+
* No JS fallback — tailwind-merge removed from bundle.
|
|
248
|
+
*/
|
|
249
|
+
|
|
226
250
|
interface MergeOptions {
|
|
227
251
|
prefix?: string;
|
|
228
252
|
separator?: string;
|
|
229
253
|
theme?: ThemeConfig$1;
|
|
230
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* createTwMerge — returns a conflict-aware merge function.
|
|
257
|
+
* Native-only: uses Rust `tw_merge_many`; throws if native binding unavailable.
|
|
258
|
+
*
|
|
259
|
+
* Note: `prefix` and `separator` options are not supported in native mode
|
|
260
|
+
* (Tailwind v3/v4 defaults are used).
|
|
261
|
+
*/
|
|
231
262
|
declare function createTwMerge(_options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
|
|
232
263
|
declare const twMerge: (...classLists: Array<string | undefined | null | false>) => string;
|
|
233
264
|
declare function mergeWithRules(rules: Record<string, (classes: string[]) => string>, ...classLists: string[]): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { a as AnimateOptions } from './types-DXr2PmGP.js';
|
|
3
|
-
import { H as HtmlTagName } from './index-
|
|
4
|
-
export { T as TokenMap } from './index-
|
|
5
|
-
export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-
|
|
3
|
+
import { H as HtmlTagName } from './index-NDINUhLN.js';
|
|
4
|
+
export { T as TokenMap } from './index-NDINUhLN.js';
|
|
5
|
+
export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-CN9ian1R.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* tailwind-styled-v4 — Core Types
|
|
@@ -26,7 +26,12 @@ interface ComponentConfig {
|
|
|
26
26
|
state?: Record<string, Record<string, string>>;
|
|
27
27
|
container?: Record<string, string>;
|
|
28
28
|
containerName?: string;
|
|
29
|
+
/** Sub-component definitions — keys di-infer otomatis oleh TypeScript */
|
|
30
|
+
sub?: Record<string, string>;
|
|
29
31
|
}
|
|
32
|
+
type InferSubFromConfig<C extends ComponentConfig> = C extends {
|
|
33
|
+
sub: Record<infer K extends string, string>;
|
|
34
|
+
} ? K : never;
|
|
30
35
|
interface ContainerConfig {
|
|
31
36
|
base?: string;
|
|
32
37
|
queries?: Record<string, string>;
|
|
@@ -61,7 +66,7 @@ type TrimRight<S extends string> = S extends `${infer L} ` | `${infer L}
|
|
|
61
66
|
` | `${infer L} ` | `${infer L}
|
|
62
67
|
` ? TrimRight<L> : S;
|
|
63
68
|
type Trim<S extends string> = TrimLeft<TrimRight<S>>;
|
|
64
|
-
type ExtractSubNames<T extends string> = T extends `${
|
|
69
|
+
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;
|
|
65
70
|
type SubComponentKeys<S extends string> = string extends S ? {
|
|
66
71
|
[key: string]: TwSubComponentAccessor;
|
|
67
72
|
} : {
|
|
@@ -80,7 +85,20 @@ type TwStyledComponent<Config extends ComponentConfig = ComponentConfig, S exten
|
|
|
80
85
|
}): TwStyledComponent<Config, S>;
|
|
81
86
|
};
|
|
82
87
|
withVariants: (config: Partial<Config>) => TwStyledComponent<Config, S>;
|
|
83
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Declare sub-component names secara eksplisit untuk autocomplete + type safety.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* export const Button = tw.button`
|
|
93
|
+
* flex h-12 ...
|
|
94
|
+
* icon { flex h-4 }
|
|
95
|
+
* `.withSub<"icon" | "footer">()
|
|
96
|
+
*
|
|
97
|
+
* Button.icon // ✅ autocomplete
|
|
98
|
+
* Button.footer // ✅ autocomplete
|
|
99
|
+
* Button.xyz // ❌ TypeScript error
|
|
100
|
+
*/
|
|
101
|
+
withSub<NewS extends string>(): TwStyledComponent<Config, NewS>;
|
|
84
102
|
animate: (opts: AnimateOptions) => Promise<TwStyledComponent<Config, S>>;
|
|
85
103
|
} & SubComponentKeys<S>;
|
|
86
104
|
interface TwSubComponent<P = unknown> {
|
|
@@ -88,9 +106,9 @@ interface TwSubComponent<P = unknown> {
|
|
|
88
106
|
displayName?: string;
|
|
89
107
|
}
|
|
90
108
|
interface TwTemplateFactory<Config extends ComponentConfig = ComponentConfig> {
|
|
91
|
-
<const T extends string>(strings: readonly [T
|
|
109
|
+
<const T extends string>(strings: readonly [T], ...exprs: []): TwStyledComponent<Config, ExtractSubNames<T>>;
|
|
92
110
|
(strings: TemplateStringsArray, ...exprs: unknown[]): TwStyledComponent<Config, string>;
|
|
93
|
-
<C extends ComponentConfig>(config: C): TwStyledComponent<C,
|
|
111
|
+
<C extends ComponentConfig>(config: C): TwStyledComponent<C, InferSubFromConfig<C>>;
|
|
94
112
|
}
|
|
95
113
|
type TwTagFactory = {
|
|
96
114
|
[K in HtmlTagName]: TwTemplateFactory;
|
|
@@ -155,6 +173,12 @@ interface ContainerQueryResult {
|
|
|
155
173
|
hasContainer: true;
|
|
156
174
|
}
|
|
157
175
|
declare function processContainer(tag: string, container: ContainerConfig, containerName?: string): ContainerQueryResult;
|
|
176
|
+
/**
|
|
177
|
+
* Generate @container CSS rules dari breakpoint config.
|
|
178
|
+
*
|
|
179
|
+
* Native-first: Rust string building tanpa intermediate allocations.
|
|
180
|
+
* JS fallback: `buildContainerRules()` loop.
|
|
181
|
+
*/
|
|
158
182
|
declare function generateContainerCss(tag: string, container: ContainerConfig, containerName?: string): string;
|
|
159
183
|
declare function getContainerRegistry(): Map<string, ContainerEntry>;
|
|
160
184
|
|
|
@@ -163,13 +187,13 @@ declare function createComponent<P extends object = Record<string, unknown>>(tag
|
|
|
163
187
|
/**
|
|
164
188
|
* tailwind-styled-v4 — cv()
|
|
165
189
|
*
|
|
166
|
-
* Runtime:
|
|
190
|
+
* Runtime: native-first with fallback to generated variant tables.
|
|
167
191
|
*
|
|
168
192
|
* Dua mode:
|
|
169
193
|
* 1. GENERATED (optimal) — import dari variants.generated.ts hasil `npx tw compile-variants`
|
|
170
194
|
* → O(1) lookup, static, zero runtime computation
|
|
171
|
-
* 2. RUNTIME (fallback) — compute on-the-fly
|
|
172
|
-
* →
|
|
195
|
+
* 2. RUNTIME (fallback) — compute on-the-fly via native binding
|
|
196
|
+
* → Requires native Rust binding for variant resolution
|
|
173
197
|
*/
|
|
174
198
|
|
|
175
199
|
declare function cv<C extends ComponentConfig>(config: C, componentId?: string): CvFn<C>;
|
|
@@ -177,39 +201,32 @@ declare function cv<C extends ComponentConfig>(config: C, componentId?: string):
|
|
|
177
201
|
/**
|
|
178
202
|
* tailwind-styled-v4 v2 — cx / cn
|
|
179
203
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* cxm() → twMerge, correct — but obscure name
|
|
185
|
-
*
|
|
186
|
-
* AFTER:
|
|
187
|
-
* cn() → simple join (for cases where you know there's no conflict)
|
|
188
|
-
* cx() → twMerge-powered, conflict-aware (recommended for most use cases)
|
|
189
|
-
* cxm() → kept as alias for cx() for backward compat
|
|
204
|
+
* Native-first:
|
|
205
|
+
* cn() → simple join (no conflict resolution) — delegates ke Rust `resolve_class_names`
|
|
206
|
+
* cx() → conflict-aware merge — delegates ke Rust `tw_merge` (required)
|
|
207
|
+
* cxm() → alias cx() untuk backward compat
|
|
190
208
|
*/
|
|
191
209
|
type ClassValue = string | undefined | null | false | 0;
|
|
192
210
|
/**
|
|
193
211
|
* cn — simple class name joiner (no conflict resolution).
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* FIX #09: Previously named `cx`. Renamed to `cn` for clarity.
|
|
212
|
+
* Native-first: delegates ke Rust `resolve_class_names` yang filter+join
|
|
213
|
+
* dalam satu pass tanpa intermediate allocations.
|
|
197
214
|
*
|
|
198
215
|
* @example cn("p-4", isActive && "opacity-100") → "p-4 opacity-100"
|
|
199
216
|
*/
|
|
200
|
-
declare function cn(...inputs: ClassValue[]): string;
|
|
217
|
+
declare function cn(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
201
218
|
/**
|
|
202
|
-
* cx — conflict-aware class merger
|
|
203
|
-
*
|
|
219
|
+
* cx — conflict-aware class merger.
|
|
220
|
+
* Native-first: delegates ke Rust `tw_merge` (required).
|
|
221
|
+
* Mendukung array inputs — flatten sebelum di-pass ke native.
|
|
204
222
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* @example cx("
|
|
208
|
-
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
|
223
|
+
* @example cx("p-4 p-8") → "p-8"
|
|
224
|
+
* @example cx("bg-red-500", "bg-blue-500") → "bg-blue-500"
|
|
225
|
+
* @example cx(["flex", "items-center"], "px-4") → "flex items-center px-4"
|
|
209
226
|
*/
|
|
210
|
-
declare function cx(...inputs: ClassValue[]): string;
|
|
227
|
+
declare function cx(...inputs: (ClassValue | ClassValue[])[]): string;
|
|
211
228
|
/**
|
|
212
|
-
* cxm — alias
|
|
229
|
+
* cxm — alias untuk cx(), kept for backward compatibility.
|
|
213
230
|
* @deprecated Use cx() instead.
|
|
214
231
|
*/
|
|
215
232
|
declare const cxm: typeof cx;
|
|
@@ -223,11 +240,25 @@ interface ThemeConfig$1 {
|
|
|
223
240
|
raw: Record<string, string>;
|
|
224
241
|
}
|
|
225
242
|
|
|
243
|
+
/**
|
|
244
|
+
* tailwind-styled-v4 — createTwMerge()
|
|
245
|
+
*
|
|
246
|
+
* Native-only: uses Rust `tw_merge_many`; requires native binding.
|
|
247
|
+
* No JS fallback — tailwind-merge removed from bundle.
|
|
248
|
+
*/
|
|
249
|
+
|
|
226
250
|
interface MergeOptions {
|
|
227
251
|
prefix?: string;
|
|
228
252
|
separator?: string;
|
|
229
253
|
theme?: ThemeConfig$1;
|
|
230
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* createTwMerge — returns a conflict-aware merge function.
|
|
257
|
+
* Native-only: uses Rust `tw_merge_many`; throws if native binding unavailable.
|
|
258
|
+
*
|
|
259
|
+
* Note: `prefix` and `separator` options are not supported in native mode
|
|
260
|
+
* (Tailwind v3/v4 defaults are used).
|
|
261
|
+
*/
|
|
231
262
|
declare function createTwMerge(_options?: MergeOptions): (...classLists: Array<string | undefined | null | false>) => string;
|
|
232
263
|
declare const twMerge: (...classLists: Array<string | undefined | null | false>) => string;
|
|
233
264
|
declare function mergeWithRules(rules: Record<string, (classes: string[]) => string>, ...classLists: string[]): string;
|