@terreno/ui 57.2.0 → 57.4.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/.ai/guidelines/core.md +1 -1
- package/README.md +17 -8
- package/dist/ActionSheet.d.ts +3 -3
- package/dist/ActionSheet.js +2 -2
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AnnouncementBanner.d.ts +12 -0
- package/dist/AnnouncementBanner.js +61 -0
- package/dist/AnnouncementBanner.js.map +1 -0
- package/dist/AnnouncementNavigator.d.ts +11 -0
- package/dist/AnnouncementNavigator.js +189 -0
- package/dist/AnnouncementNavigator.js.map +1 -0
- package/dist/AnnouncementScreen.d.ts +12 -0
- package/dist/AnnouncementScreen.js +28 -0
- package/dist/AnnouncementScreen.js.map +1 -0
- package/dist/AreaChart.d.ts +5 -0
- package/dist/AreaChart.js +69 -0
- package/dist/AreaChart.js.map +1 -0
- package/dist/BarChart.d.ts +5 -0
- package/dist/BarChart.js +89 -0
- package/dist/BarChart.js.map +1 -0
- package/dist/Box.d.ts +1 -1
- package/dist/Box.js +219 -177
- package/dist/Box.js.map +1 -1
- package/dist/Button.js +116 -35
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +215 -9
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.js +46 -12
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -1
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/DashboardGrid.d.ts +4 -0
- package/dist/DashboardGrid.js +38 -0
- package/dist/DashboardGrid.js.map +1 -0
- package/dist/DataTable.d.ts +2 -2
- package/dist/DataTable.js +278 -47
- package/dist/DataTable.js.map +1 -1
- package/dist/DataTableHeaderInfoMarkdown.d.ts +6 -0
- package/dist/DataTableHeaderInfoMarkdown.js +7 -0
- package/dist/DataTableHeaderInfoMarkdown.js.map +1 -0
- package/dist/DonutChart.d.ts +5 -0
- package/dist/DonutChart.js +84 -0
- package/dist/DonutChart.js.map +1 -0
- package/dist/EmojiSelector.d.ts +2 -46
- package/dist/EmojiSelector.js +46 -56
- package/dist/EmojiSelector.js.map +1 -1
- package/dist/Filter.js +12 -2
- package/dist/Filter.js.map +1 -1
- package/dist/GPTChat.d.ts +7 -1
- package/dist/GPTChat.js +28 -15
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts +5 -2
- package/dist/Heading.js +6 -8
- package/dist/Heading.js.map +1 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Icon.d.ts +1 -2
- package/dist/Icon.js +4 -1
- package/dist/Icon.js.map +1 -1
- package/dist/LineChart.d.ts +5 -0
- package/dist/LineChart.js +68 -0
- package/dist/LineChart.js.map +1 -0
- package/dist/MarkdownEmbed.d.ts +6 -0
- package/dist/MarkdownEmbed.js +17 -0
- package/dist/MarkdownEmbed.js.map +1 -0
- package/dist/MarkdownView.d.ts +6 -3
- package/dist/MarkdownView.js +81 -44
- package/dist/MarkdownView.js.map +1 -1
- package/dist/MediaQuery.d.ts +5 -3
- package/dist/MediaQuery.js +9 -40
- package/dist/MediaQuery.js.map +1 -1
- package/dist/Modal.js +12 -10
- package/dist/Modal.js.map +1 -1
- package/dist/ModalSheet.d.ts +5 -1
- package/dist/ModalSheet.js +31 -13
- package/dist/ModalSheet.js.map +1 -1
- package/dist/MultiselectField.js +4 -9
- package/dist/MultiselectField.js.map +1 -1
- package/dist/NotificationBell.d.ts +16 -0
- package/dist/NotificationBell.js +15 -0
- package/dist/NotificationBell.js.map +1 -0
- package/dist/NotificationInbox.d.ts +21 -0
- package/dist/NotificationInbox.js +41 -0
- package/dist/NotificationInbox.js.map +1 -0
- package/dist/NotificationPreferences.d.ts +14 -0
- package/dist/NotificationPreferences.js +32 -0
- package/dist/NotificationPreferences.js.map +1 -0
- package/dist/OpenAPIContext.js +7 -6
- package/dist/OpenAPIContext.js.map +1 -1
- package/dist/Page.js +7 -1
- package/dist/Page.js.map +1 -1
- package/dist/PickerSelect.js +8 -1
- package/dist/PickerSelect.js.map +1 -1
- package/dist/Popover.d.ts +12 -0
- package/dist/Popover.js +37 -0
- package/dist/Popover.js.map +1 -0
- package/dist/PortalHost.js +10 -1
- package/dist/PortalHost.js.map +1 -1
- package/dist/ResponsiveBreakpoint.d.ts +65 -0
- package/dist/ResponsiveBreakpoint.js +111 -0
- package/dist/ResponsiveBreakpoint.js.map +1 -0
- package/dist/SplitPage.d.ts +2 -2
- package/dist/SplitPage.js +7 -12
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +2 -2
- package/dist/SplitPage.native.js +1 -6
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TapToEdit.js +12 -10
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TerrenoFontProvider.d.ts +7 -0
- package/dist/TerrenoFontProvider.js +27 -0
- package/dist/TerrenoFontProvider.js.map +1 -0
- package/dist/TerrenoProvider.js +4 -2
- package/dist/TerrenoProvider.js.map +1 -1
- package/dist/Text.d.ts +5 -2
- package/dist/Text.js +6 -11
- package/dist/Text.js.map +1 -1
- package/dist/TextField.js +83 -6
- package/dist/TextField.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.js +9 -2
- package/dist/TextFieldNumberActionSheet.js.map +1 -1
- package/dist/Theme.js +10 -8
- package/dist/Theme.js.map +1 -1
- package/dist/ToastNotifications.d.ts +4 -2
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts +4 -3
- package/dist/Tooltip.js +14 -3
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +26 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/WebAddressAutocomplete.js +6 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/announcementBuildVersion.d.ts +6 -0
- package/dist/announcementBuildVersion.js +21 -0
- package/dist/announcementBuildVersion.js.map +1 -0
- package/dist/announcementFrequency.d.ts +42 -0
- package/dist/announcementFrequency.js +163 -0
- package/dist/announcementFrequency.js.map +1 -0
- package/dist/announcementPlatform.d.ts +2 -0
- package/dist/announcementPlatform.js +11 -0
- package/dist/announcementPlatform.js.map +1 -0
- package/dist/charts/ChartFrame.d.ts +12 -0
- package/dist/charts/ChartFrame.js +13 -0
- package/dist/charts/ChartFrame.js.map +1 -0
- package/dist/charts/bars.d.ts +18 -0
- package/dist/charts/bars.js +29 -0
- package/dist/charts/bars.js.map +1 -0
- package/dist/charts/layout.d.ts +47 -0
- package/dist/charts/layout.js +56 -0
- package/dist/charts/layout.js.map +1 -0
- package/dist/charts/paths.d.ts +31 -0
- package/dist/charts/paths.js +52 -0
- package/dist/charts/paths.js.map +1 -0
- package/dist/charts/scales.d.ts +6 -0
- package/dist/charts/scales.js +43 -0
- package/dist/charts/scales.js.map +1 -0
- package/dist/charts/theme.d.ts +9 -0
- package/dist/charts/theme.js +15 -0
- package/dist/charts/theme.js.map +1 -0
- package/dist/charts/types/chartTypes.d.ts +17 -0
- package/dist/charts/types/chartTypes.js +2 -0
- package/dist/charts/types/chartTypes.js.map +1 -0
- package/dist/dashboardGridLayout.d.ts +22 -0
- package/dist/dashboardGridLayout.js +33 -0
- package/dist/dashboardGridLayout.js.map +1 -0
- package/dist/dataTableFilters.d.ts +33 -0
- package/dist/dataTableFilters.js +221 -0
- package/dist/dataTableFilters.js.map +1 -0
- package/dist/dataTableListQuery.d.ts +42 -0
- package/dist/dataTableListQuery.js +161 -0
- package/dist/dataTableListQuery.js.map +1 -0
- package/dist/emojiCategories.d.ts +46 -0
- package/dist/emojiCategories.js +47 -0
- package/dist/emojiCategories.js.map +1 -0
- package/dist/index.d.ts +30 -13
- package/dist/index.js +12 -13
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/createLazyComponentExport.d.ts +6 -0
- package/dist/lazyBoundaries/createLazyComponentExport.js +35 -0
- package/dist/lazyBoundaries/createLazyComponentExport.js.map +1 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +53 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js +51 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -0
- package/dist/login/LoginScreen.d.ts +1 -0
- package/dist/login/LoginScreen.js +4 -2
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/login/loginTypes.d.ts +2 -0
- package/dist/markdownEmbeds.d.ts +6 -0
- package/dist/markdownEmbeds.js +59 -0
- package/dist/markdownEmbeds.js.map +1 -0
- package/dist/testing/resolveTestId.js +2 -1
- package/dist/testing/resolveTestId.js.map +1 -1
- package/dist/testing/types.d.ts +3 -0
- package/dist/textFieldOscillationGuard.d.ts +25 -0
- package/dist/textFieldOscillationGuard.js +41 -0
- package/dist/textFieldOscillationGuard.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +71 -0
- package/dist/useAcknowledgeAnnouncement.js +94 -0
- package/dist/useAcknowledgeAnnouncement.js.map +1 -0
- package/dist/useAnnouncements.d.ts +73 -0
- package/dist/useAnnouncements.js +66 -0
- package/dist/useAnnouncements.js.map +1 -0
- package/package.json +46 -18
- package/src/AIRequestExplorer.test.tsx +141 -0
- package/src/ActionSheet.tsx +9 -7
- package/src/AnnouncementBanner.test.tsx +267 -0
- package/src/AnnouncementBanner.tsx +128 -0
- package/src/AnnouncementNavigator.test.tsx +759 -0
- package/src/AnnouncementNavigator.tsx +287 -0
- package/src/AnnouncementScreen.test.tsx +97 -0
- package/src/AnnouncementScreen.tsx +70 -0
- package/src/AreaChart.test.tsx +68 -0
- package/src/AreaChart.tsx +194 -0
- package/src/AttachmentPreview.test.tsx +80 -0
- package/src/BarChart.test.tsx +96 -0
- package/src/BarChart.tsx +208 -0
- package/src/Box.test.tsx +97 -10
- package/src/Box.tsx +263 -200
- package/src/Button.test.tsx +273 -0
- package/src/Button.tsx +163 -50
- package/src/Common.ts +219 -25
- package/src/ConsentFormScreen.markdownGate.test.tsx +129 -0
- package/src/ConsentFormScreen.test.tsx +145 -8
- package/src/ConsentFormScreen.tsx +74 -25
- package/src/ConsentNavigator.test.tsx +55 -0
- package/src/ConsentNavigator.tsx +13 -5
- package/src/DashboardGrid.test.tsx +75 -0
- package/src/DashboardGrid.tsx +69 -0
- package/src/DataTable.test.tsx +296 -1
- package/src/DataTable.tsx +623 -160
- package/src/DataTableHeaderInfoMarkdown.test.tsx +21 -0
- package/src/DataTableHeaderInfoMarkdown.tsx +17 -0
- package/src/DataTableVirtualizationRegression.test.tsx +266 -0
- package/src/DateTimeField.test.tsx +54 -0
- package/src/DonutChart.test.tsx +121 -0
- package/src/DonutChart.tsx +160 -0
- package/src/EmojiSelector.test.tsx +84 -42
- package/src/EmojiSelector.tsx +60 -57
- package/src/Field.test.tsx +18 -0
- package/src/FilePickerButton.test.tsx +167 -0
- package/src/Filter.test.tsx +25 -0
- package/src/Filter.tsx +38 -7
- package/src/FilterAccordion.test.tsx +37 -0
- package/src/FilterBoolean.test.tsx +96 -0
- package/src/FilterSelectMenu.test.tsx +23 -0
- package/src/GPTChat.test.tsx +803 -0
- package/src/GPTChat.tsx +177 -87
- package/src/GPTMemoryModal.test.tsx +67 -0
- package/src/Heading.tsx +8 -14
- package/src/HeightActionSheet.test.tsx +6 -9
- package/src/Hyperlink.tsx +5 -18
- package/src/Icon.tsx +6 -2
- package/src/LineChart.test.tsx +166 -0
- package/src/LineChart.tsx +190 -0
- package/src/MarkdownEditor.test.tsx +134 -0
- package/src/MarkdownEditorField.test.tsx +124 -0
- package/src/MarkdownEmbed.test.tsx +34 -0
- package/src/MarkdownEmbed.tsx +43 -0
- package/src/MarkdownView.test.tsx +112 -11
- package/src/MarkdownView.tsx +197 -150
- package/src/MediaQuery.ts +30 -34
- package/src/Modal.test.tsx +107 -14
- package/src/Modal.tsx +20 -8
- package/src/ModalSheet.test.tsx +121 -9
- package/src/ModalSheet.tsx +46 -11
- package/src/MultiselectField.test.tsx +21 -0
- package/src/MultiselectField.tsx +11 -13
- package/src/NotificationBell.test.tsx +91 -0
- package/src/NotificationBell.tsx +77 -0
- package/src/NotificationInbox.test.tsx +130 -0
- package/src/NotificationInbox.tsx +144 -0
- package/src/NotificationPreferences.test.tsx +25 -0
- package/src/NotificationPreferences.tsx +75 -0
- package/src/OpenAPIContext.tsx +36 -29
- package/src/OpenAPIRenderRegression.test.tsx +200 -0
- package/src/P0RenderRegression.test.tsx +214 -0
- package/src/P1RenderRegression.test.tsx +141 -0
- package/src/P2ButtonRenderRegression.test.tsx +158 -0
- package/src/Page.test.tsx +13 -0
- package/src/Page.tsx +25 -5
- package/src/PickerSelect.test.tsx +38 -0
- package/src/PickerSelect.tsx +7 -0
- package/src/Popover.test.tsx +151 -0
- package/src/Popover.tsx +211 -0
- package/src/PortalHost.tsx +12 -6
- package/src/ResponsiveBreakpoint.test.tsx +184 -0
- package/src/ResponsiveBreakpoint.tsx +195 -0
- package/src/RootImportRegression.test.tsx +82 -0
- package/src/SplitPage.native.tsx +5 -9
- package/src/SplitPage.tsx +16 -19
- package/src/TapToEdit.test.tsx +45 -0
- package/src/TapToEdit.tsx +23 -18
- package/src/TerrenoFontProvider.test.tsx +38 -0
- package/src/TerrenoFontProvider.tsx +50 -0
- package/src/TerrenoProvider.tsx +6 -1
- package/src/Text.tsx +8 -21
- package/src/TextField.test.tsx +421 -0
- package/src/TextField.tsx +121 -4
- package/src/TextFieldNumberActionSheet.test.tsx +100 -0
- package/src/TextFieldNumberActionSheet.tsx +11 -2
- package/src/Theme.test.tsx +27 -0
- package/src/Theme.tsx +15 -10
- package/src/Toast.tsx +1 -1
- package/src/ToastNotifications.tsx +4 -4
- package/src/Tooltip.test.tsx +64 -0
- package/src/Tooltip.tsx +18 -4
- package/src/Unifier.ts +26 -3
- package/src/WebAddressAutocomplete.tsx +6 -2
- package/src/__snapshots__/ActionSheet.test.tsx.snap +0 -36
- package/src/__snapshots__/AddressField.test.tsx.snap +1 -0
- package/src/__snapshots__/AttachmentPreview.test.tsx.snap +225 -0
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +7 -0
- package/src/__snapshots__/DataTable.test.tsx.snap +793 -250
- package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/EmojiSelector.test.tsx.snap +35555 -30
- package/src/__snapshots__/Field.test.tsx.snap +29 -0
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +1 -0
- package/src/__snapshots__/HeightActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/HeightField.test.tsx.snap +0 -20
- package/src/__snapshots__/ModalSheet.test.tsx.snap +4 -1
- package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/Page.test.tsx.snap +13 -1
- package/src/__snapshots__/PickerSelect.test.tsx.snap +7 -0
- package/src/__snapshots__/SelectField.test.tsx.snap +6 -0
- package/src/__snapshots__/TextArea.test.tsx.snap +5 -5
- package/src/__snapshots__/TextField.test.tsx.snap +5 -5
- package/src/__snapshots__/TimezonePicker.test.tsx.snap +6 -0
- package/src/announcementBuildVersion.test.ts +43 -0
- package/src/announcementBuildVersion.ts +21 -0
- package/src/announcementFrequency.test.ts +245 -0
- package/src/announcementFrequency.ts +246 -0
- package/src/announcementPlatform.test.ts +27 -0
- package/src/announcementPlatform.ts +13 -0
- package/src/benchmarks/importGraph.test.ts +71 -0
- package/src/benchmarks/importGraph.ts +136 -0
- package/src/benchmarks/importTiming.test.ts +42 -0
- package/src/benchmarks/importTiming.ts +86 -0
- package/src/bunSetup.ts +174 -32
- package/src/charts/ChartFrame.tsx +67 -0
- package/src/charts/bars.test.ts +56 -0
- package/src/charts/bars.ts +53 -0
- package/src/charts/layout.test.ts +80 -0
- package/src/charts/layout.ts +99 -0
- package/src/charts/paths.test.ts +79 -0
- package/src/charts/paths.ts +100 -0
- package/src/charts/scales.test.ts +59 -0
- package/src/charts/scales.ts +60 -0
- package/src/charts/theme.test.ts +22 -0
- package/src/charts/theme.ts +24 -0
- package/src/charts/types/chartTypes.ts +19 -0
- package/src/dashboardGridLayout.test.ts +90 -0
- package/src/dashboardGridLayout.ts +60 -0
- package/src/dataTableFilters.test.tsx +552 -0
- package/src/dataTableFilters.tsx +441 -0
- package/src/dataTableListQuery.test.ts +220 -0
- package/src/dataTableListQuery.ts +201 -0
- package/src/emojiCategories.test.ts +23 -0
- package/src/emojiCategories.ts +46 -0
- package/src/index.tsx +48 -14
- package/src/lazyBoundaries/createLazyComponentExport.test.tsx +104 -0
- package/src/lazyBoundaries/createLazyComponentExport.tsx +63 -0
- package/src/lazyBoundaries/heavyOptionalExports.test.tsx +33 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +134 -0
- package/src/login/LoginScreen.test.tsx +9 -2
- package/src/login/LoginScreen.tsx +6 -2
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +22 -0
- package/src/login/loginTypes.ts +2 -0
- package/src/markdownEmbeds.test.ts +53 -0
- package/src/markdownEmbeds.ts +62 -0
- package/src/pdfHtmlTemplate.test.ts +119 -0
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -0
- package/src/table/TableDate.test.tsx +35 -1
- package/src/table/__snapshots__/TableBadge.test.tsx.snap +1 -0
- package/src/testing/resolveTestId.test.ts +3 -0
- package/src/testing/resolveTestId.ts +1 -0
- package/src/testing/types.ts +3 -0
- package/src/textFieldOscillationGuard.test.ts +63 -0
- package/src/textFieldOscillationGuard.ts +89 -0
- package/src/types/react-native-markdown-display.d.ts +6 -0
- package/src/types/react-native-swiper-flatlist.d.ts +5 -5
- package/src/useAcknowledgeAnnouncement.test.ts +223 -0
- package/src/useAcknowledgeAnnouncement.ts +166 -0
- package/src/useAnnouncements.test.ts +226 -0
- package/src/useAnnouncements.ts +150 -0
package/dist/Button.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
3
14
|
import debounce from "lodash/debounce";
|
|
4
15
|
import { PressableOpacity, PressableScale, PressableWithoutFeedback, } from "pressto";
|
|
5
|
-
import { lazy, Suspense, useCallback, useMemo, useState } from "react";
|
|
16
|
+
import { lazy, memo, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
17
|
import { ActivityIndicator, Pressable, Text, View } from "react-native";
|
|
7
18
|
import { Box } from "./Box";
|
|
8
19
|
import { useCustomIcon } from "./IconRegistry";
|
|
@@ -19,9 +30,30 @@ const PRESSABLE_BY_ANIMATION = {
|
|
|
19
30
|
opacity: PressableOpacity,
|
|
20
31
|
scale: PressableScale,
|
|
21
32
|
};
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
33
|
+
const useDebouncedPress = (handlePress) => {
|
|
34
|
+
const debouncedHandlePress = useMemo(() => debounce(handlePress, 500, { leading: true, trailing: false }), [handlePress]);
|
|
35
|
+
// Cancel retained debounce timers when the callback changes or the button unmounts.
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
return () => {
|
|
38
|
+
debouncedHandlePress.cancel();
|
|
39
|
+
};
|
|
40
|
+
}, [debouncedHandlePress]);
|
|
41
|
+
const endPressCooldown = useCallback(() => {
|
|
42
|
+
debouncedHandlePress.cancel();
|
|
43
|
+
}, [debouncedHandlePress]);
|
|
44
|
+
return { endPressCooldown, onPress: debouncedHandlePress };
|
|
45
|
+
};
|
|
46
|
+
const useMountedRef = () => {
|
|
47
|
+
const isMountedRef = useRef(true);
|
|
48
|
+
// Prevent async press completions from updating state after the button unmounts.
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
return () => {
|
|
51
|
+
isMountedRef.current = false;
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
return isMountedRef;
|
|
55
|
+
};
|
|
56
|
+
const ButtonVisual = ({ accessibilityLabel, children, disabled = false, fullWidth = false, iconName, iconPosition = "left", isLoading, onPress, pressAnimation = DEFAULT_BUTTON_PRESS_ANIMATION, size = "default", state = "default", testID, text, variant = "primary", withConfirmation = false, }) => {
|
|
25
57
|
const { theme } = useTheme();
|
|
26
58
|
const CustomIcon = useCustomIcon(iconName);
|
|
27
59
|
const { backgroundColor, borderColor, borderWidth, color } = useMemo(() => {
|
|
@@ -55,41 +87,34 @@ const ButtonComponent = ({ confirmationText = "Are you sure you want to continue
|
|
|
55
87
|
bgColor = "transparent";
|
|
56
88
|
textColor = theme.surface.secondaryDark;
|
|
57
89
|
}
|
|
90
|
+
if (!disabled && state === "active") {
|
|
91
|
+
if (variant === "primary") {
|
|
92
|
+
bgColor = theme.surface.secondaryDark;
|
|
93
|
+
}
|
|
94
|
+
else if (variant === "destructive") {
|
|
95
|
+
bgColor = theme.surface.error;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
bgColor = theme.surface.primary;
|
|
99
|
+
}
|
|
100
|
+
bColor = undefined;
|
|
101
|
+
bWidth = undefined;
|
|
102
|
+
textColor = theme.surface.base;
|
|
103
|
+
}
|
|
58
104
|
return {
|
|
59
105
|
backgroundColor: bgColor,
|
|
60
106
|
borderColor: bColor,
|
|
61
107
|
borderWidth: bWidth,
|
|
62
108
|
color: textColor,
|
|
63
109
|
};
|
|
64
|
-
}, [disabled, variant, theme]);
|
|
65
|
-
const handlePress = useCallback(async () => {
|
|
66
|
-
await Unifier.utils.haptic();
|
|
67
|
-
setLoading(true);
|
|
68
|
-
try {
|
|
69
|
-
// If a confirmation is required, and the confirmation modal is not currently open,
|
|
70
|
-
// open it.
|
|
71
|
-
if (withConfirmation && !showConfirmation) {
|
|
72
|
-
setShowConfirmation(true);
|
|
73
|
-
}
|
|
74
|
-
else if (!withConfirmation && onClick) {
|
|
75
|
-
// If a confirmation is not required, perform the action.
|
|
76
|
-
await onClick();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
setLoading(false);
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
setLoading(false);
|
|
84
|
-
}, [onClick, showConfirmation, withConfirmation]);
|
|
85
|
-
const debouncedHandlePress = useMemo(() => debounce(handlePress, 500, { leading: true, trailing: false }), [handlePress]);
|
|
110
|
+
}, [disabled, state, variant, theme]);
|
|
86
111
|
if (!theme) {
|
|
87
112
|
return null;
|
|
88
113
|
}
|
|
89
|
-
const isPressDisabled = disabled ||
|
|
114
|
+
const isPressDisabled = disabled || isLoading;
|
|
90
115
|
const PressableComponent = (isPressDisabled ? Pressable : PRESSABLE_BY_ANIMATION[pressAnimation]);
|
|
91
116
|
const pressableInteractionProps = isPressDisabled ? { disabled: true } : { enabled: true };
|
|
92
|
-
return (_jsxs(PressableComponent, Object.assign({ accessibilityHint: withConfirmation ? "Opens a confirmation dialog" : "Press to perform action", accessibilityLabel: text, accessibilityRole: "button", accessibilityState: { disabled: isPressDisabled } }, pressableInteractionProps, { onPress:
|
|
117
|
+
return (_jsxs(PressableComponent, Object.assign({ accessibilityHint: withConfirmation ? "Opens a confirmation dialog" : "Press to perform action", accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : text, accessibilityRole: "button", accessibilityState: { disabled: isPressDisabled } }, pressableInteractionProps, { onPress: onPress, style: {
|
|
93
118
|
alignItems: "center",
|
|
94
119
|
alignSelf: fullWidth ? "stretch" : "flex-start",
|
|
95
120
|
backgroundColor,
|
|
@@ -106,17 +131,73 @@ const ButtonComponent = ({ confirmationText = "Are you sure you want to continue
|
|
|
106
131
|
alignSelf: "center",
|
|
107
132
|
marginLeft: iconPosition === "right" ? 8 : 0,
|
|
108
133
|
marginRight: iconPosition === "left" ? 8 : 0,
|
|
109
|
-
}, children: CustomIcon ? (_jsx(CustomIcon, { color: color !== null && color !== void 0 ? color : theme.text.inverted, size: size === "sm" ? 12 : 16 })) : (_jsx(FontAwesome6, { color: color, name: iconName, size: size === "sm" ? 12 : 16, solid: true })) })), _jsx(Text, { style: { color, fontSize: size === "sm" ? 14 : 16, fontWeight: "700" }, children: text })] }),
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
}, children: CustomIcon ? (_jsx(CustomIcon, { color: color !== null && color !== void 0 ? color : theme.text.inverted, size: size === "sm" ? 12 : 16 })) : (_jsx(FontAwesome6, { color: color, name: iconName, size: size === "sm" ? 12 : 16, solid: true })) })), _jsx(Text, { style: { color, fontSize: size === "sm" ? 14 : 16, fontWeight: "700" }, children: text })] }), isLoading && (_jsx(Box, { marginLeft: 2, children: _jsx(ActivityIndicator, { color: color, size: "small" }) }))] }), children] })));
|
|
135
|
+
};
|
|
136
|
+
const PlainButton = (props) => {
|
|
137
|
+
const { loading = false, onClick } = props;
|
|
138
|
+
const { confirmationText: _confirmationText, modalSubTitle: _modalSubTitle, modalTitle: _modalTitle, onClick: _onClick, withConfirmation: _withConfirmation } = props, visualProps = __rest(props, ["confirmationText", "modalSubTitle", "modalTitle", "onClick", "withConfirmation"]);
|
|
139
|
+
const [isHandlingPress, setIsHandlingPress] = useState(false);
|
|
140
|
+
const isMountedRef = useMountedRef();
|
|
141
|
+
const handlePress = useCallback(async () => {
|
|
142
|
+
await Unifier.utils.haptic();
|
|
143
|
+
if (!isMountedRef.current) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setIsHandlingPress(true);
|
|
147
|
+
try {
|
|
148
|
+
await onClick();
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (isMountedRef.current) {
|
|
152
|
+
setIsHandlingPress(false);
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
if (isMountedRef.current) {
|
|
157
|
+
setIsHandlingPress(false);
|
|
158
|
+
}
|
|
159
|
+
}, [isMountedRef, onClick]);
|
|
160
|
+
const { onPress } = useDebouncedPress(handlePress);
|
|
161
|
+
return _jsx(ButtonVisual, Object.assign({}, visualProps, { isLoading: loading || isHandlingPress, onPress: onPress }));
|
|
162
|
+
};
|
|
163
|
+
const ConfirmationButton = (_a) => {
|
|
164
|
+
var { confirmationText = "Are you sure you want to continue?", loading = false, modalSubTitle, modalTitle = "Confirm", onClick } = _a, props = __rest(_a, ["confirmationText", "loading", "modalSubTitle", "modalTitle", "onClick"]);
|
|
165
|
+
const [showConfirmation, setShowConfirmation] = useState(false);
|
|
166
|
+
const isMountedRef = useMountedRef();
|
|
167
|
+
const handlePress = useCallback(async () => {
|
|
168
|
+
await Unifier.utils.haptic();
|
|
169
|
+
if (!isMountedRef.current) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setShowConfirmation(true);
|
|
173
|
+
}, [isMountedRef]);
|
|
174
|
+
const { endPressCooldown, onPress } = useDebouncedPress(handlePress);
|
|
175
|
+
// The press debounce only guards opening the modal, so closing it must clear the
|
|
176
|
+
// cooldown or a quick reopen after Cancel, dismiss, or Confirm would be swallowed.
|
|
177
|
+
const handleDismiss = useCallback(() => {
|
|
178
|
+
endPressCooldown();
|
|
179
|
+
if (isMountedRef.current) {
|
|
180
|
+
setShowConfirmation(false);
|
|
181
|
+
}
|
|
182
|
+
}, [endPressCooldown, isMountedRef]);
|
|
183
|
+
const handleConfirm = useCallback(async () => {
|
|
184
|
+
await onClick();
|
|
185
|
+
endPressCooldown();
|
|
186
|
+
if (isMountedRef.current) {
|
|
187
|
+
setShowConfirmation(false);
|
|
188
|
+
}
|
|
189
|
+
}, [endPressCooldown, isMountedRef, onClick]);
|
|
190
|
+
return (_jsx(ButtonVisual, Object.assign({}, props, { isLoading: loading, onPress: onPress, withConfirmation: true, children: showConfirmation && (_jsx(Suspense, { fallback: null, children: _jsx(LazyModal, { onDismiss: handleDismiss, primaryButtonOnClick: handleConfirm, primaryButtonText: "Confirm", secondaryButtonOnClick: handleDismiss, secondaryButtonText: "Cancel", subtitle: modalSubTitle, text: confirmationText, title: modalTitle, visible: showConfirmation }) })) })));
|
|
113
191
|
};
|
|
114
|
-
|
|
192
|
+
const ButtonRender = (props) => {
|
|
115
193
|
const { tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false } = props;
|
|
116
194
|
const isMobileOrNative = isMobileDevice() || isNative();
|
|
195
|
+
const button = props.withConfirmation ? (_jsx(ConfirmationButton, Object.assign({}, props))) : (_jsx(PlainButton, Object.assign({}, props)));
|
|
117
196
|
if (tooltipText && !isMobileOrNative) {
|
|
118
|
-
return (_jsx(Tooltip, { idealPosition: tooltipIdealPosition, includeArrow: tooltipIncludeArrow, text: tooltipText, children:
|
|
197
|
+
return (_jsx(Tooltip, { idealPosition: tooltipIdealPosition, includeArrow: tooltipIncludeArrow, text: tooltipText, children: button }));
|
|
119
198
|
}
|
|
120
|
-
return
|
|
199
|
+
return button;
|
|
121
200
|
};
|
|
201
|
+
const MemoizedButton = memo(ButtonRender);
|
|
202
|
+
export const Button = MemoizedButton;
|
|
122
203
|
//# sourceMappingURL=Button.js.map
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"
|
|
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,EAEL,gBAAgB,EAChB,cAAc,EACd,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OA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,CAAC;IAC/E,MAAM,gBAAgB,GAAG,cAAc,EAAE,IAAI,QAAQ,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CACtC,KAAC,kBAAkB,oBAAK,KAAK,EAAI,CAClC,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,oBAAK,KAAK,EAAI,CAC3B,CAAC;IAEF,IAAI,WAAW,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACrC,OAAO,CACL,KAAC,OAAO,IACN,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,mBAAmB,EACjC,IAAI,EAAE,WAAW,YAEhB,MAAM,GACC,CACX,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,MAAM,GAA0B,cAAc,CAAC"}
|
package/dist/Common.d.ts
CHANGED
|
@@ -393,8 +393,17 @@ export interface FilterProps extends WithTestID {
|
|
|
393
393
|
children: React.ReactNode;
|
|
394
394
|
/** Trigger button label. */
|
|
395
395
|
label?: string;
|
|
396
|
+
/** Accessible name when the visible trigger label is empty or abbreviated. */
|
|
397
|
+
triggerAccessibilityLabel?: string;
|
|
396
398
|
/** Trigger button icon. Defaults to the built-in `bars-filter` glyph. */
|
|
397
399
|
iconName?: IconName;
|
|
400
|
+
/**
|
|
401
|
+
* Render the trigger as a compact `IconButton` instead of a labeled button.
|
|
402
|
+
* Use for dense chrome such as table column headers. `label` is ignored.
|
|
403
|
+
*/
|
|
404
|
+
iconOnly?: boolean;
|
|
405
|
+
/** Trigger size when `iconOnly` is set. Defaults to `sm`. */
|
|
406
|
+
triggerSize?: "sm" | "default";
|
|
398
407
|
/** Controlled open state. Omit to use `defaultOpen`. */
|
|
399
408
|
isOpen?: boolean;
|
|
400
409
|
/** Initial open state when uncontrolled. */
|
|
@@ -483,13 +492,14 @@ export interface BoxPropsBase extends WithTestID {
|
|
|
483
492
|
lgColumn?: UnsignedUpTo12;
|
|
484
493
|
dangerouslySetInlineStyle?: {
|
|
485
494
|
__style: {
|
|
486
|
-
[key: string]:
|
|
495
|
+
[key: string]: unknown;
|
|
487
496
|
};
|
|
488
497
|
};
|
|
489
498
|
direction?: "row" | "column";
|
|
490
499
|
smDirection?: "row" | "column";
|
|
491
500
|
mdDirection?: "row" | "column";
|
|
492
501
|
lgDirection?: "row" | "column";
|
|
502
|
+
xlDirection?: "row" | "column";
|
|
493
503
|
display?: "none" | "flex" | "block" | "inlineBlock" | "visuallyHidden";
|
|
494
504
|
smDisplay?: "none" | "flex" | "block" | "inlineBlock" | "visuallyHidden";
|
|
495
505
|
mdDisplay?: "none" | "flex" | "block" | "inlineBlock" | "visuallyHidden";
|
|
@@ -737,6 +747,12 @@ export interface AiSuggestionProps {
|
|
|
737
747
|
}
|
|
738
748
|
export interface TextFieldProps extends BaseFieldProps, HelperTextProps, ErrorTextProps {
|
|
739
749
|
type?: "email" | "password" | "phoneNumber" | "search" | "text" | "url";
|
|
750
|
+
/**
|
|
751
|
+
* Renders the show/hide eye control on `type="password"`. Set to `false` for fields where
|
|
752
|
+
* revealing the value is not acceptable, such as a shared or on-camera screen.
|
|
753
|
+
* @default true
|
|
754
|
+
*/
|
|
755
|
+
showVisibilityToggle?: boolean;
|
|
740
756
|
autoComplete?: "current-password" | "on" | "off" | "username";
|
|
741
757
|
returnKeyType?: "done" | "go" | "next" | "search" | "send";
|
|
742
758
|
grow?: boolean;
|
|
@@ -872,7 +888,10 @@ export interface LayoutChangeEvent {
|
|
|
872
888
|
layout: LayoutRectangle;
|
|
873
889
|
};
|
|
874
890
|
}
|
|
875
|
-
export interface
|
|
891
|
+
export interface SplitPageListItem {
|
|
892
|
+
id: string;
|
|
893
|
+
}
|
|
894
|
+
export interface SplitPageProps<TItem extends SplitPageListItem = SplitPageListItem> {
|
|
876
895
|
/**
|
|
877
896
|
* can accept either one React Child or any array of ReactChild. If this is not provided,
|
|
878
897
|
* renderContent must return one or many ReactChild.
|
|
@@ -889,15 +908,15 @@ export interface SplitPageProps {
|
|
|
889
908
|
loading?: boolean;
|
|
890
909
|
color?: SurfaceColor;
|
|
891
910
|
keyboardOffset?: number;
|
|
892
|
-
renderListViewItem: (itemInfo: ListRenderItemInfo<
|
|
911
|
+
renderListViewItem: (itemInfo: ListRenderItemInfo<TItem>) => ReactElement | null;
|
|
893
912
|
renderListViewHeader?: () => ReactElement | null;
|
|
894
913
|
renderContent?: (index?: number) => ReactElement | ReactElement[] | null;
|
|
895
|
-
listViewData:
|
|
914
|
+
listViewData: TItem[];
|
|
896
915
|
listViewExtraData?: unknown;
|
|
897
916
|
listViewWidth?: number;
|
|
898
917
|
listViewMaxWidth?: number;
|
|
899
918
|
renderChild?: () => ReactChild;
|
|
900
|
-
onSelectionChange?: (value?:
|
|
919
|
+
onSelectionChange?: (value?: ListRenderItemInfo<TItem>) => void | Promise<void>;
|
|
901
920
|
}
|
|
902
921
|
export type PermissionKind = "location" | "locationAlways" | "camera" | "microphone" | "photo" | "contacts" | "event" | "reminder" | "bluetooth" | "notification" | "backgroundRefresh" | "speechRecognition" | "mediaLibrary" | "motion";
|
|
903
922
|
export type PermissionStatus = "authorized" | "denied" | "softDenied" | "restricted" | "undetermined";
|
|
@@ -1375,6 +1394,89 @@ export interface ThumbsUpDownFeedbackProps extends WithTestID {
|
|
|
1375
1394
|
*/
|
|
1376
1395
|
value?: ThumbsUpDownFeedbackValue;
|
|
1377
1396
|
}
|
|
1397
|
+
export type PopoverStatus = "loading" | "loaded" | "error";
|
|
1398
|
+
export interface PopoverProps extends WithTestID {
|
|
1399
|
+
/**
|
|
1400
|
+
* The body of the document, rendered under the header when status is "loaded". Use this for
|
|
1401
|
+
* rich content; prefer `text` for a plain summary.
|
|
1402
|
+
*/
|
|
1403
|
+
children?: React.ReactNode;
|
|
1404
|
+
/**
|
|
1405
|
+
* Supporting copy shown under the error title.
|
|
1406
|
+
* @default "Something went wrong while loading this document. Check your connection and try again."
|
|
1407
|
+
*/
|
|
1408
|
+
errorText?: string;
|
|
1409
|
+
/**
|
|
1410
|
+
* Title shown in the error state.
|
|
1411
|
+
* @default "Couldn't load this document"
|
|
1412
|
+
*/
|
|
1413
|
+
errorTitle?: string;
|
|
1414
|
+
/**
|
|
1415
|
+
* The currently selected feedback on the document. Only shown when `onFeedbackChange` is set.
|
|
1416
|
+
*/
|
|
1417
|
+
feedback?: ThumbsUpDownFeedbackValue;
|
|
1418
|
+
/**
|
|
1419
|
+
* Height of the popover. The popover is the same height in every status: the body scrolls when
|
|
1420
|
+
* it overflows, and the spinner and error message are centered in the remaining space.
|
|
1421
|
+
* @default 480
|
|
1422
|
+
*/
|
|
1423
|
+
height?: NumberOrPercentage;
|
|
1424
|
+
/**
|
|
1425
|
+
* Header text shown while the document is loading.
|
|
1426
|
+
* @default "Loading document..."
|
|
1427
|
+
*/
|
|
1428
|
+
loadingText?: string;
|
|
1429
|
+
/**
|
|
1430
|
+
* Called when the close button is pressed.
|
|
1431
|
+
*/
|
|
1432
|
+
onClose: () => void | Promise<void>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Called with the newly selected feedback, or undefined when the current value is deselected.
|
|
1435
|
+
* When omitted, the thumbs up/down controls are hidden.
|
|
1436
|
+
*/
|
|
1437
|
+
onFeedbackChange?: (value?: ThumbsUpDownFeedbackValue) => void | Promise<void>;
|
|
1438
|
+
/**
|
|
1439
|
+
* Called when the "Open" action is pressed. When omitted, the action is hidden.
|
|
1440
|
+
*/
|
|
1441
|
+
onOpen?: () => void | Promise<void>;
|
|
1442
|
+
/**
|
|
1443
|
+
* Called when the "Try again" button is pressed in the error state. When omitted, the button
|
|
1444
|
+
* is hidden.
|
|
1445
|
+
*/
|
|
1446
|
+
onRetry?: () => void | Promise<void>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Text of the action that opens the full document.
|
|
1449
|
+
* @default "Open"
|
|
1450
|
+
*/
|
|
1451
|
+
openText?: string;
|
|
1452
|
+
/**
|
|
1453
|
+
* Text of the button that retries loading in the error state.
|
|
1454
|
+
* @default "Try again"
|
|
1455
|
+
*/
|
|
1456
|
+
retryText?: string;
|
|
1457
|
+
/**
|
|
1458
|
+
* The state of the document being previewed.
|
|
1459
|
+
* @default "loaded"
|
|
1460
|
+
*/
|
|
1461
|
+
status?: PopoverStatus;
|
|
1462
|
+
/**
|
|
1463
|
+
* Secondary header line, usually the document's date.
|
|
1464
|
+
*/
|
|
1465
|
+
subtitle?: string;
|
|
1466
|
+
/**
|
|
1467
|
+
* A plain text summary of the document, rendered when no `children` are provided.
|
|
1468
|
+
*/
|
|
1469
|
+
text?: string;
|
|
1470
|
+
/**
|
|
1471
|
+
* The document's title, shown in the header when status is "loaded".
|
|
1472
|
+
*/
|
|
1473
|
+
title?: string;
|
|
1474
|
+
/**
|
|
1475
|
+
* Width of the popover.
|
|
1476
|
+
* @default 480
|
|
1477
|
+
*/
|
|
1478
|
+
width?: NumberOrPercentage;
|
|
1479
|
+
}
|
|
1378
1480
|
export interface SelectBadgeProps {
|
|
1379
1481
|
/**
|
|
1380
1482
|
* When status is "custom", determines the badge's background color.
|
|
@@ -1473,6 +1575,8 @@ export interface BodyProps {
|
|
|
1473
1575
|
}
|
|
1474
1576
|
export type ButtonPressAnimation = "scale" | "opacity" | "none";
|
|
1475
1577
|
export interface ButtonProps extends WithTestID {
|
|
1578
|
+
/** Accessible name. Defaults to `text`. */
|
|
1579
|
+
accessibilityLabel?: string;
|
|
1476
1580
|
/**
|
|
1477
1581
|
* The text content of the confirmation modal.
|
|
1478
1582
|
* @default "Are you sure you want to continue?"
|
|
@@ -1537,6 +1641,12 @@ export interface ButtonProps extends WithTestID {
|
|
|
1537
1641
|
* @default "default"
|
|
1538
1642
|
*/
|
|
1539
1643
|
size?: "default" | "sm";
|
|
1644
|
+
/**
|
|
1645
|
+
* Controls the button's interaction state. Use Default for standard button appearance
|
|
1646
|
+
* and Active to indicate a selected or currently engaged state.
|
|
1647
|
+
* @default "default"
|
|
1648
|
+
*/
|
|
1649
|
+
state?: "default" | "active";
|
|
1540
1650
|
/**
|
|
1541
1651
|
* The type of the button, which determines its style.
|
|
1542
1652
|
* @default "primary"
|
|
@@ -1713,16 +1823,29 @@ export interface HeightActionSheetProps {
|
|
|
1713
1823
|
/** Title shown at the top of the action sheet */
|
|
1714
1824
|
title?: string;
|
|
1715
1825
|
}
|
|
1826
|
+
export interface LinkifyMatch {
|
|
1827
|
+
index: number;
|
|
1828
|
+
lastIndex: number;
|
|
1829
|
+
raw: string;
|
|
1830
|
+
schema: string;
|
|
1831
|
+
text: string;
|
|
1832
|
+
url: string;
|
|
1833
|
+
}
|
|
1834
|
+
export interface LinkifyItLike {
|
|
1835
|
+
pretest: (text: string) => boolean;
|
|
1836
|
+
test: (text: string) => boolean;
|
|
1837
|
+
match: (text: string) => LinkifyMatch[] | null;
|
|
1838
|
+
}
|
|
1716
1839
|
export interface HyperlinkProps {
|
|
1717
1840
|
linkDefault?: boolean;
|
|
1718
|
-
linkify?:
|
|
1719
|
-
linkStyle?: StyleProp<
|
|
1841
|
+
linkify?: LinkifyItLike;
|
|
1842
|
+
linkStyle?: StyleProp<TextStyle>;
|
|
1720
1843
|
linkText?: string | ((url: string) => string);
|
|
1721
1844
|
onPress?: (url: string) => void;
|
|
1722
1845
|
onLongPress?: (url: string, text: string) => void;
|
|
1723
|
-
injectViewProps?: (url: string) =>
|
|
1846
|
+
injectViewProps?: (url: string) => Record<string, unknown>;
|
|
1724
1847
|
children?: React.ReactNode;
|
|
1725
|
-
style?: StyleProp<
|
|
1848
|
+
style?: StyleProp<ViewStyle | TextStyle>;
|
|
1726
1849
|
}
|
|
1727
1850
|
export interface IconButtonProps extends WithTestID {
|
|
1728
1851
|
/**
|
|
@@ -1882,6 +2005,8 @@ export interface PageProps extends WithTestID {
|
|
|
1882
2005
|
display?: "flex" | "none" | "block" | "inlineBlock";
|
|
1883
2006
|
title?: string;
|
|
1884
2007
|
backButton?: boolean;
|
|
2008
|
+
/** When set, invoked instead of `router.back()` for the header back arrow. */
|
|
2009
|
+
onBack?: () => void;
|
|
1885
2010
|
closeButton?: boolean;
|
|
1886
2011
|
direction?: "row" | "column";
|
|
1887
2012
|
padding?: UnsignedUpTo12;
|
|
@@ -2093,6 +2218,42 @@ export interface PaginationProps extends WithTestID {
|
|
|
2093
2218
|
setPage: (page: number) => void;
|
|
2094
2219
|
totalPages: number;
|
|
2095
2220
|
}
|
|
2221
|
+
export interface LineChartProps extends WithTestID {
|
|
2222
|
+
/** Summary announced for the whole chart. */
|
|
2223
|
+
accessibilityLabel?: string;
|
|
2224
|
+
/** Single series of labeled numeric points. */
|
|
2225
|
+
data: Array<{
|
|
2226
|
+
color?: string;
|
|
2227
|
+
label: string;
|
|
2228
|
+
value: number;
|
|
2229
|
+
}>;
|
|
2230
|
+
/** Copy shown when `data` is empty. */
|
|
2231
|
+
emptyText?: string;
|
|
2232
|
+
/** Formats the numeric value in tooltips. */
|
|
2233
|
+
formatValue?: (value: number) => string;
|
|
2234
|
+
/** Plot height in pixels. */
|
|
2235
|
+
height?: number;
|
|
2236
|
+
/** Series name shown under the plot. */
|
|
2237
|
+
legendLabel?: string;
|
|
2238
|
+
/** When true, shows a spinner instead of the plot. */
|
|
2239
|
+
loading?: boolean;
|
|
2240
|
+
}
|
|
2241
|
+
export interface AreaChartProps extends LineChartProps {
|
|
2242
|
+
}
|
|
2243
|
+
export interface BarChartProps extends LineChartProps {
|
|
2244
|
+
}
|
|
2245
|
+
export interface DonutChartProps extends LineChartProps {
|
|
2246
|
+
}
|
|
2247
|
+
export interface DashboardGridProps extends WithTestID {
|
|
2248
|
+
children?: React.ReactNode;
|
|
2249
|
+
/** Column counts by breakpoint. Defaults to `{sm: 1, md: 2, lg: 3}`. */
|
|
2250
|
+
columns?: {
|
|
2251
|
+
lg: number;
|
|
2252
|
+
md: number;
|
|
2253
|
+
sm: number;
|
|
2254
|
+
};
|
|
2255
|
+
gap?: UnsignedUpTo12;
|
|
2256
|
+
}
|
|
2096
2257
|
/**
|
|
2097
2258
|
* Data Table
|
|
2098
2259
|
*/
|
|
@@ -2105,6 +2266,28 @@ export type DataTableCustomComponentMap = Record<string, React.ComponentType<{
|
|
|
2105
2266
|
column: DataTableColumn;
|
|
2106
2267
|
cellData: DataTableCellData;
|
|
2107
2268
|
}>>;
|
|
2269
|
+
export interface DataTableColumnFilterChoiceOption {
|
|
2270
|
+
label: string;
|
|
2271
|
+
value: string;
|
|
2272
|
+
}
|
|
2273
|
+
export interface DataTableColumnFilterRenderArgs {
|
|
2274
|
+
field: string;
|
|
2275
|
+
onChange: (value: unknown) => void;
|
|
2276
|
+
value: unknown;
|
|
2277
|
+
}
|
|
2278
|
+
export interface DataTableColumnFilter {
|
|
2279
|
+
field: string;
|
|
2280
|
+
kind: "text" | "boolean" | "numberRange" | "dateRange" | "choice";
|
|
2281
|
+
label?: string;
|
|
2282
|
+
/** When true, choice filters include an Empty option for null/unset field values. */
|
|
2283
|
+
allowEmpty?: boolean;
|
|
2284
|
+
options?: DataTableColumnFilterChoiceOption[];
|
|
2285
|
+
renderFilter?: (args: DataTableColumnFilterRenderArgs) => React.ReactNode;
|
|
2286
|
+
}
|
|
2287
|
+
export interface DataTableQueryParams {
|
|
2288
|
+
[field: string]: unknown;
|
|
2289
|
+
$or?: Array<Record<string, unknown>>;
|
|
2290
|
+
}
|
|
2108
2291
|
export interface DataTableColumn {
|
|
2109
2292
|
title: string;
|
|
2110
2293
|
columnType: "text" | "number" | "date" | "boolean" | string;
|
|
@@ -2112,11 +2295,16 @@ export interface DataTableColumn {
|
|
|
2112
2295
|
highlight?: SurfaceColor;
|
|
2113
2296
|
sortable?: boolean;
|
|
2114
2297
|
infoModalText?: string;
|
|
2298
|
+
filter?: DataTableColumnFilter;
|
|
2115
2299
|
}
|
|
2116
2300
|
export interface DataTableProps extends WithTestID {
|
|
2117
2301
|
testIDs?: DataTableTestIDs;
|
|
2118
2302
|
data: DataTableCellData[][];
|
|
2119
2303
|
columns: DataTableColumn[];
|
|
2304
|
+
/** Filter definitions that are not attached to a visible column. */
|
|
2305
|
+
additionalFilters?: DataTableColumnFilter[];
|
|
2306
|
+
/** Content shown below the header when `data` is empty. */
|
|
2307
|
+
emptyContent?: React.ReactNode;
|
|
2120
2308
|
alternateRowBackground?: boolean;
|
|
2121
2309
|
totalPages?: number;
|
|
2122
2310
|
page?: number;
|
|
@@ -2141,6 +2329,16 @@ export interface DataTableProps extends WithTestID {
|
|
|
2141
2329
|
* Returns a stable key for row test ids. Defaults to row index when omitted.
|
|
2142
2330
|
*/
|
|
2143
2331
|
getRowTestID?: (row: DataTableCellData[], rowIndex: number) => string | number;
|
|
2332
|
+
/** Toolbar search string (controlled). Omit with `searchFields` to hide search. */
|
|
2333
|
+
search?: string;
|
|
2334
|
+
/** Fields included in generic `$or` search params. */
|
|
2335
|
+
searchFields?: string[];
|
|
2336
|
+
onSearchChange?: (search: string) => void;
|
|
2337
|
+
/** Controlled column filter draft/applied values keyed by field (and `field_gte` / `field_lte`). */
|
|
2338
|
+
filterValues?: Record<string, unknown>;
|
|
2339
|
+
onFilterValuesChange?: (next: Record<string, unknown>) => void;
|
|
2340
|
+
/** Fires when debounced search or applied filters change. Excludes page, limit, and sort. */
|
|
2341
|
+
onQueryChange?: (params: DataTableQueryParams) => void;
|
|
2144
2342
|
}
|
|
2145
2343
|
export interface DataTableCellProps {
|
|
2146
2344
|
value: DataTableCellData;
|
|
@@ -2341,6 +2539,14 @@ export type TapToEditProps = (BaseTapToEditProps & Omit<TextFieldProps, "onChang
|
|
|
2341
2539
|
type: "address";
|
|
2342
2540
|
});
|
|
2343
2541
|
export interface BaseTapToEditProps extends Omit<FieldProps, "onChange" | "value"> {
|
|
2542
|
+
/**
|
|
2543
|
+
* Root test id. Forwards to the Field input and suffixes action controls for e2e:
|
|
2544
|
+
* `{testID}.edit-clickable`, `{testID}.cancel`, `{testID}.clear`, `{testID}.save`.
|
|
2545
|
+
* The edit control is a pressable Box (`-clickable` is appended by Box).
|
|
2546
|
+
* Cancel/Clear/Save only render when the user opened edit from inside the
|
|
2547
|
+
* component, not when `isEditing` is true.
|
|
2548
|
+
*/
|
|
2549
|
+
testID?: string;
|
|
2344
2550
|
title: string;
|
|
2345
2551
|
value: any;
|
|
2346
2552
|
/**
|
package/dist/Common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,GACZ,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Common.js","sourceRoot":"","sources":["../src/Common.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAsgBjC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;CACP,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAqB,EAAE,EAAE;IAClD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAC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