@kanso-labs/react-native-kanso-ui 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/button/index.d.ts +32 -2
  2. package/dist/button/index.js +38 -26
  3. package/dist/button/index.js.map +1 -1
  4. package/dist/button/pending.js +144 -0
  5. package/dist/button/pending.js.map +1 -0
  6. package/dist/button/slots.js +7 -0
  7. package/dist/button/slots.js.map +1 -0
  8. package/dist/components/avatar/index.d.ts +2 -2
  9. package/dist/components/avatar/index.js.map +1 -1
  10. package/dist/components/button/index.d.ts +3 -3
  11. package/dist/components/button/index.js +159 -111
  12. package/dist/components/button/index.js.map +1 -1
  13. package/dist/components/card/index.d.ts +2 -2
  14. package/dist/components/card/index.js.map +1 -1
  15. package/dist/components/checkbox/index.d.ts +2 -2
  16. package/dist/components/checkbox/index.js.map +1 -1
  17. package/dist/components/chip/index.d.ts +2 -2
  18. package/dist/components/chip/index.js.map +1 -1
  19. package/dist/components/chip-group/index.d.ts +3 -3
  20. package/dist/components/chip-group/index.js.map +1 -1
  21. package/dist/components/copy-field/index.d.ts +2 -2
  22. package/dist/components/copy-field/index.js.map +1 -1
  23. package/dist/components/dialog/index.d.ts +131 -0
  24. package/dist/components/dialog/index.js +861 -0
  25. package/dist/components/dialog/index.js.map +1 -0
  26. package/dist/components/icon-button/index.d.ts +3 -3
  27. package/dist/components/icon-button/index.js +165 -109
  28. package/dist/components/icon-button/index.js.map +1 -1
  29. package/dist/components/link/index.js +1 -1
  30. package/dist/components/link/index.js.map +1 -1
  31. package/dist/components/meter/index.d.ts +73 -0
  32. package/dist/components/meter/index.js +179 -0
  33. package/dist/components/meter/index.js.map +1 -0
  34. package/dist/components/number-field/index.d.ts +3 -3
  35. package/dist/components/number-field/index.js +1 -9
  36. package/dist/components/number-field/index.js.map +1 -1
  37. package/dist/components/product-icon/index.d.ts +2 -2
  38. package/dist/components/product-icon/index.js.map +1 -1
  39. package/dist/components/progress-indicator/index.d.ts +113 -0
  40. package/dist/components/progress-indicator/index.js +1024 -0
  41. package/dist/components/progress-indicator/index.js.map +1 -0
  42. package/dist/components/radio-group/index.d.ts +3 -3
  43. package/dist/components/radio-group/index.js.map +1 -1
  44. package/dist/components/search-field/index.d.ts +3 -3
  45. package/dist/components/search-field/index.js.map +1 -1
  46. package/dist/components/segmented-button/index.d.ts +3 -3
  47. package/dist/components/segmented-button/index.js.map +1 -1
  48. package/dist/components/snackbar/index.d.ts +120 -0
  49. package/dist/components/snackbar/index.js +540 -0
  50. package/dist/components/snackbar/index.js.map +1 -0
  51. package/dist/components/switch/index.d.ts +2 -2
  52. package/dist/components/switch/index.js.map +1 -1
  53. package/dist/components/text-field/index.d.ts +3 -3
  54. package/dist/components/text-field/index.js.map +1 -1
  55. package/dist/field/index.d.ts +1 -1
  56. package/dist/field/index.js.map +1 -1
  57. package/dist/form/index.d.ts +1 -1
  58. package/dist/form/index.js.map +1 -1
  59. package/dist/glyphs/hidden.js +13 -0
  60. package/dist/glyphs/hidden.js.map +1 -0
  61. package/dist/glyphs/index.js +2 -8
  62. package/dist/glyphs/index.js.map +1 -1
  63. package/dist/i18n/index.js +23 -0
  64. package/dist/i18n/index.js.map +1 -0
  65. package/dist/i18n/messages.js +41 -0
  66. package/dist/i18n/messages.js.map +1 -0
  67. package/dist/index.d.ts +5 -1
  68. package/dist/index.js +7 -3
  69. package/dist/indicator/index.d.ts +15 -0
  70. package/dist/indicator/index.js +256 -0
  71. package/dist/indicator/index.js.map +1 -0
  72. package/dist/indicator/motion.js +86 -0
  73. package/dist/indicator/motion.js.map +1 -0
  74. package/dist/indicator/paths.js +72 -0
  75. package/dist/indicator/paths.js.map +1 -0
  76. package/dist/indicator/styles.js +62 -0
  77. package/dist/indicator/styles.js.map +1 -0
  78. package/dist/mark/index.d.ts +1 -1
  79. package/dist/mark/index.js.map +1 -1
  80. package/dist/number/locale.js +14 -0
  81. package/dist/number/locale.js.map +1 -0
  82. package/dist/overlay/host.js +65 -2
  83. package/dist/overlay/host.js.map +1 -1
  84. package/dist/press/index.js +63 -63
  85. package/dist/press/index.js.map +1 -1
  86. package/dist/theme/resolve.js +1 -1
  87. package/dist/theme/resolve.js.map +1 -1
  88. package/package.json +11 -11
