radix-native-ui 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -313,7 +313,7 @@ If you're familiar with Radix Themes for web, here are the key differences for R
313
313
  |------------------|-------------------------------|
314
314
  | `css={{ p: '$4' }}` | `padding={4}` |
315
315
  | `variant="solid"` | `variant="solid"` (same) |
316
- | `size="2"` | `size={2}` (number, not string) |
316
+ | `size="2"` | `size={2}` (number is canonical; strings also accepted) |
317
317
  | `onClick` | `onPress` |
318
318
  | `color="red"` | `color="red"` (same) |
319
319
 
package/dist/index.cjs CHANGED
@@ -3961,10 +3961,10 @@ AnimatedPressable.displayName = "AnimatedPressable";
3961
3961
  //#endregion
3962
3962
  //#region src/components/layout/Box.tsx
3963
3963
  const areEqual$12 = (prevProps, nextProps) => {
3964
- if (prevProps.children === nextProps.children && prevProps.style === nextProps.style && prevProps.backgroundColor === nextProps.backgroundColor && prevProps.display === nextProps.display && prevProps.flexDirection === nextProps.flexDirection && prevProps.opacity === nextProps.opacity && prevProps.radius === nextProps.radius) return true;
3964
+ if (prevProps.children === nextProps.children && prevProps.style === nextProps.style && prevProps.backgroundColor === nextProps.backgroundColor && prevProps.display === nextProps.display && prevProps.flexDirection === nextProps.flexDirection && prevProps.flex === nextProps.flex && prevProps.opacity === nextProps.opacity && prevProps.radius === nextProps.radius) return true;
3965
3965
  return false;
3966
3966
  };
