@kbach/ui 0.1.0-beta.7 → 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.
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
- 'use client';
2
1
  "use strict";
3
- var __create = Object.create;
4
2
  var __defProp = Object.defineProperty;
5
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
6
  var __export = (target, all) => {
10
7
  for (var name in all)
@@ -18,1184 +15,41 @@ var __copyProps = (to, from, except, desc) => {
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
19
 
31
20
  // src/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
34
- InteractiveWrapper: () => InteractiveWrapper,
35
- KbachReset: () => KbachReset,
36
- ThemeContext: () => ThemeContext,
37
- ThemeProvider: () => ThemeProvider,
38
- buildConfig: () => import_core13.buildConfig,
39
- clearCache: () => import_core13.clearCache,
40
- cx: () => cx,
41
- defaultColors: () => import_core13.defaultColors,
42
- defaultTheme: () => import_core13.defaultTheme,
43
- disableRuntimeCSS: () => import_core13.disableRuntimeCSS,
44
- flatten: () => import_core13.flatten,
45
- generateKbachTypesDts: () => import_core13.generateKbachTypesDts,
46
- getConfig: () => import_core13.getConfig,
47
- initConfig: () => import_core13.initConfig,
48
- kb: () => kb,
49
- normalizeClassString: () => import_core13.normalizeClassString,
50
- parseClass: () => import_core13.parseClass,
51
- parseClasses: () => import_core13.parseClasses,
52
- registerWebElement: () => registerWebElement,
53
- resolve: () => import_core13.resolve,
54
- setResolveTarget: () => import_core13.setResolveTarget,
55
- splitClassTokens: () => import_core13.splitClassTokens,
56
- styled: () => styled,
57
- updateConfig: () => import_core13.updateConfig,
58
- useBreakpoint: () => useBreakpoint,
59
- useColors: () => useColors,
60
- useGlobalDarkMode: () => useGlobalDarkMode,
61
- useIsDark: () => useIsDark,
62
- useResolvedStyle: () => useResolvedStyle,
63
- useResponsive: () => useResponsive,
64
- useSpacing: () => useSpacing,
65
- useStyles: () => useStyles,
66
- useTheme: () => useTheme,
67
- wrapColors: () => wrapColors,
68
- wrapSpacing: () => wrapSpacing
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ clsx: () => clsx,
24
+ default: () => src_default
69
25
  });
