@bloxwap/hig 0.0.0-stage → 0.5.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 (220) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +44 -2
  3. package/chart/README.md +23 -0
  4. package/chart/dist/index.d.ts +8 -0
  5. package/chart/dist/index.js +12 -0
  6. package/contracts/README.md +3 -0
  7. package/contracts/dist/announcements.d.ts +12 -0
  8. package/contracts/dist/announcements.js +8 -0
  9. package/contracts/dist/feedback.d.ts +40 -0
  10. package/contracts/dist/feedback.js +1 -0
  11. package/contracts/dist/index.d.ts +41 -0
  12. package/contracts/dist/index.js +52 -0
  13. package/contracts/dist/messages.d.ts +300 -0
  14. package/contracts/dist/messages.js +114 -0
  15. package/css.d.ts +2 -0
  16. package/feedback/README.md +7 -0
  17. package/feedback/assets/error.wav +0 -0
  18. package/feedback/assets/manifest.json +78 -0
  19. package/feedback/assets/success.wav +0 -0
  20. package/feedback/assets/tick.wav +0 -0
  21. package/feedback/assets/toggle.wav +0 -0
  22. package/feedback/dist/browser-haptic.d.ts +23 -0
  23. package/feedback/dist/browser-haptic.js +41 -0
  24. package/feedback/dist/contract.d.ts +40 -0
  25. package/feedback/dist/contract.js +59 -0
  26. package/feedback/dist/native.d.ts +28 -0
  27. package/feedback/dist/native.js +63 -0
  28. package/feedback/dist/preferences.d.ts +8 -0
  29. package/feedback/dist/preferences.js +24 -0
  30. package/feedback/dist/presets.d.ts +57 -0
  31. package/feedback/dist/presets.js +1 -0
  32. package/feedback/dist/react.d.ts +19 -0
  33. package/feedback/dist/react.js +23 -0
  34. package/feedback/dist/web-haptic.d.ts +6 -0
  35. package/feedback/dist/web-haptic.js +6 -0
  36. package/feedback/dist/web-sound.d.ts +5 -0
  37. package/feedback/dist/web-sound.js +32 -0
  38. package/feedback/dist/web.d.ts +3 -0
  39. package/feedback/dist/web.js +4 -0
  40. package/native/README.md +16 -0
  41. package/native/android/build.gradle +28 -0
  42. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
  43. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
  44. package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
  45. package/native/dist/animated-number-model.d.ts +24 -0
  46. package/native/dist/animated-number-model.js +110 -0
  47. package/native/dist/animated-number.d.ts +9 -0
  48. package/native/dist/animated-number.js +97 -0
  49. package/native/dist/brand.d.ts +7 -0
  50. package/native/dist/brand.js +7 -0
  51. package/native/dist/button.d.ts +30 -0
  52. package/native/dist/button.js +36 -0
  53. package/native/dist/checkbox.d.ts +3 -0
  54. package/native/dist/checkbox.js +11 -0
  55. package/native/dist/data.d.ts +57 -0
  56. package/native/dist/data.js +47 -0
  57. package/native/dist/field.d.ts +16 -0
  58. package/native/dist/field.js +26 -0
  59. package/native/dist/gesture-sheet.d.ts +73 -0
  60. package/native/dist/gesture-sheet.js +153 -0
  61. package/native/dist/icons.d.ts +21 -0
  62. package/native/dist/icons.js +20 -0
  63. package/native/dist/navigation.d.ts +48 -0
  64. package/native/dist/navigation.js +58 -0
  65. package/native/dist/overlay.d.ts +36 -0
  66. package/native/dist/overlay.js +65 -0
  67. package/native/dist/pickers.d.ts +54 -0
  68. package/native/dist/pickers.js +60 -0
  69. package/native/dist/provider.d.ts +62 -0
  70. package/native/dist/provider.js +67 -0
  71. package/native/dist/radio-group.d.ts +21 -0
  72. package/native/dist/radio-group.js +91 -0
  73. package/native/dist/recipes.d.ts +45 -0
  74. package/native/dist/recipes.js +32 -0
  75. package/native/dist/roles.d.ts +6 -0
  76. package/native/dist/roles.js +4 -0
  77. package/native/dist/select.d.ts +3 -0
  78. package/native/dist/select.js +9 -0
  79. package/native/dist/selection-types.d.ts +22 -0
  80. package/native/dist/selection-types.js +1 -0
  81. package/native/dist/selection.d.ts +8 -0
  82. package/native/dist/selection.js +7 -0
  83. package/native/dist/slider.d.ts +11 -0
  84. package/native/dist/slider.js +42 -0
  85. package/native/dist/status.d.ts +86 -0
  86. package/native/dist/status.js +112 -0
  87. package/native/dist/surface.d.ts +19 -0
  88. package/native/dist/surface.js +42 -0
  89. package/native/dist/swap-panel.d.ts +125 -0
  90. package/native/dist/swap-panel.js +177 -0
  91. package/native/dist/swap-parts.d.ts +86 -0
  92. package/native/dist/swap-parts.js +66 -0
  93. package/native/dist/swap-shared.d.ts +65 -0
  94. package/native/dist/swap-shared.js +76 -0
  95. package/native/dist/swap-sheet.d.ts +14 -0
  96. package/native/dist/swap-sheet.js +26 -0
  97. package/native/dist/swap-views.d.ts +41 -0
  98. package/native/dist/swap-views.js +37 -0
  99. package/native/dist/switch-row.d.ts +8 -0
  100. package/native/dist/switch-row.js +18 -0
  101. package/native/dist/switch.d.ts +10 -0
  102. package/native/dist/switch.js +30 -0
  103. package/native/dist/text-content.d.ts +5 -0
  104. package/native/dist/text-content.js +6 -0
  105. package/native/dist/wallet-address.d.ts +37 -0
  106. package/native/dist/wallet-address.js +50 -0
  107. package/native-fonts/README.md +17 -0
  108. package/native-fonts/dist/index.d.ts +164 -0
  109. package/native-fonts/dist/index.js +164 -0
  110. package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
  111. package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
  112. package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  113. package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
  114. package/native-fonts/fonts/BloxwapMono.ttf +0 -0
  115. package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  116. package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  117. package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
  118. package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  119. package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
  120. package/native-fonts/fonts/BloxwapSans.ttf +0 -0
  121. package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
  122. package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
  123. package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
  124. package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
  125. package/native-fonts/fonts/OFL.txt +93 -0
  126. package/native-fonts/fonts/manifest.json +164 -0
  127. package/og-fonts/README.md +34 -0
  128. package/og-fonts/dist/index.d.ts +116 -0
  129. package/og-fonts/dist/index.js +102 -0
  130. package/og-fonts/dist/node.d.ts +11 -0
  131. package/og-fonts/dist/node.js +39 -0
  132. package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  133. package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  134. package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  135. package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  136. package/og-fonts/fonts/BloxwapSans.ttf +0 -0
  137. package/og-fonts/fonts/OFL.txt +93 -0
  138. package/og-fonts/fonts/manifest.json +65 -0
  139. package/package.json +476 -4
  140. package/react/README.md +30 -0
  141. package/react/dist/animated-number-model.d.ts +20 -0
  142. package/react/dist/animated-number-model.js +92 -0
  143. package/react/dist/animated-number.d.ts +8 -0
  144. package/react/dist/animated-number.js +72 -0
  145. package/react/dist/base.css +9 -0
  146. package/react/dist/brand.d.ts +7 -0
  147. package/react/dist/brand.js +5 -0
  148. package/react/dist/button.d.ts +14 -0
  149. package/react/dist/button.js +20 -0
  150. package/react/dist/data.d.ts +78 -0
  151. package/react/dist/data.js +36 -0
  152. package/react/dist/dialog.d.ts +29 -0
  153. package/react/dist/dialog.js +21 -0
  154. package/react/dist/field.d.ts +16 -0
  155. package/react/dist/field.js +20 -0
  156. package/react/dist/gesture-sheet.d.ts +41 -0
  157. package/react/dist/gesture-sheet.js +128 -0
  158. package/react/dist/navigation.d.ts +48 -0
  159. package/react/dist/navigation.js +69 -0
  160. package/react/dist/notify.d.ts +14 -0
  161. package/react/dist/notify.js +6 -0
  162. package/react/dist/overlay.d.ts +17 -0
  163. package/react/dist/overlay.js +18 -0
  164. package/react/dist/provider.d.ts +25 -0
  165. package/react/dist/provider.js +50 -0
  166. package/react/dist/recipes/activity-list.d.ts +8 -0
  167. package/react/dist/recipes/activity-list.js +6 -0
  168. package/react/dist/recipes/balance-card.d.ts +6 -0
  169. package/react/dist/recipes/balance-card.js +5 -0
  170. package/react/dist/recipes/code-window.d.ts +4 -0
  171. package/react/dist/recipes/code-window.js +4 -0
  172. package/react/dist/recipes/install-command.d.ts +6 -0
  173. package/react/dist/recipes/install-command.js +15 -0
  174. package/react/dist/recipes/market-row.d.ts +25 -0
  175. package/react/dist/recipes/market-row.js +8 -0
  176. package/react/dist/recipes/marketing-hero.d.ts +7 -0
  177. package/react/dist/recipes/marketing-hero.js +5 -0
  178. package/react/dist/recipes/pickers.d.ts +57 -0
  179. package/react/dist/recipes/pickers.js +78 -0
  180. package/react/dist/recipes/swap/amount-card.d.ts +40 -0
  181. package/react/dist/recipes/swap/amount-card.js +7 -0
  182. package/react/dist/recipes/swap/picker.d.ts +26 -0
  183. package/react/dist/recipes/swap/picker.js +20 -0
  184. package/react/dist/recipes/swap/settings.d.ts +24 -0
  185. package/react/dist/recipes/swap/settings.js +25 -0
  186. package/react/dist/recipes/swap/shared.d.ts +98 -0
  187. package/react/dist/recipes/swap/shared.js +106 -0
  188. package/react/dist/recipes/swap-panel.d.ts +127 -0
  189. package/react/dist/recipes/swap-panel.js +170 -0
  190. package/react/dist/recipes/swap-sheet.d.ts +16 -0
  191. package/react/dist/recipes/swap-sheet.js +22 -0
  192. package/react/dist/recipes/trade-entry.d.ts +11 -0
  193. package/react/dist/recipes/trade-entry.js +12 -0
  194. package/react/dist/recipes.d.ts +10 -0
  195. package/react/dist/recipes.js +11 -0
  196. package/react/dist/select.d.ts +4 -0
  197. package/react/dist/select.js +174 -0
  198. package/react/dist/selection.d.ts +40 -0
  199. package/react/dist/selection.js +23 -0
  200. package/react/dist/slider.d.ts +11 -0
  201. package/react/dist/slider.js +10 -0
  202. package/react/dist/status.d.ts +63 -0
  203. package/react/dist/status.js +47 -0
  204. package/react/dist/styles.css +542 -0
  205. package/react/dist/surface.d.ts +291 -0
  206. package/react/dist/surface.js +9 -0
  207. package/react/dist/toast.d.ts +17 -0
  208. package/react/dist/toast.js +21 -0
  209. package/react/dist/wallet-address.d.ts +23 -0
  210. package/react/dist/wallet-address.js +24 -0
  211. package/tokens/README.md +17 -0
  212. package/tokens/assets/bloxwap-icon.svg +1 -0
  213. package/tokens/dist/brand.d.ts +19 -0
  214. package/tokens/dist/brand.js +24 -0
  215. package/tokens/dist/index.d.ts +437 -0
  216. package/tokens/dist/index.js +514 -0
  217. package/tokens/dist/manifest.json +200 -0
  218. package/tokens/dist/theme.d.ts +11 -0
  219. package/tokens/dist/theme.js +22 -0
  220. package/tokens/dist/tokens.css +120 -0
