@fluxus-ui/native 0.0.0-stage → 0.1.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 (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/lib/module/Avatar.js +58 -0
  4. package/lib/module/Avatar.js.map +1 -0
  5. package/lib/module/Badge.js +72 -0
  6. package/lib/module/Badge.js.map +1 -0
  7. package/lib/module/BottomSheet.js +159 -0
  8. package/lib/module/BottomSheet.js.map +1 -0
  9. package/lib/module/Button.js +133 -0
  10. package/lib/module/Button.js.map +1 -0
  11. package/lib/module/Card.js +71 -0
  12. package/lib/module/Card.js.map +1 -0
  13. package/lib/module/Dialog.js +137 -0
  14. package/lib/module/Dialog.js.map +1 -0
  15. package/lib/module/Disclosure.js +153 -0
  16. package/lib/module/Disclosure.js.map +1 -0
  17. package/lib/module/EmptyState.js +43 -0
  18. package/lib/module/EmptyState.js.map +1 -0
  19. package/lib/module/ListItem.js +83 -0
  20. package/lib/module/ListItem.js.map +1 -0
  21. package/lib/module/Menu.js +76 -0
  22. package/lib/module/Menu.js.map +1 -0
  23. package/lib/module/Message.js +51 -0
  24. package/lib/module/Message.js.map +1 -0
  25. package/lib/module/Popover.js +153 -0
  26. package/lib/module/Popover.js.map +1 -0
  27. package/lib/module/Progress.js +54 -0
  28. package/lib/module/Progress.js.map +1 -0
  29. package/lib/module/Select.js +146 -0
  30. package/lib/module/Select.js.map +1 -0
  31. package/lib/module/Skeleton.js +39 -0
  32. package/lib/module/Skeleton.js.map +1 -0
  33. package/lib/module/Slider.js +137 -0
  34. package/lib/module/Slider.js.map +1 -0
  35. package/lib/module/Spinner.js +30 -0
  36. package/lib/module/Spinner.js.map +1 -0
  37. package/lib/module/Swap.js +87 -0
  38. package/lib/module/Swap.js.map +1 -0
  39. package/lib/module/Tabs.js +118 -0
  40. package/lib/module/Tabs.js.map +1 -0
  41. package/lib/module/Text.js +47 -0
  42. package/lib/module/Text.js.map +1 -0
  43. package/lib/module/TextField.js +190 -0
  44. package/lib/module/TextField.js.map +1 -0
  45. package/lib/module/Toast.js +108 -0
  46. package/lib/module/Toast.js.map +1 -0
  47. package/lib/module/blur.js +55 -0
  48. package/lib/module/blur.js.map +1 -0
  49. package/lib/module/controls.js +259 -0
  50. package/lib/module/controls.js.map +1 -0
  51. package/lib/module/generated/tokens.js +484 -0
  52. package/lib/module/generated/tokens.js.map +1 -0
  53. package/lib/module/icon.js +51 -0
  54. package/lib/module/icon.js.map +1 -0
  55. package/lib/module/index.js +33 -0
  56. package/lib/module/index.js.map +1 -0
  57. package/lib/module/layout.js +75 -0
  58. package/lib/module/layout.js.map +1 -0
  59. package/lib/module/motion.js +28 -0
  60. package/lib/module/motion.js.map +1 -0
  61. package/lib/module/overlay.js +99 -0
  62. package/lib/module/overlay.js.map +1 -0
  63. package/lib/module/package.json +1 -0
  64. package/lib/module/pending.js +177 -0
  65. package/lib/module/pending.js.map +1 -0
  66. package/lib/module/presence.js +68 -0
  67. package/lib/module/presence.js.map +1 -0
  68. package/lib/module/press.js +32 -0
  69. package/lib/module/press.js.map +1 -0
  70. package/lib/module/screen.js +45 -0
  71. package/lib/module/screen.js.map +1 -0
  72. package/lib/module/theme.js +41 -0
  73. package/lib/module/theme.js.map +1 -0
  74. package/lib/typescript/Avatar.d.ts +17 -0
  75. package/lib/typescript/Avatar.d.ts.map +1 -0
  76. package/lib/typescript/Badge.d.ts +21 -0
  77. package/lib/typescript/Badge.d.ts.map +1 -0
  78. package/lib/typescript/BottomSheet.d.ts +27 -0
  79. package/lib/typescript/BottomSheet.d.ts.map +1 -0
  80. package/lib/typescript/Button.d.ts +27 -0
  81. package/lib/typescript/Button.d.ts.map +1 -0
  82. package/lib/typescript/Card.d.ts +17 -0
  83. package/lib/typescript/Card.d.ts.map +1 -0
  84. package/lib/typescript/Dialog.d.ts +34 -0
  85. package/lib/typescript/Dialog.d.ts.map +1 -0
  86. package/lib/typescript/Disclosure.d.ts +39 -0
  87. package/lib/typescript/Disclosure.d.ts.map +1 -0
  88. package/lib/typescript/EmptyState.d.ts +12 -0
  89. package/lib/typescript/EmptyState.d.ts.map +1 -0
  90. package/lib/typescript/ListItem.d.ts +20 -0
  91. package/lib/typescript/ListItem.d.ts.map +1 -0
  92. package/lib/typescript/Menu.d.ts +23 -0
  93. package/lib/typescript/Menu.d.ts.map +1 -0
  94. package/lib/typescript/Message.d.ts +14 -0
  95. package/lib/typescript/Message.d.ts.map +1 -0
  96. package/lib/typescript/Popover.d.ts +71 -0
  97. package/lib/typescript/Popover.d.ts.map +1 -0
  98. package/lib/typescript/Progress.d.ts +12 -0
  99. package/lib/typescript/Progress.d.ts.map +1 -0
  100. package/lib/typescript/Select.d.ts +30 -0
  101. package/lib/typescript/Select.d.ts.map +1 -0
  102. package/lib/typescript/Skeleton.d.ts +13 -0
  103. package/lib/typescript/Skeleton.d.ts.map +1 -0
  104. package/lib/typescript/Slider.d.ts +21 -0
  105. package/lib/typescript/Slider.d.ts.map +1 -0
  106. package/lib/typescript/Spinner.d.ts +12 -0
  107. package/lib/typescript/Spinner.d.ts.map +1 -0
  108. package/lib/typescript/Swap.d.ts +25 -0
  109. package/lib/typescript/Swap.d.ts.map +1 -0
  110. package/lib/typescript/Tabs.d.ts +18 -0
  111. package/lib/typescript/Tabs.d.ts.map +1 -0
  112. package/lib/typescript/Text.d.ts +20 -0
  113. package/lib/typescript/Text.d.ts.map +1 -0
  114. package/lib/typescript/TextField.d.ts +36 -0
  115. package/lib/typescript/TextField.d.ts.map +1 -0
  116. package/lib/typescript/Toast.d.ts +25 -0
  117. package/lib/typescript/Toast.d.ts.map +1 -0
  118. package/lib/typescript/blur.d.ts +4 -0
  119. package/lib/typescript/blur.d.ts.map +1 -0
  120. package/lib/typescript/controls.d.ts +37 -0
  121. package/lib/typescript/controls.d.ts.map +1 -0
  122. package/lib/typescript/generated/tokens.d.ts +499 -0
  123. package/lib/typescript/generated/tokens.d.ts.map +1 -0
  124. package/lib/typescript/icon.d.ts +25 -0
  125. package/lib/typescript/icon.d.ts.map +1 -0
  126. package/lib/typescript/index.d.ts +31 -0
  127. package/lib/typescript/index.d.ts.map +1 -0
  128. package/lib/typescript/layout.d.ts +24 -0
  129. package/lib/typescript/layout.d.ts.map +1 -0
  130. package/lib/typescript/motion.d.ts +7 -0
  131. package/lib/typescript/motion.d.ts.map +1 -0
  132. package/lib/typescript/overlay.d.ts +33 -0
  133. package/lib/typescript/overlay.d.ts.map +1 -0
  134. package/lib/typescript/package.json +1 -0
  135. package/lib/typescript/pending.d.ts +25 -0
  136. package/lib/typescript/pending.d.ts.map +1 -0
  137. package/lib/typescript/presence.d.ts +37 -0
  138. package/lib/typescript/presence.d.ts.map +1 -0
  139. package/lib/typescript/press.d.ts +12 -0
  140. package/lib/typescript/press.d.ts.map +1 -0
  141. package/lib/typescript/screen.d.ts +16 -0
  142. package/lib/typescript/screen.d.ts.map +1 -0
  143. package/lib/typescript/theme.d.ts +32 -0
  144. package/lib/typescript/theme.d.ts.map +1 -0
  145. package/package.json +100 -3
  146. package/src/Avatar.tsx +44 -0
  147. package/src/Badge.tsx +45 -0
  148. package/src/BottomSheet.tsx +109 -0
  149. package/src/Button.tsx +117 -0
  150. package/src/Card.tsx +65 -0
  151. package/src/Dialog.tsx +93 -0
  152. package/src/Disclosure.tsx +108 -0
  153. package/src/EmptyState.tsx +32 -0
  154. package/src/ListItem.tsx +73 -0
  155. package/src/Menu.tsx +57 -0
  156. package/src/Message.tsx +43 -0
  157. package/src/Popover.tsx +145 -0
  158. package/src/Progress.tsx +33 -0
  159. package/src/Select.tsx +118 -0
  160. package/src/Skeleton.tsx +27 -0
  161. package/src/Slider.tsx +107 -0
  162. package/src/Spinner.tsx +18 -0
  163. package/src/Swap.tsx +74 -0
  164. package/src/Tabs.tsx +84 -0
  165. package/src/Text.tsx +44 -0
  166. package/src/TextField.tsx +137 -0
  167. package/src/Toast.tsx +94 -0
  168. package/src/blur.tsx +33 -0
  169. package/src/controls.tsx +196 -0
  170. package/src/generated/tokens.ts +653 -0
  171. package/src/icon.tsx +39 -0
  172. package/src/index.ts +30 -0
  173. package/src/layout.tsx +40 -0
  174. package/src/motion.ts +22 -0
  175. package/src/overlay.tsx +77 -0
  176. package/src/pending.tsx +131 -0
  177. package/src/presence.tsx +65 -0
  178. package/src/press.ts +23 -0
  179. package/src/screen.tsx +32 -0
  180. package/src/theme.tsx +49 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/motion.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAoB,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC;AACtD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC;AAErD,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,EAAE,SAAQ,YAAuB,KAAG,MAGpE,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,EAAE,WAAU,aAAwB,EAAE,SAAQ,WAAwB,KAAG,MAIzG,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What opens above everything: a window of React Native (`Modal`) that paints and moves nothing of its own,
3
+ * where Fluxus draws the veil and moves the panel. Back on Android, Escape in a browser and the scrub of
4
+ * VoiceOver close it. (SPEC §15.8)
5
+ */
6
+ import { type ReactNode } from 'react';
7
+ import { type ViewStyle } from 'react-native';
8
+ import { type SharedValue } from 'react-native-reanimated';
9
+ import { type Theme } from './theme.js';
10
+ /** A screen reader goes to it: to the title on opening, back to what opened it on closing. */
11
+ export declare const focusOn: (target: unknown) => void;
12
+ /** The surface of what floats: raised, edged, and with the one shadow of the package. */
13
+ export declare const floating: (theme: Theme) => ViewStyle;
14
+ /** `mounted` outlives `open` by the time it takes to go; `t` goes 0 → 1 as it comes and back as it goes. */
15
+ export declare function useOverlay(open: boolean): {
16
+ mounted: boolean;
17
+ t: SharedValue<number>;
18
+ };
19
+ export interface OverlayProps {
20
+ open: boolean;
21
+ /** Back on Android, Escape in a browser, the scrub of VoiceOver, and a press outside if `dismissible`. */
22
+ onClose: () => void;
23
+ /** It darkens what is behind. Default: true. */
24
+ veil?: boolean;
25
+ /** A press outside closes it. Default: true. */
26
+ dismissible?: boolean;
27
+ /** Once the window is on the screen. */
28
+ onShow?: () => void;
29
+ /** The panel, given `t`, in a box as big as the screen. */
30
+ children: (t: SharedValue<number>) => ReactNode;
31
+ }
32
+ export declare function Overlay({ open, onClose, veil, dismissible, onShow, children }: OverlayProps): import("react").JSX.Element | null;
33
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/overlay.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAsF,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAClI,OAAiB,EAAsD,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGzH,OAAO,EAAY,KAAK,KAAK,EAAE,MAAM,YAAS,CAAC;AAG/C,8FAA8F;AAC9F,eAAO,MAAM,OAAO,GAAI,QAAQ,OAAO,KAAG,IAEzC,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,KAAG,SAMtC,CAAC;AAEH,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAetF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,0GAA0G;IAC1G,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;CACjD;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAW,EAAE,WAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,YAAY,sCAiBzG"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The wait is born from the finger, as on the web (core/src/pending.ts, SPEC §14.35): what was pressed and now
3
+ * waits fills slowly from where it was touched, never to the whole; when the answer comes it fills and goes,
4
+ * and if it failed it drains back to the finger. A wait shorter than 150 ms shows nothing; once seen, it lasts
5
+ * 400 ms at least. (SPEC §15.6, §15.9)
6
+ */
7
+ import { type ReactNode } from 'react';
8
+ import type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';
9
+ /**
10
+ * `onPress` may return a promise: until it settles, what was pressed waits. If it is rejected, it failed: the
11
+ * third value is true until the next press. The rejection goes no further: the app has its own `catch`.
12
+ */
13
+ export declare function useAsyncPress<E>(onPress: ((event: E) => unknown) | null | undefined): [waiting: boolean, run: (event: E) => void, failed: boolean];
14
+ /** `done` runs once `result` is fulfilled if it is a promise, and at once if it is not. If it fails, it does not run. */
15
+ export declare function settle(result: unknown, done: () => void): void | Promise<void>;
16
+ /**
17
+ * For what is pressed and may wait. Give it `onPressIn` and `onLayout`, put `fill` first inside it, and clip it
18
+ * (`overflow: 'hidden'`). `ink` is the colour of its text; `failed`, whether the wait that ends now did.
19
+ */
20
+ export declare function usePending(waiting: boolean, ink: string, failed?: boolean): {
21
+ onPressIn: (e: GestureResponderEvent) => void;
22
+ onLayout: (e: LayoutChangeEvent) => void;
23
+ fill: ReactNode;
24
+ };
25
+ //# sourceMappingURL=pending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../src/pending.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAU7E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAmBlJ;AAED,yHAAyH;AACzH,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9E;AA+BD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAgDtL"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Nothing jumps: what comes fades in as it rises, what goes fades out, and what
3
+ * stays glides to its new place. The values of the web (core/src/stagger.ts),
4
+ * on the layout animations of Reanimated. With reduced motion on in the system
5
+ * they are immediate. (SPEC §15.4)
6
+ */
7
+ import type { ComponentRef, Ref } from 'react';
8
+ import { type ViewProps } from 'react-native';
9
+ import Animated, { FadeInDown, FadeOut, LinearTransition } from 'react-native-reanimated';
10
+ /** How far it rises as it comes, and how long the nth of a group waits for the one before. */
11
+ export declare const RISE = 12;
12
+ export declare const STAGGER = 70;
13
+ /** For `entering`: it fades in as it rises; `index` is its place in a group that comes together. */
14
+ export declare const enter: (index?: number) => FadeInDown;
15
+ /** For `exiting`: it fades out, fast. */
16
+ export declare const exit: () => FadeOut;
17
+ /** For `layout`: it glides to where it is now, on the smooth spring. */
18
+ export declare const shift: () => LinearTransition;
19
+ interface Presence {
20
+ entering: ReturnType<typeof enter>;
21
+ exiting: ReturnType<typeof exit>;
22
+ layout: ReturnType<typeof shift>;
23
+ }
24
+ /**
25
+ * The three, for a view that comes, goes and moves. In a browser they are off: there Reanimated pins a view
26
+ * that has them where it first was (`position: absolute`, seen with 4.7.1), and the layout breaks.
27
+ */
28
+ export declare const presence: (index?: number) => Partial<Presence>;
29
+ export interface AppearProps extends ViewProps {
30
+ /** Its place in a group that comes together: each waits a little for the one before. */
31
+ index?: number;
32
+ ref?: Ref<ComponentRef<typeof Animated.View>>;
33
+ }
34
+ /** A view that comes, goes and moves without a jump. Its siblings glide too when each is an Appear. */
35
+ export declare function Appear({ index, ...rest }: AppearProps): import("react").JSX.Element;
36
+ export {};
37
+ //# sourceMappingURL=presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/presence.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,QAAQ,EAAE,EAAU,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAgB,MAAM,yBAAyB,CAAC;AAOhH,8FAA8F;AAC9F,eAAO,MAAM,IAAI,KAAK,CAAC;AACvB,eAAO,MAAM,OAAO,KAAK,CAAC;AAE1B,oGAAoG;AACpG,eAAO,MAAM,KAAK,GAAI,cAAS,eAKO,CAAC;AAEvC,yCAAyC;AACzC,eAAO,MAAM,IAAI,eAA6G,CAAC;AAE/H,wEAAwE;AACxE,eAAO,MAAM,KAAK,wBAGjB,CAAC;AAEF,UAAU,QAAQ;IAChB,QAAQ,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;IACnC,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;IACjC,MAAM,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;CAClC;AAGD;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,cAAS,KAAG,OAAO,CAAC,QAAQ,CAMpD,CAAC;AAEF,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;CAC/C;AAED,uGAAuG;AACvG,wBAAgB,MAAM,CAAC,EAAE,KAAS,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,+BAEzD"}
@@ -0,0 +1,12 @@
1
+ import type { GestureResponderEvent, PressableProps } from 'react-native';
2
+ /** The style and the two handlers of something that gives when pressed; the handlers of the app still run. */
3
+ export declare function usePress({ onPressIn, onPressOut }: Pick<PressableProps, 'onPressIn' | 'onPressOut'>): {
4
+ style: import("react-native-reanimated/lib/typescript/hook/commonTypes").AnimatedStyleHandle<{
5
+ transform: {
6
+ scale: number;
7
+ }[];
8
+ }>;
9
+ onPressIn: (e: GestureResponderEvent) => void;
10
+ onPressOut: (e: GestureResponderEvent) => void;
11
+ };
12
+ //# sourceMappingURL=press.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/press.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAO1E,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,YAAY,CAAC;;;;;;mBAKjF,qBAAqB;oBAIpB,qBAAqB;EAKxC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `@fluxus-ui/native/screen`: the ground of a screen, inside the safe area. Its own entry, so that an app that
3
+ * lays out its screens some other way does not need react-native-safe-area-context. (SPEC §15.5)
4
+ */
5
+ import { type ViewProps } from 'react-native';
6
+ import { type Edge } from 'react-native-safe-area-context';
7
+ export interface ScreenProps extends ViewProps {
8
+ /** It scrolls, and the keyboard does not cover the field in use. */
9
+ scroll?: boolean;
10
+ /** Which sides keep clear of the notch and the bars. Default: all. With a header or a tab bar, leave theirs out. */
11
+ edges?: readonly Edge[];
12
+ /** The gutter of the theme around what it holds, and its gap between. Default: true. */
13
+ padded?: boolean;
14
+ }
15
+ export declare function Screen({ scroll, edges, padded, style, children, ...rest }: ScreenProps): import("react").JSX.Element;
16
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/screen.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAGzE,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,oEAAoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oHAAoH;IACpH,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IACxB,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,MAAM,CAAC,EAAE,MAAc,EAAE,KAAK,EAAE,MAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,+BAcrG"}
@@ -0,0 +1,32 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ThemeTokens } from './generated/tokens.js';
3
+ export type Mode = 'light' | 'dark';
4
+ /**
5
+ * The faces the app loaded (with expo-font, or linked), by weight. With a face for a weight, text takes
6
+ * that family and no `fontWeight`: Android would thicken it again. Without, the regular one and the weight.
7
+ */
8
+ export interface Fonts {
9
+ regular: string;
10
+ medium?: string;
11
+ bold?: string;
12
+ }
13
+ /** A theme in one mode: what a component reads. `Theme<typeof theme>` has the tokens of the app too, by name. */
14
+ export type Theme<T extends ThemeTokens = ThemeTokens> = Omit<T, 'color'> & {
15
+ mode: Mode;
16
+ color: T['color']['light'];
17
+ /** Without it, the font of the system. */
18
+ font?: Fonts;
19
+ };
20
+ export interface ThemeProviderProps {
21
+ /** Default: the base theme. */
22
+ theme?: ThemeTokens;
23
+ /** Default: what the system says. */
24
+ mode?: Mode;
25
+ /** Default: the font of the system. */
26
+ fonts?: Fonts;
27
+ children?: ReactNode;
28
+ }
29
+ export declare function ThemeProvider({ theme, mode, fonts, children }: ThemeProviderProps): import("react").JSX.Element;
30
+ /** The theme, in the mode it is in. `useTheme<typeof theme>()` gives the app its own tokens (`app.…`), checked by name. */
31
+ export declare function useTheme<T extends ThemeTokens = ThemeTokens>(): Theme<T>;
32
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,uBAAoB,CAAC;AAE9D,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iHAAiH;AACjH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAC1E,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3B,0CAA0C;IAC1C,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAIF,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qCAAqC;IACrC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,uCAAuC;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAmB,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,kBAAkB,+BAK/F;AAED,2HAA2H;AAC3H,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAIxE"}
package/package.json CHANGED
@@ -1,6 +1,103 @@
1
1
  {
2
2
  "name": "@fluxus-ui/native",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Fluxus for React Native: the same tokens and motion vocabulary, on Reanimated.",
5
+ "license": "MIT",
6
+ "author": "Jhony0709 (https://github.com/Jhony0709)",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Jhony0709/fluxus.git",
10
+ "directory": "packages/native"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "sideEffects": false,
16
+ "main": "./lib/module/index.js",
17
+ "types": "./lib/typescript/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./lib/typescript/index.d.ts",
21
+ "default": "./lib/module/index.js"
22
+ },
23
+ "./icon": {
24
+ "types": "./lib/typescript/icon.d.ts",
25
+ "default": "./lib/module/icon.js"
26
+ },
27
+ "./screen": {
28
+ "types": "./lib/typescript/screen.d.ts",
29
+ "default": "./lib/module/screen.js"
30
+ },
31
+ "./blur": {
32
+ "types": "./lib/typescript/blur.d.ts",
33
+ "default": "./lib/module/blur.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "lib",
39
+ "src"
40
+ ],
41
+ "peerDependencies": {
42
+ "expo-blur": ">=58",
43
+ "react": ">=19",
44
+ "react-native": ">=0.86",
45
+ "react-native-reanimated": ">=4.5",
46
+ "react-native-safe-area-context": ">=5",
47
+ "react-native-svg": ">=15",
48
+ "react-native-worklets": ">=0.10"
49
+ },
50
+ "devDependencies": {
51
+ "@babel/core": "^7.29.13",
52
+ "@react-native/babel-preset": "0.88.1",
53
+ "@react-native/jest-preset": "0.88.1",
54
+ "@testing-library/react-native": "14.1.0",
55
+ "@types/jest": "^29.5.14",
56
+ "@types/react": "^19.3.3",
57
+ "expo-blur": "~58.0.6",
58
+ "jest": "^29.7.0",
59
+ "react": "19.3.0",
60
+ "react-native": "0.88.1",
61
+ "react-native-builder-bob": "^0.44.1",
62
+ "react-native-reanimated": "4.8.0",
63
+ "react-native-safe-area-context": "~5.11.1",
64
+ "react-native-svg": "15.16.0",
65
+ "react-native-worklets": "0.14.0",
66
+ "test-renderer": "^1.3.1",
67
+ "typescript": "^5.9.3"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "react-native-safe-area-context": {
71
+ "optional": true
72
+ },
73
+ "react-native-svg": {
74
+ "optional": true
75
+ },
76
+ "expo-blur": {
77
+ "optional": true
78
+ }
79
+ },
80
+ "react-native-builder-bob": {
81
+ "source": "src",
82
+ "output": "lib",
83
+ "targets": [
84
+ [
85
+ "module",
86
+ {
87
+ "esm": true
88
+ }
89
+ ],
90
+ [
91
+ "typescript",
92
+ {
93
+ "project": "tsconfig.build.json"
94
+ }
95
+ ]
96
+ ]
97
+ },
98
+ "scripts": {
99
+ "build": "bob build",
100
+ "typecheck": "tsc --noEmit",
101
+ "test": "jest"
102
+ }
6
103
  }
