@vuu-ui/vuu-data-react 3.3.10 → 4.0.0-alpha.1
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 +18 -17
- package/src/datasource-provider/VuuDataSourceProvider.js +18 -11
- package/src/hooks/useSessionDataSource.js +1 -1
- package/src/hooks/useVuuTables.js +2 -11
- package/types/data-editing/EditForm.d.ts +3 -3
- package/types/data-editing/UnsavedChangesReport.d.ts +1 -1
- package/types/data-editing/get-data-item-edit-control.d.ts +1 -1
- package/types/data-editing/useEditForm.d.ts +3 -3
- package/types/datasource-provider/VuuDataSourceProvider.d.ts +5 -14
- package/types/lost-connection-indicator/LostConnectionIndicator.d.ts +1 -1
- package/types/session-editing-form/SessionEditingForm.d.ts +1 -1
- package/src/datasource-provider/useAutoLoginToVuuServer.js +0 -42
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "4.0.0-alpha.1",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"build:dev": "node ../../scripts/run-build.mjs",
|
|
@@ -10,24 +11,25 @@
|
|
|
10
11
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
11
12
|
},
|
|
12
13
|
"devDependencies": {
|
|
13
|
-
"@vuu-ui/vuu-data-types": "
|
|
14
|
-
"@vuu-ui/vuu-filter-types": "
|
|
15
|
-
"@vuu-ui/vuu-protocol-types": "
|
|
16
|
-
"@vuu-ui/vuu-table-types": "
|
|
14
|
+
"@vuu-ui/vuu-data-types": "4.0.0-alpha.1",
|
|
15
|
+
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.1",
|
|
16
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.1",
|
|
17
|
+
"@vuu-ui/vuu-table-types": "4.0.0-alpha.1"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@vuu-ui/vuu-context-menu": "
|
|
20
|
-
"@vuu-ui/vuu-data-remote": "
|
|
21
|
-
"@vuu-ui/vuu-filter-parser": "
|
|
22
|
-
"@vuu-ui/vuu-filters": "
|
|
23
|
-
"@vuu-ui/vuu-layout": "
|
|
24
|
-
"@vuu-ui/vuu-notifications": "
|
|
25
|
-
"@vuu-ui/vuu-ui-controls": "
|
|
26
|
-
"@vuu-ui/vuu-utils": "
|
|
27
|
-
"@vuu-ui/vuu-table": "
|
|
28
|
-
"@salt-ds/core": "1.
|
|
20
|
+
"@vuu-ui/vuu-context-menu": "4.0.0-alpha.1",
|
|
21
|
+
"@vuu-ui/vuu-data-remote": "4.0.0-alpha.1",
|
|
22
|
+
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.1",
|
|
23
|
+
"@vuu-ui/vuu-filters": "4.0.0-alpha.1",
|
|
24
|
+
"@vuu-ui/vuu-layout": "4.0.0-alpha.1",
|
|
25
|
+
"@vuu-ui/vuu-notifications": "4.0.0-alpha.1",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "4.0.0-alpha.1",
|
|
27
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.1",
|
|
28
|
+
"@vuu-ui/vuu-table": "4.0.0-alpha.1",
|
|
29
|
+
"@salt-ds/core": "1.67.0",
|
|
29
30
|
"@salt-ds/styles": "0.2.1",
|
|
30
|
-
"@salt-ds/window": "0.1.1"
|
|
31
|
+
"@salt-ds/window": "0.1.1",
|
|
32
|
+
"@vuu-ui/core": "4.0.0-alpha.1"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"clsx": "^2.0.0",
|
|
@@ -47,6 +49,5 @@
|
|
|
47
49
|
},
|
|
48
50
|
"module": "./src/index.js",
|
|
49
51
|
"name": "@vuu-ui/vuu-data-react",
|
|
50
|
-
"type": "module",
|
|
51
52
|
"types": "types/index.d.ts"
|
|
52
53
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataProvider, useOptionalVuuConnectionId } from "@vuu-ui/core";
|
|
2
3
|
import { ConnectionManager, VuuDataSource } from "@vuu-ui/vuu-data-remote";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
const VuuDataSourceProvider = ({ children })=>{
|
|
6
|
+
const connectionId = useOptionalVuuConnectionId() ?? "portal";
|
|
7
|
+
const BoundVuuDataSource = useMemo(()=>class extends VuuDataSource {
|
|
8
|
+
constructor(props){
|
|
9
|
+
super({
|
|
10
|
+
...props,
|
|
11
|
+
connectionId
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}, [
|
|
15
|
+
connectionId
|
|
16
|
+
]);
|
|
17
|
+
const getServerAPI = useMemo(()=>()=>ConnectionManager.serverAPIFor(connectionId), [
|
|
18
|
+
connectionId
|
|
19
|
+
]);
|
|
13
20
|
return /*#__PURE__*/ jsx(DataProvider, {
|
|
14
|
-
VuuDataSource:
|
|
21
|
+
VuuDataSource: BoundVuuDataSource,
|
|
15
22
|
getServerAPI: getServerAPI,
|
|
16
23
|
isLocalData: false,
|
|
17
24
|
children: children
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { useData } from "@vuu-ui/
|
|
2
|
-
import {
|
|
1
|
+
import { useData } from "@vuu-ui/core";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
const useVuuTables = ()=>{
|
|
4
4
|
const [tableSchemas, setTableSchemas] = useState();
|
|
5
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
6
|
useEffect(()=>{
|
|
15
7
|
async function fetchTableMetadata() {
|
|
16
8
|
try {
|
|
@@ -24,7 +16,6 @@ const useVuuTables = ()=>{
|
|
|
24
16
|
}
|
|
25
17
|
fetchTableMetadata();
|
|
26
18
|
}, [
|
|
27
|
-
buildTables,
|
|
28
19
|
getServerAPI
|
|
29
20
|
]);
|
|
30
21
|
return tableSchemas;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLAttributes } from "react";
|
|
2
|
-
import { EditFormHookProps } from "./useEditForm";
|
|
1
|
+
import type { HTMLAttributes } from "react";
|
|
2
|
+
import { type EditFormHookProps } from "./useEditForm";
|
|
3
3
|
export interface EditFormProps extends EditFormHookProps, Omit<HTMLAttributes<HTMLDivElement>, "onSubmit"> {
|
|
4
4
|
}
|
|
5
|
-
export declare const EditForm: ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes }: EditFormProps) => import("react
|
|
5
|
+
export declare const EditForm: ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes }: EditFormProps) => import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ export interface UnsavedChangesReportProps<T extends Entity = Entity> {
|
|
|
3
3
|
entity: T;
|
|
4
4
|
editedEntity: T;
|
|
5
5
|
}
|
|
6
|
-
export declare const UnsavedChangesReport: ({ entity, editedEntity, }: UnsavedChangesReportProps) => import("react
|
|
6
|
+
export declare const UnsavedChangesReport: ({ entity, editedEntity, }: UnsavedChangesReportProps) => import("react").JSX.Element;
|
|
@@ -34,4 +34,4 @@ export interface DataItemEditControlProps {
|
|
|
34
34
|
variant?: FilterControlVariant;
|
|
35
35
|
}
|
|
36
36
|
export type ValidationStatus = "initial" | true | string;
|
|
37
|
-
export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react
|
|
37
|
+
export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataSource, DataValueDescriptor } from "@vuu-ui/vuu-data-types";
|
|
2
|
-
import { CommitHandler, Entity } from "@vuu-ui/vuu-utils";
|
|
3
|
-
import {
|
|
2
|
+
import { type CommitHandler, type Entity } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { type ChangeEventHandler, type FocusEventHandler } from "react";
|
|
4
4
|
export interface EditFormHookProps {
|
|
5
5
|
dataSource?: DataSource;
|
|
6
6
|
formFieldDescriptors: DataValueDescriptor[];
|
|
@@ -14,7 +14,7 @@ export declare const useEditForm: ({ dataSource, formFieldDescriptors, onSubmit,
|
|
|
14
14
|
isClean: boolean;
|
|
15
15
|
ok: boolean;
|
|
16
16
|
onCancel: () => Promise<void>;
|
|
17
|
-
onChange:
|
|
17
|
+
onChange: ChangeEventHandler<HTMLElement>;
|
|
18
18
|
onCommit: CommitHandler<HTMLElement>;
|
|
19
19
|
onFocus: FocusEventHandler;
|
|
20
20
|
onSubmit: () => Promise<void>;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* VuuDataSource, which will source data from a remote vuu server.
|
|
6
|
-
*
|
|
7
|
-
* In production code, it will generally be used without props, authentication
|
|
8
|
-
* and connection to vuu server will be handled elsewhere. The props are
|
|
9
|
-
* useful for rendering standalone components.
|
|
3
|
+
* Supplies the standard VUU data-source implementation. Authentication and
|
|
4
|
+
* websocket lifecycle are handled by AuthenticationProvider.
|
|
10
5
|
*/
|
|
11
|
-
export declare const VuuDataSourceProvider: ({
|
|
12
|
-
authenticate?: boolean;
|
|
13
|
-
autoConnect?: boolean;
|
|
14
|
-
autoLogin?: boolean;
|
|
6
|
+
export declare const VuuDataSourceProvider: ({ children, }: {
|
|
15
7
|
children: ReactNode;
|
|
16
|
-
|
|
17
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LostConnectionIndicator: () => import("react
|
|
1
|
+
export declare const LostConnectionIndicator: () => import("react").JSX.Element;
|
|
@@ -21,4 +21,4 @@ export interface SessionEditingFormProps extends HTMLAttributes<HTMLDivElement>
|
|
|
21
21
|
dataSource?: DataSource;
|
|
22
22
|
schema?: TableSchema;
|
|
23
23
|
}
|
|
24
|
-
export declare const SessionEditingForm: ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes }: SessionEditingFormProps) => import("react
|
|
24
|
+
export declare const SessionEditingForm: ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes }: SessionEditingFormProps) => import("react").JSX.Element;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ConnectionManager, authenticate as vuu_data_remote_authenticate } from "@vuu-ui/vuu-data-remote";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
const useAutoLoginToVuuServer = ({ authenticate = true, autoConnect = true, secure = true, token: tokenProp = "no-token", user = "steve", websocketUrl } = {})=>{
|
|
5
|
-
const [errorMessage, setErrorMessage] = useState("");
|
|
6
|
-
useEffect(()=>{
|
|
7
|
-
const connect = async ()=>{
|
|
8
|
-
try {
|
|
9
|
-
let token = tokenProp;
|
|
10
|
-
if (authenticate) {
|
|
11
|
-
const response = await vuu_data_remote_authenticate(user, "xyz", "/api/authn");
|
|
12
|
-
token = response.token;
|
|
13
|
-
}
|
|
14
|
-
const url = websocketUrl ?? `${secure ? "wss" : "ws"}://localhost/8090/websocket`;
|
|
15
|
-
ConnectionManager.connect({
|
|
16
|
-
url,
|
|
17
|
-
token
|
|
18
|
-
});
|
|
19
|
-
} catch (e) {
|
|
20
|
-
if (e instanceof Error) {
|
|
21
|
-
console.error(e.message);
|
|
22
|
-
setErrorMessage(e.message);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
if (autoConnect) connect();
|
|
27
|
-
return ()=>{
|
|
28
|
-
if (autoConnect) ConnectionManager.disconnect();
|
|
29
|
-
};
|
|
30
|
-
}, [
|
|
31
|
-
authenticate,
|
|
32
|
-
autoConnect,
|
|
33
|
-
secure,
|
|
34
|
-
tokenProp,
|
|
35
|
-
user,
|
|
36
|
-
websocketUrl
|
|
37
|
-
]);
|
|
38
|
-
if (errorMessage) return /*#__PURE__*/ jsx("p", {
|
|
39
|
-
children: "Unable to authenticate against Vuu Server A Vuu Server instance must be running to show this example."
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
export { useAutoLoginToVuuServer };
|