@vuu-ui/vuu-data-react 2.1.19-beta.2 → 2.1.19-beta.4

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.
Files changed (119) hide show
  1. package/cjs/data-editing/EditForm.css.js +6 -0
  2. package/cjs/data-editing/EditForm.css.js.map +1 -0
  3. package/cjs/data-editing/EditForm.js +90 -0
  4. package/cjs/data-editing/EditForm.js.map +1 -0
  5. package/cjs/data-editing/UnsavedChangesReport.css.js +6 -0
  6. package/cjs/data-editing/UnsavedChangesReport.css.js.map +1 -0
  7. package/cjs/data-editing/UnsavedChangesReport.js +29 -0
  8. package/cjs/data-editing/UnsavedChangesReport.js.map +1 -0
  9. package/cjs/data-editing/edit-rule-validation-checker.js +41 -0
  10. package/cjs/data-editing/edit-rule-validation-checker.js.map +1 -0
  11. package/cjs/data-editing/edit-validation-rules.js +52 -0
  12. package/cjs/data-editing/edit-validation-rules.js.map +1 -0
  13. package/cjs/data-editing/form-edit-state.js +26 -0
  14. package/cjs/data-editing/form-edit-state.js.map +1 -0
  15. package/cjs/data-editing/get-data-item-edit-control.js +105 -0
  16. package/cjs/data-editing/get-data-item-edit-control.js.map +1 -0
  17. package/cjs/data-editing/useEditForm.js +258 -0
  18. package/cjs/data-editing/useEditForm.js.map +1 -0
  19. package/cjs/datasource-provider/VuuDataSourceProvider.js +34 -0
  20. package/cjs/datasource-provider/VuuDataSourceProvider.js.map +1 -0
  21. package/cjs/datasource-provider/useAutoLoginToVuuServer.js +52 -0
  22. package/cjs/datasource-provider/useAutoLoginToVuuServer.js.map +1 -0
  23. package/cjs/hooks/useLookupValues.js +100 -0
  24. package/cjs/hooks/useLookupValues.js.map +1 -0
  25. package/cjs/hooks/useSessionDataSource.js +58 -0
  26. package/cjs/hooks/useSessionDataSource.js.map +1 -0
  27. package/cjs/hooks/useTypeaheadSuggestions.js +57 -0
  28. package/cjs/hooks/useTypeaheadSuggestions.js.map +1 -0
  29. package/cjs/hooks/useVisualLinks.js +84 -0
  30. package/cjs/hooks/useVisualLinks.js.map +1 -0
  31. package/cjs/hooks/useVuuMenuActions.js +352 -0
  32. package/cjs/hooks/useVuuMenuActions.js.map +1 -0
  33. package/cjs/hooks/useVuuTables.js +38 -0
  34. package/cjs/hooks/useVuuTables.js.map +1 -0
  35. package/cjs/index.js +42 -0
  36. package/cjs/index.js.map +1 -0
  37. package/cjs/lost-connection-indicator/LostConnectionIndicator.css.js +6 -0
  38. package/cjs/lost-connection-indicator/LostConnectionIndicator.css.js.map +1 -0
  39. package/cjs/lost-connection-indicator/LostConnectionIndicator.js +24 -0
  40. package/cjs/lost-connection-indicator/LostConnectionIndicator.js.map +1 -0
  41. package/cjs/lost-connection-indicator/useLostConnection.js +34 -0
  42. package/cjs/lost-connection-indicator/useLostConnection.js.map +1 -0
  43. package/cjs/session-editing-form/SessionEditingForm.css.js +6 -0
  44. package/cjs/session-editing-form/SessionEditingForm.css.js.map +1 -0
  45. package/cjs/session-editing-form/SessionEditingForm.js +270 -0
  46. package/cjs/session-editing-form/SessionEditingForm.js.map +1 -0
  47. package/esm/data-editing/EditForm.css.js +4 -0
  48. package/esm/data-editing/EditForm.css.js.map +1 -0
  49. package/esm/data-editing/EditForm.js +88 -0
  50. package/esm/data-editing/EditForm.js.map +1 -0
  51. package/esm/data-editing/UnsavedChangesReport.css.js +4 -0
  52. package/esm/data-editing/UnsavedChangesReport.css.js.map +1 -0
  53. package/esm/data-editing/UnsavedChangesReport.js +27 -0
  54. package/esm/data-editing/UnsavedChangesReport.js.map +1 -0
  55. package/esm/data-editing/edit-rule-validation-checker.js +37 -0
  56. package/esm/data-editing/edit-rule-validation-checker.js.map +1 -0
  57. package/esm/data-editing/edit-validation-rules.js +50 -0
  58. package/esm/data-editing/edit-validation-rules.js.map +1 -0
  59. package/esm/data-editing/form-edit-state.js +23 -0
  60. package/esm/data-editing/form-edit-state.js.map +1 -0
  61. package/esm/data-editing/get-data-item-edit-control.js +103 -0
  62. package/esm/data-editing/get-data-item-edit-control.js.map +1 -0
  63. package/esm/data-editing/useEditForm.js +256 -0
  64. package/esm/data-editing/useEditForm.js.map +1 -0
  65. package/esm/datasource-provider/VuuDataSourceProvider.js +32 -0
  66. package/esm/datasource-provider/VuuDataSourceProvider.js.map +1 -0
  67. package/esm/datasource-provider/useAutoLoginToVuuServer.js +50 -0
  68. package/esm/datasource-provider/useAutoLoginToVuuServer.js.map +1 -0
  69. package/esm/hooks/useLookupValues.js +98 -0
  70. package/esm/hooks/useLookupValues.js.map +1 -0
  71. package/esm/hooks/useSessionDataSource.js +56 -0
  72. package/esm/hooks/useSessionDataSource.js.map +1 -0
  73. package/esm/hooks/useTypeaheadSuggestions.js +54 -0
  74. package/esm/hooks/useTypeaheadSuggestions.js.map +1 -0
  75. package/esm/hooks/useVisualLinks.js +82 -0
  76. package/esm/hooks/useVisualLinks.js.map +1 -0
  77. package/esm/hooks/useVuuMenuActions.js +348 -0
  78. package/esm/hooks/useVuuMenuActions.js.map +1 -0
  79. package/esm/hooks/useVuuTables.js +36 -0
  80. package/esm/hooks/useVuuTables.js.map +1 -0
  81. package/esm/index.js +16 -0
  82. package/esm/index.js.map +1 -0
  83. package/esm/lost-connection-indicator/LostConnectionIndicator.css.js +4 -0
  84. package/esm/lost-connection-indicator/LostConnectionIndicator.css.js.map +1 -0
  85. package/esm/lost-connection-indicator/LostConnectionIndicator.js +22 -0
  86. package/esm/lost-connection-indicator/LostConnectionIndicator.js.map +1 -0
  87. package/esm/lost-connection-indicator/useLostConnection.js +32 -0
  88. package/esm/lost-connection-indicator/useLostConnection.js.map +1 -0
  89. package/esm/session-editing-form/SessionEditingForm.css.js +4 -0
  90. package/esm/session-editing-form/SessionEditingForm.css.js.map +1 -0
  91. package/esm/session-editing-form/SessionEditingForm.js +268 -0
  92. package/esm/session-editing-form/SessionEditingForm.js.map +1 -0
  93. package/package.json +21 -18
  94. package/src/data-editing/EditForm.css.js +0 -53
  95. package/src/data-editing/EditForm.js +0 -82
  96. package/src/data-editing/UnsavedChangesReport.css.js +0 -27
  97. package/src/data-editing/UnsavedChangesReport.js +0 -41
  98. package/src/data-editing/edit-rule-validation-checker.js +0 -30
  99. package/src/data-editing/edit-validation-rules.js +0 -33
  100. package/src/data-editing/form-edit-state.js +0 -16
  101. package/src/data-editing/get-data-item-edit-control.js +0 -63
  102. package/src/data-editing/index.js +0 -6
  103. package/src/data-editing/useEditForm.js +0 -253
  104. package/src/datasource-provider/VuuDataSourceProvider.js +0 -20
  105. package/src/datasource-provider/index.js +0 -1
  106. package/src/datasource-provider/useAutoLoginToVuuServer.js +0 -42
  107. package/src/hooks/useLookupValues.js +0 -93
  108. package/src/hooks/useSessionDataSource.js +0 -37
  109. package/src/hooks/useTypeaheadSuggestions.js +0 -50
  110. package/src/hooks/useVisualLinks.js +0 -87
  111. package/src/hooks/useVuuMenuActions.js +0 -269
  112. package/src/hooks/useVuuTables.js +0 -32
  113. package/src/index.js +0 -10
  114. package/src/lost-connection-indicator/LostConnectionIndicator.css.js +0 -29
  115. package/src/lost-connection-indicator/LostConnectionIndicator.js +0 -30
  116. package/src/lost-connection-indicator/useLostConnection.js +0 -28
  117. package/src/session-editing-form/SessionEditingForm.css.js +0 -47
  118. package/src/session-editing-form/SessionEditingForm.js +0 -236
  119. package/src/session-editing-form/index.js +0 -1
