@terreno/ui 0.0.16 → 0.0.17

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 (35) hide show
  1. package/dist/Button.js +7 -9
  2. package/dist/Button.js.map +1 -1
  3. package/dist/Common.d.ts +39 -0
  4. package/dist/UserInactivity.d.ts +28 -0
  5. package/dist/UserInactivity.js +100 -0
  6. package/dist/UserInactivity.js.map +1 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/Button.tsx +20 -37
  12. package/src/Common.ts +45 -0
  13. package/src/DateTimeActionSheet.test.tsx +53 -4
  14. package/src/MobileAddressAutoComplete.test.tsx +47 -4
  15. package/src/ModalSheet.test.tsx +37 -5
  16. package/src/PickerSelect.test.tsx +41 -5
  17. package/src/Signature.test.tsx +21 -4
  18. package/src/SignatureField.test.tsx +49 -5
  19. package/src/SplitPage.test.tsx +71 -4
  20. package/src/UnifiedAddressAutoComplete.test.tsx +43 -5
  21. package/src/UserInactivity.test.tsx +96 -0
  22. package/src/UserInactivity.tsx +129 -0
  23. package/src/WebAddressAutocomplete.test.tsx +22 -4
  24. package/src/__snapshots__/Button.test.tsx.snap +0 -347
  25. package/src/__snapshots__/DateTimeActionSheet.test.tsx.snap +11 -0
  26. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +230 -0
  27. package/src/__snapshots__/ModalSheet.test.tsx.snap +37 -0
  28. package/src/__snapshots__/PickerSelect.test.tsx.snap +798 -11
  29. package/src/__snapshots__/Signature.test.tsx.snap +67 -0
  30. package/src/__snapshots__/SignatureField.test.tsx.snap +129 -21
  31. package/src/__snapshots__/SplitPage.test.tsx.snap +686 -0
  32. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +377 -0
  33. package/src/__snapshots__/UserInactivity.test.tsx.snap +108 -0
  34. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +238 -0
  35. package/src/index.tsx +1 -0
package/dist/Button.js CHANGED
@@ -1,18 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
3
3
  import debounce from "lodash/debounce";
4
- import { useMemo, useState } from "react";
4
+ import { lazy, Suspense, useMemo, useState } from "react";
5
5
  import { ActivityIndicator, Pressable, Text, View } from "react-native";
6
6
  import { Box } from "./Box";
7
7
  import { isMobileDevice } from "./MediaQuery";
8
- import { Modal } from "./Modal";
9
8
  import { useTheme } from "./Theme";
10
9
  import { Tooltip } from "./Tooltip";
11
10
  import { Unifier } from "./Unifier";
12
11
  import { isNative } from "./Utilities";
13
- const ConfirmationModal = ({ visible, title, subtitle, text, onConfirm, onCancel }) => {
14
- return (_jsx(Modal, { onDismiss: onCancel, primaryButtonOnClick: onConfirm, primaryButtonText: "Confirm", secondaryButtonOnClick: onCancel, secondaryButtonText: "Cancel", subtitle: subtitle, title: title, visible: visible, children: _jsx(Text, { children: text }) }));
15
- };
12
+ // Lazy load Modal to break the circular dependency: Modal -> Button -> Modal
13
+ const LazyModal = lazy(() => import("./Modal").then((module) => ({ default: module.Modal })));
16
14
  const ButtonComponent = ({ confirmationText = "Are you sure you want to continue?", disabled = false, fullWidth = false, iconName, iconPosition = "left", loading: propsLoading, modalTitle = "Confirm", modalSubTitle, testID, text, variant = "primary", withConfirmation = false, onClick, }) => {
17
15
  const [loading, setLoading] = useState(propsLoading);
18
16
  const [showConfirmation, setShowConfirmation] = useState(false);
@@ -89,10 +87,10 @@ const ButtonComponent = ({ confirmationText = "Are you sure you want to continue
89
87
  alignSelf: "center",
90
88
  marginLeft: iconPosition === "right" ? 8 : 0,
91
89
  marginRight: iconPosition === "left" ? 8 : 0,
92
- }, children: _jsx(FontAwesome6, { color: color, name: iconName, size: 16, solid: true }) })), _jsx(Text, { style: { color, fontSize: 16, fontWeight: "700" }, children: text })] }), Boolean(loading) && (_jsx(Box, { marginLeft: 2, children: _jsx(ActivityIndicator, { color: color, size: "small" }) }))] }), withConfirmation && (_jsx(ConfirmationModal, { onCancel: () => setShowConfirmation(false), onConfirm: async () => {
93
- await onClick();
94
- setShowConfirmation(false);
95
- }, subtitle: modalSubTitle, text: confirmationText, title: modalTitle, visible: showConfirmation }))] }));
90
+ }, children: _jsx(FontAwesome6, { color: color, name: iconName, size: 16, solid: true }) })), _jsx(Text, { style: { color, fontSize: 16, fontWeight: "700" }, children: text })] }), Boolean(loading) && (_jsx(Box, { marginLeft: 2, children: _jsx(ActivityIndicator, { color: color, size: "small" }) }))] }), withConfirmation && showConfirmation && (_jsx(Suspense, { fallback: null, children: _jsx(LazyModal, { onDismiss: () => setShowConfirmation(false), primaryButtonOnClick: async () => {
91
+ await onClick();
92
+ setShowConfirmation(false);
93
+ }, primaryButtonText: "Confirm", secondaryButtonOnClick: () => setShowConfirmation(false), secondaryButtonText: "Cancel", subtitle: modalSubTitle, text: confirmationText, title: modalTitle, visible: showConfirmation }) }))] }));
96
94
  };
