@kbach/react 0.6.51 → 1.0.0-beta.1

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.
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -31,737 +30,521 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
30
  // src/jsx-runtime.tsx
32
31
  var jsx_runtime_exports = {};
33
32
  __export(jsx_runtime_exports, {
34
- Fragment: () => import_react4.Fragment,
35
- _invalidateDefaultFontCache: () => _invalidateDefaultFontCache,
33
+ Fragment: () => import_react.Fragment,
36
34
  jsx: () => jsx,
37
- jsxs: () => jsxs,
38
- registerWebElement: () => registerWebElement
35
+ jsxs: () => jsxs
39
36
  });
40
37
  module.exports = __toCommonJS(jsx_runtime_exports);
41
38
  var import_jsx_runtime = require("react/jsx-runtime");
42
- var import_react4 = require("react");
43
- var import_core6 = require("./core");
39
+ var import_react = require("react");
44
40
 
45
- // src/InteractiveWrapper.tsx
46
- var import_react2 = __toESM(require("react"));
47
- var import_core4 = require("./core");
48
-
49
- // src/useGlobalDarkMode.ts
50
- var import_core = require("./core");
41
+ // src/wasmLoader.ts
42
+ var import_core_engine = __toESM(require("@kbach/core-engine"));
43
+ var ready = false;
44
+ function generateCss(classString, themeJson) {
45
+ if (!ready) {
46
+ throw new Error(
47
+ "[kbach] generateCss() was called before initKbach() resolved. Call `await initKbach()` once at startup (e.g. before rendering your app) before using kb()."
48
+ );
49
+ }
50
+ return (0, import_core_engine.generate_css)(classString, themeJson);
51
+ }
51
52
 
