@fluidframework/react 2.90.0-378676 → 2.91.0
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/CHANGELOG.md +13 -0
- package/README.md +2 -0
- package/api-report/react.alpha.api.md +8 -8
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/propNode.js.map +1 -1
- package/lib/reactSharedTreeView.d.ts +6 -6
- package/lib/reactSharedTreeView.d.ts.map +1 -1
- package/lib/reactSharedTreeView.js +16 -18
- package/lib/reactSharedTreeView.js.map +1 -1
- package/lib/test/mochaHooks.js +13 -0
- package/lib/test/mochaHooks.js.map +1 -0
- package/lib/test/reactSharedTreeView.spec.js +3 -3
- package/lib/test/reactSharedTreeView.spec.js.map +1 -1
- package/lib/test/text/plainUtils.test.js +75 -0
- package/lib/test/text/plainUtils.test.js.map +1 -0
- package/lib/test/text/textEditor.test.js +760 -0
- package/lib/test/text/textEditor.test.js.map +1 -0
- package/lib/test/undoRedo.test.js +62 -0
- package/lib/test/undoRedo.test.js.map +1 -0
- package/lib/test/useObservation.spec.js +8 -9
- package/lib/test/useObservation.spec.js.map +1 -1
- package/lib/test/useTree.spec.js +15 -16
- package/lib/test/useTree.spec.js.map +1 -1
- package/lib/text/formatted/index.d.ts +6 -0
- package/lib/text/formatted/index.d.ts.map +1 -0
- package/lib/text/formatted/index.js +6 -0
- package/lib/text/formatted/index.js.map +1 -0
- package/lib/text/formatted/quillFormattedView.d.ts +66 -0
- package/lib/text/formatted/quillFormattedView.d.ts.map +1 -0
- package/lib/text/formatted/quillFormattedView.js +520 -0
- package/lib/text/formatted/quillFormattedView.js.map +1 -0
- package/lib/text/index.d.ts +7 -0
- package/lib/text/index.d.ts.map +1 -0
- package/lib/text/index.js +7 -0
- package/lib/text/index.js.map +1 -0
- package/lib/text/plain/index.d.ts +7 -0
- package/lib/text/plain/index.d.ts.map +1 -0
- package/lib/text/plain/index.js +7 -0
- package/lib/text/plain/index.js.map +1 -0
- package/lib/text/plain/plainTextView.d.ts +14 -0
- package/lib/text/plain/plainTextView.d.ts.map +1 -0
- package/lib/text/plain/plainTextView.js +70 -0
- package/lib/text/plain/plainTextView.js.map +1 -0
- package/lib/text/plain/plainUtils.d.ts +23 -0
- package/lib/text/plain/plainUtils.d.ts.map +1 -0
- package/lib/text/plain/plainUtils.js +51 -0
- package/lib/text/plain/plainUtils.js.map +1 -0
- package/lib/text/plain/quillView.d.ts +22 -0
- package/lib/text/plain/quillView.d.ts.map +1 -0
- package/lib/text/plain/quillView.js +106 -0
- package/lib/text/plain/quillView.js.map +1 -0
- package/lib/undoRedo.d.ts +51 -0
- package/lib/undoRedo.d.ts.map +1 -0
- package/lib/undoRedo.js +76 -0
- package/lib/undoRedo.js.map +1 -0
- package/lib/useObservation.js +6 -6
- package/lib/useObservation.js.map +1 -1
- package/lib/useTree.d.ts +7 -7
- package/lib/useTree.d.ts.map +1 -1
- package/lib/useTree.js +6 -6
- package/lib/useTree.js.map +1 -1
- package/package.json +28 -46
- package/react.test-files.tar +0 -0
- package/src/index.ts +10 -0
- package/src/propNode.ts +1 -1
- package/src/reactSharedTreeView.tsx +11 -13
- package/src/text/formatted/index.ts +11 -0
- package/src/text/formatted/quillFormattedView.tsx +627 -0
- package/src/text/index.ts +15 -0
- package/src/text/plain/index.ts +7 -0
- package/src/text/plain/plainTextView.tsx +110 -0
- package/src/text/plain/plainUtils.ts +68 -0
- package/src/text/plain/quillView.tsx +149 -0
- package/src/undoRedo.ts +117 -0
- package/src/useObservation.ts +6 -6
- package/src/useTree.ts +19 -12
- package/tsconfig.json +6 -0
- package/api-extractor/api-extractor-lint-alpha.cjs.json +0 -5
- package/api-extractor/api-extractor-lint-beta.cjs.json +0 -5
- package/api-extractor/api-extractor-lint-public.cjs.json +0 -5
- package/dist/alpha.d.ts +0 -45
- package/dist/beta.d.ts +0 -15
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -26
- package/dist/index.js.map +0 -1
- package/dist/package.json +0 -4
- package/dist/propNode.d.ts +0 -114
- package/dist/propNode.d.ts.map +0 -1
- package/dist/propNode.js +0 -43
- package/dist/propNode.js.map +0 -1
- package/dist/public.d.ts +0 -15
- package/dist/reactSharedTreeView.d.ts +0 -119
- package/dist/reactSharedTreeView.d.ts.map +0 -1
- package/dist/reactSharedTreeView.js +0 -206
- package/dist/reactSharedTreeView.js.map +0 -1
- package/dist/simpleIdentifier.d.ts +0 -19
- package/dist/simpleIdentifier.d.ts.map +0 -1
- package/dist/simpleIdentifier.js +0 -33
- package/dist/simpleIdentifier.js.map +0 -1
- package/dist/useObservation.d.ts +0 -83
- package/dist/useObservation.d.ts.map +0 -1
- package/dist/useObservation.js +0 -295
- package/dist/useObservation.js.map +0 -1
- package/dist/useTree.d.ts +0 -80
- package/dist/useTree.d.ts.map +0 -1
- package/dist/useTree.js +0 -137
- package/dist/useTree.js.map +0 -1
- package/tsconfig.cjs.json +0 -7
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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.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; } });
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/dist/package.json
DELETED
package/dist/propNode.d.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
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
|
package/dist/propNode.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"propNode.d.ts","sourceRoot":"","sources":["../src/propNode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEpE;;;;;;;;;GASG;AAEH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;CAAG;AAE5F;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAC1C,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC7B,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,GAExB,CAAC,SAAS,MAAM,CAAC,GACf,oBAAoB,CACpB,CAAC,EACD;KACE,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,SAAS,CAAC,GAET,CAAC,GACA;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wB,CAAC,CAAC,SAAS,kBAAkB,IAAI;IACpE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACtC,MAAM,EACN,aAAa,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,SAAS,CAClD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,QAAQ,GAAG,aAAa,GAAG,SAAS,IAAI,CAAC,SAAS,QAAQ,GAC3F,YAAY,CAAC,CAAC,CAAC,GACf,CAAC,CAAC;AAEL;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,GAAG,aAAa,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAE5F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAEzF"}
|
package/dist/propNode.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
package/dist/propNode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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, @typescript-eslint/no-empty-object-type\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
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
|
|
@@ -1,119 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactSharedTreeView.d.ts","sourceRoot":"","sources":["../src/reactSharedTreeView.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,cAAc,EAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,O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aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;QAChC,IAAI,EAAE,aAAa,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;KACzD,CAAC,CAAC;IAEH;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC;CAG5D;AAED;;;GAGG;AACH,8BAAsB,mBAAmB,CACvC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,CAE1D,SAAQ,cACR,YAAW,oBAAoB,CAAC,OAAO,CAAC;;IAExC,kBAAyB,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAIhE;;OAEG;IACH,IAAW,QAAQ,IAAI,QAAQ,CAAC,OAAO,CAAC,CAKvC;IAGD,SAAgB,iBAAiB,uCAG9B,cAAc,OAAO,CAAC,uBAKrB;CACJ;AA4CD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,mBAAmB,EAAE,EACtE,IAAI,EACJ,aAAa,EAAE,aAAa,EAC5B,cAAc,GACd,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG;IAC3B,IAAI,EAAE,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;CACtD,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAuBpB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,yBAAyB,CAAC;IAClD;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;CACnC"}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
30
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
31
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
32
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
33
|
-
};
|
|
34
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
38
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
39
|
-
};
|
|
40
|
-
var _ReactTreeDataObject_treeView;
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.TreeViewComponent = exports.ReactTreeDataObject = exports.treeDataObjectInternal = exports.treeDataObject = void 0;
|
|
43
|
-
const internal_1 = require("@fluidframework/aqueduct/internal");
|
|
44
|
-
const internal_2 = require("@fluidframework/tree/internal");
|
|
45
|
-
const React = __importStar(require("react"));
|
|
46
|
-
const propNode_js_1 = require("./propNode.js");
|
|
47
|
-
/**
|
|
48
|
-
* Opt into extra validation to detect encoding bugs and data corruption.
|
|
49
|
-
* As long as this is an experimental package, opting into extra validation (at a small perf and bundle size cost) seems reasonable.
|
|
50
|
-
*/
|
|
51
|
-
const SharedTree = (0, internal_2.configuredSharedTree)({
|
|
52
|
-
jsonValidator: internal_2.FormatValidatorBasic,
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
56
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
57
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
58
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
59
|
-
* @alpha
|
|
60
|
-
*/
|
|
61
|
-
function treeDataObject(treeConfiguration, createInitialTree) {
|
|
62
|
-
return treeDataObjectInternal(treeConfiguration, createInitialTree);
|
|
63
|
-
}
|
|
64
|
-
exports.treeDataObject = treeDataObject;
|
|
65
|
-
/**
|
|
66
|
-
* Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.
|
|
67
|
-
* @param treeConfiguration - See {@link IReactTreeDataObject.config}.
|
|
68
|
-
* @param createInitialTree - Function which populates the tree with initial data on document create.
|
|
69
|
-
* @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
function treeDataObjectInternal(treeConfiguration, createInitialTree) {
|
|
73
|
-
var _SchemaAwareTreeDataObject_treeView;
|
|
74
|
-
class SchemaAwareTreeDataObject extends ReactTreeDataObject {
|
|
75
|
-
constructor() {
|
|
76
|
-
super(...arguments);
|
|
77
|
-
this.config = treeConfiguration;
|
|
78
|
-
_SchemaAwareTreeDataObject_treeView.set(this, void 0);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The schema-aware view of the tree.
|
|
82
|
-
*/
|
|
83
|
-
get treeView() {
|
|
84
|
-
if (__classPrivateFieldGet(this, _SchemaAwareTreeDataObject_treeView, "f") === undefined) {
|
|
85
|
-
throw new Error("treeView has not been initialized.");
|
|
86
|
-
}
|
|
87
|
-
return __classPrivateFieldGet(this, _SchemaAwareTreeDataObject_treeView, "f");
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Converts the underlying ITree into a typed TreeView using the provided schema configuration.
|
|
91
|
-
*
|
|
92
|
-
* @param tree - The ITree instance to view.
|
|
93
|
-
* @returns A typed TreeView using the TodoList schema.
|
|
94
|
-
*/
|
|
95
|
-
initializeView() {
|
|
96
|
-
__classPrivateFieldSet(this, _SchemaAwareTreeDataObject_treeView, this.tree.viewWith(this.config), "f");
|
|
97
|
-
}
|
|
98
|
-
async initializingFirstTime() {
|
|
99
|
-
this.initializeView();
|
|
100
|
-
this.treeView.initialize(createInitialTree());
|
|
101
|
-
}
|
|
102
|
-
async initializingFromExisting() {
|
|
103
|
-
this.initializeView();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
_SchemaAwareTreeDataObject_treeView = new WeakMap();
|
|
107
|
-
SchemaAwareTreeDataObject.factory = new internal_1.PureDataObjectFactory(`TreeDataObject`, SchemaAwareTreeDataObject, [SharedTree.getFactory()], {});
|
|
108
|
-
return (0, internal_1.createDataObjectKind)(SchemaAwareTreeDataObject);
|
|
109
|
-
}
|
|
110
|
-
exports.treeDataObjectInternal = treeDataObjectInternal;
|
|
111
|
-
/**
|
|
112
|
-
* Generic DataObject for shared trees.
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
class ReactTreeDataObject extends internal_1.TreeDataObject {
|
|
116
|
-
constructor() {
|
|
117
|
-
super(...arguments);
|
|
118
|
-
_ReactTreeDataObject_treeView.set(this, void 0);
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
|
|
120
|
-
this.TreeViewComponent = ({ viewComponent, errorComponent, }) => TreeViewComponent({
|
|
121
|
-
tree: this,
|
|
122
|
-
viewComponent,
|
|
123
|
-
errorComponent,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* The schema-aware view of the tree.
|
|
128
|
-
*/
|
|
129
|
-
get treeView() {
|
|
130
|
-
if (__classPrivateFieldGet(this, _ReactTreeDataObject_treeView, "f") === undefined) {
|
|
131
|
-
throw new Error("treeView has not been initialized.");
|
|
132
|
-
}
|
|
133
|
-
return __classPrivateFieldGet(this, _ReactTreeDataObject_treeView, "f");
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.ReactTreeDataObject = ReactTreeDataObject;
|
|
137
|
-
_ReactTreeDataObject_treeView = new WeakMap();
|
|
138
|
-
function useViewCompatibility(view) {
|
|
139
|
-
const [compatibility, setCompatibility] = React.useState(view.compatibility);
|
|
140
|
-
React.useEffect(() => {
|
|
141
|
-
const updateCompatibility = () => {
|
|
142
|
-
setCompatibility(view.compatibility);
|
|
143
|
-
};
|
|
144
|
-
updateCompatibility();
|
|
145
|
-
return view.events.on("schemaChanged", updateCompatibility);
|
|
146
|
-
}, [view]);
|
|
147
|
-
return compatibility;
|
|
148
|
-
}
|
|
149
|
-
function useViewRoot(view) {
|
|
150
|
-
const [root, setRoot] = React.useState(undefined);
|
|
151
|
-
React.useEffect(() => {
|
|
152
|
-
const updateRoot = () => {
|
|
153
|
-
if (view.compatibility.canView) {
|
|
154
|
-
setRoot(view.root);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
setRoot(undefined);
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
updateRoot();
|
|
161
|
-
return view.events.on("rootChanged", updateRoot);
|
|
162
|
-
}, [view]);
|
|
163
|
-
return root;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* React component which handles schematizing trees.
|
|
167
|
-
* This includes displaying errors when the document can not be schematized.
|
|
168
|
-
* @alpha
|
|
169
|
-
*/
|
|
170
|
-
function TreeViewComponent({ tree, viewComponent: ViewComponent, errorComponent, }) {
|
|
171
|
-
const view = tree.treeView;
|
|
172
|
-
const compatibility = useViewCompatibility(view);
|
|
173
|
-
const root = useViewRoot(view);
|
|
174
|
-
const upgradeSchema = React.useCallback(() => view.upgradeSchema(), [view]);
|
|
175
|
-
// Note: this policy is on the stricter side and ensures that clients will only be able to submit edits when their view schema
|
|
176
|
-
// supports exactly the same documents as the stored schema.
|
|
177
|
-
// A realistic production application using this strategy would need to take steps to attempt to open the document using
|
|
178
|
-
// several different view schemas in order to ensure that their users don't temporarily lose access to documents while
|
|
179
|
-
// code rollout is in progress.
|
|
180
|
-
// Alternative policies can be implemented, see "Schema Evolvability" in SharedTree's README for more information.
|
|
181
|
-
if (!compatibility.isEquivalent) {
|
|
182
|
-
const Error = errorComponent ?? TreeErrorComponent;
|
|
183
|
-
return React.createElement(Error, { compatibility: compatibility, upgradeSchema: upgradeSchema });
|
|
184
|
-
}
|
|
185
|
-
if (root === undefined) {
|
|
186
|
-
return React.createElement("div", null, "View not set");
|
|
187
|
-
}
|
|
188
|
-
return React.createElement(ViewComponent, { root: (0, propNode_js_1.toPropTreeNode)(root) });
|
|
189
|
-
}
|
|
190
|
-
exports.TreeViewComponent = TreeViewComponent;
|
|
191
|
-
/**
|
|
192
|
-
* React component which displays schema errors and allows upgrading schema when possible.
|
|
193
|
-
*/
|
|
194
|
-
function TreeErrorComponent({ compatibility, upgradeSchema, }) {
|
|
195
|
-
// eslint-disable-next-line unicorn/prefer-ternary
|
|
196
|
-
if (compatibility.canUpgrade) {
|
|
197
|
-
return (React.createElement("div", null,
|
|
198
|
-
React.createElement("div", null, "Document is incompatible with current version of the application, but the document format can be updated. This may prevent other versions of the application from opening this document."),
|
|
199
|
-
React.createElement("button", { onClick: upgradeSchema }, "Upgrade"),
|
|
200
|
-
";"));
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
return (React.createElement("div", null, "Document is incompatible with current version of the application, and the document format cannot be updated. The document is likely from a newer or otherwise incompatible version of the application, or a different application."));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
//# sourceMappingURL=reactSharedTreeView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactSharedTreeView.js","sourceRoot":"","sources":["../src/reactSharedTreeView.tsx"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gEAI2C;AAY3C,4DAA2F;AAC3F,6CAA+B;AAE/B,+CAAmE;AAEnE;;;GAGG;AACH,MAAM,UAAU,GAAG,IAAA,+BAAoB,EAAC;IACvC,aAAa,EAAE,+BAAoB;CACnC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC7B,iBAAiD,EACjD,iBAAsE;IAEtE,OAAO,sBAAsB,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;AACrE,CAAC;AALD,wCAKC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACrC,iBAAiD,EACjD,iBAAsE;;IAItE,MAAM,yBAA0B,SAAQ,mBAA4B;QAApE;;YAC0B,WAAM,GAAG,iBAAiB,CAAC;YASp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AG,IAAI,CAAC,QAAQ,CAAC;IAE3B,MAAM,aAAa,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,GAAS,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAElF,8HAA8H;IAC9H,4DAA4D;IAC5D,wHAAwH;IACxH,sHAAsH;IACtH,+BAA+B;IAC/B,kHAAkH;IAClH,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,cAAc,IAAI,kBAAkB,CAAC;QACnD,OAAO,oBAAC,KAAK,IAAC,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,GAAI,CAAC;IAC9E,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,gDAAuB,CAAC;IAChC,CAAC;IAED,OAAO,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAA,4BAAc,EAAC,IAAI,CAAC,GAAI,CAAC;AACtD,CAAC;AA7BD,8CA6BC;AAiBD;;GAEG;AACH,SAAS,kBAAkB,CAAC,EAC3B,aAAa,EACb,aAAa,GAIb;IACA,kDAAkD;IAClD,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QAC9B,OAAO,CACN;YACC,4NAIM;YACN,gCAAQ,OAAO,EAAE,aAAa,cAAkB;gBAC3C,CACN,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO,CACN,sQAIM,CACN,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tPureDataObjectFactory,\n\tTreeDataObject,\n\tcreateDataObjectKind,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport type {\n\tSchemaCompatibilityStatus,\n\tTreeViewConfiguration,\n\tTreeFieldFromImplicitField,\n\tTreeView,\n\tImplicitFieldSchema,\n\tInsertableTreeFieldFromImplicitField,\n} from \"@fluidframework/tree\";\nimport { configuredSharedTree, FormatValidatorBasic } from \"@fluidframework/tree/internal\";\nimport * as React from \"react\";\n\nimport { toPropTreeNode, type PropTreeValue } from \"./propNode.js\";\n\n/**\n * Opt into extra validation to detect encoding bugs and data corruption.\n * As long as this is an experimental package, opting into extra validation (at a small perf and bundle size cost) seems reasonable.\n */\nconst SharedTree = configuredSharedTree({\n\tjsonValidator: FormatValidatorBasic,\n});\n\n/**\n * Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.\n * @param treeConfiguration - See {@link IReactTreeDataObject.config}.\n * @param createInitialTree - Function which populates the tree with initial data on document create.\n * @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.\n * @alpha\n */\nexport function treeDataObject<TSchema extends ImplicitFieldSchema>(\n\ttreeConfiguration: TreeViewConfiguration<TSchema>,\n\tcreateInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>,\n): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable> {\n\treturn treeDataObjectInternal(treeConfiguration, createInitialTree);\n}\n\n/**\n * Defines a DataObject for a {@link @fluidframework/tree#SharedTree} with a built in {@link @fluidframework/tree#TreeViewConfiguration}.\n * @param treeConfiguration - See {@link IReactTreeDataObject.config}.\n * @param createInitialTree - Function which populates the tree with initial data on document create.\n * @returns A {@link @fluidframework/fluid-static#DataObjectClass} to allow easy use of a SharedTree in a ContainerSchema.\n * @internal\n */\nexport function treeDataObjectInternal<TSchema extends ImplicitFieldSchema>(\n\ttreeConfiguration: TreeViewConfiguration<TSchema>,\n\tcreateInitialTree: () => InsertableTreeFieldFromImplicitField<TSchema>,\n): SharedObjectKind<IReactTreeDataObject<TSchema> & IFluidLoadable & TreeDataObject> & {\n\treadonly factory: IFluidDataStoreFactory;\n} {\n\tclass SchemaAwareTreeDataObject extends ReactTreeDataObject<TSchema> {\n\t\tpublic override readonly config = treeConfiguration;\n\n\t\tpublic static readonly factory = new PureDataObjectFactory<ReactTreeDataObject<TSchema>>(\n\t\t\t`TreeDataObject`,\n\t\t\tSchemaAwareTreeDataObject,\n\t\t\t[SharedTree.getFactory()],\n\t\t\t{},\n\t\t);\n\n\t\t#treeView: TreeView<TSchema> | undefined;\n\n\t\t/**\n\t\t * The schema-aware view of the tree.\n\t\t */\n\t\tpublic get treeView(): TreeView<TSchema> {\n\t\t\tif (this.#treeView === undefined) {\n\t\t\t\tthrow new Error(\"treeView has not been initialized.\");\n\t\t\t}\n\t\t\treturn this.#treeView;\n\t\t}\n\n\t\t/**\n\t\t * Converts the underlying ITree into a typed TreeView using the provided schema configuration.\n\t\t *\n\t\t * @param tree - The ITree instance to view.\n\t\t * @returns A typed TreeView using the TodoList schema.\n\t\t */\n\t\tprivate initializeView(): void {\n\t\t\tthis.#treeView = this.tree.viewWith(this.config);\n\t\t}\n\n\t\tprotected override async initializingFirstTime(): Promise<void> {\n\t\t\tthis.initializeView();\n\t\t\tthis.treeView.initialize(createInitialTree());\n\t\t}\n\n\t\tprotected override async initializingFromExisting(): Promise<void> {\n\t\t\tthis.initializeView();\n\t\t}\n\t}\n\treturn createDataObjectKind(SchemaAwareTreeDataObject);\n}\n\n/**\n * A schema-aware tree-backed DataObject, extended with a React Component to view the tree.\n * @remarks Allows for the Tree's schema to be baked into the container schema.\n * @sealed @alpha\n */\nexport interface IReactTreeDataObject<TSchema extends ImplicitFieldSchema> {\n\t/**\n\t * The configuration used to initialize new documents, as well as to interpret (schematize) existing ones.\n\t *\n\t * @remarks\n\t * The fact that a single view schema is provided here (on the data object) makes it impossible to try and apply multiple different schema.\n\t * Since the view schema currently does not provide any adapters for handling differences between view and stored schema,\n\t * it's also impossible for this single view schema to handle multiple different stored schema.\n\t * Therefore, with this current API, two different applications (or different versions of the same application)\n\t * with differing stored schema requirements (as implied by their view schema) can not collaborate on the same tree.\n\t * The only schema evolution that's currently possible is upgrading the schema to one that supports a superset of what the old schema allowed,\n\t * and collaborating between clients which have view schema that exactly correspond to that stored schema.\n\t * Future work on tree as well as these utilities should address this limitation.\n\t */\n\treadonly config: TreeViewConfiguration<TSchema>;\n\n\t/**\n\t * The schema-aware view of the tree.\n\t */\n\treadonly treeView: TreeView<TSchema>;\n\n\t/**\n\t * React component which handles schematizing trees.\n\t * This includes displaying errors when the document can not be viewed using the view schema.\n\t *\n\t * @privateRemarks\n\t * 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,\n\t * and thus making it a member avoids the user of this from having to explicitly provide the type parameter.\n\t * This is an arrow function not a method so it gets the correct this when not called as a member.\n\t */\n\treadonly TreeViewComponent: (props: TreeViewProps<TSchema>) => React.JSX.Element;\n}\n\n/**\n * React props for viewing a tree.\n * @input @alpha\n */\nexport interface TreeViewProps<TSchema extends ImplicitFieldSchema> {\n\t/**\n\t * Component to display the tree content.\n\t */\n\treadonly viewComponent: React.FC<{\n\t\troot: PropTreeValue<TreeFieldFromImplicitField<TSchema>>;\n\t}>;\n\n\t/**\n\t * Component to display instead of the {@link TreeViewProps.viewComponent}\n\t * when tree content is not compatible with the {@link @fluidframework/tree#TreeViewConfiguration}.\n\t *\n\t * @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.\n\t */\n\treadonly errorComponent?: React.FC<SchemaIncompatibleProps>;\n\n\t// TODO: Once its possible to query the status of individual schema upgrades, provide more options here for handling such cases.\n}\n\n/**\n * Generic DataObject for shared trees.\n * @internal\n */\nexport abstract class ReactTreeDataObject<\n\t\tTSchema extends ImplicitFieldSchema = ImplicitFieldSchema,\n\t>\n\textends TreeDataObject\n\timplements IReactTreeDataObject<TSchema>\n{\n\tpublic abstract readonly config: TreeViewConfiguration<TSchema>;\n\n\treadonly #treeView: TreeView<TSchema> | undefined;\n\n\t/**\n\t * The schema-aware view of the tree.\n\t */\n\tpublic get treeView(): TreeView<TSchema> {\n\t\tif (this.#treeView === undefined) {\n\t\t\tthrow new Error(\"treeView has not been initialized.\");\n\t\t}\n\t\treturn this.#treeView;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type\n\tpublic readonly TreeViewComponent = ({\n\t\tviewComponent,\n\t\terrorComponent,\n\t}: TreeViewProps<TSchema>) =>\n\t\tTreeViewComponent<TSchema>({\n\t\t\ttree: this,\n\t\t\tviewComponent,\n\t\t\terrorComponent,\n\t\t});\n}\n\nfunction useViewCompatibility<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): SchemaCompatibilityStatus {\n\tconst [compatibility, setCompatibility] = React.useState<SchemaCompatibilityStatus>(\n\t\tview.compatibility,\n\t);\n\n\tReact.useEffect(() => {\n\t\tconst updateCompatibility = (): void => {\n\t\t\tsetCompatibility(view.compatibility);\n\t\t};\n\n\t\tupdateCompatibility();\n\t\treturn view.events.on(\"schemaChanged\", updateCompatibility);\n\t}, [view]);\n\n\treturn compatibility;\n}\n\nfunction useViewRoot<TSchema extends ImplicitFieldSchema>(\n\tview: TreeView<TSchema>,\n): TreeFieldFromImplicitField<TSchema> | undefined {\n\tconst [root, setRoot] = React.useState<TreeFieldFromImplicitField<TSchema> | undefined>(\n\t\tundefined,\n\t);\n\n\tReact.useEffect(() => {\n\t\tconst updateRoot = (): void => {\n\t\t\tif (view.compatibility.canView) {\n\t\t\t\tsetRoot(view.root);\n\t\t\t} else {\n\t\t\t\tsetRoot(undefined);\n\t\t\t}\n\t\t};\n\n\t\tupdateRoot();\n\t\treturn view.events.on(\"rootChanged\", updateRoot);\n\t}, [view]);\n\n\treturn root;\n}\n\n/**\n * React component which handles schematizing trees.\n * This includes displaying errors when the document can not be schematized.\n * @alpha\n */\nexport function TreeViewComponent<TSchema extends ImplicitFieldSchema>({\n\ttree,\n\tviewComponent: ViewComponent,\n\terrorComponent,\n}: TreeViewProps<TSchema> & {\n\ttree: Pick<IReactTreeDataObject<TSchema>, \"treeView\">;\n}): React.JSX.Element {\n\tconst view = tree.treeView;\n\n\tconst compatibility = useViewCompatibility(view);\n\tconst root = useViewRoot(view);\n\tconst upgradeSchema = React.useCallback((): void => view.upgradeSchema(), [view]);\n\n\t// Note: this policy is on the stricter side and ensures that clients will only be able to submit edits when their view schema\n\t// supports exactly the same documents as the stored schema.\n\t// A realistic production application using this strategy would need to take steps to attempt to open the document using\n\t// several different view schemas in order to ensure that their users don't temporarily lose access to documents while\n\t// code rollout is in progress.\n\t// Alternative policies can be implemented, see \"Schema Evolvability\" in SharedTree's README for more information.\n\tif (!compatibility.isEquivalent) {\n\t\tconst Error = errorComponent ?? TreeErrorComponent;\n\t\treturn <Error compatibility={compatibility} upgradeSchema={upgradeSchema} />;\n\t}\n\n\tif (root === undefined) {\n\t\treturn <div>View not set</div>;\n\t}\n\n\treturn <ViewComponent root={toPropTreeNode(root)} />;\n}\n\n/**\n * React Props for displaying when the opened document is incompatible with the required view schema.\n * @alpha\n */\nexport interface SchemaIncompatibleProps {\n\t/**\n\t * Information about the view schema's compatibility with the stored schema.\n\t */\n\treadonly compatibility: SchemaCompatibilityStatus;\n\t/**\n\t * Callback to request that the stored schema in the document be upgraded.\n\t */\n\treadonly upgradeSchema: () => void;\n}\n\n/**\n * React component which displays schema errors and allows upgrading schema when possible.\n */\nfunction TreeErrorComponent({\n\tcompatibility,\n\tupgradeSchema,\n}: {\n\tcompatibility: SchemaCompatibilityStatus;\n\tupgradeSchema: () => void;\n}): React.JSX.Element {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (compatibility.canUpgrade) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<div>\n\t\t\t\t\tDocument is incompatible with current version of the application, but the document\n\t\t\t\t\tformat can be updated. This may prevent other versions of the application from\n\t\t\t\t\topening this document.\n\t\t\t\t</div>\n\t\t\t\t<button onClick={upgradeSchema}>Upgrade</button>;\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\tDocument is incompatible with current version of the application, and the document\n\t\t\t\tformat cannot be updated. The document is likely from a newer or otherwise incompatible\n\t\t\t\tversion of the application, or a different application.\n\t\t\t</div>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Associates a unique number with an object.
|
|
7
|
-
* @remarks
|
|
8
|
-
* The ID number is tied to the object identity, not the object's contents; modifying the object will not cause it to get a different ID.
|
|
9
|
-
*
|
|
10
|
-
* This can be handy for generating {@link https://react.dev/learn/rendering-lists#where-to-get-your-key | keys for React lists} from TreeNodes.
|
|
11
|
-
*
|
|
12
|
-
* Most cases which could use this function should just use the objects themselves instead of getting IDs from them, since the objects will have the same equality as the IDs.
|
|
13
|
-
* For example, if storing data associated with the objects in a map, using the object as the key is more efficient than getting an ID from it and using that.
|
|
14
|
-
* This functions exists to deal with the edge case where you would like to use object identity, but you can't.
|
|
15
|
-
* React keys are an examples of such a case, since React does not allow objects as keys.
|
|
16
|
-
* @alpha
|
|
17
|
-
*/
|
|
18
|
-
export declare function objectIdNumber(object: object): number;
|
|
19
|
-
//# sourceMappingURL=simpleIdentifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simpleIdentifier.d.ts","sourceRoot":"","sources":["../src/simpleIdentifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQrD"}
|