sanity-plugin-taxonomy-manager 3.3.2 → 3.4.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/lib/index.d.ts +41 -17
  2. package/lib/index.esm.d.mts +41 -17
  3. package/lib/index.esm.esm.js +26 -26
  4. package/lib/index.esm.esm.js.map +1 -1
  5. package/lib/index.esm.mjs +26 -26
  6. package/lib/index.esm.mjs.map +1 -1
  7. package/lib/index.js +12 -12
  8. package/lib/index.js.map +1 -1
  9. package/package.json +23 -8
  10. package/src/components/ChildConcepts.tsx +7 -6
  11. package/src/components/Children.tsx +129 -73
  12. package/src/components/{Orphans.tsx → Concepts.tsx} +40 -35
  13. package/src/components/Hierarchy.tsx +33 -69
  14. package/src/components/TopConcepts.tsx +25 -26
  15. package/src/components/TreeStructure.tsx +28 -47
  16. package/src/components/TreeView.tsx +43 -39
  17. package/src/components/guides/NewScheme.tsx +4 -3
  18. package/src/components/guides/NoConcepts.tsx +3 -2
  19. package/src/components/inputs/ArrayHierarchyInput.tsx +82 -30
  20. package/src/components/inputs/Identifier.tsx +5 -4
  21. package/src/components/inputs/InputHierarchy.tsx +25 -18
  22. package/src/components/inputs/ManagementControls.tsx +1 -1
  23. package/src/components/inputs/RdfUri.tsx +2 -2
  24. package/src/components/inputs/ReferenceHierarchyInput.tsx +82 -29
  25. package/src/components/interactions/ConceptDetailDialogue.tsx +4 -3
  26. package/src/components/interactions/ConceptDetailLink.tsx +4 -3
  27. package/src/components/interactions/ConceptSelectLink.tsx +6 -4
  28. package/src/context.ts +16 -1
  29. package/src/{modules → helpers}/baseIriField.tsx +2 -1
  30. package/src/helpers/branchFilter.ts +4 -3
  31. package/src/helpers/schemeFilter.ts +5 -5
  32. package/src/hooks/useAddTitle.tsx +1 -1
  33. package/src/hooks/useCreateConcept.tsx +94 -76
  34. package/src/hooks/useLinkColorScheme.tsx +1 -1
  35. package/src/hooks/useOpenNewConceptPane.tsx +1 -1
  36. package/src/hooks/useRemoveConcept.tsx +32 -15
  37. package/src/index.ts +8 -6
  38. package/src/queries.ts +49 -87
  39. package/src/skosConcept.tsx +35 -22
  40. package/src/skosConceptScheme.tsx +10 -9
  41. package/src/structure.ts +3 -4
  42. package/src/styles.ts +2 -2
  43. package/src/types.tsx +64 -1
  44. /package/src/{components → static}/NodeTree.tsx +0 -0
package/lib/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import {ArrayFieldProps} from 'sanity'
2
- import {FieldDefinition} from 'sanity'
1
+ import type {ArrayFieldProps} from 'sanity'
2
+ import type {FieldDefinition} from 'sanity'
3
3
  import {JSX as JSX_2} from 'react'
4
- import {ObjectFieldProps} from 'sanity'
4
+ import type {ObjectFieldProps} from 'sanity'
5
5
  import {Plugin as Plugin_2} from 'sanity'
6
- import {Reference} from 'sanity'
6
+ import type {Reference} from 'sanity'
7
+ import type {SanityDocument} from 'sanity'
7
8
 
8
9
  /**
9
- * Hierarchy View Input Component
10
- *
11
- * This component allows Studio users to browse and select taxonomy
10
+ * #### Hierarchy View Input Component
11
+ * Allows Studio users to browse and select taxonomy
12
12
  * terms from a hierarchical tree structure. It is designed to be
13
13
  * used as an input for taxonomy array fields in Sanity Studio.
14
14
  *
@@ -60,6 +60,27 @@ declare type BranchOptions = {
60
60
  branchId: string
61
61
  }
62
62
 
63
+ declare interface ConceptSchemeDocument extends SanityDocument {
64
+ displayed: {
65
+ _id: string
66
+ _type: 'skosConceptScheme'
67
+ title?: string
68
+ description?: string
69
+ baseIri?: string
70
+ schemeId?: string
71
+ topConcepts?: Array<{
72
+ _key: string
73
+ _ref: string
74
+ _type: 'reference'
75
+ }>
76
+ concepts?: Array<{
77
+ _key: string
78
+ _ref: string
79
+ _type: 'reference'
80
+ }>
81
+ }
82
+ }
83
+
63
84
  declare interface Options {
64
85
  baseUri?: string
65
86
  customConceptFields?: FieldDefinition[]
@@ -67,9 +88,8 @@ declare interface Options {
67
88
  }
68
89
 
69
90
  /**
70
- * Hierarchy View Input Component for Reference Fields
71
- *
72
- * This component allows Studio users to browse and select taxonomy
91
+ * #### Hierarchy View Input Component for Reference Fields
92
+ * Allows Studio users to browse and select taxonomy
73
93
  * terms from a hierarchical tree structure. It is designed to be
74
94
  * used as an input for taxonomy reference fields in Sanity Studio.
75
95
  *
@@ -137,19 +157,23 @@ export declare const taxonomyManager: Plugin_2<Options | undefined>
137
157
  * This is the view component for the hierarchy tree. It is the
138
158
  * top level of concept scheme views and is passed into Desk
139
159
  * structure to render the primary view for taxonomy documents.
140
- * @param inputComponent - Specifies whether the component is Studio
141
- * input component, which will hide tree view controls and chrome.
160
+ * @param document - The document to render.
161
+ * @param branchId - The branch ID to fetch concepts from.
162
+ * @param inputComponent - Specifies whether the component is Studio input component, which will hide tree view controls and chrome.
163
+ * @param selectConcept - The function to call when a concept is selected.
142
164
  */