70
- module.exports = __toCommonJS(index_exports);
71
-
72
- // src/context.tsx
73
- var import_react = require("react");
74
- var import_core = require("./core");
75
- var ThemeContext = (0, import_core.getGlobalSingleton)("themeContext", () => (0, import_react.createContext)(null));
76
- function useTheme() {
77
- const ctx = (0, import_react.useContext)(ThemeContext);
78
- if (!ctx) {
79
- throw new Error(
80
- "[Kbach] useTheme() must be called inside a <ThemeProvider>. Wrap your app root with <ThemeProvider>."
81
- );
82
- }
83
- return ctx;
84
- }
85
- function useIsDark() {
86
- return useTheme().isDark;
87
- }
88
-
89
- // src/useColors.ts
90
- var import_react2 = require("react");
91
- var import_core2 = require("./core");
92
- function applyOpacity(color, opacity) {
93
- const a = Math.max(0, Math.min(1, opacity / 100));
94
- if (color.startsWith("#")) {
95
- const rgb = (0, import_core2.parseHexRgb)(color);
96
- if (!rgb) return color;
97
- const [r, g, b] = rgb;
98
- return `rgba(${r},${g},${b},${a})`;
99
- }
100
- if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
101
- if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
102
- return color;
103
- }
104
- function pickSide(value, isDark) {
105
- return (0, import_core2.isModeAwareColor)(value) ? isDark ? value.dark : value.light : value;
106
- }
107
- function makeShadeProxy(shades, isDark) {
108
- return new Proxy(shades, {
109
- get(target, prop) {
110
- const key = String(prop);
111
- if (key === "then") return void 0;
112
- if (key.includes("/")) {
113
- const slash = key.indexOf("/");
114
- const shade = key.slice(0, slash);
115
- const op = Number(key.slice(slash + 1));
116
- const color2 = target[shade];
117
- return color2 !== void 0 ? applyOpacity(pickSide(color2, isDark), op) : void 0;
118
- }
119
- const color = target[key];
120
- return color !== void 0 ? pickSide(color, isDark) : void 0;
121
- }
122
- });
123
- }
124
- function wrapColors(rawColors, isDark = false) {
125
- const cache = /* @__PURE__ */ new Map();
126
- const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
127
- return new Proxy({ alpha }, {
128
- get(_, prop) {
129
- const key = String(prop);
130
- if (key === "then") return void 0;
131
- if (key === "alpha") return alpha;
132
- if (key.includes("/")) {
133
- const slash = key.indexOf("/");
134
- const name = key.slice(0, slash);
135
- const op = Number(key.slice(slash + 1));
136
- const entry2 = rawColors[name];
137
- return entry2 !== void 0 && (typeof entry2 === "string" || (0, import_core2.isModeAwareColor)(entry2)) ? applyOpacity(pickSide(entry2, isDark), op) : void 0;
138
- }
139
- const entry = rawColors[key];
140
- if (entry === void 0) return void 0;
141
- if (typeof entry === "string" || (0, import_core2.isModeAwareColor)(entry)) return pickSide(entry, isDark);
142
- const cacheKey = `${key}:${isDark}`;
143
- if (!cache.has(cacheKey)) cache.set(cacheKey, makeShadeProxy(entry, isDark));
144
- return cache.get(cacheKey);
145
- }
146
- });
147
- }
148
- function useColors() {
149
- const { config, isDark } = useTheme();
150
- return (0, import_react2.useMemo)(() => wrapColors(config.theme.colors, isDark), [config.theme.colors, isDark]);
151
- }
152
-
153
- // src/useSpacing.ts
154
- var import_react3 = require("react");
155
- function wrapSpacing(rawSpacing) {
156
- return rawSpacing;
157
- }
158
- function useSpacing() {
159
- const { config } = useTheme();
160
- return (0, import_react3.useMemo)(() => wrapSpacing(config.theme.spacing), [config.theme.spacing]);
161
- }
162
-
163
- // src/ThemeProvider.tsx
164
- var import_react5 = require("react");
165
-
166
- // src/useSyncExternalStoreShim.ts
167
- var import_react4 = __toESM(require("react"));
168
- var useSyncExternalStore = import_react4.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
169
- const isServer = typeof window === "undefined";
170
- const [, forceUpdate] = import_react4.default.useReducer((n) => n + 1, 0);
171
- const value = isServer && getServerSnapshot ? getServerSnapshot() : getSnapshot();
172
- import_react4.default.useEffect(() => {
173
- if (getSnapshot() !== value) forceUpdate();
174
- return subscribe(forceUpdate);
175
- }, [subscribe]);
176
- return value;
177
- };
178
-
179
- // src/ThemeProvider.tsx
180
- var import_core3 = require("./core");
181
- var import_jsx_runtime = require("react/jsx-runtime");
182
- var useIsomorphicLayoutEffect = import_core3.isWeb || import_core3.isNative ? import_react5.useLayoutEffect : import_react5.useEffect;
183
- var STORAGE_KEY = "kbach-theme";
184
- var _mountedProviderCount = 0;
185
- var _warnedMultipleProviders = false;
186
- var _mountedConfigOverrideCount = 0;
187
- var _warnedConfigOverride = false;
188
- var _warnedMediaModeToggle = false;
189
- function loadPersistedMode() {
190
- try {
191
- if (import_core3.isWeb) return localStorage.getItem(STORAGE_KEY);
192
- return null;
193
- } catch {
194
- return null;
195
- }
196
- }
197
- function persistMode(mode) {
198
- try {
199
- if (import_core3.isWeb) localStorage.setItem(STORAGE_KEY, mode);
200
- } catch {
201
- }
202
- }
203
- function subscribeSystemScheme(callback) {
204
- if (!import_core3.isWeb || typeof window === "undefined") return () => {
205
- };
206
- const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
207
- if (!mq) return () => {
208
- };
209
- mq.addEventListener("change", callback);
210
- return () => mq.removeEventListener("change", callback);
211
- }
212
- function getSystemScheme() {
213
- if (!import_core3.isWeb || typeof window === "undefined") return "light";
214
- return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches ? "dark" : "light";
215
- }
216
- function getSystemSchemeServerSnapshot() {
217
- return "light";
218
- }
219
- function applyWebTheme(resolvedMode, strategy) {
220
- if (!import_core3.isWeb) return;
221
- const root = document.documentElement;
222
- if (strategy === "attribute") {
223
- root.setAttribute("data-theme", resolvedMode);
224
- } else if (strategy === "class") {
225
- root.classList.toggle("dark", resolvedMode === "dark");
226
- root.classList.toggle("light", resolvedMode === "light");
227
- }
228
- }
229
- function ThemeProvider({
230
- children,
231
- defaultMode = "system",
232
- colorScheme,
233
- windowWidth: windowWidthProp,
234
- config: configOverride,
235
- disablePersistence = false
236
- }) {
237
- let nativeColorScheme = null;
238
- let nativeWindowWidth;
239
- if (import_core3.isNative) {
240
- const { useColorScheme, useWindowDimensions } = require("react-native");
241
- const raw = useColorScheme();
242
- nativeColorScheme = raw === "dark" ? "dark" : raw === "light" ? "light" : null;
243
- nativeWindowWidth = useWindowDimensions().width;
244
- }
245
- const [resolvedConfig, setResolvedConfig] = (0, import_react5.useState)(
246
- () => configOverride ? (0, import_core3.buildConfig)(configOverride) : (0, import_core3.getConfig)()
247
- );
248
- const _prevConfigOverrideRef = (0, import_react5.useRef)(void 0);
249
- if (configOverride && _prevConfigOverrideRef.current !== configOverride) {
250
- _prevConfigOverrideRef.current = configOverride;
251
- (0, import_core3.updateConfig)(configOverride);
252
- const fresh = (0, import_core3.getConfig)();
253
- if (fresh !== resolvedConfig) setResolvedConfig(fresh);
26
+ module.exports = __toCommonJS(src_exports);
27
+ function clsx(...inputs) {
28
+ let out = "";
29
+ for (const input of inputs) {
30
+ const piece = resolveClassValue(input);
31
+ if (piece) out = out ? `${out} ${piece}` : piece;
254
32
  }
255
- (0, import_react5.useEffect)(() => {
256
- _mountedProviderCount++;
257
- if (configOverride) _mountedConfigOverrideCount++;
258
- if (process.env.NODE_ENV !== "production") {
259
- if (_mountedProviderCount > 1 && !_warnedMultipleProviders) {
260
- _warnedMultipleProviders = true;
261
- (0, import_core3.kbachWarn)(
262
- "Multiple <ThemeProvider> instances are mounted at once. Dark mode and responsive width are shared through one global store, so whichever provider rendered most recently wins for every consumer \u2014 nested or per-section theming is not isolated between providers."
263
- );
264
- }
265
- if (_mountedConfigOverrideCount > 1 && !_warnedConfigOverride) {
266
- _warnedConfigOverride = true;
267
- (0, import_core3.kbachWarn)(
268
- "Multiple <ThemeProvider config={...}> overrides are mounted at once. The resolved config is shared through the same global store as dark mode/width (see the multiple-providers warning), so per-tree config overrides are not actually isolated between providers \u2014 plain className/kb elements with no hover:/dark:/sm: modifier resolve against whichever override last committed, not necessarily their nearest ancestor <ThemeProvider>."
269
- );
270
- }
271
- }
272
- return () => {
273
- _mountedProviderCount--;
274
- if (configOverride) _mountedConfigOverrideCount--;
275
- if (_prevConfigOverrideRef.current !== void 0 && _mountedProviderCount === 0) {
276
- (0, import_core3.resetConfig)();
277
- }
278
- };
279
- }, []);
280
- const [webWidth, setWebWidth] = (0, import_react5.useState)(0);
281
- const effectiveWidth = (0, import_core3.getEffectiveIsWeb)() ? webWidth : windowWidthProp ?? nativeWindowWidth ?? 0;
282
- const numericScreens = (0, import_react5.useMemo)(() => {
283
- const out = {};
284
- for (const [k, v] of Object.entries(resolvedConfig.theme.screens ?? {})) {
285
- out[k] = typeof v === "number" ? v : parseInt(String(v), 10);
286
- }
287
- return out;
288
- }, [resolvedConfig.theme.screens]);
289
- const _prevWidthRef = (0, import_react5.useRef)(-1);
290
- if (_prevWidthRef.current !== effectiveWidth) {
291
- _prevWidthRef.current = effectiveWidth;
292
- (0, import_core3.syncGlobalWidth)(effectiveWidth);
293
- }
294
- const _prevScreensRef = (0, import_react5.useRef)(null);
295
- if (_prevScreensRef.current !== numericScreens) {
296
- _prevScreensRef.current = numericScreens;
297
- (0, import_core3.syncGlobalScreens)(numericScreens);
298
- }
299
- (0, import_react5.useEffect)(() => {
300
- (0, import_core3.setGlobalWidth)(effectiveWidth);
301
- }, [effectiveWidth]);
302
- (0, import_react5.useEffect)(() => {
303
- if (!import_core3.isWeb || typeof window === "undefined") return;
304
- setWebWidth(window.innerWidth);
305
- let raf = 0;
306
- const update = () => {
307
- cancelAnimationFrame(raf);
308
- raf = requestAnimationFrame(() => {
309
- const w = window.innerWidth;
310
- setWebWidth(w);
311
- (0, import_core3.setGlobalWidth)(w);
312
- });
313
- };
314
- window.addEventListener("resize", update);
315
- return () => {
316
- window.removeEventListener("resize", update);
317
- cancelAnimationFrame(raf);
318
- };
319
- }, []);
320
- const webScheme = useSyncExternalStore(
321
- subscribeSystemScheme,
322
- getSystemScheme,
323
- getSystemSchemeServerSnapshot
324
- );
325
- const systemScheme = (0, import_core3.getEffectiveIsWeb)() ? webScheme : (colorScheme ?? nativeColorScheme) === "dark" ? "dark" : "light";
326
- const [mode, _setMode] = (0, import_react5.useState)(defaultMode);
327
- (0, import_react5.useEffect)(() => {
328
- if (disablePersistence) return;
329
- const persisted = loadPersistedMode();
330
- if (persisted) _setMode(persisted);
331
- }, []);
332
- (0, import_react5.useEffect)(() => {
333
- if (disablePersistence || !import_core3.isWeb || typeof window === "undefined") return;
334
- const onStorage = (e) => {
335
- if (e.key !== STORAGE_KEY || e.newValue == null) return;
336
- if (e.newValue === "light" || e.newValue === "dark" || e.newValue === "system") {
337
- _setMode(e.newValue);
338
- }
339
- };
340
- window.addEventListener("storage", onStorage);
341
- return () => window.removeEventListener("storage", onStorage);
342
- }, [disablePersistence]);
343
- const setMode = (0, import_react5.useCallback)((next) => {
344
- if (process.env.NODE_ENV !== "production" && import_core3.isWeb && resolvedConfig.darkMode === "media" && !_warnedMediaModeToggle) {
345
- _warnedMediaModeToggle = true;
346
- (0, import_core3.kbachWarn)(
347
- 'setMode()/toggle() was called while darkMode is "media" \u2014 the resolved mode/isDark from useTheme()/useIsDark() will update, but the actual CSS stays driven by prefers-color-scheme and will not change to match. Use darkMode: "attribute" or "class" if the app needs manual toggling.'
348
- );
349
- }
350
- _setMode(next);
351
- if (!disablePersistence) persistMode(next);
352
- }, [disablePersistence, resolvedConfig.darkMode]);
353
- const toggle = (0, import_react5.useCallback)(() => {
354
- setMode(mode === "dark" || mode === "system" && systemScheme === "dark" ? "light" : "dark");
355
- }, [mode, systemScheme, setMode]);
356
- const resolvedMode = mode === "system" ? systemScheme : mode;
357
- const isDark = resolvedMode === "dark";
358
- (0, import_core3.syncGlobalDarkMode)(isDark);
359
- useIsomorphicLayoutEffect(() => {
360
- applyWebTheme(resolvedMode, resolvedConfig.darkMode);
361
- (0, import_core3.setGlobalDarkMode)(isDark);
362
- }, [isDark, resolvedMode, resolvedConfig.darkMode]);
363
- (0, import_react5.useEffect)(() => {
364
- if (configOverride) return;
365
- let mounted = true;
366
- const unsub = (0, import_core3.onConfigChange)((config) => {
367
- if (mounted) setResolvedConfig(config);
368
- });
369
- return () => {
370
- mounted = false;
371
- unsub();
372
- };
373
- }, [configOverride]);
374
- const contextValue = (0, import_react5.useMemo)(
375
- () => ({ mode, resolvedMode, isDark, setMode, toggle, config: resolvedConfig }),
376
- [mode, resolvedMode, isDark, setMode, toggle, resolvedConfig]
377
- );
378
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: contextValue, children });
379
- }
380
-
381
- // src/KbachReset.tsx
382
- var import_core4 = require("./core");
383
- var import_jsx_runtime2 = require("react/jsx-runtime");
384
- function KbachReset() {
385
- if (import_core4.isNative) return null;
386
- if ((0, import_core4.isRuntimeCSSDisabled)()) return null;
387
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { id: import_core4.RESET_STYLE_ID, children: import_core4.BASE_RESET });
388
- }
389
-
390
- // src/styled.tsx
391
- var import_react6 = __toESM(require("react"));
392
- var import_core8 = require("./core");
393
-
394
- // src/useGlobalDarkMode.ts
395
- var import_core5 = require("./core");
396
- var NOOP_SUB = (_) => () => {
397
- };
398
- var FALSE_SNAP = () => false;
399
- function useGlobalDarkMode() {
400
- return useSyncExternalStore(
401
- import_core5.subscribeGlobalDarkMode,
402
- import_core5.getGlobalDarkMode,
403
- () => false
404
- // SSR: default light
405
- );
406
- }
407
- function useConditionalGlobalDarkMode(active) {
408
- return useSyncExternalStore(
409
- active ? import_core5.subscribeGlobalDarkMode : NOOP_SUB,
410
- active ? import_core5.getGlobalDarkMode : FALSE_SNAP,
411
- FALSE_SNAP
412
- );
413
- }
414
-
415
- // src/useGlobalWidth.ts
416
- var import_core6 = require("./core");
417
- var NOOP_SUB2 = (_) => () => {
418
- };
419
- var ZERO_SNAP = () => 0;
420
- var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
421
- var _webListeners = null;
422
- var _webRaf = 0;
423
- function _webResizeHandler() {
424
- cancelAnimationFrame(_webRaf);
425
- _webRaf = requestAnimationFrame(() => {
426
- if (_webListeners) for (const cb of _webListeners) cb();
427
- });
428
- }
429
- function subscribeWebWidth(cb) {
430
- if (typeof window === "undefined") return () => {
431
- };
432
- if (!_webListeners) {
433
- _webListeners = /* @__PURE__ */ new Set();
434
- window.addEventListener("resize", _webResizeHandler);
435
- }
436
- _webListeners.add(cb);
437
- return () => {
438
- _webListeners.delete(cb);
439
- if (_webListeners.size === 0) {
440
- window.removeEventListener("resize", _webResizeHandler);
441
- cancelAnimationFrame(_webRaf);
442
- _webListeners = null;
443
- }
444
- };
445
- }
446
- function getWebWidth() {
447
- return typeof window !== "undefined" ? window.innerWidth : 0;
448
- }
449
- function useGlobalWidth() {
450
- return useSyncExternalStore(
451
- import_core6.isWeb ? subscribeWebWidth : import_core6.subscribeGlobalWidth,
452
- import_core6.isWeb ? getWebWidth : import_core6.getGlobalWidth,
453
- ZERO_SNAP
454
- );
455
- }
456
- function useConditionalWidth(active) {
457
- return useSyncExternalStore(
458
- active ? import_core6.isWeb ? subscribeWebWidth : import_core6.subscribeGlobalWidth : NOOP_SUB2,
459
- active ? import_core6.isWeb ? getWebWidth : import_core6.getGlobalWidth : ZERO_SNAP,
460
- ZERO_SNAP
461
- );
462
- }
463
-
464
- // src/shared-utils.ts
465
- var import_core7 = require("./core");
466
- function hasResponsiveBuckets(resolved) {
467
- const responsiveMods = (0, import_core7.getResponsiveModifiers)();
468
- for (const key of Object.keys(resolved)) {
469
- if (key === "base") continue;
470
- for (const mod of key.split(":")) {
471
- if (responsiveMods.has(mod)) return true;
472
- }
473
- }
474
- return false;
475
- }
476
- function hasInteractiveBuckets(resolved) {
477
- const interactiveMods = (0, import_core7.getInteractiveModifiers)();
478
- for (const key of Object.keys(resolved)) {
479
- if (key === "base") continue;
480
- for (const mod of key.split(":")) {
481
- if (interactiveMods.has(mod)) return true;
482
- }
483
- }
484
- return false;
485
- }
486
- function chain(original, extra) {
487
- return (...args) => {
488
- original?.(...args);
489
- extra();
490
- };
491
- }
492
- function stripInternalMarkers(s) {
493
- delete s.__divideX;
494
- delete s.__divideY;
495
- delete s.__divideColor;
496
- delete s.__divideStyle;
497
- delete s.__keyframe;
498
- }
499
- function stripWebOnlyProps(s) {
500
- if (s.display === "grid" || s.display === "inline-grid") delete s.display;
501
- delete s.gridTemplateColumns;
502
- delete s.gridTemplateRows;
503
- delete s.gridColumn;
504
- delete s.gridRow;
505
- delete s.gridArea;
506
- delete s.gridColumnStart;
507
- delete s.gridColumnEnd;
508
- delete s.gridRowStart;
509
- delete s.gridRowEnd;
510
- delete s.gridAutoFlow;
511
- delete s.gridAutoColumns;
512
- delete s.gridAutoRows;
513
- delete s.placeItems;
514
- delete s.placeContent;
515
- delete s.justifyItems;
516
- delete s.placeSelf;
517
- delete s.justifySelf;
518
- if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
519
- delete s.position;
520
- }
521
- }
522
- function composeNativeStyle(computed, userStyle) {
523
- if (!userStyle) return computed;
524
- return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
525
- }
526
-
527
- // src/web-substitute.ts
528
- var _rnToHtml = {
529
- View: "div",
530
- SafeAreaView: "div",
531
- KeyboardAvoidingView: "div",
532
- ScrollView: "div",
533
- VirtualizedList: "div",
534
- FlatList: "div",
535
- SectionList: "div",
536
- Text: "span",
537
- TextInput: "input",
538
- Image: "img",
539
- ImageBackground: "div",
540
- Pressable: "div",
541
- TouchableOpacity: "div",
542
- TouchableHighlight: "div",
543
- TouchableWithoutFeedback: "div",
544
- TouchableNativeFeedback: "div"
545
- };
546
- var _userMap = /* @__PURE__ */ new Map();
547
- var _cache = /* @__PURE__ */ new WeakMap();
548
- function registerWebElement(rnComponent, htmlTag) {
549
- if (typeof rnComponent !== "object" && typeof rnComponent !== "function") return;
550
- _userMap.set(rnComponent, htmlTag);
551
- _cache.delete(rnComponent);
552
- }
553
- var _forwardRefOrMemoType = /* @__PURE__ */ new Set([
554
- /* @__PURE__ */ Symbol.for("react.forward_ref"),
555
- /* @__PURE__ */ Symbol.for("react.memo")
556
- ]);
557
- function looksLikeRealRNPrimitive(type) {
558
- const t = type.$$typeof;
559
- if (t !== void 0) return _forwardRefOrMemoType.has(t);
560
- return !!type.prototype?.isReactComponent;
561
- }
562
- function getWebTag(type, props) {
563
- if (typeof type === "string") return null;
564
- if (type === null || typeof type !== "function" && typeof type !== "object") return null;
565
- const obj = type;
566
- if (_userMap.has(obj)) return _userMap.get(obj);
567
- if (!looksLikeRealRNPrimitive(obj)) return null;
568
- const name = obj.displayName ?? obj.name;
569
- if (!name) {
570
- _cache.set(obj, null);
571
- return null;
572
- }
573
- if (name === "TextInput") {
574
- const multiline = !!props && (props.multiline === true || Number(props.numberOfLines) > 1);
575
- return multiline ? "textarea" : "input";
576
- }
577
- if (_cache.has(obj)) return _cache.get(obj);
578
- const tag = _rnToHtml[name] ?? null;
579
- _cache.set(obj, tag);
580
- return tag;
581
- }
582
- function getImpliedRNClasses(webTag, resolvedBase) {
583
- if (!webTag || !resolvedBase) return void 0;
584
- const classes = [];
585
- if (resolvedBase.position === void 0) classes.push("relative");
586
- const explicitDisplay = resolvedBase.display;
587
- const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase || "gap" in resolvedBase || "columnGap" in resolvedBase || "rowGap" in resolvedBase;
588
- const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
589
- if (willBeFlex && (explicitDisplay === void 0 || resolvedBase.flexDirection === void 0)) {
590
- classes.push("flex-col");
591
- }
592
- return classes.length > 0 ? classes.join(" ") : void 0;
593
- }
594
- var _rnOnlyProps = /* @__PURE__ */ new Set([
595
- // Interaction
596
- "onLongPress",
597
- "delayLongPress",
598
- "activeOpacity",
599
- "underlayColor",
600
- "hitSlop",
601
- "pressRetentionOffset",
602
- "android_ripple",
603
- "android_disableSound",
604
- "onHoverIn",
605
- "onHoverOut",
606
- "onHoverStart",
607
- "onHoverEnd",
608
- // Layout event
609
- "onLayout",
610
- // Accessibility
611
- "accessible",
612
- "accessibilityState",
613
- "accessibilityLiveRegion",
614
- "importantForAccessibility",
615
- // Platform
616
- "nativeID",
617
- "collapsable",
618
- "needsOffscreenAlphaCompositing",
619
- "renderToHardwareTextureAndroid",
620
- "shouldRasterizeIOS",
621
- "focusable",
622
- "hasTVPreferredFocus",
623
- // 'pointerEvents' is handled in transformToWebProps (mapped to CSS style)
624
- // Text
625
- "selectable",
626
- "allowFontScaling",
627
- "adjustsFontSizeToFit",
628
- "minimumFontScale",
629
- "ellipsizeMode",
630
- "numberOfLines",
631
- "onTextLayout",
632
- "textBreakStrategy",
633
- "lineBreakStrategyIOS",
634
- // TextInput
635
- "multiline",
636
- // NOTE: 'resizeMode' (Image's prop, not TextInput's) deliberately does NOT
637
- // go here — it's handled below in the isImage branch (mapped to CSS
638
- // object-fit). Blacklisting it here would make that branch unreachable.
639
- "blurOnSubmit",
640
- "clearButtonMode",
641
- "clearTextOnFocus",
642
- "enablesReturnKeyAutomatically",
643
- "returnKeyType",
644
- "spellCheck",
645
- // ScrollView
646
- "scrollEnabled",
647
- "showsVerticalScrollIndicator",
648
- "showsHorizontalScrollIndicator",
649
- "contentContainerStyle",
650
- // 'horizontal' is handled in transformToWebProps (converted to CSS overflow-x).
651
- "keyboardShouldPersistTaps",
652
- "keyboardDismissMode",
653
- "pagingEnabled",
654
- "scrollEventThrottle",
655
- "decelerationRate",
656
- "bounces",
657
- "alwaysBounceHorizontal",
658
- "alwaysBounceVertical",
659
- "snapToAlignment",
660
- "snapToInterval",
661
- "snapToOffsets",
662
- "removeClippedSubviews",
663
- "overScrollMode",
664
- "stickyHeaderIndices",
665
- "invertStickyHeaders",
666
- "onScrollBeginDrag",
667
- "onScrollEndDrag",
668
- "onMomentumScrollBegin",
669
- "onMomentumScrollEnd",
670
- "contentInset",
671
- "contentInsetAdjustmentBehavior",
672
- "automaticallyAdjustContentInsets",
673
- "automaticallyAdjustsScrollIndicatorInsets",
674
- // expo-image
675
- "contentPosition",
676
- "cachePolicy",
677
- "recyclingKey",
678
- "blurRadius",
679
- "fadeDuration",
680
- "responsivePolicy",
681
- "tintColor",
682
- "allowDownscaling",
683
- "placeholderContentFit",
684
- // FlatList / SectionList
685
- "data",
686
- "renderItem",
687
- "keyExtractor",
688
- "getItemLayout",
689
- "initialScrollIndex",
690
- "initialNumToRender",
691
- "maxToRenderPerBatch",
692
- "windowSize",
693
- "updateCellsBatchingPeriod",
694
- "onEndReached",
695
- "onEndReachedThreshold",
696
- "ListHeaderComponent",
697
- "ListFooterComponent",
698
- "ListEmptyComponent",
699
- "ListHeaderComponentStyle",
700
- "ListFooterComponentStyle",
701
- "ItemSeparatorComponent",
702
- "SectionSeparatorComponent",
703
- "inverted",
704
- "getItem",
705
- "getItemCount"
706
- ]);
707
- var _pressableNames = /* @__PURE__ */ new Set([
708
- "Pressable",
709
- "TouchableOpacity",
710
- "TouchableHighlight",
711
- "TouchableWithoutFeedback",
712
- "TouchableNativeFeedback"
713
- ]);
714
- var _keyboardTypeMap = {
715
- "numeric": "number",
716
- "number-pad": "number",
717
- "decimal-pad": "decimal",
718
- "email-address": "email",
719
- "phone-pad": "tel",
720
- "url": "url"
721
- };
722
- var _resizeModeMap = {
723
- "contain": "contain",
724
- "cover": "cover",
725
- "stretch": "fill",
726
- "center": "none",
727
- "repeat": "none"
728
- };
729
- var PLACEHOLDER_RULE_ATTR = "data-kbach-ph";
730
- var _placeholderRuleInjected = false;
731
- function ensurePlaceholderColorRuleInjected() {
732
- if (_placeholderRuleInjected || typeof document === "undefined") return;
733
- _placeholderRuleInjected = true;
734
- const style = document.createElement("style");
735
- style.setAttribute("data-kbach-placeholder", "");
736
- style.textContent = `[${PLACEHOLDER_RULE_ATTR}]::placeholder{color:var(--kbach-ph-color)}`;
737
- document.head.appendChild(style);
738
- }
739
- function transformToWebProps(originalName, tag, props) {
740
- const out = {};
741
- const isPressable = _pressableNames.has(originalName);
742
- const isTextInput = originalName === "TextInput";
743
- const isImage = originalName === "Image" || originalName === "ImageBackground";
744
- const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
745
- let pendingStyle = null;
746
- for (const [k, v] of Object.entries(props)) {
747
- if (_rnOnlyProps.has(k)) continue;
748
- if (k === "onPress") {
749
- if (!("onClick" in props)) out.onClick = v;
750
- continue;
751
- }
752
- if (k === "accessibilityLabel") {
753
- if (out["aria-label"] == null) out["aria-label"] = v;
754
- continue;
755
- }
756
- if (k === "accessibilityRole") {
757
- if (out.role == null) out.role = v;
758
- continue;
759
- }
760
- if (k === "testID") {
761
- if (out["data-testid"] == null) out["data-testid"] = v;
762
- continue;
763
- }
764
- if (isTextInput) {
765
- if (k === "onChangeText") {
766
- if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
767
- continue;
768
- }
769
- if (k === "onSubmitEditing") {
770
- if (!("onKeyDown" in props)) {
771
- out.onKeyDown = (e) => {
772
- if (e.key === "Enter") v();
773
- };
774
- }
775
- continue;
776
- }
777
- if (k === "placeholderTextColor") {
778
- if (v) {
779
- ensurePlaceholderColorRuleInjected();
780
- out[PLACEHOLDER_RULE_ATTR] = "";
781
- pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
782
- }
783
- continue;
784
- }
785
- if (k === "secureTextEntry") {
786
- if (v && !("type" in props)) out.type = "password";
787
- continue;
788
- }
789
- if (k === "keyboardType") {
790
- if (!("type" in props) && !props.secureTextEntry) {
791
- const mapped = _keyboardTypeMap[v];
792
- if (mapped) out.type = mapped;
793
- }
794
- continue;
795
- }
796
- if (k === "editable") {
797
- if (v === false) out.readOnly = true;
798
- continue;
799
- }
800
- if (k === "maxLength") {
801
- out.maxLength = v;
802
- continue;
803
- }
804
- }
805
- if (isScrollable && k === "horizontal") {
806
- if (v) pendingStyle = { ...pendingStyle ?? {}, display: "flex", flexDirection: "row", overflowX: "auto" };
807
- continue;
808
- }
809
- if (k === "pointerEvents") {
810
- if (v === "none" || v === "auto") pendingStyle = { ...pendingStyle ?? {}, pointerEvents: v };
811
- continue;
812
- }
813
- if (isImage) {
814
- if (k === "source") {
815
- if (typeof v === "string") {
816
- out.src = v;
817
- } else if (v && typeof v === "object" && "uri" in v) {
818
- out.src = v.uri;
819
- if (v.headers) out["crossOrigin"] = "anonymous";
820
- }
821
- continue;
822
- }
823
- if (k === "resizeMode") {
824
- pendingStyle = { ...pendingStyle ?? {}, objectFit: _resizeModeMap[v] ?? "cover" };
825
- continue;
826
- }
827
- if (k === "contentFit") {
828
- pendingStyle = { ...pendingStyle ?? {}, objectFit: v };
829
- continue;
830
- }
831
- if (k === "defaultSource") continue;
832
- }
833
- if (k === "style") {
834
- if (Array.isArray(v)) {
835
- out.style = Object.assign({}, ...v.filter(Boolean));
836
- } else if (v != null) {
837
- out.style = v;
838
- }
839
- continue;
840
- }
841
- out[k] = v;
842
- }
843
- if (pendingStyle) {
844
- out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
845
- }
846
- if (isPressable && !out.role) out.role = "button";
847
- if (isImage && tag === "img" && out.alt == null) out.alt = "";
848
33
  return out;
849
34
  }
