@sanity/hierarchical-document-list 0.1.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.
Files changed (85) hide show
  1. package/.husky/commit-msg +4 -0
  2. package/.husky/pre-commit +4 -0
  3. package/.idea/hierarchical-document-list.iml +11 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/misc.xml +6 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/prettier.xml +7 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/CHANGELOG.md +15 -0
  10. package/README.md +329 -224
  11. package/commitlint.config.js +3 -0
  12. package/lib/TreeDeskStructure.d.ts +8 -7
  13. package/lib/TreeDeskStructure.js +96 -71
  14. package/lib/TreeInputComponent.d.ts +19 -19
  15. package/lib/TreeInputComponent.js +50 -21
  16. package/lib/components/DeskWarning.d.ts +6 -6
  17. package/lib/components/DeskWarning.js +46 -25
  18. package/lib/components/DocumentInNode.d.ts +11 -11
  19. package/lib/components/DocumentInNode.js +81 -58
  20. package/lib/components/DocumentPreviewStatus.d.ts +7 -7
  21. package/lib/components/DocumentPreviewStatus.js +39 -35
  22. package/lib/components/NodeActions.d.ts +10 -10
  23. package/lib/components/NodeActions.js +61 -37
  24. package/lib/components/NodeContentRenderer.d.ts +8 -8
  25. package/lib/components/NodeContentRenderer.js +105 -81
  26. package/lib/components/PlaceholderDropzone.d.ts +9 -9
  27. package/lib/components/PlaceholderDropzone.js +30 -28
  28. package/lib/components/SuppressedDnDManager.d.ts +2 -0
  29. package/lib/components/SuppressedDnDManager.js +59 -0
  30. package/lib/components/TreeEditor.d.ts +12 -12
  31. package/lib/components/TreeEditor.js +74 -54
  32. package/lib/components/TreeEditorErrorBoundary.d.ts +16 -17
  33. package/lib/components/TreeEditorErrorBoundary.js +74 -69
  34. package/lib/components/TreeNodeRenderer.d.ts +3 -3
  35. package/lib/components/TreeNodeRenderer.js +59 -35
  36. package/lib/components/TreeNodeRendererScaffold.d.ts +4 -4
  37. package/lib/components/TreeNodeRendererScaffold.js +44 -42
  38. package/lib/createDeskHierarchy.d.ts +14 -14
  39. package/lib/createDeskHierarchy.js +84 -67
  40. package/lib/createHierarchicalSchemas.d.ts +98 -0
  41. package/lib/createHierarchicalSchemas.js +138 -0
  42. package/lib/{utils → hooks}/useAllItems.d.ts +7 -7
  43. package/lib/{utils → hooks}/useAllItems.js +119 -94
  44. package/lib/{utils → hooks}/useLocalTree.d.ts +17 -17
  45. package/lib/{utils → hooks}/useLocalTree.js +59 -37
  46. package/lib/{utils → hooks}/useTreeOperations.d.ts +9 -9
  47. package/lib/hooks/useTreeOperations.js +39 -0
  48. package/lib/{utils → hooks}/useTreeOperationsProvider.d.ts +14 -14
  49. package/lib/hooks/useTreeOperationsProvider.js +85 -0
  50. package/lib/index.d.ts +3 -3
  51. package/lib/index.js +12 -3
  52. package/lib/schemas/hierarchy.tree.d.ts +13 -23
  53. package/lib/schemas/hierarchy.tree.js +19 -31
  54. package/lib/types.d.ts +128 -0
  55. package/lib/types.js +2 -0
  56. package/lib/utils/flatDataToTree.d.ts +6 -6
  57. package/lib/utils/flatDataToTree.js +26 -23
  58. package/lib/utils/getAdjescentNodes.d.ts +12 -12
  59. package/lib/utils/getAdjescentNodes.js +19 -16
  60. package/lib/utils/getCommonTreeProps.d.ts +7 -7
  61. package/lib/utils/getCommonTreeProps.js +33 -27
  62. package/lib/utils/getTreeHeight.d.ts +3 -3
  63. package/lib/utils/getTreeHeight.js +11 -7
  64. package/lib/utils/gradientPatchAdapter.d.ts +4 -4
  65. package/lib/utils/gradientPatchAdapter.js +40 -35
  66. package/lib/utils/idUtils.d.ts +2 -2
  67. package/lib/utils/idUtils.js +13 -8
  68. package/lib/utils/injectNodeTypeInPatches.d.ts +12 -0
  69. package/lib/utils/injectNodeTypeInPatches.js +59 -0
  70. package/lib/utils/moveItemInArray.d.ts +5 -5
  71. package/lib/utils/moveItemInArray.js +26 -23
  72. package/lib/utils/throwError.d.ts +7 -0
  73. package/lib/utils/throwError.js +12 -0
  74. package/lib/utils/treeData.d.ts +18 -18
  75. package/lib/utils/treeData.js +118 -106
  76. package/lib/utils/treePatches.d.ts +15 -15
  77. package/lib/utils/treePatches.js +171 -141
  78. package/lint-staged.config.js +4 -0
  79. package/package.json +65 -56
  80. package/sanity.json +12 -12
  81. package/tsconfig.json +20 -20
  82. package/lib/createHierarchicalField.d.ts +0 -8
  83. package/lib/createHierarchicalField.js +0 -51
  84. package/lib/utils/useTreeOperations.js +0 -16
  85. package/lib/utils/useTreeOperationsProvider.js +0 -60
