sanity-plugin-taxonomy-manager 4.6.0 → 4.7.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/lib/index.d.ts CHANGED
@@ -8,16 +8,148 @@ import type {SanityDocument} from 'sanity'
8
8
  import type {useClient} from 'sanity'
9
9
 
10
10
  /**
11
- * #### Hierarchy View Input Component
12
- * Allows Studio users to browse and select taxonomy
13
- * terms from a hierarchical tree structure. It is designed to be
14
- * used as an input for taxonomy array fields in Sanity Studio.
11
+ * Input component that replaces Sanity's default array field input with a
12
+ * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms
13
+ * organized in their scheme hierarchy and select terms to add to the array field.
15
14
  *
16
- * Hierarchy view must be used in conjunction with the Taxonomy Manager
17
- * plugin `schemeFilter` or `branchFilter` options.
15
+ * @remarks
16
+ * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's
17
+ * `options.filter`. Rendering without a filter will display a configuration warning.
18
+ * - Supports only **single-schema arrays** (i.e., `of: [{type: 'reference'}]`). Arrays
19
+ * with multiple schema types will render a warning and fall back to the default input.
20
+ * - Taxonomy selection is disabled when viewing the published perspective.
21
+ * - When `browseOnly` is set in the filter configuration, Sanity's default search input
22
+ * is suppressed and only the tree browser is available for term selection.
23
+ * - When `expanded` is set in the filter configuration, the hierarchy tree loads open
24
+ * by default instead of collapsed.
18
25
  *
26
+ * @param props - Standard Sanity `ArrayFieldProps` extended with an optional
27
+ * `embeddingsIndex` configuration object.
28
+ * @param props.embeddingsIndex - Optional configuration for AI-assisted term
29
+ * recommendations via a Sanity Embeddings Index. When provided, opening the tree
30
+ * browser queries the specified index and annotates matching taxonomy terms with
31
+ * a relevance score to help authors identify the most appropriate terms.
32
+ * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index
33
+ * to query. Must be an index that includes `skosConcept` documents.
34
+ * @param props.embeddingsIndex.fieldReferences - An array of field names from the
35
+ * current document whose values are concatenated and sent as the embeddings search
36
+ * query. All listed fields must contain values when the tree browser is opened;
37
+ * empty fields will display an error message in the tree view rather than scores.
38
+ * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching
39
+ * terms to return from the embeddings index. Defaults to `3`.
40
+ *
41
+ * @example
42
+ * Basic usage with a scheme filter:
43
+ * ```js
44
+ * import {ArrayHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
45
+ *
46
+ * defineField({
47
+ * name: 'categories',
48
+ * title: 'Categories',
49
+ * type: 'array',
50
+ * of: [
51
+ * {
52
+ * type: 'reference',
53
+ * to: {type: 'skosConcept'},
54
+ * options: {
55
+ * filter: schemeFilter({schemeId: 'f3deba'}),
56
+ * disableNew: true,
57
+ * },
58
+ * },
59
+ * ],
60
+ * components: {field: ArrayHierarchyInput},
61
+ * })
62
+ * ```
63
+ *
64
+ * @example
65
+ * Branch filter with tree expanded by default:
66
+ * ```js
67
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
68
+ *
69
+ * defineField({
70
+ * name: 'habitats',
71
+ * title: 'Habitats',
72
+ * type: 'array',
73
+ * of: [
74
+ * {
75
+ * type: 'reference',
76
+ * to: {type: 'skosConcept'},
77
+ * options: {
78
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),
79
+ * disableNew: true,
80
+ * },
81
+ * },
82
+ * ],
83
+ * components: {field: ArrayHierarchyInput},
84
+ * })
85
+ * ```
86
+ *
87
+ * @example
88
+ * Browse-only mode (suppresses the default Sanity search input):
89
+ * ```js
90
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
91
+ *
92
+ * defineField({
93
+ * name: 'habitats',
94
+ * title: 'Habitats',
95
+ * type: 'array',
96
+ * of: [
97
+ * {
98
+ * type: 'reference',
99
+ * to: {type: 'skosConcept'},
100
+ * options: {
101
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),
102
+ * disableNew: true,
103
+ * },
104
+ * },
105
+ * ],
106
+ * components: {field: ArrayHierarchyInput},
107
+ * })
108
+ * ```
109
+ *
110
+ * @example
111
+ * AI-assisted recommendations via an embeddings index:
112
+ * ```jsx
113
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
114
+ *
115
+ * defineField({
116
+ * name: 'categories',
117
+ * title: 'Categories',
118
+ * type: 'array',
119
+ * of: [
120
+ * {
121
+ * type: 'reference',
122
+ * to: [{type: 'skosConcept'}],
123
+ * options: {
124
+ * filter: branchFilter({schemeId: 'f3deba', branchId: '25f826'}),
125
+ * disableNew: true,
126
+ * },
127
+ * },
128
+ * ],
129
+ * components: {
130
+ * field: (props) => (
131
+ * <ArrayHierarchyInput
132
+ * {...props}
133
+ * embeddingsIndex={{
134
+ * indexName: 'my-taxonomy-index',
135
+ * fieldReferences: ['title', 'description'],
136
+ * maxResults: 4,
137
+ * }}
138
+ * />
139
+ * ),
140
+ * },
141
+ * })
142
+ * ```
143
+ *
144
+ * @see {@link ReferenceHierarchyInput} for single-value `reference` fields
145
+ * @see {@link schemeFilter} for filtering by a full concept scheme
146
+ * @see {@link branchFilter} for filtering by a branch within a concept scheme
19
147
  */