850
-
851
- // src/styled.tsx
852
- function styled(Component, baseClasses = "") {
853
- const Styled = (0, import_react6.forwardRef)(
854
- (props, ref) => {
855
- const {
856
- kb: extraClasses,
857
- style: styleProp,
858
- onPressIn,
859
- onPressOut,
860
- onPointerDown,
861
- onPointerUp,
862
- onPointerLeave,
863
- onPointerCancel,
864
- onMouseEnter,
865
- onMouseLeave,
866
- onFocus,
867
- onBlur,
868
- ...rest
869
- } = props;
870
- const disabled = !!props.disabled;
871
- const checked = !!props.checked;
872
- const { config } = useTheme();
873
- const isWebPlatform = (0, import_core8.getEffectiveIsWeb)();
874
- const isDark = useConditionalGlobalDarkMode(!isWebPlatform);
875
- const [pressed, setPressed] = (0, import_react6.useState)(false);
876
- const [hovered, setHovered] = (0, import_react6.useState)(false);
877
- const [focused, setFocused] = (0, import_react6.useState)(false);
878
- const handlePressIn = (0, import_react6.useCallback)(chain(onPressIn, () => {
879
- if (!isWebPlatform) setPressed(true);
880
- }), [onPressIn, isWebPlatform]);
881
- const handlePressOut = (0, import_react6.useCallback)(chain(onPressOut, () => {
882
- if (!isWebPlatform) setPressed(false);
883
- }), [onPressOut, isWebPlatform]);
884
- const handlePointerDown = (0, import_react6.useCallback)(chain(onPointerDown, () => {
885
- if (!isWebPlatform) setPressed(true);
886
- }), [onPointerDown, isWebPlatform]);
887
- const handlePointerUp = (0, import_react6.useCallback)(chain(onPointerUp, () => {
888
- if (!isWebPlatform) setPressed(false);
889
- }), [onPointerUp, isWebPlatform]);
890
- const handlePointerLeave = (0, import_react6.useCallback)(chain(onPointerLeave, () => {
891
- if (!isWebPlatform) setPressed(false);
892
- }), [onPointerLeave, isWebPlatform]);
893
- const handlePointerCancel = (0, import_react6.useCallback)(chain(onPointerCancel, () => {
894
- if (!isWebPlatform) setPressed(false);
895
- }), [onPointerCancel, isWebPlatform]);
896
- const handleMouseEnter = (0, import_react6.useCallback)(chain(onMouseEnter, () => {
897
- if (!isWebPlatform) setHovered(true);
898
- }), [onMouseEnter, isWebPlatform]);
899
- const handleMouseLeave = (0, import_react6.useCallback)(chain(onMouseLeave, () => {
900
- if (!isWebPlatform) setHovered(false);
901
- }), [onMouseLeave, isWebPlatform]);
902
- const handleFocus = (0, import_react6.useCallback)(chain(onFocus, () => {
903
- if (!isWebPlatform) setFocused(true);
904
- }), [onFocus, isWebPlatform]);
905
- const handleBlur = (0, import_react6.useCallback)(chain(onBlur, () => {
906
- if (!isWebPlatform) setFocused(false);
907
- }), [onBlur, isWebPlatform]);
908
- const combined = extraClasses ? `${baseClasses} ${extraClasses}` : baseClasses;
909
- const firstPassResolved = (0, import_react6.useMemo)(() => (0, import_core8.resolve)(combined, config.theme, config.darkMode), [combined, config.theme, config.darkMode]);
910
- const webTag = isWebPlatform ? getWebTag(Component, rest) : null;
911
- const impliedClasses = getImpliedRNClasses(webTag, firstPassResolved.base);
912
- const finalClassStr = impliedClasses ? `${combined} ${impliedClasses}` : combined;
913
- const resolved = (0, import_react6.useMemo)(() => (0, import_core8.resolve)(finalClassStr, config.theme, config.darkMode), [finalClassStr, config.theme, config.darkMode]);
914
- const hasInteractive = (0, import_react6.useMemo)(() => hasInteractiveBuckets(resolved), [resolved]);
915
- const needsWidth = hasResponsiveBuckets(resolved);
916
- const width = useConditionalWidth(needsWidth && !isWebPlatform);
917
- const breakpoints = needsWidth ? (0, import_core8.getActiveBreakpoints)(width) : EMPTY_BREAKPOINTS;
918
- const screens = (0, import_core8.getGlobalScreens)();
919
- const computedStyle = (0, import_react6.useMemo)(
920
- () => isWebPlatform ? {} : (0, import_core8.flatten)(resolved, isDark, { pressed, hover: hovered, focus: focused, disabled, checked }, breakpoints),
921
- [resolved, isDark, pressed, hovered, focused, disabled, checked, width, screens]
922
- // eslint-disable-line react-hooks/exhaustive-deps
923
- );
924
- const finalStyle = isWebPlatform ? (Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp) ?? void 0 : composeNativeStyle(computedStyle, styleProp);
925
- const effectiveComponent = webTag ?? Component;
926
- const componentName2 = Component.displayName ?? Component.name ?? "";
927
- const effectiveRest = webTag && componentName2 ? transformToWebProps(componentName2, webTag, rest) : rest;
928
- return import_react6.default.createElement(effectiveComponent, {
929
- ref,
930
- ...effectiveRest,
931
- style: finalStyle,
932
- // className lets injected CSS rules (group-hover:, before:, print:, etc.) match the element.
933
- ...isWebPlatform && finalClassStr ? { className: (0, import_core8.normalizeClassString)(finalClassStr) } : {},
934
- // Only attach state-tracking handlers when interactive modifiers are present.
935
- // Always forward user-provided handlers to avoid silently swallowing them.
936
- // Gated on isNative, not isWeb: isWeb is false during SSR too (no `window` there),
937
- // and onPressIn/onPressOut must stay excluded there as well — SSR is exactly where
938
- // getWebTag() above is skipped (it's isWeb-gated), so effectiveComponent may still be
939
- // a non-string RN-style reference server-side, and this used to forward onPressIn/
940
- // onPressOut to it unconditionally in that case (isWeb ? ... : ...'s false branch
941
- // covered both native AND SSR). onPressIn/onPressOut are RN-only prop names — a
942
- // non-string effectiveComponent on the web/SSR side is just as likely to be an
943
- // ordinary web component (React Router's <Link>, Next.js's <Link>, any custom
944
- // wrapper) as an actual react-native-web primitive, and "not a string" alone isn't a
945
- // reliable signal either way. Forwarding them made React DOM warn "Unknown event
946
- // handler property" the moment any such component got an interactive modifier
947
- // (hover:, active:, …), which is the common case, not the exception.
948
- ...!import_core8.isNative ? hasInteractive ? {
949
- onPointerDown: handlePointerDown,
950
- onPointerUp: handlePointerUp,
951
- onPointerLeave: handlePointerLeave,
952
- onPointerCancel: handlePointerCancel
953
- } : {
954
- onPointerDown,
955
- onPointerUp,
956
- onPointerLeave,
957
- onPointerCancel
958
- } : hasInteractive ? { onPressIn: handlePressIn, onPressOut: handlePressOut } : { onPressIn, onPressOut },
959
- onMouseEnter: hasInteractive ? handleMouseEnter : onMouseEnter,
960
- onMouseLeave: hasInteractive ? handleMouseLeave : onMouseLeave,
961
- onFocus: hasInteractive ? handleFocus : onFocus,
962
- onBlur: hasInteractive ? handleBlur : onBlur
963
- });
964
- }
965
- );
966
- const componentName = Component.displayName ?? Component.name ?? "Component";
967
- Styled.displayName = `Styled(${componentName})`;
968
- return Styled;
969
- }
970
-
971
- // src/useStyles.ts
972
- var import_react7 = require("react");
973
- var import_core9 = require("./core");
974
- function useStyles(classString, state = {}) {
975
- const { isDark, config } = useTheme();
976
- const width = useGlobalWidth();
977
- const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
978
- return (0, import_react7.useMemo)(() => {
979
- const resolved = (0, import_core9.resolve)(normalised, config.theme, config.darkMode);
980
- const breakpoints = (0, import_core9.getActiveBreakpoints)(width);
981
- return (0, import_core9.flatten)(resolved, isDark, state, breakpoints);
982
- }, [normalised, isDark, config.theme, config.darkMode, width, state.hover, state.focus, state.pressed, state.active, state.disabled, state.checked, state.visited, state.placeholder]);
983
- }
984
- function useResolvedStyle(classString) {
985
- const { config } = useTheme();
986
- const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
987
- return (0, import_react7.useMemo)(
988
- () => (0, import_core9.resolve)(normalised, config.theme, config.darkMode),
989
- [normalised, config]
990
- );
991
- }
992
-
993
- // src/useBreakpoint.ts
994
- var import_react8 = require("react");
995
- var import_core10 = require("./core");
996
- function toNumericScreens(screens) {
997
- const out = {};
998
- for (const [name, v] of Object.entries(screens)) {
999
- const n = typeof v === "number" ? v : parseInt(String(v), 10);
1000
- if (!Number.isNaN(n)) out[name] = n;
1001
- }
1002
- return out;
1003
- }
1004
- function useBreakpoint() {
1005
- const { config } = useTheme();
1006
- const width = useGlobalWidth();
1007
- const screens = config.theme.screens;
1008
- const numericScreens = (0, import_react8.useMemo)(() => toNumericScreens(screens), [screens]);
1009
- return (0, import_react8.useMemo)(() => {
1010
- const active = (0, import_core10.getActiveBreakpoints)(width, numericScreens);
1011
- let best = null;
1012
- let bestMinW = -Infinity;
1013
- for (const name of active) {
1014
- const minW = numericScreens[name];
1015
- if (minW > bestMinW) {
1016
- bestMinW = minW;
1017
- best = name;
35
+ function resolveClassValue(value) {
36
+ if (!value) return "";
37
+ const type = typeof value;
38
+ if (type === "string" || type === "number" || type === "bigint") return String(value);
39
+ if (Array.isArray(value)) return clsx(...value);
40
+ if (type === "object") {
41
+ let out = "";
42
+ for (const key in value) {
43
+ if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
44
+ out = out ? `${out} ${key}` : key;
1018
45
  }
1019
46
  }
1020
- return best ?? "xs";
1021
- }, [numericScreens, width]);
1022
- }
1023
- function useResponsive() {
1024
- const { config } = useTheme();
1025
- const width = useGlobalWidth();
1026
- const screens = config.theme.screens;
1027
- const numericScreens = (0, import_react8.useMemo)(() => toNumericScreens(screens), [screens]);
1028
- return (0, import_react8.useMemo)(() => {
1029
- const active = (0, import_core10.getActiveBreakpoints)(width, numericScreens);
1030
- const result = {};
1031
- for (const name of Object.keys(numericScreens)) {
1032
- result[name] = active.has(name);
1033
- }
1034
- return result;
1035
- }, [numericScreens, width]);
1036
- }
1037
-
1038
- // src/InteractiveWrapper.tsx
1039
- var import_react9 = __toESM(require("react"));
1040
- var import_core11 = require("./core");
1041
- var InteractiveWrapper = (0, import_react9.forwardRef)(
1042
- function InteractiveWrapper2({
1043
- Component,
1044
- resolvedStyle,
1045
- className,
1046
- style: styleProp,
1047
- onPressIn,
1048
- onPressOut,
1049
- onPointerDown,
1050
- onPointerUp,
1051
- onPointerLeave,
1052
- onPointerCancel,
1053
- onMouseEnter,
1054
- onMouseLeave,
1055
- onFocus,
1056
- onBlur,
1057
- ...rest
1058
- }, ref) {
1059
- const isWebPlatform = (0, import_core11.getEffectiveIsWeb)();
1060
- const isDark = useConditionalGlobalDarkMode(!isWebPlatform);
1061
- const needsWidth = hasResponsiveBuckets(resolvedStyle);
1062
- const width = useConditionalWidth(needsWidth && !isWebPlatform);
1063
- const breakpoints = needsWidth ? (0, import_core11.getActiveBreakpoints)(width) : EMPTY_BREAKPOINTS;
1064
- const screens = (0, import_core11.getGlobalScreens)();
1065
- const [pressed, setPressed] = (0, import_react9.useState)(false);
1066
- const [hovered, setHovered] = (0, import_react9.useState)(false);
1067
- const [focused, setFocused] = (0, import_react9.useState)(false);
1068
- const handlePressIn = (0, import_react9.useCallback)(chain(onPressIn, () => {
1069
- if (!isWebPlatform) setPressed(true);
1070
- }), [onPressIn, isWebPlatform]);
1071
- const handlePressOut = (0, import_react9.useCallback)(chain(onPressOut, () => {
1072
- if (!isWebPlatform) setPressed(false);
1073
- }), [onPressOut, isWebPlatform]);
1074
- const handlePointerDown = (0, import_react9.useCallback)(chain(onPointerDown, () => {
1075
- if (!isWebPlatform) setPressed(true);
1076
- }), [onPointerDown, isWebPlatform]);
1077
- const handlePointerUp = (0, import_react9.useCallback)(chain(onPointerUp, () => {
1078
- if (!isWebPlatform) setPressed(false);
1079
- }), [onPointerUp, isWebPlatform]);
1080
- const handlePointerLeave = (0, import_react9.useCallback)(chain(onPointerLeave, () => {
1081
- if (!isWebPlatform) setPressed(false);
1082
- }), [onPointerLeave, isWebPlatform]);
1083
- const handlePointerCancel = (0, import_react9.useCallback)(chain(onPointerCancel, () => {
1084
- if (!isWebPlatform) setPressed(false);
1085
- }), [onPointerCancel, isWebPlatform]);
1086
- const handleMouseEnter = (0, import_react9.useCallback)(chain(onMouseEnter, () => {
1087
- if (!isWebPlatform) setHovered(true);
1088
- }), [onMouseEnter, isWebPlatform]);
1089
- const handleMouseLeave = (0, import_react9.useCallback)(chain(onMouseLeave, () => {
1090
- if (!isWebPlatform) setHovered(false);
1091
- }), [onMouseLeave, isWebPlatform]);
1092
- const handleFocus = (0, import_react9.useCallback)(chain(onFocus, () => {
1093
- if (!isWebPlatform) setFocused(true);
1094
- }), [onFocus, isWebPlatform]);
1095
- const handleBlur = (0, import_react9.useCallback)(chain(onBlur, () => {
1096
- if (!isWebPlatform) setFocused(false);
1097
- }), [onBlur, isWebPlatform]);
1098
- const { children, disabled, checked, ...restForComponent } = rest;
1099
- const isNonStringComponent = typeof Component !== "string";
1100
- const computedStyle = (0, import_react9.useMemo)(
1101
- () => {
1102
- if (isWebPlatform) return {};
1103
- const s = (0, import_core11.flatten)(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
1104
- stripInternalMarkers(s);
1105
- if (isNonStringComponent) stripWebOnlyProps(s);
1106
- return s;
1107
- },
1108
- [resolvedStyle, isDark, pressed, hovered, focused, width, screens, disabled, checked, isNonStringComponent]
1109
- );
1110
- const skipComputedInline = isWebPlatform;
1111
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : composeNativeStyle(computedStyle, styleProp);
1112
- const componentProps = {
1113
- ref,
1114
- ...restForComponent,
1115
- ...disabled !== void 0 ? { disabled } : {},
1116
- ...checked !== void 0 ? { checked } : {},
1117
- style: finalStyle,
1118
- ...!import_core11.isNative && className ? { className } : {},
1119
- // On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch) —
1120
- // onPressIn/onPressOut are RN-only prop names and are never forwarded here, even when
1121
- // Component isn't a literal HTML tag string. A non-string Component on web is just as
1122
- // likely to be an ordinary web component (React Router's <Link>, Next.js's <Link>, any
1123
- // custom wrapper) as an actual react-native-web primitive — "not a string" alone was never
1124
- // a reliable signal that onPressIn/onPressOut are wanted, and forwarding them
1125
- // unconditionally made React DOM warn "Unknown event handler property" the moment any web
1126
- // component got an interactive modifier (hover:, active:, …), which is the common case,
1127
- // not the exception. (A real react-native-web primitive would additionally have this pair
1128
- // of props silently vanish after hydration anyway, once the browser-only web-substitution
1129
- // in jsx-runtime.tsx swaps it for a plain host tag — so keeping them pre-hydration would
1130
- // only have traded one prop-mismatch warning for another.) Genuinely native code paths
1131
- // still get them via the isNative branch below.
1132
- ...!import_core11.isNative ? {
1133
- onPointerDown: handlePointerDown,
1134
- onPointerUp: handlePointerUp,
1135
- onPointerLeave: handlePointerLeave,
1136
- onPointerCancel: handlePointerCancel
1137
- } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
1138
- onMouseEnter: handleMouseEnter,
1139
- onMouseLeave: handleMouseLeave,
1140
- onFocus: handleFocus,
1141
- onBlur: handleBlur
1142
- };
1143
- return Array.isArray(children) ? import_react9.default.createElement(Component, componentProps, ...children) : import_react9.default.createElement(Component, componentProps, children);
1144
- }
1145
- );
1146
- InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
1147
-
1148
- // src/kb.ts
1149
- var import_core12 = require("./core");
1150
- function kb(classString, isDark = false) {
1151
- const config = (0, import_core12.getConfig)();
1152
- const resolved = (0, import_core12.resolve)(classString, config.theme, config.darkMode);
1153
- if ((0, import_core12.getEffectiveIsWeb)()) {
1154
- return classString;
47
+ return out;
1155
48
  }
1156
- return (0, import_core12.flatten)(resolved, isDark);
49
+ return "";
1157
50
  }
1158
- function cx(...classes) {
1159
- return classes.filter(Boolean).join(" ");
1160
- }
1161
-
1162
- // src/index.ts
1163
- var import_core13 = require("./core");
51
+ var src_default = clsx;
1164
52
  // Annotate the CommonJS export names for ESM import in node:
1165
53
  0 && (module.exports = {
1166
- InteractiveWrapper,
1167
- KbachReset,
1168
- ThemeContext,
1169
- ThemeProvider,
1170
- buildConfig,
1171
- clearCache,
1172
- cx,
1173
- defaultColors,
1174
- defaultTheme,
1175
- disableRuntimeCSS,
1176
- flatten,
1177
- generateKbachTypesDts,
1178
- getConfig,
1179
- initConfig,
1180
- kb,
1181
- normalizeClassString,
1182
- parseClass,
1183
- parseClasses,
1184
- registerWebElement,
1185
- resolve,
1186
- setResolveTarget,
1187
- splitClassTokens,
1188
- styled,
1189
- updateConfig,
1190
- useBreakpoint,
1191
- useColors,
1192
- useGlobalDarkMode,
1193
- useIsDark,
1194
- useResolvedStyle,
1195
- useResponsive,
1196
- useSpacing,
1197
- useStyles,
1198
- useTheme,
1199
- wrapColors,
1200
- wrapSpacing
54
+ clsx
1201
55
  });