@vuu-ui/vuu-data-react 5.0.0-alpha.5 → 5.0.0-alpha.7
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 +16 -16
- 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 +13 -17
- package/src/session-editing-form/SessionEditingForm.js +5 -6
- package/types/hooks/useVuuMenuActions.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.0-alpha.
|
|
2
|
+
"version": "5.0.0-alpha.7",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"type": "module",
|
|
@@ -10,26 +10,26 @@
|
|
|
10
10
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@vuu-ui/vuu-data-types": "5.0.0-alpha.
|
|
14
|
-
"@vuu-ui/vuu-filter-types": "5.0.0-alpha.
|
|
15
|
-
"@vuu-ui/vuu-protocol-types": "5.0.0-alpha.
|
|
16
|
-
"@vuu-ui/vuu-table-types": "5.0.0-alpha.
|
|
13
|
+
"@vuu-ui/vuu-data-types": "5.0.0-alpha.7",
|
|
14
|
+
"@vuu-ui/vuu-filter-types": "5.0.0-alpha.7",
|
|
15
|
+
"@vuu-ui/vuu-protocol-types": "5.0.0-alpha.7",
|
|
16
|
+
"@vuu-ui/vuu-table-types": "5.0.0-alpha.7"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@vuu-ui/vuu-context-menu": "5.0.0-alpha.
|
|
20
|
-
"@vuu-ui/vuu-data-editing": "5.0.0-alpha.
|
|
21
|
-
"@vuu-ui/vuu-data-remote": "5.0.0-alpha.
|
|
22
|
-
"@vuu-ui/vuu-filter-parser": "5.0.0-alpha.
|
|
23
|
-
"@vuu-ui/vuu-filters": "5.0.0-alpha.
|
|
24
|
-
"@vuu-ui/vuu-layout": "5.0.0-alpha.
|
|
25
|
-
"@vuu-ui/vuu-notifications": "5.0.0-alpha.
|
|
26
|
-
"@vuu-ui/vuu-ui-controls": "5.0.0-alpha.
|
|
27
|
-
"@vuu-ui/vuu-utils": "5.0.0-alpha.
|
|
28
|
-
"@vuu-ui/vuu-table": "5.0.0-alpha.
|
|
19
|
+
"@vuu-ui/vuu-context-menu": "5.0.0-alpha.7",
|
|
20
|
+
"@vuu-ui/vuu-data-editing": "5.0.0-alpha.7",
|
|
21
|
+
"@vuu-ui/vuu-data-remote": "5.0.0-alpha.7",
|
|
22
|
+
"@vuu-ui/vuu-filter-parser": "5.0.0-alpha.7",
|
|
23
|
+
"@vuu-ui/vuu-filters": "5.0.0-alpha.7",
|
|
24
|
+
"@vuu-ui/vuu-layout": "5.0.0-alpha.7",
|
|
25
|
+
"@vuu-ui/vuu-notifications": "5.0.0-alpha.7",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "5.0.0-alpha.7",
|
|
27
|
+
"@vuu-ui/vuu-utils": "5.0.0-alpha.7",
|
|
28
|
+
"@vuu-ui/vuu-table": "5.0.0-alpha.7",
|
|
29
29
|
"@salt-ds/core": "1.74.0",
|
|
30
30
|
"@salt-ds/styles": "0.4.2",
|
|
31
31
|
"@salt-ds/window": "0.1.2",
|
|
32
|
-
"@vuu-ui/core": "5.0.0-alpha.
|
|
32
|
+
"@vuu-ui/core": "5.0.0-alpha.7"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"clsx": "^2.0.0",
|
|
@@ -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();
|
|
@@ -12,7 +12,7 @@ const loadLookupValues = (connectionId, VuuDataSource, { labelColumn, table, val
|
|
|
12
12
|
const tableKey = `${connectionId}:${table.module}:${table.table}`;
|
|
13
13
|
const lookupValues = lookupValueMap.get(tableKey);
|
|
14
14
|
if (lookupValues) return lookupValues;
|
|
15
|
-
{
|
|
15
|
+
else {
|
|
16
16
|
const promise = new Promise((resolve)=>{
|
|
17
17
|
const columns = [
|
|
18
18
|
valueColumn,
|
|
@@ -45,7 +45,7 @@ const loadLookupValues = (connectionId, VuuDataSource, { labelColumn, table, val
|
|
|
45
45
|
};
|
|
46
46
|
const getLookupDetails = ({ name, type })=>{
|
|
47
47
|
if (isTypeDescriptor(type) && isLookupRenderer(type.renderer)) return type.renderer.lookup;
|
|
48
|
-
throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
|
|
48
|
+
else throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
|
|
49
49
|
};
|
|
50
50
|
const useLookupValues = (column, initialValueProp)=>{
|
|
51
51
|
const { type: columnType } = column;
|
|
@@ -59,8 +59,7 @@ const useLookupValues = (column, initialValueProp)=>{
|
|
|
59
59
|
initialValue: getSelectedOption(values, initialValueProp) ?? null,
|
|
60
60
|
values
|
|
61
61
|
};
|
|
62
|
-
}
|
|
63
|
-
{
|
|
62
|
+
} else {
|
|
64
63
|
const lookupDetails = getLookupDetails(column);
|
|
65
64
|
const values = getLookupValues?.(lookupDetails.table) ?? NO_VALUES;
|
|
66
65
|
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
|
|
@@ -4,7 +4,7 @@ import { hasShowNotificationAction, isGroupMenuItemDescriptor } from "@vuu-ui/vu
|
|
|
4
4
|
import { getFilterPredicate } from "@vuu-ui/vuu-filter-parser";
|
|
5
5
|
import { NotificationType, useNotifications } from "@vuu-ui/vuu-notifications";
|
|
6
6
|
import { BulkEditPanel, isTableLocation } from "@vuu-ui/vuu-table";
|
|
7
|
-
import { getLayoutComponent, isActionMessage, isCustomComponentActionMessage, isSessionTableActionMessage, useData } from "@vuu-ui/vuu-utils";
|
|
7
|
+
import { getLayoutComponent, getServerNotificationStatus, isActionMessage, isCustomComponentActionMessage, isSessionTableActionMessage, useData } from "@vuu-ui/vuu-utils";
|
|
8
8
|
import { useModal } from "@vuu-ui/core";
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { SessionEditingForm } from "../session-editing-form/index.js";
|
|
@@ -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);
|
|
@@ -171,7 +170,7 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
|
|
|
171
170
|
onClose: closeDialog
|
|
172
171
|
}), "Set Parameters");
|
|
173
172
|
}
|
|
174
|
-
const sessionDs = await ds.createSessionDataSource?.(
|
|
173
|
+
const sessionDs = await ds.createSessionDataSource?.("All");
|
|
175
174
|
const handleSubmit = ()=>{
|
|
176
175
|
sessionDs?.rpcRequest?.({
|
|
177
176
|
params: {
|
|
@@ -209,35 +208,34 @@ 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) {
|
|
233
232
|
if (onRpcResponse?.(rpcResponse) === true) return true;
|
|
234
233
|
if (isActionMessage(rpcResponse)) {
|
|
235
234
|
if (hasShowNotificationAction(rpcResponse)) {
|
|
236
|
-
const { action
|
|
235
|
+
const { action } = rpcResponse;
|
|
237
236
|
showNotification({
|
|
238
|
-
|
|
239
|
-
content: message,
|
|
240
|
-
header: title,
|
|
237
|
+
...getServerNotificationStatus(action),
|
|
238
|
+
content: action.message,
|
|
241
239
|
type: NotificationType.Toast
|
|
242
240
|
});
|
|
243
241
|
} else if (isSessionTableActionMessage(rpcResponse)) showSessionEditingForm(dataSource, rpcResponse.action);
|
|
@@ -246,12 +244,10 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
|
|
|
246
244
|
}
|
|
247
245
|
});
|
|
248
246
|
return true;
|
|
249
|
-
}
|
|
250
|
-
if ("link-table" === menuItemId) {
|
|
247
|
+
} else if ("link-table" === menuItemId) {
|
|
251
248
|
if (dataSource) dataSource.visualLink = options;
|
|
252
249
|
return true;
|
|
253
|
-
}
|
|
254
|
-
console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
|
|
250
|
+
} else console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
|
|
255
251
|
return false;
|
|
256
252
|
}, [
|
|
257
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 = (VuuDataSource, 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();
|
|
@@ -161,7 +160,7 @@ const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, ke
|
|
|
161
160
|
className: `${classBase}-fieldValue vuuReadOnly`,
|
|
162
161
|
children: value
|
|
163
162
|
});
|
|
164
|
-
return /*#__PURE__*/ jsx(Input, {
|
|
163
|
+
else return /*#__PURE__*/ jsx(Input, {
|
|
165
164
|
className: `${classBase}-fieldValue`,
|
|
166
165
|
onBlur: handleBlur,
|
|
167
166
|
onChange: handleChange,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MenuActionHandler } from "@vuu-ui/vuu-context-menu";
|
|
2
|
-
import { DataSource, DataSourceVisualLinkCreatedMessage, RpcResponseHandler } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import type { DataSource, DataSourceVisualLinkCreatedMessage, RpcResponseHandler } from "@vuu-ui/vuu-data-types";
|
|
3
3
|
import type { LinkDescriptorWithLabel, VuuDataRowDto, VuuMenu, VuuMenuItem, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
4
4
|
import type { ColumnDescriptor, TableContextMenuDef } from "@vuu-ui/vuu-table-types";
|
|
5
5
|
export interface MenuActionConfig {
|