@sanity/presets 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +410 -453
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -1,489 +1,446 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { uuid } from "@sanity/uuid";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { useTelemetry } from "@sanity/telemetry/react";
|
|
5
|
-
import { useEffect } from "react";
|
|
6
5
|
import { defineEvent } from "@sanity/telemetry";
|
|
7
|
-
import {
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { ALL_FIELDS_GROUP, defineArrayMember, defineField, defineType } from "sanity";
|
|
8
8
|
import { getImageDimensions } from "@sanity/asset-utils";
|
|
9
9
|
const PresetsAdded = defineEvent({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
name: "Presets Added",
|
|
11
|
+
version: 1,
|
|
12
|
+
description: "Workspace using presets was accessed"
|
|
13
13
|
}), registries = /* @__PURE__ */ new Map();
|
|
14
14
|
function registerRegistry(id) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
registries.set(id, {
|
|
16
|
+
id,
|
|
17
|
+
presets: /* @__PURE__ */ new Set(),
|
|
18
|
+
logged: !1
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
function recordPresetUsage(registryId, identifier) {
|
|
22
|
-
|
|
22
|
+
registries.get(registryId)?.presets.add(identifier);
|
|
23
23
|
}
|
|
24
24
|
function collectPresetsRegistryTelemetry(registryId, telemetry) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
presetNames: [...record.presets]
|
|
28
|
-
}));
|
|
25
|
+
let record = registries.get(registryId);
|
|
26
|
+
!record || record.logged || (record.logged = !0, record.presets.size > 0 && telemetry.log(PresetsAdded, { presetNames: [...record.presets] }));
|
|
29
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A transparent input component wrapper that triggers telemetry collection
|
|
30
|
+
* for the presets registry. Renders the user-provided input component if
|
|
31
|
+
* supplied, otherwise the default input component unchanged.
|
|
32
|
+
*
|
|
33
|
+
* Attached to every schema type produced by a define<Type> function via
|
|
34
|
+
* components.input. The first instance to render for a given registry id
|
|
35
|
+
* submits the PresetsAdded telemetry event; subsequent renders are no-ops.
|
|
36
|
+
*/
|
|
30
37
|
const PresetsTelemetryCollector = (t0) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = t0, telemetry = useTelemetry();
|
|
36
|
-
let t1, t2;
|
|
37
|
-
return $[0] !== registryId || $[1] !== telemetry ? (t1 = () => {
|
|
38
|
-
collectPresetsRegistryTelemetry(registryId, telemetry);
|
|
39
|
-
}, t2 = [registryId, telemetry], $[0] = registryId, $[1] = telemetry, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2), UserInput ? /* @__PURE__ */ jsx(UserInput, { ...props }) : props.renderDefault(props);
|
|
40
|
-
};
|
|
41
|
-
const ctaType = {
|
|
42
|
-
name: "cta",
|
|
43
|
-
identifier: "core.cta",
|
|
44
|
-
schemaType: (config, registry) => {
|
|
45
|
-
const {
|
|
46
|
-
fields,
|
|
47
|
-
...objectConfig
|
|
48
|
-
} = config;
|
|
49
|
-
return defineType({
|
|
50
|
-
...objectConfig,
|
|
51
|
-
type: "object",
|
|
52
|
-
fields: [registry.getPreset("link", {
|
|
53
|
-
name: "link",
|
|
54
|
-
title: "Link"
|
|
55
|
-
}), defineField({
|
|
56
|
-
name: "level",
|
|
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.",
|
|
59
|
-
type: "number",
|
|
60
|
-
options: {
|
|
61
|
-
layout: "radio",
|
|
62
|
-
list: [1, 2, 3]
|
|
63
|
-
}
|
|
64
|
-
}), ...fields ?? []],
|
|
65
|
-
preview: {
|
|
66
|
-
select: {
|
|
67
|
-
linkType: "link.linkType",
|
|
68
|
-
url: "link.url",
|
|
69
|
-
referenceTitle: "link.reference.title",
|
|
70
|
-
referenceName: "link.reference.name"
|
|
71
|
-
},
|
|
72
|
-
prepare({
|
|
73
|
-
linkType: linkType2,
|
|
74
|
-
url,
|
|
75
|
-
referenceTitle,
|
|
76
|
-
referenceName
|
|
77
|
-
}) {
|
|
78
|
-
return {
|
|
79
|
-
title: linkType2 === "external" ? url || "No URL" : referenceTitle || referenceName || "No reference",
|
|
80
|
-
subtitle: "Button"
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}, imageType = {
|
|
87
|
-
name: "image",
|
|
88
|
-
identifier: "core.image",
|
|
89
|
-
schemaType: (config) => {
|
|
90
|
-
const {
|
|
91
|
-
altText = !0,
|
|
92
|
-
caption = !0,
|
|
93
|
-
hotspot = !0,
|
|
94
|
-
fields,
|
|
95
|
-
...imageConfig
|
|
96
|
-
} = config;
|
|
97
|
-
return defineType({
|
|
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({
|
|
105
|
-
name: "altText",
|
|
106
|
-
title: "Alt text",
|
|
107
|
-
description: "Describes the image for screen readers and search engines. Important for accessibility.",
|
|
108
|
-
type: "string",
|
|
109
|
-
validation: (rule) => rule.warning("Alt text improves accessibility.")
|
|
110
|
-
})] : [], ...caption ? [defineField({
|
|
111
|
-
name: "caption",
|
|
112
|
-
title: "Caption",
|
|
113
|
-
type: "text"
|
|
114
|
-
})] : [], ...fields ?? []],
|
|
115
|
-
preview: {
|
|
116
|
-
select: {
|
|
117
|
-
title: altText ? "altText" : caption ? "caption" : "asset.originalFilename"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
38
|
+
let $ = c(4), { registryId, userInput: UserInput, ...props } = t0, telemetry = useTelemetry(), t1, t2;
|
|
39
|
+
return $[0] !== registryId || $[1] !== telemetry ? (t1 = () => {
|
|
40
|
+
collectPresetsRegistryTelemetry(registryId, telemetry);
|
|
41
|
+
}, t2 = [registryId, telemetry], $[0] = registryId, $[1] = telemetry, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2), UserInput ? /* @__PURE__ */ jsx(UserInput, { ...props }) : props.renderDefault(props);
|
|
122
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* A typed passthrough for defining a preset. Given a `PresetDefinition`, it
|
|
45
|
+
* returns the same value, narrowed to its concrete generic parameters so
|
|
46
|
+
* downstream code can infer the preset's config type from it.
|
|
47
|
+
*
|
|
48
|
+
* This is intentionally lightweight: it performs no work at call time. The
|
|
49
|
+
* registry is responsible for invoking `schemaType` when a preset is
|
|
50
|
+
* instantiated, and for applying `map` hooks to the produced schema type.
|
|
51
|
+
*/
|
|
52
|
+
function definePresetType(preset) {
|
|
53
|
+
return preset;
|
|
54
|
+
}
|
|
55
|
+
const ctaType = definePresetType({
|
|
56
|
+
name: "cta",
|
|
57
|
+
identifier: "core.cta",
|
|
58
|
+
schemaType: (config, registry) => {
|
|
59
|
+
let { fields, ...objectConfig } = config;
|
|
60
|
+
return defineType({
|
|
61
|
+
...objectConfig,
|
|
62
|
+
type: "object",
|
|
63
|
+
fields: [
|
|
64
|
+
registry.getPreset("link", {
|
|
65
|
+
name: "link",
|
|
66
|
+
title: "Link"
|
|
67
|
+
}),
|
|
68
|
+
defineField({
|
|
69
|
+
name: "level",
|
|
70
|
+
title: "Level",
|
|
71
|
+
description: "The importance of the action relative to its siblings: level 1 being the primary action, 2 the secondary action, and so on.",
|
|
72
|
+
type: "number",
|
|
73
|
+
options: {
|
|
74
|
+
layout: "radio",
|
|
75
|
+
list: [
|
|
76
|
+
1,
|
|
77
|
+
2,
|
|
78
|
+
3
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
...fields ?? []
|
|
83
|
+
],
|
|
84
|
+
preview: {
|
|
85
|
+
select: {
|
|
86
|
+
linkType: "link.linkType",
|
|
87
|
+
url: "link.url",
|
|
88
|
+
referenceTitle: "link.reference.title",
|
|
89
|
+
referenceName: "link.reference.name"
|
|
90
|
+
},
|
|
91
|
+
prepare({ linkType, url, referenceTitle, referenceName }) {
|
|
92
|
+
return {
|
|
93
|
+
title: linkType === "external" ? url || "No URL" : referenceTitle || referenceName || "No reference",
|
|
94
|
+
subtitle: "Button"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}), imageType = definePresetType({
|
|
101
|
+
name: "image",
|
|
102
|
+
identifier: "core.image",
|
|
103
|
+
schemaType: (config) => {
|
|
104
|
+
let { altText = !0, caption = !0, hotspot = !0, fields, ...imageConfig } = config;
|
|
105
|
+
return defineType({
|
|
106
|
+
...imageConfig,
|
|
107
|
+
type: "image",
|
|
108
|
+
options: { hotspot },
|
|
109
|
+
fields: [
|
|
110
|
+
...altText ? [defineField({
|
|
111
|
+
name: "altText",
|
|
112
|
+
title: "Alt text",
|
|
113
|
+
description: "Describes the image for screen readers and search engines. Important for accessibility.",
|
|
114
|
+
type: "string",
|
|
115
|
+
validation: (rule) => rule.warning("Alt text improves accessibility.")
|
|
116
|
+
})] : [],
|
|
117
|
+
...caption ? [defineField({
|
|
118
|
+
name: "caption",
|
|
119
|
+
title: "Caption",
|
|
120
|
+
type: "text"
|
|
121
|
+
})] : [],
|
|
122
|
+
...fields ?? []
|
|
123
|
+
],
|
|
124
|
+
preview: { select: { title: altText ? "altText" : caption ? "caption" : "asset.originalFilename" } }
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
123
128
|
function normalizeToTargets(entries) {
|
|
124
|
-
|
|
125
|
-
type: entry
|
|
126
|
-
} : entry);
|
|
129
|
+
return entries.map((entry) => typeof entry == "string" ? { type: entry } : entry);
|
|
127
130
|
}
|
|
128
|
-
const linkType = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
131
|
+
const linkType = definePresetType({
|
|
132
|
+
name: "link",
|
|
133
|
+
identifier: "core.link",
|
|
134
|
+
schemaType: ({ to, fields, ...objectConfig }) => {
|
|
135
|
+
let referenceTargets = normalizeToTargets(to ?? []);
|
|
136
|
+
return defineType({
|
|
137
|
+
...objectConfig,
|
|
138
|
+
type: "object",
|
|
139
|
+
fields: [
|
|
140
|
+
defineField({
|
|
141
|
+
name: "linkType",
|
|
142
|
+
type: "string",
|
|
143
|
+
title: "Link Type",
|
|
144
|
+
description: "Internal links point to a page in this project. External links point to a full URL.",
|
|
145
|
+
initialValue: "internal",
|
|
146
|
+
options: {
|
|
147
|
+
layout: "radio",
|
|
148
|
+
list: [{
|
|
149
|
+
title: "Internal",
|
|
150
|
+
value: "internal"
|
|
151
|
+
}, {
|
|
152
|
+
title: "External",
|
|
153
|
+
value: "external"
|
|
154
|
+
}]
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
defineField({
|
|
158
|
+
name: "reference",
|
|
159
|
+
type: "reference",
|
|
160
|
+
title: "Internal Link",
|
|
161
|
+
to: referenceTargets,
|
|
162
|
+
hidden: ({ parent }) => parent?.linkType === "external"
|
|
163
|
+
}),
|
|
164
|
+
defineField({
|
|
165
|
+
name: "url",
|
|
166
|
+
type: "url",
|
|
167
|
+
title: "URL",
|
|
168
|
+
description: "Full URL including protocol, e.g. https://example.com. Supports http, https, mailto, and tel.",
|
|
169
|
+
hidden: ({ parent }) => parent?.linkType === "internal",
|
|
170
|
+
validation: (rule) => rule.uri({ scheme: [
|
|
171
|
+
"http",
|
|
172
|
+
"https",
|
|
173
|
+
"mailto",
|
|
174
|
+
"tel"
|
|
175
|
+
] })
|
|
176
|
+
}),
|
|
177
|
+
defineField({
|
|
178
|
+
name: "openInNewTab",
|
|
179
|
+
type: "boolean",
|
|
180
|
+
title: "Open in New Tab",
|
|
181
|
+
initialValue: !1,
|
|
182
|
+
hidden: ({ parent }) => parent?.linkType === "internal"
|
|
183
|
+
}),
|
|
184
|
+
...fields ?? []
|
|
185
|
+
],
|
|
186
|
+
preview: {
|
|
187
|
+
select: {
|
|
188
|
+
linkType: "linkType",
|
|
189
|
+
url: "url",
|
|
190
|
+
referenceTitle: "reference.title",
|
|
191
|
+
referenceName: "reference.name"
|
|
192
|
+
},
|
|
193
|
+
prepare({ linkType, url, referenceTitle, referenceName }) {
|
|
194
|
+
return {
|
|
195
|
+
title: linkType === "external" ? url || "No URL" : referenceTitle || referenceName || "No reference",
|
|
196
|
+
subtitle: linkType === "external" ? "External link" : "Internal link"
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
});
|
|
206
203
|
function wrapArrayAsPageBuilderBlock(arraySchema) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
204
|
+
let components = "components" in arraySchema ? arraySchema.components : void 0;
|
|
205
|
+
return defineArrayMember({
|
|
206
|
+
name: arraySchema.name,
|
|
207
|
+
title: arraySchema.title,
|
|
208
|
+
type: "object",
|
|
209
|
+
fields: [defineField({
|
|
210
|
+
name: "content",
|
|
211
|
+
type: "array",
|
|
212
|
+
of: arraySchema.of,
|
|
213
|
+
components
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
219
216
|
}
|
|
220
217
|
function toPageBuilderArrayMember(block, lookupArrayPreset) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
return block.type === "array" ? wrapArrayAsPageBuilderBlock(block) : defineArrayMember(block);
|
|
218
|
+
if (typeof block == "string") {
|
|
219
|
+
let arrayPreset = lookupArrayPreset(block);
|
|
220
|
+
return arrayPreset ? wrapArrayAsPageBuilderBlock(arrayPreset) : defineArrayMember({ type: block });
|
|
221
|
+
}
|
|
222
|
+
return block.type === "array" ? wrapArrayAsPageBuilderBlock(block) : defineArrayMember(block);
|
|
228
223
|
}
|
|
229
224
|
function defineLazyContentField(blocks, lookupArrayPreset) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
225
|
+
let cached;
|
|
226
|
+
return defineField({
|
|
227
|
+
name: "content",
|
|
228
|
+
title: "Content",
|
|
229
|
+
description: "Page sections rendered in order. Add, remove, or reorder blocks to build the page.",
|
|
230
|
+
group: "main",
|
|
231
|
+
type: "array",
|
|
232
|
+
get of() {
|
|
233
|
+
return cached ??= blocks.map((block) => toPageBuilderArrayMember(block, lookupArrayPreset)), cached;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
241
236
|
}
|
|
242
|
-
function createPageType({
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
237
|
+
function createPageType({ lookupArrayPreset }) {
|
|
238
|
+
return definePresetType({
|
|
239
|
+
name: "page",
|
|
240
|
+
identifier: "core.page",
|
|
241
|
+
schemaType: (config, registry) => {
|
|
242
|
+
let { pageBuilderBlocks, groups, fields, ...documentConfig } = config;
|
|
243
|
+
return defineType({
|
|
244
|
+
...documentConfig,
|
|
245
|
+
type: "document",
|
|
246
|
+
groups: [
|
|
247
|
+
{
|
|
248
|
+
...ALL_FIELDS_GROUP,
|
|
249
|
+
hidden: !0
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "main",
|
|
253
|
+
title: "Main",
|
|
254
|
+
default: !0
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "metadata",
|
|
258
|
+
title: "Metadata"
|
|
259
|
+
},
|
|
260
|
+
...groups ?? []
|
|
261
|
+
],
|
|
262
|
+
fields: [
|
|
263
|
+
defineField({
|
|
264
|
+
name: "name",
|
|
265
|
+
title: "Name",
|
|
266
|
+
description: "Used as the page title and as the source for the auto-generated slug.",
|
|
267
|
+
type: "string",
|
|
268
|
+
group: "main",
|
|
269
|
+
validation: (rule) => rule.required()
|
|
270
|
+
}),
|
|
271
|
+
defineField({
|
|
272
|
+
name: "slug",
|
|
273
|
+
title: "Slug",
|
|
274
|
+
type: "slug",
|
|
275
|
+
group: "main",
|
|
276
|
+
options: { source: "name" }
|
|
277
|
+
}),
|
|
278
|
+
defineLazyContentField(pageBuilderBlocks ?? [], lookupArrayPreset),
|
|
279
|
+
registry.getPreset("seo", {
|
|
280
|
+
name: "seo",
|
|
281
|
+
title: "SEO",
|
|
282
|
+
group: "metadata"
|
|
283
|
+
}),
|
|
284
|
+
...fields ?? []
|
|
285
|
+
]
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
});
|
|
292
289
|
}
|
|
290
|
+
createPageType({ lookupArrayPreset: () => void 0 });
|
|
293
291
|
function resolveObjects(objects) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
link,
|
|
311
|
-
image,
|
|
312
|
-
cta
|
|
313
|
-
};
|
|
292
|
+
if (objects === !1) return {
|
|
293
|
+
link: !1,
|
|
294
|
+
image: !1,
|
|
295
|
+
cta: !1
|
|
296
|
+
};
|
|
297
|
+
if (objects === !0 || objects === void 0) return {
|
|
298
|
+
link: !0,
|
|
299
|
+
image: !0,
|
|
300
|
+
cta: !0
|
|
301
|
+
};
|
|
302
|
+
let { link = !0, image = !0, cta = !0 } = objects;
|
|
303
|
+
return {
|
|
304
|
+
link,
|
|
305
|
+
image,
|
|
306
|
+
cta
|
|
307
|
+
};
|
|
314
308
|
}
|
|
315
|
-
const richTextType = {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
aspectRatio: 1.91 / 1
|
|
381
|
-
}]
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
validation: (Rule) => Rule.custom((value) => {
|
|
385
|
-
if (!value?.asset?._ref)
|
|
386
|
-
return !0;
|
|
387
|
-
const {
|
|
388
|
-
height,
|
|
389
|
-
width
|
|
390
|
-
} = getImageDimensions(value.asset?._ref);
|
|
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()
|
|
393
|
-
}), ...fields ?? []]
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
};
|
|
309
|
+
const richTextType = definePresetType({
|
|
310
|
+
name: "richText",
|
|
311
|
+
identifier: "core.richText",
|
|
312
|
+
schemaType: (config, registry) => {
|
|
313
|
+
let { objects, ...arrayConfig } = config, { link, image, cta } = resolveObjects(objects), linkAnnotation = link ? registry.getPreset("link", {
|
|
314
|
+
name: "link",
|
|
315
|
+
title: "Link"
|
|
316
|
+
}) : void 0, ctaInline = cta ? registry.getPreset("cta", {
|
|
317
|
+
name: "cta",
|
|
318
|
+
title: "CTA"
|
|
319
|
+
}) : void 0, imageMember = image ? registry.getPreset("image", {
|
|
320
|
+
name: "richTextImage",
|
|
321
|
+
title: "Image"
|
|
322
|
+
}) : void 0, blockMember = defineArrayMember({
|
|
323
|
+
type: "block",
|
|
324
|
+
marks: { annotations: linkAnnotation ? [linkAnnotation] : [] },
|
|
325
|
+
...ctaInline && { of: [ctaInline] }
|
|
326
|
+
});
|
|
327
|
+
return defineType({
|
|
328
|
+
...arrayConfig,
|
|
329
|
+
type: "array",
|
|
330
|
+
of: imageMember ? [blockMember, imageMember] : [blockMember]
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}), seoType = definePresetType({
|
|
334
|
+
name: "seo",
|
|
335
|
+
identifier: "core.seo",
|
|
336
|
+
schemaType: (config) => {
|
|
337
|
+
let { fields, ...objectConfig } = config;
|
|
338
|
+
return defineType({
|
|
339
|
+
...objectConfig,
|
|
340
|
+
type: "object",
|
|
341
|
+
fields: [
|
|
342
|
+
defineField({
|
|
343
|
+
name: "title",
|
|
344
|
+
title: "Title",
|
|
345
|
+
type: "string",
|
|
346
|
+
validation: (rule) => rule.max(70).info("Search engines may truncate this title.")
|
|
347
|
+
}),
|
|
348
|
+
defineField({
|
|
349
|
+
name: "description",
|
|
350
|
+
title: "Description",
|
|
351
|
+
type: "text",
|
|
352
|
+
validation: (rule) => rule.max(150).info("Search engines may truncate this description.")
|
|
353
|
+
}),
|
|
354
|
+
defineField({
|
|
355
|
+
name: "ogImage",
|
|
356
|
+
title: "Open Graph image",
|
|
357
|
+
type: "image",
|
|
358
|
+
description: "Landscape 1200x630 (1.91:1)",
|
|
359
|
+
options: { hotspot: { previews: [{
|
|
360
|
+
title: "Landscape (1.91:1)",
|
|
361
|
+
aspectRatio: 1.91 / 1
|
|
362
|
+
}] } },
|
|
363
|
+
validation: (Rule) => Rule.custom((value) => {
|
|
364
|
+
if (!value?.asset?._ref) return !0;
|
|
365
|
+
let { height, width } = getImageDimensions(value.asset?._ref);
|
|
366
|
+
return height !== 630 || width !== 1200 ? "Open Graph images are recommended to be exactly 1200x630 (1.91:1) for the best social sharing previews." : !0;
|
|
367
|
+
}).warning()
|
|
368
|
+
}),
|
|
369
|
+
...fields ?? []
|
|
370
|
+
]
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
397
374
|
function createPresetsRegistry(config = {}) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
375
|
+
let registryId = uuid();
|
|
376
|
+
registerRegistry(registryId);
|
|
377
|
+
let seed = {}, registeredSchemas = /* @__PURE__ */ new Map();
|
|
378
|
+
return [
|
|
379
|
+
linkType,
|
|
380
|
+
ctaType,
|
|
381
|
+
seoType,
|
|
382
|
+
imageType,
|
|
383
|
+
createPageType({ lookupArrayPreset: (name) => {
|
|
384
|
+
let registered = registeredSchemas.get(name);
|
|
385
|
+
return registered?.type === "array" ? registered : void 0;
|
|
386
|
+
} }),
|
|
387
|
+
richTextType
|
|
388
|
+
].reduce((registry, preset) => {
|
|
389
|
+
let key = getPresetKey(preset.name);
|
|
390
|
+
return registry[key] = createDefiner({
|
|
391
|
+
registryId,
|
|
392
|
+
preset,
|
|
393
|
+
config,
|
|
394
|
+
registry,
|
|
395
|
+
registeredSchemas
|
|
396
|
+
}), registry;
|
|
397
|
+
}, seed);
|
|
416
398
|
}
|
|
417
399
|
function getPresetKey(name) {
|
|
418
|
-
|
|
400
|
+
return `define${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
419
401
|
}
|
|
420
|
-
function createRegistryContext({
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (!definer)
|
|
427
|
-
throw new Error(`Cannot resolve preset "${name}". No such preset in this registry.`);
|
|
428
|
-
return definer(presetConfig);
|
|
429
|
-
}
|
|
430
|
-
};
|
|
402
|
+
function createRegistryContext({ registry }) {
|
|
403
|
+
return { getPreset: (name, presetConfig) => {
|
|
404
|
+
let definer = registry[getPresetKey(name)];
|
|
405
|
+
if (!definer) throw Error(`Cannot resolve preset "${name}". No such preset in this registry.`);
|
|
406
|
+
return definer(presetConfig);
|
|
407
|
+
} };
|
|
431
408
|
}
|
|
432
|
-
function createDefiner({
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
recordPresetUsage(registryId, preset.identifier ?? "unnamed");
|
|
444
|
-
const registryContext = createRegistryContext({
|
|
445
|
-
registry
|
|
446
|
-
}), registryDefaults = config[preset.name], mergedConfig = {
|
|
447
|
-
...typeof registryDefaults == "object" && registryDefaults !== null ? registryDefaults : {},
|
|
448
|
-
...userConfig
|
|
449
|
-
}, {
|
|
450
|
-
map,
|
|
451
|
-
...factoryConfig
|
|
452
|
-
} = mergedConfig, schemaType = preset.schemaType(
|
|
453
|
-
// 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
|
|
454
|
-
factoryConfig,
|
|
455
|
-
registryContext
|
|
456
|
-
);
|
|
457
|
-
return registeredSchemas.set(name, schemaType), applyMapHooks(addTelemetryComponent(schemaType, registryId), map);
|
|
458
|
-
};
|
|
409
|
+
function createDefiner({ registryId, preset, config, registry, registeredSchemas }) {
|
|
410
|
+
return function(userConfig = {}) {
|
|
411
|
+
let name = userConfig.name;
|
|
412
|
+
if (typeof name != "string" || name.length === 0) throw Error(`${getPresetKey(preset.name)}: "name" is required. Pass {name: "yourTypeName"}.`);
|
|
413
|
+
recordPresetUsage(registryId, preset.identifier ?? "unnamed");
|
|
414
|
+
let registryContext = createRegistryContext({ registry }), registryDefaults = config[preset.name], { map, ...factoryConfig } = {
|
|
415
|
+
...typeof registryDefaults == "object" && registryDefaults ? registryDefaults : {},
|
|
416
|
+
...userConfig
|
|
417
|
+
}, schemaType = preset.schemaType(factoryConfig, registryContext);
|
|
418
|
+
return registeredSchemas.set(name, schemaType), applyMapHooks(addTelemetryComponent(schemaType, registryId), map);
|
|
419
|
+
};
|
|
459
420
|
}
|
|
460
421
|
function applyMapHooks(schemaType, map) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return {
|
|
469
|
-
...schemaType,
|
|
470
|
-
...mappedSchemaType
|
|
471
|
-
};
|
|
422
|
+
if (!map || typeof map != "object") return schemaType;
|
|
423
|
+
let mappedSchemaType = {};
|
|
424
|
+
for (let [configName, configValue] of Object.entries(map)) typeof configValue == "function" && (mappedSchemaType[configName] = configValue(schemaType[configName]));
|
|
425
|
+
return {
|
|
426
|
+
...schemaType,
|
|
427
|
+
...mappedSchemaType
|
|
428
|
+
};
|
|
472
429
|
}
|
|
473
430
|
function addTelemetryComponent(schemaType, registryId) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
431
|
+
let existing = "components" in schemaType ? schemaType.components : void 0, existingInput = existing && "input" in existing && typeof existing.input == "function" ? existing.input : void 0;
|
|
432
|
+
return {
|
|
433
|
+
...schemaType,
|
|
434
|
+
components: {
|
|
435
|
+
...existing,
|
|
436
|
+
input: (props) => /* @__PURE__ */ jsx(PresetsTelemetryCollector, {
|
|
437
|
+
...props,
|
|
438
|
+
registryId,
|
|
439
|
+
userInput: existingInput
|
|
440
|
+
})
|
|
441
|
+
}
|
|
442
|
+
};
|
|
485
443
|
}
|
|
486
|
-
export {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
//# sourceMappingURL=index.js.map
|
|
444
|
+
export { createPresetsRegistry };
|
|
445
|
+
|
|
446
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/__telemetry__/presets.telemetry.ts","../src/telemetry.ts","../src/components/PresetsTelemetryCollector.tsx","../src/presets/cta-type/index.ts","../src/presets/image-type/index.ts","../src/presets/link-type/index.ts","../src/presets/page-type/index.ts","../src/presets/rich-text-type/index.ts","../src/presets/seo-type/index.ts","../src/registry.tsx"],"sourcesContent":["import {defineEvent} from '@sanity/telemetry'\n\ninterface PresetsAddedInfo {\n presetNames: string[]\n}\n\nexport const PresetsAdded = defineEvent<PresetsAddedInfo>({\n name: 'Presets Added',\n version: 1,\n description: 'Workspace using presets was accessed',\n})\n","import {PresetsAdded} from './__telemetry__/presets.telemetry'\n\n/**\n * Minimal interface for the subset of TelemetryLogger we need.\n * Avoids forcing callers to satisfy the full generic TelemetryLogger type.\n */\nexport interface TelemetryLog {\n log(event: unknown, data: unknown): void\n}\n\ninterface RegistryRecord {\n id: string\n presets: Set<string>\n logged: boolean\n}\n\nconst registries = new Map<string, RegistryRecord>()\n\nexport function registerRegistry(id: string): void {\n registries.set(id, {id, presets: new Set(), logged: false})\n}\n\nexport function recordPresetUsage(registryId: string, identifier: string): void {\n registries.get(registryId)?.presets.add(identifier)\n}\n\nexport function collectPresetsRegistryTelemetry(registryId: string, telemetry: TelemetryLog): void {\n const record = registries.get(registryId)\n if (!record || record.logged) return\n record.logged = true\n if (record.presets.size > 0) {\n telemetry.log(PresetsAdded, {presetNames: [...record.presets]})\n }\n}\n\n/** @internal */\nexport function resetRegistries(): void {\n registries.clear()\n}\n","import {useTelemetry} from '@sanity/telemetry/react'\nimport {useEffect, type ComponentType} from 'react'\nimport type {InputProps} from 'sanity'\n\nimport {collectPresetsRegistryTelemetry} from '../telemetry'\n\ntype Props = InputProps & {\n registryId: string\n userInput?: ComponentType<InputProps>\n}\n\n/**\n * A transparent input component wrapper that triggers telemetry collection\n * for the presets registry. Renders the user-provided input component if\n * supplied, otherwise the default input component unchanged.\n *\n * Attached to every schema type produced by a define<Type> function via\n * components.input. The first instance to render for a given registry id\n * submits the PresetsAdded telemetry event; subsequent renders are no-ops.\n */\nexport const PresetsTelemetryCollector: ComponentType<Props> = ({\n registryId,\n userInput: UserInput,\n ...props\n}) => {\n const telemetry = useTelemetry()\n\n useEffect(() => {\n collectPresetsRegistryTelemetry(registryId, telemetry)\n }, [registryId, telemetry])\n\n if (UserInput) {\n return <UserInput {...props} />\n }\n\n return props.renderDefault(props)\n}\n","import {defineField, defineType} from 'sanity'\n\nimport {definePresetType} from '../../definePresetType'\n\nexport const ctaType = definePresetType<{}, 'object', 'preview'>({\n name: 'cta',\n identifier: 'core.cta',\n schemaType: (config, registry) => {\n const {fields, ...objectConfig} = config\n\n return defineType({\n ...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,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AKC,OAAOvF,QAAQC,GAAG;AACpD,WAAOqF,eAAgB,eAI3BF,iBAAiBC,UAAU,IAAIC;AAAAA;AAAAA,MAE7BpH,WAAWmH,UAAU;AAAA,IAAA;AAIzB,SAAO;AAAA,IAAC,GAAGnH;AAAAA,IAAY,GAAGkH;AAAAA,EAAAA;AAC5B;AAEA,SAASD,sBACPjH,YACAvB,YACsB;AACtB,QAAM6I,WAAW,gBAAgBtH,aAAaA,WAAW2C,aAAaC,QAChE2E,gBACJD,YAAY,WAAWA,YAAY,OAAOA,SAASE,SAAU;AAAA;AAAA,IAExDF,SAASE;AAAAA,MACV5E;AAEN,SAAO;AAAA,IACL,GAAG5C;AAAAA,IACH2C,YAAY;AAAA,MACV,GAAG2E;AAAAA,MACHE,OAAQ/H,WACN,oBAAC,2BAAA,EAA0B,GAAIA,OAAO,YAAwB,WAAW8H,cAAAA,CAAc;AAAA,IAAA;AAAA,EAE3F;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["defineEvent","PresetsAddedInfo","presetNames","PresetsAdded","name","version","description","PresetsAdded","TelemetryLog","log","event","data","RegistryRecord","id","presets","Set","logged","registries","Map","registerRegistry","set","recordPresetUsage","registryId","identifier","get","add","collectPresetsRegistryTelemetry","telemetry","record","size","presetNames","resetRegistries","clear","useTelemetry","useEffect","ComponentType","InputProps","collectPresetsRegistryTelemetry","Props","registryId","userInput","PresetsTelemetryCollector","t0","$","_c","UserInput","props","telemetry","t1","t2","renderDefault","FieldDefinition","FieldDefinitionBase","IntrinsicTypeName","SchemaTypeDefinition","PartialSchemaDefinition","RegistryContext","getPreset","presetName","config","Record","ProhibitedProperties","SanitizeProperties","ExcludedProperties","PropertyKey","Omit","Properties","DerivedConfig","Context","AliasedType","LockedProperties","map","input","Key","UserConfig","PresetDefinition","name","identifier","schemaType","registry","definePresetType","preset","AnyPresetDefinition","defineField","defineType","definePresetType","ctaType","name","identifier","schemaType","config","registry","fields","objectConfig","type","getPreset","title","description","options","layout","list","preview","select","linkType","url","referenceTitle","referenceName","prepare","referenceLabel","subtitle","defineField","defineType","definePresetType","ImageTypeConfig","altText","caption","hotspot","imageType","name","identifier","schemaType","config","fields","imageConfig","type","options","title","description","validation","rule","warning","preview","select","defineField","defineType","definePresetType","LinkToEntry","type","LinkTypeConfig","to","normalizeToTargets","entries","map","entry","linkType","name","identifier","schemaType","fields","objectConfig","referenceTargets","title","description","initialValue","options","layout","list","value","hidden","parent","validation","rule","uri","scheme","preview","select","url","referenceTitle","referenceName","prepare","referenceLabel","subtitle","ALL_FIELDS_GROUP","ArrayDefinition","defineArrayMember","defineField","defineType","FieldDefinition","SchemaTypeDefinition","definePresetType","PageBuilderBlock","LookupArrayPreset","name","wrapArrayAsPageBuilderBlock","arraySchema","components","undefined","title","type","fields","of","toPageBuilderArrayMember","block","lookupArrayPreset","arrayPreset","defineLazyContentField","blocks","cached","ReturnType","description","group","map","PageTypeConfig","pageBuilderBlocks","createPageType","identifier","schemaType","config","registry","groups","documentConfig","hidden","default","validation","rule","required","options","source","getPreset","pageType","defineArrayMember","defineType","definePresetType","RichTextObjectsConfig","link","image","cta","RichTextTypeConfig","objects","resolveObjects","Required","undefined","richTextType","name","identifier","schemaType","config","registry","arrayConfig","linkAnnotation","getPreset","title","ctaInline","imageMember","blockMember","type","marks","annotations","of","getImageDimensions","defineField","defineType","definePresetType","seoType","name","identifier","schemaType","config","fields","objectConfig","type","title","validation","rule","max","info","description","options","hotspot","previews","aspectRatio","Rule","custom","value","asset","_ref","height","width","warning","uuid","ComponentType","ArrayDefinition","FieldDefinition","InputProps","SchemaTypeDefinition","PresetsTelemetryCollector","AnyPresetDefinition","PresetDefinition","RegistryContext","UserConfig","ctaType","imageType","ImageTypeConfig","linkType","LinkTypeConfig","createPageType","pageType","PageTypeConfig","richTextType","seoType","recordPresetUsage","registerRegistry","PresetsRegistryConfig","link","image","page","DefineFunction","Preset","config","Context","AliasedType","LockedProperties","PresetsRegistry","defineLink","defineCta","defineSeo","defineImage","definePage","defineRichText","createPresetsRegistry","registryId","seed","DefinerRecord","registeredSchemas","Map","pageTypeWithLookup","lookupArrayPreset","name","registered","get","type","undefined","systemPresets","const","reduce","registry","preset","key","getPresetKey","createDefiner","charAt","toUpperCase","slice","Definer","Record","createRegistryContext","getPreset","presetConfig","definer","Error","CreateDefinerOptions","define","userConfig","length","identifier","registryContext","registryDefaults","mergedConfig","map","factoryConfig","schemaType","Parameters","set","applyMapHooks","addTelemetryComponent","mappedSchemaType","configName","configValue","Object","entries","existing","components","existingInput","input","props"],"sources":["../src/__telemetry__/presets.telemetry.ts","../src/telemetry.ts","../src/components/PresetsTelemetryCollector.tsx","../src/definePresetType.ts","../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 type {\n FieldDefinition,\n FieldDefinitionBase,\n IntrinsicTypeName,\n SchemaTypeDefinition,\n} from 'sanity'\n\nimport type {PartialSchemaDefinition} from './types'\n\nexport interface RegistryContext {\n getPreset: (\n presetName: string,\n config?: Record<string, unknown>,\n ) => SchemaTypeDefinition & FieldDefinition\n}\n\ntype ProhibitedProperties = 'type'\n\ntype SanitizeProperties<Properties, ExcludedProperties extends string | undefined> = [\n ExcludedProperties,\n] extends [PropertyKey]\n ? Omit<Properties, ExcludedProperties>\n : Properties\n\nexport type DerivedConfig<\n Context,\n AliasedType extends IntrinsicTypeName | undefined = undefined,\n LockedProperties extends string | undefined = undefined,\n> = Context &\n FieldDefinitionBase &\n (AliasedType extends string\n ? SanitizeProperties<\n PartialSchemaDefinition<AliasedType>,\n ProhibitedProperties | LockedProperties\n >\n : {}) & {\n map?: AliasedType extends string\n ? {\n [Key in keyof PartialSchemaDefinition<AliasedType>]?: (\n input: PartialSchemaDefinition<AliasedType>[Key],\n ) => PartialSchemaDefinition<AliasedType>[Key]\n }\n : {}\n }\n\n/**\n * The public-facing config shape that a registry's `define<Name>` function\n * accepts at the call site. Includes the full `DerivedConfig` with required\n * `name` (inherited from `FieldDefinitionBase`) and optional `map`.\n */\nexport type UserConfig<\n Context = {},\n AliasedType extends IntrinsicTypeName | undefined = undefined,\n LockedProperties extends string | undefined = undefined,\n> = DerivedConfig<Context, AliasedType, LockedProperties>\n\n/**\n * A preset definition describes how to produce a Sanity schema type.\n *\n * - `name` is the registry key for the preset (it determines the\n * `define<Name>` function and the `PresetsRegistryConfig` key).\n * - `identifier` is an optional stable identifier used for telemetry.\n * - `schemaType` is the factory that produces the Sanity schema type. It\n * receives the merged config (minus `map`) and the registry context, and\n * returns a `SchemaTypeDefinition`.\n */\nexport interface PresetDefinition<\n Context = {},\n AliasedType extends IntrinsicTypeName | undefined = undefined,\n LockedProperties extends string | undefined = undefined,\n> {\n name: string\n identifier?: string\n schemaType: (\n config: Omit<DerivedConfig<Context, AliasedType, LockedProperties>, 'map' | 'name'> & {\n name: string\n },\n registry: RegistryContext,\n ) => SchemaTypeDefinition\n}\n\n/**\n * A typed passthrough for defining a preset. Given a `PresetDefinition`, it\n * returns the same value, narrowed to its concrete generic parameters so\n * downstream code can infer the preset's config type from it.\n *\n * This is intentionally lightweight: it performs no work at call time. The\n * registry is responsible for invoking `schemaType` when a preset is\n * instantiated, and for applying `map` hooks to the produced schema type.\n */\nexport function definePresetType<\n Context = {},\n AliasedType extends IntrinsicTypeName | undefined = undefined,\n LockedProperties extends string | undefined = undefined,\n>(\n preset: PresetDefinition<Context, AliasedType, LockedProperties>,\n): PresetDefinition<Context, AliasedType, LockedProperties> {\n return preset\n}\n\n/**\n * A preset definition with its generic parameters erased, for use in code\n * that handles presets generically (e.g. the registry).\n */\nexport type AnyPresetDefinition = PresetDefinition<any, any, any>\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"],"mappings":";;;;;;;;AAMA,MAAaG,eAAeH,YAA8B;CACxDI,MAAM;CACNC,SAAS;CACTC,aAAa;AACf,CAAC,GCMKW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AAI,OAAOD,oBAAqB,YAAYA,mBACxCA,mBACA,CAAC;GACL,GAAGJ;EAG2BK,GAE1BG,aAAaxB,OAAOwB,WAExBD,eACAJ,eACF;EAKA,OAHAhC,kBAAkBuC,IAAInC,MAAMiC,UAAU,GAG/BG,cACLC,sBAAsBJ,YAAYxC,UAAU,GAC5CsC,GACF;CACF;AACF;AAEA,SAASK,cAAcH,YAAkCF,KAAoC;CAC3F,IAAI,CAACA,OAAO,OAAOA,OAAQ,UAAU,OAAOE;CAE5C,IAAMK,mBAA4C,CAAC;CAEnD,KAAK,IAAM,CAACC,YAAYC,gBAAgBC,OAAOC,QAAQX,GAAG,GACpD,OAAOS,eAAgB,eAI3BF,iBAAiBC,cAAcC,YAE7BP,WAAWM,WACb;CAGF,OAAO;EAAC,GAAGN;EAAY,GAAGK;CAAgB;AAC5C;AAEA,SAASD,sBACPJ,YACAxC,YACsB;CACtB,IAAMkD,WAAW,gBAAgBV,aAAaA,WAAWW,aAAaxC,KAAAA,GAChEyC,gBACJF,YAAY,WAAWA,YAAY,OAAOA,SAASG,SAAU,aAExDH,SAASG,QACV1C,KAAAA;CAEN,OAAO;EACL,GAAG6B;EACHW,YAAY;GACV,GAAGD;GACHG,QAAQC,UACN,oBAAC,2BAAD;IAA2B,GAAIA;IAAmBtD;IAAY,WAAWoD;GAAc,CAAA;EAE3F;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/presets",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Production ready preset patterns for Sanity Studio",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -32,19 +32,20 @@
|
|
|
32
32
|
"@sanity/uuid": "^3.0.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@sanity/
|
|
35
|
+
"@sanity/tsconfig": "^2.2.0",
|
|
36
|
+
"@sanity/tsdown-config": "^0.11.0",
|
|
36
37
|
"@testing-library/jest-dom": "^6.9.1",
|
|
37
38
|
"@testing-library/react": "^16.3.2",
|
|
38
39
|
"@types/node": "^24.13.2",
|
|
39
40
|
"@types/react": "^19.2.17",
|
|
40
41
|
"@types/react-dom": "^19.2.3",
|
|
42
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
41
43
|
"jsdom": "^29.1.1",
|
|
42
44
|
"react": "^19.2.7",
|
|
43
45
|
"react-dom": "^19.2.7",
|
|
44
|
-
"sanity": "^6.
|
|
45
|
-
"styled-components": "^6.4.
|
|
46
|
-
"
|
|
47
|
-
"@repo/tsconfig": "0.0.0"
|
|
46
|
+
"sanity": "^6.3.0",
|
|
47
|
+
"styled-components": "^6.4.3",
|
|
48
|
+
"tsdown": "^0.22.3"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"react": "^19.2",
|
|
@@ -55,6 +56,6 @@
|
|
|
55
56
|
"node": ">=20.19 <22 || >=22.12"
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
|
-
"build": "
|
|
59
|
+
"build": "tsdown"
|
|
59
60
|
}
|
|
60
61
|
}
|