@bloxwap/hig 0.0.0-stage → 0.2.0

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 (179) 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 +162 -0
  14. package/contracts/dist/messages.js +68 -0
  15. package/feedback/README.md +7 -0
  16. package/feedback/assets/error.wav +0 -0
  17. package/feedback/assets/manifest.json +68 -0
  18. package/feedback/assets/success.wav +0 -0
  19. package/feedback/assets/tick.wav +0 -0
  20. package/feedback/assets/toggle.wav +0 -0
  21. package/feedback/dist/browser-haptic.d.ts +23 -0
  22. package/feedback/dist/browser-haptic.js +41 -0
  23. package/feedback/dist/contract.d.ts +96 -0
  24. package/feedback/dist/contract.js +58 -0
  25. package/feedback/dist/native.d.ts +27 -0
  26. package/feedback/dist/native.js +63 -0
  27. package/feedback/dist/preferences.d.ts +8 -0
  28. package/feedback/dist/preferences.js +24 -0
  29. package/feedback/dist/react.d.ts +19 -0
  30. package/feedback/dist/react.js +23 -0
  31. package/feedback/dist/web-haptic.d.ts +6 -0
  32. package/feedback/dist/web-haptic.js +6 -0
  33. package/feedback/dist/web-sound.d.ts +5 -0
  34. package/feedback/dist/web-sound.js +32 -0
  35. package/feedback/dist/web.d.ts +3 -0
  36. package/feedback/dist/web.js +4 -0
  37. package/native/README.md +11 -0
  38. package/native/android/build.gradle +28 -0
  39. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
  40. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
  41. package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
  42. package/native/dist/animated-number-model.d.ts +24 -0
  43. package/native/dist/animated-number-model.js +110 -0
  44. package/native/dist/animated-number.d.ts +9 -0
  45. package/native/dist/animated-number.js +93 -0
  46. package/native/dist/brand.d.ts +7 -0
  47. package/native/dist/brand.js +6 -0
  48. package/native/dist/button.d.ts +29 -0
  49. package/native/dist/button.js +34 -0
  50. package/native/dist/checkbox.d.ts +3 -0
  51. package/native/dist/checkbox.js +11 -0
  52. package/native/dist/data.d.ts +40 -0
  53. package/native/dist/data.js +27 -0
  54. package/native/dist/field.d.ts +15 -0
  55. package/native/dist/field.js +13 -0
  56. package/native/dist/gesture-sheet.d.ts +73 -0
  57. package/native/dist/gesture-sheet.js +151 -0
  58. package/native/dist/navigation.d.ts +47 -0
  59. package/native/dist/navigation.js +16 -0
  60. package/native/dist/overlay.d.ts +36 -0
  61. package/native/dist/overlay.js +65 -0
  62. package/native/dist/provider.d.ts +43 -0
  63. package/native/dist/provider.js +52 -0
  64. package/native/dist/radio-group.d.ts +5 -0
  65. package/native/dist/radio-group.js +53 -0
  66. package/native/dist/recipes.d.ts +42 -0
  67. package/native/dist/recipes.js +19 -0
  68. package/native/dist/roles.d.ts +6 -0
  69. package/native/dist/roles.js +4 -0
  70. package/native/dist/select.d.ts +3 -0
  71. package/native/dist/select.js +9 -0
  72. package/native/dist/selection-types.d.ts +22 -0
  73. package/native/dist/selection-types.js +1 -0
  74. package/native/dist/selection.d.ts +7 -0
  75. package/native/dist/selection.js +6 -0
  76. package/native/dist/slider.d.ts +11 -0
  77. package/native/dist/slider.js +41 -0
  78. package/native/dist/status.d.ts +75 -0
  79. package/native/dist/status.js +72 -0
  80. package/native/dist/surface.d.ts +18 -0
  81. package/native/dist/surface.js +41 -0
  82. package/native/dist/switch-row.d.ts +8 -0
  83. package/native/dist/switch-row.js +18 -0
  84. package/native/dist/switch.d.ts +10 -0
  85. package/native/dist/switch.js +23 -0
  86. package/native/dist/text-content.d.ts +5 -0
  87. package/native/dist/text-content.js +6 -0
  88. package/native-fonts/README.md +17 -0
  89. package/native-fonts/dist/index.d.ts +164 -0
  90. package/native-fonts/dist/index.js +164 -0
  91. package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
  92. package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
  93. package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  94. package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
  95. package/native-fonts/fonts/BloxwapMono.ttf +0 -0
  96. package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  97. package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  98. package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
  99. package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  100. package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
  101. package/native-fonts/fonts/BloxwapSans.ttf +0 -0
  102. package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
  103. package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
  104. package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
  105. package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
  106. package/native-fonts/fonts/OFL.txt +93 -0
  107. package/native-fonts/fonts/manifest.json +164 -0
  108. package/og-fonts/README.md +34 -0
  109. package/og-fonts/dist/index.d.ts +116 -0
  110. package/og-fonts/dist/index.js +102 -0
  111. package/og-fonts/dist/node.d.ts +11 -0
  112. package/og-fonts/dist/node.js +39 -0
  113. package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  114. package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  115. package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  116. package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  117. package/og-fonts/fonts/BloxwapSans.ttf +0 -0
  118. package/og-fonts/fonts/OFL.txt +93 -0
  119. package/og-fonts/fonts/manifest.json +65 -0
  120. package/package.json +358 -4
  121. package/react/README.md +9 -0
  122. package/react/dist/animated-number-model.d.ts +20 -0
  123. package/react/dist/animated-number-model.js +92 -0
  124. package/react/dist/animated-number.d.ts +8 -0
  125. package/react/dist/animated-number.js +71 -0
  126. package/react/dist/base.css +9 -0
  127. package/react/dist/brand.d.ts +7 -0
  128. package/react/dist/brand.js +4 -0
  129. package/react/dist/button.d.ts +14 -0
  130. package/react/dist/button.js +20 -0
  131. package/react/dist/data.d.ts +63 -0
  132. package/react/dist/data.js +23 -0
  133. package/react/dist/dialog.d.ts +29 -0
  134. package/react/dist/dialog.js +21 -0
  135. package/react/dist/field.d.ts +15 -0
  136. package/react/dist/field.js +19 -0
  137. package/react/dist/gesture-sheet.d.ts +41 -0
  138. package/react/dist/gesture-sheet.js +128 -0
  139. package/react/dist/navigation.d.ts +48 -0
  140. package/react/dist/navigation.js +69 -0
  141. package/react/dist/overlay.d.ts +17 -0
  142. package/react/dist/overlay.js +18 -0
  143. package/react/dist/provider.d.ts +25 -0
  144. package/react/dist/provider.js +50 -0
  145. package/react/dist/recipes/activity-list.d.ts +8 -0
  146. package/react/dist/recipes/activity-list.js +6 -0
  147. package/react/dist/recipes/balance-card.d.ts +6 -0
  148. package/react/dist/recipes/balance-card.js +5 -0
  149. package/react/dist/recipes/code-window.d.ts +4 -0
  150. package/react/dist/recipes/code-window.js +4 -0
  151. package/react/dist/recipes/install-command.d.ts +5 -0
  152. package/react/dist/recipes/install-command.js +8 -0
  153. package/react/dist/recipes/market-row.d.ts +25 -0
  154. package/react/dist/recipes/market-row.js +8 -0
  155. package/react/dist/recipes/marketing-hero.d.ts +7 -0
  156. package/react/dist/recipes/marketing-hero.js +5 -0
  157. package/react/dist/recipes/trade-entry.d.ts +11 -0
  158. package/react/dist/recipes/trade-entry.js +12 -0
  159. package/react/dist/recipes.d.ts +8 -0
  160. package/react/dist/recipes.js +9 -0
  161. package/react/dist/select.d.ts +4 -0
  162. package/react/dist/select.js +172 -0
  163. package/react/dist/selection.d.ts +27 -0
  164. package/react/dist/selection.js +16 -0
  165. package/react/dist/slider.d.ts +11 -0
  166. package/react/dist/slider.js +10 -0
  167. package/react/dist/status.d.ts +53 -0
  168. package/react/dist/status.js +43 -0
  169. package/react/dist/styles.css +228 -0
  170. package/react/dist/surface.d.ts +291 -0
  171. package/react/dist/surface.js +9 -0
  172. package/tokens/README.md +9 -0
  173. package/tokens/assets/bloxwap-icon.svg +1 -0
  174. package/tokens/dist/index.d.ts +429 -0
  175. package/tokens/dist/index.js +507 -0
  176. package/tokens/dist/manifest.json +197 -0
  177. package/tokens/dist/theme.d.ts +11 -0
  178. package/tokens/dist/theme.js +22 -0
  179. package/tokens/dist/tokens.css +119 -0
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bloxwap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to inclusion of this notice. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
package/README.md CHANGED
@@ -1,3 +1,45 @@
1
- # Temporary Holding Version
1
+ # @bloxwap/hig
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Bloxwap Human Interface Guidelines in one package: semantic tokens, platform-neutral contracts, React and
4
+ React Native components, the `@bloxwap/chart` adapter, optional sound and haptic feedback, and the native and
5
+ Open Graph font faces.
6
+
7
+ ```sh
8
+ npm install @bloxwap/hig
9
+ ```
10
+
11
+ Import only the entries you use. Nothing loads from a root barrel.
12
+
13
+ ```ts
14
+ import '@bloxwap/hig/tokens/css';
15
+ import '@bloxwap/hig/react/css';
16
+ import {HIGProvider} from '@bloxwap/hig/react/provider';
17
+ import {Button} from '@bloxwap/hig/react/button';
18
+ ```
19
+
20
+ | Entry | Contents |
21
+ | --- | --- |
22
+ | `@bloxwap/hig/tokens` | Tokens, `resolvePrimaryColor`, `./tokens/css`, `./tokens/manifest` ([README](tokens/README.md)) |
23
+ | `@bloxwap/hig/contracts` | Types, formatting, feedback, announcements and messages ([README](contracts/README.md)) |
24
+ | `@bloxwap/hig/react/*` | Web components, recipes, `./react/css` and `./react/css/base` ([README](react/README.md)) |
25
+ | `@bloxwap/hig/native/*` | React Native components ([README](native/README.md)) |
26
+ | `@bloxwap/hig/chart` | `PriceChart` and `chartTheme` for `@bloxwap/chart` ([README](chart/README.md)) |
27
+ | `@bloxwap/hig/feedback/*` | Opt-in web and native sound/haptic adapters ([README](feedback/README.md)) |
28
+ | `@bloxwap/hig/native-fonts` | Static TTFs for React Native and Expo ([README](native-fonts/README.md)) |
29
+ | `@bloxwap/hig/og-fonts` | Satori / `next/og` faces and the Node loader ([README](og-fonts/README.md)) |
30
+
31
+ ## Peers
32
+
33
+ Every renderer, device and overlay peer is optional: install React DOM and Radix for web overlays, React Native
34
+ and its community modules for native, `vaul` for the web gesture sheet, and the Expo or Bloxwap audio/haptic
35
+ packages for feedback, only when you import those entries. `@bloxwap/chart` `^0.3.0` is the one required peer;
36
+ an optional peer on it makes npm 11 drop a host's workspace `@bloxwap/chart` (bloxwap/hig#96).
37
+
38
+ ## Moving from 0.1
39
+
40
+ HIG 0.1 published eight packages (`@bloxwap/hig-tokens`, `-contracts`, `-react`, `-native`, `-chart`,
41
+ `-feedback`, `-native-fonts`, `-og-fonts`). Replace them with `@bloxwap/hig` and change the hyphen after `hig`
42
+ to a slash in each import: `@bloxwap/hig-react/button` becomes `@bloxwap/hig/react/button`. Entry names and
43
+ exports are unchanged. In Next, list `'@bloxwap/hig'` in `transpilePackages` or `serverExternalPackages`.
44
+
45
+ MIT licensed. Font binaries are derived from `@bloxwap/font` (OFL-1.1).
@@ -0,0 +1,23 @@
1
+ # @bloxwap/hig/chart
2
+
3
+ Version 0.2.0, an entry of `@bloxwap/hig`. The HIG adapter for [`@bloxwap/chart`](https://github.com/bloxwap/chart): `PriceChart` (a
4
+ `<figure>` with a required text `summary`, lazy-loading `@bloxwap/chart/react` inside `Suspense`) and
5
+ `chartTheme` (HIG token colors in sRGB for the canvas). Web only; React Native uses labeled readouts and lists
6
+ from `@bloxwap/hig/native/data`.
7
+
8
+ ```sh
9
+ npm install @bloxwap/hig @bloxwap/chart@^0.3.0
10
+ ```
11
+
12
+ ```tsx
13
+ import {PriceChart, chartTheme} from '@bloxwap/hig/chart';
14
+ ```
15
+
16
+ Needs `react` and `@bloxwap/chart` `^0.3.0`; `HIGProvider` from `@bloxwap/hig/react/provider` supplies the
17
+ loading messages. `@bloxwap/chart` is the one required peer of `@bloxwap/hig`, and deliberately not optional: npm 11 drops a workspace copy of
18
+ `@bloxwap/chart` from a lockfile regenerated from scratch when an installed package declares it as an optional
19
+ peer (bloxwap/hig#96).
20
+
21
+ Moved from `@bloxwap/hig/react/chart` in bloxwap/hig#96; there is no `./react/chart` entry, and no other entry
22
+ imports `@bloxwap/chart`. Replace `@bloxwap/hig/react/chart` with `@bloxwap/hig/chart` in imports; the
23
+ exports and props are unchanged.
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { ChartProps } from '@bloxwap/chart/react';
3
+ import type { DeepPartial, ChartConfig } from '@bloxwap/chart/config';
4
+ export declare const chartTheme: DeepPartial<ChartConfig>;
5
+ /** Web canvas only. Native uses labeled price rows; no embedded engine or WebView claim. */
6
+ export declare function PriceChart({ summary, ...props }: ChartProps & {
7
+ summary: string;
8
+ }): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // @bloxwap/hig/chart: the HIG adapter for @bloxwap/chart (#96). No other entry imports @bloxwap/chart, and
4
+ // @bloxwap/hig declares it as a required peer, never optional.
5
+ import { Suspense, lazy, useMemo } from 'react';
6
+ import { tokens } from '@bloxwap/hig/tokens';
7
+ import * as en from '@bloxwap/hig/contracts/messages';
8
+ import { useHIG, useColors } from '@bloxwap/hig/react/provider';
9
+ const Chart = lazy(() => import('@bloxwap/chart/react').then(m => ({ default: m.Chart })));
10
+ export const chartTheme = { theme: { background: tokens.colors.surface.srgb, textColor: tokens.colors.text.srgb, borderColor: tokens.colors.border.srgb, fontFamily: 'Bloxwap Sans, system-ui, sans-serif', monoFamily: 'Bloxwap Mono, monospace' }, grid: { color: tokens.colors.border.srgb }, crosshair: { color: tokens.colors.muted.srgb, labelBackground: tokens.colors.action.srgb, labelColor: tokens.colors.onAction.srgb }, series: { upColor: tokens.colors.buy.srgb, downColor: tokens.colors.sell.srgb } };
11
+ /** Web canvas only. Native uses labeled price rows; no embedded engine or WebView claim. */
12
+ export function PriceChart({ summary, ...props }) { const { messages } = useHIG(); const colors = useColors(); const theme = useMemo(() => ({ ...chartTheme, crosshair: { ...chartTheme.crosshair, labelBackground: colors.action, labelColor: colors.onAction } }), [colors]); return _jsxs("figure", { children: [_jsx("figcaption", { children: summary }), _jsx(Suspense, { fallback: _jsx("p", { role: 'status', children: messages.loadingChart ?? en.loadingChart }), children: _jsx(Chart, { ...props, preset: theme }) })] }); }
@@ -0,0 +1,3 @@
1
+ # @bloxwap/hig/contracts
2
+
3
+ Version 0.2.0, an entry of `@bloxwap/hig`. See the HIG architecture and platform limitations before adoption.
@@ -0,0 +1,12 @@
1
+ export interface NotificationMessage {
2
+ id: string;
3
+ message: string;
4
+ severity: 'info' | 'success' | 'warning' | 'error';
5
+ }
6
+ /** One announcement per committed burst; repeated ids/content do not create repeated effects. */
7
+ export declare function notificationDelta(previous: ReadonlyMap<string, string>, notices: readonly NotificationMessage[]): {
8
+ next: Map<string, string>;
9
+ id: string | undefined;
10
+ message: string | undefined;
11
+ severity: "error" | "info" | "success" | "warning";
12
+ };
@@ -0,0 +1,8 @@
1
+ /** One announcement per committed burst; repeated ids/content do not create repeated effects. */
2
+ export function notificationDelta(previous, notices) {
3
+ const unique = [...new Map(notices.map(notice => [notice.id, notice])).values()];
4
+ const next = new Map(unique.map(notice => [notice.id, JSON.stringify([notice.message, notice.severity])]));
5
+ const changed = unique.filter(notice => previous.get(notice.id) !== next.get(notice.id));
6
+ const important = changed.find(notice => notice.severity === 'error') ?? changed.at(-1);
7
+ return { next, id: important?.id, message: important?.message, severity: important?.severity ?? 'info' };
8
+ }
@@ -0,0 +1,40 @@
1
+ export type FeedbackIntent = 'press' | 'activate' | 'release' | 'cancel' | 'selection' | 'toggle' | 'disclosure' | 'success' | 'warning' | 'error' | 'notification';
2
+ export type FeedbackOrigin = 'pointer' | 'keyboard' | 'native' | 'programmatic';
3
+ /** Async outcomes use the host operation id. A successful call is not proof of physical output. */
4
+ export interface FeedbackEvent {
5
+ id: string;
6
+ source: string;
7
+ intent: FeedbackIntent;
8
+ origin: FeedbackOrigin;
9
+ impact?: 'light' | 'medium' | 'heavy';
10
+ cancelled?: boolean;
11
+ disabled?: boolean;
12
+ busy?: boolean;
13
+ suppressed?: boolean;
14
+ }
15
+ export interface FeedbackSink {
16
+ emit: (event: FeedbackEvent) => void;
17
+ }
18
+ export interface FeedbackPreferences {
19
+ version: 1;
20
+ sound: boolean;
21
+ haptics: boolean;
22
+ volume: number;
23
+ motion: boolean;
24
+ }
25
+ export interface FeedbackCapability {
26
+ available: boolean;
27
+ mechanism: 'none' | 'web-audio' | 'browser-vibration' | 'physical-tap' | 'native-audio' | 'native-haptics';
28
+ observed: boolean;
29
+ reason?: string;
30
+ }
31
+ export interface FeedbackAdapter {
32
+ capability: FeedbackCapability;
33
+ play: (event: FeedbackEvent, preferences: FeedbackPreferences) => void | Promise<void>;
34
+ cancel?: () => void | Promise<void>;
35
+ dispose?: () => void | Promise<void>;
36
+ }
37
+ export interface PreferenceStorage {
38
+ read: () => unknown | Promise<unknown>;
39
+ write: (value: FeedbackPreferences) => void | Promise<void>;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ export type Density = 'comfortable' | 'compact';
2
+ export type Intent = 'primary' | 'secondary' | 'destructive' | 'ghost';
3
+ export type Direction = 'ltr' | 'rtl';
4
+ export interface Environment {
5
+ density: Density;
6
+ locale: string;
7
+ direction: Direction;
8
+ reducedMotion: boolean;
9
+ }
10
+ export declare const defaultEnvironment: Environment;
11
+ /** A host-supplied locale: a BCP 47 tag (`ar-EG`), a Java/Android identifier (`ar_EG`, `az_IR_#Arab`), or a locale object that may carry its own `textDirection`, such as expo-localization's `getLocales()[0]`. */
12
+ export type HostLocale = string | {
13
+ readonly textDirection?: Direction | null;
14
+ readonly languageTag?: string | null;
15
+ };
16
+ /**
17
+ * Writing direction of a host-supplied locale, or `undefined` when the value names no language (empty, `und`, malformed).
18
+ * An explicit `textDirection` wins; otherwise a script subtag decides, then the language. Pass the result to `HIGProvider direction`
19
+ * only in apps that lay out right to left: it reports the locale's direction, not whether the host allows RTL (#86).
20
+ */
21
+ export declare function localeDirection(locale: HostLocale | null | undefined): Direction | undefined;
22
+ /** Display only. Keep raw decimal strings in transaction logic. */
23
+ export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
24
+ /** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
25
+ export declare function formatLeverage(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
26
+ /** Amount followed by an untranslated ticker such as `USDC` (not an ISO 4217 currency), joined by a no-break space. Unknown → `—`. */
27
+ export declare function formatTicker(value: number | null | undefined, ticker: string, locale?: string, options?: Intl.NumberFormatOptions): string;
28
+ /** Clock display for funding and other protocol instants. The host must name the zone; the zone name is always shown. Unknown → `—`. */
29
+ export declare function formatZonedTime(value: Date | number | null | undefined, locale: string, timeZone: string, options?: Intl.DateTimeFormatOptions): string;
30
+ /** Font 0.1.2 publishes CSS/Next loaders, native faces are derived by the optional pinned HIG font generator. */
31
+ export interface FontManifest {
32
+ version: string;
33
+ faces: ReadonlyArray<{
34
+ family: string;
35
+ weight: number;
36
+ asset: string;
37
+ script: string;
38
+ registration?: string;
39
+ }>;
40
+ }
41
+ export declare function nativeFont(manifest: FontManifest, family: string, weight: number, script?: string): string;
@@ -0,0 +1,52 @@
1
+ export const defaultEnvironment = { density: 'comfortable', locale: 'en-US', direction: 'ltr', reducedMotion: false };
2
+ // Scripts written right to left (ISO 15924), and languages whose default script is one of them when no script subtag is given.
3
+ const rtlScripts = new Set(['adlm', 'arab', 'aran', 'armi', 'avst', 'chrs', 'cprt', 'elym', 'hatr', 'hebr', 'hung', 'khar', 'lydi', 'mand', 'mani', 'mend', 'merc', 'mero', 'narb', 'nbat', 'nkoo', 'orkh', 'ougr', 'palm', 'phli', 'phlp', 'phnx', 'prti', 'rohg', 'samr', 'sarb', 'sogd', 'sogo', 'syrc', 'thaa', 'yezi']);
4
+ const rtlLanguages = new Set(['ar', 'arc', 'azb', 'bal', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'iw', 'ji', 'khw', 'ks', 'lrc', 'mzn', 'nqo', 'pnb', 'prs', 'ps', 'rhg', 'sd', 'sdh', 'skr', 'syr', 'ug', 'ur', 'yi']);
5
+ /**
6
+ * Writing direction of a host-supplied locale, or `undefined` when the value names no language (empty, `und`, malformed).
7
+ * An explicit `textDirection` wins; otherwise a script subtag decides, then the language. Pass the result to `HIGProvider direction`
8
+ * only in apps that lay out right to left: it reports the locale's direction, not whether the host allows RTL (#86).
9
+ */
10
+ export function localeDirection(locale) {
11
+ if (locale == null)
12
+ return undefined;
13
+ if (typeof locale === 'object') {
14
+ if (locale.textDirection === 'rtl' || locale.textDirection === 'ltr')
15
+ return locale.textDirection;
16
+ return localeDirection(locale.languageTag);
17
+ }
18
+ const [language = '', ...rest] = locale.trim().toLowerCase().split(/[-_#]+/);
19
+ if (!/^[a-z]{2,3}$/.test(language) || language === 'und')
20
+ return undefined;
21
+ // The script precedes any singleton extension (`-u-nu-arab` names Arabic digits, not Arabic script).
22
+ const singleton = rest.findIndex(subtag => subtag.length === 1);
23
+ const script = (singleton < 0 ? rest : rest.slice(0, singleton)).find(subtag => /^[a-z]{4}$/.test(subtag));
24
+ return (script ? rtlScripts.has(script) : rtlLanguages.has(language)) ? 'rtl' : 'ltr';
25
+ }
26
+ /** Display only. Keep raw decimal strings in transaction logic. */
27
+ export function formatNumber(value, locale = 'en-US', options = {}) {
28
+ return value == null || !Number.isFinite(value) ? '—' : new Intl.NumberFormat(locale, options).format(value);
29
+ }
30
+ /** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
31
+ export function formatLeverage(value, locale = 'en-US', options = { maximumFractionDigits: 2 }) {
32
+ const amount = formatNumber(value, locale, { ...options, style: 'decimal' });
33
+ return amount === '—' ? amount : `${amount}×`;
34
+ }
35
+ /** Amount followed by an untranslated ticker such as `USDC` (not an ISO 4217 currency), joined by a no-break space. Unknown → `—`. */
36
+ export function formatTicker(value, ticker, locale = 'en-US', options = {}) {
37
+ const amount = formatNumber(value, locale, { ...options, style: 'decimal' });
38
+ return amount === '—' ? amount : `${amount}\u00a0${ticker}`;
39
+ }
40
+ /** Clock display for funding and other protocol instants. The host must name the zone; the zone name is always shown. Unknown → `—`. */
41
+ export function formatZonedTime(value, locale, timeZone, options = { hour: 'numeric', minute: '2-digit' }) {
42
+ const time = value instanceof Date ? value.getTime() : value;
43
+ if (time == null || !Number.isFinite(time))
44
+ return '—';
45
+ return new Intl.DateTimeFormat(locale, { timeZoneName: 'short', ...options, timeZone }).format(time);
46
+ }
47
+ export function nativeFont(manifest, family, weight, script = 'latin') {
48
+ const face = manifest.faces.find(f => f.family === family && f.weight === weight && f.script === script);
49
+ if (!face)
50
+ throw new Error(`Register a pinned ${family} ${weight} ${script} native face`);
51
+ return face.registration ?? face.family;
52
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Built-in copy rendered by HIG React and React Native components (visible text and accessible names).
3
+ * English (`en-US`) defaults only: HIG ships no translations. Hosts pass their own catalog through
4
+ * `HIGProvider messages`; components with a `closeLabel`/`cancelLabel`/`dismissLabel`/`busyLabel` prop take a
5
+ * per-instance override. Keys and wording are documented in docs/foundations/localization.md.
6
+ *
7
+ * Each English default is also a named export so a component bundles only the copy it renders
8
+ * (`import * as en from '@bloxwap/hig/contracts/messages'; messages.close ?? en.close`).
9
+ */
10
+ export interface HIGMessages {
11
+ /** Button that closes Dialog, Sheet, Popover, native Menu and GestureSheet. UI dismissal, not the glossary “close” of a position. */
12
+ close: string;
13
+ /** Web AlertDialog's explicit decline button. */
14
+ cancel: string;
15
+ /** Visible Toast dismiss button. */
16
+ dismiss: string;
17
+ /** Toast dismiss accessible name. Must contain `dismiss` (the visible label) so voice control still matches. */
18
+ dismissNotice: (message: string, dismiss: string) => string;
19
+ /** Visible and announced Button busy suffix (` · Working`). An empty string hides the suffix; busy state is still exposed. On Android the platform's busy state description replaces the suffix in the accessible name. */
20
+ busy: string;
21
+ /** Web Toast landmark name. */
22
+ notifications: string;
23
+ /** Spinner default label (an ellipsis is appended on web). */
24
+ loading: string;
25
+ /** Skeleton default label. */
26
+ loadingContent: string;
27
+ /** List loading row. */
28
+ loadingItems: string;
29
+ /** Web PriceChart fallback while the chart engine loads. */
30
+ loadingChart: string;
31
+ /** List default empty text. */
32
+ noItems: string;
33
+ /** Web Table empty text. */
34
+ noRows: string;
35
+ /** List retry button. */
36
+ retry: string;
37
+ /** List load-more button. */
38
+ loadMore: string;
39
+ /** Stale marker appended to a NumberReadout reading and its accessible name. */
40
+ stale: string;
41
+ /** Marker appended to a required Field label and its accessible name. */
42
+ required: string;
43
+ /** Web Breadcrumb landmark name. */
44
+ breadcrumb: string;
45
+ /** Web Pagination landmark name. */
46
+ pagination: string;
47
+ /** Pagination previous-page button. */
48
+ previous: string;
49
+ /** Pagination next-page button. */
50
+ next: string;
51
+ /** Pagination position; `page` and `total` arrive already formatted for the provider locale. */
52
+ pageOf: (page: string, total: string) => string;
53
+ /** Search field label. */
54
+ search: string;
55
+ /** Search in-progress status. */
56
+ searching: string;
57
+ /** Search empty status. */
58
+ noResults: string;
59
+ /** Native Search result count status. Use Intl.PluralRules for locales with more plural forms. */
60
+ resultCount: (count: number, locale: string) => string;
61
+ /** Native BackButton. */
62
+ back: string;
63
+ /** Native Menu sheet description. */
64
+ menuDescription: string;
65
+ /** Native Select trigger value before a choice. */
66
+ choose: string;
67
+ /** Native Select sheet description. */
68
+ chooseOne: string;
69
+ /** Native indeterminate Progress value text. */
70
+ inProgress: string;
71
+ /** Native determinate Progress value text; numbers arrive formatted for the provider locale. */
72
+ progressValue: (value: string, max: string) => string;
73
+ /** InstallCommand success status. */
74
+ copied: string;
75
+ /** InstallCommand failure status. */
76
+ copyFailed: string;
77
+ /** InstallCommand copy button. */
78
+ copyInstallCommand: string;
79
+ /** TradeEntry heading. */
80
+ reviewAssetOrder: (asset: string) => string;
81
+ /** TradeEntry amount field label. */
82
+ amountInAsset: (asset: string) => string;
83
+ /** TradeEntry amount field description. */
84
+ availableAmount: (available: string) => string;
85
+ /** TradeEntry review button. */
86
+ reviewOrder: string;
87
+ /** TradeEntry confirmation dialog title and confirm button. */
88
+ confirmOrder: string;
89
+ /** TradeEntry confirmation dialog description. */
90
+ confirmOrderDescription: (amount: string, asset: string) => string;
91
+ /** TradeEntry error alert title (web). */
92
+ orderUnavailable: string;
93
+ /** ActivityList empty text. */
94
+ noActivity: string;
95
+ /** StatusIndicator `online` state. */
96
+ statusOnline: string;
97
+ /** StatusIndicator `offline` state. */
98
+ statusOffline: string;
99
+ /** StatusIndicator `stale` state. */
100
+ statusStale: string;
101
+ /** Native Slider increment accessibility action label (Android action list; RN 0.83 otherwise exposes an empty label). */
102
+ increase: string;
103
+ /** Native Slider decrement accessibility action label. */
104
+ decrease: string;
105
+ }
106
+ export declare const close = "Close";
107
+ export declare const cancel = "Cancel";
108
+ export declare const dismiss = "Dismiss";
109
+ export declare const dismissNotice: (message: string, dismiss: string) => string;
110
+ export declare const busy = "Working";
111
+ export declare const notifications = "Notifications";
112
+ export declare const loading = "Loading";
113
+ export declare const loadingContent = "Loading content";
114
+ export declare const loadingItems = "Loading items";
115
+ export declare const loadingChart = "Loading chart\u2026";
116
+ export declare const noItems = "No items";
117
+ export declare const noRows = "No rows";
118
+ export declare const retry = "Retry";
119
+ export declare const loadMore = "Load more";
120
+ export declare const stale = "(stale)";
121
+ export declare const required = "(required)";
122
+ export declare const breadcrumb = "Breadcrumb";
123
+ export declare const pagination = "Pagination";
124
+ export declare const previous = "Previous";
125
+ export declare const next = "Next";
126
+ export declare const pageOf: (page: string, total: string) => string;
127
+ export declare const search = "Search";
128
+ export declare const searching = "Searching\u2026";
129
+ export declare const noResults = "No results";
130
+ export declare const resultCount: (count: number, locale: string) => string;
131
+ export declare const back = "Back";
132
+ export declare const menuDescription = "Available actions";
133
+ export declare const choose = "Choose";
134
+ export declare const chooseOne = "Choose one option.";
135
+ export declare const inProgress = "In progress";
136
+ export declare const progressValue: (value: string, max: string) => string;
137
+ export declare const copied = "Copied";
138
+ export declare const copyFailed = "Copy failed. Select the command and copy manually.";
139
+ export declare const copyInstallCommand = "Copy install command";
140
+ export declare const reviewAssetOrder: (asset: string) => string;
141
+ export declare const amountInAsset: (asset: string) => string;
142
+ export declare const availableAmount: (available: string) => string;
143
+ export declare const reviewOrder = "Review order";
144
+ export declare const confirmOrder = "Confirm order";
145
+ export declare const confirmOrderDescription: (amount: string, asset: string) => string;
146
+ export declare const orderUnavailable = "Order unavailable";
147
+ export declare const noActivity = "No activity yet";
148
+ export declare const statusOnline = "online";
149
+ export declare const statusOffline = "offline";
150
+ export declare const statusStale = "stale";
151
+ export declare const increase = "Increase";
152
+ export declare const decrease = "Decrease";
153
+ /** The complete English catalog. */
154
+ export declare const defaultMessages: Readonly<HIGMessages>;
155
+ /** Every message key, in documentation order. */
156
+ export declare const messageKeys: readonly (keyof HIGMessages)[];
157
+ /**
158
+ * Overlays host overrides on a base catalog (both may be partial). `undefined` entries keep the base copy, and a
159
+ * value of the wrong kind (a string for a formatter key, or the reverse) is ignored, so a partial or untyped catalog
160
+ * never blanks a label or throws while rendering.
161
+ */
162
+ export declare function resolveMessages<T extends Partial<HIGMessages>>(base: T, overrides?: Partial<HIGMessages>): T;
@@ -0,0 +1,68 @@
1
+ // Canonical English copy, one export per key. Hosts translate these; they do not edit them.
2
+ export const close = 'Close';
3
+ export const cancel = 'Cancel';
4
+ export const dismiss = 'Dismiss';
5
+ export const dismissNotice = (message, dismiss) => `${dismiss} ${message}`;
6
+ export const busy = 'Working';
7
+ export const notifications = 'Notifications';
8
+ export const loading = 'Loading';
9
+ export const loadingContent = 'Loading content';
10
+ export const loadingItems = 'Loading items';
11
+ export const loadingChart = 'Loading chart…';
12
+ export const noItems = 'No items';
13
+ export const noRows = 'No rows';
14
+ export const retry = 'Retry';
15
+ export const loadMore = 'Load more';
16
+ export const stale = '(stale)';
17
+ export const required = '(required)';
18
+ export const breadcrumb = 'Breadcrumb';
19
+ export const pagination = 'Pagination';
20
+ export const previous = 'Previous';
21
+ export const next = 'Next';
22
+ export const pageOf = (page, total) => `Page ${page} of ${total}`;
23
+ export const search = 'Search';
24
+ export const searching = 'Searching…';
25
+ export const noResults = 'No results';
26
+ export const resultCount = (count, locale) => `${new Intl.NumberFormat(locale).format(count)} ${count === 1 ? 'result' : 'results'}`;
27
+ export const back = 'Back';
28
+ export const menuDescription = 'Available actions';
29
+ export const choose = 'Choose';
30
+ export const chooseOne = 'Choose one option.';
31
+ export const inProgress = 'In progress';
32
+ export const progressValue = (value, max) => `${value} of ${max}`;
33
+ export const copied = 'Copied';
34
+ export const copyFailed = 'Copy failed. Select the command and copy manually.';
35
+ export const copyInstallCommand = 'Copy install command';
36
+ export const reviewAssetOrder = (asset) => `Review ${asset} order`;
37
+ export const amountInAsset = (asset) => `Amount (${asset})`;
38
+ export const availableAmount = (available) => `Available: ${available}`;
39
+ export const reviewOrder = 'Review order';
40
+ export const confirmOrder = 'Confirm order';
41
+ export const confirmOrderDescription = (amount, asset) => `Amount: ${amount} ${asset}. Verify the host-provided terms before submission.`;
42
+ export const orderUnavailable = 'Order unavailable';
43
+ export const noActivity = 'No activity yet';
44
+ export const statusOnline = 'online';
45
+ export const statusOffline = 'offline';
46
+ export const statusStale = 'stale';
47
+ export const increase = 'Increase';
48
+ export const decrease = 'Decrease';
49
+ /** The complete English catalog. */
50
+ export const defaultMessages = { close, cancel, dismiss, dismissNotice, busy, notifications, loading, loadingContent, loadingItems, loadingChart, noItems, noRows, retry, loadMore, stale, required, breadcrumb, pagination, previous, next, pageOf, search, searching, noResults, resultCount, back, menuDescription, choose, chooseOne, inProgress, progressValue, copied, copyFailed, copyInstallCommand, reviewAssetOrder, amountInAsset, availableAmount, reviewOrder, confirmOrder, confirmOrderDescription, orderUnavailable, noActivity, statusOnline, statusOffline, statusStale, increase, decrease };
51
+ /** Every message key, in documentation order. */
52
+ export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
53
+ /**
54
+ * Overlays host overrides on a base catalog (both may be partial). `undefined` entries keep the base copy, and a
55
+ * value of the wrong kind (a string for a formatter key, or the reverse) is ignored, so a partial or untyped catalog
56
+ * never blanks a label or throws while rendering.
57
+ */
58
+ export function resolveMessages(base, overrides) {
59
+ if (!overrides)
60
+ return base;
61
+ const formatters = ['dismissNotice', 'pageOf', 'resultCount', 'progressValue', 'reviewAssetOrder', 'amountInAsset', 'availableAmount', 'confirmOrderDescription'];
62
+ const resolved = { ...base };
63
+ for (const [key, value] of Object.entries(overrides)) {
64
+ if (value !== undefined && typeof value === (formatters.includes(key) ? 'function' : 'string'))
65
+ resolved[key] = value;
66
+ }
67
+ return resolved;
68
+ }
@@ -0,0 +1,7 @@
1
+ # @bloxwap/hig/feedback
2
+
3
+ Version 0.2.0, an entry of `@bloxwap/hig`. Root contract imports no React, DOM, RN, audio or device API. Use independent web/native entries and opt in to each channel. Successful API invocation never certifies physical output. See docs/feedback for timing, storage, capability and device verification.
4
+
5
+ `createWebSoundAdapter` passes a per-adapter abort signal to SFX. The signal-aware engine cancels that root's active voices while other roots and host-owned playback continue. The shared default engine remains reference-counted.
6
+
7
+ `createBrowserHapticAdapter` retains its no-import browser fallback and optional `{vibrate}` backend. Hosts using the imperative Haptic API can inject `{canTriggerHaptic, triggerHaptic}`. Capability is probed at request time; iOS imperative output remains unavailable and observation remains false. Browser vibration cancellation is document-wide.
Binary file
@@ -0,0 +1,68 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "exporter": "@bloxwap/sfx 0.1.0 / node-web-audio-api 2.2.0",
4
+ "command": "sfx-wav --out packages/hig/feedback/assets --sounds tick,toggle,success,error --sample-rate 48000 --bit-depth 16 --channels 1 --trim",
5
+ "noise": "Noise recipes can vary; compare duration/envelope/levels, not regenerated bytes. Hashes identify the reviewed committed artifact.",
6
+ "cues": [
7
+ {
8
+ "name": "tick",
9
+ "file": "tick.wav",
10
+ "recipe": "tick",
11
+ "package": "@bloxwap/sfx",
12
+ "packageVersion": "0.1.0",
13
+ "channels": 1,
14
+ "sampleRate": 48000,
15
+ "bitDepth": 16,
16
+ "durationMs": 83.02,
17
+ "peakDbFS": -15.19,
18
+ "rmsDbFS": -40.13,
19
+ "bytes": 8014,
20
+ "sha256": "2a4a100e1bb38a86e4f314bbf6f5254f34d3293d760a051c96fde09f996401c1"
21
+ },
22
+ {
23
+ "name": "toggle",
24
+ "file": "toggle.wav",
25
+ "recipe": "toggle",
26
+ "package": "@bloxwap/sfx",
27
+ "packageVersion": "0.1.0",
28
+ "channels": 1,
29
+ "sampleRate": 48000,
30
+ "bitDepth": 16,
31
+ "durationMs": 113.58,
32
+ "peakDbFS": -18.17,
33
+ "rmsDbFS": -39.27,
34
+ "bytes": 10948,
35
+ "sha256": "6b8c2c0eccd1f3b5ac20adcfd34b6360ecbf59b786cdb02e60c81e7b363a147c"
36
+ },
37
+ {
38
+ "name": "success",
39
+ "file": "success.wav",
40
+ "recipe": "success",
41
+ "package": "@bloxwap/sfx",
42
+ "packageVersion": "0.1.0",
43
+ "channels": 1,
44
+ "sampleRate": 48000,
45
+ "bitDepth": 16,
46
+ "durationMs": 566.92,
47
+ "peakDbFS": -15.46,
48
+ "rmsDbFS": -31.85,
49
+ "bytes": 54468,
50
+ "sha256": "297662685cf37860711fbb54f670e424974905a3c35eb2440d932a1a332b1c1e"
51
+ },
52
+ {
53
+ "name": "error",
54
+ "file": "error.wav",
55
+ "recipe": "error",
56
+ "package": "@bloxwap/sfx",
57
+ "packageVersion": "0.1.0",
58
+ "channels": 1,
59
+ "sampleRate": 48000,
60
+ "bitDepth": 16,
61
+ "durationMs": 314,
62
+ "peakDbFS": -14.98,
63
+ "rmsDbFS": -31.9,
64
+ "bytes": 30188,
65
+ "sha256": "e0b541e34955dbfa32b0146682f1dc1aa6f5cd251318476aabccc25039856ac0"
66
+ }
67
+ ]
68
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1,23 @@
1
+ import type { FeedbackAdapter, FeedbackCapability } from '@bloxwap/hig/contracts/feedback';
2
+ declare const vibrationPatterns: {
3
+ readonly selection: readonly [8];
4
+ readonly success: readonly [30, 60, 40];
5
+ readonly warning: readonly [40, 100, 40];
6
+ readonly error: readonly [40, 40, 40, 40, 40];
7
+ };
8
+ type HapticCue = keyof typeof vibrationPatterns;
9
+ export interface BrowserVibrationBackend {
10
+ vibrate: (pattern: number | number[]) => boolean;
11
+ }
12
+ /** Optional structural bridge to the merged @bloxwap/haptic imperative API; no package import. */
13
+ export interface ImperativeHapticBackend {
14
+ canTriggerHaptic: () => FeedbackCapability;
15
+ triggerHaptic: (cue: HapticCue) => Promise<{
16
+ delivered: boolean;
17
+ mechanism: 'browser-vibration' | 'physical-tap' | 'none';
18
+ reason?: string;
19
+ }>;
20
+ }
21
+ /** Browser vibration for accepted semantic events. iOS imperative haptics remain unavailable. */
22
+ export declare function createBrowserHapticAdapter(backend?: BrowserVibrationBackend | ImperativeHapticBackend): FeedbackAdapter;
23
+ export {};