@newtonedev/components 0.1.2 → 0.1.4

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.
Files changed (113) hide show
  1. package/dist/Popover/Popover.d.ts.map +1 -1
  2. package/dist/Popover/Popover.styles.d.ts +64 -1
  3. package/dist/Popover/Popover.styles.d.ts.map +1 -1
  4. package/dist/Select/Select.d.ts.map +1 -1
  5. package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts +70 -0
  6. package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts.map +1 -0
  7. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts +22 -0
  8. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts.map +1 -0
  9. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts +45 -0
  10. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts.map +1 -0
  11. package/dist/_COMPONENT_TEMPLATE/index.d.ts +3 -0
  12. package/dist/_COMPONENT_TEMPLATE/index.d.ts.map +1 -0
  13. package/dist/fonts/GoogleFontLoader.d.ts.map +1 -1
  14. package/dist/fonts/IconFontLoader.d.ts.map +1 -1
  15. package/dist/index.cjs +371 -74
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +11 -5
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +370 -76
  20. package/dist/index.js.map +1 -1
  21. package/dist/{Frame → primitives/Frame}/Frame.d.ts +1 -1
  22. package/dist/primitives/Frame/Frame.d.ts.map +1 -0
  23. package/dist/{Frame → primitives/Frame}/Frame.styles.d.ts +11 -2
  24. package/dist/primitives/Frame/Frame.styles.d.ts.map +1 -0
  25. package/dist/primitives/Frame/Frame.types.d.ts +240 -0
  26. package/dist/primitives/Frame/Frame.types.d.ts.map +1 -0
  27. package/dist/{Frame → primitives/Frame}/Frame.utils.d.ts +12 -12
  28. package/dist/primitives/Frame/Frame.utils.d.ts.map +1 -0
  29. package/dist/primitives/Frame/index.d.ts.map +1 -0
  30. package/dist/primitives/Icon/Icon.d.ts +17 -0
  31. package/dist/primitives/Icon/Icon.d.ts.map +1 -0
  32. package/dist/primitives/Icon/Icon.types.d.ts +55 -0
  33. package/dist/primitives/Icon/Icon.types.d.ts.map +1 -0
  34. package/dist/primitives/Icon/index.d.ts +3 -0
  35. package/dist/primitives/Icon/index.d.ts.map +1 -0
  36. package/dist/primitives/Text/Text.d.ts +17 -0
  37. package/dist/primitives/Text/Text.d.ts.map +1 -0
  38. package/dist/primitives/Text/Text.types.d.ts +85 -0
  39. package/dist/primitives/Text/Text.types.d.ts.map +1 -0
  40. package/dist/primitives/Text/index.d.ts +3 -0
  41. package/dist/primitives/Text/index.d.ts.map +1 -0
  42. package/dist/primitives/Wrapper/Wrapper.d.ts +29 -0
  43. package/dist/primitives/Wrapper/Wrapper.d.ts.map +1 -0
  44. package/dist/primitives/Wrapper/Wrapper.styles.d.ts +28 -0
  45. package/dist/primitives/Wrapper/Wrapper.styles.d.ts.map +1 -0
  46. package/dist/primitives/Wrapper/Wrapper.types.d.ts +113 -0
  47. package/dist/primitives/Wrapper/Wrapper.types.d.ts.map +1 -0
  48. package/dist/primitives/Wrapper/index.d.ts +3 -0
  49. package/dist/primitives/Wrapper/index.d.ts.map +1 -0
  50. package/dist/primitives/index.d.ts +12 -0
  51. package/dist/primitives/index.d.ts.map +1 -0
  52. package/dist/primitives/useFocusVisible.d.ts +29 -0
  53. package/dist/primitives/useFocusVisible.d.ts.map +1 -0
  54. package/dist/theme/defaults.d.ts.map +1 -1
  55. package/dist/theme/types.d.ts +13 -6
  56. package/dist/theme/types.d.ts.map +1 -1
  57. package/dist/tokens/computeTokens.d.ts +13 -6
  58. package/dist/tokens/computeTokens.d.ts.map +1 -1
  59. package/dist/tokens/types.d.ts +16 -7
  60. package/dist/tokens/types.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/Button/Button.styles.ts +9 -9
  63. package/src/Button/Button.tsx +1 -1
  64. package/src/Card/Card.styles.ts +1 -1
  65. package/src/ColorScaleSlider/ColorScaleSlider.styles.ts +1 -1
  66. package/src/HueSlider/HueSlider.styles.ts +1 -1
  67. package/src/Popover/Popover.styles.ts +5 -1
  68. package/src/Popover/Popover.tsx +3 -1
  69. package/src/Select/Select.styles.ts +9 -9
  70. package/src/Select/Select.tsx +2 -3
  71. package/src/Select/SelectOption.tsx +6 -6
  72. package/src/Slider/Slider.styles.ts +1 -1
  73. package/src/TextInput/TextInput.styles.ts +3 -3
  74. package/src/Toggle/Toggle.styles.ts +1 -1
  75. package/src/_COMPONENT_TEMPLATE/ComponentName.styles.ts +29 -0
  76. package/src/_COMPONENT_TEMPLATE/ComponentName.tsx +106 -0
  77. package/src/_COMPONENT_TEMPLATE/ComponentName.types.ts +86 -0
  78. package/src/_COMPONENT_TEMPLATE/index.ts +2 -0
  79. package/src/fonts/GoogleFontLoader.tsx +2 -0
  80. package/src/fonts/IconFontLoader.tsx +2 -0
  81. package/src/index.ts +22 -5
  82. package/src/{Frame → primitives/Frame}/Frame.styles.ts +46 -9
  83. package/src/{Frame → primitives/Frame}/Frame.tsx +90 -16
  84. package/src/primitives/Frame/Frame.types.ts +315 -0
  85. package/src/{Frame → primitives/Frame}/Frame.utils.ts +56 -20
  86. package/src/primitives/Icon/Icon.tsx +89 -0
  87. package/src/primitives/Icon/Icon.types.ts +70 -0
  88. package/src/primitives/Icon/index.ts +2 -0
  89. package/src/primitives/Text/Text.tsx +90 -0
  90. package/src/primitives/Text/Text.types.ts +108 -0
  91. package/src/primitives/Text/index.ts +10 -0
  92. package/src/primitives/Wrapper/Wrapper.styles.ts +113 -0
  93. package/src/primitives/Wrapper/Wrapper.tsx +104 -0
  94. package/src/primitives/Wrapper/Wrapper.types.ts +149 -0
  95. package/src/primitives/Wrapper/index.ts +2 -0
  96. package/src/primitives/index.ts +46 -0
  97. package/src/primitives/useFocusVisible.ts +102 -0
  98. package/src/theme/defaults.ts +13 -6
  99. package/src/theme/types.ts +13 -6
  100. package/src/tokens/computeTokens.ts +1 -1
  101. package/src/tokens/types.ts +16 -7
  102. package/dist/Frame/Frame.d.ts.map +0 -1
  103. package/dist/Frame/Frame.styles.d.ts.map +0 -1
  104. package/dist/Frame/Frame.types.d.ts +0 -115
  105. package/dist/Frame/Frame.types.d.ts.map +0 -1
  106. package/dist/Frame/Frame.utils.d.ts.map +0 -1
  107. package/dist/Frame/index.d.ts.map +0 -1
  108. package/dist/Icon/Icon.d.ts +0 -36
  109. package/dist/Icon/Icon.d.ts.map +0 -1
  110. package/src/Frame/Frame.types.ts +0 -181
  111. package/src/Icon/Icon.tsx +0 -76
  112. /package/dist/{Frame → primitives/Frame}/index.d.ts +0 -0
  113. /package/src/{Frame → primitives/Frame}/index.ts +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import React11, { createContext, useState, useMemo, useContext, useRef, useCallback, useEffect } from 'react';