20
- export declare function ArrayHierarchyInput(props: ArrayFieldProps): JSX.Element
148
+ export declare function ArrayHierarchyInput(props: ArrayHierarchyInputProps): JSX.Element
149
+
150
+ declare type ArrayHierarchyInputProps = ArrayFieldProps & {
151
+ embeddingsIndex?: EmbeddingsIndexConfig
152
+ }
21
153
 
22
154
  /**
23
155
  * #### Reference Field Scheme & Branch Filter
@@ -103,6 +235,24 @@ declare interface ConceptSchemeDocument extends SanityDocument {
103
235
  }
104
236
  }
105
237
 
238
+ declare interface EmbeddingsIndexConfig {
239
+ indexName: string
240
+ fieldReferences: string[]
241
+ maxResults?: number
242
+ }
243
+
244
+ declare interface EmbeddingsResult {
245
+ score: number
246
+ value: {
247
+ documentId: string
248
+ type: string
249
+ }
250
+ }
251
+
252
+ declare type HierarchyInput = ObjectFieldProps<Reference> & {
253
+ embeddingsIndex?: EmbeddingsIndexConfig
254
+ }
255
+
106
256
  declare interface Options {
107
257
  baseUri?: string
108
258
  customConceptFields?: FieldDefinition[]
@@ -116,15 +266,122 @@ declare interface Options {
116
266
  }
117
267
 
118
268
  /**
119
- * #### Hierarchy View Input Component for Reference Fields
120
- * Allows Studio users to browse and select taxonomy
121
- * terms from a hierarchical tree structure. It is designed to be
122
- * used as an input for taxonomy reference fields in Sanity Studio.
269
+ * Input component that replaces Sanity's default reference field input with a
270
+ * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms
271
+ * organized in their scheme hierarchy and select a single term for the field.
272
+ *
273
+ * @remarks
274
+ * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's
275
+ * `options.filter`. Rendering without a filter will display a configuration warning.
276
+ * - Taxonomy selection is disabled when viewing the published perspective.
277
+ * - When `browseOnly` is set in the filter configuration, Sanity's default search input
278
+ * is suppressed and only the tree browser is available for term selection.
279
+ * - When `expanded` is set in the filter configuration, the hierarchy tree loads open
280
+ * by default instead of collapsed.
281
+ *
282
+ * @param props - Standard Sanity `ObjectFieldProps<Reference>` extended with an optional
283
+ * `embeddingsIndex` configuration object.
284
+ * @param props.embeddingsIndex - Optional configuration for AI-assisted term
285
+ * recommendations via a Sanity Embeddings Index. When provided, opening the tree
286
+ * browser queries the specified index and annotates matching taxonomy terms with
287
+ * a relevance score to help authors identify the most appropriate term.
288
+ * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index
289
+ * to query. Must be an index that includes `skosConcept` documents.
290
+ * @param props.embeddingsIndex.fieldReferences - An array of field names from the
291
+ * current document whose values are concatenated and sent as the embeddings search
292
+ * query. All listed fields must contain values when the tree browser is opened;
293
+ * empty fields will display an error message in the tree view rather than scores.
294
+ * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching
295
+ * terms to return from the embeddings index. Defaults to `3`.
296
+ *
297
+ * @example
298
+ * Basic usage with a scheme filter:
299
+ * ```js
300
+ * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
123
301
  *
124
- * Hierarchy view must be used in conjunction with the Taxonomy Manager
125
- * plugin `schemeFilter` or `branchFilter` options.
302
+ * defineField({
303
+ * name: 'gradeLevel',
304
+ * title: 'Grade Level',
305
+ * type: 'reference',
306
+ * to: {type: 'skosConcept'},
307
+ * options: {
308
+ * filter: schemeFilter({schemeId: 'f3deba'}),
309
+ * disableNew: true,
310
+ * },
311
+ * components: {field: ReferenceHierarchyInput},
312
+ * })
313
+ * ```
314
+ *
315
+ * @example
316
+ * Branch filter with tree expanded by default:
317
+ * ```js
318
+ * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
319
+ *
320
+ * defineField({
321
+ * name: 'topics',
322
+ * title: 'Topics',
323
+ * type: 'reference',
324
+ * to: {type: 'skosConcept'},
325
+ * options: {
326
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),
327
+ * disableNew: true,
328
+ * },
329
+ * components: {field: ReferenceHierarchyInput},
330
+ * })
331
+ * ```
332
+ *
333
+ * @example
334
+ * Browse-only mode (suppresses the default Sanity search input):
335
+ * ```js
336
+ * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
337
+ *
338
+ * defineField({
339
+ * name: 'topics',
340
+ * title: 'Topics',
341
+ * type: 'reference',
342
+ * to: {type: 'skosConcept'},
343
+ * options: {
344
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),
345
+ * disableNew: true,
346
+ * },
347
+ * components: {field: ReferenceHierarchyInput},
348
+ * })
349
+ * ```
350
+ *
351
+ * @example
352
+ * AI-assisted recommendations via an embeddings index:
353
+ * ```jsx
354
+ * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
355
+ *
356
+ * defineField({
357
+ * name: 'topics',
358
+ * title: 'Topics',
359
+ * type: 'reference',
360
+ * to: [{type: 'skosConcept'}],
361
+ * options: {
362
+ * filter: schemeFilter({schemeId: 'f3deba'}),
363
+ * disableNew: true,
364
+ * },
365
+ * components: {
366
+ * field: (props) => (
367
+ * <ReferenceHierarchyInput
368
+ * {...props}
369
+ * embeddingsIndex={{
370
+ * indexName: 'my-taxonomy-index',
371
+ * fieldReferences: ['title', 'metaDescription'],
372
+ * maxResults: 4,
373
+ * }}
374
+ * />
375
+ * ),
376
+ * },
377
+ * })
378
+ * ```
379
+ *
380
+ * @see {@link ArrayHierarchyInput} for multi-value `array` fields
381
+ * @see {@link schemeFilter} for filtering by a full concept scheme
382
+ * @see {@link branchFilter} for filtering by a branch within a concept scheme
126
383
  */
