@momo-kits/foundation 0.169.5-beta.1 → 0.169.5

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 (138) hide show
  1. package/Application/BottomSheet.hooks.ts +8 -8
  2. package/Application/BottomSheet.parts.tsx +44 -34
  3. package/Application/BottomSheet.tsx +40 -37
  4. package/Application/BottomTab/ActiveIndicator.tsx +15 -14
  5. package/Application/BottomTab/BottomTabBar.tsx +43 -34
  6. package/Application/BottomTab/BottomTabInset.tsx +8 -4
  7. package/Application/BottomTab/CurvedContainer.tsx +14 -12
  8. package/Application/BottomTab/CustomBottomTabItem.tsx +10 -6
  9. package/Application/BottomTab/DuoBarCompression.tsx +13 -19
  10. package/Application/BottomTab/DuoRailTabBar.tsx +13 -13
  11. package/Application/BottomTab/DuoTabBar.tsx +8 -9
  12. package/Application/BottomTab/TabBarIcon.tsx +13 -8
  13. package/Application/BottomTab/TabScreen.tsx +1 -5
  14. package/Application/BottomTab/index.tsx +38 -30
  15. package/Application/BottomTab/metrics.ts +21 -20
  16. package/Application/BottomTab/tabItems.ts +1 -1
  17. package/Application/BottomTab/usePressLift.ts +2 -2
  18. package/Application/Components/BackgroundImageView.tsx +4 -0
  19. package/Application/Components/DuoGlassBackground.tsx +5 -4
  20. package/Application/Components/HeaderAnimated.tsx +4 -0
  21. package/Application/Components/HeaderBackground.tsx +4 -0
  22. package/Application/Components/HeaderExtendHeader.tsx +11 -10
  23. package/Application/Components/HeaderLeft.tsx +2 -1
  24. package/Application/Components/HeaderRight.tsx +2 -1
  25. package/Application/Components/HeaderTitle.shared.ts +11 -9
  26. package/Application/Components/HeaderTitle.tsx +4 -3
  27. package/Application/Components/HeaderToolkitAction.tsx +17 -20
  28. package/Application/Components/NavigationButton.tsx +2 -1
  29. package/Application/Components/SearchHeader.tsx +17 -10
  30. package/Application/Components/TitleJourney.tsx +2 -2
  31. package/Application/Components/TitleLocation.tsx +2 -2
  32. package/Application/Components/TitleUser.tsx +2 -2
  33. package/Application/Components/useToolkitActions.tsx +17 -32
  34. package/Application/Localize.ts +7 -0
  35. package/Application/ModalScreen.tsx +10 -10
  36. package/Application/Navigation.ts +14 -16
  37. package/Application/NavigationContainer.tsx +19 -18
  38. package/Application/Navigator.ts +20 -48
  39. package/Application/StackScreen.tracking.ts +11 -26
  40. package/Application/StackScreen.tsx +9 -39
  41. package/Application/TooltipPortal.tsx +12 -5
  42. package/Application/WidgetContainer.tsx +10 -4
  43. package/Application/modalLayout.ts +13 -14
  44. package/Application/navigationOptions.tsx +21 -17
  45. package/Badge/Badge.tsx +5 -0
  46. package/Badge/BadgeDot.tsx +1 -0
  47. package/Badge/BadgeDotAnimation.tsx +15 -7
  48. package/Badge/BadgeRibbon.tsx +46 -38
  49. package/Badge/Shape.tsx +2 -0
  50. package/Badge/types.ts +2 -2
  51. package/Button/index.tsx +5 -16
  52. package/Button/utils.ts +9 -15
  53. package/CheckBox/index.tsx +4 -0
  54. package/Consts/theme.ts +10 -10
  55. package/Context/index.ts +1 -0
  56. package/Divider/DashDivider.tsx +1 -0
  57. package/Divider/index.tsx +4 -0
  58. package/FoundationList/index.tsx +4 -0
  59. package/Icon/index.tsx +6 -6
  60. package/Icon/types.ts +1 -1
  61. package/IconButton/index.tsx +4 -12
  62. package/Image/index.tsx +9 -7
  63. package/Input/Input.tsx +8 -9
  64. package/Input/InputDropDown.tsx +10 -12
  65. package/Input/InputMoney.tsx +12 -8
  66. package/Input/InputMoneyView.tsx +14 -7
  67. package/Input/InputOTP.tsx +35 -33
  68. package/Input/InputPhoneNumber.tsx +8 -9
  69. package/Input/InputSearch.tsx +4 -6
  70. package/Input/InputTextArea.tsx +4 -0
  71. package/Input/SearchTextTyping.tsx +4 -0
  72. package/Input/SystemTextInput.tsx +7 -2
  73. package/Input/TextTyping.tsx +4 -0
  74. package/Input/common.tsx +26 -12
  75. package/Input/index.tsx +17 -20
  76. package/Input/moneyUtils.ts +10 -4
  77. package/Input/styles.ts +0 -5
  78. package/Input/utils.ts +14 -12
  79. package/Layout/Card.tsx +7 -4
  80. package/Layout/FloatingButton.tsx +4 -0
  81. package/Layout/Item.tsx +6 -2
  82. package/Layout/ItemList.tsx +9 -7
  83. package/Layout/ItemSectionList.tsx +2 -1
  84. package/Layout/ReservedRegions.tsx +25 -25
  85. package/Layout/Screen.tsx +56 -58
  86. package/Layout/Section.tsx +8 -5
  87. package/Layout/TrackingScope.tsx +1 -0
  88. package/Layout/screenContent.tsx +4 -2
  89. package/Layout/screenFooter.tsx +28 -18
  90. package/Layout/screenHeader.tsx +34 -31
  91. package/Layout/screenQuickReturn.tsx +17 -20
  92. package/Layout/screenScroll.ts +4 -7
  93. package/Layout/screenTypes.ts +3 -2
  94. package/Layout/types.ts +2 -4
  95. package/Layout/utils.ts +31 -37
  96. package/Loader/DotLoader.tsx +4 -0
  97. package/Loader/Loader.tsx +4 -0
  98. package/Loader/ProgressBar.tsx +1 -0
  99. package/Loader/Spinner.tsx +4 -0
  100. package/Loader/utils.ts +11 -7
  101. package/Pagination/Dot.tsx +4 -0
  102. package/Pagination/PaginationDot.tsx +1 -0
  103. package/Pagination/PaginationNumber.tsx +5 -3
  104. package/Pagination/PaginationScroll.tsx +5 -0
  105. package/Pagination/PaginationWhiteDot.tsx +1 -0
  106. package/Pagination/index.tsx +4 -0
  107. package/Pagination/types.ts +2 -2
  108. package/Popup/PopupNotify.tsx +44 -48
  109. package/Popup/PopupPromotion.tsx +4 -7
  110. package/Popup/types.ts +4 -4
  111. package/Popup/utils.ts +4 -0
  112. package/Radio/index.tsx +4 -0
  113. package/Skeleton/index.tsx +8 -0
  114. package/Switch/index.tsx +1 -0
  115. package/Tag/index.tsx +5 -1
  116. package/Tag/types.ts +3 -3
  117. package/Text/index.tsx +14 -3
  118. package/Text/styles.ts +1 -1
  119. package/Text/types.ts +1 -6
  120. package/Text/utils.ts +9 -0
  121. package/Title/index.tsx +41 -32
  122. package/ViewBoundary/index.tsx +4 -2
  123. package/index.ts +0 -6
  124. package/package.json +1 -1
  125. package/Application/KitAdoption/AdoptionBadge.tsx +0 -119
  126. package/Application/KitAdoption/AdoptionProbe.tsx +0 -145
  127. package/Application/KitAdoption/AdoptionStore.ts +0 -80
  128. package/Application/KitAdoption/Authorship/utils.ts +0 -137
  129. package/Application/KitAdoption/constants.ts +0 -118
  130. package/Application/KitAdoption/index.ts +0 -5
  131. package/Application/KitAdoption/styles.ts +0 -55
  132. package/Application/KitAdoption/types.ts +0 -48
  133. package/Application/KitAdoption/utils.ts +0 -375
  134. package/Application/__tests__/KitAdoption.integration.test.tsx +0 -235
  135. package/Application/__tests__/KitAdoption.test.ts +0 -283
  136. package/Application/__tests__/KitAdoptionAuthorship.test.ts +0 -132
  137. package/Application/__tests__/KitAdoptionStore.test.ts +0 -110
  138. package/Application/__tests__/modalLayout.test.ts +0 -128
