@terreno/ui 57.7.0 → 57.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar.js +2 -2
- package/dist/Avatar.js.map +1 -1
- package/dist/Button.js +2 -2
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +49 -0
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DateTimeActionSheet.js +2 -2
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/DateTimeField.js +3 -3
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +1 -1
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/HeightField.js +2 -2
- package/dist/HeightField.js.map +1 -1
- package/dist/IconButton.d.ts.map +1 -1
- package/dist/IconButton.js +9 -6
- package/dist/IconButton.js.map +1 -1
- package/dist/MediaQuery.d.ts +10 -0
- package/dist/MediaQuery.d.ts.map +1 -1
- package/dist/MediaQuery.js +13 -1
- package/dist/MediaQuery.js.map +1 -1
- package/dist/MultiselectField.js +2 -2
- package/dist/MultiselectField.js.map +1 -1
- package/dist/RadioField.js +2 -2
- package/dist/RadioField.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +126 -21
- package/dist/SplitPage.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.js +2 -2
- package/dist/UnifiedAddressAutoComplete.js.map +1 -1
- package/dist/fieldElements/FieldTitle.js +2 -2
- package/dist/fieldElements/FieldTitle.js.map +1 -1
- package/package.json +1 -1
- package/src/Avatar.tsx +2 -2
- package/src/Button.test.tsx +7 -7
- package/src/Button.tsx +2 -2
- package/src/Common.ts +50 -0
- package/src/DateTimeActionSheet.tsx +4 -4
- package/src/DateTimeField.test.tsx +5 -4
- package/src/DateTimeField.tsx +3 -3
- package/src/DropdownPanel.test.tsx +12 -0
- package/src/DropdownPanel.tsx +8 -1
- package/src/HeightField.tsx +2 -2
- package/src/IconButton.test.tsx +63 -0
- package/src/IconButton.tsx +10 -5
- package/src/MediaQuery.ts +14 -1
- package/src/MultiselectField.tsx +2 -2
- package/src/RadioField.tsx +2 -2
- package/src/SplitPage.test.tsx +449 -11
- package/src/SplitPage.tsx +255 -21
- package/src/UnifiedAddressAutoComplete.test.tsx +4 -4
- package/src/UnifiedAddressAutoComplete.tsx +2 -2
- package/src/__snapshots__/DropdownPanel.test.tsx.snap +3 -1
- package/src/bunSetup.ts +2 -1
- package/src/fieldElements/FieldTitle.tsx +2 -2
package/src/IconButton.test.tsx
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import type {ReactTestInstance} from "react-test-renderer";
|
|
2
3
|
|
|
3
4
|
import {IconButton} from "./IconButton";
|
|
5
|
+
import {useTheme} from "./Theme";
|
|
4
6
|
import {renderWithIcons, renderWithTheme} from "./test-utils";
|
|
7
|
+
import {applyColorOpacity} from "./Utilities";
|
|
5
8
|
|
|
6
9
|
describe("IconButton", () => {
|
|
7
10
|
it("renders correctly with default props", () => {
|
|
@@ -129,6 +132,24 @@ describe("IconButton", () => {
|
|
|
129
132
|
expect(toJSON()).toMatchSnapshot();
|
|
130
133
|
});
|
|
131
134
|
|
|
135
|
+
it("uses the supplied accessibility hint without announcing a confirmation dialog", async () => {
|
|
136
|
+
// bunSetup replaces ./IconButton with a null mock; the query suffix loads the real module.
|
|
137
|
+
const actualIconButtonPath = "./IconButton.tsx?accessibility";
|
|
138
|
+
const {IconButton: ActualIconButton} = (await import(
|
|
139
|
+
actualIconButtonPath
|
|
140
|
+
)) as typeof import("./IconButton");
|
|
141
|
+
const {getByLabelText} = renderWithTheme(
|
|
142
|
+
<ActualIconButton
|
|
143
|
+
accessibilityHint="Back to list"
|
|
144
|
+
accessibilityLabel="Back to list"
|
|
145
|
+
iconName="arrow-left"
|
|
146
|
+
onClick={() => {}}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
expect(getByLabelText("Back to list").props.accessibilityHint).toBe("Back to list");
|
|
151
|
+
});
|
|
152
|
+
|
|
132
153
|
it("renders with confirmation props", () => {
|
|
133
154
|
const {toJSON} = renderWithTheme(
|
|
134
155
|
<IconButton
|
|
@@ -183,6 +204,48 @@ describe("IconButton", () => {
|
|
|
183
204
|
expect(toJSON()).toMatchSnapshot();
|
|
184
205
|
});
|
|
185
206
|
|
|
207
|
+
it("keeps a translucent muted background and an opaque icon", async () => {
|
|
208
|
+
// bunSetup replaces ./IconButton with a null mock; the query suffix loads the real module.
|
|
209
|
+
const actualIconButtonPath = "./IconButton.tsx?actual";
|
|
210
|
+
const {IconButton: ActualIconButton} = (await import(
|
|
211
|
+
actualIconButtonPath
|
|
212
|
+
)) as typeof import("./IconButton");
|
|
213
|
+
let inverted = "";
|
|
214
|
+
const CaptureTheme = (): null => {
|
|
215
|
+
const {theme} = useTheme();
|
|
216
|
+
inverted = theme.text.inverted;
|
|
217
|
+
return null;
|
|
218
|
+
};
|
|
219
|
+
const {getByLabelText, UNSAFE_root} = renderWithTheme(
|
|
220
|
+
<>
|
|
221
|
+
<CaptureTheme />
|
|
222
|
+
<ActualIconButton
|
|
223
|
+
accessibilityLabel="muted background solid"
|
|
224
|
+
iconName="check"
|
|
225
|
+
onClick={() => {}}
|
|
226
|
+
variant="muted"
|
|
227
|
+
/>
|
|
228
|
+
<ActualIconButton
|
|
229
|
+
accessibilityLabel="muted background translucent"
|
|
230
|
+
backgroundOpacity={0.88}
|
|
231
|
+
iconName="check"
|
|
232
|
+
onClick={() => {}}
|
|
233
|
+
variant="muted"
|
|
234
|
+
/>
|
|
235
|
+
</>
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
expect(getByLabelText("muted background solid")).toHaveStyle({backgroundColor: inverted});
|
|
239
|
+
expect(getByLabelText("muted background translucent")).toHaveStyle({
|
|
240
|
+
backgroundColor: applyColorOpacity({color: inverted, opacity: 0.88}),
|
|
241
|
+
});
|
|
242
|
+
const icons = UNSAFE_root.findAll(
|
|
243
|
+
(node: ReactTestInstance) => node.props?.name === "check" && Boolean(node.props?.color)
|
|
244
|
+
);
|
|
245
|
+
expect(icons).toHaveLength(2);
|
|
246
|
+
expect(icons[0].props.color).toBe(icons[1].props.color);
|
|
247
|
+
});
|
|
248
|
+
|
|
186
249
|
describe("custom icons", () => {
|
|
187
250
|
// IconButton renders `null` under the bun/react-test-renderer harness (all of
|
|
188
251
|
// its snapshots are null), so we verify the custom-icon code path renders
|
package/src/IconButton.tsx
CHANGED
|
@@ -5,13 +5,13 @@ import {ActivityIndicator, Text as NativeText, Pressable, View} from "react-nati
|
|
|
5
5
|
|
|
6
6
|
import type {IconButtonProps} from "./Common";
|
|
7
7
|
import {useCustomIcon} from "./IconRegistry";
|
|
8
|
-
import {
|
|
8
|
+
import {isNarrowViewport} from "./MediaQuery";
|
|
9
9
|
import {Modal} from "./Modal";
|
|
10
10
|
import {Text} from "./Text";
|
|
11
11
|
import {useTheme} from "./Theme";
|
|
12
12
|
import {Tooltip} from "./Tooltip";
|
|
13
13
|
import {Unifier} from "./Unifier";
|
|
14
|
-
import {isNative} from "./Utilities";
|
|
14
|
+
import {applyColorOpacity, isNative} from "./Utilities";
|
|
15
15
|
|
|
16
16
|
interface ConfirmationModalProps {
|
|
17
17
|
visible: boolean;
|
|
@@ -56,6 +56,7 @@ const IconButtonComponent: FC<IconButtonProps> = ({
|
|
|
56
56
|
indicator,
|
|
57
57
|
indicatorText,
|
|
58
58
|
loading: propsLoading = false,
|
|
59
|
+
backgroundOpacity,
|
|
59
60
|
size = "default",
|
|
60
61
|
state = "default",
|
|
61
62
|
testID,
|
|
@@ -109,14 +110,18 @@ const IconButtonComponent: FC<IconButtonProps> = ({
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
if (typeof backgroundOpacity === "number") {
|
|
114
|
+
backgroundColor = applyColorOpacity({color: backgroundColor, opacity: backgroundOpacity});
|
|
115
|
+
}
|
|
116
|
+
|
|
112
117
|
const indicatorColor = indicator ? theme.surface[indicator] : undefined;
|
|
113
118
|
|
|
114
119
|
return (
|
|
115
120
|
<Pressable
|
|
116
121
|
accessibilityHint={
|
|
117
|
-
|
|
122
|
+
withConfirmation
|
|
118
123
|
? `Opens a confirmation dialog to confirm ${accessLabel}`
|
|
119
|
-
: `Press to perform ${accessLabel} action`
|
|
124
|
+
: (accessibilityHint ?? `Press to perform ${accessLabel} action`)
|
|
120
125
|
}
|
|
121
126
|
aria-label={accessLabel}
|
|
122
127
|
aria-role="button"
|
|
@@ -218,7 +223,7 @@ const IconButtonComponent: FC<IconButtonProps> = ({
|
|
|
218
223
|
|
|
219
224
|
export const IconButton: FC<IconButtonProps> = (props) => {
|
|
220
225
|
const {tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false} = props;
|
|
221
|
-
const isMobileOrNative =
|
|
226
|
+
const isMobileOrNative = isNarrowViewport() || isNative();
|
|
222
227
|
|
|
223
228
|
if (tooltipText && !isMobileOrNative) {
|
|
224
229
|
return (
|
package/src/MediaQuery.ts
CHANGED
|
@@ -34,9 +34,22 @@ export const mediaQuerySmallerThan = (size: ResponsiveBreakpoint): boolean => {
|
|
|
34
34
|
return !isBreakpointAtLeast({breakpoint: media, minimum: size}) || media === size;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* True when the current window is below the desktop breakpoint.
|
|
39
|
+
* On web that floor is `lg` (1024). On native that floor is `xl`.
|
|
40
|
+
* Reads the window size at call time and does not subscribe to resize.
|
|
41
|
+
*/
|
|
42
|
+
export const isNarrowViewport = (): boolean => {
|
|
38
43
|
return !isSupportedDesktopViewport({
|
|
39
44
|
breakpoint: mediaQuery(),
|
|
40
45
|
surface: getBreakpointSurface(),
|
|
41
46
|
});
|
|
42
47
|
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `isNarrowViewport`. Supported while callers migrate.
|
|
51
|
+
* Same result as `isNarrowViewport`.
|
|
52
|
+
*/
|
|
53
|
+
export const isMobileDevice = (): boolean => {
|
|
54
|
+
return isNarrowViewport();
|
|
55
|
+
};
|
package/src/MultiselectField.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import type {MultiselectFieldProps} from "./Common";
|
|
|
6
6
|
import {FieldError} from "./fieldElements/FieldError";
|
|
7
7
|
import {FieldHelperText} from "./fieldElements/FieldHelperText";
|
|
8
8
|
import {Heading} from "./Heading";
|
|
9
|
-
import {
|
|
9
|
+
import {isNarrowViewport} from "./MediaQuery";
|
|
10
10
|
import {Text} from "./Text";
|
|
11
11
|
import {resolveFieldTestIDsFromProps} from "./testing/resolveTestId";
|
|
12
12
|
|
|
@@ -66,7 +66,7 @@ export const MultiselectField: FC<MultiselectFieldProps> = ({
|
|
|
66
66
|
testID,
|
|
67
67
|
testIDs,
|
|
68
68
|
}) => {
|
|
69
|
-
const isMobile =
|
|
69
|
+
const isMobile = isNarrowViewport();
|
|
70
70
|
const isDefault = variant === "leftText";
|
|
71
71
|
const fieldTestIDs = resolveFieldTestIDsFromProps({testID, testIDs});
|
|
72
72
|
const selectedItems = value ?? [];
|
package/src/RadioField.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {TouchableOpacity, View} from "react-native";
|
|
|
3
3
|
|
|
4
4
|
import type {RadioFieldProps} from "./Common";
|
|
5
5
|
import {Heading} from "./Heading";
|
|
6
|
-
import {
|
|
6
|
+
import {isNarrowViewport} from "./MediaQuery";
|
|
7
7
|
import {Radio} from "./Radio";
|
|
8
8
|
import {Text} from "./Text";
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ export const RadioField = ({
|
|
|
15
15
|
variant = "rightText",
|
|
16
16
|
}: RadioFieldProps): React.ReactElement => {
|
|
17
17
|
return (
|
|
18
|
-
<View style={{gap:
|
|
18
|
+
<View style={{gap: isNarrowViewport() ? 16 : 8}}>
|
|
19
19
|
<Heading size="sm">{title}</Heading>
|
|
20
20
|
{options.map((option) => (
|
|
21
21
|
<TouchableOpacity
|