@sanity/hierarchical-document-list 2.1.3 → 3.0.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 (44) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -28
  3. package/dist/index.d.ts +170 -195
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +835 -6031
  6. package/dist/index.js.map +1 -1
  7. package/package.json +38 -77
  8. package/dist/index.d.mts +0 -240
  9. package/dist/index.mjs +0 -6433
  10. package/dist/index.mjs.map +0 -1
  11. package/sanity.json +0 -8
  12. package/src/TreeDeskStructure.tsx +0 -80
  13. package/src/TreeInputComponent.tsx +0 -41
  14. package/src/components/DeskWarning.tsx +0 -40
  15. package/src/components/DocumentInNode.tsx +0 -133
  16. package/src/components/DocumentPreviewStatus.tsx +0 -70
  17. package/src/components/NodeActions.tsx +0 -85
  18. package/src/components/NodeContentRenderer.tsx +0 -141
  19. package/src/components/PlaceholderDropzone.tsx +0 -45
  20. package/src/components/TreeEditor.tsx +0 -184
  21. package/src/components/TreeEditorErrorBoundary.tsx +0 -14
  22. package/src/components/TreeNodeRenderer.tsx +0 -37
  23. package/src/components/TreeNodeRendererScaffold.tsx +0 -193
  24. package/src/createDeskHierarchy.tsx +0 -110
  25. package/src/createHierarchicalSchemas.tsx +0 -151
  26. package/src/hooks/useAllItems.ts +0 -119
  27. package/src/hooks/useLocalTree.ts +0 -40
  28. package/src/hooks/useTreeOperations.ts +0 -25
  29. package/src/hooks/useTreeOperationsProvider.ts +0 -86
  30. package/src/index.ts +0 -25
  31. package/src/schemas/hierarchy.tree.ts +0 -19
  32. package/src/types.ts +0 -148
  33. package/src/utils/flatDataToTree.ts +0 -20
  34. package/src/utils/getAdjescentNodes.ts +0 -30
  35. package/src/utils/getCommonTreeProps.tsx +0 -28
  36. package/src/utils/getTreeHeight.ts +0 -8
  37. package/src/utils/gradientPatchAdapter.ts +0 -43
  38. package/src/utils/idUtils.ts +0 -7
  39. package/src/utils/injectNodeTypeInPatches.ts +0 -60
  40. package/src/utils/moveItemInArray.ts +0 -26
  41. package/src/utils/throwError.ts +0 -9
  42. package/src/utils/treeData.tsx +0 -119
  43. package/src/utils/treePatches.ts +0 -171
  44. package/v2-incompatible.js +0 -11
