@vuu-ui/vuu-data-react 4.3.0-beta.1 → 4.3.0-beta.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/package.json +15 -15
- package/src/data-editing/form-edit-state.js +1 -1
- package/src/data-editing/useEditForm.js +2 -2
- package/src/hooks/useLookupValues.js +3 -4
- package/src/hooks/useSessionDataSource.js +1 -2
- package/src/hooks/useVuuMenuActions.js +8 -11
- package/src/session-editing-form/SessionEditingForm.js +5 -6
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.3.0-beta.
|
|
2
|
+
"version": "4.3.0-beta.2",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -9,22 +9,22 @@
|
|
|
9
9
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@vuu-ui/vuu-data-types": "4.3.0-beta.
|
|
13
|
-
"@vuu-ui/vuu-filter-types": "4.3.0-beta.
|
|
14
|
-
"@vuu-ui/vuu-protocol-types": "4.3.0-beta.
|
|
15
|
-
"@vuu-ui/vuu-table-types": "4.3.0-beta.
|
|
12
|
+
"@vuu-ui/vuu-data-types": "4.3.0-beta.2",
|
|
13
|
+
"@vuu-ui/vuu-filter-types": "4.3.0-beta.2",
|
|
14
|
+
"@vuu-ui/vuu-protocol-types": "4.3.0-beta.2",
|
|
15
|
+
"@vuu-ui/vuu-table-types": "4.3.0-beta.2"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@vuu-ui/vuu-context-menu": "4.3.0-beta.
|
|
19
|
-
"@vuu-ui/vuu-data-editing": "4.3.0-beta.
|
|
20
|
-
"@vuu-ui/vuu-data-remote": "4.3.0-beta.
|
|
21
|
-
"@vuu-ui/vuu-filter-parser": "4.3.0-beta.
|
|
22
|
-
"@vuu-ui/vuu-filters": "4.3.0-beta.
|
|
23
|
-
"@vuu-ui/vuu-layout": "4.3.0-beta.
|
|
24
|
-
"@vuu-ui/vuu-notifications": "4.3.0-beta.
|
|
25
|
-
"@vuu-ui/vuu-ui-controls": "4.3.0-beta.
|
|
26
|
-
"@vuu-ui/vuu-utils": "4.3.0-beta.
|
|
27
|
-
"@vuu-ui/vuu-table": "4.3.0-beta.
|
|
18
|
+
"@vuu-ui/vuu-context-menu": "4.3.0-beta.2",
|
|
19
|
+
"@vuu-ui/vuu-data-editing": "4.3.0-beta.2",
|
|
20
|
+
"@vuu-ui/vuu-data-remote": "4.3.0-beta.2",
|
|
21
|
+
"@vuu-ui/vuu-filter-parser": "4.3.0-beta.2",
|
|
22
|
+
"@vuu-ui/vuu-filters": "4.3.0-beta.2",
|
|
23
|
+
"@vuu-ui/vuu-layout": "4.3.0-beta.2",
|
|
24
|
+
"@vuu-ui/vuu-notifications": "4.3.0-beta.2",
|
|
25
|
+
"@vuu-ui/vuu-ui-controls": "4.3.0-beta.2",
|
|
26
|
+
"@vuu-ui/vuu-utils": "4.3.0-beta.2",
|
|
27
|
+
"@vuu-ui/vuu-table": "4.3.0-beta.2",
|
|
28
28
|
"@salt-ds/core": "1.74.0",
|
|
29
29
|
"@salt-ds/styles": "0.4.2",
|
|
30
30
|
"@salt-ds/window": "0.1.2"
|
|
@@ -4,7 +4,7 @@ const CLEAN_FORM = {
|
|
|
4
4
|
};
|
|
5
5
|
const buildFormEditState = (entity, newEntity)=>{
|
|
6
6
|
if (void 0 === entity) return CLEAN_FORM;
|
|
7
|
-
{
|
|
7
|
+
else {
|
|
8
8
|
const editedFields = [];
|
|
9
9
|
for (const [fieldName, value] of Object.entries(entity))if (value !== newEntity[fieldName]) editedFields.push(fieldName);
|
|
10
10
|
return {
|
|
@@ -26,7 +26,7 @@ const nextValidationState = (state, dataDescriptor, value)=>{
|
|
|
26
26
|
[name]: result.messages.join("\n")
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
if (!wasOk) {
|
|
29
|
+
else if (!wasOk) {
|
|
30
30
|
const fieldsInError = Object.keys(existingMessages);
|
|
31
31
|
if (fieldsInError.includes(name)) if (1 === fieldsInError.length) return {
|
|
32
32
|
ok: true,
|
|
@@ -53,7 +53,7 @@ function find(descriptors, fieldname) {
|
|
|
53
53
|
const getField = (target)=>{
|
|
54
54
|
const fieldElement = queryClosest(target, "[data-field]");
|
|
55
55
|
if (fieldElement) return fieldElement.dataset.field;
|
|
56
|
-
throw Error("no field ");
|
|
56
|
+
else throw Error("no field ");
|
|
57
57
|
};
|
|
58
58
|
const useEditForm = ({ dataSource, formFieldDescriptors, onSubmit })=>{
|
|
59
59
|
const { showDialog, closeDialog } = useModal();
|
|
@@ -11,7 +11,7 @@ const loadLookupValues = ({ labelColumn, table, valueColumn })=>{
|
|
|
11
11
|
const tableKey = `${table.module}:${table.table}`;
|
|
12
12
|
const lookupValues = lookupValueMap.get(tableKey);
|
|
13
13
|
if (lookupValues) return lookupValues;
|
|
14
|
-
{
|
|
14
|
+
else {
|
|
15
15
|
const promise = new Promise((resolve)=>{
|
|
16
16
|
const columns = [
|
|
17
17
|
valueColumn,
|
|
@@ -44,7 +44,7 @@ const loadLookupValues = ({ labelColumn, table, valueColumn })=>{
|
|
|
44
44
|
};
|
|
45
45
|
const getLookupDetails = ({ name, type })=>{
|
|
46
46
|
if (isTypeDescriptor(type) && isLookupRenderer(type.renderer)) return type.renderer.lookup;
|
|
47
|
-
throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
|
|
47
|
+
else throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
|
|
48
48
|
};
|
|
49
49
|
const useLookupValues = (column, initialValueProp)=>{
|
|
50
50
|
const { type: columnType } = column;
|
|
@@ -56,8 +56,7 @@ const useLookupValues = (column, initialValueProp)=>{
|
|
|
56
56
|
initialValue: getSelectedOption(values, initialValueProp) ?? null,
|
|
57
57
|
values
|
|
58
58
|
};
|
|
59
|
-
}
|
|
60
|
-
{
|
|
59
|
+
} else {
|
|
61
60
|
const lookupDetails = getLookupDetails(column);
|
|
62
61
|
const values = getLookupValues?.(lookupDetails.table) ?? NO_VALUES;
|
|
63
62
|
return {
|
|
@@ -16,8 +16,7 @@ const useSessionDataSource = (props)=>{
|
|
|
16
16
|
if (props?.onConfigChange) ds.on("config", props.onConfigChange);
|
|
17
17
|
sessionState.set(sessionKey, ds);
|
|
18
18
|
return ds;
|
|
19
|
-
}
|
|
20
|
-
throw Error("[useSessionDataSource] unable to create new DataSource, columns have not been defined ");
|
|
19
|
+
} else throw Error("[useSessionDataSource] unable to create new DataSource, columns have not been defined ");
|
|
21
20
|
}, [
|
|
22
21
|
VuuDataSource,
|
|
23
22
|
props?.onConfigChange
|
|
@@ -44,7 +44,7 @@ const vuuContextCompatibleWithTableLocation = (uiLocation, vuuContext, selectedR
|
|
|
44
44
|
switch(uiLocation){
|
|
45
45
|
case "grid":
|
|
46
46
|
if ("selected-rows" === vuuContext) return selectedRowCount > 0;
|
|
47
|
-
return true;
|
|
47
|
+
else return true;
|
|
48
48
|
case "header":
|
|
49
49
|
return "grid" === vuuContext;
|
|
50
50
|
default:
|
|
@@ -55,8 +55,7 @@ const gridRowMeetsFilterCriteria = (context, dataRow, selectedRows, filter)=>{
|
|
|
55
55
|
if ("cell" === context || "row" === context) {
|
|
56
56
|
const filterPredicate = getFilterPredicate(filter);
|
|
57
57
|
return filterPredicate(dataRow);
|
|
58
|
-
}
|
|
59
|
-
if ("selected-rows" === context) if (0 === selectedRows.length) return false;
|
|
58
|
+
} else if ("selected-rows" === context) if (0 === selectedRows.length) return false;
|
|
60
59
|
else {
|
|
61
60
|
const filterPredicate = getFilterPredicate(filter);
|
|
62
61
|
return selectedRows.every(filterPredicate);
|
|
@@ -209,24 +208,24 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
|
|
|
209
208
|
value: options.value,
|
|
210
209
|
type: "VIEW_PORT_MENU_CELL_RPC"
|
|
211
210
|
};
|
|
212
|
-
if (isRowMenu(options)) return {
|
|
211
|
+
else if (isRowMenu(options)) return {
|
|
213
212
|
rowKey: options.rowKey,
|
|
214
213
|
row: options.row,
|
|
215
214
|
rpcName,
|
|
216
215
|
type: "VIEW_PORT_MENU_ROW_RPC"
|
|
217
216
|
};
|
|
218
|
-
if (isSelectionMenu(options)) return {
|
|
217
|
+
else if (isSelectionMenu(options)) return {
|
|
219
218
|
rpcName,
|
|
220
219
|
type: "VIEW_PORT_MENUS_SELECT_RPC"
|
|
221
220
|
};
|
|
222
|
-
return {
|
|
221
|
+
else return {
|
|
223
222
|
rpcName,
|
|
224
223
|
type: "VIEW_PORT_MENU_TABLE_RPC"
|
|
225
224
|
};
|
|
226
225
|
};
|
|
227
226
|
const menuActionHandler = useCallback((menuItemId, options)=>{
|
|
228
227
|
if (clientSideMenuActionHandler?.(menuItemId, options)) return true;
|
|
229
|
-
if ("MENU_RPC_CALL" === menuItemId) {
|
|
228
|
+
else if ("MENU_RPC_CALL" === menuItemId) {
|
|
230
229
|
const rpcRequest = getMenuRpcRequest(options);
|
|
231
230
|
dataSource?.menuRpcCall(rpcRequest).then((rpcResponse)=>{
|
|
232
231
|
if (rpcResponse) {
|
|
@@ -245,12 +244,10 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
|
|
|
245
244
|
}
|
|
246
245
|
});
|
|
247
246
|
return true;
|
|
248
|
-
}
|
|
249
|
-
if ("link-table" === menuItemId) {
|
|
247
|
+
} else if ("link-table" === menuItemId) {
|
|
250
248
|
if (dataSource) dataSource.visualLink = options;
|
|
251
249
|
return true;
|
|
252
|
-
}
|
|
253
|
-
console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
|
|
250
|
+
} else console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
|
|
254
251
|
return false;
|
|
255
252
|
}, [
|
|
256
253
|
clientSideMenuActionHandler,
|
|
@@ -11,7 +11,7 @@ const classBase = "vuuSessionEditingForm";
|
|
|
11
11
|
const getField = (fields, name)=>{
|
|
12
12
|
const field = fields.find((f)=>f.name === name);
|
|
13
13
|
if (field) return field;
|
|
14
|
-
throw Error(`SessionEditingForm, no field '${name}' found`);
|
|
14
|
+
else throw Error(`SessionEditingForm, no field '${name}' found`);
|
|
15
15
|
};
|
|
16
16
|
const getFieldNameAndValue = ({ target })=>{
|
|
17
17
|
const formField = queryClosest(target, ".saltFormField");
|
|
@@ -22,8 +22,7 @@ const getFieldNameAndValue = ({ target })=>{
|
|
|
22
22
|
field,
|
|
23
23
|
target.value
|
|
24
24
|
];
|
|
25
|
-
}
|
|
26
|
-
throw Error("Form control is not enclosed in FormField");
|
|
25
|
+
} else throw Error("Form control is not enclosed in FormField");
|
|
27
26
|
};
|
|
28
27
|
const Status = {
|
|
29
28
|
uninitialised: 0,
|
|
@@ -33,12 +32,12 @@ const Status = {
|
|
|
33
32
|
};
|
|
34
33
|
const getDataSource = (dataSource, schema)=>{
|
|
35
34
|
if (dataSource) return dataSource;
|
|
36
|
-
if (schema) return new VuuDataSource({
|
|
35
|
+
else if (schema) return new VuuDataSource({
|
|
37
36
|
bufferSize: 0,
|
|
38
37
|
table: schema.table,
|
|
39
38
|
columns: schema.columns.map((col)=>col.name)
|
|
40
39
|
});
|
|
41
|
-
throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided");
|
|
40
|
+
else throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided");
|
|
42
41
|
};
|
|
43
42
|
const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes })=>{
|
|
44
43
|
const targetWindow = useWindow();
|
|
@@ -159,7 +158,7 @@ const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, ke
|
|
|
159
158
|
className: `${classBase}-fieldValue vuuReadOnly`,
|
|
160
159
|
children: value
|
|
161
160
|
});
|
|
162
|
-
return /*#__PURE__*/ jsx(Input, {
|
|
161
|
+
else return /*#__PURE__*/ jsx(Input, {
|
|
163
162
|
className: `${classBase}-fieldValue`,
|
|
164
163
|
onBlur: handleBlur,
|
|
165
164
|
onChange: handleChange,
|