ferns-ui 0.45.4 → 0.46.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/DateUtilities.d.ts +5 -5
- package/dist/FernsProvider.d.ts +1 -1
- package/dist/TapToEdit.js +17 -21
- package/dist/TapToEdit.js.map +1 -1
- package/dist/useStoredState.d.ts +1 -1
- package/package.json +36 -33
- package/src/TapToEdit.tsx +46 -29
package/dist/DateUtilities.d.ts
CHANGED
|
@@ -22,13 +22,13 @@ export declare function humanDateAndTime(date: string, { timezone, showTimezone
|
|
|
22
22
|
showTimezone?: boolean;
|
|
23
23
|
}): string;
|
|
24
24
|
export declare const printDate: (date?: string, { timezone, showTimezone, ignoreTime, defaultValue, }?: {
|
|
25
|
-
timezone?: string
|
|
26
|
-
showTimezone?: boolean
|
|
27
|
-
ignoreTime?: boolean
|
|
28
|
-
defaultValue?: string
|
|
25
|
+
timezone?: string;
|
|
26
|
+
showTimezone?: boolean;
|
|
27
|
+
ignoreTime?: boolean;
|
|
28
|
+
defaultValue?: string;
|
|
29
29
|
}) => string;
|
|
30
30
|
export declare const printOnlyDate: (date?: string, { defaultValue, }?: {
|
|
31
|
-
defaultValue?: string
|
|
31
|
+
defaultValue?: string;
|
|
32
32
|
}) => string;
|
|
33
33
|
export declare function printTime(date?: string, { timezone, showTimezone, defaultValue, }?: {
|
|
34
34
|
timezone: string;
|
package/dist/FernsProvider.d.ts
CHANGED
package/dist/TapToEdit.js
CHANGED
|
@@ -18,6 +18,13 @@ import { Icon } from "./Icon";
|
|
|
18
18
|
// import {useOpenAPISpec} from "./OpenAPIContext";
|
|
19
19
|
import { Text } from "./Text";
|
|
20
20
|
import { Tooltip } from "./Tooltip";
|
|
21
|
+
const TapToEditTitle = ({ title, description, showDescriptionAsTooltip, onlyShowDescriptionWhileEditing, }) => {
|
|
22
|
+
return (React.createElement(Box, { flex: "grow", marginBottom: 2 },
|
|
23
|
+
React.createElement(Text, { weight: "bold" },
|
|
24
|
+
title,
|
|
25
|
+
":"),
|
|
26
|
+
Boolean(description && !showDescriptionAsTooltip && !onlyShowDescriptionWhileEditing) && (React.createElement(Text, { color: "gray", size: "sm" }, description))));
|
|
27
|
+
};
|
|
21
28
|
export function formatAddress(address, asString = false) {
|
|
22
29
|
var _a, _b, _c, _d;
|
|
23
30
|
let city = "";
|
|
@@ -45,17 +52,10 @@ export function formatAddress(address, asString = false) {
|
|
|
45
52
|
}
|
|
46
53
|
export const TapToEdit = (_a) => {
|
|
47
54
|
var _b;
|
|
48
|
-
var { value, setValue, placeholder, title, onSave, editable = true, isEditing = false, rowBoxProps, transform, fieldComponent, withConfirmation = false, confirmationText = "Are you sure you want to save your changes?", confirmationHeading = "Confirm", description: propsDescription,
|
|
49
|
-
// openApiModel,
|
|
50
|
-
// openApiField,
|
|
51
|
-
showDescriptionAsTooltip = false, onlyShowDescriptionWhileEditing = true } = _a, fieldProps = __rest(_a, ["value", "setValue", "placeholder", "title", "onSave", "editable", "isEditing", "rowBoxProps", "transform", "fieldComponent", "withConfirmation", "confirmationText", "confirmationHeading", "description", "showDescriptionAsTooltip", "onlyShowDescriptionWhileEditing"]);
|
|
55
|
+
var { value, setValue, placeholder, title, onSave, editable = true, isEditing = false, rowBoxProps, transform, fieldComponent, withConfirmation = false, confirmationText = "Are you sure you want to save your changes?", confirmationHeading = "Confirm", description: propsDescription, showDescriptionAsTooltip = false, onlyShowDescriptionWhileEditing = true } = _a, fieldProps = __rest(_a, ["value", "setValue", "placeholder", "title", "onSave", "editable", "isEditing", "rowBoxProps", "transform", "fieldComponent", "withConfirmation", "confirmationText", "confirmationHeading", "description", "showDescriptionAsTooltip", "onlyShowDescriptionWhileEditing"]);
|
|
52
56
|
const [editing, setEditing] = useState(false);
|
|
53
57
|
const [initialValue] = useState(value);
|
|
54
|
-
// const {getModelField} = useOpenAPISpec();
|
|
55
58
|
const description = propsDescription;
|
|
56
|
-
// if (!description && openApiModel && openApiField) {
|
|
57
|
-
// description = getModelField(openApiModel, openApiField)?.description;
|
|
58
|
-
// }
|
|
59
59
|
if (editable && !setValue) {
|
|
60
60
|
throw new Error("setValue is required if editable is true");
|
|
61
61
|
}
|
|
@@ -136,19 +136,15 @@ export const TapToEdit = (_a) => {
|
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
const isClickable = (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.type) === "url" || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.type) === "address";
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
React.createElement(Box, { direction: "row", justifyContent: "start", marginLeft: 2 },
|
|
149
|
-
React.createElement(Box, { justifyContent: "start", onClick: isClickable ? openLink : undefined },
|
|
150
|
-
React.createElement(Text, { align: "right", underline: isClickable }, displayValue)),
|
|
151
|
-
editable && (React.createElement(Box, { marginLeft: 2, onClick: () => setEditing(true) },
|
|
139
|
+
// For textarea to display correctly, we place the title on its own line, then the text
|
|
140
|
+
// on the next line. This is because the textarea will take up the full width of the row.
|
|
141
|
+
return (React.createElement(Box, Object.assign({ alignItems: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.type) === "textarea" ? "start" : "center", direction: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.type) === "textarea" ? "column" : "row", justifyContent: "between", paddingX: 3, paddingY: 2, width: "100%" }, rowBoxProps),
|
|
142
|
+
showDescriptionAsTooltip ? (React.createElement(Tooltip, { idealDirection: "top", text: description },
|
|
143
|
+
React.createElement(TapToEditTitle, { description: description, onlyShowDescriptionWhileEditing: onlyShowDescriptionWhileEditing, showDescriptionAsTooltip: showDescriptionAsTooltip, title: title }))) : (React.createElement(TapToEditTitle, { description: description, onlyShowDescriptionWhileEditing: onlyShowDescriptionWhileEditing, showDescriptionAsTooltip: showDescriptionAsTooltip, title: title })),
|
|
144
|
+
React.createElement(Box, { direction: "row", flex: "grow", justifyContent: "end", marginLeft: 2 },
|
|
145
|
+
React.createElement(Box, { flex: "grow", justifyContent: "start", onClick: isClickable ? openLink : undefined },
|
|
146
|
+
React.createElement(Text, { align: (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.type) === "textarea" ? "left" : "right", underline: isClickable }, displayValue)),
|
|
147
|
+
editable && (React.createElement(Box, { alignSelf: "end", marginLeft: 2, width: 16, onClick: () => setEditing(true) },
|
|
152
148
|
React.createElement(Icon, { color: "darkGray", name: "edit", prefix: "far", size: "md" }))))));
|
|
153
149
|
}
|
|
154
150
|
};
|
package/dist/TapToEdit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TapToEdit.js","sourceRoot":"","sources":["../src/TapToEdit.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAe,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,mDAAmD;AACnD,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,QAAQ,GAAG,KAAK;;IAC1D,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,CAAC;QAClB,IAAI,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,KAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC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,wBAAwB,EAClD,KAAK,EAAE,KAAK,GACZ,CACM,CACX,CAAC,CAAC,CAAC,CACF,oBAAC,cAAc,IACb,WAAW,EAAE,WAAW,EACxB,+BAA+B,EAAE,+BAA+B,EAChE,wBAAwB,EAAE,wBAAwB,EAClD,KAAK,EAAE,KAAK,GACZ,CACH;YACD,oBAAC,GAAG,IAAC,SAAS,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,cAAc,EAAC,KAAK,EAAC,UAAU,EAAE,CAAC;gBACjE,oBAAC,GAAG,IAAC,IAAI,EAAC,MAAM,EAAC,cAAc,EAAC,OAAO,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;oBACjF,oBAAC,IAAI,IACH,KAAK,EAAE,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,MAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACzD,SAAS,EAAE,WAAW,IAErB,YAAY,CACR,CACH;gBACL,QAAQ,IAAI,CACX,oBAAC,GAAG,IAAC,SAAS,EAAC,KAAK,EAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,GAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;oBAClF,oBAAC,IAAI,IAAC,KAAK,EAAC,UAAU,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,IAAI,EAAC,IAAI,GAAG,CACxD,CACP,CACG,CACF,CACP,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
package/dist/useStoredState.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useStoredState: <T>(key: string, initialValue?: T
|
|
1
|
+
export declare const useStoredState: <T>(key: string, initialValue?: T) => [T | undefined, (value: T | undefined) => Promise<void>];
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ferns-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"local": "tsc-watch --onSuccess \"cp -a dist/* ../flourish/node_modules/ferns-ui/dist\"",
|
|
8
|
-
"lint": "eslint
|
|
9
|
-
"lintfix": "eslint --fix
|
|
8
|
+
"lint": "eslint",
|
|
9
|
+
"lintfix": "eslint --fix",
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"dev": "tsc -w",
|
|
12
12
|
"deps": "node checkDeps.js",
|
|
13
13
|
"test": "TZ=America/New_York jest --watchAll",
|
|
14
|
-
"test:ci": "TZ=America/New_York jest --ci"
|
|
14
|
+
"test:ci": "TZ=America/New_York jest --ci",
|
|
15
|
+
"postinstall": "cd ../.. && patch-package"
|
|
15
16
|
},
|
|
16
17
|
"babel": {
|
|
17
18
|
"presets": [
|
|
@@ -80,19 +81,20 @@
|
|
|
80
81
|
"src/**/*"
|
|
81
82
|
],
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@expo/config-plugins": "~7.
|
|
84
|
+
"@expo/config-plugins": "~7.9.1",
|
|
84
85
|
"@types/jest": "^29.5.12",
|
|
86
|
+
"@types/lodash": "^4.17.0",
|
|
85
87
|
"@types/luxon": "^3.4.2",
|
|
86
|
-
"@types/mdurl": "^
|
|
87
|
-
"@types/react": "~18.2.
|
|
88
|
+
"@types/mdurl": "^2.0.0",
|
|
89
|
+
"@types/react": "~18.2.45",
|
|
88
90
|
"@types/react-datetime-picker": "^5.0.0",
|
|
89
91
|
"@types/react-signature-canvas": "^1.0.5",
|
|
90
92
|
"@types/react-time-picker": "^6.0.0",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^7.0
|
|
92
|
-
"@typescript-eslint/parser": "^7.0
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
94
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
93
95
|
"babel-jest": "^29.7.0",
|
|
94
96
|
"babel-preset-react-app": "^10.0.1",
|
|
95
|
-
"eslint": "^8.
|
|
97
|
+
"eslint": "^8.57.0",
|
|
96
98
|
"eslint-config-prettier": "^9.1.0",
|
|
97
99
|
"eslint-plugin-ban": "^1.6.0",
|
|
98
100
|
"eslint-plugin-comment-length": "^1.7.3",
|
|
@@ -100,13 +102,13 @@
|
|
|
100
102
|
"eslint-plugin-import": "^2.29.1",
|
|
101
103
|
"eslint-plugin-lodash": "^7.1.0",
|
|
102
104
|
"eslint-plugin-prettier": "^5.1.3",
|
|
103
|
-
"eslint-plugin-react": "^7.
|
|
104
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
105
|
+
"eslint-plugin-react": "^7.34.1",
|
|
106
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
105
107
|
"eslint-plugin-react-native": "^4.1.0",
|
|
106
|
-
"eslint-plugin-simple-import-sort": "^12.
|
|
107
|
-
"eslint-plugin-unused-imports": "3.
|
|
108
|
+
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
109
|
+
"eslint-plugin-unused-imports": "3.2.0",
|
|
108
110
|
"jest": "^29.7.0",
|
|
109
|
-
"jest-expo": "~50.0.
|
|
111
|
+
"jest-expo": "~50.0.4",
|
|
110
112
|
"jest-github-actions-reporter": "^1.0.3",
|
|
111
113
|
"mdurl": "^2.0.0",
|
|
112
114
|
"prettier": "^3.2.5",
|
|
@@ -115,15 +117,15 @@
|
|
|
115
117
|
"react-router": "^6.22.1",
|
|
116
118
|
"react-router-dom": "^6.22.1",
|
|
117
119
|
"tsc-watch": "^6.0.4",
|
|
118
|
-
"typescript": "^5.
|
|
120
|
+
"typescript": "^5.4.5"
|
|
119
121
|
},
|
|
120
122
|
"peerDependencies": {
|
|
121
|
-
"react": "
|
|
122
|
-
"react-router": "^6.
|
|
123
|
-
"react-router-dom": "^6.
|
|
123
|
+
"react": "18.2.0",
|
|
124
|
+
"react-router": "^6.22.1",
|
|
125
|
+
"react-router-dom": "^6.22.1"
|
|
124
126
|
},
|
|
125
127
|
"dependencies": {
|
|
126
|
-
"@expo/vector-icons": "^14.0.
|
|
128
|
+
"@expo/vector-icons": "^14.0.1",
|
|
127
129
|
"@react-native-async-storage/async-storage": "1.21.0",
|
|
128
130
|
"@react-native-community/blur": "^4.4.0",
|
|
129
131
|
"@react-native-community/datetimepicker": "7.6.1",
|
|
@@ -133,32 +135,33 @@
|
|
|
133
135
|
"expo-haptics": "~12.8.1",
|
|
134
136
|
"expo-image-manipulator": "~11.8.0",
|
|
135
137
|
"expo-image-picker": "~14.7.1",
|
|
136
|
-
"expo-localization": "~14.8.
|
|
137
|
-
"libphonenumber-js": "^1.10.
|
|
138
|
+
"expo-localization": "~14.8.4",
|
|
139
|
+
"libphonenumber-js": "^1.10.61",
|
|
138
140
|
"lodash": "^4.17.21",
|
|
139
141
|
"luxon": "^3.4.4",
|
|
142
|
+
"patch-package": "^8.0.0",
|
|
140
143
|
"react-app-polyfill": "^3.0.0",
|
|
141
|
-
"react-date-picker": "^
|
|
142
|
-
"react-datetime-picker": "^
|
|
144
|
+
"react-date-picker": "^11.0.0",
|
|
145
|
+
"react-datetime-picker": "^6.0.1",
|
|
143
146
|
"react-dev-utils": "^12.0.1",
|
|
144
147
|
"react-dom": "18.2.0",
|
|
145
|
-
"react-native": "0.73.
|
|
146
|
-
"react-native-actions-sheet": "^0.9.
|
|
147
|
-
"react-native-calendars": "^1.
|
|
148
|
-
"react-native-drawer-layout": "3.
|
|
148
|
+
"react-native": "0.73.6",
|
|
149
|
+
"react-native-actions-sheet": "^0.9.3",
|
|
150
|
+
"react-native-calendars": "^1.1304.1",
|
|
151
|
+
"react-native-drawer-layout": "3.3.0",
|
|
149
152
|
"react-native-gesture-handler": "~2.14.0",
|
|
150
153
|
"react-native-google-places-autocomplete": "^2.5.6",
|
|
151
154
|
"react-native-modalize": "^2.1.1",
|
|
152
|
-
"react-native-permissions": "^4.1.
|
|
153
|
-
"react-native-picker-select": "^9.
|
|
155
|
+
"react-native-permissions": "^4.1.5",
|
|
156
|
+
"react-native-picker-select": "^9.1.3",
|
|
154
157
|
"react-native-portalize": "^1.0.7",
|
|
155
158
|
"react-native-reanimated": "~3.6.2",
|
|
156
|
-
"react-native-signature-canvas": "^4.7.
|
|
159
|
+
"react-native-signature-canvas": "^4.7.2",
|
|
157
160
|
"react-native-svg": "14.1.0",
|
|
158
|
-
"react-native-swiper-flatlist": "^3.2.
|
|
161
|
+
"react-native-swiper-flatlist": "^3.2.4",
|
|
159
162
|
"react-native-toast-notifications": "^3.4.0",
|
|
160
163
|
"react-native-webview": "13.6.4",
|
|
161
164
|
"react-signature-canvas": "^1.0.6",
|
|
162
|
-
"react-time-picker": "^
|
|
165
|
+
"react-time-picker": "^7.0.0"
|
|
163
166
|
}
|
|
164
167
|
}
|
package/src/TapToEdit.tsx
CHANGED
|
@@ -10,6 +10,29 @@ import {Icon} from "./Icon";
|
|
|
10
10
|
import {Text} from "./Text";
|
|
11
11
|
import {Tooltip} from "./Tooltip";
|
|
12
12
|
|
|
13
|
+
const TapToEditTitle = ({
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
showDescriptionAsTooltip,
|
|
17
|
+
onlyShowDescriptionWhileEditing,
|
|
18
|
+
}: {
|
|
19
|
+
onlyShowDescriptionWhileEditing?: boolean;
|
|
20
|
+
showDescriptionAsTooltip?: boolean;
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}): ReactElement => {
|
|
24
|
+
return (
|
|
25
|
+
<Box flex="grow" marginBottom={2}>
|
|
26
|
+
<Text weight="bold">{title}:</Text>
|
|
27
|
+
{Boolean(description && !showDescriptionAsTooltip && !onlyShowDescriptionWhileEditing) && (
|
|
28
|
+
<Text color="gray" size="sm">
|
|
29
|
+
{description}
|
|
30
|
+
</Text>
|
|
31
|
+
)}
|
|
32
|
+
</Box>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
13
36
|
export function formatAddress(address: any, asString = false): string {
|
|
14
37
|
let city = "";
|
|
15
38
|
if (address?.city) {
|
|
@@ -63,20 +86,13 @@ export const TapToEdit = ({
|
|
|
63
86
|
confirmationText = "Are you sure you want to save your changes?",
|
|
64
87
|
confirmationHeading = "Confirm",
|
|
65
88
|
description: propsDescription,
|
|
66
|
-
// openApiModel,
|
|
67
|
-
// openApiField,
|
|
68
89
|
showDescriptionAsTooltip = false,
|
|
69
90
|
onlyShowDescriptionWhileEditing = true,
|
|
70
91
|
...fieldProps
|
|
71
92
|
}: TapToEditProps): ReactElement => {
|
|
72
93
|
const [editing, setEditing] = useState(false);
|
|
73
94
|
const [initialValue] = useState(value);
|
|
74
|
-
// const {getModelField} = useOpenAPISpec();
|
|
75
|
-
|
|
76
95
|
const description: string | undefined = propsDescription;
|
|
77
|
-
// if (!description && openApiModel && openApiField) {
|
|
78
|
-
// description = getModelField(openApiModel, openApiField)?.description;
|
|
79
|
-
// }
|
|
80
96
|
|
|
81
97
|
if (editable && !setValue) {
|
|
82
98
|
throw new Error("setValue is required if editable is true");
|
|
@@ -186,24 +202,12 @@ export const TapToEdit = ({
|
|
|
186
202
|
};
|
|
187
203
|
const isClickable = fieldProps?.type === "url" || fieldProps?.type === "address";
|
|
188
204
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
<Box flex="grow">
|
|
192
|
-
<Text weight="bold">{title}:</Text>
|
|
193
|
-
{Boolean(
|
|
194
|
-
description && !showDescriptionAsTooltip && !onlyShowDescriptionWhileEditing
|
|
195
|
-
) && (
|
|
196
|
-
<Text color="gray" size="sm">
|
|
197
|
-
{description}
|
|
198
|
-
</Text>
|
|
199
|
-
)}
|
|
200
|
-
</Box>
|
|
201
|
-
);
|
|
202
|
-
};
|
|
203
|
-
|
|
205
|
+
// For textarea to display correctly, we place the title on its own line, then the text
|
|
206
|
+
// on the next line. This is because the textarea will take up the full width of the row.
|
|
204
207
|
return (
|
|
205
208
|
<Box
|
|
206
|
-
|
|
209
|
+
alignItems={fieldProps?.type === "textarea" ? "start" : "center"}
|
|
210
|
+
direction={fieldProps?.type === "textarea" ? "column" : "row"}
|
|
207
211
|
justifyContent="between"
|
|
208
212
|
paddingX={3}
|
|
209
213
|
paddingY={2}
|
|
@@ -212,19 +216,32 @@ export const TapToEdit = ({
|
|
|
212
216
|
>
|
|
213
217
|
{showDescriptionAsTooltip ? (
|
|
214
218
|
<Tooltip idealDirection="top" text={description}>
|
|
215
|
-
|
|
219
|
+
<TapToEditTitle
|
|
220
|
+
description={description}
|
|
221
|
+
onlyShowDescriptionWhileEditing={onlyShowDescriptionWhileEditing}
|
|
222
|
+
showDescriptionAsTooltip={showDescriptionAsTooltip}
|
|
223
|
+
title={title}
|
|
224
|
+
/>
|
|
216
225
|
</Tooltip>
|
|
217
226
|
) : (
|
|
218
|
-
|
|
227
|
+
<TapToEditTitle
|
|
228
|
+
description={description}
|
|
229
|
+
onlyShowDescriptionWhileEditing={onlyShowDescriptionWhileEditing}
|
|
230
|
+
showDescriptionAsTooltip={showDescriptionAsTooltip}
|
|
231
|
+
title={title}
|
|
232
|
+
/>
|
|
219
233
|
)}
|
|
220
|
-
<Box direction="row" justifyContent="
|
|
221
|
-
<Box justifyContent="start" onClick={isClickable ? openLink : undefined}>
|
|
222
|
-
<Text
|
|
234
|
+
<Box direction="row" flex="grow" justifyContent="end" marginLeft={2}>
|
|
235
|
+
<Box flex="grow" justifyContent="start" onClick={isClickable ? openLink : undefined}>
|
|
236
|
+
<Text
|
|
237
|
+
align={fieldProps?.type === "textarea" ? "left" : "right"}
|
|
238
|
+
underline={isClickable}
|
|
239
|
+
>
|
|
223
240
|
{displayValue}
|
|
224
241
|
</Text>
|
|
225
242
|
</Box>
|
|
226
243
|
{editable && (
|
|
227
|
-
<Box marginLeft={2} onClick={(): void => setEditing(true)}>
|
|
244
|
+
<Box alignSelf="end" marginLeft={2} width={16} onClick={(): void => setEditing(true)}>
|
|
228
245
|
<Icon color="darkGray" name="edit" prefix="far" size="md" />
|
|
229
246
|
</Box>
|
|
230
247
|
)}
|