52
- // src/useSyncExternalStoreShim.ts
53
- var import_react = __toESM(require("react"));
54
- var useSyncExternalStore = import_react.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
55
- const isServer = typeof window === "undefined";
56
- const [, forceUpdate] = import_react.default.useReducer((n) => n + 1, 0);
57
- const value = isServer && getServerSnapshot ? getServerSnapshot() : getSnapshot();
58
- import_react.default.useEffect(() => {
59
- if (getSnapshot() !== value) forceUpdate();
60
- return subscribe(forceUpdate);
61
- }, [subscribe]);
62
- return value;
53
+ // src/generatedPalette.ts
54
+ var PALETTE = {
55
+ "amber-1": "#fffbeb",
56
+ "amber-10": "#78350f",
57
+ "amber-11": "#451a03",
58
+ "amber-12": "#291002",
59
+ "amber-2": "#fef3c7",
60
+ "amber-3": "#fde68a",
61
+ "amber-4": "#fcd34d",
62
+ "amber-5": "#fbbf24",
63
+ "amber-6": "#f59e0b",
64
+ "amber-7": "#d97706",
65
+ "amber-8": "#b45309",
66
+ "amber-9": "#92400e",
67
+ "black": "#000000",
68
+ "blue-1": "#eff6ff",
69
+ "blue-10": "#1e3a8a",
70
+ "blue-11": "#172554",
71
+ "blue-12": "#0d1633",
72
+ "blue-2": "#dbeafe",
73
+ "blue-3": "#bfdbfe",
74
+ "blue-4": "#93c5fd",
75
+ "blue-5": "#60a5fa",
76
+ "blue-6": "#3b82f6",
77
+ "blue-7": "#2563eb",
78
+ "blue-8": "#1d4ed8",
79
+ "blue-9": "#1e40af",
80
+ "bronze": "#cd7f32",
81
+ "coal": "#1c1c1c",
82
+ "copper": "#b87333",
83
+ "current": "currentColor",
84
+ "cyan-1": "#ecfeff",
85
+ "cyan-10": "#164e63",
86
+ "cyan-11": "#083344",
87
+ "cyan-12": "#041e28",
88
+ "cyan-2": "#cffafe",
89
+ "cyan-3": "#a5f3fc",
90
+ "cyan-4": "#67e8f9",
91
+ "cyan-5": "#22d3ee",
92
+ "cyan-6": "#06b6d4",
93
+ "cyan-7": "#0891b2",
94
+ "cyan-8": "#0e7490",
95
+ "cyan-9": "#155e75",
96
+ "emerald-1": "#ecfdf5",
97
+ "emerald-10": "#064e3b",
98
+ "emerald-11": "#022c22",
99
+ "emerald-12": "#011a14",
100
+ "emerald-2": "#d1fae5",
101
+ "emerald-3": "#a7f3d0",
102
+ "emerald-4": "#6ee7b7",
103
+ "emerald-5": "#34d399",
104
+ "emerald-6": "#10b981",
105
+ "emerald-7": "#059669",
106
+ "emerald-8": "#047857",
107
+ "emerald-9": "#065f46",
108
+ "fuchsia-1": "#fdf4ff",
109
+ "fuchsia-10": "#701a75",
110
+ "fuchsia-11": "#4a044e",
111
+ "fuchsia-12": "#2d022f",
112
+ "fuchsia-2": "#fae8ff",
113
+ "fuchsia-3": "#f5d0fe",
114
+ "fuchsia-4": "#f0abfc",
115
+ "fuchsia-5": "#e879f9",
116
+ "fuchsia-6": "#d946ef",
117
+ "fuchsia-7": "#c026d3",
118
+ "fuchsia-8": "#a21caf",
119
+ "fuchsia-9": "#86198f",
120
+ "gold": "#d4af37",
121
+ "gray-1": "#f9fafb",
122
+ "gray-10": "#111827",
123
+ "gray-11": "#030712",
124
+ "gray-12": "#020409",
125
+ "gray-2": "#f3f4f6",
126
+ "gray-3": "#e5e7eb",
127
+ "gray-4": "#d1d5db",
128
+ "gray-5": "#9ca3af",
129
+ "gray-6": "#6b7280",
130
+ "gray-7": "#4b5563",
131
+ "gray-8": "#374151",
132
+ "gray-9": "#1f2937",
133
+ "green-1": "#f0fdf4",
134
+ "green-10": "#14532d",
135
+ "green-11": "#052e16",
136
+ "green-12": "#031b0d",
137
+ "green-2": "#dcfce7",
138
+ "green-3": "#bbf7d0",
139
+ "green-4": "#86efac",
140
+ "green-5": "#4ade80",
141
+ "green-6": "#22c55e",
142
+ "green-7": "#16a34a",
143
+ "green-8": "#15803d",
144
+ "green-9": "#166534",
145
+ "indigo-1": "#eef2ff",
146
+ "indigo-10": "#312e81",
147
+ "indigo-11": "#1e1b4b",
148
+ "indigo-12": "#12102d",
149
+ "indigo-2": "#e0e7ff",
150
+ "indigo-3": "#c7d2fe",
151
+ "indigo-4": "#a5b4fc",
152
+ "indigo-5": "#818cf8",
153
+ "indigo-6": "#6366f1",
154
+ "indigo-7": "#4f46e5",
155
+ "indigo-8": "#4338ca",
156
+ "indigo-9": "#3730a3",
157
+ "lime-1": "#f7fee7",
158
+ "lime-10": "#365314",
159
+ "lime-11": "#1a2e05",
160
+ "lime-12": "#0f1b03",
161
+ "lime-2": "#ecfccb",
162
+ "lime-3": "#d9f99d",
163
+ "lime-4": "#bef264",
164
+ "lime-5": "#a3e635",
165
+ "lime-6": "#84cc16",
166
+ "lime-7": "#65a30d",
167
+ "lime-8": "#4d7c0f",
168
+ "lime-9": "#3f6212",
169
+ "neutral-1": "#fafafa",
170
+ "neutral-10": "#171717",
171
+ "neutral-11": "#0a0a0a",
172
+ "neutral-12": "#050505",
173
+ "neutral-2": "#f5f5f5",
174
+ "neutral-3": "#e5e5e5",
175
+ "neutral-4": "#d4d4d4",
176
+ "neutral-5": "#a3a3a3",
177
+ "neutral-6": "#737373",
178
+ "neutral-7": "#525252",
179
+ "neutral-8": "#404040",
180
+ "neutral-9": "#262626",
181
+ "orange-1": "#fff7ed",
182
+ "orange-10": "#7c2d12",
183
+ "orange-11": "#431407",
184
+ "orange-12": "#270c04",
185
+ "orange-2": "#ffedd5",
186
+ "orange-3": "#fed7aa",
187
+ "orange-4": "#fdba74",
188
+ "orange-5": "#fb923c",
189
+ "orange-6": "#f97316",
190
+ "orange-7": "#ea580c",
191
+ "orange-8": "#c2410c",
192
+ "orange-9": "#9a3412",
193
+ "pink-1": "#fdf2f8",
194
+ "pink-10": "#831843",
195
+ "pink-11": "#500724",
196
+ "pink-12": "#300415",
197
+ "pink-2": "#fce7f3",
198
+ "pink-3": "#fbcfe8",
199
+ "pink-4": "#f9a8d4",
200
+ "pink-5": "#f472b6",
201
+ "pink-6": "#ec4899",
202
+ "pink-7": "#db2777",
203
+ "pink-8": "#be185d",
204
+ "pink-9": "#9d174d",
205
+ "purple-1": "#faf5ff",
206
+ "purple-10": "#581c87",
207
+ "purple-11": "#3b0764",
208
+ "purple-12": "#23043c",
209
+ "purple-2": "#f3e8ff",
210
+ "purple-3": "#e9d5ff",
211
+ "purple-4": "#d8b4fe",
212
+ "purple-5": "#c084fc",
213
+ "purple-6": "#a855f7",
214
+ "purple-7": "#9333ea",
215
+ "purple-8": "#7e22ce",
216
+ "purple-9": "#6b21a8",
217
+ "red-1": "#fef2f2",
218
+ "red-10": "#7f1d1d",
219
+ "red-11": "#450a0a",
220
+ "red-12": "#280606",
221
+ "red-2": "#fee2e2",
222
+ "red-3": "#fecaca",
223
+ "red-4": "#fca5a5",
224
+ "red-5": "#f87171",
225
+ "red-6": "#ef4444",
226
+ "red-7": "#dc2626",
227
+ "red-8": "#b91c1c",
228
+ "red-9": "#991b1b",
229
+ "rose-1": "#fff1f2",
230
+ "rose-10": "#881337",
231
+ "rose-11": "#4c0519",
232
+ "rose-12": "#2d030e",
233
+ "rose-2": "#ffe4e6",
234
+ "rose-3": "#fecdd3",
235
+ "rose-4": "#fda4af",
236
+ "rose-5": "#fb7185",
237
+ "rose-6": "#f43f5e",
238
+ "rose-7": "#e11d48",
239
+ "rose-8": "#be123c",
240
+ "rose-9": "#9f1239",
241
+ "silver": "#c0c0c0",
242
+ "sky-1": "#f0f9ff",
243
+ "sky-10": "#0c4a6e",
244
+ "sky-11": "#082f49",
245
+ "sky-12": "#041b2b",
246
+ "sky-2": "#e0f2fe",
247
+ "sky-3": "#bae6fd",
248
+ "sky-4": "#7dd3fc",
249
+ "sky-5": "#38bdf8",
250
+ "sky-6": "#0ea5e9",
251
+ "sky-7": "#0284c7",
252
+ "sky-8": "#0369a1",
253
+ "sky-9": "#075985",
254
+ "slate-1": "#f8fafc",
255
+ "slate-10": "#0f172a",
256
+ "slate-11": "#020617",
257
+ "slate-12": "#01020a",
258
+ "slate-2": "#f1f5f9",
259
+ "slate-3": "#e2e8f0",
260
+ "slate-4": "#cbd5e1",
261
+ "slate-5": "#94a3b8",
262
+ "slate-6": "#64748b",
263
+ "slate-7": "#475569",
264
+ "slate-8": "#334155",
265
+ "slate-9": "#1e293b",
266
+ "stone-1": "#fafaf9",
267
+ "stone-10": "#1c1917",
268
+ "stone-11": "#0c0a09",
269
+ "stone-12": "#070605",
270
+ "stone-2": "#f5f5f4",
271
+ "stone-3": "#e7e5e4",
272
+ "stone-4": "#d6d3d1",
273
+ "stone-5": "#a8a29e",
274
+ "stone-6": "#78716c",
275
+ "stone-7": "#57534e",
276
+ "stone-8": "#44403c",
277
+ "stone-9": "#292524",
278
+ "teal-1": "#f0fdfa",
279
+ "teal-10": "#134e4a",
280
+ "teal-11": "#042f2e",
281
+ "teal-12": "#021c1b",
282
+ "teal-2": "#ccfbf1",
283
+ "teal-3": "#99f6e4",
284
+ "teal-4": "#5eead4",
285
+ "teal-5": "#2dd4bf",
286
+ "teal-6": "#14b8a6",
287
+ "teal-7": "#0d9488",
288
+ "teal-8": "#0f766e",
289
+ "teal-9": "#115e59",
290
+ "transparent": "transparent",
291
+ "violet-1": "#f5f3ff",
292
+ "violet-10": "#4c1d95",
293
+ "violet-11": "#2e1065",
294
+ "violet-12": "#1c0a3d",
295
+ "violet-2": "#ede9fe",
296
+ "violet-3": "#ddd6fe",
297
+ "violet-4": "#c4b5fd",
298
+ "violet-5": "#a78bfa",
299
+ "violet-6": "#8b5cf6",
300
+ "violet-7": "#7c3aed",
301
+ "violet-8": "#6d28d9",
302
+ "violet-9": "#5b21b6",
303
+ "white": "#ffffff",
304
+ "yellow-1": "#fefce8",
305
+ "yellow-10": "#713f12",
306
+ "yellow-11": "#422006",
307
+ "yellow-12": "#271304",
308
+ "yellow-2": "#fef9c3",
309
+ "yellow-3": "#fef08a",
310
+ "yellow-4": "#fde047",
311
+ "yellow-5": "#facc15",
312
+ "yellow-6": "#eab308",
313
+ "yellow-7": "#ca8a04",
314
+ "yellow-8": "#a16207",
315
+ "yellow-9": "#854d0e",
316
+ "zinc-1": "#fafafa",
317
+ "zinc-10": "#18181b",
318
+ "zinc-11": "#09090b",
319
+ "zinc-12": "#050506",
320
+ "zinc-2": "#f4f4f5",
321
+ "zinc-3": "#e4e4e7",
322
+ "zinc-4": "#d4d4d8",
323
+ "zinc-5": "#a1a1aa",
324
+ "zinc-6": "#71717a",
325
+ "zinc-7": "#52525b",
326
+ "zinc-8": "#3f3f46",
327
+ "zinc-9": "#27272a"
63
328
  };
