react-native-system-ui 1.0.0 → 1.0.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.
Files changed (205) hide show
  1. package/dist/cjs/components/action-sheet/ActionSheet.js +45 -51
  2. package/dist/cjs/components/area/Area.js +22 -22
  3. package/dist/cjs/components/avatar/Avatar.js +23 -23
  4. package/dist/cjs/components/badge/Badge.js +56 -61
  5. package/dist/cjs/components/button/Button.js +87 -92
  6. package/dist/cjs/components/button/ButtonGroup.js +4 -4
  7. package/dist/cjs/components/calendar/Calendar.js +28 -28
  8. package/dist/cjs/components/cascader/Cascader.js +205 -212
  9. package/dist/cjs/components/cell/Cell.js +54 -51
  10. package/dist/cjs/components/cell/CellGroup.js +26 -25
  11. package/dist/cjs/components/checkbox/Checkbox.js +1 -0
  12. package/dist/cjs/components/checkbox/CheckboxGroup.js +20 -19
  13. package/dist/cjs/components/circle/Circle.js +66 -54
  14. package/dist/cjs/components/collapse/Collapse.js +18 -18
  15. package/dist/cjs/components/config-provider/ConfigProvider.js +5 -5
  16. package/dist/cjs/components/count-down/CountDown.js +17 -17
  17. package/dist/cjs/components/datetime-picker/DatetimePicker.js +34 -35
  18. package/dist/cjs/components/dialog/Dialog.js +16 -10
  19. package/dist/cjs/components/dialog/imperative.js +8 -14
  20. package/dist/cjs/components/dialog/tokens.js +1 -0
  21. package/dist/cjs/components/divider/Divider.js +48 -51
  22. package/dist/cjs/components/empty/Empty.js +30 -25
  23. package/dist/cjs/components/error-boundary/ErrorBoundary.js +3 -2
  24. package/dist/cjs/components/flex/Flex.js +27 -27
  25. package/dist/cjs/components/flex/FlexItem.js +1 -0
  26. package/dist/cjs/components/form/Form.js +93 -92
  27. package/dist/cjs/components/form/FormItem.js +60 -54
  28. package/dist/cjs/components/form/FormList.js +35 -35
  29. package/dist/cjs/components/grid/Grid.js +48 -48
  30. package/dist/cjs/components/grid/GridItem.js +9 -2
  31. package/dist/cjs/components/image/Image.js +25 -24
  32. package/dist/cjs/components/image/tokens.js +3 -1
  33. package/dist/cjs/components/image-preview/ImagePreview.js +19 -19
  34. package/dist/cjs/components/image-preview/tokens.js +3 -1
  35. package/dist/cjs/components/input/Input.js +16 -19
  36. package/dist/cjs/components/loading/Loading.js +27 -27
  37. package/dist/cjs/components/nav-bar/NavBar.js +21 -18
  38. package/dist/cjs/components/nav-bar/tokens.js +3 -1
  39. package/dist/cjs/components/notice-bar/NoticeBar.js +7 -3
  40. package/dist/cjs/components/notice-bar/tokens.js +3 -1
  41. package/dist/cjs/components/notify/Notify.js +2 -1
  42. package/dist/cjs/components/notify/imperative.js +17 -17
  43. package/dist/cjs/components/notify/tokens.js +1 -0
  44. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +217 -201
  45. package/dist/cjs/components/number-keyboard/tokens.js +7 -1
  46. package/dist/cjs/components/overlay/Overlay.js +15 -15
  47. package/dist/cjs/components/password-input/PasswordInput.js +49 -49
  48. package/dist/cjs/components/picker/Picker.js +50 -58
  49. package/dist/cjs/components/popup/Popup.js +10 -10
  50. package/dist/cjs/components/popup/tokens.js +1 -0
  51. package/dist/cjs/components/portal/Portal.js +3 -4
  52. package/dist/cjs/components/progress/Progress.js +94 -95
  53. package/dist/cjs/components/progress/tokens.js +1 -0
  54. package/dist/cjs/components/radio/Radio.js +67 -63
  55. package/dist/cjs/components/radio/RadioGroup.js +6 -6
  56. package/dist/cjs/components/safe-area-view/SafeAreaView.js +7 -7
  57. package/dist/cjs/components/search/Search.js +28 -28
  58. package/dist/cjs/components/selector/Selector.js +19 -26
  59. package/dist/cjs/components/share-sheet/ShareSheet.js +6 -1
  60. package/dist/cjs/components/share-sheet/tokens.js +3 -1
  61. package/dist/cjs/components/sidebar/Sidebar.js +22 -16
  62. package/dist/cjs/components/sidebar/SidebarItem.js +9 -8
  63. package/dist/cjs/components/sidebar/tokens.js +3 -1
  64. package/dist/cjs/components/skeleton/Skeleton.js +43 -42
  65. package/dist/cjs/components/space/Space.js +45 -41
  66. package/dist/cjs/components/space/tokens.js +7 -1
  67. package/dist/cjs/components/stepper/Stepper.js +17 -15
  68. package/dist/cjs/components/stepper/tokens.js +1 -0
  69. package/dist/cjs/components/swiper/Swiper.js +10 -7
  70. package/dist/cjs/components/swiper/SwiperPagIndicator.js +3 -2
  71. package/dist/cjs/components/switch/Switch.js +23 -23
  72. package/dist/cjs/components/tabbar/Tabbar.js +26 -26
  73. package/dist/cjs/components/tabs/Tabs.js +143 -153
  74. package/dist/cjs/components/tabs/tokens.js +3 -1
  75. package/dist/cjs/components/tag/Tag.js +38 -38
  76. package/dist/cjs/components/toast/Toast.js +3 -2
  77. package/dist/cjs/components/toast/tokens.js +1 -0
  78. package/dist/cjs/components/typography/Typography.js +23 -21
  79. package/dist/cjs/components/water-mark/WaterMark.js +65 -65
  80. package/dist/cjs/design-system/Text.js +38 -0
  81. package/dist/cjs/design-system/createComponentTokensHook.js +2 -2
  82. package/dist/cjs/design-system/index.js +7 -0
  83. package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
  84. package/dist/cjs/hooks/useControllableValue.js +11 -11
  85. package/dist/cjs/hooks/useCountDown.js +18 -18
  86. package/dist/cjs/platform/measure.js +4 -2
  87. package/dist/cjs/utils/color.js +2 -7
  88. package/dist/cjs/utils/compare.js +3 -3
  89. package/dist/cjs/utils/date.js +2 -2
  90. package/dist/cjs/utils/deepMerge.js +5 -5
  91. package/dist/cjs/utils/hairline.js +1 -0
  92. package/dist/cjs/utils/render.js +2 -8
  93. package/dist/cjs/utils/validate.js +2 -4
  94. package/dist/es/components/action-sheet/ActionSheet.js +45 -51
  95. package/dist/es/components/area/Area.js +22 -22
  96. package/dist/es/components/avatar/Avatar.js +23 -23
  97. package/dist/es/components/badge/Badge.js +56 -61
  98. package/dist/es/components/button/Button.js +87 -92
  99. package/dist/es/components/button/ButtonGroup.js +4 -4
  100. package/dist/es/components/calendar/Calendar.js +28 -28
  101. package/dist/es/components/cascader/Cascader.js +205 -212
  102. package/dist/es/components/cell/Cell.js +55 -52
  103. package/dist/es/components/cell/CellGroup.js +26 -25
  104. package/dist/es/components/checkbox/Checkbox.js +1 -0
  105. package/dist/es/components/checkbox/CheckboxGroup.js +20 -19
  106. package/dist/es/components/circle/Circle.js +66 -54
  107. package/dist/es/components/collapse/Collapse.js +18 -18
  108. package/dist/es/components/config-provider/ConfigProvider.js +5 -5
  109. package/dist/es/components/count-down/CountDown.js +17 -17
  110. package/dist/es/components/datetime-picker/DatetimePicker.js +34 -35
  111. package/dist/es/components/dialog/Dialog.js +16 -10
  112. package/dist/es/components/dialog/imperative.js +8 -14
  113. package/dist/es/components/dialog/tokens.js +1 -0
  114. package/dist/es/components/divider/Divider.js +48 -51
  115. package/dist/es/components/empty/Empty.js +30 -25
  116. package/dist/es/components/error-boundary/ErrorBoundary.js +3 -2
  117. package/dist/es/components/flex/Flex.js +27 -27
  118. package/dist/es/components/flex/FlexItem.js +1 -0
  119. package/dist/es/components/form/Form.js +93 -92
  120. package/dist/es/components/form/FormItem.js +60 -54
  121. package/dist/es/components/form/FormList.js +35 -35
  122. package/dist/es/components/grid/Grid.js +48 -48
  123. package/dist/es/components/grid/GridItem.js +10 -3
  124. package/dist/es/components/image/Image.js +25 -24
  125. package/dist/es/components/image/tokens.js +3 -1
  126. package/dist/es/components/image-preview/ImagePreview.js +19 -19
  127. package/dist/es/components/image-preview/tokens.js +3 -1
  128. package/dist/es/components/input/Input.js +16 -19
  129. package/dist/es/components/loading/Loading.js +27 -27
  130. package/dist/es/components/nav-bar/NavBar.js +21 -18
  131. package/dist/es/components/nav-bar/tokens.js +3 -1
  132. package/dist/es/components/notice-bar/NoticeBar.js +7 -3
  133. package/dist/es/components/notice-bar/tokens.js +3 -1
  134. package/dist/es/components/notify/Notify.js +2 -1
  135. package/dist/es/components/notify/imperative.js +17 -17
  136. package/dist/es/components/notify/tokens.js +1 -0
  137. package/dist/es/components/number-keyboard/NumberKeyboard.js +217 -201
  138. package/dist/es/components/number-keyboard/tokens.js +7 -1
  139. package/dist/es/components/overlay/Overlay.js +15 -15
  140. package/dist/es/components/password-input/PasswordInput.js +49 -49
  141. package/dist/es/components/picker/Picker.js +50 -58
  142. package/dist/es/components/popup/Popup.js +10 -10
  143. package/dist/es/components/popup/tokens.js +1 -0
  144. package/dist/es/components/portal/Portal.js +3 -4
  145. package/dist/es/components/progress/Progress.js +94 -95
  146. package/dist/es/components/progress/tokens.js +1 -0
  147. package/dist/es/components/radio/Radio.js +67 -63
  148. package/dist/es/components/radio/RadioGroup.js +6 -6
  149. package/dist/es/components/safe-area-view/SafeAreaView.js +7 -7
  150. package/dist/es/components/search/Search.js +28 -28
  151. package/dist/es/components/selector/Selector.js +19 -26
  152. package/dist/es/components/share-sheet/ShareSheet.js +6 -1
  153. package/dist/es/components/share-sheet/tokens.js +3 -1
  154. package/dist/es/components/sidebar/Sidebar.js +22 -16
  155. package/dist/es/components/sidebar/SidebarItem.js +9 -8
  156. package/dist/es/components/sidebar/tokens.js +3 -1
  157. package/dist/es/components/skeleton/Skeleton.js +43 -42
  158. package/dist/es/components/space/Space.js +45 -41
  159. package/dist/es/components/space/tokens.js +7 -1
  160. package/dist/es/components/stepper/Stepper.js +17 -15
  161. package/dist/es/components/stepper/tokens.js +1 -0
  162. package/dist/es/components/swiper/Swiper.js +11 -8
  163. package/dist/es/components/swiper/SwiperPagIndicator.js +3 -2
  164. package/dist/es/components/switch/Switch.js +23 -23
  165. package/dist/es/components/tabbar/Tabbar.js +26 -26
  166. package/dist/es/components/tabs/Tabs.js +144 -154
  167. package/dist/es/components/tabs/tokens.js +3 -1
  168. package/dist/es/components/tag/Tag.js +38 -38
  169. package/dist/es/components/toast/Toast.js +3 -2
  170. package/dist/es/components/toast/tokens.js +1 -0
  171. package/dist/es/components/typography/Typography.js +23 -21
  172. package/dist/es/components/water-mark/WaterMark.js +65 -65
  173. package/dist/es/design-system/Text.js +19 -0
  174. package/dist/es/design-system/createComponentTokensHook.js +2 -2
  175. package/dist/es/design-system/index.js +1 -0
  176. package/dist/es/design-system/mergeTokensOverride.js +1 -4
  177. package/dist/es/hooks/useControllableValue.js +11 -11
  178. package/dist/es/hooks/useCountDown.js +18 -18
  179. package/dist/es/platform/measure.js +4 -2
  180. package/dist/es/utils/color.js +1 -4
  181. package/dist/es/utils/compare.js +3 -3
  182. package/dist/es/utils/date.js +2 -2
  183. package/dist/es/utils/deepMerge.js +5 -5
  184. package/dist/es/utils/hairline.js +1 -0
  185. package/dist/es/utils/render.js +1 -1
  186. package/dist/es/utils/validate.js +1 -2
  187. package/dist/types/components/dialog/tokens.d.ts +1 -0
  188. package/dist/types/components/image-preview/tokens.d.ts +1 -0
  189. package/dist/types/components/nav-bar/tokens.d.ts +1 -1
  190. package/dist/types/components/notice-bar/tokens.d.ts +1 -0
  191. package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
  192. package/dist/types/components/picker/Picker.d.ts +1 -1
  193. package/dist/types/components/popup/tokens.d.ts +1 -0
  194. package/dist/types/components/share-sheet/tokens.d.ts +1 -0
  195. package/dist/types/components/stepper/tokens.d.ts +1 -0
  196. package/dist/types/components/tabs/tokens.d.ts +1 -0
  197. package/dist/types/components/toast/tokens.d.ts +1 -0
  198. package/dist/types/design-system/Text.d.ts +3 -0
  199. package/dist/types/design-system/index.d.ts +1 -0
  200. package/dist/types/hooks/useCountDown.d.ts +1 -1
  201. package/dist/types/utils/color.d.ts +0 -2
  202. package/dist/types/utils/date.d.ts +1 -1
  203. package/dist/types/utils/render.d.ts +1 -1
  204. package/dist/types/utils/validate.d.ts +0 -1
  205. package/package.json +17 -3
