@teselagen/ui 0.6.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DataTable/ColumnFilterMenu.d.ts +2 -1
- package/DataTable/Columns.d.ts +51 -0
- package/DataTable/DisplayOptions.d.ts +14 -14
- package/DataTable/EditabelCell.d.ts +2 -5
- package/DataTable/EditableCell.d.ts +7 -0
- package/DataTable/FilterAndSortMenu.d.ts +9 -9
- package/DataTable/PagingTool.d.ts +25 -2
- package/DataTable/RenderCell.d.ts +18 -0
- package/DataTable/SearchBar.d.ts +4 -3
- package/DataTable/SortableColumns.d.ts +6 -9
- package/DataTable/ThComponent.d.ts +9 -0
- package/DataTable/index.d.ts +0 -5
- package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
- package/DataTable/utils/handleCopyTable.d.ts +1 -0
- package/DataTable/utils/index.d.ts +4 -2
- package/DataTable/utils/primarySelectedValue.d.ts +1 -0
- package/DataTable/utils/queryParams.d.ts +13 -8
- package/DataTable/utils/removeCleanRows.d.ts +1 -1
- package/DataTable/utils/rowClick.d.ts +24 -3
- package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
- package/DataTable/utils/useTableEntities.d.ts +5 -0
- package/DataTable/utils/useTableParams.d.ts +49 -0
- package/DataTable/utils/withTableParams.d.ts +3 -16
- package/DataTable/viewColumn.d.ts +11 -4
- package/FormComponents/AbstractField.d.ts +1 -0
- package/FormComponents/Uploader.d.ts +34 -1
- package/FormComponents/index.d.ts +111 -60
- package/MatchHeaders.d.ts +9 -10
- package/SimpleStepViz.d.ts +2 -1
- package/TgSuggest/index.d.ts +1 -21
- package/UploadCsvWizard.d.ts +1 -1
- package/index.cjs.js +47861 -49125
- package/index.d.ts +6 -3
- package/index.es.js +47959 -49223
- package/package.json +6 -5
- package/src/DataTable/CellDragHandle.js +70 -69
- package/src/DataTable/ColumnFilterMenu.js +23 -21
- package/src/DataTable/Columns.js +948 -0
- package/src/DataTable/Columns.jsx +945 -0
- package/src/DataTable/DisplayOptions.js +173 -192
- package/src/DataTable/EditabelCell.js +7 -18
- package/src/DataTable/EditabelCell.jsx +44 -0
- package/src/DataTable/EditableCell.js +44 -0
- package/src/DataTable/FilterAndSortMenu.js +215 -234
- package/src/DataTable/PagingTool.js +47 -56
- package/src/DataTable/RenderCell.js +191 -0
- package/src/DataTable/RenderCell.jsx +191 -0
- package/src/DataTable/SearchBar.js +12 -5
- package/src/DataTable/SortableColumns.js +44 -39
- package/src/DataTable/ThComponent.js +44 -0
- package/src/DataTable/dataTableEnhancer.js +32 -295
- package/src/DataTable/index.js +2945 -3596
- package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
- package/src/DataTable/utils/handleCopyTable.js +16 -0
- package/src/DataTable/utils/index.js +7 -3
- package/src/DataTable/utils/primarySelectedValue.js +1 -0
- package/src/DataTable/utils/queryParams.js +110 -85
- package/src/DataTable/utils/removeCleanRows.js +3 -3
- package/src/DataTable/utils/rowClick.js +34 -9
- package/src/DataTable/utils/selection.js +1 -1
- package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
- package/src/DataTable/utils/useTableEntities.js +38 -0
- package/src/DataTable/utils/useTableParams.js +362 -0
- package/src/DataTable/utils/withTableParams.js +244 -274
- package/src/DataTable/validateTableWideErrors.js +1 -1
- package/src/DataTable/viewColumn.js +5 -9
- package/src/DialogFooter/index.js +3 -3
- package/src/FillWindow.js +2 -3
- package/src/FormComponents/AbstractField.js +388 -0
- package/src/FormComponents/Uploader.js +674 -649
- package/src/FormComponents/index.js +505 -654
- package/src/FormComponents/tryToMatchSchemas.js +1 -6
- package/src/MatchHeaders.js +27 -22
- package/src/SimpleStepViz.js +19 -23
- package/src/TgSelect/index.js +1 -1
- package/src/TgSuggest/index.js +94 -106
- package/src/UploadCsvWizard.js +571 -577
- package/src/enhancers/withDialog/tg_modalState.js +1 -0
- package/src/index.js +10 -4
- package/src/showDialogOnDocBody.js +5 -9
- package/src/useDialog.js +25 -26
- package/src/utils/commandControls.js +2 -2
- package/src/utils/handlerHelpers.js +19 -25
- package/src/utils/hooks/index.js +1 -0
- package/src/utils/hooks/useDeepEqualMemo.js +10 -0
- package/src/utils/hooks/useStableReference.js +9 -0
- package/src/utils/renderOnDoc.js +8 -5
- package/src/utils/tagUtils.js +3 -3
- package/src/utils/useTraceUpdate.js +19 -0
- package/src/wrapDialog.js +0 -2
- package/style.css +251 -251
- package/useDialog.d.ts +2 -6
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/useDeepEqualMemo.d.ts +1 -0
- package/utils/hooks/useStableReference.d.ts +1 -0
- package/utils/renderOnDoc.d.ts +1 -1
- package/utils/tagUtils.d.ts +5 -1
- package/utils/useTraceUpdate.d.ts +1 -0
|
@@ -2,9 +2,14 @@ import classNames from "classnames";
|
|
|
2
2
|
import { SketchPicker } from "react-color";
|
|
3
3
|
import { isNumber, noop, kebabCase, isPlainObject, isEqual } from "lodash-es";
|
|
4
4
|
import mathExpressionEvaluator from "math-expression-evaluator";
|
|
5
|
-
import React, {
|
|
5
|
+
import React, {
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
6
12
|
import { Field, change } from "redux-form";
|
|
7
|
-
|
|
8
13
|
import "./style.css";
|
|
9
14
|
import {
|
|
10
15
|
InputGroup,
|
|
@@ -22,7 +27,6 @@ import {
|
|
|
22
27
|
TextArea,
|
|
23
28
|
Popover
|
|
24
29
|
} from "@blueprintjs/core";
|
|
25
|
-
|
|
26
30
|
import { DateInput, DateRangeInput } from "@blueprintjs/datetime";
|
|
27
31
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
28
32
|
import { difference } from "lodash-es";
|
|
@@ -41,6 +45,8 @@ import popoverOverflowModifiers from "../utils/popoverOverflowModifiers";
|
|
|
41
45
|
import Uploader from "./Uploader";
|
|
42
46
|
import sortify from "./sortify";
|
|
43
47
|
import { fieldRequired } from "./utils";
|
|
48
|
+
import { useDispatch } from "react-redux";
|
|
49
|
+
import { useStableReference } from "../utils/hooks/useStableReference";
|
|
44
50
|
|
|
45
51
|
export { fieldRequired };
|
|
46
52
|
|
|
@@ -57,8 +63,14 @@ function getIntent({
|
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
|
|
60
|
-
function getIntentClass(
|
|
61
|
-
|
|
66
|
+
function getIntentClass({
|
|
67
|
+
showErrorIfUntouched,
|
|
68
|
+
meta: { touched, error, warning }
|
|
69
|
+
}) {
|
|
70
|
+
const intent = getIntent({
|
|
71
|
+
showErrorIfUntouched,
|
|
72
|
+
meta: { touched, error, warning }
|
|
73
|
+
});
|
|
62
74
|
if (intent === Intent.DANGER) {
|
|
63
75
|
return Classes.INTENT_DANGER;
|
|
64
76
|
} else if (intent === Intent.WARNING) {
|
|
@@ -100,8 +112,8 @@ function removeUnwantedProps(props) {
|
|
|
100
112
|
return cleanedProps;
|
|
101
113
|
}
|
|
102
114
|
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
const LabelWithTooltipInfo = ({ label, tooltipInfo, labelStyle }) =>
|
|
116
|
+
tooltipInfo ? (
|
|
105
117
|
<div style={{ display: "flex", alignItems: "center", ...labelStyle }}>
|
|
106
118
|
{label}{" "}
|
|
107
119
|
<InfoHelper
|
|
@@ -113,253 +125,214 @@ function LabelWithTooltipInfo({ label, tooltipInfo, labelStyle }) {
|
|
|
113
125
|
) : (
|
|
114
126
|
label || null
|
|
115
127
|
);
|
|
116
|
-
}
|
|
117
128
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
const AbstractInput = ({
|
|
130
|
+
assignDefaultButton,
|
|
131
|
+
asyncValidating,
|
|
132
|
+
className,
|
|
133
|
+
children,
|
|
134
|
+
containerStyle,
|
|
135
|
+
defaultValue,
|
|
136
|
+
disabled,
|
|
137
|
+
fileLimit,
|
|
138
|
+
inlineLabel,
|
|
139
|
+
input: { name },
|
|
140
|
+
intent,
|
|
141
|
+
isLabelTooltip,
|
|
142
|
+
isLoadingDefaultValue,
|
|
143
|
+
isRequired,
|
|
144
|
+
label,
|
|
145
|
+
labelStyle,
|
|
146
|
+
leftEl,
|
|
147
|
+
meta: { form, touched, error, warning },
|
|
148
|
+
noFillField,
|
|
149
|
+
noMarginBottom,
|
|
150
|
+
noOuterLabel,
|
|
151
|
+
onDefaultValChanged: _onDefaultValChanged,
|
|
152
|
+
onFieldSubmit: _onFieldSubmit,
|
|
153
|
+
rightEl,
|
|
154
|
+
secondaryLabel,
|
|
155
|
+
setAssignDefaultsMode,
|
|
156
|
+
showErrorIfUntouched,
|
|
157
|
+
showGenerateDefaultDot,
|
|
158
|
+
startAssigningDefault,
|
|
159
|
+
tooltipError,
|
|
160
|
+
tooltipInfo,
|
|
161
|
+
tooltipProps
|
|
162
|
+
}) => {
|
|
163
|
+
const dispatch = useDispatch();
|
|
164
|
+
const onDefaultValChanged = useStableReference(_onDefaultValChanged);
|
|
165
|
+
const onFieldSubmit = useStableReference(_onFieldSubmit);
|
|
166
|
+
|
|
167
|
+
// This only takes care that the default Value is changed when it is changed in the parent component
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (defaultValue !== undefined) {
|
|
170
|
+
dispatch(change(form, name, defaultValue));
|
|
171
|
+
onDefaultValChanged.current &&
|
|
172
|
+
onDefaultValChanged.current(defaultValue, name, form);
|
|
173
|
+
onFieldSubmit.current && onFieldSubmit.current(defaultValue);
|
|
130
174
|
}
|
|
175
|
+
}, [defaultValue, dispatch, form, name, onDefaultValChanged, onFieldSubmit]);
|
|
176
|
+
|
|
177
|
+
// if our custom field level validation is happening then we don't want to show the error visually
|
|
178
|
+
const showError =
|
|
179
|
+
(touched || showErrorIfUntouched) && error && !asyncValidating;
|
|
180
|
+
const showWarning = (touched || showErrorIfUntouched) && warning;
|
|
181
|
+
let componentToWrap =
|
|
182
|
+
isLabelTooltip || tooltipError ? (
|
|
183
|
+
<Tooltip
|
|
184
|
+
disabled={isLabelTooltip ? false : !showError}
|
|
185
|
+
intent={isLabelTooltip ? "none" : error ? "danger" : "warning"}
|
|
186
|
+
content={isLabelTooltip ? label : error || warning}
|
|
187
|
+
position={Position.TOP}
|
|
188
|
+
modifiers={popoverOverflowModifiers}
|
|
189
|
+
{...tooltipProps}
|
|
190
|
+
>
|
|
191
|
+
{children}
|
|
192
|
+
</Tooltip>
|
|
193
|
+
) : (
|
|
194
|
+
children
|
|
195
|
+
);
|
|
196
|
+
const testClassName = "tg-test-" + kebabCase(name);
|
|
197
|
+
if (noFillField) {
|
|
198
|
+
componentToWrap = <div className="tg-no-fill-field">{componentToWrap}</div>;
|
|
131
199
|
}
|
|
132
200
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
defaultValue,
|
|
140
|
-
defaultValCount,
|
|
141
|
-
enableReinitialize,
|
|
142
|
-
input: { value }
|
|
143
|
-
} = this.props;
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
((value !== false && !value) ||
|
|
147
|
-
enableReinitialize ||
|
|
148
|
-
defaultValCount !== oldDefaultValCount) &&
|
|
149
|
-
!isEqual(defaultValue, oldDefaultValue)
|
|
150
|
-
) {
|
|
151
|
-
this.updateDefaultValue();
|
|
201
|
+
let helperText;
|
|
202
|
+
if (!tooltipError) {
|
|
203
|
+
if (showError) {
|
|
204
|
+
helperText = error;
|
|
205
|
+
} else if (showWarning) {
|
|
206
|
+
helperText = warning;
|
|
152
207
|
}
|
|
153
208
|
}
|
|
154
209
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
meta: { dispatch, form },
|
|
160
|
-
onDefaultValChanged,
|
|
161
|
-
onFieldSubmit
|
|
162
|
-
} = this.props;
|
|
163
|
-
dispatch(change(form, name, defaultValue));
|
|
164
|
-
onDefaultValChanged &&
|
|
165
|
-
onDefaultValChanged(defaultValue, name, form, this.props);
|
|
166
|
-
onFieldSubmit && onFieldSubmit(defaultValue);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
render() {
|
|
170
|
-
const {
|
|
171
|
-
children,
|
|
172
|
-
tooltipProps,
|
|
173
|
-
tooltipError,
|
|
174
|
-
disabled,
|
|
175
|
-
intent,
|
|
176
|
-
tooltipInfo,
|
|
177
|
-
label,
|
|
178
|
-
inlineLabel,
|
|
179
|
-
isLabelTooltip,
|
|
180
|
-
secondaryLabel,
|
|
181
|
-
className,
|
|
182
|
-
showErrorIfUntouched,
|
|
183
|
-
asyncValidating,
|
|
184
|
-
meta,
|
|
185
|
-
containerStyle,
|
|
186
|
-
leftEl,
|
|
187
|
-
rightEl,
|
|
188
|
-
labelStyle,
|
|
189
|
-
noOuterLabel,
|
|
190
|
-
fileLimit,
|
|
191
|
-
noMarginBottom,
|
|
192
|
-
assignDefaultButton,
|
|
193
|
-
showGenerateDefaultDot,
|
|
194
|
-
setAssignDefaultsMode,
|
|
195
|
-
startAssigningDefault,
|
|
196
|
-
input,
|
|
197
|
-
noFillField,
|
|
198
|
-
isRequired,
|
|
199
|
-
isLoadingDefaultValue
|
|
200
|
-
} = this.props;
|
|
201
|
-
const { touched, error, warning } = meta;
|
|
202
|
-
|
|
203
|
-
// if our custom field level validation is happening then we don't want to show the error visually
|
|
204
|
-
const showError =
|
|
205
|
-
(touched || showErrorIfUntouched) && error && !asyncValidating;
|
|
206
|
-
const showWarning = (touched || showErrorIfUntouched) && warning;
|
|
207
|
-
let componentToWrap =
|
|
208
|
-
isLabelTooltip || tooltipError ? (
|
|
209
|
-
<Tooltip
|
|
210
|
-
disabled={isLabelTooltip ? false : !showError}
|
|
211
|
-
intent={isLabelTooltip ? "none" : error ? "danger" : "warning"}
|
|
212
|
-
content={isLabelTooltip ? label : error || warning}
|
|
213
|
-
position={Position.TOP}
|
|
214
|
-
modifiers={popoverOverflowModifiers}
|
|
215
|
-
{...tooltipProps}
|
|
216
|
-
>
|
|
217
|
-
{children}
|
|
218
|
-
</Tooltip>
|
|
219
|
-
) : (
|
|
220
|
-
children
|
|
221
|
-
);
|
|
222
|
-
const testClassName = "tg-test-" + kebabCase(input.name);
|
|
223
|
-
if (noFillField) {
|
|
224
|
-
componentToWrap = (
|
|
225
|
-
<div className="tg-no-fill-field">{componentToWrap}</div>
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
let helperText;
|
|
230
|
-
if (!tooltipError) {
|
|
231
|
-
if (showError) {
|
|
232
|
-
helperText = error;
|
|
233
|
-
} else if (showWarning) {
|
|
234
|
-
helperText = warning;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// if in a cypress test show message so that inputs will not be interactable
|
|
239
|
-
if (window.Cypress && isLoadingDefaultValue) {
|
|
240
|
-
return "Loading default value...";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
let labelInfo = secondaryLabel;
|
|
244
|
-
|
|
245
|
-
const hasOuterLabel = !noOuterLabel && !isLabelTooltip;
|
|
246
|
-
function getFileLimitInfo() {
|
|
247
|
-
if (!fileLimit) return "";
|
|
248
|
-
return `max ${fileLimit} file${fileLimit === 1 ? "" : "s"}`;
|
|
249
|
-
}
|
|
210
|
+
// if in a cypress test show message so that inputs will not be interactable
|
|
211
|
+
if (window.Cypress && isLoadingDefaultValue) {
|
|
212
|
+
return "Loading default value...";
|
|
213
|
+
}
|
|
250
214
|
|
|
251
|
-
|
|
252
|
-
labelInfo = `(required${fileLimit ? `, ${getFileLimitInfo()}` : ""})`;
|
|
253
|
-
} else if (!labelInfo && fileLimit) {
|
|
254
|
-
labelInfo = `(${getFileLimitInfo()})`;
|
|
255
|
-
}
|
|
215
|
+
let labelInfo = secondaryLabel;
|
|
256
216
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
"tg-tooltipError": tooltipError,
|
|
262
|
-
"tg-has-error": showError && error
|
|
263
|
-
})}
|
|
264
|
-
disabled={disabled}
|
|
265
|
-
helperText={helperText}
|
|
266
|
-
intent={intent}
|
|
267
|
-
label={
|
|
268
|
-
hasOuterLabel && (
|
|
269
|
-
<LabelWithTooltipInfo
|
|
270
|
-
labelStyle={labelStyle}
|
|
271
|
-
label={label}
|
|
272
|
-
tooltipInfo={tooltipInfo}
|
|
273
|
-
/>
|
|
274
|
-
)
|
|
275
|
-
}
|
|
276
|
-
inline={inlineLabel}
|
|
277
|
-
labelInfo={labelInfo}
|
|
278
|
-
style={{
|
|
279
|
-
...(noMarginBottom && { marginBottom: 0 }),
|
|
280
|
-
...containerStyle
|
|
281
|
-
}}
|
|
282
|
-
>
|
|
283
|
-
{showGenerateDefaultDot && (
|
|
284
|
-
<div
|
|
285
|
-
style={{ zIndex: 10, position: "relative", height: 0, width: 0 }}
|
|
286
|
-
>
|
|
287
|
-
<div style={{ position: "absolute", left: "0px", top: "0px" }}>
|
|
288
|
-
<Tooltip
|
|
289
|
-
modifiers={popoverOverflowModifiers}
|
|
290
|
-
content="Allows a Default to be Set. Click to Enter Set Default Mode (or press Shift+D when outside the input field)"
|
|
291
|
-
>
|
|
292
|
-
<div
|
|
293
|
-
onClick={() => {
|
|
294
|
-
setAssignDefaultsMode(true);
|
|
295
|
-
startAssigningDefault();
|
|
296
|
-
}}
|
|
297
|
-
className="generateDefaultDot"
|
|
298
|
-
></div>
|
|
299
|
-
</Tooltip>
|
|
300
|
-
</div>
|
|
301
|
-
</div>
|
|
302
|
-
)}
|
|
303
|
-
{assignDefaultButton}
|
|
304
|
-
{leftEl} {componentToWrap} {rightEl}
|
|
305
|
-
</FormGroup>
|
|
306
|
-
);
|
|
217
|
+
const hasOuterLabel = !noOuterLabel && !isLabelTooltip;
|
|
218
|
+
function getFileLimitInfo() {
|
|
219
|
+
if (!fileLimit) return "";
|
|
220
|
+
return `max ${fileLimit} file${fileLimit === 1 ? "" : "s"}`;
|
|
307
221
|
}
|
|
308
|
-
}
|
|
309
222
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
{...removeUnwantedProps(rest)}
|
|
316
|
-
intent={intent}
|
|
317
|
-
inputProps={inputProps}
|
|
318
|
-
{...input}
|
|
319
|
-
value={input.value ? new Date(input.value) : undefined}
|
|
320
|
-
onChange={function (selectedDate) {
|
|
321
|
-
input.onChange(selectedDate);
|
|
322
|
-
onFieldSubmit(selectedDate);
|
|
323
|
-
}}
|
|
324
|
-
/>
|
|
325
|
-
);
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
export const renderBlueprintDateRangeInput = props => {
|
|
329
|
-
const { input, intent, onFieldSubmit, inputProps, ...rest } = props;
|
|
223
|
+
if (isRequired && hasOuterLabel && label && !labelInfo) {
|
|
224
|
+
labelInfo = `(required${fileLimit ? `, ${getFileLimitInfo()}` : ""})`;
|
|
225
|
+
} else if (!labelInfo && fileLimit) {
|
|
226
|
+
labelInfo = `(${getFileLimitInfo()})`;
|
|
227
|
+
}
|
|
330
228
|
|
|
331
229
|
return (
|
|
332
|
-
<
|
|
333
|
-
{
|
|
334
|
-
|
|
230
|
+
<FormGroup
|
|
231
|
+
className={classNames(className, testClassName, {
|
|
232
|
+
"tg-flex-form-content": leftEl || rightEl,
|
|
233
|
+
"tg-tooltipError": tooltipError,
|
|
234
|
+
"tg-has-error": showError && error
|
|
235
|
+
})}
|
|
236
|
+
disabled={disabled}
|
|
237
|
+
helperText={helperText}
|
|
335
238
|
intent={intent}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
239
|
+
label={
|
|
240
|
+
hasOuterLabel && (
|
|
241
|
+
<LabelWithTooltipInfo
|
|
242
|
+
labelStyle={labelStyle}
|
|
243
|
+
label={label}
|
|
244
|
+
tooltipInfo={tooltipInfo}
|
|
245
|
+
/>
|
|
246
|
+
)
|
|
342
247
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
248
|
+
inline={inlineLabel}
|
|
249
|
+
labelInfo={labelInfo}
|
|
250
|
+
style={{
|
|
251
|
+
...(noMarginBottom && { marginBottom: 0 }),
|
|
252
|
+
...containerStyle
|
|
346
253
|
}}
|
|
347
|
-
|
|
254
|
+
>
|
|
255
|
+
{showGenerateDefaultDot && (
|
|
256
|
+
<div style={{ zIndex: 10, position: "relative", height: 0, width: 0 }}>
|
|
257
|
+
<div style={{ position: "absolute", left: "0px", top: "0px" }}>
|
|
258
|
+
<Tooltip
|
|
259
|
+
modifiers={popoverOverflowModifiers}
|
|
260
|
+
content="Allows a Default to be Set. Click to Enter Set Default Mode (or press Shift+D when outside the input field)"
|
|
261
|
+
>
|
|
262
|
+
<div
|
|
263
|
+
onClick={() => {
|
|
264
|
+
setAssignDefaultsMode(true);
|
|
265
|
+
startAssigningDefault();
|
|
266
|
+
}}
|
|
267
|
+
className="generateDefaultDot"
|
|
268
|
+
/>
|
|
269
|
+
</Tooltip>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
)}
|
|
273
|
+
{assignDefaultButton}
|
|
274
|
+
{leftEl} {componentToWrap} {rightEl}
|
|
275
|
+
</FormGroup>
|
|
348
276
|
);
|
|
349
277
|
};
|
|
350
278
|
|
|
351
|
-
export const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
279
|
+
export const renderBlueprintDateInput = ({
|
|
280
|
+
input,
|
|
281
|
+
intent,
|
|
282
|
+
onFieldSubmit,
|
|
283
|
+
inputProps,
|
|
284
|
+
...rest
|
|
285
|
+
}) => (
|
|
286
|
+
<DateInput
|
|
287
|
+
{...getDayjsFormatter("L")}
|
|
288
|
+
{...removeUnwantedProps(rest)}
|
|
289
|
+
intent={intent}
|
|
290
|
+
inputProps={inputProps}
|
|
291
|
+
{...input}
|
|
292
|
+
value={input.value ? new Date(input.value) : undefined}
|
|
293
|
+
onChange={function (selectedDate) {
|
|
294
|
+
input.onChange(selectedDate);
|
|
295
|
+
onFieldSubmit(selectedDate);
|
|
296
|
+
}}
|
|
297
|
+
/>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
export const renderBlueprintDateRangeInput = ({
|
|
301
|
+
input,
|
|
302
|
+
intent,
|
|
303
|
+
onFieldSubmit,
|
|
304
|
+
inputProps,
|
|
305
|
+
...rest
|
|
306
|
+
}) => (
|
|
307
|
+
<DateRangeInput
|
|
308
|
+
{...getDayjsFormatter("L")}
|
|
309
|
+
{...removeUnwantedProps(rest)}
|
|
310
|
+
intent={intent}
|
|
311
|
+
inputProps={inputProps}
|
|
312
|
+
{...input}
|
|
313
|
+
value={
|
|
314
|
+
input.value
|
|
315
|
+
? [new Date(input.value[0]), new Date(input.value[1])]
|
|
316
|
+
: undefined
|
|
317
|
+
}
|
|
318
|
+
onChange={function (selectedDate) {
|
|
319
|
+
input.onChange(selectedDate);
|
|
320
|
+
onFieldSubmit(selectedDate);
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
export const RenderBlueprintInput = ({
|
|
326
|
+
input,
|
|
327
|
+
// meta = {},
|
|
328
|
+
intent,
|
|
329
|
+
onFieldSubmit,
|
|
330
|
+
onKeyDown = noop,
|
|
331
|
+
asyncValidating,
|
|
332
|
+
rightElement,
|
|
333
|
+
clickToEdit,
|
|
334
|
+
...rest
|
|
335
|
+
}) => {
|
|
363
336
|
const [isOpen, setOpen] = useState(false);
|
|
364
337
|
const [value, setVal] = useState(null);
|
|
365
338
|
const toSpread = {};
|
|
@@ -433,11 +406,7 @@ export const RenderBlueprintInput = props => {
|
|
|
433
406
|
{clickToEdit &&
|
|
434
407
|
(isOpen ? (
|
|
435
408
|
<>
|
|
436
|
-
<Button
|
|
437
|
-
icon="small-cross"
|
|
438
|
-
onClick={stopEdit}
|
|
439
|
-
intent="danger"
|
|
440
|
-
></Button>
|
|
409
|
+
<Button icon="small-cross" onClick={stopEdit} intent="danger" />
|
|
441
410
|
<Button
|
|
442
411
|
icon="small-tick"
|
|
443
412
|
onClick={() => {
|
|
@@ -448,7 +417,7 @@ export const RenderBlueprintInput = props => {
|
|
|
448
417
|
stopEdit();
|
|
449
418
|
}}
|
|
450
419
|
intent="success"
|
|
451
|
-
|
|
420
|
+
/>{" "}
|
|
452
421
|
</>
|
|
453
422
|
) : (
|
|
454
423
|
<Button
|
|
@@ -457,30 +426,33 @@ export const RenderBlueprintInput = props => {
|
|
|
457
426
|
setOpen(true);
|
|
458
427
|
}}
|
|
459
428
|
icon="edit"
|
|
460
|
-
|
|
429
|
+
/>
|
|
461
430
|
))}
|
|
462
431
|
</div>
|
|
463
432
|
);
|
|
464
433
|
return inner;
|
|
465
434
|
};
|
|
466
435
|
|
|
467
|
-
export const renderBlueprintCheckbox =
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
436
|
+
export const renderBlueprintCheckbox = ({
|
|
437
|
+
input,
|
|
438
|
+
label,
|
|
439
|
+
tooltipInfo,
|
|
440
|
+
beforeOnChange,
|
|
441
|
+
onFieldSubmit,
|
|
442
|
+
...rest
|
|
443
|
+
}) => (
|
|
444
|
+
<Checkbox
|
|
445
|
+
{...removeUnwantedProps(rest)}
|
|
446
|
+
{...input}
|
|
447
|
+
checked={input.value}
|
|
448
|
+
label={<LabelWithTooltipInfo label={label} tooltipInfo={tooltipInfo} />}
|
|
449
|
+
onChange={getCheckboxOrSwitchOnChange({
|
|
450
|
+
beforeOnChange,
|
|
451
|
+
input,
|
|
452
|
+
onFieldSubmit
|
|
453
|
+
})}
|
|
454
|
+
/>
|
|
455
|
+
);
|
|
484
456
|
|
|
485
457
|
const getCheckboxOrSwitchOnChange = ({
|
|
486
458
|
beforeOnChange,
|
|
@@ -498,154 +470,136 @@ const getCheckboxOrSwitchOnChange = ({
|
|
|
498
470
|
onFieldSubmit(v);
|
|
499
471
|
};
|
|
500
472
|
|
|
501
|
-
export const renderBlueprintSwitch =
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
473
|
+
export const renderBlueprintSwitch = ({
|
|
474
|
+
input,
|
|
475
|
+
label,
|
|
476
|
+
tooltipInfo,
|
|
477
|
+
onFieldSubmit,
|
|
478
|
+
beforeOnChange,
|
|
479
|
+
...rest
|
|
480
|
+
}) => (
|
|
481
|
+
<Switch
|
|
482
|
+
{...removeUnwantedProps(rest)}
|
|
483
|
+
{...input}
|
|
484
|
+
checked={input.value}
|
|
485
|
+
label={<LabelWithTooltipInfo label={label} tooltipInfo={tooltipInfo} />}
|
|
486
|
+
onChange={getCheckboxOrSwitchOnChange({
|
|
487
|
+
beforeOnChange,
|
|
488
|
+
input,
|
|
489
|
+
onFieldSubmit
|
|
490
|
+
})}
|
|
491
|
+
/>
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
export const renderFileUpload = ({ input, onFieldSubmit, ...rest }) => (
|
|
495
|
+
<Uploader
|
|
496
|
+
fileList={input.value}
|
|
497
|
+
onFieldSubmit={onFieldSubmit}
|
|
498
|
+
{...rest}
|
|
499
|
+
name={input.name}
|
|
500
|
+
onChange={input.onChange}
|
|
501
|
+
/>
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
export const RenderBlueprintTextarea = ({
|
|
505
|
+
input,
|
|
506
|
+
onFieldSubmit,
|
|
507
|
+
onKeyDown,
|
|
508
|
+
intentClass,
|
|
509
|
+
inputClassName,
|
|
510
|
+
clickToEdit,
|
|
511
|
+
disabled,
|
|
512
|
+
...rest
|
|
513
|
+
}) => {
|
|
514
|
+
const [value, setValue] = useState(null);
|
|
515
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
531
516
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
isOpen: false
|
|
536
|
-
};
|
|
537
|
-
allowEdit = () => {
|
|
538
|
-
this.setState({ isOpen: true });
|
|
539
|
-
};
|
|
540
|
-
stopEdit = () => {
|
|
541
|
-
this.setState({ isOpen: false });
|
|
542
|
-
this.setState({ value: null });
|
|
543
|
-
};
|
|
544
|
-
updateVal = e => {
|
|
545
|
-
this.setState({ value: e.target.value });
|
|
517
|
+
const stopEdit = () => {
|
|
518
|
+
setIsOpen(false);
|
|
519
|
+
setValue(null);
|
|
546
520
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
);
|
|
555
|
-
this.stopEdit();
|
|
521
|
+
|
|
522
|
+
const handleValSubmit = () => {
|
|
523
|
+
input.onChange(value === null ? input.value : value);
|
|
524
|
+
onFieldSubmit(value === null ? input.value : value, {
|
|
525
|
+
cmdEnter: true
|
|
526
|
+
});
|
|
527
|
+
stopEdit();
|
|
556
528
|
};
|
|
557
|
-
|
|
529
|
+
|
|
530
|
+
const handleOnKeyDown = (...args) => {
|
|
558
531
|
const e = args[0];
|
|
559
|
-
(
|
|
532
|
+
(onKeyDown || noop)(...args);
|
|
560
533
|
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
534
|
+
onFieldSubmit(e.target.value, { cmdEnter: true }, e);
|
|
535
|
+
input.onChange(e);
|
|
536
|
+
stopEdit();
|
|
564
537
|
}
|
|
565
538
|
};
|
|
566
|
-
render() {
|
|
567
|
-
const {
|
|
568
|
-
input,
|
|
569
|
-
intentClass,
|
|
570
|
-
inputClassName,
|
|
571
|
-
onFieldSubmit,
|
|
572
|
-
clickToEdit,
|
|
573
|
-
onKeyDown,
|
|
574
|
-
disabled,
|
|
575
|
-
...rest
|
|
576
|
-
} = this.props;
|
|
577
|
-
if (clickToEdit) {
|
|
578
|
-
const isDisabled = clickToEdit && !this.state.isOpen;
|
|
579
539
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
disabled={rest.disabled || isDisabled}
|
|
585
|
-
className={classNames(
|
|
586
|
-
intentClass,
|
|
587
|
-
inputClassName,
|
|
588
|
-
Classes.INPUT,
|
|
589
|
-
Classes.FILL
|
|
590
|
-
)}
|
|
591
|
-
value={this.state.value === null ? input.value : this.state.value}
|
|
592
|
-
onChange={this.updateVal}
|
|
593
|
-
onKeyDown={this.onKeyDown}
|
|
594
|
-
/>
|
|
595
|
-
{clickToEdit &&
|
|
596
|
-
!disabled &&
|
|
597
|
-
(this.state.isOpen ? (
|
|
598
|
-
//show okay/cancel buttons
|
|
599
|
-
<div>
|
|
600
|
-
<Button onClick={this.stopEdit} intent="danger">
|
|
601
|
-
Cancel
|
|
602
|
-
</Button>
|
|
603
|
-
<Button onClick={this.handleValSubmit} intent="success">
|
|
604
|
-
Ok
|
|
605
|
-
</Button>
|
|
606
|
-
</div>
|
|
607
|
-
) : (
|
|
608
|
-
//show click to edit button
|
|
609
|
-
<Button onClick={this.allowEdit}>Edit</Button>
|
|
610
|
-
))}
|
|
611
|
-
</React.Fragment>
|
|
612
|
-
);
|
|
613
|
-
} else {
|
|
614
|
-
return (
|
|
540
|
+
if (clickToEdit) {
|
|
541
|
+
const isDisabled = clickToEdit && !isOpen;
|
|
542
|
+
return (
|
|
543
|
+
<>
|
|
615
544
|
<TextArea
|
|
616
545
|
{...removeUnwantedProps(rest)}
|
|
617
|
-
disabled={disabled}
|
|
546
|
+
disabled={rest.disabled || isDisabled}
|
|
618
547
|
className={classNames(
|
|
619
548
|
intentClass,
|
|
620
549
|
inputClassName,
|
|
621
550
|
Classes.INPUT,
|
|
622
551
|
Classes.FILL
|
|
623
552
|
)}
|
|
624
|
-
{
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
input.onBlur(e, val);
|
|
628
|
-
onFieldSubmit(e.target ? e.target.value : val, { blur: true }, e);
|
|
629
|
-
}}
|
|
630
|
-
onKeyDown={(...args) => {
|
|
631
|
-
const e = args[0];
|
|
632
|
-
(onKeyDown || noop)(...args);
|
|
633
|
-
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
|
|
634
|
-
onFieldSubmit(e.target.value, { cmdEnter: true }, e);
|
|
635
|
-
}
|
|
636
|
-
}}
|
|
553
|
+
value={value === null ? input.value : value}
|
|
554
|
+
onChange={e => setValue(e.target.value)}
|
|
555
|
+
onKeyDown={handleOnKeyDown}
|
|
637
556
|
/>
|
|
638
|
-
|
|
639
|
-
|
|
557
|
+
{clickToEdit &&
|
|
558
|
+
!disabled &&
|
|
559
|
+
(isOpen ? (
|
|
560
|
+
//show okay/cancel buttons
|
|
561
|
+
<div>
|
|
562
|
+
<Button onClick={stopEdit} intent="danger">
|
|
563
|
+
Cancel
|
|
564
|
+
</Button>
|
|
565
|
+
<Button onClick={handleValSubmit} intent="success">
|
|
566
|
+
Ok
|
|
567
|
+
</Button>
|
|
568
|
+
</div>
|
|
569
|
+
) : (
|
|
570
|
+
//show click to edit button
|
|
571
|
+
<Button onClick={() => setIsOpen(true)}>Edit</Button>
|
|
572
|
+
))}
|
|
573
|
+
</>
|
|
574
|
+
);
|
|
575
|
+
} else {
|
|
576
|
+
return (
|
|
577
|
+
<TextArea
|
|
578
|
+
{...removeUnwantedProps(rest)}
|
|
579
|
+
disabled={disabled}
|
|
580
|
+
className={classNames(
|
|
581
|
+
intentClass,
|
|
582
|
+
inputClassName,
|
|
583
|
+
Classes.INPUT,
|
|
584
|
+
Classes.FILL
|
|
585
|
+
)}
|
|
586
|
+
{...input}
|
|
587
|
+
onBlur={function (e, val) {
|
|
588
|
+
if (rest.readOnly) return;
|
|
589
|
+
input.onBlur(e, val);
|
|
590
|
+
onFieldSubmit(e.target ? e.target.value : val, { blur: true }, e);
|
|
591
|
+
}}
|
|
592
|
+
onKeyDown={(...args) => {
|
|
593
|
+
const e = args[0];
|
|
594
|
+
(onKeyDown || noop)(...args);
|
|
595
|
+
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
|
|
596
|
+
onFieldSubmit(e.target.value, { cmdEnter: true }, e);
|
|
597
|
+
}
|
|
598
|
+
}}
|
|
599
|
+
/>
|
|
600
|
+
);
|
|
640
601
|
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// class ClickToEditWrapper extends React.Component {
|
|
644
|
-
// state = { isEditing: false };
|
|
645
|
-
// render() {
|
|
646
|
-
// return <div />;
|
|
647
|
-
// }
|
|
648
|
-
// }
|
|
602
|
+
};
|
|
649
603
|
|
|
650
604
|
export const renderBlueprintEditableText = props => {
|
|
651
605
|
const { input, onFieldSubmit, ...rest } = props;
|
|
@@ -767,17 +721,15 @@ export const renderSuggest_old = props => {
|
|
|
767
721
|
return renderReactSelect({ ...props, asSuggest: true });
|
|
768
722
|
};
|
|
769
723
|
|
|
770
|
-
export const renderSuggest =
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
} = props;
|
|
780
|
-
|
|
724
|
+
export const renderSuggest = ({
|
|
725
|
+
async,
|
|
726
|
+
input: { value, onChange },
|
|
727
|
+
hideValue,
|
|
728
|
+
intent,
|
|
729
|
+
options,
|
|
730
|
+
onFieldSubmit,
|
|
731
|
+
...rest
|
|
732
|
+
}) => {
|
|
781
733
|
const propsToUse = {
|
|
782
734
|
...removeUnwantedProps(rest),
|
|
783
735
|
intent,
|
|
@@ -793,27 +745,25 @@ export const renderSuggest = props => {
|
|
|
793
745
|
}
|
|
794
746
|
}
|
|
795
747
|
};
|
|
796
|
-
return <TgSuggest {...propsToUse}
|
|
748
|
+
return <TgSuggest {...propsToUse} />;
|
|
797
749
|
};
|
|
798
750
|
|
|
799
751
|
export const BPSelect = ({ value, onChange, ...rest }) => {
|
|
800
752
|
return renderSelect({ ...rest, input: { onChange, value } });
|
|
801
753
|
};
|
|
802
754
|
|
|
803
|
-
export const renderSelect =
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
...rest
|
|
816
|
-
} = props;
|
|
755
|
+
export const renderSelect = ({
|
|
756
|
+
input: { value, onChange },
|
|
757
|
+
hideValue,
|
|
758
|
+
className,
|
|
759
|
+
placeholder,
|
|
760
|
+
onFieldSubmit,
|
|
761
|
+
options,
|
|
762
|
+
hidePlaceHolder,
|
|
763
|
+
minimal,
|
|
764
|
+
disabled,
|
|
765
|
+
...rest
|
|
766
|
+
}) => {
|
|
817
767
|
return (
|
|
818
768
|
<div
|
|
819
769
|
className={
|
|
@@ -892,16 +842,15 @@ export const renderSelect = props => {
|
|
|
892
842
|
);
|
|
893
843
|
};
|
|
894
844
|
|
|
895
|
-
export const renderBlueprintNumericInput =
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
} = props;
|
|
845
|
+
export const renderBlueprintNumericInput = ({
|
|
846
|
+
input,
|
|
847
|
+
hideValue,
|
|
848
|
+
intent,
|
|
849
|
+
inputClassName,
|
|
850
|
+
onFieldSubmit,
|
|
851
|
+
onAnyNumberChange,
|
|
852
|
+
...rest
|
|
853
|
+
}) => {
|
|
905
854
|
function handleBlurOrButtonClick(stringVal) {
|
|
906
855
|
if (rest.readOnly) return;
|
|
907
856
|
try {
|
|
@@ -984,201 +933,59 @@ export const renderBlueprintRadioGroup = ({
|
|
|
984
933
|
);
|
|
985
934
|
};
|
|
986
935
|
|
|
987
|
-
export
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
borderRadius: "2px",
|
|
1028
|
-
background: `${input.value}`
|
|
1029
|
-
}}
|
|
1030
|
-
/>
|
|
1031
|
-
</div>
|
|
1032
|
-
</Popover>
|
|
1033
|
-
);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// tgreen: This doesn't work because the async validate function will not be automatically rerun onSubmit
|
|
1038
|
-
// class AddAsyncValidate extends Component {
|
|
1039
|
-
// constructor(props) {
|
|
1040
|
-
// super(props);
|
|
1041
|
-
// this.state = {
|
|
1042
|
-
// asyncValidating: false
|
|
1043
|
-
// };
|
|
1044
|
-
// this.runAsyncValidationDebounced = debounce(this.runAsyncValidation, 500);
|
|
1045
|
-
// }
|
|
1046
|
-
|
|
1047
|
-
// componentDidUpdate(oldProps) {
|
|
1048
|
-
// const {
|
|
1049
|
-
// validateOnChange,
|
|
1050
|
-
// input: { name, value },
|
|
1051
|
-
// meta: { touched, form, dispatch }
|
|
1052
|
-
// } = this.props;
|
|
1053
|
-
// const newValue = value;
|
|
1054
|
-
// const oldValue = oldProps.input.value;
|
|
1055
|
-
// const valueHasChanged = newValue !== oldValue;
|
|
1056
|
-
// if (validateOnChange && valueHasChanged) {
|
|
1057
|
-
// this.runAsyncValidationDebounced(newValue);
|
|
1058
|
-
// }
|
|
1059
|
-
// // mark the input as touched after changing value
|
|
1060
|
-
// if (valueHasChanged && !touched) {
|
|
1061
|
-
// dispatch(touch(form, name));
|
|
1062
|
-
// }
|
|
1063
|
-
// }
|
|
1064
|
-
|
|
1065
|
-
// triggerAsyncValidation(error) {
|
|
1066
|
-
// const {
|
|
1067
|
-
// input: { name },
|
|
1068
|
-
// meta: { dispatch, form },
|
|
1069
|
-
// formAsyncErrors
|
|
1070
|
-
// } = this.props;
|
|
1071
|
-
// // this needs to get a fresh prop for formAsyncErrors otherwise it will get out of sync.
|
|
1072
|
-
// // the test will catch this.
|
|
1073
|
-
// dispatch(
|
|
1074
|
-
// stopAsyncValidation(form, {
|
|
1075
|
-
// ...formAsyncErrors,
|
|
1076
|
-
// [name]: error
|
|
1077
|
-
// })
|
|
1078
|
-
// );
|
|
1079
|
-
// }
|
|
1080
|
-
|
|
1081
|
-
// runAsyncValidation = async val => {
|
|
1082
|
-
// const {
|
|
1083
|
-
// input: { name },
|
|
1084
|
-
// meta: { dispatch, form },
|
|
1085
|
-
// asyncValidate
|
|
1086
|
-
// } = this.props;
|
|
1087
|
-
|
|
1088
|
-
// this.setState({
|
|
1089
|
-
// asyncValidating: true
|
|
1090
|
-
// });
|
|
1091
|
-
// // mark this field as invalid so that the user can not submit this form while async validating
|
|
1092
|
-
// this.triggerAsyncValidation("asyncValidating");
|
|
1093
|
-
// dispatch(startAsyncValidation(form));
|
|
1094
|
-
// const error = await asyncValidate(val);
|
|
1095
|
-
// this.triggerAsyncValidation(error);
|
|
1096
|
-
// // if there is no error then clear it from redux
|
|
1097
|
-
// if (!error) {
|
|
1098
|
-
// dispatch(clearAsyncError(form, name));
|
|
1099
|
-
// }
|
|
1100
|
-
|
|
1101
|
-
// this.setState({
|
|
1102
|
-
// asyncValidating: false
|
|
1103
|
-
// });
|
|
1104
|
-
|
|
1105
|
-
// return error;
|
|
1106
|
-
// };
|
|
1107
|
-
|
|
1108
|
-
// onBlur = (...args) => {
|
|
1109
|
-
// const { input } = this.props;
|
|
1110
|
-
// // always run this on input blur so that the user cannot submit a form with a field that has not finished validating
|
|
1111
|
-
// this.runAsyncValidation(input.value);
|
|
1112
|
-
// input.onBlur(...args);
|
|
1113
|
-
// };
|
|
1114
|
-
|
|
1115
|
-
// render() {
|
|
1116
|
-
// const { asyncValidating } = this.state;
|
|
1117
|
-
// const {
|
|
1118
|
-
// passedComponent: Component,
|
|
1119
|
-
// input,
|
|
1120
|
-
// formAsyncErrors, // don't pass through
|
|
1121
|
-
// dispatch, // don't pass through
|
|
1122
|
-
// ...rest
|
|
1123
|
-
// } = this.props;
|
|
1124
|
-
|
|
1125
|
-
// return (
|
|
1126
|
-
// <Component
|
|
1127
|
-
// {...rest}
|
|
1128
|
-
// input={{
|
|
1129
|
-
// ...input,
|
|
1130
|
-
// onBlur: this.onBlur
|
|
1131
|
-
// }}
|
|
1132
|
-
// asyncValidating={asyncValidating}
|
|
1133
|
-
// />
|
|
1134
|
-
// );
|
|
1135
|
-
// }
|
|
1136
|
-
// }
|
|
1137
|
-
|
|
1138
|
-
// const WrappedAddAsyncValidate = connect((state, { meta }) => {
|
|
1139
|
-
// return {
|
|
1140
|
-
// formAsyncErrors: getFormAsyncErrors(meta.form)(state)
|
|
1141
|
-
// };
|
|
1142
|
-
// })(AddAsyncValidate);
|
|
936
|
+
export const RenderReactColorPicker = ({ input, onFieldSubmit, ...rest }) => (
|
|
937
|
+
<Popover
|
|
938
|
+
position="bottom-right"
|
|
939
|
+
minimal
|
|
940
|
+
modifiers={popoverOverflowModifiers}
|
|
941
|
+
content={
|
|
942
|
+
<SketchPicker
|
|
943
|
+
className="tg-color-picker-selector"
|
|
944
|
+
color={input.value}
|
|
945
|
+
onChangeComplete={color => {
|
|
946
|
+
input.onChange(color.hex);
|
|
947
|
+
onFieldSubmit(color.hex);
|
|
948
|
+
}}
|
|
949
|
+
{...removeUnwantedProps(rest)}
|
|
950
|
+
/>
|
|
951
|
+
}
|
|
952
|
+
>
|
|
953
|
+
<div
|
|
954
|
+
style={{
|
|
955
|
+
padding: "7px",
|
|
956
|
+
margin: "1px",
|
|
957
|
+
background: "#fff",
|
|
958
|
+
borderRadius: "1px",
|
|
959
|
+
boxShadow: "0 0 0 1px rgba(0,0,0,.1)",
|
|
960
|
+
display: "inline-block",
|
|
961
|
+
cursor: "pointer"
|
|
962
|
+
}}
|
|
963
|
+
>
|
|
964
|
+
<div
|
|
965
|
+
className="tg-color-picker-selected-color"
|
|
966
|
+
style={{
|
|
967
|
+
width: "36px",
|
|
968
|
+
height: "14px",
|
|
969
|
+
borderRadius: "2px",
|
|
970
|
+
background: `${input.value}`
|
|
971
|
+
}}
|
|
972
|
+
/>
|
|
973
|
+
</div>
|
|
974
|
+
</Popover>
|
|
975
|
+
);
|
|
1143
976
|
|
|
1144
977
|
export function generateField(component, opts) {
|
|
1145
978
|
const compWithDefaultVal = withAbstractWrapper(component, opts);
|
|
1146
|
-
return
|
|
1147
|
-
name,
|
|
1148
|
-
isRequired,
|
|
1149
|
-
onFieldSubmit = noop,
|
|
1150
|
-
noRedux,
|
|
1151
|
-
// asyncValidate,
|
|
1152
|
-
...rest
|
|
1153
|
-
}) {
|
|
1154
|
-
const component = compWithDefaultVal;
|
|
1155
|
-
|
|
979
|
+
return ({ name, isRequired, onFieldSubmit = noop, ...rest }) => {
|
|
1156
980
|
const props = {
|
|
1157
981
|
onFieldSubmit,
|
|
1158
982
|
name,
|
|
1159
|
-
|
|
1160
|
-
input: {
|
|
1161
|
-
onChange: rest.onChange || noop,
|
|
1162
|
-
onBlur: rest.onBlur || noop,
|
|
1163
|
-
value: rest.value,
|
|
1164
|
-
name
|
|
1165
|
-
}
|
|
1166
|
-
}),
|
|
1167
|
-
component,
|
|
983
|
+
component: compWithDefaultVal,
|
|
1168
984
|
...(isRequired && { validate: fieldRequired }),
|
|
1169
985
|
isRequired,
|
|
1170
986
|
...rest
|
|
1171
987
|
};
|
|
1172
988
|
|
|
1173
|
-
// if (asyncValidate) {
|
|
1174
|
-
// props = {
|
|
1175
|
-
// ...props,
|
|
1176
|
-
// asyncValidate,
|
|
1177
|
-
// component: WrappedAddAsyncValidate,
|
|
1178
|
-
// passedComponent: component
|
|
1179
|
-
// };
|
|
1180
|
-
// }
|
|
1181
|
-
|
|
1182
989
|
return <Field {...props} />;
|
|
1183
990
|
};
|
|
1184
991
|
}
|
|
@@ -1194,9 +1001,15 @@ export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
|
1194
1001
|
...rest
|
|
1195
1002
|
} = props;
|
|
1196
1003
|
|
|
1004
|
+
const {
|
|
1005
|
+
showErrorIfUntouched: _showErrorIfUntouched,
|
|
1006
|
+
meta: { touched, error, warning }
|
|
1007
|
+
} = props;
|
|
1008
|
+
const showErrorIfUntouched =
|
|
1009
|
+
opts.showErrorIfUntouched || _showErrorIfUntouched;
|
|
1197
1010
|
//get is assign defaults mode
|
|
1198
1011
|
//if assign default value mode then add on to the component
|
|
1199
|
-
const [defaultValCount, setDefaultValCount] =
|
|
1012
|
+
const [defaultValCount, setDefaultValCount] = useState(0);
|
|
1200
1013
|
const [defaultValueFromBackend, setDefault] = useState();
|
|
1201
1014
|
const [allowUserOverride, setUserOverride] = useState(true);
|
|
1202
1015
|
const [isLoadingDefaultValue, setLoadingDefaultValue] = useState(false);
|
|
@@ -1210,14 +1023,17 @@ export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
|
1210
1023
|
|
|
1211
1024
|
const caresAboutToolContext = generateDefaultValue?.params?.toolName;
|
|
1212
1025
|
|
|
1213
|
-
const customParamsToUse =
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1026
|
+
const customParamsToUse = useMemo(
|
|
1027
|
+
() => ({
|
|
1028
|
+
...(caresAboutToolContext
|
|
1029
|
+
? { ...workflowDefaultParamsObj, ...workflowParams }
|
|
1030
|
+
: {}),
|
|
1031
|
+
...(generateDefaultValue ? generateDefaultValue.customParams : {})
|
|
1032
|
+
}),
|
|
1033
|
+
[caresAboutToolContext, generateDefaultValue, workflowParams]
|
|
1034
|
+
);
|
|
1219
1035
|
|
|
1220
|
-
|
|
1036
|
+
const triggerGetDefault = useCallback(async () => {
|
|
1221
1037
|
if (!defaultValueByIdOverride) {
|
|
1222
1038
|
//if defaultValueByIdOverride is passed, we can skip over getting the value from the backend straight to massaging the default value
|
|
1223
1039
|
if (!window.__triggerGetDefaultValueRequest) return;
|
|
@@ -1292,22 +1108,52 @@ export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
|
1292
1108
|
await fakeWait();
|
|
1293
1109
|
}
|
|
1294
1110
|
setLoadingDefaultValue(false);
|
|
1295
|
-
}
|
|
1111
|
+
}, [
|
|
1112
|
+
caresAboutToolContext,
|
|
1113
|
+
customParamsToUse,
|
|
1114
|
+
defaultValCount,
|
|
1115
|
+
defaultValueByIdOverride,
|
|
1116
|
+
generateDefaultValue,
|
|
1117
|
+
massageDefaultIdValue
|
|
1118
|
+
]);
|
|
1119
|
+
|
|
1296
1120
|
// if generateDefaultValue, hit the backend for that value
|
|
1297
1121
|
useDeepCompareEffect(() => {
|
|
1298
1122
|
// if the input already has a value we don't want to override with the default value request
|
|
1299
1123
|
if (rest.input.value) return;
|
|
1300
1124
|
triggerGetDefault();
|
|
1301
1125
|
}, [generateDefaultValue || {}]);
|
|
1126
|
+
|
|
1302
1127
|
// const asyncValidating = props.asyncValidating;
|
|
1303
|
-
const defaultProps =
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1128
|
+
const defaultProps = useMemo(
|
|
1129
|
+
() => ({
|
|
1130
|
+
...rest,
|
|
1131
|
+
defaultValue: defaultValueFromBackend || defaultValueFromProps,
|
|
1132
|
+
disabled: props.disabled || allowUserOverride === false,
|
|
1133
|
+
readOnly: props.readOnly || isLoadingDefaultValue,
|
|
1134
|
+
intent: getIntent({
|
|
1135
|
+
showErrorIfUntouched,
|
|
1136
|
+
meta: { touched, error, warning }
|
|
1137
|
+
}),
|
|
1138
|
+
intentClass: getIntentClass({
|
|
1139
|
+
showErrorIfUntouched,
|
|
1140
|
+
meta: { touched, error, warning }
|
|
1141
|
+
})
|
|
1142
|
+
}),
|
|
1143
|
+
[
|
|
1144
|
+
allowUserOverride,
|
|
1145
|
+
defaultValueFromBackend,
|
|
1146
|
+
defaultValueFromProps,
|
|
1147
|
+
error,
|
|
1148
|
+
isLoadingDefaultValue,
|
|
1149
|
+
props.disabled,
|
|
1150
|
+
props.readOnly,
|
|
1151
|
+
rest,
|
|
1152
|
+
showErrorIfUntouched,
|
|
1153
|
+
touched,
|
|
1154
|
+
warning
|
|
1155
|
+
]
|
|
1156
|
+
);
|
|
1311
1157
|
|
|
1312
1158
|
// don't show intent while async validating
|
|
1313
1159
|
// if (asyncValidating) {
|
|
@@ -1315,35 +1161,40 @@ export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
|
1315
1161
|
// delete defaultProps.intentClass;
|
|
1316
1162
|
// }
|
|
1317
1163
|
|
|
1318
|
-
const startAssigningDefault = (
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1164
|
+
const startAssigningDefault = useCallback(
|
|
1165
|
+
() =>
|
|
1166
|
+
window.__showAssignDefaultValueModal &&
|
|
1167
|
+
window.__showAssignDefaultValueModal({
|
|
1168
|
+
...props,
|
|
1169
|
+
generateDefaultValue: {
|
|
1170
|
+
...props.generateDefaultValue,
|
|
1171
|
+
customParams: customParamsToUse
|
|
1172
|
+
},
|
|
1173
|
+
onFinish: () => {
|
|
1174
|
+
triggerGetDefault();
|
|
1175
|
+
}
|
|
1176
|
+
}),
|
|
1177
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1178
|
+
[customParamsToUse, triggerGetDefault]
|
|
1179
|
+
);
|
|
1330
1180
|
|
|
1331
1181
|
return (
|
|
1332
1182
|
<AbstractInput
|
|
1333
|
-
{...
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1183
|
+
{...opts}
|
|
1184
|
+
defaultValCount={defaultValCount}
|
|
1185
|
+
isRequired={isRequired}
|
|
1186
|
+
{...defaultProps}
|
|
1187
|
+
isLoadingDefaultValue={isLoadingDefaultValue}
|
|
1188
|
+
showGenerateDefaultDot={
|
|
1189
|
+
!inAssignDefaultsMode &&
|
|
1190
|
+
window.__showGenerateDefaultDot?.() &&
|
|
1191
|
+
!!generateDefaultValue
|
|
1192
|
+
}
|
|
1193
|
+
setAssignDefaultsMode={setAssignDefaultsMode}
|
|
1194
|
+
startAssigningDefault={startAssigningDefault}
|
|
1195
|
+
assignDefaultButton={
|
|
1196
|
+
inAssignDefaultsMode &&
|
|
1197
|
+
generateDefaultValue && (
|
|
1347
1198
|
<Button
|
|
1348
1199
|
onClick={startAssigningDefault}
|
|
1349
1200
|
small
|
|
@@ -1352,7 +1203,7 @@ export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
|
1352
1203
|
Assign Default
|
|
1353
1204
|
</Button>
|
|
1354
1205
|
)
|
|
1355
|
-
}
|
|
1206
|
+
}
|
|
1356
1207
|
>
|
|
1357
1208
|
<ComponentToWrap {...defaultProps} />
|
|
1358
1209
|
</AbstractInput>
|
|
@@ -1372,7 +1223,7 @@ export const SwitchField = generateField(renderBlueprintSwitch, {
|
|
|
1372
1223
|
noOuterLabel: true,
|
|
1373
1224
|
noFillField: true
|
|
1374
1225
|
});
|
|
1375
|
-
export const TextareaField = generateField(
|
|
1226
|
+
export const TextareaField = generateField(RenderBlueprintTextarea);
|
|
1376
1227
|
export const SuggestField = generateField(renderSuggest);
|
|
1377
1228
|
export const EditableTextField = generateField(renderBlueprintEditableText);
|
|
1378
1229
|
export const NumericInputField = generateField(renderBlueprintNumericInput);
|