1
+ import React11, { createContext, useState, useMemo, useContext, useEffect, useCallback, useRef } from 'react';
2
2
  import { DEFAULT_NEUTRAL_SATURATION, DEFAULT_NEUTRAL_HUE, DEFAULT_ACCENT_SATURATION, DEFAULT_ACCENT_HUE, DEFAULT_SUCCESS_SATURATION, DEFAULT_SUCCESS_HUE, DEFAULT_WARNING_SATURATION, DEFAULT_WARNING_HUE, DEFAULT_ERROR_SATURATION, DEFAULT_ERROR_HUE, getColor, getColorByContrast, srgbToHex } from 'newtone';
3
3
  import { Text, Pressable, View, TextInput as TextInput$1, ScrollView, PanResponder, Animated, StyleSheet } from 'react-native';
4
4
 
@@ -28,12 +28,32 @@ var DEFAULT_THEME_CONFIG = {
28
28
  // [sunken, default, elevated]
29
29
  },
30
30
  spacing: {
31
- xs: 4,
32
- sm: 8,
33
- md: 12,
34
- lg: 16,
35
- xl: 24,
36
- xxl: 32
31
+ "00": 0,
32
+ // base * 0
33
+ "02": 2,
34
+ // base * 0.25
35
+ "04": 4,
36
+ // base * 0.5
37
+ "06": 6,
38
+ // base * 0.75
39
+ "08": 8,
40
+ // base * 1 (Medium preset, 8px base)
41
+ "10": 10,
42
+ // base * 1.25
43
+ "12": 12,
44
+ // base * 1.5
45
+ "16": 16,
46
+ // base * 2
47
+ "20": 20,
48
+ // base * 2.5
49
+ "24": 24,
50
+ // base * 3
51
+ "32": 32,
52
+ // base * 4
53
+ "40": 40,
54
+ // base * 5
55
+ "48": 48
56
+ // base * 6
37
57
  },
