@vuu-ui/vuu-data-react 0.8.94 → 0.8.96
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/cjs/data-editing/EditForm.js +1 -1
- package/cjs/hooks/useTypeaheadSuggestions.js +27 -15
- package/cjs/hooks/useTypeaheadSuggestions.js.map +1 -1
- package/cjs/hooks/useVuuMenuActions.js +2 -4
- package/cjs/hooks/useVuuMenuActions.js.map +1 -1
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/esm/data-editing/EditForm.js +1 -1
- package/esm/hooks/useTypeaheadSuggestions.js +27 -15
- package/esm/hooks/useTypeaheadSuggestions.js.map +1 -1
- package/esm/hooks/useVuuMenuActions.js +2 -4
- package/esm/hooks/useVuuMenuActions.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/package.json +13 -13
- package/types/data-editing/index.d.ts +1 -0
- package/types/datasource-provider/RestDataSourceProvider.d.ts +5 -0
- package/types/hooks/useVuuMenuActions.d.ts +1 -1
|
@@ -5,6 +5,7 @@ var getDataItemEditControl = require('./get-data-item-edit-control.js');
|
|
|
5
5
|
require('@vuu-ui/vuu-utils');
|
|
6
6
|
var styles = require('@salt-ds/styles');
|
|
7
7
|
var window = require('@salt-ds/window');
|
|
8
|
+
var useEditForm = require('./useEditForm.js');
|
|
8
9
|
require('@vuu-ui/vuu-data-remote');
|
|
9
10
|
require('react');
|
|
10
11
|
require('@vuu-ui/vuu-layout');
|
|
@@ -14,7 +15,6 @@ var core = require('@salt-ds/core');
|
|
|
14
15
|
var cx = require('clsx');
|
|
15
16
|
require('@vuu-ui/vuu-ui-controls');
|
|
16
17
|
var editValidationRules = require('./edit-validation-rules.js');
|
|
17
|
-
var useEditForm = require('./useEditForm.js');
|
|
18
18
|
var EditForm$1 = require('./EditForm.css.js');
|
|
19
19
|
|
|
20
20
|
const classBase = "EditForm";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var vuuUtils = require('@vuu-ui/vuu-utils');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
|
|
6
6
|
const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
@@ -9,20 +9,32 @@ const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
|
9
9
|
}
|
|
10
10
|
return [table, column];
|
|
11
11
|
};
|
|
12
|
-
const useTypeaheadSuggestions = () =>
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
const useTypeaheadSuggestions = () => {
|
|
13
|
+
const { getServerAPI } = vuuUtils.useDataSource();
|
|
14
|
+
return react.useCallback(
|
|
15
|
+
async (params) => {
|
|
16
|
+
const rpcMessage = params.length === 2 ? {
|
|
17
|
+
type: "RPC_CALL",
|
|
18
|
+
service: "TypeAheadRpcHandler",
|
|
19
|
+
method: "getUniqueFieldValues",
|
|
20
|
+
params
|
|
21
|
+
} : {
|
|
22
|
+
type: "RPC_CALL",
|
|
23
|
+
service: "TypeAheadRpcHandler",
|
|
24
|
+
method: "getUniqueFieldValuesStartingWith",
|
|
25
|
+
params
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
const serverAPI = await getServerAPI();
|
|
29
|
+
const response = await serverAPI.rpcCall(rpcMessage);
|
|
30
|
+
return response;
|
|
31
|
+
} catch (err) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
[getServerAPI]
|
|
36
|
+
);
|
|
37
|
+
};
|
|
26
38
|
|
|
27
39
|
exports.getTypeaheadParams = getTypeaheadParams;
|
|
28
40
|
exports.useTypeaheadSuggestions = useTypeaheadSuggestions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcServiceRequest,\n TypeaheadParams,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { useDataSource } from \"@vuu-ui/vuu-utils\";\nimport { useCallback } from \"react\";\n\nexport const getTypeaheadParams = (\n table: TableSchemaTable,\n column: string,\n text = \"\",\n selectedValues: string[] = [],\n): TypeaheadParams => {\n if (text !== \"\" && !selectedValues.includes(text.toLowerCase())) {\n return [table, column, text];\n }\n return [table, column];\n};\n\nexport const useTypeaheadSuggestions = () => {\n const { getServerAPI } = useDataSource();\n return useCallback<SuggestionFetcher>(\n async (params: TypeaheadParams) => {\n const rpcMessage: VuuRpcServiceRequest =\n params.length === 2\n ? {\n type: \"RPC_CALL\",\n service: \"TypeAheadRpcHandler\",\n method: \"getUniqueFieldValues\",\n params,\n }\n : {\n type: \"RPC_CALL\",\n service: \"TypeAheadRpcHandler\",\n method: \"getUniqueFieldValuesStartingWith\",\n params,\n };\n\n try {\n const serverAPI = await getServerAPI();\n // We don't just return serverAPI.rpcCall . In the case of an\n // error we will be returning the rejected promise, bypassing\n // the catch block below.\n const response = await serverAPI.rpcCall<string[]>(rpcMessage);\n return response;\n } catch (err) {\n return false;\n }\n },\n [getServerAPI],\n );\n};\n"],"names":["useDataSource","useCallback"],"mappings":";;;;;AAQa,MAAA,kBAAA,GAAqB,CAChC,KACA,EAAA,MAAA,EACA,OAAO,EACP,EAAA,cAAA,GAA2B,EACP,KAAA;AACpB,EAAI,IAAA,IAAA,KAAS,MAAM,CAAC,cAAA,CAAe,SAAS,IAAK,CAAA,WAAA,EAAa,CAAG,EAAA;AAC/D,IAAO,OAAA,CAAC,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA,CAAA;AAAA,GAC7B;AACA,EAAO,OAAA,CAAC,OAAO,MAAM,CAAA,CAAA;AACvB,EAAA;AAEO,MAAM,0BAA0B,MAAM;AAC3C,EAAM,MAAA,EAAE,YAAa,EAAA,GAAIA,sBAAc,EAAA,CAAA;AACvC,EAAO,OAAAC,iBAAA;AAAA,IACL,OAAO,MAA4B,KAAA;AACjC,MAAM,MAAA,UAAA,GACJ,MAAO,CAAA,MAAA,KAAW,CACd,GAAA;AAAA,QACE,IAAM,EAAA,UAAA;AAAA,QACN,OAAS,EAAA,qBAAA;AAAA,QACT,MAAQ,EAAA,sBAAA;AAAA,QACR,MAAA;AAAA,OAEF,GAAA;AAAA,QACE,IAAM,EAAA,UAAA;AAAA,QACN,OAAS,EAAA,qBAAA;AAAA,QACT,MAAQ,EAAA,kCAAA;AAAA,QACR,MAAA;AAAA,OACF,CAAA;AAEN,MAAI,IAAA;AACF,QAAM,MAAA,SAAA,GAAY,MAAM,YAAa,EAAA,CAAA;AAIrC,QAAA,MAAM,QAAW,GAAA,MAAM,SAAU,CAAA,OAAA,CAAkB,UAAU,CAAA,CAAA;AAC7D,QAAO,OAAA,QAAA,CAAA;AAAA,eACA,GAAK,EAAA;AACZ,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,IACA,CAAC,YAAY,CAAA;AAAA,GACf,CAAA;AACF;;;;;"}
|
|
@@ -8,7 +8,6 @@ var core = require('@salt-ds/core');
|
|
|
8
8
|
var react = require('react');
|
|
9
9
|
var SessionEditingForm = require('../session-editing-form/SessionEditingForm.js');
|
|
10
10
|
|
|
11
|
-
const NO_CONFIG = {};
|
|
12
11
|
const keyFirst = (c1, c2) => c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;
|
|
13
12
|
const defaultFormConfig = {
|
|
14
13
|
fields: [],
|
|
@@ -42,14 +41,13 @@ const getFormConfig = (action) => {
|
|
|
42
41
|
const useVuuMenuActions = ({
|
|
43
42
|
clientSideMenuActionHandler,
|
|
44
43
|
dataSource,
|
|
45
|
-
menuActionConfig = NO_CONFIG,
|
|
46
44
|
onRpcResponse
|
|
47
45
|
}) => {
|
|
48
46
|
const { VuuDataSource } = vuuUtils.useDataSource();
|
|
49
47
|
const buildViewserverMenuOptions = react.useCallback(
|
|
50
48
|
(location, options) => {
|
|
51
49
|
const { links, menu } = dataSource;
|
|
52
|
-
const { visualLink } =
|
|
50
|
+
const { visualLink } = dataSource;
|
|
53
51
|
const descriptors = [];
|
|
54
52
|
if (location === "grid" && links && !visualLink) {
|
|
55
53
|
links.forEach((linkDescriptor) => {
|
|
@@ -76,7 +74,7 @@ const useVuuMenuActions = ({
|
|
|
76
74
|
}
|
|
77
75
|
return descriptors;
|
|
78
76
|
},
|
|
79
|
-
[dataSource
|
|
77
|
+
[dataSource]
|
|
80
78
|
);
|
|
81
79
|
const { showDialog, closeDialog } = vuuPopups.useDialogContext();
|
|
82
80
|
const showNotification = vuuPopups.useNotifications();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVuuMenuActions.js","sources":["../../src/hooks/useVuuMenuActions.tsx"],"sourcesContent":["import {\n ContextMenuItemDescriptor,\n DataSource,\n DataSourceVisualLinkCreatedMessage,\n MenuActionHandler,\n MenuBuilder,\n RpcResponseHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n useDialogContext,\n useNotifications,\n type MenuActionClosePopup,\n} from \"@vuu-ui/vuu-popups\";\nimport type {\n LinkDescriptorWithLabel,\n OpenDialogAction,\n VuuMenu,\n VuuMenuItem,\n VuuRpcResponse,\n VuuTable,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { BulkEditPanel } from \"@vuu-ui/vuu-table\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n VuuServerMenuOptions,\n buildMenuDescriptorFromVuuMenu,\n getMenuRpcRequest,\n hasShowNotificationAction,\n isActionMessage,\n isGroupMenuItemDescriptor,\n isOpenBulkEditResponse,\n isRoot,\n isSessionTableActionMessage,\n isTableLocation,\n useDataSource,\n viewportRpcRequest,\n} from \"@vuu-ui/vuu-utils\";\nimport { Button } from \"@salt-ds/core\";\nimport { useCallback } from \"react\";\nimport {\n FormConfig,\n FormFieldDescriptor,\n SessionEditingForm,\n} from \"../session-editing-form\";\n\nconst NO_CONFIG: MenuActionConfig = {};\n\nexport type VuuMenuActionHandler = (type: string, options: unknown) => boolean;\n\nexport interface ViewServerHookResult {\n buildViewserverMenuOptions: MenuBuilder;\n handleMenuAction: MenuActionHandler;\n}\n\nexport interface MenuActionConfig {\n vuuMenu?: VuuMenu;\n visualLink?: DataSourceVisualLinkCreatedMessage;\n visualLinks?: LinkDescriptorWithLabel[];\n}\n\nexport interface VuuMenuActionHookProps {\n /**\n * By default, vuuMenuActions will be handled automatically. When activated, a\n * message will be sent to server and response will be handled here too.\n * This prop allows client to provide a custom handler for a menu Item. This will\n * take priority and if handler returns true, no further processing for the menu\n * item will be handled by Vuu. This can also be used to prevent an item from being\n * actioned, even when no custom handling is intended. If the handler returns false,\n * Vuu will process the menuItem.\n */\n clientSideMenuActionHandler?: VuuMenuActionHandler;\n dataSource: DataSource;\n menuActionConfig?: MenuActionConfig;\n onRpcResponse?: RpcResponseHandler;\n}\n\nconst keyFirst = (c1: FormFieldDescriptor, c2: FormFieldDescriptor) =>\n c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;\n\nconst defaultFormConfig = {\n fields: [],\n key: \"\",\n title: \"\",\n};\n\nconst configFromSchema = (schema?: TableSchema): FormConfig | undefined => {\n if (schema) {\n const { columns, key } = schema;\n return {\n key,\n title: `Parameters for command`,\n fields: columns\n .map((col) => ({\n description: col.name,\n label: col.name,\n name: col.name,\n type: col.serverDataType,\n isKeyField: col.name === key,\n }))\n .sort(keyFirst),\n };\n }\n};\n\nconst getFormConfig = (\n action: OpenDialogAction & { tableSchema: TableSchema },\n) => {\n const { tableSchema: schema } = action;\n const config = configFromSchema(schema) ?? defaultFormConfig;\n\n return {\n config,\n schema,\n };\n};\n\nexport const useVuuMenuActions = ({\n clientSideMenuActionHandler,\n dataSource,\n menuActionConfig = NO_CONFIG,\n onRpcResponse,\n}: VuuMenuActionHookProps): ViewServerHookResult => {\n const { VuuDataSource } = useDataSource();\n const buildViewserverMenuOptions: MenuBuilder = useCallback(\n (location, options) => {\n const { links, menu } = dataSource;\n const { visualLink } = menuActionConfig;\n const descriptors: ContextMenuItemDescriptor[] = [];\n\n if (location === \"grid\" && links && !visualLink) {\n links.forEach((linkDescriptor: LinkDescriptorWithLabel) => {\n const { link, label: linkLabel } = linkDescriptor;\n const label = linkLabel ? linkLabel : link.toTable;\n descriptors.push({\n label: `Link to ${label}`,\n action: \"link-table\",\n options: linkDescriptor,\n });\n });\n }\n\n if (menu && isTableLocation(location)) {\n const menuDescriptor = buildMenuDescriptorFromVuuMenu(\n menu,\n location,\n options as VuuServerMenuOptions,\n );\n if (isRoot(menu) && isGroupMenuItemDescriptor(menuDescriptor)) {\n descriptors.push(...menuDescriptor.children);\n } else if (menuDescriptor) {\n descriptors.push(menuDescriptor);\n }\n }\n\n return descriptors;\n },\n [dataSource, menuActionConfig],\n );\n\n const { showDialog, closeDialog } = useDialogContext();\n const showNotification = useNotifications();\n\n const showBulkEditDialog = useCallback(\n (table: VuuTable, columns?: ColumnDescriptor[]) => {\n // NO send BULK_EDIT_BEGIN\n const sessionDs = new VuuDataSource({\n table,\n viewport: table.table,\n });\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n columns={columns}\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Bulk Amend\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [VuuDataSource, closeDialog, dataSource, showDialog],\n );\n\n const showSessionEditingForm = useCallback(\n (action: OpenDialogAction & { tableSchema: TableSchema }) => {\n const { tableSchema } = action;\n if (tableSchema) {\n const formConfig = getFormConfig(action);\n showDialog(\n <SessionEditingForm {...formConfig} onClose={closeDialog} />,\n \"Set Parameters\",\n );\n }\n\n const sessionDs = dataSource.createSessionDataSource?.(action.table);\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Multi Row Edit\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [closeDialog, dataSource, showDialog],\n );\n\n const handleMenuAction = useCallback(\n ({ menuId, options }: MenuActionClosePopup) => {\n if (clientSideMenuActionHandler?.(menuId, options)) {\n return true;\n } else if (menuId === \"MENU_RPC_CALL\") {\n const rpcRequest = getMenuRpcRequest(options as unknown as VuuMenuItem);\n\n dataSource\n .menuRpcCall(rpcRequest)\n .then((rpcResponse: Omit<VuuRpcResponse, \"requestId\">) => {\n if (rpcResponse) {\n if (onRpcResponse?.(rpcResponse) === true) {\n return true;\n }\n if (isActionMessage(rpcResponse)) {\n if (hasShowNotificationAction(rpcResponse)) {\n const {\n action: { message, title = \"Success\" },\n } = rpcResponse;\n showNotification({\n type: \"success\",\n body: message,\n header: title,\n });\n } else if (isOpenBulkEditResponse(rpcResponse)) {\n showBulkEditDialog(rpcResponse.action.table, options.columns);\n } else if (isSessionTableActionMessage(rpcResponse)) {\n showSessionEditingForm(rpcResponse.action);\n }\n }\n }\n });\n return true;\n } else if (menuId === \"link-table\") {\n dataSource.visualLink = options as LinkDescriptorWithLabel;\n return true;\n } else {\n console.log(\n `useViewServer handleMenuAction, can't handle action type ${menuId}`,\n );\n }\n\n return false;\n },\n [\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n showBulkEditDialog,\n showNotification,\n showSessionEditingForm,\n ],\n );\n\n return {\n buildViewserverMenuOptions,\n handleMenuAction,\n };\n};\n"],"names":["useDataSource","useCallback","isTableLocation","buildMenuDescriptorFromVuuMenu","isRoot","isGroupMenuItemDescriptor","useDialogContext","useNotifications","viewportRpcRequest","jsx","BulkEditPanel","Button","SessionEditingForm","getMenuRpcRequest","isActionMessage","hasShowNotificationAction","isOpenBulkEditResponse","isSessionTableActionMessage"],"mappings":";;;;;;;;;;AA8CA,MAAM,YAA8B,EAAC,CAAA;AA+BrC,MAAM,QAAA,GAAW,CAAC,EAAyB,EAAA,EAAA,KACzC,GAAG,UAAa,GAAA,CAAA,CAAA,GAAK,EAAG,CAAA,UAAA,GAAa,CAAI,GAAA,CAAA,CAAA;AAE3C,MAAM,iBAAoB,GAAA;AAAA,EACxB,QAAQ,EAAC;AAAA,EACT,GAAK,EAAA,EAAA;AAAA,EACL,KAAO,EAAA,EAAA;AACT,CAAA,CAAA;AAEA,MAAM,gBAAA,GAAmB,CAAC,MAAiD,KAAA;AACzE,EAAA,IAAI,MAAQ,EAAA;AACV,IAAM,MAAA,EAAE,OAAS,EAAA,GAAA,EAAQ,GAAA,MAAA,CAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAA;AAAA,MACA,KAAO,EAAA,CAAA,sBAAA,CAAA;AAAA,MACP,MAAQ,EAAA,OAAA,CACL,GAAI,CAAA,CAAC,GAAS,MAAA;AAAA,QACb,aAAa,GAAI,CAAA,IAAA;AAAA,QACjB,OAAO,GAAI,CAAA,IAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,MAAM,GAAI,CAAA,cAAA;AAAA,QACV,UAAA,EAAY,IAAI,IAAS,KAAA,GAAA;AAAA,OAC3B,CAAE,CACD,CAAA,IAAA,CAAK,QAAQ,CAAA;A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WAAW,CAAG,EAAA;AAC9C,gBAAA,kBAAA,CAAmB,WAAY,CAAA,MAAA,CAAO,KAAO,EAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,eAC9D,MAAA,IAAWC,oCAA4B,CAAA,WAAW,CAAG,EAAA;AACnD,gBAAA,sBAAA,CAAuB,YAAY,MAAM,CAAA,CAAA;AAAA,eAC3C;AAAA,aACF;AAAA,WACF;AAAA,SACD,CAAA,CAAA;AACH,QAAO,OAAA,IAAA,CAAA;AAAA,OACT,MAAA,IAAW,WAAW,YAAc,EAAA;AAClC,QAAA,UAAA,CAAW,UAAa,GAAA,OAAA,CAAA;AACxB,QAAO,OAAA,IAAA,CAAA;AAAA,OACF,MAAA;AACL,QAAQ,OAAA,CAAA,GAAA;AAAA,UACN,6DAA6D,MAAM,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AAEA,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,IACA;AAAA,MACE,2BAAA;AAAA,MACA,UAAA;AAAA,MACA,aAAA;AAAA,MACA,kBAAA;AAAA,MACA,gBAAA;AAAA,MACA,sBAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,0BAAA;AAAA,IACA,gBAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useVuuMenuActions.js","sources":["../../src/hooks/useVuuMenuActions.tsx"],"sourcesContent":["import {\n ContextMenuItemDescriptor,\n DataSource,\n DataSourceVisualLinkCreatedMessage,\n MenuActionHandler,\n MenuBuilder,\n RpcResponseHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n useDialogContext,\n useNotifications,\n type MenuActionClosePopup,\n} from \"@vuu-ui/vuu-popups\";\nimport type {\n LinkDescriptorWithLabel,\n OpenDialogAction,\n VuuMenu,\n VuuMenuItem,\n VuuRpcResponse,\n VuuTable,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { BulkEditPanel } from \"@vuu-ui/vuu-table\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n VuuServerMenuOptions,\n buildMenuDescriptorFromVuuMenu,\n getMenuRpcRequest,\n hasShowNotificationAction,\n isActionMessage,\n isGroupMenuItemDescriptor,\n isOpenBulkEditResponse,\n isRoot,\n isSessionTableActionMessage,\n isTableLocation,\n useDataSource,\n viewportRpcRequest,\n} from \"@vuu-ui/vuu-utils\";\nimport { Button } from \"@salt-ds/core\";\nimport { useCallback } from \"react\";\nimport {\n FormConfig,\n FormFieldDescriptor,\n SessionEditingForm,\n} from \"../session-editing-form\";\n\nexport type VuuMenuActionHandler = (type: string, options: unknown) => boolean;\n\nexport interface ViewServerHookResult {\n buildViewserverMenuOptions: MenuBuilder;\n handleMenuAction: MenuActionHandler;\n}\n\nexport interface MenuActionConfig {\n vuuMenu?: VuuMenu;\n visualLink?: DataSourceVisualLinkCreatedMessage;\n visualLinks?: LinkDescriptorWithLabel[];\n}\n\nexport interface VuuMenuActionHookProps {\n /**\n * By default, vuuMenuActions will be handled automatically. When activated, a\n * message will be sent to server and response will be handled here too.\n * This prop allows client to provide a custom handler for a menu Item. This will\n * take priority and if handler returns true, no further processing for the menu\n * item will be handled by Vuu. This can also be used to prevent an item from being\n * actioned, even when no custom handling is intended. If the handler returns false,\n * Vuu will process the menuItem.\n */\n clientSideMenuActionHandler?: VuuMenuActionHandler;\n dataSource: DataSource;\n menuActionConfig?: MenuActionConfig;\n onRpcResponse?: RpcResponseHandler;\n}\n\nconst keyFirst = (c1: FormFieldDescriptor, c2: FormFieldDescriptor) =>\n c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;\n\nconst defaultFormConfig = {\n fields: [],\n key: \"\",\n title: \"\",\n};\n\nconst configFromSchema = (schema?: TableSchema): FormConfig | undefined => {\n if (schema) {\n const { columns, key } = schema;\n return {\n key,\n title: `Parameters for command`,\n fields: columns\n .map((col) => ({\n description: col.name,\n label: col.name,\n name: col.name,\n type: col.serverDataType,\n isKeyField: col.name === key,\n }))\n .sort(keyFirst),\n };\n }\n};\n\nconst getFormConfig = (\n action: OpenDialogAction & { tableSchema: TableSchema },\n) => {\n const { tableSchema: schema } = action;\n const config = configFromSchema(schema) ?? defaultFormConfig;\n\n return {\n config,\n schema,\n };\n};\n\nexport const useVuuMenuActions = ({\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n}: VuuMenuActionHookProps): ViewServerHookResult => {\n const { VuuDataSource } = useDataSource();\n const buildViewserverMenuOptions: MenuBuilder = useCallback(\n (location, options) => {\n const { links, menu } = dataSource;\n const { visualLink } = dataSource;\n const descriptors: ContextMenuItemDescriptor[] = [];\n\n if (location === \"grid\" && links && !visualLink) {\n links.forEach((linkDescriptor: LinkDescriptorWithLabel) => {\n const { link, label: linkLabel } = linkDescriptor;\n const label = linkLabel ? linkLabel : link.toTable;\n descriptors.push({\n label: `Link to ${label}`,\n action: \"link-table\",\n options: linkDescriptor,\n });\n });\n }\n\n if (menu && isTableLocation(location)) {\n const menuDescriptor = buildMenuDescriptorFromVuuMenu(\n menu,\n location,\n options as VuuServerMenuOptions,\n );\n if (isRoot(menu) && isGroupMenuItemDescriptor(menuDescriptor)) {\n descriptors.push(...menuDescriptor.children);\n } else if (menuDescriptor) {\n descriptors.push(menuDescriptor);\n }\n }\n\n return descriptors;\n },\n [dataSource],\n );\n\n const { showDialog, closeDialog } = useDialogContext();\n const showNotification = useNotifications();\n\n const showBulkEditDialog = useCallback(\n (table: VuuTable, columns?: ColumnDescriptor[]) => {\n // NO send BULK_EDIT_BEGIN\n const sessionDs = new VuuDataSource({\n table,\n viewport: table.table,\n });\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n columns={columns}\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Bulk Amend\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [VuuDataSource, closeDialog, dataSource, showDialog],\n );\n\n const showSessionEditingForm = useCallback(\n (action: OpenDialogAction & { tableSchema: TableSchema }) => {\n const { tableSchema } = action;\n if (tableSchema) {\n const formConfig = getFormConfig(action);\n showDialog(\n <SessionEditingForm {...formConfig} onClose={closeDialog} />,\n \"Set Parameters\",\n );\n }\n\n const sessionDs = dataSource.createSessionDataSource?.(action.table);\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Multi Row Edit\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [closeDialog, dataSource, showDialog],\n );\n\n const handleMenuAction = useCallback(\n ({ menuId, options }: MenuActionClosePopup) => {\n if (clientSideMenuActionHandler?.(menuId, options)) {\n return true;\n } else if (menuId === \"MENU_RPC_CALL\") {\n const rpcRequest = getMenuRpcRequest(options as unknown as VuuMenuItem);\n\n dataSource\n .menuRpcCall(rpcRequest)\n .then((rpcResponse: Omit<VuuRpcResponse, \"requestId\">) => {\n if (rpcResponse) {\n if (onRpcResponse?.(rpcResponse) === true) {\n return true;\n }\n if (isActionMessage(rpcResponse)) {\n if (hasShowNotificationAction(rpcResponse)) {\n const {\n action: { message, title = \"Success\" },\n } = rpcResponse;\n showNotification({\n type: \"success\",\n body: message,\n header: title,\n });\n } else if (isOpenBulkEditResponse(rpcResponse)) {\n showBulkEditDialog(rpcResponse.action.table, options.columns);\n } else if (isSessionTableActionMessage(rpcResponse)) {\n showSessionEditingForm(rpcResponse.action);\n }\n }\n }\n });\n return true;\n } else if (menuId === \"link-table\") {\n dataSource.visualLink = options as LinkDescriptorWithLabel;\n return true;\n } else {\n console.log(\n `useViewServer handleMenuAction, can't handle action type ${menuId}`,\n );\n }\n\n return false;\n },\n [\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n showBulkEditDialog,\n showNotification,\n showSessionEditingForm,\n ],\n );\n\n return {\n buildViewserverMenuOptions,\n handleMenuAction,\n };\n};\n"],"names":["useDataSource","useCallback","isTableLocation","buildMenuDescriptorFromVuuMenu","isRoot","isGroupMenuItemDescriptor","useDialogContext","useNotifications","viewportRpcRequest","jsx","BulkEditPanel","Button","SessionEditingForm","getMenuRpcRequest","isActionMessage","hasShowNotificationAction","isOpenBulkEditResponse","isSessionTableActionMessage"],"mappings":";;;;;;;;;;AA2EA,MAAM,QAAA,GAAW,CAAC,EAAyB,EAAA,EAAA,KACzC,GAAG,UAAa,GAAA,CAAA,CAAA,GAAK,EAAG,CAAA,UAAA,GAAa,CAAI,GAAA,CAAA,CAAA;AAE3C,MAAM,iBAAoB,GAAA;AAAA,EACxB,QAAQ,EAAC;AAAA,EACT,GAAK,EAAA,EAAA;AAAA,EACL,KAAO,EAAA,EAAA;AACT,CAAA,CAAA;AAEA,MAAM,gBAAA,GAAmB,CAAC,MAAiD,KAAA;AACzE,EAAA,IAAI,MAAQ,EAAA;AACV,IAAM,MAAA,EAAE,OAAS,EAAA,GAAA,EAAQ,GAAA,MAAA,CAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAA;AAAA,MACA,KAAO,EAAA,CAAA,sBAAA,CAAA;AAAA,MACP,MAAQ,EAAA,OAAA,CACL,GAAI,CAAA,CAAC,GAAS,MAAA;AAAA,QACb,aAAa,GAAI,CAAA,IAAA;AAAA,QACjB,OAAO,GAAI,CAAA,IAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,MAAM,GAAI,CAAA,cAAA;AAAA,QACV,UAAA,EA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;AAAA,eACH,MAAA,IAAWC,+BAAuB,CAAA,WAAW,CAAG,EAAA;AAC9C,gBAAA,kBAAA,CAAmB,WAAY,CAAA,MAAA,CAAO,KAAO,EAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,eAC9D,MAAA,IAAWC,oCAA4B,CAAA,WAAW,CAAG,EAAA;AACnD,gBAAA,sBAAA,CAAuB,YAAY,MAAM,CAAA,CAAA;AAAA,eAC3C;AAAA,aACF;AAAA,WACF;AAAA,SACD,CAAA,CAAA;AACH,QAAO,OAAA,IAAA,CAAA;AAAA,OACT,MAAA,IAAW,WAAW,YAAc,EAAA;AAClC,QAAA,UAAA,CAAW,UAAa,GAAA,OAAA,CAAA;AACxB,QAAO,OAAA,IAAA,CAAA;AAAA,OACF,MAAA;AACL,QAAQ,OAAA,CAAA,GAAA;AAAA,UACN,6DAA6D,MAAM,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AAEA,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,IACA;AAAA,MACE,2BAAA;AAAA,MACA,UAAA;AAAA,MACA,aAAA;AAAA,MACA,kBAAA;AAAA,MACA,gBAAA;AAAA,MACA,sBAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,0BAAA;AAAA,IACA,gBAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var getDataItemEditControl = require('./data-editing/get-data-item-edit-control.
|
|
|
4
4
|
var EditForm = require('./data-editing/EditForm.js');
|
|
5
5
|
var editRuleValidationChecker = require('./data-editing/edit-rule-validation-checker.js');
|
|
6
6
|
var UnsavedChangesReport = require('./data-editing/UnsavedChangesReport.js');
|
|
7
|
+
var useEditForm = require('./data-editing/useEditForm.js');
|
|
7
8
|
var VuuDataSourceProvider = require('./datasource-provider/VuuDataSourceProvider.js');
|
|
8
9
|
var useLookupValues = require('./hooks/useLookupValues.js');
|
|
9
10
|
var useSessionDataSource = require('./hooks/useSessionDataSource.js');
|
|
@@ -22,6 +23,7 @@ exports.OK = editRuleValidationChecker.OK;
|
|
|
22
23
|
exports.buildValidationChecker = editRuleValidationChecker.buildValidationChecker;
|
|
23
24
|
exports.getEditValidationRules = editRuleValidationChecker.getEditValidationRules;
|
|
24
25
|
exports.UnsavedChangesReport = UnsavedChangesReport.UnsavedChangesReport;
|
|
26
|
+
exports.useEditForm = useEditForm.useEditForm;
|
|
25
27
|
exports.VuuDataSourceProvider = VuuDataSourceProvider.VuuDataSourceProvider;
|
|
26
28
|
exports.useLookupValues = useLookupValues.useLookupValues;
|
|
27
29
|
exports.useSessionDataSource = useSessionDataSource.useSessionDataSource;
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { getDataItemEditControl } from './get-data-item-edit-control.js';
|
|
|
3
3
|
import '@vuu-ui/vuu-utils';
|
|
4
4
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
5
5
|
import { useWindow } from '@salt-ds/window';
|
|
6
|
+
import { useEditForm } from './useEditForm.js';
|
|
6
7
|
import '@vuu-ui/vuu-data-remote';
|
|
7
8
|
import 'react';
|
|
8
9
|
import '@vuu-ui/vuu-layout';
|
|
@@ -12,7 +13,6 @@ import { FormField, FormFieldLabel, Button } from '@salt-ds/core';
|
|
|
12
13
|
import cx from 'clsx';
|
|
13
14
|
import '@vuu-ui/vuu-ui-controls';
|
|
14
15
|
import { registerRules } from './edit-validation-rules.js';
|
|
15
|
-
import { useEditForm } from './useEditForm.js';
|
|
16
16
|
import editFormCss from './EditForm.css.js';
|
|
17
17
|
|
|
18
18
|
const classBase = "EditForm";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDataSource } from '@vuu-ui/vuu-utils';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
@@ -7,20 +7,32 @@ const getTypeaheadParams = (table, column, text = "", selectedValues = []) => {
|
|
|
7
7
|
}
|
|
8
8
|
return [table, column];
|
|
9
9
|
};
|
|
10
|
-
const useTypeaheadSuggestions = () =>
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
const useTypeaheadSuggestions = () => {
|
|
11
|
+
const { getServerAPI } = useDataSource();
|
|
12
|
+
return useCallback(
|
|
13
|
+
async (params) => {
|
|
14
|
+
const rpcMessage = params.length === 2 ? {
|
|
15
|
+
type: "RPC_CALL",
|
|
16
|
+
service: "TypeAheadRpcHandler",
|
|
17
|
+
method: "getUniqueFieldValues",
|
|
18
|
+
params
|
|
19
|
+
} : {
|
|
20
|
+
type: "RPC_CALL",
|
|
21
|
+
service: "TypeAheadRpcHandler",
|
|
22
|
+
method: "getUniqueFieldValuesStartingWith",
|
|
23
|
+
params
|
|
24
|
+
};
|
|
25
|
+
try {
|
|
26
|
+
const serverAPI = await getServerAPI();
|
|
27
|
+
const response = await serverAPI.rpcCall(rpcMessage);
|
|
28
|
+
return response;
|
|
29
|
+
} catch (err) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[getServerAPI]
|
|
34
|
+
);
|
|
35
|
+
};
|
|
24
36
|
|
|
25
37
|
export { getTypeaheadParams, useTypeaheadSuggestions };
|
|
26
38
|
//# sourceMappingURL=useTypeaheadSuggestions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useTypeaheadSuggestions.js","sources":["../../src/hooks/useTypeaheadSuggestions.ts"],"sourcesContent":["import { SuggestionFetcher, TableSchemaTable } from \"@vuu-ui/vuu-data-types\";\nimport {\n VuuRpcServiceRequest,\n TypeaheadParams,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { useDataSource } from \"@vuu-ui/vuu-utils\";\nimport { useCallback } from \"react\";\n\nexport const getTypeaheadParams = (\n table: TableSchemaTable,\n column: string,\n text = \"\",\n selectedValues: string[] = [],\n): TypeaheadParams => {\n if (text !== \"\" && !selectedValues.includes(text.toLowerCase())) {\n return [table, column, text];\n }\n return [table, column];\n};\n\nexport const useTypeaheadSuggestions = () => {\n const { getServerAPI } = useDataSource();\n return useCallback<SuggestionFetcher>(\n async (params: TypeaheadParams) => {\n const rpcMessage: VuuRpcServiceRequest =\n params.length === 2\n ? {\n type: \"RPC_CALL\",\n service: \"TypeAheadRpcHandler\",\n method: \"getUniqueFieldValues\",\n params,\n }\n : {\n type: \"RPC_CALL\",\n service: \"TypeAheadRpcHandler\",\n method: \"getUniqueFieldValuesStartingWith\",\n params,\n };\n\n try {\n const serverAPI = await getServerAPI();\n // We don't just return serverAPI.rpcCall . In the case of an\n // error we will be returning the rejected promise, bypassing\n // the catch block below.\n const response = await serverAPI.rpcCall<string[]>(rpcMessage);\n return response;\n } catch (err) {\n return false;\n }\n },\n [getServerAPI],\n );\n};\n"],"names":[],"mappings":";;;AAQa,MAAA,kBAAA,GAAqB,CAChC,KACA,EAAA,MAAA,EACA,OAAO,EACP,EAAA,cAAA,GAA2B,EACP,KAAA;AACpB,EAAI,IAAA,IAAA,KAAS,MAAM,CAAC,cAAA,CAAe,SAAS,IAAK,CAAA,WAAA,EAAa,CAAG,EAAA;AAC/D,IAAO,OAAA,CAAC,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA,CAAA;AAAA,GAC7B;AACA,EAAO,OAAA,CAAC,OAAO,MAAM,CAAA,CAAA;AACvB,EAAA;AAEO,MAAM,0BAA0B,MAAM;AAC3C,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,aAAc,EAAA,CAAA;AACvC,EAAO,OAAA,WAAA;AAAA,IACL,OAAO,MAA4B,KAAA;AACjC,MAAM,MAAA,UAAA,GACJ,MAAO,CAAA,MAAA,KAAW,CACd,GAAA;AAAA,QACE,IAAM,EAAA,UAAA;AAAA,QACN,OAAS,EAAA,qBAAA;AAAA,QACT,MAAQ,EAAA,sBAAA;AAAA,QACR,MAAA;AAAA,OAEF,GAAA;AAAA,QACE,IAAM,EAAA,UAAA;AAAA,QACN,OAAS,EAAA,qBAAA;AAAA,QACT,MAAQ,EAAA,kCAAA;AAAA,QACR,MAAA;AAAA,OACF,CAAA;AAEN,MAAI,IAAA;AACF,QAAM,MAAA,SAAA,GAAY,MAAM,YAAa,EAAA,CAAA;AAIrC,QAAA,MAAM,QAAW,GAAA,MAAM,SAAU,CAAA,OAAA,CAAkB,UAAU,CAAA,CAAA;AAC7D,QAAO,OAAA,QAAA,CAAA;AAAA,eACA,GAAK,EAAA;AACZ,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,IACA,CAAC,YAAY,CAAA;AAAA,GACf,CAAA;AACF;;;;"}
|
|
@@ -6,7 +6,6 @@ import { Button } from '@salt-ds/core';
|
|
|
6
6
|
import { useCallback } from 'react';
|
|
7
7
|
import { SessionEditingForm } from '../session-editing-form/SessionEditingForm.js';
|
|
8
8
|
|
|
9
|
-
const NO_CONFIG = {};
|
|
10
9
|
const keyFirst = (c1, c2) => c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;
|
|
11
10
|
const defaultFormConfig = {
|
|
12
11
|
fields: [],
|
|
@@ -40,14 +39,13 @@ const getFormConfig = (action) => {
|
|
|
40
39
|
const useVuuMenuActions = ({
|
|
41
40
|
clientSideMenuActionHandler,
|
|
42
41
|
dataSource,
|
|
43
|
-
menuActionConfig = NO_CONFIG,
|
|
44
42
|
onRpcResponse
|
|
45
43
|
}) => {
|
|
46
44
|
const { VuuDataSource } = useDataSource();
|
|
47
45
|
const buildViewserverMenuOptions = useCallback(
|
|
48
46
|
(location, options) => {
|
|
49
47
|
const { links, menu } = dataSource;
|
|
50
|
-
const { visualLink } =
|
|
48
|
+
const { visualLink } = dataSource;
|
|
51
49
|
const descriptors = [];
|
|
52
50
|
if (location === "grid" && links && !visualLink) {
|
|
53
51
|
links.forEach((linkDescriptor) => {
|
|
@@ -74,7 +72,7 @@ const useVuuMenuActions = ({
|
|
|
74
72
|
}
|
|
75
73
|
return descriptors;
|
|
76
74
|
},
|
|
77
|
-
[dataSource
|
|
75
|
+
[dataSource]
|
|
78
76
|
);
|
|
79
77
|
const { showDialog, closeDialog } = useDialogContext();
|
|
80
78
|
const showNotification = useNotifications();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVuuMenuActions.js","sources":["../../src/hooks/useVuuMenuActions.tsx"],"sourcesContent":["import {\n ContextMenuItemDescriptor,\n DataSource,\n DataSourceVisualLinkCreatedMessage,\n MenuActionHandler,\n MenuBuilder,\n RpcResponseHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n useDialogContext,\n useNotifications,\n type MenuActionClosePopup,\n} from \"@vuu-ui/vuu-popups\";\nimport type {\n LinkDescriptorWithLabel,\n OpenDialogAction,\n VuuMenu,\n VuuMenuItem,\n VuuRpcResponse,\n VuuTable,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { BulkEditPanel } from \"@vuu-ui/vuu-table\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n VuuServerMenuOptions,\n buildMenuDescriptorFromVuuMenu,\n getMenuRpcRequest,\n hasShowNotificationAction,\n isActionMessage,\n isGroupMenuItemDescriptor,\n isOpenBulkEditResponse,\n isRoot,\n isSessionTableActionMessage,\n isTableLocation,\n useDataSource,\n viewportRpcRequest,\n} from \"@vuu-ui/vuu-utils\";\nimport { Button } from \"@salt-ds/core\";\nimport { useCallback } from \"react\";\nimport {\n FormConfig,\n FormFieldDescriptor,\n SessionEditingForm,\n} from \"../session-editing-form\";\n\nconst NO_CONFIG: MenuActionConfig = {};\n\nexport type VuuMenuActionHandler = (type: string, options: unknown) => boolean;\n\nexport interface ViewServerHookResult {\n buildViewserverMenuOptions: MenuBuilder;\n handleMenuAction: MenuActionHandler;\n}\n\nexport interface MenuActionConfig {\n vuuMenu?: VuuMenu;\n visualLink?: DataSourceVisualLinkCreatedMessage;\n visualLinks?: LinkDescriptorWithLabel[];\n}\n\nexport interface VuuMenuActionHookProps {\n /**\n * By default, vuuMenuActions will be handled automatically. When activated, a\n * message will be sent to server and response will be handled here too.\n * This prop allows client to provide a custom handler for a menu Item. This will\n * take priority and if handler returns true, no further processing for the menu\n * item will be handled by Vuu. This can also be used to prevent an item from being\n * actioned, even when no custom handling is intended. If the handler returns false,\n * Vuu will process the menuItem.\n */\n clientSideMenuActionHandler?: VuuMenuActionHandler;\n dataSource: DataSource;\n menuActionConfig?: MenuActionConfig;\n onRpcResponse?: RpcResponseHandler;\n}\n\nconst keyFirst = (c1: FormFieldDescriptor, c2: FormFieldDescriptor) =>\n c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;\n\nconst defaultFormConfig = {\n fields: [],\n key: \"\",\n title: \"\",\n};\n\nconst configFromSchema = (schema?: TableSchema): FormConfig | undefined => {\n if (schema) {\n const { columns, key } = schema;\n return {\n key,\n title: `Parameters for command`,\n fields: columns\n .map((col) => ({\n description: col.name,\n label: col.name,\n name: col.name,\n type: col.serverDataType,\n isKeyField: col.name === key,\n }))\n .sort(keyFirst),\n };\n }\n};\n\nconst getFormConfig = (\n action: OpenDialogAction & { tableSchema: TableSchema },\n) => {\n const { tableSchema: schema } = action;\n const config = configFromSchema(schema) ?? defaultFormConfig;\n\n return {\n config,\n schema,\n };\n};\n\nexport const useVuuMenuActions = ({\n clientSideMenuActionHandler,\n dataSource,\n menuActionConfig = NO_CONFIG,\n onRpcResponse,\n}: VuuMenuActionHookProps): ViewServerHookResult => {\n const { VuuDataSource } = useDataSource();\n const buildViewserverMenuOptions: MenuBuilder = useCallback(\n (location, options) => {\n const { links, menu } = dataSource;\n const { visualLink } = menuActionConfig;\n const descriptors: ContextMenuItemDescriptor[] = [];\n\n if (location === \"grid\" && links && !visualLink) {\n links.forEach((linkDescriptor: LinkDescriptorWithLabel) => {\n const { link, label: linkLabel } = linkDescriptor;\n const label = linkLabel ? linkLabel : link.toTable;\n descriptors.push({\n label: `Link to ${label}`,\n action: \"link-table\",\n options: linkDescriptor,\n });\n });\n }\n\n if (menu && isTableLocation(location)) {\n const menuDescriptor = buildMenuDescriptorFromVuuMenu(\n menu,\n location,\n options as VuuServerMenuOptions,\n );\n if (isRoot(menu) && isGroupMenuItemDescriptor(menuDescriptor)) {\n descriptors.push(...menuDescriptor.children);\n } else if (menuDescriptor) {\n descriptors.push(menuDescriptor);\n }\n }\n\n return descriptors;\n },\n [dataSource, menuActionConfig],\n );\n\n const { showDialog, closeDialog } = useDialogContext();\n const showNotification = useNotifications();\n\n const showBulkEditDialog = useCallback(\n (table: VuuTable, columns?: ColumnDescriptor[]) => {\n // NO send BULK_EDIT_BEGIN\n const sessionDs = new VuuDataSource({\n table,\n viewport: table.table,\n });\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n columns={columns}\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Bulk Amend\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [VuuDataSource, closeDialog, dataSource, showDialog],\n );\n\n const showSessionEditingForm = useCallback(\n (action: OpenDialogAction & { tableSchema: TableSchema }) => {\n const { tableSchema } = action;\n if (tableSchema) {\n const formConfig = getFormConfig(action);\n showDialog(\n <SessionEditingForm {...formConfig} onClose={closeDialog} />,\n \"Set Parameters\",\n );\n }\n\n const sessionDs = dataSource.createSessionDataSource?.(action.table);\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Multi Row Edit\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [closeDialog, dataSource, showDialog],\n );\n\n const handleMenuAction = useCallback(\n ({ menuId, options }: MenuActionClosePopup) => {\n if (clientSideMenuActionHandler?.(menuId, options)) {\n return true;\n } else if (menuId === \"MENU_RPC_CALL\") {\n const rpcRequest = getMenuRpcRequest(options as unknown as VuuMenuItem);\n\n dataSource\n .menuRpcCall(rpcRequest)\n .then((rpcResponse: Omit<VuuRpcResponse, \"requestId\">) => {\n if (rpcResponse) {\n if (onRpcResponse?.(rpcResponse) === true) {\n return true;\n }\n if (isActionMessage(rpcResponse)) {\n if (hasShowNotificationAction(rpcResponse)) {\n const {\n action: { message, title = \"Success\" },\n } = rpcResponse;\n showNotification({\n type: \"success\",\n body: message,\n header: title,\n });\n } else if (isOpenBulkEditResponse(rpcResponse)) {\n showBulkEditDialog(rpcResponse.action.table, options.columns);\n } else if (isSessionTableActionMessage(rpcResponse)) {\n showSessionEditingForm(rpcResponse.action);\n }\n }\n }\n });\n return true;\n } else if (menuId === \"link-table\") {\n dataSource.visualLink = options as LinkDescriptorWithLabel;\n return true;\n } else {\n console.log(\n `useViewServer handleMenuAction, can't handle action type ${menuId}`,\n );\n }\n\n return false;\n },\n [\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n showBulkEditDialog,\n showNotification,\n showSessionEditingForm,\n ],\n );\n\n return {\n buildViewserverMenuOptions,\n handleMenuAction,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AA8CA,MAAM,YAA8B,EAAC,CAAA;AA+BrC,MAAM,QAAA,GAAW,CAAC,EAAyB,EAAA,EAAA,KACzC,GAAG,UAAa,GAAA,CAAA,CAAA,GAAK,EAAG,CAAA,UAAA,GAAa,CAAI,GAAA,CAAA,CAAA;AAE3C,MAAM,iBAAoB,GAAA;AAAA,EACxB,QAAQ,EAAC;AAAA,EACT,GAAK,EAAA,EAAA;AAAA,EACL,KAAO,EAAA,EAAA;AACT,CAAA,CAAA;AAEA,MAAM,gBAAA,GAAmB,CAAC,MAAiD,KAAA;AACzE,EAAA,IAAI,MAAQ,EAAA;AACV,IAAM,MAAA,EAAE,OAAS,EAAA,GAAA,EAAQ,GAAA,MAAA,CAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAA;AAAA,MACA,KAAO,EAAA,CAAA,sBAAA,CAAA;AAAA,MACP,MAAQ,EAAA,OAAA,CACL,GAAI,CAAA,CAAC,GAAS,MAAA;AAAA,QACb,aAAa,GAAI,CAAA,IAAA;AAAA,QACjB,OAAO,GAAI,CAAA,IAAA;AAAA,QACX,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,MAAM,GAAI,CAAA,cAAA;AAAA,QACV,UAAA,EAAY,IAAI,IAAS,KAAA,GAAA;AAAA,OAC3B,CAAE,CACD,CAAA,IAAA,CAAK,QAAQ,CAAA;AAAA,KAClB,CAAA;AAAA,GACF;AACF,CAAA,CAAA;AAEA,MAAM,aAAA,GAAgB,CACpB,MACG,KAAA;AACH,EAAM,MAAA,EAAE,WAAa,EAAA,MAAA,EAAW,GAAA,MAAA,CAAA;AAChC,EAAM,MAAA,MAAA,GAAS,gBAAiB,CAAA,MAAM,CAAK,IAAA,iBAAA,CAAA;AAE3C,EAAO,OAAA;AAAA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IAAA,CAAA;AAAA,OACT,MAAA,IAAW,WAAW,YAAc,EAAA;AAClC,QAAA,UAAA,CAAW,UAAa,GAAA,OAAA,CAAA;AACxB,QAAO,OAAA,IAAA,CAAA;AAAA,OACF,MAAA;AACL,QAAQ,OAAA,CAAA,GAAA;AAAA,UACN,6DAA6D,MAAM,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AAEA,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,IACA;AAAA,MACE,2BAAA;AAAA,MACA,UAAA;AAAA,MACA,aAAA;AAAA,MACA,kBAAA;AAAA,MACA,gBAAA;AAAA,MACA,sBAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,0BAAA;AAAA,IACA,gBAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useVuuMenuActions.js","sources":["../../src/hooks/useVuuMenuActions.tsx"],"sourcesContent":["import {\n ContextMenuItemDescriptor,\n DataSource,\n DataSourceVisualLinkCreatedMessage,\n MenuActionHandler,\n MenuBuilder,\n RpcResponseHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport {\n useDialogContext,\n useNotifications,\n type MenuActionClosePopup,\n} from \"@vuu-ui/vuu-popups\";\nimport type {\n LinkDescriptorWithLabel,\n OpenDialogAction,\n VuuMenu,\n VuuMenuItem,\n VuuRpcResponse,\n VuuTable,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport { BulkEditPanel } from \"@vuu-ui/vuu-table\";\nimport { ColumnDescriptor } from \"@vuu-ui/vuu-table-types\";\nimport {\n VuuServerMenuOptions,\n buildMenuDescriptorFromVuuMenu,\n getMenuRpcRequest,\n hasShowNotificationAction,\n isActionMessage,\n isGroupMenuItemDescriptor,\n isOpenBulkEditResponse,\n isRoot,\n isSessionTableActionMessage,\n isTableLocation,\n useDataSource,\n viewportRpcRequest,\n} from \"@vuu-ui/vuu-utils\";\nimport { Button } from \"@salt-ds/core\";\nimport { useCallback } from \"react\";\nimport {\n FormConfig,\n FormFieldDescriptor,\n SessionEditingForm,\n} from \"../session-editing-form\";\n\nexport type VuuMenuActionHandler = (type: string, options: unknown) => boolean;\n\nexport interface ViewServerHookResult {\n buildViewserverMenuOptions: MenuBuilder;\n handleMenuAction: MenuActionHandler;\n}\n\nexport interface MenuActionConfig {\n vuuMenu?: VuuMenu;\n visualLink?: DataSourceVisualLinkCreatedMessage;\n visualLinks?: LinkDescriptorWithLabel[];\n}\n\nexport interface VuuMenuActionHookProps {\n /**\n * By default, vuuMenuActions will be handled automatically. When activated, a\n * message will be sent to server and response will be handled here too.\n * This prop allows client to provide a custom handler for a menu Item. This will\n * take priority and if handler returns true, no further processing for the menu\n * item will be handled by Vuu. This can also be used to prevent an item from being\n * actioned, even when no custom handling is intended. If the handler returns false,\n * Vuu will process the menuItem.\n */\n clientSideMenuActionHandler?: VuuMenuActionHandler;\n dataSource: DataSource;\n menuActionConfig?: MenuActionConfig;\n onRpcResponse?: RpcResponseHandler;\n}\n\nconst keyFirst = (c1: FormFieldDescriptor, c2: FormFieldDescriptor) =>\n c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;\n\nconst defaultFormConfig = {\n fields: [],\n key: \"\",\n title: \"\",\n};\n\nconst configFromSchema = (schema?: TableSchema): FormConfig | undefined => {\n if (schema) {\n const { columns, key } = schema;\n return {\n key,\n title: `Parameters for command`,\n fields: columns\n .map((col) => ({\n description: col.name,\n label: col.name,\n name: col.name,\n type: col.serverDataType,\n isKeyField: col.name === key,\n }))\n .sort(keyFirst),\n };\n }\n};\n\nconst getFormConfig = (\n action: OpenDialogAction & { tableSchema: TableSchema },\n) => {\n const { tableSchema: schema } = action;\n const config = configFromSchema(schema) ?? defaultFormConfig;\n\n return {\n config,\n schema,\n };\n};\n\nexport const useVuuMenuActions = ({\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n}: VuuMenuActionHookProps): ViewServerHookResult => {\n const { VuuDataSource } = useDataSource();\n const buildViewserverMenuOptions: MenuBuilder = useCallback(\n (location, options) => {\n const { links, menu } = dataSource;\n const { visualLink } = dataSource;\n const descriptors: ContextMenuItemDescriptor[] = [];\n\n if (location === \"grid\" && links && !visualLink) {\n links.forEach((linkDescriptor: LinkDescriptorWithLabel) => {\n const { link, label: linkLabel } = linkDescriptor;\n const label = linkLabel ? linkLabel : link.toTable;\n descriptors.push({\n label: `Link to ${label}`,\n action: \"link-table\",\n options: linkDescriptor,\n });\n });\n }\n\n if (menu && isTableLocation(location)) {\n const menuDescriptor = buildMenuDescriptorFromVuuMenu(\n menu,\n location,\n options as VuuServerMenuOptions,\n );\n if (isRoot(menu) && isGroupMenuItemDescriptor(menuDescriptor)) {\n descriptors.push(...menuDescriptor.children);\n } else if (menuDescriptor) {\n descriptors.push(menuDescriptor);\n }\n }\n\n return descriptors;\n },\n [dataSource],\n );\n\n const { showDialog, closeDialog } = useDialogContext();\n const showNotification = useNotifications();\n\n const showBulkEditDialog = useCallback(\n (table: VuuTable, columns?: ColumnDescriptor[]) => {\n // NO send BULK_EDIT_BEGIN\n const sessionDs = new VuuDataSource({\n table,\n viewport: table.table,\n });\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n columns={columns}\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Bulk Amend\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [VuuDataSource, closeDialog, dataSource, showDialog],\n );\n\n const showSessionEditingForm = useCallback(\n (action: OpenDialogAction & { tableSchema: TableSchema }) => {\n const { tableSchema } = action;\n if (tableSchema) {\n const formConfig = getFormConfig(action);\n showDialog(\n <SessionEditingForm {...formConfig} onClose={closeDialog} />,\n \"Set Parameters\",\n );\n }\n\n const sessionDs = dataSource.createSessionDataSource?.(action.table);\n const handleSubmit = () => {\n sessionDs?.rpcCall?.(viewportRpcRequest(\"VP_BULK_EDIT_SUBMIT_RPC\"));\n closeDialog();\n };\n\n if (sessionDs) {\n showDialog(\n <BulkEditPanel\n dataSource={sessionDs}\n onSubmit={handleSubmit}\n parentDs={dataSource}\n />,\n \"Multi Row Edit\",\n [\n <Button key=\"cancel\" onClick={closeDialog}>\n Cancel\n </Button>,\n <Button key=\"submit\" onClick={handleSubmit}>\n Save\n </Button>,\n ],\n );\n\n return true;\n }\n },\n [closeDialog, dataSource, showDialog],\n );\n\n const handleMenuAction = useCallback(\n ({ menuId, options }: MenuActionClosePopup) => {\n if (clientSideMenuActionHandler?.(menuId, options)) {\n return true;\n } else if (menuId === \"MENU_RPC_CALL\") {\n const rpcRequest = getMenuRpcRequest(options as unknown as VuuMenuItem);\n\n dataSource\n .menuRpcCall(rpcRequest)\n .then((rpcResponse: Omit<VuuRpcResponse, \"requestId\">) => {\n if (rpcResponse) {\n if (onRpcResponse?.(rpcResponse) === true) {\n return true;\n }\n if (isActionMessage(rpcResponse)) {\n if (hasShowNotificationAction(rpcResponse)) {\n const {\n action: { message, title = \"Success\" },\n } = rpcResponse;\n showNotification({\n type: \"success\",\n body: message,\n header: title,\n });\n } else if (isOpenBulkEditResponse(rpcResponse)) {\n showBulkEditDialog(rpcResponse.action.table, options.columns);\n } else if (isSessionTableActionMessage(rpcResponse)) {\n showSessionEditingForm(rpcResponse.action);\n }\n }\n }\n });\n return true;\n } else if (menuId === \"link-table\") {\n dataSource.visualLink = options as LinkDescriptorWithLabel;\n return true;\n } else {\n console.log(\n `useViewServer handleMenuAction, can't handle action type ${menuId}`,\n );\n }\n\n return false;\n },\n [\n clientSideMenuActionHandler,\n dataSource,\n onRpcResponse,\n showBulkEditDialog,\n showNotification,\n showSessionEditingForm,\n ],\n );\n\n return {\n buildViewserverMenuOptions,\n handleMenuAction,\n };\n};\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,CAAA,CAAA;AAAA,SACrE,CAAA;AAAA,OACF;AAEA,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AAAA,IACA;AAAA,MACE,2BAAA;AAAA,MACA,UAAA;AAAA,MACA,aAAA;AAAA,MACA,kBAAA;AAAA,MACA,gBAAA;AAAA,MACA,sBAAA;AAAA,KACF;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,0BAAA;AAAA,IACA,gBAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { getDataItemEditControl } from './data-editing/get-data-item-edit-contro
|
|
|
2
2
|
export { EditForm } from './data-editing/EditForm.js';
|
|
3
3
|
export { OK, buildValidationChecker, getEditValidationRules } from './data-editing/edit-rule-validation-checker.js';
|
|
4
4
|
export { UnsavedChangesReport } from './data-editing/UnsavedChangesReport.js';
|
|
5
|
+
export { useEditForm } from './data-editing/useEditForm.js';
|
|
5
6
|
export { VuuDataSourceProvider } from './datasource-provider/VuuDataSourceProvider.js';
|
|
6
7
|
export { useLookupValues } from './hooks/useLookupValues.js';
|
|
7
8
|
export { useSessionDataSource } from './hooks/useSessionDataSource.js';
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.
|
|
2
|
+
"version": "0.8.96",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "0.8.
|
|
7
|
-
"@vuu-ui/vuu-filter-types": "0.8.
|
|
8
|
-
"@vuu-ui/vuu-popups": "0.8.
|
|
9
|
-
"@vuu-ui/vuu-protocol-types": "0.8.
|
|
10
|
-
"@vuu-ui/vuu-table-types": "0.8.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "0.8.96",
|
|
7
|
+
"@vuu-ui/vuu-filter-types": "0.8.96",
|
|
8
|
+
"@vuu-ui/vuu-popups": "0.8.96",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.8.96",
|
|
10
|
+
"@vuu-ui/vuu-table-types": "0.8.96"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@vuu-ui/vuu-data-remote": "0.8.
|
|
14
|
-
"@vuu-ui/vuu-filter-parser": "0.8.
|
|
15
|
-
"@vuu-ui/vuu-layout": "0.8.
|
|
16
|
-
"@vuu-ui/vuu-popups": "0.8.
|
|
17
|
-
"@vuu-ui/vuu-ui-controls": "0.8.
|
|
18
|
-
"@vuu-ui/vuu-utils": "0.8.
|
|
19
|
-
"@vuu-ui/vuu-table": "0.8.
|
|
13
|
+
"@vuu-ui/vuu-data-remote": "0.8.96",
|
|
14
|
+
"@vuu-ui/vuu-filter-parser": "0.8.96",
|
|
15
|
+
"@vuu-ui/vuu-layout": "0.8.96",
|
|
16
|
+
"@vuu-ui/vuu-popups": "0.8.96",
|
|
17
|
+
"@vuu-ui/vuu-ui-controls": "0.8.96",
|
|
18
|
+
"@vuu-ui/vuu-utils": "0.8.96",
|
|
19
|
+
"@vuu-ui/vuu-table": "0.8.96",
|
|
20
20
|
"@salt-ds/core": "1.34.0",
|
|
21
21
|
"@salt-ds/styles": "0.2.1",
|
|
22
22
|
"@salt-ds/window": "0.1.1"
|
|
@@ -25,4 +25,4 @@ export interface VuuMenuActionHookProps {
|
|
|
25
25
|
menuActionConfig?: MenuActionConfig;
|
|
26
26
|
onRpcResponse?: RpcResponseHandler;
|
|
27
27
|
}
|
|
28
|
-
export declare const useVuuMenuActions: ({ clientSideMenuActionHandler, dataSource,
|
|
28
|
+
export declare const useVuuMenuActions: ({ clientSideMenuActionHandler, dataSource, onRpcResponse, }: VuuMenuActionHookProps) => ViewServerHookResult;
|