@jobber/components-native 0.98.4 → 0.99.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 (73) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/AtlantisOverlayProvider/AtlantisOverlayProvider.js +5 -0
  3. package/dist/src/AtlantisOverlayProvider/index.js +1 -0
  4. package/dist/src/BottomSheet/BottomSheet.js +9 -11
  5. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +2 -2
  6. package/dist/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.js +9 -11
  7. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +7 -9
  8. package/dist/src/index.js +1 -1
  9. package/dist/src/utils/meta/meta.json +1 -1
  10. package/dist/tsconfig.build.tsbuildinfo +1 -1
  11. package/dist/types/src/AtlantisOverlayProvider/AtlantisOverlayProvider.d.ts +6 -0
  12. package/dist/types/src/AtlantisOverlayProvider/index.d.ts +1 -0
  13. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +3 -3
  14. package/dist/types/src/index.d.ts +1 -1
  15. package/package.json +2 -2
  16. package/src/AtlantisOverlayProvider/AtlantisOverlayProvider.tsx +12 -0
  17. package/src/AtlantisOverlayProvider/index.ts +1 -0
  18. package/src/BottomSheet/BottomSheet.tsx +13 -13
  19. package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +10 -10
  20. package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +4 -4
  21. package/src/ButtonGroup/ButtonGroup.stories.tsx +10 -8
  22. package/src/ButtonGroup/ButtonGroup.test.tsx +7 -10
  23. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +26 -29
  24. package/src/Form/Form.stories.tsx +8 -4
  25. package/src/Form/Form.test.tsx +51 -54
  26. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +7 -10
  27. package/src/FormatFile/FormatFile.stories.tsx +3 -4
  28. package/src/FormatFile/FormatFile.test.tsx +11 -14
  29. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +6 -9
  30. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +21 -24
  31. package/src/InputDate/InputDate.test.tsx +5 -8
  32. package/src/InputTime/InputTime.stories.tsx +8 -4
  33. package/src/InputTime/InputTime.test.tsx +5 -8
  34. package/src/ThumbnailList/ThumbnailList.stories.tsx +6 -4
  35. package/src/ThumbnailList/ThumbnailList.test.tsx +5 -8
  36. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +101 -150
  37. package/src/index.ts +1 -1
  38. package/src/utils/meta/meta.json +2 -2
  39. package/dist/src/Menu/Menu.js +0 -85
  40. package/dist/src/Menu/Menu.style.js +0 -7
  41. package/dist/src/Menu/components/MenuOption/MenuOption.js +0 -27
  42. package/dist/src/Menu/components/MenuOption/MenuOption.style.js +0 -11
  43. package/dist/src/Menu/components/MenuOption/index.js +0 -1
  44. package/dist/src/Menu/components/Overlay/Overlay.js +0 -10
  45. package/dist/src/Menu/components/Overlay/Overlay.style.js +0 -8
  46. package/dist/src/Menu/components/Overlay/index.js +0 -1
  47. package/dist/src/Menu/index.js +0 -1
  48. package/dist/src/Menu/types.js +0 -1
  49. package/dist/src/Menu/utils.js +0 -78
  50. package/dist/types/src/Menu/Menu.d.ts +0 -3
  51. package/dist/types/src/Menu/Menu.style.d.ts +0 -18
  52. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +0 -3
  53. package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +0 -8
  54. package/dist/types/src/Menu/components/MenuOption/index.d.ts +0 -1
  55. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +0 -3
  56. package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +0 -12
  57. package/dist/types/src/Menu/components/Overlay/index.d.ts +0 -1
  58. package/dist/types/src/Menu/index.d.ts +0 -2
  59. package/dist/types/src/Menu/types.d.ts +0 -26
  60. package/dist/types/src/Menu/utils.d.ts +0 -11
  61. package/src/Menu/Menu.stories.tsx +0 -52
  62. package/src/Menu/Menu.style.ts +0 -17
  63. package/src/Menu/Menu.test.tsx +0 -203
  64. package/src/Menu/Menu.tsx +0 -141
  65. package/src/Menu/components/MenuOption/MenuOption.style.tsx +0 -12
  66. package/src/Menu/components/MenuOption/MenuOption.tsx +0 -66
  67. package/src/Menu/components/MenuOption/index.ts +0 -1
  68. package/src/Menu/components/Overlay/Overlay.style.ts +0 -15
  69. package/src/Menu/components/Overlay/Overlay.tsx +0 -18
  70. package/src/Menu/components/Overlay/index.ts +0 -1
  71. package/src/Menu/index.ts +0 -6
  72. package/src/Menu/types.ts +0 -31
  73. package/src/Menu/utils.ts +0 -148
