@kanso-labs/react-native-kanso-ui 0.8.0 → 0.10.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/README.md +4 -3
- package/dist/autocomplete/index.js +15 -1
- package/dist/autocomplete/index.js.map +1 -1
- package/dist/badge/index.js +9 -70
- package/dist/badge/index.js.map +1 -1
- package/dist/button/group.d.ts +5 -0
- package/dist/button/group.js +115 -0
- package/dist/button/group.js.map +1 -0
- package/dist/button/index.d.ts +4 -1
- package/dist/button/index.js +45 -23
- package/dist/button/index.js.map +1 -1
- package/dist/button/palettes.d.ts +2 -0
- package/dist/button/slots.js +2 -1
- package/dist/button/slots.js.map +1 -1
- package/dist/calendar/index.js +351 -182
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/styles.js +33 -2
- package/dist/calendar/styles.js.map +1 -1
- package/dist/carousel/arrangement.d.ts +5 -0
- package/dist/carousel/arrangement.js +123 -0
- package/dist/carousel/arrangement.js.map +1 -0
- package/dist/chequer/index.js +95 -0
- package/dist/chequer/index.js.map +1 -0
- package/dist/collection/index.d.ts +157 -0
- package/dist/collection/index.js +1331 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/color-thumb/index.js +56 -0
- package/dist/color-thumb/index.js.map +1 -0
- package/dist/components/badge/index.d.ts +48 -0
- package/dist/components/badge/index.js +122 -0
- package/dist/components/badge/index.js.map +1 -0
- package/dist/{badge → components/badge}/styles.js +10 -6
- package/dist/components/badge/styles.js.map +1 -0
- package/dist/components/breadcrumbs/index.d.ts +66 -0
- package/dist/components/breadcrumbs/index.js +285 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/button/index.d.ts +4 -2
- package/dist/components/button/index.js +227 -188
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/index.d.ts +87 -0
- package/dist/components/button-group/index.js +275 -0
- package/dist/components/button-group/index.js.map +1 -0
- package/dist/components/calendar/index.d.ts +11 -3
- package/dist/components/calendar/index.js +60 -45
- package/dist/components/calendar/index.js.map +1 -1
- package/dist/components/carousel/index.d.ts +72 -0
- package/dist/components/carousel/index.js +496 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +7 -1
- package/dist/components/checkbox/index.js +183 -138
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +92 -0
- package/dist/components/checkbox-group/index.js +306 -0
- package/dist/components/checkbox-group/index.js.map +1 -0
- package/dist/components/code/index.d.ts +25 -0
- package/dist/components/code/index.js +87 -0
- package/dist/components/code/index.js.map +1 -0
- package/dist/components/color-area/index.d.ts +85 -0
- package/dist/components/color-area/index.js +630 -0
- package/dist/components/color-area/index.js.map +1 -0
- package/dist/components/color-field/index.d.ts +144 -0
- package/dist/components/color-field/index.js +516 -0
- package/dist/components/color-field/index.js.map +1 -0
- package/dist/components/color-picker/index.d.ts +74 -0
- package/dist/components/color-picker/index.js +317 -0
- package/dist/components/color-picker/index.js.map +1 -0
- package/dist/components/color-slider/index.d.ts +82 -0
- package/dist/components/color-slider/index.js +456 -0
- package/dist/components/color-slider/index.js.map +1 -0
- package/dist/components/color-swatch/index.d.ts +46 -0
- package/dist/components/color-swatch/index.js +127 -0
- package/dist/components/color-swatch/index.js.map +1 -0
- package/dist/components/color-swatch-picker/index.d.ts +81 -0
- package/dist/components/color-swatch-picker/index.js +287 -0
- package/dist/components/color-swatch-picker/index.js.map +1 -0
- package/dist/components/color-wheel/index.d.ts +71 -0
- package/dist/components/color-wheel/index.js +407 -0
- package/dist/components/color-wheel/index.js.map +1 -0
- package/dist/components/combo-box/index.d.ts +193 -0
- package/dist/components/combo-box/index.js +616 -0
- package/dist/components/combo-box/index.js.map +1 -0
- package/dist/components/container/index.d.ts +47 -0
- package/dist/components/container/index.js +85 -0
- package/dist/components/container/index.js.map +1 -0
- package/dist/components/date-field/index.d.ts +120 -0
- package/dist/components/date-field/index.js +111 -0
- package/dist/components/date-field/index.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +130 -0
- package/dist/components/date-picker/index.js +310 -0
- package/dist/components/date-picker/index.js.map +1 -0
- package/dist/components/date-range-picker/index.d.ts +139 -0
- package/dist/components/date-range-picker/index.js +421 -0
- package/dist/components/date-range-picker/index.js.map +1 -0
- package/dist/components/disclosure/index.d.ts +94 -0
- package/dist/components/disclosure/index.js +365 -0
- package/dist/components/disclosure/index.js.map +1 -0
- package/dist/components/disclosure-group/index.d.ts +61 -0
- package/dist/components/disclosure-group/index.js +100 -0
- package/dist/components/disclosure-group/index.js.map +1 -0
- package/dist/components/drop-zone/index.d.ts +113 -0
- package/dist/components/drop-zone/index.js +304 -0
- package/dist/components/drop-zone/index.js.map +1 -0
- package/dist/components/fab/index.d.ts +80 -0
- package/dist/components/fab/index.js +246 -0
- package/dist/components/fab/index.js.map +1 -0
- package/dist/components/fab-menu/index.d.ts +120 -0
- package/dist/components/fab-menu/index.js +640 -0
- package/dist/components/fab-menu/index.js.map +1 -0
- package/dist/components/feed/index.d.ts +57 -0
- package/dist/components/feed/index.js +167 -0
- package/dist/components/feed/index.js.map +1 -0
- package/dist/components/form/index.d.ts +3 -2
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +4 -2
- package/dist/components/icon-button/index.js +204 -171
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/keycap/index.d.ts +27 -0
- package/dist/components/keycap/index.js +136 -0
- package/dist/components/keycap/index.js.map +1 -0
- package/dist/components/list/index.d.ts +15 -158
- package/dist/components/list/index.js +21 -1047
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-box/index.d.ts +73 -0
- package/dist/components/list-box/index.js +82 -0
- package/dist/components/list-box/index.js.map +1 -0
- package/dist/components/loading-indicator/index.d.ts +32 -0
- package/dist/components/loading-indicator/index.js +174 -0
- package/dist/components/loading-indicator/index.js.map +1 -0
- package/dist/components/menu/index.js +1 -1
- package/dist/components/navigation-tree/index.d.ts +117 -0
- package/dist/components/navigation-tree/index.js +135 -0
- package/dist/components/navigation-tree/index.js.map +1 -0
- package/dist/components/number-field/index.js +132 -143
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/range-calendar/index.d.ts +69 -0
- package/dist/components/range-calendar/index.js +144 -0
- package/dist/components/range-calendar/index.js.map +1 -0
- package/dist/components/search-view/index.d.ts +78 -0
- package/dist/components/search-view/index.js +570 -0
- package/dist/components/search-view/index.js.map +1 -0
- package/dist/components/select/index.d.ts +152 -0
- package/dist/components/select/index.js +419 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/separator/index.d.ts +3 -2
- package/dist/components/separator/index.js +29 -26
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +111 -0
- package/dist/components/slider/index.js +673 -0
- package/dist/components/slider/index.js.map +1 -0
- package/dist/components/split-button/index.d.ts +77 -0
- package/dist/components/split-button/index.js +354 -0
- package/dist/components/split-button/index.js.map +1 -0
- package/dist/components/supporting-pane/index.d.ts +44 -0
- package/dist/components/supporting-pane/index.js +109 -0
- package/dist/components/supporting-pane/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +196 -0
- package/dist/components/tabs/index.js +1137 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/text/index.d.ts +1 -1
- package/dist/components/text/index.js +49 -21
- package/dist/components/text/index.js.map +1 -1
- package/dist/components/text-area/index.d.ts +145 -0
- package/dist/components/text-area/index.js +231 -0
- package/dist/components/text-area/index.js.map +1 -0
- package/dist/components/time-field/index.d.ts +43 -0
- package/dist/components/time-field/index.js +107 -0
- package/dist/components/time-field/index.js.map +1 -0
- package/dist/components/time-picker/index.d.ts +65 -0
- package/dist/components/time-picker/index.js +1168 -0
- package/dist/components/time-picker/index.js.map +1 -0
- package/dist/components/toolbar/index.d.ts +53 -0
- package/dist/components/toolbar/index.js +185 -0
- package/dist/components/toolbar/index.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +101 -0
- package/dist/components/tooltip/index.js +223 -0
- package/dist/components/tooltip/index.js.map +1 -0
- package/dist/components/tree/index.d.ts +112 -0
- package/dist/components/tree/index.js +157 -0
- package/dist/components/tree/index.js.map +1 -0
- package/dist/control/group.js +23 -0
- package/dist/control/group.js.map +1 -0
- package/dist/disclosure/chevron.js +75 -0
- package/dist/disclosure/chevron.js.map +1 -0
- package/dist/disclosure/index.js +7 -0
- package/dist/disclosure/index.js.map +1 -0
- package/dist/drop/index.d.ts +54 -0
- package/dist/drop/index.js +161 -0
- package/dist/drop/index.js.map +1 -0
- package/dist/fab/index.d.ts +19 -0
- package/dist/fab/index.js +147 -0
- package/dist/fab/index.js.map +1 -0
- package/dist/field/chevron.js +74 -0
- package/dist/field/chevron.js.map +1 -0
- package/dist/field/index.d.ts +2 -1
- package/dist/field/index.js +350 -153
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +27 -0
- package/dist/field/styles.js.map +1 -1
- package/dist/files/index.d.ts +18 -0
- package/dist/files/index.js +107 -0
- package/dist/files/index.js.map +1 -0
- package/dist/form/index.d.ts +6 -4
- package/dist/form/index.js +64 -85
- package/dist/form/index.js.map +1 -1
- package/dist/glyphs/index.js +92 -1
- package/dist/glyphs/index.js.map +1 -1
- package/dist/i18n/index.js +20 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +1394 -34
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +51 -6
- package/dist/index.js +47 -4
- package/dist/indicator/paths.js +23 -1
- package/dist/indicator/paths.js.map +1 -1
- package/dist/modal/index.js +96 -68
- package/dist/modal/index.js.map +1 -1
- package/dist/navigation/index.js +8 -5
- package/dist/navigation/index.js.map +1 -1
- package/dist/number/keyboard.js +16 -0
- package/dist/number/keyboard.js.map +1 -0
- package/dist/overlay/anchored.js +68 -38
- package/dist/overlay/anchored.js.map +1 -1
- package/dist/overlay/keyboard.js +57 -0
- package/dist/overlay/keyboard.js.map +1 -0
- package/dist/overlay/panel.js +173 -19
- package/dist/overlay/panel.js.map +1 -1
- package/dist/overlay/placement.js +16 -2
- package/dist/overlay/placement.js.map +1 -1
- package/dist/picker/index.js +322 -0
- package/dist/picker/index.js.map +1 -0
- package/dist/press/index.d.ts +2 -0
- package/dist/press/index.js +102 -100
- package/dist/press/index.js.map +1 -1
- package/dist/row/index.js +77 -69
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +13 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/segments/field.js +277 -0
- package/dist/segments/field.js.map +1 -0
- package/dist/segments/index.js +574 -0
- package/dist/segments/index.js.map +1 -0
- package/dist/segments/styles.js +24 -0
- package/dist/segments/styles.js.map +1 -0
- package/dist/separator/index.js +7 -0
- package/dist/separator/index.js.map +1 -0
- package/dist/slider/index.js +145 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/swatch/index.js +56 -0
- package/dist/swatch/index.js.map +1 -0
- package/dist/typography/size.js +14 -0
- package/dist/typography/size.js.map +1 -0
- package/package.json +11 -2
- package/dist/badge/styles.js.map +0 -1
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
import { IconStyleContext } from "../../glyphs/icon-style.js";
|
|
2
|
+
import { useTheme } from "../../theme/scope.js";
|
|
3
|
+
import { composeStyles, themedStyles } from "../../theme/styles.js";
|
|
4
|
+
import { usePressFeedback } from "../../press/index.js";
|
|
5
|
+
import { useTypeRole } from "../../typography/roles.js";
|
|
6
|
+
import { CloseGlyph } from "../../glyphs/index.js";
|
|
7
|
+
import { refsOf } from "../../ref/index.js";
|
|
8
|
+
import { AnimatedPressable, buttonStyles } from "../../button/index.js";
|
|
9
|
+
import { DismissLayer, useBackToClose, useFocusOnPlaced, useReturnFocus } from "../../overlay/panel.js";
|
|
10
|
+
import { Overlay } from "../../overlay/host.js";
|
|
11
|
+
import { useAnchoredPlacement } from "../../overlay/anchored.js";
|
|
12
|
+
import { FAB_ICON_SIZES, fabColorsOf, fabCornersOf, fabPalettesOf, fabShadowOf, fabSizesOf } from "../../fab/index.js";
|
|
13
|
+
import { c } from "react/compiler-runtime";
|
|
14
|
+
import { I18nManager, Pressable, StyleSheet, Text, View } from "react-native";
|
|
15
|
+
import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from "react-native-reanimated";
|
|
16
|
+
import { useEffect, useRef, useState } from "react";
|
|
17
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { useMenuTriggerState } from "react-stately/useMenuTriggerState";
|
|
19
|
+
import { useTreeState } from "react-stately/useTreeState";
|
|
20
|
+
//#region src/components/fab-menu/index.tsx
|
|
21
|
+
const CLOSE_SIZE = 20;
|
|
22
|
+
const RISE_FROM = 8;
|
|
23
|
+
const HAS_MENU = { "aria-haspopup": "menu" };
|
|
24
|
+
const CLOSE = /* @__PURE__ */ jsx(CloseGlyph, {});
|
|
25
|
+
const styles = StyleSheet.create({
|
|
26
|
+
base: {
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
flexShrink: 0,
|
|
29
|
+
justifyContent: "center"
|
|
30
|
+
},
|
|
31
|
+
icon: {
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
justifyContent: "center"
|
|
35
|
+
},
|
|
36
|
+
label: { flexShrink: 1 }
|
|
37
|
+
});
|
|
38
|
+
const stylesOf = themedStyles(({ radii, sizing, spacing }) => StyleSheet.create({
|
|
39
|
+
action: {
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
columnGap: spacing.sm,
|
|
42
|
+
flexDirection: "row",
|
|
43
|
+
minHeight: sizing.controlLg,
|
|
44
|
+
minWidth: sizing.controlLg,
|
|
45
|
+
paddingHorizontal: spacing.xl
|
|
46
|
+
},
|
|
47
|
+
corner: { borderRadius: radii.pill },
|
|
48
|
+
menu: {
|
|
49
|
+
alignItems: "flex-end",
|
|
50
|
+
rowGap: spacing.xs
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
/**
|
|
54
|
+
* A FAB that opens a column of related actions above it, and closes them
|
|
55
|
+
* again. The actions are `FabMenu.Item`s.
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <FabMenu aria-label="Label" icon={<PlusIcon />}>
|
|
59
|
+
* <FabMenu.Item icon={<FirstIcon />} id="first">
|
|
60
|
+
* First item
|
|
61
|
+
* </FabMenu.Item>
|
|
62
|
+
* <FabMenu.Item icon={<SecondIcon />} id="second">
|
|
63
|
+
* Second item
|
|
64
|
+
* </FabMenu.Item>
|
|
65
|
+
* </FabMenu>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* `style`, `ref` and `testID` land on the FAB, which is what a call site
|
|
69
|
+
* positions over its screen.
|
|
70
|
+
*/
|
|
71
|
+
function FabMenu(t0) {
|
|
72
|
+
const $ = c(51);
|
|
73
|
+
const { "aria-label": label, children, defaultOpen, icon, isOpen, onAction, onOpenChange, ref, size: t1, style, testID, tone: t2 } = t0;
|
|
74
|
+
const size = t1 === void 0 ? "md" : t1;
|
|
75
|
+
const tone = t2 === void 0 ? "primary" : t2;
|
|
76
|
+
const theme = useTheme();
|
|
77
|
+
let t3;
|
|
78
|
+
if ($[0] !== defaultOpen || $[1] !== isOpen || $[2] !== onOpenChange) {
|
|
79
|
+
t3 = {
|
|
80
|
+
defaultOpen,
|
|
81
|
+
isOpen,
|
|
82
|
+
onOpenChange
|
|
83
|
+
};
|
|
84
|
+
$[0] = defaultOpen;
|
|
85
|
+
$[1] = isOpen;
|
|
86
|
+
$[2] = onOpenChange;
|
|
87
|
+
$[3] = t3;
|
|
88
|
+
} else t3 = $[3];
|
|
89
|
+
const state = useMenuTriggerState(t3);
|
|
90
|
+
const open = state.isOpen;
|
|
91
|
+
const fab = useRef(null);
|
|
92
|
+
const anchor = useCloseButtonAnchor(fab, theme.sizing.controlLg);
|
|
93
|
+
const { content } = fabColorsOf(theme)[open ? "filled" : "tonal"][tone];
|
|
94
|
+
const feedback = usePressFeedback({ color: content });
|
|
95
|
+
const morph = useCloseMorph(open, size, tone);
|
|
96
|
+
let t4;
|
|
97
|
+
if ($[4] !== state) {
|
|
98
|
+
t4 = () => {
|
|
99
|
+
state.toggle();
|
|
100
|
+
};
|
|
101
|
+
$[4] = state;
|
|
102
|
+
$[5] = t4;
|
|
103
|
+
} else t4 = $[5];
|
|
104
|
+
const toggle = t4;
|
|
105
|
+
let t5;
|
|
106
|
+
if ($[6] !== state) {
|
|
107
|
+
t5 = () => {
|
|
108
|
+
state.close();
|
|
109
|
+
};
|
|
110
|
+
$[6] = state;
|
|
111
|
+
$[7] = t5;
|
|
112
|
+
} else t5 = $[7];
|
|
113
|
+
const close = t5;
|
|
114
|
+
useReturnFocus(open, false, fab);
|
|
115
|
+
const T0 = AnimatedPressable;
|
|
116
|
+
const t6 = HAS_MENU;
|
|
117
|
+
const t7 = "button";
|
|
118
|
+
const t8 = feedback.handlers;
|
|
119
|
+
let t9;
|
|
120
|
+
if ($[8] !== ref) {
|
|
121
|
+
t9 = refsOf(fab, ref);
|
|
122
|
+
$[8] = ref;
|
|
123
|
+
$[9] = t9;
|
|
124
|
+
} else t9 = $[9];
|
|
125
|
+
let t10;
|
|
126
|
+
if ($[10] !== feedback || $[11] !== morph.container || $[12] !== style || $[13] !== theme) {
|
|
127
|
+
t10 = composeStyles(styles.base, morph.container, fabShadowOf(feedback, false, theme), feedback.ring, style);
|
|
128
|
+
$[10] = feedback;
|
|
129
|
+
$[11] = morph.container;
|
|
130
|
+
$[12] = style;
|
|
131
|
+
$[13] = theme;
|
|
132
|
+
$[14] = t10;
|
|
133
|
+
} else t10 = $[14];
|
|
134
|
+
let t11;
|
|
135
|
+
if ($[15] !== morph.clip) {
|
|
136
|
+
t11 = composeStyles(buttonStyles.clip, morph.clip);
|
|
137
|
+
$[15] = morph.clip;
|
|
138
|
+
$[16] = t11;
|
|
139
|
+
} else t11 = $[16];
|
|
140
|
+
let t12;
|
|
141
|
+
if ($[17] !== feedback.layer || $[18] !== t11) {
|
|
142
|
+
t12 = /* @__PURE__ */ jsx(Animated.View, {
|
|
143
|
+
style: t11,
|
|
144
|
+
children: feedback.layer
|
|
145
|
+
});
|
|
146
|
+
$[17] = feedback.layer;
|
|
147
|
+
$[18] = t11;
|
|
148
|
+
$[19] = t12;
|
|
149
|
+
} else t12 = $[19];
|
|
150
|
+
const T1 = View;
|
|
151
|
+
const t13 = styles;
|
|
152
|
+
const T2 = IconStyleContext;
|
|
153
|
+
const t14 = iconStyleOf(content, open ? CLOSE_SIZE : FAB_ICON_SIZES[size]);
|
|
154
|
+
const t15 = open ? CLOSE : icon;
|
|
155
|
+
let t16;
|
|
156
|
+
if ($[20] !== T2 || $[21] !== t14 || $[22] !== t15) {
|
|
157
|
+
t16 = /* @__PURE__ */ jsx(T2, {
|
|
158
|
+
value: t14,
|
|
159
|
+
children: t15
|
|
160
|
+
});
|
|
161
|
+
$[20] = T2;
|
|
162
|
+
$[21] = t14;
|
|
163
|
+
$[22] = t15;
|
|
164
|
+
$[23] = t16;
|
|
165
|
+
} else t16 = $[23];
|
|
166
|
+
let t17;
|
|
167
|
+
if ($[24] !== T1 || $[25] !== t13.icon || $[26] !== t16) {
|
|
168
|
+
t17 = /* @__PURE__ */ jsx(T1, {
|
|
169
|
+
style: t13.icon,
|
|
170
|
+
children: t16
|
|
171
|
+
});
|
|
172
|
+
$[24] = T1;
|
|
173
|
+
$[25] = t13.icon;
|
|
174
|
+
$[26] = t16;
|
|
175
|
+
$[27] = t17;
|
|
176
|
+
} else t17 = $[27];
|
|
177
|
+
let t18;
|
|
178
|
+
if ($[28] !== T0 || $[29] !== feedback.handlers || $[30] !== label || $[31] !== open || $[32] !== t10 || $[33] !== t12 || $[34] !== t17 || $[35] !== t6 || $[36] !== t9 || $[37] !== testID || $[38] !== toggle) {
|
|
179
|
+
t18 = /* @__PURE__ */ jsxs(T0, {
|
|
180
|
+
...t6,
|
|
181
|
+
"aria-expanded": open,
|
|
182
|
+
"aria-label": label,
|
|
183
|
+
role: t7,
|
|
184
|
+
testID,
|
|
185
|
+
...t8,
|
|
186
|
+
onPress: toggle,
|
|
187
|
+
ref: t9,
|
|
188
|
+
style: t10,
|
|
189
|
+
children: [t12, t17]
|
|
190
|
+
});
|
|
191
|
+
$[28] = T0;
|
|
192
|
+
$[29] = feedback.handlers;
|
|
193
|
+
$[30] = label;
|
|
194
|
+
$[31] = open;
|
|
195
|
+
$[32] = t10;
|
|
196
|
+
$[33] = t12;
|
|
197
|
+
$[34] = t17;
|
|
198
|
+
$[35] = t6;
|
|
199
|
+
$[36] = t9;
|
|
200
|
+
$[37] = testID;
|
|
201
|
+
$[38] = toggle;
|
|
202
|
+
$[39] = t18;
|
|
203
|
+
} else t18 = $[39];
|
|
204
|
+
let t19;
|
|
205
|
+
if ($[40] !== anchor || $[41] !== children || $[42] !== close || $[43] !== label || $[44] !== onAction || $[45] !== open || $[46] !== tone) {
|
|
206
|
+
t19 = open ? /* @__PURE__ */ jsx(Overlay, { children: /* @__PURE__ */ jsx(FabMenuPanel, {
|
|
207
|
+
anchor,
|
|
208
|
+
close,
|
|
209
|
+
label,
|
|
210
|
+
onAction,
|
|
211
|
+
tone,
|
|
212
|
+
children
|
|
213
|
+
}) }) : null;
|
|
214
|
+
$[40] = anchor;
|
|
215
|
+
$[41] = children;
|
|
216
|
+
$[42] = close;
|
|
217
|
+
$[43] = label;
|
|
218
|
+
$[44] = onAction;
|
|
219
|
+
$[45] = open;
|
|
220
|
+
$[46] = tone;
|
|
221
|
+
$[47] = t19;
|
|
222
|
+
} else t19 = $[47];
|
|
223
|
+
let t20;
|
|
224
|
+
if ($[48] !== t18 || $[49] !== t19) {
|
|
225
|
+
t20 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t18, t19] });
|
|
226
|
+
$[48] = t18;
|
|
227
|
+
$[49] = t19;
|
|
228
|
+
$[50] = t20;
|
|
229
|
+
} else t20 = $[50];
|
|
230
|
+
return t20;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* One action: a pill holding an icon and a label, on the menu's tone. A press
|
|
234
|
+
* on it runs it and closes the menu.
|
|
235
|
+
*
|
|
236
|
+
* The menu draws it from its entry in the collection, so it renders nothing
|
|
237
|
+
* on its own. `style`, `ref` and `testID` land on the pill.
|
|
238
|
+
*/
|
|
239
|
+
function FabMenuItem(_props) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
FabMenuItem.getCollectionNode = function* getCollectionNode(props) {
|
|
243
|
+
yield {
|
|
244
|
+
hasChildNodes: false,
|
|
245
|
+
key: props.id,
|
|
246
|
+
props,
|
|
247
|
+
rendered: props.children,
|
|
248
|
+
textValue: props.textValue ?? (typeof props.children === "string" ? props.children : ""),
|
|
249
|
+
type: "item"
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
/** An action's pill, drawn from its entry in the collection. */
|
|
253
|
+
function FabMenuAction(t0) {
|
|
254
|
+
const $ = c(35);
|
|
255
|
+
const { activate, isDisabled, node, setFocusTarget, tone } = t0;
|
|
256
|
+
const theme = useTheme();
|
|
257
|
+
const own = stylesOf(theme);
|
|
258
|
+
const role = useTypeRole("titleMedium");
|
|
259
|
+
let children;
|
|
260
|
+
let icon;
|
|
261
|
+
let onBlur;
|
|
262
|
+
let onFocus;
|
|
263
|
+
let onHoverIn;
|
|
264
|
+
let onHoverOut;
|
|
265
|
+
let onPress;
|
|
266
|
+
let onPressIn;
|
|
267
|
+
let onPressOut;
|
|
268
|
+
let props;
|
|
269
|
+
let ref;
|
|
270
|
+
let style;
|
|
271
|
+
if ($[0] !== node.props) {
|
|
272
|
+
const { children: t1, icon: t2, id: _id, isDisabled: _isDisabled, onAction: _onAction, onBlur: t3, onFocus: t4, onHoverIn: t5, onHoverOut: t6, onPress: t7, onPressIn: t8, onPressOut: t9, ref: t10, style: t11, textValue: _textValue, ...t12 } = node.props;
|
|
273
|
+
children = t1;
|
|
274
|
+
icon = t2;
|
|
275
|
+
onBlur = t3;
|
|
276
|
+
onFocus = t4;
|
|
277
|
+
onHoverIn = t5;
|
|
278
|
+
onHoverOut = t6;
|
|
279
|
+
onPress = t7;
|
|
280
|
+
onPressIn = t8;
|
|
281
|
+
onPressOut = t9;
|
|
282
|
+
ref = t10;
|
|
283
|
+
style = t11;
|
|
284
|
+
props = t12;
|
|
285
|
+
$[0] = node.props;
|
|
286
|
+
$[1] = children;
|
|
287
|
+
$[2] = icon;
|
|
288
|
+
$[3] = onBlur;
|
|
289
|
+
$[4] = onFocus;
|
|
290
|
+
$[5] = onHoverIn;
|
|
291
|
+
$[6] = onHoverOut;
|
|
292
|
+
$[7] = onPress;
|
|
293
|
+
$[8] = onPressIn;
|
|
294
|
+
$[9] = onPressOut;
|
|
295
|
+
$[10] = props;
|
|
296
|
+
$[11] = ref;
|
|
297
|
+
$[12] = style;
|
|
298
|
+
} else {
|
|
299
|
+
children = $[1];
|
|
300
|
+
icon = $[2];
|
|
301
|
+
onBlur = $[3];
|
|
302
|
+
onFocus = $[4];
|
|
303
|
+
onHoverIn = $[5];
|
|
304
|
+
onHoverOut = $[6];
|
|
305
|
+
onPress = $[7];
|
|
306
|
+
onPressIn = $[8];
|
|
307
|
+
onPressOut = $[9];
|
|
308
|
+
props = $[10];
|
|
309
|
+
ref = $[11];
|
|
310
|
+
style = $[12];
|
|
311
|
+
}
|
|
312
|
+
const palettes = fabPalettesOf(theme);
|
|
313
|
+
const colors = isDisabled ? palettes.disabled : palettes.tonal[tone];
|
|
314
|
+
const feedback = usePressFeedback({
|
|
315
|
+
color: colors.content,
|
|
316
|
+
corners: own.corner,
|
|
317
|
+
disabled: isDisabled,
|
|
318
|
+
onBlur,
|
|
319
|
+
onFocus,
|
|
320
|
+
onHoverIn,
|
|
321
|
+
onHoverOut,
|
|
322
|
+
onPressIn,
|
|
323
|
+
onPressOut
|
|
324
|
+
});
|
|
325
|
+
const T0 = Pressable;
|
|
326
|
+
const t1 = "menuitem";
|
|
327
|
+
const t2 = feedback.handlers;
|
|
328
|
+
let t3;
|
|
329
|
+
if ($[13] !== activate || $[14] !== node || $[15] !== onPress) {
|
|
330
|
+
t3 = pressThen(onPress, activate, node);
|
|
331
|
+
$[13] = activate;
|
|
332
|
+
$[14] = node;
|
|
333
|
+
$[15] = onPress;
|
|
334
|
+
$[16] = t3;
|
|
335
|
+
} else t3 = $[16];
|
|
336
|
+
let t4;
|
|
337
|
+
if ($[17] !== ref || $[18] !== setFocusTarget) {
|
|
338
|
+
t4 = refsOf(setFocusTarget, ref);
|
|
339
|
+
$[17] = ref;
|
|
340
|
+
$[18] = setFocusTarget;
|
|
341
|
+
$[19] = t4;
|
|
342
|
+
} else t4 = $[19];
|
|
343
|
+
const t5 = composeStyles(own.action, own.corner, colors.container, fabShadowOf(feedback, isDisabled, theme), feedback.ring, style);
|
|
344
|
+
const t6 = feedback.layer;
|
|
345
|
+
const t7 = icon === void 0 ? null : /* @__PURE__ */ jsx(View, {
|
|
346
|
+
style: styles.icon,
|
|
347
|
+
children: /* @__PURE__ */ jsx(IconStyleContext, {
|
|
348
|
+
value: iconStyleOf(colors.content, FAB_ICON_SIZES.md),
|
|
349
|
+
children: icon
|
|
350
|
+
})
|
|
351
|
+
});
|
|
352
|
+
const T1 = Text;
|
|
353
|
+
const t8 = 1;
|
|
354
|
+
const t9 = composeStyles(role, styles.label, colors.label);
|
|
355
|
+
let t10;
|
|
356
|
+
if ($[20] !== T1 || $[21] !== children || $[22] !== t9) {
|
|
357
|
+
t10 = /* @__PURE__ */ jsx(T1, {
|
|
358
|
+
numberOfLines: t8,
|
|
359
|
+
style: t9,
|
|
360
|
+
children
|
|
361
|
+
});
|
|
362
|
+
$[20] = T1;
|
|
363
|
+
$[21] = children;
|
|
364
|
+
$[22] = t9;
|
|
365
|
+
$[23] = t10;
|
|
366
|
+
} else t10 = $[23];
|
|
367
|
+
let t11;
|
|
368
|
+
if ($[24] !== T0 || $[25] !== feedback.handlers || $[26] !== feedback.layer || $[27] !== isDisabled || $[28] !== props || $[29] !== t10 || $[30] !== t3 || $[31] !== t4 || $[32] !== t5 || $[33] !== t7) {
|
|
369
|
+
t11 = /* @__PURE__ */ jsxs(T0, {
|
|
370
|
+
role: t1,
|
|
371
|
+
...props,
|
|
372
|
+
...t2,
|
|
373
|
+
disabled: isDisabled,
|
|
374
|
+
onPress: t3,
|
|
375
|
+
ref: t4,
|
|
376
|
+
style: t5,
|
|
377
|
+
children: [
|
|
378
|
+
t6,
|
|
379
|
+
t7,
|
|
380
|
+
t10
|
|
381
|
+
]
|
|
382
|
+
});
|
|
383
|
+
$[24] = T0;
|
|
384
|
+
$[25] = feedback.handlers;
|
|
385
|
+
$[26] = feedback.layer;
|
|
386
|
+
$[27] = isDisabled;
|
|
387
|
+
$[28] = props;
|
|
388
|
+
$[29] = t10;
|
|
389
|
+
$[30] = t3;
|
|
390
|
+
$[31] = t4;
|
|
391
|
+
$[32] = t5;
|
|
392
|
+
$[33] = t7;
|
|
393
|
+
$[34] = t11;
|
|
394
|
+
} else t11 = $[34];
|
|
395
|
+
return t11;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The open menu: the dismiss layer, then the column of actions, placed above
|
|
399
|
+
* the close button's end and risen into place once it has been.
|
|
400
|
+
*/
|
|
401
|
+
function FabMenuPanel(t0) {
|
|
402
|
+
const $ = c(29);
|
|
403
|
+
const { anchor, children, close, label, onAction, tone } = t0;
|
|
404
|
+
const theme = useTheme();
|
|
405
|
+
const own = stylesOf(theme);
|
|
406
|
+
const t1 = children;
|
|
407
|
+
let t2;
|
|
408
|
+
if ($[0] !== t1) {
|
|
409
|
+
t2 = { children: t1 };
|
|
410
|
+
$[0] = t1;
|
|
411
|
+
$[1] = t2;
|
|
412
|
+
} else t2 = $[1];
|
|
413
|
+
const state = useTreeState(t2);
|
|
414
|
+
let t3;
|
|
415
|
+
if ($[2] !== anchor || $[3] !== theme.spacing.sm) {
|
|
416
|
+
t3 = {
|
|
417
|
+
align: "end",
|
|
418
|
+
anchor,
|
|
419
|
+
side: "top",
|
|
420
|
+
sideOffset: theme.spacing.sm
|
|
421
|
+
};
|
|
422
|
+
$[2] = anchor;
|
|
423
|
+
$[3] = theme.spacing.sm;
|
|
424
|
+
$[4] = t3;
|
|
425
|
+
} else t3 = $[4];
|
|
426
|
+
const placement = useAnchoredPlacement(t3);
|
|
427
|
+
const rise = useRiseIn(placement.placed);
|
|
428
|
+
const [focusTarget, setFocusTarget] = useState(null);
|
|
429
|
+
let t4;
|
|
430
|
+
if ($[5] !== state) {
|
|
431
|
+
t4 = firstActionKey(state);
|
|
432
|
+
$[5] = state;
|
|
433
|
+
$[6] = t4;
|
|
434
|
+
} else t4 = $[6];
|
|
435
|
+
const focusKey = t4;
|
|
436
|
+
let t5;
|
|
437
|
+
if ($[7] !== close || $[8] !== onAction) {
|
|
438
|
+
t5 = (node) => {
|
|
439
|
+
const action = node.props;
|
|
440
|
+
if (action.onAction === void 0) onAction?.(node.key);
|
|
441
|
+
else action.onAction();
|
|
442
|
+
close();
|
|
443
|
+
};
|
|
444
|
+
$[7] = close;
|
|
445
|
+
$[8] = onAction;
|
|
446
|
+
$[9] = t5;
|
|
447
|
+
} else t5 = $[9];
|
|
448
|
+
const activate = t5;
|
|
449
|
+
useBackToClose(close, true);
|
|
450
|
+
useFocusOnPlaced(placement.placed, focusTarget);
|
|
451
|
+
let t6;
|
|
452
|
+
if ($[10] !== close) {
|
|
453
|
+
t6 = /* @__PURE__ */ jsx(DismissLayer, { onPress: close });
|
|
454
|
+
$[10] = close;
|
|
455
|
+
$[11] = t6;
|
|
456
|
+
} else t6 = $[11];
|
|
457
|
+
const t7 = Animated;
|
|
458
|
+
const t8 = placement.onLayout;
|
|
459
|
+
const t9 = "menu";
|
|
460
|
+
const t10 = composeStyles(own.menu, placement.style, rise);
|
|
461
|
+
let t11;
|
|
462
|
+
if ($[12] !== activate || $[13] !== focusKey || $[14] !== setFocusTarget || $[15] !== state.collection || $[16] !== state.selectionManager || $[17] !== tone) {
|
|
463
|
+
t11 = [...state.collection].map((node_0) => /* @__PURE__ */ jsx(FabMenuAction, {
|
|
464
|
+
activate,
|
|
465
|
+
isDisabled: state.selectionManager.isDisabled(node_0.key),
|
|
466
|
+
node: node_0,
|
|
467
|
+
setFocusTarget: node_0.key === focusKey ? setFocusTarget : void 0,
|
|
468
|
+
tone
|
|
469
|
+
}, node_0.key));
|
|
470
|
+
$[12] = activate;
|
|
471
|
+
$[13] = focusKey;
|
|
472
|
+
$[14] = setFocusTarget;
|
|
473
|
+
$[15] = state.collection;
|
|
474
|
+
$[16] = state.selectionManager;
|
|
475
|
+
$[17] = tone;
|
|
476
|
+
$[18] = t11;
|
|
477
|
+
} else t11 = $[18];
|
|
478
|
+
let t12;
|
|
479
|
+
if ($[19] !== close || $[20] !== label || $[21] !== placement.onLayout || $[22] !== t10 || $[23] !== t11 || $[24] !== t7.View) {
|
|
480
|
+
t12 = /* @__PURE__ */ jsx(t7.View, {
|
|
481
|
+
"aria-label": label,
|
|
482
|
+
onAccessibilityEscape: close,
|
|
483
|
+
onLayout: t8,
|
|
484
|
+
role: t9,
|
|
485
|
+
style: t10,
|
|
486
|
+
children: t11
|
|
487
|
+
});
|
|
488
|
+
$[19] = close;
|
|
489
|
+
$[20] = label;
|
|
490
|
+
$[21] = placement.onLayout;
|
|
491
|
+
$[22] = t10;
|
|
492
|
+
$[23] = t11;
|
|
493
|
+
$[24] = t7.View;
|
|
494
|
+
$[25] = t12;
|
|
495
|
+
} else t12 = $[25];
|
|
496
|
+
let t13;
|
|
497
|
+
if ($[26] !== t12 || $[27] !== t6) {
|
|
498
|
+
t13 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t6, t12] });
|
|
499
|
+
$[26] = t12;
|
|
500
|
+
$[27] = t6;
|
|
501
|
+
$[28] = t13;
|
|
502
|
+
} else t13 = $[28];
|
|
503
|
+
return t13;
|
|
504
|
+
}
|
|
505
|
+
/** The first action a press reaches, which a screen reader is sent to. */
|
|
506
|
+
function firstActionKey(state) {
|
|
507
|
+
for (const key of state.collection.getKeys()) if (!state.selectionManager.isDisabled(key)) return key;
|
|
508
|
+
return null;
|
|
509
|
+
}
|
|
510
|
+
function iconStyleOf(color, size) {
|
|
511
|
+
return {
|
|
512
|
+
color,
|
|
513
|
+
size
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* The press handler of an action: the call site's own `onPress`, then the
|
|
518
|
+
* action's activation. Built by a call rather than written inline at the
|
|
519
|
+
* prop, which is what react-perf's no-new-function-as-prop is after.
|
|
520
|
+
*/
|
|
521
|
+
function pressThen(onPress, activate, node) {
|
|
522
|
+
return (event) => {
|
|
523
|
+
onPress?.(event);
|
|
524
|
+
activate(node);
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* The close button the FAB becomes, for the actions to be placed against: a
|
|
529
|
+
* square of the close button's edge in the FAB's bottom trailing corner, read
|
|
530
|
+
* off the FAB wherever in its change it is when it is measured.
|
|
531
|
+
*/
|
|
532
|
+
function useCloseButtonAnchor(fab, edge) {
|
|
533
|
+
const $ = c(3);
|
|
534
|
+
let t0;
|
|
535
|
+
if ($[0] !== edge || $[1] !== fab) {
|
|
536
|
+
t0 = { current: { measureInWindow: (callback) => {
|
|
537
|
+
fab.current?.measureInWindow((x, y, width, height) => {
|
|
538
|
+
callback(I18nManager.isRTL ? x : x + width - edge, y + height - edge, edge, edge);
|
|
539
|
+
});
|
|
540
|
+
} } };
|
|
541
|
+
$[0] = edge;
|
|
542
|
+
$[1] = fab;
|
|
543
|
+
$[2] = t0;
|
|
544
|
+
} else t0 = $[2];
|
|
545
|
+
return t0;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* The FAB's change into the close button and back: its width, height,
|
|
549
|
+
* corner and container eased to the state's over medium1 on the emphasised
|
|
550
|
+
* curve, at once under reduced motion. The corner is returned twice, for the
|
|
551
|
+
* container and for the clip its press feedback is drawn in.
|
|
552
|
+
*/
|
|
553
|
+
function useCloseMorph(isOpen, size, tone) {
|
|
554
|
+
const $ = c(3);
|
|
555
|
+
const theme = useTheme();
|
|
556
|
+
const reduceMotion = useReducedMotion();
|
|
557
|
+
const { motion, sizing } = theme;
|
|
558
|
+
const edge = isOpen ? sizing.controlLg : fabSizesOf(theme)[size].width;
|
|
559
|
+
const corner = isOpen ? sizing.controlLg / 2 : fabCornersOf(theme)[size].borderRadius;
|
|
560
|
+
const fill = fabColorsOf(theme)[isOpen ? "filled" : "tonal"][tone].container;
|
|
561
|
+
const timing = {
|
|
562
|
+
duration: motion.durationMedium1,
|
|
563
|
+
easing: Easing.bezier(...motion.easingEmphasized)
|
|
564
|
+
};
|
|
565
|
+
const container = useAnimatedStyle(() => {
|
|
566
|
+
"worklet";
|
|
567
|
+
return {
|
|
568
|
+
backgroundColor: reduceMotion ? fill : withTiming(fill, timing),
|
|
569
|
+
borderRadius: reduceMotion ? corner : withTiming(corner, timing),
|
|
570
|
+
height: reduceMotion ? edge : withTiming(edge, timing),
|
|
571
|
+
width: reduceMotion ? edge : withTiming(edge, timing)
|
|
572
|
+
};
|
|
573
|
+
});
|
|
574
|
+
const clip = useAnimatedStyle(() => {
|
|
575
|
+
"worklet";
|
|
576
|
+
return { borderRadius: reduceMotion ? corner : withTiming(corner, timing) };
|
|
577
|
+
});
|
|
578
|
+
let t0;
|
|
579
|
+
if ($[0] !== clip || $[1] !== container) {
|
|
580
|
+
t0 = {
|
|
581
|
+
clip,
|
|
582
|
+
container
|
|
583
|
+
};
|
|
584
|
+
$[0] = clip;
|
|
585
|
+
$[1] = container;
|
|
586
|
+
$[2] = t0;
|
|
587
|
+
} else t0 = $[2];
|
|
588
|
+
return t0;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* The actions' arrival: they fade in and rise 8dp into place over short3 on
|
|
592
|
+
* the emphasised decelerating curve once they have been placed, and stay
|
|
593
|
+
* transparent until then. Under reduced motion they arrive at once.
|
|
594
|
+
*/
|
|
595
|
+
function useRiseIn(placed) {
|
|
596
|
+
const $ = c(6);
|
|
597
|
+
const { motion } = useTheme();
|
|
598
|
+
const reduceMotion = useReducedMotion();
|
|
599
|
+
const shown = useSharedValue(0);
|
|
600
|
+
let t0;
|
|
601
|
+
let t1;
|
|
602
|
+
if ($[0] !== motion || $[1] !== placed || $[2] !== reduceMotion || $[3] !== shown) {
|
|
603
|
+
t0 = () => {
|
|
604
|
+
if (!placed) return;
|
|
605
|
+
shown.set(reduceMotion ? 1 : withTiming(1, {
|
|
606
|
+
duration: motion.durationShort3,
|
|
607
|
+
easing: Easing.bezier(...motion.easingEmphasizedDecelerate)
|
|
608
|
+
}));
|
|
609
|
+
};
|
|
610
|
+
t1 = [
|
|
611
|
+
motion,
|
|
612
|
+
placed,
|
|
613
|
+
reduceMotion,
|
|
614
|
+
shown
|
|
615
|
+
];
|
|
616
|
+
$[0] = motion;
|
|
617
|
+
$[1] = placed;
|
|
618
|
+
$[2] = reduceMotion;
|
|
619
|
+
$[3] = shown;
|
|
620
|
+
$[4] = t0;
|
|
621
|
+
$[5] = t1;
|
|
622
|
+
} else {
|
|
623
|
+
t0 = $[4];
|
|
624
|
+
t1 = $[5];
|
|
625
|
+
}
|
|
626
|
+
useEffect(t0, t1);
|
|
627
|
+
return useAnimatedStyle(() => {
|
|
628
|
+
"worklet";
|
|
629
|
+
const progress = shown.get();
|
|
630
|
+
return {
|
|
631
|
+
opacity: progress,
|
|
632
|
+
transform: [{ translateY: RISE_FROM * (1 - progress) }]
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
FabMenu.Item = FabMenuItem;
|
|
637
|
+
//#endregion
|
|
638
|
+
export { FabMenu, FabMenuItem };
|
|
639
|
+
|
|
640
|
+
//# sourceMappingURL=index.js.map
|