127
- export declare function ReferenceHierarchyInput(props: ObjectFieldProps<Reference>): JSX.Element
384
+ export declare function ReferenceHierarchyInput(props: HierarchyInput): JSX.Element
128
385
 
129
386
  /**
130
387
  * #### Reference Field Scheme Filter
@@ -218,14 +475,18 @@ export declare const TreeView: ({
218
475
  inputComponent,
219
476
  selectConcept,
220
477
  expanded,
478
+ conceptRecs,
479
+ recsError,
221
480
  }: TreeViewProps) => JSX.Element
222
481
 
223
482
  declare interface TreeViewProps {
224
483
  document?: ConceptSchemeDocument
225
- branchId: string
484
+ branchId?: string | null
226
485
  selectConcept?: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void
227
486
  inputComponent?: boolean
228
487
  expanded?: boolean
488
+ conceptRecs?: EmbeddingsResult[]
489
+ recsError?: string | null
229
490
  }
230
491
 
231
492
  export {}
@@ -8,16 +8,148 @@ import type {SanityDocument} from 'sanity'
8
8
  import type {useClient} from 'sanity'
9
9
 
10
10
  /**
11
- * #### Hierarchy View Input Component
12
- * Allows Studio users to browse and select taxonomy
13
- * terms from a hierarchical tree structure. It is designed to be
14
- * used as an input for taxonomy array fields in Sanity Studio.
11
+ * Input component that replaces Sanity's default array field input with a
12
+ * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms
13
+ * organized in their scheme hierarchy and select terms to add to the array field.
15
14
  *
16
- * Hierarchy view must be used in conjunction with the Taxonomy Manager
17
- * plugin `schemeFilter` or `branchFilter` options.
15
+ * @remarks
16
+ * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's
17
+ * `options.filter`. Rendering without a filter will display a configuration warning.
18
+ * - Supports only **single-schema arrays** (i.e., `of: [{type: 'reference'}]`). Arrays
19
+ * with multiple schema types will render a warning and fall back to the default input.
20
+ * - Taxonomy selection is disabled when viewing the published perspective.
21
+ * - When `browseOnly` is set in the filter configuration, Sanity's default search input
22
+ * is suppressed and only the tree browser is available for term selection.
23
+ * - When `expanded` is set in the filter configuration, the hierarchy tree loads open
24
+ * by default instead of collapsed.
18
25
  *
26
+ * @param props - Standard Sanity `ArrayFieldProps` extended with an optional
27
+ * `embeddingsIndex` configuration object.
28
+ * @param props.embeddingsIndex - Optional configuration for AI-assisted term
29
+ * recommendations via a Sanity Embeddings Index. When provided, opening the tree
30
+ * browser queries the specified index and annotates matching taxonomy terms with
31
+ * a relevance score to help authors identify the most appropriate terms.
32
+ * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index
33
+ * to query. Must be an index that includes `skosConcept` documents.
34
+ * @param props.embeddingsIndex.fieldReferences - An array of field names from the
35
+ * current document whose values are concatenated and sent as the embeddings search
36
+ * query. All listed fields must contain values when the tree browser is opened;
37
+ * empty fields will display an error message in the tree view rather than scores.
38
+ * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching
39
+ * terms to return from the embeddings index. Defaults to `3`.
40
+ *
41
+ * @example
42
+ * Basic usage with a scheme filter:
43
+ * ```js
44
+ * import {ArrayHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
45
+ *
46
+ * defineField({
47
+ * name: 'categories',
48
+ * title: 'Categories',
49
+ * type: 'array',
50
+ * of: [
51
+ * {
52
+ * type: 'reference',
53
+ * to: {type: 'skosConcept'},
54
+ * options: {
55
+ * filter: schemeFilter({schemeId: 'f3deba'}),
56
+ * disableNew: true,
57
+ * },
58
+ * },
59
+ * ],
60
+ * components: {field: ArrayHierarchyInput},
61
+ * })
62
+ * ```
63
+ *
64
+ * @example
65
+ * Branch filter with tree expanded by default:
66
+ * ```js
67
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
68
+ *
69
+ * defineField({
70
+ * name: 'habitats',
71
+ * title: 'Habitats',
72
+ * type: 'array',
73
+ * of: [
74
+ * {
75
+ * type: 'reference',
76
+ * to: {type: 'skosConcept'},
77
+ * options: {
78
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),
79
+ * disableNew: true,
80
+ * },
81
+ * },
82
+ * ],
83
+ * components: {field: ArrayHierarchyInput},
84
+ * })
85
+ * ```
86
+ *
87
+ * @example
88
+ * Browse-only mode (suppresses the default Sanity search input):
89
+ * ```js
90
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
91
+ *
92
+ * defineField({
93
+ * name: 'habitats',
94
+ * title: 'Habitats',
95
+ * type: 'array',
96
+ * of: [
97
+ * {
98
+ * type: 'reference',
99
+ * to: {type: 'skosConcept'},
100
+ * options: {
101
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),
102
+ * disableNew: true,
103
+ * },
104
+ * },
105
+ * ],
106
+ * components: {field: ArrayHierarchyInput},
107
+ * })
108
+ * ```
109
+ *
110
+ * @example
111
+ * AI-assisted recommendations via an embeddings index:
112
+ * ```jsx
113
+ * import {ArrayHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
114
+ *
115
+ * defineField({
116
+ * name: 'categories',
117
+ * title: 'Categories',
118
+ * type: 'array',
119
+ * of: [
120
+ * {
121
+ * type: 'reference',
122
+ * to: [{type: 'skosConcept'}],
123
+ * options: {
124
+ * filter: branchFilter({schemeId: 'f3deba', branchId: '25f826'}),
125
+ * disableNew: true,
126
+ * },
127
+ * },
128
+ * ],
129
+ * components: {
130
+ * field: (props) => (
131
+ * <ArrayHierarchyInput
132
+ * {...props}
133
+ * embeddingsIndex={{
134
+ * indexName: 'my-taxonomy-index',
135
+ * fieldReferences: ['title', 'description'],
136
+ * maxResults: 4,
137
+ * }}
138
+ * />
139
+ * ),
140
+ * },
141
+ * })
142
+ * ```
143
+ *
144
+ * @see {@link ReferenceHierarchyInput} for single-value `reference` fields
145
+ * @see {@link schemeFilter} for filtering by a full concept scheme
146
+ * @see {@link branchFilter} for filtering by a branch within a concept scheme
19
147
  */
