@terreno/ui 56.0.0-beta.2 → 57.0.0-beta.1
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/Badge.d.ts +1 -1
- package/dist/Badge.js +37 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Common.d.ts +110 -3
- package/dist/Common.js.map +1 -1
- package/dist/Filter.d.ts +13 -0
- package/dist/Filter.js +120 -0
- package/dist/Filter.js.map +1 -0
- package/dist/FilterAccordion.d.ts +8 -0
- package/dist/FilterAccordion.js +59 -0
- package/dist/FilterAccordion.js.map +1 -0
- package/dist/FilterBoolean.d.ts +8 -0
- package/dist/FilterBoolean.js +74 -0
- package/dist/FilterBoolean.js.map +1 -0
- package/dist/FilterChangesBadge.d.ts +8 -0
- package/dist/FilterChangesBadge.js +11 -0
- package/dist/FilterChangesBadge.js.map +1 -0
- package/dist/FilterSelectMenu.d.ts +8 -0
- package/dist/FilterSelectMenu.js +37 -0
- package/dist/FilterSelectMenu.js.map +1 -0
- package/dist/IconRegistry.js +11 -6
- package/dist/IconRegistry.js.map +1 -1
- package/dist/PickerSelect.d.ts +8 -1
- package/dist/PickerSelect.js +2 -2
- package/dist/PickerSelect.js.map +1 -1
- package/dist/SelectField.js +2 -2
- package/dist/SelectField.js.map +1 -1
- package/dist/Theme.js +2 -0
- package/dist/Theme.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +5 -1
- package/dist/WebDropdownMenu.js +24 -10
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/icons/BarsFilterIcon.d.ts +9 -0
- package/dist/icons/BarsFilterIcon.js +12 -0
- package/dist/icons/BarsFilterIcon.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +23 -23
- package/src/Badge.test.tsx +22 -1
- package/src/Badge.tsx +43 -0
- package/src/Common.ts +120 -5
- package/src/DateTimeField.test.tsx +16 -18
- package/src/Filter.test.tsx +94 -0
- package/src/Filter.tsx +257 -0
- package/src/FilterAccordion.test.tsx +58 -0
- package/src/FilterAccordion.tsx +113 -0
- package/src/FilterBoolean.test.tsx +65 -0
- package/src/FilterBoolean.tsx +130 -0
- package/src/FilterChangesBadge.test.tsx +16 -0
- package/src/FilterChangesBadge.tsx +13 -0
- package/src/FilterSelectMenu.test.tsx +56 -0
- package/src/FilterSelectMenu.tsx +76 -0
- package/src/IconRegistry.test.tsx +6 -4
- package/src/IconRegistry.tsx +13 -8
- package/src/PickerSelect.test.tsx +20 -0
- package/src/PickerSelect.tsx +10 -0
- package/src/SelectField.tsx +2 -0
- package/src/Theme.tsx +2 -0
- package/src/WebDropdownMenu.test.tsx +86 -1
- package/src/WebDropdownMenu.tsx +43 -21
- package/src/__snapshots__/Filter.test.tsx.snap +161 -0
- package/src/__snapshots__/FilterAccordion.test.tsx.snap +83 -0
- package/src/__snapshots__/FilterBoolean.test.tsx.snap +109 -0
- package/src/__snapshots__/FilterChangesBadge.test.tsx.snap +18 -0
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +359 -0
- package/src/conflictFieldDiff.test.ts +43 -0
- package/src/icons/BarsFilterIcon.tsx +18 -0
- package/src/index.tsx +6 -0
package/package.json
CHANGED
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"@react-navigation/native": "^7.1.8",
|
|
33
33
|
"@shopify/react-native-skia": "2.6.5",
|
|
34
34
|
"emoji-datasource": "^16.0.0",
|
|
35
|
-
"expo-clipboard": "~
|
|
36
|
-
"expo-document-picker": "~
|
|
37
|
-
"expo-font": "~
|
|
38
|
-
"expo-haptics": "~
|
|
39
|
-
"expo-image-manipulator": "~
|
|
40
|
-
"expo-image-picker": "~
|
|
41
|
-
"expo-linear-gradient": "~
|
|
42
|
-
"expo-linking": "~
|
|
43
|
-
"expo-localization": "~
|
|
44
|
-
"expo-notifications": "~
|
|
45
|
-
"expo-print": "~
|
|
46
|
-
"expo-router": "~
|
|
47
|
-
"expo-sharing": "~
|
|
48
|
-
"expo-updates": "~
|
|
49
|
-
"expo-web-browser": "~
|
|
35
|
+
"expo-clipboard": "~57.0.1",
|
|
36
|
+
"expo-document-picker": "~57.0.1",
|
|
37
|
+
"expo-font": "~57.0.1",
|
|
38
|
+
"expo-haptics": "~57.0.1",
|
|
39
|
+
"expo-image-manipulator": "~57.0.11",
|
|
40
|
+
"expo-image-picker": "~57.0.11",
|
|
41
|
+
"expo-linear-gradient": "~57.0.1",
|
|
42
|
+
"expo-linking": "~57.0.6",
|
|
43
|
+
"expo-localization": "~57.0.1",
|
|
44
|
+
"expo-notifications": "~57.0.12",
|
|
45
|
+
"expo-print": "~57.0.1",
|
|
46
|
+
"expo-router": "~57.0.14",
|
|
47
|
+
"expo-sharing": "~57.0.13",
|
|
48
|
+
"expo-updates": "~57.0.15",
|
|
49
|
+
"expo-web-browser": "~57.0.2",
|
|
50
50
|
"libphonenumber-js": "^1.13.8",
|
|
51
51
|
"linkify-it": "^5.0.2",
|
|
52
52
|
"lodash": "^4.18.1",
|
|
@@ -58,20 +58,20 @@
|
|
|
58
58
|
"react-dev-utils": "^12.0.1",
|
|
59
59
|
"react-dom": "19.2.3",
|
|
60
60
|
"react-keyed-flatten-children": "^5.1.1",
|
|
61
|
-
"react-native": "0.
|
|
61
|
+
"react-native": "0.86.2",
|
|
62
62
|
"react-native-actions-sheet": "^0.9.3",
|
|
63
63
|
"react-native-calendars": "^1.1312.1",
|
|
64
64
|
"react-native-drawer-layout": "4.2.0",
|
|
65
|
-
"react-native-gesture-handler": "~2.
|
|
65
|
+
"react-native-gesture-handler": "~2.32.0",
|
|
66
66
|
"react-native-google-places-autocomplete": "^2.6.4",
|
|
67
67
|
"react-native-markdown-display": "^7.0.2",
|
|
68
68
|
"react-native-modalize": "^2.1.1",
|
|
69
69
|
"react-native-permissions": "^5.4.4",
|
|
70
70
|
"react-native-picker-select": "^9.1.3",
|
|
71
71
|
"react-native-portalize": "^1.0.7",
|
|
72
|
-
"react-native-reanimated": "4.
|
|
72
|
+
"react-native-reanimated": "4.5.1",
|
|
73
73
|
"react-native-safe-area-context": "~5.7.0",
|
|
74
|
-
"react-native-screens": "4.
|
|
74
|
+
"react-native-screens": "4.26.2",
|
|
75
75
|
"react-native-svg": "15.15.4",
|
|
76
76
|
"react-native-swiper-flatlist": "^3.2.5",
|
|
77
77
|
"react-native-web": "^0.21.2",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@biomejs/biome": "^2.3.6",
|
|
83
|
-
"@expo/config-plugins": "~
|
|
83
|
+
"@expo/config-plugins": "~57.0.8",
|
|
84
84
|
"@happy-dom/global-registrator": "^17.4.4",
|
|
85
85
|
"@testing-library/react-native": "^13.2.0",
|
|
86
86
|
"@types/bun": "^1.3.8",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@types/react-datetime-picker": "^5.0.0",
|
|
93
93
|
"@types/react-time-picker": "^6.0.0",
|
|
94
94
|
"babel-preset-react-app": "^10.0.1",
|
|
95
|
-
"expo-modules-core": "~
|
|
95
|
+
"expo-modules-core": "~57.0.11",
|
|
96
96
|
"mdurl": "^2.0.0",
|
|
97
97
|
"prettier": "^3.3.3",
|
|
98
98
|
"react": "19.2.3",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"react": "19.2.3",
|
|
117
117
|
"react-dom": "^19.2.0",
|
|
118
|
-
"react-native": "~0.
|
|
118
|
+
"react-native": "~0.86.0",
|
|
119
119
|
"react-router": "^6.26.2",
|
|
120
120
|
"react-router-dom": "^6.30.1"
|
|
121
121
|
},
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"test:coverage": "TZ=America/New_York bun run ../scripts/check-coverage.ts",
|
|
150
150
|
"types": "bun typedoc"
|
|
151
151
|
},
|
|
152
|
-
"version": "
|
|
152
|
+
"version": "57.0.0-beta.1"
|
|
153
153
|
}
|
package/src/Badge.test.tsx
CHANGED
|
@@ -40,8 +40,29 @@ describe("Badge", () => {
|
|
|
40
40
|
expect(getByTestId("number-badge")).toHaveStyle({minWidth: 20});
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
it("renders the status variant as an 8px dot", () => {
|
|
44
|
+
const {getByTestId} = renderWithTheme(
|
|
45
|
+
<Badge color="bold" status="active" testID="dot" variant="status" />
|
|
46
|
+
);
|
|
47
|
+
const dot = getByTestId("dot");
|
|
48
|
+
expect(dot).toHaveStyle({height: 8, width: 8});
|
|
49
|
+
expect(dot).toHaveStyle({backgroundColor: expect.any(String)});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("uses distinct bold and subtle tones for the status dot", () => {
|
|
53
|
+
const bold = renderWithTheme(
|
|
54
|
+
<Badge color="bold" status="active" testID="dot" variant="status" />
|
|
55
|
+
).getByTestId("dot");
|
|
56
|
+
const subtle = renderWithTheme(
|
|
57
|
+
<Badge color="subtle" status="active" testID="dot" variant="status" />
|
|
58
|
+
).getByTestId("dot");
|
|
59
|
+
const boldBg = bold.props.style.backgroundColor;
|
|
60
|
+
const subtleBg = subtle.props.style.backgroundColor;
|
|
61
|
+
expect(boldBg).not.toBe(subtleBg);
|
|
62
|
+
});
|
|
63
|
+
|
|
43
64
|
it("applies correct status colors", () => {
|
|
44
|
-
const statuses = ["error", "warning", "info", "success", "neutral"] as const;
|
|
65
|
+
const statuses = ["error", "warning", "info", "success", "neutral", "active"] as const;
|
|
45
66
|
|
|
46
67
|
statuses.forEach((status) => {
|
|
47
68
|
let {getByTestId} = renderWithTheme(
|
package/src/Badge.tsx
CHANGED
|
@@ -5,12 +5,33 @@ import type {BadgeProps, SurfaceTheme, TextTheme} from "./Common";
|
|
|
5
5
|
import {Icon} from "./Icon";
|
|
6
6
|
import {useTheme} from "./Theme";
|
|
7
7
|
|
|
8
|
+
const STATUS_DOT_SIZE = 8;
|
|
9
|
+
|
|
10
|
+
// Surface tokens for the "status" dot variant, per bold vs subtle tone.
|
|
11
|
+
const STATUS_DOT_BOLD: Record<string, keyof SurfaceTheme> = {
|
|
12
|
+
active: "primary",
|
|
13
|
+
error: "error",
|
|
14
|
+
info: "secondaryDark",
|
|
15
|
+
neutral: "neutralDark",
|
|
16
|
+
success: "success",
|
|
17
|
+
warning: "warning",
|
|
18
|
+
};
|
|
19
|
+
const STATUS_DOT_SUBTLE: Record<string, keyof SurfaceTheme> = {
|
|
20
|
+
active: "secondaryLight",
|
|
21
|
+
error: "errorLight",
|
|
22
|
+
info: "secondaryLight",
|
|
23
|
+
neutral: "neutralLight",
|
|
24
|
+
success: "successLight",
|
|
25
|
+
warning: "warningLight",
|
|
26
|
+
};
|
|
27
|
+
|
|
8
28
|
export const Badge = ({
|
|
9
29
|
value,
|
|
10
30
|
iconName,
|
|
11
31
|
status = "info",
|
|
12
32
|
secondary = false,
|
|
13
33
|
variant,
|
|
34
|
+
color = "bold",
|
|
14
35
|
maxValue = 100,
|
|
15
36
|
customBackgroundColor,
|
|
16
37
|
customTextColor,
|
|
@@ -22,10 +43,28 @@ export const Badge = ({
|
|
|
22
43
|
const {theme} = useTheme();
|
|
23
44
|
const isIconOnly = variant === "iconOnly";
|
|
24
45
|
|
|
46
|
+
if (variant === "status") {
|
|
47
|
+
const dotSurface =
|
|
48
|
+
(color === "subtle" ? STATUS_DOT_SUBTLE : STATUS_DOT_BOLD)[status] ?? "primary";
|
|
49
|
+
const dotColor = status === "custom" ? customBackgroundColor : theme.surface[dotSurface];
|
|
50
|
+
return (
|
|
51
|
+
<View
|
|
52
|
+
style={{
|
|
53
|
+
backgroundColor: dotColor,
|
|
54
|
+
borderRadius: STATUS_DOT_SIZE,
|
|
55
|
+
height: STATUS_DOT_SIZE,
|
|
56
|
+
width: STATUS_DOT_SIZE,
|
|
57
|
+
}}
|
|
58
|
+
testID={testID}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
25
63
|
let badgeColor: keyof TextTheme = "inverted";
|
|
26
64
|
|
|
27
65
|
// TODO: Move to theme
|
|
28
66
|
const secondaryBorderColors = {
|
|
67
|
+
active: "#8FC1D2",
|
|
29
68
|
custom: "#AAAAAA",
|
|
30
69
|
error: "#F39E9E",
|
|
31
70
|
info: "#8FC1D2",
|
|
@@ -45,6 +84,8 @@ export const Badge = ({
|
|
|
45
84
|
badgeColor = "success";
|
|
46
85
|
} else if (status === "neutral") {
|
|
47
86
|
badgeColor = "primary";
|
|
87
|
+
} else if (status === "active") {
|
|
88
|
+
badgeColor = "link";
|
|
48
89
|
}
|
|
49
90
|
}
|
|
50
91
|
|
|
@@ -60,6 +101,8 @@ export const Badge = ({
|
|
|
60
101
|
badgeBgColor = secondary ? "successLight" : "success";
|
|
61
102
|
} else if (status === "neutral") {
|
|
62
103
|
badgeBgColor = secondary ? "neutralLight" : "neutralDark";
|
|
104
|
+
} else if (status === "active") {
|
|
105
|
+
badgeBgColor = secondary ? "secondaryLight" : "primary";
|
|
63
106
|
}
|
|
64
107
|
|
|
65
108
|
const backgroundColor = status === "custom" ? customBackgroundColor : theme.surface[badgeBgColor];
|
package/src/Common.ts
CHANGED
|
@@ -218,6 +218,8 @@ export interface TextThemeConfig {
|
|
|
218
218
|
|
|
219
219
|
export interface SurfaceThemeConfig {
|
|
220
220
|
base: keyof ThemePrimitiveColors;
|
|
221
|
+
baseAlternate: keyof ThemePrimitiveColors;
|
|
222
|
+
baseHover: keyof ThemePrimitiveColors;
|
|
221
223
|
primary: keyof ThemePrimitiveColors;
|
|
222
224
|
secondaryExtraLight: keyof ThemePrimitiveColors;
|
|
223
225
|
secondaryLight: keyof ThemePrimitiveColors;
|
|
@@ -287,6 +289,8 @@ export interface TextTheme {
|
|
|
287
289
|
|
|
288
290
|
export interface SurfaceTheme {
|
|
289
291
|
base: string;
|
|
292
|
+
baseAlternate: string;
|
|
293
|
+
baseHover: string;
|
|
290
294
|
primary: string;
|
|
291
295
|
secondaryExtraLight: string;
|
|
292
296
|
secondaryLight: string;
|
|
@@ -397,8 +401,10 @@ export type OnChangeCallback = (result: string) => void;
|
|
|
397
401
|
* }
|
|
398
402
|
* ```
|
|
399
403
|
*/
|
|
400
|
-
|
|
401
|
-
|
|
404
|
+
export interface CustomIconRegistry {
|
|
405
|
+
/** Built-in "bars-filter" glyph (FontAwesome Classic Solid, E0AD). */
|
|
406
|
+
"bars-filter": true;
|
|
407
|
+
}
|
|
402
408
|
|
|
403
409
|
/** The set of custom icon names registered via {@link CustomIconRegistry}. */
|
|
404
410
|
export type CustomIconName = keyof CustomIconRegistry & string;
|
|
@@ -427,6 +433,97 @@ export type CustomIconComponent = FC<CustomIconProps>;
|
|
|
427
433
|
*/
|
|
428
434
|
export type IconRegistryMap = Record<string, CustomIconComponent>;
|
|
429
435
|
|
|
436
|
+
export interface FilterOption {
|
|
437
|
+
label: string;
|
|
438
|
+
value: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** Small blue dot that signals a filter control differs from its default. */
|
|
442
|
+
export type FilterChangesBadgeProps = WithTestID;
|
|
443
|
+
|
|
444
|
+
export interface FilterSelectMenuProps extends WithTestID {
|
|
445
|
+
/** Label shown to the left of the select control. */
|
|
446
|
+
title: string;
|
|
447
|
+
/** Selectable options for the single-select control. */
|
|
448
|
+
options: FilterOption[];
|
|
449
|
+
/** Currently selected value. */
|
|
450
|
+
value?: string;
|
|
451
|
+
/** Called with the newly selected value. */
|
|
452
|
+
onChange: (value: string) => void;
|
|
453
|
+
/** Text shown when no value is selected. */
|
|
454
|
+
placeholder?: string;
|
|
455
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
456
|
+
showChangesBadge?: boolean;
|
|
457
|
+
/** Disables the control. */
|
|
458
|
+
disabled?: boolean;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface FilterBooleanProps extends WithTestID {
|
|
462
|
+
/** Label shown to the left of the toggle. */
|
|
463
|
+
title: string;
|
|
464
|
+
/** Whether the toggle is on. */
|
|
465
|
+
value: boolean;
|
|
466
|
+
/** Called with the next toggle value. The entire row is the click zone. */
|
|
467
|
+
onChange: (value: boolean) => void;
|
|
468
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
469
|
+
showChangesBadge?: boolean;
|
|
470
|
+
/** Disables the toggle and the row click zone. */
|
|
471
|
+
disabled?: boolean;
|
|
472
|
+
/** Renders the toggle in a focused (keyboard) state. */
|
|
473
|
+
focused?: boolean;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export interface FilterAccordionProps extends WithTestID {
|
|
477
|
+
/** Label shown in the always-visible header row. */
|
|
478
|
+
title: string;
|
|
479
|
+
/** Custom content revealed when expanded. Empty by default. */
|
|
480
|
+
children?: React.ReactNode;
|
|
481
|
+
/** Controlled expanded state. Omit to use `defaultExpanded`. */
|
|
482
|
+
expanded?: boolean;
|
|
483
|
+
/** Initial expanded state when uncontrolled. */
|
|
484
|
+
defaultExpanded?: boolean;
|
|
485
|
+
/** Called with the next expanded state when the header row is pressed. */
|
|
486
|
+
onToggle?: (expanded: boolean) => void;
|
|
487
|
+
/** When true, shows the blue changes dot next to the title. */
|
|
488
|
+
showChangesBadge?: boolean;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export interface FilterProps extends WithTestID {
|
|
492
|
+
/** Composed filter controls rendered inside the dropdown panel. */
|
|
493
|
+
children: React.ReactNode;
|
|
494
|
+
/** Trigger button label. */
|
|
495
|
+
label?: string;
|
|
496
|
+
/** Trigger button icon. Defaults to the built-in `bars-filter` glyph. */
|
|
497
|
+
iconName?: IconName;
|
|
498
|
+
/** Controlled open state. Omit to use `defaultOpen`. */
|
|
499
|
+
isOpen?: boolean;
|
|
500
|
+
/** Initial open state when uncontrolled. */
|
|
501
|
+
defaultOpen?: boolean;
|
|
502
|
+
/** Called whenever the dropdown opens or closes. */
|
|
503
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
504
|
+
/** Master toggle for the Apply/Clear/Cancel footer. */
|
|
505
|
+
showActionButtons?: boolean;
|
|
506
|
+
/** Show the Apply button in the footer. */
|
|
507
|
+
showApplyButton?: boolean;
|
|
508
|
+
/** Show the Clear hyperlink in the footer. */
|
|
509
|
+
showClearButton?: boolean;
|
|
510
|
+
/** Show the Cancel button in the footer. */
|
|
511
|
+
showCancelButton?: boolean;
|
|
512
|
+
applyButtonText?: string;
|
|
513
|
+
clearButtonText?: string;
|
|
514
|
+
cancelButtonText?: string;
|
|
515
|
+
/** Called when Apply is pressed. The dropdown then closes. */
|
|
516
|
+
onApply?: () => void;
|
|
517
|
+
/** Called when Clear is pressed. The dropdown then closes. */
|
|
518
|
+
onClear?: () => void;
|
|
519
|
+
/** Called when Cancel or a click-outside closes the dropdown. */
|
|
520
|
+
onCancel?: () => void;
|
|
521
|
+
/** Primary theming for the trigger and Apply button. */
|
|
522
|
+
variant?: "primary" | "secondary";
|
|
523
|
+
/** Panel width in pixels. Defaults to 320 per the design spec. */
|
|
524
|
+
width?: number;
|
|
525
|
+
}
|
|
526
|
+
|
|
430
527
|
export type AlignContent = "start" | "end" | "center" | "between" | "around" | "stretch";
|
|
431
528
|
export type AlignSelf = "auto" | "start" | "end" | "center" | "baseline" | "stretch";
|
|
432
529
|
export type AlignItems = "start" | "end" | "center" | "baseline" | "stretch";
|
|
@@ -1562,7 +1659,14 @@ export interface BadgeProps extends WithTestID {
|
|
|
1562
1659
|
* The status of the badge. Determines its color and appearance.
|
|
1563
1660
|
* @default "info"
|
|
1564
1661
|
*/
|
|
1565
|
-
status?: "info" | "error" | "warning" | "success" | "neutral" | "custom";
|
|
1662
|
+
status?: "info" | "error" | "warning" | "success" | "neutral" | "active" | "custom";
|
|
1663
|
+
|
|
1664
|
+
/**
|
|
1665
|
+
* For the "status" variant, whether the dot uses the bold (saturated) or
|
|
1666
|
+
* subtle (light) tone.
|
|
1667
|
+
* @default "bold"
|
|
1668
|
+
*/
|
|
1669
|
+
color?: "bold" | "subtle";
|
|
1566
1670
|
|
|
1567
1671
|
/**
|
|
1568
1672
|
* The text or number to display inside the badge.
|
|
@@ -1570,9 +1674,10 @@ export interface BadgeProps extends WithTestID {
|
|
|
1570
1674
|
value?: number | string;
|
|
1571
1675
|
|
|
1572
1676
|
/**
|
|
1573
|
-
* The variant of the badge.
|
|
1677
|
+
* The variant of the badge. "status" renders a small colored dot (no text)
|
|
1678
|
+
* used to indicate an active/modified state.
|
|
1574
1679
|
*/
|
|
1575
|
-
variant?: "iconOnly" | "numberOnly";
|
|
1680
|
+
variant?: "iconOnly" | "numberOnly" | "status";
|
|
1576
1681
|
}
|
|
1577
1682
|
|
|
1578
1683
|
export type ThumbsUpDownFeedbackValue = "positive" | "negative";
|
|
@@ -3065,6 +3170,16 @@ export interface SelectFieldPropsBase extends WithTestID {
|
|
|
3065
3170
|
*/
|
|
3066
3171
|
disableSearch?: boolean;
|
|
3067
3172
|
|
|
3173
|
+
/**
|
|
3174
|
+
* Web only. When true, the dropdown menu renders in a fixed portal on
|
|
3175
|
+
* `document.body` (zIndex 9999) instead of a React Native `Modal`. Use this
|
|
3176
|
+
* when the select lives inside another portaled/high-zIndex overlay (e.g. the
|
|
3177
|
+
* `Filter` panel) where a `Modal` would stack behind the overlay and be
|
|
3178
|
+
* invisible and unclickable.
|
|
3179
|
+
* @default false
|
|
3180
|
+
*/
|
|
3181
|
+
renderMenuInBodyPortal?: boolean;
|
|
3182
|
+
|
|
3068
3183
|
/**
|
|
3069
3184
|
* The title of the select field.
|
|
3070
3185
|
*/
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// noExplicitAny: test mock typing
|
|
2
|
-
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
3
1
|
import {
|
|
4
2
|
afterAll,
|
|
5
3
|
afterEach,
|
|
@@ -281,8 +279,8 @@ describe("DateTimeField", () => {
|
|
|
281
279
|
});
|
|
282
280
|
|
|
283
281
|
// Month should be capped and always return a valid date
|
|
284
|
-
const validCalls = mockOnChange.mock.calls.filter((args:
|
|
285
|
-
const date = DateTime.fromISO(args[0]);
|
|
282
|
+
const validCalls = mockOnChange.mock.calls.filter((args: unknown[]) => {
|
|
283
|
+
const date = DateTime.fromISO(String(args[0]));
|
|
286
284
|
return date.isValid && date.month <= 12;
|
|
287
285
|
});
|
|
288
286
|
|
|
@@ -309,7 +307,7 @@ describe("DateTimeField", () => {
|
|
|
309
307
|
// and must never emit an invalid minute (60).
|
|
310
308
|
expect(mockOnChange).toHaveBeenCalled();
|
|
311
309
|
expect(mockOnChange).toHaveBeenCalledTimes(4);
|
|
312
|
-
const calls = mockOnChange.mock.calls.map(([
|
|
310
|
+
const calls = mockOnChange.mock.calls.map((call: unknown[]) => String(call[0]));
|
|
313
311
|
// No call should use an invalid "60" minute.
|
|
314
312
|
expect(calls.some((iso: string) => iso.includes(":60:00.000Z"))).toBe(false);
|
|
315
313
|
// It should include a reset to "00" and then a valid "06".
|
|
@@ -764,7 +762,7 @@ describe("DateTimeField", () => {
|
|
|
764
762
|
);
|
|
765
763
|
|
|
766
764
|
const actionSheet = UNSAFE_root.findAll(
|
|
767
|
-
(n:
|
|
765
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.visible !== undefined
|
|
768
766
|
);
|
|
769
767
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
770
768
|
await act(async () => {
|
|
@@ -785,7 +783,7 @@ describe("DateTimeField", () => {
|
|
|
785
783
|
);
|
|
786
784
|
|
|
787
785
|
const actionSheet = UNSAFE_root.findAll(
|
|
788
|
-
(n:
|
|
786
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.visible !== undefined
|
|
789
787
|
);
|
|
790
788
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
791
789
|
await act(async () => {
|
|
@@ -806,7 +804,7 @@ describe("DateTimeField", () => {
|
|
|
806
804
|
);
|
|
807
805
|
|
|
808
806
|
const actionSheet = UNSAFE_root.findAll(
|
|
809
|
-
(n:
|
|
807
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.visible !== undefined
|
|
810
808
|
);
|
|
811
809
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
812
810
|
await act(async () => {
|
|
@@ -827,7 +825,7 @@ describe("DateTimeField", () => {
|
|
|
827
825
|
);
|
|
828
826
|
|
|
829
827
|
const actionSheet = UNSAFE_root.findAll(
|
|
830
|
-
(n:
|
|
828
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.visible !== undefined
|
|
831
829
|
);
|
|
832
830
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
833
831
|
await act(async () => {
|
|
@@ -850,7 +848,7 @@ describe("DateTimeField", () => {
|
|
|
850
848
|
/>
|
|
851
849
|
);
|
|
852
850
|
|
|
853
|
-
const amPmSelects = UNSAFE_root.findAll((n:
|
|
851
|
+
const amPmSelects = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onAmPmChange);
|
|
854
852
|
expect(amPmSelects.length).toBeGreaterThan(0);
|
|
855
853
|
await act(async () => {
|
|
856
854
|
amPmSelects[0].props.onAmPmChange("pm");
|
|
@@ -873,7 +871,7 @@ describe("DateTimeField", () => {
|
|
|
873
871
|
/>
|
|
874
872
|
);
|
|
875
873
|
|
|
876
|
-
const tzPickers = UNSAFE_root.findAll((n:
|
|
874
|
+
const tzPickers = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onTimezoneChange);
|
|
877
875
|
expect(tzPickers.length).toBeGreaterThan(0);
|
|
878
876
|
await act(async () => {
|
|
879
877
|
tzPickers[0].props.onTimezoneChange("America/Chicago");
|
|
@@ -892,7 +890,7 @@ describe("DateTimeField", () => {
|
|
|
892
890
|
/>
|
|
893
891
|
);
|
|
894
892
|
|
|
895
|
-
const tzPickers = UNSAFE_root.findAll((n:
|
|
893
|
+
const tzPickers = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onTimezoneChange);
|
|
896
894
|
expect(tzPickers.length).toBeGreaterThan(0);
|
|
897
895
|
await act(async () => {
|
|
898
896
|
tzPickers[0].props.onTimezoneChange("America/Chicago");
|
|
@@ -997,7 +995,7 @@ describe("DateTimeField", () => {
|
|
|
997
995
|
);
|
|
998
996
|
|
|
999
997
|
const actionSheet = UNSAFE_root.findAll(
|
|
1000
|
-
(n:
|
|
998
|
+
(n: ReactTestInstance) => n.props?.onDismiss && n.props?.visible !== undefined
|
|
1001
999
|
);
|
|
1002
1000
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
1003
1001
|
await act(async () => {
|
|
@@ -1017,7 +1015,7 @@ describe("DateTimeField", () => {
|
|
|
1017
1015
|
/>
|
|
1018
1016
|
);
|
|
1019
1017
|
|
|
1020
|
-
const pressables = UNSAFE_root.findAll((n:
|
|
1018
|
+
const pressables = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onLayout);
|
|
1021
1019
|
expect(pressables.length).toBeGreaterThan(0);
|
|
1022
1020
|
await act(async () => {
|
|
1023
1021
|
pressables[0].props.onLayout({nativeEvent: {layout: {width: 500}}});
|
|
@@ -1037,7 +1035,7 @@ describe("DateTimeField", () => {
|
|
|
1037
1035
|
value="2023-05-15T15:30:00.000Z"
|
|
1038
1036
|
/>
|
|
1039
1037
|
);
|
|
1040
|
-
const selects = UNSAFE_root.findAll((n:
|
|
1038
|
+
const selects = UNSAFE_root.findAll((n: ReactTestInstance) => {
|
|
1041
1039
|
const opts = n.props?.options;
|
|
1042
1040
|
return (
|
|
1043
1041
|
Array.isArray(opts) &&
|
|
@@ -1182,7 +1180,7 @@ describe("DateTimeField", () => {
|
|
|
1182
1180
|
|
|
1183
1181
|
mockOnChange.mockClear();
|
|
1184
1182
|
const actionSheet = UNSAFE_root.findAll(
|
|
1185
|
-
(n:
|
|
1183
|
+
(n: ReactTestInstance) => n.props?.onChange && n.props?.visible !== undefined
|
|
1186
1184
|
);
|
|
1187
1185
|
expect(actionSheet.length).toBeGreaterThan(0);
|
|
1188
1186
|
await act(async () => {
|
|
@@ -1284,7 +1282,7 @@ describe("DateTimeField", () => {
|
|
|
1284
1282
|
/>
|
|
1285
1283
|
);
|
|
1286
1284
|
|
|
1287
|
-
const tzPickers = UNSAFE_root.findAll((n:
|
|
1285
|
+
const tzPickers = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onTimezoneChange);
|
|
1288
1286
|
expect(tzPickers.length).toBeGreaterThan(0);
|
|
1289
1287
|
await act(async () => {
|
|
1290
1288
|
tzPickers[0].props.onTimezoneChange("America/Chicago");
|
|
@@ -1303,7 +1301,7 @@ describe("DateTimeField", () => {
|
|
|
1303
1301
|
/>
|
|
1304
1302
|
);
|
|
1305
1303
|
|
|
1306
|
-
const tzPickers = UNSAFE_root.findAll((n:
|
|
1304
|
+
const tzPickers = UNSAFE_root.findAll((n: ReactTestInstance) => n.props?.onTimezoneChange);
|
|
1307
1305
|
expect(tzPickers.length).toBeGreaterThan(0);
|
|
1308
1306
|
await act(async () => {
|
|
1309
1307
|
tzPickers[0].props.onTimezoneChange("America/Chicago");
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {act, fireEvent, waitFor} from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import {Filter} from "./Filter";
|
|
5
|
+
import {Text} from "./Text";
|
|
6
|
+
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
|
|
8
|
+
describe("Filter", () => {
|
|
9
|
+
it("renders correctly with default props", () => {
|
|
10
|
+
const {toJSON} = renderWithTheme(
|
|
11
|
+
<Filter>
|
|
12
|
+
<Text>Body</Text>
|
|
13
|
+
</Filter>
|
|
14
|
+
);
|
|
15
|
+
expect(toJSON()).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("renders the trigger label", () => {
|
|
19
|
+
const {getByText} = renderWithTheme(
|
|
20
|
+
<Filter label="Filters">
|
|
21
|
+
<Text>Body</Text>
|
|
22
|
+
</Filter>
|
|
23
|
+
);
|
|
24
|
+
expect(getByText("Filters")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("keeps the panel closed by default and open with defaultOpen", () => {
|
|
28
|
+
const closed = renderWithTheme(
|
|
29
|
+
<Filter testID="f">
|
|
30
|
+
<Text>Body</Text>
|
|
31
|
+
</Filter>
|
|
32
|
+
);
|
|
33
|
+
expect(closed.queryByTestId("f.panel")).toBeNull();
|
|
34
|
+
|
|
35
|
+
const open = renderWithTheme(
|
|
36
|
+
<Filter defaultOpen testID="f">
|
|
37
|
+
<Text>Body</Text>
|
|
38
|
+
</Filter>
|
|
39
|
+
);
|
|
40
|
+
expect(open.queryByTestId("f.panel")).toBeTruthy();
|
|
41
|
+
expect(open.getByText("Body")).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("hides the footer when action buttons are disabled", () => {
|
|
45
|
+
const {queryByTestId} = renderWithTheme(
|
|
46
|
+
<Filter defaultOpen showActionButtons={false} testID="f">
|
|
47
|
+
<Text>Body</Text>
|
|
48
|
+
</Filter>
|
|
49
|
+
);
|
|
50
|
+
expect(queryByTestId("f.apply")).toBeNull();
|
|
51
|
+
expect(queryByTestId("f.clear")).toBeNull();
|
|
52
|
+
expect(queryByTestId("f.cancel")).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("closes on outside click and calls onCancel", () => {
|
|
56
|
+
const onCancel = mock();
|
|
57
|
+
const {getByTestId, queryByTestId} = renderWithTheme(
|
|
58
|
+
<Filter defaultOpen onCancel={onCancel} testID="f">
|
|
59
|
+
<Text>Body</Text>
|
|
60
|
+
</Filter>
|
|
61
|
+
);
|
|
62
|
+
fireEvent.press(getByTestId("f.backdrop"));
|
|
63
|
+
expect(onCancel).toHaveBeenCalled();
|
|
64
|
+
expect(queryByTestId("f.panel")).toBeNull();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("calls onClear and keeps the panel open when Clear is pressed", () => {
|
|
68
|
+
const onClear = mock();
|
|
69
|
+
const {getByTestId} = renderWithTheme(
|
|
70
|
+
<Filter defaultOpen onClear={onClear} testID="f">
|
|
71
|
+
<Text>Body</Text>
|
|
72
|
+
</Filter>
|
|
73
|
+
);
|
|
74
|
+
fireEvent.press(getByTestId("f.clear"));
|
|
75
|
+
expect(onClear).toHaveBeenCalled();
|
|
76
|
+
expect(getByTestId("f.panel")).toBeTruthy();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("calls onApply and closes when Apply is pressed", async () => {
|
|
80
|
+
const onApply = mock();
|
|
81
|
+
const {getByTestId, queryByTestId} = renderWithTheme(
|
|
82
|
+
<Filter defaultOpen onApply={onApply} testID="f">
|
|
83
|
+
<Text>Body</Text>
|
|
84
|
+
</Filter>
|
|
85
|
+
);
|
|
86
|
+
await act(async () => {
|
|
87
|
+
fireEvent.press(getByTestId("f.apply"));
|
|
88
|
+
});
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(onApply).toHaveBeenCalled();
|
|
91
|
+
});
|
|
92
|
+
expect(queryByTestId("f.panel")).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|