@sanity/hierarchical-document-list 1.0.0 → 1.1.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/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.idea/hierarchical-document-list.iml +11 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/CHANGELOG.md +15 -0
- package/README.md +329 -297
- package/commitlint.config.js +3 -0
- package/lib/TreeDeskStructure.d.ts +8 -8
- package/lib/TreeDeskStructure.js +96 -96
- package/lib/TreeInputComponent.d.ts +19 -19
- package/lib/TreeInputComponent.js +50 -52
- package/lib/components/DeskWarning.d.ts +6 -6
- package/lib/components/DeskWarning.js +46 -46
- package/lib/components/DocumentInNode.d.ts +11 -11
- package/lib/components/DocumentInNode.js +81 -82
- package/lib/components/DocumentPreviewStatus.d.ts +7 -7
- package/lib/components/DocumentPreviewStatus.js +39 -39
- package/lib/components/NodeActions.d.ts +10 -10
- package/lib/components/NodeActions.js +61 -61
- package/lib/components/NodeContentRenderer.d.ts +8 -8
- package/lib/components/NodeContentRenderer.js +105 -105
- package/lib/components/PlaceholderDropzone.d.ts +9 -9
- package/lib/components/PlaceholderDropzone.js +30 -30
- package/lib/components/SuppressedDnDManager.d.ts +2 -0
- package/lib/components/SuppressedDnDManager.js +59 -0
- package/lib/components/TreeEditor.d.ts +12 -12
- package/lib/components/TreeEditor.js +74 -59
- package/lib/components/TreeEditorErrorBoundary.d.ts +16 -3
- package/lib/components/TreeEditorErrorBoundary.js +74 -59
- package/lib/components/TreeNodeRenderer.d.ts +3 -3
- package/lib/components/TreeNodeRenderer.js +59 -59
- package/lib/components/TreeNodeRendererScaffold.d.ts +4 -4
- package/lib/components/TreeNodeRendererScaffold.js +44 -44
- package/lib/createDeskHierarchy.d.ts +14 -14
- package/lib/createDeskHierarchy.js +84 -85
- package/lib/createHierarchicalSchemas.d.ts +98 -78
- package/lib/createHierarchicalSchemas.js +138 -138
- package/lib/hooks/useAllItems.d.ts +7 -7
- package/lib/hooks/useAllItems.js +119 -119
- package/lib/hooks/useLocalTree.d.ts +17 -17
- package/lib/hooks/useLocalTree.js +59 -59
- package/lib/hooks/useTreeOperations.d.ts +9 -9
- package/lib/hooks/useTreeOperations.js +39 -39
- package/lib/hooks/useTreeOperationsProvider.d.ts +14 -14
- package/lib/hooks/useTreeOperationsProvider.js +85 -85
- package/lib/index.d.ts +3 -3
- package/lib/index.js +12 -12
- package/lib/schemas/hierarchy.tree.d.ts +13 -13
- package/lib/schemas/hierarchy.tree.js +19 -19
- package/lib/types.d.ts +128 -0
- package/lib/types.js +2 -0
- package/lib/utils/flatDataToTree.d.ts +6 -6
- package/lib/utils/flatDataToTree.js +26 -26
- package/lib/utils/getAdjescentNodes.d.ts +12 -12
- package/lib/utils/getAdjescentNodes.js +19 -19
- package/lib/utils/getCommonTreeProps.d.ts +7 -7
- package/lib/utils/getCommonTreeProps.js +33 -33
- package/lib/utils/getTreeHeight.d.ts +3 -3
- package/lib/utils/getTreeHeight.js +11 -11
- package/lib/utils/gradientPatchAdapter.d.ts +4 -4
- package/lib/utils/gradientPatchAdapter.js +40 -42
- package/lib/utils/idUtils.d.ts +2 -2
- package/lib/utils/idUtils.js +13 -13
- package/lib/utils/injectNodeTypeInPatches.d.ts +12 -12
- package/lib/utils/injectNodeTypeInPatches.js +59 -58
- package/lib/utils/moveItemInArray.d.ts +5 -5
- package/lib/utils/moveItemInArray.js +26 -26
- package/lib/utils/throwError.d.ts +7 -7
- package/lib/utils/throwError.js +12 -12
- package/lib/utils/treeData.d.ts +18 -18
- package/lib/utils/treeData.js +118 -118
- package/lib/utils/treePatches.d.ts +15 -15
- package/lib/utils/treePatches.js +171 -171
- package/lint-staged.config.js +4 -0
- package/package.json +65 -55
- package/sanity.json +12 -12
- package/tsconfig.json +20 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type Patch = Record<string, any>;
|
|
2
|
-
declare type GradientPatch = Record<string, any>;
|
|
3
|
-
export declare function toGradient(patches: Patch[]): GradientPatch[];
|
|
4
|
-
export {};
|
|
1
|
+
declare type Patch = Record<string, any>;
|
|
2
|
+
declare type GradientPatch = Record<string, any>;
|
|
3
|
+
export declare function toGradient(patches: Patch[]): GradientPatch[];
|
|
4
|
+
export {};
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_d;
|
|
42
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toGradient = void 0;
|
|
4
|
+
// Adapted from @sanity/form-builder/src/sanity/utils/gradientPatchAdapter.ts
|
|
5
|
+
var mutator_1 = require("@sanity/mutator");
|
|
6
|
+
function toGradient(patches) {
|
|
7
|
+
return patches.map(toGradientPatch);
|
|
8
|
+
}
|
|
9
|
+
exports.toGradient = toGradient;
|
|
10
|
+
function toGradientPatch(patch) {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
var matchPath = (0, mutator_1.arrayToJSONMatchPath)(patch.path || []);
|
|
13
|
+
if (patch.type === 'insert') {
|
|
14
|
+
var position = patch.position, items = patch.items;
|
|
15
|
+
return {
|
|
16
|
+
insert: (_a = {},
|
|
17
|
+
_a[position] = matchPath,
|
|
18
|
+
_a.items = items,
|
|
19
|
+
_a)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (patch.type === 'unset') {
|
|
23
|
+
return {
|
|
24
|
+
unset: [matchPath]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (!patch.type) {
|
|
28
|
+
throw new Error("Missing patch type in patch ".concat(JSON.stringify(patch)));
|
|
29
|
+
}
|
|
30
|
+
if (matchPath) {
|
|
31
|
+
return _b = {},
|
|
32
|
+
_b[patch.type] = (_c = {},
|
|
33
|
+
_c[matchPath] = patch.value,
|
|
34
|
+
_c),
|
|
35
|
+
_b;
|
|
36
|
+
}
|
|
37
|
+
return _d = {},
|
|
38
|
+
_d[patch.type] = patch.value,
|
|
39
|
+
_d;
|
|
40
|
+
}
|
package/lib/utils/idUtils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function unprefixId(_id?: string): string;
|
|
2
|
-
export declare function isDraft(_id?: string): boolean;
|
|
1
|
+
export declare function unprefixId(_id?: string): string;
|
|
2
|
+
export declare function isDraft(_id?: string): boolean;
|
package/lib/utils/idUtils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDraft = exports.unprefixId = void 0;
|
|
4
|
-
function unprefixId(_id) {
|
|
5
|
-
if (_id === void 0) { _id = ''; }
|
|
6
|
-
return _id.replace('drafts.', '');
|
|
7
|
-
}
|
|
8
|
-
exports.unprefixId = unprefixId;
|
|
9
|
-
function isDraft(_id) {
|
|
10
|
-
if (_id === void 0) { _id = ''; }
|
|
11
|
-
return _id.startsWith('drafts.');
|
|
12
|
-
}
|
|
13
|
-
exports.isDraft = isDraft;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDraft = exports.unprefixId = void 0;
|
|
4
|
+
function unprefixId(_id) {
|
|
5
|
+
if (_id === void 0) { _id = ''; }
|
|
6
|
+
return _id.replace('drafts.', '');
|
|
7
|
+
}
|
|
8
|
+
exports.unprefixId = unprefixId;
|
|
9
|
+
function isDraft(_id) {
|
|
10
|
+
if (_id === void 0) { _id = ''; }
|
|
11
|
+
return _id.startsWith('drafts.');
|
|
12
|
+
}
|
|
13
|
+
exports.isDraft = isDraft;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export declare function getSchemaTypeName(documentType: string, type: 'document' | 'node' | 'nodeValue' | 'array'): string;
|
|
2
|
-
/**
|
|
3
|
-
* Temporary value of nodes' `_type` before they are normalized and persisted as the user-defined choice.
|
|
4
|
-
*/
|
|
5
|
-
export declare const DEFAULT_DOC_TYPE = "hierarchy.tree";
|
|
6
|
-
export declare const INTERNAL_NODE_TYPE: string;
|
|
7
|
-
export declare const INTERNAL_NODE_VALUE_TYPE: string;
|
|
8
|
-
export declare const INTERNAL_NODE_ARRAY_TYPE: string;
|
|
9
|
-
/**
|
|
10
|
-
* Barebones recursive utility to inject the desired nodeObjectType in patches generated in deeply nested components and utilities.
|
|
11
|
-
*/
|
|
12
|
-
export default function injectNodeTypeInPatches(patchData: any, documentType: string): any;
|
|
1
|
+
export declare function getSchemaTypeName(documentType: string, type: 'document' | 'node' | 'nodeValue' | 'array'): string;
|
|
2
|
+
/**
|
|
3
|
+
* Temporary value of nodes' `_type` before they are normalized and persisted as the user-defined choice.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_DOC_TYPE = "hierarchy.tree";
|
|
6
|
+
export declare const INTERNAL_NODE_TYPE: string;
|
|
7
|
+
export declare const INTERNAL_NODE_VALUE_TYPE: string;
|
|
8
|
+
export declare const INTERNAL_NODE_ARRAY_TYPE: string;
|
|
9
|
+
/**
|
|
10
|
+
* Barebones recursive utility to inject the desired nodeObjectType in patches generated in deeply nested components and utilities.
|
|
11
|
+
*/
|
|
12
|
+
export default function injectNodeTypeInPatches(patchData: any, documentType: string): any;
|
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.INTERNAL_NODE_ARRAY_TYPE = exports.INTERNAL_NODE_VALUE_TYPE = exports.INTERNAL_NODE_TYPE = exports.DEFAULT_DOC_TYPE = exports.getSchemaTypeName = void 0;
|
|
15
|
-
function getSchemaTypeName(documentType, type) {
|
|
16
|
-
switch (type) {
|
|
17
|
-
case 'document':
|
|
18
|
-
return documentType;
|
|
19
|
-
case 'array':
|
|
20
|
-
return "".concat(documentType, ".array");
|
|
21
|
-
case 'node':
|
|
22
|
-
return "".concat(documentType, ".node");
|
|
23
|
-
case 'nodeValue':
|
|
24
|
-
return "".concat(documentType, ".nodeValue");
|
|
25
|
-
default:
|
|
26
|
-
return documentType;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.getSchemaTypeName = getSchemaTypeName;
|
|
30
|
-
/**
|
|
31
|
-
* Temporary value of nodes' `_type` before they are normalized and persisted as the user-defined choice.
|
|
32
|
-
*/
|
|
33
|
-
exports.DEFAULT_DOC_TYPE = 'hierarchy.tree';
|
|
34
|
-
exports.INTERNAL_NODE_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'node');
|
|
35
|
-
exports.INTERNAL_NODE_VALUE_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'nodeValue');
|
|
36
|
-
exports.INTERNAL_NODE_ARRAY_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'array');
|
|
37
|
-
/**
|
|
38
|
-
* Barebones recursive utility to inject the desired nodeObjectType in patches generated in deeply nested components and utilities.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.INTERNAL_NODE_ARRAY_TYPE = exports.INTERNAL_NODE_VALUE_TYPE = exports.INTERNAL_NODE_TYPE = exports.DEFAULT_DOC_TYPE = exports.getSchemaTypeName = void 0;
|
|
15
|
+
function getSchemaTypeName(documentType, type) {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'document':
|
|
18
|
+
return documentType;
|
|
19
|
+
case 'array':
|
|
20
|
+
return "".concat(documentType, ".array");
|
|
21
|
+
case 'node':
|
|
22
|
+
return "".concat(documentType, ".node");
|
|
23
|
+
case 'nodeValue':
|
|
24
|
+
return "".concat(documentType, ".nodeValue");
|
|
25
|
+
default:
|
|
26
|
+
return documentType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.getSchemaTypeName = getSchemaTypeName;
|
|
30
|
+
/**
|
|
31
|
+
* Temporary value of nodes' `_type` before they are normalized and persisted as the user-defined choice.
|
|
32
|
+
*/
|
|
33
|
+
exports.DEFAULT_DOC_TYPE = 'hierarchy.tree';
|
|
34
|
+
exports.INTERNAL_NODE_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'node');
|
|
35
|
+
exports.INTERNAL_NODE_VALUE_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'nodeValue');
|
|
36
|
+
exports.INTERNAL_NODE_ARRAY_TYPE = getSchemaTypeName(exports.DEFAULT_DOC_TYPE, 'array');
|
|
37
|
+
/**
|
|
38
|
+
* Barebones recursive utility to inject the desired nodeObjectType in patches generated in deeply nested components and utilities.
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
41
|
+
function injectNodeTypeInPatches(patchData, documentType) {
|
|
42
|
+
if (Array.isArray(patchData)) {
|
|
43
|
+
return patchData.map(function (child) { return injectNodeTypeInPatches(child, documentType); });
|
|
44
|
+
}
|
|
45
|
+
if (typeof patchData === 'object' && patchData !== null) {
|
|
46
|
+
return Object.keys(patchData).reduce(function (newObject, key) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
var value = patchData[key];
|
|
49
|
+
if (key === '_type' &&
|
|
50
|
+
typeof value === 'string' &&
|
|
51
|
+
[exports.INTERNAL_NODE_TYPE, exports.INTERNAL_NODE_VALUE_TYPE].includes(value)) {
|
|
52
|
+
return __assign(__assign({}, newObject), (_a = {}, _a[key] = getSchemaTypeName(documentType, value === exports.INTERNAL_NODE_TYPE ? 'node' : 'nodeValue'), _a));
|
|
53
|
+
}
|
|
54
|
+
return __assign(__assign({}, newObject), (_b = {}, _b[key] = injectNodeTypeInPatches(value, documentType), _b));
|
|
55
|
+
}, {});
|
|
56
|
+
}
|
|
57
|
+
return patchData;
|
|
58
|
+
}
|
|
59
|
+
exports.default = injectNodeTypeInPatches;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export default function moveItemInArray<ItemType = unknown>({ array, fromIndex, toIndex }: {
|
|
2
|
-
array: ItemType[];
|
|
3
|
-
fromIndex: number;
|
|
4
|
-
toIndex: number;
|
|
5
|
-
}): ItemType[];
|
|
1
|
+
export default function moveItemInArray<ItemType = unknown>({ array, fromIndex, toIndex }: {
|
|
2
|
+
array: ItemType[];
|
|
3
|
+
fromIndex: number;
|
|
4
|
+
toIndex: number;
|
|
5
|
+
}): ItemType[];
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
function moveItemInArray(_a) {
|
|
13
|
-
var array = _a.array, fromIndex = _a.fromIndex, toIndex = _a.toIndex;
|
|
14
|
-
if (fromIndex === toIndex) {
|
|
15
|
-
return array;
|
|
16
|
-
}
|
|
17
|
-
var newArray = __spreadArray([], array, true);
|
|
18
|
-
var target = newArray[fromIndex];
|
|
19
|
-
var inc = toIndex < fromIndex ? -1 : 1;
|
|
20
|
-
for (var i = fromIndex; i !== toIndex; i += inc) {
|
|
21
|
-
newArray[i] = newArray[i + inc];
|
|
22
|
-
}
|
|
23
|
-
newArray[toIndex] = target;
|
|
24
|
-
return newArray;
|
|
25
|
-
}
|
|
26
|
-
exports.default = moveItemInArray;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
function moveItemInArray(_a) {
|
|
13
|
+
var array = _a.array, fromIndex = _a.fromIndex, toIndex = _a.toIndex;
|
|
14
|
+
if (fromIndex === toIndex) {
|
|
15
|
+
return array;
|
|
16
|
+
}
|
|
17
|
+
var newArray = __spreadArray([], array, true);
|
|
18
|
+
var target = newArray[fromIndex];
|
|
19
|
+
var inc = toIndex < fromIndex ? -1 : 1;
|
|
20
|
+
for (var i = fromIndex; i !== toIndex; i += inc) {
|
|
21
|
+
newArray[i] = newArray[i + inc];
|
|
22
|
+
}
|
|
23
|
+
newArray[toIndex] = target;
|
|
24
|
+
return newArray;
|
|
25
|
+
}
|
|
26
|
+
exports.default = moveItemInArray;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare const ERROR_MESSAGES: {
|
|
2
|
-
invalidDocumentId: string;
|
|
3
|
-
invalidDocumentType: string;
|
|
4
|
-
invalidReferenceTo: string;
|
|
5
|
-
};
|
|
6
|
-
export default function throwError(message: keyof typeof ERROR_MESSAGES, extraContext?: string): void;
|
|
7
|
-
export {};
|
|
1
|
+
declare const ERROR_MESSAGES: {
|
|
2
|
+
invalidDocumentId: string;
|
|
3
|
+
invalidDocumentType: string;
|
|
4
|
+
invalidReferenceTo: string;
|
|
5
|
+
};
|
|
6
|
+
export default function throwError(message: keyof typeof ERROR_MESSAGES, extraContext?: string): void;
|
|
7
|
+
export {};
|
package/lib/utils/throwError.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var ERROR_MESSAGES = {
|
|
4
|
-
invalidDocumentId: 'Please add a documentId to your tree',
|
|
5
|
-
invalidDocumentType: 'Please add a valid documentType to createHierarchicalSchemas',
|
|
6
|
-
invalidReferenceTo: "Missing valid 'referenceTo' value"
|
|
7
|
-
};
|
|
8
|
-
function throwError(message, extraContext) {
|
|
9
|
-
if (extraContext === void 0) { extraContext = ''; }
|
|
10
|
-
throw new Error("[hierarchical input] ".concat(ERROR_MESSAGES[message], " ").concat(extraContext));
|
|
11
|
-
}
|
|
12
|
-
exports.default = throwError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var ERROR_MESSAGES = {
|
|
4
|
+
invalidDocumentId: 'Please add a documentId to your tree',
|
|
5
|
+
invalidDocumentType: 'Please add a valid documentType to createHierarchicalSchemas',
|
|
6
|
+
invalidReferenceTo: "Missing valid 'referenceTo' value"
|
|
7
|
+
};
|
|
8
|
+
function throwError(message, extraContext) {
|
|
9
|
+
if (extraContext === void 0) { extraContext = ''; }
|
|
10
|
+
throw new Error("[hierarchical input] ".concat(ERROR_MESSAGES[message], " ").concat(extraContext));
|
|
11
|
+
}
|
|
12
|
+
exports.default = throwError;
|
package/lib/utils/treeData.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { SanityDocument } from '@sanity/client';
|
|
2
|
-
import { TreeItem } from 'react-sortable-tree';
|
|
3
|
-
import { AllItems, EnhancedTreeItem, LocalTreeItem, StoredTreeItem, VisibilityMap } from '../types';
|
|
4
|
-
export declare const dataToEditorTree: ({ tree, allItems, visibilityMap }: {
|
|
5
|
-
tree: StoredTreeItem[];
|
|
6
|
-
allItems: AllItems;
|
|
7
|
-
visibilityMap: VisibilityMap;
|
|
8
|
-
}) => LocalTreeItem[];
|
|
9
|
-
export declare const flatTree: (tree: TreeItem[]) => TreeItem[];
|
|
10
|
-
export interface FetchData {
|
|
11
|
-
mainTree?: LocalTreeItem[];
|
|
12
|
-
allItems?: SanityDocument[];
|
|
13
|
-
}
|
|
14
|
-
export declare const getUnaddedItems: (data: {
|
|
15
|
-
allItems: AllItems;
|
|
16
|
-
tree: StoredTreeItem[];
|
|
17
|
-
}) => EnhancedTreeItem[];
|
|
18
|
-
export declare function normalizeNodeForStorage(item: LocalTreeItem): StoredTreeItem;
|
|
1
|
+
import { SanityDocument } from '@sanity/client';
|
|
2
|
+
import { TreeItem } from 'react-sortable-tree';
|
|
3
|
+
import { AllItems, EnhancedTreeItem, LocalTreeItem, StoredTreeItem, VisibilityMap } from '../types';
|
|
4
|
+
export declare const dataToEditorTree: ({ tree, allItems, visibilityMap }: {
|
|
5
|
+
tree: StoredTreeItem[];
|
|
6
|
+
allItems: AllItems;
|
|
7
|
+
visibilityMap: VisibilityMap;
|
|
8
|
+
}) => LocalTreeItem[];
|
|
9
|
+
export declare const flatTree: (tree: TreeItem[]) => TreeItem[];
|
|
10
|
+
export interface FetchData {
|
|
11
|
+
mainTree?: LocalTreeItem[];
|
|
12
|
+
allItems?: SanityDocument[];
|
|
13
|
+
}
|
|
14
|
+
export declare const getUnaddedItems: (data: {
|
|
15
|
+
allItems: AllItems;
|
|
16
|
+
tree: StoredTreeItem[];
|
|
17
|
+
}) => EnhancedTreeItem[];
|
|
18
|
+
export declare function normalizeNodeForStorage(item: LocalTreeItem): StoredTreeItem;
|