97
95
  export const Button = (props) => {
98
96
  const { tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false } = props;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,iCAAiC,CAAC;AAC3D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAU,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EA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K,KAAK,EAAI,GACtB,CACX,CAAC;IACJ,CAAC;IAED,OAAO,KAAC,eAAe,oBAAK,KAAK,EAAI,CAAC;AACxC,CAAC,CAAC"}
package/dist/Common.d.ts CHANGED
@@ -2322,4 +2322,43 @@ export interface SliderProps extends HelperTextProps, ErrorTextProps {
2322
2322
  */
2323
2323
  valueMapping?: ValueMappingItem[];
2324
2324
  }
2325
+ export interface UserInactivityProps {
2326
+ /**
2327
+ * Children components to embed inside UserInactivity's View.
2328
+ * If any children component is pressed, `onAction` is called after
2329
+ * `timeForInactivity` milliseconds.
2330
+ */
2331
+ children: React.ReactNode;
2332
+ /**
2333
+ * If it's explicitly set to `true` after the component has already been initialized,
2334
+ * the timer restarts and the view is considered active until the new timer expires.
2335
+ * @default true
2336
+ */
2337
+ isActive?: boolean;
2338
+ /**
2339
+ * Callback triggered anytime UserInactivity's View isn't touched for more than
2340
+ * `timeForInactivity` milliseconds.
2341
+ * The `active` argument is true if and only if the View wasn't touched for more
2342
+ * than `timeForInactivity` milliseconds.
2343
+ */
2344
+ onAction: (active: boolean) => void;
2345
+ /**
2346
+ * If set to true, the timer is not reset when the keyboard appears
2347
+ * or disappears.
2348
+ * @default false
2349
+ */
2350
+ skipKeyboard?: boolean;
2351
+ /**
2352
+ * Optional custom style for UserInactivity's View.
2353
+ * @default { flex: 1 }
2354
+ */
2355
+ style?: StyleProp<ViewStyle>;
2356
+ /**
2357
+ * Number of milliseconds after which the view is considered inactive.
2358
+ * If it changed, the timer restarts and the view is considered active until
2359
+ * the new timer expires.
2360
+ * @default 10000
2361
+ */
2362
+ timeForInactivity?: number;
2363
+ }
2325
2364
  export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2017-2021 Alberto Schiabel
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ *
24
+ * Vendored from https://github.com/jkomyno/react-native-user-inactivity
25
+ */
26
+ import { type FC } from "react";
27
+ import type { UserInactivityProps } from "./Common";
28
+ export declare const UserInactivity: FC<UserInactivityProps>;
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2017-2021 Alberto Schiabel
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ *
25
+ * Vendored from https://github.com/jkomyno/react-native-user-inactivity
26
+ */
27
+ import { useCallback, useEffect, useRef, useState } from "react";
28
+ import { Keyboard, PanResponder, View } from "react-native";
29
+ const DEFAULT_TIME_FOR_INACTIVITY = 10000;
30
+ const DEFAULT_STYLE = {
31
+ flex: 1,
32
+ };
33
+ export const UserInactivity = ({ children, isActive: isActiveProp, onAction, skipKeyboard = false, style, timeForInactivity = DEFAULT_TIME_FOR_INACTIVITY, }) => {
34
+ const actualStyle = style !== null && style !== void 0 ? style : DEFAULT_STYLE;
35
+ const initialActive = isActiveProp === undefined ? true : isActiveProp;
36
+ const [active, setActive] = useState(initialActive);
37
+ const [resetKey, setResetKey] = useState(0);
38
+ const timeoutRef = useRef(null);
39
+ const isFirstRender = useRef(true);
40
+ const clearTimer = useCallback(() => {
41
+ if (timeoutRef.current !== null) {
42
+ clearTimeout(timeoutRef.current);
43
+ timeoutRef.current = null;
44
+ }
45
+ }, []);
46
+ const resetTimerDueToActivity = useCallback(() => {
47
+ clearTimer();
48
+ setActive(true);
49
+ setResetKey((prev) => prev + 1);
50
+ }, [clearTimer]);
51
+ // Handle isActive prop changes
52
+ useEffect(() => {
53
+ if (isActiveProp) {
54
+ resetTimerDueToActivity();
55
+ }
56
+ }, [isActiveProp, resetTimerDueToActivity]);
57
+ // Setup the inactivity timeout
58
+ useEffect(() => {
59
+ timeoutRef.current = setTimeout(() => {
60
+ setActive(false);
61
+ onAction(false);
62
+ }, timeForInactivity);
63
+ return clearTimer;
64
+ }, [resetKey, timeForInactivity, onAction, clearTimer]);
65
+ // Trigger onAction when active state changes (except on first render)
66
+ useEffect(() => {
67
+ if (isFirstRender.current) {
68
+ isFirstRender.current = false;
69
+ }
70
+ else {
71
+ if (active) {
72
+ onAction(true);
73
+ }
74
+ }
75
+ }, [active, onAction]);
76
+ // Setup keyboard listeners
77
+ useEffect(() => {
78
+ if (skipKeyboard) {
79
+ return;
80
+ }
81
+ const hideEvent = Keyboard.addListener("keyboardDidHide", resetTimerDueToActivity);
82
+ const showEvent = Keyboard.addListener("keyboardDidShow", resetTimerDueToActivity);
83
+ return () => {
84
+ hideEvent.remove();
85
+ showEvent.remove();
86
+ };
87
+ }, [skipKeyboard, resetTimerDueToActivity]);
88
+ const resetTimerForPanResponder = useCallback(() => {
89
+ resetTimerDueToActivity();
90
+ return false;
91
+ }, [resetTimerDueToActivity]);
92
+ // Initialize PanResponder once
93
+ const [panResponder] = useState(() => PanResponder.create({
94
+ onMoveShouldSetPanResponderCapture: resetTimerForPanResponder,
95
+ onPanResponderTerminationRequest: resetTimerForPanResponder,
96
+ onStartShouldSetPanResponderCapture: resetTimerForPanResponder,
97
+ }));
98
+ return (_jsx(View, Object.assign({ collapsable: false, style: actualStyle }, panResponder.panHandlers, { children: children })));
99
+ };
100
+ //# sourceMappingURL=UserInactivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserInactivity.js","sourceRoot":"","sources":["../src/UserInactivity.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAU,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAiB,MAAM,cAAc,CAAC;AAI1E,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAC1C,MAAM,aAAa,GAAc;IAC/B,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAA4B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+BAA+B;IAC/B,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACnC,YAAY,CAAC,MAAM,CAAC;QAClB,kCAAkC,EAAE,yBAAyB;QAC7D,gCAAgC,EAAE,yBAAyB;QAC3D,mCAAmC,EAAE,yBAAyB;KAC/D,CAAC,CACH,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,kBAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,IAAM,YAAY,CAAC,WAAW,cACvE,QAAQ,IACJ,CACR,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -83,6 +83,7 @@ export * from "./table/TableTitle";
83
83
  export * from "./table/tableContext";
84
84
  export * from "./UnifiedAddressAutoComplete";
85
85
  export * from "./Unifier";
86
+ export * from "./UserInactivity";
86
87
  export * from "./Utilities";
87
88
  export * from "./useStoredState";
88
89
  export * from "./WebAddressAutocomplete";
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ export * from "./table/TableTitle";
83
83
  export * from "./table/tableContext";
84
84
  export * from "./UnifiedAddressAutoComplete";
85
85
  export * from "./Unifier";
86
+ export * from "./UserInactivity";
86
87
  export * from "./Utilities";
87
88
  export * from "./useStoredState";
88
89
  export * from "./WebAddressAutocomplete";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aA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AAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
package/package.json CHANGED
@@ -128,5 +128,5 @@
128
128
  "test:ci": "TZ=America/New_York bun test",
129
129
  "types": "bunx typedoc"
130
130
  },