64
329
 
65
- // src/useGlobalDarkMode.ts
66
- var NOOP_SUB = (_) => () => {
330
+ // src/theme.ts
331
+ var defaultTheme = {
332
+ colors: {
333
+ ...PALETTE,
334
+ surface: { light: "#f9fafb", dark: "#111827" }
335
+ },
336
+ // Real Tailwind's default spacing scale in full — every step is exactly
337
+ // `n * 4px` (Tailwind's base spacing unit), including the fractional
338
+ // `.5` steps (`1.5` -> 6px, `2.5` -> 10px, `3.5` -> 14px) and the "px"
339
+ // literal (a bare 1px, for `p-px`-style hairline spacing). Previously
340
+ // this only had {0,1,2,4,6,8} — a handful of spot-checked values, not
341
+ // the real scale — so anything else (`p-3`, `w-5`, `border-2`, `gap-10`,
342
+ // ...) silently failed to resolve (an unknown spacing key returns `None`
343
+ // the same way an unknown class does, with no error). "0" itself is
344
+ // still needed explicitly (not derivable as "any number * 4") for the
345
+ // same reason it always was: `sticky top-0` needs an actual "0" key to
346
+ // resolve at all, not just fall through as unresolvable.
347
+ spacing: {
348
+ "0": 0,
349
+ "px": 1,
350
+ "0.5": 2,
351
+ "1": 4,
352
+ "1.5": 6,
353
+ "2": 8,
354
+ "2.5": 10,
355
+ "3": 12,
356
+ "3.5": 14,
357
+ "4": 16,
358
+ "5": 20,
359
+ "6": 24,
360
+ "7": 28,
361
+ "8": 32,
362
+ "9": 36,
363
+ "10": 40,
364
+ "11": 44,
365
+ "12": 48,
366
+ "14": 56,
367
+ "16": 64,
368
+ "20": 80,
369
+ "24": 96,
370
+ "28": 112,
371
+ "32": 128,
372
+ "36": 144,
373
+ "40": 160,
374
+ "44": 176,
375
+ "48": 192,
376
+ "52": 208,
377
+ "56": 224,
378
+ "60": 240,
379
+ "64": 256,
380
+ "72": 288,
381
+ "80": 320,
382
+ "96": 384
383
+ },
384
+ screens: {
385
+ sm: 640,
386
+ md: 768,
387
+ lg: 1024,
388
+ xl: 1280,
389
+ "2xl": 1536
390
+ },
391
+ darkMode: "attribute"
67
392
  };
68
- var FALSE_SNAP = () => false;
69
- function useConditionalGlobalDarkMode(active) {
70
- return useSyncExternalStore(
71
- active ? import_core.subscribeGlobalDarkMode : NOOP_SUB,
72
- active ? import_core.getGlobalDarkMode : FALSE_SNAP,
73
- FALSE_SNAP
74
- );
393
+ var activeThemeJson = JSON.stringify(defaultTheme);
394
+ function getThemeJson() {
395
+ return activeThemeJson;
75
396
  }
76
397
 
77
- // src/useGlobalWidth.ts
78
- var import_core2 = require("./core");
79
- var NOOP_SUB2 = (_) => () => {
80
- };
81
- var ZERO_SNAP = () => 0;
82
- var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
83
- var _webListeners = null;
84
- var _webRaf = 0;
85
- function _webResizeHandler() {
86
- cancelAnimationFrame(_webRaf);
87
- _webRaf = requestAnimationFrame(() => {
88
- if (_webListeners) for (const cb of _webListeners) cb();
89
- });
90
- }
91
- function subscribeWebWidth(cb) {
92
- if (typeof window === "undefined") return () => {
93
- };
94
- if (!_webListeners) {
95
- _webListeners = /* @__PURE__ */ new Set();
96
- window.addEventListener("resize", _webResizeHandler);
97
- }
98
- _webListeners.add(cb);
99
- return () => {
100
- _webListeners.delete(cb);
101
- if (_webListeners.size === 0) {
102
- window.removeEventListener("resize", _webResizeHandler);
103
- cancelAnimationFrame(_webRaf);
104
- _webListeners = null;
105
- }
106
- };
107
- }
108
- function getWebWidth() {
109
- return typeof window !== "undefined" ? window.innerWidth : 0;
110
- }
111
- function useConditionalWidth(active) {
112
- return useSyncExternalStore(
113
- active ? import_core2.isWeb ? subscribeWebWidth : import_core2.subscribeGlobalWidth : NOOP_SUB2,
114
- active ? import_core2.isWeb ? getWebWidth : import_core2.getGlobalWidth : ZERO_SNAP,
115
- ZERO_SNAP
116
- );
117
- }
398
+ // src/reset.ts
399
+ var RESET_STYLE_ID = "kbach-reset";
400
+ var RESET_RULES = [
401
+ // border-style: solid means border-N utilities show a visible border without an extra border-solid class.
402
+ // border-width: 0 keeps all elements borderless by default.
403
+ { css: "*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }" },
404
+ { css: "body { margin: 0; padding: 0; }" },
405
+ { css: "h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }", tags: ["h1", "h2", "h3", "h4", "h5", "h6"] },
406
+ { css: "p { margin: 0; }", tags: ["p"] },
407
+ { css: "a { color: inherit; text-decoration: none; }", tags: ["a"] },
408
+ { css: "ul, ol { margin: 0; padding: 0; list-style: none; }", tags: ["ul", "ol"] },
409
+ // svg here only covers a literal <svg> tag in JSX — an icon imported as
410
+ // a component (e.g. `<ArrowIcon />`) never appears as the text "svg" in
411
+ // source, so this rule won't be pulled in by that usage alone. Same
412
+ // caveat applies to every tag-gated rule below: detection is a literal
413
+ // source-text scan (see vite-plugin/scan.ts's scanUsedTags), not a real
414
+ // DOM/type check.
415
+ { css: "img, video, svg { display: block; max-width: 100%; }", tags: ["img", "video", "svg"] },
416
+ // appearance: none is deliberately NOT applied to checkbox/radio/select below —
417
+ // stripping it hides their native checkmark/arrow with nothing rendered in its
418
+ // place, leaving an invisible checkbox or an arrow-less <select> that looks like
419
+ // plain text. Text-like inputs, textarea, and button don't have that problem
420
+ // (their native chrome is just a skin around content utilities can fully
421
+ // restyle), so they keep the blank-canvas treatment.
422
+ // :where() wraps the :not() exclusions so they contribute ZERO specificity
423
+ // (unlike a bare `input:not([type='checkbox']):not([type='radio'])`, whose
424
+ // two :not([attr]) clauses each add a class-level specificity point — (0,2,1)
425
+ // total, MORE than any single utility class (0,1,0)). Without :where(), this
426
+ // reset's `color: inherit` always won the cascade over a text-* color
427
+ // utility applied directly to a <input>/<textarea> regardless of source
428
+ // order, since author rules only override on a tie or higher specificity —
429
+ // confirmed on a real app: a TextInput's own text color utility resolved
430
+ // and injected correctly, class and all, but silently never painted.
431
+ {
432
+ 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; }",
433
+ tags: ["input", "textarea"]
434
+ },
435
+ // Native checkbox/radio/range still get typography + spacing normalized, and
436
+ // accent-color re-themes their native indicator to the current text color
437
+ // instead of the browser/OS default blue, so they stay on-brand without
438
+ // needing to be rebuilt from scratch. Wrapped in :where() for the exact
439
+ // same reason as the input:not(...) exclusions above — a bare
440
+ // `input[type='range']` attribute selector has specificity (0,1,1),
441
+ // MORE than any single utility class (0,1,0), so an `accent-*` utility
442
+ // (Phase 23) applied directly to a checkbox/radio/range would resolve and
443
+ // inject correctly but silently never paint, losing the cascade to this
444
+ // reset regardless of source order — confirmed by hand via
445
+ // getComputedStyle on a real `accent-red-6` range input, which reported
446
+ // `currentColor`'s inherited value instead. `:where()` zeroes this
447
+ // selector's specificity contribution entirely, so any `accent-*`
448
+ // utility trivially wins once applied.
449
+ {
450
+ css: ":where(input[type='checkbox'], input[type='radio'], input[type='range']) { margin: 0; font: inherit; accent-color: currentColor; }",
451
+ tags: ["input"]
452
+ },
453
+ // select keeps its native chrome (border/background/arrow are all part of the
454
+ // same OS-drawn widget that appearance: none would blank out) — only typography
455
+ // and spacing are normalized so it still matches surrounding text.
456
+ { css: "select { margin: 0; font: inherit; color: inherit; line-height: inherit; }", tags: ["select"] },
457
+ { 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"] },
458
+ // Also covers any element opted into the button role (`role="button"` on
459
+ // a <div>/<span>) — but only when a literal <button> tag is ALSO
460
+ // somewhere in the scanned source, since detection here is purely
461
+ // tag-name-based; a project using role="button" exclusively, with no
462
+ // real <button> anywhere, won't pull this rule in. Acceptable tradeoff
463
+ // for this project's scope (rare pattern) — cheap enough that scanning
464
+ // for it separately isn't worth the added complexity.
465
+ { css: "button, [role='button'] { cursor: pointer; }", tags: ["button"] },
466
+ { css: ":disabled { cursor: default; }", tags: ["button", "input", "select", "textarea"] },
467
+ { css: "textarea { resize: vertical; }", tags: ["textarea"] },
468
+ // Firefox renders placeholders at ~54% opacity by default; every other browser uses 1 —
469
+ // normalize to 1 so placeholder color is consistent and fully controlled by the placeholder: modifier.
470
+ { css: "::placeholder { opacity: 1; }", tags: ["input", "textarea"] },
471
+ { css: "input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button { margin: 0; }", tags: ["input"] },
472
+ { css: "input[type='search']::-webkit-search-decoration, input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }", tags: ["input"] },
473
+ { css: "fieldset { padding: 0; margin: 0; }", tags: ["fieldset"] },
474
+ { css: "table { border-collapse: collapse; border-spacing: 0; }", tags: ["table"] }
475
+ ];
476
+ var BASE_RESET = RESET_RULES.map((r) => r.css).join("\n");
118
477
 
119
- // src/shared-utils.ts
120
- var import_core3 = require("./core");
121
- function hasResponsiveBuckets(resolved) {
122
- const responsiveMods = (0, import_core3.getResponsiveModifiers)();
123
- for (const key of Object.keys(resolved)) {
124
- if (key === "base") continue;
125
- for (const mod of key.split(":")) {
126
- if (responsiveMods.has(mod)) return true;
127
- }
128
- }
129
- return false;
130
- }
131
- function chain(original, extra) {
132
- return (...args) => {
133
- original?.(...args);
134
- extra();
135
- };
478
+ // src/kb.ts
479
+ var runtimeCSSDisabled = false;
480
+ var styleEl = null;
481
+ var sheetKeys = [];
482
+ var ruleOrderByKey = /* @__PURE__ */ new Map();
483
+ function getStyleEl() {
484
+ if (styleEl) return styleEl;
485
+ styleEl = document.createElement("style");
486
+ styleEl.setAttribute("data-kbach", "");
487
+ document.head.appendChild(styleEl);
488
+ return styleEl;
136
489
  }
137
- function stripInternalMarkers(s) {
138
- delete s.__divideX;
139
- delete s.__divideY;
140
- delete s.__divideColor;
141
- delete s.__divideStyle;
142
- delete s.__keyframe;
143
- }
144
- function stripWebOnlyProps(s) {
145
- if (s.display === "grid" || s.display === "inline-grid") delete s.display;
146
- delete s.gridTemplateColumns;
147
- delete s.gridTemplateRows;
148
- delete s.gridColumn;
149
- delete s.gridRow;
150
- delete s.gridArea;
151
- delete s.gridColumnStart;
152
- delete s.gridColumnEnd;
153
- delete s.gridRowStart;
154
- delete s.gridRowEnd;
155
- delete s.gridAutoFlow;
156
- delete s.gridAutoColumns;
157
- delete s.gridAutoRows;
158
- delete s.placeItems;
159
- delete s.placeContent;
160
- delete s.justifyItems;
161
- delete s.placeSelf;
162
- delete s.justifySelf;
163
- if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
164
- delete s.position;
165
- }
166
- }
167
- function composeNativeStyle(computed, userStyle) {
168
- if (!userStyle) return computed;
169
- return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
170
- }
171
-
172
- // src/InteractiveWrapper.tsx
173
- var InteractiveWrapper = (0, import_react2.forwardRef)(
174
- function InteractiveWrapper2({
175
- Component,
176
- resolvedStyle,
177
- className,
178
- style: styleProp,
179
- onPressIn,
180
- onPressOut,
181
- onPointerDown,
182
- onPointerUp,
183
- onPointerLeave,
184
- onPointerCancel,
185
- onMouseEnter,
186
- onMouseLeave,
187
- onFocus,
188
- onBlur,
189
- ...rest
190
- }, ref) {
191
- const isWebPlatform = (0, import_core4.getEffectiveIsWeb)();
192
- const isDark = useConditionalGlobalDarkMode(!isWebPlatform);
193
- const needsWidth = hasResponsiveBuckets(resolvedStyle);
194
- const width = useConditionalWidth(needsWidth && !isWebPlatform);
195
- const breakpoints = needsWidth ? (0, import_core4.getActiveBreakpoints)(width) : EMPTY_BREAKPOINTS;
196
- const screens = (0, import_core4.getGlobalScreens)();
197
- const [pressed, setPressed] = (0, import_react2.useState)(false);
198
- const [hovered, setHovered] = (0, import_react2.useState)(false);
199
- const [focused, setFocused] = (0, import_react2.useState)(false);
200
- const handlePressIn = (0, import_react2.useCallback)(chain(onPressIn, () => {
201
- if (!isWebPlatform) setPressed(true);
202
- }), [onPressIn, isWebPlatform]);
203
- const handlePressOut = (0, import_react2.useCallback)(chain(onPressOut, () => {
204
- if (!isWebPlatform) setPressed(false);
205
- }), [onPressOut, isWebPlatform]);
206
- const handlePointerDown = (0, import_react2.useCallback)(chain(onPointerDown, () => {
207
- if (!isWebPlatform) setPressed(true);
208
- }), [onPointerDown, isWebPlatform]);
209
- const handlePointerUp = (0, import_react2.useCallback)(chain(onPointerUp, () => {
210
- if (!isWebPlatform) setPressed(false);
211
- }), [onPointerUp, isWebPlatform]);
212
- const handlePointerLeave = (0, import_react2.useCallback)(chain(onPointerLeave, () => {
213
- if (!isWebPlatform) setPressed(false);
214
- }), [onPointerLeave, isWebPlatform]);
215
- const handlePointerCancel = (0, import_react2.useCallback)(chain(onPointerCancel, () => {
216
- if (!isWebPlatform) setPressed(false);
217
- }), [onPointerCancel, isWebPlatform]);
218
- const handleMouseEnter = (0, import_react2.useCallback)(chain(onMouseEnter, () => {
219
- if (!isWebPlatform) setHovered(true);
220
- }), [onMouseEnter, isWebPlatform]);
221
- const handleMouseLeave = (0, import_react2.useCallback)(chain(onMouseLeave, () => {
222
- if (!isWebPlatform) setHovered(false);
223
- }), [onMouseLeave, isWebPlatform]);
224
- const handleFocus = (0, import_react2.useCallback)(chain(onFocus, () => {
225
- if (!isWebPlatform) setFocused(true);
226
- }), [onFocus, isWebPlatform]);
227
- const handleBlur = (0, import_react2.useCallback)(chain(onBlur, () => {
228
- if (!isWebPlatform) setFocused(false);
229
- }), [onBlur, isWebPlatform]);
230
- const { children, disabled, checked, ...restForComponent } = rest;
231
- const isNonStringComponent = typeof Component !== "string";
232
- const computedStyle = (0, import_react2.useMemo)(
233
- () => {
234
- if (isWebPlatform) return {};
235
- const s = (0, import_core4.flatten)(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
236
- stripInternalMarkers(s);
237
- if (isNonStringComponent) stripWebOnlyProps(s);
238
- return s;
239
- },
240
- [resolvedStyle, isDark, pressed, hovered, focused, width, screens, disabled, checked, isNonStringComponent]
241
- );
242
- const skipComputedInline = isWebPlatform;
243
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : composeNativeStyle(computedStyle, styleProp);
244
- const componentProps = {
245
- ref,
246
- ...restForComponent,
247
- ...disabled !== void 0 ? { disabled } : {},
248
- ...checked !== void 0 ? { checked } : {},
249
- style: finalStyle,
250
- ...!import_core4.isNative && className ? { className } : {},
251
- // On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch) —
252
- // onPressIn/onPressOut are RN-only prop names and are never forwarded here, even when
253
- // Component isn't a literal HTML tag string. A non-string Component on web is just as
254
- // likely to be an ordinary web component (React Router's <Link>, Next.js's <Link>, any
255
- // custom wrapper) as an actual react-native-web primitive — "not a string" alone was never
256
- // a reliable signal that onPressIn/onPressOut are wanted, and forwarding them
257
- // unconditionally made React DOM warn "Unknown event handler property" the moment any web
258
- // component got an interactive modifier (hover:, active:, …), which is the common case,
259
- // not the exception. (A real react-native-web primitive would additionally have this pair
260
- // of props silently vanish after hydration anyway, once the browser-only web-substitution
261
- // in jsx-runtime.tsx swaps it for a plain host tag — so keeping them pre-hydration would
262
- // only have traded one prop-mismatch warning for another.) Genuinely native code paths
263
- // still get them via the isNative branch below.
264
- ...!import_core4.isNative ? {
265
- onPointerDown: handlePointerDown,
266
- onPointerUp: handlePointerUp,
267
- onPointerLeave: handlePointerLeave,
268
- onPointerCancel: handlePointerCancel
269
- } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
270
- onMouseEnter: handleMouseEnter,
271
- onMouseLeave: handleMouseLeave,
272
- onFocus: handleFocus,
273
- onBlur: handleBlur
274
- };
275
- return Array.isArray(children) ? import_react2.default.createElement(Component, componentProps, ...children) : import_react2.default.createElement(Component, componentProps, children);
276
- }
277
- );
278
- InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
279
-
280
- // src/DarkWrapper.tsx
281
- var import_react3 = __toESM(require("react"));
282
- var import_core5 = require("./core");
283
- var DarkWrapper = import_react3.default.forwardRef(
284
- function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
285
- const isWebPlatform = (0, import_core5.getEffectiveIsWeb)();
286
- const isDark = useConditionalGlobalDarkMode(!isWebPlatform);
287
- const needsWidth = hasResponsiveBuckets(resolvedStyle);
288
- const width = useConditionalWidth(needsWidth && !isWebPlatform);
289
- const breakpoints = needsWidth ? (0, import_core5.getActiveBreakpoints)(width) : EMPTY_BREAKPOINTS;
290
- const screens = (0, import_core5.getGlobalScreens)();
291
- const isNonStringComponent = typeof Component !== "string";
292
- const computedStyle = (0, import_react3.useMemo)(() => {
293
- if (isWebPlatform) return {};
294
- const s = (0, import_core5.flatten)(resolvedStyle, isDark, {}, breakpoints);
295
- stripInternalMarkers(s);
296
- if (isNonStringComponent) stripWebOnlyProps(s);
297
- return s;
298
- }, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
299
- const skipComputedInline = isWebPlatform;
300
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : composeNativeStyle(computedStyle, styleProp);
301
- const props = { ref, ...rest, style: finalStyle };
302
- return Array.isArray(children) ? import_react3.default.createElement(Component, props, ...children) : import_react3.default.createElement(Component, props, children);
490
+ function findInsertionIndex(order) {
491
+ let lo = 0;
492
+ let hi = sheetKeys.length;
493
+ while (lo < hi) {
494
+ const mid = lo + hi >>> 1;
495
+ if (ruleOrderByKey.get(sheetKeys[mid]) > order) hi = mid;
496
+ else lo = mid + 1;
303
497
  }
304
- );
305
- DarkWrapper.displayName = "Kbach.DarkWrapper";
306
-
307
- // src/web-substitute.ts
308
- var _rnToHtml = {
309
- View: "div",
310
- SafeAreaView: "div",
311
- KeyboardAvoidingView: "div",
312
- ScrollView: "div",
313
- VirtualizedList: "div",
314
- FlatList: "div",
315
- SectionList: "div",
316
- Text: "span",
317
- TextInput: "input",
318
- Image: "img",
319
- ImageBackground: "div",
320
- Pressable: "div",
321
- TouchableOpacity: "div",
322
- TouchableHighlight: "div",
323
- TouchableWithoutFeedback: "div",
324
- TouchableNativeFeedback: "div"
325
- };
326
- var _userMap = /* @__PURE__ */ new Map();
327
- var _cache = /* @__PURE__ */ new WeakMap();
328
- function registerWebElement(rnComponent, htmlTag) {
329
- if (typeof rnComponent !== "object" && typeof rnComponent !== "function") return;
330
- _userMap.set(rnComponent, htmlTag);
331
- _cache.delete(rnComponent);
332
- }
333
- var _forwardRefOrMemoType = /* @__PURE__ */ new Set([
334
- /* @__PURE__ */ Symbol.for("react.forward_ref"),
335
- /* @__PURE__ */ Symbol.for("react.memo")
336
- ]);
337
- function looksLikeRealRNPrimitive(type) {
338
- const t = type.$$typeof;
339
- if (t !== void 0) return _forwardRefOrMemoType.has(t);
340
- return !!type.prototype?.isReactComponent;
498
+ return lo;
341
499
  }
342
- function getWebTag(type, props) {
343
- if (typeof type === "string") return null;
344
- if (type === null || typeof type !== "function" && typeof type !== "object") return null;
345
- const obj = type;
346
- if (_userMap.has(obj)) return _userMap.get(obj);
347
- if (!looksLikeRealRNPrimitive(obj)) return null;
348
- const name = obj.displayName ?? obj.name;
349
- if (!name) {
350
- _cache.set(obj, null);
351
- return null;
500
+ function injectRule(rule, order) {
501
+ if (ruleOrderByKey.has(rule)) return;
502
+ const sheet = getStyleEl().sheet;
503
+ if (!sheet) return;
504
+ const idx = findInsertionIndex(order);
505
+ try {
506
+ sheet.insertRule(rule, idx);
507
+ } catch {
508
+ return;
352
509
  }
353
- if (name === "TextInput") {
354
- const multiline = !!props && (props.multiline === true || Number(props.numberOfLines) > 1);
355
- return multiline ? "textarea" : "input";
356
- }
357
- if (_cache.has(obj)) return _cache.get(obj);
358
- const tag = _rnToHtml[name] ?? null;
359
- _cache.set(obj, tag);
360
- return tag;
510
+ sheetKeys.splice(idx, 0, rule);
511
+ ruleOrderByKey.set(rule, order);
361
512
  }
362
- function getImpliedRNClasses(webTag, resolvedBase) {
363
- if (!webTag || !resolvedBase) return void 0;
364
- const classes = [];
365
- if (resolvedBase.position === void 0) classes.push("relative");
366
- const explicitDisplay = resolvedBase.display;
367
- const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
368
- const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
369
- if (willBeFlex && (explicitDisplay === void 0 || resolvedBase.flexDirection === void 0)) {
370
- classes.push("flex-col");
371
- }
372
- return classes.length > 0 ? classes.join(" ") : void 0;
513
+ var resetChecked = false;
514
+ function ensureResetInjected() {
515
+ if (resetChecked) return;
516
+ resetChecked = true;
517
+ if (document.getElementById(RESET_STYLE_ID)) return;
518
+ const el = document.createElement("style");
519
+ el.id = RESET_STYLE_ID;
520
+ el.textContent = BASE_RESET;
521
+ document.head.insertBefore(el, document.head.firstChild);
373
522
  }
374
- var _rnOnlyProps = /* @__PURE__ */ new Set([
375
- // Interaction
376
- "onLongPress",
377
- "delayLongPress",
378
- "activeOpacity",
379
- "underlayColor",
380
- "hitSlop",
381
- "pressRetentionOffset",
382
- "android_ripple",
383
- "android_disableSound",
384
- "onHoverIn",
385
- "onHoverOut",
386
- "onHoverStart",
387
- "onHoverEnd",
388
- // Layout event
389
- "onLayout",
390
- // Accessibility
391
- "accessible",
392
- "accessibilityState",
393
- "accessibilityLiveRegion",
394
- "importantForAccessibility",
395
- // Platform
396
- "nativeID",
397
- "collapsable",
398
- "needsOffscreenAlphaCompositing",
399
- "renderToHardwareTextureAndroid",
400
- "shouldRasterizeIOS",
401
- "focusable",
402
- "hasTVPreferredFocus",
403
- // 'pointerEvents' is handled in transformToWebProps (mapped to CSS style)
404
- // Text
405
- "selectable",
406
- "allowFontScaling",
407
- "adjustsFontSizeToFit",
408
- "minimumFontScale",
409
- "ellipsizeMode",
410
- "numberOfLines",
411
- "onTextLayout",
412
- "textBreakStrategy",
413
- "lineBreakStrategyIOS",
414
- // TextInput
415
- "multiline",
416
- // NOTE: 'resizeMode' (Image's prop, not TextInput's) deliberately does NOT
417
- // go here — it's handled below in the isImage branch (mapped to CSS
418
- // object-fit). Blacklisting it here would make that branch unreachable.
419
- "blurOnSubmit",
420
- "clearButtonMode",
421
- "clearTextOnFocus",
422
- "enablesReturnKeyAutomatically",
423
- "returnKeyType",
424
- "spellCheck",
425
- // ScrollView
426
- "scrollEnabled",
427
- "showsVerticalScrollIndicator",
428
- "showsHorizontalScrollIndicator",
429
- "contentContainerStyle",
430
- // 'horizontal' is handled in transformToWebProps (converted to CSS overflow-x).
431
- "keyboardShouldPersistTaps",
432
- "keyboardDismissMode",
433
- "pagingEnabled",
434
- "scrollEventThrottle",
435
- "decelerationRate",
436
- "bounces",
437
- "alwaysBounceHorizontal",
438
- "alwaysBounceVertical",
439
- "snapToAlignment",
440
- "snapToInterval",
441
- "snapToOffsets",
442
- "removeClippedSubviews",
443
- "overScrollMode",
444
- "stickyHeaderIndices",
445
- "invertStickyHeaders",
446
- "onScrollBeginDrag",
447
- "onScrollEndDrag",
448
- "onMomentumScrollBegin",
449
- "onMomentumScrollEnd",
450
- "contentInset",
451
- "contentInsetAdjustmentBehavior",
452
- "automaticallyAdjustContentInsets",
453
- "automaticallyAdjustsScrollIndicatorInsets",
454
- // expo-image
455
- "contentPosition",
456
- "cachePolicy",
457
- "recyclingKey",
458
- "blurRadius",
459
- "fadeDuration",
460
- "responsivePolicy",
461
- "tintColor",
462
- "allowDownscaling",
463
- "placeholderContentFit",
464
- // FlatList / SectionList
465
- "data",
466
- "renderItem",
467
- "keyExtractor",
468
- "getItemLayout",
469
- "initialScrollIndex",
470
- "initialNumToRender",
471
- "maxToRenderPerBatch",
472
- "windowSize",
473
- "updateCellsBatchingPeriod",
474
- "onEndReached",
475
- "onEndReachedThreshold",
476
- "ListHeaderComponent",
477
- "ListFooterComponent",
478
- "ListEmptyComponent",
479
- "ListHeaderComponentStyle",
480
- "ListFooterComponentStyle",
481
- "ItemSeparatorComponent",
482
- "SectionSeparatorComponent",
483
- "inverted",
484
- "getItem",
485
- "getItemCount"
486
- ]);
487
- var _pressableNames = /* @__PURE__ */ new Set([
488
- "Pressable",
489
- "TouchableOpacity",
490
- "TouchableHighlight",
491
- "TouchableWithoutFeedback",
492
- "TouchableNativeFeedback"
493
- ]);
494
- var _keyboardTypeMap = {
495
- "numeric": "number",
496
- "number-pad": "number",
497
- "decimal-pad": "decimal",
498
- "email-address": "email",
499
- "phone-pad": "tel",
500
- "url": "url"
501
- };
502
- var _resizeModeMap = {
503
- "contain": "contain",
504
- "cover": "cover",
505
- "stretch": "fill",
506
- "center": "none",
507
- "repeat": "none"
508
- };
509
- var PLACEHOLDER_RULE_ATTR = "data-kbach-ph";
510
- var _placeholderRuleInjected = false;
511
- function ensurePlaceholderColorRuleInjected() {
512
- if (_placeholderRuleInjected || typeof document === "undefined") return;
513
- _placeholderRuleInjected = true;
514
- const style = document.createElement("style");
515
- style.setAttribute("data-kbach-placeholder", "");
516
- style.textContent = `[${PLACEHOLDER_RULE_ATTR}]::placeholder{color:var(--kbach-ph-color)}`;
517
- document.head.appendChild(style);
518
- }
519
- function transformToWebProps(originalName, tag, props) {
520
- const out = {};
521
- const isPressable = _pressableNames.has(originalName);
522
- const isTextInput = originalName === "TextInput";
523
- const isImage = originalName === "Image" || originalName === "ImageBackground";
524
- const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
525
- let pendingStyle = null;
526
- for (const [k, v] of Object.entries(props)) {
527
- if (_rnOnlyProps.has(k)) continue;
528
- if (k === "onPress") {
529
- if (!("onClick" in props)) out.onClick = v;
530
- continue;
531
- }
532
- if (k === "accessibilityLabel") {
533
- if (out["aria-label"] == null) out["aria-label"] = v;
534
- continue;
535
- }
536
- if (k === "accessibilityRole") {
537
- if (out.role == null) out.role = v;
538
- continue;
539
- }
540
- if (k === "testID") {
541
- if (out["data-testid"] == null) out["data-testid"] = v;
542
- continue;
543
- }
544
- if (isTextInput) {
545
- if (k === "onChangeText") {
546
- if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
547
- continue;
548
- }
549
- if (k === "onSubmitEditing") {
550
- if (!("onKeyDown" in props)) {
551
- out.onKeyDown = (e) => {
552
- if (e.key === "Enter") v();
553
- };
554
- }
555
- continue;
556
- }
557
- if (k === "placeholderTextColor") {
558
- if (v) {
559
- ensurePlaceholderColorRuleInjected();
560
- out[PLACEHOLDER_RULE_ATTR] = "";
561
- pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
562
- }
563
- continue;
564
- }
565
- if (k === "secureTextEntry") {
566
- if (v && !("type" in props)) out.type = "password";
567
- continue;
568
- }
569
- if (k === "keyboardType") {
570
- if (!("type" in props) && !props.secureTextEntry) {
571
- const mapped = _keyboardTypeMap[v];
572
- if (mapped) out.type = mapped;
573
- }
574
- continue;
575
- }
576
- if (k === "editable") {
577
- if (v === false) out.readOnly = true;
578
- continue;
579
- }
580
- if (k === "maxLength") {
581
- out.maxLength = v;
582
- continue;
583
- }
584
- }
585
- if (isScrollable && k === "horizontal") {
586
- if (v) pendingStyle = { ...pendingStyle ?? {}, display: "flex", flexDirection: "row", overflowX: "auto" };
587
- continue;
523
+ function kb(classString) {
524
+ const json = generateCss(classString, getThemeJson());
525
+ const { className, rules } = JSON.parse(json);
526
+ if (!runtimeCSSDisabled) {
527
+ ensureResetInjected();
528
+ for (const { rule, order } of rules) {
529
+ injectRule(rule, order);
588
530
  }
589
- if (k === "pointerEvents") {
590
- if (v === "none" || v === "auto") pendingStyle = { ...pendingStyle ?? {}, pointerEvents: v };
591
- continue;
592
- }
593
- if (isImage) {
594
- if (k === "source") {
595
- if (typeof v === "string") {
596
- out.src = v;
597
- } else if (v && typeof v === "object" && "uri" in v) {
598
- out.src = v.uri;
599
- if (v.headers) out["crossOrigin"] = "anonymous";
600
- }
601
- continue;
602
- }
603
- if (k === "resizeMode") {
604
- pendingStyle = { ...pendingStyle ?? {}, objectFit: _resizeModeMap[v] ?? "cover" };
605
- continue;
606
- }
607
- if (k === "contentFit") {
608
- pendingStyle = { ...pendingStyle ?? {}, objectFit: v };
609
- continue;
610
- }
611
- if (k === "defaultSource") continue;
612
- }
613
- if (k === "style") {
614
- if (Array.isArray(v)) {
615
- out.style = Object.assign({}, ...v.filter(Boolean));
616
- } else if (v != null) {
617
- out.style = v;
618
- }
619
- continue;
620
- }
621
- out[k] = v;
622
- }
623
- if (pendingStyle) {
624
- out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
625
531
  }
626
- if (isPressable && !out.role) out.role = "button";
627
- if (isImage && tag === "img" && out.alt == null) out.alt = "";
628
- return out;
532
+ return className;
629
533
  }
630
534
 
631
535
  // src/jsx-runtime.tsx
632
- var _cachedDefaultFont = void 0;
633
- var _defaultFontVersion = 0;
634
- var _lastFontVersion = -1;
635
- function _invalidateDefaultFontCache() {
636
- _defaultFontVersion++;
637
- }
638
- {
639
- const _KEY = "__kbach_font_cache_unsub__";
640
- const g = globalThis;
641
- if (g[_KEY]) g[_KEY]();
642
- g[_KEY] = (0, import_core6.onConfigChange)(_invalidateDefaultFontCache);
643
- }
644
- function getCachedDefaultFont() {
645
- if (_lastFontVersion !== _defaultFontVersion) {
646
- _cachedDefaultFont = (0, import_core6.getDefaultFontFamily)();
647
- _lastFontVersion = _defaultFontVersion;
648
- }
649
- return _cachedDefaultFont;
650
- }
651
- var _bucketModsCache = /* @__PURE__ */ new WeakMap();
652
- function bucketMods(resolved) {
653
- const cached = _bucketModsCache.get(resolved);
654
- if (cached) return cached;
655
- const interactiveMods = (0, import_core6.getInteractiveModifiers)();
656
- const modeMods = (0, import_core6.getModeModifiers)();
657
- const responsiveMods = (0, import_core6.getResponsiveModifiers)();
658
- let interactive = false;
659
- let modeOrResponsive = false;
660
- for (const key of Object.keys(resolved)) {
661
- if (key === "base") continue;
662
- for (const mod of key.split(":")) {
663
- if (!interactive && interactiveMods.has(mod)) interactive = true;
664
- if (!modeOrResponsive && (modeMods.has(mod) || responsiveMods.has(mod))) modeOrResponsive = true;
665
- }
666
- if (interactive && modeOrResponsive) break;
667
- }
668
- const result = { interactive, modeOrResponsive };
669
- _bucketModsCache.set(resolved, result);
670
- return result;
671
- }
672
- var CONSUMED_PROPS = /* @__PURE__ */ new Set(["className", "kb", "__kbachStyles", "__kbachClasses"]);
673
- function omitConsumed(props) {
674
- const out = {};
675
- for (const key of Object.keys(props)) {
676
- if (!CONSUMED_PROPS.has(key)) out[key] = props[key];
677
- }
678
- return out;
679
- }
680
536
  function makeElement(isStaticChildren, type, props, key) {
681
537
  return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
682
538
  }
683
539
  function processElement(type, rawProps, key, isStaticChildren) {
684
- if (type === null || typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
685
- const webTag = (0, import_core6.getEffectiveIsWeb)() ? getWebTag(type, rawProps ?? void 0) : null;
686
- const effectiveType = webTag ?? type;
687
- const originalName = webTag ? type?.displayName ?? type?.name : void 0;
688
- if (!rawProps) return (0, import_jsx_runtime.jsx)(effectiveType, null, key);
689
- const workingProps = webTag && originalName ? transformToWebProps(originalName, webTag, rawProps) : rawProps;
690
- const { className, kb: kbProp, __kbachStyles, __kbachClasses } = workingProps;
691
- const classStrRaw = className ?? kbProp ?? __kbachClasses;
692
- if (classStrRaw !== void 0 && typeof classStrRaw !== "string") {
693
- return makeElement(isStaticChildren, effectiveType, workingProps, key);
694
- }
695
- const classStr = classStrRaw;
696
- const config = (0, import_core6.getConfig)();
697
- let expandedClassStr = classStr ? (0, import_core6.expandModeAwareColorClasses)(classStr, config.theme.colors) : classStr;
698
- if (!import_core6.isNative && (0, import_core6.isRuntimeCSSDisabled)() && expandedClassStr && !__kbachStyles) {
699
- const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
700
- return makeElement(isStaticChildren, effectiveType, {
701
- ...passProps2,
702
- className: (0, import_core6.normalizeClassString)(expandedClassStr),
703
- ...userStyle2 !== void 0 ? { style: userStyle2 } : {}
704
- }, key);
705
- }
706
- if (classStr && !__kbachStyles && /^(__[A-Za-z0-9_]+\s*)+$/.test(classStr.trim())) {
707
- const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
708
- return makeElement(isStaticChildren, effectiveType, {
709
- ...passProps2,
710
- className: classStr,
711
- ...userStyle2 !== void 0 ? { style: userStyle2 } : {}
712
- }, key);
713
- }
714
- if (!classStr && !__kbachStyles) {
715
- if ((0, import_core6.getEffectiveIsWeb)()) return makeElement(isStaticChildren, effectiveType, omitConsumed(workingProps), key);
716
- const defaultFont = getCachedDefaultFont();
717
- if (!defaultFont || getWebTag(type) !== "span") {
718
- return makeElement(isStaticChildren, effectiveType, workingProps, key);
719
- }
720
- const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
721
- const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
722
- return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
723
- }
724
- let resolved = import_core6.isNative && __kbachStyles != null ? __kbachStyles : expandedClassStr ? (0, import_core6.resolve)(expandedClassStr, config.theme, config.darkMode) : {};
725
- const impliedClasses = getImpliedRNClasses(webTag, resolved.base);
726
- if (impliedClasses) {
727
- expandedClassStr = expandedClassStr ? `${expandedClassStr} ${impliedClasses}` : impliedClasses;
728
- resolved = (0, import_core6.resolve)(expandedClassStr, config.theme, config.darkMode);
729
- }
730
- const { style: userStyle, ...passProps } = omitConsumed(workingProps);
731
- const { interactive, modeOrResponsive } = bucketMods(resolved);
732
- if (interactive) {
733
- return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
734
- Component: effectiveType,
735
- resolvedStyle: resolved,
736
- ...!import_core6.isNative && expandedClassStr ? { className: (0, import_core6.normalizeClassString)(expandedClassStr) } : {},
737
- style: userStyle,
738
- ...passProps
739
- }, key);
740
- }
741
- if (modeOrResponsive) {
742
- return (0, import_jsx_runtime.jsx)(DarkWrapper, {
743
- Component: effectiveType,
744
- resolvedStyle: resolved,
745
- ...!import_core6.isNative && expandedClassStr ? { className: (0, import_core6.normalizeClassString)(expandedClassStr) } : {},
746
- style: userStyle,
747
- ...passProps
748
- }, key);
540
+ if (type === null || typeof type === "symbol" || !rawProps) {
541
+ return makeElement(isStaticChildren, type, rawProps ?? {}, key);
749
542
  }
750
- const skipComputedInline = (0, import_core6.getEffectiveIsWeb)();
751
- let finalStyle;
752
- if (!skipComputedInline) {
753
- const computedStyle = (0, import_core6.flatten)(resolved, false);
754
- stripInternalMarkers(computedStyle);
755
- if (typeof effectiveType !== "string") stripWebOnlyProps(computedStyle);
756
- finalStyle = composeNativeStyle(computedStyle, userStyle);
757
- } else {
758
- finalStyle = userStyle ?? void 0;
543
+ const { className: classStrRaw, ...rest } = rawProps;
544
+ if (typeof classStrRaw !== "string") {
545
+ return makeElement(isStaticChildren, type, rawProps, key);
759
546
  }
760
- return makeElement(isStaticChildren, effectiveType, {
761
- ...passProps,
762
- ...finalStyle !== void 0 ? { style: finalStyle } : {},
763
- ...!import_core6.isNative && expandedClassStr ? { className: (0, import_core6.normalizeClassString)(expandedClassStr) } : {}
764
- }, key);
547
+ return makeElement(isStaticChildren, type, { ...rest, className: kb(classStrRaw) }, key);
765
548
  }
766
549
  function jsx(type, props, key) {
767
550
  return processElement(type, props, key, false);
@@ -772,8 +555,6 @@ function jsxs(type, props, key) {
772
555
  // Annotate the CommonJS export names for ESM import in node:
773
556
  0 && (module.exports = {
774
557
  Fragment,
775
- _invalidateDefaultFontCache,
776
558
  jsx,
777
- jsxs,
778
- registerWebElement
559
+ jsxs
779
560
  });