@kbach/ui 0.1.0-beta.2 → 0.1.0-beta.4
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/KBACH.md +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1 -0
- package/dist/index.mjs +2 -0
- package/dist/vite-plugin.js +5 -2
- package/dist/vite-plugin.mjs +5 -2
- package/package.json +1 -1
package/KBACH.md
CHANGED
|
@@ -32,7 +32,7 @@ export default { plugins: [react({ jsxImportSource: '@kbach/ui' })] };
|
|
|
32
32
|
import { ThemeProvider, KbachReset } from '@kbach/ui';
|
|
33
33
|
<ThemeProvider defaultMode="system"><KbachReset /><App /></ThemeProvider>
|
|
34
34
|
```
|
|
35
|
-
`<KbachReset />` renders Kbach's base browser-default reset (borderless button/input, visible checkbox/radio, no arrow-less `<select>`, `a`/`h1-h6`/`p`/`ul`/`ol`/`img` normalized, etc.) as a real `<style>` tag — needed for SSR under runtime-only setups (no JS runs server-side, but this is just JSX so it still renders), a no-op-but-harmless nice-to-have for plain CSR.
|
|
35
|
+
`<KbachReset />` renders Kbach's base browser-default reset (borderless button/input, visible checkbox/radio, no arrow-less `<select>`, `a`/`h1-h6`/`p`/`ul`/`ol`/`img` normalized, etc.) as a real `<style>` tag — needed for SSR under runtime-only setups (no JS runs server-side, but this is just JSX so it still renders), a no-op-but-harmless nice-to-have for plain CSR. Not needed if using static `kbach.css` (below) — that file already includes the same reset. `<KbachReset />` checks `disableRuntimeCSS()` (which the Vite plugin calls automatically wherever `kbach.css` gets imported) and renders nothing once it's active, so leaving it mounted alongside the static setup is safe rather than a duplicate reset on every page load.
|
|
36
36
|
|
|
37
37
|
### Next.js
|
|
38
38
|
- tsconfig `jsxImportSource` setup above applies as-is (SWC reads it like Vite does).
|
package/dist/index.d.ts
CHANGED
|
@@ -167,9 +167,16 @@ declare function ThemeProvider({ children, defaultMode, colorScheme, windowWidth
|
|
|
167
167
|
* hydration catches up. Render this once, as high in <head> as your
|
|
168
168
|
* framework allows, to close that gap.
|
|
169
169
|
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
170
|
+
* Skips rendering entirely once disableRuntimeCSS() has fired — the Vite
|
|
171
|
+
* plugin calls it automatically wherever kbach.css gets imported (see
|
|
172
|
+
* vite-plugin.ts's transform hook), and that static file already inlines
|
|
173
|
+
* this exact reset. Previously this rendered unconditionally regardless of
|
|
174
|
+
* that flag, so an app using the static-CSS setup that ALSO keeps
|
|
175
|
+
* <KbachReset/> mounted (e.g. copied from a starter template's root layout
|
|
176
|
+
* and never revisited) got the same reset rules twice — once from the
|
|
177
|
+
* static file, once from this tag — on every single page load, real static
|
|
178
|
+
* CSS or not. Checked here (render time), not just documented, so the
|
|
179
|
+
* static setup is actually leak-free even when this stays in the tree.
|
|
173
180
|
*/
|
|
174
181
|
declare function KbachReset(): React.JSX.Element | null;
|
|
175
182
|
|
package/dist/index.js
CHANGED
|
@@ -383,6 +383,7 @@ var import_core4 = require("./core");
|
|
|
383
383
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
384
384
|
function KbachReset() {
|
|
385
385
|
if (import_core4.isNative) return null;
|
|
386
|
+
if ((0, import_core4.isRuntimeCSSDisabled)()) return null;
|
|
386
387
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { id: import_core4.RESET_STYLE_ID, children: import_core4.BASE_RESET });
|
|
387
388
|
}
|
|
388
389
|
|
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
initConfig,
|
|
27
27
|
isModeAwareColor,
|
|
28
28
|
isNative,
|
|
29
|
+
isRuntimeCSSDisabled,
|
|
29
30
|
isWeb,
|
|
30
31
|
kbachWarn,
|
|
31
32
|
normalizeClassString,
|
|
@@ -354,6 +355,7 @@ function ThemeProvider({
|
|
|
354
355
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
355
356
|
function KbachReset() {
|
|
356
357
|
if (isNative) return null;
|
|
358
|
+
if (isRuntimeCSSDisabled()) return null;
|
|
357
359
|
return /* @__PURE__ */ jsx2("style", { id: RESET_STYLE_ID, children: BASE_RESET });
|
|
358
360
|
}
|
|
359
361
|
|
package/dist/vite-plugin.js
CHANGED
|
@@ -3577,9 +3577,12 @@ function formatKbachCSS(tokenCSS, theme, responsiveRe) {
|
|
|
3577
3577
|
const replacements = new Map([...colorVars.replacements, ...spacingVars.replacements]);
|
|
3578
3578
|
const declarations = new Map([...colorVars.declarations, ...spacingVars.declarations]);
|
|
3579
3579
|
const sortedReplacements = [...replacements].sort(([a], [b]) => b.length - a.length);
|
|
3580
|
+
const varPatternRes = sortedReplacements.map(
|
|
3581
|
+
([pattern, replacement]) => [new RegExp(`(?<!\\\\)${pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "g"), replacement]
|
|
3582
|
+
);
|
|
3580
3583
|
function applyVars(css) {
|
|
3581
|
-
for (const [
|
|
3582
|
-
css = css.
|
|
3584
|
+
for (const [re, replacement] of varPatternRes)
|
|
3585
|
+
css = css.replace(re, () => replacement);
|
|
3583
3586
|
return css;
|
|
3584
3587
|
}
|
|
3585
3588
|
const groups = new Map(GROUP_ORDER.map((g) => [g, []]));
|
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, []]));
|