@fluidframework/react 0.41.4 → 2.63.0-358419
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/.eslintrc.cjs +11 -0
- package/.mocharc.cjs +15 -0
- package/CHANGELOG.md +282 -0
- package/README.md +122 -273
- package/api-extractor/api-extractor-lint-alpha.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-alpha.esm.json +5 -0
- package/api-extractor/api-extractor-lint-beta.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-beta.esm.json +5 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/react.alpha.api.md +114 -0
- package/api-report/react.beta.api.md +7 -0
- package/api-report/react.public.api.md +7 -0
- package/biome.jsonc +4 -0
- package/dist/alpha.d.ts +45 -0
- package/dist/beta.d.ts +15 -0
- package/dist/index.d.ts +11 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/package.json +4 -0
- package/dist/propNode.d.ts +114 -0
- package/dist/propNode.d.ts.map +1 -0
- package/dist/propNode.js +43 -0
- package/dist/propNode.js.map +1 -0
- package/dist/public.d.ts +15 -0
- package/dist/reactSharedTreeView.d.ts +119 -0
- package/dist/reactSharedTreeView.d.ts.map +1 -0
- package/dist/reactSharedTreeView.js +206 -0
- package/dist/reactSharedTreeView.js.map +1 -0
- package/dist/simpleIdentifier.d.ts +19 -0
- package/dist/simpleIdentifier.d.ts.map +1 -0
- package/dist/simpleIdentifier.js +33 -0
- package/dist/simpleIdentifier.js.map +1 -0
- package/dist/useObservation.d.ts +83 -0
- package/dist/useObservation.d.ts.map +1 -0
- package/dist/useObservation.js +295 -0
- package/dist/useObservation.js.map +1 -0
- package/dist/useTree.d.ts +80 -0
- package/dist/useTree.d.ts.map +1 -0
- package/dist/useTree.js +137 -0
- package/dist/useTree.js.map +1 -0
- package/lib/alpha.d.ts +45 -0
- package/lib/beta.d.ts +15 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -7
- package/lib/index.js.map +1 -1
- package/lib/package.json +4 -0
- package/lib/propNode.d.ts +114 -0
- package/lib/propNode.d.ts.map +1 -0
- package/lib/propNode.js +36 -0
- package/lib/propNode.js.map +1 -0
- package/lib/public.d.ts +15 -0
- package/lib/reactSharedTreeView.d.ts +119 -0
- package/lib/reactSharedTreeView.d.ts.map +1 -0
- package/lib/reactSharedTreeView.js +176 -0
- package/lib/reactSharedTreeView.js.map +1 -0
- package/lib/simpleIdentifier.d.ts +19 -0
- package/lib/simpleIdentifier.d.ts.map +1 -0
- package/lib/simpleIdentifier.js +29 -0
- package/lib/simpleIdentifier.js.map +1 -0
- package/lib/test/propNode.spec.js +120 -0
- package/lib/test/propNode.spec.js.map +1 -0
- package/lib/test/reactSharedTreeView.spec.js +71 -0
- package/lib/test/reactSharedTreeView.spec.js.map +1 -0
- package/lib/test/simpleIdentifier.spec.js +18 -0
- package/lib/test/simpleIdentifier.spec.js.map +1 -0
- package/lib/test/useObservation.spec.js +162 -0
- package/lib/test/useObservation.spec.js.map +1 -0
- package/lib/test/useTree.spec.js +165 -0
- package/lib/test/useTree.spec.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/useObservation.d.ts +83 -0
- package/lib/useObservation.d.ts.map +1 -0
- package/lib/useObservation.js +266 -0
- package/lib/useObservation.js.map +1 -0
- package/lib/useTree.d.ts +80 -0
- package/lib/useTree.d.ts.map +1 -0
- package/lib/useTree.js +105 -0
- package/lib/useTree.js.map +1 -0
- package/package.json +150 -51
- package/react.test-files.tar +0 -0
- package/src/index.ts +42 -7
- package/src/propNode.ts +164 -0
- package/src/reactSharedTreeView.tsx +327 -0
- package/src/simpleIdentifier.ts +31 -0
- package/src/useObservation.ts +376 -0
- package/src/useTree.ts +147 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +12 -15
- package/tsdoc.json +4 -0
- package/.eslintrc.js +0 -11
- package/dist/createContextFluid.d.ts +0 -7
- package/dist/createContextFluid.d.ts.map +0 -1
- package/dist/createContextFluid.js +0 -46
- package/dist/createContextFluid.js.map +0 -1
- package/dist/helpers/generateFluidObjectSchema.d.ts +0 -16
- package/dist/helpers/generateFluidObjectSchema.d.ts.map +0 -1
- package/dist/helpers/generateFluidObjectSchema.js +0 -75
- package/dist/helpers/generateFluidObjectSchema.js.map +0 -1
- package/dist/helpers/getFluidFromView.d.ts +0 -15
- package/dist/helpers/getFluidFromView.d.ts.map +0 -1
- package/dist/helpers/getFluidFromView.js +0 -30
- package/dist/helpers/getFluidFromView.js.map +0 -1
- package/dist/helpers/getFluidState.d.ts +0 -15
- package/dist/helpers/getFluidState.d.ts.map +0 -1
- package/dist/helpers/getFluidState.js +0 -47
- package/dist/helpers/getFluidState.js.map +0 -1
- package/dist/helpers/getSchema.d.ts +0 -13
- package/dist/helpers/getSchema.d.ts.map +0 -1
- package/dist/helpers/getSchema.js +0 -15
- package/dist/helpers/getSchema.js.map +0 -1
- package/dist/helpers/getViewFromFluid.d.ts +0 -18
- package/dist/helpers/getViewFromFluid.d.ts.map +0 -1
- package/dist/helpers/getViewFromFluid.js +0 -47
- package/dist/helpers/getViewFromFluid.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -16
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -28
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/initializeState.d.ts +0 -22
- package/dist/helpers/initializeState.d.ts.map +0 -1
- package/dist/helpers/initializeState.js +0 -77
- package/dist/helpers/initializeState.js.map +0 -1
- package/dist/helpers/internalInterface.d.ts +0 -15
- package/dist/helpers/internalInterface.d.ts.map +0 -1
- package/dist/helpers/internalInterface.js +0 -7
- package/dist/helpers/internalInterface.js.map +0 -1
- package/dist/helpers/rootCallbackListener.d.ts +0 -24
- package/dist/helpers/rootCallbackListener.d.ts.map +0 -1
- package/dist/helpers/rootCallbackListener.js +0 -55
- package/dist/helpers/rootCallbackListener.js.map +0 -1
- package/dist/helpers/setComponentSchema.d.ts +0 -14
- package/dist/helpers/setComponentSchema.d.ts.map +0 -1
- package/dist/helpers/setComponentSchema.js +0 -18
- package/dist/helpers/setComponentSchema.js.map +0 -1
- package/dist/helpers/setFluidState.d.ts +0 -20
- package/dist/helpers/setFluidState.d.ts.map +0 -1
- package/dist/helpers/setFluidState.js +0 -94
- package/dist/helpers/setFluidState.js.map +0 -1
- package/dist/helpers/syncState.d.ts +0 -25
- package/dist/helpers/syncState.d.ts.map +0 -1
- package/dist/helpers/syncState.js +0 -98
- package/dist/helpers/syncState.js.map +0 -1
- package/dist/helpers/updateStateAndFluidObjectMap.d.ts +0 -29
- package/dist/helpers/updateStateAndFluidObjectMap.d.ts.map +0 -1
- package/dist/helpers/updateStateAndFluidObjectMap.js +0 -30
- package/dist/helpers/updateStateAndFluidObjectMap.js.map +0 -1
- package/dist/helpers/utils.d.ts +0 -12
- package/dist/helpers/utils.d.ts.map +0 -1
- package/dist/helpers/utils.js +0 -74
- package/dist/helpers/utils.js.map +0 -1
- package/dist/interface.d.ts +0 -444
- package/dist/interface.d.ts.map +0 -1
- package/dist/interface.js +0 -18
- package/dist/interface.js.map +0 -1
- package/dist/reactView.d.ts +0 -32
- package/dist/reactView.d.ts.map +0 -1
- package/dist/reactView.js +0 -79
- package/dist/reactView.js.map +0 -1
- package/dist/syncedDataObject.d.ts +0 -80
- package/dist/syncedDataObject.d.ts.map +0 -1
- package/dist/syncedDataObject.js +0 -249
- package/dist/syncedDataObject.js.map +0 -1
- package/dist/syncedObjects/array/fluidSyncedArray.d.ts +0 -11
- package/dist/syncedObjects/array/fluidSyncedArray.d.ts.map +0 -1
- package/dist/syncedObjects/array/fluidSyncedArray.js +0 -78
- package/dist/syncedObjects/array/fluidSyncedArray.js.map +0 -1
- package/dist/syncedObjects/array/index.d.ts +0 -7
- package/dist/syncedObjects/array/index.d.ts.map +0 -1
- package/dist/syncedObjects/array/index.js +0 -19
- package/dist/syncedObjects/array/index.js.map +0 -1
- package/dist/syncedObjects/array/interface.d.ts +0 -33
- package/dist/syncedObjects/array/interface.d.ts.map +0 -1
- package/dist/syncedObjects/array/interface.js +0 -3
- package/dist/syncedObjects/array/interface.js.map +0 -1
- package/dist/syncedObjects/array/syncedArray.d.ts +0 -30
- package/dist/syncedObjects/array/syncedArray.d.ts.map +0 -1
- package/dist/syncedObjects/array/syncedArray.js +0 -42
- package/dist/syncedObjects/array/syncedArray.js.map +0 -1
- package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts +0 -11
- package/dist/syncedObjects/counter/fluidSyncedCounter.d.ts.map +0 -1
- package/dist/syncedObjects/counter/fluidSyncedCounter.js +0 -79
- package/dist/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
- package/dist/syncedObjects/counter/index.d.ts +0 -7
- package/dist/syncedObjects/counter/index.d.ts.map +0 -1
- package/dist/syncedObjects/counter/index.js +0 -19
- package/dist/syncedObjects/counter/index.js.map +0 -1
- package/dist/syncedObjects/counter/interface.d.ts +0 -32
- package/dist/syncedObjects/counter/interface.d.ts.map +0 -1
- package/dist/syncedObjects/counter/interface.js +0 -3
- package/dist/syncedObjects/counter/interface.js.map +0 -1
- package/dist/syncedObjects/counter/syncedCounter.d.ts +0 -29
- package/dist/syncedObjects/counter/syncedCounter.d.ts.map +0 -1
- package/dist/syncedObjects/counter/syncedCounter.js +0 -36
- package/dist/syncedObjects/counter/syncedCounter.js.map +0 -1
- package/dist/syncedObjects/index.d.ts +0 -9
- package/dist/syncedObjects/index.d.ts.map +0 -1
- package/dist/syncedObjects/index.js +0 -21
- package/dist/syncedObjects/index.js.map +0 -1
- package/dist/syncedObjects/object/index.d.ts +0 -7
- package/dist/syncedObjects/object/index.d.ts.map +0 -1
- package/dist/syncedObjects/object/index.js +0 -19
- package/dist/syncedObjects/object/index.js.map +0 -1
- package/dist/syncedObjects/object/interface.d.ts +0 -13
- package/dist/syncedObjects/object/interface.d.ts.map +0 -1
- package/dist/syncedObjects/object/interface.js +0 -7
- package/dist/syncedObjects/object/interface.js.map +0 -1
- package/dist/syncedObjects/object/syncedObject.d.ts +0 -22
- package/dist/syncedObjects/object/syncedObject.d.ts.map +0 -1
- package/dist/syncedObjects/object/syncedObject.js +0 -46
- package/dist/syncedObjects/object/syncedObject.js.map +0 -1
- package/dist/syncedObjects/string/index.d.ts +0 -7
- package/dist/syncedObjects/string/index.d.ts.map +0 -1
- package/dist/syncedObjects/string/index.js +0 -19
- package/dist/syncedObjects/string/index.js.map +0 -1
- package/dist/syncedObjects/string/interface.d.ts +0 -16
- package/dist/syncedObjects/string/interface.d.ts.map +0 -1
- package/dist/syncedObjects/string/interface.js +0 -7
- package/dist/syncedObjects/string/interface.js.map +0 -1
- package/dist/syncedObjects/string/syncedString.d.ts +0 -25
- package/dist/syncedObjects/string/syncedString.d.ts.map +0 -1
- package/dist/syncedObjects/string/syncedString.js +0 -53
- package/dist/syncedObjects/string/syncedString.js.map +0 -1
- package/dist/useReducerFluid.d.ts +0 -7
- package/dist/useReducerFluid.d.ts.map +0 -1
- package/dist/useReducerFluid.js +0 -219
- package/dist/useReducerFluid.js.map +0 -1
- package/dist/useStateFluid.d.ts +0 -10
- package/dist/useStateFluid.d.ts.map +0 -1
- package/dist/useStateFluid.js +0 -67
- package/dist/useStateFluid.js.map +0 -1
- package/lib/createContextFluid.js +0 -23
- package/lib/createContextFluid.js.map +0 -1
- package/lib/helpers/generateFluidObjectSchema.js +0 -71
- package/lib/helpers/generateFluidObjectSchema.js.map +0 -1
- package/lib/helpers/getFluidFromView.js +0 -26
- package/lib/helpers/getFluidFromView.js.map +0 -1
- package/lib/helpers/getFluidState.js +0 -43
- package/lib/helpers/getFluidState.js.map +0 -1
- package/lib/helpers/getSchema.js +0 -11
- package/lib/helpers/getSchema.js.map +0 -1
- package/lib/helpers/getViewFromFluid.js +0 -43
- package/lib/helpers/getViewFromFluid.js.map +0 -1
- package/lib/helpers/index.js +0 -16
- package/lib/helpers/index.js.map +0 -1
- package/lib/helpers/initializeState.js +0 -73
- package/lib/helpers/initializeState.js.map +0 -1
- package/lib/helpers/internalInterface.js +0 -6
- package/lib/helpers/internalInterface.js.map +0 -1
- package/lib/helpers/rootCallbackListener.js +0 -51
- package/lib/helpers/rootCallbackListener.js.map +0 -1
- package/lib/helpers/setComponentSchema.js +0 -14
- package/lib/helpers/setComponentSchema.js.map +0 -1
- package/lib/helpers/setFluidState.js +0 -90
- package/lib/helpers/setFluidState.js.map +0 -1
- package/lib/helpers/syncState.js +0 -94
- package/lib/helpers/syncState.js.map +0 -1
- package/lib/helpers/updateStateAndFluidObjectMap.js +0 -26
- package/lib/helpers/updateStateAndFluidObjectMap.js.map +0 -1
- package/lib/helpers/utils.js +0 -67
- package/lib/helpers/utils.js.map +0 -1
- package/lib/interface.js +0 -8
- package/lib/interface.js.map +0 -1
- package/lib/reactView.js +0 -56
- package/lib/reactView.js.map +0 -1
- package/lib/syncedDataObject.js +0 -245
- package/lib/syncedDataObject.js.map +0 -1
- package/lib/syncedObjects/array/fluidSyncedArray.js +0 -72
- package/lib/syncedObjects/array/fluidSyncedArray.js.map +0 -1
- package/lib/syncedObjects/array/index.js +0 -7
- package/lib/syncedObjects/array/index.js.map +0 -1
- package/lib/syncedObjects/array/interface.js +0 -2
- package/lib/syncedObjects/array/interface.js.map +0 -1
- package/lib/syncedObjects/array/syncedArray.js +0 -37
- package/lib/syncedObjects/array/syncedArray.js.map +0 -1
- package/lib/syncedObjects/counter/fluidSyncedCounter.js +0 -73
- package/lib/syncedObjects/counter/fluidSyncedCounter.js.map +0 -1
- package/lib/syncedObjects/counter/index.js +0 -7
- package/lib/syncedObjects/counter/index.js.map +0 -1
- package/lib/syncedObjects/counter/interface.js +0 -2
- package/lib/syncedObjects/counter/interface.js.map +0 -1
- package/lib/syncedObjects/counter/syncedCounter.js +0 -31
- package/lib/syncedObjects/counter/syncedCounter.js.map +0 -1
- package/lib/syncedObjects/index.js +0 -9
- package/lib/syncedObjects/index.js.map +0 -1
- package/lib/syncedObjects/object/index.js +0 -7
- package/lib/syncedObjects/object/index.js.map +0 -1
- package/lib/syncedObjects/object/interface.js +0 -6
- package/lib/syncedObjects/object/interface.js.map +0 -1
- package/lib/syncedObjects/object/syncedObject.js +0 -41
- package/lib/syncedObjects/object/syncedObject.js.map +0 -1
- package/lib/syncedObjects/string/index.js +0 -7
- package/lib/syncedObjects/string/index.js.map +0 -1
- package/lib/syncedObjects/string/interface.js +0 -6
- package/lib/syncedObjects/string/interface.js.map +0 -1
- package/lib/syncedObjects/string/syncedString.js +0 -48
- package/lib/syncedObjects/string/syncedString.js.map +0 -1
- package/lib/useReducerFluid.js +0 -196
- package/lib/useReducerFluid.js.map +0 -1
- package/lib/useStateFluid.js +0 -44
- package/lib/useStateFluid.js.map +0 -1
- package/src/createContextFluid.tsx +0 -33
- package/src/helpers/generateFluidObjectSchema.ts +0 -95
- package/src/helpers/getFluidFromView.ts +0 -38
- package/src/helpers/getFluidState.ts +0 -67
- package/src/helpers/getSchema.ts +0 -18
- package/src/helpers/getViewFromFluid.ts +0 -68
- package/src/helpers/index.tsx +0 -16
- package/src/helpers/initializeState.ts +0 -162
- package/src/helpers/internalInterface.ts +0 -16
- package/src/helpers/rootCallbackListener.ts +0 -104
- package/src/helpers/setComponentSchema.ts +0 -21
- package/src/helpers/setFluidState.ts +0 -116
- package/src/helpers/syncState.ts +0 -159
- package/src/helpers/updateStateAndFluidObjectMap.ts +0 -85
- package/src/helpers/utils.tsx +0 -109
- package/src/interface.ts +0 -617
- package/src/reactView.tsx +0 -108
- package/src/syncedDataObject.ts +0 -337
- package/src/syncedObjects/array/fluidSyncedArray.ts +0 -126
- package/src/syncedObjects/array/index.ts +0 -7
- package/src/syncedObjects/array/interface.ts +0 -45
- package/src/syncedObjects/array/syncedArray.ts +0 -65
- package/src/syncedObjects/counter/fluidSyncedCounter.ts +0 -122
- package/src/syncedObjects/counter/index.ts +0 -7
- package/src/syncedObjects/counter/interface.ts +0 -44
- package/src/syncedObjects/counter/syncedCounter.ts +0 -64
- package/src/syncedObjects/index.ts +0 -9
- package/src/syncedObjects/object/index.ts +0 -7
- package/src/syncedObjects/object/interface.ts +0 -14
- package/src/syncedObjects/object/syncedObject.ts +0 -55
- package/src/syncedObjects/string/index.ts +0 -7
- package/src/syncedObjects/string/interface.ts +0 -17
- package/src/syncedObjects/string/syncedString.ts +0 -61
- package/src/useReducerFluid.tsx +0 -436
- package/src/useStateFluid.tsx +0 -84
- package/tsconfig.esnext.json +0 -7
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utilities for using SharedTree with React.
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
// #region @alpha APIs
|
|
18
|
+
IReactTreeDataObject,
|
|
19
|
+
IsMappableObjectType,
|
|
20
|
+
NodeRecord,
|
|
21
|
+
ObservationOptions,
|
|
22
|
+
PropTreeNode,
|
|
23
|
+
PropTreeNodeRecord,
|
|
24
|
+
PropTreeValue,
|
|
25
|
+
SchemaIncompatibleProps,
|
|
26
|
+
TreeViewComponent,
|
|
27
|
+
TreeViewProps,
|
|
28
|
+
UnwrapPropTreeNode,
|
|
29
|
+
UnwrapPropTreeNodeRecord,
|
|
30
|
+
WrapNodes,
|
|
31
|
+
WrapPropTreeNodeRecord,
|
|
32
|
+
objectIdNumber,
|
|
33
|
+
toPropTreeNode,
|
|
34
|
+
toPropTreeRecord,
|
|
35
|
+
treeDataObject,
|
|
36
|
+
unwrapPropTreeNode,
|
|
37
|
+
unwrapPropTreeRecord,
|
|
38
|
+
usePropTreeNode,
|
|
39
|
+
usePropTreeRecord,
|
|
40
|
+
useTree,
|
|
41
|
+
useTreeObservations,
|
|
42
|
+
withMemoizedTreeObservations,
|
|
43
|
+
withTreeObservations
|
|
44
|
+
// #endregion
|
|
45
|
+
} from "./index.js";
|
package/dist/beta.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utilities for using SharedTree with React.
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/export {}
|
|
15
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
5
|
+
/**
|
|
6
|
+
* Utilities for using SharedTree with React.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type { IReactTreeDataObject, TreeViewProps, SchemaIncompatibleProps, } from "./reactSharedTreeView.js";
|
|
10
|
+
export { treeDataObject, treeDataObjectInternal, TreeViewComponent, } from "./reactSharedTreeView.js";
|
|
11
|
+
export type { ObservationOptions } from "./useObservation.js";
|
|
12
|
+
export type { NodeRecord, PropTreeNode, PropTreeNodeRecord, PropTreeValue, UnwrapPropTreeNode, UnwrapPropTreeNodeRecord, WrapPropTreeNodeRecord, WrapNodes, IsMappableObjectType, } from "./propNode.js";
|
|
13
|
+
export { toPropTreeNode, toPropTreeRecord, unwrapPropTreeNode, unwrapPropTreeRecord, } from "./propNode.js";
|
|
14
|
+
export { useTree, usePropTreeNode, usePropTreeRecord, useTreeObservations, withTreeObservations, withMemoizedTreeObservations, } from "./useTree.js";
|
|
15
|
+
export { objectIdNumber } from "./simpleIdentifier.js";
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,YAAY,EACX,oBAAoB,EACpB,aAAa,EACb,uBAAuB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EACX,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACtB,SAAS,EACT,oBAAoB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
exports.objectIdNumber = exports.withMemoizedTreeObservations = exports.withTreeObservations = exports.useTreeObservations = exports.usePropTreeRecord = exports.usePropTreeNode = exports.useTree = exports.unwrapPropTreeRecord = exports.unwrapPropTreeNode = exports.toPropTreeRecord = exports.toPropTreeNode = exports.TreeViewComponent = exports.treeDataObjectInternal = exports.treeDataObject = void 0;
|
|
8
|
+
var reactSharedTreeView_js_1 = require("./reactSharedTreeView.js");
|
|
9
|
+
Object.defineProperty(exports, "treeDataObject", { enumerable: true, get: function () { return reactSharedTreeView_js_1.treeDataObject; } });
|
|
10
|
+
Object.defineProperty(exports, "treeDataObjectInternal", { enumerable: true, get: function () { return reactSharedTreeView_js_1.treeDataObjectInternal; } });
|
|
11
|
+
Object.defineProperty(exports, "TreeViewComponent", { enumerable: true, get: function () { return reactSharedTreeView_js_1.TreeViewComponent; } });
|
|
12
|
+
var propNode_js_1 = require("./propNode.js");
|
|
13
|
+
Object.defineProperty(exports, "toPropTreeNode", { enumerable: true, get: function () { return propNode_js_1.toPropTreeNode; } });
|
|
14
|
+
Object.defineProperty(exports, "toPropTreeRecord", { enumerable: true, get: function () { return propNode_js_1.toPropTreeRecord; } });
|
|
15
|
+
Object.defineProperty(exports, "unwrapPropTreeNode", { enumerable: true, get: function () { return propNode_js_1.unwrapPropTreeNode; } });
|
|
16
|
+
Object.defineProperty(exports, "unwrapPropTreeRecord", { enumerable: true, get: function () { return propNode_js_1.unwrapPropTreeRecord; } });
|
|
17
|
+
var useTree_js_1 = require("./useTree.js");
|
|
18
|
+
Object.defineProperty(exports, "useTree", { enumerable: true, get: function () { return useTree_js_1.useTree; } });
|
|
19
|
+
Object.defineProperty(exports, "usePropTreeNode", { enumerable: true, get: function () { return useTree_js_1.usePropTreeNode; } });
|
|
20
|
+
Object.defineProperty(exports, "usePropTreeRecord", { enumerable: true, get: function () { return useTree_js_1.usePropTreeRecord; } });
|
|
21
|
+
Object.defineProperty(exports, "useTreeObservations", { enumerable: true, get: function () { return useTree_js_1.useTreeObservations; } });
|
|
22
|
+
Object.defineProperty(exports, "withTreeObservations", { enumerable: true, get: function () { return useTree_js_1.withTreeObservations; } });
|
|
23
|
+
Object.defineProperty(exports, "withMemoizedTreeObservations", { enumerable: true, get: function () { return useTree_js_1.withMemoizedTreeObservations; } });
|
|
24
|
+
var simpleIdentifier_js_1 = require("./simpleIdentifier.js");
|
|
25
|
+
Object.defineProperty(exports, "objectIdNumber", { enumerable: true, get: function () { return simpleIdentifier_js_1.objectIdNumber; } });
|
|
24
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,mEAIkC;AAHjC,wHAAA,cAAc,OAAA;AACd,gIAAA,sBAAsB,OAAA;AACtB,2HAAA,iBAAiB,OAAA;AAclB,6CAKuB;AAJtB,6GAAA,cAAc,OAAA;AACd,+GAAA,gBAAgB,OAAA;AAChB,iHAAA,kBAAkB,OAAA;AAClB,mHAAA,oBAAoB,OAAA;AAErB,2CAOsB;AANrB,qGAAA,OAAO,OAAA;AACP,6GAAA,eAAe,OAAA;AACf,+GAAA,iBAAiB,OAAA;AACjB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,0HAAA,4BAA4B,OAAA;AAE7B,6DAAuD;AAA9C,qHAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Utilities for using SharedTree with React.\n * @packageDocumentation\n */\n\nexport type {\n\tIReactTreeDataObject,\n\tTreeViewProps,\n\tSchemaIncompatibleProps,\n} from \"./reactSharedTreeView.js\";\nexport {\n\ttreeDataObject,\n\ttreeDataObjectInternal,\n\tTreeViewComponent,\n} from \"./reactSharedTreeView.js\";\nexport type { ObservationOptions } from \"./useObservation.js\";\nexport type {\n\tNodeRecord,\n\tPropTreeNode,\n\tPropTreeNodeRecord,\n\tPropTreeValue,\n\tUnwrapPropTreeNode,\n\tUnwrapPropTreeNodeRecord,\n\tWrapPropTreeNodeRecord,\n\tWrapNodes,\n\tIsMappableObjectType,\n} from \"./propNode.js\";\nexport {\n\ttoPropTreeNode,\n\ttoPropTreeRecord,\n\tunwrapPropTreeNode,\n\tunwrapPropTreeRecord,\n} from \"./propNode.js\";\nexport {\n\tuseTree,\n\tusePropTreeNode,\n\tusePropTreeRecord,\n\tuseTreeObservations,\n\twithTreeObservations,\n\twithMemoizedTreeObservations,\n} from \"./useTree.js\";\nexport { objectIdNumber } from \"./simpleIdentifier.js\";\n"]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { ErasedType } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { TreeNode, TreeLeafValue } from "@fluidframework/tree";
|
|
7
|
+
/**
|
|
8
|
+
* A type erased TreeNode for use in react props.
|
|
9
|
+
* @remarks
|
|
10
|
+
* Read content from the node using {@link usePropTreeNode} or {@link usePropTreeRecord}.
|
|
11
|
+
*
|
|
12
|
+
* In events where tracking dependencies is not required, the node can be unwrapped using {@link unwrapPropTreeNode}.
|
|
13
|
+
*
|
|
14
|
+
* To convert a TreeNode to this type use {@link toPropTreeNode} or {@link toPropTreeRecord}.
|
|
15
|
+
* @alpha
|
|
16
|
+
*/
|
|
17
|
+
export interface PropTreeNode<T extends TreeNode> extends ErasedType<[T, "PropTreeNode"]> {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type TreeNodes in T as {@link PropTreeNode}s.
|
|
21
|
+
* @remarks
|
|
22
|
+
* This only handles a few cases (TreeNode, structurally typed objects fields and arrays) and leaves other types as is.
|
|
23
|
+
* Users which provide other types (e.g. maps) which contain TreeNodes will need to handle wrapping those themselves if the wrapping is desired.
|
|
24
|
+
*
|
|
25
|
+
* Users of this should not rely on a given use of TreeNode not being wrapped:
|
|
26
|
+
* future changes to this API may add more cases which are wrapped, and this will be considered a non-breaking change.
|
|
27
|
+
* @privateRemarks
|
|
28
|
+
* Covering all cases is impossible, and trying to cover more with recursive mapped types can break some of the types by losing methods, private members, etc.
|
|
29
|
+
* To mitigate this IsMappableObjectType is used for objects, and only mappable types, where the mapping actually impacted the type are modified.
|
|
30
|
+
*
|
|
31
|
+
* This is intended to cover the common cases, and users can handle other cases manually.
|
|
32
|
+
* See the tests for this for more details.
|
|
33
|
+
* @alpha
|
|
34
|
+
*/
|
|
35
|
+
export type WrapNodes<T> = T extends TreeNode ? PropTreeNode<T> : T extends readonly (infer U)[] ? readonly WrapNodes<U>[] : T extends infer U ? IsMappableObjectType<U, {
|
|
36
|
+
[P in keyof U]: WrapNodes<U[P]>;
|
|
37
|
+
} extends U ? U : {
|
|
38
|
+
[P in keyof U]: WrapNodes<U[P]>;
|
|
39
|
+
}, T> : T;
|
|
40
|
+
/**
|
|
41
|
+
* Detect if a type is a simple structural object.
|
|
42
|
+
* @remarks
|
|
43
|
+
* This returns the true case if the type is entirely defined by its set of public properties.
|
|
44
|
+
* More concretely, this indicates if creating a mapped type based on `T`
|
|
45
|
+
* will be lossy due to details mapped types cannot access.
|
|
46
|
+
*
|
|
47
|
+
* This is shallow, and distributes over unions.
|
|
48
|
+
*
|
|
49
|
+
* This also returns the true case for primitive types since mapping over them leaves them unchanged if doing so in a generic context:
|
|
50
|
+
* Mapping over a primitive does not leave them unchanged if done directly (not to a generic type parameter), but this can not detect that behavior.
|
|
51
|
+
* This is fine as the use for this is to detect when making a mapped type from a generic type parameter would be lossy.
|
|
52
|
+
* @system @alpha
|
|
53
|
+
*/
|
|
54
|
+
export type IsMappableObjectType<T, True = true, False = false, Mapped = {
|
|
55
|
+
[P in keyof T]: T[P];
|
|
56
|
+
}> = [Mapped] extends [T] ? ([T] extends [Mapped] ? True : False) : False;
|
|
57
|
+
/**
|
|
58
|
+
* Casts a node from a {@link PropTreeNode} back to a TreeNode.
|
|
59
|
+
* @remarks
|
|
60
|
+
* This should only be done in scenarios where tracking observations is not required (such as event handlers),
|
|
61
|
+
* or when taking care to handle invalidation manually.
|
|
62
|
+
* @alpha
|
|
63
|
+
*/
|
|
64
|
+
export declare function unwrapPropTreeNode<T extends TreeNode | TreeLeafValue>(propNode: PropTreeValue<T> | T): T;
|
|
65
|
+
/**
|
|
66
|
+
* {@link unwrapPropTreeNode} but for a {@link PropTreeNodeRecord}.
|
|
67
|
+
* @alpha
|
|
68
|
+
*/
|
|
69
|
+
export declare function unwrapPropTreeRecord<T extends PropTreeNodeRecord>(props: T): UnwrapPropTreeNodeRecord<T>;
|
|
70
|
+
/**
|
|
71
|
+
* {@inheritdoc unwrapPropTreeNode}
|
|
72
|
+
* @alpha
|
|
73
|
+
*/
|
|
74
|
+
export type UnwrapPropTreeNode<T extends TreeLeafValue | PropTreeNode<TreeNode> | undefined> = T extends PropTreeNode<infer Node> ? Node : T;
|
|
75
|
+
/**
|
|
76
|
+
* Record that can contain TreeNodes.
|
|
77
|
+
* @alpha
|
|
78
|
+
*/
|
|
79
|
+
export type NodeRecord = Record<string, TreeNode | TreeLeafValue>;
|
|
80
|
+
/**
|
|
81
|
+
* Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.
|
|
82
|
+
* @alpha
|
|
83
|
+
*/
|
|
84
|
+
export type WrapPropTreeNodeRecord<T extends NodeRecord> = {
|
|
85
|
+
readonly [P in keyof T]: PropTreeValue<T[P]>;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.
|
|
89
|
+
* @alpha
|
|
90
|
+
*/
|
|
91
|
+
export type UnwrapPropTreeNodeRecord<T extends PropTreeNodeRecord> = {
|
|
92
|
+
readonly [P in keyof T]: UnwrapPropTreeNode<T[P]>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.
|
|
96
|
+
* @alpha
|
|
97
|
+
*/
|
|
98
|
+
export type PropTreeNodeRecord = Record<string, TreeLeafValue | PropTreeNode<TreeNode> | undefined>;
|
|
99
|
+
/**
|
|
100
|
+
* Type erase a `TreeNode` from a `TreeNode | TreeLeafValue` as a {@link PropTreeNode}.
|
|
101
|
+
* @alpha
|
|
102
|
+
*/
|
|
103
|
+
export type PropTreeValue<T extends TreeNode | TreeLeafValue | undefined> = T extends TreeNode ? PropTreeNode<T> : T;
|
|
104
|
+
/**
|
|
105
|
+
* Type erase a TreeNode as a {@link PropTreeNode}.
|
|
106
|
+
* @alpha
|
|
107
|
+
*/
|
|
108
|
+
export declare function toPropTreeNode<T extends TreeNode | TreeLeafValue>(node: T): PropTreeValue<T>;
|
|
109
|
+
/**
|
|
110
|
+
* Type erase a {@link NodeRecord} as a {@link PropTreeNodeRecord}.
|
|
111
|
+
* @alpha
|
|
112
|
+
*/
|
|
113
|
+
export declare function toPropTreeRecord<T extends NodeRecord>(node: T): WrapPropTreeNodeRecord<T>;
|
|
114
|
+
//# sourceMappingURL=propNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propNode.d.ts","sourceRoot":"","sources":["../src/propNode.ts"],"names":[],"mappings":"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"}
|
package/dist/propNode.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.toPropTreeRecord = exports.toPropTreeNode = exports.unwrapPropTreeRecord = exports.unwrapPropTreeNode = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Casts a node from a {@link PropTreeNode} back to a TreeNode.
|
|
10
|
+
* @remarks
|
|
11
|
+
* This should only be done in scenarios where tracking observations is not required (such as event handlers),
|
|
12
|
+
* or when taking care to handle invalidation manually.
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
function unwrapPropTreeNode(propNode) {
|
|
16
|
+
return propNode;
|
|
17
|
+
}
|
|
18
|
+
exports.unwrapPropTreeNode = unwrapPropTreeNode;
|
|
19
|
+
/**
|
|
20
|
+
* {@link unwrapPropTreeNode} but for a {@link PropTreeNodeRecord}.
|
|
21
|
+
* @alpha
|
|
22
|
+
*/
|
|
23
|
+
function unwrapPropTreeRecord(props) {
|
|
24
|
+
return props;
|
|
25
|
+
}
|
|
26
|
+
exports.unwrapPropTreeRecord = unwrapPropTreeRecord;
|
|
27
|
+
/**
|
|
28
|
+
* Type erase a TreeNode as a {@link PropTreeNode}.
|
|
29
|
+
* @alpha
|
|
30
|
+
*/
|
|
31
|
+
function toPropTreeNode(node) {
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
34
|
+
exports.toPropTreeNode = toPropTreeNode;
|
|
35
|
+
/**
|
|
36
|
+
* Type erase a {@link NodeRecord} as a {@link PropTreeNodeRecord}.
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
function toPropTreeRecord(node) {
|
|
40
|
+
return node;
|
|
41
|
+
}
|
|
42
|
+
exports.toPropTreeRecord = toPropTreeRecord;
|
|
43
|
+
//# sourceMappingURL=propNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propNode.js","sourceRoot":"","sources":["../src/propNode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6EH;;;;;;GAMG;AACH,SAAgB,kBAAkB,CACjC,QAA8B;IAE9B,OAAO,QAAa,CAAC;AACtB,CAAC;AAJD,gDAIC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CACnC,KAAQ;IAER,OAAO,KAAoC,CAAC;AAC7C,CAAC;AAJD,oDAIC;AAgDD;;;GAGG;AACH,SAAgB,cAAc,CAAqC,IAAO;IACzE,OAAO,IAAmC,CAAC;AAC5C,CAAC;AAFD,wCAEC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAuB,IAAO;IAC7D,OAAO,IAA4C,CAAC;AACrD,CAAC;AAFD,4CAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedType } from \"@fluidframework/core-interfaces\";\nimport type { TreeNode, TreeLeafValue } from \"@fluidframework/tree\";\n\n/**\n * A type erased TreeNode for use in react props.\n * @remarks\n * Read content from the node using {@link usePropTreeNode} or {@link usePropTreeRecord}.\n *\n * In events where tracking dependencies is not required, the node can be unwrapped using {@link unwrapPropTreeNode}.\n *\n * To convert a TreeNode to this type use {@link toPropTreeNode} or {@link toPropTreeRecord}.\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PropTreeNode<T extends TreeNode> extends ErasedType<[T, \"PropTreeNode\"]> {}\n\n/**\n * Type TreeNodes in T as {@link PropTreeNode}s.\n * @remarks\n * This only handles a few cases (TreeNode, structurally typed objects fields and arrays) and leaves other types as is.\n * Users which provide other types (e.g. maps) which contain TreeNodes will need to handle wrapping those themselves if the wrapping is desired.\n *\n * Users of this should not rely on a given use of TreeNode not being wrapped:\n * future changes to this API may add more cases which are wrapped, and this will be considered a non-breaking change.\n * @privateRemarks\n * Covering all cases is impossible, and trying to cover more with recursive mapped types can break some of the types by losing methods, private members, etc.\n * To mitigate this IsMappableObjectType is used for objects, and only mappable types, where the mapping actually impacted the type are modified.\n *\n * This is intended to cover the common cases, and users can handle other cases manually.\n * See the tests for this for more details.\n * @alpha\n */\nexport type WrapNodes<T> = T extends TreeNode\n\t? PropTreeNode<T>\n\t: T extends readonly (infer U)[]\n\t\t? readonly WrapNodes<U>[]\n\t\t: // `T extends (infer U)` distributes over unions, allowing WrapNodes<A|B> to be WrapNodes<A> | WrapNodes<B>.\n\t\t\tT extends infer U\n\t\t\t? IsMappableObjectType<\n\t\t\t\t\tU,\n\t\t\t\t\t{\n\t\t\t\t\t\t[P in keyof U]: WrapNodes<U[P]>;\n\t\t\t\t\t} extends U\n\t\t\t\t\t\t? // Returning U in this case (when assignable to the mapped type) avoids flatting named interfaces when they are unchanged.\n\t\t\t\t\t\t\tU\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t[P in keyof U]: WrapNodes<U[P]>;\n\t\t\t\t\t\t\t},\n\t\t\t\t\tT\n\t\t\t\t>\n\t\t\t: T;\n\n/**\n * Detect if a type is a simple structural object.\n * @remarks\n * This returns the true case if the type is entirely defined by its set of public properties.\n * More concretely, this indicates if creating a mapped type based on `T`\n * will be lossy due to details mapped types cannot access.\n *\n * This is shallow, and distributes over unions.\n *\n * This also returns the true case for primitive types since mapping over them leaves them unchanged if doing so in a generic context:\n * Mapping over a primitive does not leave them unchanged if done directly (not to a generic type parameter), but this can not detect that behavior.\n * This is fine as the use for this is to detect when making a mapped type from a generic type parameter would be lossy.\n * @system @alpha\n */\nexport type IsMappableObjectType<\n\tT,\n\tTrue = true,\n\tFalse = false,\n\tMapped = {\n\t\t[P in keyof T]: T[P];\n\t},\n> = [Mapped] extends [T] ? ([T] extends [Mapped] ? True : False) : False;\n\n/**\n * Casts a node from a {@link PropTreeNode} back to a TreeNode.\n * @remarks\n * This should only be done in scenarios where tracking observations is not required (such as event handlers),\n * or when taking care to handle invalidation manually.\n * @alpha\n */\nexport function unwrapPropTreeNode<T extends TreeNode | TreeLeafValue>(\n\tpropNode: PropTreeValue<T> | T,\n): T {\n\treturn propNode as T;\n}\n\n/**\n * {@link unwrapPropTreeNode} but for a {@link PropTreeNodeRecord}.\n * @alpha\n */\nexport function unwrapPropTreeRecord<T extends PropTreeNodeRecord>(\n\tprops: T,\n): UnwrapPropTreeNodeRecord<T> {\n\treturn props as UnwrapPropTreeNodeRecord<T>;\n}\n\n/**\n * {@inheritdoc unwrapPropTreeNode}\n * @alpha\n */\nexport type UnwrapPropTreeNode<T extends TreeLeafValue | PropTreeNode<TreeNode> | undefined> =\n\tT extends PropTreeNode<infer Node> ? Node : T;\n\n/**\n * Record that can contain TreeNodes.\n * @alpha\n */\nexport type NodeRecord = Record<string, TreeNode | TreeLeafValue>;\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type WrapPropTreeNodeRecord<T extends NodeRecord> = {\n\treadonly [P in keyof T]: PropTreeValue<T[P]>;\n};\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type UnwrapPropTreeNodeRecord<T extends PropTreeNodeRecord> = {\n\treadonly [P in keyof T]: UnwrapPropTreeNode<T[P]>;\n};\n\n/**\n * Type erase `TreeNode`s from a {@link NodeRecord} as a {@link PropTreeNode}.\n * @alpha\n */\nexport type PropTreeNodeRecord = Record<\n\tstring,\n\tTreeLeafValue | PropTreeNode<TreeNode> | undefined\n>;\n\n/**\n * Type erase a `TreeNode` from a `TreeNode | TreeLeafValue` as a {@link PropTreeNode}.\n * @alpha\n */\nexport type PropTreeValue<T extends TreeNode | TreeLeafValue | undefined> = T extends TreeNode\n\t? PropTreeNode<T>\n\t: T;\n\n/**\n * Type erase a TreeNode as a {@link PropTreeNode}.\n * @alpha\n */\nexport function toPropTreeNode<T extends TreeNode | TreeLeafValue>(node: T): PropTreeValue<T> {\n\treturn node as unknown as PropTreeValue<T>;\n}\n\n/**\n * Type erase a {@link NodeRecord} as a {@link PropTreeNodeRecord}.\n * @alpha\n */\nexport function toPropTreeRecord<T extends NodeRecord>(node: T): WrapPropTreeNodeRecord<T> {\n\treturn node as unknown as WrapPropTreeNodeRecord<T>;\n}\n"]}
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
+
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Utilities for using SharedTree with React.
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/export {}
|
|
15
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TreeDataObject } from "@fluidframework/aqueduct/internal";
|
|
6
|
+
import type { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
|
+
import type { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions/internal";
|
|
8
|
+
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
|
+
import type { SchemaCompatibilityStatus, TreeViewConfiguration, TreeFieldFromImplicitField, TreeView, ImplicitFieldSchema, InsertableTreeFieldFromImplicitField } from "@fluidframework/tree";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { type PropTreeValue } from "./propNode.js";
|
|
12
|
+
/**
|
|
13
|
+
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
14
|
+
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
15
|
+
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
16
|
+
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
export declare function treeDataObject<TSchema extends ImplicitFieldSchema>(treeConfiguration: TreeViewConfiguration<TSchema>, createInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable>;
|
|
20
|
+
/**
|
|
21
|
+
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
22
|
+
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
23
|
+
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
24
|
+
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function treeDataObjectInternal<TSchema extends ImplicitFieldSchema>(treeConfiguration: TreeViewConfiguration<TSchema>, createInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable & TreeDataObject> & {
|
|
28
|
+
readonly factory: IFluidDataStoreFactory;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A schema-aware tree-backed DataObject, extended with a React Component to view the tree.
|
|
32
|
+
* @remarks Allows for the Tree's schema to be baked into the container schema.
|
|
33
|
+
* @sealed @alpha
|
|
34
|
+
*/
|
|
35
|
+
export interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> {
|
|
36
|
+
/**
|
|
37
|
+
* The configuration used to initialize new documents, as well as to interpret (schematize) existing ones.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* The fact that a single view schema is provided here (on the data object) makes it impossible to try and apply multiple different schema.
|
|
41
|
+
* Since the view schema currently does not provide any adapters for handling differences between view and stored schema,
|
|
42
|
+
* it's also impossible for this single view schema to handle multiple different stored schema.
|
|
43
|
+
* Therefore, with this current API, two different applications (or different versions of the same application)
|
|
44
|
+
* with differing stored schema requirements (as implied by their view schema) can not collaborate on the same tree.
|
|
45
|
+
* The only schema evolution that's currently possible is upgrading the schema to one that supports a superset of what the old schema allowed,
|
|
46
|
+
* and collaborating between clients which have view schema that exactly correspond to that stored schema.
|
|
47
|
+
* Future work on tree as well as these utilities should address this limitation.
|
|
48
|
+
*/
|
|
49
|
+
readonly config: TreeViewConfiguration<TSchema>;
|
|
50
|
+
/**
|
|
51
|
+
* The schema-aware view of the tree.
|
|
52
|
+
*/
|
|
53
|
+
readonly treeView: TreeView<TSchema>;
|
|
54
|
+
/**
|
|
55
|
+
* React component which handles schematizing trees.
|
|
56
|
+
* This includes displaying errors when the document can not be viewed using the view schema.
|
|
57
|
+
*
|
|
58
|
+
* @privateRemarks
|
|
59
|
+
* This is exposed as a member rather than a free function since type inference for the schema doesn't work when used as a free function,
|
|
60
|
+
* and thus making it a member avoids the user of this from having to explicitly provide the type parameter.
|
|
61
|
+
* This is an arrow function not a method so it gets the correct this when not called as a member.
|
|
62
|
+
*/
|
|
63
|
+
readonly TreeViewComponent: (props: TreeViewProps<TSchema>) => React.JSX.Element;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* React props for viewing a tree.
|
|
67
|
+
* @input @alpha
|
|
68
|
+
*/
|
|
69
|
+
export interface TreeViewProps<TSchema extends ImplicitFieldSchema> {
|
|
70
|
+
/**
|
|
71
|
+
* Component to display the tree content.
|
|
72
|
+
*/
|
|
73
|
+
readonly viewComponent: React.FC<{
|
|
74
|
+
root: PropTreeValue<TreeFieldFromImplicitField<TSchema>>;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Component to display instead of the {@link TreeViewProps.viewComponent}
|
|
78
|
+
* when tree content is not compatible with the {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
79
|
+
*
|
|
80
|
+
* @defaultValue Component which describes the situation (in English) and allows the user to upgrade the schema to match the {@link @fluidframework/tree#TreeViewConfiguration} if possible.
|
|
81
|
+
*/
|
|
82
|
+
readonly errorComponent?: React.FC<SchemaIncompatibleProps>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Generic DataObject for shared trees.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export declare abstract class ReactTreeDataObject<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> extends TreeDataObject implements IReactTreeDataObject<TSchema> {
|
|
89
|
+
#private;
|
|
90
|
+
abstract readonly config: TreeViewConfiguration<TSchema>;
|
|
91
|
+
/**
|
|
92
|
+
* The schema-aware view of the tree.
|
|
93
|
+
*/
|
|
94
|
+
get treeView(): TreeView<TSchema>;
|
|
95
|
+
readonly TreeViewComponent: ({ viewComponent, errorComponent, }: TreeViewProps<TSchema>) => React.JSX.Element;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* React component which handles schematizing trees.
|
|
99
|
+
* This includes displaying errors when the document can not be schematized.
|
|
100
|
+
* @alpha
|
|
101
|
+
*/
|
|
102
|
+
export declare function TreeViewComponent<TSchema extends ImplicitFieldSchema>({ tree, viewComponent: ViewComponent, errorComponent, }: TreeViewProps<TSchema> & {
|
|
103
|
+
tree: Pick<IReactTreeDataObject<TSchema>, "treeView">;
|
|
104
|
+
}): React.JSX.Element;
|
|
105
|
+
/**
|
|
106
|
+
* React Props for displaying when the opened document is incompatible with the required view schema.
|
|
107
|
+
* @alpha
|
|
108
|
+
*/
|
|
109
|
+
export interface SchemaIncompatibleProps {
|
|
110
|
+
/**
|
|
111
|
+
* Information about the view schema's compatibility with the stored schema.
|
|
112
|
+
*/
|
|
113
|
+
readonly compatibility: SchemaCompatibilityStatus;
|
|
114
|
+
/**
|
|
115
|
+
* Callback to request that the stored schema in the document be upgraded.
|
|
116
|
+
*/
|
|
117
|
+
readonly upgradeSchema: () => void;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=reactSharedTreeView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactSharedTreeView.d.ts","sourceRoot":"","sources":["../src/reactSharedTreeView.tsx"],"names":[],"mappings":"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"}
|