@@ -1,7 +1,6 @@
1
1
  import React, { createRef } from "react";
2
2
  import type { RenderAPI } from "@testing-library/react-native";
3
3
  import { fireEvent, render } from "@testing-library/react-native";
4
- import { Host } from "react-native-portalize";
5
4
  import { act } from "react-test-renderer";
6
5
  import type { BottomSheetOptionsSuffix } from "./FormatFileBottomSheet";
7
6
  import { FormatFileBottomSheet } from "./FormatFileBottomSheet";
@@ -20,14 +19,12 @@ const renderBottomSheet = (
20
19
  bottomSheetOptionsSuffix: BottomSheetOptionsSuffix,
21
20
  ) => {
22
21
  return render(
23
- <Host>
24
- <FormatFileBottomSheet
25
- onPreviewPress={onPreview}
26
- onRemovePress={onRemove}
27
- bottomSheetRef={bottomSheetRef}
28
- bottomSheetOptionsSuffix={bottomSheetOptionsSuffix}
29
- />
30
- </Host>,
22
+ <FormatFileBottomSheet
23
+ onPreviewPress={onPreview}
24
+ onRemovePress={onRemove}
25
+ bottomSheetRef={bottomSheetRef}
26
+ bottomSheetOptionsSuffix={bottomSheetOptionsSuffix}
27
+ />,
31
28
  );
32
29
  };
33
30
 
@@ -1,6 +1,5 @@
1
1
  import type { RefObject } from "react";
2
2
  import React from "react";
3
- import { Portal } from "react-native-portalize";
4
3
  import type { BottomSheetRef } from "../../../BottomSheet/BottomSheet";
5
4
  import { BottomSheet } from "../../../BottomSheet/BottomSheet";
6
5
  import { BottomSheetOption } from "../../../BottomSheet/components/BottomSheetOption";
@@ -30,28 +29,26 @@ export const FormatFileBottomSheet = ({
30
29
  };
31
30
 
32
31
  return (
33
- <Portal>
34
- <BottomSheet ref={bottomSheetRef}>
35
- {onPreviewPress ? (
36
- <BottomSheetOption
37
- icon={"eye"}
38
- text={t("FormatFile.preview", {
39
- item: bottomSheetOptionsSuffix || "",
40
- })}
41
- onPress={() => handlePress(onPreviewPress)}
42
- />
43
- ) : undefined}
44
- {onRemovePress ? (
45
- <BottomSheetOption
46
- icon={"trash"}
47
- destructive={true}
48
- text={t("FormatFile.remove", {
49
- item: bottomSheetOptionsSuffix || "",
50
- })}
51
- onPress={() => handlePress(onRemovePress)}
52
- />
53
- ) : undefined}
54
- </BottomSheet>
55
- </Portal>
32
+ <BottomSheet ref={bottomSheetRef}>
33
+ {onPreviewPress ? (
34
+ <BottomSheetOption
35
+ icon={"eye"}
36
+ text={t("FormatFile.preview", {
37
+ item: bottomSheetOptionsSuffix || "",
38
+ })}
39
+ onPress={() => handlePress(onPreviewPress)}
40
+ />
41
+ ) : undefined}
42
+ {onRemovePress ? (
43
+ <BottomSheetOption
44
+ icon={"trash"}
45
+ destructive={true}
46
+ text={t("FormatFile.remove", {
47
+ item: bottomSheetOptionsSuffix || "",
48
+ })}
49
+ onPress={() => handlePress(onRemovePress)}
50
+ />
51
+ ) : undefined}
52
+ </BottomSheet>
56
53
  );
57
54
  };
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { fireEvent, render, waitFor } from "@testing-library/react-native";
3
- import { Host } from "react-native-portalize";
4
3
  import { FormProvider, useForm } from "react-hook-form";
