ferns-ui 0.26.0 → 0.26.2
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 +1 -1
- package/dist/ActionSheet.js +1 -2
- package/dist/ActionSheet.js.map +1 -1
- package/dist/CheckBox.d.ts +1 -4
- package/dist/CheckBox.js +33 -20
- package/dist/CheckBox.js.map +1 -1
- package/dist/Common.d.ts +44 -10
- package/dist/Common.js.map +1 -1
- package/dist/DateTimeField.android.d.ts +1 -1
- package/dist/DateTimeField.android.js +58 -16
- package/dist/DateTimeField.android.js.map +1 -1
- package/dist/DateTimeField.d.ts +2 -2
- package/dist/DateTimeField.ios.d.ts +1 -1
- package/dist/DateTimeField.ios.js +43 -12
- package/dist/DateTimeField.ios.js.map +1 -1
- package/dist/DateTimeField.js.map +1 -1
- package/dist/Field.js +2 -2
- package/dist/Field.js.map +1 -1
- package/dist/Mask.d.ts +2 -3
- package/dist/MediaQuery.d.ts +1 -0
- package/dist/MediaQuery.js +16 -0
- package/dist/MediaQuery.js.map +1 -1
- package/dist/Page.js.map +1 -1
- package/dist/SegmentedControl.js +6 -2
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/SelectList.d.ts +1 -1
- package/dist/SelectList.js +9 -8
- package/dist/SelectList.js.map +1 -1
- package/dist/SplitPage.d.ts +3 -21
- package/dist/SplitPage.js +78 -23
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +3 -0
- package/dist/SplitPage.native.js +75 -0
- package/dist/SplitPage.native.js.map +1 -0
- package/dist/TapToEdit.d.ts +1 -0
- package/dist/TapToEdit.js +27 -17
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TextField.js +11 -6
- package/dist/TextField.js.map +1 -1
- package/dist/Utilities.js +1 -2
- package/dist/Utilities.js.map +1 -1
- package/dist/WithLabel.d.ts +3 -3
- package/dist/WithLabel.js +3 -0
- package/dist/WithLabel.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/ActionSheet.tsx +2 -3
- package/src/CheckBox.tsx +85 -60
- package/src/Common.ts +49 -10
- package/src/DateTimeField.android.tsx +71 -26
- package/src/DateTimeField.ios.tsx +55 -13
- package/src/DateTimeField.tsx +2 -2
- package/src/Field.tsx +4 -4
- package/src/Mask.tsx +2 -2
- package/src/MediaQuery.ts +14 -0
- package/src/Page.tsx +0 -1
- package/src/SegmentedControl.tsx +3 -3
- package/src/SelectList.tsx +9 -2
- package/src/SplitPage.native.tsx +156 -0
- package/src/SplitPage.tsx +136 -47
- package/src/TapToEdit.tsx +31 -22
- package/src/TextField.tsx +26 -17
- package/src/Utilities.tsx +1 -3
- package/src/WithLabel.tsx +6 -3
- package/src/index.tsx +6 -5
package/src/TapToEdit.tsx
CHANGED
|
@@ -8,6 +8,29 @@ import {Field, FieldProps} from "./Field";
|
|
|
8
8
|
import {Icon} from "./Icon";
|
|
9
9
|
import {Text} from "./Text";
|
|
10
10
|
|
|
11
|
+
export function formatAddress(address: any): 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
|
+
// Only add new lines if lines before and after are not empty to avoid awkward whitespace
|
|
29
|
+
return `${addressLineOne}${
|
|
30
|
+
addressLineOne && (addressLineTwo || addressLineThree) ? `\n` : ""
|
|
31
|
+
}${addressLineTwo}${addressLineTwo && addressLineThree ? `\n` : ""}${addressLineThree}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
export interface TapToEditProps extends Omit<FieldProps, "onChange" | "value"> {
|
|
12
35
|
title: string;
|
|
13
36
|
value: any;
|
|
@@ -113,29 +136,15 @@ export const TapToEdit = ({
|
|
|
113
136
|
displayValue = value.join(", ");
|
|
114
137
|
} else if (fieldProps?.type === "url") {
|
|
115
138
|
// Show only the domain, full links are likely too long.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
let state = "";
|
|
125
|
-
if (value?.state) {
|
|
126
|
-
state = value?.zipcode ? `${value.state} ` : `${value.state}`;
|
|
139
|
+
try {
|
|
140
|
+
const url = new URL(value);
|
|
141
|
+
displayValue = url?.hostname ?? value;
|
|
142
|
+
} catch (e) {
|
|
143
|
+
console.debug(`Invalid URL: ${value}`);
|
|
144
|
+
displayValue = value;
|
|
127
145
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const addressLineOne = value?.address1 ?? "";
|
|
132
|
-
const addressLineTwo = value?.address2 ?? "";
|
|
133
|
-
const addressLineThree = `${city}${state}${zip}`;
|
|
134
|
-
|
|
135
|
-
// Only add new lines if lines before and after are not empty to avoid awkward whitespace
|
|
136
|
-
displayValue = `${addressLineOne}${
|
|
137
|
-
addressLineOne && (addressLineTwo || addressLineThree) ? `\n` : ""
|
|
138
|
-
}${addressLineTwo}${addressLineTwo && addressLineThree ? `\n` : ""}${addressLineThree}`;
|
|
146
|
+
} else if (fieldProps?.type === "address") {
|
|
147
|
+
displayValue = formatAddress(value);
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
|
package/src/TextField.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {AsYouType} from "libphonenumber-js";
|
|
2
2
|
import moment from "moment-timezone";
|
|
3
|
-
import React, {ReactElement, useState} from "react";
|
|
3
|
+
import React, {ReactElement, useCallback, useMemo, useState} from "react";
|
|
4
4
|
import {ActivityIndicator, KeyboardTypeOptions, Platform, TextInput, View} from "react-native";
|
|
5
5
|
import {Calendar} from "react-native-calendars";
|
|
6
6
|
|
|
@@ -168,7 +168,7 @@ export function TextField({
|
|
|
168
168
|
borderColor = Unifier.theme.gray;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
const getHeight = () => {
|
|
171
|
+
const getHeight = useCallback(() => {
|
|
172
172
|
if (grow) {
|
|
173
173
|
return Math.max(40, height);
|
|
174
174
|
} else if (multiline) {
|
|
@@ -176,7 +176,29 @@ export function TextField({
|
|
|
176
176
|
} else {
|
|
177
177
|
return 40;
|
|
178
178
|
}
|
|
179
|
-
};
|
|
179
|
+
}, [grow, height, multiline]);
|
|
180
|
+
|
|
181
|
+
const defaultTextInputStyles = useMemo(() => {
|
|
182
|
+
const defaultStyles = {
|
|
183
|
+
flex: 1,
|
|
184
|
+
paddingTop: 10,
|
|
185
|
+
paddingRight: 10,
|
|
186
|
+
paddingBottom: 10,
|
|
187
|
+
paddingLeft: 0,
|
|
188
|
+
height: getHeight(),
|
|
189
|
+
width: "100%",
|
|
190
|
+
color: Unifier.theme.darkGray,
|
|
191
|
+
fontFamily: Unifier.theme.primaryFont,
|
|
192
|
+
...style,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (Platform.OS === "web") {
|
|
196
|
+
defaultStyles.outline = 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return defaultStyles;
|
|
200
|
+
}, [getHeight, style]);
|
|
201
|
+
|
|
180
202
|
const isHandledByModal =
|
|
181
203
|
type === "date" || type === "numberRange" || type === "decimalRange" || type === "height";
|
|
182
204
|
|
|
@@ -269,20 +291,7 @@ export function TextField({
|
|
|
269
291
|
placeholderTextColor={Unifier.theme.gray}
|
|
270
292
|
returnKeyType={type === "number" || type === "decimal" ? "done" : returnKeyType}
|
|
271
293
|
secureTextEntry={type === "password"}
|
|
272
|
-
style={
|
|
273
|
-
flex: 1,
|
|
274
|
-
paddingTop: 10,
|
|
275
|
-
paddingRight: 10,
|
|
276
|
-
paddingBottom: 10,
|
|
277
|
-
paddingLeft: 0,
|
|
278
|
-
height: getHeight(),
|
|
279
|
-
width: "100%",
|
|
280
|
-
color: Unifier.theme.darkGray,
|
|
281
|
-
fontFamily: Unifier.theme.primaryFont,
|
|
282
|
-
// Remove border in web.
|
|
283
|
-
outlineWidth: 0,
|
|
284
|
-
...style,
|
|
285
|
-
}}
|
|
294
|
+
style={defaultTextInputStyles}
|
|
286
295
|
// For react-native-autofocus
|
|
287
296
|
textContentType={textContentType}
|
|
288
297
|
underlineColorAndroid="transparent"
|
package/src/Utilities.tsx
CHANGED
|
@@ -4,14 +4,12 @@ import get from "lodash/get";
|
|
|
4
4
|
|
|
5
5
|
export function mergeInlineStyles(inlineStyle?: any, newStyle?: any) {
|
|
6
6
|
const inline = get(inlineStyle, "__style");
|
|
7
|
-
|
|
7
|
+
return {
|
|
8
8
|
__style: {
|
|
9
9
|
...inline,
|
|
10
10
|
...newStyle,
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
return dangerouslySetInlineStyle;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
/*
|
package/src/WithLabel.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import {Box} from "./Box";
|
|
4
|
-
import {AllColors, JustifyContent, TextSize} from "./Common";
|
|
4
|
+
import {AllColors, JustifyContent, ReactChildren, TextSize} from "./Common";
|
|
5
5
|
import {Text} from "./Text";
|
|
6
6
|
|
|
7
7
|
export interface WithLabelProps {
|
|
8
|
-
children
|
|
8
|
+
children?: ReactChildren;
|
|
9
9
|
show?: boolean;
|
|
10
10
|
label?: string;
|
|
11
11
|
labelInline?: boolean;
|
|
@@ -24,7 +24,10 @@ export function WithLabel({
|
|
|
24
24
|
labelColor,
|
|
25
25
|
show,
|
|
26
26
|
children,
|
|
27
|
-
}: WithLabelProps) {
|
|
27
|
+
}: WithLabelProps): React.ReactElement | null {
|
|
28
|
+
if (!children) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
28
31
|
return (
|
|
29
32
|
<Box
|
|
30
33
|
direction={labelInline ? "row" : "column"}
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./Constants";
|
|
2
2
|
export * from "./Common";
|
|
3
|
+
export * from "./MediaQuery";
|
|
3
4
|
export * from "./ActionSheet";
|
|
4
5
|
export * from "./Avatar";
|
|
5
6
|
export * from "./Badge";
|
|
@@ -69,7 +70,7 @@ interface Insets {
|
|
|
69
70
|
right?: number;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
// Lifted from react-native-
|
|
73
|
+
// Lifted from react-native-navigation
|
|
73
74
|
// import {Options} from "./Options";
|
|
74
75
|
export interface LayoutComponent<P = {}> {
|
|
75
76
|
/**
|
|
@@ -453,7 +454,7 @@ export interface OptionsTopBarTitle {
|
|
|
453
454
|
passProps?: object;
|
|
454
455
|
};
|
|
455
456
|
/**
|
|
456
|
-
* Top Bar title height in
|
|
457
|
+
* Top Bar title height in density pixels
|
|
457
458
|
* #### (Android specific)
|
|
458
459
|
*/
|
|
459
460
|
height?: number;
|
|
@@ -496,7 +497,7 @@ export interface OptionsTopBarBackButton {
|
|
|
496
497
|
*/
|
|
497
498
|
icon?: ImageRequireSource;
|
|
498
499
|
/**
|
|
499
|
-
*
|
|
500
|
+
* Whether the back button is visible or not
|
|
500
501
|
* @default true
|
|
501
502
|
*/
|
|
502
503
|
visible?: boolean;
|
|
@@ -1005,14 +1006,14 @@ export interface OverlayOptions {
|
|
|
1005
1006
|
*/
|
|
1006
1007
|
interceptTouchOutside?: boolean;
|
|
1007
1008
|
/**
|
|
1008
|
-
* Control
|
|
1009
|
+
* Control whether this Overlay should handle Keyboard events.
|
|
1009
1010
|
* Set this to true if your Overlay contains a TextInput.
|
|
1010
1011
|
*/
|
|
1011
1012
|
handleKeyboardEvents?: boolean;
|
|
1012
1013
|
}
|
|
1013
1014
|
export interface ModalOptions {
|
|
1014
1015
|
/**
|
|
1015
|
-
* Control
|
|
1016
|
+
* Control whether this modal should be dismiss using swipe gesture when the modalPresentationStyle = 'pageSheet'
|
|
1016
1017
|
* #### (iOS specific)
|
|
1017
1018
|
*/
|
|
1018
1019
|
swipeToDismiss?: boolean;
|