@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.
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/lib/module/AudioPlayer.js +174 -0
- package/lib/module/AudioPlayer.js.map +1 -0
- package/lib/module/Avatar.js +58 -0
- package/lib/module/Avatar.js.map +1 -0
- package/lib/module/Badge.js +72 -0
- package/lib/module/Badge.js.map +1 -0
- package/lib/module/BottomSheet.js +159 -0
- package/lib/module/BottomSheet.js.map +1 -0
- package/lib/module/Bubble.js +182 -0
- package/lib/module/Bubble.js.map +1 -0
- package/lib/module/Button.js +209 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/Card.js +79 -0
- package/lib/module/Card.js.map +1 -0
- package/lib/module/Dialog.js +137 -0
- package/lib/module/Dialog.js.map +1 -0
- package/lib/module/Disclosure.js +153 -0
- package/lib/module/Disclosure.js.map +1 -0
- package/lib/module/EmptyState.js +71 -0
- package/lib/module/EmptyState.js.map +1 -0
- package/lib/module/Link.js +97 -0
- package/lib/module/Link.js.map +1 -0
- package/lib/module/ListItem.js +89 -0
- package/lib/module/ListItem.js.map +1 -0
- package/lib/module/Menu.js +76 -0
- package/lib/module/Menu.js.map +1 -0
- package/lib/module/Message.js +51 -0
- package/lib/module/Message.js.map +1 -0
- package/lib/module/Popover.js +153 -0
- package/lib/module/Popover.js.map +1 -0
- package/lib/module/Progress.js +54 -0
- package/lib/module/Progress.js.map +1 -0
- package/lib/module/Select.js +146 -0
- package/lib/module/Select.js.map +1 -0
- package/lib/module/Skeleton.js +40 -0
- package/lib/module/Skeleton.js.map +1 -0
- package/lib/module/Slider.js +137 -0
- package/lib/module/Slider.js.map +1 -0
- package/lib/module/Spinner.js +30 -0
- package/lib/module/Spinner.js.map +1 -0
- package/lib/module/Swap.js +87 -0
- package/lib/module/Swap.js.map +1 -0
- package/lib/module/Tabs.js +118 -0
- package/lib/module/Tabs.js.map +1 -0
- package/lib/module/Text.js +47 -0
- package/lib/module/Text.js.map +1 -0
- package/lib/module/TextField.js +190 -0
- package/lib/module/TextField.js.map +1 -0
- package/lib/module/Toast.js +157 -0
- package/lib/module/Toast.js.map +1 -0
- package/lib/module/audio.js +54 -0
- package/lib/module/audio.js.map +1 -0
- package/lib/module/blur.js +55 -0
- package/lib/module/blur.js.map +1 -0
- package/lib/module/controls.js +292 -0
- package/lib/module/controls.js.map +1 -0
- package/lib/module/feel.js +24 -0
- package/lib/module/feel.js.map +1 -0
- package/lib/module/generated/tokens.js +484 -0
- package/lib/module/generated/tokens.js.map +1 -0
- package/lib/module/haptics.js +25 -0
- package/lib/module/haptics.js.map +1 -0
- package/lib/module/icon-host.js +42 -0
- package/lib/module/icon-host.js.map +1 -0
- package/lib/module/icon-shape.js +222 -0
- package/lib/module/icon-shape.js.map +1 -0
- package/lib/module/icon.js +331 -0
- package/lib/module/icon.js.map +1 -0
- package/lib/module/index.js +39 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/layout.js +75 -0
- package/lib/module/layout.js.map +1 -0
- package/lib/module/marks.js +99 -0
- package/lib/module/marks.js.map +1 -0
- package/lib/module/motion.js +95 -0
- package/lib/module/motion.js.map +1 -0
- package/lib/module/overlay.js +99 -0
- package/lib/module/overlay.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/pending.js +181 -0
- package/lib/module/pending.js.map +1 -0
- package/lib/module/presence.js +71 -0
- package/lib/module/presence.js.map +1 -0
- package/lib/module/press.js +32 -0
- package/lib/module/press.js.map +1 -0
- package/lib/module/screen.js +50 -0
- package/lib/module/screen.js.map +1 -0
- package/lib/module/success.js +59 -0
- package/lib/module/success.js.map +1 -0
- package/lib/module/theme.js +41 -0
- package/lib/module/theme.js.map +1 -0
- package/lib/typescript/AudioPlayer.d.ts +26 -0
- package/lib/typescript/AudioPlayer.d.ts.map +1 -0
- package/lib/typescript/Avatar.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts.map +1 -0
- package/lib/typescript/Badge.d.ts +21 -0
- package/lib/typescript/Badge.d.ts.map +1 -0
- package/lib/typescript/BottomSheet.d.ts +27 -0
- package/lib/typescript/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/Bubble.d.ts +23 -0
- package/lib/typescript/Bubble.d.ts.map +1 -0
- package/lib/typescript/Button.d.ts +29 -0
- package/lib/typescript/Button.d.ts.map +1 -0
- package/lib/typescript/Card.d.ts +17 -0
- package/lib/typescript/Card.d.ts.map +1 -0
- package/lib/typescript/Dialog.d.ts +34 -0
- package/lib/typescript/Dialog.d.ts.map +1 -0
- package/lib/typescript/Disclosure.d.ts +39 -0
- package/lib/typescript/Disclosure.d.ts.map +1 -0
- package/lib/typescript/EmptyState.d.ts +14 -0
- package/lib/typescript/EmptyState.d.ts.map +1 -0
- package/lib/typescript/Link.d.ts +23 -0
- package/lib/typescript/Link.d.ts.map +1 -0
- package/lib/typescript/ListItem.d.ts +20 -0
- package/lib/typescript/ListItem.d.ts.map +1 -0
- package/lib/typescript/Menu.d.ts +23 -0
- package/lib/typescript/Menu.d.ts.map +1 -0
- package/lib/typescript/Message.d.ts +14 -0
- package/lib/typescript/Message.d.ts.map +1 -0
- package/lib/typescript/Popover.d.ts +71 -0
- package/lib/typescript/Popover.d.ts.map +1 -0
- package/lib/typescript/Progress.d.ts +12 -0
- package/lib/typescript/Progress.d.ts.map +1 -0
- package/lib/typescript/Select.d.ts +30 -0
- package/lib/typescript/Select.d.ts.map +1 -0
- package/lib/typescript/Skeleton.d.ts +13 -0
- package/lib/typescript/Skeleton.d.ts.map +1 -0
- package/lib/typescript/Slider.d.ts +21 -0
- package/lib/typescript/Slider.d.ts.map +1 -0
- package/lib/typescript/Spinner.d.ts +12 -0
- package/lib/typescript/Spinner.d.ts.map +1 -0
- package/lib/typescript/Swap.d.ts +25 -0
- package/lib/typescript/Swap.d.ts.map +1 -0
- package/lib/typescript/Tabs.d.ts +18 -0
- package/lib/typescript/Tabs.d.ts.map +1 -0
- package/lib/typescript/Text.d.ts +20 -0
- package/lib/typescript/Text.d.ts.map +1 -0
- package/lib/typescript/TextField.d.ts +36 -0
- package/lib/typescript/TextField.d.ts.map +1 -0
- package/lib/typescript/Toast.d.ts +25 -0
- package/lib/typescript/Toast.d.ts.map +1 -0
- package/lib/typescript/audio.d.ts +10 -0
- package/lib/typescript/audio.d.ts.map +1 -0
- package/lib/typescript/blur.d.ts +4 -0
- package/lib/typescript/blur.d.ts.map +1 -0
- package/lib/typescript/controls.d.ts +37 -0
- package/lib/typescript/controls.d.ts.map +1 -0
- package/lib/typescript/feel.d.ts +10 -0
- package/lib/typescript/feel.d.ts.map +1 -0
- package/lib/typescript/generated/tokens.d.ts +499 -0
- package/lib/typescript/generated/tokens.d.ts.map +1 -0
- package/lib/typescript/haptics.d.ts +7 -0
- package/lib/typescript/haptics.d.ts.map +1 -0
- package/lib/typescript/icon-host.d.ts +30 -0
- package/lib/typescript/icon-host.d.ts.map +1 -0
- package/lib/typescript/icon-shape.d.ts +28 -0
- package/lib/typescript/icon-shape.d.ts.map +1 -0
- package/lib/typescript/icon.d.ts +24 -0
- package/lib/typescript/icon.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +37 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/layout.d.ts +24 -0
- package/lib/typescript/layout.d.ts.map +1 -0
- package/lib/typescript/marks.d.ts +23 -0
- package/lib/typescript/marks.d.ts.map +1 -0
- package/lib/typescript/motion.d.ts +30 -0
- package/lib/typescript/motion.d.ts.map +1 -0
- package/lib/typescript/overlay.d.ts +33 -0
- package/lib/typescript/overlay.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/pending.d.ts +26 -0
- package/lib/typescript/pending.d.ts.map +1 -0
- package/lib/typescript/presence.d.ts +37 -0
- package/lib/typescript/presence.d.ts.map +1 -0
- package/lib/typescript/press.d.ts +12 -0
- package/lib/typescript/press.d.ts.map +1 -0
- package/lib/typescript/screen.d.ts +21 -0
- package/lib/typescript/screen.d.ts.map +1 -0
- package/lib/typescript/success.d.ts +13 -0
- package/lib/typescript/success.d.ts.map +1 -0
- package/lib/typescript/theme.d.ts +32 -0
- package/lib/typescript/theme.d.ts.map +1 -0
- package/package.json +123 -3
- package/src/AudioPlayer.tsx +106 -0
- package/src/Avatar.tsx +44 -0
- package/src/Badge.tsx +45 -0
- package/src/BottomSheet.tsx +109 -0
- package/src/Bubble.tsx +112 -0
- package/src/Button.tsx +168 -0
- package/src/Card.tsx +70 -0
- package/src/Dialog.tsx +93 -0
- package/src/Disclosure.tsx +108 -0
- package/src/EmptyState.tsx +51 -0
- package/src/Link.tsx +61 -0
- package/src/ListItem.tsx +78 -0
- package/src/Menu.tsx +57 -0
- package/src/Message.tsx +43 -0
- package/src/Popover.tsx +145 -0
- package/src/Progress.tsx +33 -0
- package/src/Select.tsx +118 -0
- package/src/Skeleton.tsx +28 -0
- package/src/Slider.tsx +107 -0
- package/src/Spinner.tsx +18 -0
- package/src/Swap.tsx +74 -0
- package/src/Tabs.tsx +84 -0
- package/src/Text.tsx +44 -0
- package/src/TextField.tsx +137 -0
- package/src/Toast.tsx +122 -0
- package/src/audio.tsx +56 -0
- package/src/blur.tsx +33 -0
- package/src/controls.tsx +224 -0
- package/src/feel.ts +22 -0
- package/src/generated/tokens.ts +653 -0
- package/src/haptics.tsx +26 -0
- package/src/icon-host.tsx +46 -0
- package/src/icon-shape.ts +213 -0
- package/src/icon.tsx +276 -0
- package/src/index.ts +36 -0
- package/src/layout.tsx +40 -0
- package/src/marks.tsx +79 -0
- package/src/motion.ts +94 -0
- package/src/overlay.tsx +77 -0
- package/src/pending.tsx +135 -0
- package/src/presence.tsx +68 -0
- package/src/press.ts +23 -0
- package/src/screen.tsx +37 -0
- package/src/success.tsx +48 -0
- package/src/theme.tsx +49 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useTheme } from "./theme.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* For what takes the room left in a row. Not `flex: 1`: that has no width of its own, and in what is only as
|
|
8
|
+
* wide as what it holds (a menu, a popover) the text would break letter by letter. (SPEC §15.8)
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export const fill = {
|
|
12
|
+
flexGrow: 1,
|
|
13
|
+
flexShrink: 1,
|
|
14
|
+
flexBasis: 'auto'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** A step of the space scale: `space.3` is 12 points. */
|
|
18
|
+
|
|
19
|
+
/** What it holds, one under the other. */
|
|
20
|
+
export function Stack({
|
|
21
|
+
gap = '3',
|
|
22
|
+
align,
|
|
23
|
+
justify,
|
|
24
|
+
style,
|
|
25
|
+
...rest
|
|
26
|
+
}) {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
return /*#__PURE__*/_jsx(View, {
|
|
29
|
+
...rest,
|
|
30
|
+
style: [{
|
|
31
|
+
gap: theme.size[`space.${gap}`],
|
|
32
|
+
alignItems: align,
|
|
33
|
+
justifyContent: justify
|
|
34
|
+
}, style]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** What it holds, side by side, in the direction of the language. */
|
|
38
|
+
export function Row({
|
|
39
|
+
gap = '2',
|
|
40
|
+
align = 'center',
|
|
41
|
+
justify,
|
|
42
|
+
wrap,
|
|
43
|
+
style,
|
|
44
|
+
...rest
|
|
45
|
+
}) {
|
|
46
|
+
const theme = useTheme();
|
|
47
|
+
return /*#__PURE__*/_jsx(View, {
|
|
48
|
+
...rest,
|
|
49
|
+
style: [{
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
flexWrap: wrap ? 'wrap' : 'nowrap',
|
|
52
|
+
gap: theme.size[`space.${gap}`],
|
|
53
|
+
alignItems: align,
|
|
54
|
+
justifyContent: justify
|
|
55
|
+
}, style]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A rule between two things. It is not there for a screen reader. */
|
|
60
|
+
export function Divider({
|
|
61
|
+
style,
|
|
62
|
+
...rest
|
|
63
|
+
}) {
|
|
64
|
+
const theme = useTheme();
|
|
65
|
+
return /*#__PURE__*/_jsx(View, {
|
|
66
|
+
"aria-hidden": true,
|
|
67
|
+
importantForAccessibility: "no",
|
|
68
|
+
...rest,
|
|
69
|
+
style: [{
|
|
70
|
+
height: 1,
|
|
71
|
+
backgroundColor: theme.color['border.default']
|
|
72
|
+
}, style]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","useTheme","jsx","_jsx","fill","flexGrow","flexShrink","flexBasis","Stack","gap","align","justify","style","rest","theme","size","alignItems","justifyContent","Row","wrap","flexDirection","flexWrap","Divider","importantForAccessibility","height","backgroundColor","color"],"sourceRoot":"../../src","sources":["layout.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAwC,cAAc;AACnE,SAASC,QAAQ,QAAQ,YAAS;;AAElC;AACA;AACA;AACA;AAHA,SAAAC,GAAA,IAAAC,IAAA;AAIA,OAAO,MAAMC,IAAe,GAAG;EAAEC,QAAQ,EAAE,CAAC;EAAEC,UAAU,EAAE,CAAC;EAAEC,SAAS,EAAE;AAAO,CAAC;;AAEhF;;AASA;AACA,OAAO,SAASC,KAAKA,CAAC;EAAEC,GAAG,GAAG,GAAG;EAAEC,KAAK;EAAEC,OAAO;EAAEC,KAAK;EAAE,GAAGC;AAAiB,CAAC,EAAE;EAC/E,MAAMC,KAAK,GAAGb,QAAQ,CAAC,CAAC;EACxB,oBAAOE,IAAA,CAACH,IAAI;IAAA,GAAKa,IAAI;IAAED,KAAK,EAAE,CAAC;MAAEH,GAAG,EAAEK,KAAK,CAACC,IAAI,CAAC,SAASN,GAAG,EAAE,CAAC;MAAEO,UAAU,EAAEN,KAAK;MAAEO,cAAc,EAAEN;IAAQ,CAAC,EAAEC,KAAK;EAAE,CAAE,CAAC;AAC5H;AAOA;AACA,OAAO,SAASM,GAAGA,CAAC;EAAET,GAAG,GAAG,GAAG;EAAEC,KAAK,GAAG,QAAQ;EAAEC,OAAO;EAAEQ,IAAI;EAAEP,KAAK;EAAE,GAAGC;AAAe,CAAC,EAAE;EAC5F,MAAMC,KAAK,GAAGb,QAAQ,CAAC,CAAC;EACxB,oBAAOE,IAAA,CAACH,IAAI;IAAA,GAAKa,IAAI;IAAED,KAAK,EAAE,CAAC;MAAEQ,aAAa,EAAE,KAAK;MAAEC,QAAQ,EAAEF,IAAI,GAAG,MAAM,GAAG,QAAQ;MAAEV,GAAG,EAAEK,KAAK,CAACC,IAAI,CAAC,SAASN,GAAG,EAAE,CAAC;MAAEO,UAAU,EAAEN,KAAK;MAAEO,cAAc,EAAEN;IAAQ,CAAC,EAAEC,KAAK;EAAE,CAAE,CAAC;AACtL;;AAEA;AACA,OAAO,SAASU,OAAOA,CAAC;EAAEV,KAAK;EAAE,GAAGC;AAAgB,CAAC,EAAE;EACrD,MAAMC,KAAK,GAAGb,QAAQ,CAAC,CAAC;EACxB,oBAAOE,IAAA,CAACH,IAAI;IAAC,mBAAW;IAACuB,yBAAyB,EAAC,IAAI;IAAA,GAAKV,IAAI;IAAED,KAAK,EAAE,CAAC;MAAEY,MAAM,EAAE,CAAC;MAAEC,eAAe,EAAEX,KAAK,CAACY,KAAK,CAAC,gBAAgB;IAAE,CAAC,EAAEd,KAAK;EAAE,CAAE,CAAC;AACrJ","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Marks drawn with views, without SVG, for the pieces of the main entry: a tick, a dash and an exclamation. Each
|
|
5
|
+
* stroke is a bar that grows from where it starts, turned along it; the next one starts where it ends. Only
|
|
6
|
+
* `transform` and `opacity` move. (SPEC §15.14)
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { View } from 'react-native';
|
|
10
|
+
import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
11
|
+
import { spring } from "./motion.js";
|
|
12
|
+
|
|
13
|
+
/** x1 y1 x2 y2, on the 16 × 16 grid of the icons. */
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
/** As the icon `tick`. */
|
|
16
|
+
export const TICK = [[3.5, 8.5, 6.5, 11.5], [6.5, 11.5, 12.5, 4.5]];
|
|
17
|
+
export const DASH = [[4, 8, 12, 8]];
|
|
18
|
+
/** A bar, then its dot. */
|
|
19
|
+
export const BANG = [[8, 3.5, 8, 9], [8, 12, 8, 12]];
|
|
20
|
+
const length = ([x1, y1, x2, y2]) => Math.hypot(x2 - x1, y2 - y1);
|
|
21
|
+
export function Mark({
|
|
22
|
+
segments,
|
|
23
|
+
shown,
|
|
24
|
+
size = 16,
|
|
25
|
+
color,
|
|
26
|
+
stroke,
|
|
27
|
+
style,
|
|
28
|
+
testID
|
|
29
|
+
}) {
|
|
30
|
+
const t = useSharedValue(shown ? 1 : 0);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
t.value = spring(shown ? 1 : 0, 'snappy');
|
|
33
|
+
}, [shown, t]);
|
|
34
|
+
// A dot has no length: it takes a share of the way as if it were a short stroke.
|
|
35
|
+
const lengths = segments.map(s => Math.max(length(s), 1));
|
|
36
|
+
const total = lengths.reduce((a, b) => a + b, 0);
|
|
37
|
+
let from = 0;
|
|
38
|
+
return /*#__PURE__*/_jsx(View, {
|
|
39
|
+
testID: testID,
|
|
40
|
+
"aria-hidden": true,
|
|
41
|
+
pointerEvents: "none",
|
|
42
|
+
style: [{
|
|
43
|
+
width: size,
|
|
44
|
+
height: size
|
|
45
|
+
}, style],
|
|
46
|
+
children: segments.map((segment, i) => {
|
|
47
|
+
const part = lengths[i] / total;
|
|
48
|
+
const bar = /*#__PURE__*/_jsx(Bar, {
|
|
49
|
+
segment: segment,
|
|
50
|
+
from: from,
|
|
51
|
+
part: part,
|
|
52
|
+
t: t,
|
|
53
|
+
k: size / 16,
|
|
54
|
+
h: stroke ?? 1.5 * size / 16,
|
|
55
|
+
color: color
|
|
56
|
+
}, i);
|
|
57
|
+
from += part;
|
|
58
|
+
return bar;
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function Bar({
|
|
63
|
+
segment,
|
|
64
|
+
from,
|
|
65
|
+
part,
|
|
66
|
+
t,
|
|
67
|
+
k,
|
|
68
|
+
h,
|
|
69
|
+
color
|
|
70
|
+
}) {
|
|
71
|
+
const [x1, y1, x2, y2] = segment;
|
|
72
|
+
const angle = Math.atan2(y2 - y1, x2 - x1);
|
|
73
|
+
const grow = useAnimatedStyle(() => {
|
|
74
|
+
const local = Math.min(1, Math.max(0, (t.value - from) / part));
|
|
75
|
+
// Below 2 % it is not there: the spring that unwrites it swings past 0 and would show a sliver.
|
|
76
|
+
return {
|
|
77
|
+
opacity: local > 0.02 ? 1 : 0,
|
|
78
|
+
transform: [{
|
|
79
|
+
rotate: `${angle}rad`
|
|
80
|
+
}, {
|
|
81
|
+
scaleX: Math.max(local, 0.001)
|
|
82
|
+
}]
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
// Round ends, as the stroke of the icons: the bar reaches half its width past each end.
|
|
86
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
87
|
+
style: [{
|
|
88
|
+
position: 'absolute',
|
|
89
|
+
left: x1 * k - h / 2,
|
|
90
|
+
top: y1 * k - h / 2,
|
|
91
|
+
width: length(segment) * k + h,
|
|
92
|
+
height: h,
|
|
93
|
+
borderRadius: h / 2,
|
|
94
|
+
backgroundColor: color,
|
|
95
|
+
transformOrigin: [h / 2, h / 2, 0]
|
|
96
|
+
}, grow]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=marks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","View","Animated","useAnimatedStyle","useSharedValue","spring","jsx","_jsx","TICK","DASH","BANG","length","x1","y1","x2","y2","Math","hypot","Mark","segments","shown","size","color","stroke","style","testID","t","value","lengths","map","s","max","total","reduce","a","b","from","pointerEvents","width","height","children","segment","i","part","bar","Bar","k","h","angle","atan2","grow","local","min","opacity","transform","rotate","scaleX","position","left","top","borderRadius","backgroundColor","transformOrigin"],"sourceRoot":"../../src","sources":["marks.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,IAAI,QAAwC,cAAc;AACnE,OAAOC,QAAQ,IAAIC,gBAAgB,EAAEC,cAAc,QAA0B,yBAAyB;AACtG,SAASC,MAAM,QAAQ,aAAU;;AAEjC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGA;AACA,OAAO,MAAMC,IAAwB,GAAG,CACtC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EACrB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CACvB;AACD,OAAO,MAAMC,IAAwB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACvD;AACA,OAAO,MAAMC,IAAwB,GAAG,CACtC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EACd,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CACf;AAeD,MAAMC,MAAM,GAAGA,CAAC,CAACC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,CAAU,KAAaC,IAAI,CAACC,KAAK,CAACH,EAAE,GAAGF,EAAE,EAAEG,EAAE,GAAGF,EAAE,CAAC;AAElF,OAAO,SAASK,IAAIA,CAAC;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,IAAI,GAAG,EAAE;EAAEC,KAAK;EAAEC,MAAM;EAAEC,KAAK;EAAE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AEb,CAAC,GAAG,CAAC;MAAEc,eAAe,EAAEvC,KAAK;MAAEwC,eAAe,EAAE,CAACf,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAE,CAAC;IAAE,CAAC,EAC/LG,IAAI;EACJ,CACH,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The motion vocabulary of Fluxus on Reanimated: the same names, durations and
|
|
5
|
+
* springs as the web (core/src/tokens.ts). With reduced motion on in the system,
|
|
6
|
+
* a value goes to its end at once. (SPEC §15, §15.12)
|
|
7
|
+
*/
|
|
8
|
+
import { Easing, ReduceMotion, defineAnimation, makeMutable, withSpring, withTiming } from 'react-native-reanimated';
|
|
9
|
+
import { motion } from "./generated/tokens.js";
|
|
10
|
+
/** How many times slower than real every animation of Fluxus runs: 1 is real time. The UI thread reads `slow`. */
|
|
11
|
+
const slow = makeMutable(1);
|
|
12
|
+
let scale = 1;
|
|
13
|
+
|
|
14
|
+
/** For a screen that shows the motion, or to look at it closely: 4 makes everything four times slower. */
|
|
15
|
+
export const setMotionScale = k => {
|
|
16
|
+
scale = Math.max(1, k);
|
|
17
|
+
slow.value = scale;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** A duration in ms, at the speed the motion runs. On the JS thread, and safe while rendering. */
|
|
21
|
+
export const ms = duration => duration * scale;
|
|
22
|
+
export const spring = (to, preset = 'smooth') => {
|
|
23
|
+
'worklet';
|
|
24
|
+
|
|
25
|
+
const k = slow.value;
|
|
26
|
+
const {
|
|
27
|
+
stiffness,
|
|
28
|
+
damping,
|
|
29
|
+
mass
|
|
30
|
+
} = motion.spring[preset];
|
|
31
|
+
// The same curve, k times longer: time stretches, the shape stays.
|
|
32
|
+
return withSpring(to, {
|
|
33
|
+
stiffness: stiffness / (k * k),
|
|
34
|
+
damping: damping / k,
|
|
35
|
+
mass,
|
|
36
|
+
reduceMotion: ReduceMotion.System
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export const timing = (to, duration = 'normal', easing = 'standard') => {
|
|
40
|
+
'worklet';
|
|
41
|
+
|
|
42
|
+
const [a, b, c, d] = motion.easing[easing];
|
|
43
|
+
return withTiming(to, {
|
|
44
|
+
duration: motion.duration[duration] * slow.value,
|
|
45
|
+
easing: Easing.bezier(a, b, c, d),
|
|
46
|
+
reduceMotion: ReduceMotion.System
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The spring of the web (core/src/spring.ts): semi-implicit Euler in steps of 1/120 s. Started over another,
|
|
51
|
+
* it keeps its speed, wherever that points: a value sent back turns round, as `retarget` does on the web.
|
|
52
|
+
*/
|
|
53
|
+
export function withFluxSpring(toValue, config, callback) {
|
|
54
|
+
'worklet';
|
|
55
|
+
|
|
56
|
+
const k = slow.value;
|
|
57
|
+
return defineAnimation(toValue, () => {
|
|
58
|
+
'worklet';
|
|
59
|
+
|
|
60
|
+
const restDelta = config.restDelta ?? 0.01;
|
|
61
|
+
const restSpeed = config.restSpeed ?? 0.01;
|
|
62
|
+
const onFrame = (a, now) => {
|
|
63
|
+
let left = Math.min(Math.max(0, now - a.last) / 1000, 4 / 60) / k;
|
|
64
|
+
a.last = now;
|
|
65
|
+
while (left > 0) {
|
|
66
|
+
const dt = Math.min(1 / 120, left);
|
|
67
|
+
left -= dt;
|
|
68
|
+
a.velocity += (-config.stiffness * (a.current - a.toValue) - config.damping * a.velocity) * dt;
|
|
69
|
+
a.current += a.velocity * dt;
|
|
70
|
+
}
|
|
71
|
+
if (Math.abs(a.current - a.toValue) < restDelta && Math.abs(a.velocity) < restSpeed) {
|
|
72
|
+
a.current = a.toValue;
|
|
73
|
+
a.velocity = 0;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
const onStart = (a, value, now, previous) => {
|
|
79
|
+
a.current = value;
|
|
80
|
+
a.last = now;
|
|
81
|
+
a.velocity = (previous?.velocity ?? 0) + (config.velocity ?? 0);
|
|
82
|
+
};
|
|
83
|
+
// Not its target: Reanimated skips an animation whose target is where the value already is, and a push starts there.
|
|
84
|
+
return {
|
|
85
|
+
onFrame,
|
|
86
|
+
onStart,
|
|
87
|
+
toValue,
|
|
88
|
+
current: Number.NaN,
|
|
89
|
+
velocity: 0,
|
|
90
|
+
last: 0,
|
|
91
|
+
callback
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Easing","ReduceMotion","defineAnimation","makeMutable","withSpring","withTiming","motion","slow","scale","setMotionScale","k","Math","max","value","ms","duration","spring","to","preset","stiffness","damping","mass","reduceMotion","System","timing","easing","a","b","c","d","bezier","withFluxSpring","toValue","config","callback","restDelta","restSpeed","onFrame","now","left","min","last","dt","velocity","current","abs","onStart","previous","Number","NaN"],"sourceRoot":"../../src","sources":["motion.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,YAAY,EAAEC,eAAe,EAAEC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAAgC,yBAAyB;AAC5I,SAASC,MAAM,QAAQ,uBAAoB;AAM3C;AACA,MAAMC,IAAI,GAAGJ,WAAW,CAAC,CAAC,CAAC;AAC3B,IAAIK,KAAK,GAAG,CAAC;;AAEb;AACA,OAAO,MAAMC,cAAc,GAAIC,CAAS,IAAW;EACjDF,KAAK,GAAGG,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,CAAC,CAAC;EACtBH,IAAI,CAACM,KAAK,GAAGL,KAAK;AACpB,CAAC;;AAED;AACA,OAAO,MAAMM,EAAE,GAAIC,QAAgB,IAAaA,QAAQ,GAAGP,KAAK;AAEhE,OAAO,MAAMQ,MAAM,GAAGA,CAACC,EAAU,EAAEC,MAAoB,GAAG,QAAQ,KAAa;EA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AAQ,EAAEJ,QAAQ,IAAI,CAAC,KAAKV,MAAM,CAACU,QAAQ,IAAI,CAAC,CAAC;IACjE,CAAC;IACD;IACA,OAAO;MAAEN,OAAO;MAAES,OAAO;MAAEd,OAAO;MAAEY,OAAO,EAAEI,MAAM,CAACC,GAAG;MAAEN,QAAQ,EAAE,CAAC;MAAEF,IAAI,EAAE,CAAC;MAAEP;IAAS,CAAC;EAC3F,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What opens above everything: a window of React Native (`Modal`) that paints and moves nothing of its own,
|
|
5
|
+
* where Fluxus draws the veil and moves the panel. Back on Android, Escape in a browser and the scrub of
|
|
6
|
+
* VoiceOver close it. (SPEC §15.8)
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import { AccessibilityInfo, Modal, Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
10
|
+
import Animated, { useAnimatedStyle, useReducedMotion, useSharedValue } from 'react-native-reanimated';
|
|
11
|
+
import { motion } from "./generated/tokens.js";
|
|
12
|
+
import { ms, spring, timing } from "./motion.js";
|
|
13
|
+
import { useTheme } from "./theme.js";
|
|
14
|
+
import { ToastLayer } from "./Toast.js";
|
|
15
|
+
|
|
16
|
+
/** A screen reader goes to it: to the title on opening, back to what opened it on closing. */
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
export const focusOn = target => {
|
|
19
|
+
if (target && Platform.OS !== 'web') AccessibilityInfo.sendAccessibilityEvent(target, 'focus');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The surface of what floats: raised, edged, and with the one shadow of the package. */
|
|
23
|
+
export const floating = theme => ({
|
|
24
|
+
borderWidth: 1,
|
|
25
|
+
borderColor: theme.color['border.default'],
|
|
26
|
+
borderRadius: theme.size['radius.card'],
|
|
27
|
+
backgroundColor: theme.color['surface.raised'],
|
|
28
|
+
boxShadow: [{
|
|
29
|
+
offsetX: 0,
|
|
30
|
+
offsetY: theme.size['space.2'],
|
|
31
|
+
blurRadius: theme.size['space.6'],
|
|
32
|
+
color: theme.color['shadow.tint']
|
|
33
|
+
}]
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** `mounted` outlives `open` by the time it takes to go; `t` goes 0 → 1 as it comes and back as it goes. */
|
|
37
|
+
export function useOverlay(open) {
|
|
38
|
+
const reduced = useReducedMotion();
|
|
39
|
+
const [mounted, setMounted] = useState(open);
|
|
40
|
+
const t = useSharedValue(0);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (open) {
|
|
43
|
+
setMounted(true);
|
|
44
|
+
t.value = spring(1, 'smooth');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
t.value = timing(0, 'fast', 'accelerate');
|
|
48
|
+
const timer = setTimeout(() => setMounted(false), reduced ? 0 : ms(motion.duration.fast));
|
|
49
|
+
return () => clearTimeout(timer);
|
|
50
|
+
}, [open, reduced, t]);
|
|
51
|
+
return {
|
|
52
|
+
mounted,
|
|
53
|
+
t
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function Overlay({
|
|
57
|
+
open,
|
|
58
|
+
onClose,
|
|
59
|
+
veil = true,
|
|
60
|
+
dismissible = true,
|
|
61
|
+
onShow,
|
|
62
|
+
children
|
|
63
|
+
}) {
|
|
64
|
+
const theme = useTheme();
|
|
65
|
+
const {
|
|
66
|
+
mounted,
|
|
67
|
+
t
|
|
68
|
+
} = useOverlay(open);
|
|
69
|
+
const fade = useAnimatedStyle(() => ({
|
|
70
|
+
opacity: t.value
|
|
71
|
+
}));
|
|
72
|
+
if (!mounted) return null;
|
|
73
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
74
|
+
transparent: true,
|
|
75
|
+
visible: true,
|
|
76
|
+
animationType: "none",
|
|
77
|
+
statusBarTranslucent: true,
|
|
78
|
+
navigationBarTranslucent: true,
|
|
79
|
+
onRequestClose: onClose,
|
|
80
|
+
onShow: onShow,
|
|
81
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
82
|
+
style: StyleSheet.absoluteFill,
|
|
83
|
+
onAccessibilityEscape: onClose,
|
|
84
|
+
children: [veil && /*#__PURE__*/_jsx(Animated.View, {
|
|
85
|
+
pointerEvents: "none",
|
|
86
|
+
style: [StyleSheet.absoluteFill, {
|
|
87
|
+
backgroundColor: theme.color['surface.overlay']
|
|
88
|
+
}, fade]
|
|
89
|
+
}), /*#__PURE__*/_jsx(Pressable, {
|
|
90
|
+
"aria-hidden": true,
|
|
91
|
+
accessible: false,
|
|
92
|
+
tabIndex: -1,
|
|
93
|
+
style: StyleSheet.absoluteFill,
|
|
94
|
+
onPress: dismissible ? onClose : undefined
|
|
95
|
+
}), children(t), /*#__PURE__*/_jsx(ToastLayer, {})]
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useState","AccessibilityInfo","Modal","Platform","Pressable","StyleSheet","View","Animated","useAnimatedStyle","useReducedMotion","useSharedValue","motion","ms","spring","timing","useTheme","ToastLayer","jsx","_jsx","jsxs","_jsxs","focusOn","target","OS","sendAccessibilityEvent","floating","theme","borderWidth","borderColor","color","borderRadius","size","backgroundColor","boxShadow","offsetX","offsetY","blurRadius","useOverlay","open","reduced","mounted","setMounted","t","value","timer","setTimeout","duration","fast","clearTimeout","Overlay","onClose","veil","dismissible","onShow","children","fade","opacity","transparent","visible","animationType","statusBarTranslucent","navigationBarTranslucent","onRequestClose","style","absoluteFill","onAccessibilityEscape","pointerEvents","accessible","tabIndex","onPress","undefined"],"sourceRoot":"../../src","sources":["overlay.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,QAAwB,OAAO;AAC3D,SAASC,i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;IAAAC,QAAA,eACpIlC,KAAA,CAACd,IAAI;MAACyD,KAAK,EAAE1D,UAAU,CAAC2D,YAAa;MAACC,qBAAqB,EAAEf,OAAQ;MAAAI,QAAA,GAClEH,IAAI,iBAAIjC,IAAA,CAACX,QAAQ,CAACD,IAAI;QAAC4D,aAAa,EAAC,MAAM;QAACH,KAAK,EAAE,CAAC1D,UAAU,CAAC2D,YAAY,EAAE;UAAEhC,eAAe,EAAEN,KAAK,CAACG,KAAK,CAAC,iBAAiB;QAAE,CAAC,EAAE0B,IAAI;MAAE,CAAE,CAAC,eAE5IrC,IAAA,CAACd,SAAS;QAAC,mBAAW;QAAC+D,UAAU,EAAE,KAAM;QAACC,QAAQ,EAAE,CAAC,CAAE;QAACL,KAAK,EAAE1D,UAAU,CAAC2D,YAAa;QAACK,OAAO,EAAEjB,WAAW,GAAGF,OAAO,GAAGoB;MAAU,CAAE,CAAC,EACrIhB,QAAQ,CAACZ,CAAC,CAAC,eAEZxB,IAAA,CAACF,UAAU,IAAE,CAAC;IAAA,CACV;EAAC,CACF,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The wait is born from the finger, as on the web (core/src/pending.ts, SPEC §14.35): what was pressed and now
|
|
5
|
+
* waits fills slowly from where it was touched, never to the whole; when the answer comes it fills and goes,
|
|
6
|
+
* and if it failed it drains back to the finger. A wait shorter than 150 ms shows nothing; once seen, it lasts
|
|
7
|
+
* 400 ms at least. (SPEC §15.6, §15.9)
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
|
+
import Animated, { Easing, ReduceMotion, useAnimatedStyle, useReducedMotion, useSharedValue, withDelay, withTiming } from 'react-native-reanimated';
|
|
11
|
+
import { motion } from "./generated/tokens.js";
|
|
12
|
+
import { ms } from "./motion.js";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
const DELAY = 150;
|
|
15
|
+
const MIN_VISIBLE = 400;
|
|
16
|
+
/** How far it gets by itself, of the way to the farthest corner, and the weight of its colour. */
|
|
17
|
+
const REACH = 0.9;
|
|
18
|
+
const TINT = 0.14;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `onPress` may return a promise: until it settles, what was pressed waits. If it is rejected, it failed: the
|
|
22
|
+
* third value is true until the next press. The rejection goes no further: the app has its own `catch`. `onEnd`
|
|
23
|
+
* hears how it ended, even when it ends before a render shows it waiting.
|
|
24
|
+
*/
|
|
25
|
+
export function useAsyncPress(onPress, onEnd) {
|
|
26
|
+
const [state, setState] = useState('idle');
|
|
27
|
+
const alive = useRef(true);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
alive.current = true;
|
|
30
|
+
return () => {
|
|
31
|
+
alive.current = false;
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
const run = event => {
|
|
35
|
+
const result = onPress?.(event);
|
|
36
|
+
if (typeof result?.then !== 'function') return;
|
|
37
|
+
setState('waiting');
|
|
38
|
+
const end = next => () => {
|
|
39
|
+
if (!alive.current) return;
|
|
40
|
+
setState(next);
|
|
41
|
+
onEnd?.(next === 'failed');
|
|
42
|
+
};
|
|
43
|
+
result.then(end('idle'), end('failed'));
|
|
44
|
+
};
|
|
45
|
+
return [state === 'waiting', run, state === 'failed'];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** `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. */
|
|
49
|
+
export function settle(result, done) {
|
|
50
|
+
const promise = result;
|
|
51
|
+
if (typeof promise?.then !== 'function') return done();
|
|
52
|
+
return Promise.resolve(promise).then(done, () => undefined);
|
|
53
|
+
}
|
|
54
|
+
/** Mounted only while something waits: at rest, what can wait carries no animated view. */
|
|
55
|
+
function Fill({
|
|
56
|
+
x,
|
|
57
|
+
y,
|
|
58
|
+
radius,
|
|
59
|
+
ink,
|
|
60
|
+
ending
|
|
61
|
+
}) {
|
|
62
|
+
const reduced = useReducedMotion();
|
|
63
|
+
const grow = useSharedValue(reduced ? 1 : 0);
|
|
64
|
+
const fade = useSharedValue(1);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const fast = ms(motion.duration.fast);
|
|
67
|
+
if (ending === 'failed') grow.value = withTiming(0, {
|
|
68
|
+
duration: ms(motion.duration.normal),
|
|
69
|
+
reduceMotion: ReduceMotion.System
|
|
70
|
+
});else if (ending) {
|
|
71
|
+
grow.value = withTiming(1, {
|
|
72
|
+
duration: fast,
|
|
73
|
+
reduceMotion: ReduceMotion.System
|
|
74
|
+
});
|
|
75
|
+
fade.value = withDelay(fast, withTiming(0, {
|
|
76
|
+
duration: fast,
|
|
77
|
+
reduceMotion: ReduceMotion.System
|
|
78
|
+
}));
|
|
79
|
+
// It slows as it goes and never gets there: it does not pretend to know how long.
|
|
80
|
+
} else if (!reduced) grow.value = withTiming(REACH, {
|
|
81
|
+
duration: ms(4000),
|
|
82
|
+
easing: Easing.out(Easing.exp)
|
|
83
|
+
});
|
|
84
|
+
}, [ending, reduced, grow, fade]);
|
|
85
|
+
const style = useAnimatedStyle(() => ({
|
|
86
|
+
opacity: fade.value * TINT,
|
|
87
|
+
transform: [{
|
|
88
|
+
scale: grow.value
|
|
89
|
+
}]
|
|
90
|
+
}));
|
|
91
|
+
// Where the finger was, in the points of the element: `left` and `top`, not the direction of the language.
|
|
92
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
93
|
+
pointerEvents: "none",
|
|
94
|
+
"aria-hidden": true,
|
|
95
|
+
style: [{
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
left: x - radius,
|
|
98
|
+
top: y - radius,
|
|
99
|
+
width: 2 * radius,
|
|
100
|
+
height: 2 * radius,
|
|
101
|
+
borderRadius: radius,
|
|
102
|
+
backgroundColor: ink
|
|
103
|
+
}, style]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* For what is pressed and may wait. Give it `onPressIn` and `onLayout`, put `fill` first inside it, and clip it
|
|
109
|
+
* (`overflow: 'hidden'`). `ink` is the colour of its text; `failed`, whether the wait that ends now did.
|
|
110
|
+
*/
|
|
111
|
+
export function usePending(waiting, ink, failed = false) {
|
|
112
|
+
const [phase, setPhase] = useState('idle');
|
|
113
|
+
const how = useRef(failed);
|
|
114
|
+
how.current = failed;
|
|
115
|
+
const origin = useRef(null);
|
|
116
|
+
const size = useRef({
|
|
117
|
+
w: 0,
|
|
118
|
+
h: 0
|
|
119
|
+
});
|
|
120
|
+
const since = useRef(0);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (waiting) {
|
|
123
|
+
const timer = setTimeout(() => {
|
|
124
|
+
since.current = Date.now();
|
|
125
|
+
setPhase('shown');
|
|
126
|
+
}, DELAY);
|
|
127
|
+
return () => clearTimeout(timer);
|
|
128
|
+
}
|
|
129
|
+
if (phase !== 'shown') return;
|
|
130
|
+
let last;
|
|
131
|
+
const timer = setTimeout(() => {
|
|
132
|
+
setPhase(how.current ? 'failed' : 'done');
|
|
133
|
+
last = setTimeout(() => setPhase('idle'), ms(how.current ? motion.duration.normal : motion.duration.fast * 2));
|
|
134
|
+
}, Math.max(0, MIN_VISIBLE - (Date.now() - since.current)));
|
|
135
|
+
return () => {
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
clearTimeout(last);
|
|
138
|
+
};
|
|
139
|
+
// `phase` is read, not followed: only a change of `waiting` moves it on.
|
|
140
|
+
}, [waiting]);
|
|
141
|
+
const {
|
|
142
|
+
w,
|
|
143
|
+
h
|
|
144
|
+
} = size.current;
|
|
145
|
+
const at = origin.current ?? {
|
|
146
|
+
x: w / 2,
|
|
147
|
+
y: h / 2
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
onPressIn(e) {
|
|
151
|
+
// The event gives the point in the window; the element says where it is in it.
|
|
152
|
+
origin.current = null;
|
|
153
|
+
// Pressed with a keyboard there is no point: it fills from the centre.
|
|
154
|
+
if (!e?.nativeEvent) return;
|
|
155
|
+
const {
|
|
156
|
+
pageX,
|
|
157
|
+
pageY
|
|
158
|
+
} = e.nativeEvent;
|
|
159
|
+
e.currentTarget?.measureInWindow?.((x, y) => {
|
|
160
|
+
origin.current = {
|
|
161
|
+
x: pageX - x,
|
|
162
|
+
y: pageY - y
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
onLayout(e) {
|
|
167
|
+
size.current = {
|
|
168
|
+
w: e.nativeEvent.layout.width,
|
|
169
|
+
h: e.nativeEvent.layout.height
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
fill: phase === 'idle' ? null : /*#__PURE__*/_jsx(Fill, {
|
|
173
|
+
x: at.x,
|
|
174
|
+
y: at.y,
|
|
175
|
+
radius: Math.hypot(Math.max(at.x, w - at.x), Math.max(at.y, h - at.y)),
|
|
176
|
+
ink: ink,
|
|
177
|
+
ending: phase === 'shown' ? false : phase
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=pending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","Animated","Easing","ReduceMotion","useAnimatedStyle","useReducedMotion","useSharedValue","withDelay","withTiming","motion","ms","jsx","_jsx","DELAY","MIN_VISIBLE","REACH","TINT","useAsyncPress","onPress","onEnd","state","setState","alive","current","run","event","result","then","end","next","settle","done","promise","Promise","resolve","undefined","Fill","x","y","radius","ink","ending","reduced","grow","fade","fast","duration","value","normal","reduceMotion","System","easing","out","exp","style","opacity","transform","scale","View","pointerEvents","position","left","top","width","height","borderRadius","backgroundColor","usePending","waiting","failed","phase","setPhase","how","origin","size","w","h","since","timer","setTimeout","Date","now","clearTimeout","last","Math","max","at","onPressIn","e","nativeEvent","pageX","pageY","currentTarget","measureInWindow","onLayout","layout","fill","hypot"],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E,CAACjD,CAAC,CAAC,EAAE+C,IAAI,CAACC,GAAG,CAACC,EAAE,CAAChD,CAAC,EAAEsC,CAAC,GAAGU,EAAE,CAAChD,CAAC,CAAC,CAAE;MAACE,GAAG,EAAEA,GAAI;MAACC,MAAM,EAAE6B,KAAK,KAAK,OAAO,GAAG,KAAK,GAAGA;IAAM,CAAE;EACxL,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Nothing jumps: what comes fades in as it rises, what goes fades out, and what
|
|
5
|
+
* stays glides to its new place. The values of the web (core/src/stagger.ts),
|
|
6
|
+
* on the layout animations of Reanimated. With reduced motion on in the system
|
|
7
|
+
* they are immediate. (SPEC §15.4)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Platform } from 'react-native';
|
|
11
|
+
import Animated, { Easing, FadeInDown, FadeOut, LinearTransition, ReduceMotion } from 'react-native-reanimated';
|
|
12
|
+
import { motion } from "./generated/tokens.js";
|
|
13
|
+
import { ms } from "./motion.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const curve = name => {
|
|
16
|
+
const [a, b, c, d] = motion.easing[name];
|
|
17
|
+
return Easing.bezier(a, b, c, d);
|
|
18
|
+
};
|
|
19
|
+
/** How far it rises as it comes, and how long the nth of a group waits for the one before. */
|
|
20
|
+
export const RISE = 12;
|
|
21
|
+
export const STAGGER = 70;
|
|
22
|
+
|
|
23
|
+
/** For `entering`: it fades in as it rises; `index` is its place in a group that comes together. */
|
|
24
|
+
export const enter = (index = 0) => FadeInDown.duration(ms(motion.duration.normal)).delay(ms(index * STAGGER)).easing(curve('decelerate')).withInitialValues({
|
|
25
|
+
transform: [{
|
|
26
|
+
translateY: RISE
|
|
27
|
+
}]
|
|
28
|
+
}).reduceMotion(ReduceMotion.System);
|
|
29
|
+
|
|
30
|
+
/** For `exiting`: it fades out, fast. */
|
|
31
|
+
export const exit = () => FadeOut.duration(ms(motion.duration.fast)).easing(curve('accelerate')).reduceMotion(ReduceMotion.System);
|
|
32
|
+
|
|
33
|
+
/** For `layout`: it glides to where it is now, on the smooth spring. */
|
|
34
|
+
export const shift = () => {
|
|
35
|
+
const {
|
|
36
|
+
stiffness,
|
|
37
|
+
damping,
|
|
38
|
+
mass
|
|
39
|
+
} = motion.spring.smooth;
|
|
40
|
+
const k = ms(1);
|
|
41
|
+
return LinearTransition.springify().stiffness(stiffness / (k * k)).damping(damping / k).mass(mass).reduceMotion(ReduceMotion.System);
|
|
42
|
+
};
|
|
43
|
+
const MADE = new Map();
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The three, for a view that comes, goes and moves. In a browser they are off: there Reanimated pins a view
|
|
47
|
+
* that has them where it first was (`position: absolute`, seen with 4.7.1), and the layout breaks.
|
|
48
|
+
*/
|
|
49
|
+
export const presence = (index = 0) => {
|
|
50
|
+
if (Platform.OS === 'web') return {};
|
|
51
|
+
// One set for each place in a group, made once: a render does not build them again.
|
|
52
|
+
const key = `${index}:${ms(1)}`;
|
|
53
|
+
let made = MADE.get(key);
|
|
54
|
+
if (!made) MADE.set(key, made = {
|
|
55
|
+
entering: enter(index),
|
|
56
|
+
exiting: exit(),
|
|
57
|
+
layout: shift()
|
|
58
|
+
});
|
|
59
|
+
return made;
|
|
60
|
+
};
|
|
61
|
+
/** A view that comes, goes and moves without a jump. Its siblings glide too when each is an Appear. */
|
|
62
|
+
export function Appear({
|
|
63
|
+
index = 0,
|
|
64
|
+
...rest
|
|
65
|
+
}) {
|
|
66
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
67
|
+
...presence(index),
|
|
68
|
+
...rest
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=presence.js.map
|