sanity-plugin-taxonomy-manager 3.1.5 → 3.2.1
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/README.md +74 -8
- package/lib/index.d.ts +11 -12
- package/lib/index.esm.d.mts +11 -12
- package/lib/index.esm.esm.js +19 -19
- package/lib/index.esm.esm.js.map +1 -1
- package/lib/index.esm.mjs +19 -19
- package/lib/index.esm.mjs.map +1 -1
- package/lib/index.js +13 -13
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChildConcepts.tsx +1 -12
- package/src/components/Children.tsx +9 -8
- package/src/components/Hierarchy.tsx +3 -4
- package/src/components/Orphans.tsx +5 -6
- package/src/components/TopConcepts.tsx +5 -6
- package/src/components/TreeStructure.tsx +1 -25
- package/src/components/TreeView.tsx +5 -6
- package/src/components/guides/NewScheme.tsx +1 -2
- package/src/components/guides/NoConcepts.tsx +2 -3
- package/src/{helpers → components/inputs}/HierarchyInput.tsx +3 -9
- package/src/components/inputs/Identifier.tsx +1 -3
- package/src/components/inputs/{hierarchy/InputHierarchy.tsx → InputHierarchy.tsx} +11 -14
- package/src/components/inputs/RdfUri.tsx +1 -1
- package/src/components/inputs/index.ts +2 -0
- package/src/components/{ConceptDetailDialogue.tsx → interactions/ConceptDetailDialogue.tsx} +2 -2
- package/src/components/{ConceptDetailLink.tsx → interactions/ConceptDetailLink.tsx} +4 -4
- package/src/components/{ConceptSelectLink.tsx → interactions/ConceptSelectLink.tsx} +3 -3
- package/src/helpers/branchFilter.ts +1 -2
- package/src/helpers/index.ts +0 -1
- package/src/helpers/schemeFilter.ts +1 -2
- package/src/hooks/useAddTitle.tsx +1 -1
- package/src/hooks/useCreateConcept.tsx +1 -2
- package/src/hooks/useOpenNewConceptPane.tsx +1 -1
- package/src/hooks/useRemoveConcept.tsx +1 -2
- package/src/index.ts +13 -6
- package/src/modules/baseIriField.tsx +4 -5
- package/src/queries.ts +6 -8
- package/src/skosConcept.tsx +7 -15
- package/src/skosConceptScheme.tsx +10 -12
- package/src/structure.ts +2 -5
- package/src/components/inputs/hierarchy/InputChildren.tsx +0 -99
- package/src/components/inputs/hierarchy/InputOrphans.tsx +0 -79
- package/src/components/inputs/hierarchy/InputTopConcepts.tsx +0 -80
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# Sanity Taxonomy Manager
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|

|
|
5
4
|

