@fluxus-ui/native 0.0.0-stage → 0.3.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 (230) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/lib/module/AudioPlayer.js +174 -0
  4. package/lib/module/AudioPlayer.js.map +1 -0
  5. package/lib/module/Avatar.js +58 -0
  6. package/lib/module/Avatar.js.map +1 -0
  7. package/lib/module/Badge.js +72 -0
  8. package/lib/module/Badge.js.map +1 -0
  9. package/lib/module/BottomSheet.js +159 -0
  10. package/lib/module/BottomSheet.js.map +1 -0
  11. package/lib/module/Bubble.js +182 -0
  12. package/lib/module/Bubble.js.map +1 -0
  13. package/lib/module/Button.js +209 -0
  14. package/lib/module/Button.js.map +1 -0
  15. package/lib/module/Card.js +79 -0
  16. package/lib/module/Card.js.map +1 -0
  17. package/lib/module/Dialog.js +137 -0
  18. package/lib/module/Dialog.js.map +1 -0
  19. package/lib/module/Disclosure.js +153 -0
  20. package/lib/module/Disclosure.js.map +1 -0
  21. package/lib/module/EmptyState.js +71 -0
  22. package/lib/module/EmptyState.js.map +1 -0
  23. package/lib/module/Link.js +97 -0
  24. package/lib/module/Link.js.map +1 -0
  25. package/lib/module/ListItem.js +89 -0
  26. package/lib/module/ListItem.js.map +1 -0
  27. package/lib/module/Menu.js +76 -0
  28. package/lib/module/Menu.js.map +1 -0
  29. package/lib/module/Message.js +51 -0
  30. package/lib/module/Message.js.map +1 -0
  31. package/lib/module/Popover.js +153 -0
  32. package/lib/module/Popover.js.map +1 -0
  33. package/lib/module/Progress.js +54 -0
  34. package/lib/module/Progress.js.map +1 -0
  35. package/lib/module/Select.js +146 -0
  36. package/lib/module/Select.js.map +1 -0
  37. package/lib/module/Skeleton.js +40 -0
  38. package/lib/module/Skeleton.js.map +1 -0
  39. package/lib/module/Slider.js +137 -0
  40. package/lib/module/Slider.js.map +1 -0
  41. package/lib/module/Spinner.js +30 -0
  42. package/lib/module/Spinner.js.map +1 -0
  43. package/lib/module/Swap.js +87 -0
  44. package/lib/module/Swap.js.map +1 -0
  45. package/lib/module/Tabs.js +118 -0
  46. package/lib/module/Tabs.js.map +1 -0
  47. package/lib/module/Text.js +47 -0
  48. package/lib/module/Text.js.map +1 -0
  49. package/lib/module/TextField.js +190 -0
  50. package/lib/module/TextField.js.map +1 -0
  51. package/lib/module/Toast.js +157 -0
  52. package/lib/module/Toast.js.map +1 -0
  53. package/lib/module/audio.js +54 -0
  54. package/lib/module/audio.js.map +1 -0
  55. package/lib/module/blur.js +55 -0
  56. package/lib/module/blur.js.map +1 -0
  57. package/lib/module/controls.js +292 -0
  58. package/lib/module/controls.js.map +1 -0
  59. package/lib/module/feel.js +24 -0
  60. package/lib/module/feel.js.map +1 -0
  61. package/lib/module/generated/tokens.js +484 -0
  62. package/lib/module/generated/tokens.js.map +1 -0
  63. package/lib/module/haptics.js +25 -0
  64. package/lib/module/haptics.js.map +1 -0
  65. package/lib/module/icon-host.js +42 -0
  66. package/lib/module/icon-host.js.map +1 -0
  67. package/lib/module/icon-shape.js +222 -0
  68. package/lib/module/icon-shape.js.map +1 -0
  69. package/lib/module/icon.js +331 -0
  70. package/lib/module/icon.js.map +1 -0
  71. package/lib/module/index.js +39 -0
  72. package/lib/module/index.js.map +1 -0
  73. package/lib/module/layout.js +75 -0
  74. package/lib/module/layout.js.map +1 -0
  75. package/lib/module/marks.js +99 -0
  76. package/lib/module/marks.js.map +1 -0
  77. package/lib/module/motion.js +95 -0
  78. package/lib/module/motion.js.map +1 -0
  79. package/lib/module/overlay.js +99 -0
  80. package/lib/module/overlay.js.map +1 -0
  81. package/lib/module/package.json +1 -0
  82. package/lib/module/pending.js +181 -0
  83. package/lib/module/pending.js.map +1 -0
  84. package/lib/module/presence.js +71 -0
  85. package/lib/module/presence.js.map +1 -0
  86. package/lib/module/press.js +32 -0
  87. package/lib/module/press.js.map +1 -0
  88. package/lib/module/screen.js +50 -0
  89. package/lib/module/screen.js.map +1 -0
  90. package/lib/module/success.js +59 -0
  91. package/lib/module/success.js.map +1 -0
  92. package/lib/module/theme.js +41 -0
  93. package/lib/module/theme.js.map +1 -0
  94. package/lib/typescript/AudioPlayer.d.ts +26 -0
  95. package/lib/typescript/AudioPlayer.d.ts.map +1 -0
  96. package/lib/typescript/Avatar.d.ts +17 -0
  97. package/lib/typescript/Avatar.d.ts.map +1 -0
  98. package/lib/typescript/Badge.d.ts +21 -0
  99. package/lib/typescript/Badge.d.ts.map +1 -0
  100. package/lib/typescript/BottomSheet.d.ts +27 -0
  101. package/lib/typescript/BottomSheet.d.ts.map +1 -0
  102. package/lib/typescript/Bubble.d.ts +23 -0
  103. package/lib/typescript/Bubble.d.ts.map +1 -0
  104. package/lib/typescript/Button.d.ts +29 -0
  105. package/lib/typescript/Button.d.ts.map +1 -0
  106. package/lib/typescript/Card.d.ts +17 -0
  107. package/lib/typescript/Card.d.ts.map +1 -0
  108. package/lib/typescript/Dialog.d.ts +34 -0
  109. package/lib/typescript/Dialog.d.ts.map +1 -0
  110. package/lib/typescript/Disclosure.d.ts +39 -0
  111. package/lib/typescript/Disclosure.d.ts.map +1 -0
  112. package/lib/typescript/EmptyState.d.ts +14 -0
  113. package/lib/typescript/EmptyState.d.ts.map +1 -0
  114. package/lib/typescript/Link.d.ts +23 -0
  115. package/lib/typescript/Link.d.ts.map +1 -0
  116. package/lib/typescript/ListItem.d.ts +20 -0
  117. package/lib/typescript/ListItem.d.ts.map +1 -0
  118. package/lib/typescript/Menu.d.ts +23 -0
  119. package/lib/typescript/Menu.d.ts.map +1 -0
  120. package/lib/typescript/Message.d.ts +14 -0
  121. package/lib/typescript/Message.d.ts.map +1 -0
  122. package/lib/typescript/Popover.d.ts +71 -0
  123. package/lib/typescript/Popover.d.ts.map +1 -0
  124. package/lib/typescript/Progress.d.ts +12 -0
  125. package/lib/typescript/Progress.d.ts.map +1 -0
  126. package/lib/typescript/Select.d.ts +30 -0
  127. package/lib/typescript/Select.d.ts.map +1 -0
  128. package/lib/typescript/Skeleton.d.ts +13 -0
  129. package/lib/typescript/Skeleton.d.ts.map +1 -0
  130. package/lib/typescript/Slider.d.ts +21 -0
  131. package/lib/typescript/Slider.d.ts.map +1 -0
  132. package/lib/typescript/Spinner.d.ts +12 -0
  133. package/lib/typescript/Spinner.d.ts.map +1 -0
  134. package/lib/typescript/Swap.d.ts +25 -0
  135. package/lib/typescript/Swap.d.ts.map +1 -0
  136. package/lib/typescript/Tabs.d.ts +18 -0
  137. package/lib/typescript/Tabs.d.ts.map +1 -0
  138. package/lib/typescript/Text.d.ts +20 -0
  139. package/lib/typescript/Text.d.ts.map +1 -0
  140. package/lib/typescript/TextField.d.ts +36 -0
  141. package/lib/typescript/TextField.d.ts.map +1 -0
  142. package/lib/typescript/Toast.d.ts +25 -0
  143. package/lib/typescript/Toast.d.ts.map +1 -0
  144. package/lib/typescript/audio.d.ts +10 -0
  145. package/lib/typescript/audio.d.ts.map +1 -0
  146. package/lib/typescript/blur.d.ts +4 -0
  147. package/lib/typescript/blur.d.ts.map +1 -0
  148. package/lib/typescript/controls.d.ts +37 -0
  149. package/lib/typescript/controls.d.ts.map +1 -0
  150. package/lib/typescript/feel.d.ts +10 -0
  151. package/lib/typescript/feel.d.ts.map +1 -0
  152. package/lib/typescript/generated/tokens.d.ts +499 -0
  153. package/lib/typescript/generated/tokens.d.ts.map +1 -0
  154. package/lib/typescript/haptics.d.ts +7 -0
  155. package/lib/typescript/haptics.d.ts.map +1 -0
  156. package/lib/typescript/icon-host.d.ts +30 -0
  157. package/lib/typescript/icon-host.d.ts.map +1 -0
  158. package/lib/typescript/icon-shape.d.ts +28 -0
  159. package/lib/typescript/icon-shape.d.ts.map +1 -0
  160. package/lib/typescript/icon.d.ts +24 -0
  161. package/lib/typescript/icon.d.ts.map +1 -0
  162. package/lib/typescript/index.d.ts +37 -0
  163. package/lib/typescript/index.d.ts.map +1 -0
  164. package/lib/typescript/layout.d.ts +24 -0
  165. package/lib/typescript/layout.d.ts.map +1 -0
  166. package/lib/typescript/marks.d.ts +23 -0
  167. package/lib/typescript/marks.d.ts.map +1 -0
  168. package/lib/typescript/motion.d.ts +30 -0
  169. package/lib/typescript/motion.d.ts.map +1 -0
  170. package/lib/typescript/overlay.d.ts +33 -0
  171. package/lib/typescript/overlay.d.ts.map +1 -0
  172. package/lib/typescript/package.json +1 -0
  173. package/lib/typescript/pending.d.ts +26 -0
  174. package/lib/typescript/pending.d.ts.map +1 -0
  175. package/lib/typescript/presence.d.ts +37 -0
  176. package/lib/typescript/presence.d.ts.map +1 -0
  177. package/lib/typescript/press.d.ts +12 -0
  178. package/lib/typescript/press.d.ts.map +1 -0
  179. package/lib/typescript/screen.d.ts +21 -0
  180. package/lib/typescript/screen.d.ts.map +1 -0
  181. package/lib/typescript/success.d.ts +13 -0
  182. package/lib/typescript/success.d.ts.map +1 -0
  183. package/lib/typescript/theme.d.ts +32 -0
  184. package/lib/typescript/theme.d.ts.map +1 -0
  185. package/package.json +123 -3
  186. package/src/AudioPlayer.tsx +106 -0
  187. package/src/Avatar.tsx +44 -0
  188. package/src/Badge.tsx +45 -0
  189. package/src/BottomSheet.tsx +109 -0
  190. package/src/Bubble.tsx +112 -0
  191. package/src/Button.tsx +168 -0
  192. package/src/Card.tsx +70 -0
  193. package/src/Dialog.tsx +93 -0
  194. package/src/Disclosure.tsx +108 -0
  195. package/src/EmptyState.tsx +51 -0
  196. package/src/Link.tsx +61 -0
  197. package/src/ListItem.tsx +78 -0
  198. package/src/Menu.tsx +57 -0
  199. package/src/Message.tsx +43 -0
  200. package/src/Popover.tsx +145 -0
  201. package/src/Progress.tsx +33 -0
  202. package/src/Select.tsx +118 -0
  203. package/src/Skeleton.tsx +28 -0
  204. package/src/Slider.tsx +107 -0
  205. package/src/Spinner.tsx +18 -0
  206. package/src/Swap.tsx +74 -0
  207. package/src/Tabs.tsx +84 -0
  208. package/src/Text.tsx +44 -0
  209. package/src/TextField.tsx +137 -0
  210. package/src/Toast.tsx +122 -0
  211. package/src/audio.tsx +56 -0
  212. package/src/blur.tsx +33 -0
  213. package/src/controls.tsx +224 -0
  214. package/src/feel.ts +22 -0
  215. package/src/generated/tokens.ts +653 -0
  216. package/src/haptics.tsx +26 -0
  217. package/src/icon-host.tsx +46 -0
  218. package/src/icon-shape.ts +213 -0
  219. package/src/icon.tsx +276 -0
  220. package/src/index.ts +36 -0
  221. package/src/layout.tsx +40 -0
  222. package/src/marks.tsx +79 -0
  223. package/src/motion.ts +94 -0
  224. package/src/overlay.tsx +77 -0
  225. package/src/pending.tsx +135 -0
  226. package/src/presence.tsx +68 -0
  227. package/src/press.ts +23 -0
  228. package/src/screen.tsx +37 -0
  229. package/src/success.tsx +48 -0
  230. package/src/theme.tsx +49 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jhony0709
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,76 @@
1
- # Temporary Holding Version
1
+ # @fluxus-ui/native
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
+ Fluxus for React Native: the same tokens and motion vocabulary as the web, on Reanimated. Design and decisions: `SPEC.md` §15.
4
+
5
+ ```sh
6
+ npx expo install @fluxus-ui/native react-native-reanimated react-native-worklets
7
+ ```
8
+
9
+ It needs the New Architecture (Reanimated 4 does). Peer dependencies: `react`, `react-native`, `react-native-reanimated`, `react-native-worklets`.
10
+
11
+ With Expo, `babel-preset-expo` already adds the worklets plugin. Without Expo, add it to the app's Babel config, last in the list:
12
+
13
+ ```js
14
+ module.exports = { presets: ['module:@react-native/babel-preset'], plugins: ['react-native-worklets/plugin'] };
15
+ ```
16
+
17
+ Inside a monorepo, the app must run one copy of React and of Reanimated: see `examples/native/metro.config.js`.
18
+
19
+ ```tsx
20
+ import { Button, Text, ThemeProvider, themes } from '@fluxus-ui/native';
21
+
22
+ export default function App() {
23
+ return (
24
+ <ThemeProvider theme={themes.base}>
25
+ <Text variant="title">Lecciones</Text>
26
+ <Button variant="primary" onPress={() => {}}>
27
+ Entrar
28
+ </Button>
29
+ </ThemeProvider>
30
+ );
31
+ }
32
+ ```
33
+
34
+ `src/generated/tokens.ts` is written by `pnpm --filter @fluxus-ui/ui tokens:native` from `packages/ui/tokens/*.tokens.json`: a theme is the same file for the web and for here.
35
+
36
+ Some pieces need a library of their own, and live in their own entry so that nobody else installs it:
37
+
38
+ ```tsx
39
+ import { Icon } from '@fluxus-ui/native/icon'; // react-native-svg and @fluxus-ui/icons
40
+ import { Screen } from '@fluxus-ui/native/screen'; // react-native-safe-area-context
41
+ import { Swap } from '@fluxus-ui/native/blur'; // expo-blur: the Swap that loses focus on a phone too
42
+ import { Audio } from '@fluxus-ui/native/audio'; // expo-audio: the player, playing
43
+ import { enableHaptics } from '@fluxus-ui/native/haptics'; // expo-haptics: what the hand feels
44
+ ```
45
+
46
+ The main entry never imports them: an app without them works. What it can use of them it is given: haptics by registration (`enableHaptics()`, once at the root), an icon as a prop or a child.
47
+
48
+ What is pressed can wait: if `onPress` of a `Button`, a `Card` or a `ListItem`, or `onChange` of `Tabs`, returns a promise, it fills from where it was pressed until the promise settles. If the promise is rejected, the fill goes back to the finger: the app says why, in its own `catch`. `<Swap id={what}>` makes what is shown give way to what comes.
49
+
50
+ Forms: `TextField` (with `reveal` for a password, `rows` for several lines), `TextArea`, `SearchField`, `Checkbox`, `Switch`, `RadioGroup` and `Slider`. The slider takes the touch with React Native's own responder: it needs no gesture library.
51
+
52
+ What opens above: `BottomSheet` and `Dialog` (with `ConfirmDialog`) take `open` and `onClose`; `Menu` and `Popover` take a `trigger`; `Select` is a field that opens a sheet. They are a `Modal` of React Native with nothing of its own: no library. Back on Android always closes. If what is chosen or confirmed returns a promise, what was pressed waits and the window closes once it is fulfilled; if it fails, it stays open. `BottomSheet` and `Select` take `inset`: the safe area at the bottom, which the app knows (`useSafeAreaInsets().bottom`).
53
+
54
+ A notice of `useToast` called while one of them is open is painted inside it too: behind the window nobody would see it. A window of the app's own (`Modal`) gets them with `<ToastLayer />`.
55
+
56
+ `Disclosure` and `Accordion` show and hide what is under a title. It is the one piece that animates a height: what is below travels with it.
57
+
58
+ `Screen` with `scroll` gives its `ScrollView`: `scrollRef` to take it somewhere (`scrollToEnd` in a chat), `scrollProps` for what else it takes (`onScroll`). Its padding stays the one of the theme.
59
+
60
+ `Link` is a link in text: alone, with a target of 44 points; `inline`, inside a sentence. It opens `href` with the system, or calls `onPress` (the browser of the app, a screen). If `onPress` returns a promise the link waits for it: faded, and taking no other press. `Bubble` is a message of a chat, on the side of who wrote it (`side="start"` or `"end"`), with `author` and `meta`.
61
+
62
+ `AudioPlayer` is a button, how far it is and the time; it plays nothing by itself (`playing`, `position`, `duration`, `onToggle`, `onSeek`, and `loading` while the sound is not here yet). `<Audio source={…} labels={{ play, pause }} />`, from `@fluxus-ui/native/audio`, is the same playing with `expo-audio`: it waits from the press until the sound comes, and tells `onError` if it cannot.
63
+
64
+ The icons of `@fluxus-ui/icons` move as on the web, on the UI thread: `<Icon icon={menu} />`. Inside a `Button`, a `Card` or a `ListItem` an icon takes the state of the control (`on` when it has `aria-expanded` or `aria-checked`), its colour, and its push when pressed: a `menu` in the trigger of a `Menu` becomes a cross while the menu is open, and nobody wires it. `state` and `progress` set them by hand. With reduced motion a state changes at once and nothing is pushed. An icon with no other state and no push draws once, with nothing animated. `setMotionScale(4)` makes every animation of Fluxus four times slower, to look at it.
65
+
66
+ Components answer: a `Button` with `feedback` draws a tick where its text was when what its press returns is fulfilled, and shakes its text once if it fails. A `Checkbox` draws its tick, the knob of a `Switch` widens towards where it goes while pressed, a `Toast` draws its mark by tone, a `Bubble` with `status` (`sending`, `sent`, `read`, `failed`) draws its ticks and shakes once when it fails, and the `icon` of an `EmptyState` comes with a small gesture. `<Success label="Pago enviado" />`, from the `icon` entry, grows and draws a tick in a circle. With `enableHaptics()` the hand feels them too. The ticks are drawn with views, without SVG. With reduced motion nothing shakes or grows, and marks appear drawn.
67
+
68
+ The app's own font, loaded with `expo-font`: `<ThemeProvider fonts={{ regular: 'Atkinson-Regular', medium: 'Atkinson-Medium', bold: 'Atkinson-Bold' }}>`. Without it, the font of the system.
69
+
70
+ Nothing jumps: `<Appear>` is a view that comes rising, goes fading and glides to a new place; `presence()` gives the three props for any `Animated.View`. In a browser they are off.
71
+
72
+ An app's own theme: `npx fluxus-native-theme --theme its.tokens.json --out its-theme.ts` (the command of `@fluxus-ui/ui`, a dev dependency of the app), then `<ThemeProvider theme={theme}>`. `examples/native` does it with an example of ALBA.
73
+
74
+ A theme may add the tokens of its app under the group `app` (`app.surface.note`), with their `$type`; nothing else can be added. `useTheme<typeof theme>()` gives them by name, and a wrong name does not compile.
75
+
76
+ Checked by `node verify-native.mjs` (types and Jest). Jest runs no native code and paints nothing: how it looks and moves is checked on a phone.
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * What plays a sound: a round button, how far it is and the time. It plays nothing by itself: the app, or
5
+ * `@fluxus-ui/native/audio`, tells it where the sound is. The triangle and the bars are drawn with edges,
6
+ * and give way to each other without moving anything else. (SPEC §15.10)
7
+ */
8
+ import { useEffect } from 'react';
9
+ import { ActivityIndicator, Pressable, View } from 'react-native';
10
+ import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
11
+ import { fill } from "./layout.js";
12
+ import { spring } from "./motion.js";
13
+ import { usePress } from "./press.js";
14
+ import { Progress } from "./Progress.js";
15
+ import { Slider } from "./Slider.js";
16
+ import { Text } from "./Text.js";
17
+ import { useTheme } from "./theme.js";
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
+ /** Seconds as `1:04`. */
20
+ export const clock = seconds => {
21
+ const whole = Math.max(0, Math.floor(seconds));
22
+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, '0')}`;
23
+ };
24
+
25
+ /** What the bar asks for where its row is as wide as what it holds (a bubble); it gives it up where there is no room. */
26
+ const BAR = 160;
27
+ const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
28
+ export function AudioPlayer({
29
+ playing,
30
+ position,
31
+ duration,
32
+ onToggle,
33
+ onSeek,
34
+ labels,
35
+ loading = false,
36
+ disabled = false,
37
+ style,
38
+ ...rest
39
+ }) {
40
+ const theme = useTheme();
41
+ const press = usePress({});
42
+ const on = useSharedValue(playing ? 1 : 0);
43
+ useEffect(() => {
44
+ on.value = spring(playing ? 1 : 0, 'snappy');
45
+ }, [playing, on]);
46
+ const wait = useSharedValue(loading ? 1 : 0);
47
+ useEffect(() => {
48
+ wait.value = spring(loading ? 1 : 0, 'snappy');
49
+ }, [loading, wait]);
50
+ // While it waits, neither mark is seen: the spinner is where they were.
51
+ const play = useAnimatedStyle(() => ({
52
+ opacity: (1 - on.value) * (1 - wait.value),
53
+ transform: [{
54
+ scale: 1 - 0.4 * on.value
55
+ }]
56
+ }));
57
+ const pause = useAnimatedStyle(() => ({
58
+ opacity: on.value * (1 - wait.value),
59
+ transform: [{
60
+ scale: 0.6 + 0.4 * on.value
61
+ }]
62
+ }));
63
+ const waiting = useAnimatedStyle(() => ({
64
+ opacity: wait.value
65
+ }));
66
+ const side = theme.size['target.min'];
67
+ const ink = theme.color['button.fg'];
68
+ const unit = theme.size['space.1'];
69
+ const name = labels.position ?? 'Position';
70
+ const told = `${clock(position)} / ${clock(duration)}`;
71
+ const at = Math.min(position, duration);
72
+ return /*#__PURE__*/_jsxs(View, {
73
+ ...rest,
74
+ style: [{
75
+ flexDirection: 'row',
76
+ alignItems: 'center',
77
+ gap: theme.size['space.3'],
78
+ opacity: disabled ? 0.5 : 1
79
+ }, style],
80
+ children: [/*#__PURE__*/_jsxs(AnimatedPressable, {
81
+ role: "button",
82
+ "aria-label": playing ? labels.pause : labels.play,
83
+ "aria-disabled": disabled,
84
+ "aria-busy": loading,
85
+ disabled: disabled,
86
+ onPress: onToggle,
87
+ onPressIn: press.onPressIn,
88
+ onPressOut: press.onPressOut,
89
+ style: [{
90
+ width: side,
91
+ height: side,
92
+ borderRadius: side / 2,
93
+ alignItems: 'center',
94
+ justifyContent: 'center',
95
+ backgroundColor: theme.color['button.bg']
96
+ }, press.style],
97
+ children: [/*#__PURE__*/_jsx(Animated.View, {
98
+ style: [{
99
+ position: 'absolute',
100
+ marginLeft: unit / 2,
101
+ width: 0,
102
+ height: 0,
103
+ borderTopWidth: unit * 1.75,
104
+ borderBottomWidth: unit * 1.75,
105
+ borderLeftWidth: unit * 2.75,
106
+ borderTopColor: 'transparent',
107
+ borderBottomColor: 'transparent',
108
+ borderLeftColor: ink
109
+ }, play]
110
+ }), /*#__PURE__*/_jsxs(Animated.View, {
111
+ style: [{
112
+ position: 'absolute',
113
+ flexDirection: 'row',
114
+ gap: unit
115
+ }, pause],
116
+ children: [/*#__PURE__*/_jsx(View, {
117
+ style: {
118
+ width: unit,
119
+ height: unit * 3.5,
120
+ borderRadius: 1,
121
+ backgroundColor: ink
122
+ }
123
+ }), /*#__PURE__*/_jsx(View, {
124
+ style: {
125
+ width: unit,
126
+ height: unit * 3.5,
127
+ borderRadius: 1,
128
+ backgroundColor: ink
129
+ }
130
+ })]
131
+ }), loading && /*#__PURE__*/_jsx(Animated.View, {
132
+ "aria-hidden": true,
133
+ importantForAccessibility: "no-hide-descendants",
134
+ style: [{
135
+ position: 'absolute'
136
+ }, waiting],
137
+ children: /*#__PURE__*/_jsx(ActivityIndicator, {
138
+ size: "small",
139
+ color: ink
140
+ })
141
+ })]
142
+ }), /*#__PURE__*/_jsx(View, {
143
+ style: [fill, {
144
+ width: BAR,
145
+ minWidth: theme.size['space.16']
146
+ }],
147
+ children: onSeek && duration > 0 ? /*#__PURE__*/_jsx(Slider, {
148
+ label: name,
149
+ min: 0,
150
+ max: Math.max(1, Math.floor(duration)),
151
+ step: 1,
152
+ value: Math.floor(at),
153
+ onChange: onSeek,
154
+ valueText: () => told,
155
+ disabled: disabled
156
+ }) : /*#__PURE__*/_jsx(Progress, {
157
+ label: name,
158
+ value: at,
159
+ max: duration || 1
160
+ })
161
+ }), /*#__PURE__*/_jsx(Text, {
162
+ variant: "caption",
163
+ tone: "muted",
164
+ "aria-hidden": !!onSeek && duration > 0,
165
+ style: {
166
+ fontVariant: ['tabular-nums'],
167
+ minWidth: theme.size['space.16'],
168
+ textAlign: 'right'
169
+ },
170
+ children: told
171
+ })]
172
+ });
173
+ }
174
+ //# sourceMappingURL=AudioPlayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","ActivityIndicator","Pressable","View","Animated","useAnimatedStyle","useSharedValue","fill","spring","usePress","Progress","Slider","Text","useTheme","jsx","_jsx","jsxs","_jsxs","clock","seconds","whole","Math","max","floor","String","padStart","BAR","AnimatedPressable","createAnimatedComponent","AudioPlayer","playing","position","duration","onToggle","onSeek","labels","loading","disabled","style","rest","theme","press","on","value","wait","play","opacity","transform","scale","pause","waiting","side","size","ink","color","unit","name","told","at","min","flexDirection","alignItems","gap","children","role","onPress","onPressIn","onPressOut","width","height","borderRadius","justifyContent","backgroundColor","marginLeft","borderTopWidth","borderBottomWidth","borderLeftWidth","borderTopColor","borderBottomColor","borderLeftColor","importantForAccessibility","minWidth","label","step","onChange","valueText","variant","tone","fontVariant","textAlign"],"sourceRoot":"../../src","sources":["AudioPlayer.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,EAAEC,SAAS,EAAEC,IAAI,QAAwD,cAAc;AACjH,OAAOC,QAAQ,IAAIC,gBAAgB,EAAEC,cAAc,QAAQ,yBAAyB;AACpF,SAASC,IAAI,QAAQ,aAAU;AAC/B,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,QAAQ,QAAQ,YAAS;AAClC,SAASC,QAAQ,QAAQ,eAAY;AACrC,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,QAAQ,QAAQ,YAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAoBnC;AACA,OAAO,MAAMC,KAAK,GAAIC,OAAe,IAAa;EAChD,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAACJ,OAAO,CAAC,CAAC;EAC9C,OAAO,GAAGE,IAAI,CAACE,KAAK,CAACH,KAAK,GAAG,EAAE,CAAC,IAAII,MAAM,CAACJ,KAAK,GAAG,EAAE,CAAC,CAACK,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE;AAC3E,CAAC;;AAED;AACA,MAAMC,GAAG,GAAG,GAAG;AAEf,MAAMC,iBAAiB,GAAGvB,QAAQ,CAACwB,uBAAuB,CAAC1B,SAAS,CAAC;AAErE,OAAO,SAAS2B,WAAWA,CAAC;EAAEC,OAAO;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC,MAAM;EAAEC,MAAM;EAAEC,OA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,IAAI,CAAC,UAAU,CAAC;QAAEqC,SAAS,EAAE;MAAQ,CAAE;MAAA1B,QAAA,EACxKN;IAAI,CACD,CAAC;EAAA,CACH,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ import { Image, View } from 'react-native';
4
+ import { Text } from "./Text.js";
5
+ import { useTheme } from "./theme.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ /** As the web: the first letter of the first two words that start with a letter or a figure. */
8
+ export const initials = name => name.trim().split(/\s+/).filter(w => /^[\p{L}\p{N}]/u.test(w)).slice(0, 2).map(w => Array.from(w)[0] ?? '').join('').toUpperCase();
9
+
10
+ /** Who someone is, in a circle: the picture, or the initials. */
11
+ export function Avatar({
12
+ name,
13
+ src,
14
+ label,
15
+ size = 'md',
16
+ style,
17
+ ...rest
18
+ }) {
19
+ const theme = useTheme();
20
+ const side = theme.size[`control.h.${size}`];
21
+ const a11y = label ? {
22
+ accessible: true,
23
+ role: 'img',
24
+ 'aria-label': label
25
+ } : {
26
+ 'aria-hidden': true,
27
+ importantForAccessibility: 'no-hide-descendants'
28
+ };
29
+ return /*#__PURE__*/_jsx(View, {
30
+ ...a11y,
31
+ ...rest,
32
+ style: [{
33
+ width: side,
34
+ height: side,
35
+ borderRadius: side,
36
+ alignItems: 'center',
37
+ justifyContent: 'center',
38
+ overflow: 'hidden',
39
+ backgroundColor: theme.color['accent.subtle']
40
+ }, style],
41
+ children: src ? /*#__PURE__*/_jsx(Image, {
42
+ source: {
43
+ uri: src
44
+ },
45
+ style: {
46
+ width: side,
47
+ height: side
48
+ }
49
+ }) : /*#__PURE__*/_jsx(Text, {
50
+ variant: size === 'sm' ? 'caption' : 'label',
51
+ weight: "medium",
52
+ tone: "accent",
53
+ allowFontScaling: false,
54
+ children: initials(name)
55
+ })
56
+ });
57
+ }
58
+ //# sourceMappingURL=Avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Image","View","Text","useTheme","jsx","_jsx","initials","name","trim","split","filter","w","test","slice","map","Array","from","join","toUpperCase","Avatar","src","label","size","style","rest","theme","side","a11y","accessible","role","importantForAccessibility","width","height","borderRadius","alignItems","justifyContent","overflow","backgroundColor","color","children","source","uri","variant","weight","tone","allowFontScaling"],"sourceRoot":"../../src","sources":["Avatar.tsx"],"mappings":";;AAAA,SAASA,KAAK,EAAEC,IAAI,QAAwD,cAAc;AAC1F,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,QAAQ,QAAQ,YAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAcnC;AACA,OAAO,MAAMC,QAAQ,GAAIC,IAAY,IACnCA,IAAI,CACDC,IAAI,CAAC,CAAC,CACNC,KAAK,CAAC,KAAK,CAAC,CACZC,MAAM,CAAEC,CAAC,IAAK,gBAAgB,CAACC,IAAI,CAACD,CAAC,CAAC,CAAC,CACvCE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACXC,GAAG,CAAEH,CAAC,IAAKI,KAAK,CAACC,IAAI,CAACL,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAClCM,IAAI,CAAC,EAAE,CAAC,CACRC,WAAW,CAAC,CAAC;;AAElB;AACA,OAAO,SAASC,MAAMA,CAAC;EAAEZ,IAAI;EAAEa,GAAG;EAAEC,KAAK;EAAEC,IAAI,GAAG,IAAI;EAAEC,KAAK;EAAE,GAAGC;AAAkB,CAAC,EAAE;EACrF,MAAMC,KAAK,GAAGtB,QAAQ,CAAC,CAAC;EACxB,MAAMuB,IAAI,GAAGD,KAAK,CAACH,IAAI,CAAC,aAAaA,IAAI,EAAE,CAAC;EAC5C,MAAMK,IAAI,GAAGN,KAAK,GAAI;IAAEO,UAAU,EAAE,IAAI;IAAEC,IAAI,EAAE,KAAK;IAAE,YAAY,EAAER;EAAM,CAAC,GAAc;IAAE,aAAa,EAAE,IAAI;IAAES,yBAAyB,EAAE;EAAsB,CAAW;EAC7K,oBACEzB,IAAA,CAACJ,IAAI;IAAA,GAAK0B,IAAI;IAAA,GAAMH,IAAI;IAAED,KAAK,EAAE,CAAC;MAAEQ,KAAK,EAAEL,IAAI;MAAEM,MAAM,EAAEN,IAAI;MAAEO,YAAY,EAAEP,IAAI;MAAEQ,UAAU,EAAE,QAAQ;MAAEC,cAAc,EAAE,QAAQ;MAAEC,QAAQ,EAAE,QAAQ;MAAEC,eAAe,EAAEZ,KAAK,CAACa,KAAK,CAAC,eAAe;IAAE,CAAC,EAAEf,KAAK,CAAE;IAAAgB,QAAA,EAC5MnB,GAAG,gBACFf,IAAA,CAACL,KAAK;MAACwC,MAAM,EAAE;QAAEC,GAAG,EAAErB;MAAI,CAAE;MAACG,KAAK,EAAE;QAAEQ,KAAK,EAAEL,IAAI;QAAEM,MAAM,EAAEN;MAAK;IAAE,CAAE,CAAC,gBAErErB,IAAA,CAACH,IAAI;MAACwC,OAAO,EAAEpB,IAAI,KAAK,IAAI,GAAG,SAAS,GAAG,OAAQ;MAACqB,MAAM,EAAC,QAAQ;MAACC,IAAI,EAAC,QAAQ;MAACC,gBAAgB,EAAE,KAAM;MAAAN,QAAA,EACvGjC,QAAQ,CAACC,IAAI;IAAC,CACX;EACP,CACG,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ import { View } from 'react-native';
4
+ import { Text } from "./Text.js";
5
+ import { useTheme } from "./theme.js";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ /** The ground, the ink and the solid colour of a tone. */
8
+ export function toneColors(theme, tone = 'neutral') {
9
+ const c = theme.color;
10
+ if (tone === 'neutral') return {
11
+ subtle: c['surface.sunken'],
12
+ ink: c['text.muted'],
13
+ solid: c['text.muted']
14
+ };
15
+ if (tone === 'accent') return {
16
+ subtle: c['accent.subtle'],
17
+ ink: c['text.accent'],
18
+ solid: c['accent.default']
19
+ };
20
+ return {
21
+ subtle: c[`state.${tone}.subtle`],
22
+ ink: c[`state.${tone}.text`],
23
+ solid: c[`state.${tone}.solid`]
24
+ };
25
+ }
26
+
27
+ /** A state in a word. The tone is never the only thing that says it: the text does. */
28
+ export function Badge({
29
+ children,
30
+ tone = 'neutral',
31
+ look = 'tint',
32
+ style,
33
+ ...rest
34
+ }) {
35
+ const theme = useTheme();
36
+ const {
37
+ subtle,
38
+ ink,
39
+ solid
40
+ } = toneColors(theme, tone);
41
+ const dot = look === 'dot';
42
+ const size = theme.size['space.2'];
43
+ return /*#__PURE__*/_jsxs(View, {
44
+ ...rest,
45
+ style: [{
46
+ flexDirection: 'row',
47
+ alignItems: 'center',
48
+ alignSelf: 'flex-start',
49
+ gap: theme.size['space.1'],
50
+ paddingHorizontal: theme.size['space.2'],
51
+ paddingVertical: theme.size['space.1'] / 2,
52
+ borderRadius: theme.size['radius.pill'],
53
+ backgroundColor: dot ? theme.color['surface.sunken'] : subtle
54
+ }, style],
55
+ children: [dot && /*#__PURE__*/_jsx(View, {
56
+ style: {
57
+ width: size,
58
+ height: size,
59
+ borderRadius: size,
60
+ backgroundColor: solid
61
+ }
62
+ }), /*#__PURE__*/_jsx(Text, {
63
+ variant: "caption",
64
+ weight: "medium",
65
+ style: {
66
+ color: dot ? theme.color['text.default'] : ink
67
+ },
68
+ children: children
69
+ })]
70
+ });
71
+ }
72
+ //# sourceMappingURL=Badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["View","Text","useTheme","jsx","_jsx","jsxs","_jsxs","toneColors","theme","tone","c","color","subtle","ink","solid","Badge","children","look","style","rest","dot","size","flexDirection","alignItems","alignSelf","gap","paddingHorizontal","paddingVertical","borderRadius","backgroundColor","width","height","variant","weight"],"sourceRoot":"../../src","sources":["Badge.tsx"],"mappings":";;AACA,SAASA,IAAI,QAAwD,cAAc;AACnF,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,QAAQ,QAAoB,YAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAa/C;AACA,OAAO,SA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AAEC,GAAG,EAAEjB,KAAK,CAACa,IAAI,CAAC,SAAS,CAAC;MAAEK,iBAAiB,EAAElB,KAAK,CAACa,IAAI,CAAC,SAAS,CAAC;MAAEM,eAAe,EAAEnB,KAAK,CAACa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;MAAEO,YAAY,EAAEpB,KAAK,CAACa,IAAI,CAAC,aAAa,CAAC;MAAEQ,eAAe,EAAET,GAAG,GAAGZ,KAAK,CAACG,KAAK,CAAC,gBAAgB,CAAC,GAAGC;IAAO,CAAC,EACjSM,KAAK,CACL;IAAAF,QAAA,GAEDI,GAAG,iBAAIhB,IAAA,CAACJ,IAAI;MAACkB,KAAK,EAAE;QAAEY,KAAK,EAAET,IAAI;QAAEU,MAAM,EAAEV,IAAI;QAAEO,YAAY,EAAEP,IAAI;QAAEQ,eAAe,EAAEf;MAAM;IAAE,CAAE,CAAC,eAClGV,IAAA,CAACH,IAAI;MAAC+B,OAAO,EAAC,SAAS;MAACC,MAAM,EAAC,QAAQ;MAACf,KAAK,EAAE;QAAEP,KAAK,EAAES,GAAG,GAAGZ,KAAK,CAACG,KAAK,CAAC,cAAc,CAAC,GAAGE;MAAI,CAAE;MAAAG,QAAA,EAC/FA;IAAQ,CACL,CAAC;EAAA,CACH,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * A sheet that rises from the bottom, moved only by its transform. As tall as what it holds, up to nine tenths
5
+ * of the screen. Dragged down from its header, it goes; so it does with its handle, which is a button with a
6
+ * name for whoever cannot drag. (SPEC §15.8)
7
+ */
8
+ import { useRef, useState } from 'react';
9
+ import { PanResponder, Pressable, ScrollView, useWindowDimensions, View } from 'react-native';
10
+ import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
11
+ import { spring } from "./motion.js";
12
+ import { floating, focusOn, Overlay } from "./overlay.js";
13
+ import { Text } from "./Text.js";
14
+ import { useTheme } from "./theme.js";
15
+
16
+ /** How much of the screen it may take, how far down it must be let go to close, and how fast a flick is. */
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ const TALLEST = 0.9;
19
+ const CLOSE_AT = 0.3;
20
+ const FLICK = 0.8;
21
+ function Sheet({
22
+ t,
23
+ onClose,
24
+ title,
25
+ titleHidden,
26
+ children,
27
+ inset,
28
+ closeLabel = 'Close',
29
+ dismissible = true,
30
+ scroll = true,
31
+ testID,
32
+ heading
33
+ }) {
34
+ const theme = useTheme();
35
+ const {
36
+ height: screen
37
+ } = useWindowDimensions();
38
+ const [height, setHeight] = useState(0);
39
+ const drag = useSharedValue(0);
40
+ // Until it is measured it waits below the screen, wherever that is.
41
+ const far = height || screen;
42
+ const rise = useAnimatedStyle(() => ({
43
+ transform: [{
44
+ translateY: (1 - t.value) * far + drag.value
45
+ }]
46
+ }));
47
+ const latest = useRef({
48
+ height,
49
+ onClose
50
+ });
51
+ latest.current = {
52
+ height,
53
+ onClose
54
+ };
55
+ const [pan] = useState(() => PanResponder.create({
56
+ // Only a drag down, and only from the header: what it holds may scroll.
57
+ onMoveShouldSetPanResponder: (_, g) => g.dy > 4 && g.dy > Math.abs(g.dx),
58
+ onPanResponderMove: (_, g) => {
59
+ drag.value = Math.max(0, g.dy);
60
+ },
61
+ onPanResponderRelease: (_, g) => {
62
+ if (g.dy > latest.current.height * CLOSE_AT || g.vy > FLICK) latest.current.onClose();else drag.value = spring(0, 'snappy');
63
+ },
64
+ onPanResponderTerminate: () => {
65
+ drag.value = spring(0, 'snappy');
66
+ }
67
+ }));
68
+ const radius = theme.size['radius.card'];
69
+ const pad = theme.size['space.4'];
70
+ const body = /*#__PURE__*/_jsx(View, {
71
+ style: {
72
+ paddingInline: pad,
73
+ paddingBottom: pad + (inset ?? 0)
74
+ },
75
+ children: children
76
+ });
77
+ return /*#__PURE__*/_jsxs(Animated.View, {
78
+ role: "dialog",
79
+ "aria-modal": true,
80
+ accessibilityViewIsModal: true,
81
+ "aria-label": title,
82
+ testID: testID,
83
+ onLayout: e => setHeight(e.nativeEvent.layout.height),
84
+ style: [floating(theme), {
85
+ position: 'absolute',
86
+ start: 0,
87
+ end: 0,
88
+ bottom: 0,
89
+ maxHeight: screen * TALLEST,
90
+ borderBottomWidth: 0,
91
+ borderBottomStartRadius: 0,
92
+ borderBottomEndRadius: 0,
93
+ borderTopStartRadius: radius,
94
+ borderTopEndRadius: radius
95
+ }, rise],
96
+ children: [/*#__PURE__*/_jsxs(View, {
97
+ ...(dismissible ? pan.panHandlers : null),
98
+ style: {
99
+ paddingInline: pad,
100
+ paddingBottom: theme.size['space.3']
101
+ },
102
+ children: [dismissible && /*#__PURE__*/_jsx(Pressable, {
103
+ role: "button",
104
+ "aria-label": closeLabel,
105
+ onPress: onClose,
106
+ hitSlop: theme.size['space.3'],
107
+ style: {
108
+ alignSelf: 'center',
109
+ paddingBlock: theme.size['space.2']
110
+ },
111
+ children: /*#__PURE__*/_jsx(View, {
112
+ style: {
113
+ width: theme.size['space.10'],
114
+ height: theme.size['space.1'],
115
+ borderRadius: theme.size['space.1'],
116
+ backgroundColor: theme.color['border.strong']
117
+ }
118
+ })
119
+ }), !titleHidden &&
120
+ /*#__PURE__*/
121
+ // Not selectable: in a browser, a drag that selects text is not a drag of the sheet.
122
+ _jsx(Text, {
123
+ ref: heading,
124
+ variant: "title",
125
+ selectable: false,
126
+ style: dismissible ? null : {
127
+ paddingTop: pad
128
+ },
129
+ children: title
130
+ })]
131
+ }), scroll ? /*#__PURE__*/_jsx(ScrollView, {
132
+ bounces: false,
133
+ keyboardShouldPersistTaps: "handled",
134
+ children: body
135
+ }) : body]
136
+ });
137
+ }
138
+ export function BottomSheet({
139
+ open,
140
+ onClose,
141
+ dismissible = true,
142
+ ...rest
143
+ }) {
144
+ const heading = useRef(null);
145
+ return /*#__PURE__*/_jsx(Overlay, {
146
+ open: open,
147
+ onClose: onClose,
148
+ dismissible: dismissible,
149
+ onShow: () => focusOn(heading.current),
150
+ children: t => /*#__PURE__*/_jsx(Sheet, {
151
+ t: t,
152
+ onClose: onClose,
153
+ dismissible: dismissible,
154
+ heading: heading,
155
+ ...rest
156
+ })
157
+ });
158
+ }
159
+ //# sourceMappingURL=BottomSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","useState","PanResponder","Pressable","ScrollView","useWindowDimensions","View","Animated","useAnimatedStyle","useSharedValue","spring","floating","focusOn","Overlay","Text","useTheme","jsx","_jsx","jsxs","_jsxs","TALLEST","CLOSE_AT","FLICK","Sheet","t","onClose","title","titleHidden","children","inset","closeLabel","dismissible","scroll","testID","heading","theme","height","screen","setHeight","drag","far","rise","transform","translateY","value","latest","current","pan","create","onMoveShouldSetPanResponder","_","g","dy","Math","abs","dx","onPanResponderMove","max","onPanResponderRelease","vy","onPanResponderTerminate","radius","size","pad","body","style","paddingInline","paddingBottom","role","accessibilityViewIsModal","onLayout","e","nativeEvent","layout","position","start","end","bottom","maxHeight","borderBottomWidth","borderBottomStartRadius","borderBottomEndRadius","borderTopStartRadius","borderTopEndRadius","panHandlers","onPress","hitSlop","alignSelf","paddingBlock","width","borderRadius","backgroundColor","color","ref","variant","selectable","paddingTop","bounces","keyboardShouldPersistTaps","BottomSheet","open","rest","onShow"],"sourceRoot":"../../src","sources":["BottomSheet.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAA2D,OAAO;AAC3F,SAASC,YAAY,EAAEC,SAAS,EAAEC,UAAU,EAAsBC,mBAAmB,EAAEC,IAAI,QAAQ,cAAc;AACjH,OAAOC,QAAQ,IAAIC,gBAAgB,EAAEC,cAAc,QAA0B,yBAAyB;AACtG,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,cAAW;AACtD,SAASC,IAAI,QAAQ,WAAQ;AAC7B,SAASC,QAAQ,QAAQ,YAAS;;AAElC;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA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