@sanity/presets 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -24
- package/dist/index.d.ts +14 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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,8 @@ 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
|
+
|
|
167
168
|
**Fields:**
|
|
168
169
|
|
|
169
170
|
| Field | Type | Group | Description |
|
|
@@ -177,11 +178,11 @@ definePage({
|
|
|
177
178
|
|
|
178
179
|
**Options:**
|
|
179
180
|
|
|
180
|
-
| Option | Type | Description
|
|
181
|
-
| ------------------- | ------------------------ |
|
|
182
|
-
| `pageBuilderBlocks` | `
|
|
183
|
-
| `fields` | `FieldDefinition[]` | Additional fields to append.
|
|
184
|
-
| `groups` | `FieldGroupDefinition[]` | Additional groups to append after the defaults.
|
|
181
|
+
| Option | Type | Description |
|
|
182
|
+
| ------------------- | ------------------------ | ----------------------------------------------------------------------------- |
|
|
183
|
+
| `pageBuilderBlocks` | `PageBuilderBlock[]` | Type names or inline schema type definitions to include in the content array. |
|
|
184
|
+
| `fields` | `FieldDefinition[]` | Additional fields to append. |
|
|
185
|
+
| `groups` | `FieldGroupDefinition[]` | Additional groups to append after the defaults. |
|
|
185
186
|
|
|
186
187
|
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
188
|
|
|
@@ -347,6 +348,20 @@ The `objects` option only toggles embedded objects on or off. To reshape the arr
|
|
|
347
348
|
|
|
348
349
|
## Recommended patterns
|
|
349
350
|
|
|
351
|
+
### Configure links globally
|
|
352
|
+
|
|
353
|
+
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:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
const {defineLink, defineCta, definePage} = createPresetsRegistry({
|
|
357
|
+
link: {
|
|
358
|
+
internalTypes: ['page', 'post', 'product'],
|
|
359
|
+
},
|
|
360
|
+
})
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
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.
|
|
364
|
+
|
|
350
365
|
### Use presets alongside custom types
|
|
351
366
|
|
|
352
367
|
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 +378,20 @@ defineType({
|
|
|
363
378
|
title: 'Blockquote',
|
|
364
379
|
type: 'object',
|
|
365
380
|
fields: [
|
|
366
|
-
defineField({
|
|
367
|
-
|
|
368
|
-
|
|
381
|
+
defineField({
|
|
382
|
+
name: 'quote',
|
|
383
|
+
title: 'Quote',
|
|
384
|
+
type: 'text',
|
|
385
|
+
}),
|
|
386
|
+
defineField({
|
|
387
|
+
name: 'author',
|
|
388
|
+
title: 'Author',
|
|
389
|
+
type: 'string',
|
|
390
|
+
}),
|
|
391
|
+
defineLink({
|
|
392
|
+
name: 'source',
|
|
393
|
+
title: 'Source',
|
|
394
|
+
}),
|
|
369
395
|
],
|
|
370
396
|
})
|
|
371
397
|
```
|
|
@@ -382,7 +408,7 @@ definePage({
|
|
|
382
408
|
title: 'Blog Post',
|
|
383
409
|
// These types must be defined in your schema.
|
|
384
410
|
// See "Use presets alongside custom types" for more.
|
|
385
|
-
pageBuilderBlocks: ['richText', '
|
|
411
|
+
pageBuilderBlocks: ['richText', defineImage({name: 'imageBlock'})],
|
|
386
412
|
groups: [{name: 'settings', title: 'Settings'}],
|
|
387
413
|
fields: [
|
|
388
414
|
defineField({
|
|
@@ -430,17 +456,3 @@ A few guidelines for using map hooks:
|
|
|
430
456
|
|
|
431
457
|
- 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
458
|
- 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,EAAO,uBAAA,CAAwB,WAAA,EAAa,GAAA,MACzC,uBAAA,CAAwB,WAAA,EAAa,GAAA;AAAA;;;;;;KAUxC,UAAA,mC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AAW,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
|
@@ -245,9 +245,9 @@ const ctaType = {
|
|
|
245
245
|
title: "Content",
|
|
246
246
|
group: "main",
|
|
247
247
|
type: "array",
|
|
248
|
-
of: (pageBuilderBlocks ?? []).map((
|
|
249
|
-
type:
|
|
250
|
-
}))
|
|
248
|
+
of: (pageBuilderBlocks ?? []).map((block) => typeof block == "string" ? defineArrayMember({
|
|
249
|
+
type: block
|
|
250
|
+
}) : defineArrayMember(block))
|
|
251
251
|
}), registry.getPreset("seo", {
|
|
252
252
|
name: "seo",
|
|
253
253
|
title: "SEO",
|
|
@@ -398,11 +398,13 @@ function createDefiner({
|
|
|
398
398
|
registry
|
|
399
399
|
}) {
|
|
400
400
|
return function(userConfig = {}) {
|
|
401
|
+
const name = userConfig.name;
|
|
402
|
+
if (typeof name != "string" || name.length === 0)
|
|
403
|
+
throw new Error(`${getPresetKey(preset.name)}: "name" is required. Pass {name: "yourTypeName"}.`);
|
|
401
404
|
recordPresetUsage(registryId, preset.identifier ?? "unnamed");
|
|
402
405
|
const registryContext = createRegistryContext({
|
|
403
406
|
registry
|
|
404
407
|
}), registryDefaults = config[preset.name], mergedConfig = {
|
|
405
|
-
name: preset.name,
|
|
406
408
|
...typeof registryDefaults == "object" && registryDefaults !== null ? registryDefaults : {},
|
|
407
409
|
...userConfig
|
|
408
410
|
}, {
|
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,I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/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 {\n ALL_FIELDS_GROUP,\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\nexport interface PageTypeConfig {\n pageBuilderBlocks?: PageBuilderBlock[]\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((block) =>\n typeof block === 'string' ? defineArrayMember({type: block}) : defineArrayMember(block),\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 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 // 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","block","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","length","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,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A;AAC5B;AAEA,SAASD,sBACPpG,YACAvB,YACsB;AACtB,QAAMiI,WAAW,gBAAgB1G,aAAaA,WAAW2G,aAAanD,QAChEoD,gBACJF,YAAY,WAAWA,YAAY,OAAOA,SAASG,SAAU;AAAA;AAAA,IAExDH,SAASG;AAAAA,MACVrD;AAEN,SAAO;AAAA,IACL,GAAGxD;AAAAA,IACH2G,YAAY;AAAA,MACV,GAAGD;AAAAA,MACHG,OAAQpH,WACN,oBAAC,2BAAA,EAA0B,GAAIA,OAAO,YAAwB,WAAWmH,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.0",
|
|
4
4
|
"description": "Production ready preset patterns for Sanity Studio",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -32,7 +32,7 @@
|
|
|
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
38
|
"@types/node": "^24.12.2",
|