@sanity/presets 0.4.1 → 0.5.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 +22 -22
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ import {createPresetsRegistry} from '@sanity/presets'
|
|
|
43
43
|
|
|
44
44
|
const {defineLink, defineCta, defineSeo, defineImage, definePage} = createPresetsRegistry({
|
|
45
45
|
link: {
|
|
46
|
-
|
|
46
|
+
to: ['page', 'post'],
|
|
47
47
|
},
|
|
48
48
|
})
|
|
49
49
|
```
|
|
@@ -78,7 +78,7 @@ The **presets registry** is the entry point to `@sanity/presets`. Call `createPr
|
|
|
78
78
|
|
|
79
79
|
The registry serves two purposes:
|
|
80
80
|
|
|
81
|
-
1. **Global configuration.** Presets can be configured at the registry level, providing defaults that apply everywhere a preset is used. For example, configuring `link.
|
|
81
|
+
1. **Global configuration.** Presets can be configured at the registry level, providing defaults that apply everywhere a preset is used. For example, configuring `link.to` once means every link — whether standalone, inside a CTA, or inside rich text — knows which document types are available for internal links.
|
|
82
82
|
|
|
83
83
|
2. **Composition.** Some presets compose other presets internally. The CTA preset includes a link field; the page preset includes SEO fields. The registry ensures these composed presets share the same global configuration.
|
|
84
84
|
|
|
@@ -87,7 +87,7 @@ const {defineLink, defineCta, definePage} = createPresetsRegistry({
|
|
|
87
87
|
link: {
|
|
88
88
|
// Every link in this registry — standalone, inside CTAs,
|
|
89
89
|
// inside rich text — will offer these types for internal links.
|
|
90
|
-
|
|
90
|
+
to: ['marketingPage', 'blogPost'],
|
|
91
91
|
},
|
|
92
92
|
})
|
|
93
93
|
```
|
|
@@ -97,8 +97,8 @@ Global configuration can be overridden at the call site. If a specific link inst
|
|
|
97
97
|
```ts
|
|
98
98
|
defineLink({
|
|
99
99
|
name: 'specialLink',
|
|
100
|
-
// Overrides the registry-level
|
|
101
|
-
|
|
100
|
+
// Overrides the registry-level to for this instance only.
|
|
101
|
+
to: ['product'],
|
|
102
102
|
})
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -106,10 +106,10 @@ defineLink({
|
|
|
106
106
|
|
|
107
107
|
Presets can compose other presets. This means configuring one preset can affect others that depend on it.
|
|
108
108
|
|
|
109
|
-
The **link** preset is the clearest example. When you configure `link.
|
|
109
|
+
The **link** preset is the clearest example. When you configure `link.to` at the registry level, that configuration cascades to:
|
|
110
110
|
|
|
111
|
-
- **CTA (call to action)** — the CTA preset includes an inline link field. The link field automatically uses the registry-level `
|
|
112
|
-
- **Rich text** — the rich text preset includes link annotations. Those annotations also use the registry-level `
|
|
111
|
+
- **CTA (call to action)** — the CTA preset includes an inline link field. The link field automatically uses the registry-level `to` configuration.
|
|
112
|
+
- **Rich text** — the rich text preset includes link annotations. Those annotations also use the registry-level `to` configuration.
|
|
113
113
|
|
|
114
114
|
This means you configure link behaviour once, and every preset that uses links inherits that configuration automatically.
|
|
115
115
|
|
|
@@ -197,8 +197,8 @@ defineLink({
|
|
|
197
197
|
name: 'primaryLink',
|
|
198
198
|
title: 'Primary Link',
|
|
199
199
|
// Document types available for internal links. Falls back to
|
|
200
|
-
// the registry-level link.
|
|
201
|
-
|
|
200
|
+
// the registry-level link.to if not provided here.
|
|
201
|
+
to: ['page', 'post'],
|
|
202
202
|
})
|
|
203
203
|
```
|
|
204
204
|
|
|
@@ -207,15 +207,15 @@ defineLink({
|
|
|
207
207
|
| Field | Type | Description |
|
|
208
208
|
| -------------- | ----------- | -------------------------------------------------------------------------------------------------------- |
|
|
209
209
|
| `linkType` | `string` | "Internal" or "External". Defaults to "Internal". |
|
|
210
|
-
| `reference` | `reference` | Internal link. Hidden when link type is external. Targets configured via `
|
|
210
|
+
| `reference` | `reference` | Internal link. Hidden when link type is external. Targets configured via `to`. |
|
|
211
211
|
| `url` | `url` | External URL. Hidden when link type is internal. Validates `http`, `https`, `mailto`, and `tel` schemes. |
|
|
212
212
|
| `openInNewTab` | `boolean` | Whether to open in a new tab. Hidden for internal links. |
|
|
213
213
|
|
|
214
214
|
**Options:**
|
|
215
215
|
|
|
216
|
-
| Option
|
|
217
|
-
|
|
|
218
|
-
| `
|
|
216
|
+
| Option | Type | Description |
|
|
217
|
+
| ------ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
218
|
+
| `to` | `(string \| {type: string})[]` | Document types available for internal links. Accepts string shorthand (`['page']`) or object form (`[{type: 'page'}]`). Falls back to the registry-level `link.to`. |
|
|
219
219
|
|
|
220
220
|
### CTA (call to action)
|
|
221
221
|
|
|
@@ -230,10 +230,10 @@ defineCta({
|
|
|
230
230
|
|
|
231
231
|
**Fields:**
|
|
232
232
|
|
|
233
|
-
| Field | Type | Description
|
|
234
|
-
| ------- | -------- |
|
|
235
|
-
| `link` | `object` | An inline link, composed from the link preset. Inherits `
|
|
236
|
-
| `level` | `number` | Semantic importance level (1, 2, or 3).
|
|
233
|
+
| Field | Type | Description |
|
|
234
|
+
| ------- | -------- | ------------------------------------------------------------------------------- |
|
|
235
|
+
| `link` | `object` | An inline link, composed from the link preset. Inherits `to` from the registry. |
|
|
236
|
+
| `level` | `number` | Semantic importance level (1, 2, or 3). |
|
|
237
237
|
|
|
238
238
|
### SEO (search engine optimization)
|
|
239
239
|
|
|
@@ -332,12 +332,12 @@ defineRichText({
|
|
|
332
332
|
|
|
333
333
|
#### Configuring the embedded presets
|
|
334
334
|
|
|
335
|
-
Configure each object's options (link `
|
|
335
|
+
Configure each object's options (link `to`, image `altText`, and so on) at the registry level. Those options cascade into every rich text field:
|
|
336
336
|
|
|
337
337
|
```ts
|
|
338
338
|
const {defineRichText} = createPresetsRegistry({
|
|
339
339
|
link: {
|
|
340
|
-
|
|
340
|
+
to: ['page', 'post'],
|
|
341
341
|
},
|
|
342
342
|
image: {
|
|
343
343
|
altText: true,
|
|
@@ -352,12 +352,12 @@ The `objects` option only toggles embedded objects on or off. To reshape the arr
|
|
|
352
352
|
|
|
353
353
|
### Configure links globally
|
|
354
354
|
|
|
355
|
-
The [link preset](#link) is used by multiple other presets ([CTA](#cta-call-to-action), [rich text](#rich-text)). Configure `
|
|
355
|
+
The [link preset](#link) is used by multiple other presets ([CTA](#cta-call-to-action), [rich text](#rich-text)). Configure `to` at the registry level so all links share the same set of linkable document types:
|
|
356
356
|
|
|
357
357
|
```ts
|
|
358
358
|
const {defineLink, defineCta, definePage} = createPresetsRegistry({
|
|
359
359
|
link: {
|
|
360
|
-
|
|
360
|
+
to: ['page', 'post', 'product'],
|
|
361
361
|
},
|
|
362
362
|
})
|
|
363
363
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type PartialSchemaDefinition<TypeName extends IntrinsicTypeName> = Partial<Defin
|
|
|
3
3
|
preview: PreviewConfig;
|
|
4
4
|
}> & Pick<DefineSchemaBase<TypeName, TypeName>, 'name'>;
|
|
5
5
|
interface RegistryContext {
|
|
6
|
-
getPreset: (presetName: string, config?: Record<string, unknown>) => FieldDefinition;
|
|
6
|
+
getPreset: (presetName: string, config?: Record<string, unknown>) => SchemaTypeDefinition & FieldDefinition;
|
|
7
7
|
}
|
|
8
8
|
type ProhibitedProperties = 'type';
|
|
9
9
|
type SanitizeProperties<Properties, ExcludedProperties extends string | undefined> = [ExcludedProperties] extends [PropertyKey] ? Omit<Properties, ExcludedProperties> : Properties;
|
|
@@ -49,9 +49,12 @@ interface ImageTypeConfig {
|
|
|
49
49
|
caption?: boolean;
|
|
50
50
|
hotspot?: boolean;
|
|
51
51
|
}
|
|
52
|
-
declare const imageType: PresetDefinition<ImageTypeConfig, "
|
|
52
|
+
declare const imageType: PresetDefinition<ImageTypeConfig, "image", "preview">;
|
|
53
|
+
type LinkToEntry = string | {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
53
56
|
interface LinkTypeConfig {
|
|
54
|
-
|
|
57
|
+
to?: LinkToEntry[];
|
|
55
58
|
}
|
|
56
59
|
declare const linkType: PresetDefinition<LinkTypeConfig, "object", "preview">;
|
|
57
60
|
interface RichTextObjectsConfig {
|
|
@@ -65,7 +68,7 @@ interface RichTextTypeConfig {
|
|
|
65
68
|
* Defaults to all enabled. Pass `false` to disable every object, or an
|
|
66
69
|
* object to toggle individual ones (e.g. `{link: false}`).
|
|
67
70
|
*
|
|
68
|
-
* Each object's options (link `
|
|
71
|
+
* Each object's options (link `to`, image `altText`, …) are
|
|
69
72
|
* configured on `createPresetsRegistry` and cascade into every rich text
|
|
70
73
|
* field. Use `map.of` for per-field structural changes.
|
|
71
74
|
*/
|
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/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,
|
|
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,GACE,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AA;EACA,KAAA;EACA,GAAA;AAAA;AAAA,UAGe,kBAAA;ENPE;;;;;;;;;EMiBjB,OAAA,aAAoB,qBAAA;AAAA;AAAA,cAUT,YAAA,EAAY,gBAAA,CAAA,kBAAA;AAAA,cCzBZ,OAAA,EAwDX,gBAAA;AAAA,UC1Ce,qBAAA;EACf,IAAA,GAAO,cAAA;EACP,KAAA,GAAQ,eAAA;EACR,IAAA,GAAO,cAAA;AAAA;AAAA,KAGJ,cAAA,gBAA8B,mBAAA,IACjC,MAAA,SAAe,gBAAA,8DAET,MAAA,EAAQ,UAAA,CAAW,OAAA,EAAS,WAAA,EAAa,gBAAA,MACtC,oBAAA,GAAuB,eAAA;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
|
@@ -55,6 +55,7 @@ const ctaType = {
|
|
|
55
55
|
}), defineField({
|
|
56
56
|
name: "level",
|
|
57
57
|
title: "Level",
|
|
58
|
+
description: "The importance of the action relative to its siblings: level 1 being the primary action, 2 the secondary action, and so on.",
|
|
58
59
|
type: "number",
|
|
59
60
|
options: {
|
|
60
61
|
layout: "radio",
|
|
@@ -91,21 +92,19 @@ const ctaType = {
|
|
|
91
92
|
caption = !0,
|
|
92
93
|
hotspot = !0,
|
|
93
94
|
fields,
|
|
94
|
-
...
|
|
95
|
+
...imageConfig
|
|
95
96
|
} = config;
|
|
96
97
|
return defineType({
|
|
97
|
-
...
|
|
98
|
-
type: "
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
hotspot
|
|
105
|
-
}
|
|
106
|
-
}), ...altText ? [defineField({
|
|
98
|
+
...imageConfig,
|
|
99
|
+
type: "image",
|
|
100
|
+
// hotspot is the curated default; callers override other image options (accept, sources, storeOriginalFilename) via the map.options hook
|
|
101
|
+
options: {
|
|
102
|
+
hotspot
|
|
103
|
+
},
|
|
104
|
+
fields: [...altText ? [defineField({
|
|
107
105
|
name: "altText",
|
|
108
106
|
title: "Alt text",
|
|
107
|
+
description: "Describes the image for screen readers and search engines. Important for accessibility.",
|
|
109
108
|
type: "string",
|
|
110
109
|
validation: (rule) => rule.warning("Alt text improves accessibility.")
|
|
111
110
|
})] : [], ...caption ? [defineField({
|
|
@@ -115,23 +114,26 @@ const ctaType = {
|
|
|
115
114
|
})] : [], ...fields ?? []],
|
|
116
115
|
preview: {
|
|
117
116
|
select: {
|
|
118
|
-
title: altText ? "altText" : caption ? "caption" : "
|
|
119
|
-
media: "image"
|
|
117
|
+
title: altText ? "altText" : caption ? "caption" : "asset.originalFilename"
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
});
|
|
123
121
|
}
|
|
124
|
-
}
|
|
122
|
+
};
|
|
123
|
+
function normalizeToTargets(entries) {
|
|
124
|
+
return entries.map((entry) => typeof entry == "string" ? {
|
|
125
|
+
type: entry
|
|
126
|
+
} : entry);
|
|
127
|
+
}
|
|
128
|
+
const linkType = {
|
|
125
129
|
name: "link",
|
|
126
130
|
identifier: "core.link",
|
|
127
131
|
schemaType: ({
|
|
128
|
-
|
|
132
|
+
to,
|
|
129
133
|
fields,
|
|
130
134
|
...objectConfig
|
|
131
135
|
}) => {
|
|
132
|
-
const referenceTargets = (
|
|
133
|
-
type
|
|
134
|
-
}));
|
|
136
|
+
const referenceTargets = normalizeToTargets(to ?? []);
|
|
135
137
|
return defineType({
|
|
136
138
|
...objectConfig,
|
|
137
139
|
type: "object",
|
|
@@ -139,6 +141,7 @@ const ctaType = {
|
|
|
139
141
|
name: "linkType",
|
|
140
142
|
type: "string",
|
|
141
143
|
title: "Link Type",
|
|
144
|
+
description: "Internal links point to a page in this project. External links point to a full URL.",
|
|
142
145
|
initialValue: "internal",
|
|
143
146
|
options: {
|
|
144
147
|
layout: "radio",
|
|
@@ -162,6 +165,7 @@ const ctaType = {
|
|
|
162
165
|
name: "url",
|
|
163
166
|
type: "url",
|
|
164
167
|
title: "URL",
|
|
168
|
+
description: "Full URL including protocol, e.g. https://example.com. Supports http, https, mailto, and tel.",
|
|
165
169
|
hidden: ({
|
|
166
170
|
parent
|
|
167
171
|
}) => parent?.linkType === "internal",
|
|
@@ -227,6 +231,7 @@ function defineLazyContentField(blocks, lookupArrayPreset) {
|
|
|
227
231
|
return defineField({
|
|
228
232
|
name: "content",
|
|
229
233
|
title: "Content",
|
|
234
|
+
description: "Page sections rendered in order. Add, remove, or reorder blocks to build the page.",
|
|
230
235
|
group: "main",
|
|
231
236
|
type: "array",
|
|
232
237
|
get of() {
|
|
@@ -264,6 +269,7 @@ function createPageType({
|
|
|
264
269
|
fields: [defineField({
|
|
265
270
|
name: "name",
|
|
266
271
|
title: "Name",
|
|
272
|
+
description: "Used as the page title and as the source for the auto-generated slug.",
|
|
267
273
|
type: "string",
|
|
268
274
|
group: "main",
|
|
269
275
|
validation: (rule) => rule.required()
|
|
@@ -382,8 +388,8 @@ const richTextType = {
|
|
|
382
388
|
height,
|
|
383
389
|
width
|
|
384
390
|
} = getImageDimensions(value.asset?._ref);
|
|
385
|
-
return height !== 630 || width !== 1200 ? "Open Graph
|
|
386
|
-
})
|
|
391
|
+
return height !== 630 || width !== 1200 ? "Open Graph images are recommended to be exactly 1200x630 (1.91:1) for the best social sharing previews." : !0;
|
|
392
|
+
}).warning()
|
|
387
393
|
}), ...fields ?? []]
|
|
388
394
|
});
|
|
389
395
|
}
|
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 ...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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,SAASD,sBACP/G,YACAvB,YACsB;AACtB,QAAM4I,WAAW,gBAAgBrH,aAAaA,WAAWyC,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;"}
|
|
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 description:\n 'The importance of the action relative to its siblings: level 1 being the primary action, 2 the secondary action, and so on.',\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, 'image', 'preview'>({\n name: 'image',\n identifier: 'core.image',\n schemaType: (config) => {\n const {altText = true, caption = true, hotspot = true, fields, ...imageConfig} = config\n\n return defineType({\n ...imageConfig,\n type: 'image',\n // hotspot is the curated default; callers override other image options (accept, sources, storeOriginalFilename) via the map.options hook\n options: {\n hotspot,\n },\n fields: [\n ...(altText\n ? [\n defineField({\n name: 'altText',\n title: 'Alt text',\n description:\n 'Describes the image for screen readers and search engines. Important for accessibility.',\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' : 'asset.originalFilename',\n },\n },\n })\n },\n})\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\ntype LinkToEntry = string | {type: string}\n\nexport interface LinkTypeConfig {\n to?: LinkToEntry[]\n}\n\nfunction normalizeToTargets(entries: LinkToEntry[]): {type: string}[] {\n return entries.map((entry) => (typeof entry === 'string' ? {type: entry} : entry))\n}\n\nexport const linkType = definePresetType<LinkTypeConfig, 'object', 'preview'>({\n name: 'link',\n identifier: 'core.link',\n schemaType: ({to, fields, ...objectConfig}) => {\n const referenceTargets = normalizeToTargets(to ?? [])\n\n return defineType({\n ...objectConfig,\n type: 'object',\n fields: [\n defineField({\n name: 'linkType',\n type: 'string',\n title: 'Link Type',\n description:\n 'Internal links point to a page in this project. External links point to a full URL.',\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 description:\n 'Full URL including protocol, e.g. https://example.com. Supports http, https, mailto, and tel.',\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 description:\n 'Page sections rendered in order. Add, remove, or reorder blocks to build the page.',\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 description: 'Used as the page title and as the source for the auto-generated slug.',\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 `to`, 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 images are recommended to be exactly 1200x630 (1.91:1) for the best social sharing previews.'\n }\n\n return true\n }).warning(),\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","imageConfig","validation","rule","warning","normalizeToTargets","entries","map","entry","to","referenceTargets","initialValue","value","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","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,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,YAA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AAQ/H,WACN,oBAAC,2BAAA,EAA0B,GAAIA,OAAO,YAAwB,WAAW8H,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.5.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.
|
|
35
|
+
"@sanity/pkg-utils": "^10.5.0",
|
|
36
36
|
"@testing-library/jest-dom": "^6.9.1",
|
|
37
37
|
"@testing-library/react": "^16.3.2",
|
|
38
38
|
"@types/node": "^24.12.4",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"react": "^19.2.5",
|
|
43
43
|
"react-dom": "^19.2.5",
|
|
44
44
|
"sanity": "^5.21.0",
|
|
45
|
-
"styled-components": "^6.4.
|
|
45
|
+
"styled-components": "^6.4.2",
|
|
46
46
|
"@repo/package.config": "0.0.0",
|
|
47
47
|
"@repo/tsconfig": "0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": "^19.2",
|
|
51
51
|
"react-dom": "^19.2",
|
|
52
|
-
"sanity": "^5"
|
|
52
|
+
"sanity": "^5 || ^6.0.0-0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=20.19 <22 || >=22.12"
|