@kbach/react 0.6.51 → 1.0.0-beta.0

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.
@@ -0,0 +1,414 @@
1
+ // src/generatedPalette.ts
2
+ var PALETTE = {
3
+ "amber-1": "#fffbeb",
4
+ "amber-10": "#78350f",
5
+ "amber-11": "#451a03",
6
+ "amber-12": "#291002",
7
+ "amber-2": "#fef3c7",
8
+ "amber-3": "#fde68a",
9
+ "amber-4": "#fcd34d",
10
+ "amber-5": "#fbbf24",
11
+ "amber-6": "#f59e0b",
12
+ "amber-7": "#d97706",
13
+ "amber-8": "#b45309",
14
+ "amber-9": "#92400e",
15
+ "black": "#000000",
16
+ "blue-1": "#eff6ff",
17
+ "blue-10": "#1e3a8a",
18
+ "blue-11": "#172554",
19
+ "blue-12": "#0d1633",
20
+ "blue-2": "#dbeafe",
21
+ "blue-3": "#bfdbfe",
22
+ "blue-4": "#93c5fd",
23
+ "blue-5": "#60a5fa",
24
+ "blue-6": "#3b82f6",
25
+ "blue-7": "#2563eb",
26
+ "blue-8": "#1d4ed8",
27
+ "blue-9": "#1e40af",
28
+ "bronze": "#cd7f32",
29
+ "coal": "#1c1c1c",
30
+ "copper": "#b87333",
31
+ "current": "currentColor",
32
+ "cyan-1": "#ecfeff",
33
+ "cyan-10": "#164e63",
34
+ "cyan-11": "#083344",
35
+ "cyan-12": "#041e28",
36
+ "cyan-2": "#cffafe",
37
+ "cyan-3": "#a5f3fc",
38
+ "cyan-4": "#67e8f9",
39
+ "cyan-5": "#22d3ee",
40
+ "cyan-6": "#06b6d4",
41
+ "cyan-7": "#0891b2",
42
+ "cyan-8": "#0e7490",
43
+ "cyan-9": "#155e75",
44
+ "emerald-1": "#ecfdf5",
45
+ "emerald-10": "#064e3b",
46
+ "emerald-11": "#022c22",
47
+ "emerald-12": "#011a14",
48
+ "emerald-2": "#d1fae5",
49
+ "emerald-3": "#a7f3d0",
50
+ "emerald-4": "#6ee7b7",
51
+ "emerald-5": "#34d399",
52
+ "emerald-6": "#10b981",
53
+ "emerald-7": "#059669",
54
+ "emerald-8": "#047857",
55
+ "emerald-9": "#065f46",
56
+ "fuchsia-1": "#fdf4ff",
57
+ "fuchsia-10": "#701a75",
58
+ "fuchsia-11": "#4a044e",
59
+ "fuchsia-12": "#2d022f",
60
+ "fuchsia-2": "#fae8ff",
61
+ "fuchsia-3": "#f5d0fe",
62
+ "fuchsia-4": "#f0abfc",
63
+ "fuchsia-5": "#e879f9",
64
+ "fuchsia-6": "#d946ef",
65
+ "fuchsia-7": "#c026d3",
66
+ "fuchsia-8": "#a21caf",
67
+ "fuchsia-9": "#86198f",
68
+ "gold": "#d4af37",
69
+ "gray-1": "#f9fafb",
70
+ "gray-10": "#111827",
71
+ "gray-11": "#030712",
72
+ "gray-12": "#020409",
73
+ "gray-2": "#f3f4f6",
74
+ "gray-3": "#e5e7eb",
75
+ "gray-4": "#d1d5db",
76
+ "gray-5": "#9ca3af",
77
+ "gray-6": "#6b7280",
78
+ "gray-7": "#4b5563",
79
+ "gray-8": "#374151",
80
+ "gray-9": "#1f2937",
81
+ "green-1": "#f0fdf4",
82
+ "green-10": "#14532d",
83
+ "green-11": "#052e16",
84
+ "green-12": "#031b0d",
85
+ "green-2": "#dcfce7",
86
+ "green-3": "#bbf7d0",
87
+ "green-4": "#86efac",
88
+ "green-5": "#4ade80",
89
+ "green-6": "#22c55e",
90
+ "green-7": "#16a34a",
91
+ "green-8": "#15803d",
92
+ "green-9": "#166534",
93
+ "indigo-1": "#eef2ff",
94
+ "indigo-10": "#312e81",
95
+ "indigo-11": "#1e1b4b",
96
+ "indigo-12": "#12102d",
97
+ "indigo-2": "#e0e7ff",
98
+ "indigo-3": "#c7d2fe",
99
+ "indigo-4": "#a5b4fc",
100
+ "indigo-5": "#818cf8",
101
+ "indigo-6": "#6366f1",
102
+ "indigo-7": "#4f46e5",
103
+ "indigo-8": "#4338ca",
104
+ "indigo-9": "#3730a3",
105
+ "lime-1": "#f7fee7",
106
+ "lime-10": "#365314",
107
+ "lime-11": "#1a2e05",
108
+ "lime-12": "#0f1b03",
109
+ "lime-2": "#ecfccb",
110
+ "lime-3": "#d9f99d",
111
+ "lime-4": "#bef264",
112
+ "lime-5": "#a3e635",
113
+ "lime-6": "#84cc16",
114
+ "lime-7": "#65a30d",
115
+ "lime-8": "#4d7c0f",
116
+ "lime-9": "#3f6212",
117
+ "neutral-1": "#fafafa",
118
+ "neutral-10": "#171717",
119
+ "neutral-11": "#0a0a0a",
120
+ "neutral-12": "#050505",
121
+ "neutral-2": "#f5f5f5",
122
+ "neutral-3": "#e5e5e5",
123
+ "neutral-4": "#d4d4d4",
124
+ "neutral-5": "#a3a3a3",
125
+ "neutral-6": "#737373",
126
+ "neutral-7": "#525252",
127
+ "neutral-8": "#404040",
128
+ "neutral-9": "#262626",
129
+ "orange-1": "#fff7ed",
130
+ "orange-10": "#7c2d12",
131
+ "orange-11": "#431407",
132
+ "orange-12": "#270c04",
133
+ "orange-2": "#ffedd5",
134
+ "orange-3": "#fed7aa",
135
+ "orange-4": "#fdba74",
136
+ "orange-5": "#fb923c",
137
+ "orange-6": "#f97316",
138
+ "orange-7": "#ea580c",
139
+ "orange-8": "#c2410c",
140
+ "orange-9": "#9a3412",
141
+ "pink-1": "#fdf2f8",
142
+ "pink-10": "#831843",
143
+ "pink-11": "#500724",
144
+ "pink-12": "#300415",
145
+ "pink-2": "#fce7f3",
146
+ "pink-3": "#fbcfe8",
147
+ "pink-4": "#f9a8d4",
148
+ "pink-5": "#f472b6",
149
+ "pink-6": "#ec4899",
150
+ "pink-7": "#db2777",
151
+ "pink-8": "#be185d",
152
+ "pink-9": "#9d174d",
153
+ "purple-1": "#faf5ff",
154
+ "purple-10": "#581c87",
155
+ "purple-11": "#3b0764",
156
+ "purple-12": "#23043c",
157
+ "purple-2": "#f3e8ff",
158
+ "purple-3": "#e9d5ff",
159
+ "purple-4": "#d8b4fe",
160
+ "purple-5": "#c084fc",
161
+ "purple-6": "#a855f7",
162
+ "purple-7": "#9333ea",
163
+ "purple-8": "#7e22ce",
164
+ "purple-9": "#6b21a8",
165
+ "red-1": "#fef2f2",
166
+ "red-10": "#7f1d1d",
167
+ "red-11": "#450a0a",
168
+ "red-12": "#280606",
169
+ "red-2": "#fee2e2",
170
+ "red-3": "#fecaca",
171
+ "red-4": "#fca5a5",
172
+ "red-5": "#f87171",
173
+ "red-6": "#ef4444",
174
+ "red-7": "#dc2626",
175
+ "red-8": "#b91c1c",
176
+ "red-9": "#991b1b",
177
+ "rose-1": "#fff1f2",
178
+ "rose-10": "#881337",
179
+ "rose-11": "#4c0519",
180
+ "rose-12": "#2d030e",
181
+ "rose-2": "#ffe4e6",
182
+ "rose-3": "#fecdd3",
183
+ "rose-4": "#fda4af",
184
+ "rose-5": "#fb7185",
185
+ "rose-6": "#f43f5e",
186
+ "rose-7": "#e11d48",
187
+ "rose-8": "#be123c",
188
+ "rose-9": "#9f1239",
189
+ "silver": "#c0c0c0",
190
+ "sky-1": "#f0f9ff",
191
+ "sky-10": "#0c4a6e",
192
+ "sky-11": "#082f49",
193
+ "sky-12": "#041b2b",
194
+ "sky-2": "#e0f2fe",
195
+ "sky-3": "#bae6fd",
196
+ "sky-4": "#7dd3fc",
197
+ "sky-5": "#38bdf8",
198
+ "sky-6": "#0ea5e9",
199
+ "sky-7": "#0284c7",
200
+ "sky-8": "#0369a1",
201
+ "sky-9": "#075985",
202
+ "slate-1": "#f8fafc",
203
+ "slate-10": "#0f172a",
204
+ "slate-11": "#020617",
205
+ "slate-12": "#01020a",
206
+ "slate-2": "#f1f5f9",
207
+ "slate-3": "#e2e8f0",
208
+ "slate-4": "#cbd5e1",
209
+ "slate-5": "#94a3b8",
210
+ "slate-6": "#64748b",
211
+ "slate-7": "#475569",
212
+ "slate-8": "#334155",
213
+ "slate-9": "#1e293b",
214
+ "stone-1": "#fafaf9",
215
+ "stone-10": "#1c1917",
216
+ "stone-11": "#0c0a09",
217
+ "stone-12": "#070605",
218
+ "stone-2": "#f5f5f4",
219
+ "stone-3": "#e7e5e4",
220
+ "stone-4": "#d6d3d1",
221
+ "stone-5": "#a8a29e",
222
+ "stone-6": "#78716c",
223
+ "stone-7": "#57534e",
224
+ "stone-8": "#44403c",
225
+ "stone-9": "#292524",
226
+ "teal-1": "#f0fdfa",
227
+ "teal-10": "#134e4a",
228
+ "teal-11": "#042f2e",
229
+ "teal-12": "#021c1b",
230
+ "teal-2": "#ccfbf1",
231
+ "teal-3": "#99f6e4",
232
+ "teal-4": "#5eead4",
233
+ "teal-5": "#2dd4bf",
234
+ "teal-6": "#14b8a6",
235
+ "teal-7": "#0d9488",
236
+ "teal-8": "#0f766e",
237
+ "teal-9": "#115e59",
238
+ "transparent": "transparent",
239
+ "violet-1": "#f5f3ff",
240
+ "violet-10": "#4c1d95",
241
+ "violet-11": "#2e1065",
242
+ "violet-12": "#1c0a3d",
243
+ "violet-2": "#ede9fe",
244
+ "violet-3": "#ddd6fe",
245
+ "violet-4": "#c4b5fd",
246
+ "violet-5": "#a78bfa",
247
+ "violet-6": "#8b5cf6",
248
+ "violet-7": "#7c3aed",
249
+ "violet-8": "#6d28d9",
250
+ "violet-9": "#5b21b6",
251
+ "white": "#ffffff",
252
+ "yellow-1": "#fefce8",
253
+ "yellow-10": "#713f12",
254
+ "yellow-11": "#422006",
255
+ "yellow-12": "#271304",
256
+ "yellow-2": "#fef9c3",
257
+ "yellow-3": "#fef08a",
258
+ "yellow-4": "#fde047",
259
+ "yellow-5": "#facc15",
260
+ "yellow-6": "#eab308",
261
+ "yellow-7": "#ca8a04",
262
+ "yellow-8": "#a16207",
263
+ "yellow-9": "#854d0e",
264
+ "zinc-1": "#fafafa",
265
+ "zinc-10": "#18181b",
266
+ "zinc-11": "#09090b",
267
+ "zinc-12": "#050506",
268
+ "zinc-2": "#f4f4f5",
269
+ "zinc-3": "#e4e4e7",
270
+ "zinc-4": "#d4d4d8",
271
+ "zinc-5": "#a1a1aa",
272
+ "zinc-6": "#71717a",
273
+ "zinc-7": "#52525b",
274
+ "zinc-8": "#3f3f46",
275
+ "zinc-9": "#27272a"
276
+ };
277
+
278
+ // src/theme.ts
279
+ var defaultTheme = {
280
+ colors: {
281
+ ...PALETTE,
282
+ surface: { light: "#f9fafb", dark: "#111827" }
283
+ },
284
+ spacing: {
285
+ // "0" is always a hardcoded zero in real Tailwind's own scale too,
286
+ // regardless of the base spacing unit — needed for `p-0`/`m-0`/
287
+ // `top-0`/`inset-0`/etc., and specifically for `sticky top-0` (a
288
+ // sticky element needs an explicit offset to have any stick point at
289
+ // all; without one it behaves just like `relative`, no different from
290
+ // omitting `top-0` outright). Confirmed missing by hand: this
291
+ // sandbox's own header used `sticky top-0`, which silently never
292
+ // resolved (no "0" spacing key existed) until this was added.
293
+ "0": 0,
294
+ "1": 4,
295
+ "2": 8,
296
+ "4": 16,
297
+ "6": 24,
298
+ "8": 32
299
+ },
300
+ screens: {
301
+ sm: 640,
302
+ md: 768,
303
+ lg: 1024,
304
+ xl: 1280,
305
+ "2xl": 1536
306
+ },
307
+ darkMode: "attribute"
308
+ };
309
+ var activeTheme = defaultTheme;
310
+ var activeThemeJson = JSON.stringify(defaultTheme);
311
+ function setTheme(theme) {
312
+ activeTheme = theme;
313
+ activeThemeJson = JSON.stringify(theme);
314
+ }
315
+ function getTheme() {
316
+ return activeTheme;
317
+ }
318
+ function getThemeJson() {
319
+ return activeThemeJson;
320
+ }
321
+
322
+ // src/reset.ts
323
+ var RESET_STYLE_ID = "kbach-reset";
324
+ var RESET_RULES = [
325
+ // border-style: solid means border-N utilities show a visible border without an extra border-solid class.
326
+ // border-width: 0 keeps all elements borderless by default.
327
+ { css: "*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }" },
328
+ { css: "body { margin: 0; padding: 0; }" },
329
+ { css: "h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }", tags: ["h1", "h2", "h3", "h4", "h5", "h6"] },
330
+ { css: "p { margin: 0; }", tags: ["p"] },
331
+ { css: "a { color: inherit; text-decoration: none; }", tags: ["a"] },
332
+ { css: "ul, ol { margin: 0; padding: 0; list-style: none; }", tags: ["ul", "ol"] },
333
+ // svg here only covers a literal <svg> tag in JSX — an icon imported as
334
+ // a component (e.g. `<ArrowIcon />`) never appears as the text "svg" in
335
+ // source, so this rule won't be pulled in by that usage alone. Same
336
+ // caveat applies to every tag-gated rule below: detection is a literal
337
+ // source-text scan (see vite-plugin/scan.ts's scanUsedTags), not a real
338
+ // DOM/type check.
339
+ { css: "img, video, svg { display: block; max-width: 100%; }", tags: ["img", "video", "svg"] },
340
+ // appearance: none is deliberately NOT applied to checkbox/radio/select below —
341
+ // stripping it hides their native checkmark/arrow with nothing rendered in its
342
+ // place, leaving an invisible checkbox or an arrow-less <select> that looks like
343
+ // plain text. Text-like inputs, textarea, and button don't have that problem
344
+ // (their native chrome is just a skin around content utilities can fully
345
+ // restyle), so they keep the blank-canvas treatment.
346
+ // :where() wraps the :not() exclusions so they contribute ZERO specificity
347
+ // (unlike a bare `input:not([type='checkbox']):not([type='radio'])`, whose
348
+ // two :not([attr]) clauses each add a class-level specificity point — (0,2,1)
349
+ // total, MORE than any single utility class (0,1,0)). Without :where(), this
350
+ // reset's `color: inherit` always won the cascade over a text-* color
351
+ // utility applied directly to a <input>/<textarea> regardless of source
352
+ // order, since author rules only override on a tie or higher specificity —
353
+ // confirmed on a real app: a TextInput's own text color utility resolved
354
+ // and injected correctly, class and all, but silently never painted.
355
+ {
356
+ css: "input:where(:not([type='checkbox']):not([type='radio'])), textarea { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; line-height: inherit; }",
357
+ tags: ["input", "textarea"]
358
+ },
359
+ // Native checkbox/radio/range still get typography + spacing normalized, and
360
+ // accent-color re-themes their native indicator to the current text color
361
+ // instead of the browser/OS default blue, so they stay on-brand without
362
+ // needing to be rebuilt from scratch. Wrapped in :where() for the exact
363
+ // same reason as the input:not(...) exclusions above — a bare
364
+ // `input[type='range']` attribute selector has specificity (0,1,1),
365
+ // MORE than any single utility class (0,1,0), so an `accent-*` utility
366
+ // (Phase 23) applied directly to a checkbox/radio/range would resolve and
367
+ // inject correctly but silently never paint, losing the cascade to this
368
+ // reset regardless of source order — confirmed by hand via
369
+ // getComputedStyle on a real `accent-red-6` range input, which reported
370
+ // `currentColor`'s inherited value instead. `:where()` zeroes this
371
+ // selector's specificity contribution entirely, so any `accent-*`
372
+ // utility trivially wins once applied.
373
+ {
374
+ css: ":where(input[type='checkbox'], input[type='radio'], input[type='range']) { margin: 0; font: inherit; accent-color: currentColor; }",
375
+ tags: ["input"]
376
+ },
377
+ // select keeps its native chrome (border/background/arrow are all part of the
378
+ // same OS-drawn widget that appearance: none would blank out) — only typography
379
+ // and spacing are normalized so it still matches surrounding text.
380
+ { css: "select { margin: 0; font: inherit; color: inherit; line-height: inherit; }", tags: ["select"] },
381
+ { css: "button { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; line-height: inherit; text-align: inherit; }", tags: ["button"] },
382
+ // Also covers any element opted into the button role (`role="button"` on
383
+ // a <div>/<span>) — but only when a literal <button> tag is ALSO
384
+ // somewhere in the scanned source, since detection here is purely
385
+ // tag-name-based; a project using role="button" exclusively, with no
386
+ // real <button> anywhere, won't pull this rule in. Acceptable tradeoff
387
+ // for this project's scope (rare pattern) — cheap enough that scanning
388
+ // for it separately isn't worth the added complexity.
389
+ { css: "button, [role='button'] { cursor: pointer; }", tags: ["button"] },
390
+ { css: ":disabled { cursor: default; }", tags: ["button", "input", "select", "textarea"] },
391
+ { css: "textarea { resize: vertical; }", tags: ["textarea"] },
392
+ // Firefox renders placeholders at ~54% opacity by default; every other browser uses 1 —
393
+ // normalize to 1 so placeholder color is consistent and fully controlled by the placeholder: modifier.
394
+ { css: "::placeholder { opacity: 1; }", tags: ["input", "textarea"] },
395
+ { css: "input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button { margin: 0; }", tags: ["input"] },
396
+ { css: "input[type='search']::-webkit-search-decoration, input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }", tags: ["input"] },
397
+ { css: "fieldset { padding: 0; margin: 0; }", tags: ["fieldset"] },
398
+ { css: "table { border-collapse: collapse; border-spacing: 0; }", tags: ["table"] }
399
+ ];
400
+ var BASE_RESET = RESET_RULES.map((r) => r.css).join("\n");
401
+ function buildResetCSS(usedTags) {
402
+ if (!usedTags) return BASE_RESET;
403
+ return RESET_RULES.filter((r) => !r.tags || r.tags.some((t) => usedTags.has(t))).map((r) => r.css).join("\n");
404
+ }
405
+
406
+ export {
407
+ defaultTheme,
408
+ setTheme,
409
+ getTheme,
410
+ getThemeJson,
411
+ RESET_STYLE_ID,
412
+ BASE_RESET,
413
+ buildResetCSS
414
+ };
@@ -0,0 +1,100 @@
1
+ import {
2
+ BASE_RESET,
3
+ RESET_STYLE_ID,
4
+ getThemeJson
5
+ } from "./chunk-AFY36PRX.mjs";
6
+
7
+ // src/wasmLoader.ts
8
+ import init, { generate_css as wasmGenerateCss } from "@kbach/core-engine";
9
+ var readyPromise = null;
10
+ var ready = false;
11
+ function initKbach() {
12
+ if (!readyPromise) {
13
+ readyPromise = init().then(() => {
14
+ ready = true;
15
+ });
16
+ }
17
+ return readyPromise;
18
+ }
19
+ function isKbachReady() {
20
+ return ready;
21
+ }
22
+ function generateCss(classString, themeJson) {
23
+ if (!ready) {
24
+ throw new Error(
25
+ "[kbach] generateCss() was called before initKbach() resolved. Call `await initKbach()` once at startup (e.g. before rendering your app) before using kb()."
26
+ );
27
+ }
28
+ return wasmGenerateCss(classString, themeJson);
29
+ }
30
+
31
+ // src/kb.ts
32
+ var runtimeCSSDisabled = false;
33
+ function disableRuntimeCSS() {
34
+ runtimeCSSDisabled = true;
35
+ }
36
+ function isRuntimeCSSDisabled() {
37
+ return runtimeCSSDisabled;
38
+ }
39
+ var styleEl = null;
40
+ var sheetKeys = [];
41
+ var ruleOrderByKey = /* @__PURE__ */ new Map();
42
+ function getStyleEl() {
43
+ if (styleEl) return styleEl;
44
+ styleEl = document.createElement("style");
45
+ styleEl.setAttribute("data-kbach", "");
46
+ document.head.appendChild(styleEl);
47
+ return styleEl;
48
+ }
49
+ function findInsertionIndex(order) {
50
+ let lo = 0;
51
+ let hi = sheetKeys.length;
52
+ while (lo < hi) {
53
+ const mid = lo + hi >>> 1;
54
+ if (ruleOrderByKey.get(sheetKeys[mid]) > order) hi = mid;
55
+ else lo = mid + 1;
56
+ }
57
+ return lo;
58
+ }
59
+ function injectRule(rule, order) {
60
+ if (ruleOrderByKey.has(rule)) return;
61
+ const sheet = getStyleEl().sheet;
62
+ if (!sheet) return;
63
+ const idx = findInsertionIndex(order);
64
+ try {
65
+ sheet.insertRule(rule, idx);
66
+ } catch {
67
+ return;
68
+ }
69
+ sheetKeys.splice(idx, 0, rule);
70
+ ruleOrderByKey.set(rule, order);
71
+ }
72
+ var resetChecked = false;
73
+ function ensureResetInjected() {
74
+ if (resetChecked) return;
75
+ resetChecked = true;
76
+ if (document.getElementById(RESET_STYLE_ID)) return;
77
+ const el = document.createElement("style");
78
+ el.id = RESET_STYLE_ID;
79
+ el.textContent = BASE_RESET;
80
+ document.head.insertBefore(el, document.head.firstChild);
81
+ }
82
+ function kb(classString) {
83
+ const json = generateCss(classString, getThemeJson());
84
+ const { className, rules } = JSON.parse(json);
85
+ if (!runtimeCSSDisabled) {
86
+ ensureResetInjected();
87
+ for (const { rule, order } of rules) {
88
+ injectRule(rule, order);
89
+ }
90
+ }
91
+ return className;
92
+ }
93
+
94
+ export {
95
+ initKbach,
96
+ isKbachReady,
97
+ disableRuntimeCSS,
98
+ isRuntimeCSSDisabled,
99
+ kb
100
+ };
@@ -0,0 +1,32 @@
1
+ import {
2
+ kb
3
+ } from "./chunk-G3RJJNSY.mjs";
4
+
5
+ // src/jsx-runtime.tsx
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ import { Fragment } from "react";
8
+ function makeElement(isStaticChildren, type, props, key) {
9
+ return (isStaticChildren ? _jsxs : _jsx)(type, props, key);
10
+ }
11
+ function processElement(type, rawProps, key, isStaticChildren) {
12
+ if (type === null || typeof type === "symbol" || !rawProps) {
13
+ return makeElement(isStaticChildren, type, rawProps ?? {}, key);
14
+ }
15
+ const { className: classStrRaw, ...rest } = rawProps;
16
+ if (typeof classStrRaw !== "string") {
17
+ return makeElement(isStaticChildren, type, rawProps, key);
18
+ }
19
+ return makeElement(isStaticChildren, type, { ...rest, className: kb(classStrRaw) }, key);
20
+ }
21
+ function jsx(type, props, key) {
22
+ return processElement(type, props, key, false);
23
+ }
24
+ function jsxs(type, props, key) {
25
+ return processElement(type, props, key, true);
26
+ }
27
+
28
+ export {
29
+ Fragment,
30
+ jsx,
31
+ jsxs
32
+ };
@@ -0,0 +1,117 @@
1
+ export { T as ThemeConfig, d as defaultTheme, g as getTheme, s as setTheme } from './theme-BKAb78KP.mjs';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * Loads and instantiates the Rust/WASM core engine. Call once at startup
7
+ * (e.g. before `ReactDOM.createRoot(...).render(...)`) and await it — every
8
+ * subsequent call returns the same memoized promise, so it's safe to call
9
+ * again from multiple entry points.
10
+ */
11
+ declare function initKbach(): Promise<void>;
12
+ declare function isKbachReady(): boolean;
13
+
14
+ declare function disableRuntimeCSS(): void;
15
+ declare function isRuntimeCSSDisabled(): boolean;
16
+ /**
17
+ * Resolves a Kbach class string via the Rust/WASM engine, cascade-order-safe
18
+ * injects the resulting CSS rules into a single `<style data-kbach>` tag,
19
+ * and returns the class string unchanged for use as `className`.
20
+ *
21
+ * Must be called after `await initKbach()` resolves — see wasmLoader.ts.
22
+ */
23
+ declare function kb(classString: string): string;
24
+
25
+ /**
26
+ * Renders Kbach's base browser-default reset (borderless button/input,
27
+ * visible checkbox/radio, no arrow-less <select>, etc.) as a plain <style>
28
+ * tag so it's part of the page's initial HTML.
29
+ *
30
+ * Runtime-only setups (no Vite plugin / static kbach.css) otherwise only get
31
+ * this reset once kb()'s first call injects it — fine for a plain CSR app,
32
+ * but under SSR the server has no JS to run it, so the first paint ships
33
+ * with raw browser defaults (e.g. the native button border) until
34
+ * hydration catches up. Render this once, as high in <head> as your
35
+ * framework allows, to close that gap.
36
+ *
37
+ * Skips rendering entirely once disableRuntimeCSS() has fired — the Vite
38
+ * plugin calls it automatically wherever kbach.css gets imported (see
39
+ * vite-plugin/format.ts's own BASE_RESET inlining), and that static file
40
+ * already has this exact reset. No isNative check (unlike old-kbach's
41
+ * version of this component): @kbach/react is a web-only package now, so
42
+ * there's no cross-platform import path for this component to guard against.
43
+ */
44
+ declare function KbachReset(): react.JSX.Element | null;
45
+
46
+ /**
47
+ * Port of old-kbach's dark-mode architecture (`packages/ui/src/core/
48
+ * darkModeStore.ts` + `ThemeProvider.tsx`), simplified for this package's
49
+ * web-only scope: a single module-level store is the actual source of
50
+ * truth, and `<ThemeProvider>`/`useTheme()` (see `ThemeProvider.tsx`) are a
51
+ * thin, OPTIONAL React wrapper around it — every function here works
52
+ * standalone, with no provider mounted anywhere, which is the whole point:
53
+ * a plain script, an event handler, or a component that never wants
54
+ * Context can call `toggleGlobalDarkMode()` directly.
55
+ */
56
+ type ThemeMode = 'light' | 'dark' | 'system';
57
+ declare function getGlobalDarkMode(): boolean;
58
+ declare function getGlobalThemeMode(): ThemeMode;
59
+ /** Explicit user choice — persisted, and takes priority over any later `<ThemeProvider defaultMode>` seed (see `seedDefaultMode` below). */
60
+ declare function setGlobalThemeMode(nextMode: ThemeMode): void;
61
+ declare function toggleGlobalDarkMode(): void;
62
+ declare function subscribeGlobalDarkMode(listener: () => void): () => void;
63
+
64
+ /**
65
+ * Reactive read of the global dark-mode store — works with or without a
66
+ * `<ThemeProvider>` mounted anywhere in the tree, since it subscribes to
67
+ * `darkModeStore.ts` directly. `useSyncExternalStore`'s SSR snapshot always
68
+ * returns `false` (light), matching `applyToDom`'s own server no-op — the
69
+ * server and the client's very first render agree, so there's no
70
+ * hydration-mismatch warning; the real value (if different) applies on the
71
+ * client immediately after.
72
+ */
73
+ declare function useGlobalDarkMode(): boolean;
74
+
75
+ interface ThemeProviderProps {
76
+ children: ReactNode;
77
+ /**
78
+ * Applied once, on this provider's first mount, but ONLY if the user has
79
+ * no persisted preference already (see `darkModeStore.ts::seedDefaultMode`)
80
+ * — an explicit prior choice always wins over a component's own default.
81
+ */
82
+ defaultMode?: ThemeMode;
83
+ }
84
+ /**
85
+ * Optional React Context wrapper around `darkModeStore.ts`'s single global
86
+ * store — port of old-kbach's `ThemeProvider` (`packages/ui/src/
87
+ * ThemeProvider.tsx`), same "provider is a thin wrapper around a global
88
+ * store, not the source of truth itself" shape, simplified to this
89
+ * package's web-only scope (no native `useColorScheme()`/`windowWidth`
90
+ * branch, no `disablePersistence` prop — persistence is always on, since
91
+ * `darkModeStore.ts` already guards every `localStorage` access for
92
+ * environments where it's unavailable).
93
+ *
94
+ * Because the store is global, MULTIPLE mounted providers share the exact
95
+ * same `mode`/`isDark` state rather than each getting their own scoped
96
+ * value — mounting more than one is very likely a mistake (each fighting
97
+ * over the same state via a different `defaultMode`), so this warns once
98
+ * in dev, matching old-kbach's identical guard.
99
+ */
100
+ declare function ThemeProvider({ children, defaultMode }: ThemeProviderProps): react.JSX.Element;
101
+
102
+ interface ThemeContextValue {
103
+ mode: ThemeMode;
104
+ isDark: boolean;
105
+ setMode: (mode: ThemeMode) => void;
106
+ toggle: () => void;
107
+ }
108
+ /**
109
+ * Requires a `<ThemeProvider>` ancestor — throws otherwise, since a
110
+ * component that destructures `{ mode, setMode }` genuinely needs Context
111
+ * (unlike a component that just wants the dark/light boolean, which should
112
+ * reach for `useGlobalDarkMode()` instead and never needs a provider at
113
+ * all).
114
+ */
115
+ declare function useTheme(): ThemeContextValue;
116
+
117
+ export { KbachReset, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, disableRuntimeCSS, getGlobalDarkMode, getGlobalThemeMode, initKbach, isKbachReady, isRuntimeCSSDisabled, kb, setGlobalThemeMode, subscribeGlobalDarkMode, toggleGlobalDarkMode, useGlobalDarkMode, useTheme };