38
58
  radius: {
39
59
  none: 0,
@@ -421,27 +441,27 @@ function useTokens(elevation) {
421
441
  function getSizeConfig(tokens) {
422
442
  return {
423
443
  sm: {
424
- paddingVertical: tokens.spacing.xs,
425
- paddingHorizontal: tokens.spacing.md,
444
+ paddingVertical: tokens.spacing["04"],
445
+ paddingHorizontal: tokens.spacing["12"],
426
446
  fontSize: tokens.typography.size.sm,
427
447
  borderRadius: tokens.radius.sm,
428
- gap: tokens.spacing.xs,
448
+ gap: tokens.spacing["04"],
429
449
  iconSize: tokens.typography.size.sm
430
450
  },
431
451
  md: {
432
- paddingVertical: tokens.spacing.sm,
433
- paddingHorizontal: tokens.spacing.lg,
452
+ paddingVertical: tokens.spacing["08"],
453
+ paddingHorizontal: tokens.spacing["16"],
434
454
  fontSize: tokens.typography.size.base,
435
455
  borderRadius: tokens.radius.md,
436
- gap: tokens.spacing.sm,
456
+ gap: tokens.spacing["08"],
437
457
  iconSize: tokens.typography.size.base
438
458
  },
439
459
  lg: {
440
- paddingVertical: tokens.spacing.md,
441
- paddingHorizontal: tokens.spacing.xl,
460
+ paddingVertical: tokens.spacing["12"],
461
+ paddingHorizontal: tokens.spacing["24"],
442
462
  fontSize: tokens.typography.size.base,
443
463
  borderRadius: tokens.radius.lg,
444
- gap: tokens.spacing.sm,
464
+ gap: tokens.spacing["08"],
445
465
  iconSize: tokens.typography.size.base
446
466
  }
447
467
  };
@@ -522,25 +542,41 @@ function Icon({
522
542
  color,
523
543
  elevation = 1,
524
544
  style,
525
- onPress
545
+ onPress,
546
+ // Accessibility
547
+ accessibilityLabel,
548
+ // Testing & platform
549
+ testID,
550
+ nativeID,
551
+ ref
526
552
  }) {
527
553
  const tokens = useTokens(elevation);
528
- const fontSize = size ?? tokens.typography.size.base;
529
- const opsz = opticalSize ?? fontSize;
530
- const iconColor = color ?? srgbToHex(tokens.textPrimary.srgb);
531
- const fontFamily = `Material Symbols ${tokens.icons.variant.charAt(0).toUpperCase() + tokens.icons.variant.slice(1)}`;
532
- const fontVariationSettings = `'FILL' ${fill}, 'wght' ${tokens.icons.weight}, 'GRAD' ${tokens.icons.grade}, 'opsz' ${opsz}`;
554
+ const iconStyle = useMemo(() => {
555
+ const fontSize = size ?? tokens.typography.size.base;
556
+ const opsz = opticalSize ?? fontSize;
557
+ const iconColor = color ?? srgbToHex(tokens.textPrimary.srgb);
558
+ const fontFamily = `Material Symbols ${tokens.icons.variant.charAt(0).toUpperCase() + tokens.icons.variant.slice(1)}`;
559
+ const fontVariationSettings = `'FILL' ${fill}, 'wght' ${tokens.icons.weight}, 'GRAD' ${tokens.icons.grade}, 'opsz' ${opsz}`;
560
+ return {
561
+ fontFamily,
562
+ fontSize,
563
+ color: iconColor,
564
+ userSelect: "none",
565
+ // web-only: prevents users from selecting the icon as text
566
+ fontVariationSettings,
567
+ // web-only: controls the variable font axes listed above
568
+ ...style
569
+ };
570
+ }, [tokens, size, opticalSize, fill, color, style]);
533
571
  return /* @__PURE__ */ React11.createElement(
534
572
  Text,
535
573
  {
536
- style: {
537
- fontFamily,
538
- fontSize,
539
- color: iconColor,
540
- userSelect: "none",
541
- fontVariationSettings,
542
- ...style
543
- },
574
+ ref,
575
+ testID,
576
+ nativeID,
577
+ accessibilityLabel,
578
+ importantForAccessibility: accessibilityLabel ? "yes" : "no-hide-descendants",
579
+ style: iconStyle,
544
580
  onPress
545
581
  },
546
582
  name
@@ -599,7 +635,7 @@ function getCardStyles(tokens, disabled) {
599
635
  borderWidth: 1,
600
636
  borderColor: srgbToHex(tokens.border.srgb),
601
637
  borderRadius: tokens.radius.lg,
602
- padding: tokens.spacing.lg,
638
+ padding: tokens.spacing["16"],
603
639
  opacity: disabled ? 0.5 : 1
604
640
  }
605
641
  });
@@ -619,8 +655,51 @@ function Card({
619
655
  );
620
656
  return /* @__PURE__ */ React11.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, children);
621
657
  }
658
+ var hadKeyboardEvent = false;
659
+ var isListenerSetup = false;
660
+ function setupModality() {
661
+ if (isListenerSetup || typeof document === "undefined") return;
662
+ isListenerSetup = true;
663
+ const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
664
+ "Tab",
665
+ "ArrowUp",
666
+ "ArrowDown",
667
+ "ArrowLeft",
668
+ "ArrowRight",
669
+ "Enter",
670
+ " ",
671
+ "Escape"
672
+ ]);
673
+ document.addEventListener("keydown", (e) => {
674
+ if (NAVIGATION_KEYS.has(e.key)) {
675
+ hadKeyboardEvent = true;
676
+ }
677
+ }, true);
678
+ document.addEventListener("pointerdown", () => {
679
+ hadKeyboardEvent = false;
680
+ }, true);
681
+ document.addEventListener("mousedown", () => {
682
+ hadKeyboardEvent = false;
683
+ }, true);
684
+ }
685
+ function useFocusVisible() {
686
+ const [isFocusVisible, setIsFocusVisible] = useState(false);
687
+ useEffect(() => {
688
+ setupModality();
689
+ }, []);
690
+ const onFocus = useCallback(() => {
691
+ if (hadKeyboardEvent) {
692
+ setIsFocusVisible(true);
693
+ }
694
+ }, []);
695
+ const onBlur = useCallback(() => {
696
+ setIsFocusVisible(false);
697
+ }, []);
698
+ const focusProps = { onFocus, onBlur };
699
+ return { isFocusVisible, focusProps };
700
+ }
622
701
 
