@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,109 @@
|
|
|
1
|
+
import React, {Children, type ReactElement, useEffect} from "react";
|
|
2
|
+
import {ScrollView} from "react-native";
|
|
3
|
+
import type {DimensionValue} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
4
|
+
|
|
5
|
+
import {Box} from "../Box";
|
|
6
|
+
import type {ColumnSortInterface, TableProps, TableRowProps} from "../Common";
|
|
7
|
+
import {Pagination} from "../Pagination";
|
|
8
|
+
import {TableContextProvider} from "./tableContext";
|
|
9
|
+
|
|
10
|
+
export const Table = ({
|
|
11
|
+
children,
|
|
12
|
+
columns, // see notes in common about table columns width and decide if we need to change this to a more specific type 'size'
|
|
13
|
+
borderStyle,
|
|
14
|
+
alternateRowBackground = true,
|
|
15
|
+
maxHeight,
|
|
16
|
+
stickyHeader = true,
|
|
17
|
+
sort,
|
|
18
|
+
page: propsPage,
|
|
19
|
+
setPage: propsSetPage,
|
|
20
|
+
totalPages,
|
|
21
|
+
more,
|
|
22
|
+
extraControls,
|
|
23
|
+
}: TableProps): React.ReactElement => {
|
|
24
|
+
const arrayChildren = Children.toArray(children);
|
|
25
|
+
|
|
26
|
+
// Check if any of the rows below have a drawerContents prop to see if we need to render space
|
|
27
|
+
// for the caret.
|
|
28
|
+
const [sortColumn, setSortColumn] = React.useState<ColumnSortInterface | undefined>(sort);
|
|
29
|
+
const [page, setPage] = React.useState<number>(propsPage ?? 1);
|
|
30
|
+
// Check if any of the rows below have a drawerContents prop to see if we need to render space
|
|
31
|
+
// for the caret.
|
|
32
|
+
const hasDrawerContents = arrayChildren.some((child) => {
|
|
33
|
+
return (child as ReactElement<TableRowProps>).props?.drawerContents;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Calculate the total width of the table. If the table has only number widths, calculate a
|
|
37
|
+
// width. Otherwise use 100%.
|
|
38
|
+
let width: DimensionValue;
|
|
39
|
+
if (columns.every((column) => typeof column === "number")) {
|
|
40
|
+
width = columns.reduce((acc, curr) => {
|
|
41
|
+
return (acc as number) + (curr as number) + 8; // 8 for margin between columns;
|
|
42
|
+
}, 0) as number;
|
|
43
|
+
if (hasDrawerContents) {
|
|
44
|
+
// Size of IconButton + padding is 56
|
|
45
|
+
width = (width as number) + 56;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
width = "100%";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// If propsPage changes in the parent, update the local page state.
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (propsPage && propsPage !== page) {
|
|
54
|
+
setPage(propsPage);
|
|
55
|
+
}
|
|
56
|
+
}, [page, propsPage]);
|
|
57
|
+
|
|
58
|
+
const shouldPaginate = more || page > 1;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<TableContextProvider
|
|
62
|
+
alternateRowBackground={alternateRowBackground}
|
|
63
|
+
borderStyle={borderStyle}
|
|
64
|
+
columns={columns}
|
|
65
|
+
hasDrawerContents={hasDrawerContents}
|
|
66
|
+
page={page}
|
|
67
|
+
setSortColumn={setSortColumn}
|
|
68
|
+
sortColumn={sortColumn}
|
|
69
|
+
stickyHeader={stickyHeader}
|
|
70
|
+
>
|
|
71
|
+
<Box
|
|
72
|
+
flex="grow"
|
|
73
|
+
maxWidth="100%"
|
|
74
|
+
style={{
|
|
75
|
+
position: "relative",
|
|
76
|
+
}}
|
|
77
|
+
width={width}
|
|
78
|
+
>
|
|
79
|
+
<ScrollView horizontal style={{maxWidth: "100%", width}}>
|
|
80
|
+
{/* TODO: Replace table scrollview with flat list */}
|
|
81
|
+
<ScrollView
|
|
82
|
+
// nestedScrollEnabled
|
|
83
|
+
stickyHeaderIndices={stickyHeader ? [0] : undefined}
|
|
84
|
+
style={{flex: 1, maxHeight, maxWidth: "100%", width}}
|
|
85
|
+
>
|
|
86
|
+
{Children.map(
|
|
87
|
+
children,
|
|
88
|
+
(child, index) =>
|
|
89
|
+
Boolean(child) &&
|
|
90
|
+
React.cloneElement(child as ReactElement<TableRowProps>, {
|
|
91
|
+
color: index % 2 === 1 && alternateRowBackground ? "neutralLight" : "base",
|
|
92
|
+
})
|
|
93
|
+
)}
|
|
94
|
+
</ScrollView>
|
|
95
|
+
</ScrollView>
|
|
96
|
+
</Box>
|
|
97
|
+
{Boolean(shouldPaginate && totalPages !== undefined) && (
|
|
98
|
+
<Box alignItems="center" borderTop="default" direction="row" height={60} paddingX={8}>
|
|
99
|
+
<Pagination
|
|
100
|
+
page={propsPage ?? page}
|
|
101
|
+
setPage={propsSetPage ?? setPage}
|
|
102
|
+
totalPages={totalPages!}
|
|
103
|
+
/>
|
|
104
|
+
{Boolean(extraControls) && extraControls}
|
|
105
|
+
</Box>
|
|
106
|
+
)}
|
|
107
|
+
</TableContextProvider>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {type FC, useState} from "react";
|
|
2
|
+
import {View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {Badge} from "../Badge";
|
|
5
|
+
import type {TableBadgeProps} from "../Common";
|
|
6
|
+
import {SelectField} from "../SelectField";
|
|
7
|
+
|
|
8
|
+
export interface TableBadgeHandles {
|
|
9
|
+
handleSave: () => void | Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// TODO: Support error state in TableBadge
|
|
13
|
+
export const TableBadge: FC<TableBadgeProps> = ({
|
|
14
|
+
value,
|
|
15
|
+
badgeStatus = "info",
|
|
16
|
+
badgeIconName,
|
|
17
|
+
isEditing = false,
|
|
18
|
+
editingOptions,
|
|
19
|
+
}) => {
|
|
20
|
+
const [selected, setSelected] = useState<string | undefined>(value);
|
|
21
|
+
|
|
22
|
+
const handleChange = (newVal: string | undefined) => {
|
|
23
|
+
if (newVal === "") {
|
|
24
|
+
setSelected(undefined);
|
|
25
|
+
} else {
|
|
26
|
+
setSelected(newVal);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
style={{
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{isEditing && editingOptions ? (
|
|
38
|
+
<SelectField onChange={handleChange} options={editingOptions} value={selected} />
|
|
39
|
+
) : (
|
|
40
|
+
<Badge iconName={badgeIconName} secondary status={badgeStatus} value={value} />
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
TableBadge.displayName = "TableBadge";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {type FC, useCallback, useState} from "react";
|
|
2
|
+
import {TouchableOpacity, View, type ViewStyle} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {CheckBox} from "../CheckBox";
|
|
5
|
+
import type {TableBooleanProps} from "../Common";
|
|
6
|
+
import {Icon} from "../Icon";
|
|
7
|
+
import {useTheme} from "../Theme";
|
|
8
|
+
|
|
9
|
+
export interface TableBooleanHandles {
|
|
10
|
+
handleSave: () => void | Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const TableBoolean: FC<TableBooleanProps> = ({value, isEditing = false}) => {
|
|
14
|
+
const [checked, setChecked] = useState(value);
|
|
15
|
+
const {theme} = useTheme();
|
|
16
|
+
const valueString = checked ? "checked" : "unchecked";
|
|
17
|
+
const oppositeValueString = checked ? "unchecked" : "checked";
|
|
18
|
+
|
|
19
|
+
const handlePress = useCallback(() => {
|
|
20
|
+
setChecked(!checked);
|
|
21
|
+
}, [checked]);
|
|
22
|
+
|
|
23
|
+
if (isEditing) {
|
|
24
|
+
return (
|
|
25
|
+
<TouchableOpacity
|
|
26
|
+
accessibilityHint={`Tap to change the checkbox from ${oppositeValueString} to ${valueString}`}
|
|
27
|
+
aria-label={`Checkbox is currently ${valueString}`}
|
|
28
|
+
aria-role="checkbox"
|
|
29
|
+
hitSlop={{bottom: 10, left: 10, right: 10, top: 10}}
|
|
30
|
+
onPress={handlePress}
|
|
31
|
+
style={
|
|
32
|
+
{
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
} as ViewStyle
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
<CheckBox selected={checked} size="lg" />
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
);
|
|
41
|
+
} else {
|
|
42
|
+
return (
|
|
43
|
+
<View
|
|
44
|
+
style={{
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
width: "100%",
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<View
|
|
51
|
+
accessibilityHint={value ? "Checked icon" : "Unchecked icon"}
|
|
52
|
+
aria-label={`The checkbox is ${valueString}`}
|
|
53
|
+
aria-role="image"
|
|
54
|
+
style={{
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
backgroundColor: value ? theme.surface.successLight : "transparent",
|
|
57
|
+
borderRadius: 16,
|
|
58
|
+
height: 32,
|
|
59
|
+
justifyContent: "center",
|
|
60
|
+
width: 32,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<Icon color={value ? "success" : "error"} iconName={value ? "check" : "x"} />
|
|
64
|
+
</View>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
TableBoolean.displayName = "TableBoolean";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
2
|
+
import {type FC, useState} from "react";
|
|
3
|
+
import {Text} from "react-native";
|
|
4
|
+
|
|
5
|
+
import type {TableDateProps} from "../Common";
|
|
6
|
+
|
|
7
|
+
export const TableDate: FC<TableDateProps> = ({value, annotated = false}) => {
|
|
8
|
+
const initialDate =
|
|
9
|
+
typeof value === "string" ? DateTime.fromISO(value) : DateTime.fromJSDate(value);
|
|
10
|
+
const [dateVal] = useState(initialDate);
|
|
11
|
+
|
|
12
|
+
// TODO: Formatting date with annotations should be in DateUtilities and tested.
|
|
13
|
+
const formatDate = (date: DateTime) => {
|
|
14
|
+
const now = DateTime.now();
|
|
15
|
+
const diff = now.diff(date, ["years", "months", "days"]).toObject();
|
|
16
|
+
|
|
17
|
+
let diffString = "";
|
|
18
|
+
if (diff.years) {
|
|
19
|
+
diffString += `${Math.floor(diff.years)} Year${Math.floor(diff.years) > 1 ? "s" : ""} `;
|
|
20
|
+
}
|
|
21
|
+
if (diff.months) {
|
|
22
|
+
diffString += `${Math.floor(diff.months)} Mo${Math.floor(diff.months) > 1 ? "s" : ""} `;
|
|
23
|
+
}
|
|
24
|
+
if (diff.days) {
|
|
25
|
+
diffString += `${Math.floor(diff.days)} Day${Math.floor(diff.days) > 1 ? "s" : ""}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return `${date.toFormat("MM/dd/yyyy")} (${diffString.trim()})`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Text style={{fontSize: 16}}>
|
|
33
|
+
{annotated ? formatDate(dateVal) : dateVal.toFormat("MM/dd/yyyy")}
|
|
34
|
+
</Text>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
TableDate.displayName = "TableDate";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
|
|
3
|
+
import {Box} from "../Box";
|
|
4
|
+
import type {TableHeaderProps} from "../Common";
|
|
5
|
+
import {TableRow} from "./TableRow";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Use TableHeader to group the header content in Table.
|
|
9
|
+
*/
|
|
10
|
+
export const TableHeader = ({
|
|
11
|
+
children,
|
|
12
|
+
display = "tableHeaderGroup",
|
|
13
|
+
color,
|
|
14
|
+
}: TableHeaderProps): React.ReactElement => {
|
|
15
|
+
return (
|
|
16
|
+
<Box color={color ?? "base"} display={display === "visuallyHidden" ? "none" : "flex"}>
|
|
17
|
+
<TableRow headerRow>{children}</TableRow>
|
|
18
|
+
</Box>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// TableHeaderCell.tsx
|
|
2
|
+
import {FontAwesome6} from "@expo/vector-icons";
|
|
3
|
+
import {type ReactElement, useCallback} from "react";
|
|
4
|
+
import {View} from "react-native";
|
|
5
|
+
|
|
6
|
+
import {Box} from "../Box";
|
|
7
|
+
import type {AlignItems, TableHeaderCellProps} from "../Common";
|
|
8
|
+
import {useTheme} from "../Theme";
|
|
9
|
+
import {TableTitle} from "./TableTitle";
|
|
10
|
+
import {useTableContext} from "./tableContext";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Use TableHeaderCell to define a header cell in Table.
|
|
14
|
+
*/
|
|
15
|
+
export const TableHeaderCell = ({
|
|
16
|
+
children,
|
|
17
|
+
index,
|
|
18
|
+
sortable,
|
|
19
|
+
align = "left",
|
|
20
|
+
title,
|
|
21
|
+
onSortChange,
|
|
22
|
+
}: TableHeaderCellProps): ReactElement => {
|
|
23
|
+
const {theme} = useTheme();
|
|
24
|
+
|
|
25
|
+
const {columns, setSortColumn, sortColumn} = useTableContext();
|
|
26
|
+
const width = columns[index];
|
|
27
|
+
if (!width) {
|
|
28
|
+
console.warn(`No width defined for column ${index} in TableHeaderCell`);
|
|
29
|
+
}
|
|
30
|
+
if (children && title) {
|
|
31
|
+
console.warn("Both children and title are defined in TableHeaderCell. Title will be ignored.");
|
|
32
|
+
}
|
|
33
|
+
if (!children && !title) {
|
|
34
|
+
console.error("Either children or title is required in TableHeaderCell");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const sort = sortColumn?.column === index ? sortColumn.direction : undefined;
|
|
38
|
+
let alignItems: AlignItems = "start";
|
|
39
|
+
if (align === "center") {
|
|
40
|
+
alignItems = "center";
|
|
41
|
+
} else if (align === "right") {
|
|
42
|
+
alignItems = "end";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const onClick = useCallback(() => {
|
|
46
|
+
// desc => asc => undefined
|
|
47
|
+
const newSort = sort === "desc" ? "asc" : sort === "asc" ? undefined : "desc";
|
|
48
|
+
if (setSortColumn) {
|
|
49
|
+
setSortColumn(newSort ? {column: index, direction: newSort} : undefined);
|
|
50
|
+
}
|
|
51
|
+
onSortChange?.(newSort);
|
|
52
|
+
}, [index, onSortChange, setSortColumn, sort]);
|
|
53
|
+
|
|
54
|
+
if (sortable && !onSortChange) {
|
|
55
|
+
console.error("onSortChange is required when sortable is true");
|
|
56
|
+
}
|
|
57
|
+
return (
|
|
58
|
+
<Box
|
|
59
|
+
accessibilityHint="changes sort alphabetical order"
|
|
60
|
+
accessibilityLabel="sort"
|
|
61
|
+
alignItems="center"
|
|
62
|
+
direction="row"
|
|
63
|
+
flex="grow"
|
|
64
|
+
justifyContent={alignItems}
|
|
65
|
+
onClick={sortable ? onClick : undefined}
|
|
66
|
+
>
|
|
67
|
+
{Boolean(children) && children}
|
|
68
|
+
{Boolean(title) && <TableTitle align={align} title={title!} />}
|
|
69
|
+
{Boolean(sort) && (
|
|
70
|
+
<Box alignSelf="end" paddingX={2}>
|
|
71
|
+
{/* Make it look like an IconButton, but we can't nest buttons and the whole row is clickable. */}
|
|
72
|
+
<View
|
|
73
|
+
style={{
|
|
74
|
+
alignItems: "center",
|
|
75
|
+
backgroundColor: theme.surface.primary,
|
|
76
|
+
borderRadius: theme.radius.rounded as any,
|
|
77
|
+
height: 16,
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
width: 16,
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<FontAwesome6
|
|
83
|
+
color={theme.text.inverted}
|
|
84
|
+
name={sort === "asc" ? "arrow-down" : "arrow-up"}
|
|
85
|
+
selectable={undefined}
|
|
86
|
+
size={10}
|
|
87
|
+
solid
|
|
88
|
+
/>
|
|
89
|
+
</View>
|
|
90
|
+
</Box>
|
|
91
|
+
)}
|
|
92
|
+
</Box>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// accessibility hint handled in IconButton.tsx
|
|
2
|
+
|
|
3
|
+
import type {FC} from "react";
|
|
4
|
+
import {View} from "react-native";
|
|
5
|
+
|
|
6
|
+
import type {IconButtonProps, IconName, TableIconButtonProps} from "../Common";
|
|
7
|
+
import {IconButton} from "../IconButton";
|
|
8
|
+
|
|
9
|
+
export const TableIconButton: FC<TableIconButtonProps> = ({tableIconButtonName, onClick}) => {
|
|
10
|
+
const iconButtonMap: Record<
|
|
11
|
+
string,
|
|
12
|
+
{
|
|
13
|
+
iconName: IconName;
|
|
14
|
+
variant: IconButtonProps["variant"];
|
|
15
|
+
accessibilityLabel: string;
|
|
16
|
+
accessibilityHint: string;
|
|
17
|
+
}
|
|
18
|
+
> = {
|
|
19
|
+
drawerClose: {
|
|
20
|
+
accessibilityHint: "Close Drawer",
|
|
21
|
+
accessibilityLabel: "Close Drawer for more Data",
|
|
22
|
+
iconName: "chevron-up",
|
|
23
|
+
variant: "secondary",
|
|
24
|
+
},
|
|
25
|
+
drawerOpen: {
|
|
26
|
+
accessibilityHint: "Open Drawer",
|
|
27
|
+
accessibilityLabel: "Open Drawer for more Data",
|
|
28
|
+
iconName: "chevron-down",
|
|
29
|
+
variant: "muted",
|
|
30
|
+
},
|
|
31
|
+
edit: {
|
|
32
|
+
accessibilityHint: "Edit row",
|
|
33
|
+
accessibilityLabel: "Edit",
|
|
34
|
+
iconName: "pen-to-square",
|
|
35
|
+
variant: "muted",
|
|
36
|
+
},
|
|
37
|
+
insert: {
|
|
38
|
+
accessibilityHint: "Insert Data",
|
|
39
|
+
accessibilityLabel: "Insert Data",
|
|
40
|
+
iconName: "plus",
|
|
41
|
+
variant: "primary",
|
|
42
|
+
},
|
|
43
|
+
saveAndClose: {
|
|
44
|
+
accessibilityHint: "Save and close row",
|
|
45
|
+
accessibilityLabel: "Save and close",
|
|
46
|
+
iconName: "check",
|
|
47
|
+
variant: "secondary",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View style={{alignItems: "center", justifyContent: "center", width: "100%"}}>
|
|
53
|
+
<IconButton
|
|
54
|
+
accessibilityLabel={iconButtonMap[tableIconButtonName].accessibilityLabel}
|
|
55
|
+
iconName={iconButtonMap[tableIconButtonName].iconName}
|
|
56
|
+
onClick={onClick}
|
|
57
|
+
variant={iconButtonMap[tableIconButtonName].variant}
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type {FC} from "react";
|
|
2
|
+
import {Text} from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {TableNumberProps} from "../Common";
|
|
5
|
+
import {useTheme} from "../Theme";
|
|
6
|
+
|
|
7
|
+
// TODO: Implement isEditing to TableNumber
|
|
8
|
+
export const TableNumber: FC<TableNumberProps> = ({isEditing, value, align = "right"}) => {
|
|
9
|
+
const {theme} = useTheme();
|
|
10
|
+
|
|
11
|
+
if (isEditing) {
|
|
12
|
+
console.warn("isEditing is not implemented yet.");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Text
|
|
17
|
+
style={{
|
|
18
|
+
color: theme.text.primary,
|
|
19
|
+
fontFamily: "text",
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
textAlign: align,
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{value}
|
|
25
|
+
</Text>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
TableNumber.displayName = "TableNumber";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, {Children, useRef} from "react";
|
|
2
|
+
|
|
3
|
+
import {Box} from "../Box";
|
|
4
|
+
import type {TableRowProps} from "../Common";
|
|
5
|
+
import {IconButton} from "../IconButton";
|
|
6
|
+
import {useTableContext} from "./tableContext";
|
|
7
|
+
|
|
8
|
+
const TableCell = ({children, index}: {children: React.ReactNode; index: number}) => {
|
|
9
|
+
const {columns} = useTableContext();
|
|
10
|
+
return (
|
|
11
|
+
<Box justifyContent="center" marginRight={2} paddingX={3} paddingY={4} width={columns[index]}>
|
|
12
|
+
{children}
|
|
13
|
+
</Box>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Use TableRow to define a row in Table.
|
|
19
|
+
*/
|
|
20
|
+
export const TableRow = ({
|
|
21
|
+
children,
|
|
22
|
+
headerRow = false,
|
|
23
|
+
expanded,
|
|
24
|
+
drawerContents,
|
|
25
|
+
color = "base",
|
|
26
|
+
}: TableRowProps): React.ReactElement => {
|
|
27
|
+
const [isExpanded, setIsExpanded] = React.useState(expanded || false);
|
|
28
|
+
const {hasDrawerContents} = useTableContext();
|
|
29
|
+
const rowRef = useRef<typeof Box>(null);
|
|
30
|
+
|
|
31
|
+
const border = {__style: {borderBottom: `${headerRow ? 2 : 1}px solid #e0e0e0`}};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Box color={color} dangerouslySetInlineStyle={border} ref={rowRef} width="100%">
|
|
35
|
+
<Box direction="row" paddingY={1} width="100%">
|
|
36
|
+
{Boolean(drawerContents) && (
|
|
37
|
+
<TableCell index={-1}>
|
|
38
|
+
{/* TODO: The expand table button doesn't exactly line up with the designs */}
|
|
39
|
+
<IconButton
|
|
40
|
+
accessibilityHint="press to expand"
|
|
41
|
+
accessibilityLabel="expand"
|
|
42
|
+
iconName={isExpanded ? "chevron-up" : "chevron-down"}
|
|
43
|
+
onClick={() => {
|
|
44
|
+
setIsExpanded(!isExpanded);
|
|
45
|
+
}}
|
|
46
|
+
variant="secondary"
|
|
47
|
+
/>
|
|
48
|
+
</TableCell>
|
|
49
|
+
)}
|
|
50
|
+
{/* Still render a blank space so the columns line up. */}
|
|
51
|
+
{Boolean(hasDrawerContents && !drawerContents) && (
|
|
52
|
+
<TableCell index={-1}>
|
|
53
|
+
<Box width={32} />
|
|
54
|
+
</TableCell>
|
|
55
|
+
)}
|
|
56
|
+
{Children.map(children, (child, index) => (
|
|
57
|
+
<TableCell index={index}>{child}</TableCell>
|
|
58
|
+
))}
|
|
59
|
+
</Box>
|
|
60
|
+
{Boolean(isExpanded) && (
|
|
61
|
+
<Box paddingX={2} width="100%">
|
|
62
|
+
{drawerContents}
|
|
63
|
+
</Box>
|
|
64
|
+
)}
|
|
65
|
+
</Box>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type {FC} from "react";
|
|
2
|
+
import {Text} from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {TableTextProps} from "../Common";
|
|
5
|
+
import {useTheme} from "../Theme";
|
|
6
|
+
|
|
7
|
+
// TODO: Implement isEditing to TableText
|
|
8
|
+
export const TableText: FC<TableTextProps> = ({isEditing, value, align}) => {
|
|
9
|
+
const {theme} = useTheme();
|
|
10
|
+
|
|
11
|
+
if (isEditing) {
|
|
12
|
+
console.warn("isEditing is not implemented yet.");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Text
|
|
17
|
+
style={{
|
|
18
|
+
color: theme.text.primary,
|
|
19
|
+
fontFamily: "text",
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
textAlign: align,
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
{value}
|
|
25
|
+
</Text>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
TableText.displayName = "TableText";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {FC} from "react";
|
|
2
|
+
import {Text} from "react-native";
|
|
3
|
+
|
|
4
|
+
import type {TableTitleProps} from "../Common";
|
|
5
|
+
import {useTheme} from "../Theme";
|
|
6
|
+
|
|
7
|
+
export const TableTitle: FC<TableTitleProps> = ({title, align = "left"}) => {
|
|
8
|
+
const {theme} = useTheme();
|
|
9
|
+
return (
|
|
10
|
+
// No hint needed for a title.
|
|
11
|
+
<Text
|
|
12
|
+
aria-label={`Table title: ${title}`}
|
|
13
|
+
aria-role="header"
|
|
14
|
+
ellipsizeMode="tail" // ensures that the text is clipped at the end of the line for all platforms
|
|
15
|
+
numberOfLines={3}
|
|
16
|
+
style={{
|
|
17
|
+
color: theme.text.primary,
|
|
18
|
+
flexWrap: "wrap",
|
|
19
|
+
fontFamily: "text",
|
|
20
|
+
fontSize: 10,
|
|
21
|
+
fontWeight: "700",
|
|
22
|
+
lineHeight: 16,
|
|
23
|
+
overflow: "hidden",
|
|
24
|
+
textAlign: align,
|
|
25
|
+
textTransform: "uppercase",
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
{title}
|
|
29
|
+
</Text>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import {type Context, createContext, useContext} from "react";
|
|
3
|
+
|
|
4
|
+
import type {TableContextProviderProps, TableContextType} from "../Common";
|
|
5
|
+
|
|
6
|
+
const TableContext: Context<TableContextType> = createContext<TableContextType>({
|
|
7
|
+
alternateRowBackground: true,
|
|
8
|
+
borderStyle: "sm",
|
|
9
|
+
columns: [],
|
|
10
|
+
hasDrawerContents: false,
|
|
11
|
+
page: 1,
|
|
12
|
+
setSortColumn: () => {},
|
|
13
|
+
sortColumn: undefined,
|
|
14
|
+
stickyHeader: true,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const {Provider} = TableContext;
|
|
18
|
+
|
|
19
|
+
export const TableContextProvider = ({
|
|
20
|
+
children,
|
|
21
|
+
columns,
|
|
22
|
+
hasDrawerContents,
|
|
23
|
+
sortColumn,
|
|
24
|
+
setSortColumn,
|
|
25
|
+
stickyHeader,
|
|
26
|
+
borderStyle,
|
|
27
|
+
alternateRowBackground,
|
|
28
|
+
page,
|
|
29
|
+
}: TableContextProviderProps): React.ReactElement<typeof Provider> => {
|
|
30
|
+
return (
|
|
31
|
+
<Provider
|
|
32
|
+
value={{
|
|
33
|
+
alternateRowBackground,
|
|
34
|
+
borderStyle,
|
|
35
|
+
columns,
|
|
36
|
+
hasDrawerContents,
|
|
37
|
+
page,
|
|
38
|
+
setSortColumn,
|
|
39
|
+
sortColumn,
|
|
40
|
+
stickyHeader,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</Provider>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export function useTableContext(): TableContextType {
|
|
49
|
+
const {
|
|
50
|
+
columns,
|
|
51
|
+
hasDrawerContents,
|
|
52
|
+
setSortColumn,
|
|
53
|
+
sortColumn,
|
|
54
|
+
stickyHeader,
|
|
55
|
+
alternateRowBackground,
|
|
56
|
+
borderStyle,
|
|
57
|
+
} = useContext(TableContext);
|
|
58
|
+
return {
|
|
59
|
+
alternateRowBackground,
|
|
60
|
+
borderStyle,
|
|
61
|
+
columns,
|
|
62
|
+
hasDrawerContents,
|
|
63
|
+
setSortColumn,
|
|
64
|
+
sortColumn,
|
|
65
|
+
stickyHeader,
|
|
66
|
+
};
|
|
67
|
+
}
|