@kbach/react 0.2.0 → 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.
@@ -1172,62 +1172,64 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1172
1172
  }
1173
1173
  var STANDALONE = {
1174
1174
  // Display
1175
- flex: { display: "flex" },
1176
- block: { display: "block" },
1177
- "inline-block": { display: "inline-block" },
1178
- inline: { display: "inline" },
1179
- grid: { display: "grid" },
1180
- "inline-flex": { display: "inline-flex" },
1181
- "inline-grid": { display: "inline-grid" },
1175
+ // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1176
+ // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1177
+ flex: isWeb ? { display: "flex" } : {},
1178
+ block: isWeb ? { display: "block" } : null,
1179
+ "inline-block": isWeb ? { display: "inline-block" } : null,
1180
+ inline: isWeb ? { display: "inline" } : null,
1181
+ grid: isWeb ? { display: "grid" } : null,
1182
+ "inline-flex": isWeb ? { display: "inline-flex" } : {},
1183
+ "inline-grid": isWeb ? { display: "inline-grid" } : null,
1182
1184
  hidden: { display: "none" },
1183
- contents: { display: "contents" },
1184
- "flow-root": { display: "flow-root" },
1185
- // Flex direction
1185
+ contents: isWeb ? { display: "contents" } : null,
1186
+ "flow-root": isWeb ? { display: "flow-root" } : null,
1187
+ // Flex direction (both web and native)
1186
1188
  "flex-row": { flexDirection: "row" },
1187
1189
  "flex-col": { flexDirection: "column" },
1188
1190
  "flex-row-reverse": { flexDirection: "row-reverse" },
1189
1191
  "flex-col-reverse": { flexDirection: "column-reverse" },
1190
- // Flex wrap
1192
+ // Flex wrap (both)
1191
1193
  "flex-wrap": { flexWrap: "wrap" },
1192
1194
  "flex-wrap-reverse": { flexWrap: "wrap-reverse" },
1193
1195
  "flex-nowrap": { flexWrap: "nowrap" },
1194
- // Flex grow / shrink
1196
+ // Flex grow / shrink (both)
1195
1197
  "flex-grow": { flexGrow: 1 },
1196
1198
  "flex-grow-0": { flexGrow: 0 },
1197
1199
  "flex-shrink": { flexShrink: 1 },
1198
1200
  "flex-shrink-0": { flexShrink: 0 },
1199
- // Align items
1201
+ // Align items (both)
1200
1202
  "items-start": { alignItems: "flex-start" },
1201
1203
  "items-end": { alignItems: "flex-end" },
1202
1204
  "items-center": { alignItems: "center" },
1203
1205
  "items-baseline": { alignItems: "baseline" },
1204
1206
  "items-stretch": { alignItems: "stretch" },
1205
- // Justify content
1207
+ // Justify content (both)
1206
1208
  "justify-start": { justifyContent: "flex-start" },
1207
1209
  "justify-end": { justifyContent: "flex-end" },
1208
1210
  "justify-center": { justifyContent: "center" },
1209
1211
  "justify-between": { justifyContent: "space-between" },
1210
1212
  "justify-around": { justifyContent: "space-around" },
1211
1213
  "justify-evenly": { justifyContent: "space-evenly" },
1212
- // Align content
1214
+ // Align content (both)
1213
1215
  "content-start": { alignContent: "flex-start" },
1214
1216
  "content-end": { alignContent: "flex-end" },
1215
1217
  "content-center": { alignContent: "center" },
1216
1218
  "content-between": { alignContent: "space-between" },
1217
1219
  "content-around": { alignContent: "space-around" },
1218
1220
  "content-evenly": { alignContent: "space-evenly" },
1219
- // Align self
1221
+ // Align self (both)
1220
1222
  "self-auto": { alignSelf: "auto" },
1221
1223
  "self-start": { alignSelf: "flex-start" },
1222
1224
  "self-end": { alignSelf: "flex-end" },
1223
1225
  "self-center": { alignSelf: "center" },
1224
1226
  "self-stretch": { alignSelf: "stretch" },
1225
- // Text align
1227
+ // Text align (both)
1226
1228
  "text-left": { textAlign: "left" },
1227
1229
  "text-right": { textAlign: "right" },
1228
1230
  "text-center": { textAlign: "center" },
1229
1231
  "text-justify": { textAlign: "justify" },
1230
- // Font weight shortcuts
1232
+ // Font weight shortcuts (both)
1231
1233
  "font-thin": { fontWeight: "100" },
1232
1234
  "font-extralight": { fontWeight: "200" },
1233
1235
  "font-light": { fontWeight: "300" },
@@ -1237,94 +1239,95 @@ var STANDALONE = {
1237
1239
  "font-bold": { fontWeight: "700" },
1238
1240
  "font-extrabold": { fontWeight: "800" },
1239
1241
  "font-black": { fontWeight: "900" },
1240
- // Text decoration
1242
+ // Text decoration (overline is web-only)
1241
1243
  underline: { textDecorationLine: "underline" },
1242
- overline: { textDecorationLine: "overline" },
1244
+ overline: isWeb ? { textDecorationLine: "overline" } : null,
1243
1245
  "line-through": { textDecorationLine: "line-through" },
1244
1246
  "no-underline": { textDecorationLine: "none" },
1245
- // Text transform
1247
+ // Text transform (both)
1246
1248
  uppercase: { textTransform: "uppercase" },
1247
1249
  lowercase: { textTransform: "lowercase" },
1248
1250
  capitalize: { textTransform: "capitalize" },
1249
1251
  "normal-case": { textTransform: "none" },
1250
- // Font style
1252
+ // Font style (both)
1251
1253
  italic: { fontStyle: "italic" },
1252
1254
  "non-italic": { fontStyle: "normal" },
1253
- // Position
1255
+ // Position (fixed/sticky/static are web-only; RN only supports relative/absolute)
1254
1256
  relative: { position: "relative" },
1255
1257
  absolute: { position: "absolute" },
1256
- fixed: { position: "fixed" },
1257
- sticky: { position: "sticky" },
1258
- static: { position: "static" },
1259
- // Visibility
1260
- visible: { visibility: "visible" },
1261
- invisible: { visibility: "hidden" },
1262
- // Overflow
1258
+ fixed: isWeb ? { position: "fixed" } : null,
1259
+ sticky: isWeb ? { position: "sticky" } : null,
1260
+ static: isWeb ? { position: "static" } : null,
1261
+ // Visibility (no `visibility` prop on native; use opacity instead)
1262
+ visible: isWeb ? { visibility: "visible" } : null,
1263
+ invisible: isWeb ? { visibility: "hidden" } : { opacity: 0 },
1264
+ // Overflow (RN supports 'hidden' | 'visible' | 'scroll'; not 'auto')
1263
1265
  "overflow-hidden": { overflow: "hidden" },
1264
1266
  "overflow-visible": { overflow: "visible" },
1265
1267
  "overflow-scroll": { overflow: "scroll" },
1266
- "overflow-auto": { overflow: "auto" },
1267
- "overflow-x-hidden": { overflowX: "hidden" },
1268
- "overflow-x-scroll": { overflowX: "scroll" },
1269
- "overflow-x-auto": { overflowX: "auto" },
1270
- "overflow-y-hidden": { overflowY: "hidden" },
1271
- "overflow-y-scroll": { overflowY: "scroll" },
1272
- "overflow-y-auto": { overflowY: "auto" },
1273
- // Object fit
1274
- "object-contain": { objectFit: "contain" },
1275
- "object-cover": { objectFit: "cover" },
1276
- "object-fill": { objectFit: "fill" },
1277
- "object-none": { objectFit: "none" },
1278
- "object-scale-down": { objectFit: "scale-down" },
1279
- // Border style
1268
+ "overflow-auto": isWeb ? { overflow: "auto" } : { overflow: "scroll" },
1269
+ // overflowX / overflowY are web-only
1270
+ "overflow-x-hidden": isWeb ? { overflowX: "hidden" } : null,
1271
+ "overflow-x-scroll": isWeb ? { overflowX: "scroll" } : null,
1272
+ "overflow-x-auto": isWeb ? { overflowX: "auto" } : null,
1273
+ "overflow-y-hidden": isWeb ? { overflowY: "hidden" } : null,
1274
+ "overflow-y-scroll": isWeb ? { overflowY: "scroll" } : null,
1275
+ "overflow-y-auto": isWeb ? { overflowY: "auto" } : null,
1276
+ // Object fit (web-only; use resizeMode prop on RN Image)
1277
+ "object-contain": isWeb ? { objectFit: "contain" } : null,
1278
+ "object-cover": isWeb ? { objectFit: "cover" } : null,
1279
+ "object-fill": isWeb ? { objectFit: "fill" } : null,
1280
+ "object-none": isWeb ? { objectFit: "none" } : null,
1281
+ "object-scale-down": isWeb ? { objectFit: "scale-down" } : null,
1282
+ // Border style (both)
1280
1283
  "border-solid": { borderStyle: "solid" },
1281
1284
  "border-dashed": { borderStyle: "dashed" },
1282
1285
  "border-dotted": { borderStyle: "dotted" },
1283
1286
  "border-none": { borderWidth: 0 },
1284
- // Border sides (default width 1)
1287
+ // Border sides default width (both)
1285
1288
  "border-t": { borderTopWidth: 1 },
1286
1289
  "border-r": { borderRightWidth: 1 },
1287
1290
  "border-b": { borderBottomWidth: 1 },
1288
1291
  "border-l": { borderLeftWidth: 1 },
1289
- // Cursor
1290
- "cursor-auto": { cursor: "auto" },
1291
- "cursor-default": { cursor: "default" },
1292
- "cursor-pointer": { cursor: "pointer" },
1293
- "cursor-wait": { cursor: "wait" },
1294
- "cursor-text": { cursor: "text" },
1295
- "cursor-move": { cursor: "move" },
1296
- "cursor-not-allowed": { cursor: "not-allowed" },
1297
- // Select
1298
- "select-none": { userSelect: "none" },
1299
- "select-text": { userSelect: "text" },
1300
- "select-all": { userSelect: "all" },
1301
- "select-auto": { userSelect: "auto" },
1302
- // Pointer events
1292
+ // Cursor (web-only)
1293
+ "cursor-auto": isWeb ? { cursor: "auto" } : null,
1294
+ "cursor-default": isWeb ? { cursor: "default" } : null,
1295
+ "cursor-pointer": isWeb ? { cursor: "pointer" } : null,
1296
+ "cursor-wait": isWeb ? { cursor: "wait" } : null,
1297
+ "cursor-text": isWeb ? { cursor: "text" } : null,
1298
+ "cursor-move": isWeb ? { cursor: "move" } : null,
1299
+ "cursor-not-allowed": isWeb ? { cursor: "not-allowed" } : null,
1300
+ // User select (web-only)
1301
+ "select-none": isWeb ? { userSelect: "none" } : null,
1302
+ "select-text": isWeb ? { userSelect: "text" } : null,
1303
+ "select-all": isWeb ? { userSelect: "all" } : null,
1304
+ "select-auto": isWeb ? { userSelect: "auto" } : null,
1305
+ // Pointer events (both)
1303
1306
  "pointer-events-none": { pointerEvents: "none" },
1304
1307
  "pointer-events-auto": { pointerEvents: "auto" },
1305
- // Whitespace
1306
- "whitespace-normal": { whiteSpace: "normal" },
1307
- "whitespace-nowrap": { whiteSpace: "nowrap" },
1308
- "whitespace-pre": { whiteSpace: "pre" },
1309
- "whitespace-pre-wrap": { whiteSpace: "pre-wrap" },
1310
- "whitespace-pre-line": { whiteSpace: "pre-line" },
1311
- // Word break
1312
- "break-normal": { overflowWrap: "normal", wordBreak: "normal" },
1313
- "break-words": { overflowWrap: "break-word" },
1314
- "break-all": { wordBreak: "break-all" },
1315
- // Misc
1316
- truncate: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
1317
- "box-border": { boxSizing: "border-box" },
1318
- "box-content": { boxSizing: "content-box" },
1319
- "appearance-none": { appearance: "none" },
1320
- "outline-none": { outline: "none", outlineOffset: "0" },
1321
- outline: { outline: "2px solid transparent", outlineOffset: "2px" },
1322
- resize: { resize: "both" },
1323
- "resize-none": { resize: "none" },
1324
- "resize-y": { resize: "vertical" },
1325
- "resize-x": { resize: "horizontal" },
1326
- antialiased: { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" },
1327
- "sr-only": {
1308
+ // Whitespace (web-only; RN Text uses numberOfLines prop instead)
1309
+ "whitespace-normal": isWeb ? { whiteSpace: "normal" } : null,
1310
+ "whitespace-nowrap": isWeb ? { whiteSpace: "nowrap" } : null,
1311
+ "whitespace-pre": isWeb ? { whiteSpace: "pre" } : null,
1312
+ "whitespace-pre-wrap": isWeb ? { whiteSpace: "pre-wrap" } : null,
1313
+ "whitespace-pre-line": isWeb ? { whiteSpace: "pre-line" } : null,
1314
+ // Word break (web-only)
1315
+ "break-normal": isWeb ? { overflowWrap: "normal", wordBreak: "normal" } : null,
1316
+ "break-words": isWeb ? { overflowWrap: "break-word" } : null,
1317
+ "break-all": isWeb ? { wordBreak: "break-all" } : null,
1318
+ // Misc web-only
1319
+ truncate: isWeb ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : null,
1320
+ "box-border": isWeb ? { boxSizing: "border-box" } : null,
1321
+ "box-content": isWeb ? { boxSizing: "content-box" } : null,
1322
+ "appearance-none": isWeb ? { appearance: "none" } : null,
1323
+ "outline-none": isWeb ? { outline: "none", outlineOffset: "0" } : null,
1324
+ outline: isWeb ? { outline: "2px solid transparent", outlineOffset: "2px" } : null,
1325
+ resize: isWeb ? { resize: "both" } : null,
1326
+ "resize-none": isWeb ? { resize: "none" } : null,
1327
+ "resize-y": isWeb ? { resize: "vertical" } : null,
1328
+ "resize-x": isWeb ? { resize: "horizontal" } : null,
1329
+ antialiased: isWeb ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : null,
1330
+ "sr-only": isWeb ? {
1328
1331
  position: "absolute",
1329
1332
  width: 1,
1330
1333
  height: 1,
@@ -1334,8 +1337,8 @@ var STANDALONE = {
1334
1337
  clip: "rect(0,0,0,0)",
1335
1338
  whiteSpace: "nowrap",
1336
1339
  border: 0
1337
- },
1338
- "not-sr-only": {
1340
+ } : null,
1341
+ "not-sr-only": isWeb ? {
1339
1342
  position: "static",
1340
1343
  width: "auto",
1341
1344
  height: "auto",
@@ -1344,16 +1347,16 @@ var STANDALONE = {
1344
1347
  overflow: "visible",
1345
1348
  clip: "auto",
1346
1349
  whiteSpace: "normal"
1347
- },
1348
- // Lists
1349
- "list-none": { listStyleType: "none" },
1350
- "list-disc": { listStyleType: "disc" },
1351
- "list-decimal": { listStyleType: "decimal" },
1352
- // Background clip
1353
- "bg-clip-border": { backgroundClip: "border-box" },
1354
- "bg-clip-padding": { backgroundClip: "padding-box" },
1355
- "bg-clip-content": { backgroundClip: "content-box" },
1356
- "bg-clip-text": { backgroundClip: "text", WebkitBackgroundClip: "text" }
1350
+ } : null,
1351
+ // Lists (web-only)
1352
+ "list-none": isWeb ? { listStyleType: "none" } : null,
1353
+ "list-disc": isWeb ? { listStyleType: "disc" } : null,
1354
+ "list-decimal": isWeb ? { listStyleType: "decimal" } : null,
1355
+ // Background clip (web-only)
1356
+ "bg-clip-border": isWeb ? { backgroundClip: "border-box" } : null,
1357
+ "bg-clip-padding": isWeb ? { backgroundClip: "padding-box" } : null,
1358
+ "bg-clip-content": isWeb ? { backgroundClip: "content-box" } : null,
1359
+ "bg-clip-text": isWeb ? { backgroundClip: "text", WebkitBackgroundClip: "text" } : null
1357
1360
  };
1358
1361
  var RESOLVERS = {
1359
1362
  // ── Background ─────────────────────────────────────────────────────────────
@@ -1361,8 +1364,9 @@ var RESOLVERS = {
1361
1364
  const color = resolveColor(value, colors, isArbitrary);
1362
1365
  return color ? { backgroundColor: color } : null;
1363
1366
  },
1364
- "bg-opacity": ({ value, isArbitrary }, _) => {
1365
- const v = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
1367
+ "bg-opacity": ({ value }, _) => {
1368
+ if (!isWeb) return null;
1369
+ const v = parseFloat(value) / 100;
1366
1370
  return isNaN(v) ? null : { "--bg-opacity": v };
1367
1371
  },
1368
1372
  // ── Text ───────────────────────────────────────────────────────────────────
@@ -1379,6 +1383,7 @@ var RESOLVERS = {
1379
1383
  return color ? { color } : null;
1380
1384
  },
1381
1385
  "text-opacity": ({ value }, _) => {
1386
+ if (!isWeb) return null;
1382
1387
  const v = parseFloat(value) / 100;
1383
1388
  return isNaN(v) ? null : { "--text-opacity": v };
1384
1389
  },
@@ -1544,8 +1549,8 @@ var RESOLVERS = {
1544
1549
  return r !== null ? { borderBottomRightRadius: r } : null;
1545
1550
  },
1546
1551
  // ── Flex ───────────────────────────────────────────────────────────────────
1547
- flex: ({ value, isArbitrary }, { flex, spacing }) => {
1548
- if (!value) return { display: "flex" };
1552
+ flex: ({ value, isArbitrary }, { flex }) => {
1553
+ if (!value) return isWeb ? { display: "flex" } : {};
1549
1554
  if (isArbitrary) {
1550
1555
  const v = parseFloat(value);
1551
1556
  return isNaN(v) ? null : { flex: v };
@@ -1702,8 +1707,9 @@ var RESOLVERS = {
1702
1707
  const presets = { auto: "auto", square: 1, video: 16 / 9 };
1703
1708
  return value in presets ? { aspectRatio: presets[value] } : null;
1704
1709
  },
1705
- // ── Transition ─────────────────────────────────────────────────────────────
1710
+ // ── Transition (web-only; use Animated API on native) ─────────────────────
1706
1711
  transition: ({ value }) => {
1712
+ if (!isWeb) return null;
1707
1713
  const presets = {
1708
1714
  "": "color 150ms, background-color 150ms, border-color 150ms, opacity 150ms, box-shadow 150ms",
1709
1715
  all: "all 150ms",
@@ -1717,10 +1723,12 @@ var RESOLVERS = {
1717
1723
  return v !== void 0 ? { transition: v } : null;
1718
1724
  },
1719
1725
  duration: ({ value, isArbitrary }) => {
1726
+ if (!isWeb) return null;
1720
1727
  const ms = isArbitrary ? value : `${value}ms`;
1721
1728
  return { transitionDuration: ms };
1722
1729
  },
1723
1730
  delay: ({ value, isArbitrary }) => {
1731
+ if (!isWeb) return null;
1724
1732
  const ms = isArbitrary ? value : `${value}ms`;
1725
1733
  return { transitionDelay: ms };
1726
1734
  },
@@ -1735,8 +1743,9 @@ var RESOLVERS = {
1735
1743
  }
1736
1744
  };
1737
1745
  function resolveUtility(parsed, theme) {
1738
- const standalone = STANDALONE[parsed.utility];
1739
- if (standalone) return standalone;
1746
+ if (!parsed.value && parsed.utility in STANDALONE) {
1747
+ return STANDALONE[parsed.utility] ?? null;
1748
+ }
1740
1749
  const resolver = RESOLVERS[parsed.utility];
1741
1750
  if (resolver) return resolver(parsed, theme);
1742
1751
  return null;
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-CNS23UB5.mjs";
6
- import "./chunk-PYBA3DFG.mjs";
5
+ } from "./chunk-7SN3LQKS.mjs";
6
+ import "./chunk-MXJINF4T.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",