@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.
Files changed (98) hide show
  1. package/DataTable/ColumnFilterMenu.d.ts +2 -1
  2. package/DataTable/Columns.d.ts +51 -0
  3. package/DataTable/DisplayOptions.d.ts +14 -14
  4. package/DataTable/EditabelCell.d.ts +2 -5
  5. package/DataTable/EditableCell.d.ts +7 -0
  6. package/DataTable/FilterAndSortMenu.d.ts +9 -9
  7. package/DataTable/PagingTool.d.ts +25 -2
  8. package/DataTable/RenderCell.d.ts +18 -0
  9. package/DataTable/SearchBar.d.ts +4 -3
  10. package/DataTable/SortableColumns.d.ts +6 -9
  11. package/DataTable/ThComponent.d.ts +9 -0
  12. package/DataTable/index.d.ts +0 -5
  13. package/DataTable/utils/getIdOrCodeOrIndex.d.ts +1 -2
  14. package/DataTable/utils/handleCopyTable.d.ts +1 -0
  15. package/DataTable/utils/index.d.ts +4 -2
  16. package/DataTable/utils/primarySelectedValue.d.ts +1 -0
  17. package/DataTable/utils/queryParams.d.ts +13 -8
  18. package/DataTable/utils/removeCleanRows.d.ts +1 -1
  19. package/DataTable/utils/rowClick.d.ts +24 -3
  20. package/DataTable/utils/useDeepEqualMemo.d.ts +1 -0
  21. package/DataTable/utils/useTableEntities.d.ts +5 -0
  22. package/DataTable/utils/useTableParams.d.ts +49 -0
  23. package/DataTable/utils/withTableParams.d.ts +3 -16
  24. package/DataTable/viewColumn.d.ts +11 -4
  25. package/FormComponents/AbstractField.d.ts +1 -0
  26. package/FormComponents/Uploader.d.ts +34 -1
  27. package/FormComponents/index.d.ts +111 -60
  28. package/MatchHeaders.d.ts +9 -10
  29. package/SimpleStepViz.d.ts +2 -1
  30. package/TgSuggest/index.d.ts +1 -21
  31. package/UploadCsvWizard.d.ts +1 -1
  32. package/index.cjs.js +47861 -49125
  33. package/index.d.ts +6 -3
  34. package/index.es.js +47959 -49223
  35. package/package.json +6 -5
  36. package/src/DataTable/CellDragHandle.js +70 -69
  37. package/src/DataTable/ColumnFilterMenu.js +23 -21
  38. package/src/DataTable/Columns.js +948 -0
  39. package/src/DataTable/Columns.jsx +945 -0
  40. package/src/DataTable/DisplayOptions.js +173 -192
  41. package/src/DataTable/EditabelCell.js +7 -18
  42. package/src/DataTable/EditabelCell.jsx +44 -0
  43. package/src/DataTable/EditableCell.js +44 -0
  44. package/src/DataTable/FilterAndSortMenu.js +215 -234
  45. package/src/DataTable/PagingTool.js +47 -56
  46. package/src/DataTable/RenderCell.js +191 -0
  47. package/src/DataTable/RenderCell.jsx +191 -0
  48. package/src/DataTable/SearchBar.js +12 -5
  49. package/src/DataTable/SortableColumns.js +44 -39
  50. package/src/DataTable/ThComponent.js +44 -0
  51. package/src/DataTable/dataTableEnhancer.js +32 -295
  52. package/src/DataTable/index.js +2945 -3596
  53. package/src/DataTable/utils/getIdOrCodeOrIndex.js +1 -1
  54. package/src/DataTable/utils/handleCopyTable.js +16 -0
  55. package/src/DataTable/utils/index.js +7 -3
  56. package/src/DataTable/utils/primarySelectedValue.js +1 -0
  57. package/src/DataTable/utils/queryParams.js +110 -85
  58. package/src/DataTable/utils/removeCleanRows.js +3 -3
  59. package/src/DataTable/utils/rowClick.js +34 -9
  60. package/src/DataTable/utils/selection.js +1 -1
  61. package/src/DataTable/utils/useDeepEqualMemo.js +10 -0
  62. package/src/DataTable/utils/useTableEntities.js +38 -0
  63. package/src/DataTable/utils/useTableParams.js +362 -0
  64. package/src/DataTable/utils/withTableParams.js +244 -274
  65. package/src/DataTable/validateTableWideErrors.js +1 -1
  66. package/src/DataTable/viewColumn.js +5 -9
  67. package/src/DialogFooter/index.js +3 -3
  68. package/src/FillWindow.js +2 -3
  69. package/src/FormComponents/AbstractField.js +388 -0
  70. package/src/FormComponents/Uploader.js +674 -649
  71. package/src/FormComponents/index.js +505 -654
  72. package/src/FormComponents/tryToMatchSchemas.js +1 -6
  73. package/src/MatchHeaders.js +27 -22
  74. package/src/SimpleStepViz.js +19 -23
  75. package/src/TgSelect/index.js +1 -1
  76. package/src/TgSuggest/index.js +94 -106
  77. package/src/UploadCsvWizard.js +571 -577
  78. package/src/enhancers/withDialog/tg_modalState.js +1 -0
  79. package/src/index.js +10 -4
  80. package/src/showDialogOnDocBody.js +5 -9
  81. package/src/useDialog.js +25 -26
  82. package/src/utils/commandControls.js +2 -2
  83. package/src/utils/handlerHelpers.js +19 -25
  84. package/src/utils/hooks/index.js +1 -0
  85. package/src/utils/hooks/useDeepEqualMemo.js +10 -0
  86. package/src/utils/hooks/useStableReference.js +9 -0
  87. package/src/utils/renderOnDoc.js +8 -5
  88. package/src/utils/tagUtils.js +3 -3
  89. package/src/utils/useTraceUpdate.js +19 -0
  90. package/src/wrapDialog.js +0 -2
  91. package/style.css +251 -251
  92. package/useDialog.d.ts +2 -6
  93. package/utils/hooks/index.d.ts +1 -0
  94. package/utils/hooks/useDeepEqualMemo.d.ts +1 -0
  95. package/utils/hooks/useStableReference.d.ts +1 -0
  96. package/utils/renderOnDoc.d.ts +1 -1
  97. package/utils/tagUtils.d.ts +5 -1
  98. 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, { useContext, useState } from "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(...args) {