131
- "version": "0.0.16"
131
+ "version": "0.0.17"
132
132
  }
package/src/Button.tsx CHANGED
@@ -1,40 +1,18 @@
1
1
  import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
2
2
  import debounce from "lodash/debounce";
3
- import {type FC, useMemo, useState} from "react";
3
+ import {type FC, lazy, Suspense, useMemo, useState} from "react";
4
4
  import {ActivityIndicator, Pressable, Text, View} from "react-native";
5
5
 
6
6
  import {Box} from "./Box";
7
7
  import type {ButtonProps} from "./Common";
8
8
  import {isMobileDevice} from "./MediaQuery";
9
- import {Modal} from "./Modal";
10
9
  import {useTheme} from "./Theme";
11
10
  import {Tooltip} from "./Tooltip";
12
11
  import {Unifier} from "./Unifier";
13
12
  import {isNative} from "./Utilities";
14
13
 
15
- const ConfirmationModal: FC<{
16
- visible: boolean;
17
- title: string;
18
- subtitle?: string;
19
- text: string;
20
- onConfirm: () => void;
21
- onCancel: () => void;
22
- }> = ({visible, title, subtitle, text, onConfirm, onCancel}) => {
23
- return (
24
- <Modal
25
- onDismiss={onCancel}
26
- primaryButtonOnClick={onConfirm}
27
- primaryButtonText="Confirm"
28
- secondaryButtonOnClick={onCancel}
29
- secondaryButtonText="Cancel"
30
- subtitle={subtitle}
31
- title={title}
32
- visible={visible}
33
- >
34
- <Text>{text}</Text>
35
- </Modal>
36
- );
37
- };
14
+ // Lazy load Modal to break the circular dependency: Modal -> Button -> Modal
15
+ const LazyModal = lazy(() => import("./Modal").then((module) => ({default: module.Modal})));
38
16
 