@@ -0,0 +1,861 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { useTypeRole } from "../../typography/roles.js";
4
+ import { ButtonSlotContext } from "../../button/slots.js";
5
+ import { AnimatedPressable } from "../../button/index.js";
6
+ import { withOpacity } from "../../theme/color.js";
7
+ import { useWindowSizeClass } from "../../hooks/useWindowSizeClass.js";
8
+ import { OverlayHost } from "../../overlay/host.js";
9
+ import { c } from "react/compiler-runtime";
10
+ import { AccessibilityInfo, Modal, Platform, ScrollView, StyleSheet, Text, View, useWindowDimensions } from "react-native";
11
+ import { createContext, use, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ import Animated, { Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from "react-native-reanimated";
14
+ import { SafeAreaInsetsContext } from "react-native-safe-area-context";
15
+ import { useOverlayTriggerState } from "react-stately/useOverlayTriggerState";
16
+ //#region src/components/dialog/index.tsx
17
+ const MIN_WIDTH = 280;
18
+ const MAX_WIDTH = 560;
19
+ const SCALE_FROM = .9;
20
+ const RISE_FROM = .03;
21
+ const SCRIM_OPACITY = .32;
22
+ const NO_INSETS = {
23
+ bottom: 0,
24
+ left: 0,
25
+ right: 0,
26
+ top: 0
27
+ };
28
+ const ORIENTATIONS = [
29
+ "portrait",
30
+ "portrait-upside-down",
31
+ "landscape",
32
+ "landscape-left",
33
+ "landscape-right"
34
+ ];
35
+ const NO_PARTS = {
36
+ footer: 0,
37
+ header: 0,
38
+ title: 0
39
+ };
40
+ const stylesOf = themedStyles(({ colors, radii, shadows, sizing, spacing }) => StyleSheet.create({
41
+ actions: {
42
+ alignItems: "center",
43
+ flexDirection: "row",
44
+ flexShrink: 0,
45
+ flexWrap: "wrap",
46
+ gap: spacing.sm,
47
+ justifyContent: "flex-end",
48
+ padding: spacing.xl
49
+ },
50
+ actionsFull: {
51
+ borderTopColor: colors.outlineVariant,
52
+ borderTopWidth: 1,
53
+ minHeight: sizing.rowSm,
54
+ paddingVertical: spacing.xs
55
+ },
56
+ bodyText: { color: colors.onSurfaceVariant },
57
+ container: {
58
+ backgroundColor: colors.surfaceContainerHigh,
59
+ overflow: "hidden"
60
+ },
61
+ containerBasic: {
62
+ borderRadius: radii.xl,
63
+ boxShadow: shadows.elevation3,
64
+ maxHeight: "100%",
65
+ maxWidth: MAX_WIDTH,
66
+ minWidth: MIN_WIDTH,
67
+ width: "100%"
68
+ },
69
+ containerFull: { flex: 1 },
70
+ header: {
71
+ alignItems: "center",
72
+ flexDirection: "row",
73
+ flexShrink: 0,
74
+ gap: spacing.md,
75
+ justifyContent: "space-between",
76
+ paddingBottom: spacing.lg,
77
+ paddingHorizontal: spacing.xl,
78
+ paddingTop: spacing.xl
79
+ },
80
+ headerFull: {
81
+ borderBottomColor: colors.outlineVariant,
82
+ borderBottomWidth: 1,
83
+ minHeight: sizing.rowSm,
84
+ paddingBottom: spacing.xs,
85
+ paddingTop: spacing.xs
86
+ },
87
+ layout: {
88
+ alignItems: "center",
89
+ bottom: 0,
90
+ justifyContent: "center",
91
+ left: 0,
92
+ padding: spacing.xl,
93
+ pointerEvents: "box-none",
94
+ position: "absolute",
95
+ right: 0,
96
+ top: 0
97
+ },
98
+ layoutFull: {
99
+ alignItems: "stretch",
100
+ padding: 0
101
+ },
102
+ scrim: {
103
+ backgroundColor: withOpacity(colors.scrim, SCRIM_OPACITY),
104
+ bottom: 0,
105
+ left: 0,
106
+ position: "absolute",
107
+ right: 0,
108
+ top: 0
109
+ },
110
+ title: {
111
+ color: colors.onSurface,
112
+ flexShrink: 1
113
+ }
114
+ }));
115
+ const DialogLayoutContext = createContext(null);
116
+ const DialogTriggerContext = createContext(null);
117
+ function bodyPaddingOf({ basic, parts }, spacing) {
118
+ return {
119
+ gap: spacing.lg,
120
+ paddingBottom: parts.footer > 0 ? 0 : spacing.xl,
121
+ paddingHorizontal: spacing.xl,
122
+ paddingTop: basic && parts.header > 0 ? 0 : spacing.xl
123
+ };
124
+ }
125
+ /**
126
+ * A modal dialog centred over the screen, and the same dialog filling the
127
+ * window in a compact window, the dialogs spec page's basic and full-screen
128
+ * dialogs, paired by window size as the page pairs them. An alert dialog
129
+ * stays the basic one at every width. Pass `isOpen` with `onOpenChange` to
130
+ * hold the open state, or `defaultOpen` to let it keep its own.
131
+ *
132
+ * ```tsx
133
+ * <Dialog>
134
+ * <Button>Open</Button>
135
+ * <Dialog.Content>
136
+ * <Dialog.Header>
137
+ * <Dialog.Title>Headline</Dialog.Title>
138
+ * </Dialog.Header>
139
+ * <Dialog.Body>Supporting text</Dialog.Body>
140
+ * <Dialog.Footer>
141
+ * <Button slot="close" variant="text">Cancel</Button>
142
+ * </Dialog.Footer>
143
+ * </Dialog.Content>
144
+ * </Dialog>
145
+ * ```
146
+ *
147
+ * Composed rather than configured by props, as web's is, since a dialog's
148
+ * header, body and actions all take arbitrary content. A `Button` or
149
+ * `IconButton` inside `Dialog` and outside its content opens it, and one
150
+ * given `slot="close"` anywhere inside the content closes it. A dialog nothing on
151
+ * the screen opens leaves `Dialog` out and passes `isOpen` and
152
+ * `onOpenChange` to `Dialog.Content` instead.
153
+ */
154
+ function Dialog(t0) {
155
+ const $ = c(15);
156
+ const { children, defaultOpen, isOpen, onOpenChange } = t0;
157
+ let t1;
158
+ if ($[0] !== defaultOpen || $[1] !== isOpen || $[2] !== onOpenChange) {
159
+ t1 = {
160
+ defaultOpen,
161
+ isOpen,
162
+ onOpenChange
163
+ };
164
+ $[0] = defaultOpen;
165
+ $[1] = isOpen;
166
+ $[2] = onOpenChange;
167
+ $[3] = t1;
168
+ } else t1 = $[3];
169
+ const state = useOverlayTriggerState(t1);
170
+ const [trigger, setTrigger] = useState(null);
171
+ let t2;
172
+ if ($[4] !== state || $[5] !== trigger) {
173
+ t2 = {
174
+ state,
175
+ trigger
176
+ };
177
+ $[4] = state;
178
+ $[5] = trigger;
179
+ $[6] = t2;
180
+ } else t2 = $[6];
181
+ const context = t2;
182
+ let t3;
183
+ if ($[7] !== state) {
184
+ t3 = { default: (event) => {
185
+ const target = event.currentTarget;
186
+ setTrigger(typeof target === "number" ? null : target);
187
+ state.open();
188
+ } };
189
+ $[7] = state;
190
+ $[8] = t3;
191
+ } else t3 = $[8];
192
+ const slots = t3;
193
+ let t4;
194
+ if ($[9] !== children || $[10] !== slots) {
195
+ t4 = /* @__PURE__ */ jsx(ButtonSlotContext, {
196
+ value: slots,
197
+ children
198
+ });
199
+ $[9] = children;
200
+ $[10] = slots;
201
+ $[11] = t4;
202
+ } else t4 = $[11];
203
+ let t5;
204
+ if ($[12] !== context || $[13] !== t4) {
205
+ t5 = /* @__PURE__ */ jsx(DialogTriggerContext, {
206
+ value: context,
207
+ children: t4
208
+ });
209
+ $[12] = context;
210
+ $[13] = t4;
211
+ $[14] = t5;
212
+ } else t5 = $[14];
213
+ return t5;
214
+ }
215
+ /**
216
+ * What the dialog shows, as a body that scrolls when its content runs past
217
+ * the room it has. A string is drawn in the page's body medium on on-surface
218
+ * variant; anything else draws itself. `style`, `ref` and `testID` land on
219
+ * the `ScrollView`.
220
+ *
221
+ * A body its content runs past takes focus, as web's is a tab stop, so a
222
+ * keyboard can scroll it when nothing inside it takes focus; a call site's
223
+ * own `focusable` still wins.
224
+ */
225
+ function DialogBody(t0) {
226
+ const $ = c(22);
227
+ let children;
228
+ let contentContainerStyle;
229
+ let onContentSizeChange;
230
+ let onLayout;
231
+ let props;
232
+ if ($[0] !== t0) {
233
+ ({children, contentContainerStyle, onContentSizeChange, onLayout, ...props} = t0);
234
+ $[0] = t0;
235
+ $[1] = children;
236
+ $[2] = contentContainerStyle;
237
+ $[3] = onContentSizeChange;
238
+ $[4] = onLayout;
239
+ $[5] = props;
240
+ } else {
241
+ children = $[1];
242
+ contentContainerStyle = $[2];
243
+ onContentSizeChange = $[3];
244
+ onLayout = $[4];
245
+ props = $[5];
246
+ }
247
+ const layout = useLayout("Dialog.Body");
248
+ const theme = useTheme();
249
+ const styles = stylesOf(theme);
250
+ const text = useTypeRole("bodyMedium");
251
+ const { spacing } = theme;
252
+ const [content, setContent] = useState(0);
253
+ const [room, setRoom] = useState(0);
254
+ let t1;
255
+ if ($[6] !== onContentSizeChange) {
256
+ t1 = (width, height) => {
257
+ setContent(height);
258
+ onContentSizeChange?.(width, height);
259
+ };
260
+ $[6] = onContentSizeChange;
261
+ $[7] = t1;
262
+ } else t1 = $[7];
263
+ const measureContent = t1;
264
+ let t2;
265
+ if ($[8] !== onLayout) {
266
+ t2 = (event) => {
267
+ setRoom(event.nativeEvent.layout.height);
268
+ onLayout?.(event);
269
+ };
270
+ $[8] = onLayout;
271
+ $[9] = t2;
272
+ } else t2 = $[9];
273
+ const measureRoom = t2;
274
+ const T0 = ScrollView;
275
+ const t3 = content > room;
276
+ let t4;
277
+ if ($[10] !== contentContainerStyle || $[11] !== layout || $[12] !== spacing) {
278
+ t4 = composeStyles(bodyPaddingOf(layout, spacing), contentContainerStyle);
279
+ $[10] = contentContainerStyle;
280
+ $[11] = layout;
281
+ $[12] = spacing;
282
+ $[13] = t4;
283
+ } else t4 = $[13];
284
+ const t5 = typeof children === "string" ? /* @__PURE__ */ jsx(Text, {
285
+ style: composeStyles(text, styles.bodyText),
286
+ children
287
+ }) : children;
288
+ let t6;
289
+ if ($[14] !== T0 || $[15] !== measureContent || $[16] !== measureRoom || $[17] !== props || $[18] !== t3 || $[19] !== t4 || $[20] !== t5) {
290
+ t6 = /* @__PURE__ */ jsx(T0, {
291
+ focusable: t3,
292
+ onContentSizeChange: measureContent,
293
+ onLayout: measureRoom,
294
+ ...props,
295
+ contentContainerStyle: t4,
296
+ children: t5
297
+ });
298
+ $[14] = T0;
299
+ $[15] = measureContent;
300
+ $[16] = measureRoom;
301
+ $[17] = props;
302
+ $[18] = t3;
303
+ $[19] = t4;
304
+ $[20] = t5;
305
+ $[21] = t6;
306
+ } else t6 = $[21];
307
+ return t6;
308
+ }
309
+ /**
310
+ * The dialog itself, and the scrim behind it. Everything the dialog shows
311
+ * goes in here; the button that opens it stays outside it.
312
+ *
313
+ * Inside `Dialog`, the open state is the trigger's. On its own it is this
314
+ * part's: `isOpen` with `onOpenChange` holds it, and a `slot="close"`
315
+ * button, the scrim and the back gesture all report through `onOpenChange`.
316
+ * `style`, `ref` and `testID` land on the container.
317
+ */
318
+ function DialogContent(t0) {
319
+ const $ = c(46);
320
+ let children;
321
+ let defaultOpen;
322
+ let isOpen;
323
+ let onOpenChange;
324
+ let props;
325
+ let style;
326
+ let t1;
327
+ let t2;
328
+ let t3;
329
+ if ($[0] !== t0) {
330
+ ({children, defaultOpen, isDismissable: t1, isKeyboardDismissDisabled: t2, isOpen, onOpenChange, role: t3, style, ...props} = t0);
331
+ $[0] = t0;
332
+ $[1] = children;
333
+ $[2] = defaultOpen;
334
+ $[3] = isOpen;
335
+ $[4] = onOpenChange;
336
+ $[5] = props;
337
+ $[6] = style;
338
+ $[7] = t1;
339
+ $[8] = t2;
340
+ $[9] = t3;
341
+ } else {
342
+ children = $[1];
343
+ defaultOpen = $[2];
344
+ isOpen = $[3];
345
+ onOpenChange = $[4];
346
+ props = $[5];
347
+ style = $[6];
348
+ t1 = $[7];
349
+ t2 = $[8];
350
+ t3 = $[9];
351
+ }
352
+ const isDismissable = t1 === void 0 ? true : t1;
353
+ const isKeyboardDismissDisabled = t2 === void 0 ? false : t2;
354
+ const role = t3 === void 0 ? "dialog" : t3;
355
+ const outer = use(DialogTriggerContext);
356
+ let t4;
357
+ if ($[10] !== defaultOpen || $[11] !== isOpen || $[12] !== onOpenChange) {
358
+ t4 = {
359
+ defaultOpen,
360
+ isOpen,
361
+ onOpenChange
362
+ };
363
+ $[10] = defaultOpen;
364
+ $[11] = isOpen;
365
+ $[12] = onOpenChange;
366
+ $[13] = t4;
367
+ } else t4 = $[13];
368
+ const own = useOverlayTriggerState(t4);
369
+ const state = outer?.state ?? own;
370
+ const theme = useTheme();
371
+ const styles = stylesOf(theme);
372
+ const insets = use(SafeAreaInsetsContext) ?? NO_INSETS;
373
+ const sizeClass = useWindowSizeClass();
374
+ const basic = role === "alertdialog" || sizeClass !== "compact";
375
+ const titleId = useId();
376
+ const [parts, setParts] = useState(NO_PARTS);
377
+ let t5;
378
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
379
+ t5 = () => registerOf(setParts);
380
+ $[14] = t5;
381
+ } else t5 = $[14];
382
+ const [register] = useState(t5);
383
+ const [title, setTitle] = useState(null);
384
+ const [present, setPresent] = useState(state.isOpen);
385
+ const motion = useDialogMotion(state.isOpen, present, setPresent, basic);
386
+ let t6;
387
+ if ($[15] !== state) {
388
+ t6 = () => {
389
+ state.close();
390
+ };
391
+ $[15] = state;
392
+ $[16] = t6;
393
+ } else t6 = $[16];
394
+ const close = t6;
395
+ let t7;
396
+ if ($[17] !== close) {
397
+ t7 = { close };
398
+ $[17] = close;
399
+ $[18] = t7;
400
+ } else t7 = $[18];
401
+ const slots = t7;
402
+ let t8;
403
+ if ($[19] !== basic || $[20] !== parts || $[21] !== register || $[22] !== titleId) {
404
+ t8 = {
405
+ basic,
406
+ parts,
407
+ register,
408
+ setTitle,
409
+ titleId
410
+ };
411
+ $[19] = basic;
412
+ $[20] = parts;
413
+ $[21] = register;
414
+ $[22] = titleId;
415
+ $[23] = t8;
416
+ } else t8 = $[23];
417
+ const layout = t8;
418
+ if (state.isOpen && !present) setPresent(true);
419
+ useReturnFocus(present, outer);
420
+ if (!present) return null;
421
+ const labelledBy = parts.title > 0 ? titleId : void 0;
422
+ const web = Platform.OS === "web";
423
+ let t9;
424
+ if ($[24] !== title) {
425
+ t9 = focusOf(title);
426
+ $[24] = title;
427
+ $[25] = t9;
428
+ } else t9 = $[25];
429
+ const T0 = View;
430
+ const t10 = composeStyles(styles.layout, basic ? void 0 : styles.layoutFull);
431
+ const t11 = Animated;
432
+ let t12;
433
+ if ($[26] !== labelledBy || $[27] !== role) {
434
+ t12 = web ? void 0 : panelRoleOf(role, labelledBy);
435
+ $[26] = labelledBy;
436
+ $[27] = role;
437
+ $[28] = t12;
438
+ } else t12 = $[28];
439
+ const t13 = isKeyboardDismissDisabled ? void 0 : close;
440
+ const t14 = composeStyles(styles.container, basic ? styles.containerBasic : styles.containerFull, basic ? void 0 : insetsOf(insets), motion.panel, style);
441
+ let t15;
442
+ if ($[29] !== children || $[30] !== slots) {
443
+ t15 = /* @__PURE__ */ jsx(ButtonSlotContext, {
444
+ value: slots,
445
+ children
446
+ });
447
+ $[29] = children;
448
+ $[30] = slots;
449
+ $[31] = t15;
450
+ } else t15 = $[31];
451
+ let t16;
452
+ if ($[32] !== layout || $[33] !== t15) {
453
+ t16 = /* @__PURE__ */ jsx(DialogLayoutContext, {
454
+ value: layout,
455
+ children: t15
456
+ });
457
+ $[32] = layout;
458
+ $[33] = t15;
459
+ $[34] = t16;
460
+ } else t16 = $[34];
461
+ let t17;
462
+ if ($[35] !== props || $[36] !== t11.View || $[37] !== t12 || $[38] !== t13 || $[39] !== t14 || $[40] !== t16) {
463
+ t17 = /* @__PURE__ */ jsx(t11.View, {
464
+ ...t12,
465
+ onAccessibilityEscape: t13,
466
+ ...props,
467
+ style: t14,
468
+ children: t16
469
+ });
470
+ $[35] = props;
471
+ $[36] = t11.View;
472
+ $[37] = t12;
473
+ $[38] = t13;
474
+ $[39] = t14;
475
+ $[40] = t16;
476
+ $[41] = t17;
477
+ } else t17 = $[41];
478
+ let t18;
479
+ if ($[42] !== T0 || $[43] !== t10 || $[44] !== t17) {
480
+ t18 = /* @__PURE__ */ jsx(T0, {
481
+ style: t10,
482
+ children: t17
483
+ });
484
+ $[42] = T0;
485
+ $[43] = t10;
486
+ $[44] = t17;
487
+ $[45] = t18;
488
+ } else t18 = $[45];
489
+ return /* @__PURE__ */ jsx(Modal, {
490
+ animationType: "none",
491
+ "aria-labelledby": web ? labelledBy : void 0,
492
+ navigationBarTranslucent: true,
493
+ onRequestClose: isKeyboardDismissDisabled ? ignore : close,
494
+ onShow: t9,
495
+ statusBarTranslucent: true,
496
+ supportedOrientations: ORIENTATIONS,
497
+ transparent: true,
498
+ visible: true,
499
+ children: /* @__PURE__ */ jsx(ButtonSlotContext, {
500
+ value: null,
501
+ children: /* @__PURE__ */ jsxs(OverlayHost, { children: [/* @__PURE__ */ jsx(AnimatedPressable, {
502
+ accessible: false,
503
+ "aria-hidden": true,
504
+ focusable: false,
505
+ onPress: isDismissable && state.isOpen ? close : void 0,
506
+ style: composeStyles(styles.scrim, motion.scrim),
507
+ tabIndex: -1
508
+ }), t18] })
509
+ })
510
+ });
511
+ }
512
+ /**
513
+ * The dialog's actions, at the trailing edge and wrapping onto another row
514
+ * when they do not fit on one. Full screen they are the page's bottom action
515
+ * bar. `style`, `ref` and `testID` land on its view.
516
+ */
517
+ function DialogFooter(t0) {
518
+ const $ = c(10);
519
+ let props;
520
+ let style;
521
+ if ($[0] !== t0) {
522
+ ({style, ...props} = t0);
523
+ $[0] = t0;
524
+ $[1] = props;
525
+ $[2] = style;
526
+ } else {
527
+ props = $[1];
528
+ style = $[2];
529
+ }
530
+ const layout = useLayout("Dialog.Footer");
531
+ const styles = stylesOf(useTheme());
532
+ const { register } = layout;
533
+ let t1;
534
+ let t2;
535
+ if ($[3] !== register) {
536
+ t1 = () => register("footer");
537
+ t2 = [register];
538
+ $[3] = register;
539
+ $[4] = t1;
540
+ $[5] = t2;
541
+ } else {
542
+ t1 = $[4];
543
+ t2 = $[5];
544
+ }
545
+ useLayoutEffect(t1, t2);
546
+ const T0 = View;
547
+ const t3 = composeStyles(styles.actions, layout.basic ? void 0 : styles.actionsFull, style);
548
+ let t4;
549
+ if ($[6] !== T0 || $[7] !== props || $[8] !== t3) {
550
+ t4 = /* @__PURE__ */ jsx(T0, {
551
+ ...props,
552
+ style: t3
553
+ });
554
+ $[6] = T0;
555
+ $[7] = props;
556
+ $[8] = t3;
557
+ $[9] = t4;
558
+ } else t4 = $[9];
559
+ return t4;
560
+ }
561
+ /**
562
+ * The dialog's header: its `Dialog.Title`, and anything beside it, such as a
563
+ * close button. Full screen it is the page's header bar. `style`, `ref` and
564
+ * `testID` land on its view.
565
+ */
566
+ function DialogHeader(t0) {
567
+ const $ = c(10);
568
+ let props;
569
+ let style;
570
+ if ($[0] !== t0) {
571
+ ({style, ...props} = t0);
572
+ $[0] = t0;
573
+ $[1] = props;
574
+ $[2] = style;
575
+ } else {
576
+ props = $[1];
577
+ style = $[2];
578
+ }
579
+ const layout = useLayout("Dialog.Header");
580
+ const styles = stylesOf(useTheme());
581
+ const { register } = layout;
582
+ let t1;
583
+ let t2;
584
+ if ($[3] !== register) {
585
+ t1 = () => register("header");
586
+ t2 = [register];
587
+ $[3] = register;
588
+ $[4] = t1;
589
+ $[5] = t2;
590
+ } else {
591
+ t1 = $[4];
592
+ t2 = $[5];
593
+ }
594
+ useLayoutEffect(t1, t2);
595
+ const T0 = View;
596
+ const t3 = composeStyles(styles.header, layout.basic ? void 0 : styles.headerFull, style);
597
+ let t4;
598
+ if ($[6] !== T0 || $[7] !== props || $[8] !== t3) {
599
+ t4 = /* @__PURE__ */ jsx(T0, {
600
+ ...props,
601
+ style: t3
602
+ });
603
+ $[6] = T0;
604
+ $[7] = props;
605
+ $[8] = t3;
606
+ $[9] = t4;
607
+ } else t4 = $[9];
608
+ return t4;
609
+ }
610
+ /**
611
+ * Names the dialog: the container is labelled by it, and a screen reader is
612
+ * sent to it once the dialog shows. In headline small as the basic dialog,
613
+ * and title large as the full-screen one, where it shares a 56dp bar.
614
+ * `style`, `ref` and `testID` land on React Native's own Text.
615
+ */
616
+ function DialogTitle(t0) {
617
+ const $ = c(16);
618
+ let props;
619
+ let ref;
620
+ let style;
621
+ if ($[0] !== t0) {
622
+ ({ref, style, ...props} = t0);
623
+ $[0] = t0;
624
+ $[1] = props;
625
+ $[2] = ref;
626
+ $[3] = style;
627
+ } else {
628
+ props = $[1];
629
+ ref = $[2];
630
+ style = $[3];
631
+ }
632
+ const layout = useLayout("Dialog.Title");
633
+ const styles = stylesOf(useTheme());
634
+ const role = useTypeRole(layout.basic ? "headlineSmall" : "titleLarge");
635
+ const { register, setTitle } = layout;
636
+ let t1;
637
+ let t2;
638
+ if ($[4] !== register) {
639
+ t1 = () => register("title");
640
+ t2 = [register];
641
+ $[4] = register;
642
+ $[5] = t1;
643
+ $[6] = t2;
644
+ } else {
645
+ t1 = $[5];
646
+ t2 = $[6];
647
+ }
648
+ useLayoutEffect(t1, t2);
649
+ const T0 = Text;
650
+ const t3 = layout.titleId;
651
+ let t4;
652
+ if ($[7] !== ref || $[8] !== setTitle) {
653
+ t4 = refsOf(setTitle, ref);
654
+ $[7] = ref;
655
+ $[8] = setTitle;
656
+ $[9] = t4;
657
+ } else t4 = $[9];
658
+ const t5 = "heading";
659
+ const t6 = composeStyles(role, styles.title, style);
660
+ let t7;
661
+ if ($[10] !== T0 || $[11] !== layout.titleId || $[12] !== props || $[13] !== t4 || $[14] !== t6) {
662
+ t7 = /* @__PURE__ */ jsx(T0, {
663
+ ...props,
664
+ nativeID: t3,
665
+ ref: t4,
666
+ role: t5,
667
+ style: t6
668
+ });
669
+ $[10] = T0;
670
+ $[11] = layout.titleId;
671
+ $[12] = props;
672
+ $[13] = t4;
673
+ $[14] = t6;
674
+ $[15] = t7;
675
+ } else t7 = $[15];
676
+ return t7;
677
+ }
678
+ function focusOf(title) {
679
+ return () => {
680
+ if (title !== null && Platform.OS !== "web") AccessibilityInfo.sendAccessibilityEvent(title, "focus");
681
+ };
682
+ }
683
+ function ignore() {}
684
+ function insetsOf(insets) {
685
+ return {
686
+ paddingBottom: insets.bottom,
687
+ paddingLeft: insets.left,
688
+ paddingRight: insets.right,
689
+ paddingTop: insets.top
690
+ };
691
+ }
692
+ function panelRoleOf(role, labelledBy) {
693
+ return {
694
+ "aria-labelledby": labelledBy,
695
+ "aria-modal": true,
696
+ role
697
+ };
698
+ }
699
+ function refsOf(own, other) {
700
+ return (node) => {
701
+ own(node);
702
+ if (typeof other === "function") other(node);
703
+ else if (other !== null && other !== void 0) other.current = node;
704
+ };
705
+ }
706
+ function registerOf(setParts) {
707
+ return (part) => {
708
+ setParts((parts) => ({
709
+ ...parts,
710
+ [part]: parts[part] + 1
711
+ }));
712
+ return () => {
713
+ setParts((parts) => ({
714
+ ...parts,
715
+ [part]: parts[part] - 1
716
+ }));
717
+ };
718
+ };
719
+ }
720
+ /**
721
+ * The scrim's and the panel's motion, and the timer that unmounts the dialog
722
+ * once its exit has run. The panel arrives over the medium duration on the
723
+ * emphasised decelerating curve and leaves over the short one on the
724
+ * accelerating curve, and the scrim fades over the short one on the standard
725
+ * curve, both ways. Under reduced motion the panel arrives and leaves at once.
726
+ */
727
+ function useDialogMotion(isOpen, present, setPresent, basic) {
728
+ const $ = c(24);
729
+ const { motion } = useTheme();
730
+ const reduceMotion = useReducedMotion();
731
+ const { height } = useWindowDimensions();
732
+ const panel = useSharedValue(0);
733
+ const scrim = useSharedValue(0);
734
+ let t0;
735
+ if ($[0] !== isOpen || $[1] !== motion.durationMedium1 || $[2] !== motion.durationShort2 || $[3] !== motion.durationShort3 || $[4] !== motion.easingEmphasizedAccelerate || $[5] !== motion.easingEmphasizedDecelerate || $[6] !== motion.easingStandard || $[7] !== panel || $[8] !== present || $[9] !== reduceMotion || $[10] !== scrim || $[11] !== setPresent) {
736
+ t0 = () => {
737
+ const fade = {
738
+ duration: motion.durationShort2,
739
+ easing: Easing.bezier(...motion.easingStandard)
740
+ };
741
+ if (isOpen) {
742
+ scrim.set(withTiming(1, fade));
743
+ panel.set(reduceMotion ? 1 : withTiming(1, {
744
+ duration: motion.durationMedium1,
745
+ easing: Easing.bezier(...motion.easingEmphasizedDecelerate)
746
+ }));
747
+ return;
748
+ }
749
+ if (!present) return;
750
+ scrim.set(withTiming(0, fade));
751
+ panel.set(reduceMotion ? 0 : withTiming(0, {
752
+ duration: motion.durationShort3,
753
+ easing: Easing.bezier(...motion.easingEmphasizedAccelerate)
754
+ }));
755
+ const timer = setTimeout(() => {
756
+ setPresent(false);
757
+ }, reduceMotion ? motion.durationShort2 : Math.max(motion.durationShort2, motion.durationShort3));
758
+ return () => {
759
+ clearTimeout(timer);
760
+ };
761
+ };
762
+ $[0] = isOpen;
763
+ $[1] = motion.durationMedium1;
764
+ $[2] = motion.durationShort2;
765
+ $[3] = motion.durationShort3;
766
+ $[4] = motion.easingEmphasizedAccelerate;
767
+ $[5] = motion.easingEmphasizedDecelerate;
768
+ $[6] = motion.easingStandard;
769
+ $[7] = panel;
770
+ $[8] = present;
771
+ $[9] = reduceMotion;
772
+ $[10] = scrim;
773
+ $[11] = setPresent;
774
+ $[12] = t0;
775
+ } else t0 = $[12];
776
+ let t1;
777
+ if ($[13] !== isOpen || $[14] !== motion || $[15] !== panel || $[16] !== present || $[17] !== reduceMotion || $[18] !== scrim || $[19] !== setPresent) {
778
+ t1 = [
779
+ isOpen,
780
+ motion,
781
+ panel,
782
+ present,
783
+ reduceMotion,
784
+ scrim,
785
+ setPresent
786
+ ];
787
+ $[13] = isOpen;
788
+ $[14] = motion;
789
+ $[15] = panel;
790
+ $[16] = present;
791
+ $[17] = reduceMotion;
792
+ $[18] = scrim;
793
+ $[19] = setPresent;
794
+ $[20] = t1;
795
+ } else t1 = $[20];
796
+ useEffect(t0, t1);
797
+ const t2 = useAnimatedStyle(() => {
798
+ "worklet";
799
+ const shown = panel.get();
800
+ return basic ? {
801
+ opacity: shown,
802
+ transform: [{ scale: SCALE_FROM + .09999999999999998 * shown }]
803
+ } : {
804
+ opacity: shown,
805
+ transform: [{ translateY: (1 - shown) * RISE_FROM * height }]
806
+ };
807
+ });
808
+ const t3 = useAnimatedStyle(() => {
809
+ "worklet";
810
+ return { opacity: scrim.get() };
811
+ });
812
+ let t4;
813
+ if ($[21] !== t2 || $[22] !== t3) {
814
+ t4 = {
815
+ panel: t2,
816
+ scrim: t3
817
+ };
818
+ $[21] = t2;
819
+ $[22] = t3;
820
+ $[23] = t4;
821
+ } else t4 = $[23];
822
+ return t4;
823
+ }
824
+ function useLayout(part) {
825
+ const layout = use(DialogLayoutContext);
826
+ if (layout === null) throw new Error(`${part} is drawn inside Dialog.Content.`);
827
+ return layout;
828
+ }
829
+ function useReturnFocus(present, outer) {
830
+ const $ = c(6);
831
+ const shown = useRef(present);
832
+ let t0;
833
+ if ($[0] !== outer?.trigger || $[1] !== present) {
834
+ t0 = () => {
835
+ const trigger = outer?.trigger ?? null;
836
+ const gone = shown.current && !present;
837
+ shown.current = present;
838
+ if (gone && trigger !== null && Platform.OS !== "web") AccessibilityInfo.sendAccessibilityEvent(trigger, "focus");
839
+ };
840
+ $[0] = outer?.trigger;
841
+ $[1] = present;
842
+ $[2] = t0;
843
+ } else t0 = $[2];
844
+ let t1;
845
+ if ($[3] !== outer || $[4] !== present) {
846
+ t1 = [outer, present];
847
+ $[3] = outer;
848
+ $[4] = present;
849
+ $[5] = t1;
850
+ } else t1 = $[5];
851
+ useEffect(t0, t1);
852
+ }
853
+ Dialog.Body = DialogBody;
854
+ Dialog.Content = DialogContent;
855
+ Dialog.Footer = DialogFooter;
856
+ Dialog.Header = DialogHeader;
857
+ Dialog.Title = DialogTitle;
858
+ //#endregion
859
+ export { Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle };
860
+
861
+ //# sourceMappingURL=index.js.map