@sanity/presets 0.3.0 → 0.4.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 +38 -24
- package/dist/index.d.ts +14 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -65
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
- You want opinionated defaults to get started quickly.
|
|
19
19
|
- You don't yet have a need for highly custom content modelling.
|
|
20
|
-
- You have not chosen to use LLMs for schema generation.
|
|
21
20
|
|
|
22
21
|
Presets are designed to be extended — add fields, groups, and map hooks as your needs evolve. When a preset no longer fits, replace it with your own schema type using `defineType` directly.
|
|
23
22
|
|
|
@@ -164,6 +163,10 @@ definePage({
|
|
|
164
163
|
})
|
|
165
164
|
```
|
|
166
165
|
|
|
166
|
+
Each entry in `pageBuilderBlocks` is either a string referencing a type in your schema, or an inline schema type definition - typically a preset instance such as `defineImage({name: 'imageBlock'})`. Mix both freely.
|
|
167
|
+
|
|
168
|
+
Rich text presets work in `pageBuilderBlocks`, both inline (`defineRichText({...})`) and by name (`'richText'`). Documents store each rich text block under `content[].content`.
|
|
169
|
+
|
|
167
170
|
**Fields:**
|
|
168
171
|
|
|
169
172
|
| Field | Type | Group | Description |
|
|
@@ -177,11 +180,11 @@ definePage({
|
|
|
177
180
|
|
|
178
181
|
**Options:**
|
|
179
182
|
|
|
180
|
-
| Option | Type | Description
|
|
181
|
-
| ------------------- | ------------------------ |
|
|
182
|
-
| `pageBuilderBlocks` | `
|
|
183
|
-
| `fields` | `FieldDefinition[]` | Additional fields to append.
|
|
184
|
-
| `groups` | `FieldGroupDefinition[]` | Additional groups to append after the defaults.
|
|
183
|
+
| Option | Type | Description |
|
|
184
|
+
| ------------------- | ------------------------ | ----------------------------------------------------------------------------- |
|
|
185
|
+
| `pageBuilderBlocks` | `PageBuilderBlock[]` | Type names or inline schema type definitions to include in the content array. |
|
|
186
|
+
| `fields` | `FieldDefinition[]` | Additional fields to append. |
|
|
187
|
+
| `groups` | `FieldGroupDefinition[]` | Additional groups to append after the defaults. |
|
|
185
188
|
|
|
186
189
|
The page preset is not the only way to create page documents. It provides opinionated defaults to get started quickly. For specialised page types, use `defineType` directly. See the [document type documentation](https://www.sanity.io/docs/studio/document-type).
|
|
187
190
|
|
|
@@ -347,6 +350,20 @@ The `objects` option only toggles embedded objects on or off. To reshape the arr
|
|
|
347
350
|
|
|
348
351
|
## Recommended patterns
|
|
349
352
|
|
|
353
|
+
### Configure links globally
|
|
354
|
+
|
|
355
|
+
The [link preset](#link) is used by multiple other presets ([CTA](#cta-call-to-action), [rich text](#rich-text)). Configure `internalTypes` at the registry level so all links share the same set of linkable document types:
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const {defineLink, defineCta, definePage} = createPresetsRegistry({
|
|
359
|
+
link: {
|
|
360
|
+
internalTypes: ['page', 'post', 'product'],
|
|
361
|
+
},
|
|
362
|
+
})
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
This single configuration flows into every `defineLink`, `defineCta`, and `defineRichText` call from this registry. Override at the call site only when a specific instance needs different behaviour.
|
|
366
|
+
|
|
350
367
|
### Use presets alongside custom types
|
|
351
368
|
|
|
352
369
|
Presets are not intended to replace all content modelling. They provide opinionated defaults for common patterns — pages, links, images, metadata — but your schema will likely include custom types that are specific to your project.
|
|
@@ -363,9 +380,20 @@ defineType({
|
|
|
363
380
|
title: 'Blockquote',
|
|
364
381
|
type: 'object',
|
|
365
382
|
fields: [
|
|
366
|
-
defineField({
|
|
367
|
-
|
|
368
|
-
|
|
383
|
+
defineField({
|
|
384
|
+
name: 'quote',
|
|
385
|
+
title: 'Quote',
|
|
386
|
+
type: 'text',
|
|
387
|
+
}),
|
|
388
|
+
defineField({
|
|
389
|
+
name: 'author',
|
|
390
|
+
title: 'Author',
|
|
391
|
+
type: 'string',
|
|
392
|
+
}),
|
|
393
|
+
defineLink({
|
|
394
|
+
name: 'source',
|
|
395
|
+
title: 'Source',
|
|
396
|
+
}),
|
|
369
397
|
],
|
|
370
398
|
})
|
|
371
399
|
```
|
|
@@ -382,7 +410,7 @@ definePage({
|
|
|
382
410
|
title: 'Blog Post',
|
|
383
411
|
// These types must be defined in your schema.
|
|
384
412
|
// See "Use presets alongside custom types" for more.
|
|
385
|
-
pageBuilderBlocks: ['richText', '
|
|
413
|
+
pageBuilderBlocks: ['richText', defineImage({name: 'imageBlock'})],
|
|
386
414
|
groups: [{name: 'settings', title: 'Settings'}],
|
|
387
415
|
fields: [
|
|
388
416
|
defineField({
|
|
@@ -430,17 +458,3 @@ A few guidelines for using map hooks:
|
|
|
430
458
|
|
|
431
459
|
- If you find yourself heavily rewriting the produced schema type with map hooks, it may be a sign that you should model the content type yourself. See the [schema type documentation](https://www.sanity.io/docs/apis-and-sdks/introduction-to-schemas) for more.
|
|
432
460
|
- If you use map hooks to rename fields, existing documents may need to be migrated to reflect the new field names. See the [schema and content migrations documentation](https://www.sanity.io/docs/content-lake/schema-and-content-migrations).
|
|
433
|
-
|
|
434
|
-
### Configure links globally
|
|
435
|
-
|
|
436
|
-
The [link preset](#link) is used by multiple other presets ([CTA](#cta-call-to-action), [rich text](#rich-text)). Configure `internalTypes` at the registry level so all links share the same set of linkable document types:
|
|
437
|
-
|
|
438
|
-
```ts
|
|
439
|
-
const {defineLink, defineCta, definePage} = createPresetsRegistry({
|
|
440
|
-
link: {
|
|
441
|
-
internalTypes: ['page', 'post', 'product'],
|
|
442
|
-
},
|
|
443
|
-
})
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
This single configuration flows into every `defineLink`, `defineCta`, and `defineRichText` call from this registry. Override at the call site only when a specific instance needs different behaviour.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefineSchemaBase, FieldDefinition, FieldDefinitionBase, IntrinsicTypeName, PreviewConfig, SchemaTypeDefinition } from "sanity";
|
|
2
2
|
type PartialSchemaDefinition<TypeName extends IntrinsicTypeName> = Partial<DefineSchemaBase<TypeName, TypeName> & {
|
|
3
3
|
preview: PreviewConfig;
|
|
4
|
-
}>;
|
|
4
|
+
}> & Pick<DefineSchemaBase<TypeName, TypeName>, 'name'>;
|
|
5
5
|
interface RegistryContext {
|
|
6
6
|
getPreset: (presetName: string, config?: Record<string, unknown>) => FieldDefinition;
|
|
7
7
|
}
|
|
@@ -12,21 +12,19 @@ type DerivedConfig<Context, AliasedType extends IntrinsicTypeName | undefined =
|
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* The public-facing config shape that a registry's `define<Name>` function
|
|
15
|
-
* accepts at the call site. Includes the full `DerivedConfig`
|
|
16
|
-
* `
|
|
17
|
-
* name when `name` is omitted).
|
|
15
|
+
* accepts at the call site. Includes the full `DerivedConfig` with required
|
|
16
|
+
* `name` (inherited from `FieldDefinitionBase`) and optional `map`.
|
|
18
17
|
*/
|
|
19
18
|
type UserConfig<Context = {}, AliasedType extends IntrinsicTypeName | undefined = undefined, LockedProperties extends string | undefined = undefined> = DerivedConfig<Context, AliasedType, LockedProperties>;
|
|
20
19
|
/**
|
|
21
20
|
* A preset definition describes how to produce a Sanity schema type.
|
|
22
21
|
*
|
|
23
|
-
* - `name` is the
|
|
24
|
-
*
|
|
25
|
-
* sure the override reaches the `schemaType` factory via its config.
|
|
22
|
+
* - `name` is the registry key for the preset (it determines the
|
|
23
|
+
* `define<Name>` function and the `PresetsRegistryConfig` key).
|
|
26
24
|
* - `identifier` is an optional stable identifier used for telemetry.
|
|
27
25
|
* - `schemaType` is the factory that produces the Sanity schema type. It
|
|
28
|
-
* receives the merged config (minus `map
|
|
29
|
-
*
|
|
26
|
+
* receives the merged config (minus `map`) and the registry context, and
|
|
27
|
+
* returns a `SchemaTypeDefinition`.
|
|
30
28
|
*/
|
|
31
29
|
interface PresetDefinition<Context = {}, AliasedType extends IntrinsicTypeName | undefined = undefined, LockedProperties extends string | undefined = undefined> {
|
|
32
30
|
name: string;
|
|
@@ -40,6 +38,11 @@ interface PresetDefinition<Context = {}, AliasedType extends IntrinsicTypeName |
|
|
|
40
38
|
* that handles presets generically (e.g. the registry).
|
|
41
39
|
*/
|
|
42
40
|
type AnyPresetDefinition = PresetDefinition<any, any, any>;
|
|
41
|
+
type PageBuilderBlock = string | (SchemaTypeDefinition & FieldDefinition);
|
|
42
|
+
interface PageTypeConfig {
|
|
43
|
+
pageBuilderBlocks?: PageBuilderBlock[];
|
|
44
|
+
}
|
|
45
|
+
declare const pageType: PresetDefinition<PageTypeConfig, "document", undefined>;
|
|
43
46
|
declare const ctaType: PresetDefinition<{}, "object", "preview">;
|
|
44
47
|
interface ImageTypeConfig {
|
|
45
48
|
altText?: boolean;
|
|
@@ -51,10 +54,6 @@ interface LinkTypeConfig {
|
|
|
51
54
|
internalTypes?: string[];
|
|
52
55
|
}
|
|
53
56
|
declare const linkType: PresetDefinition<LinkTypeConfig, "object", "preview">;
|
|
54
|
-
interface PageTypeConfig {
|
|
55
|
-
pageBuilderBlocks?: string[];
|
|
56
|
-
}
|
|
57
|
-
declare const pageType: PresetDefinition<PageTypeConfig, "document", undefined>;
|
|
58
57
|
interface RichTextObjectsConfig {
|
|
59
58
|
link?: boolean;
|
|
60
59
|
image?: boolean;
|
|
@@ -79,7 +78,7 @@ interface PresetsRegistryConfig {
|
|
|
79
78
|
image?: ImageTypeConfig;
|
|
80
79
|
page?: PageTypeConfig;
|
|
81
80
|
}
|
|
82
|
-
type DefineFunction<Preset extends AnyPresetDefinition> = Preset extends PresetDefinition<infer Context, infer AliasedType, infer LockedProperties> ? (config
|
|
81
|
+
type DefineFunction<Preset extends AnyPresetDefinition> = Preset extends PresetDefinition<infer Context, infer AliasedType, infer LockedProperties> ? (config: UserConfig<Context, AliasedType, LockedProperties>) => SchemaTypeDefinition & FieldDefinition : never;
|
|
83
82
|
interface PresetsRegistry {
|
|
84
83
|
defineLink: DefineFunction<typeof linkType>;
|
|
85
84
|
defineCta: DefineFunction<typeof ctaType>;
|
|
@@ -89,5 +88,5 @@ interface PresetsRegistry {
|
|
|
89
88
|
defineRichText: DefineFunction<typeof richTextType>;
|
|
90
89
|
}
|
|
91
90
|
declare function createPresetsRegistry(config?: PresetsRegistryConfig): PresetsRegistry;
|
|
92
|
-
export { type PresetsRegistry, type PresetsRegistryConfig, createPresetsRegistry };
|
|
91
|
+
export { type PageBuilderBlock, type PresetsRegistry, type PresetsRegistryConfig, createPresetsRegistry };
|
|
93
92
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/definePresetType.ts","../src/presets/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/definePresetType.ts","../src/presets/page-type/index.ts","../src/presets/cta-type/index.ts","../src/presets/image-type/index.ts","../src/presets/link-type/index.ts","../src/presets/rich-text-type/index.ts","../src/presets/seo-type/index.ts","../src/registry.tsx"],"mappings":";KAEY,uBAAA,kBAAyC,iBAAA,IAAqB,OAAA,CACxE,gBAAA,CAAiB,QAAA,EAAU,QAAA;EAAa,OAAA,EAAS,aAAA;AAAA,KAEjD,IAAA,CAAK,gBAAA,CAAiB,QAAA,EAAU,QAAA;AAAA,UCIjB,eAAA;EACf,SAAA,GAAY,UAAA,UAAoB,MAAA,GAAS,MAAA,sBAA4B,eAAA;AAAA;AAAA,KAGlE,oBAAA;AAAA,KAEA,kBAAA,+DACH,kBAAA,WACS,WAAA,IACP,IAAA,CAAK,UAAA,EAAY,kBAAA,IACjB,UAAA;AAAA,KAEQ,aAAA,8BAEU,iBAAA,qFAElB,OAAA,GACF,mBAAA,IACC,WAAA,kBACG,kBAAA,CACE,uBAAA,CAAwB,WAAA,GACxB,oBAAA,GAAuB,gBAAA;EAG3B,GAAA,GAAM,WAAA,kCAEc,uBAAA,CAAwB,WAAA,MACpC,KAAA,EA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;AAAA,UAGjB,eAAA;EACf,UAAA,EAAY,cAAA,QAAsB,QAAA;EAClC,SAAA,EAAW,cAAA,QAAsB,OAAA;EACjC,SAAA,EAAW,cAAA,QAAsB,OAAA;EACjC,WAAA,EAAa,cAAA,QAAsB,SAAA;EACnC,UAAA,EAAY,cAAA,QAAsB,QAAA;EAClC,cAAA,EAAgB,cAAA,QAAsB,YAAA;AAAA;AAAA,iBAGxB,qBAAA,CAAsB,MAAA,GAAQ,qBAAA,GAA6B,eAAA"}
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,6 @@ const ctaType = {
|
|
|
47
47
|
...objectConfig
|
|
48
48
|
} = config;
|
|
49
49
|
return defineType({
|
|
50
|
-
title: "Call to action",
|
|
51
50
|
...objectConfig,
|
|
52
51
|
type: "object",
|
|
53
52
|
fields: [registry.getPreset("link", {
|
|
@@ -95,7 +94,6 @@ const ctaType = {
|
|
|
95
94
|
...objectConfig
|
|
96
95
|
} = config;
|
|
97
96
|
return defineType({
|
|
98
|
-
title: "Image",
|
|
99
97
|
...objectConfig,
|
|
100
98
|
type: "object",
|
|
101
99
|
fields: [defineField({
|
|
@@ -135,7 +133,6 @@ const ctaType = {
|
|
|
135
133
|
type
|
|
136
134
|
}));
|
|
137
135
|
return defineType({
|
|
138
|
-
title: "Link",
|
|
139
136
|
...objectConfig,
|
|
140
137
|
type: "object",
|
|
141
138
|
fields: [defineField({
|
|
@@ -201,61 +198,92 @@ const ctaType = {
|
|
|
201
198
|
}
|
|
202
199
|
});
|
|
203
200
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
default: !0
|
|
225
|
-
}, {
|
|
226
|
-
name: "metadata",
|
|
227
|
-
title: "Metadata"
|
|
228
|
-
}, ...groups ?? []],
|
|
229
|
-
fields: [defineField({
|
|
230
|
-
name: "name",
|
|
231
|
-
title: "Name",
|
|
232
|
-
type: "string",
|
|
233
|
-
group: "main",
|
|
234
|
-
validation: (rule) => rule.required()
|
|
235
|
-
}), defineField({
|
|
236
|
-
name: "slug",
|
|
237
|
-
title: "Slug",
|
|
238
|
-
type: "slug",
|
|
239
|
-
group: "main",
|
|
240
|
-
options: {
|
|
241
|
-
source: "name"
|
|
242
|
-
}
|
|
243
|
-
}), defineField({
|
|
244
|
-
name: "content",
|
|
245
|
-
title: "Content",
|
|
246
|
-
group: "main",
|
|
247
|
-
type: "array",
|
|
248
|
-
of: (pageBuilderBlocks ?? []).map((typeName) => defineArrayMember({
|
|
249
|
-
type: typeName
|
|
250
|
-
}))
|
|
251
|
-
}), registry.getPreset("seo", {
|
|
252
|
-
name: "seo",
|
|
253
|
-
title: "SEO",
|
|
254
|
-
group: "metadata"
|
|
255
|
-
}), ...fields ?? []]
|
|
201
|
+
};
|
|
202
|
+
function wrapArrayAsPageBuilderBlock(arraySchema) {
|
|
203
|
+
const components = "components" in arraySchema ? arraySchema.components : void 0;
|
|
204
|
+
return defineArrayMember({
|
|
205
|
+
name: arraySchema.name,
|
|
206
|
+
title: arraySchema.title,
|
|
207
|
+
type: "object",
|
|
208
|
+
fields: [defineField({
|
|
209
|
+
name: "content",
|
|
210
|
+
type: "array",
|
|
211
|
+
of: arraySchema.of,
|
|
212
|
+
components
|
|
213
|
+
})]
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function toPageBuilderArrayMember(block, lookupArrayPreset) {
|
|
217
|
+
if (typeof block == "string") {
|
|
218
|
+
const arrayPreset = lookupArrayPreset(block);
|
|
219
|
+
return arrayPreset ? wrapArrayAsPageBuilderBlock(arrayPreset) : defineArrayMember({
|
|
220
|
+
type: block
|
|
256
221
|
});
|
|
257
222
|
}
|
|
258
|
-
|
|
223
|
+
return block.type === "array" ? wrapArrayAsPageBuilderBlock(block) : defineArrayMember(block);
|
|
224
|
+
}
|
|
225
|
+
function defineLazyContentField(blocks, lookupArrayPreset) {
|
|
226
|
+
let cached;
|
|
227
|
+
return defineField({
|
|
228
|
+
name: "content",
|
|
229
|
+
title: "Content",
|
|
230
|
+
group: "main",
|
|
231
|
+
type: "array",
|
|
232
|
+
get of() {
|
|
233
|
+
return cached ??= blocks.map((block) => toPageBuilderArrayMember(block, lookupArrayPreset)), cached;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function createPageType({
|
|
238
|
+
lookupArrayPreset
|
|
239
|
+
}) {
|
|
240
|
+
return {
|
|
241
|
+
name: "page",
|
|
242
|
+
identifier: "core.page",
|
|
243
|
+
schemaType: (config, registry) => {
|
|
244
|
+
const {
|
|
245
|
+
pageBuilderBlocks,
|
|
246
|
+
groups,
|
|
247
|
+
fields,
|
|
248
|
+
...documentConfig
|
|
249
|
+
} = config;
|
|
250
|
+
return defineType({
|
|
251
|
+
...documentConfig,
|
|
252
|
+
type: "document",
|
|
253
|
+
groups: [{
|
|
254
|
+
...ALL_FIELDS_GROUP,
|
|
255
|
+
hidden: !0
|
|
256
|
+
}, {
|
|
257
|
+
name: "main",
|
|
258
|
+
title: "Main",
|
|
259
|
+
default: !0
|
|
260
|
+
}, {
|
|
261
|
+
name: "metadata",
|
|
262
|
+
title: "Metadata"
|
|
263
|
+
}, ...groups ?? []],
|
|
264
|
+
fields: [defineField({
|
|
265
|
+
name: "name",
|
|
266
|
+
title: "Name",
|
|
267
|
+
type: "string",
|
|
268
|
+
group: "main",
|
|
269
|
+
validation: (rule) => rule.required()
|
|
270
|
+
}), defineField({
|
|
271
|
+
name: "slug",
|
|
272
|
+
title: "Slug",
|
|
273
|
+
type: "slug",
|
|
274
|
+
group: "main",
|
|
275
|
+
options: {
|
|
276
|
+
source: "name"
|
|
277
|
+
}
|
|
278
|
+
}), defineLazyContentField(pageBuilderBlocks ?? [], lookupArrayPreset), registry.getPreset("seo", {
|
|
279
|
+
name: "seo",
|
|
280
|
+
title: "SEO",
|
|
281
|
+
group: "metadata"
|
|
282
|
+
}), ...fields ?? []]
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
259
287
|
function resolveObjects(objects) {
|
|
260
288
|
if (objects === !1) return {
|
|
261
289
|
link: !1,
|
|
@@ -308,7 +336,6 @@ const richTextType = {
|
|
|
308
336
|
}
|
|
309
337
|
});
|
|
310
338
|
return defineType({
|
|
311
|
-
title: "Rich text",
|
|
312
339
|
...arrayConfig,
|
|
313
340
|
type: "array",
|
|
314
341
|
of: imageMember ? [blockMember, imageMember] : [blockMember]
|
|
@@ -323,7 +350,6 @@ const richTextType = {
|
|
|
323
350
|
...objectConfig
|
|
324
351
|
} = config;
|
|
325
352
|
return defineType({
|
|
326
|
-
title: "Web page metadata (SEO)",
|
|
327
353
|
...objectConfig,
|
|
328
354
|
type: "object",
|
|
329
355
|
fields: [defineField({
|
|
@@ -361,18 +387,24 @@ const richTextType = {
|
|
|
361
387
|
}), ...fields ?? []]
|
|
362
388
|
});
|
|
363
389
|
}
|
|
364
|
-
}
|
|
390
|
+
};
|
|
365
391
|
function createPresetsRegistry(config = {}) {
|
|
366
392
|
const registryId = uuid();
|
|
367
393
|
registerRegistry(registryId);
|
|
368
|
-
const seed = {}
|
|
369
|
-
|
|
394
|
+
const seed = {}, registeredSchemas = /* @__PURE__ */ new Map(), pageTypeWithLookup = createPageType({
|
|
395
|
+
lookupArrayPreset: (name) => {
|
|
396
|
+
const registered = registeredSchemas.get(name);
|
|
397
|
+
return registered?.type === "array" ? registered : void 0;
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
return [linkType, ctaType, seoType, imageType, pageTypeWithLookup, richTextType].reduce((registry, preset) => {
|
|
370
401
|
const key = getPresetKey(preset.name);
|
|
371
402
|
return registry[key] = createDefiner({
|
|
372
403
|
registryId,
|
|
373
404
|
preset,
|
|
374
405
|
config,
|
|
375
|
-
registry
|
|
406
|
+
registry,
|
|
407
|
+
registeredSchemas
|
|
376
408
|
}), registry;
|
|
377
409
|
}, seed);
|
|
378
410
|
}
|
|
@@ -395,14 +427,17 @@ function createDefiner({
|
|
|
395
427
|
registryId,
|
|
396
428
|
preset,
|
|
397
429
|
config,
|
|
398
|
-
registry
|
|
430
|
+
registry,
|
|
431
|
+
registeredSchemas
|
|
399
432
|
}) {
|
|
400
433
|
return function(userConfig = {}) {
|
|
434
|
+
const name = userConfig.name;
|
|
435
|
+
if (typeof name != "string" || name.length === 0)
|
|
436
|
+
throw new Error(`${getPresetKey(preset.name)}: "name" is required. Pass {name: "yourTypeName"}.`);
|
|
401
437
|
recordPresetUsage(registryId, preset.identifier ?? "unnamed");
|
|
402
438
|
const registryContext = createRegistryContext({
|
|
403
439
|
registry
|
|
404
440
|
}), registryDefaults = config[preset.name], mergedConfig = {
|
|
405
|
-
name: preset.name,
|
|
406
441
|
...typeof registryDefaults == "object" && registryDefaults !== null ? registryDefaults : {},
|
|
407
442
|
...userConfig
|
|
408
443
|
}, {
|
|
@@ -413,7 +448,7 @@ function createDefiner({
|
|
|
413
448
|
factoryConfig,
|
|
414
449
|
registryContext
|
|
415
450
|
);
|
|
416
|
-
return applyMapHooks(addTelemetryComponent(schemaType, registryId), map);
|
|
451
|
+
return registeredSchemas.set(name, schemaType), applyMapHooks(addTelemetryComponent(schemaType, registryId), map);
|
|
417
452
|
};
|
|
418
453
|
}
|
|
419
454
|
function applyMapHooks(schemaType, map) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/__telemetry__/presets.telemetry.ts","../src/telemetry.ts","../src/components/PresetsTelemetryCollector.tsx","../src/presets/cta-type/index.ts","../src/presets/image-type/index.ts","../src/presets/link-type/index.ts","../src/presets/page-type/index.ts","../src/presets/rich-text-type/index.ts","../src/presets/seo-type/index.ts","../src/registry.tsx"],"sourcesContent":["import {defineEvent} from '@sanity/telemetry'\n\ninterface PresetsAddedInfo {\n presetNames: string[]\n}\n\nexport const PresetsAdded = defineEvent<PresetsAddedInfo>({\n name: 'Presets Added',\n version: 1,\n description: 'Workspace using presets was accessed',\n})\n","import {PresetsAdded} from './__telemetry__/presets.telemetry'\n\n/**\n * Minimal interface for the subset of TelemetryLogger we need.\n * Avoids forcing callers to satisfy the full generic TelemetryLogger type.\n */\nexport interface TelemetryLog {\n log(event: unknown, data: unknown): void\n}\n\ninterface RegistryRecord {\n id: string\n presets: Set<string>\n logged: boolean\n}\n\nconst registries = new Map<string, RegistryRecord>()\n\nexport function registerRegistry(id: string): void {\n registries.set(id, {id, presets: new Set(), logged: false})\n}\n\nexport function recordPresetUsage(registryId: string, identifier: string): void {\n registries.get(registryId)?.presets.add(identifier)\n}\n\nexport function collectPresetsRegistryTelemetry(registryId: string, telemetry: TelemetryLog): void {\n const record = registries.get(registryId)\n if (!record || record.logged) return\n record.logged = true\n if (record.presets.size > 0) {\n telemetry.log(PresetsAdded, {presetNames: [...record.presets]})\n }\n}\n\n/** @internal */\nexport function resetRegistries(): void {\n registries.clear()\n}\n","import {useTelemetry} from '@sanity/telemetry/react'\nimport {useEffect, type ComponentType} from 'react'\nimport type {InputProps} from 'sanity'\n\nimport {collectPresetsRegistryTelemetry} from '../telemetry'\n\ntype Props = InputProps & {\n registryId: string\n userInput?: ComponentType<InputProps>\n}\n\n/**\n * A transparent input component wrapper that triggers telemetry collection\n * for the presets registry. Renders the user-provided input component if\n * supplied, otherwise the default input component unchanged.\n *\n * Attached to every schema type produced by a define<Type> function via\n * components.input. The first instance to render for a given registry id\n * submits the PresetsAdded telemetry event; subsequent renders are no-ops.\n */\nexport const PresetsTelemetryCollector: ComponentType<Props> = ({\n registryId,\n userInput: UserInput,\n ...props\n}) => {\n const telemetry = useTelemetry()\n\n useEffect(() => {\n collectPresetsRegistryTelemetry(registryId, telemetry)\n }, [registryId, telemetry])\n\n if (UserInput) {\n return <UserInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport const ctaType = definePresetType<{}, 'object', 'preview'>({\n name: 'cta',\n identifier: 'core.cta',\n schemaType: (config, registry) => {\n const {fields, ...objectConfig} = config\n\n return defineType({\n title: 'Call to action',\n ...objectConfig,\n type: 'object',\n fields: [\n registry.getPreset('link', {name: 'link', title: 'Link'}),\n defineField({\n name: 'level',\n title: 'Level',\n type: 'number',\n options: {\n layout: 'radio',\n list: [1, 2, 3],\n },\n }),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n linkType: 'link.linkType',\n url: 'link.url',\n referenceTitle: 'link.reference.title',\n referenceName: 'link.reference.name',\n },\n prepare({linkType, url, referenceTitle, referenceName}) {\n const referenceLabel = referenceTitle || referenceName || 'No reference'\n const title = linkType === 'external' ? url || 'No URL' : referenceLabel\n return {title, subtitle: 'Button'}\n },\n },\n })\n },\n})\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface ImageTypeConfig {\n altText?: boolean\n caption?: boolean\n hotspot?: boolean\n}\n\nexport const imageType = definePresetType<ImageTypeConfig, 'object', 'preview'>({\n name: 'image',\n identifier: 'core.image',\n schemaType: (config) => {\n const {altText = true, caption = true, hotspot = true, fields, ...objectConfig} = config\n\n return defineType({\n title: 'Image',\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'image',\n title: 'Image',\n type: 'image',\n options: {\n hotspot,\n },\n }),\n ...(altText\n ? [\n defineField({\n name: 'altText',\n title: 'Alt text',\n type: 'string',\n validation: (rule) => rule.warning('Alt text improves accessibility.'),\n }),\n ]\n : []),\n ...(caption\n ? [\n defineField({\n name: 'caption',\n title: 'Caption',\n type: 'text',\n }),\n ]\n : []),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n title: altText ? 'altText' : caption ? 'caption' : 'image.asset.originalFilename',\n media: 'image',\n },\n },\n })\n },\n})\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface LinkTypeConfig {\n internalTypes?: string[]\n}\n\nexport const linkType = definePresetType<LinkTypeConfig, 'object', 'preview'>({\n name: 'link',\n identifier: 'core.link',\n schemaType: ({internalTypes, fields, ...objectConfig}) => {\n const resolvedInternalTypes = internalTypes ?? []\n const referenceTargets = resolvedInternalTypes.map((type) => ({type}))\n\n return defineType({\n title: 'Link',\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'linkType',\n type: 'string',\n title: 'Link Type',\n initialValue: 'internal',\n options: {\n layout: 'radio',\n list: [\n {title: 'Internal', value: 'internal'},\n {title: 'External', value: 'external'},\n ],\n },\n }),\n defineField({\n name: 'reference',\n type: 'reference',\n title: 'Internal Link',\n to: referenceTargets,\n hidden: ({parent}) => parent?.linkType === 'external',\n }),\n defineField({\n name: 'url',\n type: 'url',\n title: 'URL',\n hidden: ({parent}) => parent?.linkType === 'internal',\n validation: (rule) =>\n rule.uri({\n scheme: ['http', 'https', 'mailto', 'tel'],\n }),\n }),\n defineField({\n name: 'openInNewTab',\n type: 'boolean',\n title: 'Open in New Tab',\n initialValue: false,\n hidden: ({parent}) => parent?.linkType === 'internal',\n }),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n linkType: 'linkType',\n url: 'url',\n referenceTitle: 'reference.title',\n referenceName: 'reference.name',\n },\n prepare({linkType, url, referenceTitle, referenceName}) {\n const referenceLabel = referenceTitle || referenceName || 'No reference'\n const title = linkType === 'external' ? url || 'No URL' : referenceLabel\n\n return {\n title,\n subtitle: linkType === 'external' ? 'External link' : 'Internal link',\n }\n },\n },\n })\n },\n})\n","import {ALL_FIELDS_GROUP, defineArrayMember, defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface PageTypeConfig {\n pageBuilderBlocks?: string[]\n}\n\nexport const pageType = definePresetType<PageTypeConfig, 'document'>({\n name: 'page',\n identifier: 'core.page',\n schemaType: (config, registry) => {\n const {pageBuilderBlocks, groups, fields, ...documentConfig} = config\n\n return defineType({\n title: 'Page',\n ...documentConfig,\n type: 'document',\n groups: [\n {\n ...ALL_FIELDS_GROUP,\n hidden: true,\n },\n {\n name: 'main',\n title: 'Main',\n default: true,\n },\n {\n name: 'metadata',\n title: 'Metadata',\n },\n ...(groups ?? []),\n ],\n fields: [\n defineField({\n name: 'name',\n title: 'Name',\n type: 'string',\n group: 'main',\n validation: (rule) => rule.required(),\n }),\n defineField({\n name: 'slug',\n title: 'Slug',\n type: 'slug',\n group: 'main',\n options: {\n source: 'name',\n },\n }),\n defineField({\n name: 'content',\n title: 'Content',\n group: 'main',\n type: 'array',\n of: (pageBuilderBlocks ?? []).map((typeName) =>\n defineArrayMember({\n type: typeName,\n }),\n ),\n }),\n registry.getPreset('seo', {\n name: 'seo',\n title: 'SEO',\n group: 'metadata',\n }),\n ...(fields ?? []),\n ],\n })\n },\n})\n","import {defineArrayMember, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface RichTextObjectsConfig {\n link?: boolean\n image?: boolean\n cta?: boolean\n}\n\nexport interface RichTextTypeConfig {\n /**\n * Toggle the embedded objects (link annotations, image blocks, inline CTAs).\n * Defaults to all enabled. Pass `false` to disable every object, or an\n * object to toggle individual ones (e.g. `{link: false}`).\n *\n * Each object's options (link `internalTypes`, image `altText`, …) are\n * configured on `createPresetsRegistry` and cascade into every rich text\n * field. Use `map.of` for per-field structural changes.\n */\n objects?: boolean | RichTextObjectsConfig\n}\n\nfunction resolveObjects(objects: RichTextTypeConfig['objects']): Required<RichTextObjectsConfig> {\n if (objects === false) return {link: false, image: false, cta: false}\n if (objects === true || objects === undefined) return {link: true, image: true, cta: true}\n const {link = true, image = true, cta = true} = objects\n return {link, image, cta}\n}\n\nexport const richTextType = definePresetType<RichTextTypeConfig, 'array', 'of'>({\n name: 'richText',\n identifier: 'core.richText',\n schemaType: (config, registry) => {\n const {objects, ...arrayConfig} = config\n const {link, image, cta} = resolveObjects(objects)\n\n // The annotation name must be 'link' — Portable Text Editor's built-in link UI keys off this name.\n const linkAnnotation = link\n ? registry.getPreset('link', {name: 'link', title: 'Link'})\n : undefined\n const ctaInline = cta ? registry.getPreset('cta', {name: 'cta', title: 'CTA'}) : undefined\n const imageMember = image\n ? registry.getPreset('image', {name: 'richTextImage', title: 'Image'})\n : undefined\n\n const blockMember = defineArrayMember({\n type: 'block',\n marks: {annotations: linkAnnotation ? [linkAnnotation] : []},\n ...(ctaInline && {of: [ctaInline]}),\n })\n\n return defineType({\n title: 'Rich text',\n ...arrayConfig,\n type: 'array',\n of: imageMember ? [blockMember, imageMember] : [blockMember],\n })\n },\n})\n","import {getImageDimensions} from '@sanity/asset-utils'\nimport {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport const seoType = definePresetType<{}, 'object'>({\n name: 'seo',\n identifier: 'core.seo',\n schemaType: (config) => {\n const {fields, ...objectConfig} = config\n\n return defineType({\n title: 'Web page metadata (SEO)',\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'title',\n title: 'Title',\n type: 'string',\n validation: (rule) => rule.max(70).info('Search engines may truncate this title.'),\n }),\n defineField({\n name: 'description',\n title: 'Description',\n type: 'text',\n validation: (rule) => rule.max(150).info('Search engines may truncate this description.'),\n }),\n defineField({\n name: 'ogImage',\n title: 'Open Graph image',\n type: 'image',\n description: 'Landscape 1200x630 (1.91:1)',\n options: {\n hotspot: {\n previews: [\n {\n title: 'Landscape (1.91:1)',\n aspectRatio: 1.91 / 1,\n },\n ],\n },\n },\n validation: (Rule) =>\n Rule.custom((value) => {\n if (!value?.asset?._ref) {\n return true\n }\n\n const {height, width} = getImageDimensions(value.asset?._ref)\n\n if (height !== 630 || width !== 1200) {\n return 'Open Graph image must be 1200x630'\n }\n\n return true\n }),\n }),\n ...(fields ?? []),\n ],\n })\n },\n})\n","import {uuid} from '@sanity/uuid'\nimport {type ComponentType} from 'react'\nimport type {FieldDefinition, InputProps, SchemaTypeDefinition} from 'sanity'\n\nimport {PresetsTelemetryCollector} from './components/PresetsTelemetryCollector'\nimport type {\n AnyPresetDefinition,\n PresetDefinition,\n RegistryContext,\n UserConfig,\n} from './definePresetType'\nimport {ctaType} from './presets/cta-type'\nimport {imageType, type ImageTypeConfig} from './presets/image-type'\nimport {linkType, type LinkTypeConfig} from './presets/link-type'\nimport {pageType, type PageTypeConfig} from './presets/page-type'\nimport {richTextType} from './presets/rich-text-type'\nimport {seoType} from './presets/seo-type'\nimport {recordPresetUsage, registerRegistry} from './telemetry'\n\nconst systemPresets = [linkType, ctaType, seoType, imageType, pageType, richTextType] as const\n\nexport interface PresetsRegistryConfig {\n link?: LinkTypeConfig\n image?: ImageTypeConfig\n page?: PageTypeConfig\n}\n\ntype DefineFunction<Preset extends AnyPresetDefinition> =\n Preset extends PresetDefinition<infer Context, infer AliasedType, infer LockedProperties>\n ? (\n config?: UserConfig<Context, AliasedType, LockedProperties>,\n ) => SchemaTypeDefinition & FieldDefinition\n : never\n\nexport interface PresetsRegistry {\n defineLink: DefineFunction<typeof linkType>\n defineCta: DefineFunction<typeof ctaType>\n defineSeo: DefineFunction<typeof seoType>\n defineImage: DefineFunction<typeof imageType>\n definePage: DefineFunction<typeof pageType>\n defineRichText: DefineFunction<typeof richTextType>\n}\n\nexport function createPresetsRegistry(config: PresetsRegistryConfig = {}): PresetsRegistry {\n const registryId = uuid()\n registerRegistry(registryId)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- seeding reduce with an empty object that is populated by each iteration\n const seed = {} as DefinerRecord & PresetsRegistry\n\n return systemPresets.reduce((registry, preset) => {\n const key = getPresetKey(preset.name)\n registry[key] = createDefiner({registryId, preset, config, registry})\n return registry\n }, seed)\n}\n\nexport function getPresetKey(name: string): string {\n return `define${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\ntype Definer = (config?: Record<string, unknown>) => SchemaTypeDefinition & FieldDefinition\ntype DefinerRecord = Record<string, Definer>\n\nfunction createRegistryContext({registry}: {registry: DefinerRecord}): RegistryContext {\n return {\n getPreset: (name, presetConfig) => {\n const key = getPresetKey(name)\n const definer = registry[key]\n if (!definer) {\n throw new Error(`Cannot resolve preset \"${name}\". No such preset in this registry.`)\n }\n return definer(presetConfig)\n },\n }\n}\n\ninterface CreateDefinerOptions {\n registryId: string\n preset: AnyPresetDefinition\n config: PresetsRegistryConfig\n registry: DefinerRecord\n}\n\nfunction createDefiner({registryId, preset, config, registry}: CreateDefinerOptions): Definer {\n return function define(userConfig = {}) {\n recordPresetUsage(registryId, preset.identifier ?? 'unnamed')\n\n const registryContext = createRegistryContext({registry})\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- PresetsRegistryConfig is keyed by preset name; dynamic lookup is safe\n const registryDefaults = (config as Record<string, unknown>)[preset.name]\n const mergedConfig: Record<string, unknown> = {\n name: preset.name,\n ...(typeof registryDefaults === 'object' && registryDefaults !== null\n ? registryDefaults\n : {}),\n ...userConfig,\n }\n\n const {map, ...factoryConfig} = mergedConfig\n\n const schemaType = preset.schemaType(\n // oxlint-disable-next-line no-unsafe-type-assertion -- factoryConfig is the merged user config (minus `map`, with `name` injected); its shape matches the factory's expected parameter at runtime\n factoryConfig as unknown as Parameters<AnyPresetDefinition['schemaType']>[0],\n registryContext,\n )\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- runtime value is a valid field definition\n return applyMapHooks(\n addTelemetryComponent(schemaType, registryId),\n map,\n ) as SchemaTypeDefinition & FieldDefinition\n }\n}\n\nfunction applyMapHooks(schemaType: SchemaTypeDefinition, map: unknown): SchemaTypeDefinition {\n if (!map || typeof map !== 'object') return schemaType\n\n const mappedSchemaType: Record<string, unknown> = {}\n\n for (const [configName, configValue] of Object.entries(map)) {\n if (typeof configValue !== 'function') {\n continue\n }\n\n mappedSchemaType[configName] = configValue(\n // oxlint-disable-next-line no-unsafe-type-assertion -- map hooks operate on arbitrary schema type properties\n schemaType[configName as keyof typeof schemaType],\n )\n }\n\n return {...schemaType, ...mappedSchemaType}\n}\n\nfunction addTelemetryComponent(\n schemaType: SchemaTypeDefinition,\n registryId: string,\n): SchemaTypeDefinition {\n const existing = 'components' in schemaType ? schemaType.components : undefined\n const existingInput =\n existing && 'input' in existing && typeof existing.input === 'function'\n ? // oxlint-disable-next-line no-unsafe-type-assertion -- presets only produce object/document schema types, whose input components are assignable to ComponentType<InputProps>\n (existing.input as ComponentType<InputProps>)\n : undefined\n // oxlint-disable-next-line no-unsafe-type-assertion -- spreading a discriminated union loses the discriminant; the runtime shape is still a valid SchemaTypeDefinition\n return {\n ...schemaType,\n components: {\n ...existing,\n input: (props: InputProps) => (\n <PresetsTelemetryCollector {...props} registryId={registryId} userInput={existingInput} />\n ),\n },\n } as SchemaTypeDefinition\n}\n\n// Re-export for consumers that previously used these types.\nexport type {PresetDefinition, AnyPresetDefinition}\n"],"names":["PresetsAdded","defineEvent","name","version","description","registries","Map","registerRegistry","id","set","presets","Set","logged","recordPresetUsage","registryId","identifier","get","add","collectPresetsRegistryTelemetry","telemetry","record","size","log","presetNames","PresetsTelemetryCollector","t0","$","_c","userInput","UserInput","props","useTelemetry","t1","t2","useEffect","renderDefault","ctaType","schemaType","config","registry","fields","objectConfig","defineType","title","type","getPreset","defineField","options","layout","list","preview","select","linkType","url","referenceTitle","referenceName","prepare","subtitle","imageType","altText","caption","hotspot","validation","rule","warning","media","internalTypes","referenceTargets","map","initialValue","value","to","hidden","parent","uri","scheme","pageType","pageBuilderBlocks","groups","documentConfig","ALL_FIELDS_GROUP","default","group","required","source","of","typeName","defineArrayMember","resolveObjects","objects","link","image","cta","undefined","richTextType","arrayConfig","linkAnnotation","ctaInline","imageMember","blockMember","marks","annotations","seoType","max","info","previews","aspectRatio","Rule","custom","asset","_ref","height","width","getImageDimensions","systemPresets","createPresetsRegistry","uuid","seed","reduce","preset","key","getPresetKey","createDefiner","charAt","toUpperCase","slice","createRegistryContext","presetConfig","definer","Error","userConfig","registryContext","registryDefaults","mergedConfig","factoryConfig","applyMapHooks","addTelemetryComponent","mappedSchemaType","configName","configValue","Object","entries","existing","components","existingInput","input"],"mappings":";;;;;;;;AAMO,MAAMA,eAAeC,YAA8B;AAAA,EACxDC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC,GCMKC,iCAAiBC,IAAAA;AAEhB,SAASC,iBAAiBC,IAAkB;AACjDH,aAAWI,IAAID,IAAI;AAAA,IAACA;AAAAA,IAAIE,6BAAaC,IAAAA;AAAAA,IAAOC,QAAQ;AAAA,EAAA,CAAM;AAC5D;AAEO,SAASC,kBAAkBC,YAAoBC,YAA0B;AAC9EV,aAAWW,IAAIF,UAAU,GAAGJ,QAAQO,IAAIF,UAAU;AACpD;AAEO,SAASG,gCAAgCJ,YAAoBK,WAA+B;AACjG,QAAMC,SAASf,WAAWW,IAAIF,UAAU;AACpC,GAACM,UAAUA,OAAOR,WACtBQ,OAAOR,SAAS,IACZQ,OAAOV,QAAQW,OAAO,KACxBF,UAAUG,IAAItB,cAAc;AAAA,IAACuB,aAAa,CAAC,GAAGH,OAAOV,OAAO;AAAA,EAAA,CAAE;AAElE;ACbO,MAAMc,4BAAkDC,CAAAA,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAC;AAAA,IAAAb;AAAAA,IAAAc,WAAAC;AAAAA,IAAA,GAAAC;AAAAA,EAAAA,IAAAL,IAK9DN,YAAkBY,aAAAA;AAAc,MAAAC,IAAAC;AAMhC,SANgCP,EAAA,CAAA,MAAAZ,cAAAY,SAAAP,aAEtBa,KAAAA,MAAA;AACRd,oCAAgCJ,YAAYK,SAAS;AAAA,EAAC,GACrDc,KAAA,CAACnB,YAAYK,SAAS,GAACO,OAAAZ,YAAAY,OAAAP,WAAAO,OAAAM,IAAAN,OAAAO,OAAAD,KAAAN,EAAA,CAAA,GAAAO,KAAAP,EAAA,CAAA,IAF1BQ,UAAUF,IAEPC,EAAuB,GAEtBJ,gCACM,WAAA,EAAS,GAAKC,OAAK,IA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C5CnI,MAAMqH,OAAOrH;AAAAA,MACb,GAAI,OAAOkI,oBAAqB,YAAYA,qBAAqB,OAC7DA,mBACA,CAAA;AAAA,MACJ,GAAGF;AAAAA,IAAAA,GAGC;AAAA,MAAC9D;AAAAA,MAAK,GAAGkE;AAAAA,IAAAA,IAAiBD,cAE1BhG,aAAakF,OAAOlF;AAAAA;AAAAA,MAExBiG;AAAAA,MACAH;AAAAA,IAAAA;AAIF,WAAOI,cACLC,sBAAsBnG,YAAYvB,UAAU,GAC5CsD,GACF;AAAA,EACF;AACF;AAEA,SAASmE,cAAclG,YAAkC+B,KAAoC;AAC3F,MAAI,CAACA,OAAO,OAAOA,OAAQ,SAAU,QAAO/B;AAE5C,QAAMoG,mBAA4C,CAAA;AAElD,aAAW,CAACC,YAAYC,WAAW,KAAKC,OAAOC,QAAQzE,GAAG;AACpD,WAAOuE,eAAgB,eAI3BF,iBAAiBC,UAAU,IAAIC;AAAAA;AAAAA,MAE7BtG,WAAWqG,UAAU;AAAA,IAAA;AAIzB,SAAO;AAAA,IAAC,GAAGrG;AAAAA,IAAY,GAAGoG;AAAAA,EAAAA;AAC5B;AAEA,SAASD,sBACPnG,YACAvB,YACsB;AACtB,QAAMgI,WAAW,gBAAgBzG,aAAaA,WAAW0G,aAAalD,QAChEmD,gBACJF,YAAY,WAAWA,YAAY,OAAOA,SAASG,SAAU;AAAA;AAAA,IAExDH,SAASG;AAAAA,MACVpD;AAEN,SAAO;AAAA,IACL,GAAGxD;AAAAA,IACH0G,YAAY;AAAA,MACV,GAAGD;AAAAA,MACHG,OAAQnH,WACN,oBAAC,2BAAA,EAA0B,GAAIA,OAAO,YAAwB,WAAWkH,cAAAA,CAAc;AAAA,IAAA;AAAA,EAE3F;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/__telemetry__/presets.telemetry.ts","../src/telemetry.ts","../src/components/PresetsTelemetryCollector.tsx","../src/presets/cta-type/index.ts","../src/presets/image-type/index.ts","../src/presets/link-type/index.ts","../src/presets/page-type/index.ts","../src/presets/rich-text-type/index.ts","../src/presets/seo-type/index.ts","../src/registry.tsx"],"sourcesContent":["import {defineEvent} from '@sanity/telemetry'\n\ninterface PresetsAddedInfo {\n presetNames: string[]\n}\n\nexport const PresetsAdded = defineEvent<PresetsAddedInfo>({\n name: 'Presets Added',\n version: 1,\n description: 'Workspace using presets was accessed',\n})\n","import {PresetsAdded} from './__telemetry__/presets.telemetry'\n\n/**\n * Minimal interface for the subset of TelemetryLogger we need.\n * Avoids forcing callers to satisfy the full generic TelemetryLogger type.\n */\nexport interface TelemetryLog {\n log(event: unknown, data: unknown): void\n}\n\ninterface RegistryRecord {\n id: string\n presets: Set<string>\n logged: boolean\n}\n\nconst registries = new Map<string, RegistryRecord>()\n\nexport function registerRegistry(id: string): void {\n registries.set(id, {id, presets: new Set(), logged: false})\n}\n\nexport function recordPresetUsage(registryId: string, identifier: string): void {\n registries.get(registryId)?.presets.add(identifier)\n}\n\nexport function collectPresetsRegistryTelemetry(registryId: string, telemetry: TelemetryLog): void {\n const record = registries.get(registryId)\n if (!record || record.logged) return\n record.logged = true\n if (record.presets.size > 0) {\n telemetry.log(PresetsAdded, {presetNames: [...record.presets]})\n }\n}\n\n/** @internal */\nexport function resetRegistries(): void {\n registries.clear()\n}\n","import {useTelemetry} from '@sanity/telemetry/react'\nimport {useEffect, type ComponentType} from 'react'\nimport type {InputProps} from 'sanity'\n\nimport {collectPresetsRegistryTelemetry} from '../telemetry'\n\ntype Props = InputProps & {\n registryId: string\n userInput?: ComponentType<InputProps>\n}\n\n/**\n * A transparent input component wrapper that triggers telemetry collection\n * for the presets registry. Renders the user-provided input component if\n * supplied, otherwise the default input component unchanged.\n *\n * Attached to every schema type produced by a define<Type> function via\n * components.input. The first instance to render for a given registry id\n * submits the PresetsAdded telemetry event; subsequent renders are no-ops.\n */\nexport const PresetsTelemetryCollector: ComponentType<Props> = ({\n registryId,\n userInput: UserInput,\n ...props\n}) => {\n const telemetry = useTelemetry()\n\n useEffect(() => {\n collectPresetsRegistryTelemetry(registryId, telemetry)\n }, [registryId, telemetry])\n\n if (UserInput) {\n return <UserInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport const ctaType = definePresetType<{}, 'object', 'preview'>({\n name: 'cta',\n identifier: 'core.cta',\n schemaType: (config, registry) => {\n const {fields, ...objectConfig} = config\n\n return defineType({\n ...objectConfig,\n type: 'object',\n fields: [\n registry.getPreset('link', {name: 'link', title: 'Link'}),\n defineField({\n name: 'level',\n title: 'Level',\n type: 'number',\n options: {\n layout: 'radio',\n list: [1, 2, 3],\n },\n }),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n linkType: 'link.linkType',\n url: 'link.url',\n referenceTitle: 'link.reference.title',\n referenceName: 'link.reference.name',\n },\n prepare({linkType, url, referenceTitle, referenceName}) {\n const referenceLabel = referenceTitle || referenceName || 'No reference'\n const title = linkType === 'external' ? url || 'No URL' : referenceLabel\n return {title, subtitle: 'Button'}\n },\n },\n })\n },\n})\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface ImageTypeConfig {\n altText?: boolean\n caption?: boolean\n hotspot?: boolean\n}\n\nexport const imageType = definePresetType<ImageTypeConfig, 'object', 'preview'>({\n name: 'image',\n identifier: 'core.image',\n schemaType: (config) => {\n const {altText = true, caption = true, hotspot = true, fields, ...objectConfig} = config\n\n return defineType({\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'image',\n title: 'Image',\n type: 'image',\n options: {\n hotspot,\n },\n }),\n ...(altText\n ? [\n defineField({\n name: 'altText',\n title: 'Alt text',\n type: 'string',\n validation: (rule) => rule.warning('Alt text improves accessibility.'),\n }),\n ]\n : []),\n ...(caption\n ? [\n defineField({\n name: 'caption',\n title: 'Caption',\n type: 'text',\n }),\n ]\n : []),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n title: altText ? 'altText' : caption ? 'caption' : 'image.asset.originalFilename',\n media: 'image',\n },\n },\n })\n },\n})\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface LinkTypeConfig {\n internalTypes?: string[]\n}\n\nexport const linkType = definePresetType<LinkTypeConfig, 'object', 'preview'>({\n name: 'link',\n identifier: 'core.link',\n schemaType: ({internalTypes, fields, ...objectConfig}) => {\n const resolvedInternalTypes = internalTypes ?? []\n const referenceTargets = resolvedInternalTypes.map((type) => ({type}))\n\n return defineType({\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'linkType',\n type: 'string',\n title: 'Link Type',\n initialValue: 'internal',\n options: {\n layout: 'radio',\n list: [\n {title: 'Internal', value: 'internal'},\n {title: 'External', value: 'external'},\n ],\n },\n }),\n defineField({\n name: 'reference',\n type: 'reference',\n title: 'Internal Link',\n to: referenceTargets,\n hidden: ({parent}) => parent?.linkType === 'external',\n }),\n defineField({\n name: 'url',\n type: 'url',\n title: 'URL',\n hidden: ({parent}) => parent?.linkType === 'internal',\n validation: (rule) =>\n rule.uri({\n scheme: ['http', 'https', 'mailto', 'tel'],\n }),\n }),\n defineField({\n name: 'openInNewTab',\n type: 'boolean',\n title: 'Open in New Tab',\n initialValue: false,\n hidden: ({parent}) => parent?.linkType === 'internal',\n }),\n ...(fields ?? []),\n ],\n preview: {\n select: {\n linkType: 'linkType',\n url: 'url',\n referenceTitle: 'reference.title',\n referenceName: 'reference.name',\n },\n prepare({linkType, url, referenceTitle, referenceName}) {\n const referenceLabel = referenceTitle || referenceName || 'No reference'\n const title = linkType === 'external' ? url || 'No URL' : referenceLabel\n\n return {\n title,\n subtitle: linkType === 'external' ? 'External link' : 'Internal link',\n }\n },\n },\n })\n },\n})\n","import {\n ALL_FIELDS_GROUP,\n type ArrayDefinition,\n defineArrayMember,\n defineField,\n defineType,\n type FieldDefinition,\n type SchemaTypeDefinition,\n} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport type PageBuilderBlock = string | (SchemaTypeDefinition & FieldDefinition)\n\ntype LookupArrayPreset = (name: string) => ArrayDefinition | undefined\n\n// Sanity rejects array members whose `type` resolves to another array. Wrap\n// array presets in an object so they can serve as page-builder members.\nfunction wrapArrayAsPageBuilderBlock(arraySchema: ArrayDefinition) {\n const components = 'components' in arraySchema ? arraySchema.components : undefined\n return defineArrayMember({\n name: arraySchema.name,\n title: arraySchema.title,\n type: 'object',\n fields: [\n defineField({\n name: 'content',\n type: 'array',\n of: arraySchema.of,\n components,\n }),\n ],\n })\n}\n\nfunction toPageBuilderArrayMember(block: PageBuilderBlock, lookupArrayPreset: LookupArrayPreset) {\n if (typeof block === 'string') {\n const arrayPreset = lookupArrayPreset(block)\n if (arrayPreset) {\n return wrapArrayAsPageBuilderBlock(arrayPreset)\n }\n return defineArrayMember({type: block})\n }\n if (block.type === 'array') {\n // oxlint-disable-next-line no-unsafe-type-assertion -- discriminating on `type` does not narrow the intersected union\n return wrapArrayAsPageBuilderBlock(block as ArrayDefinition)\n }\n return defineArrayMember(block)\n}\n\n// Defer building `content.of` so by-name references resolve after every\n// `define<X>` has run. Memoised for stable array identity across reads.\nfunction defineLazyContentField(\n blocks: PageBuilderBlock[],\n lookupArrayPreset: LookupArrayPreset,\n): FieldDefinition {\n let cached: ReturnType<typeof toPageBuilderArrayMember>[] | undefined\n return defineField({\n name: 'content',\n title: 'Content',\n group: 'main',\n type: 'array',\n get of() {\n cached ??= blocks.map((block) => toPageBuilderArrayMember(block, lookupArrayPreset))\n return cached\n },\n })\n}\n\nexport interface PageTypeConfig {\n pageBuilderBlocks?: PageBuilderBlock[]\n}\n\n// `lookupArrayPreset` is closure-injected by the registry to keep it off\n// the public `RegistryContext`. The default `pageType` below uses a no-op.\nexport function createPageType({lookupArrayPreset}: {lookupArrayPreset: LookupArrayPreset}) {\n return definePresetType<PageTypeConfig, 'document'>({\n name: 'page',\n identifier: 'core.page',\n schemaType: (config, registry) => {\n const {pageBuilderBlocks, groups, fields, ...documentConfig} = config\n\n return defineType({\n ...documentConfig,\n type: 'document',\n groups: [\n {\n ...ALL_FIELDS_GROUP,\n hidden: true,\n },\n {\n name: 'main',\n title: 'Main',\n default: true,\n },\n {\n name: 'metadata',\n title: 'Metadata',\n },\n ...(groups ?? []),\n ],\n fields: [\n defineField({\n name: 'name',\n title: 'Name',\n type: 'string',\n group: 'main',\n validation: (rule) => rule.required(),\n }),\n defineField({\n name: 'slug',\n title: 'Slug',\n type: 'slug',\n group: 'main',\n options: {\n source: 'name',\n },\n }),\n defineLazyContentField(pageBuilderBlocks ?? [], lookupArrayPreset),\n registry.getPreset('seo', {\n name: 'seo',\n title: 'SEO',\n group: 'metadata',\n }),\n ...(fields ?? []),\n ],\n })\n },\n })\n}\n\nexport const pageType = createPageType({lookupArrayPreset: () => undefined})\n","import {defineArrayMember, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport interface RichTextObjectsConfig {\n link?: boolean\n image?: boolean\n cta?: boolean\n}\n\nexport interface RichTextTypeConfig {\n /**\n * Toggle the embedded objects (link annotations, image blocks, inline CTAs).\n * Defaults to all enabled. Pass `false` to disable every object, or an\n * object to toggle individual ones (e.g. `{link: false}`).\n *\n * Each object's options (link `internalTypes`, image `altText`, …) are\n * configured on `createPresetsRegistry` and cascade into every rich text\n * field. Use `map.of` for per-field structural changes.\n */\n objects?: boolean | RichTextObjectsConfig\n}\n\nfunction resolveObjects(objects: RichTextTypeConfig['objects']): Required<RichTextObjectsConfig> {\n if (objects === false) return {link: false, image: false, cta: false}\n if (objects === true || objects === undefined) return {link: true, image: true, cta: true}\n const {link = true, image = true, cta = true} = objects\n return {link, image, cta}\n}\n\nexport const richTextType = definePresetType<RichTextTypeConfig, 'array', 'of'>({\n name: 'richText',\n identifier: 'core.richText',\n schemaType: (config, registry) => {\n const {objects, ...arrayConfig} = config\n const {link, image, cta} = resolveObjects(objects)\n\n // The annotation name must be 'link' — Portable Text Editor's built-in link UI keys off this name.\n const linkAnnotation = link\n ? registry.getPreset('link', {name: 'link', title: 'Link'})\n : undefined\n const ctaInline = cta ? registry.getPreset('cta', {name: 'cta', title: 'CTA'}) : undefined\n const imageMember = image\n ? registry.getPreset('image', {name: 'richTextImage', title: 'Image'})\n : undefined\n\n const blockMember = defineArrayMember({\n type: 'block',\n marks: {annotations: linkAnnotation ? [linkAnnotation] : []},\n ...(ctaInline && {of: [ctaInline]}),\n })\n\n return defineType({\n ...arrayConfig,\n type: 'array',\n of: imageMember ? [blockMember, imageMember] : [blockMember],\n })\n },\n})\n","import {getImageDimensions} from '@sanity/asset-utils'\nimport {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport const seoType = definePresetType<{}, 'object'>({\n name: 'seo',\n identifier: 'core.seo',\n schemaType: (config) => {\n const {fields, ...objectConfig} = config\n\n return defineType({\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'title',\n title: 'Title',\n type: 'string',\n validation: (rule) => rule.max(70).info('Search engines may truncate this title.'),\n }),\n defineField({\n name: 'description',\n title: 'Description',\n type: 'text',\n validation: (rule) => rule.max(150).info('Search engines may truncate this description.'),\n }),\n defineField({\n name: 'ogImage',\n title: 'Open Graph image',\n type: 'image',\n description: 'Landscape 1200x630 (1.91:1)',\n options: {\n hotspot: {\n previews: [\n {\n title: 'Landscape (1.91:1)',\n aspectRatio: 1.91 / 1,\n },\n ],\n },\n },\n validation: (Rule) =>\n Rule.custom((value) => {\n if (!value?.asset?._ref) {\n return true\n }\n\n const {height, width} = getImageDimensions(value.asset?._ref)\n\n if (height !== 630 || width !== 1200) {\n return 'Open Graph image must be 1200x630'\n }\n\n return true\n }),\n }),\n ...(fields ?? []),\n ],\n })\n },\n})\n","import {uuid} from '@sanity/uuid'\nimport {type ComponentType} from 'react'\nimport type {ArrayDefinition, FieldDefinition, InputProps, SchemaTypeDefinition} from 'sanity'\n\nimport {PresetsTelemetryCollector} from './components/PresetsTelemetryCollector'\nimport type {\n AnyPresetDefinition,\n PresetDefinition,\n RegistryContext,\n UserConfig,\n} from './definePresetType'\nimport {ctaType} from './presets/cta-type'\nimport {imageType, type ImageTypeConfig} from './presets/image-type'\nimport {linkType, type LinkTypeConfig} from './presets/link-type'\nimport {createPageType, pageType, type PageTypeConfig} from './presets/page-type'\nimport {richTextType} from './presets/rich-text-type'\nimport {seoType} from './presets/seo-type'\nimport {recordPresetUsage, registerRegistry} from './telemetry'\n\nexport interface PresetsRegistryConfig {\n link?: LinkTypeConfig\n image?: ImageTypeConfig\n page?: PageTypeConfig\n}\n\ntype DefineFunction<Preset extends AnyPresetDefinition> =\n Preset extends PresetDefinition<infer Context, infer AliasedType, infer LockedProperties>\n ? (\n config: UserConfig<Context, AliasedType, LockedProperties>,\n ) => SchemaTypeDefinition & FieldDefinition\n : never\n\nexport interface PresetsRegistry {\n defineLink: DefineFunction<typeof linkType>\n defineCta: DefineFunction<typeof ctaType>\n defineSeo: DefineFunction<typeof seoType>\n defineImage: DefineFunction<typeof imageType>\n definePage: DefineFunction<typeof pageType>\n defineRichText: DefineFunction<typeof richTextType>\n}\n\nexport function createPresetsRegistry(config: PresetsRegistryConfig = {}): PresetsRegistry {\n const registryId = uuid()\n registerRegistry(registryId)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- seeding reduce with an empty object that is populated by each iteration\n const seed = {} as DefinerRecord & PresetsRegistry\n\n // Tracks the schema produced under each defined preset name so `pageType`\n // can resolve string references in `pageBuilderBlocks` regardless of\n // definition order, and wrap array-typed presets at the page builder\n // boundary. Closure-injected into `pageType` via `createPageType` so it\n // does not need to live on the public `RegistryContext`.\n const registeredSchemas = new Map<string, SchemaTypeDefinition>()\n const pageTypeWithLookup = createPageType({\n lookupArrayPreset: (name) => {\n const registered = registeredSchemas.get(name)\n // oxlint-disable-next-line no-unsafe-type-assertion -- discriminating on `type` does not narrow the intersected union\n return registered?.type === 'array' ? (registered as ArrayDefinition) : undefined\n },\n })\n\n const systemPresets = [\n linkType,\n ctaType,\n seoType,\n imageType,\n pageTypeWithLookup,\n richTextType,\n ] as const\n\n return systemPresets.reduce((registry, preset) => {\n const key = getPresetKey(preset.name)\n registry[key] = createDefiner({registryId, preset, config, registry, registeredSchemas})\n return registry\n }, seed)\n}\n\nexport function getPresetKey(name: string): string {\n return `define${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\ntype Definer = (config?: Record<string, unknown>) => SchemaTypeDefinition & FieldDefinition\ntype DefinerRecord = Record<string, Definer>\n\nfunction createRegistryContext({registry}: {registry: DefinerRecord}): RegistryContext {\n return {\n getPreset: (name, presetConfig) => {\n const key = getPresetKey(name)\n const definer = registry[key]\n if (!definer) {\n throw new Error(`Cannot resolve preset \"${name}\". No such preset in this registry.`)\n }\n return definer(presetConfig)\n },\n }\n}\n\ninterface CreateDefinerOptions {\n registryId: string\n preset: AnyPresetDefinition\n config: PresetsRegistryConfig\n registry: DefinerRecord\n registeredSchemas: Map<string, SchemaTypeDefinition>\n}\n\nfunction createDefiner({\n registryId,\n preset,\n config,\n registry,\n registeredSchemas,\n}: CreateDefinerOptions): Definer {\n return function define(userConfig = {}) {\n const name = userConfig['name']\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(\n `${getPresetKey(preset.name)}: \"name\" is required. Pass {name: \"yourTypeName\"}.`,\n )\n }\n\n recordPresetUsage(registryId, preset.identifier ?? 'unnamed')\n\n const registryContext = createRegistryContext({registry})\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- PresetsRegistryConfig is keyed by preset name; dynamic lookup is safe\n const registryDefaults = (config as Record<string, unknown>)[preset.name]\n const mergedConfig: Record<string, unknown> = {\n ...(typeof registryDefaults === 'object' && registryDefaults !== null\n ? registryDefaults\n : {}),\n ...userConfig,\n }\n\n const {map, ...factoryConfig} = mergedConfig\n\n const schemaType = preset.schemaType(\n // oxlint-disable-next-line no-unsafe-type-assertion -- factoryConfig is the merged user config (minus `map`, with `name` injected); its shape matches the factory's expected parameter at runtime\n factoryConfig as unknown as Parameters<AnyPresetDefinition['schemaType']>[0],\n registryContext,\n )\n\n registeredSchemas.set(name, schemaType)\n\n // oxlint-disable-next-line no-unsafe-type-assertion -- runtime value is a valid field definition\n return applyMapHooks(\n addTelemetryComponent(schemaType, registryId),\n map,\n ) as SchemaTypeDefinition & FieldDefinition\n }\n}\n\nfunction applyMapHooks(schemaType: SchemaTypeDefinition, map: unknown): SchemaTypeDefinition {\n if (!map || typeof map !== 'object') return schemaType\n\n const mappedSchemaType: Record<string, unknown> = {}\n\n for (const [configName, configValue] of Object.entries(map)) {\n if (typeof configValue !== 'function') {\n continue\n }\n\n mappedSchemaType[configName] = configValue(\n // oxlint-disable-next-line no-unsafe-type-assertion -- map hooks operate on arbitrary schema type properties\n schemaType[configName as keyof typeof schemaType],\n )\n }\n\n return {...schemaType, ...mappedSchemaType}\n}\n\nfunction addTelemetryComponent(\n schemaType: SchemaTypeDefinition,\n registryId: string,\n): SchemaTypeDefinition {\n const existing = 'components' in schemaType ? schemaType.components : undefined\n const existingInput =\n existing && 'input' in existing && typeof existing.input === 'function'\n ? // oxlint-disable-next-line no-unsafe-type-assertion -- presets only produce object/document schema types, whose input components are assignable to ComponentType<InputProps>\n (existing.input as ComponentType<InputProps>)\n : undefined\n // oxlint-disable-next-line no-unsafe-type-assertion -- spreading a discriminated union loses the discriminant; the runtime shape is still a valid SchemaTypeDefinition\n return {\n ...schemaType,\n components: {\n ...existing,\n input: (props: InputProps) => (\n <PresetsTelemetryCollector {...props} registryId={registryId} userInput={existingInput} />\n ),\n },\n } as SchemaTypeDefinition\n}\n\n// Re-export for consumers that previously used these types.\nexport type {PresetDefinition, AnyPresetDefinition}\n"],"names":["PresetsAdded","defineEvent","name","version","description","registries","Map","registerRegistry","id","set","presets","Set","logged","recordPresetUsage","registryId","identifier","get","add","collectPresetsRegistryTelemetry","telemetry","record","size","log","presetNames","PresetsTelemetryCollector","t0","$","_c","userInput","UserInput","props","useTelemetry","t1","t2","useEffect","renderDefault","ctaType","schemaType","config","registry","fields","objectConfig","defineType","type","getPreset","title","defineField","options","layout","list","preview","select","linkType","url","referenceTitle","referenceName","prepare","subtitle","imageType","altText","caption","hotspot","validation","rule","warning","media","internalTypes","referenceTargets","map","initialValue","value","to","hidden","parent","uri","scheme","wrapArrayAsPageBuilderBlock","arraySchema","components","undefined","defineArrayMember","of","toPageBuilderArrayMember","block","lookupArrayPreset","arrayPreset","defineLazyContentField","blocks","cached","group","createPageType","pageBuilderBlocks","groups","documentConfig","ALL_FIELDS_GROUP","default","required","source","resolveObjects","objects","link","image","cta","richTextType","arrayConfig","linkAnnotation","ctaInline","imageMember","blockMember","marks","annotations","seoType","max","info","previews","aspectRatio","Rule","custom","asset","_ref","height","width","getImageDimensions","createPresetsRegistry","uuid","seed","registeredSchemas","pageTypeWithLookup","registered","reduce","preset","key","getPresetKey","createDefiner","charAt","toUpperCase","slice","createRegistryContext","presetConfig","definer","Error","userConfig","length","registryContext","registryDefaults","mergedConfig","factoryConfig","applyMapHooks","addTelemetryComponent","mappedSchemaType","configName","configValue","Object","entries","existing","existingInput","input"],"mappings":";;;;;;;;AAMO,MAAMA,eAAeC,YAA8B;AAAA,EACxDC,MAAM;AAAA,EACNC,SAAS;AAAA,EACTC,aAAa;AACf,CAAC,GCMKC,iCAAiBC,IAAAA;AAEhB,SAASC,iBAAiBC,IAAkB;AACjDH,aAAWI,IAAID,IAAI;AAAA,IAACA;AAAAA,IAAIE,6BAAaC,IAAAA;AAAAA,IAAOC,QAAQ;AAAA,EAAA,CAAM;AAC5D;AAEO,SAASC,kBAAkBC,YAAoBC,YAA0B;AAC9EV,aAAWW,IAAIF,UAAU,GAAGJ,QAAQO,IAAIF,UAAU;AACpD;AAEO,SAASG,gCAAgCJ,YAAoBK,WAA+B;AACjG,QAAMC,SAASf,WAAWW,IAAIF,UAAU;AACpC,GAACM,UAAUA,OAAOR,WACtBQ,OAAOR,SAAS,IACZQ,OAAOV,QAAQW,OAAO,KACxBF,UAAUG,IAAItB,cAAc;AAAA,IAACuB,aAAa,CAAC,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aAAaC,QAChE4E,gBACJD,YAAY,WAAWA,YAAY,OAAOA,SAASE,SAAU;AAAA;AAAA,IAExDF,SAASE;AAAAA,MACV7E;AAEN,SAAO;AAAA,IACL,GAAG1C;AAAAA,IACHyC,YAAY;AAAA,MACV,GAAG4E;AAAAA,MACHE,OAAQ9H,WACN,oBAAC,2BAAA,EAA0B,GAAIA,OAAO,YAAwB,WAAW6H,cAAAA,CAAc;AAAA,IAAA;AAAA,EAE3F;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/presets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Production ready preset patterns for Sanity Studio",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@sanity/uuid": "^3.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@sanity/pkg-utils": "^10.4.
|
|
35
|
+
"@sanity/pkg-utils": "^10.4.18",
|
|
36
36
|
"@testing-library/jest-dom": "^6.9.1",
|
|
37
37
|
"@testing-library/react": "^16.3.2",
|
|
38
|
-
"@types/node": "^24.12.
|
|
38
|
+
"@types/node": "^24.12.4",
|
|
39
39
|
"@types/react": "^19.2.14",
|
|
40
40
|
"@types/react-dom": "^19.2.3",
|
|
41
41
|
"jsdom": "^29.0.1",
|