39
17
  const ButtonComponent: FC<ButtonProps> = ({
40
18
  confirmationText = "Are you sure you want to continue?",
@@ -159,18 +137,23 @@ const ButtonComponent: FC<ButtonProps> = ({
159
137
  </Box>
160
138
  )}
161
139
  </View>
162
- {withConfirmation && (
163
- <ConfirmationModal
164
- onCancel={() => setShowConfirmation(false)}
165
- onConfirm={async () => {
166
- await onClick();
167
- setShowConfirmation(false);
168
- }}
169
- subtitle={modalSubTitle}
170
- text={confirmationText}
171
- title={modalTitle}
172
- visible={showConfirmation}
173
- />
140
+ {withConfirmation && showConfirmation && (
141
+ <Suspense fallback={null}>
142
+ <LazyModal
143
+ onDismiss={() => setShowConfirmation(false)}
144
+ primaryButtonOnClick={async () => {
145
+ await onClick();
146
+ setShowConfirmation(false);
147
+ }}
148
+ primaryButtonText="Confirm"
149
+ secondaryButtonOnClick={() => setShowConfirmation(false)}
150
+ secondaryButtonText="Cancel"
151
+ subtitle={modalSubTitle}
152
+ text={confirmationText}
153
+ title={modalTitle}
154
+ visible={showConfirmation}
155
+ />
156
+ </Suspense>
174
157
  )}
175
158
  </Pressable>
176
159
  );
package/src/Common.ts CHANGED
@@ -2785,3 +2785,48 @@ export interface SliderProps extends HelperTextProps, ErrorTextProps {
2785
2785
  */
2786
2786
  valueMapping?: ValueMappingItem[];
2787
2787
  }
2788
+
2789
+ export interface UserInactivityProps {
2790
+ /**
2791
+ * Children components to embed inside UserInactivity's View.
2792
+ * If any children component is pressed, `onAction` is called after
2793
+ * `timeForInactivity` milliseconds.
2794
+ */
2795
+ children: React.ReactNode;
2796
+
2797
+ /**
2798
+ * If it's explicitly set to `true` after the component has already been initialized,
2799
+ * the timer restarts and the view is considered active until the new timer expires.
2800
+ * @default true
2801
+ */
2802
+ isActive?: boolean;
2803
+
2804
+ /**
2805
+ * Callback triggered anytime UserInactivity's View isn't touched for more than
2806
+ * `timeForInactivity` milliseconds.
2807
+ * The `active` argument is true if and only if the View wasn't touched for more
2808
+ * than `timeForInactivity` milliseconds.
2809
+ */
2810
+ onAction: (active: boolean) => void;
2811
+
2812
+ /**
2813
+ * If set to true, the timer is not reset when the keyboard appears
2814
+ * or disappears.
2815
+ * @default false
2816
+ */
2817
+ skipKeyboard?: boolean;
2818
+
2819
+ /**
2820
+ * Optional custom style for UserInactivity's View.
2821
+ * @default { flex: 1 }
2822
+ */
2823
+ style?: StyleProp<ViewStyle>;
2824
+
2825
+ /**
2826
+ * Number of milliseconds after which the view is considered inactive.
2827
+ * If it changed, the timer restarts and the view is considered active until
2828
+ * the new timer expires.
2829
+ * @default 10000
2830
+ */
2831
+ timeForInactivity?: number;
2832
+ }
@@ -1,16 +1,65 @@
1
1
  import {describe, expect, it} from "bun:test";
2
2
 
3
3
  import {DateTimeActionSheet} from "./DateTimeActionSheet";
4
+ import {renderWithTheme} from "./test-utils";
5
+
6
+ // Note: @react-native-picker/picker, react-native-calendars, and expo-localization
7
+ // are mocked globally in bunSetup.ts
4
8
 
5
9
  describe("DateTimeActionSheet", () => {
6
- // DateTimeActionSheet uses react-native-calendars and @react-native-picker/picker
7
- // which don't work in the test environment
8
- it.skip("renders correctly (skipped - uses native picker and calendar)", () => {
9
- expect(DateTimeActionSheet).toBeDefined();
10
+ const defaultProps = {
11
+ onChange: () => {},
12
+ onDismiss: () => {},
13
+ visible: true,
14
+ };
15
+
16
+ it("renders correctly with datetime type", () => {
17
+ const {toJSON} = renderWithTheme(
18
+ <DateTimeActionSheet {...defaultProps} type="datetime" value="2024-01-15T10:30:00.000Z" />
19
+ );
20
+ expect(toJSON()).toMatchSnapshot();
10
21
  });
11
22
 
12
23
  it("component is defined", () => {
13
24
  expect(DateTimeActionSheet).toBeDefined();
14
25
  expect(typeof DateTimeActionSheet).toBe("function");
15
26
  });
27
+
28
+ it("renders correctly with date type", () => {
29
+ const {toJSON} = renderWithTheme(
30
+ <DateTimeActionSheet {...defaultProps} type="date" value="2024-01-15T00:00:00.000Z" />
31
+ );
32
+ expect(toJSON()).toMatchSnapshot();
33
+ });
34
+
35
+ it("renders correctly with time type", () => {
36
+ const {toJSON} = renderWithTheme(
37
+ <DateTimeActionSheet {...defaultProps} type="time" value="2024-01-15T10:30:00.000Z" />
38
+ );
39
+ expect(toJSON()).toMatchSnapshot();
40
+ });
41
+
42
+ it("renders correctly when not visible", () => {
43
+ const {toJSON} = renderWithTheme(
44
+ <DateTimeActionSheet
45
+ {...defaultProps}
46
+ type="datetime"
47
+ value="2024-01-15T10:30:00.000Z"
48
+ visible={false}
49
+ />
50
+ );
51
+ expect(toJSON()).toMatchSnapshot();
52
+ });
53
+
54
+ it("renders with custom timezone", () => {
55
+ const {toJSON} = renderWithTheme(
56
+ <DateTimeActionSheet
57
+ {...defaultProps}
58
+ timezone="America/Los_Angeles"
59
+ type="datetime"
60
+ value="2024-01-15T10:30:00.000Z"
61
+ />
62
+ );
63
+ expect(toJSON()).toMatchSnapshot();
64
+ });
16
65
  });
@@ -1,15 +1,58 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef} from "react";
3
+ import {Text, View} from "react-native";
2
4
 
3
5
  import {MobileAddressAutocomplete} from "./MobileAddressAutoComplete";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-native-google-places-autocomplete
9
+ mock.module("react-native-google-places-autocomplete", () => ({
10
+ GooglePlacesAutocomplete: forwardRef(({placeholder}: any, ref) => (
11
+ <View ref={ref as any} testID="google-places-autocomplete">
12
+ <Text>{placeholder}</Text>
13
+ </View>
14
+ )),
15
+ }));
4
16
 
5
17
  describe("MobileAddressAutocomplete", () => {
6
- // MobileAddressAutocomplete uses Google Places API and complex native interactions
7
- it.skip("renders correctly (skipped - uses Google Places API)", () => {
8
- expect(MobileAddressAutocomplete).toBeDefined();
18
+ const defaultProps = {
19
+ handleAddressChange: () => {},
20
+ handleAutoCompleteChange: () => {},
21
+ inputValue: "",
22
+ };
23
+
24
+ it("renders correctly with Google API key", () => {
25
+ const {toJSON} = renderWithTheme(
26
+ <MobileAddressAutocomplete {...defaultProps} googleMapsApiKey="test-api-key" />
27
+ );
28
+ expect(toJSON()).toMatchSnapshot();
9
29
  });
10
30
 
11
31
  it("component is defined", () => {
12
32
  expect(MobileAddressAutocomplete).toBeDefined();
13
33
  expect(typeof MobileAddressAutocomplete).toBe("function");
14
34
  });
35
+
36
+ it("renders TextField fallback without Google API key", () => {
37
+ const {toJSON} = renderWithTheme(<MobileAddressAutocomplete {...defaultProps} />);
38
+ expect(toJSON()).toMatchSnapshot();
39
+ });
40
+
41
+ it("renders disabled state", () => {
42
+ const {toJSON} = renderWithTheme(
43
+ <MobileAddressAutocomplete {...defaultProps} disabled googleMapsApiKey="test-api-key" />
44
+ );
45
+ expect(toJSON()).toMatchSnapshot();
46
+ });
47
+
48
+ it("renders with input value", () => {
49
+ const {toJSON} = renderWithTheme(
50
+ <MobileAddressAutocomplete
51
+ {...defaultProps}
52
+ googleMapsApiKey="test-api-key"
53
+ inputValue="123 Main St"
54
+ />
55
+ );
56
+ expect(toJSON()).toMatchSnapshot();
57
+ });
15
58
  });
@@ -1,12 +1,32 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef, useRef} from "react";
3
+ import {Text, View} from "react-native";
2
4
 
3
5
  import {SimpleContent, useCombinedRefs} from "./ModalSheet";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-native-modalize
9
+ mock.module("react-native-modalize", () => ({
10
+ Modalize: forwardRef(({children}: {children: React.ReactNode}, ref) => (
11
+ <View ref={ref as any} testID="modalize">
12
+ {children}
13
+ </View>
14
+ )),
15
+ }));
16
+
17
+ // Mock react-native-portalize
18
+ mock.module("react-native-portalize", () => ({
19
+ Portal: ({children}: {children: React.ReactNode}) => <View testID="portal">{children}</View>,
20
+ }));
4
21
 
5
22
  describe("ModalSheet", () => {
6
- // ModalSheet uses react-native-modalize and react-native-portalize
7
- // which don't work in the test environment
8
- it.skip("renders correctly (skipped - uses react-native-modalize)", () => {
9
- expect(SimpleContent).toBeDefined();
23
+ it("renders correctly with children", () => {
24
+ const {toJSON} = renderWithTheme(
25
+ <SimpleContent>
26
+ <Text>Test Content</Text>
27
+ </SimpleContent>
28
+ );
29
+ expect(toJSON()).toMatchSnapshot();
10
30
  });
11
31
 
12
32
  it("SimpleContent is defined", () => {
@@ -17,4 +37,16 @@ describe("ModalSheet", () => {
17
37
  expect(useCombinedRefs).toBeDefined();
18
38
  expect(typeof useCombinedRefs).toBe("function");
19
39
  });
40
+
41
+ it("useCombinedRefs combines multiple refs", () => {
42
+ const TestComponent = () => {
43
+ const ref1 = useRef<View>(null);
44
+ const ref2 = useRef<View>(null);
45
+ const combinedRef = useCombinedRefs(ref1, ref2);
46
+ return <View ref={combinedRef} testID="combined-ref-view" />;
47
+ };
48
+
49
+ const {getByTestId} = renderWithTheme(<TestComponent />);
50
+ expect(getByTestId("combined-ref-view")).toBeTruthy();
51
+ });
20
52
  });