@@ -19,11 +19,11 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
19
19
  const {
20
20
  tokensOverride,
21
21
  children,
22
- type: typeProp,
23
- color: colorProp,
24
- size: sizeProp,
22
+ type: typeP,
23
+ color: colorP,
24
+ size: sizeP,
25
25
  level,
26
- disabled: disabledProp,
26
+ disabled: disP,
27
27
  delete: deleted,
28
28
  underline,
29
29
  center,
@@ -34,9 +34,9 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
34
34
  ...textProps
35
35
  } = props;
36
36
  const tokens = useTypographyTokens(tokensOverride);
37
- const type = typeProp ?? tokens.defaults.type;
38
- const size = sizeProp ?? tokens.defaults.size;
39
- const disabled = disabledProp ?? tokens.defaults.disabled;
37
+ const type = typeP ?? tokens.defaults.type;
38
+ const size = sizeP ?? tokens.defaults.size;
39
+ const disabled = disP ?? tokens.defaults.disabled;
40
40
  const ellipsisRows = resolveEllipsisRows(ellipsis);
41
41
  const ellipsisConfig = isEllipsisObject(ellipsis) ? ellipsis : undefined;
42
42
  const [isTruncated, setIsTruncated] = useState(false);
@@ -48,13 +48,14 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
48
48
  setIsTruncated(prev => prev === exceeded ? prev : exceeded);
