@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.
package/dist/index.js CHANGED
@@ -1204,62 +1204,64 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1204
1204
  }
1205
1205
  var STANDALONE = {
1206
1206
  // Display
1207
- flex: { display: "flex" },
1208
- block: { display: "block" },
1209
- "inline-block": { display: "inline-block" },
1210
- inline: { display: "inline" },
1211
- grid: { display: "grid" },
1212
- "inline-flex": { display: "inline-flex" },
1213
- "inline-grid": { display: "inline-grid" },
1207
+ // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1208
+ // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1209
+ flex: isWeb ? { display: "flex" } : {},
1210
+ block: isWeb ? { display: "block" } : null,
1211
+ "inline-block": isWeb ? { display: "inline-block" } : null,
1212
+ inline: isWeb ? { display: "inline" } : null,
1213
+ grid: isWeb ? { display: "grid" } : null,
1214
+ "inline-flex": isWeb ? { display: "inline-flex" } : {},
1215
+ "inline-grid": isWeb ? { display: "inline-grid" } : null,
1214
1216
  hidden: { display: "none" },
1215
- contents: { display: "contents" },
1216
- "flow-root": { display: "flow-root" },
1217
- // Flex direction
1217
+ contents: isWeb ? { display: "contents" } : null,
1218
+ "flow-root": isWeb ? { display: "flow-root" } : null,
1219
+ // Flex direction (both web and native)
1218
1220
  "flex-row": { flexDirection: "row" },
1219
1221
  "flex-col": { flexDirection: "column" },
1220
1222
  "flex-row-reverse": { flexDirection: "row-reverse" },
1221
1223
  "flex-col-reverse": { flexDirection: "column-reverse" },
1222
- // Flex wrap
1224
+ // Flex wrap (both)
1223
1225
  "flex-wrap": { flexWrap: "wrap" },
1224
1226
  "flex-wrap-reverse": { flexWrap: "wrap-reverse" },
1225
1227
  "flex-nowrap": { flexWrap: "nowrap" },
1226
- // Flex grow / shrink
1228
+ // Flex grow / shrink (both)
1227
1229
  "flex-grow": { flexGrow: 1 },
1228
1230
  "flex-grow-0": { flexGrow: 0 },
1229
1231
  "flex-shrink": { flexShrink: 1 },
1230
1232
  "flex-shrink-0": { flexShrink: 0 },
1231
- // Align items
1233
+ // Align items (both)
1232
1234
  "items-start": { alignItems: "flex-start" },
1233
1235
  "items-end": { alignItems: "flex-end" },
1234
1236
  "items-center": { alignItems: "center" },
1235
1237
  "items-baseline": { alignItems: "baseline" },
1236
1238
  "items-stretch": { alignItems: "stretch" },
1237
- // Justify content
1239
+ // Justify content (both)
1238
1240
  "justify-start": { justifyContent: "flex-start" },
1239
1241
  "justify-end": { justifyContent: "flex-end" },
1240
1242
  "justify-center": { justifyContent: "center" },
1241
1243
  "justify-between": { justifyContent: "space-between" },
1242
1244
  "justify-around": { justifyContent: "space-around" },
1243
1245
  "justify-evenly": { justifyContent: "space-evenly" },
1244
- // Align content
1246
+ // Align content (both)
1245
1247
  "content-start": { alignContent: "flex-start" },
1246
1248
  "content-end": { alignContent: "flex-end" },
1247
1249
  "content-center": { alignContent: "center" },
1248
1250
  "content-between": { alignContent: "space-between" },
1249
1251
  "content-around": { alignContent: "space-around" },
1250
1252
  "content-evenly": { alignContent: "space-evenly" },
1251
- // Align self
1253
+ // Align self (both)
1252
1254
  "self-auto": { alignSelf: "auto" },
1253
1255
  "self-start": { alignSelf: "flex-start" },
1254
1256
  "self-end": { alignSelf: "flex-end" },
1255
1257
  "self-center": { alignSelf: "center" },
1256
1258
  "self-stretch": { alignSelf: "stretch" },
1257
- // Text align
1259
+ // Text align (both)
1258
1260
  "text-left": { textAlign: "left" },
1259
1261
  "text-right": { textAlign: "right" },
1260
1262
  "text-center": { textAlign: "center" },
1261
1263
  "text-justify": { textAlign: "justify" },
1262
- // Font weight shortcuts
1264
+ // Font weight shortcuts (both)
1263
1265
  "font-thin": { fontWeight: "100" },
1264
1266
  "font-extralight": { fontWeight: "200" },
1265
1267
  "font-light": { fontWeight: "300" },
@@ -1269,94 +1271,95 @@ var STANDALONE = {
1269
1271
  "font-bold": { fontWeight: "700" },
1270
1272
  "font-extrabold": { fontWeight: "800" },
1271
1273
  "font-black": { fontWeight: "900" },
1272
- // Text decoration
1274
+ // Text decoration (overline is web-only)
1273
1275
  underline: { textDecorationLine: "underline" },
1274
- overline: { textDecorationLine: "overline" },
1276
+ overline: isWeb ? { textDecorationLine: "overline" } : null,
1275
1277
  "line-through": { textDecorationLine: "line-through" },
1276
1278
  "no-underline": { textDecorationLine: "none" },
1277
- // Text transform
1279
+ // Text transform (both)
1278
1280
  uppercase: { textTransform: "uppercase" },
1279
1281
  lowercase: { textTransform: "lowercase" },
1280
1282
  capitalize: { textTransform: "capitalize" },
1281
1283
  "normal-case": { textTransform: "none" },
1282
- // Font style
1284
+ // Font style (both)
1283
1285
  italic: { fontStyle: "italic" },
1284
1286
  "non-italic": { fontStyle: "normal" },
1285
- // Position
1287
+ // Position (fixed/sticky/static are web-only; RN only supports relative/absolute)
1286
1288
  relative: { position: "relative" },
1287
1289
  absolute: { position: "absolute" },
1288
- fixed: { position: "fixed" },
1289
- sticky: { position: "sticky" },
1290
- static: { position: "static" },
1291
- // Visibility
1292
- visible: { visibility: "visible" },
1293
- invisible: { visibility: "hidden" },
1294
- // Overflow
1290
+ fixed: isWeb ? { position: "fixed" } : null,
1291
+ sticky: isWeb ? { position: "sticky" } : null,
1292
+ static: isWeb ? { position: "static" } : null,
1293
+ // Visibility (no `visibility` prop on native; use opacity instead)
1294
+ visible: isWeb ? { visibility: "visible" } : null,
1295
+ invisible: isWeb ? { visibility: "hidden" } : { opacity: 0 },
1296
+ // Overflow (RN supports 'hidden' | 'visible' | 'scroll'; not 'auto')
1295
1297
  "overflow-hidden": { overflow: "hidden" },
1296
1298
  "overflow-visible": { overflow: "visible" },
1297
1299
  "overflow-scroll": { overflow: "scroll" },
1298
- "overflow-auto": { overflow: "auto" },
1299
- "overflow-x-hidden": { overflowX: "hidden" },
1300
- "overflow-x-scroll": { overflowX: "scroll" },
1301
- "overflow-x-auto": { overflowX: "auto" },
1302
- "overflow-y-hidden": { overflowY: "hidden" },
1303
- "overflow-y-scroll": { overflowY: "scroll" },
1304
- "overflow-y-auto": { overflowY: "auto" },
1305
- // Object fit
1306
- "object-contain": { objectFit: "contain" },
1307
- "object-cover": { objectFit: "cover" },
1308
- "object-fill": { objectFit: "fill" },
1309
- "object-none": { objectFit: "none" },
1310
- "object-scale-down": { objectFit: "scale-down" },
1311
- // Border style
1300
+ "overflow-auto": isWeb ? { overflow: "auto" } : { overflow: "scroll" },
1301
+ // overflowX / overflowY are web-only
1302
+ "overflow-x-hidden": isWeb ? { overflowX: "hidden" } : null,
1303
+ "overflow-x-scroll": isWeb ? { overflowX: "scroll" } : null,
1304
+ "overflow-x-auto": isWeb ? { overflowX: "auto" } : null,
1305
+ "overflow-y-hidden": isWeb ? { overflowY: "hidden" } : null,
1306
+ "overflow-y-scroll": isWeb ? { overflowY: "scroll" } : null,
1307
+ "overflow-y-auto": isWeb ? { overflowY: "auto" } : null,
1308
+ // Object fit (web-only; use resizeMode prop on RN Image)
1309
+ "object-contain": isWeb ? { objectFit: "contain" } : null,
1310
+ "object-cover": isWeb ? { objectFit: "cover" } : null,
1311
+ "object-fill": isWeb ? { objectFit: "fill" } : null,
1312
+ "object-none": isWeb ? { objectFit: "none" } : null,
1313
+ "object-scale-down": isWeb ? { objectFit: "scale-down" } : null,
1314
+ // Border style (both)
1312
1315
  "border-solid": { borderStyle: "solid" },
1313
1316
  "border-dashed": { borderStyle: "dashed" },
1314
1317
  "border-dotted": { borderStyle: "dotted" },
1315
1318
  "border-none": { borderWidth: 0 },
1316
- // Border sides (default width 1)
1319
+ // Border sides default width (both)
1317
1320
  "border-t": { borderTopWidth: 1 },
1318
1321
  "border-r": { borderRightWidth: 1 },
1319
1322
  "border-b": { borderBottomWidth: 1 },
1320
1323
  "border-l": { borderLeftWidth: 1 },
1321
- // Cursor
1322
- "cursor-auto": { cursor: "auto" },
1323
- "cursor-default": { cursor: "default" },
1324
- "cursor-pointer": { cursor: "pointer" },
1325
- "cursor-wait": { cursor: "wait" },
1326
- "cursor-text": { cursor: "text" },
1327
- "cursor-move": { cursor: "move" },
1328
- "cursor-not-allowed": { cursor: "not-allowed" },
1329
- // Select
1330
- "select-none": { userSelect: "none" },
1331
- "select-text": { userSelect: "text" },
1332
- "select-all": { userSelect: "all" },
1333
- "select-auto": { userSelect: "auto" },
1334
- // Pointer events
1324
+ // Cursor (web-only)
1325
+ "cursor-auto": isWeb ? { cursor: "auto" } : null,
1326
+ "cursor-default": isWeb ? { cursor: "default" } : null,
1327
+ "cursor-pointer": isWeb ? { cursor: "pointer" } : null,
1328
+ "cursor-wait": isWeb ? { cursor: "wait" } : null,
1329
+ "cursor-text": isWeb ? { cursor: "text" } : null,
1330
+ "cursor-move": isWeb ? { cursor: "move" } : null,
1331
+ "cursor-not-allowed": isWeb ? { cursor: "not-allowed" } : null,
1332
+ // User select (web-only)
1333
+ "select-none": isWeb ? { userSelect: "none" } : null,
1334
+ "select-text": isWeb ? { userSelect: "text" } : null,
1335
+ "select-all": isWeb ? { userSelect: "all" } : null,
1336
+ "select-auto": isWeb ? { userSelect: "auto" } : null,
1337
+ // Pointer events (both)
1335
1338
  "pointer-events-none": { pointerEvents: "none" },
1336
1339
  "pointer-events-auto": { pointerEvents: "auto" },
1337
- // Whitespace
1338
- "whitespace-normal": { whiteSpace: "normal" },
1339
- "whitespace-nowrap": { whiteSpace: "nowrap" },
1340
- "whitespace-pre": { whiteSpace: "pre" },
1341
- "whitespace-pre-wrap": { whiteSpace: "pre-wrap" },
1342
- "whitespace-pre-line": { whiteSpace: "pre-line" },
1343
- // Word break
1344
- "break-normal": { overflowWrap: "normal", wordBreak: "normal" },
1345
- "break-words": { overflowWrap: "break-word" },
1346
- "break-all": { wordBreak: "break-all" },
1347
- // Misc
1348
- truncate: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
1349
- "box-border": { boxSizing: "border-box" },
1350
- "box-content": { boxSizing: "content-box" },
1351
- "appearance-none": { appearance: "none" },
1352
- "outline-none": { outline: "none", outlineOffset: "0" },
1353
- outline: { outline: "2px solid transparent", outlineOffset: "2px" },
1354
- resize: { resize: "both" },
1355
- "resize-none": { resize: "none" },
1356
- "resize-y": { resize: "vertical" },
1357
- "resize-x": { resize: "horizontal" },
1358
- antialiased: { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" },
1359
- "sr-only": {
1340
+ // Whitespace (web-only; RN Text uses numberOfLines prop instead)
1341
+ "whitespace-normal": isWeb ? { whiteSpace: "normal" } : null,
1342
+ "whitespace-nowrap": isWeb ? { whiteSpace: "nowrap" } : null,
1343
+ "whitespace-pre": isWeb ? { whiteSpace: "pre" } : null,
1344
+ "whitespace-pre-wrap": isWeb ? { whiteSpace: "pre-wrap" } : null,
1345
+ "whitespace-pre-line": isWeb ? { whiteSpace: "pre-line" } : null,
1346
+ // Word break (web-only)
1347
+ "break-normal": isWeb ? { overflowWrap: "normal", wordBreak: "normal" } : null,
1348
+ "break-words": isWeb ? { overflowWrap: "break-word" } : null,
1349
+ "break-all": isWeb ? { wordBreak: "break-all" } : null,
1350
+ // Misc web-only
1351
+ truncate: isWeb ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : null,
1352
+ "box-border": isWeb ? { boxSizing: "border-box" } : null,
1353
+ "box-content": isWeb ? { boxSizing: "content-box" } : null,
1354
+ "appearance-none": isWeb ? { appearance: "none" } : null,
1355
+ "outline-none": isWeb ? { outline: "none", outlineOffset: "0" } : null,
1356
+ outline: isWeb ? { outline: "2px solid transparent", outlineOffset: "2px" } : null,
1357
+ resize: isWeb ? { resize: "both" } : null,
1358
+ "resize-none": isWeb ? { resize: "none" } : null,
1359
+ "resize-y": isWeb ? { resize: "vertical" } : null,
1360
+ "resize-x": isWeb ? { resize: "horizontal" } : null,
1361
+ antialiased: isWeb ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : null,
1362
+ "sr-only": isWeb ? {
1360
1363
  position: "absolute",
1361
1364
  width: 1,
1362
1365
  height: 1,
@@ -1366,8 +1369,8 @@ var STANDALONE = {
1366
1369
  clip: "rect(0,0,0,0)",
1367
1370
  whiteSpace: "nowrap",
1368
1371
  border: 0
1369
- },
1370
- "not-sr-only": {
1372
+ } : null,
1373
+ "not-sr-only": isWeb ? {
1371
1374
  position: "static",
1372
1375
  width: "auto",
1373
1376
  height: "auto",
@@ -1376,16 +1379,16 @@ var STANDALONE = {
1376
1379
  overflow: "visible",
1377
1380
  clip: "auto",
1378
1381
  whiteSpace: "normal"
1379
- },
1380
- // Lists
1381
- "list-none": { listStyleType: "none" },
1382
- "list-disc": { listStyleType: "disc" },
1383
- "list-decimal": { listStyleType: "decimal" },
1384
- // Background clip
1385
- "bg-clip-border": { backgroundClip: "border-box" },
1386
- "bg-clip-padding": { backgroundClip: "padding-box" },
1387
- "bg-clip-content": { backgroundClip: "content-box" },
1388
- "bg-clip-text": { backgroundClip: "text", WebkitBackgroundClip: "text" }
1382
+ } : null,
1383
+ // Lists (web-only)
1384
+ "list-none": isWeb ? { listStyleType: "none" } : null,
1385
+ "list-disc": isWeb ? { listStyleType: "disc" } : null,
1386
+ "list-decimal": isWeb ? { listStyleType: "decimal" } : null,
1387
+ // Background clip (web-only)
1388
+ "bg-clip-border": isWeb ? { backgroundClip: "border-box" } : null,
1389
+ "bg-clip-padding": isWeb ? { backgroundClip: "padding-box" } : null,
1390
+ "bg-clip-content": isWeb ? { backgroundClip: "content-box" } : null,
1391
+ "bg-clip-text": isWeb ? { backgroundClip: "text", WebkitBackgroundClip: "text" } : null
1389
1392
  };
1390
1393
  var RESOLVERS = {
1391
1394
  // ── Background ─────────────────────────────────────────────────────────────
@@ -1393,8 +1396,9 @@ var RESOLVERS = {
1393
1396
  const color = resolveColor(value, colors, isArbitrary);
1394
1397
  return color ? { backgroundColor: color } : null;
1395
1398
  },
1396
- "bg-opacity": ({ value, isArbitrary }, _) => {
1397
- const v = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
1399
+ "bg-opacity": ({ value }, _) => {
1400
+ if (!isWeb) return null;
1401
+ const v = parseFloat(value) / 100;
1398
1402
  return isNaN(v) ? null : { "--bg-opacity": v };
1399
1403
  },
1400
1404
  // ── Text ───────────────────────────────────────────────────────────────────
@@ -1411,6 +1415,7 @@ var RESOLVERS = {
1411
1415
  return color ? { color } : null;
1412
1416
  },
1413
1417
  "text-opacity": ({ value }, _) => {
1418
+ if (!isWeb) return null;
1414
1419
  const v = parseFloat(value) / 100;
1415
1420
  return isNaN(v) ? null : { "--text-opacity": v };
1416
1421
  },
@@ -1576,8 +1581,8 @@ var RESOLVERS = {
1576
1581
  return r !== null ? { borderBottomRightRadius: r } : null;
1577
1582
  },
1578
1583
  // ── Flex ───────────────────────────────────────────────────────────────────
1579
- flex: ({ value, isArbitrary }, { flex, spacing }) => {
1580
- if (!value) return { display: "flex" };
1584
+ flex: ({ value, isArbitrary }, { flex }) => {
1585
+ if (!value) return isWeb ? { display: "flex" } : {};
1581
1586
  if (isArbitrary) {
1582
1587
  const v = parseFloat(value);
1583
1588
  return isNaN(v) ? null : { flex: v };
@@ -1734,8 +1739,9 @@ var RESOLVERS = {
1734
1739
  const presets = { auto: "auto", square: 1, video: 16 / 9 };
1735
1740
  return value in presets ? { aspectRatio: presets[value] } : null;
1736
1741
  },
1737
- // ── Transition ─────────────────────────────────────────────────────────────
1742
+ // ── Transition (web-only; use Animated API on native) ─────────────────────
1738
1743
  transition: ({ value }) => {
1744
+ if (!isWeb) return null;
1739
1745
  const presets = {
1740
1746
  "": "color 150ms, background-color 150ms, border-color 150ms, opacity 150ms, box-shadow 150ms",
1741
1747
  all: "all 150ms",
@@ -1749,10 +1755,12 @@ var RESOLVERS = {
1749
1755
  return v !== void 0 ? { transition: v } : null;
1750
1756
  },
1751
1757
  duration: ({ value, isArbitrary }) => {
1758
+ if (!isWeb) return null;
1752
1759
  const ms = isArbitrary ? value : `${value}ms`;
1753
1760
  return { transitionDuration: ms };
1754
1761
  },
1755
1762
  delay: ({ value, isArbitrary }) => {
1763
+ if (!isWeb) return null;
1756
1764
  const ms = isArbitrary ? value : `${value}ms`;
1757
1765
  return { transitionDelay: ms };
1758
1766
  },
@@ -1767,8 +1775,9 @@ var RESOLVERS = {
1767
1775
  }
1768
1776
  };
1769
1777
  function resolveUtility(parsed, theme) {
1770
- const standalone = STANDALONE[parsed.utility];
1771
- if (standalone) return standalone;
1778
+ if (!parsed.value && parsed.utility in STANDALONE) {
1779
+ return STANDALONE[parsed.utility] ?? null;
1780
+ }
1772
1781
  const resolver = RESOLVERS[parsed.utility];
1773
1782
  if (resolver) return resolver(parsed, theme);
1774
1783
  return null;
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  syncGlobalDarkMode,
16
16
  updateConfig,
17
17
  useGlobalDarkMode
18
- } from "./chunk-PYBA3DFG.mjs";
18
+ } from "./chunk-MXJINF4T.mjs";
19
19
 
20
20
  // src/context.tsx
21
21
  import { createContext, useContext } from "react";