@terreno/ui 0.0.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/LICENSE +203 -0
- package/README.md +160 -0
- package/dist/Accordion.d.ts +3 -0
- package/dist/Accordion.js +30 -0
- package/dist/Accordion.js.map +1 -0
- package/dist/ActionSheet.d.ts +169 -0
- package/dist/ActionSheet.js +637 -0
- package/dist/ActionSheet.js.map +1 -0
- package/dist/AddressField.d.ts +3 -0
- package/dist/AddressField.js +18 -0
- package/dist/AddressField.js.map +1 -0
- package/dist/Avatar.d.ts +3 -0
- package/dist/Avatar.js +189 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.d.ts +3 -0
- package/dist/Badge.js +100 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Banner.d.ts +4 -0
- package/dist/Banner.js +103 -0
- package/dist/Banner.js.map +1 -0
- package/dist/Body.d.ts +3 -0
- package/dist/Body.js +17 -0
- package/dist/Body.js.map +1 -0
- package/dist/BooleanField.d.ts +3 -0
- package/dist/BooleanField.js +89 -0
- package/dist/BooleanField.js.map +1 -0
- package/dist/Box.d.ts +3 -0
- package/dist/Box.js +289 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +3 -0
- package/dist/Button.js +105 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +2 -0
- package/dist/Card.js +18 -0
- package/dist/Card.js.map +1 -0
- package/dist/CheckBox.d.ts +3 -0
- package/dist/CheckBox.js +28 -0
- package/dist/CheckBox.js.map +1 -0
- package/dist/Common.d.ts +2325 -0
- package/dist/Common.js +47 -0
- package/dist/Common.js.map +1 -0
- package/dist/CommonIconTypes.d.ts +3 -0
- package/dist/CommonIconTypes.js +2 -0
- package/dist/CommonIconTypes.js.map +1 -0
- package/dist/Constants.d.ts +12685 -0
- package/dist/Constants.js +3310 -0
- package/dist/Constants.js.map +1 -0
- package/dist/CustomSelectField.d.ts +3 -0
- package/dist/CustomSelectField.js +59 -0
- package/dist/CustomSelectField.js.map +1 -0
- package/dist/DataTable.d.ts +3 -0
- package/dist/DataTable.js +190 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +2 -0
- package/dist/DateTimeActionSheet.js +270 -0
- package/dist/DateTimeActionSheet.js.map +1 -0
- package/dist/DateTimeField.d.ts +3 -0
- package/dist/DateTimeField.js +514 -0
- package/dist/DateTimeField.js.map +1 -0
- package/dist/DateUtilities.d.ts +57 -0
- package/dist/DateUtilities.js +308 -0
- package/dist/DateUtilities.js.map +1 -0
- package/dist/DecimalRangeActionSheet.d.ts +6 -0
- package/dist/DecimalRangeActionSheet.js +45 -0
- package/dist/DecimalRangeActionSheet.js.map +1 -0
- package/dist/DismissButton.d.ts +3 -0
- package/dist/DismissButton.js +12 -0
- package/dist/DismissButton.js.map +1 -0
- package/dist/EmailField.d.ts +3 -0
- package/dist/EmailField.js +48 -0
- package/dist/EmailField.js.map +1 -0
- package/dist/EmojiSelector.d.ts +113 -0
- package/dist/EmojiSelector.js +322 -0
- package/dist/EmojiSelector.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +19 -0
- package/dist/ErrorBoundary.js +30 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/ErrorPage.d.ts +6 -0
- package/dist/ErrorPage.js +15 -0
- package/dist/ErrorPage.js.map +1 -0
- package/dist/Field.d.ts +3 -0
- package/dist/Field.js +80 -0
- package/dist/Field.js.map +1 -0
- package/dist/FlatList.d.ts +2 -0
- package/dist/FlatList.js +3 -0
- package/dist/FlatList.js.map +1 -0
- package/dist/Heading.d.ts +3 -0
- package/dist/Heading.js +43 -0
- package/dist/Heading.js.map +1 -0
- package/dist/HeightActionSheet.d.ts +11 -0
- package/dist/HeightActionSheet.js +46 -0
- package/dist/HeightActionSheet.js.map +1 -0
- package/dist/Hyperlink.d.ts +30 -0
- package/dist/Hyperlink.js +144 -0
- package/dist/Hyperlink.js.map +1 -0
- package/dist/Icon.d.ts +3 -0
- package/dist/Icon.js +15 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +3 -0
- package/dist/IconButton.js +111 -0
- package/dist/IconButton.js.map +1 -0
- package/dist/Image.d.ts +8 -0
- package/dist/Image.js +37 -0
- package/dist/Image.js.map +1 -0
- package/dist/ImageBackground.d.ts +10 -0
- package/dist/ImageBackground.js +9 -0
- package/dist/ImageBackground.js.map +1 -0
- package/dist/InfoModalIcon.d.ts +3 -0
- package/dist/InfoModalIcon.js +10 -0
- package/dist/InfoModalIcon.js.map +1 -0
- package/dist/InfoTooltipButton.d.ts +3 -0
- package/dist/InfoTooltipButton.js +6 -0
- package/dist/InfoTooltipButton.js.map +1 -0
- package/dist/Link.d.ts +3 -0
- package/dist/Link.js +10 -0
- package/dist/Link.js.map +1 -0
- package/dist/MarkdownView.d.ts +5 -0
- package/dist/MarkdownView.js +44 -0
- package/dist/MarkdownView.js.map +1 -0
- package/dist/MediaQuery.d.ts +4 -0
- package/dist/MediaQuery.js +52 -0
- package/dist/MediaQuery.js.map +1 -0
- package/dist/MobileAddressAutoComplete.d.ts +2 -0
- package/dist/MobileAddressAutoComplete.js +54 -0
- package/dist/MobileAddressAutoComplete.js.map +1 -0
- package/dist/Modal.d.ts +3 -0
- package/dist/Modal.js +127 -0
- package/dist/Modal.js.map +1 -0
- package/dist/ModalSheet.d.ts +6 -0
- package/dist/ModalSheet.js +42 -0
- package/dist/ModalSheet.js.map +1 -0
- package/dist/MultiselectField.d.ts +3 -0
- package/dist/MultiselectField.js +45 -0
- package/dist/MultiselectField.js.map +1 -0
- package/dist/NumberField.d.ts +3 -0
- package/dist/NumberField.js +60 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberPickerActionSheet.d.ts +7 -0
- package/dist/NumberPickerActionSheet.js +22 -0
- package/dist/NumberPickerActionSheet.js.map +1 -0
- package/dist/OpenAPIContext.d.ts +4 -0
- package/dist/OpenAPIContext.js +53 -0
- package/dist/OpenAPIContext.js.map +1 -0
- package/dist/Page.d.ts +7 -0
- package/dist/Page.js +24 -0
- package/dist/Page.js.map +1 -0
- package/dist/Pagination.d.ts +3 -0
- package/dist/Pagination.js +106 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/PasswordField.d.ts +2 -0
- package/dist/PasswordField.js +6 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/Permissions.d.ts +2 -0
- package/dist/Permissions.js +35 -0
- package/dist/Permissions.js.map +1 -0
- package/dist/PhoneNumberField.d.ts +3 -0
- package/dist/PhoneNumberField.js +83 -0
- package/dist/PhoneNumberField.js.map +1 -0
- package/dist/PickerSelect.d.ts +46 -0
- package/dist/PickerSelect.js +306 -0
- package/dist/PickerSelect.js.map +1 -0
- package/dist/Radio.d.ts +3 -0
- package/dist/Radio.js +21 -0
- package/dist/Radio.js.map +1 -0
- package/dist/RadioField.d.ts +3 -0
- package/dist/RadioField.js +16 -0
- package/dist/RadioField.js.map +1 -0
- package/dist/ScrollView.d.ts +2 -0
- package/dist/ScrollView.js +3 -0
- package/dist/ScrollView.js.map +1 -0
- package/dist/SectionDivider.d.ts +2 -0
- package/dist/SectionDivider.js +12 -0
- package/dist/SectionDivider.js.map +1 -0
- package/dist/SegmentedControl.d.ts +3 -0
- package/dist/SegmentedControl.js +65 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/SelectBadge.d.ts +3 -0
- package/dist/SelectBadge.js +166 -0
- package/dist/SelectBadge.js.map +1 -0
- package/dist/SelectField.d.ts +3 -0
- package/dist/SelectField.js +16 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/SideDrawer.d.ts +3 -0
- package/dist/SideDrawer.js +32 -0
- package/dist/SideDrawer.js.map +1 -0
- package/dist/Signature.d.ts +8 -0
- package/dist/Signature.js +21 -0
- package/dist/Signature.js.map +1 -0
- package/dist/Signature.native.d.ts +8 -0
- package/dist/Signature.native.js +26 -0
- package/dist/Signature.native.js.map +1 -0
- package/dist/SignatureField.d.ts +3 -0
- package/dist/SignatureField.js +42 -0
- package/dist/SignatureField.js.map +1 -0
- package/dist/Slider.d.ts +3 -0
- package/dist/Slider.js +78 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Spinner.d.ts +3 -0
- package/dist/Spinner.js +33 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/SplitPage.d.ts +2 -0
- package/dist/SplitPage.js +139 -0
- package/dist/SplitPage.js.map +1 -0
- package/dist/SplitPage.native.d.ts +2 -0
- package/dist/SplitPage.native.js +75 -0
- package/dist/SplitPage.native.js.map +1 -0
- package/dist/TapToEdit.d.ts +4 -0
- package/dist/TapToEdit.js +170 -0
- package/dist/TapToEdit.js.map +1 -0
- package/dist/TerrenoProvider.d.ts +6 -0
- package/dist/TerrenoProvider.js +10 -0
- package/dist/TerrenoProvider.js.map +1 -0
- package/dist/Text.d.ts +3 -0
- package/dist/Text.js +95 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +3 -0
- package/dist/TextArea.js +6 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextField.d.ts +3 -0
- package/dist/TextField.js +144 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextFieldNumberActionSheet.d.ts +7 -0
- package/dist/TextFieldNumberActionSheet.js +20 -0
- package/dist/TextFieldNumberActionSheet.js.map +1 -0
- package/dist/Theme.d.ts +96 -0
- package/dist/Theme.js +213 -0
- package/dist/Theme.js.map +1 -0
- package/dist/TimezonePicker.d.ts +11 -0
- package/dist/TimezonePicker.js +27 -0
- package/dist/TimezonePicker.js.map +1 -0
- package/dist/Toast.d.ts +23 -0
- package/dist/Toast.js +157 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +3 -0
- package/dist/Tooltip.js +289 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/UnifiedAddressAutoComplete.d.ts +2 -0
- package/dist/UnifiedAddressAutoComplete.js +23 -0
- package/dist/UnifiedAddressAutoComplete.js.map +1 -0
- package/dist/Unifier.d.ts +43 -0
- package/dist/Unifier.js +154 -0
- package/dist/Unifier.js.map +1 -0
- package/dist/Utilities.d.ts +56 -0
- package/dist/Utilities.js +193 -0
- package/dist/Utilities.js.map +1 -0
- package/dist/WebAddressAutocomplete.d.ts +3 -0
- package/dist/WebAddressAutocomplete.js +61 -0
- package/dist/WebAddressAutocomplete.js.map +1 -0
- package/dist/fieldElements/FieldError.d.ts +6 -0
- package/dist/fieldElements/FieldError.js +9 -0
- package/dist/fieldElements/FieldError.js.map +1 -0
- package/dist/fieldElements/FieldHelperText.d.ts +6 -0
- package/dist/fieldElements/FieldHelperText.js +8 -0
- package/dist/fieldElements/FieldHelperText.js.map +1 -0
- package/dist/fieldElements/FieldTitle.d.ts +6 -0
- package/dist/fieldElements/FieldTitle.js +16 -0
- package/dist/fieldElements/FieldTitle.js.map +1 -0
- package/dist/fieldElements/index.d.ts +3 -0
- package/dist/fieldElements/index.js +4 -0
- package/dist/fieldElements/index.js.map +1 -0
- package/dist/icons/MobileIcon.d.ts +2 -0
- package/dist/icons/MobileIcon.js +18 -0
- package/dist/icons/MobileIcon.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +2 -0
- package/dist/icons/OfflineIcon.js +18 -0
- package/dist/icons/OfflineIcon.js.map +1 -0
- package/dist/icons/OnlineIcon.d.ts +2 -0
- package/dist/icons/OnlineIcon.js +19 -0
- package/dist/icons/OnlineIcon.js.map +1 -0
- package/dist/icons/OutOfficeIcon.d.ts +2 -0
- package/dist/icons/OutOfficeIcon.js +18 -0
- package/dist/icons/OutOfficeIcon.js.map +1 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +5 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +1328 -0
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/dist/table/Table.d.ts +3 -0
- package/dist/table/Table.js +53 -0
- package/dist/table/Table.js.map +1 -0
- package/dist/table/TableBadge.d.ts +6 -0
- package/dist/table/TableBadge.js +23 -0
- package/dist/table/TableBadge.js.map +1 -0
- package/dist/table/TableBoolean.d.ts +6 -0
- package/dist/table/TableBoolean.js +37 -0
- package/dist/table/TableBoolean.js.map +1 -0
- package/dist/table/TableDate.d.ts +3 -0
- package/dist/table/TableDate.js +27 -0
- package/dist/table/TableDate.js.map +1 -0
- package/dist/table/TableHeader.d.ts +6 -0
- package/dist/table/TableHeader.js +10 -0
- package/dist/table/TableHeader.js.map +1 -0
- package/dist/table/TableHeaderCell.d.ts +6 -0
- package/dist/table/TableHeaderCell.js +54 -0
- package/dist/table/TableHeaderCell.js.map +1 -0
- package/dist/table/TableIconButton.d.ts +3 -0
- package/dist/table/TableIconButton.js +39 -0
- package/dist/table/TableIconButton.js.map +1 -0
- package/dist/table/TableNumber.d.ts +3 -0
- package/dist/table/TableNumber.js +18 -0
- package/dist/table/TableNumber.js.map +1 -0
- package/dist/table/TableRow.d.ts +6 -0
- package/dist/table/TableRow.js +22 -0
- package/dist/table/TableRow.js.map +1 -0
- package/dist/table/TableText.d.ts +3 -0
- package/dist/table/TableText.js +18 -0
- package/dist/table/TableText.js.map +1 -0
- package/dist/table/TableTitle.d.ts +3 -0
- package/dist/table/TableTitle.js +21 -0
- package/dist/table/TableTitle.js.map +1 -0
- package/dist/table/tableContext.d.ts +5 -0
- package/dist/table/tableContext.js +38 -0
- package/dist/table/tableContext.js.map +1 -0
- package/dist/useStoredState.d.ts +1 -0
- package/dist/useStoredState.js +49 -0
- package/dist/useStoredState.js.map +1 -0
- package/package.json +123 -0
- package/src/Accordion.test.tsx +104 -0
- package/src/Accordion.tsx +81 -0
- package/src/ActionSheet.tsx +881 -0
- package/src/AddressField.test.tsx +120 -0
- package/src/AddressField.tsx +122 -0
- package/src/Avatar.test.tsx +163 -0
- package/src/Avatar.tsx +298 -0
- package/src/Badge.test.tsx +116 -0
- package/src/Badge.tsx +136 -0
- package/src/Banner.tsx +200 -0
- package/src/Body.tsx +34 -0
- package/src/BooleanField.tsx +141 -0
- package/src/Box.test.tsx +662 -0
- package/src/Box.tsx +368 -0
- package/src/Button.tsx +196 -0
- package/src/Card.tsx +19 -0
- package/src/CheckBox.tsx +45 -0
- package/src/Common.ts +2787 -0
- package/src/CommonIconTypes.ts +2030 -0
- package/src/Constants.ts +3311 -0
- package/src/CustomSelectField.tsx +115 -0
- package/src/DataTable.tsx +674 -0
- package/src/DateTimeActionSheet.tsx +559 -0
- package/src/DateTimeField.test.tsx +393 -0
- package/src/DateTimeField.tsx +777 -0
- package/src/DateUtilities.test.ts +440 -0
- package/src/DateUtilities.tsx +370 -0
- package/src/DecimalRangeActionSheet.tsx +85 -0
- package/src/DismissButton.tsx +31 -0
- package/src/EmailField.tsx +66 -0
- package/src/EmojiSelector.test.tsx +61 -0
- package/src/EmojiSelector.tsx +510 -0
- package/src/ErrorBoundary.tsx +37 -0
- package/src/ErrorPage.tsx +41 -0
- package/src/Field.tsx +101 -0
- package/src/FlatList.tsx +2 -0
- package/src/Heading.tsx +66 -0
- package/src/HeightActionSheet.tsx +91 -0
- package/src/Hyperlink.tsx +179 -0
- package/src/Icon.tsx +36 -0
- package/src/IconButton.tsx +217 -0
- package/src/Image.tsx +51 -0
- package/src/ImageBackground.tsx +14 -0
- package/src/InfoModalIcon.tsx +42 -0
- package/src/InfoTooltipButton.tsx +16 -0
- package/src/Link.tsx +22 -0
- package/src/MarkdownView.tsx +67 -0
- package/src/MediaQuery.ts +46 -0
- package/src/MobileAddressAutoComplete.tsx +126 -0
- package/src/Modal.tsx +300 -0
- package/src/ModalSheet.tsx +58 -0
- package/src/MultiselectField.tsx +112 -0
- package/src/NumberField.tsx +67 -0
- package/src/NumberPickerActionSheet.tsx +51 -0
- package/src/OpenAPIContext.tsx +74 -0
- package/src/Page.tsx +105 -0
- package/src/Pagination.tsx +169 -0
- package/src/PasswordField.tsx +7 -0
- package/src/Permissions.ts +43 -0
- package/src/PhoneNumberField.tsx +109 -0
- package/src/PickerSelect.tsx +571 -0
- package/src/Radio.tsx +33 -0
- package/src/RadioField.tsx +43 -0
- package/src/ScrollView.tsx +2 -0
- package/src/SectionDivider.tsx +18 -0
- package/src/SegmentedControl.tsx +126 -0
- package/src/SelectBadge.tsx +280 -0
- package/src/SelectField.tsx +41 -0
- package/src/SideDrawer.tsx +56 -0
- package/src/Signature.native.tsx +57 -0
- package/src/Signature.tsx +44 -0
- package/src/SignatureField.tsx +92 -0
- package/src/Slider.tsx +199 -0
- package/src/Spinner.tsx +35 -0
- package/src/SplitPage.native.tsx +163 -0
- package/src/SplitPage.tsx +304 -0
- package/src/TapToEdit.tsx +292 -0
- package/src/TerrenoProvider.tsx +31 -0
- package/src/Text.tsx +123 -0
- package/src/TextArea.test.tsx +255 -0
- package/src/TextArea.tsx +8 -0
- package/src/TextField.test.tsx +487 -0
- package/src/TextField.tsx +260 -0
- package/src/TextFieldNumberActionSheet.tsx +46 -0
- package/src/Theme.tsx +248 -0
- package/src/TimezonePicker.tsx +45 -0
- package/src/Toast.tsx +234 -0
- package/src/Tooltip.tsx +407 -0
- package/src/UnifiedAddressAutoComplete.tsx +66 -0
- package/src/Unifier.ts +172 -0
- package/src/Utilities.tsx +329 -0
- package/src/WebAddressAutocomplete.tsx +84 -0
- package/src/__snapshots__/Accordion.test.tsx.snap +126 -0
- package/src/__snapshots__/AddressField.test.tsx.snap +1197 -0
- package/src/__snapshots__/Avatar.test.tsx.snap +57 -0
- package/src/__snapshots__/Badge.test.tsx.snap +55 -0
- package/src/__snapshots__/Box.test.tsx.snap +162 -0
- package/src/__snapshots__/EmojiSelector.test.tsx.snap +422 -0
- package/src/__snapshots__/TextArea.test.tsx.snap +521 -0
- package/src/__snapshots__/TextField.test.tsx.snap +569 -0
- package/src/bunSetup.ts +1235 -0
- package/src/fieldElements/FieldError.tsx +24 -0
- package/src/fieldElements/FieldHelperText.tsx +20 -0
- package/src/fieldElements/FieldTitle.tsx +31 -0
- package/src/fieldElements/index.tsx +3 -0
- package/src/icons/MobileIcon.tsx +40 -0
- package/src/icons/OfflineIcon.tsx +37 -0
- package/src/icons/OnlineIcon.tsx +39 -0
- package/src/icons/OutOfficeIcon.tsx +36 -0
- package/src/icons/index.ts +4 -0
- package/src/index.tsx +1375 -0
- package/src/polyfill.d.ts +11 -0
- package/src/table/Table.tsx +109 -0
- package/src/table/TableBadge.tsx +46 -0
- package/src/table/TableBoolean.tsx +70 -0
- package/src/table/TableDate.tsx +38 -0
- package/src/table/TableHeader.tsx +20 -0
- package/src/table/TableHeaderCell.tsx +94 -0
- package/src/table/TableIconButton.tsx +61 -0
- package/src/table/TableNumber.tsx +29 -0
- package/src/table/TableRow.tsx +67 -0
- package/src/table/TableText.tsx +29 -0
- package/src/table/TableTitle.tsx +31 -0
- package/src/table/tableContext.tsx +67 -0
- package/src/test-utils.tsx +27 -0
- package/src/types/react-native-swiper-flatlist.d.ts +56 -0
- package/src/useStoredState.test.tsx +143 -0
- package/src/useStoredState.ts +56 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {type FC, useEffect, useState} from "react";
|
|
2
|
+
import {TouchableOpacity, View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {CheckBox} from "./CheckBox";
|
|
5
|
+
import type {MultiselectFieldProps} from "./Common";
|
|
6
|
+
import {FieldError, FieldHelperText} from "./fieldElements";
|
|
7
|
+
import {Heading} from "./Heading";
|
|
8
|
+
import {isMobileDevice} from "./MediaQuery";
|
|
9
|
+
import {Text} from "./Text";
|
|
10
|
+
|
|
11
|
+
interface OptionProps {
|
|
12
|
+
isDefault: boolean;
|
|
13
|
+
value: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
selected: boolean;
|
|
16
|
+
onSelect: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Option: FC<OptionProps> = ({value, label, isDefault, selected, onSelect}) => {
|
|
20
|
+
return (
|
|
21
|
+
<View
|
|
22
|
+
style={{
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: isDefault ? "row" : "row-reverse",
|
|
25
|
+
justifyContent: "space-between",
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<View style={{flex: 1, flexWrap: "wrap"}}>
|
|
29
|
+
<Text>{label ?? value}</Text>
|
|
30
|
+
</View>
|
|
31
|
+
<TouchableOpacity
|
|
32
|
+
accessibilityHint={`Select ${label ?? value} from list of options`}
|
|
33
|
+
aria-label={label ?? value}
|
|
34
|
+
aria-role="checkbox"
|
|
35
|
+
hitSlop={{bottom: 10, left: 10, right: 10, top: 10}}
|
|
36
|
+
key={value}
|
|
37
|
+
onPress={onSelect}
|
|
38
|
+
style={{
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<View
|
|
43
|
+
style={{
|
|
44
|
+
paddingEnd: isDefault ? 0 : 8,
|
|
45
|
+
paddingStart: isDefault ? 8 : 0,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<CheckBox selected={selected} />
|
|
49
|
+
</View>
|
|
50
|
+
</TouchableOpacity>
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const MultiselectField: FC<MultiselectFieldProps> = ({
|
|
56
|
+
options,
|
|
57
|
+
title,
|
|
58
|
+
value = [],
|
|
59
|
+
variant = "leftText",
|
|
60
|
+
onChange,
|
|
61
|
+
errorText,
|
|
62
|
+
helperText,
|
|
63
|
+
disabled,
|
|
64
|
+
}) => {
|
|
65
|
+
const isMobile = isMobileDevice();
|
|
66
|
+
const isDefault = variant === "leftText";
|
|
67
|
+
const [selectedItems, setSelectedItems] = useState<string[]>(value);
|
|
68
|
+
// set the selected items to the value passed in the props
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setSelectedItems(value);
|
|
71
|
+
}, [value]);
|
|
72
|
+
|
|
73
|
+
const toggleItem = (item: string) => {
|
|
74
|
+
const newSelectedItems = selectedItems.includes(item)
|
|
75
|
+
? selectedItems.filter((selected) => selected !== item)
|
|
76
|
+
: [...selectedItems, item];
|
|
77
|
+
setSelectedItems(newSelectedItems);
|
|
78
|
+
onChange(newSelectedItems);
|
|
79
|
+
};
|
|
80
|
+
return (
|
|
81
|
+
<View
|
|
82
|
+
accessibilityHint="Contains a prompt and list of options to select"
|
|
83
|
+
aria-label={title}
|
|
84
|
+
aria-role="combobox"
|
|
85
|
+
style={{
|
|
86
|
+
display: "flex",
|
|
87
|
+
gap: isMobile ? 16 : 8,
|
|
88
|
+
width: "100%",
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<Heading color="primary" size="sm">
|
|
92
|
+
{title}
|
|
93
|
+
</Heading>
|
|
94
|
+
{Boolean(errorText) && <FieldError text={errorText!} />}
|
|
95
|
+
{disabled ? (
|
|
96
|
+
<Text>{value.join(", ")}</Text>
|
|
97
|
+
) : (
|
|
98
|
+
options.map((option) => (
|
|
99
|
+
<Option
|
|
100
|
+
isDefault={isDefault}
|
|
101
|
+
key={option.key ?? option.value}
|
|
102
|
+
label={option.label}
|
|
103
|
+
onSelect={() => toggleItem(option.value)}
|
|
104
|
+
selected={selectedItems.includes(option.value)}
|
|
105
|
+
value={option.value}
|
|
106
|
+
/>
|
|
107
|
+
))
|
|
108
|
+
)}
|
|
109
|
+
{Boolean(helperText) && <FieldHelperText text={helperText!} />}
|
|
110
|
+
</View>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {type FC, useCallback, useEffect, useState} from "react";
|
|
2
|
+
|
|
3
|
+
import type {NumberFieldProps} from "./Common";
|
|
4
|
+
import {TextField} from "./TextField";
|
|
5
|
+
|
|
6
|
+
export const NumberField: FC<NumberFieldProps> = ({
|
|
7
|
+
errorText,
|
|
8
|
+
value: valueProp,
|
|
9
|
+
max,
|
|
10
|
+
min,
|
|
11
|
+
type,
|
|
12
|
+
onChange,
|
|
13
|
+
...rest
|
|
14
|
+
}: NumberFieldProps) => {
|
|
15
|
+
const [value, setValue] = useState(valueProp ?? "");
|
|
16
|
+
|
|
17
|
+
// Sync local state with incoming prop values
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setValue(valueProp ?? "");
|
|
20
|
+
}, [valueProp]);
|
|
21
|
+
|
|
22
|
+
const getError = useCallback(
|
|
23
|
+
(newV?: string) => {
|
|
24
|
+
const v = String(newV);
|
|
25
|
+
if (!v) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const num = type === "number" ? parseInt(v, 10) : parseFloat(v);
|
|
29
|
+
if (Number.isNaN(num) || (type === "number" && v.match(/[^0-9]/) !== null)) {
|
|
30
|
+
return "Value must be an integer";
|
|
31
|
+
} else if (
|
|
32
|
+
(type === "decimal" && v.match(/[^0-9.]+/) !== null) ||
|
|
33
|
+
(v.match(/\./g) || []).length > 1
|
|
34
|
+
) {
|
|
35
|
+
return "Value must be a decimal";
|
|
36
|
+
} else if (max !== undefined && num > max) {
|
|
37
|
+
return `Value must be less than or equal to ${max}`;
|
|
38
|
+
} else if (min !== undefined && num < min) {
|
|
39
|
+
return `Value must be greater than or equal to ${min}`;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
},
|
|
43
|
+
[max, min, type]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const error = errorText || getError(value);
|
|
47
|
+
|
|
48
|
+
// Only return the value if it is a valid number
|
|
49
|
+
const localOnChange = useCallback(
|
|
50
|
+
(v: string) => {
|
|
51
|
+
if (type === "decimal" && v === ".") {
|
|
52
|
+
// if type is decimal and dot is the first character add 0 before it
|
|
53
|
+
setValue("0.");
|
|
54
|
+
onChange("0.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const err = getError(v);
|
|
58
|
+
if (!err) {
|
|
59
|
+
setValue(v);
|
|
60
|
+
onChange(v);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[getError, onChange, type]
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return <TextField {...rest} errorText={error} onChange={localOnChange} value={value} />;
|
|
67
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {Picker} from "@react-native-picker/picker";
|
|
2
|
+
import range from "lodash/range";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
import {ActionSheet} from "./ActionSheet";
|
|
6
|
+
import {Box} from "./Box";
|
|
7
|
+
import {Button} from "./Button";
|
|
8
|
+
import type {NumberPickerActionSheetProps} from "./Common";
|
|
9
|
+
|
|
10
|
+
const PICKER_HEIGHT = 104;
|
|
11
|
+
|
|
12
|
+
type NumberPickerActionSheetState = {};
|
|
13
|
+
|
|
14
|
+
export class NumberPickerActionSheet extends React.Component<
|
|
15
|
+
NumberPickerActionSheetProps,
|
|
16
|
+
NumberPickerActionSheetState
|
|
17
|
+
> {
|
|
18
|
+
render() {
|
|
19
|
+
return (
|
|
20
|
+
<ActionSheet bounceOnOpen gestureEnabled ref={this.props.actionSheetRef}>
|
|
21
|
+
<Box marginBottom={8} paddingX={4} width="100%">
|
|
22
|
+
<Box alignItems="end" display="flex" width="100%">
|
|
23
|
+
<Box width="33%">
|
|
24
|
+
<Button
|
|
25
|
+
onClick={() => {
|
|
26
|
+
this.props.actionSheetRef?.current?.setModalVisible(false);
|
|
27
|
+
}}
|
|
28
|
+
text="Close"
|
|
29
|
+
/>
|
|
30
|
+
</Box>
|
|
31
|
+
</Box>
|
|
32
|
+
<Picker
|
|
33
|
+
itemStyle={{
|
|
34
|
+
height: PICKER_HEIGHT,
|
|
35
|
+
}}
|
|
36
|
+
onValueChange={(itemValue) => this.props.onChange(String(itemValue))}
|
|
37
|
+
selectedValue={String(this.props.value)}
|
|
38
|
+
style={{
|
|
39
|
+
backgroundColor: "#FFFFFF",
|
|
40
|
+
height: PICKER_HEIGHT,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{range(this.props.min, this.props.max).map((n) => (
|
|
44
|
+
<Picker.Item key={String(n)} label={String(n)} value={String(n)} />
|
|
45
|
+
))}
|
|
46
|
+
</Picker>
|
|
47
|
+
</Box>
|
|
48
|
+
</ActionSheet>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import camelCase from "lodash/camelCase";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import {createContext, useContext, useEffect, useState} from "react";
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
ModelFieldConfig,
|
|
7
|
+
ModelFields,
|
|
8
|
+
OpenAPIContextType,
|
|
9
|
+
OpenAPIProviderProps,
|
|
10
|
+
OpenAPISpec,
|
|
11
|
+
} from "./Common";
|
|
12
|
+
|
|
13
|
+
const OpenAPIContext = createContext<OpenAPIContextType | null>(null);
|
|
14
|
+
|
|
15
|
+
export const OpenAPIProvider = ({children, specUrl}: OpenAPIProviderProps): React.ReactElement => {
|
|
16
|
+
const [spec, setSpec] = useState<OpenAPISpec | null>(null);
|
|
17
|
+
|
|
18
|
+
const getModelFields = (modelName: string): ModelFields | null => {
|
|
19
|
+
const modelPath = `/${camelCase(modelName.replace(/\s/g, ""))}/`;
|
|
20
|
+
const rootConfig = spec?.paths?.[modelPath];
|
|
21
|
+
if (!rootConfig) {
|
|
22
|
+
if (spec?.paths && modelName) {
|
|
23
|
+
console.warn(`No OpenAPI model found for ${modelName}`);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return rootConfig?.get?.responses?.["200"]?.content?.["application/json"]?.schema?.properties
|
|
29
|
+
?.data?.items;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getModelField = (modelName: string, fieldName: string): ModelFieldConfig => {
|
|
33
|
+
const fields = getModelFields(modelName);
|
|
34
|
+
const dotFields = fieldName.split(".");
|
|
35
|
+
|
|
36
|
+
let field = fields?.properties?.[dotFields[0]];
|
|
37
|
+
if (!field && fieldName && fields?.properties) {
|
|
38
|
+
console.warn(`No OpenAPI field found for ${modelName}:${fieldName}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for (const dotField of dotFields.slice(1)) {
|
|
42
|
+
field = (field?.properties as any)?.[dotField];
|
|
43
|
+
}
|
|
44
|
+
return field;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Fetch the OpenAPI spec from the provided URL.
|
|
48
|
+
useEffect((): void => {
|
|
49
|
+
if (!specUrl) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fetch(specUrl)
|
|
54
|
+
.then(async (response) => {
|
|
55
|
+
const data = (await response.json()) as OpenAPISpec;
|
|
56
|
+
setSpec(data);
|
|
57
|
+
})
|
|
58
|
+
.catch((error: any) => console.error(`Error fetching OpenAPI spec: ${error}`));
|
|
59
|
+
}, [specUrl]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<OpenAPIContext.Provider value={{getModelField, getModelFields, spec}}>
|
|
63
|
+
{children}
|
|
64
|
+
</OpenAPIContext.Provider>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const useOpenAPISpec = () => {
|
|
69
|
+
const context = useContext(OpenAPIContext);
|
|
70
|
+
if (!context) {
|
|
71
|
+
throw new Error("useOpenAPISpec must be used within an OpenAPIProvider");
|
|
72
|
+
}
|
|
73
|
+
return context;
|
|
74
|
+
};
|
package/src/Page.tsx
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import {Box} from "./Box";
|
|
4
|
+
import {Button} from "./Button";
|
|
5
|
+
import type {PageProps} from "./Common";
|
|
6
|
+
import {ErrorBoundary} from "./ErrorBoundary";
|
|
7
|
+
import {Heading} from "./Heading";
|
|
8
|
+
import {IconButton} from "./IconButton";
|
|
9
|
+
import {Spinner} from "./Spinner";
|
|
10
|
+
|
|
11
|
+
export class Page extends React.Component<PageProps, {}> {
|
|
12
|
+
actionSheetRef: React.RefObject<any> = React.createRef();
|
|
13
|
+
|
|
14
|
+
renderHeader() {
|
|
15
|
+
if (!this.props.title && !this.props.backButton) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<Box direction="row" display="flex" width="100%">
|
|
20
|
+
{this.props.backButton && (
|
|
21
|
+
<Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
|
|
22
|
+
<IconButton
|
|
23
|
+
accessibilityHint="Navigate back"
|
|
24
|
+
accessibilityLabel=""
|
|
25
|
+
iconName="chevron-left"
|
|
26
|
+
onClick={() => this.props.navigation.goBack()}
|
|
27
|
+
/>
|
|
28
|
+
</Box>
|
|
29
|
+
)}
|
|
30
|
+
{this.props.closeButton && (
|
|
31
|
+
<Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
|
|
32
|
+
<IconButton
|
|
33
|
+
accessibilityHint="Close page"
|
|
34
|
+
accessibilityLabel=""
|
|
35
|
+
iconName="xmark"
|
|
36
|
+
onClick={() => this.props.navigation.goBack()}
|
|
37
|
+
/>
|
|
38
|
+
</Box>
|
|
39
|
+
)}
|
|
40
|
+
{Boolean(this.props.title) && (
|
|
41
|
+
<Box direction="column" display="flex" flex="grow" justifyContent="center">
|
|
42
|
+
<Heading align="center">{this.props.title}</Heading>
|
|
43
|
+
</Box>
|
|
44
|
+
)}
|
|
45
|
+
{this.props.rightButton && (
|
|
46
|
+
<Box alignItems="center" display="block" justifyContent="center" paddingY={3}>
|
|
47
|
+
<Button
|
|
48
|
+
onClick={() => this.props.rightButtonOnClick?.()}
|
|
49
|
+
text={this.props.rightButton}
|
|
50
|
+
variant="muted"
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
)}
|
|
54
|
+
</Box>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render() {
|
|
59
|
+
return (
|
|
60
|
+
<ErrorBoundary onError={this.props.onError}>
|
|
61
|
+
<Box
|
|
62
|
+
alignSelf="center"
|
|
63
|
+
avoidKeyboard
|
|
64
|
+
color={this.props.color || "base"}
|
|
65
|
+
direction={this.props.direction || "column"}
|
|
66
|
+
display={this.props.display || "flex"}
|
|
67
|
+
flex="grow"
|
|
68
|
+
height="100%"
|
|
69
|
+
keyboardOffset={this.props.keyboardOffset}
|
|
70
|
+
maxWidth={this.props.maxWidth || 800}
|
|
71
|
+
padding={this.props.padding !== undefined ? this.props.padding : 2}
|
|
72
|
+
scroll={this.props.scroll === undefined ? true : this.props.scroll}
|
|
73
|
+
width="100%"
|
|
74
|
+
>
|
|
75
|
+
{this.renderHeader()}
|
|
76
|
+
{this.props.loading === true && <Spinner />}
|
|
77
|
+
{/* <KeyboardAccessoryNavigation
|
|
78
|
+
avoidKeyboard
|
|
79
|
+
doneButton={true}
|
|
80
|
+
nextButton={true}
|
|
81
|
+
previousButton={true}
|
|
82
|
+
/> */}
|
|
83
|
+
|
|
84
|
+
{this.props.children}
|
|
85
|
+
</Box>
|
|
86
|
+
{Boolean(this.props.footer) && (
|
|
87
|
+
<Box
|
|
88
|
+
alignSelf="center"
|
|
89
|
+
color={this.props.color || "neutralLight"}
|
|
90
|
+
direction={this.props.direction || "column"}
|
|
91
|
+
display={this.props.display || "flex"}
|
|
92
|
+
flex="shrink"
|
|
93
|
+
marginBottom={8}
|
|
94
|
+
maxWidth={this.props.maxWidth || 800}
|
|
95
|
+
paddingX={this.props.padding !== undefined ? this.props.padding : 6}
|
|
96
|
+
paddingY={this.props.padding !== undefined ? this.props.padding : 2}
|
|
97
|
+
width="100%"
|
|
98
|
+
>
|
|
99
|
+
{this.props.footer}
|
|
100
|
+
</Box>
|
|
101
|
+
)}
|
|
102
|
+
</ErrorBoundary>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {type FC, useMemo} from "react";
|
|
2
|
+
import {Pressable, View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {IconName, PaginationProps} from "./Common";
|
|
5
|
+
import {Icon} from "./Icon";
|
|
6
|
+
import {Text} from "./Text";
|
|
7
|
+
import {useTheme} from "./Theme";
|
|
8
|
+
|
|
9
|
+
const PaginationButton: FC<{
|
|
10
|
+
type: "first" | "prev" | "next" | "last" | "more";
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
totalPages?: number;
|
|
13
|
+
page?: number;
|
|
14
|
+
}> = ({type, onClick, totalPages = 1, page = 1}) => {
|
|
15
|
+
let icon: IconName;
|
|
16
|
+
let disabled = false;
|
|
17
|
+
|
|
18
|
+
if (type === "prev") {
|
|
19
|
+
icon = "angle-left";
|
|
20
|
+
disabled = page <= 1;
|
|
21
|
+
} else if (type === "next") {
|
|
22
|
+
icon = "angle-right";
|
|
23
|
+
disabled = page >= totalPages;
|
|
24
|
+
} else if (type === "more") {
|
|
25
|
+
icon = "ellipsis";
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error(`Invalid Pagination Button type ${type}`);
|
|
28
|
+
}
|
|
29
|
+
// TODO: Show text input when tapping more.
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Pressable
|
|
33
|
+
accessibilityHint={`Click to go to ${type} page`}
|
|
34
|
+
aria-label="Pagination Button"
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
onPress={onClick}
|
|
37
|
+
style={{
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
display: "flex",
|
|
40
|
+
height: 32,
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
width: 32,
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<Icon color={disabled ? "extraLight" : "primary"} iconName={icon} size="md" />
|
|
46
|
+
</Pressable>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const PaginationNumber: FC<{
|
|
51
|
+
number: number | "more";
|
|
52
|
+
current: boolean;
|
|
53
|
+
onClick: () => void;
|
|
54
|
+
}> = ({number, current, onClick}) => {
|
|
55
|
+
// Shortcut to make rendering the number buttons easier.
|
|
56
|
+
if (number === "more") {
|
|
57
|
+
return <PaginationButton onClick={() => {}} type="more" />;
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<Pressable
|
|
61
|
+
accessibilityHint={`Click to go to page ${number}`}
|
|
62
|
+
accessibilityLabel="Pagination Number"
|
|
63
|
+
onPress={onClick}
|
|
64
|
+
style={{
|
|
65
|
+
alignItems: "center",
|
|
66
|
+
borderRadius: 4,
|
|
67
|
+
display: "flex",
|
|
68
|
+
height: 32,
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
width: 32,
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<Text color={current ? "accent" : "primary"}>{number}</Text>
|
|
74
|
+
</Pressable>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const Pagination: FC<PaginationProps> = ({totalPages, page, setPage}) => {
|
|
79
|
+
const {theme} = useTheme();
|
|
80
|
+
|
|
81
|
+
// Determine the number of pages to show. Show the first page,
|
|
82
|
+
// the page before and after the current page, and the last page.
|
|
83
|
+
const pages: (number | "more")[] = useMemo(() => {
|
|
84
|
+
const pagesResult: (number | "more")[] = [];
|
|
85
|
+
|
|
86
|
+
if (totalPages < 6) {
|
|
87
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
88
|
+
pagesResult.push(i);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
pagesResult.push(1);
|
|
92
|
+
|
|
93
|
+
if (page > 3) {
|
|
94
|
+
pagesResult.push("more");
|
|
95
|
+
} else {
|
|
96
|
+
pagesResult.push(2);
|
|
97
|
+
pagesResult.push(3);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// This is to help sort the last few numbers of the total pages behind the current page.
|
|
101
|
+
if (page > totalPages - 2 && !pagesResult.includes(totalPages - 2)) {
|
|
102
|
+
pagesResult.push(totalPages - 2);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (page > totalPages - 1 && !pagesResult.includes(totalPages - 1)) {
|
|
106
|
+
pagesResult.push(totalPages - 1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!pagesResult.includes(page)) {
|
|
110
|
+
pagesResult.push(page);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (page < totalPages - 2) {
|
|
114
|
+
pagesResult.push("more");
|
|
115
|
+
} else if (page !== totalPages && !pagesResult.includes(totalPages - 1)) {
|
|
116
|
+
pagesResult.push(totalPages - 1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!pagesResult.includes(totalPages)) {
|
|
120
|
+
pagesResult.push(totalPages);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return pagesResult;
|
|
124
|
+
}, [page, totalPages]);
|
|
125
|
+
|
|
126
|
+
// TODO: Add hover for pagination numbers.
|
|
127
|
+
|
|
128
|
+
if (!pages) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
return (
|
|
132
|
+
<View
|
|
133
|
+
style={{
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
display: "flex",
|
|
136
|
+
flexDirection: "row",
|
|
137
|
+
gap: theme.spacing.xs as any,
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<PaginationButton
|
|
141
|
+
onClick={() => {
|
|
142
|
+
if (page > 1) {
|
|
143
|
+
setPage(page - 1);
|
|
144
|
+
}
|
|
145
|
+
}}
|
|
146
|
+
page={page}
|
|
147
|
+
totalPages={totalPages}
|
|
148
|
+
type="prev"
|
|
149
|
+
/>
|
|
150
|
+
{pages.map((number, index) => (
|
|
151
|
+
<PaginationNumber
|
|
152
|
+
current={number === page}
|
|
153
|
+
key={number === "more" ? `more${index}` : number}
|
|
154
|
+
number={number}
|
|
155
|
+
onClick={() => setPage(number as number)}
|
|
156
|
+
/>
|
|
157
|
+
))}
|
|
158
|
+
|
|
159
|
+
<PaginationButton
|
|
160
|
+
onClick={() => {
|
|
161
|
+
setPage(page + 1);
|
|
162
|
+
}}
|
|
163
|
+
page={page}
|
|
164
|
+
totalPages={totalPages}
|
|
165
|
+
type="next"
|
|
166
|
+
/>
|
|
167
|
+
</View>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// import {Tracking} from "./Tracking";
|
|
2
|
+
// import capitalize from "lodash/capitalize";
|
|
3
|
+
// import Permissions from "react-native-permissions";
|
|
4
|
+
import type {PermissionKind, PermissionStatus} from "./Common";
|
|
5
|
+
|
|
6
|
+
export async function requestPermissions(_kind: PermissionKind): Promise<PermissionStatus> {
|
|
7
|
+
return new Promise((_resolve, _reject) => {
|
|
8
|
+
return "denied";
|
|
9
|
+
});
|
|
10
|
+
// const userPropertyKey = `PermissionsFor${capitalize(kind)}`;
|
|
11
|
+
|
|
12
|
+
// let k = kind;
|
|
13
|
+
// let options: any = undefined;
|
|
14
|
+
// if (kind === "locationAlways") {
|
|
15
|
+
// k = "location";
|
|
16
|
+
// options = { type: "always" };
|
|
17
|
+
// }
|
|
18
|
+
// if (Platform.OS === "android" && k === "notification") {
|
|
19
|
+
// return;
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
// // TODO check soft request status.
|
|
23
|
+
|
|
24
|
+
// const current = await Permissions.check(MAP[k] as any);
|
|
25
|
+
// // Tracking.log(`[permissions] ${k} permissions are ${current}`);
|
|
26
|
+
// if (current === "denied" || current === "limited") {
|
|
27
|
+
// // Tracking.setUserProperty(userPropertyKey, "false");
|
|
28
|
+
// return reject(MAP_RESULTS[current]);
|
|
29
|
+
// } else if (current === "granted") {
|
|
30
|
+
// // Tracking.setUserProperty(userPropertyKey, "true");
|
|
31
|
+
// return resolve("authorized");
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// const response = await Permissions.request(MAP[k] as any, options);
|
|
35
|
+
// if (response === "granted") {
|
|
36
|
+
// // Tracking.setUserProperty(userPropertyKey, "true");
|
|
37
|
+
// return resolve("authorized");
|
|
38
|
+
// } else {
|
|
39
|
+
// // Tracking.setUserProperty(userPropertyKey, "false");
|
|
40
|
+
// return reject(MAP_RESULTS[response]);
|
|
41
|
+
// }
|
|
42
|
+
// });
|
|
43
|
+
}
|