49
49
  }, [ellipsisRows, expanded]);
50
50
  let resolvedColor = tokens.colors[type] ?? tokens.colors.default;
51
- if (colorProp !== undefined && colorProp !== null) {
52
- const colorKey = String(colorProp);
53
- resolvedColor = hasTypographyColorKey(tokens.colors, colorKey) ? tokens.colors[colorKey] : colorKey;
51
+ if (colorP !== undefined && colorP !== null) {
52
+ const ck = String(colorP);
53
+ resolvedColor = hasTypographyColorKey(tokens.colors, ck) ? tokens.colors[ck] : ck;
54
54
  }
55
+ ;
55
56
  const fontSize = level ? tokens.sizing.titles[level].fontSize : tokens.sizing.sizes[size];
56
57
  const lineHeight = level ? tokens.sizing.titles[level].lineHeight : fontSize * tokens.sizing.lineHeightMultiplier;
57
- const textDecorationLine = underline && deleted ? 'underline line-through' : underline ? 'underline' : deleted ? 'line-through' : undefined;
58
+ const textDeco = underline && deleted ? 'underline line-through' : underline ? 'underline' : deleted ? 'line-through' : undefined;
58
59
  const baseStyle = [{
59
60
  color: resolvedColor,
60
61
  fontSize,
@@ -62,12 +63,12 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
62
63
  fontFamily: tokens.typography.fontFamily,
63
64
  fontWeight: strong ? tokens.typography.weight.strong : tokens.typography.weight.regular,
64
65
  includeFontPadding: false,
65
- textDecorationLine,
66
+ textDecorationLine: textDeco,
66
67
  textAlign: center ? 'center' : undefined,
67
68
  opacity: disabled ? tokens.opacity.disabled : 1
68
69
  }, style];
69
- const hasActionText = !!ellipsisConfig && (ellipsisConfig.expandText || ellipsisConfig.collapseText);
70
- const shouldShowAction = hasActionText && (isTruncated || expanded || isWeb);
70
+ const hasActTxt = !!ellipsisConfig && (ellipsisConfig.expandText || ellipsisConfig.collapseText);
71
+ const showAct = hasActTxt && (isTruncated || expanded || isWeb);
71
72
  const handleToggleEllipsis = useCallback(() => {
72
73
  if (!ellipsisConfig) return;
73
74
  setExpanded(prev => {
@@ -76,24 +77,24 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
76
77
  return next;
77
78
  });
78
79
  }, [ellipsisConfig]);
79
- const actionLabel = !ellipsisConfig ? undefined : expanded ? ellipsisConfig.collapseText ?? ellipsisConfig.expandText : ellipsisConfig.expandText ?? ellipsisConfig.collapseText;
80
- const actionTextStyle = {
80
+ const actLabel = !ellipsisConfig ? undefined : expanded ? ellipsisConfig.collapseText ?? ellipsisConfig.expandText : ellipsisConfig.expandText ?? ellipsisConfig.collapseText;
81
+ const actTxtStyle = {
81
82
  color: tokens.colors.primary,
82
83
  fontSize: tokens.sizing.sizes.sm,
83
84
  fontWeight: tokens.typography.weight.medium,
84
85
  marginLeft: tokens.sizing.actionMarginLeft,
85
86
  includeFontPadding: false
86
87
  };
87
- const textStyle = shouldShowAction ? [baseStyle, FLEX_SHRINK_STYLE] : baseStyle;
88
+ const textStyle = showAct ? [baseStyle, FLEX_SHRINK_STYLE] : baseStyle;
88
89
  const textNode = /*#__PURE__*/React.createElement(Text, _extends({
89
90
  ref: ref,
90
91
  style: textStyle,
91
92
  onPress: onPress,
92
93
  numberOfLines: !expanded ? ellipsisRows : undefined,
93
94
  ellipsizeMode: "tail",
94
- onTextLayout: hasActionText && ellipsisRows && !expanded && !isWeb ? handleTextLayout : undefined
95
+ onTextLayout: hasActTxt && ellipsisRows && !expanded && !isWeb ? handleTextLayout : undefined
95
96
  }, textProps), children);
96
- if (!shouldShowAction) return center ? /*#__PURE__*/React.createElement(View, {
97
+ if (!showAct) return center ? /*#__PURE__*/React.createElement(View, {
97
98
  style: tokens.layout.centerWrapper
98
99
  }, textNode) : textNode;
99
100
  const actionNode = /*#__PURE__*/React.createElement(View, {
@@ -101,8 +102,8 @@ const TypographyTextBaseInner = /*#__PURE__*/React.forwardRef((props, ref) => {
101
102
  }, textNode, /*#__PURE__*/React.createElement(Text, {
102
103
  onPress: handleToggleEllipsis,
103
104
  suppressHighlighting: true,
104
- style: actionTextStyle
105
- }, actionLabel));
105
+ style: actTxtStyle
106
+ }, actLabel));
106
107
  return center ? /*#__PURE__*/React.createElement(View, {
107
108
  style: tokens.layout.centerWrapper
108
109
  }, actionNode) : actionNode;
@@ -137,6 +138,7 @@ const TypographyLink = /*#__PURE__*/React.forwardRef((props, ref) => {
137
138
  onPress(event);
138
139
  return;
139
140
  }
141
+ ;
140
142
  if (href) {
141
143
  try {
142
144
  await Linking.openURL(href);
@@ -8,7 +8,7 @@ const resolveNonNegativeNumber = (value, fallback) => Math.max(0, resolveFiniteN
8
8
  const resolvePositiveNumber = (value, fallback) => Math.max(1, resolveFiniteNumber(value, fallback));
9
9
  const WaterMarkImpl = props => {
10
10
  const {
11
- content: contentProp,
11
+ content: contentP,
12
12
  width,
13
13
  height,
14
14
  gapX,
@@ -19,8 +19,8 @@ const WaterMarkImpl = props => {
19
19
  fontSize,
20
20
  color,
21
21
  opacity,
22
- zIndex: zIndexProp,
23
- fullPage: fullPageProp,
22
+ zIndex: zIdxP,
23
+ fullPage: fullP,
24
24
  tokensOverride,
25
25
  style,
26
26
  onLayoutCalculated,
@@ -28,9 +28,9 @@ const WaterMarkImpl = props => {
28
28
  ...rest
29
29
  } = props;
30
30
  const tokens = useWaterMarkTokens(tokensOverride);
31
- const content = contentProp ?? tokens.defaults.content;
32
- const zIndex = resolveFiniteNumber(zIndexProp, tokens.defaults.zIndex);
33
- const fullPage = fullPageProp ?? tokens.defaults.fullPage;
31
+ const content = contentP ?? tokens.defaults.content;
32
+ const zIndex = resolveFiniteNumber(zIdxP, tokens.defaults.zIndex);
33
+ const fullPage = fullP ?? tokens.defaults.fullPage;
34
34
  const window = useWindowDimensions();
35
35
  const [layoutSize, setLayoutSize] = useState({
36
36
  width: 0,
@@ -41,99 +41,99 @@ const WaterMarkImpl = props => {
41
41
  height: 0
42
42
  });
43
43
  const size = fullPage ? window : layoutSize;
44
- const resolvedGapX = resolveNonNegativeNumber(gapX, tokens.defaults.gapX);
45
- const resolvedGapY = resolveNonNegativeNumber(gapY, tokens.defaults.gapY);
46
- const resolvedRotate = resolveFiniteNumber(rotate, tokens.defaults.rotate);
47
- const resolvedOpacity = Math.max(0, Math.min(1, resolveFiniteNumber(opacity, tokens.defaults.opacity)));
48
- const fontSizeFromFont = isFiniteNumber(font?.size) ? font.size : isString(font?.size) ? Number.parseFloat(font.size) : undefined;
49
- const normalizedFontSize = Math.max(0, resolveFiniteNumber((Number.isFinite(fontSizeFromFont ?? Number.NaN) ? fontSizeFromFont : undefined) ?? fontSize, tokens.defaults.fontSize));
50
- const resolvedColor = font?.color ?? color ?? tokens.colors.mark;
51
- const markWidth = resolvePositiveNumber(image?.width ?? width, tokens.defaults.width);
52
- const markHeight = resolvePositiveNumber(image?.height ?? height, tokens.defaults.height);
53
- const cellWidth = Math.max(1, markWidth + resolvedGapX);
54
- const cellHeight = Math.max(1, markHeight + resolvedGapY);
55
- const rows = size.height ? Math.ceil(size.height / cellHeight) + 1 : 1;
56
- const cols = size.width ? Math.ceil(size.width / cellWidth) + 1 : 1;
57
- const onLayoutCalculatedRef = useRef(onLayoutCalculated);
58
- onLayoutCalculatedRef.current = onLayoutCalculated;
44
+ const rGapX = resolveNonNegativeNumber(gapX, tokens.defaults.gapX);
45
+ const rGapY = resolveNonNegativeNumber(gapY, tokens.defaults.gapY);
46
+ const rRotate = resolveFiniteNumber(rotate, tokens.defaults.rotate);
47
+ const rOpacity = Math.max(0, Math.min(1, resolveFiniteNumber(opacity, tokens.defaults.opacity)));
48
+ const fontSzFromFont = isFiniteNumber(font?.size) ? font.size : isString(font?.size) ? Number.parseFloat(font.size) : undefined;
49
+ const normFontSz = Math.max(0, resolveFiniteNumber((Number.isFinite(fontSzFromFont ?? Number.NaN) ? fontSzFromFont : undefined) ?? fontSize, tokens.defaults.fontSize));
50
+ const rColor = font?.color ?? color ?? tokens.colors.mark;
51
+ const markW = resolvePositiveNumber(image?.width ?? width, tokens.defaults.width);
52
+ const markH = resolvePositiveNumber(image?.height ?? height, tokens.defaults.height);
53
+ const cellW = Math.max(1, markW + rGapX);
54
+ const cellH = Math.max(1, markH + rGapY);
55
+ const rows = size.height ? Math.ceil(size.height / cellH) + 1 : 1;
56
+ const cols = size.width ? Math.ceil(size.width / cellW) + 1 : 1;
57
+ const onLayoutCalcRef = useRef(onLayoutCalculated);
58
+ onLayoutCalcRef.current = onLayoutCalculated;
59
59
  const handleLayout = useCallback(event => {
60
60
  if (fullPage) return;
61
61
  const {
62
- width,
63
- height
62
+ width: w,
63
+ height: h
64
64
  } = event.nativeEvent.layout;
65
- if (!isFiniteNumber(width) || !isFiniteNumber(height)) return;
66
- const nextWidth = Math.max(0, width),
67
- nextHeight = Math.max(0, height);
68
- if (lastLayoutRef.current.width === nextWidth && lastLayoutRef.current.height === nextHeight) return;
65
+ if (!isFiniteNumber(w) || !isFiniteNumber(h)) return;
66
+ const nw = Math.max(0, w),
67
+ nh = Math.max(0, h);
68
+ if (lastLayoutRef.current.width === nw && lastLayoutRef.current.height === nh) return;
69
69
  lastLayoutRef.current = {
70
- width: nextWidth,
71
- height: nextHeight
70
+ width: nw,
71
+ height: nh
72
72
  };
73
73
  setLayoutSize({
74
- width: nextWidth,
75
- height: nextHeight
74
+ width: nw,
75
+ height: nh
76
76
  });
77
- onLayoutCalculatedRef.current?.({
78
- width: nextWidth,
79
- height: nextHeight
77
+ onLayoutCalcRef.current?.({
78
+ width: nw,
79
+ height: nh
80
80
  });
81
81
  }, [fullPage]);
82
82
  useEffect(() => {
83
83
  if (!fullPage || !isFiniteNumber(window.width) || !isFiniteNumber(window.height) || window.width <= 0 || window.height <= 0) return;
84
- onLayoutCalculatedRef.current?.({
84
+ onLayoutCalcRef.current?.({
85
85
  width: window.width,
86
86
  height: window.height
87
87
  });
88
88
  }, [fullPage, window.width, window.height]);
89
- const zIndexStyle = useMemo(() => ({
89
+ const zIdxStyle = useMemo(() => ({
90
90
  zIndex
91
91
  }), [zIndex]);
92
92
  const cellStyle = useMemo(() => ({
93
- width: cellWidth,
94
- height: cellHeight
95
- }), [cellWidth, cellHeight]);
93
+ width: cellW,
94
+ height: cellH
95
+ }), [cellW, cellH]);
96
96
  const oddRowStyle = useMemo(() => ({
97
- paddingLeft: cellWidth / 2
98
- }), [cellWidth]);
97
+ paddingLeft: cellW / 2
98
+ }), [cellW]);
99
99
  const markStyle = useMemo(() => ({
100
- width: markWidth,
101
- height: markHeight,
100
+ width: markW,
101
+ height: markH,
102
102
  transform: [{
103
- rotate: `${resolvedRotate}deg`
103
+ rotate: `${rRotate}deg`
104
104
  }]
105
- }), [markWidth, markHeight, resolvedRotate]);
106
- const imageStyle = useMemo(() => ({
107
- width: markWidth,
108
- height: markHeight,
109
- opacity: resolvedOpacity
110
- }), [markWidth, markHeight, resolvedOpacity]);
111
- const textBaseStyle = useMemo(() => ({
112
- fontSize: normalizedFontSize,
113
- color: resolvedColor,
114
- opacity: resolvedOpacity,
105
+ }), [markW, markH, rRotate]);
106
+ const imgStyle = useMemo(() => ({
107
+ width: markW,
108
+ height: markH,
109
+ opacity: rOpacity
110
+ }), [markW, markH, rOpacity]);
111
+ const txtBaseStyle = useMemo(() => ({
112
+ fontSize: normFontSz,
113
+ color: rColor,
114
+ opacity: rOpacity,
115
115
  fontFamily: font?.family,
116
116
  fontWeight: font?.weight
117
- }), [normalizedFontSize, resolvedColor, resolvedOpacity, font?.family, font?.weight]);
118
- const rowIndexes = Array.from({
117
+ }), [normFontSz, rColor, rOpacity, font?.family, font?.weight]);
118
+ const rowIdx = Array.from({
119
119
  length: rows
120
120
  }, (_, i) => i);
121
- const colIndexes = Array.from({
121
+ const colIdx = Array.from({
122
122
  length: cols
123
123
  }, (_, i) => i);
124
124
  return /*#__PURE__*/React.createElement(View, _extends({
125
125
  pointerEvents: "none",
126
126
  importantForAccessibility: "no-hide-descendants",
127
127
  accessibilityElementsHidden: true,
128
- style: [fullPage ? tokens.layout.absoluteFill : null, zIndexStyle, style],
128
+ style: [fullPage ? tokens.layout.absoluteFill : null, zIdxStyle, style],
129
129
  onLayout: handleLayout
130
130
  }, rest), /*#__PURE__*/React.createElement(View, {
131
131
  style: tokens.layout.wrapper
132
- }, rowIndexes.map(rowIndex => /*#__PURE__*/React.createElement(View, {
133
- key: `row-${rowIndex}`,
134
- style: [tokens.layout.row, rowIndex % 2 === 0 ? null : oddRowStyle]
135
- }, colIndexes.map(colIndex => /*#__PURE__*/React.createElement(View, {
136
- key: `col-${rowIndex}-${colIndex}`,
132
+ }, rowIdx.map(ri => /*#__PURE__*/React.createElement(View, {
133
+ key: `row-${ri}`,
134
+ style: [tokens.layout.row, ri % 2 === 0 ? null : oddRowStyle]
135
+ }, colIdx.map(ci => /*#__PURE__*/React.createElement(View, {
136
+ key: `col-${ri}-${ci}`,
137
137
  style: [tokens.layout.cell, cellStyle]
138
138
  }, /*#__PURE__*/React.createElement(View, {
139
139
  style: [tokens.layout.mark, markStyle]
@@ -141,11 +141,11 @@ const WaterMarkImpl = props => {
141
141
  source: {
142
142
  uri: image.src
143
143
  },
144
- style: imageStyle,
144
+ style: imgStyle,
145
145
  resizeMode: "contain"
146
146
  }) : /*#__PURE__*/React.createElement(Text, {
147
147
  allowFontScaling: false,
148
- style: [textBaseStyle, textStyle]
148
+ style: [txtBaseStyle, textStyle]
149
149
  }, content))))))));
150
150
  };
151
151
  const WaterMark = /*#__PURE__*/React.memo(WaterMarkImpl);
@@ -0,0 +1,19 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from 'react';
3
+ import { Text as RNText } from 'react-native';
4
+ import { useTheme } from './useTheme';
5
+ export const Text = /*#__PURE__*/React.forwardRef(({
6
+ style,
7
+ ...rest
8
+ }, ref) => {
9
+ const {
10
+ foundations
11
+ } = useTheme();
12
+ return /*#__PURE__*/React.createElement(RNText, _extends({
13
+ ref: ref,
14
+ style: [{
15
+ fontFamily: foundations.typography.fontFamily
16
+ }, style]
17
+ }, rest));
18
+ });
19
+ Text.displayName = 'Text';
@@ -9,7 +9,7 @@ export const createComponentTokensHook = (key, createBaseTokens) => overrides =>
9
9
  const co = components?.[key];
10
10
  return useMemo(() => {
11
11
  const base = createBaseTokens(foundations);
12
- const merged = co && overrides ? deepMerge(co, overrides) : co ?? overrides;
13
- return merged ? deepMerge(base, merged) : base;
12
+ const m = co && overrides ? deepMerge(co, overrides) : co ?? overrides;
13
+ return m ? deepMerge(base, m) : base;
14
14
  }, [co, foundations, overrides]);
15
15
  };
@@ -1,4 +1,5 @@
1
1
  export { ThemeProvider } from './ThemeProvider';
2
+ export { Text } from './Text';
2
3
  export { useTheme } from './useTheme';
3
4
  export { createComponentTokensHook } from './createComponentTokensHook';
4
5
  export { mergeTokensOverride } from './mergeTokensOverride';
@@ -1,5 +1,2 @@
1
1
  import { deepMerge } from '../utils/deepMerge';
2
- export const mergeTokensOverride = (base, override) => {
3
- if (base && override) return deepMerge(base, override);
4
- return base ?? override;
5
- };
2
+ export const mergeTokensOverride = (base, override) => base && override ? deepMerge(base, override) : base ?? override;
@@ -9,21 +9,21 @@ function useControllableValue(props = {}, options = {}) {
9
9
  trigger = 'onChange'
10
10
  } = options;
11
11
  const p = props;
12
- const isControlled = hasProp(props, valuePropName);
13
- const value = p[valuePropName];
14
- const [internalValue, setInternalValue] = useState(() => {
15
- if (isControlled) return value;
12
+ const ctrl = hasProp(props, valuePropName);
13
+ const val = p[valuePropName];
14
+ const [intVal, setIntVal] = useState(() => {
15
+ if (ctrl) return val;
16
16
  if (hasProp(props, defaultValuePropName)) return p[defaultValuePropName];
17
17
  return defaultValue;
18
18
  });
19
- const handlerRef = useRef(p[trigger]);
19
+ const hRef = useRef(p[trigger]);
20
20
  useEffect(() => {
21
- handlerRef.current = p[trigger];
21
+ hRef.current = p[trigger];
22
22
  }, [props, trigger]);
23
- const triggerChange = useCallback((next, ...args) => {
24
- if (!isControlled) setInternalValue(next);
25
- if (isFunction(handlerRef.current)) handlerRef.current(next, ...args);
26
- }, [isControlled]);
27
- return [isControlled ? value : internalValue, triggerChange];
23
+ const setVal = useCallback((next, ...args) => {
24
+ if (!ctrl) setIntVal(next);
25
+ if (isFunction(hRef.current)) hRef.current(next, ...args);
26
+ }, [ctrl]);
27
+ return [ctrl ? val : intVal, setVal];
28
28
  }
29
29
  export default useControllableValue;
@@ -31,31 +31,31 @@ const useCountDown = options => {
31
31
  const timerRef = useRef(null);
32
32
  const countingRef = useRef(false);
33
33
  const [current, setCurrent] = useState(() => parseTime(remainRef.current));
34
- const clearTimer = useCallback(() => {
34
+ const clear = useCallback(() => {
35
35
  if (timerRef.current) {
36
36
  clearTimeout(timerRef.current);
37
37
  timerRef.current = null;
38
38
  }
39
39
  }, []);
40
- const update = useCallback(remain => {
41
- remainRef.current = remain;
42
- const next = parseTime(remain);
40
+ const update = useCallback(rem => {
41
+ remainRef.current = rem;
42
+ const next = parseTime(rem);
43
43
  setCurrent(next);
44
44
  onChangeRef.current?.(next);
45
- if (remain === 0) {
45
+ if (rem === 0) {
46
46
  countingRef.current = false;
47
- clearTimer();
47
+ clear();
48
48
  onFinishRef.current?.();
49
49
  }
50
- }, [clearTimer]);
50
+ }, [clear]);
51
51
  const tick = useCallback(() => {
52
52
  if (!countingRef.current) return;
53
- clearTimer();
54
- const remain = Math.max(endTimeRef.current - Date.now(), 0);
55
- update(remain);
56
- if (remain <= 0) return;
57
- timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30, remain)) : Math.max(1, Math.min(remain, remain % 1000 + 1)));
58
- }, [clearTimer, update]);
53
+ clear();
54
+ const rem = Math.max(endTimeRef.current - Date.now(), 0);
55
+ update(rem);
56
+ if (rem <= 0) return;
57
+ timerRef.current = setTimeout(tick, msRef.current ? Math.max(1, Math.min(30, rem)) : Math.max(1, Math.min(rem, rem % 1000 + 1)));
58
+ }, [clear, update]);
59
59
  const start = useCallback(() => {
60
60
  if (countingRef.current || remainRef.current <= 0) return;
61
61
  countingRef.current = true;
@@ -66,16 +66,16 @@ const useCountDown = options => {
66
66
  if (!countingRef.current) return;
67
67
  countingRef.current = false;
68
68
  remainRef.current = Math.max(endTimeRef.current - Date.now(), 0);
69
- clearTimer();
70
- }, [clearTimer]);
71
- const reset = useCallback(newTime => {
69
+ clear();
70
+ }, [clear]);
71
+ const reset = useCallback(newT => {
72
72
  pause();
73
- const n = Math.max(0, isNumber(newTime) ? newTime : timeRef.current);
73
+ const n = Math.max(0, isNumber(newT) ? newT : timeRef.current);
74
74
  remainRef.current = n;
75
75
  endTimeRef.current = Date.now() + n;
76
76
  setCurrent(parseTime(n));
77
77
  }, [pause]);
78
- useEffect(() => () => clearTimer(), [clearTimer]);
78
+ useEffect(() => () => clear(), [clear]);
79
79
  return {
80
80
  start,
81
81
  pause,
@@ -10,21 +10,23 @@ export const measureInWindow = (node, cb) => {
10
10
  cb(null);
11
11
  return;
12
12
  }
13
+ ;
13
14
  try {
14
15
  const mn = node;
15
16
  if (isFunction(mn.measureInWindow)) {
16
17
  mn.measureInWindow((x, y, w, h) => cb(toRect(x, y, w, h)));
17
18
  return;
18
19
  }
20
+ ;
19
21
  const dn = node;
20
22
  if (isFunction(dn.getBoundingClientRect)) {
21
23
  const r = dn.getBoundingClientRect();
22
24
  cb(toRect(r?.left, r?.top, r?.width, r?.height));
23
25
  return;
24
26
  }
27
+ ;
28
+ cb(null);
25
29
  } catch {
26
30
  cb(null);
27
- return;
28
31
  }
29
- cb(null);
30
32
  };
@@ -22,7 +22,4 @@ export const withAlpha = (color, alpha) => {
22
22
  }
23
23
  const rgb = parseRgb(t);
24
24
  return rgb ? `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${a})` : t;
25
- };
26
- export const ensureRgba = (color, alpha) => color.trim().toLowerCase().startsWith('rgba') ? color : withAlpha(color, alpha);
27
- const GRADIENT_RE = /(#[0-9a-fA-F]{3,8}|rgba?\([^)]*\)|hsla?\([^)]*\))/i;
28
- export const extractFirstColorToken = input => input ? input.match(GRADIENT_RE)?.[0] : undefined;
25
+ };
@@ -6,8 +6,8 @@ export const shallowEqualArray = (a = [], b = []) => {
6
6
  export const shallowEqualObject = (a, b) => {
7
7
  if (a === b) return true;
8
8
  if (!a || !b) return false;
9
- const ak = Object.keys(a);
10
- if (ak.length !== Object.keys(b).length) return false;
11
- for (const k of ak) if (a[k] !== b[k]) return false;
9
+ const ks = Object.keys(a);
10
+ if (ks.length !== Object.keys(b).length) return false;
11
+ for (const k of ks) if (a[k] !== b[k]) return false;
12
12
  return true;
13
13
  };
@@ -12,7 +12,7 @@ export const getTrueValue = value => {
12
12
  };
13
13
  export const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
14
14
  export const isValidDate = value => value instanceof Date && !Number.isNaN(value.getTime());
15
- export const formatDuration = (format, time) => {
15
+ export const formatDuration = (fmt, time) => {
16
16
  let {
17
17
  days,
18
18
  hours,
@@ -20,7 +20,7 @@ export const formatDuration = (format, time) => {
20
20
  seconds,
21
21
  milliseconds
22
22
  } = time;
23
- let t = format;
23
+ let t = fmt;
24
24
  if (t.includes('DD')) t = t.replace('DD', padZero(days));else hours += days * 24;
25
25
  if (t.includes('HH')) t = t.replace('HH', padZero(hours));else minutes += hours * 60;
26
26
  if (t.includes('mm')) t = t.replace('mm', padZero(minutes));else seconds += minutes * 60;
@@ -5,15 +5,15 @@ export function deepMerge(target, source) {
5
5
  const out = Array.isArray(target) ? [...target] : {
6
6
  ...target
7
7
  };
8
- for (const key of Object.keys(source)) {
9
- const sv = source[key];
8
+ for (const k of Object.keys(source)) {
9
+ const sv = source[k];
10
10
  if (sv === undefined) continue;
11
- const tv = target[key];
11
+ const tv = target[k];
12
12
  if (isPlainObject(tv) && isPlainObject(sv)) {
13
- out[key] = deepMerge(tv, sv);
13
+ out[k] = deepMerge(tv, sv);
14
14
  continue;
15
15
  }
16
- out[key] = Array.isArray(sv) ? [...sv] : isPlainObject(sv) ? {
16
+ out[k] = Array.isArray(sv) ? [...sv] : isPlainObject(sv) ? {
17
17
  ...sv
18
18
  } : sv;
19
19
  }
@@ -88,5 +88,6 @@ export const createHairlineView = ({
88
88
  s.transform = [SCALES[position]];
89
89
  s.transformOrigin = ORIGINS[position];
90
90
  }
91
+ ;
91
92
  return s;
92
93
  };
@@ -1,6 +1,6 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from 'react';
3
- import { Text } from 'react-native';
3
+ import { Text } from '../design-system';
4
4
  import { isText } from './validate';
5
5
  export const renderTextOrNode = (content, textStyle, textProps) => isText(content) ? /*#__PURE__*/React.createElement(Text, _extends({
6
6
  style: textStyle
@@ -11,5 +11,4 @@ export const isUndefined = val => typeof val === 'undefined';
11
11
  export const isObject = val => val !== null && typeof val === 'object';
12
12
  export const isValidNode = node => isRenderable(node) && (typeof node !== 'string' || node.length > 0);
13
13
  export const isPlainObject = val => !!val && typeof val === 'object' && !Array.isArray(val) && ! /*#__PURE__*/isValidElement(val);
14
- export const isTwoCNChar = value => /^(?:[\u4e00-\u9fa5]){2}$/.test(value);
15
- export const isImageUrlString = url => /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i.test(url);
14
+ export const isTwoCNChar = value => /^(?:[\u4e00-\u9fa5]){2}$/.test(value);
@@ -34,6 +34,7 @@ export interface DialogTokens {
34
34
  roundButtonHeight: number;
35
35
  };
36
36
  typography: {
37
+ fontFamily: string;
37
38
  titleSize: number;
38
39
  titleLineHeight: number;
39
40
  titleWeight: TextStyle['fontWeight'];
@@ -20,6 +20,7 @@ export interface ImagePreviewTokens {
20
20
  indexBadge: number;
21
21
  };
22
22
  typography: {
23
+ fontFamily: string;
23
24
  indexTextSize: number;
24
25
  };
25
26
  }
@@ -1,4 +1,4 @@
1
1
  import { type Foundations } from '../../design-system/tokens';
2
2
  import type { NavBarTokens } from './types';
3
- export declare const createNavBarTokens: ({ palette, spacing, fontSize, }: Foundations) => NavBarTokens;
3
+ export declare const createNavBarTokens: ({ palette, spacing, fontSize, typography, }: Foundations) => NavBarTokens;
4
4
  export declare const useNavBarTokens: (overrides?: import("../..").DeepPartial<NavBarTokens> | undefined) => NavBarTokens;
@@ -5,6 +5,7 @@ export interface NoticeBarTokens {
5
5
  background: string;
6
6
  };
7
7
  typography: {
8
+ fontFamily: string;
8
9
  fontSize: number;
9
10
  };
10
11
  layout: {
@@ -21,8 +21,13 @@ export interface NumberKeyboardTokens {
21
21
  keyHeight: number;
22
22
  closeHeight: number;
23
23
  fontSize: number;
24
+ defaultIconFontSize?: number;
25
+ auxFontSize?: number;
24
26
  titleFontSize: number;
25
27
  };
28
+ typography: {
29
+ fontFamily: string;
30
+ };
26
31
  radii: {
27
32
  key: number;
28
33
  };
@@ -15,7 +15,7 @@ export declare const toArrayValue: (value?: PickerValue[] | PickerValue | null)
15
15
  export declare const findEnabledIndex: (options: PickerOption[], startIdx: number) => number;
16
16
  export declare const prepareColumns: (input?: PickerColumns) => PreparedPickerColumns;
17
17
  export declare const normalizePicker: (prep: PreparedPickerColumns, raw?: PickerValue[]) => NormalizedPickerResult;
18
- export declare function usePickerValue({ columns, valueProp, defaultValue, emitConfirmOnAutoSelect, onChange, onConfirm, }: {
18
+ export declare function usePickerValue({ columns, valueProp, defaultValue, emitConfirmOnAutoSelect, onChange, onConfirm }: {
19
19
  columns?: PickerColumns;
20
20
  valueProp?: PickerProps['value'];
21
21
  defaultValue?: PickerProps['defaultValue'];
@@ -24,6 +24,7 @@ export interface PopupTokens {
24
24
  closeIconPadding: number;
25
25
  };
26
26
  typography: {
27
+ fontFamily: string;
27
28
  titleSize: number;
28
29
  titleWeight: TextStyle['fontWeight'];
29
30
  descriptionSize: number;