ferns-ui 0.36.1 → 0.36.3
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/ActionSheet.d.ts +492 -0
- package/dist/ActionSheet.js +649 -0
- package/dist/ActionSheet.js.map +1 -0
- package/dist/Avatar.d.ts +68 -0
- package/dist/Avatar.js +152 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.d.ts +10 -0
- package/dist/Badge.js +36 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Banner.d.ts +27 -0
- package/dist/Banner.js +56 -0
- package/dist/Banner.js.map +1 -0
- package/dist/BlurBox.d.ts +5 -0
- package/dist/BlurBox.js +28 -0
- package/dist/BlurBox.js.map +1 -0
- package/dist/BlurBox.native.d.ts +6 -0
- package/dist/BlurBox.native.js +30 -0
- package/dist/BlurBox.native.js.map +1 -0
- package/dist/Body.d.ts +6 -0
- package/dist/Body.js +21 -0
- package/dist/Body.js.map +1 -0
- package/dist/Box.d.ts +3 -0
- package/dist/Box.js +251 -0
- package/dist/Box.js.map +1 -0
- package/dist/Button.d.ts +26 -0
- package/dist/Button.js +120 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +5 -0
- package/dist/Card.js +8 -0
- package/dist/Card.js.map +1 -0
- package/dist/CheckBox.d.ts +3 -0
- package/dist/CheckBox.js +40 -0
- package/dist/CheckBox.js.map +1 -0
- package/dist/Common.d.ts +868 -0
- package/dist/Common.js +46 -0
- package/dist/Common.js.map +1 -0
- package/dist/Constants.d.ts +4 -0
- package/dist/Constants.js +54 -0
- package/dist/Constants.js.map +1 -0
- package/dist/CustomSelect.d.ts +14 -0
- package/dist/CustomSelect.js +43 -0
- package/dist/CustomSelect.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +12 -0
- package/dist/DateTimeActionSheet.js +248 -0
- package/dist/DateTimeActionSheet.js.map +1 -0
- package/dist/DateTimeField.android.d.ts +3 -0
- package/dist/DateTimeField.android.js +66 -0
- package/dist/DateTimeField.android.js.map +1 -0
- package/dist/DateTimeField.d.ts +3 -0
- package/dist/DateTimeField.ios.d.ts +3 -0
- package/dist/DateTimeField.ios.js +48 -0
- package/dist/DateTimeField.ios.js.map +1 -0
- package/dist/DateTimeField.js +35 -0
- package/dist/DateTimeField.js.map +1 -0
- package/dist/DecimalRangeActionSheet.d.ts +18 -0
- package/dist/DecimalRangeActionSheet.js +65 -0
- package/dist/DecimalRangeActionSheet.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +19 -0
- package/dist/ErrorBoundary.js +29 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/ErrorPage.d.ts +10 -0
- package/dist/ErrorPage.js +20 -0
- package/dist/ErrorPage.js.map +1 -0
- package/dist/FernsProvider.d.ts +4 -0
- package/dist/FernsProvider.js +9 -0
- package/dist/FernsProvider.js.map +1 -0
- package/dist/Field.d.ts +17 -0
- package/dist/Field.js +114 -0
- package/dist/Field.js.map +1 -0
- package/dist/FieldWithLabels.d.ts +3 -0
- package/dist/FieldWithLabels.js +8 -0
- package/dist/FieldWithLabels.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/Form.d.ts +22 -0
- package/dist/Form.js +89 -0
- package/dist/Form.js.map +1 -0
- package/dist/HeaderButtons.d.ts +31 -0
- package/dist/HeaderButtons.js +53 -0
- package/dist/HeaderButtons.js.map +1 -0
- package/dist/Heading.d.ts +11 -0
- package/dist/Heading.js +46 -0
- package/dist/Heading.js.map +1 -0
- package/dist/HeightActionSheet.d.ts +16 -0
- package/dist/HeightActionSheet.js +58 -0
- package/dist/HeightActionSheet.js.map +1 -0
- package/dist/Hyperlink.d.ts +43 -0
- package/dist/Hyperlink.js +135 -0
- package/dist/Hyperlink.js.map +1 -0
- package/dist/Icon.d.ts +4 -0
- package/dist/Icon.js +14 -0
- package/dist/Icon.js.map +1 -0
- package/dist/IconButton.d.ts +26 -0
- package/dist/IconButton.js +78 -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 +8 -0
- package/dist/ImageBackground.js.map +1 -0
- package/dist/InfoTooltipButton.d.ts +8 -0
- package/dist/InfoTooltipButton.js +6 -0
- package/dist/InfoTooltipButton.js.map +1 -0
- package/dist/Layer.d.ts +9 -0
- package/dist/Layer.js +12 -0
- package/dist/Layer.js.map +1 -0
- package/dist/Link.d.ts +9 -0
- package/dist/Link.js +12 -0
- package/dist/Link.js.map +1 -0
- package/dist/Mask.d.ts +2 -0
- package/dist/Mask.js +19 -0
- package/dist/Mask.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/Meta.d.ts +5 -0
- package/dist/Meta.js +7 -0
- package/dist/Meta.js.map +1 -0
- package/dist/Modal.d.ts +19 -0
- package/dist/Modal.js +101 -0
- package/dist/Modal.js.map +1 -0
- package/dist/ModalSheet.d.ts +7 -0
- package/dist/ModalSheet.js +42 -0
- package/dist/ModalSheet.js.map +1 -0
- package/dist/NumberPickerActionSheet.d.ts +16 -0
- package/dist/NumberPickerActionSheet.js +29 -0
- package/dist/NumberPickerActionSheet.js.map +1 -0
- package/dist/Page.d.ts +26 -0
- package/dist/Page.js +38 -0
- package/dist/Page.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/PickerSelect.d.ts +109 -0
- package/dist/PickerSelect.js +296 -0
- package/dist/PickerSelect.js.map +1 -0
- package/dist/Pill.d.ts +5 -0
- package/dist/Pill.js +10 -0
- package/dist/Pill.js.map +1 -0
- package/dist/Pog.d.ts +15 -0
- package/dist/Pog.js +48 -0
- package/dist/Pog.js.map +1 -0
- package/dist/ProgressBar.d.ts +9 -0
- package/dist/ProgressBar.js +41 -0
- package/dist/ProgressBar.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/SegmentedControl.d.ts +3 -0
- package/dist/SegmentedControl.js +55 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/SelectList.d.ts +18 -0
- package/dist/SelectList.js +48 -0
- package/dist/SelectList.js.map +1 -0
- package/dist/SideDrawer.d.ts +13 -0
- package/dist/SideDrawer.js +22 -0
- package/dist/SideDrawer.js.map +1 -0
- package/dist/Spinner.d.ts +3 -0
- package/dist/Spinner.js +16 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/SplitPage.d.ts +3 -0
- package/dist/SplitPage.js +149 -0
- package/dist/SplitPage.js.map +1 -0
- package/dist/SplitPage.native.d.ts +3 -0
- package/dist/SplitPage.native.js +79 -0
- package/dist/SplitPage.native.js.map +1 -0
- package/dist/Switch.d.ts +5 -0
- package/dist/Switch.js +10 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Table.d.ts +30 -0
- package/dist/Table.js +31 -0
- package/dist/Table.js.map +1 -0
- package/dist/TableHeader.d.ts +22 -0
- package/dist/TableHeader.js +11 -0
- package/dist/TableHeader.js.map +1 -0
- package/dist/TableHeaderCell.d.ts +15 -0
- package/dist/TableHeaderCell.js +36 -0
- package/dist/TableHeaderCell.js.map +1 -0
- package/dist/TableRow.d.ts +29 -0
- package/dist/TableRow.js +30 -0
- package/dist/TableRow.js.map +1 -0
- package/dist/TapToEdit.d.ts +19 -0
- package/dist/TapToEdit.js +136 -0
- package/dist/TapToEdit.js.map +1 -0
- package/dist/Text.d.ts +19 -0
- package/dist/Text.js +91 -0
- package/dist/Text.js.map +1 -0
- package/dist/TextArea.d.ts +6 -0
- package/dist/TextArea.js +24 -0
- package/dist/TextArea.js.map +1 -0
- package/dist/TextField.d.ts +3 -0
- package/dist/TextField.js +260 -0
- package/dist/TextField.js.map +1 -0
- package/dist/TextFieldNumberActionSheet.d.ts +15 -0
- package/dist/TextFieldNumberActionSheet.js +28 -0
- package/dist/TextFieldNumberActionSheet.js.map +1 -0
- package/dist/Toast.d.ts +12 -0
- package/dist/Toast.js +46 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +9 -0
- package/dist/Tooltip.js +174 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/UnifiedScreens.d.ts +9 -0
- package/dist/UnifiedScreens.js +25 -0
- package/dist/UnifiedScreens.js.map +1 -0
- package/dist/Unifier.d.ts +45 -0
- package/dist/Unifier.js +291 -0
- package/dist/Unifier.js.map +1 -0
- package/dist/Utilities.d.ts +31 -0
- package/dist/Utilities.js +73 -0
- package/dist/Utilities.js.map +1 -0
- package/dist/WithLabel.d.ts +14 -0
- package/dist/WithLabel.js +15 -0
- package/dist/WithLabel.js.map +1 -0
- package/dist/dayjsExtended.d.ts +2 -0
- package/{src/dayjsExtended.ts → dist/dayjsExtended.js} +1 -2
- package/dist/dayjsExtended.js.map +1 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.js.map +1 -0
- package/dist/tableContext.d.ts +21 -0
- package/dist/tableContext.js +35 -0
- package/dist/tableContext.js.map +1 -0
- package/package.json +4 -1
- package/checkDeps.js +0 -19
- package/src/ActionSheet.tsx +0 -1231
- package/src/Avatar.tsx +0 -317
- package/src/Badge.tsx +0 -65
- package/src/Banner.tsx +0 -124
- package/src/BlurBox.native.tsx +0 -40
- package/src/BlurBox.tsx +0 -31
- package/src/Body.tsx +0 -32
- package/src/Box.tsx +0 -308
- package/src/Button.tsx +0 -219
- package/src/Card.tsx +0 -23
- package/src/CheckBox.tsx +0 -118
- package/src/Common.ts +0 -2743
- package/src/Constants.ts +0 -53
- package/src/CustomSelect.tsx +0 -85
- package/src/DateTimeActionSheet.tsx +0 -409
- package/src/DateTimeField.android.tsx +0 -101
- package/src/DateTimeField.ios.tsx +0 -83
- package/src/DateTimeField.tsx +0 -69
- package/src/DecimalRangeActionSheet.tsx +0 -113
- package/src/ErrorBoundary.tsx +0 -37
- package/src/ErrorPage.tsx +0 -44
- package/src/FernsProvider.tsx +0 -21
- package/src/Field.tsx +0 -299
- package/src/FieldWithLabels.tsx +0 -36
- package/src/FlatList.tsx +0 -2
- package/src/Form.tsx +0 -182
- package/src/HeaderButtons.tsx +0 -107
- package/src/Heading.tsx +0 -53
- package/src/HeightActionSheet.tsx +0 -104
- package/src/Hyperlink.tsx +0 -181
- package/src/Icon.tsx +0 -24
- package/src/IconButton.tsx +0 -165
- package/src/Image.tsx +0 -50
- package/src/ImageBackground.tsx +0 -14
- package/src/InfoTooltipButton.tsx +0 -23
- package/src/Layer.tsx +0 -17
- package/src/Link.tsx +0 -17
- package/src/Mask.tsx +0 -21
- package/src/MediaQuery.ts +0 -46
- package/src/Meta.tsx +0 -9
- package/src/Modal.tsx +0 -248
- package/src/ModalSheet.tsx +0 -58
- package/src/NumberPickerActionSheet.tsx +0 -66
- package/src/Page.tsx +0 -133
- package/src/Permissions.ts +0 -44
- package/src/PickerSelect.tsx +0 -553
- package/src/Pill.tsx +0 -24
- package/src/Pog.tsx +0 -87
- package/src/ProgressBar.tsx +0 -55
- package/src/ScrollView.tsx +0 -2
- package/src/SegmentedControl.tsx +0 -102
- package/src/SelectList.tsx +0 -89
- package/src/SideDrawer.tsx +0 -62
- package/src/Spinner.tsx +0 -20
- package/src/SplitPage.native.tsx +0 -160
- package/src/SplitPage.tsx +0 -302
- package/src/Switch.tsx +0 -19
- package/src/Table.tsx +0 -87
- package/src/TableHeader.tsx +0 -36
- package/src/TableHeaderCell.tsx +0 -76
- package/src/TableRow.tsx +0 -87
- package/src/TapToEdit.tsx +0 -221
- package/src/Text.tsx +0 -131
- package/src/TextArea.tsx +0 -16
- package/src/TextField.tsx +0 -401
- package/src/TextFieldNumberActionSheet.tsx +0 -61
- package/src/Toast.tsx +0 -106
- package/src/Tooltip.tsx +0 -269
- package/src/UnifiedScreens.ts +0 -24
- package/src/Unifier.ts +0 -371
- package/src/Utilities.tsx +0 -159
- package/src/WithLabel.tsx +0 -57
- package/src/index.tsx +0 -1346
- package/src/polyfill.d.ts +0 -11
- package/src/tableContext.tsx +0 -80
- package/tsconfig.json +0 -30
- package/updateDeps.js +0 -14
package/src/TapToEdit.tsx
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import React, {ReactElement, useState} from "react";
|
|
2
|
-
import {Linking} from "react-native";
|
|
3
|
-
|
|
4
|
-
import {Box} from "./Box";
|
|
5
|
-
import {Button} from "./Button";
|
|
6
|
-
import {BoxProps} from "./Common";
|
|
7
|
-
import {Field, FieldProps} from "./Field";
|
|
8
|
-
import {Icon} from "./Icon";
|
|
9
|
-
import {Text} from "./Text";
|
|
10
|
-
|
|
11
|
-
export function formatAddress(address: any, asString = false): string {
|
|
12
|
-
let city = "";
|
|
13
|
-
if (address?.city) {
|
|
14
|
-
city = address?.state || address.zipcode ? `${address.city}, ` : `${address.city}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
let state = "";
|
|
18
|
-
if (address?.state) {
|
|
19
|
-
state = address?.zipcode ? `${address.state} ` : `${address.state}`;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const zip = address?.zipcode || "";
|
|
23
|
-
|
|
24
|
-
const addressLineOne = address?.address1 ?? "";
|
|
25
|
-
const addressLineTwo = address?.address2 ?? "";
|
|
26
|
-
const addressLineThree = `${city}${state}${zip}`;
|
|
27
|
-
|
|
28
|
-
if (!asString) {
|
|
29
|
-
// Only add new lines if lines before and after are not empty to avoid awkward whitespace
|
|
30
|
-
return `${addressLineOne}${
|
|
31
|
-
addressLineOne && (addressLineTwo || addressLineThree) ? `\n` : ""
|
|
32
|
-
}${addressLineTwo}${addressLineTwo && addressLineThree ? `\n` : ""}${addressLineThree}`;
|
|
33
|
-
} else {
|
|
34
|
-
return `${addressLineOne}${
|
|
35
|
-
addressLineOne && (addressLineTwo || addressLineThree) ? `, ` : ""
|
|
36
|
-
}${addressLineTwo}${addressLineTwo && addressLineThree ? `, ` : ""}${addressLineThree}`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface TapToEditProps extends Omit<FieldProps, "onChange" | "value"> {
|
|
41
|
-
title: string;
|
|
42
|
-
value: any;
|
|
43
|
-
// Not required if not editable.
|
|
44
|
-
setValue?: (value: any) => void;
|
|
45
|
-
// Not required if not editable.
|
|
46
|
-
onSave?: (value: any) => void | Promise<void>;
|
|
47
|
-
// Defaults to true
|
|
48
|
-
editable?: boolean;
|
|
49
|
-
// enable edit mode from outside the component
|
|
50
|
-
isEditing?: boolean;
|
|
51
|
-
// For changing how the non-editing row renders
|
|
52
|
-
rowBoxProps?: Partial<BoxProps>;
|
|
53
|
-
transform?: (value: any) => string;
|
|
54
|
-
fieldComponent?: (setValue: () => void) => ReactElement;
|
|
55
|
-
withConfirmation?: boolean;
|
|
56
|
-
confirmationText?: string;
|
|
57
|
-
confirmationHeading?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const TapToEdit = ({
|
|
61
|
-
value,
|
|
62
|
-
setValue,
|
|
63
|
-
placeholder,
|
|
64
|
-
title,
|
|
65
|
-
onSave,
|
|
66
|
-
editable = true,
|
|
67
|
-
isEditing = false,
|
|
68
|
-
rowBoxProps,
|
|
69
|
-
transform,
|
|
70
|
-
fieldComponent,
|
|
71
|
-
withConfirmation = false,
|
|
72
|
-
confirmationText = "Are you sure you want to save your changes?",
|
|
73
|
-
confirmationHeading = "Confirm",
|
|
74
|
-
...fieldProps
|
|
75
|
-
}: TapToEditProps): ReactElement => {
|
|
76
|
-
const [editing, setEditing] = useState(false);
|
|
77
|
-
const [initialValue] = useState(value);
|
|
78
|
-
|
|
79
|
-
if (editable && !setValue) {
|
|
80
|
-
throw new Error("setValue is required if editable is true");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (editable && (editing || isEditing)) {
|
|
84
|
-
return (
|
|
85
|
-
<Box direction="column">
|
|
86
|
-
{fieldComponent ? (
|
|
87
|
-
fieldComponent(setValue as any)
|
|
88
|
-
) : (
|
|
89
|
-
<Field
|
|
90
|
-
label={title}
|
|
91
|
-
placeholder={placeholder}
|
|
92
|
-
value={value}
|
|
93
|
-
onChange={setValue}
|
|
94
|
-
{...fieldProps}
|
|
95
|
-
/>
|
|
96
|
-
)}
|
|
97
|
-
{editing && !isEditing && (
|
|
98
|
-
<Box direction="row">
|
|
99
|
-
<Button
|
|
100
|
-
color="blue"
|
|
101
|
-
confirmationHeading={confirmationHeading}
|
|
102
|
-
confirmationText={confirmationText}
|
|
103
|
-
inline
|
|
104
|
-
text="Save"
|
|
105
|
-
withConfirmation={withConfirmation}
|
|
106
|
-
onClick={async (): Promise<void> => {
|
|
107
|
-
if (!onSave) {
|
|
108
|
-
console.error("No onSave provided for editable TapToEdit");
|
|
109
|
-
} else {
|
|
110
|
-
await onSave(value);
|
|
111
|
-
}
|
|
112
|
-
setEditing(false);
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
<Box marginLeft={2}>
|
|
116
|
-
<Button
|
|
117
|
-
color="red"
|
|
118
|
-
inline
|
|
119
|
-
text="Cancel"
|
|
120
|
-
onClick={(): void => {
|
|
121
|
-
if (setValue) {
|
|
122
|
-
setValue(initialValue);
|
|
123
|
-
}
|
|
124
|
-
setEditing(false);
|
|
125
|
-
}}
|
|
126
|
-
/>
|
|
127
|
-
</Box>
|
|
128
|
-
</Box>
|
|
129
|
-
)}
|
|
130
|
-
</Box>
|
|
131
|
-
);
|
|
132
|
-
} else {
|
|
133
|
-
let displayValue = value;
|
|
134
|
-
// If a transform props is present, that takes priority
|
|
135
|
-
if (transform) {
|
|
136
|
-
displayValue = transform(value);
|
|
137
|
-
} else {
|
|
138
|
-
// If no transform, try and display the value reasonably.
|
|
139
|
-
if (fieldProps?.type === "boolean") {
|
|
140
|
-
displayValue = value ? "Yes" : "No";
|
|
141
|
-
} else if (fieldProps?.type === "percent") {
|
|
142
|
-
// Prevent floating point errors from showing up by using parseFloat and precision. Pass through parseFloat again
|
|
143
|
-
// to trim off insignificant zeroes.
|
|
144
|
-
displayValue = `${parseFloat(parseFloat(String(value * 100)).toPrecision(7))}%`;
|
|
145
|
-
} else if (fieldProps?.type === "currency") {
|
|
146
|
-
// TODO: support currencies other than USD in Field and related components.
|
|
147
|
-
const formatter = new Intl.NumberFormat("en-US", {
|
|
148
|
-
style: "currency",
|
|
149
|
-
currency: "USD",
|
|
150
|
-
minimumFractionDigits: 2, // (this suffices for whole numbers, but will print 2500.10 as $2,500.1)
|
|
151
|
-
});
|
|
152
|
-
displayValue = formatter.format(value);
|
|
153
|
-
} else if (fieldProps?.type === "multiselect") {
|
|
154
|
-
// ???
|
|
155
|
-
displayValue = value.join(", ");
|
|
156
|
-
} else if (fieldProps?.type === "url") {
|
|
157
|
-
// Show only the domain, full links are likely too long.
|
|
158
|
-
try {
|
|
159
|
-
const url = new URL(value);
|
|
160
|
-
displayValue = url?.hostname ?? value;
|
|
161
|
-
} catch (e) {
|
|
162
|
-
// Don't print an error message for empty values.
|
|
163
|
-
if (value) {
|
|
164
|
-
console.debug(`Invalid URL: ${value}`);
|
|
165
|
-
}
|
|
166
|
-
displayValue = value;
|
|
167
|
-
}
|
|
168
|
-
} else if (fieldProps?.type === "address") {
|
|
169
|
-
displayValue = formatAddress(value);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const openLink = (): void => {
|
|
174
|
-
if (fieldProps?.type === "url") {
|
|
175
|
-
Linking.openURL(value);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<Box
|
|
181
|
-
direction="row"
|
|
182
|
-
justifyContent="between"
|
|
183
|
-
paddingX={3}
|
|
184
|
-
paddingY={2}
|
|
185
|
-
width="100%"
|
|
186
|
-
{...rowBoxProps}
|
|
187
|
-
>
|
|
188
|
-
<Box>
|
|
189
|
-
<Text weight="bold">{title}:</Text>
|
|
190
|
-
{fieldProps?.type === "address" && (
|
|
191
|
-
<Box
|
|
192
|
-
onClick={
|
|
193
|
-
() =>
|
|
194
|
-
Linking.openURL(
|
|
195
|
-
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(
|
|
196
|
-
formatAddress(value, true)
|
|
197
|
-
)}`
|
|
198
|
-
)
|
|
199
|
-
// eslint-disable-next-line react/jsx-curly-newline
|
|
200
|
-
}
|
|
201
|
-
>
|
|
202
|
-
<Text color="blue" underline={fieldProps?.type === "address"}>
|
|
203
|
-
Google Maps
|
|
204
|
-
</Text>
|
|
205
|
-
</Box>
|
|
206
|
-
)}
|
|
207
|
-
</Box>
|
|
208
|
-
<Box direction="row">
|
|
209
|
-
<Box onClick={fieldProps?.type === "url" ? openLink : undefined}>
|
|
210
|
-
<Text underline={fieldProps?.type === "url"}>{displayValue}</Text>
|
|
211
|
-
</Box>
|
|
212
|
-
{editable && (
|
|
213
|
-
<Box marginLeft={2} onClick={(): void => setEditing(true)}>
|
|
214
|
-
<Icon color="darkGray" name="edit" prefix="far" size="md" />
|
|
215
|
-
</Box>
|
|
216
|
-
)}
|
|
217
|
-
</Box>
|
|
218
|
-
</Box>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
};
|
package/src/Text.tsx
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {Text as NativeText, TextStyle} from "react-native";
|
|
3
|
-
|
|
4
|
-
import {AllColors, Font, TextSize} from "./Common";
|
|
5
|
-
import {Hyperlink} from "./Hyperlink";
|
|
6
|
-
import {Unifier} from "./Unifier";
|
|
7
|
-
|
|
8
|
-
export interface TextProps {
|
|
9
|
-
align?: "left" | "right" | "center" | "justify"; // default "left"
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
color?: AllColors;
|
|
12
|
-
inline?: boolean; // default false
|
|
13
|
-
italic?: boolean; // default false
|
|
14
|
-
overflow?: "normal" | "breakWord"; // deprecated
|
|
15
|
-
size?: TextSize; // default "md"
|
|
16
|
-
truncate?: boolean; // default false
|
|
17
|
-
font?: Font;
|
|
18
|
-
underline?: boolean;
|
|
19
|
-
numberOfLines?: number;
|
|
20
|
-
skipLinking?: boolean;
|
|
21
|
-
weight?: "bold" | "normal";
|
|
22
|
-
testID?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const fontSizes = {
|
|
26
|
-
sm: 12,
|
|
27
|
-
md: 14,
|
|
28
|
-
lg: 16,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export function Text({
|
|
32
|
-
align = "left",
|
|
33
|
-
children,
|
|
34
|
-
color,
|
|
35
|
-
inline = false,
|
|
36
|
-
italic = false,
|
|
37
|
-
overflow,
|
|
38
|
-
size = "md",
|
|
39
|
-
truncate = false,
|
|
40
|
-
font,
|
|
41
|
-
underline,
|
|
42
|
-
numberOfLines,
|
|
43
|
-
skipLinking,
|
|
44
|
-
testID,
|
|
45
|
-
weight = "normal",
|
|
46
|
-
}: TextProps): React.ReactElement {
|
|
47
|
-
function propsToStyle(): any {
|
|
48
|
-
const style: TextStyle = {};
|
|
49
|
-
if (overflow) {
|
|
50
|
-
console.warn(
|
|
51
|
-
"Text overflow is deprecated. Use `truncate` to cut off the text and add ellipse, otherwise breakWord is the default."
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
let computedFont = "primary";
|
|
55
|
-
if (font === "primary" || !font) {
|
|
56
|
-
if (weight === "bold") {
|
|
57
|
-
computedFont = "primaryBoldFont";
|
|
58
|
-
} else {
|
|
59
|
-
computedFont = "primaryFont";
|
|
60
|
-
}
|
|
61
|
-
} else if (font === "secondary") {
|
|
62
|
-
if (weight === "bold") {
|
|
63
|
-
computedFont = "secondaryBoldFont";
|
|
64
|
-
} else {
|
|
65
|
-
computedFont = "secondaryFont";
|
|
66
|
-
}
|
|
67
|
-
} else if (font === "button") {
|
|
68
|
-
computedFont = "buttonFont";
|
|
69
|
-
} else if (font === "title") {
|
|
70
|
-
computedFont = "titleFont";
|
|
71
|
-
} else if (font === "accent") {
|
|
72
|
-
if (weight === "bold") {
|
|
73
|
-
computedFont = "accentBoldFont";
|
|
74
|
-
} else {
|
|
75
|
-
computedFont = "accentFont";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (weight === "bold") {
|
|
79
|
-
style.fontWeight = "bold";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
style.fontFamily = Unifier.theme[computedFont as keyof typeof Unifier.theme];
|
|
83
|
-
|
|
84
|
-
style.fontSize = fontSizes[size || "md"];
|
|
85
|
-
if (align) {
|
|
86
|
-
style.textAlign = align;
|
|
87
|
-
}
|
|
88
|
-
if (color) {
|
|
89
|
-
style.color = Unifier.theme[color];
|
|
90
|
-
} else {
|
|
91
|
-
style.color = Unifier.theme.darkGray;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (italic) {
|
|
95
|
-
style.fontStyle = "italic";
|
|
96
|
-
}
|
|
97
|
-
if (underline) {
|
|
98
|
-
style.textDecorationLine = "underline";
|
|
99
|
-
}
|
|
100
|
-
// TODO: might be useful for wrapping/truncating
|
|
101
|
-
// if (numberOfLines !== 1 && !inline) {
|
|
102
|
-
// style.flexWrap = "wrap";
|
|
103
|
-
// }
|
|
104
|
-
|
|
105
|
-
return style;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let lines = 0;
|
|
109
|
-
if (numberOfLines && truncate && numberOfLines > 1) {
|
|
110
|
-
console.error(`Cannot truncate Text and have ${numberOfLines} lines`);
|
|
111
|
-
}
|
|
112
|
-
if (numberOfLines) {
|
|
113
|
-
lines = numberOfLines;
|
|
114
|
-
} else if (inline || truncate) {
|
|
115
|
-
lines = 1;
|
|
116
|
-
}
|
|
117
|
-
const inner = (
|
|
118
|
-
<NativeText numberOfLines={lines} style={propsToStyle()} testID={testID}>
|
|
119
|
-
{children}
|
|
120
|
-
</NativeText>
|
|
121
|
-
);
|
|
122
|
-
if (skipLinking) {
|
|
123
|
-
return inner;
|
|
124
|
-
} else {
|
|
125
|
-
return (
|
|
126
|
-
<Hyperlink linkDefault linkStyle={{textDecorationLine: "underline"}}>
|
|
127
|
-
{inner}
|
|
128
|
-
</Hyperlink>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
}
|
package/src/TextArea.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import {TextAreaProps} from "./Common";
|
|
4
|
-
import {TextField} from "./TextField";
|
|
5
|
-
|
|
6
|
-
export class TextArea extends React.Component<TextAreaProps, {}> {
|
|
7
|
-
constructor(props: TextAreaProps) {
|
|
8
|
-
super(props);
|
|
9
|
-
this.state = {};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
const {height, ...props} = this.props;
|
|
14
|
-
return <TextField {...props} height={height ?? 100} multiline />;
|
|
15
|
-
}
|
|
16
|
-
}
|