@@ -0,0 +1,32 @@
1
+ import { presets } from './contract.js';
2
+ let shared;
3
+ let users = 0;
4
+ /** No import/AudioContext until an enabled semantic request follows a trusted gesture. */
5
+ export function createWebSoundAdapter(load = () => import('@bloxwap/sfx')) {
6
+ let dead = false, generation = 0, used = false;
7
+ let scope;
8
+ const defaultEngine = arguments.length === 0;
9
+ const cancel = () => { generation++; scope?.abort(); scope = undefined; };
10
+ return { capability: { available: typeof window !== 'undefined', mechanism: 'web-audio', observed: false, reason: 'Shared engine with per-root abort where supported; API readiness is not observed playback' },
11
+ async play(event, prefs) { if (dead || !prefs.sound || prefs.volume <= 0)
12
+ return; const recipe = presets[event.intent].sound; if (!recipe)
13
+ return; const epoch = ++generation; const signal = (scope ??= new AbortController()).signal; if (!used) {
14
+ used = true;
15
+ if (defaultEngine)
16
+ users++;
17
+ } const engine = await (defaultEngine ? (shared ??= load()) : load()); if (dead || epoch !== generation)
18
+ return; if (await engine.unlock()) {
19
+ if (!dead && epoch === generation) {
20
+ const options = { volume: prefs.volume, minInterval: presets[event.intent].cooldown, signal };
21
+ engine.play(recipe, options);
22
+ }
23
+ } },
24
+ cancel,
25
+ dispose() { if (dead)
26
+ return; dead = true; cancel(); if (used && defaultEngine && --users === 0) {
27
+ const last = shared;
28
+ shared = undefined;
29
+ void last?.then(engine => { if (users === 0)
30
+ engine.dispose(); }).catch(() => { });
31
+ } } };
32
+ }
@@ -0,0 +1,3 @@
1
+ export { createWebSoundAdapter } from './web-sound.js';
2
+ export { createBrowserHapticAdapter, type BrowserVibrationBackend, type ImperativeHapticBackend } from './browser-haptic.js';
3
+ export { HapticFeedbackTarget } from './web-haptic.js';
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ export { createWebSoundAdapter } from './web-sound.js';
3
+ export { createBrowserHapticAdapter } from './browser-haptic.js';
4
+ export { HapticFeedbackTarget } from './web-haptic.js';
@@ -0,0 +1,16 @@
1
+ # @bloxwap/hig/native
2
+
3
+ Version 0.5.1, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
4
+
5
+ Set a brand accent with `<HIGProvider primaryColor='#ff0000'>` from
6
+ `@bloxwap/hig/native/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
7
+ sets action/focus colours, and selects black or white text on primary fills.
8
+ Omit it to keep Bloxwap green. Nested providers inherit the accent, and `useColors()`
9
+ returns the resolved roles. With `colorSpace='display-p3'` on iOS, HIG converts
10
+ the sRGB input to P3 channels. Status, buy/sell colours, and the Bloxwap mark retain
11
+ their defaults. See [the colour guide](../../../docs/foundations/platform.md#primary-brand-colour).
12
+
13
+ Market direction has its own roles. `useColors().up` and `.down` default to `buy` and
14
+ `sell`. `<HIGProvider marketColors={{up,down}}>` overrides either one for hosts whose
15
+ convention differs, and readouts paint them with `tone="up"` / `tone="down"`. See
16
+ [market direction colours](../../../docs/foundations/platform.md#market-direction-colours).
@@ -0,0 +1,28 @@
1
+ // Android support for @bloxwap/hig/native: the Slider's set-progress accessibility action (#71).
2
+ // Autolinked by React Native / Expo; the host app's React Native Gradle plugin supplies react-android.
3
+ apply plugin: 'com.android.library'
4
+
5
+ def safeExtGet(prop, fallback) {
6
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
7
+ }
8
+
9
+ android {
10
+ namespace 'com.bloxwap.hig'
11
+ compileSdkVersion safeExtGet('compileSdkVersion', 35)
12
+ defaultConfig {
13
+ minSdkVersion safeExtGet('minSdkVersion', 24)
14
+ }
15
+ compileOptions {
16
+ sourceCompatibility JavaVersion.VERSION_17
17
+ targetCompatibility JavaVersion.VERSION_17
18
+ }
19
+ }
20
+
21
+ repositories {
22
+ google()
23
+ mavenCentral()
24
+ }
25
+
26
+ dependencies {
27
+ implementation 'com.facebook.react:react-android'
28
+ }
@@ -0,0 +1,173 @@
1
+ package com.bloxwap.hig;
2
+
3
+ import android.content.Context;
4
+ import android.os.Bundle;
5
+ import android.view.View;
6
+ import android.view.ViewGroup;
7
+ import android.view.accessibility.AccessibilityEvent;
8
+ import android.view.accessibility.AccessibilityNodeInfo;
9
+ import android.view.accessibility.AccessibilityNodeProvider;
10
+ import androidx.annotation.NonNull;
11
+ import androidx.annotation.Nullable;
12
+ import com.facebook.react.bridge.Arguments;
13
+ import com.facebook.react.bridge.ReactContext;
14
+ import com.facebook.react.bridge.WritableMap;
15
+ import com.facebook.react.uimanager.UIManagerHelper;
16
+ import com.facebook.react.uimanager.events.Event;
17
+ import com.facebook.react.uimanager.events.EventDispatcher;
18
+ import com.facebook.react.views.view.ReactViewGroup;
19
+
20
+ /**
21
+ * React Native maps accessibilityActions names to fixed or synthetic action ids and drops action
22
+ * arguments, so an adjustable View cannot offer AccessibilityNodeInfo.ACTION_SET_PROGRESS (Voice
23
+ * Access, Switch Access). This view wraps whichever delegate React Native installs and adds
24
+ * set-progress while the node is enabled and carries range info (accessibilityValue min/max/now).
25
+ * The requested value reaches JS as onAccessibilityAction({actionName: 'setProgress', value}).
26
+ */
27
+ public class HIGAdjustableView extends ReactViewGroup {
28
+ public static final String SET_PROGRESS = "setProgress";
29
+
30
+ public HIGAdjustableView(Context context) {
31
+ super(context);
32
+ }
33
+
34
+ @Override
35
+ public void setAccessibilityDelegate(@Nullable View.AccessibilityDelegate delegate) {
36
+ // Only wrap a delegate React Native installed: an always-present delegate would stop
37
+ // ReactAccessibilityDelegate.setDelegate from attaching role/state/value semantics.
38
+ super.setAccessibilityDelegate(
39
+ delegate == null || delegate instanceof SetProgressDelegate
40
+ ? delegate
41
+ : new SetProgressDelegate(delegate));
42
+ }
43
+
44
+ static boolean acceptsSetProgress(@NonNull AccessibilityNodeInfo info) {
45
+ return info.isEnabled() && info.getRangeInfo() != null;
46
+ }
47
+
48
+ private void dispatchSetProgress(float value) {
49
+ Context context = getContext();
50
+ if (!(context instanceof ReactContext)) return;
51
+ int tag = getId();
52
+ EventDispatcher dispatcher =
53
+ UIManagerHelper.getEventDispatcherForReactTag((ReactContext) context, tag);
54
+ if (dispatcher == null) return;
55
+ dispatcher.dispatchEvent(new SetProgressEvent(UIManagerHelper.getSurfaceId(this), tag, value));
56
+ }
57
+
58
+ private final class SetProgressDelegate extends View.AccessibilityDelegate {
59
+ private final View.AccessibilityDelegate inner;
60
+
61
+ SetProgressDelegate(View.AccessibilityDelegate inner) {
62
+ this.inner = inner;
63
+ }
64
+
65
+ @Override
66
+ public void onInitializeAccessibilityNodeInfo(
67
+ @NonNull View host, @NonNull AccessibilityNodeInfo info) {
68
+ inner.onInitializeAccessibilityNodeInfo(host, info);
69
+ if (acceptsSetProgress(info)) {
70
+ info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS);
71
+ }
72
+ }
73
+
74
+ @Override
75
+ public boolean performAccessibilityAction(
76
+ @NonNull View host, int action, @Nullable Bundle args) {
77
+ if (action != android.R.id.accessibilityActionSetProgress) {
78
+ return inner.performAccessibilityAction(host, action, args);
79
+ }
80
+ // Re-read the current semantics: disabled sliders and sliders without a range reject it.
81
+ AccessibilityNodeInfo info = host.createAccessibilityNodeInfo();
82
+ boolean accepted = acceptsSetProgress(info);
83
+ if (android.os.Build.VERSION.SDK_INT < 33) info.recycle();
84
+ if (!accepted || args == null
85
+ || !args.containsKey(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)) {
86
+ return false;
87
+ }
88
+ float value = args.getFloat(AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE);
89
+ if (Float.isNaN(value) || Float.isInfinite(value)) return false;
90
+ dispatchSetProgress(value);
91
+ return true;
92
+ }
93
+
94
+ @Override
95
+ public void sendAccessibilityEvent(@NonNull View host, int eventType) {
96
+ inner.sendAccessibilityEvent(host, eventType);
97
+ }
98
+
99
+ @Override
100
+ public void sendAccessibilityEventUnchecked(
101
+ @NonNull View host, @NonNull AccessibilityEvent event) {
102
+ inner.sendAccessibilityEventUnchecked(host, event);
103
+ }
104
+
105
+ @Override
106
+ public boolean dispatchPopulateAccessibilityEvent(
107
+ @NonNull View host, @NonNull AccessibilityEvent event) {
108
+ return inner.dispatchPopulateAccessibilityEvent(host, event);
109
+ }
110
+
111
+ @Override
112
+ public void onPopulateAccessibilityEvent(
113
+ @NonNull View host, @NonNull AccessibilityEvent event) {
114
+ inner.onPopulateAccessibilityEvent(host, event);
115
+ }
116
+
117
+ @Override
118
+ public void onInitializeAccessibilityEvent(
119
+ @NonNull View host, @NonNull AccessibilityEvent event) {
120
+ inner.onInitializeAccessibilityEvent(host, event);
121
+ }
122
+
123
+ @Override
124
+ public boolean onRequestSendAccessibilityEvent(
125
+ @NonNull ViewGroup host, @NonNull View child, @NonNull AccessibilityEvent event) {
126
+ return inner.onRequestSendAccessibilityEvent(host, child, event);
127
+ }
128
+
129
+ @Nullable
130
+ @Override
131
+ public AccessibilityNodeProvider getAccessibilityNodeProvider(@NonNull View host) {
132
+ return inner.getAccessibilityNodeProvider(host);
133
+ }
134
+
135
+ @Override
136
+ public void addExtraDataToAccessibilityNodeInfo(
137
+ @NonNull View host,
138
+ @NonNull AccessibilityNodeInfo info,
139
+ @NonNull String extraDataKey,
140
+ @Nullable Bundle arguments) {
141
+ inner.addExtraDataToAccessibilityNodeInfo(host, info, extraDataKey, arguments);
142
+ }
143
+ }
144
+
145
+ private static final class SetProgressEvent extends Event<SetProgressEvent> {
146
+ private final float value;
147
+
148
+ SetProgressEvent(int surfaceId, int viewTag, float value) {
149
+ super(surfaceId, viewTag);
150
+ this.value = value;
151
+ }
152
+
153
+ @NonNull
154
+ @Override
155
+ public String getEventName() {
156
+ return "topAccessibilityAction";
157
+ }
158
+
159
+ @Override
160
+ public boolean canCoalesce() {
161
+ return false;
162
+ }
163
+
164
+ @Nullable
165
+ @Override
166
+ protected WritableMap getEventData() {
167
+ WritableMap data = Arguments.createMap();
168
+ data.putString("actionName", SET_PROGRESS);
169
+ data.putDouble("value", value);
170
+ return data;
171
+ }
172
+ }
173
+ }
@@ -0,0 +1,23 @@
1
+ package com.bloxwap.hig;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.facebook.react.uimanager.ThemedReactContext;
5
+ import com.facebook.react.views.view.ReactViewGroup;
6
+ import com.facebook.react.views.view.ReactViewManager;
7
+
8
+ /** A React Native View whose adjustable semantics also expose Android set-progress. */
9
+ public class HIGAdjustableViewManager extends ReactViewManager {
10
+ public static final String NAME = "HIGAdjustableView";
11
+
12
+ @NonNull
13
+ @Override
14
+ public String getName() {
15
+ return NAME;
16
+ }
17
+
18
+ @NonNull
19
+ @Override
20
+ public ReactViewGroup createViewInstance(@NonNull ThemedReactContext context) {
21
+ return new HIGAdjustableView(context);
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ package com.bloxwap.hig;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.facebook.react.ReactPackage;
5
+ import com.facebook.react.bridge.NativeModule;
6
+ import com.facebook.react.bridge.ReactApplicationContext;
7
+ import com.facebook.react.uimanager.ViewManager;
8
+ import java.util.Collections;
9
+ import java.util.List;
10
+
11
+ /** Registers the HIG native views. Autolinking discovers this package. */
12
+ public class HIGPackage implements ReactPackage {
13
+ @NonNull
14
+ @Override
15
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext context) {
16
+ return Collections.emptyList();
17
+ }
18
+
19
+ @NonNull
20
+ @Override
21
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext context) {
22
+ return Collections.<ViewManager>singletonList(new HIGAdjustableViewManager());
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ export type NumberTrend = -1 | 0 | 1 | ((previousValue: number, value: number) => -1 | 0 | 1);
2
+ export interface NumberReading {
3
+ known: boolean;
4
+ core: string;
5
+ text: string;
6
+ }
7
+ export interface NumberReelToken {
8
+ key: string;
9
+ kind: 'digit' | 'static';
10
+ type: string;
11
+ value: string;
12
+ partIndex: number;
13
+ digit?: number;
14
+ place?: number;
15
+ }
16
+ export interface NumberReelModel {
17
+ canonical: string;
18
+ digits: readonly string[];
19
+ tokens: readonly NumberReelToken[];
20
+ }
21
+ export declare function formatNumberReadout(value: number | null | undefined, locale: string, options?: Intl.NumberFormatOptions, formattedValue?: string, prefix?: string, suffix?: string): NumberReading;
22
+ export declare function numberTrendDirection(trend: NumberTrend | undefined, previousValue: number | null | undefined, value: number | null | undefined): -1 | 0 | 1;
23
+ export declare function safeNumberLayout(text: string, direction: string): boolean;
24
+ export declare function createNumberReelModel(value: number | null | undefined, locale: string, options: Intl.NumberFormatOptions | undefined, formattedValue: string | undefined, direction: string): NumberReelModel | null;
@@ -0,0 +1,110 @@
1
+ import { formatNumber } from '@bloxwap/hig/contracts';
2
+ const supportedParts = new Set(['integer', 'fraction', 'decimal', 'group', 'plusSign', 'minusSign', 'percentSign', 'currency', 'unit', 'compact', 'literal', 'exponentSeparator', 'exponentInteger', 'exponentMinusSign', 'exponentPlusSign', 'approximatelySign']);
3
+ const bidiControls = /[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/u;
4
+ export function formatNumberReadout(value, locale, options, formattedValue, prefix, suffix) {
5
+ const known = typeof value === 'number' && Number.isFinite(value);
6
+ if (!known)
7
+ return { known: false, core: '—', text: '—' };
8
+ let core;
9
+ if (formattedValue)
10
+ core = formattedValue;
11
+ else {
12
+ try {
13
+ core = formatNumber(value, locale, options);
14
+ }
15
+ catch {
16
+ core = String(value);
17
+ }
18
+ }
19
+ return { known: true, core, text: `${prefix ?? ''}${core}${suffix ?? ''}` };
20
+ }
21
+ export function numberTrendDirection(trend, previousValue, value) {
22
+ if (Object.is(previousValue, value) || typeof previousValue !== 'number' || !Number.isFinite(previousValue) || typeof value !== 'number' || !Number.isFinite(value))
23
+ return 0;
24
+ const resolved = typeof trend === 'function' ? trend(previousValue, value) : trend;
25
+ if (resolved === 1 || resolved === -1)
26
+ return resolved;
27
+ if (resolved === 0)
28
+ return 0;
29
+ return value > previousValue ? 1 : value < previousValue ? -1 : 0;
30
+ }
31
+ function strongRTL(character) {
32
+ const point = character.codePointAt(0);
33
+ if (point === undefined)
34
+ return false;
35
+ if ((point >= 0x0660 && point <= 0x0669) || (point >= 0x06f0 && point <= 0x06f9) || (point >= 0x066a && point <= 0x066c))
36
+ return false;
37
+ return (point >= 0x0590 && point <= 0x08ff) || (point >= 0xfb1d && point <= 0xfdff) || (point >= 0xfe70 && point <= 0xfefc) || (point >= 0x10800 && point <= 0x10fff) || (point >= 0x1e800 && point <= 0x1edff) || (point >= 0x1ee00 && point <= 0x1eeff);
38
+ }
39
+ export function safeNumberLayout(text, direction) {
40
+ if (direction !== 'ltr')
41
+ return false;
42
+ for (const character of Array.from(text))
43
+ if (bidiControls.test(character) || strongRTL(character))
44
+ return false;
45
+ return true;
46
+ }
47
+ export function createNumberReelModel(value, locale, options, formattedValue, direction) {
48
+ if (typeof value !== 'number' || !Number.isFinite(value) || formattedValue || direction !== 'ltr' || typeof Intl === 'undefined' || typeof Intl.NumberFormat !== 'function')
49
+ return null;
50
+ try {
51
+ const formatter = new Intl.NumberFormat(locale, options);
52
+ if (typeof formatter.formatToParts !== 'function')
53
+ return null;
54
+ const canonical = formatter.format(value);
55
+ if (canonical !== formatNumberReadout(value, locale, options).core)
56
+ return null;
57
+ const parts = formatter.formatToParts(value);
58
+ if (!parts.length || parts.map(part => part.value).join('') !== canonical)
59
+ return null;
60
+ const numberingSystem = formatter.resolvedOptions().numberingSystem;
61
+ if (!numberingSystem)
62
+ return null;
63
+ const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false, minimumFractionDigits: 0, maximumFractionDigits: 0 });
64
+ if (typeof digitFormatter.formatToParts !== 'function')
65
+ return null;
66
+ const digits = Array.from({ length: 10 }, (_, digit) => {
67
+ const formatted = digitFormatter.format(digit), parts = digitFormatter.formatToParts(digit);
68
+ return parts.length === 1 && parts[0].type === 'integer' && parts[0].value === formatted && Array.from(formatted).length === 1 ? formatted : '';
69
+ });
70
+ if (digits.some(digit => !digit) || new Set(digits).size !== 10 || !safeNumberLayout(canonical, direction))
71
+ return null;
72
+ const digitIndexes = new Map(digits.map((digit, index) => [digit, index]));
73
+ const count = (type) => parts.filter(part => part.type === type).reduce((total, part) => total + Array.from(part.value).length, 0);
74
+ const integerCount = count('integer'), exponentCount = count('exponentInteger');
75
+ let integerIndex = 0, fractionIndex = 0, exponentIndex = 0;
76
+ const tokens = [];
77
+ for (let partIndex = 0; partIndex < parts.length; partIndex++) {
78
+ const part = parts[partIndex];
79
+ if (!supportedParts.has(part.type))
80
+ return null;
81
+ if (part.type !== 'integer' && part.type !== 'fraction' && part.type !== 'exponentInteger') {
82
+ tokens.push({ key: `part:${partIndex}:${part.type}`, kind: 'static', type: part.type, value: part.value, partIndex });
83
+ continue;
84
+ }
85
+ for (const character of Array.from(part.value)) {
86
+ const digit = digitIndexes.get(character);
87
+ if (digit === undefined)
88
+ return null;
89
+ let key, place;
90
+ if (part.type === 'integer') {
91
+ place = integerCount - integerIndex++ - 1;
92
+ key = `integer:${place}`;
93
+ }
94
+ else if (part.type === 'fraction') {
95
+ place = fractionIndex++;
96
+ key = `fraction:${place}`;
97
+ }
98
+ else {
99
+ place = exponentCount - exponentIndex++ - 1;
100
+ key = `exponentInteger:${place}`;
101
+ }
102
+ tokens.push({ key, kind: 'digit', type: part.type, value: character, partIndex, digit, place });
103
+ }
104
+ }
105
+ return { canonical, digits, tokens };
106
+ }
107
+ catch {
108
+ return null;
109
+ }
110
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { type NumberProps } from './data.js';
3
+ import { type NumberTrend } from './animated-number-model.js';
4
+ export type AnimatedNumberTrend = NumberTrend;
5
+ export interface AnimatedNumberProps extends NumberProps {
6
+ duration?: number;
7
+ trend?: AnimatedNumberTrend;
8
+ }
9
+ export declare function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone, style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration }: AnimatedNumberProps): React.JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { createElement as _createElement } from "react";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { PixelRatio, StyleSheet, View } from 'react-native';
5
+ import Reanimated, { cancelAnimation, Easing, ReduceMotion, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
6
+ import * as en from '@bloxwap/hig/contracts/messages';
7
+ import { tokens } from '@bloxwap/hig/tokens';
8
+ import { createNumberReelModel, formatNumberReadout, numberTrendDirection, safeNumberLayout } from './animated-number-model.js';
9
+ import { useColors, useHIG } from './provider.js';
10
+ import { detectScript, Text } from './surface.js';
11
+ const numberTypographyKeys = new Set(['fontFamily', 'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textAlign']);
12
+ // Android Fabric reads colour 0 as "unset", so 'transparent' (0x00000000) drew the hidden reading in the default
13
+ // black under the reels. Clear white is non-zero there and still invisible.
14
+ const hiddenReading = { color: '#ffffff00' };
15
+ const clampedDuration = (duration) => Number.isFinite(duration) && duration > 0 ? Math.min(duration, 600) : 0;
16
+ function DigitReel({ digits, digit, trend, duration, reducedMotion, width, height, style, script, maxFontSizeMultiplier }) {
17
+ const position = useSharedValue(digit), previousDigit = useRef(digit);
18
+ const animatedStyle = useAnimatedStyle(() => ({ transform: [{ translateY: -position.value * height }] }), [height]);
19
+ useEffect(() => {
20
+ const motionDuration = clampedDuration(duration);
21
+ if (previousDigit.current === digit) {
22
+ if (reducedMotion || !motionDuration) {
23
+ cancelAnimation(position);
24
+ position.value = digit;
25
+ }
26
+ return;
27
+ }
28
+ previousDigit.current = digit;
29
+ cancelAnimation(position);
30
+ if (reducedMotion || !motionDuration) {
31
+ position.value = digit;
32
+ return;
33
+ }
34
+ const current = position.value;
35
+ if (!Number.isFinite(current)) {
36
+ position.value = digit;
37
+ return;
38
+ }
39
+ const cycle = trend < 0 ? 10 : 0, normalized = current >= cycle && current < cycle + 10 ? current : ((current % 10) + 10) % 10 + cycle;
40
+ if (normalized !== current)
41
+ position.value = normalized;
42
+ let destination = trend < 0 ? digit + 10 : digit;
43
+ if (trend > 0)
44
+ while (destination <= normalized)
45
+ destination += 10;
46
+ else if (trend < 0)
47
+ while (destination >= normalized)
48
+ destination -= 10;
49
+ if (destination === normalized) {
50
+ position.value = digit;
51
+ return;
52
+ }
53
+ position.value = withTiming(destination, { duration: motionDuration, easing: Easing.bezier(...tokens.easing.standard), reduceMotion: ReduceMotion.Never });
54
+ }, [digit, trend, duration, reducedMotion, position]);
55
+ useEffect(() => () => cancelAnimation(position), [position]);
56
+ const rows = Array.from({ length: 20 }, (_, index) => digits[index % 10]);
57
+ return _jsx(View, { collapsable: false, style: { width, height, overflow: 'hidden' }, children: _jsx(Reanimated.View, { style: animatedStyle, children: rows.map((glyph, index) => _jsx(Text, { accessible: false, script: script, maxFontSizeMultiplier: maxFontSizeMultiplier, style: [style, { width, height, textAlign: 'center' }], children: glyph }, `${index}:${glyph}`)) }) });
58
+ }
59
+ function recordGlyph(measurements, key, index, event, setMetrics) {
60
+ const { width, height } = event.nativeEvent.layout;
61
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0)
62
+ return;
63
+ measurements.current.values.set(index, { width, height });
64
+ if (measurements.current.values.size !== 10)
65
+ return;
66
+ const values = Array.from(measurements.current.values.values()), measuredWidth = Math.max(...values.map(value => value.width)), measuredHeight = Math.max(...values.map(value => value.height));
67
+ if (!Number.isFinite(measuredWidth) || !Number.isFinite(measuredHeight) || measuredWidth <= 0 || measuredHeight <= 0)
68
+ return;
69
+ setMetrics(current => current?.key === key && current.width === measuredWidth && current.height === measuredHeight ? current : { key, width: measuredWidth, height: measuredHeight });
70
+ }
71
+ export function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration = 180 }) {
72
+ const { locale, messages, direction, reducedMotion, fontFamily, fontFamilies, fontFamiliesByScript, letterSpacingByScript, maxFontSizeMultiplier: providerMaxFontSizeMultiplier } = useHIG(), colors = useColors();
73
+ const reading = formatNumberReadout(value, locale, options, formattedValue, prefix, suffix), staleSuffix = stale ? ` ${messages.stale ?? en.stale}` : '';
74
+ const previousValue = useRef(value), directionTrend = numberTrendDirection(trend, previousValue.current, value);
75
+ useEffect(() => { previousValue.current = value; }, [value]);
76
+ const typography = Object.fromEntries(Object.entries(StyleSheet.flatten(style) ?? {}).filter(([key]) => numberTypographyKeys.has(key)));
77
+ const color = colors[tone === 'positive' || tone === 'negative' || tone === 'muted' || tone === 'up' || tone === 'down' ? tone : 'text'];
78
+ const textStyle = [typography, { color, fontVariant: ['tabular-nums'] }];
79
+ const script = detectScript(`${reading.text}${staleSuffix}`, locale);
80
+ const model = createNumberReelModel(value, locale, options, formattedValue, direction);
81
+ const safeModel = model && safeNumberLayout(`${prefix ?? ''}${suffix ?? ''}${staleSuffix}`, direction) ? model : null;
82
+ let fontScale = 0;
83
+ try {
84
+ fontScale = PixelRatio.getFontScale();
85
+ }
86
+ catch { /* Static until native font metrics are available. */ }
87
+ const measurementKey = JSON.stringify([safeModel?.digits, typography, fontScale, maxFontSizeMultiplier, providerMaxFontSizeMultiplier, script, fontFamily, fontFamilies, fontFamiliesByScript, letterSpacingByScript]);
88
+ const measurements = useRef({ key: '', values: new Map() });
89
+ if (measurements.current.key !== measurementKey)
90
+ measurements.current = { key: measurementKey, values: new Map() };
91
+ const [metrics, setMetrics] = useState(null);
92
+ const activeModel = safeModel && fontScale > 0 && Number.isFinite(fontScale) && metrics?.key === measurementKey ? safeModel : null;
93
+ const activeMetrics = activeModel ? metrics : null;
94
+ const justifyContent = typography.textAlign === 'right' ? 'flex-end' : typography.textAlign === 'center' ? 'center' : 'flex-start';
95
+ const visualProps = { accessible: false, script, maxFontSizeMultiplier };
96
+ return _jsxs(View, { collapsable: false, style: { position: 'relative' }, children: [_jsxs(Text, { accessibilityLabel: label ? `${label}: ${reading.text}${staleSuffix}` : undefined, testID: testID, maxFontSizeMultiplier: maxFontSizeMultiplier, style: [textStyle, activeModel ? hiddenReading : undefined], children: [reading.text, staleSuffix] }), safeModel && _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none', style: { position: 'absolute', opacity: 0, flexDirection: 'row' }, children: safeModel.digits.map((glyph, index) => _createElement(Text, { ...visualProps, key: `${measurementKey}:${index}`, onLayout: event => recordGlyph(measurements, measurementKey, index, event, setMetrics), style: textStyle }, glyph)) }), activeModel && activeMetrics && _jsxs(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none', style: [StyleSheet.absoluteFill, { overflow: 'hidden', flexDirection: 'row', direction: 'ltr', alignItems: 'center', justifyContent }], children: [prefix && _jsx(Text, { ...visualProps, style: textStyle, children: prefix }), activeModel.tokens.map(token => token.kind === 'static' ? _createElement(Text, { ...visualProps, key: token.key, style: textStyle }, token.value) : _jsx(DigitReel, { digits: activeModel.digits, digit: token.digit ?? 0, trend: directionTrend, duration: duration, reducedMotion: reducedMotion, width: activeMetrics.width, height: activeMetrics.height, style: textStyle, script: script, maxFontSizeMultiplier: maxFontSizeMultiplier }, token.key)), (suffix || staleSuffix) && _jsx(Text, { ...visualProps, style: textStyle, children: `${suffix ?? ''}${staleSuffix}` })] })] });
97
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ /** The approved mark. Geometry and fills come from the pinned SVG through `@bloxwap/hig/tokens/brand`, painted in the provider's colour space and independent of its primary colour. */
3
+ export declare function BrandMark({ size, label }: {
4
+ size?: number;
5
+ label?: string;
6
+ }): React.JSX.Element;
7
+ export declare function CheckIcon(): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Svg, { Rect, G, Path } from 'react-native-svg';
3
+ import { brandMark as mark } from '@bloxwap/hig/tokens/brand';
4
+ import { useColors, useColorSpace } from './provider.js';
5
+ /** The approved mark. Geometry and fills come from the pinned SVG through `@bloxwap/hig/tokens/brand`, painted in the provider's colour space and independent of its primary colour. */
6
+ export function BrandMark({ size = 32, label }) { const space = useColorSpace() === 'display-p3' ? 'displayP3' : 'srgb'; return _jsxs(Svg, { width: size, height: size, viewBox: mark.viewBox, accessible: !!label, accessibilityLabel: label, children: [_jsx(Rect, { width: String(mark.size), height: String(mark.size), rx: String(mark.radius), fill: mark.fill[space] }), _jsx(G, { fill: 'none', stroke: mark.stroke[space], strokeWidth: String(mark.strokeWidth), strokeLinecap: mark.strokeLinecap, children: mark.paths.map(d => _jsx(Path, { d: d }, d)) })] }); }
7
+ export function CheckIcon() { const colors = useColors(); return _jsx(Svg, { width: '20', height: '20', viewBox: '0 0 24 24', accessible: false, children: _jsx(Path, { d: 'm5 12 4 4 10-10', fill: 'none', stroke: colors.text, strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round' }) }); }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { View, type PressableProps } from 'react-native';
3
+ import type { Intent } from '@bloxwap/hig/contracts';
4
+ import { type TextScript } from './surface.js';
5
+ export interface ButtonProps extends Omit<PressableProps, 'children'> {
6
+ children: React.ReactNode; /** Custom content renders host nodes directly; the host owns visible busy content. Root disabled/busy/feedback semantics stay canonical. */
7
+ contentMode?: 'default' | 'custom';
8
+ intent?: Intent;
9
+ busy?: boolean; /** Busy text for this button's accessible name; defaults to HIGProvider `messages.busy`. `''` leaves the name unchanged (accessibilityState.busy stays set). The visible busy state is a leading spinner. */
10
+ busyLabel?: string; /** Overrides the provider's text scale cap for the label. */
11
+ maxFontSizeMultiplier?: number;
12
+ script?: TextScript;
13
+ fullWidth?: boolean;
14
+ suppressFeedback?: boolean;
15
+ }
16
+ /** Android appends its localized busy state; including the suffix there would speak it twice. */
17
+ export declare function busyAccessibilityLabel(text: string, busyText: string, os?: string): string | undefined;
18
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<React.ComponentRef<typeof View>>>;
19
+ /** While busy, the spinner takes the icon's place. */
20
+ export declare function IconButton({ label, children, style, ...props }: ButtonProps & {
21
+ label: string;
22
+ }): React.JSX.Element;
23
+ export interface LinkProps extends Omit<PressableProps, 'children' | 'onPress' | 'accessibilityRole' | 'role'> {
24
+ href: string;
25
+ children: React.ReactNode; /** Host navigation replaces Linking.openURL, so one press never opens both. */
26
+ onPress?: PressableProps['onPress'];
27
+ onError?: (error: unknown) => void;
28
+ /** Custom content renders host label/icon nodes directly. */ contentMode?: 'default' | 'custom';
29
+ }
30
+ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<React.ComponentRef<typeof View>>>;