@kbach/react 0.1.9 → 0.2.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.
@@ -5,7 +5,7 @@ import {
5
5
  isWeb,
6
6
  resolve,
7
7
  useGlobalDarkMode
8
- } from "./chunk-PYBA3DFG.mjs";
8
+ } from "./chunk-MXJINF4T.mjs";
9
9
 
10
10
  // src/jsx-runtime.tsx
11
11
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
@@ -1104,62 +1104,64 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1104
1104
  }
1105
1105
  var STANDALONE = {
1106
1106
  // Display
1107
- flex: { display: "flex" },
1108
- block: { display: "block" },
1109
- "inline-block": { display: "inline-block" },
1110
- inline: { display: "inline" },
1111
- grid: { display: "grid" },
1112
- "inline-flex": { display: "inline-flex" },
1113
- "inline-grid": { display: "inline-grid" },
1107
+ // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1108
+ // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1109
+ flex: isWeb ? { display: "flex" } : {},
1110
+ block: isWeb ? { display: "block" } : null,
1111
+ "inline-block": isWeb ? { display: "inline-block" } : null,
1112
+ inline: isWeb ? { display: "inline" } : null,
1113
+ grid: isWeb ? { display: "grid" } : null,
1114
+ "inline-flex": isWeb ? { display: "inline-flex" } : {},
1115
+ "inline-grid": isWeb ? { display: "inline-grid" } : null,
1114
1116
  hidden: { display: "none" },
1115
- contents: { display: "contents" },
1116
- "flow-root": { display: "flow-root" },
1117
- // Flex direction
1117
+ contents: isWeb ? { display: "contents" } : null,
1118
+ "flow-root": isWeb ? { display: "flow-root" } : null,
1119
+ // Flex direction (both web and native)
1118
1120
  "flex-row": { flexDirection: "row" },
1119
1121
  "flex-col": { flexDirection: "column" },
1120
1122
  "flex-row-reverse": { flexDirection: "row-reverse" },
1121
1123
  "flex-col-reverse": { flexDirection: "column-reverse" },
1122
- // Flex wrap
1124
+ // Flex wrap (both)
1123
1125
  "flex-wrap": { flexWrap: "wrap" },
1124
1126
  "flex-wrap-reverse": { flexWrap: "wrap-reverse" },
1125
1127
  "flex-nowrap": { flexWrap: "nowrap" },
1126
- // Flex grow / shrink
1128
+ // Flex grow / shrink (both)
1127
1129
  "flex-grow": { flexGrow: 1 },
1128
1130
  "flex-grow-0": { flexGrow: 0 },
1129
1131
  "flex-shrink": { flexShrink: 1 },
1130
1132
  "flex-shrink-0": { flexShrink: 0 },
1131
- // Align items
1133
+ // Align items (both)
1132
1134
  "items-start": { alignItems: "flex-start" },
1133
1135
  "items-end": { alignItems: "flex-end" },
1134
1136
  "items-center": { alignItems: "center" },
1135
1137
  "items-baseline": { alignItems: "baseline" },
1136
1138
  "items-stretch": { alignItems: "stretch" },
1137
- // Justify content
1139
+ // Justify content (both)
1138
1140
  "justify-start": { justifyContent: "flex-start" },
1139
1141
  "justify-end": { justifyContent: "flex-end" },
1140
1142
  "justify-center": { justifyContent: "center" },
1141
1143
  "justify-between": { justifyContent: "space-between" },
1142
1144
  "justify-around": { justifyContent: "space-around" },
1143
1145
  "justify-evenly": { justifyContent: "space-evenly" },
1144
- // Align content
1146
+ // Align content (both)
1145
1147
  "content-start": { alignContent: "flex-start" },
1146
1148
  "content-end": { alignContent: "flex-end" },
1147
1149
  "content-center": { alignContent: "center" },
1148
1150
  "content-between": { alignContent: "space-between" },
1149
1151
  "content-around": { alignContent: "space-around" },
1150
1152
  "content-evenly": { alignContent: "space-evenly" },
1151
- // Align self
1153
+ // Align self (both)
1152
1154
  "self-auto": { alignSelf: "auto" },
1153
1155
  "self-start": { alignSelf: "flex-start" },
1154
1156
  "self-end": { alignSelf: "flex-end" },
1155
1157
  "self-center": { alignSelf: "center" },
1156
1158
  "self-stretch": { alignSelf: "stretch" },
1157
- // Text align
1159
+ // Text align (both)
1158
1160
  "text-left": { textAlign: "left" },
1159
1161
  "text-right": { textAlign: "right" },
1160
1162
  "text-center": { textAlign: "center" },
1161
1163
  "text-justify": { textAlign: "justify" },
1162
- // Font weight shortcuts
1164
+ // Font weight shortcuts (both)
1163
1165
  "font-thin": { fontWeight: "100" },
1164
1166
  "font-extralight": { fontWeight: "200" },
1165
1167
  "font-light": { fontWeight: "300" },
@@ -1169,94 +1171,95 @@ var STANDALONE = {
1169
1171
  "font-bold": { fontWeight: "700" },
1170
1172
  "font-extrabold": { fontWeight: "800" },
1171
1173
  "font-black": { fontWeight: "900" },
1172
- // Text decoration
1174
+ // Text decoration (overline is web-only)
1173
1175
  underline: { textDecorationLine: "underline" },
1174
- overline: { textDecorationLine: "overline" },
1176
+ overline: isWeb ? { textDecorationLine: "overline" } : null,
1175
1177
  "line-through": { textDecorationLine: "line-through" },
1176
1178
  "no-underline": { textDecorationLine: "none" },
1177
- // Text transform
1179
+ // Text transform (both)
1178
1180
  uppercase: { textTransform: "uppercase" },
1179
1181
  lowercase: { textTransform: "lowercase" },
1180
1182
  capitalize: { textTransform: "capitalize" },
1181
1183
  "normal-case": { textTransform: "none" },
1182
- // Font style
1184
+ // Font style (both)
1183
1185
  italic: { fontStyle: "italic" },
1184
1186
  "non-italic": { fontStyle: "normal" },
1185
- // Position
1187
+ // Position (fixed/sticky/static are web-only; RN only supports relative/absolute)
1186
1188
  relative: { position: "relative" },
1187
1189
  absolute: { position: "absolute" },
1188
- fixed: { position: "fixed" },
1189
- sticky: { position: "sticky" },
1190
- static: { position: "static" },
1191
- // Visibility
1192
- visible: { visibility: "visible" },
1193
- invisible: { visibility: "hidden" },
1194
- // Overflow
1190
+ fixed: isWeb ? { position: "fixed" } : null,
1191
+ sticky: isWeb ? { position: "sticky" } : null,
1192
+ static: isWeb ? { position: "static" } : null,
1193
+ // Visibility (no `visibility` prop on native; use opacity instead)
1194
+ visible: isWeb ? { visibility: "visible" } : null,
1195
+ invisible: isWeb ? { visibility: "hidden" } : { opacity: 0 },
1196
+ // Overflow (RN supports 'hidden' | 'visible' | 'scroll'; not 'auto')
1195
1197
  "overflow-hidden": { overflow: "hidden" },
1196
1198
  "overflow-visible": { overflow: "visible" },
1197
1199
  "overflow-scroll": { overflow: "scroll" },
1198
- "overflow-auto": { overflow: "auto" },
1199
- "overflow-x-hidden": { overflowX: "hidden" },
1200
- "overflow-x-scroll": { overflowX: "scroll" },
1201
- "overflow-x-auto": { overflowX: "auto" },
1202
- "overflow-y-hidden": { overflowY: "hidden" },
1203
- "overflow-y-scroll": { overflowY: "scroll" },
1204
- "overflow-y-auto": { overflowY: "auto" },
1205
- // Object fit
1206
- "object-contain": { objectFit: "contain" },
1207
- "object-cover": { objectFit: "cover" },
1208
- "object-fill": { objectFit: "fill" },
1209
- "object-none": { objectFit: "none" },
1210
- "object-scale-down": { objectFit: "scale-down" },
1211
- // Border style
1200
+ "overflow-auto": isWeb ? { overflow: "auto" } : { overflow: "scroll" },
1201
+ // overflowX / overflowY are web-only
1202
+ "overflow-x-hidden": isWeb ? { overflowX: "hidden" } : null,
1203
+ "overflow-x-scroll": isWeb ? { overflowX: "scroll" } : null,
1204
+ "overflow-x-auto": isWeb ? { overflowX: "auto" } : null,
1205
+ "overflow-y-hidden": isWeb ? { overflowY: "hidden" } : null,
1206
+ "overflow-y-scroll": isWeb ? { overflowY: "scroll" } : null,
1207
+ "overflow-y-auto": isWeb ? { overflowY: "auto" } : null,
1208
+ // Object fit (web-only; use resizeMode prop on RN Image)
1209
+ "object-contain": isWeb ? { objectFit: "contain" } : null,
1210
+ "object-cover": isWeb ? { objectFit: "cover" } : null,
1211
+ "object-fill": isWeb ? { objectFit: "fill" } : null,
1212
+ "object-none": isWeb ? { objectFit: "none" } : null,
1213
+ "object-scale-down": isWeb ? { objectFit: "scale-down" } : null,
1214
+ // Border style (both)
1212
1215
  "border-solid": { borderStyle: "solid" },
1213
1216
  "border-dashed": { borderStyle: "dashed" },
1214
1217
  "border-dotted": { borderStyle: "dotted" },
1215
1218
  "border-none": { borderWidth: 0 },
1216
- // Border sides (default width 1)
1219
+ // Border sides default width (both)
1217
1220
  "border-t": { borderTopWidth: 1 },
1218
1221
  "border-r": { borderRightWidth: 1 },
1219
1222
  "border-b": { borderBottomWidth: 1 },
1220
1223
  "border-l": { borderLeftWidth: 1 },
1221
- // Cursor
1222
- "cursor-auto": { cursor: "auto" },
1223
- "cursor-default": { cursor: "default" },
1224
- "cursor-pointer": { cursor: "pointer" },
1225
- "cursor-wait": { cursor: "wait" },
1226
- "cursor-text": { cursor: "text" },
1227
- "cursor-move": { cursor: "move" },
1228
- "cursor-not-allowed": { cursor: "not-allowed" },
1229
- // Select
1230
- "select-none": { userSelect: "none" },
1231
- "select-text": { userSelect: "text" },
1232
- "select-all": { userSelect: "all" },
1233
- "select-auto": { userSelect: "auto" },
1234
- // Pointer events
1224
+ // Cursor (web-only)
1225
+ "cursor-auto": isWeb ? { cursor: "auto" } : null,
1226
+ "cursor-default": isWeb ? { cursor: "default" } : null,
1227
+ "cursor-pointer": isWeb ? { cursor: "pointer" } : null,
1228
+ "cursor-wait": isWeb ? { cursor: "wait" } : null,
1229
+ "cursor-text": isWeb ? { cursor: "text" } : null,
1230
+ "cursor-move": isWeb ? { cursor: "move" } : null,
1231
+ "cursor-not-allowed": isWeb ? { cursor: "not-allowed" } : null,
1232
+ // User select (web-only)
1233
+ "select-none": isWeb ? { userSelect: "none" } : null,
1234
+ "select-text": isWeb ? { userSelect: "text" } : null,
1235
+ "select-all": isWeb ? { userSelect: "all" } : null,
1236
+ "select-auto": isWeb ? { userSelect: "auto" } : null,
1237
+ // Pointer events (both)
1235
1238
  "pointer-events-none": { pointerEvents: "none" },
1236
1239
  "pointer-events-auto": { pointerEvents: "auto" },
1237
- // Whitespace
1238
- "whitespace-normal": { whiteSpace: "normal" },
1239
- "whitespace-nowrap": { whiteSpace: "nowrap" },
1240
- "whitespace-pre": { whiteSpace: "pre" },
1241
- "whitespace-pre-wrap": { whiteSpace: "pre-wrap" },
1242
- "whitespace-pre-line": { whiteSpace: "pre-line" },
1243
- // Word break
1244
- "break-normal": { overflowWrap: "normal", wordBreak: "normal" },
1245
- "break-words": { overflowWrap: "break-word" },
1246
- "break-all": { wordBreak: "break-all" },
1247
- // Misc
1248
- truncate: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
1249
- "box-border": { boxSizing: "border-box" },
1250
- "box-content": { boxSizing: "content-box" },
1251
- "appearance-none": { appearance: "none" },
1252
- "outline-none": { outline: "none", outlineOffset: "0" },
1253
- outline: { outline: "2px solid transparent", outlineOffset: "2px" },
1254
- resize: { resize: "both" },
1255
- "resize-none": { resize: "none" },
1256
- "resize-y": { resize: "vertical" },
1257
- "resize-x": { resize: "horizontal" },
1258
- antialiased: { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" },
1259
- "sr-only": {
1240
+ // Whitespace (web-only; RN Text uses numberOfLines prop instead)
1241
+ "whitespace-normal": isWeb ? { whiteSpace: "normal" } : null,
1242
+ "whitespace-nowrap": isWeb ? { whiteSpace: "nowrap" } : null,
1243
+ "whitespace-pre": isWeb ? { whiteSpace: "pre" } : null,
1244
+ "whitespace-pre-wrap": isWeb ? { whiteSpace: "pre-wrap" } : null,
1245
+ "whitespace-pre-line": isWeb ? { whiteSpace: "pre-line" } : null,
1246
+ // Word break (web-only)
1247
+ "break-normal": isWeb ? { overflowWrap: "normal", wordBreak: "normal" } : null,
1248
+ "break-words": isWeb ? { overflowWrap: "break-word" } : null,
1249
+ "break-all": isWeb ? { wordBreak: "break-all" } : null,
1250
+ // Misc web-only
1251
+ truncate: isWeb ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : null,
1252
+ "box-border": isWeb ? { boxSizing: "border-box" } : null,
1253
+ "box-content": isWeb ? { boxSizing: "content-box" } : null,
1254
+ "appearance-none": isWeb ? { appearance: "none" } : null,
1255
+ "outline-none": isWeb ? { outline: "none", outlineOffset: "0" } : null,
1256
+ outline: isWeb ? { outline: "2px solid transparent", outlineOffset: "2px" } : null,
1257
+ resize: isWeb ? { resize: "both" } : null,
1258
+ "resize-none": isWeb ? { resize: "none" } : null,
1259
+ "resize-y": isWeb ? { resize: "vertical" } : null,
1260
+ "resize-x": isWeb ? { resize: "horizontal" } : null,
1261
+ antialiased: isWeb ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : null,
1262
+ "sr-only": isWeb ? {
1260
1263
  position: "absolute",
1261
1264
  width: 1,
1262
1265
  height: 1,
@@ -1266,8 +1269,8 @@ var STANDALONE = {
1266
1269
  clip: "rect(0,0,0,0)",
1267
1270
  whiteSpace: "nowrap",
1268
1271
  border: 0
1269
- },
1270
- "not-sr-only": {
1272
+ } : null,
1273
+ "not-sr-only": isWeb ? {
1271
1274
  position: "static",
1272
1275
  width: "auto",
1273
1276
  height: "auto",
@@ -1276,16 +1279,16 @@ var STANDALONE = {
1276
1279
  overflow: "visible",
1277
1280
  clip: "auto",
1278
1281
  whiteSpace: "normal"
1279
- },
1280
- // Lists
1281
- "list-none": { listStyleType: "none" },
1282
- "list-disc": { listStyleType: "disc" },
1283
- "list-decimal": { listStyleType: "decimal" },
1284
- // Background clip
1285
- "bg-clip-border": { backgroundClip: "border-box" },
1286
- "bg-clip-padding": { backgroundClip: "padding-box" },
1287
- "bg-clip-content": { backgroundClip: "content-box" },
1288
- "bg-clip-text": { backgroundClip: "text", WebkitBackgroundClip: "text" }
1282
+ } : null,
1283
+ // Lists (web-only)
1284
+ "list-none": isWeb ? { listStyleType: "none" } : null,
1285
+ "list-disc": isWeb ? { listStyleType: "disc" } : null,
1286
+ "list-decimal": isWeb ? { listStyleType: "decimal" } : null,
1287
+ // Background clip (web-only)
1288
+ "bg-clip-border": isWeb ? { backgroundClip: "border-box" } : null,
1289
+ "bg-clip-padding": isWeb ? { backgroundClip: "padding-box" } : null,
1290
+ "bg-clip-content": isWeb ? { backgroundClip: "content-box" } : null,
1291
+ "bg-clip-text": isWeb ? { backgroundClip: "text", WebkitBackgroundClip: "text" } : null
1289
1292
  };
1290
1293
  var RESOLVERS = {
1291
1294
  // ── Background ─────────────────────────────────────────────────────────────
@@ -1293,8 +1296,9 @@ var RESOLVERS = {
1293
1296
  const color = resolveColor(value, colors, isArbitrary);
1294
1297
  return color ? { backgroundColor: color } : null;
1295
1298
  },
1296
- "bg-opacity": ({ value, isArbitrary }, _) => {
1297
- const v = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
1299
+ "bg-opacity": ({ value }, _) => {
1300
+ if (!isWeb) return null;
1301
+ const v = parseFloat(value) / 100;
1298
1302
  return isNaN(v) ? null : { "--bg-opacity": v };
1299
1303
  },
1300
1304
  // ── Text ───────────────────────────────────────────────────────────────────
@@ -1311,6 +1315,7 @@ var RESOLVERS = {
1311
1315
  return color ? { color } : null;
1312
1316
  },
1313
1317
  "text-opacity": ({ value }, _) => {
1318
+ if (!isWeb) return null;
1314
1319
  const v = parseFloat(value) / 100;
1315
1320
  return isNaN(v) ? null : { "--text-opacity": v };
1316
1321
  },
@@ -1476,8 +1481,8 @@ var RESOLVERS = {
1476
1481
  return r !== null ? { borderBottomRightRadius: r } : null;
1477
1482
  },
1478
1483
  // ── Flex ───────────────────────────────────────────────────────────────────
1479
- flex: ({ value, isArbitrary }, { flex, spacing }) => {
1480
- if (!value) return { display: "flex" };
1484
+ flex: ({ value, isArbitrary }, { flex }) => {
1485
+ if (!value) return isWeb ? { display: "flex" } : {};
1481
1486
  if (isArbitrary) {
1482
1487
  const v = parseFloat(value);
1483
1488
  return isNaN(v) ? null : { flex: v };
@@ -1634,8 +1639,9 @@ var RESOLVERS = {
1634
1639
  const presets = { auto: "auto", square: 1, video: 16 / 9 };
1635
1640
  return value in presets ? { aspectRatio: presets[value] } : null;
1636
1641
  },
1637
- // ── Transition ─────────────────────────────────────────────────────────────
1642
+ // ── Transition (web-only; use Animated API on native) ─────────────────────
1638
1643
  transition: ({ value }) => {
1644
+ if (!isWeb) return null;
1639
1645
  const presets = {
1640
1646
  "": "color 150ms, background-color 150ms, border-color 150ms, opacity 150ms, box-shadow 150ms",
1641
1647
  all: "all 150ms",
@@ -1649,10 +1655,12 @@ var RESOLVERS = {
1649
1655
  return v !== void 0 ? { transition: v } : null;
1650
1656
  },
1651
1657
  duration: ({ value, isArbitrary }) => {
1658
+ if (!isWeb) return null;
1652
1659
  const ms = isArbitrary ? value : `${value}ms`;
1653
1660
  return { transitionDuration: ms };
1654
1661
  },
1655
1662
  delay: ({ value, isArbitrary }) => {
1663
+ if (!isWeb) return null;
1656
1664
  const ms = isArbitrary ? value : `${value}ms`;
1657
1665
  return { transitionDelay: ms };
1658
1666
  },
@@ -1667,8 +1675,9 @@ var RESOLVERS = {
1667
1675
  }
1668
1676
  };
1669
1677
  function resolveUtility(parsed, theme) {
1670
- const standalone = STANDALONE[parsed.utility];
1671
- if (standalone) return standalone;
1678
+ if (!parsed.value && parsed.utility in STANDALONE) {
1679
+ return STANDALONE[parsed.utility] ?? null;
1680
+ }
1672
1681
  const resolver = RESOLVERS[parsed.utility];
1673
1682
  if (resolver) return resolver(parsed, theme);
1674
1683
  return null;