@kbach/ui 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,779 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/jsx-runtime.tsx
32
+ var jsx_runtime_exports = {};
33
+ __export(jsx_runtime_exports, {
34
+ Fragment: () => import_react4.Fragment,
35
+ _invalidateDefaultFontCache: () => _invalidateDefaultFontCache,
36
+ jsx: () => jsx,
37
+ jsxs: () => jsxs,
38
+ registerWebElement: () => registerWebElement
39
+ });
40
+ module.exports = __toCommonJS(jsx_runtime_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react4 = require("react");
43
+ var import_core6 = require("./core");
44
+
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");
51
+
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;
63
+ };
64
+
65
+ // src/useGlobalDarkMode.ts
66
+ var NOOP_SUB = (_) => () => {
67
+ };
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
+ );
75
+ }
76
+
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
+ }
118
+
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
+ };
136
+ }
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);
303
+ }
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;
341
+ }
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;
352
+ }
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;
361
+ }
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;
373
+ }
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;
588
+ }
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
+ }
626
+ if (isPressable && !out.role) out.role = "button";
627
+ if (isImage && tag === "img" && out.alt == null) out.alt = "";
628
+ return out;
629
+ }
630
+
631
+ // 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
+ function makeElement(isStaticChildren, type, props, key) {
681
+ return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
682
+ }
683
+ 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);
749
+ }
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;
759
+ }
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);
765
+ }
766
+ function jsx(type, props, key) {
767
+ return processElement(type, props, key, false);
768
+ }
769
+ function jsxs(type, props, key) {
770
+ return processElement(type, props, key, true);
771
+ }
772
+ // Annotate the CommonJS export names for ESM import in node:
773
+ 0 && (module.exports = {
774
+ Fragment,
775
+ _invalidateDefaultFontCache,
776
+ jsx,
777
+ jsxs,
778
+ registerWebElement
779
+ });