@kanso-labs/react-native-kanso-ui 0.7.0 → 0.9.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 (150) hide show
  1. package/README.md +37 -0
  2. package/dist/badge/index.js +9 -68
  3. package/dist/badge/index.js.map +1 -1
  4. package/dist/button/index.d.ts +2 -1
  5. package/dist/button/index.js +1 -1
  6. package/dist/button/index.js.map +1 -1
  7. package/dist/button/palettes.d.ts +2 -0
  8. package/dist/button/pending.js +17 -21
  9. package/dist/button/pending.js.map +1 -1
  10. package/dist/calendar/index.js +1 -1
  11. package/dist/components/autocomplete/index.js +28 -26
  12. package/dist/components/autocomplete/index.js.map +1 -1
  13. package/dist/components/avatar/index.d.ts +2 -2
  14. package/dist/components/avatar/index.js +2 -2
  15. package/dist/components/avatar/index.js.map +1 -1
  16. package/dist/components/badge/index.d.ts +48 -0
  17. package/dist/components/badge/index.js +122 -0
  18. package/dist/components/badge/index.js.map +1 -0
  19. package/dist/{badge → components/badge}/styles.js +10 -6
  20. package/dist/components/badge/styles.js.map +1 -0
  21. package/dist/components/breadcrumbs/index.d.ts +66 -0
  22. package/dist/components/breadcrumbs/index.js +285 -0
  23. package/dist/components/breadcrumbs/index.js.map +1 -0
  24. package/dist/components/calendar/index.d.ts +1 -1
  25. package/dist/components/calendar/index.js +77 -38
  26. package/dist/components/calendar/index.js.map +1 -1
  27. package/dist/components/checkbox/index.d.ts +7 -1
  28. package/dist/components/checkbox/index.js +183 -138
  29. package/dist/components/checkbox/index.js.map +1 -1
  30. package/dist/components/checkbox-group/index.d.ts +93 -0
  31. package/dist/components/checkbox-group/index.js +306 -0
  32. package/dist/components/checkbox-group/index.js.map +1 -0
  33. package/dist/components/chip-group/index.d.ts +4 -3
  34. package/dist/components/chip-group/index.js +47 -45
  35. package/dist/components/chip-group/index.js.map +1 -1
  36. package/dist/components/code/index.d.ts +25 -0
  37. package/dist/components/code/index.js +87 -0
  38. package/dist/components/code/index.js.map +1 -0
  39. package/dist/components/container/index.d.ts +47 -0
  40. package/dist/components/container/index.js +85 -0
  41. package/dist/components/container/index.js.map +1 -0
  42. package/dist/components/copy-field/index.d.ts +5 -5
  43. package/dist/components/copy-field/index.js +30 -28
  44. package/dist/components/copy-field/index.js.map +1 -1
  45. package/dist/components/currency/index.d.ts +2 -2
  46. package/dist/components/currency/index.js +3 -1
  47. package/dist/components/currency/index.js.map +1 -1
  48. package/dist/components/fab/index.d.ts +80 -0
  49. package/dist/components/fab/index.js +231 -0
  50. package/dist/components/fab/index.js.map +1 -0
  51. package/dist/components/fab-menu/index.d.ts +120 -0
  52. package/dist/components/fab-menu/index.js +640 -0
  53. package/dist/components/fab-menu/index.js.map +1 -0
  54. package/dist/components/feed/index.d.ts +57 -0
  55. package/dist/components/feed/index.js +167 -0
  56. package/dist/components/feed/index.js.map +1 -0
  57. package/dist/components/keycap/index.d.ts +27 -0
  58. package/dist/components/keycap/index.js +136 -0
  59. package/dist/components/keycap/index.js.map +1 -0
  60. package/dist/components/list/index.d.ts +6 -5
  61. package/dist/components/list/index.js +97 -106
  62. package/dist/components/list/index.js.map +1 -1
  63. package/dist/components/menu/index.d.ts +4 -3
  64. package/dist/components/menu/index.js +33 -40
  65. package/dist/components/menu/index.js.map +1 -1
  66. package/dist/components/meter/index.d.ts +2 -1
  67. package/dist/components/meter/index.js +9 -7
  68. package/dist/components/meter/index.js.map +1 -1
  69. package/dist/components/number-field/index.d.ts +7 -3
  70. package/dist/components/number-field/index.js +214 -192
  71. package/dist/components/number-field/index.js.map +1 -1
  72. package/dist/components/product-icon/index.d.ts +2 -2
  73. package/dist/components/product-icon/index.js +2 -2
  74. package/dist/components/product-icon/index.js.map +1 -1
  75. package/dist/components/progress-indicator/index.d.ts +2 -1
  76. package/dist/components/progress-indicator/index.js +15 -13
  77. package/dist/components/progress-indicator/index.js.map +1 -1
  78. package/dist/components/search-field/index.d.ts +3 -3
  79. package/dist/components/search-field/index.js +105 -104
  80. package/dist/components/search-field/index.js.map +1 -1
  81. package/dist/components/separator/index.d.ts +3 -2
  82. package/dist/components/separator/index.js +29 -26
  83. package/dist/components/separator/index.js.map +1 -1
  84. package/dist/components/sheet/index.d.ts +2 -2
  85. package/dist/components/sheet/index.js +22 -26
  86. package/dist/components/sheet/index.js.map +1 -1
  87. package/dist/components/snackbar/index.d.ts +3 -3
  88. package/dist/components/snackbar/index.js +36 -34
  89. package/dist/components/snackbar/index.js.map +1 -1
  90. package/dist/components/supporting-pane/index.d.ts +44 -0
  91. package/dist/components/supporting-pane/index.js +109 -0
  92. package/dist/components/supporting-pane/index.js.map +1 -0
  93. package/dist/components/tag/index.d.ts +58 -0
  94. package/dist/components/tag/index.js +205 -0
  95. package/dist/components/tag/index.js.map +1 -0
  96. package/dist/components/text/index.d.ts +1 -1
  97. package/dist/components/text/index.js +49 -21
  98. package/dist/components/text/index.js.map +1 -1
  99. package/dist/components/text-area/index.d.ts +145 -0
  100. package/dist/components/text-area/index.js +231 -0
  101. package/dist/components/text-area/index.js.map +1 -0
  102. package/dist/components/text-field/index.d.ts +6 -3
  103. package/dist/components/text-field/index.js +3 -0
  104. package/dist/components/text-field/index.js.map +1 -1
  105. package/dist/components/toolbar/index.d.ts +53 -0
  106. package/dist/components/toolbar/index.js +185 -0
  107. package/dist/components/toolbar/index.js.map +1 -0
  108. package/dist/control/group.js +23 -0
  109. package/dist/control/group.js.map +1 -0
  110. package/dist/fab/index.d.ts +19 -0
  111. package/dist/fab/index.js +147 -0
  112. package/dist/fab/index.js.map +1 -0
  113. package/dist/field/index.js +123 -79
  114. package/dist/field/index.js.map +1 -1
  115. package/dist/field/styles.js +18 -0
  116. package/dist/field/styles.js.map +1 -1
  117. package/dist/form/index.d.ts +1 -2
  118. package/dist/form/index.js +1 -1
  119. package/dist/form/index.js.map +1 -1
  120. package/dist/i18n/index.js +12 -1
  121. package/dist/i18n/index.js.map +1 -1
  122. package/dist/i18n/messages.js +367 -0
  123. package/dist/i18n/messages.js.map +1 -1
  124. package/dist/i18n/provider.d.ts +53 -0
  125. package/dist/i18n/provider.js +96 -0
  126. package/dist/i18n/provider.js.map +1 -0
  127. package/dist/index.d.ts +19 -4
  128. package/dist/index.js +17 -3
  129. package/dist/indicator/index.js +1 -2
  130. package/dist/indicator/index.js.map +1 -1
  131. package/dist/mark/index.js +77 -117
  132. package/dist/mark/index.js.map +1 -1
  133. package/dist/mark/initials.js.map +1 -1
  134. package/dist/modal/index.js +59 -46
  135. package/dist/modal/index.js.map +1 -1
  136. package/dist/navigation/index.js +8 -5
  137. package/dist/navigation/index.js.map +1 -1
  138. package/dist/number/count.js +15 -0
  139. package/dist/number/count.js.map +1 -0
  140. package/dist/number/locale.js.map +1 -1
  141. package/dist/overlay/host.js +30 -21
  142. package/dist/overlay/host.js.map +1 -1
  143. package/dist/overlay/placement.js +3 -1
  144. package/dist/overlay/placement.js.map +1 -1
  145. package/dist/separator/index.js +7 -0
  146. package/dist/separator/index.js.map +1 -0
  147. package/dist/typography/size.js +14 -0
  148. package/dist/typography/size.js.map +1 -0
  149. package/package.json +1 -1
  150. 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