3967
- const Box = react.default.memo(react.default.forwardRef(({ asChild = false, children, style, backgroundColor, radius, display, flexDirection, justifyContent, alignItems, flexWrap, flexGrow, flexShrink, flexBasis, alignSelf, width, height, minWidth, maxWidth, minHeight, maxHeight, position, top, right, bottom, left, zIndex, overflow, margin, marginTop, marginBottom, marginLeft, marginRight, marginHorizontal, marginVertical, padding, paddingTop, paddingBottom, paddingLeft, paddingRight, paddingHorizontal, paddingVertical, borderWidth, borderRadius: borderRadiusProp, borderColor, opacity, elevation, ...rest }, ref) => {
3967
+ const Box = react.default.memo(react.default.forwardRef(({ asChild = false, children, style, backgroundColor, radius, display, flexDirection, justifyContent, alignItems, flexWrap, flex, flexGrow, flexShrink, flexBasis, alignSelf, width, height, minWidth, maxWidth, minHeight, maxHeight, position, top, right, bottom, left, zIndex, overflow, margin, marginTop, marginBottom, marginLeft, marginRight, marginHorizontal, marginVertical, padding, paddingTop, paddingBottom, paddingLeft, paddingRight, paddingHorizontal, paddingVertical, borderWidth, borderRadius: borderRadiusProp, borderColor, opacity, elevation, ...rest }, ref) => {
3968
3968
  const theme = useTheme$1();
3969
3969
  const colors = theme.colors.gray;
3970
3970
  const radii = theme.radii;
@@ -3988,6 +3988,7 @@ const Box = react.default.memo(react.default.forwardRef(({ asChild = false, chil
3988
3988
  justifyContent,
3989
3989
  alignItems,
3990
3990
  flexWrap,
3991
+ flex,
3991
3992
  flexGrow,
3992
3993
  flexShrink,
3993
3994
  flexBasis,
@@ -4030,6 +4031,7 @@ const Box = react.default.memo(react.default.forwardRef(({ asChild = false, chil
4030
4031
  justifyContent,
4031
4032
  alignItems,
4032
4033
  flexWrap,
4034
+ flex,
4033
4035
  flexGrow,
4034
4036
  flexShrink,
4035
4037
  flexBasis,
@@ -4510,21 +4512,20 @@ Separator.displayName = "Separator";
4510
4512
  * </Stack>
4511
4513
  */
4512
4514
  const Stack = react.default.memo(({ children, direction = "vertical", gap, align, justify, wrap = "nowrap", asChild = false, style, width, height, flexGrow, flexShrink, padding, backgroundColor }) => {
4513
- const theme = useTheme$1();
4514
4515
  const stackStyle = (0, react.useMemo)(() => {
4515
4516
  const baseStyle = {
4516
4517
  display: "flex",
4517
4518
  flexDirection: direction === "horizontal" ? "row" : "column",
4518
4519
  flexWrap: wrap
4519
4520
  };
4520
- if (gap !== void 0) baseStyle.gap = theme.space[gap];
4521
+ if (gap !== void 0) baseStyle.gap = gap;
4521
4522
  if (align !== void 0) baseStyle.alignItems = align;
4522
4523
  if (justify !== void 0) baseStyle.justifyContent = justify;
4523
4524
  if (width !== void 0) baseStyle.width = width;
4524
4525
  if (height !== void 0) baseStyle.height = height;
4525
4526
  if (flexGrow !== void 0) baseStyle.flexGrow = flexGrow;
4526
4527
  if (flexShrink !== void 0) baseStyle.flexShrink = flexShrink;
4527
- if (padding !== void 0) baseStyle.padding = theme.space[padding];
4528
+ if (padding !== void 0) baseStyle.padding = padding;
4528
4529
  if (backgroundColor !== void 0) baseStyle.backgroundColor = backgroundColor;
4529
4530
  return baseStyle;
4530
4531
  }, [
@@ -4538,8 +4539,7 @@ const Stack = react.default.memo(({ children, direction = "vertical", gap, align
4538
4539
  flexGrow,
4539
4540
  flexShrink,
4540
4541
  padding,
4541
- backgroundColor,
4542
- theme.space
4542
+ backgroundColor
4543
4543
  ]);
4544
4544
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? Slot : RnView, {
4545
4545
  style: [stackStyle, style],
@@ -5411,8 +5411,8 @@ const TextFieldRoot = react.default.forwardRef(({ children, ...props }, ref) =>
5411
5411
  const variantColors = getVariantColors(theme, activeColor, mode, variant || "outline", highContrast || false);
5412
5412
  const [isFocused, setIsFocused] = react.default.useState(false);
5413
5413
  const getSizeValues = () => {
5414
- switch (size) {
5415
- case "1": return {
5414
+ switch (Number(size)) {
5415
+ case 1: return {
5416
5416
  fontSize: theme.typography.fontSizes[4].fontSize,
5417
5417
  paddingVertical: theme.space[2],
5418
5418
  paddingHorizontal: theme.space[3],
@@ -5420,7 +5420,7 @@ const TextFieldRoot = react.default.forwardRef(({ children, ...props }, ref) =>
5420
5420
  height: multiline ? void 0 : 36,
5421
5421
  slotPadding: theme.space[1]
5422
5422
  };
5423
- case "3": return {
5423
+ case 3: return {
5424
5424
  fontSize: theme.typography.fontSizes[6].fontSize,
5425
5425
  paddingVertical: theme.space[4],
5426
5426
  paddingHorizontal: theme.space[4],
@@ -5683,13 +5683,13 @@ const TextAreaRoot = react.default.forwardRef(({ children, ...props }, ref) => {
5683
5683
  const variantColors = getVariantColors(theme, activeColor, mode, variant, highContrast);
5684
5684
  const accentColorScale = getColorScale(theme, activeColor, mode);
5685
5685
  const getSizeValues = () => {
5686
- switch (size) {
5687
- case "1": return {
5686
+ switch (Number(size)) {
5687
+ case 1: return {
5688
5688
  fontSize: theme.typography.fontSizes[4].fontSize,
5689
5689
  padding: theme.space[2],
5690
5690
  height: 100
5691
5691
  };
5692
- case "3": return {
5692
+ case 3: return {
5693
5693
  fontSize: theme.typography.fontSizes[6].fontSize,
5694
5694
  padding: theme.space[4],
5695
5695
  height: 140
@@ -5853,8 +5853,8 @@ const Checkbox = react.default.forwardRef(({ checked, defaultChecked = false, on
5853
5853
  getContrast(theme, activeColor, mode, highContrast);
5854
5854
  const variantColors = getVariantColors(theme, activeColor, mode, variant, highContrast);
5855
5855
  const getSizeValues = () => {
5856
- switch (size) {
5857
- case "1": return {
5856
+ switch (Number(size)) {
5857
+ case 1: return {
5858
5858
  boxSize: 20,
5859
5859
  iconSize: 11,
5860
5860
  fontSize: theme.typography.fontSizes[1].fontSize,
@@ -5862,7 +5862,7 @@ const Checkbox = react.default.forwardRef(({ checked, defaultChecked = false, on
5862
5862
  borderWidth: 1,
5863
5863
  height: 2.5
5864
5864
  };
5865
- case "3": return {
5865
+ case 3: return {
5866
5866
  boxSize: 28,
5867
5867
  iconSize: 16,
5868
5868
  fontSize: theme.typography.fontSizes[3].fontSize,
@@ -6079,15 +6079,15 @@ const CheckboxCardsItem = react.default.forwardRef(({ value, side: itemSide, dis
6079
6079
  getAccentColor(theme, mode);
6080
6080
  const variantColors = getVariantColors(theme, color || theme.accentColor, mode, variant, highContrast);
6081
6081
  const getSizeValues = () => {
6082
- switch (size) {
6083
- case "1": return {
6082
+ switch (Number(size)) {
6083
+ case 1: return {
6084
6084
  padding: theme.space[3],
6085
6085
  indicatorSize: 18,
6086
6086
  innerIndicatorSize: 6,
6087
6087
  borderWidth: 1,
6088
6088
  checkHeight: 2.2
6089
6089
  };
6090
- case "3": return {
6090
+ case 3: return {
6091
6091
  padding: theme.space[5],
6092
6092
  indicatorSize: 26,
6093
6093
  innerIndicatorSize: 10,
@@ -6186,15 +6186,15 @@ const Radio = react.default.forwardRef(({ defaultChecked, value, selected, onSel
6186
6186
  const [isInternallySelected, setIsInternallySelected] = react.default.useState(defaultChecked ?? false);
6187
6187
  const isSelected = selected !== void 0 ? selected : isInternallySelected;
6188
6188
  const getSizeValues = () => {
6189
- switch (size) {
6190
- case "1": return {
6189
+ switch (Number(size)) {
6190
+ case 1: return {
6191
6191
  boxSize: 18,
6192
6192
  innerSize: 6,
6193
6193
  iconSize: 8,
6194
6194
  fontSize: theme.typography.fontSizes[1].fontSize,
6195
6195
  gap: theme.space[1]
6196
6196
  };
6197
- case "3": return {
6197
+ case 3: return {
6198
6198
  boxSize: 28,
6199
6199
  innerSize: 12,
6200
6200
  iconSize: 16,
@@ -6417,14 +6417,14 @@ const RadioCardsItem = react.default.forwardRef(({ value, side: itemSide, disabl
6417
6417
  getAccentColor(theme, mode);
6418
6418
  const variantColors = getVariantColors(theme, color || theme.accentColor, mode, variant, highContrast);
6419
6419
  const getSizeValues = () => {
6420
- switch (size) {
6421
- case "1": return {
6420
+ switch (Number(size)) {
6421
+ case 1: return {
6422
6422
  padding: theme.space[3],
6423
6423
  indicatorSize: 18,
6424
6424
  innerIndicatorSize: 8,
6425
6425
  borderWidth: 1
6426
6426
  };
6427
- case "3": return {
6427
+ case 3: return {
6428
6428
  padding: theme.space[5],
6429
6429
  indicatorSize: 26,
6430
6430
  innerIndicatorSize: 12,
@@ -6552,15 +6552,15 @@ const Switch = react.default.forwardRef(({ defaultChecked, checked, onCheckedCha
6552
6552
  }).start();
6553
6553
  }, [isChecked]);
6554
6554
  const getSizeValues = () => {
6555
- switch (size) {
6556
- case "1": return {
6555
+ switch (Number(size)) {
6556
+ case 1: return {
6557
6557
  trackWidth: 32,
6558
6558
  trackHeight: 20,
6559
6559
  thumbSize: 14,
6560
6560
  gap: theme.space[1],
6561
6561
  fontSize: theme.typography.fontSizes[1].fontSize
6562
6562
  };
6563
- case "3": return {
6563
+ case 3: return {
6564
6564
  trackWidth: 58,
6565
6565
  trackHeight: 32,
6566
6566
  thumbSize: 26,
@@ -7603,18 +7603,18 @@ const Slider = react.default.forwardRef(({ value: controlledValue, defaultValue,
7603
7603
  };
7604
7604
  const thumbAnimations = (0, react.useRef)(values.map((v) => new react_native.Animated.Value(getInitialPosition(v)))).current;
7605
7605
  const sizeValues = (0, react.useMemo)(() => {
7606
- switch (size) {
7607
- case "1": return {
7606
+ switch (Number(size)) {
7607
+ case 1: return {
7608
7608
  trackHeight: 4,
7609
7609
  thumbSize: 16,
7610
7610
  fontSize: theme.typography.fontSizes[1].fontSize
7611
7611
  };
7612
- case "3": return {
7612
+ case 3: return {
7613
7613
  trackHeight: 8,
7614
7614
  thumbSize: 28,
7615
7615
  fontSize: theme.typography.fontSizes[3].fontSize
7616
7616
  };
7617
- case "4": return {
7617
+ case 4: return {
7618
7618
  trackHeight: 10,
7619
7619
  thumbSize: 34,
7620
7620
  fontSize: theme.typography.fontSizes[4].fontSize
@@ -11946,7 +11946,7 @@ const FancyList = ({ data, renderItem, keyExtractor, style, showDividers = true,
11946
11946
  const backgroundColor = isDark ? grayAlpha["2"] : grayAlpha["1"];
11947
11947
  const defaultKeyExtractor = (item, index) => {
11948
11948
  if (keyExtractor) return keyExtractor(item, index);
11949
- if ("id" in item) return String(item.id);
11949
+ if (item && typeof item === "object" && "id" in item) return String(item.id);
11950
11950
  return String(index);
11951
11951
  };
11952
11952
  const renderListItem = (info) => {
@@ -12202,11 +12202,9 @@ const PULSE_ANIMATION = {
12202
12202
  duration: 1e3,
12203
12203
  useNativeDriver: true
12204
12204
  };
12205
- const SKELEON_COLORS = {
12206
- light: "#E5E7EB",
12207
- dark: "#D1D5DB"
12208
- };
12209
12205
  const Skeleton = react.default.forwardRef(({ children, loading = true, style, textStyle, width, height, accessibilityLabel = "Loading", testID }, ref) => {
12206
+ const theme = useTheme$1();
12207
+ const grayScale = useThemeMode$1() === "dark" ? theme.colors.gray.dark : theme.colors.gray;
12210
12208
  const pulseAnim = (0, react.useRef)(new react_native.Animated.Value(0)).current;
12211
12209
  (0, react.useEffect)(() => {
12212
12210
  const animation = react_native.Animated.loop(react_native.Animated.sequence([react_native.Animated.timing(pulseAnim, {
@@ -12223,7 +12221,7 @@ const Skeleton = react.default.forwardRef(({ children, loading = true, style, te
12223
12221
  }, [pulseAnim]);
12224
12222
  const pulseStyle = { backgroundColor: pulseAnim.interpolate({
12225
12223
  inputRange: [0, 1],
12226
- outputRange: [SKELEON_COLORS.light, SKELEON_COLORS.dark]
12224
+ outputRange: [grayScale[3], grayScale[5]]
12227
12225
  }) };
12228
12226
  if (!loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
12229
12227
  if (!react.default.isValidElement(children) && typeof children === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Animated.Text, {
@@ -12369,12 +12367,12 @@ const TableColumnHeaderCell = react.default.forwardRef(({ children, width, align
12369
12367
  const theme = useTheme$1();
12370
12368
  const grayScale = useThemeMode$1() === "dark" ? theme.colors.gray.dark : theme.colors.gray;
12371
12369
  const getSizePadding = () => {
12372
- switch (context.size) {
12373
- case "1": return {
12370
+ switch (Number(context.size)) {
12371
+ case 1: return {
12374
12372
  paddingVertical: theme.space[2],
12375
12373
  paddingHorizontal: theme.space[3]
12376
12374
  };
12377
- case "3": return {
12375
+ case 3: return {
12378
12376
  paddingVertical: theme.space[4],
12379
12377
  paddingHorizontal: theme.space[5]
12380
12378
  };
@@ -12385,9 +12383,9 @@ const TableColumnHeaderCell = react.default.forwardRef(({ children, width, align
12385
12383
  }
12386
12384
  };
12387
12385
  const getSizeFont = () => {
12388
- switch (context.size) {
12389
- case "1": return { fontSize: theme.typography.fontSizes[1].fontSize };
12390
- case "3": return { fontSize: theme.typography.fontSizes[3].fontSize };
12386
+ switch (Number(context.size)) {
12387
+ case 1: return { fontSize: theme.typography.fontSizes[1].fontSize };
12388
+ case 3: return { fontSize: theme.typography.fontSizes[3].fontSize };
12391
12389
  default: return { fontSize: theme.typography.fontSizes[2].fontSize };
12392
12390
  }
12393
12391
  };
@@ -12424,12 +12422,12 @@ const TableCell = react.default.forwardRef(({ children, align = "left", style },
12424
12422
  const theme = useTheme$1();
12425
12423
  const grayScale = useThemeMode$1() === "dark" ? theme.colors.gray.dark : theme.colors.gray;
12426
12424
  const getSizePadding = () => {
12427
- switch (context.size) {
12428
- case "1": return {
12425
+ switch (Number(context.size)) {
12426
+ case 1: return {
12429
12427
  paddingVertical: theme.space[2],
12430
12428
  paddingHorizontal: theme.space[3]
12431
12429
  };
12432
- case "3": return {
12430
+ case 3: return {
12433
12431
  paddingVertical: theme.space[4],
12434
12432
  paddingHorizontal: theme.space[5]
12435
12433
  };
@@ -12440,9 +12438,9 @@ const TableCell = react.default.forwardRef(({ children, align = "left", style },
12440
12438
  }
12441
12439
  };
12442
12440
  const getSizeFont = () => {
12443
- switch (context.size) {
12444
- case "1": return { fontSize: theme.typography.fontSizes[1].fontSize };
12445
- case "3": return { fontSize: theme.typography.fontSizes[3].fontSize };
12441
+ switch (Number(context.size)) {
12442
+ case 1: return { fontSize: theme.typography.fontSizes[1].fontSize };
12443
+ case 3: return { fontSize: theme.typography.fontSizes[3].fontSize };
12446
12444
  default: return { fontSize: theme.typography.fontSizes[2].fontSize };
12447
12445
  }
12448
12446
  };
@@ -13110,15 +13108,15 @@ const AccordionTrigger = react.default.forwardRef(({ children, style, icon, hapt
13110
13108
  }).start();
13111
13109
  }, [open, rotationAnim]);
13112
13110
  const getSizeStyles = () => {
13113
- switch (size) {
13114
- case "1": return {
13111
+ switch (Number(size)) {
13112
+ case 1: return {
13115
13113
  paddingVertical: theme.space[2],
13116
13114
  paddingHorizontal: theme.space[3],
13117
13115
  fontSize: theme.typography.fontSizes[1].fontSize,
13118
13116
  lineHeight: theme.typography.fontSizes[1].lineHeight,
13119
13117
  iconSize: 14
13120
13118
  };
13121
- case "3": return {
13119
+ case 3: return {
13122
13120
  paddingVertical: theme.space[4],
13123
13121
  paddingHorizontal: theme.space[5],
13124
13122
  fontSize: theme.typography.fontSizes[4].fontSize,
@@ -13224,9 +13222,9 @@ const AccordionContent = react.default.forwardRef(({ children, style }, ref) =>
13224
13222
  const heightAnim = (0, react.useRef)(new react_native.Animated.Value(0)).current;
13225
13223
  const opacityAnim = (0, react.useRef)(new react_native.Animated.Value(0)).current;
13226
13224
  const getContentPadding = () => {
13227
- switch (size) {
13228
- case "1": return theme.space[2];
13229
- case "3": return theme.space[5];
13225
+ switch (Number(size)) {
13226
+ case 1: return theme.space[2];
13227
+ case 3: return theme.space[5];
13230
13228
  default: return theme.space[4];
13231
13229
  }
13232
13230
  };
@@ -13352,6 +13350,15 @@ const useResponsive = (breakpoints = defaultBreakpoints) => {
13352
13350
  return getResponsiveInfo(window, breakpoints);
13353
13351
  };
13354
13352
 
13353
+ //#endregion
13354
+ //#region src/utils/size.ts
13355
+ /**
13356
+ * Normalize a SizeInput to its canonical numeric form.
13357
+ * Returns the value unchanged when already numeric, the parsed number for
13358
+ * legacy string inputs, or `undefined` when absent.
13359
+ */
13360
+ const toNumericSize = (size) => size === void 0 ? void 0 : Number(size);
13361
+
13355
13362
  //#endregion
13356
13363
  exports.AbsoluteCenter = AbsoluteCenter;
13357
13364
  exports.Accordion = Accordion;
@@ -13558,6 +13565,7 @@ exports.slateAlpha = slateAlpha;
13558
13565
  exports.space = space;
13559
13566
  exports.teal = teal;
13560
13567
  exports.tealAlpha = tealAlpha;
13568
+ exports.toNumericSize = toNumericSize;
13561
13569
  exports.tomato = tomato;
13562
13570
  exports.tomatoAlpha = tomatoAlpha;
13563
13571
  exports.typography = typography;