61
- const intent = getIntent(...args);
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
- function LabelWithTooltipInfo({ label, tooltipInfo, labelStyle }) {
104
- return tooltipInfo ? (
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
- class AbstractInput extends React.Component {
119
- componentDidMount() {
120
- const {
121
- defaultValue,
122
- enableReinitialize,
123
- input: { value }
124
- } = this.props;
125
- if (
126
- ((value !== false && !value) || enableReinitialize) &&
127
- defaultValue !== undefined
128
- ) {
129
- this.updateDefaultValue();
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
- componentDidUpdate(oldProps) {
134
- const {
135
- defaultValue: oldDefaultValue,
136
- defaultValCount: oldDefaultValCount
137
- } = oldProps;
138
- const {
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
- updateDefaultValue = () => {
156
- const {
157
- defaultValue,
158
- input: { name },
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
- if (isRequired && hasOuterLabel && label && !labelInfo) {
252
- labelInfo = `(required${fileLimit ? `, ${getFileLimitInfo()}` : ""})`;
253
- } else if (!labelInfo && fileLimit) {
254
- labelInfo = `(${getFileLimitInfo()})`;
255
- }
215
+ let labelInfo = secondaryLabel;
256
216
 
257
- return (
258
- <FormGroup
259
- className={classNames(className, testClassName, {
260
- "tg-flex-form-content": leftEl || rightEl,
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
- export const renderBlueprintDateInput = props => {
311
- const { input, intent, onFieldSubmit, inputProps, ...rest } = props;
312
- return (
313
- <DateInput
314
- {...getDayjsFormatter("L")}
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
- <DateRangeInput
333
- {...getDayjsFormatter("L")}
334
- {...removeUnwantedProps(rest)}
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
- inputProps={inputProps}
337
- {...input}
338
- value={
339
- input.value
340
- ? [new Date(input.value[0]), new Date(input.value[1])]
341
- : undefined
239
+ label={
240
+ hasOuterLabel && (
241
+ <LabelWithTooltipInfo
242
+ labelStyle={labelStyle}
243
+ label={label}
244
+ tooltipInfo={tooltipInfo}
245
+ />
246
+ )
342
247
  }
343
- onChange={function (selectedDate) {
344
- input.onChange(selectedDate);
345
- onFieldSubmit(selectedDate);
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 RenderBlueprintInput = props => {
352
- const {
353
- input,
354
- // meta = {},
355
- intent,
356
- onFieldSubmit,
357
- onKeyDown = noop,
358
- asyncValidating,
359
- rightElement,
360
- clickToEdit,
361
- ...rest
362
- } = props;
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
- ></Button>{" "}
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
- ></Button>
429
+ />
461
430
  ))}
462
431
  </div>
463
432
  );
464
433
  return inner;
465
434
  };
466
435
 
467
- export const renderBlueprintCheckbox = props => {
468
- const { input, label, tooltipInfo, beforeOnChange, onFieldSubmit, ...rest } =
469
- props;
470
- return (
471
- <Checkbox
472
- {...removeUnwantedProps(rest)}
473
- {...input}
474
- checked={input.value}
475
- label={<LabelWithTooltipInfo label={label} tooltipInfo={tooltipInfo} />}
476
- onChange={getCheckboxOrSwitchOnChange({
477
- beforeOnChange,
478
- input,
479
- onFieldSubmit
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 = props => {
502
- const { input, label, tooltipInfo, onFieldSubmit, beforeOnChange, ...rest } =
503
- props;
504
-
505
- return (
506
- <Switch
507
- {...removeUnwantedProps(rest)}
508
- {...input}
509
- checked={input.value}
510
- label={<LabelWithTooltipInfo label={label} tooltipInfo={tooltipInfo} />}
511
- onChange={getCheckboxOrSwitchOnChange({
512
- beforeOnChange,
513
- input,
514
- onFieldSubmit
515
- })}
516
- />
517
- );
518
- };
519
-
520
- export const renderFileUpload = props => {
521
- const { input, onFieldSubmit, ...rest } = props;
522
- return (
523
- <Uploader
524
- fileList={input.value}
525
- onFieldSubmit={onFieldSubmit}
526
- {...rest}
527
- onChange={input.onChange}
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
- export class renderBlueprintTextarea extends React.Component {
533
- state = {
534
- value: null,
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
- handleValSubmit = () => {
548
- this.props.input.onChange(
549
- this.state.value === null ? this.props.input.value : this.state.value
550
- );
551
- this.props.onFieldSubmit(
552
- this.state.value === null ? this.props.input.value : this.state.value,
553
- { cmdEnter: true }
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
- onKeyDown = (...args) => {
529
+
530
+ const handleOnKeyDown = (...args) => {
558
531
  const e = args[0];
559
- (this.props.onKeyDown || noop)(...args);
532
+ (onKeyDown || noop)(...args);
560
533
  if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
561
- this.props.onFieldSubmit(e.target.value, { cmdEnter: true }, e);
562
- this.props.input.onChange(e);
563
- this.stopEdit();
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
- return (
581
- <React.Fragment>
582
- <TextArea
583
- {...removeUnwantedProps(rest)}
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
- {...input}
625
- onBlur={function (e, val) {
626
- if (rest.readOnly) return;
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 = props => {
771
- const {
772
- async,
773
- input: { value, onChange },
774
- hideValue,
775
- intent,
776
- options,
777
- onFieldSubmit,
778
- ...rest
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}></TgSuggest>;
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 = props => {
804
- // spreading input not working, grab the values needed instead
805
- const {
806
- input: { value, onChange },
807
- hideValue,
808
- className,
809
- placeholder,
810
- onFieldSubmit,
811
- options,
812
- hidePlaceHolder,
813
- minimal,
814
- disabled,
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 = props => {
896
- const {
897
- input,
898
- hideValue,
899
- intent,
900
- inputClassName,
901
- onFieldSubmit,
902
- onAnyNumberChange,
903
- ...rest
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 class RenderReactColorPicker extends React.Component {
988
- handleChange = color => {
989
- const { input, onFieldSubmit } = this.props;
990
-
991
- input.onChange(color.hex);
992
- onFieldSubmit(color.hex);
993
- };
994
-
995
- render() {
996
- const { input, onFieldSubmit, ...rest } = this.props;
997
- return (
998
- <Popover
999
- position="bottom-right"
1000
- minimal
1001
- modifiers={popoverOverflowModifiers}
1002
- content={
1003
- <SketchPicker
1004
- className="tg-color-picker-selector"
1005
- color={input.value}
1006
- onChangeComplete={this.handleChange}
1007
- {...removeUnwantedProps(rest)}
1008
- />
1009
- }
1010
- >
1011
- <div
1012
- style={{
1013
- padding: "7px",
1014
- margin: "1px",
1015
- background: "#fff",
1016
- borderRadius: "1px",
1017
- boxShadow: "0 0 0 1px rgba(0,0,0,.1)",
1018
- display: "inline-block",
1019
- cursor: "pointer"
1020
- }}
1021
- >
1022
- <div
1023
- className="tg-color-picker-selected-color"
1024
- style={{
1025
- width: "36px",
1026
- height: "14px",
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 function FieldMaker({
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
- ...(noRedux && {
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] = React.useState(0);
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
- ...(caresAboutToolContext
1215
- ? { ...workflowDefaultParamsObj, ...workflowParams }
1216
- : {}),
1217
- ...(generateDefaultValue ? generateDefaultValue.customParams : {})
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
- async function triggerGetDefault() {
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
- ...rest,
1305
- defaultValue: defaultValueFromBackend || defaultValueFromProps,
1306
- disabled: props.disabled || allowUserOverride === false,
1307
- readOnly: props.readOnly || isLoadingDefaultValue,
1308
- intent: getIntent(props),
1309
- intentClass: getIntentClass(props)
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
- window.__showAssignDefaultValueModal &&
1320
- window.__showAssignDefaultValueModal({
1321
- ...props,
1322
- generateDefaultValue: {
1323
- ...props.generateDefaultValue,
1324
- customParams: customParamsToUse
1325
- },
1326
- onFinish: () => {
1327
- triggerGetDefault();
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
- ...opts,
1335
- defaultValCount,
1336
- isRequired,
1337
- ...defaultProps,
1338
- isLoadingDefaultValue,
1339
- showGenerateDefaultDot:
1340
- !inAssignDefaultsMode &&
1341
- window.__showGenerateDefaultDot &&
1342
- window.__showGenerateDefaultDot() &&
1343
- !!generateDefaultValue,
1344
- setAssignDefaultsMode,
1345
- startAssigningDefault,
1346
- assignDefaultButton: inAssignDefaultsMode && generateDefaultValue && (
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(renderBlueprintTextarea);
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);