@teselagen/ui 0.5.23-beta.33 → 0.5.23-beta.35
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/SearchBar.d.ts +3 -2
- package/FormComponents/AbstractField.d.ts +1 -0
- package/FormComponents/index.d.ts +15 -30
- package/index.cjs.js +15 -30
- package/index.d.ts +1 -0
- package/index.es.js +15 -30
- package/package.json +1 -3
- package/src/DataTable/EditabelCell.js +4 -4
- package/src/DataTable/SearchBar.js +8 -1
- package/src/DataTable/index.js +1 -0
- package/src/DataTable/utils/useTableParams.js +1 -0
- package/src/FormComponents/AbstractField.js +388 -0
- package/src/FormComponents/index.js +1 -21
- package/src/index.js +1 -0
package/DataTable/SearchBar.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export default SearchBar;
|
|
2
|
-
declare function SearchBar({ searchInput, setSearchTerm, loading, searchMenuButton, disabled, autoFocusSearch }: {
|
|
2
|
+
declare function SearchBar({ searchInput, setSearchTerm, loading, searchMenuButton, disabled, autoFocusSearch, noForm }: {
|
|
3
3
|
searchInput: any;
|
|
4
4
|
setSearchTerm: any;
|
|
5
5
|
loading: any;
|
|
6
6
|
searchMenuButton: any;
|
|
7
7
|
disabled: any;
|
|
8
8
|
autoFocusSearch: any;
|
|
9
|
-
|
|
9
|
+
noForm: any;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function withAbstractWrapper(ComponentToWrap: any, opts?: {}): (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { fieldRequired } from './utils';
|
|
2
|
-
export function generateField(component: any, opts: any): ({ name, isRequired, onFieldSubmit,
|
|
2
|
+
export function generateField(component: any, opts: any): ({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
name: any;
|
|
5
5
|
isRequired: any;
|
|
6
6
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
7
|
-
noRedux?: boolean | undefined;
|
|
8
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export { fieldRequired };
|
|
10
9
|
export function renderBlueprintDateInput({ input, intent, onFieldSubmit, inputProps, ...rest }: {
|
|
@@ -118,101 +117,87 @@ export function RenderReactColorPicker({ input, onFieldSubmit, ...rest }: {
|
|
|
118
117
|
onFieldSubmit: any;
|
|
119
118
|
}): import("react/jsx-runtime").JSX.Element;
|
|
120
119
|
export function withAbstractWrapper(ComponentToWrap: any, opts?: {}): (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
121
|
-
export function InputField({ name, isRequired, onFieldSubmit,
|
|
120
|
+
export function InputField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
122
121
|
[x: string]: any;
|
|
123
122
|
name: any;
|
|
124
123
|
isRequired: any;
|
|
125
124
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
126
|
-
noRedux?: boolean | undefined;
|
|
127
125
|
}): import("react/jsx-runtime").JSX.Element;
|
|
128
|
-
export function FileUploadField({ name, isRequired, onFieldSubmit,
|
|
126
|
+
export function FileUploadField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
129
127
|
[x: string]: any;
|
|
130
128
|
name: any;
|
|
131
129
|
isRequired: any;
|
|
132
130
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
133
|
-
noRedux?: boolean | undefined;
|
|
134
131
|
}): import("react/jsx-runtime").JSX.Element;
|
|
135
|
-
export function DateInputField({ name, isRequired, onFieldSubmit,
|
|
132
|
+
export function DateInputField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
136
133
|
[x: string]: any;
|
|
137
134
|
name: any;
|
|
138
135
|
isRequired: any;
|
|
139
136
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
140
|
-
noRedux?: boolean | undefined;
|
|
141
137
|
}): import("react/jsx-runtime").JSX.Element;
|
|
142
|
-
export function DateRangeInputField({ name, isRequired, onFieldSubmit,
|
|
138
|
+
export function DateRangeInputField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
143
139
|
[x: string]: any;
|
|
144
140
|
name: any;
|
|
145
141
|
isRequired: any;
|
|
146
142
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
147
|
-
noRedux?: boolean | undefined;
|
|
148
143
|
}): import("react/jsx-runtime").JSX.Element;
|
|
149
|
-
export function CheckboxField({ name, isRequired, onFieldSubmit,
|
|
144
|
+
export function CheckboxField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
150
145
|
[x: string]: any;
|
|
151
146
|
name: any;
|
|
152
147
|
isRequired: any;
|
|
153
148
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
154
|
-
noRedux?: boolean | undefined;
|
|
155
149
|
}): import("react/jsx-runtime").JSX.Element;
|
|
156
|
-
export function SwitchField({ name, isRequired, onFieldSubmit,
|
|
150
|
+
export function SwitchField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
157
151
|
[x: string]: any;
|
|
158
152
|
name: any;
|
|
159
153
|
isRequired: any;
|
|
160
154
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
161
|
-
noRedux?: boolean | undefined;
|
|
162
155
|
}): import("react/jsx-runtime").JSX.Element;
|
|
163
|
-
export function TextareaField({ name, isRequired, onFieldSubmit,
|
|
156
|
+
export function TextareaField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
164
157
|
[x: string]: any;
|
|
165
158
|
name: any;
|
|
166
159
|
isRequired: any;
|
|
167
160
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
168
|
-
noRedux?: boolean | undefined;
|
|
169
161
|
}): import("react/jsx-runtime").JSX.Element;
|
|
170
|
-
export function SuggestField({ name, isRequired, onFieldSubmit,
|
|
162
|
+
export function SuggestField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
171
163
|
[x: string]: any;
|
|
172
164
|
name: any;
|
|
173
165
|
isRequired: any;
|
|
174
166
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
175
|
-
noRedux?: boolean | undefined;
|
|
176
167
|
}): import("react/jsx-runtime").JSX.Element;
|
|
177
|
-
export function EditableTextField({ name, isRequired, onFieldSubmit,
|
|
168
|
+
export function EditableTextField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
178
169
|
[x: string]: any;
|
|
179
170
|
name: any;
|
|
180
171
|
isRequired: any;
|
|
181
172
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
182
|
-
noRedux?: boolean | undefined;
|
|
183
173
|
}): import("react/jsx-runtime").JSX.Element;
|
|
184
|
-
export function NumericInputField({ name, isRequired, onFieldSubmit,
|
|
174
|
+
export function NumericInputField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
185
175
|
[x: string]: any;
|
|
186
176
|
name: any;
|
|
187
177
|
isRequired: any;
|
|
188
178
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
189
|
-
noRedux?: boolean | undefined;
|
|
190
179
|
}): import("react/jsx-runtime").JSX.Element;
|
|
191
|
-
export function RadioGroupField({ name, isRequired, onFieldSubmit,
|
|
180
|
+
export function RadioGroupField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
192
181
|
[x: string]: any;
|
|
193
182
|
name: any;
|
|
194
183
|
isRequired: any;
|
|
195
184
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
196
|
-
noRedux?: boolean | undefined;
|
|
197
185
|
}): import("react/jsx-runtime").JSX.Element;
|
|
198
|
-
export function ReactSelectField({ name, isRequired, onFieldSubmit,
|
|
186
|
+
export function ReactSelectField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
199
187
|
[x: string]: any;
|
|
200
188
|
name: any;
|
|
201
189
|
isRequired: any;
|
|
202
190
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
203
|
-
noRedux?: boolean | undefined;
|
|
204
191
|
}): import("react/jsx-runtime").JSX.Element;
|
|
205
|
-
export function SelectField({ name, isRequired, onFieldSubmit,
|
|
192
|
+
export function SelectField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
206
193
|
[x: string]: any;
|
|
207
194
|
name: any;
|
|
208
195
|
isRequired: any;
|
|
209
196
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
210
|
-
noRedux?: boolean | undefined;
|
|
211
197
|
}): import("react/jsx-runtime").JSX.Element;
|
|
212
|
-
export function ReactColorField({ name, isRequired, onFieldSubmit,
|
|
198
|
+
export function ReactColorField({ name, isRequired, onFieldSubmit, ...rest }: {
|
|
213
199
|
[x: string]: any;
|
|
214
200
|
name: any;
|
|
215
201
|
isRequired: any;
|
|
216
202
|
onFieldSubmit?: ((...args: any[]) => void) | undefined;
|
|
217
|
-
noRedux?: boolean | undefined;
|
|
218
203
|
}): import("react/jsx-runtime").JSX.Element;
|
package/index.cjs.js
CHANGED
|
@@ -32697,37 +32697,13 @@ const RenderReactColorPicker = /* @__PURE__ */ __name((_E) => {
|
|
|
32697
32697
|
function generateField(component, opts) {
|
|
32698
32698
|
const compWithDefaultVal = withAbstractWrapper(component, opts);
|
|
32699
32699
|
return (_a) => {
|
|
32700
|
-
var _b = _a, {
|
|
32701
|
-
|
|
32702
|
-
isRequired,
|
|
32703
|
-
onFieldSubmit = noop$4,
|
|
32704
|
-
noRedux = false
|
|
32705
|
-
} = _b, rest = __objRest(_b, [
|
|
32706
|
-
"name",
|
|
32707
|
-
"isRequired",
|
|
32708
|
-
"onFieldSubmit",
|
|
32709
|
-
"noRedux"
|
|
32710
|
-
]);
|
|
32711
|
-
const input = React$1.useMemo(() => {
|
|
32712
|
-
if (noRedux)
|
|
32713
|
-
return {
|
|
32714
|
-
input: {
|
|
32715
|
-
onChange: rest.onChange || noop$4,
|
|
32716
|
-
onBlur: rest.onBlur || noop$4,
|
|
32717
|
-
value: rest.value,
|
|
32718
|
-
name
|
|
32719
|
-
}
|
|
32720
|
-
};
|
|
32721
|
-
return {};
|
|
32722
|
-
}, [name, noRedux, rest.onBlur, rest.onChange, rest.value]);
|
|
32723
|
-
const props = __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
32700
|
+
var _b = _a, { name, isRequired, onFieldSubmit = noop$4 } = _b, rest = __objRest(_b, ["name", "isRequired", "onFieldSubmit"]);
|
|
32701
|
+
const props = __spreadValues(__spreadProps(__spreadValues({
|
|
32724
32702
|
onFieldSubmit,
|
|
32725
|
-
name
|
|
32726
|
-
}, input), {
|
|
32703
|
+
name,
|
|
32727
32704
|
component: compWithDefaultVal
|
|
32728
|
-
}
|
|
32729
|
-
isRequired
|
|
32730
|
-
noRedux
|
|
32705
|
+
}, isRequired && { validate: fieldRequired }), {
|
|
32706
|
+
isRequired
|
|
32731
32707
|
}), rest);
|
|
32732
32708
|
return /* @__PURE__ */ React$1.createElement(reduxForm.Field, __spreadValues({}, props));
|
|
32733
32709
|
};
|
|
@@ -32952,8 +32928,15 @@ const SearchBar = /* @__PURE__ */ __name(({
|
|
|
32952
32928
|
loading,
|
|
32953
32929
|
searchMenuButton,
|
|
32954
32930
|
disabled,
|
|
32955
|
-
autoFocusSearch
|
|
32931
|
+
autoFocusSearch,
|
|
32932
|
+
noForm
|
|
32956
32933
|
}) => {
|
|
32934
|
+
if (noForm) {
|
|
32935
|
+
console.error(
|
|
32936
|
+
"The search bar requires the component to be wrapped in a form"
|
|
32937
|
+
);
|
|
32938
|
+
return;
|
|
32939
|
+
}
|
|
32957
32940
|
let rightElement;
|
|
32958
32941
|
if (searchMenuButton) {
|
|
32959
32942
|
rightElement = /* @__PURE__ */ React$1.createElement("div", { style: { display: "flex" } }, loading && /* @__PURE__ */ React$1.createElement(core.Spinner, { size: "18" }), searchMenuButton);
|
|
@@ -54964,6 +54947,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
|
|
|
54964
54947
|
)) : "", /* @__PURE__ */ React$1.createElement(
|
|
54965
54948
|
SearchBar,
|
|
54966
54949
|
{
|
|
54950
|
+
noForm,
|
|
54967
54951
|
searchInput: currentParams.searchTerm,
|
|
54968
54952
|
setSearchTerm,
|
|
54969
54953
|
loading: isLoading,
|
|
@@ -74867,6 +74851,7 @@ exports.tickMenuEnhancer = tickMenuEnhancer;
|
|
|
74867
74851
|
exports.tubeIcon = tubeIcon;
|
|
74868
74852
|
exports.useDeepEqualMemo = useDeepEqualMemo;
|
|
74869
74853
|
exports.useDialog = useDialog;
|
|
74854
|
+
exports.useStableReference = useStableReference;
|
|
74870
74855
|
exports.useTableEntities = useTableEntities;
|
|
74871
74856
|
exports.useTableParams = useTableParams;
|
|
74872
74857
|
exports.useTraceUpdate = useTraceUpdate;
|
package/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './utils/browserUtils';
|
|
|
14
14
|
export * from './utils/commandUtils';
|
|
15
15
|
export * from './utils/commandControls';
|
|
16
16
|
export * from './utils/useTraceUpdate';
|
|
17
|
+
export * from './utils/hooks/useStableReference';
|
|
17
18
|
export { default as Uploader } from './FormComponents/Uploader';
|
|
18
19
|
export { useDeepEqualMemo } from './utils/hooks';
|
|
19
20
|
export { default as Loading } from './Loading';
|
package/index.es.js
CHANGED
|
@@ -32679,37 +32679,13 @@ const RenderReactColorPicker = /* @__PURE__ */ __name((_E) => {
|
|
|
32679
32679
|
function generateField(component, opts) {
|
|
32680
32680
|
const compWithDefaultVal = withAbstractWrapper(component, opts);
|
|
32681
32681
|
return (_a) => {
|
|
32682
|
-
var _b = _a, {
|
|
32683
|
-
|
|
32684
|
-
isRequired,
|
|
32685
|
-
onFieldSubmit = noop$4,
|
|
32686
|
-
noRedux = false
|
|
32687
|
-
} = _b, rest = __objRest(_b, [
|
|
32688
|
-
"name",
|
|
32689
|
-
"isRequired",
|
|
32690
|
-
"onFieldSubmit",
|
|
32691
|
-
"noRedux"
|
|
32692
|
-
]);
|
|
32693
|
-
const input = useMemo(() => {
|
|
32694
|
-
if (noRedux)
|
|
32695
|
-
return {
|
|
32696
|
-
input: {
|
|
32697
|
-
onChange: rest.onChange || noop$4,
|
|
32698
|
-
onBlur: rest.onBlur || noop$4,
|
|
32699
|
-
value: rest.value,
|
|
32700
|
-
name
|
|
32701
|
-
}
|
|
32702
|
-
};
|
|
32703
|
-
return {};
|
|
32704
|
-
}, [name, noRedux, rest.onBlur, rest.onChange, rest.value]);
|
|
32705
|
-
const props = __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
32682
|
+
var _b = _a, { name, isRequired, onFieldSubmit = noop$4 } = _b, rest = __objRest(_b, ["name", "isRequired", "onFieldSubmit"]);
|
|
32683
|
+
const props = __spreadValues(__spreadProps(__spreadValues({
|
|
32706
32684
|
onFieldSubmit,
|
|
32707
|
-
name
|
|
32708
|
-
}, input), {
|
|
32685
|
+
name,
|
|
32709
32686
|
component: compWithDefaultVal
|
|
32710
|
-
}
|
|
32711
|
-
isRequired
|
|
32712
|
-
noRedux
|
|
32687
|
+
}, isRequired && { validate: fieldRequired }), {
|
|
32688
|
+
isRequired
|
|
32713
32689
|
}), rest);
|
|
32714
32690
|
return /* @__PURE__ */ React__default.createElement(Field, __spreadValues({}, props));
|
|
32715
32691
|
};
|
|
@@ -32934,8 +32910,15 @@ const SearchBar = /* @__PURE__ */ __name(({
|
|
|
32934
32910
|
loading,
|
|
32935
32911
|
searchMenuButton,
|
|
32936
32912
|
disabled,
|
|
32937
|
-
autoFocusSearch
|
|
32913
|
+
autoFocusSearch,
|
|
32914
|
+
noForm
|
|
32938
32915
|
}) => {
|
|
32916
|
+
if (noForm) {
|
|
32917
|
+
console.error(
|
|
32918
|
+
"The search bar requires the component to be wrapped in a form"
|
|
32919
|
+
);
|
|
32920
|
+
return;
|
|
32921
|
+
}
|
|
32939
32922
|
let rightElement;
|
|
32940
32923
|
if (searchMenuButton) {
|
|
32941
32924
|
rightElement = /* @__PURE__ */ React__default.createElement("div", { style: { display: "flex" } }, loading && /* @__PURE__ */ React__default.createElement(Spinner, { size: "18" }), searchMenuButton);
|
|
@@ -54946,6 +54929,7 @@ const DataTable = /* @__PURE__ */ __name((_G) => {
|
|
|
54946
54929
|
)) : "", /* @__PURE__ */ React__default.createElement(
|
|
54947
54930
|
SearchBar,
|
|
54948
54931
|
{
|
|
54932
|
+
noForm,
|
|
54949
54933
|
searchInput: currentParams.searchTerm,
|
|
54950
54934
|
setSearchTerm,
|
|
54951
54935
|
loading: isLoading,
|
|
@@ -74850,6 +74834,7 @@ export {
|
|
|
74850
74834
|
tubeIcon,
|
|
74851
74835
|
useDeepEqualMemo,
|
|
74852
74836
|
useDialog,
|
|
74837
|
+
useStableReference,
|
|
74853
74838
|
useTableEntities,
|
|
74854
74839
|
useTableParams,
|
|
74855
74840
|
useTraceUpdate,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/ui",
|
|
3
|
-
"version": "0.5.23-beta.
|
|
3
|
+
"version": "0.5.23-beta.35",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"react-color": "^2.19.3",
|
|
46
46
|
"react-dom": "^18.3.1",
|
|
47
47
|
"react-dropzone": "^11.4.2",
|
|
48
|
-
"react-markdown": "8.0.7",
|
|
49
48
|
"react-redux": "^8.0.5",
|
|
50
49
|
"react-rnd": "^10.2.4",
|
|
51
50
|
"react-router-dom": "4",
|
|
@@ -54,7 +53,6 @@
|
|
|
54
53
|
"redux": "^4.1.2",
|
|
55
54
|
"redux-form": "^8.3.10",
|
|
56
55
|
"redux-thunk": "2.4.1",
|
|
57
|
-
"remark-gfm": "^3.0.1",
|
|
58
56
|
"tippy.js": "^6.3.7",
|
|
59
57
|
"url-join": "^4.0.1",
|
|
60
58
|
"use-deep-compare-effect": "^1.6.1",
|
|
@@ -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(() => {
|
|
@@ -10,8 +10,15 @@ const SearchBar = ({
|
|
|
10
10
|
loading,
|
|
11
11
|
searchMenuButton,
|
|
12
12
|
disabled,
|
|
13
|
-
autoFocusSearch
|
|
13
|
+
autoFocusSearch,
|
|
14
|
+
noForm
|
|
14
15
|
}) => {
|
|
16
|
+
if (noForm) {
|
|
17
|
+
console.error(
|
|
18
|
+
"The search bar requires the component to be wrapped in a form"
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
15
22
|
let rightElement;
|
|
16
23
|
// need to always render searchMenuButton so it doesn't close
|
|
17
24
|
if (searchMenuButton) {
|
package/src/DataTable/index.js
CHANGED
|
@@ -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
|
+
};
|
|
@@ -976,33 +976,13 @@ export const RenderReactColorPicker = ({ input, onFieldSubmit, ...rest }) => (
|
|
|
976
976
|
|
|
977
977
|
export function generateField(component, opts) {
|
|
978
978
|
const compWithDefaultVal = withAbstractWrapper(component, opts);
|
|
979
|
-
return ({
|
|
980
|
-
name,
|
|
981
|
-
isRequired,
|
|
982
|
-
onFieldSubmit = noop,
|
|
983
|
-
noRedux = false,
|
|
984
|
-
...rest
|
|
985
|
-
}) => {
|
|
986
|
-
const input = useMemo(() => {
|
|
987
|
-
if (noRedux)
|
|
988
|
-
return {
|
|
989
|
-
input: {
|
|
990
|
-
onChange: rest.onChange || noop,
|
|
991
|
-
onBlur: rest.onBlur || noop,
|
|
992
|
-
value: rest.value,
|
|
993
|
-
name
|
|
994
|
-
}
|
|
995
|
-
};
|
|
996
|
-
return {};
|
|
997
|
-
}, [name, noRedux, rest.onBlur, rest.onChange, rest.value]);
|
|
979
|
+
return ({ name, isRequired, onFieldSubmit = noop, ...rest }) => {
|
|
998
980
|
const props = {
|
|
999
981
|
onFieldSubmit,
|
|
1000
982
|
name,
|
|
1001
|
-
...input,
|
|
1002
983
|
component: compWithDefaultVal,
|
|
1003
984
|
...(isRequired && { validate: fieldRequired }),
|
|
1004
985
|
isRequired,
|
|
1005
|
-
noRedux,
|
|
1006
986
|
...rest
|
|
1007
987
|
};
|
|
1008
988
|
|
package/src/index.js
CHANGED
|
@@ -75,6 +75,7 @@ export * from "./utils/browserUtils";
|
|
|
75
75
|
export * from "./utils/commandUtils";
|
|
76
76
|
export * from "./utils/commandControls";
|
|
77
77
|
export * from "./utils/useTraceUpdate";
|
|
78
|
+
export * from "./utils/hooks/useStableReference";
|
|
78
79
|
export { default as AsyncValidateFieldSpinner } from "./AsyncValidateFieldSpinner";
|
|
79
80
|
export { default as showProgressToast } from "./utils/showProgressToast";
|
|
80
81
|
export { default as getTextFromEl } from "./utils/getTextFromEl";
|