@@ -1,137 +0,0 @@
1
- import {
2
- FIBER_TAG,
3
- LOCAL_SOURCE_KEY,
4
- REACT_FACTORY_FRAME_NAMES,
5
- REACT_STACK_BOTTOM_FRAME,
6
- } from '../constants';
7
- import type { FiberLike } from '../types';
8
-
9
- const HTTP_ORIGIN_PATTERN = /^(https?:\/\/[^/]+)/i;
10
- const FILE_URL_PATTERN = /^file:\/\//i;
11
- const LINE_COL_SUFFIX_PATTERN = /:\d+(?::\d+)?$/;
12
- const PAREN_LOCATION_PATTERN = /\((?:address at )?(.+)\)\s*$/;
13
- const BARE_LOCATION_PATTERN = /^\s*at\s+(.+?)\s*$/;
14
- const FRAME_NAME_PATTERN = /^\s*at\s+([^\s(]+)/;
15
- const NATIVE_FRAME_LOCATION = 'native';
16
-
17
- const creatorSourceCache = new WeakMap<object, string | null>();
18
- let hostSource: string | undefined;
19
-
20
- /**
21
- * Bundle identity of a frame location: the origin for http(s), the directory
22
- * for file URLs, and one shared key for bare source paths (jest).
23
- */
24
- const getSourceKey = (location: string): string => {
25
- const origin = HTTP_ORIGIN_PATTERN.exec(location);
26
- if (origin) return origin[1];
27
- if (!FILE_URL_PATTERN.test(location)) return LOCAL_SOURCE_KEY;
28
- const path = location.replace(LINE_COL_SUFFIX_PATTERN, '');
29
- return path.slice(0, path.lastIndexOf('/'));
30
- };
31
-
32
- /** Location (`url:line:col`) of a stack frame line, or undefined when it has none. */
33
- const parseFrameLocation = (line: string): string | undefined => {
34
- const match =
35
- PAREN_LOCATION_PATTERN.exec(line) ?? BARE_LOCATION_PATTERN.exec(line);
36
- return match?.[1];
37
- };
38
-
39
- /** Reads `.stack` of a debug stack value without throwing; undefined if it is not a string. */
40
- const readStack = (debugStack: unknown): string | undefined => {
41
- try {
42
- const stack = (debugStack as { stack?: unknown } | null)?.stack;
43
- return typeof stack === 'string' ? stack : undefined;
44
- } catch {
45
- return undefined;
46
- }
47
- };
48
-
49
- /** Frame lines below the header, cut at React's bottom-frame marker. */
50
- const getFrameLines = (stack: string): string[] => {
51
- const lines = stack.split('\n').slice(1);
52
- const bottom = lines.findIndex(line =>
53
- line.includes(REACT_STACK_BOTTOM_FRAME),
54
- );
55
- return bottom === -1 ? lines : lines.slice(0, bottom);
56
- };
57
-
58
- /**
59
- * True for frames that cannot be the element's creator: React's own factory
60
- * wrappers and native frames (e.g. `apply (native)`), which carry no bundle.
61
- */
62
- const isSkippedFrame = (line: string): boolean => {
63
- const name = FRAME_NAME_PATTERN.exec(line)?.[1] ?? '';
64
- const isNative = parseFrameLocation(line) === NATIVE_FRAME_LOCATION;
65
- return isNative || REACT_FACTORY_FRAME_NAMES.includes(name);
66
- };
67
-
68
- /** Source key of the frame that created the element, skipping React's factory frames. */
69
- const findCreatorSource = (stack: string): string | undefined => {
70
- const lines = getFrameLines(stack).slice(1);
71
- const index = lines.findIndex(line => !isSkippedFrame(line));
72
- const location = index === -1 ? undefined : parseFrameLocation(lines[index]);
73
- return location === undefined ? undefined : getSourceKey(location);
74
- };
75
-
76
- /**
77
- * Source key of the code that created an element, read from its debug stack.
78
- * Cached per stack object since fibers and alternates share it.
79
- */
80
- const getCreatorSource = (debugStack: unknown): string | undefined => {
81
- const isCacheable = typeof debugStack === 'object' && debugStack !== null;
82
- if (isCacheable && creatorSourceCache.has(debugStack)) {
83
- return creatorSourceCache.get(debugStack) ?? undefined;
84
- }
85
- const stack = readStack(debugStack);
86
- const source = stack === undefined ? undefined : findCreatorSource(stack);
87
- if (isCacheable) creatorSourceCache.set(debugStack, source ?? null);
88
- return source;
89
- };
90
-
91
- /** Source key of the bundle running this module (the host), cached after the first read. */
92
- const getHostSource = (): string => {
93
- if (hostSource !== undefined) return hostSource;
94
- const line = (new Error().stack ?? '').split('\n')[1] ?? '';
95
- const location = parseFrameLocation(line);
96
- hostSource =
97
- location === undefined ? LOCAL_SOURCE_KEY : getSourceKey(location);
98
- return hostSource;
99
- };
100
-
101
- /**
102
- * The fiber whose stack decides authorship. React creates the inner fiber of a
103
- * MemoComponent itself, with no stack, so it inherits its memo parent's.
104
- */
105
- const getAuthorFiber = (fiber: FiberLike): FiberLike =>
106
- fiber.return?.tag === FIBER_TAG.MemoComponent && fiber.return.child === fiber
107
- ? fiber.return
108
- : fiber;
109
-
110
- /**
111
- * True when the fiber has no dev stack (prod jsx) or its creator frame lives
112
- * in a bundle other than the host's. Unparseable stacks count as host.
113
- */
114
- const isAppAuthored = (fiber: FiberLike): boolean => {
115
- if (!fiber._debugStack) return true;
116
- const source = getCreatorSource(fiber._debugStack);
117
- return source !== undefined && source !== getHostSource();
118
- };
119
-
120
- /**
121
- * True when the fiber's first child was created by host code and is owned by
122
- * this fiber, which marks a host-internal wrapper.
123
- */
124
- const isHostDefined = (fiber: FiberLike): boolean => {
125
- const child = fiber.child;
126
- return !!child && !isAppAuthored(child) && child._debugOwner === fiber;
127
- };
128
-
129
- export {
130
- getAuthorFiber,
131
- getCreatorSource,
132
- getHostSource,
133
- getSourceKey,
134
- isAppAuthored,
135
- isHostDefined,
136
- parseFrameLocation,
137
- };
@@ -1,118 +0,0 @@
1
- const SETTLE_MS = 3000;
2
- const MAX_FIBERS = 20000;
3
- const SLOT_SCAN_DEPTH = 4;
4
- const TOP_TRANSPARENT_LIMIT = 10;
5
-
6
- // Generic lib names (Badge, Title, Logo, ...) are left out on purpose so app components with the same name are not counted as kit.
7
- const LIB_UNIT_NAMES: string[] = [
8
- 'AutoComplete',
9
- 'Avatar',
10
- 'Calendar',
11
- 'Carousel',
12
- 'Chip',
13
- 'Collapse',
14
- 'DateTimePicker',
15
- 'ProgressInfo',
16
- 'Rating',
17
- 'Slider',
18
- 'Stepper',
19
- 'Steps',
20
- 'SuggestAction',
21
- 'Swipe',
22
- 'TabView',
23
- 'TabBar',
24
- 'CardTabBar',
25
- 'ScrollableTabBar',
26
- 'HeaderSliderBanner',
27
- 'TrustBanner',
28
- 'Uploader',
29
- ];
30
-
31
- const RN_PRIMITIVE_NAMES: string[] = [
32
- 'View',
33
- 'Text',
34
- 'Image',
35
- 'ImageBackground',
36
- 'TextInput',
37
- 'ScrollView',
38
- 'FlatList',
39
- 'SectionList',
40
- 'VirtualizedList',
41
- 'TouchableOpacity',
42
- 'TouchableHighlight',
43
- 'TouchableWithoutFeedback',
44
- 'Pressable',
45
- 'Switch',
46
- 'ActivityIndicator',
47
- 'Modal',
48
- 'KeyboardAvoidingView',
49
- 'RefreshControl',
50
- ];
51
-
52
- /** Foundation exports that come from third-party or RN and must not count as kit. */
53
- const FOUNDATION_REEXPORT_NAMES: string[] = [
54
- 'TouchableOpacity',
55
- 'LinearGradient',
56
- 'SafeAreaView',
57
- 'SafeAreaProvider',
58
- 'SafeAreaConsumer',
59
- 'SafeAreaInsetsContext',
60
- 'SafeAreaFrameContext',
61
- 'withSafeAreaInsets',
62
- ];
63
-
64
- const FIBER_TAG = {
65
- FunctionComponent: 0,
66
- ClassComponent: 1,
67
- HostRoot: 3,
68
- HostComponent: 5,
69
- HostText: 6,
70
- Fragment: 7,
71
- ContextProvider: 10,
72
- ForwardRef: 11,
73
- MemoComponent: 14,
74
- SimpleMemoComponent: 15,
75
- } as const;
76
-
77
- /** Fiber tags that are component fibers; every other tag is walked through without counting. */
78
- const COUNTED_FIBER_TAGS: number[] = [
79
- FIBER_TAG.FunctionComponent,
80
- FIBER_TAG.ClassComponent,
81
- FIBER_TAG.HostComponent,
82
- FIBER_TAG.ForwardRef,
83
- FIBER_TAG.SimpleMemoComponent,
84
- ];
85
-
86
- const HOST_RN_PREFIXES: string[] = ['RCT', 'Android'];
87
-
88
- const LOCAL_SOURCE_KEY = 'local';
89
- const REACT_STACK_BOTTOM_FRAME = 'react-stack-bottom-frame';
90
- const REACT_FACTORY_FRAME_NAMES: string[] = [
91
- 'jsx',
92
- 'jsxs',
93
- 'jsxDEV',
94
- 'jsxDEVImpl',
95
- 'createElement',
96
- 'jsxProd',
97
- ];
98
-
99
- const REACT_MEMO_TYPE = Symbol.for('react.memo');
100
- const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
101
-
102
- export {
103
- COUNTED_FIBER_TAGS,
104
- FIBER_TAG,
105
- FOUNDATION_REEXPORT_NAMES,
106
- HOST_RN_PREFIXES,
107
- LIB_UNIT_NAMES,
108
- LOCAL_SOURCE_KEY,
109
- MAX_FIBERS,
110
- REACT_FACTORY_FRAME_NAMES,
111
- REACT_FORWARD_REF_TYPE,
112
- REACT_MEMO_TYPE,
113
- REACT_STACK_BOTTOM_FRAME,
114
- RN_PRIMITIVE_NAMES,
115
- SETTLE_MS,
116
- SLOT_SCAN_DEPTH,
117
- TOP_TRANSPARENT_LIMIT,
118
- };
@@ -1,5 +0,0 @@
1
- import { AdoptionBadge } from './AdoptionBadge';
2
- import { AdoptionProbe } from './AdoptionProbe';
3
- import { adoptionStore } from './AdoptionStore';
4
-
5
- export { AdoptionBadge, AdoptionProbe, adoptionStore };
@@ -1,55 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- import { Colors, Radius, Spacing } from '../../Consts';
4
-
5
- // Keeps the summary pill from stretching across a narrow screen.
6
- const BADGE_MAX_WIDTH = 240;
7
- // Wide enough for the three action labels without clipping.
8
- const PANEL_MIN_WIDTH = 180;
9
- // Floats the dev overlay above screen content.
10
- const BADGE_Z_INDEX = 9999;
11
-
12
- const styles = StyleSheet.create({
13
- wrapper: {
14
- position: 'absolute',
15
- left: 0,
16
- right: 0,
17
- alignItems: 'flex-end',
18
- paddingRight: Spacing.L,
19
- zIndex: BADGE_Z_INDEX,
20
- },
21
- badge: {
22
- maxWidth: BADGE_MAX_WIDTH,
23
- backgroundColor: Colors.black_17,
24
- borderRadius: Radius.S,
25
- paddingHorizontal: Spacing.S,
26
- paddingVertical: Spacing.XS,
27
- },
28
- panel: {
29
- marginTop: Spacing.XS,
30
- minWidth: PANEL_MIN_WIDTH,
31
- gap: Spacing.XS,
32
- padding: Spacing.S,
33
- backgroundColor: Colors.black_01,
34
- borderRadius: Radius.M,
35
- borderWidth: StyleSheet.hairlineWidth,
36
- borderColor: Colors.black_05,
37
- },
38
- action: {
39
- alignItems: 'center',
40
- paddingHorizontal: Spacing.S,
41
- paddingVertical: Spacing.XS,
42
- borderRadius: Radius.S,
43
- backgroundColor: Colors.blue_09,
44
- },
45
- actionOutline: {
46
- alignItems: 'center',
47
- paddingHorizontal: Spacing.S,
48
- paddingVertical: Spacing.XS,
49
- borderRadius: Radius.S,
50
- borderWidth: StyleSheet.hairlineWidth,
51
- borderColor: Colors.black_07,
52
- },
53
- });
54
-
55
- export { styles };
@@ -1,48 +0,0 @@
1
- type AdoptionBucket = 'K' | 'R' | 'O';
2
-
3
- type SnapshotStatus = 'ok' | 'dev_bundle' | 'truncated' | 'error';
4
-
5
- type WalkResult = {
6
- counts: { K: number; R: number; O: number };
7
- kit: Record<string, number>;
8
- rn: Record<string, number>;
9
- other: Record<string, number>;
10
- top_transparent: { name: string; count: number }[];
11
- fibers: number;
12
- truncated: boolean;
13
- status: SnapshotStatus;
14
- };
15
-
16
- type ScreenSnapshot = WalkResult & {
17
- app_id: string;
18
- screen_name: string;
19
- foundation_version?: string;
20
- platform: string;
21
- ts: number;
22
- walk_ms: number;
23
- };
24
-
25
- type FiberLike = {
26
- tag: number;
27
- type: unknown;
28
- child?: FiberLike | null;
29
- sibling?: FiberLike | null;
30
- return?: FiberLike | null;
31
- alternate?: FiberLike | null;
32
- memoizedProps?: unknown;
33
- _debugStack?: unknown;
34
- _debugOwner?: unknown;
35
- stateNode?: unknown;
36
- };
37
-
38
- /** Identity sets of component objects: kit exports and RN primitives. */
39
- type KitRegistries = { kit: WeakSet<object>; rn: WeakSet<object> };
40
-
41
- export type {
42
- AdoptionBucket,
43
- FiberLike,
44
- KitRegistries,
45
- ScreenSnapshot,
46
- SnapshotStatus,
47
- WalkResult,
48
- };