package/src/Avatar.tsx ADDED
@@ -0,0 +1,44 @@
1
+ import { Image, View, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
2
+ import { Text } from './Text';
3
+ import { useTheme } from './theme';
4
+
5
+ export interface AvatarProps extends Omit<ViewProps, 'style' | 'children'> {
6
+ /** Gives the initials. */
7
+ name: string;
8
+ /** A picture over the initials. */
9
+ src?: string;
10
+ /** Who it is, for a screen reader. Without it the avatar is decoration: the name is usually beside it. */
11
+ label?: string;
12
+ /** Default: 'md'. */
13
+ size?: 'sm' | 'md' | 'lg';
14
+ style?: StyleProp<ViewStyle>;
15
+ }
16
+
17
+ /** As the web: the first letter of the first two words that start with a letter or a figure. */
18
+ export const initials = (name: string): string =>
19
+ name
20
+ .trim()
21
+ .split(/\s+/)
22
+ .filter((w) => /^[\p{L}\p{N}]/u.test(w))
23
+ .slice(0, 2)
24
+ .map((w) => Array.from(w)[0] ?? '')
25
+ .join('')
26
+ .toUpperCase();
27
+
28
+ /** Who someone is, in a circle: the picture, or the initials. */
29
+ export function Avatar({ name, src, label, size = 'md', style, ...rest }: AvatarProps) {
30
+ const theme = useTheme();
31
+ const side = theme.size[`control.h.${size}`];
32
+ const a11y = label ? ({ accessible: true, role: 'img', 'aria-label': label } as const) : ({ 'aria-hidden': true, importantForAccessibility: 'no-hide-descendants' } as const);
33
+ return (
34
+ <View {...a11y} {...rest} style={[{ width: side, height: side, borderRadius: side, alignItems: 'center', justifyContent: 'center', overflow: 'hidden', backgroundColor: theme.color['accent.subtle'] }, style]}>
35
+ {src ? (
36
+ <Image source={{ uri: src }} style={{ width: side, height: side }} />
37
+ ) : (
38
+ <Text variant={size === 'sm' ? 'caption' : 'label'} weight="medium" tone="accent" allowFontScaling={false}>
39
+ {initials(name)}
40
+ </Text>
41
+ )}
42
+ </View>
43
+ );
44
+ }
package/src/Badge.tsx ADDED
@@ -0,0 +1,45 @@
1
+ import type { ReactNode } from 'react';
2
+ import { View, type StyleProp, type ViewProps, type ViewStyle } from 'react-native';
3
+ import { Text } from './Text';
4
+ import { useTheme, type Theme } from './theme';
5
+
6
+ export type Tone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger' | 'info';
7
+
8
+ export interface BadgeProps extends Omit<ViewProps, 'style'> {
9
+ children: ReactNode;
10
+ /** Default: 'neutral'. */
11
+ tone?: Tone;
12
+ /** 'dot': a point of the tone before the text, on a quiet ground. Default: 'tint'. */
13
+ look?: 'tint' | 'dot';
14
+ style?: StyleProp<ViewStyle>;
15
+ }
16
+
17
+ /** The ground, the ink and the solid colour of a tone. */
18
+ export function toneColors(theme: Theme, tone: Tone = 'neutral'): { subtle: string; ink: string; solid: string } {
19
+ const c = theme.color;
20
+ if (tone === 'neutral') return { subtle: c['surface.sunken'], ink: c['text.muted'], solid: c['text.muted'] };
21
+ if (tone === 'accent') return { subtle: c['accent.subtle'], ink: c['text.accent'], solid: c['accent.default'] };
22
+ return { subtle: c[`state.${tone}.subtle`], ink: c[`state.${tone}.text`], solid: c[`state.${tone}.solid`] };
23
+ }
24
+
25
+ /** A state in a word. The tone is never the only thing that says it: the text does. */
26
+ export function Badge({ children, tone = 'neutral', look = 'tint', style, ...rest }: BadgeProps) {
27
+ const theme = useTheme();
28
+ const { subtle, ink, solid } = toneColors(theme, tone);
29
+ const dot = look === 'dot';
30
+ const size = theme.size['space.2'];
31
+ return (
32
+ <View
33
+ {...rest}
34
+ style={[
35
+ { flexDirection: 'row', alignItems: 'center', alignSelf: 'flex-start', gap: theme.size['space.1'], paddingHorizontal: theme.size['space.2'], paddingVertical: theme.size['space.1'] / 2, borderRadius: theme.size['radius.pill'], backgroundColor: dot ? theme.color['surface.sunken'] : subtle },
36
+ style,
37
+ ]}
38
+ >
39
+ {dot && <View style={{ width: size, height: size, borderRadius: size, backgroundColor: solid }} />}
40
+ <Text variant="caption" weight="medium" style={{ color: dot ? theme.color['text.default'] : ink }}>
41
+ {children}
42
+ </Text>
43
+ </View>
44
+ );
45
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * A sheet that rises from the bottom, moved only by its transform. As tall as what it holds, up to nine tenths
3
+ * of the screen. Dragged down from its header, it goes; so it does with its handle, which is a button with a
4
+ * name for whoever cannot drag. (SPEC §15.8)
5
+ */
6
+ import { useRef, useState, type ComponentRef, type ReactNode, type RefObject } from 'react';
7
+ import { PanResponder, Pressable, ScrollView, Text as NativeText, useWindowDimensions, View } from 'react-native';
8
+ import Animated, { useAnimatedStyle, useSharedValue, type SharedValue } from 'react-native-reanimated';
9
+ import { spring } from './motion';
10
+ import { floating, focusOn, Overlay } from './overlay';
11
+ import { Text } from './Text';
12
+ import { useTheme } from './theme';
13
+
14
+ /** How much of the screen it may take, how far down it must be let go to close, and how fast a flick is. */
15
+ const TALLEST = 0.9;
16
+ const CLOSE_AT = 0.3;
17
+ const FLICK = 0.8;
18
+
19
+ export interface BottomSheetProps {
20
+ open: boolean;
21
+ /** A press outside, back, the handle, or dragging it down. */
22
+ onClose: () => void;
23
+ /** Its name: at the top, and what a screen reader hears on opening. */
24
+ title: string;
25
+ /** The title is only for a screen reader. */
26
+ titleHidden?: boolean;
27
+ children?: ReactNode;
28
+ /** What the bottom edge of the screen takes: the safe area of the app. It is added to its own padding. Default: 0. */
29
+ inset?: number;
30
+ /** The name of the handle, for a screen reader. Default: 'Close'. */
31
+ closeLabel?: string;
32
+ /** A press outside or a drag closes it, and it has a handle. Default: true. Back always closes. */
33
+ dismissible?: boolean;
34
+ /** What does not fit scrolls. Default: true; false when what it holds scrolls by itself. */
35
+ scroll?: boolean;
36
+ testID?: string;
37
+ }
38
+
39
+ function Sheet({ t, onClose, title, titleHidden, children, inset, closeLabel = 'Close', dismissible = true, scroll = true, testID, heading }: Omit<BottomSheetProps, 'open'> & { t: SharedValue<number>; heading: RefObject<ComponentRef<typeof NativeText> | null> }) {
40
+ const theme = useTheme();
41
+ const { height: screen } = useWindowDimensions();
42
+ const [height, setHeight] = useState(0);
43
+ const drag = useSharedValue(0);
44
+ // Until it is measured it waits below the screen, wherever that is.
45
+ const far = height || screen;
46
+ const rise = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * far + drag.value }] }));
47
+ const latest = useRef({ height, onClose });
48
+ latest.current = { height, onClose };
49
+ const [pan] = useState(() =>
50
+ PanResponder.create({
51
+ // Only a drag down, and only from the header: what it holds may scroll.
52
+ onMoveShouldSetPanResponder: (_, g) => g.dy > 4 && g.dy > Math.abs(g.dx),
53
+ onPanResponderMove: (_, g) => {
54
+ drag.value = Math.max(0, g.dy);
55
+ },
56
+ onPanResponderRelease: (_, g) => {
57
+ if (g.dy > latest.current.height * CLOSE_AT || g.vy > FLICK) latest.current.onClose();
58
+ else drag.value = spring(0, 'snappy');
59
+ },
60
+ onPanResponderTerminate: () => {
61
+ drag.value = spring(0, 'snappy');
62
+ },
63
+ }),
64
+ );
65
+ const radius = theme.size['radius.card'];
66
+ const pad = theme.size['space.4'];
67
+ const body = <View style={{ paddingInline: pad, paddingBottom: pad + (inset ?? 0) }}>{children}</View>;
68
+ return (
69
+ <Animated.View
70
+ role="dialog"
71
+ aria-modal
72
+ accessibilityViewIsModal
73
+ aria-label={title}
74
+ testID={testID}
75
+ onLayout={(e) => setHeight(e.nativeEvent.layout.height)}
76
+ style={[floating(theme), { position: 'absolute', start: 0, end: 0, bottom: 0, maxHeight: screen * TALLEST, borderBottomWidth: 0, borderBottomStartRadius: 0, borderBottomEndRadius: 0, borderTopStartRadius: radius, borderTopEndRadius: radius }, rise]}
77
+ >
78
+ <View {...(dismissible ? pan.panHandlers : null)} style={{ paddingInline: pad, paddingBottom: theme.size['space.3'] }}>
79
+ {dismissible && (
80
+ <Pressable role="button" aria-label={closeLabel} onPress={onClose} hitSlop={theme.size['space.3']} style={{ alignSelf: 'center', paddingBlock: theme.size['space.2'] }}>
81
+ <View style={{ width: theme.size['space.10'], height: theme.size['space.1'], borderRadius: theme.size['space.1'], backgroundColor: theme.color['border.strong'] }} />
82
+ </Pressable>
83
+ )}
84
+ {!titleHidden && (
85
+ // Not selectable: in a browser, a drag that selects text is not a drag of the sheet.
86
+ <Text ref={heading} variant="title" selectable={false} style={dismissible ? null : { paddingTop: pad }}>
87
+ {title}
88
+ </Text>
89
+ )}
90
+ </View>
91
+ {scroll ? (
92
+ <ScrollView bounces={false} keyboardShouldPersistTaps="handled">
93
+ {body}
94
+ </ScrollView>
95
+ ) : (
96
+ body
97
+ )}
98
+ </Animated.View>
99
+ );
100
+ }
101
+
102
+ export function BottomSheet({ open, onClose, dismissible = true, ...rest }: BottomSheetProps) {
103
+ const heading = useRef<ComponentRef<typeof NativeText>>(null);
104
+ return (
105
+ <Overlay open={open} onClose={onClose} dismissible={dismissible} onShow={() => focusOn(heading.current)}>
106
+ {(t) => <Sheet t={t} onClose={onClose} dismissible={dismissible} heading={heading} {...rest} />}
107
+ </Overlay>
108
+ );
109
+ }
package/src/Button.tsx ADDED
@@ -0,0 +1,117 @@
1
+ import { useState, type ComponentRef, type ReactNode, type Ref } from 'react';
2
+ import { ActivityIndicator, Pressable, type GestureResponderEvent, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
3
+ import Animated from 'react-native-reanimated';
4
+ import { useAsyncPress, usePending } from './pending';
5
+ import { presence } from './presence';
6
+ import { usePress } from './press';
7
+ import { Text } from './Text';
8
+ import { useTheme, type Theme } from './theme';
9
+
10
+ export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
11
+ export type ButtonSize = 'sm' | 'md' | 'lg';
12
+
13
+ export interface ButtonProps extends Omit<PressableProps, 'children' | 'style' | 'ref' | 'onPress'> {
14
+ /** If it returns a promise, the button waits for it: it fills from where it was pressed and takes no other press. */
15
+ onPress?: (event: GestureResponderEvent) => void | Promise<unknown>;
16
+ children: ReactNode;
17
+ /** Default: 'secondary'. */
18
+ variant?: ButtonVariant;
19
+ /** Default: 'md'. */
20
+ size?: ButtonSize;
21
+ /** It is working: it shows a spinner, says so to a screen reader and takes no press. */
22
+ busy?: boolean;
23
+ style?: StyleProp<ViewStyle>;
24
+ ref?: Ref<ComponentRef<typeof Pressable>>;
25
+ }
26
+
27
+ const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
28
+
29
+ /** The surface, the ink and the edge of a variant, and the box of a size: only tokens. */
30
+ export function buttonStyle(theme: Theme, variant: ButtonVariant = 'secondary', size: ButtonSize = 'md'): { box: ViewStyle; ink: string; slop: number } {
31
+ const c = theme.color;
32
+ const [surface, ink, edge] = {
33
+ primary: [c['button.bg'], c['button.fg'], 'transparent'],
34
+ secondary: [c['surface.raised'], c['text.default'], c['border.control']],
35
+ ghost: ['transparent', c['text.default'], 'transparent'],
36
+ danger: [c['state.danger.subtle'], c['state.danger.text'], 'transparent'],
37
+ }[variant] as [string, string, string];
38
+ const height = theme.size[`control.h.${size}`];
39
+ return {
40
+ box: {
41
+ // A minimum, not a height: the text grows with the system's text size.
42
+ minHeight: height,
43
+ flexDirection: 'row',
44
+ alignItems: 'center',
45
+ justifyContent: 'center',
46
+ gap: theme.size['space.2'],
47
+ paddingHorizontal: theme.size['pad.control-x'],
48
+ borderWidth: 1,
49
+ borderColor: edge,
50
+ borderRadius: theme.size['button.radius'],
51
+ backgroundColor: surface,
52
+ },
53
+ ink,
54
+ // A small button is still a target of target.min: the rest is around it.
55
+ slop: Math.max(0, (theme.size['target.min'] - height) / 2),
56
+ };
57
+ }
58
+
59
+ /** A button with the variants and sizes of the web; pressed, it gives on the snappy spring. */
60
+ export function Button({ children, variant = 'secondary', size = 'md', busy = false, disabled, style, onPress, onPressIn, onPressOut, onLayout, onFocus, onBlur, ...rest }: ButtonProps) {
61
+ const theme = useTheme();
62
+ const { box, ink, slop } = buttonStyle(theme, variant, size);
63
+ const [waiting, run, failed] = useAsyncPress(onPress);
64
+ const pending = usePending(waiting, ink, failed);
65
+ const off = !!disabled || busy || waiting;
66
+ const press = usePress({ onPressIn, onPressOut });
67
+ const { layout, ...coming } = presence();
68
+ // With a keyboard or a remote: a ring around it, drawn outside so that nothing moves.
69
+ const [focused, setFocused] = useState(false);
70
+ const ring: ViewStyle | null = focused ? { outlineStyle: 'solid', outlineWidth: theme.size['focus.width'], outlineOffset: theme.size['focus.offset'], outlineColor: theme.color['focus.ring'] } : null;
71
+ return (
72
+ <AnimatedPressable
73
+ role="button"
74
+ hitSlop={slop}
75
+ {...rest}
76
+ disabled={off}
77
+ aria-disabled={off}
78
+ aria-busy={busy || waiting}
79
+ onPress={run}
80
+ onLayout={(e) => {
81
+ pending.onLayout(e);
82
+ onLayout?.(e);
83
+ }}
84
+ onPressIn={(e) => {
85
+ pending.onPressIn(e);
86
+ press.onPressIn(e);
87
+ }}
88
+ onPressOut={press.onPressOut}
89
+ onFocus={(e) => {
90
+ setFocused(true);
91
+ onFocus?.(e);
92
+ }}
93
+ onBlur={(e) => {
94
+ setFocused(false);
95
+ onBlur?.(e);
96
+ }}
97
+ style={[box, { overflow: 'hidden' }, disabled ? { opacity: 0.5 } : null, ring, style, press.style]}
98
+ >
99
+ {pending.fill}
100
+ {busy && (
101
+ <Animated.View {...coming}>
102
+ <ActivityIndicator size="small" color={ink} />
103
+ </Animated.View>
104
+ )}
105
+ {/* The label makes room for the spinner by gliding, not by jumping. */}
106
+ <Animated.View layout={layout}>
107
+ {typeof children === 'string' ? (
108
+ <Text variant="label" style={{ color: ink }}>
109
+ {children}
110
+ </Text>
111
+ ) : (
112
+ children
113
+ )}
114
+ </Animated.View>
115
+ </AnimatedPressable>
116
+ );
117
+ }