623
- // src/Frame/Frame.utils.ts
702
+ // src/primitives/Frame/Frame.utils.ts
624
703
  function resolveSpacing(value, tokens) {
625
704
  if (typeof value === "number") return value;
626
705
  return tokens.spacing[value];
@@ -685,7 +764,7 @@ function resolveSizing(width, height) {
685
764
  }
686
765
  if (height !== void 0) {
687
766
  if (height === "fill") {
688
- style.flexGrow = style.flexGrow === 1 ? 1 : 1;
767
+ style.flexGrow = 1;
689
768
  style.height = "100%";
690
769
  } else if (typeof height === "number") {
691
770
  style.height = height;
@@ -721,7 +800,7 @@ function resolveFlexDirection(direction, reverse) {
721
800
  return reverse ? "column-reverse" : "column";
722
801
  }
723
802
 
724
- // src/Frame/Frame.styles.ts
803
+ // src/primitives/Frame/Frame.styles.ts
725
804
  function getFrameStyles(input) {
726
805
  const {
727
806
  tokens,
@@ -810,12 +889,15 @@ function getFrameStyles(input) {
810
889
  if (layout === "grid") {
811
890
  gridWebStyle = {
812
891
  display: "grid",
892
+ // Divide into equal-width columns (e.g. 3 columns → "repeat(3, 1fr)").
813
893
  gridTemplateColumns: columns ? `repeat(${columns}, 1fr)` : void 0,
814
894
  gridTemplateRows: rows ? `repeat(${rows}, 1fr)` : void 0
815
895
  };
816
896
  }
817
897
  const insetBoxShadow = frameElevation === -2 ? "inset 0 2px 4px rgba(0,0,0,0.12)" : null;
818
898
  return {
899
+ // Validate and optimize the container styles through StyleSheet.create(),
900
+ // then extract the single style object with `.c`.
819
901
  container: StyleSheet.create({ c: container }).c,
820
902
  pressed,
821
903
  gridWebStyle,
@@ -823,7 +905,7 @@ function getFrameStyles(input) {
823
905
  };
824
906
  }
825
907
 
826
- // src/Frame/Frame.tsx
908
+ // src/primitives/Frame/Frame.tsx
827
909
  function wrapTextChildren(children, textStyle) {
828
910
  return React11.Children.map(children, (child) => {
829
911
  if (typeof child === "string" || typeof child === "number") {
@@ -869,6 +951,13 @@ function Frame({
869
951
  onPress,
870
952
  href,
871
953
  disabled = false,
954
+ // Accessibility
955
+ accessibilityLabel,
956
+ accessibilityHint,
957
+ // Testing & platform
958
+ testID,
959
+ nativeID,
960
+ ref,
872
961
  // Style override
873
962
  style
874
963
  }) {
@@ -952,6 +1041,14 @@ function Frame({
952
1041
  }
953
1042
  const userStyles = Array.isArray(style) ? style : style ? [style] : [];
954
1043
  const isInteractive = onPress !== void 0 || href !== void 0;
1044
+ const { isFocusVisible, focusProps } = useFocusVisible();
1045
+ const focusRingStyle = isFocusVisible && !disabled ? {
1046
+ outlineWidth: 2,
1047
+ outlineStyle: "solid",
1048
+ outlineColor: srgbToHex(tokens.interactive.srgb),
1049
+ outlineOffset: 2
1050
+ } : void 0;
1051
+ const webFocusProps = isInteractive ? focusProps : {};
955
1052
  const textStyle = useMemo(
956
1053
  () => ({
957
1054
  color: srgbToHex(tokens.textPrimary.srgb),
@@ -961,27 +1058,56 @@ function Frame({
961
1058
  }),
962
1059
  [tokens]
963
1060
  );
964
- const wrappedChildren = wrapTextChildren(children, textStyle);
965
- return /* @__PURE__ */ React11.createElement(FrameContext.Provider, { value: contextValue }, isInteractive ? /* @__PURE__ */ React11.createElement(
966
- Pressable,
967
- {
968
- onPress,
969
- disabled,
970
- ...href ? { href, accessibilityRole: "link" } : { accessibilityRole: "button" },
971
- style: ({ pressed }) => [
972
- styles.container,
973
- pressed && !disabled && styles.pressed,
974
- ...webOverrides,
975
- ...userStyles
976
- ]
977
- },
978
- wrappedChildren
979
- ) : /* @__PURE__ */ React11.createElement(View, { style: [styles.container, ...webOverrides, ...userStyles] }, wrappedChildren));
1061
+ const wrappedChildren = useMemo(
1062
+ () => wrapTextChildren(children, textStyle),
1063
+ [children, textStyle]
1064
+ );
1065
+ return /* @__PURE__ */ React11.createElement(FrameContext.Provider, { value: contextValue }, isInteractive ? (
1066
+ // Pressable handles taps. When href is set, react-native-web renders
1067
+ // it as an <a> tag so it works like a regular link on the web.
1068
+ /* @__PURE__ */ React11.createElement(
1069
+ Pressable,
1070
+ {
1071
+ ref,
1072
+ testID,
1073
+ nativeID,
1074
+ accessibilityLabel,
1075
+ accessibilityHint,
1076
+ accessibilityState: disabled ? { disabled: true } : void 0,
1077
+ onPress,
1078
+ disabled,
1079
+ ...href ? { href, accessibilityRole: "link" } : { accessibilityRole: "button" },
1080
+ ...webFocusProps,
1081
+ style: ({ pressed }) => [
1082
+ styles.container,
1083
+ pressed && !disabled && styles.pressed,
1084
+ focusRingStyle,
1085
+ ...webOverrides,
1086
+ ...userStyles
1087
+ ]
1088
+ },
1089
+ wrappedChildren
1090
+ )
1091
+ ) : (
1092
+ // Non-interactive Frame: just a plain View with no tap handling.
1093
+ /* @__PURE__ */ React11.createElement(
1094
+ View,
1095
+ {
1096
+ ref,
1097
+ testID,
1098
+ nativeID,
1099
+ accessibilityLabel,
1100
+ accessibilityHint,
1101
+ style: [styles.container, ...webOverrides, ...userStyles]
1102
+ },
1103
+ wrappedChildren
1104
+ )
1105
+ ));
980
1106
  }
981
1107
  function getTextInputStyles(tokens, disabled) {
982
1108
  return StyleSheet.create({
983
1109
  container: {
984
- gap: tokens.spacing.xs
1110
+ gap: tokens.spacing["04"]
985
1111
  },
986
1112
  label: {
987
1113
  fontFamily: tokens.typography.fonts.default,
@@ -995,8 +1121,8 @@ function getTextInputStyles(tokens, disabled) {
995
1121
  borderWidth: 1,
996
1122
  borderColor: srgbToHex(tokens.border.srgb),
997
1123
  borderRadius: tokens.radius.md,
998
- paddingVertical: tokens.spacing.sm,
999
- paddingHorizontal: tokens.spacing.md,
1124
+ paddingVertical: tokens.spacing["08"],
1125
+ paddingHorizontal: tokens.spacing["12"],
1000
1126
  fontSize: tokens.typography.size.base,
1001
1127
  color: disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb),
1002
1128
  opacity: disabled ? 0.5 : 1
@@ -1042,7 +1168,11 @@ function getPopoverStyles(tokens, triggerHeight, offset, maxHeight, width, isOpe
1042
1168
  maxHeight,
1043
1169
  zIndex: 1e3,
1044
1170
  overflow: "hidden",
1045
- ...{ boxShadow: "0 4px 12px rgba(0,0,0,0.15)" }
1171
+ shadowColor: "#000",
1172
+ shadowOffset: { width: 0, height: 4 },
1173
+ shadowOpacity: 0.15,
1174
+ shadowRadius: 12,
1175
+ elevation: 8
1046
1176
  }
1047
1177
  });
1048
1178
  }
@@ -1081,6 +1211,7 @@ function Popover({
1081
1211
  }, [isOpen, onClose]);
1082
1212
  useEffect(() => {
1083
1213
  if (!isOpen) return;
1214
+ if (typeof document === "undefined") return;
1084
1215
  const handleMouseDown = (e) => {
1085
1216
  const node = containerRef.current;
1086
1217
  if (node && !node.contains(e.target)) {
@@ -1151,12 +1282,12 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
1151
1282
  const isSm = size === "sm";
1152
1283
  const fontSize = isSm ? tokens.typography.size.sm : tokens.typography.size.base;
1153
1284
  const iconSize = fontSize + 2;
1154
- const iconSpace = iconSize + tokens.spacing.sm;
1155
- const paddingVertical = isSm ? tokens.spacing.xs : tokens.spacing.sm;
1156
- const paddingHorizontal = isSm ? tokens.spacing.sm : tokens.spacing.md;
1285
+ const iconSpace = iconSize + tokens.spacing["08"];
1286
+ const paddingVertical = isSm ? tokens.spacing["04"] : tokens.spacing["08"];
1287
+ const paddingHorizontal = isSm ? tokens.spacing["08"] : tokens.spacing["12"];
1157
1288
  return StyleSheet.create({
1158
1289
  container: {
1159
- gap: tokens.spacing.xs,
1290
+ gap: tokens.spacing["04"],
1160
1291
  zIndex: isOpen ? 999 : 0
1161
1292
  },
1162
1293
  label: {
@@ -1174,7 +1305,7 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
1174
1305
  borderRadius: tokens.radius.md,
1175
1306
  paddingVertical,
1176
1307
  paddingLeft: paddingHorizontal,
1177
- paddingRight: iconSpace + (isSm ? tokens.spacing.xs : tokens.spacing.sm),
1308
+ paddingRight: iconSpace + (isSm ? tokens.spacing["04"] : tokens.spacing["08"]),
1178
1309
  opacity: disabled ? 0.5 : 1
1179
1310
  },
1180
1311
  triggerText: {
@@ -1185,7 +1316,7 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
1185
1316
  },
1186
1317
  iconWrapper: {
1187
1318
  position: "absolute",
1188
- right: isSm ? tokens.spacing.xs : tokens.spacing.sm,
1319
+ right: isSm ? tokens.spacing["04"] : tokens.spacing["08"],
1189
1320
  top: 0,
1190
1321
  bottom: 0,
1191
1322
  justifyContent: "center"
@@ -1197,9 +1328,9 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
1197
1328
  color: srgbToHex(tokens.textSecondary.srgb),
1198
1329
  textTransform: "uppercase",
1199
1330
  letterSpacing: 0.5,
1200
- paddingVertical: tokens.spacing.xs,
1201
- paddingHorizontal: isSm ? tokens.spacing.sm : tokens.spacing.md,
1202
- paddingTop: tokens.spacing.sm
1331
+ paddingVertical: tokens.spacing["04"],
1332
+ paddingHorizontal: isSm ? tokens.spacing["08"] : tokens.spacing["12"],
1333
+ paddingTop: tokens.spacing["08"]
1203
1334
  }
1204
1335
  });
1205
1336
  }
@@ -1313,8 +1444,8 @@ function SelectOptionRow({
1313
1444
  size
1314
1445
  }) {
1315
1446
  const tokens = useTokens(1);
1316
- const paddingVertical = size === "sm" ? tokens.spacing.xs : tokens.spacing.sm;
1317
- const paddingHorizontal = size === "sm" ? tokens.spacing.sm : tokens.spacing.md;
1447
+ const paddingVertical = size === "sm" ? tokens.spacing["04"] : tokens.spacing["08"];
1448
+ const paddingHorizontal = size === "sm" ? tokens.spacing["08"] : tokens.spacing["12"];
1318
1449
  const fontSize = size === "sm" ? tokens.typography.size.sm : tokens.typography.size.base;
1319
1450
  if (renderOption) {
1320
1451
  return /* @__PURE__ */ React11.createElement(
@@ -1323,7 +1454,7 @@ function SelectOptionRow({
1323
1454
  onPress: option.disabled ? void 0 : onSelect,
1324
1455
  disabled: option.disabled,
1325
1456
  role: "option",
1326
- "aria-selected": isSelected
1457
+ accessibilityState: { selected: isSelected }
1327
1458
  },
1328
1459
  renderOption(option, { isSelected, isFocused })
1329
1460
  );
@@ -1334,7 +1465,7 @@ function SelectOptionRow({
1334
1465
  onPress: option.disabled ? void 0 : onSelect,
1335
1466
  disabled: option.disabled,
1336
1467
  role: "option",
1337
- "aria-selected": isSelected,
1468
+ accessibilityState: { selected: isSelected },
1338
1469
  style: ({ pressed }) => [
1339
1470
  {
1340
1471
  flexDirection: "row",
@@ -1379,7 +1510,7 @@ function SelectOptionRow({
1379
1510
  },
1380
1511
  option.label
1381
1512
  ),
1382
- isSelected && /* @__PURE__ */ React11.createElement(View, { style: { marginLeft: tokens.spacing.sm } }, /* @__PURE__ */ React11.createElement(
1513
+ isSelected && /* @__PURE__ */ React11.createElement(View, { style: { marginLeft: tokens.spacing["08"] } }, /* @__PURE__ */ React11.createElement(
1383
1514
  Icon,
1384
1515
  {
1385
1516
  name: "check",
@@ -1440,8 +1571,7 @@ function Select({
1440
1571
  onPress: disabled ? void 0 : toggle,
1441
1572
  disabled,
1442
1573
  role: "combobox",
1443
- "aria-expanded": isOpen,
1444
- "aria-haspopup": "listbox",
1574
+ accessibilityState: { expanded: isOpen },
1445
1575
  ...triggerWebProps,
1446
1576
  style: styles.trigger
1447
1577
  },
@@ -1515,7 +1645,7 @@ function getToggleStyles(tokens, value, disabled) {
1515
1645
  container: {
1516
1646
  flexDirection: "row",
1517
1647
  alignItems: "center",
1518
- gap: tokens.spacing.sm,
1648
+ gap: tokens.spacing["08"],
1519
1649
  opacity: disabled ? 0.5 : 1
1520
1650
  },
1521
1651
  label: {
@@ -1576,7 +1706,7 @@ var THUMB_SIZE2 = 16;
1576
1706
  function getSliderStyles(tokens, disabled) {
1577
1707
  return StyleSheet.create({
1578
1708
  container: {
1579
- gap: tokens.spacing.xs,
1709
+ gap: tokens.spacing["04"],
1580
1710
  opacity: disabled ? 0.5 : 1
1581
1711
  },
1582
1712
  labelRow: {
@@ -1792,7 +1922,7 @@ function buildHueSegments(min, max) {
1792
1922
  function getHueSliderStyles(tokens, disabled) {
1793
1923
  return StyleSheet.create({
1794
1924
  container: {
1795
- gap: tokens.spacing.xs,
1925
+ gap: tokens.spacing["04"],
1796
1926
  opacity: disabled ? 0.5 : 1
1797
1927
  },
1798
1928
  labelRow: {
@@ -1966,7 +2096,7 @@ var THUMB_SIZE4 = 18;
1966
2096
  function getColorScaleSliderStyles(tokens, disabled) {
1967
2097
  return StyleSheet.create({
1968
2098
  container: {
1969
- gap: tokens.spacing.xs,
2099
+ gap: tokens.spacing["04"],
1970
2100
  opacity: disabled ? 0.5 : 1
1971
2101
  },
1972
2102
  labelRow: {
@@ -2131,6 +2261,170 @@ function ColorScaleSlider({
2131
2261
  /* @__PURE__ */ React11.createElement(Animated.View, { style: [styles.thumb, { left: thumbAnim }] })
2132
2262
  ), warning && /* @__PURE__ */ React11.createElement(Text, { style: styles.warning }, warning));
2133
2263
  }
2264
+ function getWrapperStyles(input) {
2265
+ const {
2266
+ tokens,
2267
+ direction = "vertical",
2268
+ wrap = false,
2269
+ reverse = false,
2270
+ align,
2271
+ justify,
2272
+ padding,
2273
+ gap,
2274
+ width,
2275
+ height,
2276
+ minWidth,
2277
+ maxWidth,
2278
+ minHeight,
2279
+ maxHeight
2280
+ } = input;
2281
+ const container = {};
2282
+ container.flexDirection = resolveFlexDirection(direction, reverse);
2283
+ if (wrap) container.flexWrap = "wrap";
2284
+ if (align) container.alignItems = resolveAlignment(align);
2285
+ if (justify) container.justifyContent = resolveJustification(justify);
2286
+ if (padding !== void 0) {
2287
+ const p = resolvePadding(padding, tokens);
2288
+ container.paddingTop = p.top;
2289
+ container.paddingRight = p.right;
2290
+ container.paddingBottom = p.bottom;
2291
+ container.paddingLeft = p.left;
2292
+ }
2293
+ if (gap !== void 0) {
2294
+ const g = resolveGap(gap, tokens);
2295
+ container.rowGap = g.rowGap;
2296
+ container.columnGap = g.columnGap;
2297
+ }
2298
+ Object.assign(container, resolveSizing(width, height));
2299
+ if (minWidth !== void 0) container.minWidth = minWidth;
2300
+ if (maxWidth !== void 0) container.maxWidth = maxWidth;
2301
+ if (minHeight !== void 0) container.minHeight = minHeight;
2302
+ if (maxHeight !== void 0) container.maxHeight = maxHeight;
2303
+ return StyleSheet.create({ c: container }).c;
2304
+ }
2305
+
2306
+ // src/primitives/Wrapper/Wrapper.tsx
2307
+ function Wrapper({
2308
+ children,
2309
+ direction,
2310
+ wrap,
2311
+ reverse,
2312
+ align,
2313
+ justify,
2314
+ padding,
2315
+ gap,
2316
+ width,
2317
+ height,
2318
+ minWidth,
2319
+ maxWidth,
2320
+ minHeight,
2321
+ maxHeight,
2322
+ style,
2323
+ // Testing & platform
2324
+ testID,
2325
+ nativeID,
2326
+ ref
2327
+ }) {
2328
+ const tokens = useTokens(1);
2329
+ const containerStyle = useMemo(
2330
+ () => getWrapperStyles({
2331
+ tokens,
2332
+ direction,
2333
+ wrap,
2334
+ reverse,
2335
+ align,
2336
+ justify,
2337
+ padding,
2338
+ gap,
2339
+ width,
2340
+ height,
2341
+ minWidth,
2342
+ maxWidth,
2343
+ minHeight,
2344
+ maxHeight
2345
+ }),
2346
+ [
2347
+ tokens,
2348
+ direction,
2349
+ wrap,
2350
+ reverse,
2351
+ align,
2352
+ justify,
2353
+ padding,
2354
+ gap,
2355
+ width,
2356
+ height,
2357
+ minWidth,
2358
+ maxWidth,
2359
+ minHeight,
2360
+ maxHeight
2361
+ ]
2362
+ );
2363
+ const userStyles = Array.isArray(style) ? style : style ? [style] : [];
2364
+ return /* @__PURE__ */ React11.createElement(
2365
+ View,
2366
+ {
2367
+ ref,
2368
+ testID,
2369
+ nativeID,
2370
+ accessibilityRole: "none",
2371
+ style: [containerStyle, ...userStyles]
2372
+ },
2373
+ children
2374
+ );
2375
+ }
2376
+ var COLOR_MAP = {
2377
+ primary: "textPrimary",
2378
+ secondary: "textSecondary",
2379
+ interactive: "interactive"
2380
+ };
2381
+ function Text11({
2382
+ children,
2383
+ size = "base",
2384
+ weight = "regular",
2385
+ color = "primary",
2386
+ font = "default",
2387
+ lineHeight = "normal",
2388
+ align,
2389
+ numberOfLines,
2390
+ elevation = 1,
2391
+ style,
2392
+ // Accessibility
2393
+ accessibilityRole,
2394
+ // Testing & platform
2395
+ testID,
2396
+ nativeID,
2397
+ ref
2398
+ }) {
2399
+ const tokens = useTokens(elevation);
2400
+ const resolvedStyle = useMemo(() => {
2401
+ const fontSize = tokens.typography.size[size];
2402
+ return {
2403
+ // Font family from the theme (e.g. 'default' → 'Inter', 'mono' → 'JetBrains Mono').
2404
+ fontFamily: tokens.typography.fonts[font],
2405
+ fontSize,
2406
+ // Font weight is stored as a number (e.g. 400, 600) but React Native expects a string.
2407
+ fontWeight: String(tokens.typography.weight[weight]),
2408
+ // Convert the theme color from internal sRGB format to a hex string (e.g. '#1a1a1a').
2409
+ color: srgbToHex(tokens[COLOR_MAP[color]].srgb),
2410
+ // Line height = font size × multiplier (e.g. 16px × 1.5 = 24px line height).
2411
+ lineHeight: fontSize * tokens.typography.lineHeight[lineHeight],
2412
+ textAlign: align
2413
+ };
2414
+ }, [tokens, size, weight, color, font, lineHeight, align]);
2415
+ return /* @__PURE__ */ React11.createElement(
2416
+ Text,
2417
+ {
2418
+ ref,
2419
+ testID,
2420
+ nativeID,
2421
+ accessibilityRole,
2422
+ style: style ? [resolvedStyle, ...Array.isArray(style) ? style : [style]] : resolvedStyle,
2423
+ numberOfLines
2424
+ },
2425
+ children
2426
+ );
2427
+ }
2134
2428
  function getAppShellStyles(tokens) {
2135
2429
  return StyleSheet.create({
2136
2430
  container: {
@@ -2793,6 +3087,6 @@ var SYSTEM_FONTS = [
2793
3087
  }
2794
3088
  ];
2795
3089
 
2796
- export { AppShell, Button, CATEGORIES, COMPONENTS, Card, ColorScaleSlider, DEFAULT_THEME_CONFIG, Frame, GOOGLE_FONTS, HueSlider, Icon, Navbar, NewtoneProvider, Popover, SYSTEM_FONTS, Select, Sidebar, Slider, TextInput, Toggle, buildGoogleFontsUrl, computeTokens, generateComponentCode, getCategory, getComponent, getComponentsByCategory, isOptionGroup, useFrameContext, useNewtoneTheme, usePopover, useTokens };
3090
+ export { AppShell, Button, CATEGORIES, COMPONENTS, Card, ColorScaleSlider, DEFAULT_THEME_CONFIG, Frame, GOOGLE_FONTS, HueSlider, Icon, Navbar, NewtoneProvider, Popover, SYSTEM_FONTS, Select, Sidebar, Slider, Text11 as Text, TextInput, Toggle, Wrapper, buildGoogleFontsUrl, computeTokens, generateComponentCode, getCategory, getComponent, getComponentsByCategory, isOptionGroup, useFocusVisible, useFrameContext, useNewtoneTheme, usePopover, useTokens };
2797
3091
  //# sourceMappingURL=index.js.map
2798
3092
  //# sourceMappingURL=index.js.map