|
|
6
5
|
|
|
@@ -11,19 +10,20 @@
|
|
|
11
10
|
The Taxonomy Manager document schema is based on the [World Wide Web Consortium](https://www.w3.org/) (W3C) [Simple Knowledge Organization Scheme](https://www.w3.org/TR/skos-reference/) (SKOS) recommendation. Concept and concept scheme editor tools include standard SKOS properties, hints for creating consistent concepts and vocabularies, and validation functions for preventing consistency errors. -->
|
|
12
11
|
|
|
13
12
|
|  |
|
|
14
|
-
|
|
|
13
|
+
| ----------------------------------------------------------------------- |
|
|
15
14
|
|
|
16
15
|
## Documentation
|
|
17
16
|
|
|
18
17
|
For full documentation, visit [sanitytaxonomymanager.com](https://sanitytaxonomymanager.com).
|
|
19
18
|
|
|
20
19
|
## Features
|
|
20
|
+
|
|
21
21
|
<!-- make this more concise -->
|
|
22
|
+
|
|
22
23
|
- Adds two document types to your Sanity schema which are used to generate [SKOS](https://www.w3.org/TR/skos-primer/) compliant concepts and taxonomies: `skosConcept` and `skosConceptScheme`
|
|
23
24
|
- Includes reference filter helpers to allow you to easily include a specific taxonomy, or particular branch of a taxonomy in your Sanity documents
|
|
24
25
|
- Encourages taxonomy and thesaurus design best practices by enforcing [disjunction between Broader and Related relationships](https://www.w3.org/TR/skos-reference/#L2422) and [disjunction between Preferred and Alternate/Hidden labels](https://www.w3.org/TR/skos-reference/#L1567)
|
|
25
|
-
- Standards compliant architecture means that taxonomy terms and structures can be migrated to standards compliant standalone tools when you need higher level taxonomy and knowledge graph support.
|
|
26
|
-
|
|
26
|
+
- Standards compliant architecture means that taxonomy terms and structures can be migrated to standards compliant standalone tools when you need higher level taxonomy and knowledge graph support.
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
@@ -62,6 +62,16 @@ export default defineConfig({
|
|
|
62
62
|
taxonomyManager({
|
|
63
63
|
// Optional: Set a Base URI to use for new concepts & concept schemes
|
|
64
64
|
baseUri: 'https://example.com/',
|
|
65
|
+
// Optional: Use `customConceptFields` and `customSchemeFields` keys to add custom fields to Concept or Concept Scheme document types
|
|
66
|
+
customConceptFields: [
|
|
67
|
+
{
|
|
68
|
+
name: 'sameAs',
|
|
69
|
+
title: 'Same As',
|
|
70
|
+
type: 'url',
|
|
71
|
+
description:
|
|
72
|
+
'Specify a fully qualified IRI that identifies the same concept in another vocabulary',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
65
75
|
}),
|
|
66
76
|
],
|
|
67
77
|
schema: {
|
|
@@ -96,9 +106,7 @@ export default defineConfig({
|
|
|
96
106
|
),
|
|
97
107
|
]),
|
|
98
108
|
}),
|
|
99
|
-
taxonomyManager(
|
|
100
|
-
baseUri: 'https://example.com/',
|
|
101
|
-
}),
|
|
109
|
+
taxonomyManager(),
|
|
102
110
|
],
|
|
103
111
|
schema: {
|
|
104
112
|
types: schemaTypes,
|
|
@@ -107,7 +115,65 @@ export default defineConfig({
|
|
|
107
115
|
```
|
|
108
116
|
|
|
109
117
|
## Contributing
|
|
110
|
-
|
|
118
|
+
|
|
119
|
+
Community collaboration is highly encouraged. To make sure your contributions are aligned with project goals and principles, please read the [contributing docs](https://sanitytaxonomymanager.com/#/contributing) before submitting a pull request.
|
|
120
|
+
|
|
121
|
+
- This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
122
|
+
with default configuration for build & watch scripts.
|
|
123
|
+
|
|
124
|
+
- See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
125
|
+
on how to run the plugin with hot-reload in the studio.
|
|
126
|
+
|
|
127
|
+
### Component Diagrams
|
|
128
|
+
|
|
129
|
+
The following diagrams map out the relationships between the components used in this plugin and are intended to help those interested in contributing to the project orient themselves. The Taxonomy Manager tree view is designed to support polyhierarchy, and to provide UI affordances common to other taxonomy management tools, both of which lend some complexity to the component structure.
|
|
130
|
+
|
|
131
|
+
> [!TIP]
|
|
132
|
+
> You **do not** need to understand any of this to use the plugin!
|
|
133
|
+
|
|
134
|
+
<Details>
|
|
135
|
+
<Summary><h4>Tree View</h4></Summary>
|
|
136
|
+
|
|
137
|
+
The [Tree View component](docs/_images/taxonomyManager.png) creates the user interface for interacting with a given taxonomy (SKOS Concept Scheme) visually in the Sanity Structure tool.
|
|
138
|
+
|
|
139
|
+
```mermaid
|
|
140
|
+
graph BT
|
|
141
|
+
subgraph SchemeContext.Provider
|
|
142
|
+
direction BT
|
|
143
|
+
Hierarchy.tsx-->TreeView.tsx
|
|
144
|
+
subgraph TreeContext.Provider
|
|
145
|
+
direction BT
|
|
146
|
+
TreeStructure.tsx-->Hierarchy.tsx
|
|
147
|
+
TopConcepts.tsx[
|
|
148
|
+
TopConcepts.tsx
|
|
149
|
+
<i style="color: gray; font-size: small">uses SchemeContext</i>
|
|
150
|
+
<i style="color: gray; font-size: small">uses TreeContext</i>
|
|
151
|
+
]-->TreeStructure.tsx
|
|
152
|
+
Orphans.tsx[
|
|
153
|
+
Orphans.tsx
|
|
154
|
+
<i style="color: gray; font-size: small">uses SchemeContext</i>
|
|
155
|
+
<i style="color: gray; font-size: small">uses TreeContext</i>
|
|
156
|
+
]-->TreeStructure.tsx
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
%% Sequence below maintains RTL ordering:
|
|
160
|
+
ConceptDetailLink.tsx-->TopConcepts.tsx
|
|
161
|
+
ConceptDetailLink.tsx-->Orphans.tsx
|
|
162
|
+
|
|
163
|
+
ChildConcepts.tsx-->TopConcepts.tsx
|
|
164
|
+
ChildConcepts.tsx-->Orphans.tsx
|
|
165
|
+
Children.tsx-->ChildConcepts.tsx
|
|
166
|
+
|
|
167
|
+
ConceptDetailDialogue.tsx-->Orphans.tsx
|
|
168
|
+
ConceptDetailDialogue.tsx-->TopConcepts.tsx
|
|
169
|
+
|
|
170
|
+
ConceptDetailLink.tsx-->Children.tsx
|
|
171
|
+
ConceptDetailDialogue.tsx-->Children.tsx
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
</Details>
|
|
111
177
|
|
|
112
178
|
## License
|
|
113
179
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {FieldDefinition} from 'sanity'
|
|
1
2
|
import {JSX as JSX_2} from 'react'
|
|
2
3
|
import {ObjectFieldProps} from 'sanity'
|
|
3
4
|
import {Plugin as Plugin_2} from 'sanity'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* Document Branch Filter
|
|
7
|
-
*
|
|
7
|
+
* #### Document Branch Filter
|
|
8
8
|
* A pluggable Function for Filtering to a Top Concept Branch within a SKOS Concept Scheme
|
|
9
9
|
* @param schemeId - The unique six character concept identifier for the Concept Scheme to which you wish to filter.
|
|
10
10
|
* @param branchId - The unique six character concept identifier of a branch. Child concepts will be returned.
|
|
@@ -24,18 +24,17 @@ declare type BranchOptions = {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Hierarchy View Input Component for Reference Fields
|
|
27
|
-
* TODO check for scheme or branch filters — it only works if they're used; alternatively
|
|
28
|
-
* provide optional parameters if a custom filter is used?
|
|
29
27
|
*/
|
|
30
28
|
export declare function HierarchyInput(props: ObjectFieldProps): JSX_2.Element
|
|
31
29
|
|
|
32
30
|
declare interface Options {
|
|
33
31
|
baseUri?: string
|
|
32
|
+
customConceptFields?: FieldDefinition[]
|
|
33
|
+
customSchemeFields?: FieldDefinition[]
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Document Scheme Filter
|
|
38
|
-
*
|
|
37
|
+
* #### Document Scheme Filter
|
|
39
38
|
* Pluggable Function for Filtering to a Single SKOS Concept Scheme
|
|
40
39
|
* @param schemeId - The unique six character concept identifier for the Concept Scheme to which you wish to filter.
|
|
41
40
|
* @returns A reference type filter for Concepts and Top Concepts in the selected Concept Scheme
|
|
@@ -52,23 +51,23 @@ declare type SchemeOptions = {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
|
-
* Defines a Sanity plugin for managing taxonomies
|
|
56
|
-
*
|
|
54
|
+
* #### Defines a Sanity plugin for managing taxonomies
|
|
57
55
|
* BaseURI should follow an IANA http/s scheme and should terminate with either a / or #.
|
|
58
56
|
* @param options - Optional configuration options for the plugin.
|
|
59
57
|
* @param options.baseUri - The base URI to use for SKOS concepts and concept schemes.
|
|
58
|
+
* @param options.customConceptFields - An array of additional fields to add to the skosConcept type.
|
|
59
|
+
* @param options.customSchemeFields - An array of additional fields to add to the skosConceptScheme type.
|
|
60
60
|
* @returns A Sanity plugin object.
|
|
61
61
|
*/
|
|
62
62
|
export declare const taxonomyManager: Plugin_2<Options | undefined>
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Tree View Component Wrapper
|
|
65
|
+
* #### Tree View Component Wrapper
|
|
66
66
|
* This is the view component for the hierarchy tree. It is the
|
|
67
67
|
* top level of concept scheme views and is passed into Desk
|
|
68
68
|
* structure to render the primary view for taxonomy documents.
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* structure?
|
|
69
|
+
* @param inputComponent - Specifies whether the component is Studio
|
|
70
|
+
* input component, which will hide tree view controls and chrome.
|
|
72
71
|
*/
|
|
73
72
|
export declare const TreeView: ({
|
|
74
73
|
document,
|
package/lib/index.esm.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {FieldDefinition} from 'sanity'
|
|
1
2
|
import {JSX as JSX_2} from 'react'
|
|
2
3
|
import {ObjectFieldProps} from 'sanity'
|
|
3
4
|
import {Plugin as Plugin_2} from 'sanity'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* Document Branch Filter
|
|
7
|
-
*
|
|
7
|
+
* #### Document Branch Filter
|
|
8
8
|
* A pluggable Function for Filtering to a Top Concept Branch within a SKOS Concept Scheme
|
|
9
9
|
* @param schemeId - The unique six character concept identifier for the Concept Scheme to which you wish to filter.
|
|
10
10
|
* @param branchId - The unique six character concept identifier of a branch. Child concepts will be returned.
|
|
@@ -24,18 +24,17 @@ declare type BranchOptions = {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Hierarchy View Input Component for Reference Fields
|
|
27
|
-
* TODO check for scheme or branch filters — it only works if they're used; alternatively
|
|
28
|
-
* provide optional parameters if a custom filter is used?
|
|
29
27
|
*/
|
|
30
28
|
export declare function HierarchyInput(props: ObjectFieldProps): JSX_2.Element
|
|
31
29
|
|
|
32
30
|
declare interface Options {
|
|
33
31
|
baseUri?: string
|
|
32
|
+
customConceptFields?: FieldDefinition[]
|
|
33
|
+
customSchemeFields?: FieldDefinition[]
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Document Scheme Filter
|
|
38
|
-
*
|
|
37
|
+
* #### Document Scheme Filter
|
|
39
38
|
* Pluggable Function for Filtering to a Single SKOS Concept Scheme
|
|
40
39
|
* @param schemeId - The unique six character concept identifier for the Concept Scheme to which you wish to filter.
|
|
41
40
|
* @returns A reference type filter for Concepts and Top Concepts in the selected Concept Scheme
|
|
@@ -52,23 +51,23 @@ declare type SchemeOptions = {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
/**
|
|
55
|
-
* Defines a Sanity plugin for managing taxonomies
|
|
56
|
-
*
|
|
54
|
+
* #### Defines a Sanity plugin for managing taxonomies
|
|
57
55
|
* BaseURI should follow an IANA http/s scheme and should terminate with either a / or #.
|
|
58
56
|
* @param options - Optional configuration options for the plugin.
|
|
59
57
|
* @param options.baseUri - The base URI to use for SKOS concepts and concept schemes.
|
|
58
|
+
* @param options.customConceptFields - An array of additional fields to add to the skosConcept type.
|
|
59
|
+
* @param options.customSchemeFields - An array of additional fields to add to the skosConceptScheme type.
|
|
60
60
|
* @returns A Sanity plugin object.
|
|
61
61
|
*/
|
|
62
62
|
export declare const taxonomyManager: Plugin_2<Options | undefined>
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Tree View Component Wrapper
|
|
65
|
+
* #### Tree View Component Wrapper
|
|
66
66
|
* This is the view component for the hierarchy tree. It is the
|
|
67
67
|
* top level of concept scheme views and is passed into Desk
|
|
68
68
|
* structure to render the primary view for taxonomy documents.
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* structure?
|
|
69
|
+
* @param inputComponent - Specifies whether the component is Studio
|
|
70
|
+
* input component, which will hide tree view controls and chrome.
|
|
72
71
|
*/
|
|
73
72
|
export declare const TreeView: ({
|
|
74
73
|
document,
|