ferns-ui 0.47.10 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion.d.ts +3 -0
- package/dist/Accordion.js +38 -0
- package/dist/Accordion.js.map +1 -0
- package/dist/ActionSheet.d.ts +9 -10
- package/dist/ActionSheet.js +8 -6
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AddressField.d.ts +3 -0
- package/dist/AddressField.js +33 -0
- package/dist/AddressField.js.map +1 -0
- package/dist/Avatar.d.ts +2 -2
- package/dist/Avatar.js +132 -96
- package/dist/Avatar.js.map +1 -1
- package/dist/Badge.d.ts +1 -1
- package/dist/Badge.js +95 -20
- package/dist/Badge.js.map +1 -1
- package/dist/Banner.d.ts +1 -1
- package/dist/Banner.js +89 -51
- package/dist/Banner.js.map +1 -1
- package/dist/Body.js +4 -4
- package/dist/Body.js.map +1 -1
- package/dist/BooleanField.d.ts +3 -0
- package/dist/BooleanField.js +90 -0
- package/dist/BooleanField.js.map +1 -0
- package/dist/Box.js +80 -80
- package/dist/Box.js.map +1 -1
- package/dist/Button.d.ts +2 -2
- package/dist/Button.js +87 -109
- package/dist/Button.js.map +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/CheckBox.d.ts +2 -2
- package/dist/CheckBox.js +23 -35
- package/dist/CheckBox.js.map +1 -1
- package/dist/Common.d.ts +1129 -413
- package/dist/Common.js +39 -3
- package/dist/Common.js.map +1 -1
- package/dist/CommonIconTypes.d.ts +3 -0
- package/dist/CommonIconTypes.js +2 -0
- package/dist/CommonIconTypes.js.map +1 -0
- package/dist/CustomSelectField.d.ts +3 -0
- package/dist/CustomSelectField.js +64 -0
- package/dist/CustomSelectField.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +1 -1
- package/dist/DateTimeActionSheet.js +170 -158
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/DateTimeField.d.ts +3 -3
- package/dist/DateTimeField.js +140 -30
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DateUtilities.js.map +1 -1
- package/dist/DateUtilities.test.js +2 -1
- package/dist/DateUtilities.test.js.map +1 -1
- package/dist/DecimalRangeActionSheet.js +3 -15
- package/dist/DecimalRangeActionSheet.js.map +1 -1
- package/dist/DismissButton.d.ts +3 -0
- package/dist/DismissButton.js +14 -0
- package/dist/DismissButton.js.map +1 -0
- package/dist/EmailField.d.ts +3 -0
- package/dist/EmailField.js +52 -0
- package/dist/EmailField.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +1 -1
- package/dist/ErrorPage.js +2 -2
- package/dist/ErrorPage.js.map +1 -1
- package/dist/FernsProvider.js +1 -1
- package/dist/FernsProvider.js.map +1 -1
- package/dist/Field.d.ts +2 -2
- package/dist/Field.js +67 -136
- package/dist/Field.js.map +1 -1
- package/dist/Heading.js +37 -16
- package/dist/Heading.js.map +1 -1
- package/dist/HeightActionSheet.js +3 -7
- package/dist/HeightActionSheet.js.map +1 -1
- package/dist/Hyperlink.js +7 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Icon.d.ts +1 -2
- package/dist/Icon.js +8 -10
- package/dist/Icon.js.map +1 -1
- package/dist/IconButton.d.ts +2 -2
- package/dist/IconButton.js +93 -92
- package/dist/IconButton.js.map +1 -1
- package/dist/InfoTooltipButton.d.ts +1 -1
- package/dist/InfoTooltipButton.js +2 -2
- package/dist/InfoTooltipButton.js.map +1 -1
- package/dist/Link.d.ts +1 -1
- package/dist/Link.js +7 -3
- package/dist/Link.js.map +1 -1
- package/dist/MobileAddressAutoComplete.js +8 -8
- package/dist/MobileAddressAutoComplete.js.map +1 -1
- package/dist/Modal.d.ts +2 -2
- package/dist/Modal.js +95 -80
- package/dist/Modal.js.map +1 -1
- package/dist/MultiselectField.d.ts +3 -0
- package/dist/MultiselectField.js +49 -0
- package/dist/MultiselectField.js.map +1 -0
- package/dist/NumberField.d.ts +3 -0
- package/dist/NumberField.js +49 -0
- package/dist/NumberField.js.map +1 -0
- package/dist/NumberPickerActionSheet.js +2 -2
- package/dist/NumberPickerActionSheet.js.map +1 -1
- package/dist/OpenAPIContext.js.map +1 -1
- package/dist/Page.js +6 -6
- package/dist/Page.js.map +1 -1
- package/dist/Pagination.d.ts +2 -8
- package/dist/Pagination.js +107 -13
- package/dist/Pagination.js.map +1 -1
- package/dist/PasswordField.d.ts +2 -0
- package/dist/PasswordField.js +6 -0
- package/dist/PasswordField.js.map +1 -0
- package/dist/PhoneNumberField.d.ts +3 -0
- package/dist/PhoneNumberField.js +79 -0
- package/dist/PhoneNumberField.js.map +1 -0
- package/dist/PickerSelect.d.ts +6 -67
- package/dist/PickerSelect.js +145 -115
- package/dist/PickerSelect.js.map +1 -1
- 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 +22 -0
- package/dist/RadioField.js.map +1 -0
- package/dist/SegmentedControl.d.ts +1 -1
- package/dist/SegmentedControl.js +37 -68
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/SelectField.d.ts +3 -0
- package/dist/SelectField.js +20 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/SideDrawer.js +8 -2
- package/dist/SideDrawer.js.map +1 -1
- package/dist/Signature.d.ts +1 -0
- package/dist/Signature.js +8 -7
- package/dist/Signature.js.map +1 -1
- package/dist/Signature.native.js +8 -7
- package/dist/Signature.native.js.map +1 -1
- package/dist/SignatureField.d.ts +3 -0
- package/dist/SignatureField.js +54 -0
- package/dist/SignatureField.js.map +1 -0
- package/dist/Spinner.js +17 -2
- package/dist/Spinner.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.js +10 -10
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +7 -7
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TapToEdit.d.ts +3 -3
- package/dist/TapToEdit.js +64 -59
- package/dist/TapToEdit.js.map +1 -1
- package/dist/Text.d.ts +1 -1
- package/dist/Text.js +70 -64
- package/dist/Text.js.map +1 -1
- package/dist/TextArea.d.ts +1 -1
- package/dist/TextArea.js +2 -14
- package/dist/TextArea.js.map +1 -1
- package/dist/TextField.d.ts +2 -2
- package/dist/TextField.js +89 -206
- package/dist/TextField.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.js +2 -2
- package/dist/TextFieldNumberActionSheet.js.map +1 -1
- package/dist/Theme.d.ts +87 -3
- package/dist/Theme.js +197 -98
- package/dist/Theme.js.map +1 -1
- package/dist/TimezonePicker.js +3 -5
- package/dist/TimezonePicker.js.map +1 -1
- package/dist/Toast.d.ts +18 -5
- package/dist/Toast.js +130 -31
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.d.ts +2 -2
- package/dist/Tooltip.js +177 -80
- package/dist/Tooltip.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.js +2 -2
- package/dist/UnifiedAddressAutoComplete.js.map +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/Utilities.js +5 -3
- package/dist/Utilities.js.map +1 -1
- package/dist/WebAddressAutocomplete.js +2 -2
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/fieldElements/FieldError.d.ts +6 -0
- package/dist/fieldElements/FieldError.js +14 -0
- package/dist/fieldElements/FieldError.js.map +1 -0
- package/dist/fieldElements/FieldHelperText.d.ts +6 -0
- package/dist/fieldElements/FieldHelperText.js +11 -0
- package/dist/fieldElements/FieldHelperText.js.map +1 -0
- package/dist/fieldElements/FieldTitle.d.ts +6 -0
- package/dist/fieldElements/FieldTitle.js +19 -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 +3 -0
- package/dist/icons/MobileIcon.js +24 -0
- package/dist/icons/MobileIcon.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +3 -0
- package/dist/icons/OfflineIcon.js +23 -0
- package/dist/icons/OfflineIcon.js.map +1 -0
- package/dist/icons/OnlineIcon.d.ts +3 -0
- package/dist/icons/OnlineIcon.js +24 -0
- package/dist/icons/OnlineIcon.js.map +1 -0
- package/dist/icons/OutOfficeIcon.d.ts +3 -0
- package/dist/icons/OutOfficeIcon.js +24 -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 +28 -14
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +1 -1
- package/dist/setupTests.js.map +1 -1
- package/dist/{Table.d.ts → table/Table.d.ts} +2 -2
- package/dist/{Table.js → table/Table.js} +18 -10
- package/dist/table/Table.js.map +1 -0
- package/dist/table/TableBadge.d.ts +6 -0
- package/dist/table/TableBadge.js +22 -0
- package/dist/table/TableBadge.js.map +1 -0
- package/dist/table/TableBoolean.d.ts +6 -0
- package/dist/table/TableBoolean.js +39 -0
- package/dist/table/TableBoolean.js.map +1 -0
- package/dist/table/TableDate.d.ts +3 -0
- package/dist/table/TableDate.js +26 -0
- package/dist/table/TableDate.js.map +1 -0
- package/dist/{TableHeader.d.ts → table/TableHeader.d.ts} +1 -1
- package/dist/{TableHeader.js → table/TableHeader.js} +2 -2
- package/dist/table/TableHeader.js.map +1 -0
- package/dist/{TableHeaderCell.d.ts → table/TableHeaderCell.d.ts} +2 -2
- package/dist/table/TableHeaderCell.js +58 -0
- package/dist/table/TableHeaderCell.js.map +1 -0
- package/dist/table/TableIconButton.d.ts +3 -0
- package/dist/table/TableIconButton.js +42 -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/{TableRow.d.ts → table/TableRow.d.ts} +1 -1
- package/dist/table/TableRow.js +28 -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 +22 -0
- package/dist/table/TableTitle.js.map +1 -0
- package/dist/{tableContext.d.ts → table/tableContext.d.ts} +1 -1
- package/dist/table/tableContext.js.map +1 -0
- package/package.json +10 -4
- package/src/Accordion.tsx +92 -0
- package/src/ActionSheet.tsx +8 -5
- package/src/AddressField.tsx +122 -0
- package/src/Avatar.tsx +193 -147
- package/src/Badge.tsx +117 -49
- package/src/Banner.tsx +158 -111
- package/src/Body.tsx +4 -4
- package/src/BooleanField.tsx +122 -0
- package/src/Box.tsx +92 -82
- package/src/Button.tsx +151 -167
- package/src/Card.tsx +2 -2
- package/src/CheckBox.tsx +30 -111
- package/src/Common.ts +1380 -2059
- package/src/CommonIconTypes.ts +2030 -0
- package/src/CustomSelectField.tsx +116 -0
- package/src/DateTimeActionSheet.tsx +341 -259
- package/src/DateTimeField.tsx +168 -61
- package/src/DateUtilities.test.ts +6 -2
- package/src/DateUtilities.tsx +1 -1
- package/src/DecimalRangeActionSheet.tsx +2 -17
- package/src/DismissButton.tsx +31 -0
- package/src/EmailField.tsx +70 -0
- package/src/ErrorPage.tsx +2 -2
- package/src/FernsProvider.tsx +1 -1
- package/src/Field.tsx +83 -345
- package/src/Heading.tsx +44 -16
- package/src/HeightActionSheet.tsx +2 -9
- package/src/Hyperlink.tsx +8 -1
- package/src/Icon.tsx +22 -14
- package/src/IconButton.tsx +188 -156
- package/src/InfoTooltipButton.tsx +4 -6
- package/src/Link.tsx +14 -5
- package/src/MobileAddressAutoComplete.tsx +17 -13
- package/src/Modal.tsx +214 -190
- package/src/MultiselectField.tsx +103 -0
- package/src/NumberField.tsx +55 -0
- package/src/NumberPickerActionSheet.tsx +1 -4
- package/src/OpenAPIContext.tsx +1 -1
- package/src/Page.tsx +9 -13
- package/src/Pagination.tsx +171 -36
- package/src/PasswordField.tsx +7 -0
- package/src/PhoneNumberField.tsx +103 -0
- package/src/PickerSelect.tsx +169 -151
- package/src/Radio.tsx +33 -0
- package/src/RadioField.tsx +43 -0
- package/src/SegmentedControl.tsx +46 -97
- package/src/SelectField.tsx +41 -0
- package/src/SideDrawer.tsx +8 -2
- package/src/Signature.native.tsx +16 -9
- package/src/Signature.tsx +19 -11
- package/src/SignatureField.tsx +92 -0
- package/src/Spinner.tsx +16 -2
- package/src/SplitPage.native.tsx +9 -7
- package/src/SplitPage.tsx +11 -12
- package/src/TapToEdit.tsx +122 -109
- package/src/Text.tsx +79 -69
- package/src/TextArea.tsx +2 -2
- package/src/TextField.tsx +133 -285
- package/src/TextFieldNumberActionSheet.tsx +1 -4
- package/src/Theme.tsx +223 -172
- package/src/TimezonePicker.tsx +3 -18
- package/src/Toast.tsx +193 -70
- package/src/Tooltip.tsx +233 -122
- package/src/UnifiedAddressAutoComplete.tsx +3 -3
- package/src/Unifier.ts +4 -4
- package/src/Utilities.tsx +11 -3
- package/src/WebAddressAutocomplete.tsx +2 -3
- 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 +41 -0
- package/src/icons/OfflineIcon.tsx +38 -0
- package/src/icons/OnlineIcon.tsx +40 -0
- package/src/icons/OutOfficeIcon.tsx +37 -0
- package/src/icons/index.ts +4 -0
- package/src/index.tsx +28 -14
- package/src/setupTests.ts +1 -0
- package/src/{Table.tsx → table/Table.tsx} +24 -14
- package/src/table/TableBadge.tsx +46 -0
- package/src/table/TableBoolean.tsx +70 -0
- package/src/table/TableDate.tsx +38 -0
- package/src/{TableHeader.tsx → table/TableHeader.tsx} +3 -3
- package/src/table/TableHeaderCell.tsx +93 -0
- package/src/table/TableIconButton.tsx +62 -0
- package/src/table/TableNumber.tsx +29 -0
- package/src/{TableRow.tsx → table/TableRow.tsx} +28 -25
- package/src/table/TableText.tsx +29 -0
- package/src/table/TableTitle.tsx +32 -0
- package/src/{tableContext.tsx → table/tableContext.tsx} +1 -1
- package/dist/BlurBox.d.ts +0 -5
- package/dist/BlurBox.js +0 -28
- package/dist/BlurBox.js.map +0 -1
- package/dist/BlurBox.native.d.ts +0 -6
- package/dist/BlurBox.native.js +0 -30
- package/dist/BlurBox.native.js.map +0 -1
- package/dist/CustomSelect.d.ts +0 -3
- package/dist/CustomSelect.js +0 -47
- package/dist/CustomSelect.js.map +0 -1
- package/dist/DateTimeField.android.d.ts +0 -3
- package/dist/DateTimeField.android.js +0 -67
- package/dist/DateTimeField.android.js.map +0 -1
- package/dist/DateTimeField.ios.d.ts +0 -3
- package/dist/DateTimeField.ios.js +0 -49
- package/dist/DateTimeField.ios.js.map +0 -1
- package/dist/FieldWithLabels.d.ts +0 -3
- package/dist/FieldWithLabels.js +0 -8
- package/dist/FieldWithLabels.js.map +0 -1
- package/dist/Form.d.ts +0 -16
- package/dist/Form.js +0 -89
- package/dist/Form.js.map +0 -1
- package/dist/HeaderButtons.d.ts +0 -31
- package/dist/HeaderButtons.js +0 -53
- package/dist/HeaderButtons.js.map +0 -1
- package/dist/Mask.d.ts +0 -2
- package/dist/Mask.js +0 -19
- package/dist/Mask.js.map +0 -1
- package/dist/Pill.d.ts +0 -3
- package/dist/Pill.js +0 -8
- package/dist/Pill.js.map +0 -1
- package/dist/Pog.d.ts +0 -3
- package/dist/Pog.js +0 -48
- package/dist/Pog.js.map +0 -1
- package/dist/ProgressBar.d.ts +0 -3
- package/dist/ProgressBar.js +0 -35
- package/dist/ProgressBar.js.map +0 -1
- package/dist/SelectList.d.ts +0 -27
- package/dist/SelectList.js +0 -56
- package/dist/SelectList.js.map +0 -1
- package/dist/Switch.d.ts +0 -3
- package/dist/Switch.js +0 -20
- package/dist/Switch.js.map +0 -1
- package/dist/Table.js.map +0 -1
- package/dist/TableHeader.js.map +0 -1
- package/dist/TableHeaderCell.js +0 -36
- package/dist/TableHeaderCell.js.map +0 -1
- package/dist/TableRow.js +0 -30
- package/dist/TableRow.js.map +0 -1
- package/dist/WithLabel.d.ts +0 -3
- package/dist/WithLabel.js +0 -15
- package/dist/WithLabel.js.map +0 -1
- package/dist/tableContext.js.map +0 -1
- package/src/BlurBox.native.tsx +0 -40
- package/src/BlurBox.tsx +0 -31
- package/src/CustomSelect.tsx +0 -80
- package/src/DateTimeField.android.tsx +0 -103
- package/src/DateTimeField.ios.tsx +0 -85
- package/src/FieldWithLabels.tsx +0 -36
- package/src/Form.tsx +0 -175
- package/src/HeaderButtons.tsx +0 -107
- package/src/Mask.tsx +0 -21
- package/src/Pill.tsx +0 -22
- package/src/Pog.tsx +0 -75
- package/src/ProgressBar.tsx +0 -47
- package/src/SelectList.tsx +0 -109
- package/src/Switch.tsx +0 -18
- package/src/TableHeaderCell.tsx +0 -72
- package/src/WithLabel.tsx +0 -45
- /package/dist/{tableContext.js → table/tableContext.js} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Svg, {Path} from "react-native-svg";
|
|
3
|
+
|
|
4
|
+
import {CustomSvgProps} from "../Common";
|
|
5
|
+
|
|
6
|
+
export const MobileIcon = ({doNotDisturb, ...props}: CustomSvgProps) => {
|
|
7
|
+
return (
|
|
8
|
+
<Svg fill="none" height={33} viewBox="0 0 33 45" width={30} {...props}>
|
|
9
|
+
<Path d="M3 7h24v35H3z" fill="#fff" />
|
|
10
|
+
<Path
|
|
11
|
+
d="M8.864 5.5A5.867 5.867 0 0 0 3 11.364v26.182a5.867 5.867 0 0 0 5.864 5.863h15.272A5.867 5.867 0 0 0 30 37.546V11.364A5.867 5.867 0 0 0 24.136 5.5H8.864Zm1.5 7.364h12.272v18.818H10.364V12.864Z"
|
|
12
|
+
fill="#3EA45C"
|
|
13
|
+
stroke="#fff"
|
|
14
|
+
strokeWidth={3}
|
|
15
|
+
/>
|
|
16
|
+
<Path
|
|
17
|
+
d="M14.622 37.249h3.768a.789.582 0 0 1 .789.582.789.582 0 0 1-.789.581h-3.779a.789.582 0 0 1-.789-.581.8.582 0 0 1 .8-.582Z"
|
|
18
|
+
fill="#fff"
|
|
19
|
+
stroke="#fff"
|
|
20
|
+
/>
|
|
21
|
+
{doNotDisturb && (
|
|
22
|
+
<>
|
|
23
|
+
<Path
|
|
24
|
+
d="M21 4h8l-8 6.857h8"
|
|
25
|
+
stroke="#fff"
|
|
26
|
+
strokeLinecap="round"
|
|
27
|
+
strokeLinejoin="round"
|
|
28
|
+
strokeWidth={8}
|
|
29
|
+
/>
|
|
30
|
+
<Path
|
|
31
|
+
d="M21 4h8l-8 6.857h8"
|
|
32
|
+
stroke="#3EA45C"
|
|
33
|
+
strokeLinecap="round"
|
|
34
|
+
strokeLinejoin="round"
|
|
35
|
+
strokeWidth={3}
|
|
36
|
+
/>
|
|
37
|
+
</>
|
|
38
|
+
)}
|
|
39
|
+
</Svg>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Svg, {Path} from "react-native-svg";
|
|
3
|
+
|
|
4
|
+
import {CustomSvgProps} from "../Common";
|
|
5
|
+
export const OfflineIcon = ({doNotDisturb, ...props}: CustomSvgProps) => (
|
|
6
|
+
<Svg fill="none" height={33} width={30} {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
d="M28.5 18c0 7.456-6.044 13.5-13.5 13.5S1.5 25.456 1.5 18 7.544 4.5 15 4.5 28.5 10.544 28.5 18Z"
|
|
9
|
+
fill="#2B6072"
|
|
10
|
+
stroke="#fff"
|
|
11
|
+
strokeWidth={3}
|
|
12
|
+
/>
|
|
13
|
+
<Path
|
|
14
|
+
d="M24.5 18a9.5 9.5 0 1 1-19 0 9.5 9.5 0 0 1 19 0Z"
|
|
15
|
+
fill="#fff"
|
|
16
|
+
stroke="#9A9A9A"
|
|
17
|
+
strokeWidth={5}
|
|
18
|
+
/>
|
|
19
|
+
{doNotDisturb && (
|
|
20
|
+
<>
|
|
21
|
+
<Path
|
|
22
|
+
d="M18 4h8l-8 6.857h8"
|
|
23
|
+
stroke="#fff"
|
|
24
|
+
strokeLinecap="round"
|
|
25
|
+
strokeLinejoin="round"
|
|
26
|
+
strokeWidth={8}
|
|
27
|
+
/>
|
|
28
|
+
<Path
|
|
29
|
+
d="M18 4h8l-8 6.857h8"
|
|
30
|
+
stroke="#9A9A9A"
|
|
31
|
+
strokeLinecap="round"
|
|
32
|
+
strokeLinejoin="round"
|
|
33
|
+
strokeWidth={3}
|
|
34
|
+
/>
|
|
35
|
+
</>
|
|
36
|
+
)}
|
|
37
|
+
</Svg>
|
|
38
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Generated with https://react-svgr.com/playground/?native=true&typescript=true
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Svg, {Path} from "react-native-svg";
|
|
5
|
+
|
|
6
|
+
import {CustomSvgProps} from "../Common";
|
|
7
|
+
|
|
8
|
+
export const OnlineIcon = ({doNotDisturb, ...props}: CustomSvgProps) => {
|
|
9
|
+
return (
|
|
10
|
+
<Svg fill="none" height="33" width="30" {...props}>
|
|
11
|
+
<Path
|
|
12
|
+
d="M28.5 18c0 7.456-6.044 13.5-13.5 13.5S1.5 25.456 1.5 18 7.544 4.5 15 4.5 28.5 10.544 28.5 18Z"
|
|
13
|
+
fill="#fff"
|
|
14
|
+
stroke="#fff"
|
|
15
|
+
/>
|
|
16
|
+
<Path
|
|
17
|
+
d="M26 18c0 6.075-4.925 11-11 11S4 24.075 4 18 8.925 7 15 7s11 4.925 11 11Z"
|
|
18
|
+
fill="#3EA45C"
|
|
19
|
+
/>
|
|
20
|
+
{doNotDisturb && (
|
|
21
|
+
<>
|
|
22
|
+
<Path
|
|
23
|
+
d="M18 4h8l-8 6.857h8"
|
|
24
|
+
stroke="#fff"
|
|
25
|
+
strokeLinecap="round"
|
|
26
|
+
strokeLinejoin="round"
|
|
27
|
+
strokeWidth={8}
|
|
28
|
+
/>
|
|
29
|
+
<Path
|
|
30
|
+
d="M18 4h8l-8 6.857h8"
|
|
31
|
+
stroke="#3EA45C"
|
|
32
|
+
strokeLinecap="round"
|
|
33
|
+
strokeLinejoin="round"
|
|
34
|
+
strokeWidth={3}
|
|
35
|
+
/>
|
|
36
|
+
</>
|
|
37
|
+
)}
|
|
38
|
+
</Svg>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Svg, {Path} from "react-native-svg";
|
|
3
|
+
|
|
4
|
+
import {CustomSvgProps} from "../Common";
|
|
5
|
+
export const OutOfOfficeIcon = ({doNotDisturb, ...props}: CustomSvgProps) => (
|
|
6
|
+
<Svg fill="none" height={33} width={30} {...props}>
|
|
7
|
+
<Path
|
|
8
|
+
d="M28.5 18c0 7.456-6.044 13.5-13.5 13.5S1.5 25.456 1.5 18 7.544 4.5 15 4.5 28.5 10.544 28.5 18Z"
|
|
9
|
+
fill="#fff"
|
|
10
|
+
stroke="#fff"
|
|
11
|
+
strokeWidth={3}
|
|
12
|
+
/>
|
|
13
|
+
<Path
|
|
14
|
+
d="M26 18c0 6.075-4.925 11-11 11S4 24.075 4 18 8.925 7 15 7s11 4.925 11 11Z"
|
|
15
|
+
fill="#D33232"
|
|
16
|
+
/>
|
|
17
|
+
<Path d="M9 18h12" stroke="#fff" strokeLinecap="round" strokeWidth={4} />
|
|
18
|
+
{doNotDisturb && (
|
|
19
|
+
<>
|
|
20
|
+
<Path
|
|
21
|
+
d="M18 4h8l-8 6.857h8"
|
|
22
|
+
stroke="#fff"
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
|
+
strokeWidth={8}
|
|
26
|
+
/>
|
|
27
|
+
<Path
|
|
28
|
+
d="M18 4h8l-8 6.857h8"
|
|
29
|
+
stroke="#D33232"
|
|
30
|
+
strokeLinecap="round"
|
|
31
|
+
strokeLinejoin="round"
|
|
32
|
+
strokeWidth={3}
|
|
33
|
+
/>
|
|
34
|
+
</>
|
|
35
|
+
)}
|
|
36
|
+
</Svg>
|
|
37
|
+
);
|
package/src/index.tsx
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
export * from "./Accordion";
|
|
1
2
|
export * from "./ActionSheet";
|
|
3
|
+
export * from "./AddressField";
|
|
2
4
|
export * from "./Avatar";
|
|
3
5
|
export * from "./Badge";
|
|
4
6
|
export * from "./Banner";
|
|
5
|
-
export * from "./BlurBox";
|
|
6
7
|
export * from "./Body";
|
|
8
|
+
export * from "./BooleanField";
|
|
7
9
|
export * from "./Box";
|
|
8
10
|
export * from "./Button";
|
|
9
11
|
export * from "./Card";
|
|
10
12
|
export * from "./CheckBox";
|
|
11
13
|
export * from "./Common";
|
|
12
14
|
export * from "./Constants";
|
|
15
|
+
export * from "./CustomSelectField";
|
|
13
16
|
export * from "./DateTimeActionSheet";
|
|
14
17
|
export * from "./DateTimeField";
|
|
15
18
|
export * from "./DateUtilities";
|
|
16
19
|
export * from "./DecimalRangeActionSheet";
|
|
20
|
+
export * from "./DismissButton";
|
|
21
|
+
export * from "./EmailField";
|
|
17
22
|
export * from "./ErrorBoundary";
|
|
18
23
|
export * from "./ErrorPage";
|
|
19
24
|
export * from "./FernsProvider";
|
|
20
25
|
export * from "./Field";
|
|
21
26
|
export * from "./FlatList";
|
|
22
|
-
export * from "./Form";
|
|
23
|
-
export * from "./HeaderButtons";
|
|
24
27
|
export * from "./Heading";
|
|
25
28
|
export * from "./HeightActionSheet";
|
|
26
29
|
export * from "./Icon";
|
|
@@ -29,29 +32,41 @@ export * from "./Image";
|
|
|
29
32
|
export * from "./ImageBackground";
|
|
30
33
|
export * from "./InfoTooltipButton";
|
|
31
34
|
export * from "./Link";
|
|
32
|
-
export * from "./Mask";
|
|
33
35
|
export * from "./MediaQuery";
|
|
34
36
|
export * from "./MobileAddressAutoComplete";
|
|
35
37
|
export * from "./Modal";
|
|
36
38
|
export * from "./ModalSheet";
|
|
39
|
+
export * from "./MultiselectField";
|
|
40
|
+
export * from "./NumberField";
|
|
37
41
|
export * from "./NumberPickerActionSheet";
|
|
38
42
|
export * from "./OpenAPIContext";
|
|
39
43
|
export * from "./Page";
|
|
40
|
-
export * from "./
|
|
41
|
-
export * from "./
|
|
44
|
+
export * from "./Pagination";
|
|
45
|
+
export * from "./PasswordField";
|
|
46
|
+
export * from "./PhoneNumberField";
|
|
47
|
+
export * from "./Radio";
|
|
48
|
+
export * from "./RadioField";
|
|
42
49
|
export * from "./ScrollView";
|
|
43
50
|
export * from "./SegmentedControl";
|
|
44
|
-
export * from "./
|
|
51
|
+
export * from "./SelectField";
|
|
45
52
|
export * from "./SideDrawer";
|
|
46
53
|
export * from "./Signature";
|
|
54
|
+
export * from "./SignatureField";
|
|
47
55
|
export * from "./Spinner";
|
|
48
56
|
export * from "./SplitPage";
|
|
49
|
-
export * from "./
|
|
50
|
-
export * from "./Table";
|
|
51
|
-
export * from "./
|
|
52
|
-
export * from "./
|
|
53
|
-
export * from "./
|
|
54
|
-
export * from "./
|
|
57
|
+
export * from "./table/Table";
|
|
58
|
+
export * from "./table/Table";
|
|
59
|
+
export * from "./table/TableBadge";
|
|
60
|
+
export * from "./table/TableBoolean";
|
|
61
|
+
export * from "./table/tableContext";
|
|
62
|
+
export * from "./table/TableDate";
|
|
63
|
+
export * from "./table/TableHeader";
|
|
64
|
+
export * from "./table/TableHeaderCell";
|
|
65
|
+
export * from "./table/TableIconButton";
|
|
66
|
+
export * from "./table/TableNumber";
|
|
67
|
+
export * from "./table/TableRow";
|
|
68
|
+
export * from "./table/TableText";
|
|
69
|
+
export * from "./table/TableTitle";
|
|
55
70
|
export * from "./TapToEdit";
|
|
56
71
|
export * from "./Text";
|
|
57
72
|
export * from "./TextArea";
|
|
@@ -64,7 +79,6 @@ export * from "./Unifier";
|
|
|
64
79
|
export * from "./useStoredState";
|
|
65
80
|
export * from "./Utilities";
|
|
66
81
|
export * from "./WebAddressAutocomplete";
|
|
67
|
-
export * from "./WithLabel";
|
|
68
82
|
// export * from "./Layout";
|
|
69
83
|
// export * from "./Drawer";
|
|
70
84
|
// export * from "./Chart";
|
package/src/setupTests.ts
CHANGED
|
@@ -2,14 +2,14 @@ import React, {Children, ReactElement, useEffect} from "react";
|
|
|
2
2
|
import {ScrollView} from "react-native";
|
|
3
3
|
import {DimensionValue} from "react-native/Libraries/StyleSheet/StyleSheetTypes";
|
|
4
4
|
|
|
5
|
-
import {Box} from "
|
|
6
|
-
import {ColumnSortInterface, TableProps} from "
|
|
7
|
-
import {
|
|
5
|
+
import {Box} from "../Box";
|
|
6
|
+
import {ColumnSortInterface, TableProps} from "../Common";
|
|
7
|
+
import {Pagination} from "../Pagination";
|
|
8
8
|
import {TableContextProvider} from "./tableContext";
|
|
9
9
|
|
|
10
10
|
export const Table = ({
|
|
11
11
|
children,
|
|
12
|
-
columns,
|
|
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
13
|
borderStyle,
|
|
14
14
|
alternateRowBackground = true,
|
|
15
15
|
maxHeight,
|
|
@@ -17,6 +17,7 @@ export const Table = ({
|
|
|
17
17
|
sort,
|
|
18
18
|
page: propsPage,
|
|
19
19
|
setPage: propsSetPage,
|
|
20
|
+
totalPages,
|
|
20
21
|
more,
|
|
21
22
|
extraControls,
|
|
22
23
|
}: TableProps): React.ReactElement => {
|
|
@@ -37,10 +38,11 @@ export const Table = ({
|
|
|
37
38
|
let width: DimensionValue;
|
|
38
39
|
if (columns.every((column) => typeof column === "number")) {
|
|
39
40
|
width = columns.reduce((acc, curr) => {
|
|
40
|
-
return (acc as number) + (curr as number);
|
|
41
|
+
return (acc as number) + (curr as number) + 8; // 8 for margin between columns;
|
|
41
42
|
}, 0) as number;
|
|
42
43
|
if (hasDrawerContents) {
|
|
43
|
-
|
|
44
|
+
// Size of IconButton + padding is 56
|
|
45
|
+
width = (width as number) + 56;
|
|
44
46
|
}
|
|
45
47
|
} else {
|
|
46
48
|
width = "100%";
|
|
@@ -67,9 +69,18 @@ export const Table = ({
|
|
|
67
69
|
stickyHeader={stickyHeader}
|
|
68
70
|
>
|
|
69
71
|
<>
|
|
70
|
-
<Box
|
|
72
|
+
<Box
|
|
73
|
+
flex="grow"
|
|
74
|
+
maxWidth="100%"
|
|
75
|
+
style={{
|
|
76
|
+
position: "relative",
|
|
77
|
+
}}
|
|
78
|
+
width={width}
|
|
79
|
+
>
|
|
71
80
|
<ScrollView horizontal style={{width, maxWidth: "100%"}}>
|
|
81
|
+
{/* TODO: Replace table scrollview with flat list */}
|
|
72
82
|
<ScrollView
|
|
83
|
+
// nestedScrollEnabled
|
|
73
84
|
stickyHeaderIndices={stickyHeader ? [0] : undefined}
|
|
74
85
|
style={{width, maxWidth: "100%", flex: 1, maxHeight}}
|
|
75
86
|
>
|
|
@@ -77,20 +88,19 @@ export const Table = ({
|
|
|
77
88
|
children,
|
|
78
89
|
(child, index) =>
|
|
79
90
|
Boolean(child) &&
|
|
80
|
-
React.cloneElement(child as
|
|
81
|
-
color: index % 2 === 1 && alternateRowBackground ? "
|
|
91
|
+
React.cloneElement(child as ReactElement, {
|
|
92
|
+
color: index % 2 === 1 && alternateRowBackground ? "neutralLight" : "base",
|
|
82
93
|
})
|
|
83
94
|
)}
|
|
84
95
|
</ScrollView>
|
|
85
96
|
</ScrollView>
|
|
86
97
|
</Box>
|
|
87
|
-
{Boolean(shouldPaginate) && (
|
|
88
|
-
<Box alignItems="center" borderTop="
|
|
89
|
-
<
|
|
98
|
+
{Boolean(shouldPaginate && totalPages !== undefined) && (
|
|
99
|
+
<Box alignItems="center" borderTop="default" direction="row" height={60} paddingX={8}>
|
|
100
|
+
<Pagination
|
|
90
101
|
page={propsPage ?? page}
|
|
91
102
|
setPage={propsSetPage ?? setPage}
|
|
92
|
-
|
|
93
|
-
shouldDisableNextButton={!more}
|
|
103
|
+
totalPages={totalPages!}
|
|
94
104
|
/>
|
|
95
105
|
{Boolean(extraControls) && extraControls}
|
|
96
106
|
</Box>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, {FC, useState} from "react";
|
|
2
|
+
import {View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {Badge} from "../Badge";
|
|
5
|
+
import {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
|
+
justifyContent: "center",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{isEditing && editingOptions ? (
|
|
38
|
+
<SelectField options={editingOptions} value={selected} onChange={handleChange} />
|
|
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 React, {FC, useCallback, useState} from "react";
|
|
2
|
+
import {TouchableOpacity, View, ViewStyle} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {CheckBox} from "../CheckBox";
|
|
5
|
+
import {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
|
+
accessibilityLabel={`Checkbox is currently ${valueString}`}
|
|
28
|
+
accessibilityRole="checkbox"
|
|
29
|
+
hitSlop={{top: 10, bottom: 10, left: 10, right: 10}}
|
|
30
|
+
style={
|
|
31
|
+
{
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
justifyContent: "center",
|
|
34
|
+
} as ViewStyle
|
|
35
|
+
}
|
|
36
|
+
onPress={handlePress}
|
|
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
|
+
accessibilityLabel={`The checkbox is ${valueString}`}
|
|
53
|
+
accessibilityRole="image"
|
|
54
|
+
style={{
|
|
55
|
+
height: 32,
|
|
56
|
+
width: 32,
|
|
57
|
+
borderRadius: 16,
|
|
58
|
+
backgroundColor: value ? theme.surface.successLight : "transparent",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
justifyContent: "center",
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<Icon color={value ? "success" : "secondaryLight"} 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 React, {FC, useState} from "react";
|
|
3
|
+
import {Text} from "react-native";
|
|
4
|
+
|
|
5
|
+
import {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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {Box} from "
|
|
4
|
-
import {TableHeaderProps} from "
|
|
3
|
+
import {Box} from "../Box";
|
|
4
|
+
import {TableHeaderProps} from "../Common";
|
|
5
5
|
import {TableRow} from "./TableRow";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@ export const TableHeader = ({
|
|
|
13
13
|
color,
|
|
14
14
|
}: TableHeaderProps): React.ReactElement => {
|
|
15
15
|
return (
|
|
16
|
-
<Box color={color ?? "
|
|
16
|
+
<Box color={color ?? "base"} display={display === "visuallyHidden" ? "none" : "flex"}>
|
|
17
17
|
<TableRow headerRow>{children}</TableRow>
|
|
18
18
|
</Box>
|
|
19
19
|
);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// TableHeaderCell.tsx
|
|
2
|
+
import {FontAwesome6} from "@expo/vector-icons";
|
|
3
|
+
import React, {ReactElement, useCallback} from "react";
|
|
4
|
+
import {View} from "react-native";
|
|
5
|
+
|
|
6
|
+
import {Box} from "../Box";
|
|
7
|
+
import {AlignItems, TableHeaderCellProps} from "../Common";
|
|
8
|
+
import {useTheme} from "../Theme";
|
|
9
|
+
import {useTableContext} from "./tableContext";
|
|
10
|
+
import {TableTitle} from "./TableTitle";
|
|
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 && 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
|
+
justifyContent: "center",
|
|
78
|
+
height: 16,
|
|
79
|
+
width: 16,
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
<FontAwesome6
|
|
83
|
+
color={theme.text.inverted}
|
|
84
|
+
name={sort === "asc" ? "arrow-down" : "arrow-up"}
|
|
85
|
+
size={10}
|
|
86
|
+
solid
|
|
87
|
+
/>
|
|
88
|
+
</View>
|
|
89
|
+
</Box>
|
|
90
|
+
)}
|
|
91
|
+
</Box>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable react-native-a11y/has-accessibility-hint */
|
|
2
|
+
// accessibility hint handled in IconButton.tsx
|
|
3
|
+
|
|
4
|
+
import React, {FC} from "react";
|
|
5
|
+
import {View} from "react-native";
|
|
6
|
+
|
|
7
|
+
import {IconButtonProps, IconName, TableIconButtonProps} from "../Common";
|
|
8
|
+
import {IconButton} from "../IconButton";
|
|
9
|
+
|
|
10
|
+
export const TableIconButton: FC<TableIconButtonProps> = ({tableIconButtonName, onClick}) => {
|
|
11
|
+
const iconButtonMap: Record<
|
|
12
|
+
string,
|
|
13
|
+
{
|
|
14
|
+
iconName: IconName;
|
|
15
|
+
variant: IconButtonProps["variant"];
|
|
16
|
+
accessibilityLabel: string;
|
|
17
|
+
accessibilityHint: string;
|
|
18
|
+
}
|
|
19
|
+
> = {
|
|
20
|
+
edit: {
|
|
21
|
+
iconName: "pen-to-square",
|
|
22
|
+
variant: "muted",
|
|
23
|
+
accessibilityLabel: "Edit",
|
|
24
|
+
accessibilityHint: "Edit row",
|
|
25
|
+
},
|
|
26
|
+
saveAndClose: {
|
|
27
|
+
iconName: "check",
|
|
28
|
+
variant: "secondary",
|
|
29
|
+
accessibilityLabel: "Save and close",
|
|
30
|
+
accessibilityHint: "Save and close row",
|
|
31
|
+
},
|
|
32
|
+
insert: {
|
|
33
|
+
iconName: "plus",
|
|
34
|
+
variant: "primary",
|
|
35
|
+
accessibilityLabel: "Insert Data",
|
|
36
|
+
accessibilityHint: "Insert Data",
|
|
37
|
+
},
|
|
38
|
+
drawerOpen: {
|
|
39
|
+
iconName: "chevron-down",
|
|
40
|
+
variant: "muted",
|
|
41
|
+
accessibilityLabel: "Open Drawer for more Data",
|
|
42
|
+
accessibilityHint: "Open Drawer",
|
|
43
|
+
},
|
|
44
|
+
drawerClose: {
|
|
45
|
+
iconName: "chevron-up",
|
|
46
|
+
variant: "secondary",
|
|
47
|
+
accessibilityLabel: "Close Drawer for more Data",
|
|
48
|
+
accessibilityHint: "Close Drawer",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View style={{justifyContent: "center", alignItems: "center", width: "100%"}}>
|
|
54
|
+
<IconButton
|
|
55
|
+
accessibilityLabel={iconButtonMap[tableIconButtonName].accessibilityLabel}
|
|
56
|
+
iconName={iconButtonMap[tableIconButtonName].iconName}
|
|
57
|
+
variant={iconButtonMap[tableIconButtonName].variant}
|
|
58
|
+
onClick={onClick}
|
|
59
|
+
/>
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
};
|