@dxos/react-client 2.27.3-dev.ad30f8df → 2.27.4-dev.0a2ac7a1
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/.rush/temp/package-deps_build.json +2 -2
- package/.rush/temp/package-deps_build:test.json +2 -2
- package/.rush/temp/package-deps_prerelease.json +2 -2
- package/dist/src/hooks/echo-selections/useSelection.d.ts +2 -2
- package/dist/src/hooks/echo-selections/useSelection.d.ts.map +1 -1
- package/dist/src/hooks/echo-selections/useSelection.js +7 -3
- package/dist/src/hooks/echo-selections/useSelection.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/hooks/echo-selections/useSelection.ts +10 -5
- package/out/index.html +0 -13
- package/out/index.js +0 -207310
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-client",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.4-dev.0a2ac7a1",
|
|
4
4
|
"description": "React client API",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,23 +8,23 @@
|
|
|
8
8
|
"main": "dist/src/index.js",
|
|
9
9
|
"types": "dist/src/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@dxos/async": "2.27.
|
|
12
|
-
"@dxos/bot-factory-client": "2.27.
|
|
13
|
-
"@dxos/client": "2.27.
|
|
14
|
-
"@dxos/config": "2.27.
|
|
15
|
-
"@dxos/credentials": "2.27.
|
|
16
|
-
"@dxos/crypto": "2.27.
|
|
17
|
-
"@dxos/debug": "2.27.
|
|
18
|
-
"@dxos/echo-db": "2.27.
|
|
19
|
-
"@dxos/util": "2.27.
|
|
11
|
+
"@dxos/async": "2.27.4-dev.0a2ac7a1",
|
|
12
|
+
"@dxos/bot-factory-client": "2.27.4-dev.0a2ac7a1",
|
|
13
|
+
"@dxos/client": "2.27.4-dev.0a2ac7a1",
|
|
14
|
+
"@dxos/config": "2.27.4-dev.0a2ac7a1",
|
|
15
|
+
"@dxos/credentials": "2.27.4-dev.0a2ac7a1",
|
|
16
|
+
"@dxos/crypto": "2.27.4-dev.0a2ac7a1",
|
|
17
|
+
"@dxos/debug": "2.27.4-dev.0a2ac7a1",
|
|
18
|
+
"@dxos/echo-db": "2.27.4-dev.0a2ac7a1",
|
|
19
|
+
"@dxos/util": "2.27.4-dev.0a2ac7a1",
|
|
20
20
|
"assert": "^2.0.0",
|
|
21
21
|
"debug": "^4.3.3",
|
|
22
22
|
"react-display-name": "^0.2.5",
|
|
23
23
|
"use-subscription": "^1.4.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@dxos/esbuild-plugins": "2.27.
|
|
27
|
-
"@dxos/toolchain-node-library": "2.27.
|
|
26
|
+
"@dxos/esbuild-plugins": "2.27.4-dev.0a2ac7a1",
|
|
27
|
+
"@dxos/toolchain-node-library": "2.27.3",
|
|
28
28
|
"@mui/material": "^5.0.1",
|
|
29
29
|
"@testing-library/react": "^11.0.4",
|
|
30
30
|
"@testing-library/react-hooks": "5.1.2",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Entity, Selection } from '@dxos/client';
|
|
7
|
+
import { Entity, Selection, SelectionResult } from '@dxos/client';
|
|
8
8
|
import { Falsy } from '@dxos/util';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -19,16 +19,16 @@ import { Falsy } from '@dxos/util';
|
|
|
19
19
|
* @param deps Array of values that trigger the selector when changed.
|
|
20
20
|
*/
|
|
21
21
|
export function useSelection<T extends Entity<any>> (
|
|
22
|
-
selection: Selection<T> | Falsy,
|
|
22
|
+
selection: Selection<T> | SelectionResult<T> | Falsy,
|
|
23
23
|
deps: readonly any[] = []
|
|
24
24
|
): T[] | undefined {
|
|
25
|
-
const [result, setResult] = useState(() => selection
|
|
25
|
+
const [result, setResult] = useState(() => coerseSelection(selection));
|
|
26
26
|
const [data, setData] = useState(() => result ? result.result : undefined);
|
|
27
27
|
|
|
28
28
|
// Update selection when the query or customs deps change.
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
const newResult = selection
|
|
31
|
-
const newData = newResult
|
|
30
|
+
const newResult = coerseSelection(selection);
|
|
31
|
+
const newData = newResult?.result;
|
|
32
32
|
setResult(newResult);
|
|
33
33
|
setData(newData);
|
|
34
34
|
}, [!!selection, !!selection && selection.root, ...deps]);
|
|
@@ -44,3 +44,8 @@ export function useSelection<T extends Entity<any>> (
|
|
|
44
44
|
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
const coerseSelection = <T extends Entity>(arg: Selection<T> | SelectionResult<T> | Falsy): SelectionResult<T> | undefined =>
|
|
49
|
+
!arg ? undefined
|
|
50
|
+
: arg instanceof Selection ? arg.query()
|
|
51
|
+
: arg;
|
package/out/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>ESBuild-Server Book</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id='root'></div>
|
|
11
|
-
<script src='index.js'></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|