@momo-kits/native-kits 0.165.1-beta.11 → 0.165.2-beta.2

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 (150) hide show
  1. package/CLAUDE.md +1 -0
  2. package/ios/Application/Navigation/NavigatorManager.swift +0 -27
  3. package/ios/Information/Information.swift +5 -2
  4. package/ios/InputMoney/InputMoney.swift +76 -21
  5. package/ios/Typography/Text.swift +41 -1
  6. package/ios/native-kits.podspec +1 -1
  7. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  8. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +9 -1
  9. package/package.json +1 -1
  10. package/publish.sh +25 -0
  11. package/build.gradle.kts +0 -11
  12. package/compose/build.gradle.kts +0 -190
  13. package/compose/build.gradle.kts.backup +0 -190
  14. package/compose/compose.podspec +0 -47
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -150
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -134
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -216
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -296
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -38
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -207
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -609
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -175
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -331
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -75
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -37
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -364
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -69
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -98
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  142. package/gradle/libs.versions.toml +0 -69
  143. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  144. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  145. package/gradle.properties +0 -26
  146. package/gradlew +0 -252
  147. package/gradlew.bat +0 -94
  148. package/ios-demo/README.md +0 -120
  149. package/local.properties +0 -8
  150. package/settings.gradle.kts +0 -64
package/CLAUDE.md CHANGED
@@ -45,6 +45,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
45
45
  - **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
46
46
  - **Native bridge:** `IMaxApi` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge (dismiss, tracking, device info, language).
47
47
  - Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
48
+ - **iOS swipe-back:** the host owns the only edge-pan recogniser and replays it through `HostBackGestureBridge` (`navigation/HostBackGestureBridge.kt`; the kit framework is never exported, so the host reaches it through its own Koin-provided facade): `checkCanPop` / `canPopInner` / `pop` route the back into the kit stack, `started` / `progressed` / `completed` / `cancelled` seek the NavHost transition, `shouldUseFloatingArrowBack` is set by bottom tabs. `NavigationContainer` attaches itself automatically (`AttachHostBackGesture`, iOS only, detached by identity on dispose) — hosts need no wrapper and no `setNavigator`. `maxApi` is a required parameter of `NavigationContainer` — every container, nested or root, is handed its host bridge explicitly.
48
49
 
49
50
  ## i18n / Localize (port of RN `Localize`)
50
51
 
@@ -1,19 +1,3 @@
1
- //
2
- // NavigatorManager.swift
3
- // MoMoUIKits
4
- //
5
- // Host bridge for the native iOS edge-swipe back — the SwiftUI mirror of Compose's
6
- // `ComposeNavigatorManager` (momo-app `vn.momo.compose.uikits.ComposeNavigatorManager`).
7
- //
8
- // The kit does NOT own the swipe gesture. In the host app a kit screen lives inside a
9
- // `UIHostingController` hosted by the mini-app container VC, and that VC owns the
10
- // `UIScreenEdgePanGestureRecognizer`. When the swipe fires the host asks this manager
11
- // whether a kit stack is mounted (`checkCanPop`) and, if so, routes the back into it
12
- // (`pop` → `Navigator.onBackSafe`) instead of dismissing the whole mini-app. Standalone
13
- // (no such host, e.g. the demo app) there is no edge swipe — same as Compose on iOS,
14
- // whose `BackHandler` is a no-op and which relies entirely on the host.
15
- //
16
-
17
1
  import Foundation
18
2
 
19
3
  @available(iOS 16.0, *)
