@teselagen/ui 0.7.2-beta.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FormComponents/AbstractField.d.ts +1 -0
- package/FormComponents/FormSeparator.d.ts +3 -0
- package/index.cjs.js +8 -4
- package/index.d.ts +1 -0
- package/index.es.js +8 -4
- package/package.json +1 -1
- package/src/DataTable/EditabelCell.js +4 -4
- package/src/DataTable/index.js +2 -2
- package/src/DataTable/utils/useTableParams.js +1 -0
- package/src/DataTable/utils/withTableParams.js +2 -2
- package/src/FormComponents/AbstractField.js +388 -0
- package/src/FormComponents/FormSeparator.js +9 -0
- package/src/FormComponents/style.css +24 -0
- package/src/index.js +1 -0
- package/style.css +29 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function withAbstractWrapper(ComponentToWrap: any, opts?: {}): (props: any) => import("react/jsx-runtime").JSX.Element;
|
package/index.cjs.js
CHANGED
|
@@ -3071,6 +3071,9 @@ const LoadingDots = /* @__PURE__ */ __name(() => {
|
|
|
3071
3071
|
}, []);
|
|
3072
3072
|
return /* @__PURE__ */ React$1.createElement("span", null, dots);
|
|
3073
3073
|
}, "LoadingDots");
|
|
3074
|
+
const FormSeparator = /* @__PURE__ */ __name(({ label = "or" } = {}) => {
|
|
3075
|
+
return /* @__PURE__ */ React$1.createElement("div", { className: "form-separator" }, /* @__PURE__ */ React$1.createElement("p", { style: { opacity: 0.8 } }, label));
|
|
3076
|
+
}, "FormSeparator");
|
|
3074
3077
|
const AssignDefaultsModeContext = React$1.createContext({
|
|
3075
3078
|
inAssignDefaultsMode: false,
|
|
3076
3079
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -52593,8 +52596,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
52593
52596
|
props = __spreadValues(__spreadValues({}, props), tableParams);
|
|
52594
52597
|
const queryParams = React$1.useMemo(() => {
|
|
52595
52598
|
if (!isTableParamsConnected) {
|
|
52596
|
-
const additionalFilterToUse = typeof props.additionalFilter === "function" ? props.additionalFilter : () => props.additionalFilter;
|
|
52597
|
-
const additionalOrFilterToUse = typeof props.additionalOrFilter === "function" ? props.additionalOrFilter : () => props.additionalOrFilter;
|
|
52599
|
+
const additionalFilterToUse = typeof props.additionalFilter === "function" ? props.additionalFilter.bind(void 0, ownProps) : () => props.additionalFilter;
|
|
52600
|
+
const additionalOrFilterToUse = typeof props.additionalOrFilter === "function" ? props.additionalOrFilter.bind(void 0, ownProps) : () => props.additionalOrFilter;
|
|
52598
52601
|
return getQueryParams({
|
|
52599
52602
|
doNotCoercePageSize,
|
|
52600
52603
|
currentParams,
|
|
@@ -68626,8 +68629,8 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
68626
68629
|
[controlled_pageSize, defaultsToUse, pageSize, history == null ? void 0 : history.location]
|
|
68627
68630
|
);
|
|
68628
68631
|
const queryParams = React$1.useMemo(() => {
|
|
68629
|
-
const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter : () => additionalFilter;
|
|
68630
|
-
const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter : () => additionalOrFilter;
|
|
68632
|
+
const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter.bind(void 0, passingProps) : () => additionalFilter;
|
|
68633
|
+
const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter.bind(void 0, passingProps) : () => additionalOrFilter;
|
|
68631
68634
|
return getQueryParams({
|
|
68632
68635
|
doNotCoercePageSize,
|
|
68633
68636
|
currentParams,
|
|
@@ -74767,6 +74770,7 @@ exports.EditableTextField = EditableTextField;
|
|
|
74767
74770
|
exports.EnhancedMenuItem = EnhancedMenuItem;
|
|
74768
74771
|
exports.FileUploadField = FileUploadField;
|
|
74769
74772
|
exports.FillWindow = FillWindow;
|
|
74773
|
+
exports.FormSeparator = FormSeparator;
|
|
74770
74774
|
exports.HotkeysDialog = HotkeysDialog;
|
|
74771
74775
|
exports.InfoHelper = InfoHelper;
|
|
74772
74776
|
exports.InputField = InputField;
|
package/index.d.ts
CHANGED
package/index.es.js
CHANGED
|
@@ -3053,6 +3053,9 @@ const LoadingDots = /* @__PURE__ */ __name(() => {
|
|
|
3053
3053
|
}, []);
|
|
3054
3054
|
return /* @__PURE__ */ React__default.createElement("span", null, dots);
|
|
3055
3055
|
}, "LoadingDots");
|
|
3056
|
+
const FormSeparator = /* @__PURE__ */ __name(({ label = "or" } = {}) => {
|
|
3057
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "form-separator" }, /* @__PURE__ */ React__default.createElement("p", { style: { opacity: 0.8 } }, label));
|
|
3058
|
+
}, "FormSeparator");
|
|
3056
3059
|
const AssignDefaultsModeContext = React__default.createContext({
|
|
3057
3060
|
inAssignDefaultsMode: false,
|
|
3058
3061
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -52575,8 +52578,8 @@ const DataTable = /* @__PURE__ */ __name((_I) => {
|
|
|
52575
52578
|
props = __spreadValues(__spreadValues({}, props), tableParams);
|
|
52576
52579
|
const queryParams = useMemo(() => {
|
|
52577
52580
|
if (!isTableParamsConnected) {
|
|
52578
|
-
const additionalFilterToUse = typeof props.additionalFilter === "function" ? props.additionalFilter : () => props.additionalFilter;
|
|
52579
|
-
const additionalOrFilterToUse = typeof props.additionalOrFilter === "function" ? props.additionalOrFilter : () => props.additionalOrFilter;
|
|
52581
|
+
const additionalFilterToUse = typeof props.additionalFilter === "function" ? props.additionalFilter.bind(void 0, ownProps) : () => props.additionalFilter;
|
|
52582
|
+
const additionalOrFilterToUse = typeof props.additionalOrFilter === "function" ? props.additionalOrFilter.bind(void 0, ownProps) : () => props.additionalOrFilter;
|
|
52580
52583
|
return getQueryParams({
|
|
52581
52584
|
doNotCoercePageSize,
|
|
52582
52585
|
currentParams,
|
|
@@ -68608,8 +68611,8 @@ const useTableParams = /* @__PURE__ */ __name((props) => {
|
|
|
68608
68611
|
[controlled_pageSize, defaultsToUse, pageSize, history == null ? void 0 : history.location]
|
|
68609
68612
|
);
|
|
68610
68613
|
const queryParams = useMemo(() => {
|
|
68611
|
-
const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter : () => additionalFilter;
|
|
68612
|
-
const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter : () => additionalOrFilter;
|
|
68614
|
+
const additionalFilterToUse = typeof additionalFilter === "function" ? additionalFilter.bind(void 0, passingProps) : () => additionalFilter;
|
|
68615
|
+
const additionalOrFilterToUse = typeof additionalOrFilter === "function" ? additionalOrFilter.bind(void 0, passingProps) : () => additionalOrFilter;
|
|
68613
68616
|
return getQueryParams({
|
|
68614
68617
|
doNotCoercePageSize,
|
|
68615
68618
|
currentParams,
|
|
@@ -74750,6 +74753,7 @@ export {
|
|
|
74750
74753
|
EnhancedMenuItem,
|
|
74751
74754
|
FileUploadField,
|
|
74752
74755
|
FillWindow,
|
|
74756
|
+
FormSeparator,
|
|
74753
74757
|
HotkeysDialog,
|
|
74754
74758
|
InfoHelper,
|
|
74755
74759
|
InputField,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
3
|
export const EditableCell = ({
|
|
4
|
+
value,
|
|
5
|
+
setValue,
|
|
4
6
|
cancelEdit,
|
|
5
7
|
dataTest,
|
|
6
8
|
finishEdit,
|
|
7
|
-
isNumeric
|
|
8
|
-
initialValue
|
|
9
|
+
isNumeric
|
|
9
10
|
}) => {
|
|
10
|
-
const [value, setValue] = useState(initialValue);
|
|
11
11
|
const inputRef = useRef(null);
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
package/src/DataTable/index.js
CHANGED
|
@@ -338,12 +338,12 @@ const DataTable = ({
|
|
|
338
338
|
if (!isTableParamsConnected) {
|
|
339
339
|
const additionalFilterToUse =
|
|
340
340
|
typeof props.additionalFilter === "function"
|
|
341
|
-
? props.additionalFilter
|
|
341
|
+
? props.additionalFilter.bind(this, ownProps)
|
|
342
342
|
: () => props.additionalFilter;
|
|
343
343
|
|
|
344
344
|
const additionalOrFilterToUse =
|
|
345
345
|
typeof props.additionalOrFilter === "function"
|
|
346
|
-
? props.additionalOrFilter
|
|
346
|
+
? props.additionalOrFilter.bind(this, ownProps)
|
|
347
347
|
: () => props.additionalOrFilter;
|
|
348
348
|
|
|
349
349
|
return getQueryParams({
|
|
@@ -168,12 +168,12 @@ export const useTableParams = props => {
|
|
|
168
168
|
const queryParams = useMemo(() => {
|
|
169
169
|
const additionalFilterToUse =
|
|
170
170
|
typeof additionalFilter === "function"
|
|
171
|
-
? additionalFilter
|
|
171
|
+
? additionalFilter.bind(this, passingProps)
|
|
172
172
|
: () => additionalFilter;
|
|
173
173
|
|
|
174
174
|
const additionalOrFilterToUse =
|
|
175
175
|
typeof additionalOrFilter === "function"
|
|
176
|
-
? additionalOrFilter
|
|
176
|
+
? additionalOrFilter.bind(this, passingProps)
|
|
177
177
|
: () => additionalOrFilter;
|
|
178
178
|
|
|
179
179
|
return getQueryParams({
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { Button, FormGroup, Position, Tooltip } from "@blueprintjs/core";
|
|
2
|
+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
AssignDefaultsModeContext,
|
|
5
|
+
WorkflowDefaultParamsContext,
|
|
6
|
+
workflowDefaultParamsObj
|
|
7
|
+
} from "../AssignDefaultsModeContext";
|
|
8
|
+
import { difference, isEqual, kebabCase } from "lodash-es";
|
|
9
|
+
import {
|
|
10
|
+
fakeWait,
|
|
11
|
+
getIntent,
|
|
12
|
+
getIntentClass,
|
|
13
|
+
LabelWithTooltipInfo
|
|
14
|
+
} from "./utils";
|
|
15
|
+
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
16
|
+
import { change } from "redux-form";
|
|
17
|
+
import popoverOverflowModifiers from "../utils/popoverOverflowModifiers";
|
|
18
|
+
import classNames from "classnames";
|
|
19
|
+
|
|
20
|
+
const AbstractInput = props => {
|
|
21
|
+
const {
|
|
22
|
+
defaultValue,
|
|
23
|
+
meta: { dispatch, form, touched, error, warning },
|
|
24
|
+
onDefaultValChanged,
|
|
25
|
+
onFieldSubmit,
|
|
26
|
+
children,
|
|
27
|
+
tooltipProps,
|
|
28
|
+
tooltipError,
|
|
29
|
+
disabled,
|
|
30
|
+
intent,
|
|
31
|
+
tooltipInfo,
|
|
32
|
+
label,
|
|
33
|
+
inlineLabel,
|
|
34
|
+
isLabelTooltip,
|
|
35
|
+
secondaryLabel,
|
|
36
|
+
className,
|
|
37
|
+
showErrorIfUntouched,
|
|
38
|
+
asyncValidating,
|
|
39
|
+
containerStyle,
|
|
40
|
+
leftEl,
|
|
41
|
+
rightEl,
|
|
42
|
+
labelStyle,
|
|
43
|
+
noOuterLabel,
|
|
44
|
+
fileLimit,
|
|
45
|
+
noMarginBottom,
|
|
46
|
+
assignDefaultButton,
|
|
47
|
+
showGenerateDefaultDot,
|
|
48
|
+
setAssignDefaultsMode,
|
|
49
|
+
startAssigningDefault,
|
|
50
|
+
input,
|
|
51
|
+
noFillField,
|
|
52
|
+
isRequired,
|
|
53
|
+
isLoadingDefaultValue,
|
|
54
|
+
enableReinitialize,
|
|
55
|
+
defaultValCount
|
|
56
|
+
} = props;
|
|
57
|
+
|
|
58
|
+
const prevProps = useRef({ defaultValue, defaultValCount });
|
|
59
|
+
|
|
60
|
+
const updateDefaultValue = useCallback(() => {
|
|
61
|
+
dispatch(change(form, input.name, defaultValue));
|
|
62
|
+
onDefaultValChanged &&
|
|
63
|
+
onDefaultValChanged(defaultValue, input.name, form, props);
|
|
64
|
+
onFieldSubmit && onFieldSubmit(defaultValue);
|
|
65
|
+
}, [
|
|
66
|
+
defaultValue,
|
|
67
|
+
dispatch,
|
|
68
|
+
form,
|
|
69
|
+
input.name,
|
|
70
|
+
onDefaultValChanged,
|
|
71
|
+
onFieldSubmit,
|
|
72
|
+
props
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (
|
|
77
|
+
((input.value !== false && !input.value) || enableReinitialize) &&
|
|
78
|
+
defaultValue !== undefined
|
|
79
|
+
) {
|
|
80
|
+
updateDefaultValue();
|
|
81
|
+
}
|
|
82
|
+
}, [defaultValue, enableReinitialize, input.value, updateDefaultValue]);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const {
|
|
86
|
+
defaultValue: oldDefaultValue,
|
|
87
|
+
defaultValCount: oldDefaultValCount
|
|
88
|
+
} = prevProps.current;
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
((input.value !== false && !input.value) ||
|
|
92
|
+
enableReinitialize ||
|
|
93
|
+
defaultValCount !== oldDefaultValCount) &&
|
|
94
|
+
!isEqual(defaultValue, oldDefaultValue)
|
|
95
|
+
) {
|
|
96
|
+
updateDefaultValue();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
prevProps.current = { defaultValue, defaultValCount };
|
|
100
|
+
}, [
|
|
101
|
+
defaultValue,
|
|
102
|
+
defaultValCount,
|
|
103
|
+
enableReinitialize,
|
|
104
|
+
input.value,
|
|
105
|
+
updateDefaultValue
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
// if our custom field level validation is happening then we don't want to show the error visually
|
|
109
|
+
const showError =
|
|
110
|
+
(touched || showErrorIfUntouched) && error && !asyncValidating;
|
|
111
|
+
const showWarning = (touched || showErrorIfUntouched) && warning;
|
|
112
|
+
let componentToWrap =
|
|
113
|
+
isLabelTooltip || tooltipError ? (
|
|
114
|
+
<Tooltip
|
|
115
|
+
disabled={isLabelTooltip ? false : !showError}
|
|
116
|
+
intent={isLabelTooltip ? "none" : error ? "danger" : "warning"}
|
|
117
|
+
content={isLabelTooltip ? label : error || warning}
|
|
118
|
+
position={Position.TOP}
|
|
119
|
+
modifiers={popoverOverflowModifiers}
|
|
120
|
+
{...tooltipProps}
|
|
121
|
+
>
|
|
122
|
+
{children}
|
|
123
|
+
</Tooltip>
|
|
124
|
+
) : (
|
|
125
|
+
children
|
|
126
|
+
);
|
|
127
|
+
const testClassName = "tg-test-" + kebabCase(input.name);
|
|
128
|
+
if (noFillField) {
|
|
129
|
+
componentToWrap = <div className="tg-no-fill-field">{componentToWrap}</div>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let helperText;
|
|
133
|
+
if (!tooltipError) {
|
|
134
|
+
if (showError) {
|
|
135
|
+
helperText = error;
|
|
136
|
+
} else if (showWarning) {
|
|
137
|
+
helperText = warning;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// if in a cypress test show message so that inputs will not be interactable
|
|
142
|
+
if (window.Cypress && isLoadingDefaultValue) {
|
|
143
|
+
return "Loading default value...";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let labelInfo = secondaryLabel;
|
|
147
|
+
|
|
148
|
+
const hasOuterLabel = !noOuterLabel && !isLabelTooltip;
|
|
149
|
+
function getFileLimitInfo() {
|
|
150
|
+
if (!fileLimit) return "";
|
|
151
|
+
return `max ${fileLimit} file${fileLimit === 1 ? "" : "s"}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (isRequired && hasOuterLabel && label && !labelInfo) {
|
|
155
|
+
labelInfo = `(required${fileLimit ? `, ${getFileLimitInfo()}` : ""})`;
|
|
156
|
+
} else if (!labelInfo && fileLimit) {
|
|
157
|
+
labelInfo = `(${getFileLimitInfo()})`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<FormGroup
|
|
162
|
+
className={classNames(className, testClassName, {
|
|
163
|
+
"tg-flex-form-content": leftEl || rightEl,
|
|
164
|
+
"tg-tooltipError": tooltipError,
|
|
165
|
+
"tg-has-error": showError && error
|
|
166
|
+
})}
|
|
167
|
+
disabled={disabled}
|
|
168
|
+
helperText={helperText}
|
|
169
|
+
intent={intent}
|
|
170
|
+
label={
|
|
171
|
+
hasOuterLabel && (
|
|
172
|
+
<LabelWithTooltipInfo
|
|
173
|
+
labelStyle={labelStyle}
|
|
174
|
+
label={label}
|
|
175
|
+
tooltipInfo={tooltipInfo}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
inline={inlineLabel}
|
|
180
|
+
labelInfo={labelInfo}
|
|
181
|
+
style={{
|
|
182
|
+
...(noMarginBottom && { marginBottom: 0 }),
|
|
183
|
+
...containerStyle
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
{showGenerateDefaultDot && (
|
|
187
|
+
<div style={{ zIndex: 10, position: "relative", height: 0, width: 0 }}>
|
|
188
|
+
<div style={{ position: "absolute", left: "0px", top: "0px" }}>
|
|
189
|
+
<Tooltip
|
|
190
|
+
modifiers={popoverOverflowModifiers}
|
|
191
|
+
content="Allows a Default to be Set. Click to Enter Set Default Mode (or press Shift+D when outside the input field)"
|
|
192
|
+
>
|
|
193
|
+
<div
|
|
194
|
+
onClick={() => {
|
|
195
|
+
setAssignDefaultsMode(true);
|
|
196
|
+
startAssigningDefault();
|
|
197
|
+
}}
|
|
198
|
+
className="generateDefaultDot"
|
|
199
|
+
></div>
|
|
200
|
+
</Tooltip>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
204
|
+
{assignDefaultButton}
|
|
205
|
+
{leftEl} {componentToWrap} {rightEl}
|
|
206
|
+
</FormGroup>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export const withAbstractWrapper = (ComponentToWrap, opts = {}) => {
|
|
211
|
+
return props => {
|
|
212
|
+
const {
|
|
213
|
+
massageDefaultIdValue,
|
|
214
|
+
generateDefaultValue,
|
|
215
|
+
defaultValueByIdOverride,
|
|
216
|
+
defaultValue: defaultValueFromProps,
|
|
217
|
+
isRequired,
|
|
218
|
+
...rest
|
|
219
|
+
} = props;
|
|
220
|
+
|
|
221
|
+
//get is assign defaults mode
|
|
222
|
+
//if assign default value mode then add on to the component
|
|
223
|
+
const [defaultValCount, setDefaultValCount] = useState(0);
|
|
224
|
+
const [defaultValueFromBackend, setDefault] = useState();
|
|
225
|
+
const [allowUserOverride, setUserOverride] = useState(true);
|
|
226
|
+
const [isLoadingDefaultValue, setLoadingDefaultValue] = useState(false);
|
|
227
|
+
const { inAssignDefaultsMode, setAssignDefaultsMode } = useContext(
|
|
228
|
+
AssignDefaultsModeContext
|
|
229
|
+
);
|
|
230
|
+
// tnr: we might want to grab this context object off the window in the future and have it live in lims by default
|
|
231
|
+
// there is no reason for those vals to live in TRC. Example code below:
|
|
232
|
+
// const workflowParams = useContext(window.__tgDefaultValParamsContext || defaultNullContext);
|
|
233
|
+
const workflowParams = useContext(WorkflowDefaultParamsContext);
|
|
234
|
+
|
|
235
|
+
const caresAboutToolContext = generateDefaultValue?.params?.toolName;
|
|
236
|
+
|
|
237
|
+
const customParamsToUse = {
|
|
238
|
+
...(caresAboutToolContext
|
|
239
|
+
? { ...workflowDefaultParamsObj, ...workflowParams }
|
|
240
|
+
: {}),
|
|
241
|
+
...(generateDefaultValue ? generateDefaultValue.customParams : {})
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
async function triggerGetDefault() {
|
|
245
|
+
if (!defaultValueByIdOverride) {
|
|
246
|
+
//if defaultValueByIdOverride is passed, we can skip over getting the value from the backend straight to massaging the default value
|
|
247
|
+
if (!window.__triggerGetDefaultValueRequest) return;
|
|
248
|
+
if (!generateDefaultValue) return;
|
|
249
|
+
setLoadingDefaultValue(true);
|
|
250
|
+
//custom params should match params keys. if not throw an error
|
|
251
|
+
const doParamsMatch = isEqual(
|
|
252
|
+
Object.keys({
|
|
253
|
+
...(caresAboutToolContext ? workflowDefaultParamsObj : {}), //we don't want to compare these keys so we just spread them here
|
|
254
|
+
...(generateDefaultValue.params || {})
|
|
255
|
+
}).sort(),
|
|
256
|
+
Object.keys(customParamsToUse).sort()
|
|
257
|
+
);
|
|
258
|
+
if (!doParamsMatch) {
|
|
259
|
+
console.warn(
|
|
260
|
+
`Issue with generateDefaultValue. customParams don't match params`
|
|
261
|
+
);
|
|
262
|
+
console.warn(
|
|
263
|
+
`generateDefaultValue.params:`,
|
|
264
|
+
generateDefaultValue.params
|
|
265
|
+
);
|
|
266
|
+
console.warn(`generateDefaultValue.customParams:`, customParamsToUse);
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Issue with generateDefaultValue code=${
|
|
269
|
+
generateDefaultValue.code
|
|
270
|
+
}: Difference detected with: ${difference(
|
|
271
|
+
Object.keys(generateDefaultValue.params || {}),
|
|
272
|
+
Object.keys(customParamsToUse || {})
|
|
273
|
+
).join(
|
|
274
|
+
", "
|
|
275
|
+
)}. customParams passed into the field should match params (as defined in defaultValueConstants.js). See console for more details.`
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
let { defaultValue, allowUserOverride } = defaultValueByIdOverride
|
|
282
|
+
? { defaultValue: defaultValueByIdOverride }
|
|
283
|
+
: await window.__triggerGetDefaultValueRequest(
|
|
284
|
+
generateDefaultValue.code,
|
|
285
|
+
customParamsToUse
|
|
286
|
+
);
|
|
287
|
+
if (massageDefaultIdValue) {
|
|
288
|
+
const massagedRes = await massageDefaultIdValue({
|
|
289
|
+
defaultValueById: defaultValue
|
|
290
|
+
});
|
|
291
|
+
if (massagedRes.defaultValue) {
|
|
292
|
+
defaultValue = massagedRes.defaultValue;
|
|
293
|
+
}
|
|
294
|
+
if (massagedRes.preventUserOverrideFromBeingDisabled) {
|
|
295
|
+
allowUserOverride = true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// TODO:Add ths back in when we have a better way to determine if a field is a checkbox or switch
|
|
300
|
+
// if (
|
|
301
|
+
// "false" === false
|
|
302
|
+
// // ComponentToWrap === renderBlueprintCheckbox ||
|
|
303
|
+
// // ComponentToWrap === renderBlueprintSwitch
|
|
304
|
+
// ) {
|
|
305
|
+
// setDefault(defaultValue === "true");
|
|
306
|
+
// } else {
|
|
307
|
+
if (typeof defaultValue === "string") {
|
|
308
|
+
// remove double spaces and leading/trailing
|
|
309
|
+
defaultValue = defaultValue.replace(/\s+/g, " ").trim();
|
|
310
|
+
}
|
|
311
|
+
setDefault(defaultValue);
|
|
312
|
+
// }
|
|
313
|
+
setUserOverride(allowUserOverride);
|
|
314
|
+
setDefaultValCount(defaultValCount + 1);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.error(`error aswf298f:`, error);
|
|
317
|
+
}
|
|
318
|
+
if (window.Cypress && window.Cypress.addFakeDefaultValueWait) {
|
|
319
|
+
await fakeWait();
|
|
320
|
+
}
|
|
321
|
+
setLoadingDefaultValue(false);
|
|
322
|
+
}
|
|
323
|
+
// if generateDefaultValue, hit the backend for that value
|
|
324
|
+
useDeepCompareEffect(() => {
|
|
325
|
+
// if the input already has a value we don't want to override with the default value request
|
|
326
|
+
if (rest.input.value) return;
|
|
327
|
+
triggerGetDefault();
|
|
328
|
+
}, [generateDefaultValue || {}]);
|
|
329
|
+
// const asyncValidating = props.asyncValidating;
|
|
330
|
+
const defaultProps = {
|
|
331
|
+
...rest,
|
|
332
|
+
defaultValue: defaultValueFromBackend || defaultValueFromProps,
|
|
333
|
+
disabled: props.disabled || allowUserOverride === false,
|
|
334
|
+
readOnly: props.readOnly || isLoadingDefaultValue,
|
|
335
|
+
intent: getIntent(props),
|
|
336
|
+
intentClass: getIntentClass(props)
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// don't show intent while async validating
|
|
340
|
+
// if (asyncValidating) {
|
|
341
|
+
// delete defaultProps.intent;
|
|
342
|
+
// delete defaultProps.intentClass;
|
|
343
|
+
// }
|
|
344
|
+
|
|
345
|
+
const startAssigningDefault = () =>
|
|
346
|
+
window.__showAssignDefaultValueModal &&
|
|
347
|
+
window.__showAssignDefaultValueModal({
|
|
348
|
+
...props,
|
|
349
|
+
generateDefaultValue: {
|
|
350
|
+
...props.generateDefaultValue,
|
|
351
|
+
customParams: customParamsToUse
|
|
352
|
+
},
|
|
353
|
+
onFinish: () => {
|
|
354
|
+
triggerGetDefault();
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
<AbstractInput
|
|
360
|
+
{...{
|
|
361
|
+
...opts,
|
|
362
|
+
defaultValCount,
|
|
363
|
+
isRequired,
|
|
364
|
+
...defaultProps,
|
|
365
|
+
isLoadingDefaultValue,
|
|
366
|
+
showGenerateDefaultDot:
|
|
367
|
+
!inAssignDefaultsMode &&
|
|
368
|
+
window.__showGenerateDefaultDot &&
|
|
369
|
+
window.__showGenerateDefaultDot() &&
|
|
370
|
+
!!generateDefaultValue,
|
|
371
|
+
setAssignDefaultsMode,
|
|
372
|
+
startAssigningDefault,
|
|
373
|
+
assignDefaultButton: inAssignDefaultsMode && generateDefaultValue && (
|
|
374
|
+
<Button
|
|
375
|
+
onClick={startAssigningDefault}
|
|
376
|
+
small
|
|
377
|
+
style={{ background: "yellow", color: "black" }}
|
|
378
|
+
>
|
|
379
|
+
Assign Default
|
|
380
|
+
</Button>
|
|
381
|
+
)
|
|
382
|
+
}}
|
|
383
|
+
>
|
|
384
|
+
<ComponentToWrap {...defaultProps} />
|
|
385
|
+
</AbstractInput>
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
};
|
|
@@ -249,3 +249,27 @@
|
|
|
249
249
|
.bp3-dark .tg-color-picker-selector input {
|
|
250
250
|
color: #222222;
|
|
251
251
|
}
|
|
252
|
+
|
|
253
|
+
.form-separator {
|
|
254
|
+
p {
|
|
255
|
+
display: flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
width: 100%;
|
|
258
|
+
}
|
|
259
|
+
p::before {
|
|
260
|
+
content: "";
|
|
261
|
+
display: block;
|
|
262
|
+
width: 100%;
|
|
263
|
+
height: 1px;
|
|
264
|
+
background-color: #e1e4e8;
|
|
265
|
+
margin-right: 16px;
|
|
266
|
+
}
|
|
267
|
+
p::after {
|
|
268
|
+
content: "";
|
|
269
|
+
display: block;
|
|
270
|
+
width: 100%;
|
|
271
|
+
height: 1px;
|
|
272
|
+
background-color: #e1e4e8;
|
|
273
|
+
margin-left: 16px;
|
|
274
|
+
}
|
|
275
|
+
}
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import "@blueprintjs/icons/lib/css/blueprint-icons.css";
|
|
|
4
4
|
import "./style.css";
|
|
5
5
|
import "./autoTooltip";
|
|
6
6
|
export { LoadingDots } from "./FormComponents/LoadingDots";
|
|
7
|
+
export { FormSeparator } from "./FormComponents/FormSeparator";
|
|
7
8
|
export * from "./AssignDefaultsModeContext";
|
|
8
9
|
export { default as Uploader } from "./FormComponents/Uploader";
|
|
9
10
|
export { mergeSchemas } from "./DataTable/utils/convertSchema";
|
package/style.css
CHANGED
|
@@ -9081,11 +9081,7 @@ button:not(:disabled):active {
|
|
|
9081
9081
|
.bp3-popover[style*="transform-origin"][style*="right"] .bp3-popover-arrow {
|
|
9082
9082
|
transform: translate(-0.5px, 0);
|
|
9083
9083
|
}
|
|
9084
|
-
.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}.
|
|
9085
|
-
.rg-celleditor input {
|
|
9086
|
-
border: none;
|
|
9087
|
-
}
|
|
9088
|
-
.tg-flex-form-content .bp3-form-content {
|
|
9084
|
+
.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}.tg-flex-form-content .bp3-form-content {
|
|
9089
9085
|
display: flex;
|
|
9090
9086
|
}
|
|
9091
9087
|
|
|
@@ -9336,6 +9332,34 @@ button:not(:disabled):active {
|
|
|
9336
9332
|
.bp3-dark .tg-color-picker-selector input {
|
|
9337
9333
|
color: #222222;
|
|
9338
9334
|
}
|
|
9335
|
+
|
|
9336
|
+
.form-separator {
|
|
9337
|
+
p {
|
|
9338
|
+
display: flex;
|
|
9339
|
+
align-items: center;
|
|
9340
|
+
width: 100%;
|
|
9341
|
+
}
|
|
9342
|
+
p::before {
|
|
9343
|
+
content: "";
|
|
9344
|
+
display: block;
|
|
9345
|
+
width: 100%;
|
|
9346
|
+
height: 1px;
|
|
9347
|
+
background-color: #e1e4e8;
|
|
9348
|
+
margin-right: 16px;
|
|
9349
|
+
}
|
|
9350
|
+
p::after {
|
|
9351
|
+
content: "";
|
|
9352
|
+
display: block;
|
|
9353
|
+
width: 100%;
|
|
9354
|
+
height: 1px;
|
|
9355
|
+
background-color: #e1e4e8;
|
|
9356
|
+
margin-left: 16px;
|
|
9357
|
+
}
|
|
9358
|
+
}
|
|
9359
|
+
.rg-celleditor-input,
|
|
9360
|
+
.rg-celleditor input {
|
|
9361
|
+
border: none;
|
|
9362
|
+
}
|
|
9339
9363
|
.tg-select {
|
|
9340
9364
|
width: 100%;
|
|
9341
9365
|
min-width: 170px;
|