package/package.json CHANGED
@@ -1,103 +1,64 @@
1
1
  {
2
2
  "name": "@sanity/hierarchical-document-list",
3
- "version": "2.1.3",
3
+ "version": "3.0.0",
4
4
  "description": "Sanity Plugin - Hierarchical Document List",
5
5
  "keywords": [
6
6
  "sanity",
7
7
  "sanity-plugin"
8
8
  ],
9
- "homepage": "https://github.com/sanity-io/hierarchical-document-list#readme",
9
+ "homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/@sanity/hierarchical-document-list#readme",
10
10
  "bugs": {
11
- "url": "https://github.com/sanity-io/hierarchical-document-list/issues"
11
+ "url": "https://github.com/sanity-io/plugins/issues"
12
12
  },
13
- "type": "commonjs",
13
+ "license": "MIT",
14
+ "author": "Sanity.io <hello@sanity.io>",
14
15
  "repository": {
15
16
  "type": "git",
16
- "url": "git@github.com:sanity-io/hierarchical-document-list.git"
17
+ "url": "git+ssh://git@github.com/sanity-io/plugins.git",
18
+ "directory": "plugins/@sanity/hierarchical-document-list"
17
19
  },
18
- "license": "MIT",
19
- "author": "Sanity <hello@sanity.io>",
20
- "exports": {
21
- ".": {
22
- "source": "./src/index.ts",
23
- "import": "./dist/index.mjs",
24
- "require": "./dist/index.js",
25
- "default": "./dist/index.mjs"
26
- },
27
- "./package.json": "./package.json"
28
- },
29
- "main": "./dist/index.js",
30
- "module": "./dist/index.mjs",
31
- "types": "./dist/index.d.ts",
32
20
  "files": [
33
- "dist",
34
- "sanity.json",
35
- "src",
36
- "v2-incompatible.js"
21
+ "dist"
37
22
  ],
38
- "scripts": {
39
- "dev": "sanity dev",
40
- "prepare": "npm run build && husky install",
41
- "build": "run-s clean && pkg-utils build --strict && pkg-utils --strict",
42
- "prepublishOnly": "run-s build",
43
- "clean": "rimraf dist",
44
- "format": "prettier --write --cache --ignore-unknown .",
45
- "link-watch": "plugin-kit link-watch",
46
- "lint": "eslint .",
47
- "watch": "pkg-utils watch --strict"
23
+ "type": "module",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": "./dist/index.js",
27
+ "./package.json": "./package.json"
48
28
  },
49
29
  "dependencies": {
50
- "@sanity/icons": "^3.7.0",
51
- "@sanity/incompatible-plugin": "^1.0.5",
52
- "@sanity/mutator": "^3.78.1",
53
- "@sanity/ui": "^2.15.2",
54
- "@sanity/util": "^3.78.1",
30
+ "@nosferatu500/react-sortable-tree": "^5.0.0",
31
+ "@sanity/color": "^3.0.6",
32
+ "@sanity/icons": "^3.7.4",
33
+ "@sanity/mutator": "^6.0.0",
34
+ "@sanity/ui": "^3.2.0",
35
+ "@sanity/util": "^6.1.0",
55
36
  "react-dnd": "^16.0.1",
56
37
  "react-dnd-html5-backend": "^16.0.1"
57
38
  },
58
39
  "devDependencies": {
59
- "@commitlint/cli": "^18.4.3",
60
- "@commitlint/config-conventional": "^18.4.3",
61
- "@nosferatu500/react-sortable-tree": "^4.4.0",
62
- "@sanity/pkg-utils": "^7.0.4",
63
- "@sanity/plugin-kit": "^4.0.19",
64
- "@sanity/semantic-release-preset": "^4.1.6",
65
- "@sanity/vision": "^3.78.1",
66
- "@types/react": "^19.0.10",
67
- "@typescript-eslint/eslint-plugin": "^6.13.1",
68
- "@typescript-eslint/parser": "^6.13.1",
69
- "eslint": "^8.55.0",
70
- "eslint-config-prettier": "^9.1.0",
71
- "eslint-config-sanity": "^7.0.1",
72
- "eslint-plugin-prettier": "^5.0.1",
73
- "eslint-plugin-react": "^7.33.2",
74
- "eslint-plugin-react-hooks": "^4.6.0",
75
- "husky": "^8.0.3",
76
- "lint-staged": "^15.2.0",
77
- "npm-run-all": "^4.1.5",
78
- "prettier": "^3.1.0",
79
- "prettier-plugin-packagejson": "^2.4.7",
80
- "react": "^19.0.0",
81
- "react-dom": "^19.0.0",
82
- "react-is": "^19.0.0",
83
- "rimraf": "^5.0.5",
84
- "sanity": "^3.78.1",
85
- "styled-components": "^6.1.15",
86
- "typescript": "5.4.x"
40
+ "@sanity/pkg-utils": "^10.5.7",
41
+ "@types/react": "^19.2.17",
42
+ "@types/react-dom": "^19.2.3",
43
+ "babel-plugin-react-compiler": "^1.0.0",
44
+ "babel-plugin-styled-components": "^2.3.0",
45
+ "react": "^19.2.7",
46
+ "react-dom": "^19.2.7",
47
+ "sanity": "^6.1.0",
48
+ "styled-components": "^6.4.2",
49
+ "@repo/package.config": "0.0.0",
50
+ "@repo/tsconfig": "0.0.0"
87
51
  },
88
52
  "peerDependencies": {
89
- "react": "^18.3 || ^19",
90
- "react-dom": "^18.3 || ^19",
91
- "react-is": "^18.3 || ^19",
92
- "sanity": "^3 || ^4.0.0-0 || ^5.0.0",
53
+ "react": "^19.2",
54
+ "react-dom": "^19.2",
55
+ "sanity": "^5 || ^6.0.0-0",
93
56
  "styled-components": "^6.1"
94
57
  },
95
- "overrides": {
96
- "react": "$react",
97
- "react-dom": "$react-dom",
98
- "react-is": "$react-is"
99
- },
100
58
  "engines": {
101
- "node": ">=14"
59
+ "node": ">=20.19 <22 || >=22.12"
60
+ },
61
+ "scripts": {
62
+ "build": "pkg build --strict --check --clean"
102
63
  }
103
- }
64
+ }
package/dist/index.d.mts DELETED
@@ -1,240 +0,0 @@
1
- import {ArraySchemaType} from 'sanity'
2
- import type {ConfigContext} from 'sanity'
3
- import {DocumentDefinition} from 'sanity'
4
- import {Plugin as Plugin_2} from 'sanity'
5
- import {PreviewConfig} from 'sanity'
6
- import * as React_2 from 'react'
7
- import {StructureBuilder} from 'sanity/desk'
8
-
9
- export declare function createDeskHierarchy(props: TreeProps): any
10
-
11
- export declare function createHierarchicalSchemas(options: SchemaOptions): (
12
- | {
13
- name: string
14
- title: string
15
- type: string
16
- fields: (
17
- | {
18
- name: string
19
- type: string
20
- }
21
- | {
22
- name: string
23
- type: string
24
- title: string
25
- fields: (
26
- | {
27
- name: string
28
- type: string
29
- weak?: undefined
30
- to?: undefined
31
- options?: undefined
32
- }
33
- | {
34
- name: string
35
- type: string
36
- weak: boolean
37
- to: {
38
- type: string
39
- }[]
40
- options:
41
- | {
42
- filter?: string | undefined
43
- filterParams?: Record<string, unknown> | undefined
44
- }
45
- | undefined
46
- }
47
- )[]
48
- }
49
- )[]
50
- }
51
- | {
52
- name: string
53
- title: string
54
- type: string
55
- of: (
56
- | {
57
- name: string
58
- title: string
59
- type: string
60
- fields: (
61
- | {
62
- name: string
63
- type: string
64
- }
65
- | {
66
- name: string
67
- type: string
68
- title: string
69
- fields: (
70
- | {
71
- name: string
72
- type: string
73
- weak?: undefined
74
- to?: undefined
75
- options?: undefined
76
- }
77
- | {
78
- name: string
79
- type: string
80
- weak: boolean
81
- to: {
82
- type: string
83
- }[]
84
- options:
85
- | {
86
- filter?: string | undefined
87
- filterParams?: Record<string, unknown> | undefined
88
- }
89
- | undefined
90
- }
91
- )[]
92
- }
93
- )[]
94
- }
95
- | {
96
- type: string
97
- }
98
- )[]
99
- }
100
- | {
101
- name: string | undefined
102
- title: string
103
- type: string
104
- liveEdit: boolean
105
- fields: (Omit<ArraySchemaType<unknown>, 'type' | 'of' | 'jsonType'> & {
106
- type: string
107
- inputComponent: React_2.FC<any>
108
- of?: any[] | undefined
109
- })[]
110
- preview: {
111
- select: {
112
- id: string
113
- tree: string
114
- }
115
- prepare({id, tree}: {id: string; tree: unknown[]}): Record<string, string>
116
- }
117
- }
118
- )[]
119
-
120
- export declare function flatDataToTree(data: StoredTreeItem[]): TreeItemWithChildren[]
121
-
122
- /**
123
- * Usage in `sanity.config.ts` (or .js)
124
- *
125
- * ```ts
126
- * import {defineConfig} from 'sanity'
127
- * import {hierarchicalDocumentList} from '@sanity/hierarchical-document-list'
128
- *
129
- * export default defineConfig({
130
- * // ...
131
- * plugins: [hierarchicalDocumentList()],
132
- * })
133
- * ```
134
- */
135
- export declare const hierarchicalDocumentList: Plugin_2<void>
136
-
137
- export declare const hierarchyTree: {
138
- type: 'document'
139
- name: 'hierarchy.tree'
140
- } & Omit<DocumentDefinition, 'preview'> & {
141
- preview?: PreviewConfig<Record<string, string>, Record<never, any>> | undefined
142
- }
143
-
144
- declare const INTERNAL_NODE_TYPE: string
145
-
146
- declare const INTERNAL_NODE_VALUE_TYPE: string
147
-
148
- declare interface SanityReference {
149
- _type: 'reference'
150
- _ref: string
151
- _weak?: boolean
152
- }
153
-
154
- declare type SchemaOptions = Omit<TreeDeskStructureProps, 'documentId' | 'maxDepth'>
155
-
156
- /**
157
- * Objects saved to tree documents in Sanity's Content Lake
158
- */
159
- declare interface StoredTreeItem {
160
- _key: string
161
- _type: typeof INTERNAL_NODE_TYPE | string
162
- value?: {
163
- _type: typeof INTERNAL_NODE_VALUE_TYPE | string
164
- reference?: SanityReference
165
- docType?: string
166
- }
167
- /**
168
- * _key of parent node
169
- */
170
- parent?: string | null
171
- }
172
-
173
- declare interface TreeDeskStructureProps extends TreeInputOptions {
174
- /**
175
- * _id of the document that will hold the tree data.
176
- */
177
- documentId: string
178
- /**
179
- * (Optional)
180
- * Key for the field representing the hierarchical tree inside the document.
181
- * `tree` by default.
182
- */
183
- fieldKeyInDocument?: string
184
- }
185
-
186
- declare interface TreeInputOptions {
187
- /**
188
- * What document types this hierarchy can refer to.
189
- * Similar to the `to` property of the [reference field](https://www.sanity.io/docs/reference-type).
190
- */
191
- referenceTo: string[]
192
- /**
193
- * Used to provide fine-grained filtering for documents.
194
- */
195
- referenceOptions?: {
196
- /**
197
- * Static filter to apply to tree document queries.
198
- */
199
- filter?: string
200
- /**
201
- * Parameters / variables to pass to the GROQ query ran to fetch documents.
202
- */
203
- filterParams?: Record<string, unknown>
204
- }
205
- /**
206
- * How deep should editors be allowed to nest items.
207
- */
208
- maxDepth?: number
209
- /**
210
- * Schema type for your hierarchical documents.
211
- * Refer to documentation on how to provide these schemas in your studio.
212
- *
213
- * Defautlt: 'hierarchy.tree' - this schema is bundled with the plugin
214
- */
215
- documentType?: string
216
- }
217
-
218
- declare interface TreeItemWithChildren extends StoredTreeItem {
219
- children?: TreeItemWithChildren[]
220
- }
221
-
222
- export declare interface TreeProps extends TreeDeskStructureProps {
223
- /**
224
- * Visible title above the tree.
225
- * Also used as the label in the desk list item.
226
- */
227
- title: string
228
- /**
229
- * Optional icon for rendering the item in the desk structure.
230
- */
231
- icon?: any
232
- context?: ConfigContext | any
233
- S?: StructureBuilder | any
234
- /**
235
- * Restrict document types that can be created.
236
- */
237
- creatableTypes?: string[]
238
- }
239
-
240
- export {}