@@ -1,16 +1,19 @@
1
- /**
2
- * Gets adjescent non-children nodes of a given treeIndex.
3
- */
4
- export default function getAdjescentNodes(_a) {
5
- var flatTree = _a.flatTree, node = _a.node, treeIndex = _a.treeIndex;
6
- var leadingNode = flatTree
7
- .slice(0, treeIndex)
8
- .reverse()
9
- // Disregard children nodes - these include the current node's key in their `path` array
10
- .find(function (item) { return !item.path.includes(node._key); });
11
- var followingNode = flatTree.slice(treeIndex + 1).find(function (item) { return !item.path.includes(node._key); });
12
- return {
13
- leadingNode: leadingNode,
14
- followingNode: followingNode
15
- };
16
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Gets adjescent non-children nodes of a given treeIndex.
5
+ */
6
+ function getAdjescentNodes(_a) {
7
+ var flatTree = _a.flatTree, node = _a.node, treeIndex = _a.treeIndex;
8
+ var leadingNode = flatTree
9
+ .slice(0, treeIndex)
10
+ .reverse()
11
+ // Disregard children nodes - these include the current node's key in their `path` array
12
+ .find(function (item) { return !item.path.includes(node._key); });
13
+ var followingNode = flatTree.slice(treeIndex + 1).find(function (item) { return !item.path.includes(node._key); });
14
+ return {
15
+ leadingNode: leadingNode,
16
+ followingNode: followingNode
17
+ };
18
+ }
19
+ exports.default = getAdjescentNodes;
@@ -1,7 +1,7 @@
1
- import { ReactSortableTreeProps } from 'react-sortable-tree';
2
- export default function getCommonTreeProps({ placeholder }: {
3
- placeholder: {
4
- title: string;
5
- subtitle?: string;
6
- };
7
- }): Partial<ReactSortableTreeProps>;
1
+ import { ReactSortableTreeProps } from 'react-sortable-tree';
2
+ export default function getCommonTreeProps({ placeholder }: {
3
+ placeholder: {
4
+ title: string;
5
+ subtitle?: string;
6
+ };
7
+ }): Partial<ReactSortableTreeProps>;
@@ -1,27 +1,33 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import NodeContentRenderer from '../components/NodeContentRenderer';
14
- import PlaceholderDropzone from '../components/PlaceholderDropzone';
15
- import TreeNodeRenderer from '../components/TreeNodeRenderer';
16
- import { ROW_HEIGHT } from './getTreeHeight';
17
- export default function getCommonTreeProps(_a) {
18
- var placeholder = _a.placeholder;
19
- return {
20
- theme: {
21
- nodeContentRenderer: NodeContentRenderer,
22
- placeholderRenderer: function (props) { return _jsx(PlaceholderDropzone, __assign({}, placeholder, props), void 0); },
23
- treeNodeRenderer: TreeNodeRenderer,
24
- rowHeight: ROW_HEIGHT
25
- }
26
- };
27
- }
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
+ var NodeContentRenderer_1 = __importDefault(require("../components/NodeContentRenderer"));
19
+ var PlaceholderDropzone_1 = __importDefault(require("../components/PlaceholderDropzone"));
20
+ var TreeNodeRenderer_1 = __importDefault(require("../components/TreeNodeRenderer"));
21
+ var getTreeHeight_1 = require("./getTreeHeight");
22
+ function getCommonTreeProps(_a) {
23
+ var placeholder = _a.placeholder;
24
+ return {
25
+ theme: {
26
+ nodeContentRenderer: NodeContentRenderer_1.default,
27
+ placeholderRenderer: function (props) { return (0, jsx_runtime_1.jsx)(PlaceholderDropzone_1.default, __assign({}, placeholder, props), void 0); },
28
+ treeNodeRenderer: TreeNodeRenderer_1.default,
29
+ rowHeight: getTreeHeight_1.ROW_HEIGHT
30
+ }
31
+ };
32
+ }
33
+ exports.default = getCommonTreeProps;
@@ -1,3 +1,3 @@
1
- import { TreeItem } from 'react-sortable-tree';
2
- export declare const ROW_HEIGHT = 51;
3
- export default function getTreeHeight(treeData: TreeItem[]): string;
1
+ import { TreeItem } from 'react-sortable-tree';
2
+ export declare const ROW_HEIGHT = 51;
3
+ export default function getTreeHeight(treeData: TreeItem[]): string;
@@ -1,7 +1,11 @@
1
- import { getVisibleNodeCount } from 'react-sortable-tree';
2
- export var ROW_HEIGHT = 51;
3
- export default function getTreeHeight(treeData) {
4
- var visibleNodeCount = getVisibleNodeCount({ treeData: treeData });
5
- // prettier-ignore
6
- return "".concat(50 + (ROW_HEIGHT * visibleNodeCount), "px");
7
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ROW_HEIGHT = void 0;
4
+ var react_sortable_tree_1 = require("react-sortable-tree");
5
+ exports.ROW_HEIGHT = 51;
6
+ function getTreeHeight(treeData) {
7
+ var visibleNodeCount = (0, react_sortable_tree_1.getVisibleNodeCount)({ treeData: treeData });
8
+ // prettier-ignore
9
+ return "".concat(50 + (exports.ROW_HEIGHT * visibleNodeCount), "px");
10
+ }
11
+ exports.default = getTreeHeight;
@@ -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,35 +1,40 @@
1
- // Adapted from @sanity/form-builder/src/sanity/utils/gradientPatchAdapter.ts
2
- import assert from 'assert';
3
- import { arrayToJSONMatchPath } from '@sanity/mutator';
4
- export function toGradient(patches) {
5
- return patches.map(toGradientPatch);
6
- }
7
- function toGradientPatch(patch) {
8
- var _a, _b, _c, _d;
9
- var matchPath = arrayToJSONMatchPath(patch.path || []);
10
- if (patch.type === 'insert') {
11
- var position = patch.position, items = patch.items;
12
- return {
13
- insert: (_a = {},
14
- _a[position] = matchPath,
15
- _a.items = items,
16
- _a)
17
- };
18
- }
19
- if (patch.type === 'unset') {
20
- return {
21
- unset: [matchPath]
22
- };
23
- }
24
- assert(patch.type, "Missing patch type in patch ".concat(JSON.stringify(patch)));
25
- if (matchPath) {
26
- return _b = {},
27
- _b[patch.type] = (_c = {},
28
- _c[matchPath] = patch.value,
29
- _c),
30
- _b;
31
- }
32
- return _d = {},
33
- _d[patch.type] = patch.value,
34
- _d;
35
- }
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
+ }
@@ -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;
@@ -1,8 +1,13 @@
1
- export function unprefixId(_id) {
2
- if (_id === void 0) { _id = ''; }
3
- return _id.replace('drafts.', '');
4
- }
5
- export function isDraft(_id) {
6
- if (_id === void 0) { _id = ''; }
7
- return _id.startsWith('drafts.');
8
- }
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;
@@ -0,0 +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;
@@ -0,0 +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
+ // 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,23 +1,26 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- export default function moveItemInArray(_a) {
11
- var array = _a.array, fromIndex = _a.fromIndex, toIndex = _a.toIndex;
12
- if (fromIndex === toIndex) {
13
- return array;
14
- }
15
- var newArray = __spreadArray([], array, true);
16
- var target = newArray[fromIndex];
17
- var inc = toIndex < fromIndex ? -1 : 1;
18
- for (var i = fromIndex; i !== toIndex; i += inc) {
19
- newArray[i] = newArray[i + inc];
20
- }
21
- newArray[toIndex] = target;
22
- return newArray;
23
- }
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;
@@ -0,0 +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 {};
@@ -0,0 +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,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;