20
- export declare function ArrayHierarchyInput(props: ArrayFieldProps): JSX.Element
148
+ export declare function ArrayHierarchyInput(props: ArrayHierarchyInputProps): JSX.Element
149
+
150
+ declare type ArrayHierarchyInputProps = ArrayFieldProps & {
151
+ embeddingsIndex?: EmbeddingsIndexConfig
152
+ }
21
153
 
22
154
  /**
23
155
  * #### Reference Field Scheme & Branch Filter
@@ -103,6 +235,24 @@ declare interface ConceptSchemeDocument extends SanityDocument {
103
235
  }
104
236
  }
105
237
 
238
+ declare interface EmbeddingsIndexConfig {
239
+ indexName: string
240
+ fieldReferences: string[]
241
+ maxResults?: number
242
+ }
243
+
244
+ declare interface EmbeddingsResult {
245
+ score: number
246
+ value: {
247
+ documentId: string
248
+ type: string
249
+ }
250
+ }
251
+
252
+ declare type HierarchyInput = ObjectFieldProps<Reference> & {
253
+ embeddingsIndex?: EmbeddingsIndexConfig
254
+ }
255
+
106
256
  declare interface Options {
107
257
  baseUri?: string
108
258
  customConceptFields?: FieldDefinition[]
@@ -116,15 +266,122 @@ declare interface Options {
116
266
  }
117
267
 
118
268
  /**
119
- * #### Hierarchy View Input Component for Reference Fields
120
- * Allows Studio users to browse and select taxonomy
121
- * terms from a hierarchical tree structure. It is designed to be
122
- * used as an input for taxonomy reference fields in Sanity Studio.
269
+ * Input component that replaces Sanity's default reference field input with a
270
+ * hierarchical taxonomy tree browser. Studio users can browse taxonomy terms
271
+ * organized in their scheme hierarchy and select a single term for the field.
272
+ *
273
+ * @remarks
274
+ * - Must be used with a `schemeFilter` or `branchFilter` helper in the field's
275
+ * `options.filter`. Rendering without a filter will display a configuration warning.
276
+ * - Taxonomy selection is disabled when viewing the published perspective.
277
+ * - When `browseOnly` is set in the filter configuration, Sanity's default search input
278
+ * is suppressed and only the tree browser is available for term selection.
279
+ * - When `expanded` is set in the filter configuration, the hierarchy tree loads open
280
+ * by default instead of collapsed.
281
+ *
282
+ * @param props - Standard Sanity `ObjectFieldProps<Reference>` extended with an optional
283
+ * `embeddingsIndex` configuration object.
284
+ * @param props.embeddingsIndex - Optional configuration for AI-assisted term
285
+ * recommendations via a Sanity Embeddings Index. When provided, opening the tree
286
+ * browser queries the specified index and annotates matching taxonomy terms with
287
+ * a relevance score to help authors identify the most appropriate term.
288
+ * @param props.embeddingsIndex.indexName - The name of the Sanity Embeddings Index
289
+ * to query. Must be an index that includes `skosConcept` documents.
290
+ * @param props.embeddingsIndex.fieldReferences - An array of field names from the
291
+ * current document whose values are concatenated and sent as the embeddings search
292
+ * query. All listed fields must contain values when the tree browser is opened;
293
+ * empty fields will display an error message in the tree view rather than scores.
294
+ * @param props.embeddingsIndex.maxResults - Maximum number of semantically matching
295
+ * terms to return from the embeddings index. Defaults to `3`.
296
+ *
297
+ * @example
298
+ * Basic usage with a scheme filter:
299
+ * ```js
300
+ * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
123
301
  *
124
- * Hierarchy view must be used in conjunction with the Taxonomy Manager
125
- * plugin `schemeFilter` or `branchFilter` options.
302
+ * defineField({
303
+ * name: 'gradeLevel',
304
+ * title: 'Grade Level',
305
+ * type: 'reference',
306
+ * to: {type: 'skosConcept'},
307
+ * options: {
308
+ * filter: schemeFilter({schemeId: 'f3deba'}),
309
+ * disableNew: true,
310
+ * },
311
+ * components: {field: ReferenceHierarchyInput},
312
+ * })
313
+ * ```
314
+ *
315
+ * @example
316
+ * Branch filter with tree expanded by default:
317
+ * ```js
318
+ * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
319
+ *
320
+ * defineField({
321
+ * name: 'topics',
322
+ * title: 'Topics',
323
+ * type: 'reference',
324
+ * to: {type: 'skosConcept'},
325
+ * options: {
326
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', expanded: true}),
327
+ * disableNew: true,
328
+ * },
329
+ * components: {field: ReferenceHierarchyInput},
330
+ * })
331
+ * ```
332
+ *
333
+ * @example
334
+ * Browse-only mode (suppresses the default Sanity search input):
335
+ * ```js
336
+ * import {ReferenceHierarchyInput, branchFilter} from 'sanity-plugin-taxonomy-manager'
337
+ *
338
+ * defineField({
339
+ * name: 'topics',
340
+ * title: 'Topics',
341
+ * type: 'reference',
342
+ * to: {type: 'skosConcept'},
343
+ * options: {
344
+ * filter: branchFilter({schemeId: 'cf76c1', branchId: '1e5e6c', browseOnly: true}),
345
+ * disableNew: true,
346
+ * },
347
+ * components: {field: ReferenceHierarchyInput},
348
+ * })
349
+ * ```
350
+ *
351
+ * @example
352
+ * AI-assisted recommendations via an embeddings index:
353
+ * ```jsx
354
+ * import {ReferenceHierarchyInput, schemeFilter} from 'sanity-plugin-taxonomy-manager'
355
+ *
356
+ * defineField({
357
+ * name: 'topics',
358
+ * title: 'Topics',
359
+ * type: 'reference',
360
+ * to: [{type: 'skosConcept'}],
361
+ * options: {
362
+ * filter: schemeFilter({schemeId: 'f3deba'}),
363
+ * disableNew: true,
364
+ * },
365
+ * components: {
366
+ * field: (props) => (
367
+ * <ReferenceHierarchyInput
368
+ * {...props}
369
+ * embeddingsIndex={{
370
+ * indexName: 'my-taxonomy-index',
371
+ * fieldReferences: ['title', 'metaDescription'],
372
+ * maxResults: 4,
373
+ * }}
374
+ * />
375
+ * ),
376
+ * },
377
+ * })
378
+ * ```
379
+ *
380
+ * @see {@link ArrayHierarchyInput} for multi-value `array` fields
381
+ * @see {@link schemeFilter} for filtering by a full concept scheme
382
+ * @see {@link branchFilter} for filtering by a branch within a concept scheme
126
383
  */
127
- export declare function ReferenceHierarchyInput(props: ObjectFieldProps<Reference>): JSX.Element
384
+ export declare function ReferenceHierarchyInput(props: HierarchyInput): JSX.Element
128
385
 
129
386
  /**
130
387
  * #### Reference Field Scheme Filter
@@ -218,14 +475,18 @@ export declare const TreeView: ({
218
475
  inputComponent,
219
476
  selectConcept,
220
477
  expanded,
478
+ conceptRecs,
479
+ recsError,
221
480
  }: TreeViewProps) => JSX.Element
222
481
 
223
482
  declare interface TreeViewProps {
224
483
  document?: ConceptSchemeDocument
225
- branchId: string
484
+ branchId?: string | null
226
485
  selectConcept?: (conceptId: {_ref: string; _type: 'reference'; _originalId?: string}) => void
227
486
  inputComponent?: boolean
228
487
  expanded?: boolean
488
+ conceptRecs?: EmbeddingsResult[]
489
+ recsError?: string | null
229
490
  }
230
491
 
231
492
  export {}