@kbach/ui 0.1.0-beta.3 → 0.1.0-beta.5
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.ts +8 -8
- package/dist/vite-plugin.d.mts +2 -1
- package/dist/vite-plugin.d.ts +2 -1
- package/dist/vite-plugin.js +24 -2
- package/dist/vite-plugin.mjs +23 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -191,8 +191,8 @@ type OmittedKeys = 'style';
|
|
|
191
191
|
* Create a styled component from any React / React Native component.
|
|
192
192
|
*
|
|
193
193
|
* ```tsx
|
|
194
|
-
* const Card = styled(View, 'bg-white dark:bg-gray-
|
|
195
|
-
* const Button = styled(TouchableOpacity, 'bg-blue-
|
|
194
|
+
* const Card = styled(View, 'bg-white dark:bg-gray-9 rounded-xl p-4 shadow-md');
|
|
195
|
+
* const Button = styled(TouchableOpacity, 'bg-blue-6 pressed:bg-blue-8 dark:bg-blue-7 rounded-lg p-3');
|
|
196
196
|
*
|
|
197
197
|
* // Use it:
|
|
198
198
|
* <Card kb="mt-4">...</Card>
|
|
@@ -217,14 +217,14 @@ interface InteractionState {
|
|
|
217
217
|
*
|
|
218
218
|
* ```tsx
|
|
219
219
|
* // Basic usage
|
|
220
|
-
* const styles = useStyles('bg-white dark:bg-gray-
|
|
220
|
+
* const styles = useStyles('bg-white dark:bg-gray-9 p-4');
|
|
221
221
|
*
|
|
222
222
|
* // With interaction state
|
|
223
223
|
* const [pressed, setPressed] = useState(false);
|
|
224
|
-
* const styles = useStyles('bg-blue-
|
|
224
|
+
* const styles = useStyles('bg-blue-6 pressed:bg-blue-8', { pressed });
|
|
225
225
|
*
|
|
226
226
|
* // Multiple class strings (merged left-to-right)
|
|
227
|
-
* const styles = useStyles(['bg-white p-4', 'dark:bg-gray-
|
|
227
|
+
* const styles = useStyles(['bg-white p-4', 'dark:bg-gray-9 rounded-xl']);
|
|
228
228
|
* ```
|
|
229
229
|
*/
|
|
230
230
|
declare function useStyles(classString: string | string[], state?: InteractionState): StyleValue;
|
|
@@ -309,7 +309,7 @@ declare const InteractiveWrapper: React__default.ForwardRefExoticComponent<Inter
|
|
|
309
309
|
* });
|
|
310
310
|
*
|
|
311
311
|
* // Web: use as className
|
|
312
|
-
* <div className={kb('bg-white dark:bg-gray-
|
|
312
|
+
* <div className={kb('bg-white dark:bg-gray-9 p-4') as string} />
|
|
313
313
|
* ```
|
|
314
314
|
*
|
|
315
315
|
* @param classString Space-separated utility classes
|
|
@@ -320,8 +320,8 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
|
|
|
320
320
|
* Conditionally join class names. Falsy values are ignored.
|
|
321
321
|
*
|
|
322
322
|
* ```ts
|
|
323
|
-
* cx('bg-white p-4', isActive && 'border-2 border-blue-
|
|
324
|
-
* // → 'bg-white p-4 border-2 border-blue-
|
|
323
|
+
* cx('bg-white p-4', isActive && 'border-2 border-blue-6', undefined)
|
|
324
|
+
* // → 'bg-white p-4 border-2 border-blue-6'
|
|
325
325
|
* ```
|
|
326
326
|
*/
|
|
327
327
|
declare function cx(...classes: Array<string | false | null | undefined>): string;
|
package/dist/vite-plugin.d.mts
CHANGED
|
@@ -145,6 +145,7 @@ interface FrameworkConfig {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
declare function formatKbachCSS(tokenCSS: Map<string, string>, theme: ThemeConfig, responsiveRe: RegExp): string;
|
|
148
|
+
declare function extractClassStrings(code: string): string[];
|
|
148
149
|
interface KbachPluginOptions {
|
|
149
150
|
framework?: FrameworkConfig;
|
|
150
151
|
/** Directories to scan for class strings (relative to Vite root). Defaults to common source dirs. */
|
|
@@ -152,4 +153,4 @@ interface KbachPluginOptions {
|
|
|
152
153
|
}
|
|
153
154
|
declare function kbach(userConfigOrOptions?: FrameworkConfig | KbachPluginOptions): Plugin;
|
|
154
155
|
|
|
155
|
-
export { type KbachPluginOptions, formatKbachCSS, kbach };
|
|
156
|
+
export { type KbachPluginOptions, extractClassStrings, formatKbachCSS, kbach };
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -145,6 +145,7 @@ interface FrameworkConfig {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
declare function formatKbachCSS(tokenCSS: Map<string, string>, theme: ThemeConfig, responsiveRe: RegExp): string;
|
|
148
|
+
declare function extractClassStrings(code: string): string[];
|
|
148
149
|
interface KbachPluginOptions {
|
|
149
150
|
framework?: FrameworkConfig;
|
|
150
151
|
/** Directories to scan for class strings (relative to Vite root). Defaults to common source dirs. */
|
|
@@ -152,4 +153,4 @@ interface KbachPluginOptions {
|
|
|
152
153
|
}
|
|
153
154
|
declare function kbach(userConfigOrOptions?: FrameworkConfig | KbachPluginOptions): Plugin;
|
|
154
155
|
|
|
155
|
-
export { type KbachPluginOptions, formatKbachCSS, kbach };
|
|
156
|
+
export { type KbachPluginOptions, extractClassStrings, formatKbachCSS, kbach };
|
package/dist/vite-plugin.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/vite-plugin.ts
|
|
31
31
|
var vite_plugin_exports = {};
|
|
32
32
|
__export(vite_plugin_exports, {
|
|
33
|
+
extractClassStrings: () => extractClassStrings,
|
|
33
34
|
formatKbachCSS: () => formatKbachCSS,
|
|
34
35
|
kbach: () => kbach
|
|
35
36
|
});
|
|
@@ -3577,9 +3578,12 @@ function formatKbachCSS(tokenCSS, theme, responsiveRe) {
|
|
|
3577
3578
|
const replacements = new Map([...colorVars.replacements, ...spacingVars.replacements]);
|
|
3578
3579
|
const declarations = new Map([...colorVars.declarations, ...spacingVars.declarations]);
|
|
3579
3580
|
const sortedReplacements = [...replacements].sort(([a], [b]) => b.length - a.length);
|
|
3581
|
+
const varPatternRes = sortedReplacements.map(
|
|
3582
|
+
([pattern, replacement]) => [new RegExp(`(?<!\\\\)${pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g"), replacement]
|
|
3583
|
+
);
|
|
3580
3584
|
function applyVars(css) {
|
|
3581
|
-
for (const [
|
|
3582
|
-
css = css.
|
|
3585
|
+
for (const [re, replacement] of varPatternRes)
|
|
3586
|
+
css = css.replace(re, () => replacement);
|
|
3583
3587
|
return css;
|
|
3584
3588
|
}
|
|
3585
3589
|
const groups = new Map(GROUP_ORDER.map((g) => [g, []]));
|
|
@@ -3770,6 +3774,23 @@ function extractClassStrings(code) {
|
|
|
3770
3774
|
clsxCallRe.lastIndex = i + 1;
|
|
3771
3775
|
pushClassLikeStrings(block, found);
|
|
3772
3776
|
}
|
|
3777
|
+
const styledCallRe = /\bstyled\(/g;
|
|
3778
|
+
while ((m = styledCallRe.exec(code)) !== null) {
|
|
3779
|
+
let depth = 1;
|
|
3780
|
+
let i = m.index + m[0].length;
|
|
3781
|
+
let block = "";
|
|
3782
|
+
while (i < code.length && depth > 0) {
|
|
3783
|
+
const ch = code[i];
|
|
3784
|
+
if (ch === "(") depth++;
|
|
3785
|
+
else if (ch === ")") {
|
|
3786
|
+
if (--depth === 0) break;
|
|
3787
|
+
}
|
|
3788
|
+
block += ch;
|
|
3789
|
+
i++;
|
|
3790
|
+
}
|
|
3791
|
+
styledCallRe.lastIndex = i + 1;
|
|
3792
|
+
pushClassLikeStrings(block, found);
|
|
3793
|
+
}
|
|
3773
3794
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
3774
3795
|
while ((m = templateRe.exec(code)) !== null) pushTemplateLiteralBody(m[1], found);
|
|
3775
3796
|
return [...found];
|
|
@@ -4024,6 +4045,7 @@ ${code}`,
|
|
|
4024
4045
|
}
|
|
4025
4046
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4026
4047
|
0 && (module.exports = {
|
|
4048
|
+
extractClassStrings,
|
|
4027
4049
|
formatKbachCSS,
|
|
4028
4050
|
kbach
|
|
4029
4051
|
});
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -3542,9 +3542,12 @@ function formatKbachCSS(tokenCSS, theme, responsiveRe) {
|
|
|
3542
3542
|
const replacements = new Map([...colorVars.replacements, ...spacingVars.replacements]);
|
|
3543
3543
|
const declarations = new Map([...colorVars.declarations, ...spacingVars.declarations]);
|
|
3544
3544
|
const sortedReplacements = [...replacements].sort(([a], [b]) => b.length - a.length);
|
|
3545
|
+
const varPatternRes = sortedReplacements.map(
|
|
3546
|
+
([pattern, replacement]) => [new RegExp(`(?<!\\\\)${pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g"), replacement]
|
|
3547
|
+
);
|
|
3545
3548
|
function applyVars(css) {
|
|
3546
|
-
for (const [
|
|
3547
|
-
css = css.
|
|
3549
|
+
for (const [re, replacement] of varPatternRes)
|
|
3550
|
+
css = css.replace(re, () => replacement);
|
|
3548
3551
|
return css;
|
|
3549
3552
|
}
|
|
3550
3553
|
const groups = new Map(GROUP_ORDER.map((g) => [g, []]));
|
|
@@ -3735,6 +3738,23 @@ function extractClassStrings(code) {
|
|
|
3735
3738
|
clsxCallRe.lastIndex = i + 1;
|
|
3736
3739
|
pushClassLikeStrings(block, found);
|
|
3737
3740
|
}
|
|
3741
|
+
const styledCallRe = /\bstyled\(/g;
|
|
3742
|
+
while ((m = styledCallRe.exec(code)) !== null) {
|
|
3743
|
+
let depth = 1;
|
|
3744
|
+
let i = m.index + m[0].length;
|
|
3745
|
+
let block = "";
|
|
3746
|
+
while (i < code.length && depth > 0) {
|
|
3747
|
+
const ch = code[i];
|
|
3748
|
+
if (ch === "(") depth++;
|
|
3749
|
+
else if (ch === ")") {
|
|
3750
|
+
if (--depth === 0) break;
|
|
3751
|
+
}
|
|
3752
|
+
block += ch;
|
|
3753
|
+
i++;
|
|
3754
|
+
}
|
|
3755
|
+
styledCallRe.lastIndex = i + 1;
|
|
3756
|
+
pushClassLikeStrings(block, found);
|
|
3757
|
+
}
|
|
3738
3758
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
3739
3759
|
while ((m = templateRe.exec(code)) !== null) pushTemplateLiteralBody(m[1], found);
|
|
3740
3760
|
return [...found];
|
|
@@ -3988,6 +4008,7 @@ ${code}`,
|
|
|
3988
4008
|
};
|
|
3989
4009
|
}
|
|
3990
4010
|
export {
|
|
4011
|
+
extractClassStrings,
|
|
3991
4012
|
formatKbachCSS,
|
|
3992
4013
|
kbach
|
|
3993
4014
|
};
|