@@ -21,28 +5,17 @@ public final class NavigatorManager {
21
5
  public static let shared = NavigatorManager()
22
6
  private init() {}
23
7
 
24
- /// Stack of mounted navigators; the last one is the visible top (nested mini-apps
25
- /// push more than one). Held strongly, mirroring `ComposeNavigatorManager` — entries
26
- /// are released by `NavigationContainer` on disappear, not by ARC.
27
8
  private var navigators: [Navigator] = []
28
9
 
29
- /// Idempotent: SwiftUI can re-run a view's `onAppear`, and a double push would need a
30
- /// matching double remove to unwind.
31
10
  public func push(_ navigator: Navigator) {
32
11
  guard !navigators.contains(where: { $0 === navigator }) else { return }
33
12
  navigators.append(navigator)
34
13
  }
35
14
 
36
- /// Removes by identity rather than `removeLast` so a spurious disappear of a covered
37
- /// (non-top) container can't drop the wrong navigator.
38
15
  public func remove(_ navigator: Navigator) {
39
16
  navigators.removeAll { $0 === navigator }
40
17
  }
41
18
 
42
- /// True while any kit stack is mounted — tells the host to route the back into the kit
43
- /// instead of dismissing the mini-app. Matches `ComposeNavigatorManager.checkCanPop`:
44
- /// it does not inspect stack depth; `onBackSafe` handles the at-root case itself by
45
- /// asking the host to dismiss (via `composeApi`).
46
19
  public func checkCanPop() -> Bool { !navigators.isEmpty }
47
20
 
48
21
  public func pop() { navigators.last?.onBackSafe() }
@@ -18,6 +18,7 @@ public struct Information: View {
18
18
  private let action: String?
19
19
  private let showIconClose: Bool
20
20
  private let onPressClose: (() -> Void)?
21
+ private let highlightText: [String]
21
22
 
22
23
  public init(
23
24
  title: String? = nil,
@@ -28,7 +29,8 @@ public struct Information: View {
28
29
  showIcon: Bool = true,
29
30
  action: String? = nil,
30
31
  showIconClose: Bool = true,
31
- onPressClose: (() -> Void)? = nil
32
+ onPressClose: (() -> Void)? = nil,
33
+ highlightText: [String] = []
32
34
  ) {
33
35
  self.title = title
34
36
  self.description = description
@@ -39,6 +41,7 @@ public struct Information: View {
39
41
  self.action = action
40
42
  self.showIconClose = showIconClose
41
43
  self.onPressClose = onPressClose
44
+ self.highlightText = highlightText
42
45
  }
43
46
 
44
47
  private var borderColor: Color {
@@ -90,7 +93,7 @@ public struct Information: View {
90
93
  if let title {
91
94
  MomoText(title, typography: .labelDefaultMedium)
92
95
  }
93
- MomoText(description, typography: .descriptionDefaultRegular)
96
+ MomoText(description, typography: .descriptionDefaultRegular, highlightText: highlightText)
94
97
  }
95
98
  .frame(maxWidth: .infinity, alignment: .leading)
96
99
 
@@ -46,6 +46,42 @@ public func formatNumberToMoney(_ digits: String, currency: String = "đ") -> St
46
46
  return String(chars.reversed()) + currency
47
47
  }
48
48
 
49
+ private func isMoneyDigit(_ char: Character) -> Bool { char.isASCII && char.isNumber }
50
+
51
+ /// Applies an edit of `display[start..<end]` → `inserted` to the digits of `display`.
52
+ /// Separators and currency are never deleted: removing a separator deletes the
53
+ /// digit before it instead, removing only the currency leaves the digits untouched. Returns the new digits and the caret as a digit index.
54
+ private func applyMoneyEdit(_ display: String, start: Int, end: Int, inserted: String) -> (digits: String, caretDigit: Int) {
55
+ let chars = Array(display)
56
+ let start = min(start, chars.count)
57
+ let end = min(max(end, start), chars.count)
58
+ let digits = chars.filter(isMoneyDigit)
59
+ var left = chars[..<start].filter(isMoneyDigit).count
60
+ var removed = chars[start..<end].filter(isMoneyDigit).count
61
+ let insertedDigits = inserted.filter(isMoneyDigit)
62
+ if removed == 0 && insertedDigits.isEmpty && left > 0 && chars[start..<end].contains(".") {
63
+ left -= 1
64
+ removed = 1
65
+ }
66
+ if removed == 0 && insertedDigits.isEmpty {
67
+ return (String(digits), left)
68
+ }
69
+ let next = String(digits[..<left]) + insertedDigits + String(digits[(left + removed)...])
70
+ var trimmed = String(next.drop(while: { $0 == "0" }))
71
+ if trimmed.isEmpty { trimmed = String(next.prefix(1)) }
72
+ return (trimmed, max(0, left + insertedDigits.count - (next.count - trimmed.count)))
73
+ }
74
+
75
+ /// Caret offset right after the `digitIndex`-th digit of `display`.
76
+ private func moneyCaret(_ display: String, digitIndex: Int) -> Int {
77
+ var count = 0
78
+ for (index, char) in display.enumerated() where isMoneyDigit(char) {
79
+ count += 1
80
+ if count == digitIndex { return index + 1 }
81
+ }
82
+ return 0
83
+ }
84
+
49
85
  // MARK: - InputMoney
50
86
 
51
87
  public struct InputMoney: View {
@@ -261,8 +297,8 @@ public struct InputMoney: View {
261
297
  // MARK: - MoneyTextField (UIViewRepresentable)
262
298
 
263
299
  /// A UITextField that shows live thousands-separated currency while the bound
264
- /// `digits` string holds only the raw numeric value. Caret is pinned before
265
- /// the trailing currency symbol.
300
+ /// `digits` string holds only the raw numeric value. The caret can move freely
301
+ /// but never past the trailing currency symbol; edits apply at the caret.
266
302
  private struct MoneyTextField: UIViewRepresentable {
267
303
  @Binding var digits: String
268
304
  var keyboardType: UIKeyboardType
@@ -286,11 +322,6 @@ private struct MoneyTextField: UIViewRepresentable {
286
322
  field.setContentHuggingPriority(.defaultLow, for: .horizontal)
287
323
  field.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
288
324
  field.text = displayValue(digits)
289
- field.addTarget(
290
- context.coordinator,
291
- action: #selector(Coordinator.editingChanged(_:)),
292
- for: .editingChanged
293
- )
294
325
  return field
295
326
  }
296
327
 
@@ -302,12 +333,13 @@ private struct MoneyTextField: UIViewRepresentable {
302
333
  field.textColor = textColor
303
334
  field.tintColor = cursorColor
304
335
  let expected = displayValue(digits)
305
- if !field.isFirstResponder && field.text != expected {
336
+ if field.text != expected {
306
337
  field.text = expected
338
+ context.coordinator.setCaret(field, offset: moneyCaret(expected, digitIndex: expected.filter(isMoneyDigit).count))
307
339
  }
308
340
  }
309
341
 
310
- private func displayValue(_ raw: String) -> String {
342
+ fileprivate func displayValue(_ raw: String) -> String {
311
343
  let numeric = raw.filter { $0.isNumber }
312
344
  return numeric.isEmpty ? "" : formatNumberToMoney(numeric)
313
345
  }
@@ -330,21 +362,44 @@ private struct MoneyTextField: UIViewRepresentable {
330
362
  return true
331
363
  }
332
364
 
333
- @objc func editingChanged(_ textField: UITextField) {
334
- // Extract digits from whatever the user typed/deleted.
335
- let numeric = (textField.text ?? "").filter { $0.isNumber }
336
- let formatted = numeric.isEmpty ? "" : formatNumberToMoney(numeric)
337
- if textField.text != formatted {
338
- textField.text = formatted
339
- // Keep caret before the currency suffix ("đ").
340
- if let end = textField.position(from: textField.endOfDocument, offset: -1) {
341
- textField.selectedTextRange = textField.textRange(from: end, to: end)
342
- }
343
- }
365
+ func textField(
366
+ _ textField: UITextField,
367
+ shouldChangeCharactersIn range: NSRange,
368
+ replacementString string: String
369
+ ) -> Bool {
370
+ let (numeric, caretDigit) = applyMoneyEdit(
371
+ textField.text ?? "",
372
+ start: range.location,
373
+ end: range.location + range.length,
374
+ inserted: string
375
+ )
376
+ let formatted = parent.displayValue(numeric)
377
+ textField.text = formatted
378
+ setCaret(textField, offset: moneyCaret(formatted, digitIndex: caretDigit))
344
379
  if parent.digits != numeric {
345
380
  parent.digits = numeric
381
+ parent.onChangeText?(numeric)
382
+ }
383
+ return false
384
+ }
385
+
386
+ // Keeps the caret out of the currency suffix.
387
+ func textFieldDidChangeSelection(_ textField: UITextField) {
388
+ guard let text = textField.text, !text.isEmpty,
389
+ let range = textField.selectedTextRange,
390
+ let limit = textField.position(from: textField.endOfDocument, offset: -1)
391
+ else { return }
392
+ let start = textField.compare(range.start, to: limit) == .orderedDescending ? limit : range.start
393
+ let end = textField.compare(range.end, to: limit) == .orderedDescending ? limit : range.end
394
+ if start != range.start || end != range.end {
395
+ textField.selectedTextRange = textField.textRange(from: start, to: end)
396
+ }
397
+ }
398
+
399
+ func setCaret(_ textField: UITextField, offset: Int) {
400
+ if let position = textField.position(from: textField.beginningOfDocument, offset: offset) {
401
+ textField.selectedTextRange = textField.textRange(from: position, to: position)
346
402
  }
347
- parent.onChangeText?(numeric)
348
403
  }
349
404
  }
350
405
  }
@@ -139,6 +139,7 @@ public struct MomoText: View {
139
139
  private let letterSpacing: CGFloat?
140
140
  private let softWrap: Bool
141
141
  private let accessibilityId: String?
142
+ private var highlightText: [String] = []
142
143
 
143
144
  public init(
144
145
  _ content: String,
@@ -176,13 +177,52 @@ public struct MomoText: View {
176
177
  self.accessibilityId = accessibilityId
177
178
  }
178
179
 
180
+ init(_ content: String, typography: TypographyStyle, highlightText: [String]) {
181
+ self.init(content, typography: typography)
182
+ self.highlightText = highlightText
183
+ }
184
+
185
+ // Whole-word matches of `highlightText` render semibold; the longest keyword wins (RN parity).
186
+ private var baseText: SwiftUI.Text {
187
+ let keywords = highlightText.filter { !$0.isEmpty }.sorted { $0.count > $1.count }
188
+ guard !keywords.isEmpty else { return SwiftUI.Text(content) }
189
+ let highlightFont = momoFont(size: fontScale(typography.fontSize), weight: TypographyStyle.headerXsSemibold.fontWeight, family: theme.font)
190
+ func isWordChar(_ character: Character?) -> Bool {
191
+ guard let character else { return false }
192
+ return character.isLetter || character.isNumber || character == "_"
193
+ }
194
+
195
+ var result = SwiftUI.Text(verbatim: "")
196
+ var plainStart = content.startIndex
197
+ var index = content.startIndex
198
+ while index < content.endIndex {
199
+ let previous = index > content.startIndex ? content[content.index(before: index)] : nil
200
+ let keyword = isWordChar(previous) ? nil : keywords.first { keyword in
201
+ guard content[index...].hasPrefix(keyword) else { return false }
202
+ let end = content.index(index, offsetBy: keyword.count)
203
+ return !isWordChar(end < content.endIndex ? content[end] : nil)
204
+ }
205
+ guard let keyword else {
206
+ index = content.index(after: index)
207
+ continue
208
+ }
209
+ let end = content.index(index, offsetBy: keyword.count)
210
+ result = result
211
+ + SwiftUI.Text(verbatim: String(content[plainStart..<index]))
212
+ + SwiftUI.Text(verbatim: String(content[index..<end])).font(highlightFont)
213
+ plainStart = end
214
+ index = end
215
+ }
216
+ return result + SwiftUI.Text(verbatim: String(content[plainStart...]))
217
+ }
218
+
179
219
  public var body: some View {
180
220
  let textColor = color ?? theme.colors.text.default
181
221
  // Strikethrough is driven either by the typography variant (mirrors Compose
182
222
  // *Strikethrough styles) or the explicit `strikethrough` flag.
183
223
  let isStrikethrough = strikethrough || typography.isStrikethrough
184
224
 
185
- var text = SwiftUI.Text(content)
225
+ var text = baseText
186
226
  .font(momoFont(size: fontScale(typography.fontSize), weight: typography.fontWeight, family: theme.font))
187
227
  .foregroundColor(textColor)
188
228
  .strikethrough(isStrikethrough, color: textColor)
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.165.1-beta.11'
3
+ s.version = '0.165.2-beta.2'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.165.1-beta.11'
3
+ s.version = '0.165.2-beta.2'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -44,6 +44,10 @@ private struct InformationPreview: View {
44
44
  Information(title: "Payment failed", description: "We couldn't process your payment.",
45
45
  state: .error, onPressAction: {}, action: "Retry")
46
46
  }
47
+ BasicColumnBox("Highlight text", alignment: .leading) {
48
+ Information(description: "Bạn được hoàn 50.000đ, áp dụng đến hết 31/12/2026",
49
+ highlightText: ["50.000đ", "31/12/2026"])
50
+ }
47
51
  BasicColumnBox("Without icon", alignment: .leading) {
48
52
  Information(title: "No icon", description: "showIcon is set to false.", showIcon: false)
49
53
  }
@@ -60,6 +64,7 @@ private struct InformationPlayground: View {
60
64
  @State private var showIcon = true
61
65
  @State private var showIconClose = false
62
66
  @State private var action = ""
67
+ @State private var highlightText = "description"
63
68
 
64
69
  var body: some View {
65
70
  PlaygroundTab(
@@ -72,12 +77,15 @@ private struct InformationPlayground: View {
72
77
  showIcon: showIcon,
73
78
  action: action.isEmpty ? nil : action,
74
79
  showIconClose: showIconClose,
75
- onPressClose: {}
80
+ onPressClose: {},
81
+ highlightText: highlightText.components(separatedBy: ",")
82
+ .map { $0.trimmingCharacters(in: .whitespaces) }
76
83
  )
77
84
  },
78
85
  params: [
79
86
  .string("Title", $title),
80
87
  .string("Description", $description),
88
+ .string("HighlightText: [String] (comma-separated)", $highlightText),
81
89
  .radio("State", informationStateList, $state),
82
90
  .checkbox("ShowIcon", $showIcon),
83
91
  .checkbox("ShowIconClose", $showIconClose),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.165.1-beta.11",
3
+ "version": "0.165.2-beta.2",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},
package/publish.sh CHANGED
@@ -372,10 +372,34 @@ phase_publish_npm() {
372
372
  # FIRST PUBLISH: DEBUG VERSION (with compose kits included)
373
373
  # ============================================================
374
374
  echo ""
375
+ # A bad token surfaces as a 404 on the PUT, after the working tree was already rewritten
376
+ # below — so verify auth first, before anything is touched.
377
+ if ! npm whoami --registry https://registry.npmjs.org >/dev/null 2>&1; then
378
+ echo "❌ Error: npm auth failed (npm whoami). Renew the token in .npmrc / ~/.npmrc and retry."
379
+ exit 1
380
+ fi
381
+
375
382
  echo "🔧 Preparing debug version with compose kits..."
376
383
 
377
384
  # Create debug version
378
385
  DEBUG_VERSION="${VERSION}-debug"
386
+
387
+ # set -e aborts mid-phase on any failure; put the tree back no matter where it stopped.
388
+ # Idempotent: the happy path already moved the backups away and reset the version.
389
+ restore_npm_workspace() {
390
+ [ -f .npmignore.backup ] && mv .npmignore.backup .npmignore
391
+ [ -f compose/build.gradle.kts.backup ] && mv compose/build.gradle.kts.backup compose/build.gradle.kts
392
+ local pkg_version
393
+ pkg_version=$(node -p "require('./package.json').version")
394
+ if [ "$pkg_version" != "$VERSION" ]; then
395
+ if [[ "$OSTYPE" == "darwin"* ]]; then
396
+ sed -i '' "s/\"version\": \"$pkg_version\"/\"version\": \"$VERSION\"/" package.json
397
+ else
398
+ sed -i "s/\"version\": \"$pkg_version\"/\"version\": \"$VERSION\"/" package.json
399
+ fi
400
+ fi
401
+ }
402
+ trap restore_npm_workspace EXIT
379
403
  echo "📦 Debug version: $DEBUG_VERSION"
380
404
 
381
405
  # Get current version from package.json (in case it's different from $VERSION)
@@ -482,6 +506,7 @@ EOF
482
506
  npm publish --tag $NPM_TAG --access=public
483
507
 
484
508
  echo "✅ Normal version published successfully!"
509
+ trap - EXIT
485
510
 
486
511
  echo ""
487
512
  echo "✅ PHASE 3 COMPLETED"
package/build.gradle.kts DELETED
@@ -1,11 +0,0 @@
1
- plugins {
2
- // this is necessary to avoid the plugins to be loaded multiple times
3
- // in each subproject's classloader
4
- alias(libs.plugins.android.application) apply false
5
- alias(libs.plugins.android.library) apply false
6
- alias(libs.plugins.compose) apply false
7
- alias(libs.plugins.kotlin.compose.compiler) apply false
8
- alias(libs.plugins.jetbrains.kotlin.multiplatform) apply false
9
- alias(libs.plugins.jetbrains.kotlin.serialization) apply false
10
- alias(libs.plugins.vanniktech.mavenPublish) apply false
11
- }
@@ -1,190 +0,0 @@
1
- // import com.vanniktech.maven.publish.JavadocJar
2
- // import com.vanniktech.maven.publish.KotlinMultiplatform
3
- import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4
-
5
- plugins {
6
- alias(libs.plugins.jetbrains.kotlin.multiplatform)
7
- alias(libs.plugins.android.library)
8
- alias(libs.plugins.compose)
9
- alias(libs.plugins.kotlin.compose.compiler)
10
- // alias(libs.plugins.vanniktech.mavenPublish)
11
- id(libs.plugins.jetbrains.kotlin.cocoapods.get().pluginId)
12
- kotlin("plugin.serialization")
13
- }
14
-
15
- val gitlabName: String = findProperty("name") as String? ?: ""
16
- val gitlabRepo: String = findProperty("repo") as String? ?: ""
17
- val gitlabUrl: String = findProperty("url") as String? ?: ""
18
- val gitlabGroup: String = findProperty("group") as String? ?: ""
19
- val gitlabArtifactId: String = findProperty("artifact.id") as String? ?: ""
20
- val gitlabVersion: String = findProperty("version") as String? ?: ""
21
- val gitlabUser: String = findProperty("gitlab.user") as String? ?: ""
22
- val gitlabKey: String = findProperty("gitlab.password") as String? ?: ""
23
-
24
- kotlin {
25
- androidTarget {
26
- compilerOptions {
27
- jvmTarget.set(JvmTarget.JVM_17)
28
- }
29
- publishLibraryVariants("release")
30
- }
31
-
32
- val fwName = gitlabArtifactId
33
- val iosTargets = listOf(iosArm64(), iosSimulatorArm64())
34
- iosTargets.forEach {
35
- it.binaries.framework {
36
- baseName = fwName
37
- binaryOption("bundleId", "$gitlabGroup.$fwName")
38
- isStatic = true
39
- }
40
- }
41
-
42
- cocoapods {
43
- version = "0.165.1-beta.11-debug"
44
- summary = "IOS Shared module"
45
- homepage = "https://momo.vn"
46
- ios.deploymentTarget = "15.0"
47
-
48
- framework {
49
- baseName = fwName
50
- isStatic = true
51
- }
52
-
53
- pod("lottie-ios") {
54
- moduleName = "Lottie"
55
- version = "4.4.3"
56
- extraOpts += listOf("-compiler-option", "-fmodules")
57
- }
58
- }
59
-
60
- sourceSets {
61
- all {
62
- languageSettings.optIn("vn.momo.kits.modifier.InternalApi")
63
- }
64
- commonMain.dependencies {
65
- implementation(compose.runtime)
66
- implementation(compose.material)
67
- implementation(compose.material3)
68
- implementation(compose.components.resources)
69
- implementation(libs.compose.ui.backhandler)
70
- implementation(libs.ktor.client.core)
71
- implementation(libs.jetbrains.coroutines.core)
72
- implementation(libs.navigation.multiplatform)
73
- implementation(libs.coil.multiplatform.compose)
74
- implementation(libs.coil.multiplatform.core)
75
- implementation(libs.coil.multiplatform.network.ktor)
76
- implementation(libs.jetbrains.serialization.json)
77
- implementation(libs.kotlinx.datetime)
78
- api(libs.native.max.api)
79
- implementation(libs.compottie)
80
- implementation(libs.gif.image)
81
- }
82
- androidMain.dependencies {
83
- implementation(libs.ktor.client.okhttp)
84
- implementation(libs.airbnb.lottie)
85
- }
86
- iosMain.dependencies {
87
- implementation(libs.ktor.client.darwin)
88
- }
89
- }
90
- }
91
-
92
- android {
93
- namespace = "vn.momo.kits.kits"
94
- compileSdk = 35
95
- compileOptions {
96
- sourceCompatibility = JavaVersion.VERSION_17
97
- targetCompatibility = JavaVersion.VERSION_17
98
- }
99
- defaultConfig {
100
- minSdk = 24
101
- }
102
- }
103
-
104
- dependencies {
105
- }
106
-
107
- repositories {
108
- google {
109
- mavenContent {
110
- includeGroupAndSubgroups("androidx")
111
- includeGroupAndSubgroups("com.android")
112
- includeGroupAndSubgroups("com.google")
113
- }
114
- }
115
- mavenCentral()
116
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
117
- maven {
118
- url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
119
- credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
120
- }
121
- maven {
122
- url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
123
- credentials {
124
- username = "viewer"
125
- password = "viewer"
126
- }
127
- isAllowInsecureProtocol = true
128
- }
129
- }
130
-
131
- compose {
132
- resources {
133
- publicResClass = true
134
- packageOfResClass = "vn.momo.uikits.resources"
135
- generateResClass = always
136
- }
137
- }
138
-
139
- // publishing {
140
- // repositories {
141
- // maven {
142
- // name = "${gitlabRepo}Packages"
143
- // credentials {
144
- // username = gitlabUser
145
- // password = gitlabKey
146
- // }
147
- // url = uri("$gitlabUrl")
148
- // }
149
- // }
150
- // }
151
-
152
- // mavenPublishing {
153
- // configure(
154
- // KotlinMultiplatform(
155
- // javadocJar = JavadocJar.Empty(),
156
- // sourcesJar = true,
157
- // androidVariantsToPublish = listOf("release")
158
- // )
159
- // )
160
- //
161
- // repositories {
162
- // maven {
163
- // name = "${gitlabRepo}Packages"
164
- // credentials { username = gitlabUser; password = gitlabKey }
165
- // url = uri("$gitlabUrl")
166
- // }
167
- // }
168
- //
169
- // coordinates(gitlabGroup.toString(), gitlabArtifactId, gitlabVersion.toString())
170
- //
171
- // pom {
172
- // name = "$gitlabName Klib"
173
- // description = "$gitlabName"
174
- // url = "https://gitlab.mservice.com.vn"
175
- // licenses {
176
- // license {
177
- // name = "The Apache License, Version 2.0"
178
- // url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
179
- // distribution = "https://www.apache.org/licenses/LICENSE-2.0.txt"
180
- // }
181
- // }
182
- // developers {
183
- // developer {
184
- // id = "kotlin-hands-on"
185
- // name = "Kotlin Developer Advocate"
186
- // url = "https://github.com/kotlin-hands-on/"
187
- // }
188
- // }
189
- // }
190
- // }