@vuu-ui/vuu-data-react 0.13.4 → 0.13.6
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/hooks/useSessionDataSource.js +7 -3
- package/cjs/hooks/useSessionDataSource.js.map +1 -1
- package/esm/hooks/useSessionDataSource.js +8 -4
- package/esm/hooks/useSessionDataSource.js.map +1 -1
- package/package.json +20 -17
- package/types/data-editing/EditForm.d.ts +5 -0
- package/types/data-editing/UnsavedChangesReport.d.ts +6 -0
- package/types/data-editing/edit-rule-validation-checker.d.ts +4 -0
- package/types/data-editing/edit-validation-rules.d.ts +1 -0
- package/types/data-editing/form-edit-state.d.ts +7 -0
- package/types/data-editing/get-data-item-edit-control.d.ts +18 -0
- package/types/data-editing/index.d.ts +6 -0
- package/types/data-editing/useEditForm.d.ts +21 -0
- package/types/datasource-provider/RestDataSourceProvider.d.ts +11 -0
- package/types/datasource-provider/VuuDataSourceProvider.d.ts +8 -0
- package/types/datasource-provider/index.d.ts +2 -0
- package/types/datasource-provider/useAutoLoginToVuuServer.d.ts +7 -0
- package/types/hooks/index.d.ts +6 -0
- package/types/hooks/useLookupValues.d.ts +5 -0
- package/types/hooks/useSessionDataSource.d.ts +5 -0
- package/types/hooks/useTypeaheadSuggestions.d.ts +4 -0
- package/types/hooks/useVisualLinks.d.ts +2 -0
- package/types/hooks/useVuuMenuActions.d.ts +44 -0
- package/types/hooks/useVuuTables.d.ts +2 -0
- package/types/index.d.ts +4 -0
- package/types/session-editing-form/SessionEditingForm.d.ts +24 -0
- package/types/session-editing-form/index.d.ts +1 -0
|
@@ -12,19 +12,23 @@ const useSessionDataSource = ({
|
|
|
12
12
|
const { id, load, save, loadSession, saveSession, title } = vuuLayout.useViewContext();
|
|
13
13
|
const { VuuDataSource } = vuuUtils.useData();
|
|
14
14
|
const { "datasource-config": dataSourceConfigFromState } = react.useMemo(() => load?.() ?? NO_CONFIG, [load]);
|
|
15
|
+
const dataSourceConfigRef = react.useRef(
|
|
16
|
+
dataSourceConfigFromState
|
|
17
|
+
);
|
|
15
18
|
const handleDataSourceConfigChange = react.useCallback(
|
|
16
19
|
(config, _range, confirmed) => {
|
|
17
20
|
if (confirmed !== false) {
|
|
18
21
|
const { noChanges } = vuuUtils.isConfigChanged(
|
|
19
|
-
|
|
22
|
+
dataSourceConfigRef.current,
|
|
20
23
|
config
|
|
21
24
|
);
|
|
22
25
|
if (noChanges === false) {
|
|
26
|
+
dataSourceConfigRef.current = config;
|
|
23
27
|
save?.(config, "datasource-config");
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
|
-
[
|
|
31
|
+
[save]
|
|
28
32
|
);
|
|
29
33
|
const dataSource = react.useMemo(() => {
|
|
30
34
|
let ds = loadSession?.(dataSourceSessionKey);
|
|
@@ -42,7 +46,7 @@ const useSessionDataSource = ({
|
|
|
42
46
|
// bufferSize: 0,
|
|
43
47
|
viewport: id,
|
|
44
48
|
table: tableSchema.table,
|
|
45
|
-
...
|
|
49
|
+
...dataSourceConfigRef.current,
|
|
46
50
|
columns,
|
|
47
51
|
title
|
|
48
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionDataSource.js","sources":["../../src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo } from \"react\";\n\ntype
|
|
1
|
+
{"version":3,"file":"useSessionDataSource.js","sources":["../../src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\ntype SessionState = {\n \"datasource-config\"?: DataSourceConfig;\n};\n\nconst NO_CONFIG: SessionState = {};\n\nexport const useSessionDataSource = ({\n dataSourceSessionKey = \"data-source\",\n tableSchema,\n}: {\n dataSourceSessionKey?: string;\n tableSchema: TableSchema;\n}) => {\n const { id, load, save, loadSession, saveSession, title } = useViewContext();\n const { VuuDataSource } = useData();\n\n const { \"datasource-config\": dataSourceConfigFromState } =\n useMemo<SessionState>(() => load?.() ?? NO_CONFIG, [load]);\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(\n dataSourceConfigFromState,\n );\n\n const handleDataSourceConfigChange =\n useCallback<DataSourceConfigChangeHandler>(\n (\n config: DataSourceConfig | undefined,\n _range: VuuRange,\n confirmed?: boolean,\n ) => {\n if (confirmed !== false) {\n const { noChanges } = isConfigChanged(\n dataSourceConfigRef.current,\n config,\n );\n if (noChanges === false) {\n dataSourceConfigRef.current = config;\n save?.(config, \"datasource-config\");\n }\n }\n },\n [save],\n );\n\n const dataSource: DataSource = useMemo(() => {\n let ds = loadSession?.(dataSourceSessionKey) as DataSource;\n if (ds) {\n if (dataSourceConfigFromState) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // DO we definitely need this ? If not apply config can be provate\n ds.applyConfig(dataSourceConfigFromState, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n\n return ds;\n }\n\n const columns =\n dataSourceConfigFromState?.columns ??\n tableSchema.columns.map((col) => col.name);\n\n ds = new VuuDataSource({\n // bufferSize: 0,\n viewport: id,\n table: tableSchema.table,\n ...dataSourceConfigRef.current,\n columns,\n title,\n });\n ds.on(\"config\", handleDataSourceConfigChange);\n saveSession?.(ds, \"data-source\");\n return ds;\n }, [\n VuuDataSource,\n dataSourceConfigFromState,\n dataSourceSessionKey,\n handleDataSourceConfigChange,\n id,\n loadSession,\n saveSession,\n tableSchema.columns,\n tableSchema.table,\n title,\n ]);\n\n return dataSource;\n};\n"],"names":["useViewContext","useData","useMemo","useRef","useCallback","isConfigChanged"],"mappings":";;;;;;AAeA,MAAM,YAA0B,EAAC;AAE1B,MAAM,uBAAuB,CAAC;AAAA,EACnC,oBAAuB,GAAA,aAAA;AAAA,EACvB;AACF,CAGM,KAAA;AACJ,EAAM,MAAA,EAAE,IAAI,IAAM,EAAA,IAAA,EAAM,aAAa,WAAa,EAAA,KAAA,KAAUA,wBAAe,EAAA;AAC3E,EAAM,MAAA,EAAE,aAAc,EAAA,GAAIC,gBAAQ,EAAA;AAElC,EAAM,MAAA,EAAE,mBAAqB,EAAA,yBAAA,EAC3B,GAAAC,aAAA,CAAsB,MAAM,IAAA,IAAY,IAAA,SAAA,EAAW,CAAC,IAAI,CAAC,CAAA;AAE3D,EAAA,MAAM,mBAAsB,GAAAC,YAAA;AAAA,IAC1B;AAAA,GACF;AAEA,EAAA,MAAM,4BACJ,GAAAC,iBAAA;AAAA,IACE,CACE,MACA,EAAA,MAAA,EACA,SACG,KAAA;AACH,MAAA,IAAI,cAAc,KAAO,EAAA;AACvB,QAAM,MAAA,EAAE,WAAc,GAAAC,wBAAA;AAAA,UACpB,mBAAoB,CAAA,OAAA;AAAA,UACpB;AAAA,SACF;AACA,QAAA,IAAI,cAAc,KAAO,EAAA;AACvB,UAAA,mBAAA,CAAoB,OAAU,GAAA,MAAA;AAC9B,UAAA,IAAA,GAAO,QAAQ,mBAAmB,CAAA;AAAA;AACpC;AACF,KACF;AAAA,IACA,CAAC,IAAI;AAAA,GACP;AAEF,EAAM,MAAA,UAAA,GAAyBH,cAAQ,MAAM;AAC3C,IAAI,IAAA,EAAA,GAAK,cAAc,oBAAoB,CAAA;AAC3C,IAAA,IAAI,EAAI,EAAA;AACN,MAAA,IAAI,yBAA2B,EAAA;AAK7B,QAAG,EAAA,CAAA,WAAA,CAAY,2BAA2B,IAAI,CAAA;AAAA;AAGhD,MAAI,IAAA,EAAA,CAAG,KAAM,CAAA,IAAA,GAAO,CAAG,EAAA;AAErB,QAAG,EAAA,CAAA,KAAA,GAAQ,GAAG,KAAM,CAAA,KAAA;AAAA;AAGtB,MAAO,OAAA,EAAA;AAAA;AAGT,IAAM,MAAA,OAAA,GACJ,2BAA2B,OAC3B,IAAA,WAAA,CAAY,QAAQ,GAAI,CAAA,CAAC,GAAQ,KAAA,GAAA,CAAI,IAAI,CAAA;AAE3C,IAAA,EAAA,GAAK,IAAI,aAAc,CAAA;AAAA;AAAA,MAErB,QAAU,EAAA,EAAA;AAAA,MACV,OAAO,WAAY,CAAA,KAAA;AAAA,MACnB,GAAG,mBAAoB,CAAA,OAAA;AAAA,MACvB,OAAA;AAAA,MACA;AAAA,KACD,CAAA;AACD,IAAG,EAAA,CAAA,EAAA,CAAG,UAAU,4BAA4B,CAAA;AAC5C,IAAA,WAAA,GAAc,IAAI,aAAa,CAAA;AAC/B,IAAO,OAAA,EAAA;AAAA,GACN,EAAA;AAAA,IACD,aAAA;AAAA,IACA,yBAAA;AAAA,IACA,oBAAA;AAAA,IACA,4BAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAY,CAAA,OAAA;AAAA,IACZ,WAAY,CAAA,KAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAO,OAAA,UAAA;AACT;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useViewContext } from '@vuu-ui/vuu-layout';
|
|
2
2
|
import { useData, isConfigChanged } from '@vuu-ui/vuu-utils';
|
|
3
|
-
import { useMemo, useCallback } from 'react';
|
|
3
|
+
import { useMemo, useRef, useCallback } from 'react';
|
|
4
4
|
|
|
5
5
|
const NO_CONFIG = {};
|
|
6
6
|
const useSessionDataSource = ({
|
|
@@ -10,19 +10,23 @@ const useSessionDataSource = ({
|
|
|
10
10
|
const { id, load, save, loadSession, saveSession, title } = useViewContext();
|
|
11
11
|
const { VuuDataSource } = useData();
|
|
12
12
|
const { "datasource-config": dataSourceConfigFromState } = useMemo(() => load?.() ?? NO_CONFIG, [load]);
|
|
13
|
+
const dataSourceConfigRef = useRef(
|
|
14
|
+
dataSourceConfigFromState
|
|
15
|
+
);
|
|
13
16
|
const handleDataSourceConfigChange = useCallback(
|
|
14
17
|
(config, _range, confirmed) => {
|
|
15
18
|
if (confirmed !== false) {
|
|
16
19
|
const { noChanges } = isConfigChanged(
|
|
17
|
-
|
|
20
|
+
dataSourceConfigRef.current,
|
|
18
21
|
config
|
|
19
22
|
);
|
|
20
23
|
if (noChanges === false) {
|
|
24
|
+
dataSourceConfigRef.current = config;
|
|
21
25
|
save?.(config, "datasource-config");
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
|
-
[
|
|
29
|
+
[save]
|
|
26
30
|
);
|
|
27
31
|
const dataSource = useMemo(() => {
|
|
28
32
|
let ds = loadSession?.(dataSourceSessionKey);
|
|
@@ -40,7 +44,7 @@ const useSessionDataSource = ({
|
|
|
40
44
|
// bufferSize: 0,
|
|
41
45
|
viewport: id,
|
|
42
46
|
table: tableSchema.table,
|
|
43
|
-
...
|
|
47
|
+
...dataSourceConfigRef.current,
|
|
44
48
|
columns,
|
|
45
49
|
title
|
|
46
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionDataSource.js","sources":["../../src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo } from \"react\";\n\ntype
|
|
1
|
+
{"version":3,"file":"useSessionDataSource.js","sources":["../../src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\ntype SessionState = {\n \"datasource-config\"?: DataSourceConfig;\n};\n\nconst NO_CONFIG: SessionState = {};\n\nexport const useSessionDataSource = ({\n dataSourceSessionKey = \"data-source\",\n tableSchema,\n}: {\n dataSourceSessionKey?: string;\n tableSchema: TableSchema;\n}) => {\n const { id, load, save, loadSession, saveSession, title } = useViewContext();\n const { VuuDataSource } = useData();\n\n const { \"datasource-config\": dataSourceConfigFromState } =\n useMemo<SessionState>(() => load?.() ?? NO_CONFIG, [load]);\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(\n dataSourceConfigFromState,\n );\n\n const handleDataSourceConfigChange =\n useCallback<DataSourceConfigChangeHandler>(\n (\n config: DataSourceConfig | undefined,\n _range: VuuRange,\n confirmed?: boolean,\n ) => {\n if (confirmed !== false) {\n const { noChanges } = isConfigChanged(\n dataSourceConfigRef.current,\n config,\n );\n if (noChanges === false) {\n dataSourceConfigRef.current = config;\n save?.(config, \"datasource-config\");\n }\n }\n },\n [save],\n );\n\n const dataSource: DataSource = useMemo(() => {\n let ds = loadSession?.(dataSourceSessionKey) as DataSource;\n if (ds) {\n if (dataSourceConfigFromState) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // DO we definitely need this ? If not apply config can be provate\n ds.applyConfig(dataSourceConfigFromState, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n\n return ds;\n }\n\n const columns =\n dataSourceConfigFromState?.columns ??\n tableSchema.columns.map((col) => col.name);\n\n ds = new VuuDataSource({\n // bufferSize: 0,\n viewport: id,\n table: tableSchema.table,\n ...dataSourceConfigRef.current,\n columns,\n title,\n });\n ds.on(\"config\", handleDataSourceConfigChange);\n saveSession?.(ds, \"data-source\");\n return ds;\n }, [\n VuuDataSource,\n dataSourceConfigFromState,\n dataSourceSessionKey,\n handleDataSourceConfigChange,\n id,\n loadSession,\n saveSession,\n tableSchema.columns,\n tableSchema.table,\n title,\n ]);\n\n return dataSource;\n};\n"],"names":[],"mappings":";;;;AAeA,MAAM,YAA0B,EAAC;AAE1B,MAAM,uBAAuB,CAAC;AAAA,EACnC,oBAAuB,GAAA,aAAA;AAAA,EACvB;AACF,CAGM,KAAA;AACJ,EAAM,MAAA,EAAE,IAAI,IAAM,EAAA,IAAA,EAAM,aAAa,WAAa,EAAA,KAAA,KAAU,cAAe,EAAA;AAC3E,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,OAAQ,EAAA;AAElC,EAAM,MAAA,EAAE,mBAAqB,EAAA,yBAAA,EAC3B,GAAA,OAAA,CAAsB,MAAM,IAAA,IAAY,IAAA,SAAA,EAAW,CAAC,IAAI,CAAC,CAAA;AAE3D,EAAA,MAAM,mBAAsB,GAAA,MAAA;AAAA,IAC1B;AAAA,GACF;AAEA,EAAA,MAAM,4BACJ,GAAA,WAAA;AAAA,IACE,CACE,MACA,EAAA,MAAA,EACA,SACG,KAAA;AACH,MAAA,IAAI,cAAc,KAAO,EAAA;AACvB,QAAM,MAAA,EAAE,WAAc,GAAA,eAAA;AAAA,UACpB,mBAAoB,CAAA,OAAA;AAAA,UACpB;AAAA,SACF;AACA,QAAA,IAAI,cAAc,KAAO,EAAA;AACvB,UAAA,mBAAA,CAAoB,OAAU,GAAA,MAAA;AAC9B,UAAA,IAAA,GAAO,QAAQ,mBAAmB,CAAA;AAAA;AACpC;AACF,KACF;AAAA,IACA,CAAC,IAAI;AAAA,GACP;AAEF,EAAM,MAAA,UAAA,GAAyB,QAAQ,MAAM;AAC3C,IAAI,IAAA,EAAA,GAAK,cAAc,oBAAoB,CAAA;AAC3C,IAAA,IAAI,EAAI,EAAA;AACN,MAAA,IAAI,yBAA2B,EAAA;AAK7B,QAAG,EAAA,CAAA,WAAA,CAAY,2BAA2B,IAAI,CAAA;AAAA;AAGhD,MAAI,IAAA,EAAA,CAAG,KAAM,CAAA,IAAA,GAAO,CAAG,EAAA;AAErB,QAAG,EAAA,CAAA,KAAA,GAAQ,GAAG,KAAM,CAAA,KAAA;AAAA;AAGtB,MAAO,OAAA,EAAA;AAAA;AAGT,IAAM,MAAA,OAAA,GACJ,2BAA2B,OAC3B,IAAA,WAAA,CAAY,QAAQ,GAAI,CAAA,CAAC,GAAQ,KAAA,GAAA,CAAI,IAAI,CAAA;AAE3C,IAAA,EAAA,GAAK,IAAI,aAAc,CAAA;AAAA;AAAA,MAErB,QAAU,EAAA,EAAA;AAAA,MACV,OAAO,WAAY,CAAA,KAAA;AAAA,MACnB,GAAG,mBAAoB,CAAA,OAAA;AAAA,MACvB,OAAA;AAAA,MACA;AAAA,KACD,CAAA;AACD,IAAG,EAAA,CAAA,EAAA,CAAG,UAAU,4BAA4B,CAAA;AAC5C,IAAA,WAAA,GAAc,IAAI,aAAa,CAAA;AAC/B,IAAO,OAAA,EAAA;AAAA,GACN,EAAA;AAAA,IACD,aAAA;AAAA,IACA,yBAAA;AAAA,IACA,oBAAA;AAAA,IACA,4BAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAY,CAAA,OAAA;AAAA,IACZ,WAAY,CAAA,KAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAO,OAAA,UAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.6",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
7
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
8
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "0.13.6",
|
|
7
|
+
"@vuu-ui/vuu-filter-types": "0.13.6",
|
|
8
|
+
"@vuu-ui/vuu-popups": "0.13.6",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.13.6",
|
|
10
|
+
"@vuu-ui/vuu-table-types": "0.13.6"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@vuu-ui/vuu-context-menu": "0.13.
|
|
14
|
-
"@vuu-ui/vuu-data-remote": "0.13.
|
|
15
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
16
|
-
"@vuu-ui/vuu-layout": "0.13.
|
|
17
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
18
|
-
"@vuu-ui/vuu-ui-controls": "0.13.
|
|
19
|
-
"@vuu-ui/vuu-utils": "0.13.
|
|
20
|
-
"@vuu-ui/vuu-table": "0.13.
|
|
13
|
+
"@vuu-ui/vuu-context-menu": "0.13.6",
|
|
14
|
+
"@vuu-ui/vuu-data-remote": "0.13.6",
|
|
15
|
+
"@vuu-ui/vuu-filter-parser": "0.13.6",
|
|
16
|
+
"@vuu-ui/vuu-layout": "0.13.6",
|
|
17
|
+
"@vuu-ui/vuu-popups": "0.13.6",
|
|
18
|
+
"@vuu-ui/vuu-ui-controls": "0.13.6",
|
|
19
|
+
"@vuu-ui/vuu-utils": "0.13.6",
|
|
20
|
+
"@vuu-ui/vuu-table": "0.13.6",
|
|
21
21
|
"@salt-ds/core": "1.43.0",
|
|
22
22
|
"@salt-ds/styles": "0.2.1",
|
|
23
23
|
"@salt-ds/window": "0.1.1"
|
|
@@ -30,16 +30,19 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"README.md",
|
|
32
32
|
"esm",
|
|
33
|
-
"cjs"
|
|
33
|
+
"cjs",
|
|
34
|
+
"/types"
|
|
34
35
|
],
|
|
35
36
|
"exports": {
|
|
36
37
|
".": {
|
|
37
38
|
"require": "./cjs/index.js",
|
|
38
|
-
"import": "./esm/index.js"
|
|
39
|
+
"import": "./esm/index.js",
|
|
40
|
+
"types": "./types/index.d.ts"
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
"main": "cjs/index.js",
|
|
42
44
|
"module": "esm/index.js",
|
|
43
45
|
"name": "@vuu-ui/vuu-data-react",
|
|
44
|
-
"type": "module"
|
|
46
|
+
"type": "module",
|
|
47
|
+
"types": "types/index.d.ts"
|
|
45
48
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
import { EditFormHookProps } from "./useEditForm";
|
|
3
|
+
export interface EditFormProps extends EditFormHookProps, Omit<HTMLAttributes<HTMLDivElement>, "onSubmit"> {
|
|
4
|
+
}
|
|
5
|
+
export declare const EditForm: ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes }: EditFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Entity } from "@vuu-ui/vuu-utils";
|
|
2
|
+
export interface UnsavedChangesReportProps<T extends Entity = Entity> {
|
|
3
|
+
entity: T;
|
|
4
|
+
editedEntity: T;
|
|
5
|
+
}
|
|
6
|
+
export declare const UnsavedChangesReport: ({ entity, editedEntity, }: UnsavedChangesReportProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataValueDescriptor, DataValueValidationChecker, EditPhase, EditRuleValidationSuccessResult, EditValidationRule } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
export declare const OK: EditRuleValidationSuccessResult;
|
|
3
|
+
export declare function getEditValidationRules(descriptor: DataValueDescriptor, editPhase: EditPhase | "*"): EditValidationRule[];
|
|
4
|
+
export declare const buildValidationChecker: (rules: EditValidationRule[]) => DataValueValidationChecker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const registerRules: () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Entity } from "@vuu-ui/vuu-utils";
|
|
2
|
+
export type FormEditState = {
|
|
3
|
+
isClean: boolean;
|
|
4
|
+
editedFields: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const CLEAN_FORM: FormEditState;
|
|
7
|
+
export declare const buildFormEditState: (entity: Entity | undefined, newEntity: Entity) => FormEditState;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DataValueDescriptor, TableSchemaTable } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { VuuTypeaheadInputProps } from "@vuu-ui/vuu-ui-controls";
|
|
3
|
+
import { CommitHandler } from "@vuu-ui/vuu-utils";
|
|
4
|
+
import { InputProps } from "@salt-ds/core";
|
|
5
|
+
export interface DataItemEditControlProps {
|
|
6
|
+
InputProps?: Partial<InputProps>;
|
|
7
|
+
TypeaheadProps?: Pick<VuuTypeaheadInputProps, "highlightFirstSuggestion">;
|
|
8
|
+
commitWhenCleared?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A table column or form field Descriptor.
|
|
11
|
+
*/
|
|
12
|
+
dataDescriptor: DataValueDescriptor;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
onCommit: CommitHandler<HTMLElement>;
|
|
15
|
+
table?: TableSchemaTable;
|
|
16
|
+
}
|
|
17
|
+
export type ValidationStatus = "initial" | true | string;
|
|
18
|
+
export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, commitWhenCleared, dataDescriptor, errorMessage, onCommit, table, }: DataItemEditControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DataSource, DataValueDescriptor } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { CommitHandler, Entity } from "@vuu-ui/vuu-utils";
|
|
3
|
+
import { FocusEventHandler, SyntheticEvent } from "react";
|
|
4
|
+
export interface EditFormHookProps {
|
|
5
|
+
dataSource?: DataSource;
|
|
6
|
+
formFieldDescriptors: DataValueDescriptor[];
|
|
7
|
+
onSubmit?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useEditForm: ({ dataSource, formFieldDescriptors, onSubmit, }: EditFormHookProps) => {
|
|
10
|
+
editedFields: string[];
|
|
11
|
+
editEntity: Entity | undefined;
|
|
12
|
+
errorMessages: Record<string, string>;
|
|
13
|
+
formFieldsContainerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
14
|
+
isClean: boolean;
|
|
15
|
+
ok: boolean;
|
|
16
|
+
onCancel: () => Promise<void>;
|
|
17
|
+
onChange: (evt: SyntheticEvent<HTMLInputElement>) => void;
|
|
18
|
+
onCommit: CommitHandler<HTMLElement>;
|
|
19
|
+
onFocus: FocusEventHandler;
|
|
20
|
+
onSubmit: () => Promise<void>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export type RestDataSourceExtension = {
|
|
4
|
+
createHttpHeaders?: () => Headers;
|
|
5
|
+
};
|
|
6
|
+
export declare const isRestDataSourceExtension: (o?: unknown) => o is RestDataSourceExtension;
|
|
7
|
+
export declare const RestDataSourceProvider: ({ children, createHttpHeaders, tableSchemas, url, }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
tableSchemas?: Record<string, TableSchema>;
|
|
10
|
+
url: string;
|
|
11
|
+
} & RestDataSourceExtension) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const VuuDataSourceProvider: ({ authenticate, autoConnect, autoLogin, children, websocketUrl, }: {
|
|
3
|
+
authenticate?: boolean;
|
|
4
|
+
autoConnect?: boolean;
|
|
5
|
+
autoLogin?: boolean;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
websocketUrl?: string;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const useAutoLoginToVuuServer: ({ authenticate, autoConnect, secure, websocketUrl, }?: {
|
|
2
|
+
authenticate?: boolean;
|
|
3
|
+
autoConnect?: boolean;
|
|
4
|
+
autoLogin?: boolean;
|
|
5
|
+
secure?: boolean;
|
|
6
|
+
websocketUrl?: string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SuggestionFetcher, TableSchemaTable } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { TypeaheadParams } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
export declare const getTypeaheadParams: (table: TableSchemaTable, column: string, text?: string, selectedValues?: string[]) => TypeaheadParams;
|
|
4
|
+
export declare const useTypeaheadSuggestions: () => SuggestionFetcher;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type MenuActionHandler, type MenuBuilder } from "@vuu-ui/vuu-context-menu";
|
|
2
|
+
import { DataSource, DataSourceVisualLinkCreatedMessage, RpcResponseHandler } from "@vuu-ui/vuu-data-types";
|
|
3
|
+
import type { LinkDescriptorWithLabel, VuuDataRowDto, VuuMenu, VuuMenuItem, VuuRowDataItemType } from "@vuu-ui/vuu-protocol-types";
|
|
4
|
+
import { TableContextMenuOptions, TableMenuLocation } from "@vuu-ui/vuu-table";
|
|
5
|
+
import type { ColumnDescriptor } from "@vuu-ui/vuu-table-types";
|
|
6
|
+
export interface VuuMenuActionHookResult {
|
|
7
|
+
menuBuilder: MenuBuilder<TableMenuLocation, TableContextMenuOptions>;
|
|
8
|
+
menuActionHandler: MenuActionHandler;
|
|
9
|
+
}
|
|
10
|
+
export interface MenuActionConfig {
|
|
11
|
+
vuuMenu?: VuuMenu;
|
|
12
|
+
visualLink?: DataSourceVisualLinkCreatedMessage;
|
|
13
|
+
visualLinks?: LinkDescriptorWithLabel[];
|
|
14
|
+
}
|
|
15
|
+
export interface VuuMenuActionHookProps {
|
|
16
|
+
/**
|
|
17
|
+
* By default, vuuMenuActions will be handled automatically. When activated, a
|
|
18
|
+
* message will be sent to server and response will be handled here too.
|
|
19
|
+
* This prop allows client to provide a custom handler for a menu Item. This will
|
|
20
|
+
* take priority and if handler returns true, no further processing for the menu
|
|
21
|
+
* item will be handled by Vuu. This can also be used to prevent an item from being
|
|
22
|
+
* actioned, even when no custom handling is intended. If the handler returns false,
|
|
23
|
+
* Vuu will process the menuItem.
|
|
24
|
+
*/
|
|
25
|
+
clientSideMenuActionHandler?: MenuActionHandler;
|
|
26
|
+
dataSource?: DataSource;
|
|
27
|
+
menuActionConfig?: MenuActionConfig;
|
|
28
|
+
onRpcResponse?: RpcResponseHandler;
|
|
29
|
+
}
|
|
30
|
+
export interface VuuCellContextMenuItemOptions extends VuuMenuItem {
|
|
31
|
+
rowKey: string;
|
|
32
|
+
field: string;
|
|
33
|
+
value: VuuRowDataItemType;
|
|
34
|
+
}
|
|
35
|
+
export interface VuuRowContextMenuItemOptions extends VuuMenuItem {
|
|
36
|
+
rowKey: string;
|
|
37
|
+
row: VuuDataRowDto;
|
|
38
|
+
}
|
|
39
|
+
export interface VuuSelectedRowsContextMenuItemOptions extends VuuMenuItem {
|
|
40
|
+
columns: ColumnDescriptor[];
|
|
41
|
+
}
|
|
42
|
+
export declare const isRowMenu: (options: VuuMenuItem) => options is VuuRowContextMenuItemOptions;
|
|
43
|
+
export declare const isSelectionMenu: (options: VuuMenuItem) => options is VuuSelectedRowsContextMenuItemOptions;
|
|
44
|
+
export declare const useVuuMenuActions: ({ clientSideMenuActionHandler, dataSource, onRpcResponse, }: VuuMenuActionHookProps) => VuuMenuActionHookResult;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DataSource, TableSchema } from "@vuu-ui/vuu-data-types";
|
|
2
|
+
import { VuuColumnDataType } from "@vuu-ui/vuu-protocol-types";
|
|
3
|
+
import { HTMLAttributes } from "react";
|
|
4
|
+
export type FormFieldDescriptor = {
|
|
5
|
+
isKeyField?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: VuuColumnDataType;
|
|
9
|
+
description: string;
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type FormConfig = {
|
|
14
|
+
title: string;
|
|
15
|
+
key: string;
|
|
16
|
+
fields: FormFieldDescriptor[];
|
|
17
|
+
};
|
|
18
|
+
export interface SessionEditingFormProps extends HTMLAttributes<HTMLDivElement> {
|
|
19
|
+
config: FormConfig;
|
|
20
|
+
onClose?: () => void;
|
|
21
|
+
dataSource?: DataSource;
|
|
22
|
+
schema?: TableSchema;
|
|
23
|
+
}
|
|
24
|
+
export declare const SessionEditingForm: ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes }: SessionEditingFormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./SessionEditingForm";
|