143
165
  export declare const TreeView: ({
144
166
  document,
145
167
  branchId,
146
- selectConcept,
147
168
  inputComponent,
148
- }: {
149
- document: any
169
+ selectConcept,
170
+ }: TreeViewProps) => JSX_2.Element
171
+
172
+ declare interface TreeViewProps {
173
+ document?: ConceptSchemeDocument
150
174
  branchId: string
151
- selectConcept: any
175
+ selectConcept?: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void
152
176
  inputComponent?: boolean
153
- }) => JSX_2.Element
177
+ }
154
178
 
155
179
  export {}
@@ -1,14 +1,14 @@
1
- import {ArrayFieldProps} from 'sanity'
2
- import {FieldDefinition} from 'sanity'
1
+ import type {ArrayFieldProps} from 'sanity'
2
+ import type {FieldDefinition} from 'sanity'
3
3
  import {JSX as JSX_2} from 'react'
4
- import {ObjectFieldProps} from 'sanity'
4
+ import type {ObjectFieldProps} from 'sanity'
5
5
  import {Plugin as Plugin_2} from 'sanity'
6
- import {Reference} from 'sanity'
6
+ import type {Reference} from 'sanity'
7
+ import type {SanityDocument} from 'sanity'
7
8
 
8
9
  /**
9
- * Hierarchy View Input Component
10
- *
11
- * This component allows Studio users to browse and select taxonomy
10
+ * #### Hierarchy View Input Component
11
+ * Allows Studio users to browse and select taxonomy
12
12
  * terms from a hierarchical tree structure. It is designed to be
13
13
  * used as an input for taxonomy array fields in Sanity Studio.
14
14
  *
@@ -60,6 +60,27 @@ declare type BranchOptions = {
60
60
  branchId: string
61
61
  }
62
62
 
63
+ declare interface ConceptSchemeDocument extends SanityDocument {
64
+ displayed: {
65
+ _id: string
66
+ _type: 'skosConceptScheme'
67
+ title?: string
68
+ description?: string
69
+ baseIri?: string
70
+ schemeId?: string
71
+ topConcepts?: Array<{
72
+ _key: string
73
+ _ref: string
74
+ _type: 'reference'
75
+ }>
76
+ concepts?: Array<{
77
+ _key: string
78
+ _ref: string
79
+ _type: 'reference'
80
+ }>
81
+ }
82
+ }
83
+
63
84
  declare interface Options {
64
85
  baseUri?: string
65
86
  customConceptFields?: FieldDefinition[]
@@ -67,9 +88,8 @@ declare interface Options {
67
88
  }
68
89
 
69
90
  /**
70
- * Hierarchy View Input Component for Reference Fields
71
- *
72
- * This component allows Studio users to browse and select taxonomy
91
+ * #### Hierarchy View Input Component for Reference Fields
92
+ * Allows Studio users to browse and select taxonomy
73
93
  * terms from a hierarchical tree structure. It is designed to be
74
94
  * used as an input for taxonomy reference fields in Sanity Studio.
75
95
  *
@@ -137,19 +157,23 @@ export declare const taxonomyManager: Plugin_2<Options | undefined>
137
157
  * This is the view component for the hierarchy tree. It is the
138
158
  * top level of concept scheme views and is passed into Desk
139
159
  * structure to render the primary view for taxonomy documents.
140
- * @param inputComponent - Specifies whether the component is Studio
141
- * input component, which will hide tree view controls and chrome.
160
+ * @param document - The document to render.
161
+ * @param branchId - The branch ID to fetch concepts from.
162
+ * @param inputComponent - Specifies whether the component is Studio input component, which will hide tree view controls and chrome.
163
+ * @param selectConcept - The function to call when a concept is selected.
142
164
  */
143
165
  export declare const TreeView: ({
144
166
  document,
145
167
  branchId,
146
- selectConcept,
147
168
  inputComponent,
148
- }: {
149
- document: any
169
+ selectConcept,
170
+ }: TreeViewProps) => JSX_2.Element
171
+
172
+ declare interface TreeViewProps {
173
+ document?: ConceptSchemeDocument
150
174
  branchId: string
151
- selectConcept: any
175
+ selectConcept?: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void
152
176
  inputComponent?: boolean
153
- }) => JSX_2.Element
177
+ }
154
178
 
155
179
  export {}