5
4
  import { Keyboard } from "react-native";
6
5
  import { InputDate } from "./InputDate";
@@ -175,13 +174,11 @@ describe("InputDate", () => {
175
174
  const setup = () =>
176
175
  render(
177
176
  <SimpleFormWithProvider defaultValues={{ [pickerName]: value }}>
178
- <Host>
179
- <InputDate
180
- name={pickerName}
181
- onChange={handleChange}
182
- validations={{ required: requiredError }}
183
- />
184
- </Host>
177
+ <InputDate
178
+ name={pickerName}
179
+ onChange={handleChange}
180
+ validations={{ required: requiredError }}
181
+ />
185
182
  </SimpleFormWithProvider>,
186
183
  );
187
184
 
@@ -1,8 +1,12 @@
1
1
  import React, { useState } from "react";
2
2
  import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
3
- import { Host } from "react-native-portalize";
4
3
  import { SafeAreaProvider } from "react-native-safe-area-context";
5
- import { Content, Form, InputTime } from "@jobber/components-native";
4
+ import {
5
+ AtlantisOverlayProvider,
6
+ Content,
7
+ Form,
8
+ InputTime,
9
+ } from "@jobber/components-native";
6
10
 
7
11
  const meta = {
8
12
  title: "Components/Forms and Inputs/InputTime",
@@ -63,7 +67,7 @@ const EmptyValueTemplate = (args: ControlledStory["args"]) => {
63
67
 
64
68
  const FormControlledTemplate = (args: FormStory["args"]) => (
65
69
  <SafeAreaProvider>
66
- <Host>
70
+ <AtlantisOverlayProvider>
67
71
  <Form
68
72
  initialValues={{ startTime: new Date("2023-07-21T16:36:34.873Z") }}
69
73
  onSubmit={value =>
@@ -84,7 +88,7 @@ const FormControlledTemplate = (args: FormStory["args"]) => (
84
88
  />
85
89
  </Content>
86
90
  </Form>
87
- </Host>
91
+ </AtlantisOverlayProvider>
88
92
  </SafeAreaProvider>
89
93
  );
90
94
 
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { fireEvent, render, waitFor } from "@testing-library/react-native";
3
- import { Host } from "react-native-portalize";
4
3
  import { FormProvider, useForm } from "react-hook-form";
5
4
  import { Keyboard } from "react-native";
6
5
  import { InputTime } from "./InputTime";
@@ -223,13 +222,11 @@ describe("Form controlled", () => {
223
222
  const setup = () =>
224
223
  render(
225
224
  <SimpleFormWithProvider defaultValues={{ [pickerName]: value }}>
226
- <Host>
227
- <InputTime
228
- name={pickerName}
229
- onChange={handleChange}
230
- validations={{ required: requiredError }}
231
- />
232
- </Host>
225
+ <InputTime
226
+ name={pickerName}
227
+ onChange={handleChange}
228
+ validations={{ required: requiredError }}
229
+ />
233
230
  </SimpleFormWithProvider>,
234
231
  );
235
232
 
@@ -1,8 +1,10 @@
1
1
  import React from "react";
2
2
  import type { Meta, StoryObj } from "@storybook/react-native-web-vite";
3
- import { Host } from "react-native-portalize";
4
3
  import { SafeAreaProvider } from "react-native-safe-area-context";
5
- import { ThumbnailList } from "@jobber/components-native";
4
+ import {
5
+ AtlantisOverlayProvider,
6
+ ThumbnailList,
7
+ } from "@jobber/components-native";
6
8
 
7
9
  const meta = {
8
10
  title: "Components/Images and Icons/ThumbnailList",
@@ -17,9 +19,9 @@ type Story = StoryObj<typeof meta>;
17
19
 
18
20
  const BasicTemplate = (args: Story["args"]) => (
19
21
  <SafeAreaProvider>
20
- <Host>
22
+ <AtlantisOverlayProvider>
21
23
  <ThumbnailList {...args} />
22
- </Host>
24
+ </AtlantisOverlayProvider>
23
25
  </SafeAreaProvider>
24
26
  );
25
27
 
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { fireEvent, render, screen } from "@testing-library/react-native";
3
- import { Host } from "react-native-portalize";
4
3
  import { ThumbnailList } from "./ThumbnailList";
5
4
  import type { File } from "../FormatFile/types";
6
5
 
@@ -46,13 +45,11 @@ const mockCreateThumbnail = jest.fn(async () => ({
46
45
 
47
46
  function setup(snapshot?: boolean) {
48
47
  return render(
49
- <Host>
50
- <ThumbnailList
51
- files={snapshot ? snapshotFile : files}
52
- handleOpenFile={onOpenFile}
53
- createThumbnail={mockCreateThumbnail}
54
- />
55
- </Host>,
48
+ <ThumbnailList
49
+ files={snapshot ? snapshotFile : files}
50
+ handleOpenFile={onOpenFile}
51
+ createThumbnail={mockCreateThumbnail}
52
+ />,
56
53
  );
57
54
  }
58
55
 
@@ -1,185 +1,136 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`renders a thumbnail component with attachments 1`] = `
4
- [
5
- <View
6
- collapsable={false}
7
- pointerEvents="box-none"
8
- style={
9
- [
10
- {
11
- "flex": 1,
12
- },
13
- undefined,
14
- ]
15
- }
16
- >
4
+ <View
5
+ style={
6
+ [
7
+ {
8
+ "display": "flex",
9
+ "flexDirection": "row",
10
+ "flexWrap": "wrap",
11
+ "marginTop": 4,
12
+ "maxHeight": 136,
13
+ "overflow": "hidden",
14
+ },
15
+ false,
16
+ ]
17
+ }
18
+ >
19
+ <View>
17
20
  <View
21
+ accessibilityHint="Select for more options"
22
+ accessibilityRole="imagebutton"
23
+ accessibilityState={
24
+ {
25
+ "busy": undefined,
26
+ "checked": undefined,
27
+ "disabled": undefined,
28
+ "expanded": undefined,
29
+ "selected": undefined,
30
+ }
31
+ }
32
+ accessibilityValue={
33
+ {
34
+ "max": undefined,
35
+ "min": undefined,
36
+ "now": undefined,
37
+ "text": undefined,
38
+ }
39
+ }
40
+ accessible={true}
41
+ collapsable={false}
42
+ focusable={true}
43
+ onClick={[Function]}
44
+ onResponderGrant={[Function]}
45
+ onResponderMove={[Function]}
46
+ onResponderRelease={[Function]}
47
+ onResponderTerminate={[Function]}
48
+ onResponderTerminationRequest={[Function]}
49
+ onStartShouldSetResponder={[Function]}
18
50
  style={
19
- [
20
- {
21
- "display": "flex",
22
- "flexDirection": "row",
23
- "flexWrap": "wrap",
24
- "marginTop": 4,
25
- "maxHeight": 136,
26
- "overflow": "hidden",
27
- },
28
- false,
29
- ]
51
+ {
52
+ "opacity": 1,
53
+ }
30
54
  }
31
55
  >
32
- <View>
33
- <View
34
- accessibilityHint="Select for more options"
35
- accessibilityRole="imagebutton"
36
- accessibilityState={
56
+ <View
57
+ style={
58
+ [
37
59
  {
38
- "busy": undefined,
39
- "checked": undefined,
40
- "disabled": undefined,
41
- "expanded": undefined,
42
- "selected": undefined,
43
- }
44
- }
45
- accessibilityValue={
60
+ "backgroundColor": "hsl(43, 18%, 92%)",
61
+ "borderColor": "hsl(200, 13%, 87%)",
62
+ "borderRadius": 8,
63
+ "borderWidth": 1,
64
+ "marginBottom": 8,
65
+ "overflow": "hidden",
66
+ },
46
67
  {
47
- "max": undefined,
48
- "min": undefined,
49
- "now": undefined,
50
- "text": undefined,
51
- }
52
- }
68
+ "height": 64,
69
+ "marginRight": 8,
70
+ "width": 64,
71
+ },
72
+ ]
73
+ }
74
+ >
75
+ <View
76
+ accessibilityLabel="image.jpeg"
53
77
  accessible={true}
54
- collapsable={false}
55
- focusable={true}
56
- onClick={[Function]}
57
- onResponderGrant={[Function]}
58
- onResponderMove={[Function]}
59
- onResponderRelease={[Function]}
60
- onResponderTerminate={[Function]}
61
- onResponderTerminationRequest={[Function]}
62
- onStartShouldSetResponder={[Function]}
63
- style={
64
- {
65
- "opacity": 1,
66
- }
67
- }
68
78
  >
69
79
  <View
80
+ accessibilityIgnoresInvertColors={true}
70
81
  style={
71
82
  [
72
83
  {
73
- "backgroundColor": "hsl(43, 18%, 92%)",
74
- "borderColor": "hsl(200, 13%, 87%)",
75
- "borderRadius": 8,
76
- "borderWidth": 1,
77
- "marginBottom": 8,
78
- "overflow": "hidden",
84
+ "alignItems": "center",
85
+ "justifyContent": "center",
86
+ "width": "100%",
79
87
  },
80
88
  {
81
- "height": 64,
82
- "marginRight": 8,
83
- "width": 64,
89
+ "height": "100%",
84
90
  },
85
91
  ]
86
92
  }
87
93
  >
88
- <View
89
- accessibilityLabel="image.jpeg"
90
- accessible={true}
91
- >
92
- <View
93
- accessibilityIgnoresInvertColors={true}
94
- style={
95
- [
96
- {
97
- "alignItems": "center",
98
- "justifyContent": "center",
99
- "width": "100%",
100
- },
101
- {
102
- "height": "100%",
103
- },
104
- ]
94
+ <Image
95
+ onLoadEnd={[Function]}
96
+ onLoadStart={[Function]}
97
+ resizeMode="cover"
98
+ source={
99
+ {
100
+ "uri": "https://imageurl.com/ababathumb.jpg",
105
101
  }
106
- >
107
- <Image
108
- onLoadEnd={[Function]}
109
- onLoadStart={[Function]}
110
- resizeMode="cover"
111
- source={
112
- {
113
- "uri": "https://imageurl.com/ababathumb.jpg",
114
- }
115
- }
116
- style={
117
- [
118
- {
119
- "bottom": 0,
120
- "left": 0,
121
- "position": "absolute",
122
- "right": 0,
123
- "top": 0,
124
- },
125
- {
126
- "height": "100%",
127
- "width": "100%",
128
- },
129
- undefined,
130
- ]
131
- }
132
- testID="test-image"
133
- />
134
- </View>
135
- </View>
102
+ }
103
+ style={
104
+ [
105
+ {
106
+ "bottom": 0,
107
+ "left": 0,
108
+ "position": "absolute",
109
+ "right": 0,
110
+ "top": 0,
111
+ },
112
+ {
113
+ "height": "100%",
114
+ "width": "100%",
115
+ },
116
+ undefined,
117
+ ]
118
+ }
119
+ testID="test-image"
120
+ />
136
121
  </View>
137
122
  </View>
138
123
  </View>
139
124
  </View>
140
- </View>,
141
- <View
142
- collapsable={false}
143
- pointerEvents="box-none"
144
- style={
145
- {
146
- "bottom": 0,
147
- "left": 0,
148
- "position": "absolute",
149
- "right": 0,
150
- "top": 0,
151
- }
152
- }
153
- >
154
125
  <View
155
- backdropComponent={[Function]}
156
- backgroundStyle={
157
- {
158
- "borderTopLeftRadius": 24,
159
- "borderTopRightRadius": 24,
160
- }
161
- }
162
- enablePanDownToClose={true}
163
- handleStyle={
164
- {
165
- "display": "none",
166
- }
167
- }
168
- keyboardBlurBehavior="restore"
169
126
  style={
170
127
  {
171
128
  "display": "none",
172
129
  }
173
130
  }
174
- testID="bottom-sheet-mock"
131
+ testID="bottom-sheet-modal-mock"
175
132
  >
176
133
  <View
177
- style={
178
- {
179
- "paddingBottom": 8,
180
- "paddingTop": 8,
181
- }
182
- }
183
134
  testID="bottom-sheet-view"
184
135
  >
185
136
  <View
@@ -348,6 +299,6 @@ exports[`renders a thumbnail component with attachments 1`] = `
348
299
  </View>
349
300
  </View>
350
301
  </View>
351
- </View>,
352
- ]
302
+ </View>
303
+ </View>
353
304
  `;
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./ActionItem";
2
2
  export * from "./ActionLabel";
3
3
  export * from "./ActivityIndicator";
4
4
  export * from "./AtlantisContext";
5
+ export * from "./AtlantisOverlayProvider";
5
6
  export * from "./AtlantisThemeContext";
6
7
  export * from "./AutoLink";
7
8
  export * from "./Banner";
@@ -35,7 +36,6 @@ export * from "./InputPressable";
35
36
  export * from "./InputSearch";
36
37
  export * from "./InputText";
37
38
  export * from "./InputTime";
38
- export * from "./Menu";
39
39
  export * from "./ProgressBar";
40
40
  export * from "./Select";
41
41
  export * from "./StatusLabel";
@@ -9,6 +9,7 @@
9
9
  "AtlantisContext.Provider",
10
10
  "AtlantisFormContext.Consumer",
11
11
  "AtlantisFormContext.Provider",
12
+ "AtlantisOverlayProvider",
12
13
  "AtlantisThemeContextProvider",
13
14
  "AutoLink",
14
15
  "Banner",
@@ -56,7 +57,6 @@
56
57
  "InputSearch",
57
58
  "InputText",
58
59
  "InputTime",
59
- "Menu",
60
60
  "Option",
61
61
  "ProgressBar",
62
62
  "Select",
@@ -70,4 +70,4 @@
70
70
  "Typography",
71
71
  "TypographyGestureDetector"
72
72
  ]
73
- }
73
+ }
@@ -1,85 +0,0 @@
1
- import React, { useCallback, useRef, useState } from "react";
2
- import { Keyboard, Platform, Pressable, View, useWindowDimensions, } from "react-native";
3
- import { Portal } from "react-native-portalize";
4
- import { useSafeAreaFrame } from "react-native-safe-area-context";
5
- import { useStyles } from "./Menu.style";
6
- import { findViewpoint } from "./utils";
7
- import { MenuOption } from "./components/MenuOption";
8
- import { Overlay } from "./components/Overlay";
9
- import { Button } from "../Button";
10
- import { Content } from "../Content";
11
- import { useAtlantisContext } from "../AtlantisContext";
12
- import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
13
- import { useAtlantisTheme } from "../AtlantisThemeContext";
14
- export function Menu({ menuOptions, customActivator }) {
15
- const [open, setOpen] = useState(false);
16
- const [menuPosition, setMenuPosition] = useState();
17
- const activatorLayout = useRef(null);
18
- const menuButtonRef = useRef(null);
19
- const screenInfo = useScreenInformation();
20
- const { t } = useAtlantisI18n();
21
- const styles = useStyles();
22
- const findMenuLayout = useCallback(() => {
23
- if (activatorLayout.current) {
24
- setMenuPosition(findViewpoint(screenInfo, activatorLayout.current, styles));
25
- }
26
- }, [screenInfo, activatorLayout, styles]);
27
- const openMenu = () => {
28
- var _a;
29
- (_a = menuButtonRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow((x, y, width, height) => {
30
- activatorLayout.current = {
31
- x,
32
- y,
33
- width,
34
- height,
35
- };
36
- findMenuLayout();
37
- setOpen(true);
38
- });
39
- };
40
- const activatorOnPress = (onPress) => {
41
- onPress && onPress();
42
- if (Platform.OS === "ios" && Keyboard.isVisible()) {
43
- // On iOS, the keyboard height causes problems with the menu positioning logic.
44
- // Wait until the keyboard is fully hidden before we show the menu.
45
- onKeyboardDidHide(openMenu);
46
- Keyboard.dismiss();
47
- }
48
- else {
49
- openMenu();
50
- }
51
- };
52
- const { tokens } = useAtlantisTheme();
53
- return (React.createElement(React.Fragment, null,
54
- React.createElement(View, { ref: ref => {
55
- menuButtonRef.current = ref;
56
- }, collapsable: false },
57
- customActivator && (React.createElement(Pressable, { style: ({ pressed }) => [
58
- {
59
- opacity: pressed ? tokens["opacity-pressed"] : 1,
60
- },
61
- ], pointerEvents: "box-only", onPress: () => {
62
- activatorOnPress(customActivator.props.onPress);
63
- }, onLongPress: customActivator.props.onLongPress }, customActivator)),
64
- !customActivator && (React.createElement(Button, { icon: "more", accessibilityLabel: t("menu"), variation: "cancel", type: "tertiary", onPress: () => {
65
- activatorOnPress();
66
- } }))),
67
- React.createElement(Portal, null, open && (React.createElement(React.Fragment, null,
68
- React.createElement(Overlay, { setOpen: setOpen }),
69
- React.createElement(View, { style: [open && menuPosition, styles.menu] },
70
- React.createElement(Content, { spacing: "none", childSpacing: "small" }, menuOptions === null || menuOptions === void 0 ? void 0 : menuOptions.map((menuOption, index) => {
71
- return (React.createElement(MenuOption, Object.assign({}, menuOption, { key: index, setOpen: setOpen })));
72
- }))))))));
73
- }
74
- function useScreenInformation() {
75
- const { headerHeight } = useAtlantisContext();
76
- const windowWidth = useWindowDimensions().width;
77
- const { height: windowHeight } = useSafeAreaFrame();
78
- return { headerHeight, windowWidth, windowHeight };
79
- }
80
- function onKeyboardDidHide(callback) {
81
- const listener = Keyboard.addListener("keyboardDidHide", () => {
82
- listener.remove();
83
- callback();
84
- });
85
- }
@@ -1,7 +0,0 @@
1
- import { buildThemedStyles } from "../AtlantisThemeContext";
2
- const menuWidth = 208;
3
- export const useStyles = buildThemedStyles(tokens => {
4
- return {
5
- menu: Object.assign({ position: "absolute", backgroundColor: tokens["color-surface"], paddingHorizontal: tokens["space-small"], paddingVertical: tokens["space-small"] + tokens["space-smallest"], borderRadius: tokens["radius-base"], width: menuWidth }, tokens["shadow-high"]),
6
- };
7
- });