@@ -1,50 +0,0 @@
1
- import { useDataSource } from "@vuu-ui/vuu-utils";
2
- import { useCallback } from "react";
3
- const getTypeaheadParams = (table, column, text = "", selectedValues = [])=>{
4
- if ("" !== text && !selectedValues.includes(text.toLowerCase())) return [
5
- table,
6
- column,
7
- text
8
- ];
9
- return [
10
- table,
11
- column
12
- ];
13
- };
14
- const useTypeaheadSuggestions = ()=>{
15
- const dataSource = useDataSource(false);
16
- return useCallback(async ([{ module, table }, column, starts])=>{
17
- if (void 0 === dataSource) {
18
- console.warn("[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)");
19
- return false;
20
- }
21
- const rpcMessage = void 0 === starts ? {
22
- params: {
23
- column,
24
- module,
25
- table
26
- },
27
- rpcName: "getUniqueFieldValues",
28
- type: "RPC_REQUEST"
29
- } : {
30
- params: {
31
- column,
32
- module,
33
- starts,
34
- table
35
- },
36
- rpcName: "getUniqueFieldValuesStartingWith",
37
- type: "RPC_REQUEST"
38
- };
39
- try {
40
- const response = await dataSource.rpcRequest?.(rpcMessage);
41
- if (response?.type === "SUCCESS_RESULT") return response.data;
42
- return false;
43
- } catch (err) {
44
- return false;
45
- }
46
- }, [
47
- dataSource
48
- ]);
49
- };
50
- export { getTypeaheadParams, useTypeaheadSuggestions };
@@ -1,87 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useViewContext } from "@vuu-ui/vuu-layout";
3
- import { IconButton } from "@vuu-ui/vuu-ui-controls";
4
- import { useCallback, useEffect } from "react";
5
- const useVisualLinks = (dataSource)=>{
6
- const { dispatch } = useViewContext();
7
- const clearVisualLinkTarget = useCallback(()=>{
8
- if (dataSource.visualLink) dispatch?.({
9
- type: "broadcast-message",
10
- message: {
11
- targetId: dataSource.visualLink.parentClientVpId,
12
- type: "highlight-off"
13
- }
14
- });
15
- }, [
16
- dataSource,
17
- dispatch
18
- ]);
19
- const removeVisualLink = useCallback(()=>{
20
- if (dataSource.visualLink) {
21
- dispatch?.({
22
- type: "broadcast-message",
23
- message: {
24
- targetId: dataSource.visualLink.parentClientVpId,
25
- type: "highlight-off"
26
- }
27
- });
28
- dataSource.visualLink = void 0;
29
- }
30
- }, [
31
- dataSource,
32
- dispatch
33
- ]);
34
- const handleLinkRemoved = useCallback(()=>{
35
- dispatch?.({
36
- type: "remove-toolbar-contribution",
37
- location: "post-title"
38
- });
39
- }, [
40
- dispatch
41
- ]);
42
- const highlightVisualLinkTarget = useCallback(()=>{
43
- if (dataSource.visualLink) dispatch?.({
44
- type: "broadcast-message",
45
- message: {
46
- targetId: dataSource.visualLink.parentClientVpId,
47
- type: "highlight-on"
48
- }
49
- });
50
- }, [
51
- dataSource,
52
- dispatch
53
- ]);
54
- const handleLinkCreated = useCallback(()=>{
55
- dispatch?.({
56
- type: "add-toolbar-contribution",
57
- location: "post-title",
58
- content: /*#__PURE__*/ jsx(IconButton, {
59
- appearance: "transparent",
60
- "aria-label": "remove-link",
61
- icon: "link",
62
- onClick: removeVisualLink,
63
- onMouseEnter: highlightVisualLinkTarget,
64
- onMouseLeave: clearVisualLinkTarget,
65
- sentiment: "neutral"
66
- })
67
- });
68
- }, [
69
- dispatch,
70
- removeVisualLink,
71
- highlightVisualLinkTarget,
72
- clearVisualLinkTarget
73
- ]);
74
- useEffect(()=>{
75
- dataSource.on("visual-link-created", handleLinkCreated);
76
- dataSource.on("visual-link-removed", handleLinkRemoved);
77
- return ()=>{
78
- dataSource.removeListener("visual-link-created", handleLinkCreated);
79
- dataSource.removeListener("visual-link-removed", handleLinkRemoved);
80
- };
81
- }, [
82
- dataSource,
83
- handleLinkCreated,
84
- handleLinkRemoved
85
- ]);
86
- };
87
- export { useVisualLinks };
@@ -1,269 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Button } from "@salt-ds/core";
3
- import { hasShowNotificationAction, isGroupMenuItemDescriptor } from "@vuu-ui/vuu-context-menu";
4
- import { getFilterPredicate } from "@vuu-ui/vuu-filter-parser";
5
- import { NotificationType, useNotifications } from "@vuu-ui/vuu-notifications";
6
- import { BulkEditPanel, isTableLocation } from "@vuu-ui/vuu-table";
7
- import { getLayoutComponent, isActionMessage, isCustomComponentActionMessage, isSessionTableActionMessage, useData } from "@vuu-ui/vuu-utils";
8
- import { useCallback } from "react";
9
- import { SessionEditingForm } from "../session-editing-form/index.js";
10
- import { useModal } from "@vuu-ui/vuu-ui-controls";
11
- const isRoot = (menu)=>"ROOT" === menu.name;
12
- const isCellMenu = (options)=>"cell" === options.context;
13
- const isRowMenu = (options)=>"row" === options.context;
14
- const isSelectionMenu = (options)=>"selected-rows" === options.context;
15
- const isVuuMenuItem = (menu)=>"rpcName" in menu;
16
- const isGroupMenuItem = (menu)=>"menus" in menu;
17
- const hasFilter = ({ filter })=>"string" == typeof filter && filter.length > 0;
18
- const getMenuItemOptions = (menu, options)=>{
19
- switch(menu.context){
20
- case "cell":
21
- return {
22
- ...menu,
23
- field: options.column.name,
24
- rowKey: options.dataRow.key,
25
- value: options.dataRow[options.column.name]
26
- };
27
- case "row":
28
- return {
29
- ...menu,
30
- columns: options.columns,
31
- row: options.dataRow,
32
- rowKey: options.dataRow.key
33
- };
34
- case "selected-rows":
35
- return {
36
- ...menu,
37
- columns: options.columns
38
- };
39
- default:
40
- return menu;
41
- }
42
- };
43
- const vuuContextCompatibleWithTableLocation = (uiLocation, vuuContext, selectedRowCount = 0)=>{
44
- switch(uiLocation){
45
- case "grid":
46
- if ("selected-rows" === vuuContext) return selectedRowCount > 0;
47
- return true;
48
- case "header":
49
- return "grid" === vuuContext;
50
- default:
51
- return false;
52
- }
53
- };
54
- const gridRowMeetsFilterCriteria = (context, dataRow, selectedRows, filter)=>{
55
- if ("cell" === context || "row" === context) {
56
- const filterPredicate = getFilterPredicate(filter);
57
- return filterPredicate(dataRow);
58
- }
59
- if ("selected-rows" === context) if (0 === selectedRows.length) return false;
60
- else {
61
- const filterPredicate = getFilterPredicate(filter);
62
- return selectedRows.every(filterPredicate);
63
- }
64
- return true;
65
- };
66
- const menuShouldBeRenderedInThisContext = (menuItem, tableLocation, options)=>{
67
- if (isGroupMenuItem(menuItem)) return menuItem.menus.some((childMenu)=>menuShouldBeRenderedInThisContext(childMenu, tableLocation, options));
68
- if (!vuuContextCompatibleWithTableLocation(tableLocation, menuItem.context, options.selectedRows?.length)) return false;
69
- if ("grid" === tableLocation && hasFilter(menuItem)) return gridRowMeetsFilterCriteria(menuItem.context, options.dataRow, options.selectedRows, menuItem.filter);
70
- if (isCellMenu(menuItem) && "*" !== menuItem.field) return menuItem.field === options.column.name;
71
- return true;
72
- };
73
- const buildMenuDescriptorFromVuuMenu = (menu, tableLocation, options)=>{
74
- if (menuShouldBeRenderedInThisContext(menu, tableLocation, options)) if (isVuuMenuItem(menu)) return {
75
- label: menu.name,
76
- id: "MENU_RPC_CALL",
77
- options: getMenuItemOptions(menu, options)
78
- };
79
- else {
80
- const children = menu.menus.map((childMenu)=>buildMenuDescriptorFromVuuMenu(childMenu, tableLocation, options)).filter((childMenu)=>void 0 !== childMenu);
81
- if (children.length > 0) return {
82
- label: menu.name,
83
- children
84
- };
85
- }
86
- };
87
- const keyFirst = (c1, c2)=>c1.isKeyField ? -1 : c2.isKeyField ? 1 : 0;
88
- const defaultFormConfig = {
89
- fields: [],
90
- key: "",
91
- title: ""
92
- };
93
- const configFromSchema = (schema)=>{
94
- if (schema) {
95
- const { columns, key } = schema;
96
- return {
97
- key,
98
- title: "Parameters for command",
99
- fields: columns.map((col)=>({
100
- description: col.name,
101
- label: col.name,
102
- name: col.name,
103
- type: col.serverDataType,
104
- isKeyField: col.name === key
105
- })).sort(keyFirst)
106
- };
107
- }
108
- };
109
- const getFormConfig = (action)=>{
110
- const { tableSchema: schema } = action;
111
- const config = configFromSchema(schema) ?? defaultFormConfig;
112
- return {
113
- config,
114
- schema
115
- };
116
- };
117
- const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcResponse })=>{
118
- const { VuuDataSource } = useData();
119
- const menuBuilder = useCallback((location, options)=>{
120
- const descriptors = [];
121
- if (dataSource) {
122
- const { links, menu } = dataSource;
123
- const { visualLink } = dataSource;
124
- if ("grid" === location && links && !visualLink) links.forEach((linkDescriptor)=>{
125
- const { link, label: linkLabel } = linkDescriptor;
126
- const label = linkLabel ? linkLabel : link.toTable;
127
- descriptors.push({
128
- label: `Link to ${label}`,
129
- id: "link-table",
130
- options: linkDescriptor
131
- });
132
- });
133
- if (menu && isTableLocation(location)) {
134
- const menuDescriptor = buildMenuDescriptorFromVuuMenu(menu, location, options);
135
- if (isRoot(menu) && isGroupMenuItemDescriptor(menuDescriptor)) descriptors.push(...menuDescriptor.children);
136
- else if (menuDescriptor) descriptors.push(menuDescriptor);
137
- }
138
- } else throw Error("useVuuMenuActions no dataSource provided");
139
- return descriptors;
140
- }, [
141
- dataSource
142
- ]);
143
- const { showDialog, closeDialog, showPrompt } = useModal();
144
- const { showNotification } = useNotifications();
145
- const showCustomComponentInDialog = useCallback((componentId, ds, table)=>{
146
- const sessionDs = new VuuDataSource({
147
- columns: ds.columns,
148
- table,
149
- viewport: table.table
150
- });
151
- const handleOpenChangePrompt = (open)=>{
152
- if (!open) ds.unsubscribe();
153
- };
154
- const Component = getLayoutComponent(componentId);
155
- showPrompt(/*#__PURE__*/ jsx(Component, {
156
- dataSource: sessionDs
157
- }), {
158
- title: "Confirm operation on selected rows",
159
- onOpenChange: handleOpenChangePrompt
160
- });
161
- }, [
162
- VuuDataSource,
163
- showPrompt
164
- ]);
165
- const showSessionEditingForm = useCallback(async (ds, action)=>{
166
- const { tableSchema } = action;
167
- if (tableSchema) {
168
- const formConfig = getFormConfig(action);
169
- showDialog(/*#__PURE__*/ jsx(SessionEditingForm, {
170
- ...formConfig,
171
- onClose: closeDialog
172
- }), "Set Parameters");
173
- }
174
- const sessionDs = await ds.createSessionDataSource?.(action.table);
175
- const handleSubmit = ()=>{
176
- sessionDs?.rpcRequest?.({
177
- params: {
178
- save: true
179
- },
180
- rpcName: "endEditSession",
181
- type: "RPC_REQUEST"
182
- });
183
- closeDialog();
184
- };
185
- if (sessionDs) showDialog(/*#__PURE__*/ jsx(BulkEditPanel, {
186
- sessionDs: sessionDs,
187
- onSubmit: handleSubmit,
188
- parentDs: ds
189
- }), "Multi Row Edit", [
190
- /*#__PURE__*/ jsx(Button, {
191
- onClick: closeDialog,
192
- children: "Cancel"
193
- }, "cancel"),
194
- /*#__PURE__*/ jsx(Button, {
195
- onClick: handleSubmit,
196
- children: "Save"
197
- }, "submit")
198
- ]);
199
- }, [
200
- closeDialog,
201
- showDialog
202
- ]);
203
- const getMenuRpcRequest = (options)=>{
204
- const { rpcName } = options;
205
- if (isCellMenu(options)) return {
206
- field: options.field,
207
- rowKey: options.rowKey,
208
- rpcName,
209
- value: options.value,
210
- type: "VIEW_PORT_MENU_CELL_RPC"
211
- };
212
- if (isRowMenu(options)) return {
213
- rowKey: options.rowKey,
214
- row: options.row,
215
- rpcName,
216
- type: "VIEW_PORT_MENU_ROW_RPC"
217
- };
218
- if (isSelectionMenu(options)) return {
219
- rpcName,
220
- type: "VIEW_PORT_MENUS_SELECT_RPC"
221
- };
222
- return {
223
- rpcName,
224
- type: "VIEW_PORT_MENU_TABLE_RPC"
225
- };
226
- };
227
- const menuActionHandler = useCallback((menuItemId, options)=>{
228
- if (clientSideMenuActionHandler?.(menuItemId, options)) return true;
229
- if ("MENU_RPC_CALL" === menuItemId) {
230
- const rpcRequest = getMenuRpcRequest(options);
231
- dataSource?.menuRpcCall(rpcRequest).then((rpcResponse)=>{
232
- if (rpcResponse) {
233
- if (onRpcResponse?.(rpcResponse) === true) return true;
234
- if (isActionMessage(rpcResponse)) {
235
- if (hasShowNotificationAction(rpcResponse)) {
236
- const { action: { message, title = "Success" } } = rpcResponse;
237
- showNotification({
238
- status: "success",
239
- content: message,
240
- header: title,
241
- type: NotificationType.Toast
242
- });
243
- } else if (isSessionTableActionMessage(rpcResponse)) showSessionEditingForm(dataSource, rpcResponse.action);
244
- else if (isCustomComponentActionMessage(rpcResponse)) showCustomComponentInDialog(rpcResponse.action.renderComponent, dataSource, rpcResponse.action.table);
245
- }
246
- }
247
- });
248
- return true;
249
- }
250
- if ("link-table" === menuItemId) {
251
- if (dataSource) dataSource.visualLink = options;
252
- return true;
253
- }
254
- console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
255
- return false;
256
- }, [
257
- clientSideMenuActionHandler,
258
- dataSource,
259
- onRpcResponse,
260
- showCustomComponentInDialog,
261
- showNotification,
262
- showSessionEditingForm
263
- ]);
264
- return {
265
- menuBuilder,
266
- menuActionHandler
267
- };
268
- };
269
- export { isRowMenu, isSelectionMenu, useVuuMenuActions };
@@ -1,32 +0,0 @@
1
- import { useData } from "@vuu-ui/vuu-utils";
2
- import { useCallback, useEffect, useState } from "react";
3
- const useVuuTables = ()=>{
4
- const [tableSchemas, setTableSchemas] = useState();
5
- const { getServerAPI } = useData();
6
- const buildTables = useCallback((schemas)=>{
7
- const vuuTables = new Map();
8
- schemas.forEach((schema)=>{
9
- const { module, table } = schema.table;
10
- vuuTables.set(`${module}:${table}`, schema);
11
- });
12
- return vuuTables;
13
- }, []);
14
- useEffect(()=>{
15
- async function fetchTableMetadata() {
16
- try {
17
- const server = await getServerAPI();
18
- const { tables } = await server.getTableList();
19
- const tableSchemas = await Promise.all(tables.map((vuuTable)=>server.getTableSchema(vuuTable)));
20
- setTableSchemas(tableSchemas);
21
- } catch (err) {
22
- console.warn(`useVuuTables: error fetching table metadata ${String(err)}`);
23
- }
24
- }
25
- fetchTableMetadata();
26
- }, [
27
- buildTables,
28
- getServerAPI
29
- ]);
30
- return tableSchemas;
31
- };
32
- export { useVuuTables };
package/src/index.js DELETED
@@ -1,10 +0,0 @@
1
- export * from "./data-editing/index.js";
2
- export * from "./datasource-provider/index.js";
3
- export * from "./session-editing-form/index.js";
4
- export { useLookupValues } from "./hooks/useLookupValues.js";
5
- export { useSessionDataSource } from "./hooks/useSessionDataSource.js";
6
- export { getTypeaheadParams, useTypeaheadSuggestions } from "./hooks/useTypeaheadSuggestions.js";
7
- export { useVisualLinks } from "./hooks/useVisualLinks.js";
8
- export { isRowMenu, isSelectionMenu, useVuuMenuActions } from "./hooks/useVuuMenuActions.js";
9
- export { useVuuTables } from "./hooks/useVuuTables.js";
10
- export { useLostConnection } from "./lost-connection-indicator/useLostConnection.js";
@@ -1,29 +0,0 @@
1
- const css = `
2
- .vuuLostConnectionIndicator {
3
- --spinner-color: var(--vuuSpinner-color, #e23434);
4
- align-items: center;
5
- gap: var(--salt-spacing-300);
6
- flex-direction: column;
7
- justify-content: center;
8
- display: flex;
9
-
10
- & .vuuLostConnectionIndicator-spinner {
11
- background: radial-gradient(farthest-side,var(--spinner-color) 94%,#0000) top/9px 9px no-repeat,
12
- conic-gradient(#0000 30%,var(--spinner-color));
13
- border-radius: 50%;
14
- width: 75px;
15
- height: 75px;
16
- animation: 1s linear infinite spinner-rounded-comet-anim;
17
- mask: radial-gradient(farthest-side, #0000 calc(100% - 4px), #000 0);
18
- }
19
- }
20
-
21
- @keyframes spinner-rounded-comet-anim {
22
- 100% {
23
- transform: rotate(1turn);
24
- }
25
- }
26
-
27
-
28
- `;
29
- export default css;
@@ -1,30 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useComponentCssInjection } from "@salt-ds/styles";
3
- import { useWindow } from "@salt-ds/window";
4
- import LostConnectionIndicator from "./LostConnectionIndicator.css";
5
- const classBase = "vuuLostConnectionIndicator";
6
- const LostConnectionIndicator_LostConnectionIndicator = ()=>{
7
- const targetWindow = useWindow();
8
- useComponentCssInjection({
9
- testId: "vuu-toast-notification",
10
- css: LostConnectionIndicator,
11
- window: targetWindow
12
- });
13
- return /*#__PURE__*/ jsxs("div", {
14
- className: classBase,
15
- children: [
16
- /*#__PURE__*/ jsx("h2", {
17
- className: `${classBase}-title`,
18
- children: "CONNECTION LOST"
19
- }),
20
- /*#__PURE__*/ jsx("div", {
21
- className: `${classBase}-spinner`
22
- }),
23
- /*#__PURE__*/ jsx("h3", {
24
- className: `${classBase}-status`,
25
- children: "RECONNECTING"
26
- })
27
- ]
28
- });
29
- };
30
- export { LostConnectionIndicator_LostConnectionIndicator as LostConnectionIndicator };
@@ -1,28 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ConnectionManager, isConnected } from "@vuu-ui/vuu-data-remote";
3
- import { useCallback, useMemo, useRef } from "react";
4
- import { NotificationType, useNotifications } from "@vuu-ui/vuu-notifications";
5
- import { LostConnectionIndicator } from "./LostConnectionIndicator.js";
6
- const useLostConnection = ()=>{
7
- const { hideNotification, showNotification } = useNotifications();
8
- const isConnectedRef = useRef(ConnectionManager.connected);
9
- const handleConnectionStatusChange = useCallback((connectionStatus)=>{
10
- const { current: wasConnected } = isConnectedRef;
11
- isConnectedRef.current = isConnected(connectionStatus);
12
- if (wasConnected && "disconnected" === connectionStatus) showNotification({
13
- content: /*#__PURE__*/ jsx(LostConnectionIndicator, {}),
14
- status: "error",
15
- type: NotificationType.Workspace
16
- });
17
- else if (!wasConnected && isConnectedRef.current) hideNotification();
18
- }, [
19
- hideNotification,
20
- showNotification
21
- ]);
22
- useMemo(async ()=>{
23
- ConnectionManager.on("connection-status", handleConnectionStatusChange);
24
- }, [
25
- handleConnectionStatusChange
26
- ]);
27
- };
28
- export { useLostConnection };
@@ -1,47 +0,0 @@
1
- const css = `
2
- .vuuSessionEditingForm {
3
- flex-direction: column;
4
- gap: 3px;
5
- min-width: 400px;
6
- display: flex;
7
- }
8
-
9
- .vuuSessionEditingForm-content {
10
- padding: var(--salt-spacing-200);
11
- flex-direction: column;
12
- flex: auto;
13
- gap: 3px;
14
- display: flex;
15
- overflow: auto;
16
- }
17
-
18
- .vuuSessionEditingForm-fieldValue.vuuReadOnly {
19
- font-weight: var(--salt-text-label-fontWeight-strong);
20
- }
21
-
22
- .vuuSessionEditingForm-buttonbar {
23
- border-top: solid 1px var(--salt-container-primary-borderColor);
24
- box-sizing: content-box;
25
- flex: 0 0 autox;
26
- height: var(--salt-size-base);
27
- margin: var(--salt-spacing-200);
28
- padding-top: var(--salt-spacing-200);
29
- justify-content: flex-end;
30
- align-items: center;
31
- gap: 6px;
32
- display: flex;
33
- }
34
-
35
- .vuuSessionEditingForm-errorBanner {
36
- --vuu-icon-left: 3px;
37
- --vuu-icon-size: 18px;
38
- --vuu-icon-top: 3px;
39
- border: solid 1px var(--salt-status-error-borderColor);
40
- padding: 0 6px 0 26px;
41
- line-height: 24px;
42
- position: relative;
43
- }
44
-
45
-
46
- `;
47
- export default css;