sanity-plugin-hotspot-picker 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dennis Regalado
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # sanity-plugin-hotspot-picker
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Sanity Studio array input that places each item as a draggable spot on an image field: shoppable images, annotated diagrams, store maps.
4
+
5
+ - **Click the image** to add a spot where you clicked.
6
+ - **Drag a spot** to move it. Its position is stored as `x`/`y` percentages of the image.
7
+ - **Click a spot** to edit its item. Hover to see the item's preview.
8
+ - **Spots with validation errors** show a warning icon and turn red.
9
+ - **Crop-aware**: the preview uses the image field's crop, so positions match a cropped image on your frontend.
10
+ - The Studio's own array list stays under the image, so reordering, removing and editing work as usual.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install sanity-plugin-hotspot-picker
16
+ ```
17
+
18
+ **Requirements:** Sanity Studio 6. `@sanity/ui` (v4) and `@sanity/icons` (v5) are peer dependencies, and `sanity` already installs them, so there's nothing else to add.
19
+
20
+ ```ts
21
+ // sanity.config.ts
22
+ import {defineConfig} from 'sanity'
23
+ import {hotspotPicker} from 'sanity-plugin-hotspot-picker'
24
+
25
+ export default defineConfig({
26
+ // ...
27
+ plugins: [hotspotPicker()],
28
+ })
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Add `options.hotspotPicker` to an array of objects, next to the image field the spots sit on. Each item needs `x` and `y` number fields; `hotspotFields()` returns them, hidden and read-only.
34
+
35
+ ```ts
36
+ import {defineArrayMember, defineField, defineType} from 'sanity'
37
+ import {hotspotFields} from 'sanity-plugin-hotspot-picker'
38
+
39
+ export default defineType({
40
+ name: 'shoppableImage',
41
+ type: 'object',
42
+ fields: [
43
+ defineField({name: 'image', type: 'image', options: {hotspot: true}}),
44
+ defineField({
45
+ name: 'spots',
46
+ type: 'array',
47
+ options: {hotspotPicker: {imagePath: 'image'}},
48
+ of: [
49
+ defineArrayMember({
50
+ name: 'spot',
51
+ type: 'object',
52
+ title: 'Product',
53
+ fields: [
54
+ ...hotspotFields(),
55
+ defineField({
56
+ name: 'product',
57
+ type: 'reference',
58
+ to: [{type: 'product'}],
59
+ validation: (rule) => rule.required(),
60
+ }),
61
+ ],
62
+ preview: {select: {title: 'product.title', media: 'product.image'}},
63
+ }),
64
+ ],
65
+ }),
66
+ ],
67
+ })
68
+ ```
69
+
70
+ ### Options
71
+
72
+ Pass options to the plugin to set defaults for every field. A field's `options.hotspotPicker` overrides them (`hotspotPicker: true` uses the defaults).
73
+
74
+ | Option | Default | |
75
+ | ------------------ | --------- | ------------------------------------------------------------------------------------------ |
76
+ | `imagePath` | `'image'` | Field-level only. The image field, relative to the array's parent. Dots for nested fields. |
77
+ | `imageWidth` | `1200` | Width of the preview image requested from the Sanity CDN. |
78
+ | `icon` | Pin | Icon component on each spot. |
79
+ | `tooltipPlacement` | automatic | `(item) => Placement`: where a spot's preview opens, e.g. from a field on the item. |
80
+
81
+ Open the preview toward a placement stored on the item:
82
+
83
+ ```ts
84
+ hotspotPicker({
85
+ tooltipPlacement: (item) => {
86
+ const placement = item.placement as {vertical?: string; horizontal?: string} | undefined
87
+ if (placement?.vertical === 'top' && placement.horizontal === 'right') return 'top-start'
88
+ return undefined
89
+ },
90
+ })
91
+ ```
92
+
93
+ ### Without the plugin
94
+
95
+ Use the input on one field:
96
+
97
+ ```ts
98
+ import {HotspotPicker} from 'sanity-plugin-hotspot-picker'
99
+
100
+ defineField({
101
+ name: 'spots',
102
+ type: 'array',
103
+ options: {hotspotPicker: {imagePath: 'image'}},
104
+ components: {input: HotspotPicker},
105
+ of: [/* ... */],
106
+ })
107
+ ```
108
+
109
+ ## Stored value
110
+
111
+ ```ts
112
+ spots: [{_key: 'a1b2c3d4e5f6', _type: 'spot', x: 42.5, y: 61.25, product: {_ref: '…'}}]
113
+ ```
114
+
115
+ `x` and `y` are percentages (0–100, two decimals) from the image's top-left corner, measured on the cropped image.
116
+
117
+ ## GROQ
118
+
119
+ ```groq
120
+ *[_type == "page"][0]{
121
+ image,
122
+ spots[]{_key, x, y, "product": product->{title, slug}}
123
+ }
124
+ ```
125
+
126
+ Position each spot with `left: ${x}%; top: ${y}%` over an image rendered with the same crop.
127
+
128
+ ## License
129
+
130
+ MIT © Dennis Regalado
@@ -0,0 +1,157 @@
1
+ import {ArrayOfObjectsInputProps} from 'sanity'
2
+ import type {ArraySchemaType} from 'sanity'
3
+ import type {ComponentType} from 'react'
4
+ import {FieldDefinition} from 'sanity'
5
+ import type {ImageDefinition} from 'sanity'
6
+ import type {Placement} from '@sanity/ui'
7
+ import {Plugin as Plugin_2} from 'sanity'
8
+ import type {PreviewConfig} from 'sanity'
9
+ import {default as React_2} from 'react'
10
+ import {ReactNode} from 'react'
11
+ import type {ReferenceDefinition} from 'sanity'
12
+
13
+ /** Default name of the object type the plugin registers. */
14
+ export declare const DEFAULT_TYPE_NAME = 'hotspotImage'
15
+
16
+ export declare type HotspotArraySchemaType = Omit<ArraySchemaType, 'options'> & {
17
+ options?: ArraySchemaType['options'] & {
18
+ hotspotPicker?: HotspotPickerOptions | true
19
+ }
20
+ }
21
+
22
+ /**
23
+ * The hidden `x` and `y` fields a spot needs (percentages of the image, set by dragging).
24
+ * Spread them into the array member's `fields`.
25
+ */
26
+ export declare function hotspotFields(): FieldDefinition[]
27
+
28
+ /** The plugin's object type's value. */
29
+ export declare type HotspotImageValue<
30
+ Fields = {
31
+ [key: string]: unknown
32
+ },
33
+ > = {
34
+ _type?: string
35
+ image?: {
36
+ _type?: string
37
+ asset?: {
38
+ _ref: string
39
+ }
40
+ [key: string]: unknown
41
+ }
42
+ items?: HotspotItem<
43
+ Fields & {
44
+ reference?: {
45
+ _ref: string
46
+ _type?: string
47
+ }
48
+ }
49
+ >[]
50
+ }
51
+
52
+ /** One array item placed on the image. `x`/`y` are percentages (0–100) of the image. */
53
+ export declare type HotspotItem<
54
+ Fields = {
55
+ [key: string]: unknown
56
+ },
57
+ > = {
58
+ _key: string
59
+ _type: string
60
+ x?: number
61
+ y?: number
62
+ } & Fields
63
+
64
+ /**
65
+ * Use the input without the plugin, as a field's `components.input`. Set the field's
66
+ * `options.hotspotPicker` (or `true`) for its options.
67
+ */
68
+ export declare function HotspotPicker(props: ArrayOfObjectsInputProps): React_2.ReactElement
69
+
70
+ /**
71
+ * Registers the `hotspotImage` object type: an `image` and an array of `items`, each a draggable
72
+ * spot on the image with a `reference` and an `x`/`y` position. Also turns any array field with
73
+ * `options.hotspotPicker` into a spot picker.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * // sanity.config.ts
78
+ * plugins: [hotspotPicker({reference: {title: 'Product', to: [{type: 'product'}]}})]
79
+ *
80
+ * // schema
81
+ * defineField({name: 'shoppable', type: 'hotspotImage'})
82
+ * ```
83
+ */
84
+ export declare const hotspotPicker: Plugin_2<void | HotspotPickerPluginOptions>
85
+
86
+ /**
87
+ * Array input that places each item as a draggable spot on an image field. The list below the
88
+ * image is the Studio's own array input, so adding, reordering, removing and editing work as usual.
89
+ * Inside the plugin's object type, the object input shows the image instead (above this field).
90
+ */
91
+ export declare function HotspotPickerInput(
92
+ props: HotspotPickerInputProps & {
93
+ defaults?: HotspotPickerOptions
94
+ },
95
+ ): ReactNode
96
+
97
+ export declare type HotspotPickerInputProps = ArrayOfObjectsInputProps<
98
+ HotspotItem,
99
+ HotspotArraySchemaType
100
+ >
101
+
102
+ /** Options shared by the plugin and each field (a field's options win). */
103
+ export declare interface HotspotPickerOptions {
104
+ /**
105
+ * Field holding the image the spots sit on, relative to the array's parent object. Use dots for
106
+ * nested fields (`media.image`). Defaults to `image`.
107
+ */
108
+ imagePath?: string
109
+ /** Width of the preview image requested from the Sanity CDN. Defaults to `1200`. */
110
+ imageWidth?: number
111
+ /** Icon on each spot. Defaults to a pin. */
112
+ icon?: ComponentType
113
+ /** Where a spot's preview tooltip opens, from the item's value. Defaults to automatic. */
114
+ tooltipPlacement?: (item: HotspotItem) => Placement | undefined
115
+ }
116
+
117
+ /** Options for the plugin (argument to `hotspotPicker`). */
118
+ export declare interface HotspotPickerPluginOptions extends Omit<
119
+ HotspotPickerOptions,
120
+ 'imagePath'
121
+ > {
122
+ /** Name of the object type the plugin registers. Defaults to `hotspotImage`. */
123
+ name?: string
124
+ /** Title of the object type. Defaults to `Hotspot image`. */
125
+ title?: string
126
+ /** Overrides for the `image` field (`fields`, `options`, `title`...). Hotspot/crop is on. */
127
+ image?: Partial<Omit<ImageDefinition, 'name' | 'type'>>
128
+ /**
129
+ * Each item's `reference` field (`to` is required), e.g. `{title: 'Product', to: [{type:
130
+ * 'product'}]}`. Required by default. The spot's tooltip previews the referenced document.
131
+ * Leave out for items without a reference.
132
+ */
133
+ reference?: Omit<ReferenceDefinition, 'name' | 'type'>
134
+ /** The items in the `items` array. */
135
+ item?: {
136
+ /** Type name of each item. Defaults to `spot`. */
137
+ name?: string
138
+ /** Title of each item. Defaults to the reference's title, else `Spot`. */
139
+ title?: string
140
+ /** Title of the `items` field. Defaults to `Items`. */
141
+ listTitle?: string
142
+ icon?: ComponentType
143
+ /** Extra fields on each item, after `reference`. */
144
+ fields?: FieldDefinition[]
145
+ /** Preview of each item in the list. Defaults to the referenced document's `title`. */
146
+ preview?: PreviewConfig
147
+ }
148
+ }
149
+
150
+ export {}
151
+
152
+ declare module 'sanity' {
153
+ interface ArrayOptions {
154
+ /** Place this array's items as spots on an image. `true` uses the defaults. */
155
+ hotspotPicker?: HotspotPickerOptions | true
156
+ }
157
+ }
package/dist/index.js ADDED
@@ -0,0 +1,454 @@
1
+ import React, { useMemo, useState, useEffect, useRef, useCallback, createContext, useContext } from "react";
2
+ import { isReferenceSchemaType, useClient, usePerspective, SearchResultItemPreview, SanityDefaultPreview, setIfMissing, insert, set, useFormCallbacks, PatchEvent, useFormValue, defineField, defineType, defineArrayMember, definePlugin, isArrayOfObjectsSchemaType } from "sanity";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Button, Box, Card, Stack, Text, Flex } from "@sanity/ui";
5
+ import { getImageDimensions } from "@sanity/asset-utils";
6
+ import { createImageUrlBuilder } from "@sanity/image-url";
7
+ import { PinIcon } from "@sanity/icons/Pin";
8
+ import { WarningOutlineIcon } from "@sanity/icons/WarningOutline";
9
+ import { Popover } from "@sanity/ui/popover";
10
+ import { usePaneRouter } from "sanity/structure";
11
+ import { EditIcon } from "@sanity/icons/Edit";
12
+ import { Tooltip } from "@sanity/ui/tooltip";
13
+ function useReferenceTarget(value, schemaType) {
14
+ const field = useMemo(
15
+ () => schemaType.fields.find((f) => f.name === "reference" && isReferenceSchemaType(f.type)) ?? schemaType.fields.find((f) => isReferenceSchemaType(f.type)),
16
+ [schemaType]
17
+ ), refType = field?.type, documentId = field ? value[field.name]?._ref : void 0, singleType = refType?.to.length === 1 ? refType.to[0] : void 0, client = useClient({ apiVersion: "2025-01-01" }), [fetched, setFetched] = useState(null);
18
+ useEffect(() => {
19
+ if (!documentId || singleType) return;
20
+ const subscription = client.observable.fetch('*[_id in [$id, "drafts." + $id]][0]._type', { id: documentId }).subscribe((type) => setFetched({ id: documentId, type }));
21
+ return () => subscription.unsubscribe();
22
+ }, [client, documentId, singleType]);
23
+ const fetchedType = fetched && fetched.id === documentId ? fetched.type : null, toType = singleType ?? refType?.to.find((t) => t.name === fetchedType);
24
+ return { fieldName: field?.name, documentId, toType };
25
+ }
26
+ function useReferencePaneOpen(target) {
27
+ const { routerPanesState, groupIndex } = usePaneRouter(), { documentId, toType } = target;
28
+ if (!documentId || !toType) return !1;
29
+ const nextPaneGroup = Array.isArray(routerPanesState) ? routerPanesState[groupIndex + 1] : null;
30
+ let siblings = [];
31
+ return Array.isArray(nextPaneGroup) ? siblings = nextPaneGroup : nextPaneGroup && (siblings = [nextPaneGroup]), siblings.some((sibling) => {
32
+ const pane = sibling, id = pane.id || pane.params?.id || pane.payload?.id, type = pane.params?.type || pane.payload?.type;
33
+ return id === documentId && (!type || type === toType.name);
34
+ });
35
+ }
36
+ function SpotPreview(props) {
37
+ const { value, itemPath, schemaType, renderPreview, target, referencePaneOpen } = props, perspective = usePerspective(), { ReferenceChildLink } = usePaneRouter(), { fieldName, documentId, toType } = target;
38
+ let preview;
39
+ return documentId && toType && fieldName ? preview = /* @__PURE__ */ jsx(
40
+ ReferenceChildLink,
41
+ {
42
+ documentId,
43
+ documentType: toType.name,
44
+ parentRefPath: [...itemPath, fieldName],
45
+ children: /* @__PURE__ */ jsx(
46
+ Button,
47
+ {
48
+ as: "span",
49
+ mode: referencePaneOpen ? "default" : "bleed",
50
+ tone: referencePaneOpen ? "primary" : "default",
51
+ padding: 0,
52
+ width: "fill",
53
+ style: { clipPath: "inset(3px round 2px)" },
54
+ children: /* @__PURE__ */ jsx(
55
+ SearchResultItemPreview,
56
+ {
57
+ documentId,
58
+ documentType: toType.name,
59
+ layout: "compact",
60
+ perspective: perspective.perspectiveStack,
61
+ schemaType: toType,
62
+ showBadge: !1
63
+ }
64
+ )
65
+ }
66
+ )
67
+ }
68
+ ) : documentId ? preview = /* @__PURE__ */ jsx(SanityDefaultPreview, { isPlaceholder: !0, layout: "compact" }) : preview = renderPreview({ value, schemaType, layout: "compact" }), /* @__PURE__ */ jsx(Box, { style: { minWidth: 240 }, children: preview });
69
+ }
70
+ const ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789";
71
+ function randomKey(length = 12) {
72
+ const bytes = crypto.getRandomValues(new Uint8Array(length));
73
+ return Array.from(bytes, (byte) => ALPHABET[byte % ALPHABET.length]).join("");
74
+ }
75
+ function toPercent(value) {
76
+ return Math.round(Math.min(100, Math.max(0, value)) * 100) / 100;
77
+ }
78
+ function resolveImagePath(arrayPath, imagePath) {
79
+ return [...arrayPath.slice(0, -1), ...imagePath.split(".").filter(Boolean)];
80
+ }
81
+ const DRAG_THRESHOLD = 3, CLOSE_DELAY = 150;
82
+ function Spot(props) {
83
+ const { value, frameRef, schemaType, renderPreview, invalid, readOnly, icon, placement } = props, { itemPath, onMove, onOpen } = props, [hovered, setHovered] = useState(!1), closeTimer = useRef(null), cancelClose = useCallback(() => {
84
+ closeTimer.current && clearTimeout(closeTimer.current), closeTimer.current = null;
85
+ }, []), handleEnter = useCallback(() => {
86
+ cancelClose(), setHovered(!0);
87
+ }, [cancelClose]), handleLeave = useCallback(() => {
88
+ cancelClose(), closeTimer.current = setTimeout(() => setHovered(!1), CLOSE_DELAY);
89
+ }, [cancelClose]);
90
+ useEffect(() => cancelClose, [cancelClose]);
91
+ const target = useReferenceTarget(value, schemaType), referencePaneOpen = useReferencePaneOpen(target), [dragPosition, setDragPosition] = useState(null), start = useRef(null), positionFromEvent = useCallback(
92
+ (event) => {
93
+ const rect = frameRef.current?.getBoundingClientRect();
94
+ return !rect?.width || !rect.height ? null : {
95
+ x: toPercent((event.clientX - rect.left) / rect.width * 100),
96
+ y: toPercent((event.clientY - rect.top) / rect.height * 100)
97
+ };
98
+ },
99
+ [frameRef]
100
+ ), handlePointerDown = useCallback(
101
+ (event) => {
102
+ readOnly || event.button !== 0 || (event.currentTarget.setPointerCapture(event.pointerId), start.current = { x: event.clientX, y: event.clientY });
103
+ },
104
+ [readOnly]
105
+ ), handlePointerMove = useCallback(
106
+ (event) => {
107
+ if (!start.current) return;
108
+ const moved = Math.hypot(event.clientX - start.current.x, event.clientY - start.current.y);
109
+ if (!dragPosition && moved < DRAG_THRESHOLD) return;
110
+ const next = positionFromEvent(event);
111
+ next && setDragPosition(next);
112
+ },
113
+ [dragPosition, positionFromEvent]
114
+ ), handlePointerUp = useCallback(
115
+ (event) => {
116
+ start.current && (start.current = null, dragPosition ? (onMove(value._key, dragPosition.x, dragPosition.y), setDragPosition(null)) : onOpen(value._key), event.currentTarget.releasePointerCapture(event.pointerId));
117
+ },
118
+ [dragPosition, onMove, onOpen, value._key]
119
+ ), handlePointerCancel = useCallback(() => {
120
+ start.current = null, setDragPosition(null);
121
+ }, []), handleKeyboardClick = useCallback(
122
+ (event) => {
123
+ event.detail === 0 && onOpen(value._key);
124
+ },
125
+ [onOpen, value._key]
126
+ ), x = dragPosition?.x ?? value.x ?? 50, y = dragPosition?.y ?? value.y ?? 50, dragging = dragPosition !== null;
127
+ let cursor = "grab";
128
+ return readOnly ? cursor = "pointer" : dragging && (cursor = "grabbing"), /* @__PURE__ */ jsx("div", { style: { position: "absolute", left: `${x}%`, top: `${y}%`, zIndex: dragging ? 1 : 0 }, children: /* @__PURE__ */ jsx(
129
+ Popover,
130
+ {
131
+ open: !dragging && (hovered || referencePaneOpen),
132
+ portal: !0,
133
+ animate: !0,
134
+ radius: 2,
135
+ shadow: 2,
136
+ placement: placement ?? "top",
137
+ fallbackPlacements: ["bottom", "right", "left"],
138
+ content: /* @__PURE__ */ jsx("div", { onMouseEnter: handleEnter, onMouseLeave: handleLeave, style: { padding: 4 }, children: /* @__PURE__ */ jsx(
139
+ SpotPreview,
140
+ {
141
+ value,
142
+ itemPath,
143
+ schemaType,
144
+ renderPreview,
145
+ target,
146
+ referencePaneOpen
147
+ }
148
+ ) }),
149
+ children: /* @__PURE__ */ jsx(
150
+ Button,
151
+ {
152
+ onClick: handleKeyboardClick,
153
+ onMouseEnter: handleEnter,
154
+ onMouseLeave: handleLeave,
155
+ onPointerDown: handlePointerDown,
156
+ onPointerMove: handlePointerMove,
157
+ onPointerUp: handlePointerUp,
158
+ onPointerCancel: handlePointerCancel,
159
+ "aria-label": `Edit ${schemaType.title ?? "spot"}`,
160
+ style: {
161
+ position: "absolute",
162
+ transform: "translate(-50%, -50%)",
163
+ cursor,
164
+ touchAction: "none"
165
+ },
166
+ padding: 2,
167
+ icon: invalid ? WarningOutlineIcon : icon ?? PinIcon,
168
+ mode: "ghost",
169
+ tone: invalid ? "critical" : "default"
170
+ }
171
+ )
172
+ }
173
+ ) });
174
+ }
175
+ const DEFAULT_IMAGE_WIDTH = 1200;
176
+ function useImagePreview(image, width = DEFAULT_IMAGE_WIDTH) {
177
+ const client = useClient({ apiVersion: "2025-01-01" });
178
+ return useMemo(() => {
179
+ const ref = image?.asset?._ref;
180
+ if (!ref) return null;
181
+ const dimensions = getImageDimensions(ref), crop = image.crop, croppedWidth = dimensions.width * (1 - (crop?.left ?? 0) - (crop?.right ?? 0)), croppedHeight = dimensions.height * (1 - (crop?.top ?? 0) - (crop?.bottom ?? 0));
182
+ return {
183
+ url: createImageUrlBuilder(client).image(image).width(width).url(),
184
+ aspectRatio: croppedWidth / croppedHeight
185
+ };
186
+ }, [image, client, width]);
187
+ }
188
+ function HotspotFrame(props) {
189
+ const { image, items, arrayPath, itemType, invalidKeys, readOnly, options, renderPreview } = props, { onPatch, onOpen } = props, preview = useImagePreview(image, options.imageWidth), frameRef = useRef(null), handleImageClick = useCallback(
190
+ (event) => {
191
+ if (readOnly || event.target !== event.currentTarget) return;
192
+ const rect = event.currentTarget.getBoundingClientRect(), item = {
193
+ _key: randomKey(),
194
+ _type: itemType.name,
195
+ x: toPercent((event.clientX - rect.left) / rect.width * 100),
196
+ y: toPercent((event.clientY - rect.top) / rect.height * 100)
197
+ };
198
+ onPatch([setIfMissing([]), insert([item], "after", [-1])]);
199
+ },
200
+ [readOnly, onPatch, itemType.name]
201
+ ), handleMove = useCallback(
202
+ (key, x, y) => {
203
+ onPatch([set(x, [{ _key: key }, "x"]), set(y, [{ _key: key }, "y"])]);
204
+ },
205
+ [onPatch]
206
+ );
207
+ return preview ? /* @__PURE__ */ jsx(Card, { border: !0, radius: 2, overflow: "hidden", children: /* @__PURE__ */ jsx(
208
+ "div",
209
+ {
210
+ ref: frameRef,
211
+ onClick: handleImageClick,
212
+ style: {
213
+ position: "relative",
214
+ aspectRatio: preview.aspectRatio,
215
+ backgroundImage: `url(${preview.url})`,
216
+ backgroundSize: "100% 100%",
217
+ cursor: readOnly ? "default" : "crosshair"
218
+ },
219
+ children: items?.map((spot) => /* @__PURE__ */ jsx(
220
+ Spot,
221
+ {
222
+ value: spot,
223
+ itemPath: [...arrayPath, { _key: spot._key }],
224
+ frameRef,
225
+ schemaType: itemType,
226
+ renderPreview,
227
+ invalid: invalidKeys.has(spot._key),
228
+ readOnly,
229
+ icon: options.icon,
230
+ placement: options.tooltipPlacement?.(spot),
231
+ onMove: handleMove,
232
+ onOpen
233
+ },
234
+ spot._key
235
+ ))
236
+ }
237
+ ) }) : null;
238
+ }
239
+ const HotspotObjectContext = createContext(null), NO_MEMBERS = [];
240
+ function HotspotObjectInput(props) {
241
+ const { path, onChange, renderPreview, readOnly, defaults } = props, value = props.value, hasImage = !!value?.image?.asset?._ref, [isEditing, setIsEditing] = useState(!1), editing = isEditing || !hasImage, handleEditToggle = useCallback(() => setIsEditing((current) => !current), []), context = useMemo(() => ({ editing }), [editing]), itemsMember = props.members.find(
242
+ (member) => member.kind === "field" && member.name === "items"
243
+ ), itemsField = itemsMember?.kind === "field" ? itemsMember.field : void 0, invalidKeys = useInvalidKeys(itemsField?.members ?? NO_MEMBERS), itemType = props.schemaType.fields.find((field) => field.name === "items")?.type?.of[0], arrayPath = useMemo(() => [...path, "items"], [path]), { onPathOpen } = useFormCallbacks(), handlePatch = useCallback(
244
+ (patches) => onChange(PatchEvent.from(patches).prefixAll("items")),
245
+ [onChange]
246
+ ), openItem = useCallback(
247
+ (key) => onPathOpen([...arrayPath, { _key: key }]),
248
+ [onPathOpen, arrayPath]
249
+ ), parentRenderInput = props.renderInput, renderInput = useCallback(
250
+ (inputProps) => {
251
+ const isImage = inputProps.path.length === path.length + 1 && inputProps.path[path.length] === "image";
252
+ return editing || !isImage || !itemType ? parentRenderInput(inputProps) : /* @__PURE__ */ jsx(
253
+ HotspotFrame,
254
+ {
255
+ image: value?.image,
256
+ items: value?.items,
257
+ arrayPath,
258
+ itemType,
259
+ invalidKeys,
260
+ readOnly,
261
+ options: defaults ?? {},
262
+ renderPreview,
263
+ onPatch: handlePatch,
264
+ onOpen: openItem
265
+ }
266
+ );
267
+ },
268
+ [
269
+ editing,
270
+ path,
271
+ itemType,
272
+ parentRenderInput,
273
+ value,
274
+ arrayPath,
275
+ invalidKeys,
276
+ readOnly,
277
+ defaults,
278
+ renderPreview,
279
+ handlePatch,
280
+ openItem
281
+ ]
282
+ );
283
+ return /* @__PURE__ */ jsx(HotspotObjectContext.Provider, { value: context, children: /* @__PURE__ */ jsxs(Stack, { gap: 5, children: [
284
+ hasImage && /* @__PURE__ */ jsx(Box, { style: { position: "absolute", top: 0, right: 0 }, children: /* @__PURE__ */ jsx(
285
+ Tooltip,
286
+ {
287
+ animate: !0,
288
+ delay: 5,
289
+ placement: "top",
290
+ content: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: "Edit image" }),
291
+ portal: !0,
292
+ children: /* @__PURE__ */ jsx(
293
+ Button,
294
+ {
295
+ mode: "bleed",
296
+ icon: EditIcon,
297
+ padding: 2,
298
+ onClick: handleEditToggle,
299
+ selected: isEditing,
300
+ "aria-label": "Edit image"
301
+ }
302
+ )
303
+ }
304
+ ) }),
305
+ props.renderDefault({ ...props, renderInput })
306
+ ] }) });
307
+ }
308
+ function useInvalidKeys(members) {
309
+ return useMemo(() => {
310
+ const keys = /* @__PURE__ */ new Set();
311
+ for (const member of members)
312
+ member.kind === "item" && member.item.validation.some((v) => v.level === "error") && keys.add(member.key);
313
+ return keys;
314
+ }, [members]);
315
+ }
316
+ function useHotspotOptions(props, defaults) {
317
+ const fieldOptions = props.schemaType.options?.hotspotPicker;
318
+ return {
319
+ ...defaults,
320
+ ...typeof fieldOptions == "object" ? fieldOptions : {},
321
+ imagePath: typeof fieldOptions == "object" && fieldOptions.imagePath || defaults?.imagePath || "image",
322
+ imageWidth: typeof fieldOptions == "object" && fieldOptions.imageWidth || defaults?.imageWidth || DEFAULT_IMAGE_WIDTH
323
+ };
324
+ }
325
+ function HotspotPickerInput(props) {
326
+ return useContext(HotspotObjectContext) ? props.renderDefault(props) : /* @__PURE__ */ jsx(StandaloneHotspotPicker, { ...props });
327
+ }
328
+ function StandaloneHotspotPicker(props) {
329
+ const { value, onChange, schemaType, renderPreview, path, onItemOpen, members, readOnly } = props, options = useHotspotOptions(props, props.defaults), itemType = schemaType.of[0], imagePath = useMemo(
330
+ () => resolveImagePath(path, options.imagePath),
331
+ [path, options.imagePath]
332
+ ), image = useFormValue(imagePath), invalidKeys = useInvalidKeys(members), handlePatch = useCallback(
333
+ (patches) => onChange(PatchEvent.from(patches)),
334
+ [onChange]
335
+ ), openItem = useCallback(
336
+ (key) => onItemOpen([...path, { _key: key }]),
337
+ [onItemOpen, path]
338
+ );
339
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
340
+ image?.asset?._ref ? /* @__PURE__ */ jsx(
341
+ HotspotFrame,
342
+ {
343
+ image,
344
+ items: value,
345
+ arrayPath: path,
346
+ itemType,
347
+ invalidKeys,
348
+ readOnly,
349
+ options,
350
+ renderPreview,
351
+ onPatch: handlePatch,
352
+ onOpen: openItem
353
+ }
354
+ ) : /* @__PURE__ */ jsx(Card, { padding: 3, radius: 2, tone: "caution", border: !0, children: /* @__PURE__ */ jsx(Text, { size: 1, children: "Add an image first to place spots on it." }) }),
355
+ props.renderDefault(props)
356
+ ] });
357
+ }
358
+ function ImageField(props) {
359
+ return React.createElement(React.Fragment, null, props.children);
360
+ }
361
+ const DEFAULT_TYPE_NAME = "hotspotImage";
362
+ function hotspotFields() {
363
+ const coordinate = (name) => defineField({
364
+ name,
365
+ type: "number",
366
+ readOnly: !0,
367
+ hidden: !0,
368
+ initialValue: 50,
369
+ validation: (rule) => rule.required().min(0).max(100)
370
+ });
371
+ return [coordinate("x"), coordinate("y")];
372
+ }
373
+ function createHotspotType(options = {}) {
374
+ const { reference, image, item } = options, referenceField = reference ? [
375
+ defineField({
376
+ title: "Reference",
377
+ validation: (rule) => rule.required(),
378
+ ...reference,
379
+ name: "reference",
380
+ type: "reference"
381
+ })
382
+ ] : [];
383
+ return defineType({
384
+ name: options.name ?? DEFAULT_TYPE_NAME,
385
+ title: options.title ?? "Hotspot image",
386
+ type: "object",
387
+ components: {
388
+ input: (props) => React.createElement(HotspotObjectInput, { ...props, defaults: options })
389
+ },
390
+ fields: [
391
+ defineField({
392
+ options: { hotspot: !0 },
393
+ ...image,
394
+ // Just the input: the object field's own title stands for it, like the search listing.
395
+ components: { field: ImageField, ...image?.components },
396
+ name: "image",
397
+ title: image?.title ?? "Image",
398
+ type: "image"
399
+ }),
400
+ defineField({
401
+ name: "items",
402
+ title: item?.listTitle ?? "Items",
403
+ type: "array",
404
+ options: { hotspotPicker: !0 },
405
+ of: [
406
+ defineArrayMember({
407
+ name: item?.name ?? "spot",
408
+ title: item?.title ?? reference?.title ?? "Spot",
409
+ type: "object",
410
+ icon: item?.icon,
411
+ fields: [...referenceField, ...item?.fields ?? [], ...hotspotFields()],
412
+ preview: item?.preview ?? {
413
+ select: { title: "reference.title" },
414
+ prepare: ({ title }) => ({ title: title || "Untitled" })
415
+ }
416
+ })
417
+ ]
418
+ })
419
+ ],
420
+ preview: {
421
+ select: { media: "image", items: "items" },
422
+ prepare: ({ media, items }) => {
423
+ const count = items?.length ?? 0;
424
+ return { title: count === 1 ? "1 item" : `${count} items`, media };
425
+ }
426
+ }
427
+ });
428
+ }
429
+ const hotspotPicker = definePlugin((options) => {
430
+ const defaults = options ?? void 0;
431
+ return {
432
+ name: "hotspot-picker",
433
+ schema: { types: [createHotspotType(defaults)] },
434
+ form: {
435
+ components: {
436
+ input: (props) => isArrayOfObjectsSchemaType(props.schemaType) && props.schemaType.options?.hotspotPicker ? React.createElement(HotspotPickerInput, {
437
+ ...props,
438
+ defaults
439
+ }) : props.renderDefault(props)
440
+ }
441
+ }
442
+ };
443
+ });
444
+ function HotspotPicker(props) {
445
+ return React.createElement(HotspotPickerInput, props);
446
+ }
447
+ export {
448
+ DEFAULT_TYPE_NAME,
449
+ HotspotPicker,
450
+ HotspotPickerInput,
451
+ hotspotFields,
452
+ hotspotPicker
453
+ };
454
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/SpotPreview.tsx","../src/utils.ts","../src/Spot.tsx","../src/HotspotFrame.tsx","../src/HotspotObjectInput.tsx","../src/HotspotPickerInput.tsx","../src/schema.ts","../src/index.ts"],"sourcesContent":["import {Box, Button} from '@sanity/ui'\nimport {type ReactNode, useEffect, useMemo, useState} from 'react'\nimport {\n isReferenceSchemaType,\n type ObjectSchemaType,\n type Path,\n type ReferenceSchemaType,\n type RenderPreviewCallback,\n SanityDefaultPreview,\n type SchemaType,\n SearchResultItemPreview,\n useClient,\n usePerspective,\n} from 'sanity'\nimport {usePaneRouter} from 'sanity/structure'\n\nimport type {HotspotItem} from './types'\n\nexport interface ReferenceTarget {\n /** Name of the item's reference field. */\n fieldName?: string\n documentId?: string\n toType?: SchemaType\n}\n\n/** The item's `reference` field (else its first reference field) and the document it points at. */\nexport function useReferenceTarget(\n value: HotspotItem,\n schemaType: ObjectSchemaType,\n): ReferenceTarget {\n const field = useMemo(\n () =>\n schemaType.fields.find((f) => f.name === 'reference' && isReferenceSchemaType(f.type)) ??\n schemaType.fields.find((f) => isReferenceSchemaType(f.type)),\n [schemaType],\n )\n const refType = field?.type as ReferenceSchemaType | undefined\n const documentId = field ? (value[field.name] as {_ref?: string} | undefined)?._ref : undefined\n const singleType = refType?.to.length === 1 ? refType.to[0] : undefined\n\n // With several allowed types, look up which one the document is.\n const client = useClient({apiVersion: '2025-01-01'})\n const [fetched, setFetched] = useState<{id: string; type: string | null} | null>(null)\n useEffect(() => {\n if (!documentId || singleType) return undefined\n const subscription = client.observable\n .fetch<string | null>(`*[_id in [$id, \"drafts.\" + $id]][0]._type`, {id: documentId})\n .subscribe((type) => setFetched({id: documentId, type}))\n return () => subscription.unsubscribe()\n }, [client, documentId, singleType])\n const fetchedType = fetched && fetched.id === documentId ? fetched.type : null\n\n const toType = singleType ?? refType?.to.find((t) => t.name === fetchedType)\n return {fieldName: field?.name, documentId, toType}\n}\n\n/** Whether the referenced document is open in the pane next to this one (as link-picker checks). */\nexport function useReferencePaneOpen(target: ReferenceTarget): boolean {\n const {routerPanesState, groupIndex} = usePaneRouter()\n const {documentId, toType} = target\n if (!documentId || !toType) return false\n const nextPaneGroup = Array.isArray(routerPanesState) ? routerPanesState[groupIndex + 1] : null\n let siblings: unknown[] = []\n if (Array.isArray(nextPaneGroup)) siblings = nextPaneGroup\n else if (nextPaneGroup) siblings = [nextPaneGroup]\n return siblings.some((sibling) => {\n const pane = sibling as {\n id?: string\n params?: {id?: string; type?: string}\n payload?: {id?: string; type?: string}\n }\n const id = pane.id || pane.params?.id || pane.payload?.id\n const type = pane.params?.type || pane.payload?.type\n return id === documentId && (!type || type === toType.name)\n })\n}\n\nexport interface SpotPreviewProps {\n value: HotspotItem\n itemPath: Path\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n target: ReferenceTarget\n referencePaneOpen: boolean\n}\n\n/**\n * A spot's popover. Like the Studio's reference inputs, it previews the item's referenced document\n * (compact, with its draft/published status) and opens it in the next pane. Items without a\n * reference show their own preview.\n */\nexport function SpotPreview(props: SpotPreviewProps): ReactNode {\n const {value, itemPath, schemaType, renderPreview, target, referencePaneOpen} = props\n const perspective = usePerspective()\n const {ReferenceChildLink} = usePaneRouter()\n const {fieldName, documentId, toType} = target\n\n let preview: ReactNode\n if (documentId && toType && fieldName) {\n preview = (\n <ReferenceChildLink\n documentId={documentId}\n documentType={toType.name}\n parentRefPath={[...itemPath, fieldName]}\n >\n <Button\n as=\"span\"\n mode={referencePaneOpen ? 'default' : 'bleed'}\n tone={referencePaneOpen ? 'primary' : 'default'}\n padding={0}\n width=\"fill\"\n style={{clipPath: 'inset(3px round 2px)'}}\n >\n <SearchResultItemPreview\n documentId={documentId}\n documentType={toType.name}\n layout=\"compact\"\n perspective={perspective.perspectiveStack}\n schemaType={toType}\n showBadge={false}\n />\n </Button>\n </ReferenceChildLink>\n )\n } else if (documentId) {\n preview = <SanityDefaultPreview isPlaceholder layout=\"compact\" />\n } else {\n preview = renderPreview({value, schemaType, layout: 'compact'})\n }\n\n return <Box style={{minWidth: 240}}>{preview}</Box>\n}\n","import type {Path} from 'sanity'\n\nconst ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'\n\n/** A random `_key`, like Sanity's own. */\nexport function randomKey(length = 12): string {\n const bytes = crypto.getRandomValues(new Uint8Array(length))\n return Array.from(bytes, (byte) => ALPHABET[byte % ALPHABET.length]).join('')\n}\n\n/** Clamp to 0–100 and round to two decimals. */\nexport function toPercent(value: number): number {\n return Math.round(Math.min(100, Math.max(0, value)) * 100) / 100\n}\n\n/** The image field's path: the array's parent plus `imagePath` (dots for nesting). */\nexport function resolveImagePath(arrayPath: Path, imagePath: string): Path {\n return [...arrayPath.slice(0, -1), ...imagePath.split('.').filter(Boolean)]\n}\n","import {PinIcon} from '@sanity/icons/Pin'\nimport {WarningOutlineIcon} from '@sanity/icons/WarningOutline'\nimport {Button, type Placement} from '@sanity/ui'\nimport {Popover} from '@sanity/ui/popover'\nimport {\n type ComponentType,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type RefObject,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react'\nimport type {ObjectSchemaType, Path, RenderPreviewCallback} from 'sanity'\n\nimport {SpotPreview, useReferencePaneOpen, useReferenceTarget} from './SpotPreview'\nimport type {HotspotItem} from './types'\nimport {toPercent} from './utils'\n\n/** Pointer travel (px) before a press counts as a drag rather than a click. */\nconst DRAG_THRESHOLD = 3\n\n/** Delay (ms) before the popover closes, so the pointer can cross from the spot onto it. */\nconst CLOSE_DELAY = 150\n\nexport interface SpotProps {\n value: HotspotItem\n /** Path of this item, for opening its reference. */\n itemPath: Path\n frameRef: RefObject<HTMLDivElement | null>\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n invalid: boolean\n readOnly?: boolean\n icon?: ComponentType\n placement?: Placement\n onMove: (key: string, x: number, y: number) => void\n onOpen: (key: string) => void\n}\n\n/** A draggable marker. Drag to move it, click to open the item. */\nexport function Spot(props: SpotProps): ReactNode {\n const {value, frameRef, schemaType, renderPreview, invalid, readOnly, icon, placement} = props\n const {itemPath, onMove, onOpen} = props\n\n // Open while the pointer is over the spot or its popover, and while its reference is open.\n const [hovered, setHovered] = useState(false)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n const cancelClose = useCallback(() => {\n if (closeTimer.current) clearTimeout(closeTimer.current)\n closeTimer.current = null\n }, [])\n const handleEnter = useCallback(() => {\n cancelClose()\n setHovered(true)\n }, [cancelClose])\n const handleLeave = useCallback(() => {\n cancelClose()\n closeTimer.current = setTimeout(() => setHovered(false), CLOSE_DELAY)\n }, [cancelClose])\n useEffect(() => cancelClose, [cancelClose])\n const target = useReferenceTarget(value, schemaType)\n const referencePaneOpen = useReferencePaneOpen(target)\n\n // Local position while dragging; the stored value is only patched on release.\n const [dragPosition, setDragPosition] = useState<{x: number; y: number} | null>(null)\n const start = useRef<{x: number; y: number} | null>(null)\n\n const positionFromEvent = useCallback(\n (event: PointerEvent) => {\n const rect = frameRef.current?.getBoundingClientRect()\n if (!rect?.width || !rect.height) return null\n return {\n x: toPercent(((event.clientX - rect.left) / rect.width) * 100),\n y: toPercent(((event.clientY - rect.top) / rect.height) * 100),\n }\n },\n [frameRef],\n )\n\n const handlePointerDown = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (readOnly || event.button !== 0) return\n event.currentTarget.setPointerCapture(event.pointerId)\n start.current = {x: event.clientX, y: event.clientY}\n },\n [readOnly],\n )\n\n const handlePointerMove = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (!start.current) return\n const moved = Math.hypot(event.clientX - start.current.x, event.clientY - start.current.y)\n if (!dragPosition && moved < DRAG_THRESHOLD) return\n const next = positionFromEvent(event)\n if (next) setDragPosition(next)\n },\n [dragPosition, positionFromEvent],\n )\n\n const handlePointerUp = useCallback(\n (event: PointerEvent<HTMLButtonElement>) => {\n if (!start.current) return\n start.current = null\n if (dragPosition) {\n onMove(value._key, dragPosition.x, dragPosition.y)\n setDragPosition(null)\n } else {\n onOpen(value._key)\n }\n event.currentTarget.releasePointerCapture(event.pointerId)\n },\n [dragPosition, onMove, onOpen, value._key],\n )\n\n const handlePointerCancel = useCallback(() => {\n start.current = null\n setDragPosition(null)\n }, [])\n\n // Pointer clicks open from `pointerup`; Enter/Space fire a click with `detail` 0.\n const handleKeyboardClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (event.detail === 0) onOpen(value._key)\n },\n [onOpen, value._key],\n )\n\n const x = dragPosition?.x ?? value.x ?? 50\n const y = dragPosition?.y ?? value.y ?? 50\n const dragging = dragPosition !== null\n let cursor = 'grab'\n if (readOnly) cursor = 'pointer'\n else if (dragging) cursor = 'grabbing'\n\n return (\n <div style={{position: 'absolute', left: `${x}%`, top: `${y}%`, zIndex: dragging ? 1 : 0}}>\n <Popover\n open={!dragging && (hovered || referencePaneOpen)}\n portal\n animate\n radius={2}\n shadow={2}\n placement={placement ?? 'top'}\n fallbackPlacements={['bottom', 'right', 'left']}\n content={\n <div onMouseEnter={handleEnter} onMouseLeave={handleLeave} style={{padding: 4}}>\n <SpotPreview\n value={value}\n itemPath={itemPath}\n schemaType={schemaType}\n renderPreview={renderPreview}\n target={target}\n referencePaneOpen={referencePaneOpen}\n />\n </div>\n }\n >\n <Button\n onClick={handleKeyboardClick}\n onMouseEnter={handleEnter}\n onMouseLeave={handleLeave}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerCancel}\n aria-label={`Edit ${schemaType.title ?? 'spot'}`}\n style={{\n position: 'absolute',\n transform: 'translate(-50%, -50%)',\n cursor,\n touchAction: 'none',\n }}\n padding={2}\n icon={invalid ? WarningOutlineIcon : (icon ?? PinIcon)}\n mode=\"ghost\"\n tone={invalid ? 'critical' : 'default'}\n />\n </Popover>\n </div>\n )\n}\n","import {getImageDimensions} from '@sanity/asset-utils'\nimport {createImageUrlBuilder} from '@sanity/image-url'\nimport {Card} from '@sanity/ui'\nimport {type MouseEvent, type ReactNode, useCallback, useMemo, useRef} from 'react'\nimport {\n type FormPatch,\n type ImageValue,\n insert,\n type ObjectSchemaType,\n type Path,\n type RenderPreviewCallback,\n set,\n setIfMissing,\n useClient,\n} from 'sanity'\n\nimport {Spot} from './Spot'\nimport type {HotspotItem, HotspotPickerOptions} from './types'\nimport {randomKey, toPercent} from './utils'\n\nexport const DEFAULT_IMAGE_WIDTH = 1200\n\nexport interface HotspotFrameProps {\n image: ImageValue | undefined\n items: HotspotItem[] | undefined\n /** Path of the items array, for opening items and their references. */\n arrayPath: Path\n itemType: ObjectSchemaType\n invalidKeys: Set<string>\n readOnly?: boolean\n options: HotspotPickerOptions\n renderPreview: RenderPreviewCallback\n /** Patches relative to the items array. */\n onPatch: (patches: FormPatch[]) => void\n onOpen: (key: string) => void\n}\n\n/** The preview image's URL and its (cropped) aspect ratio, or `null` without an image. */\nexport function useImagePreview(\n image: ImageValue | undefined,\n width = DEFAULT_IMAGE_WIDTH,\n): {url: string; aspectRatio: number} | null {\n const client = useClient({apiVersion: '2025-01-01'})\n return useMemo(() => {\n const ref = image?.asset?._ref\n if (!ref) return null\n const dimensions = getImageDimensions(ref)\n const crop = image.crop\n const croppedWidth = dimensions.width * (1 - (crop?.left ?? 0) - (crop?.right ?? 0))\n const croppedHeight = dimensions.height * (1 - (crop?.top ?? 0) - (crop?.bottom ?? 0))\n return {\n url: createImageUrlBuilder(client).image(image).width(width).url(),\n aspectRatio: croppedWidth / croppedHeight,\n }\n }, [image, client, width])\n}\n\n/**\n * The image with its spots. Click the image to add a spot, drag a spot to move it, click it to\n * edit its item. The preview is cropped like the frontend's, so positions are relative to the crop.\n */\nexport function HotspotFrame(props: HotspotFrameProps): ReactNode {\n const {image, items, arrayPath, itemType, invalidKeys, readOnly, options, renderPreview} = props\n const {onPatch, onOpen} = props\n const preview = useImagePreview(image, options.imageWidth)\n const frameRef = useRef<HTMLDivElement | null>(null)\n\n const handleImageClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (readOnly || event.target !== event.currentTarget) return\n const rect = event.currentTarget.getBoundingClientRect()\n const item: HotspotItem = {\n _key: randomKey(),\n _type: itemType.name,\n x: toPercent(((event.clientX - rect.left) / rect.width) * 100),\n y: toPercent(((event.clientY - rect.top) / rect.height) * 100),\n }\n onPatch([setIfMissing([]), insert([item], 'after', [-1])])\n },\n [readOnly, onPatch, itemType.name],\n )\n\n const handleMove = useCallback(\n (key: string, x: number, y: number) => {\n onPatch([set(x, [{_key: key}, 'x']), set(y, [{_key: key}, 'y'])])\n },\n [onPatch],\n )\n\n if (!preview) return null\n\n return (\n <Card border radius={2} overflow=\"hidden\">\n <div\n ref={frameRef}\n onClick={handleImageClick}\n style={{\n position: 'relative',\n aspectRatio: preview.aspectRatio,\n backgroundImage: `url(${preview.url})`,\n backgroundSize: '100% 100%',\n cursor: readOnly ? 'default' : 'crosshair',\n }}\n >\n {items?.map((spot) => (\n <Spot\n key={spot._key}\n value={spot}\n itemPath={[...arrayPath, {_key: spot._key}]}\n frameRef={frameRef}\n schemaType={itemType}\n renderPreview={renderPreview}\n invalid={invalidKeys.has(spot._key)}\n readOnly={readOnly}\n icon={options.icon}\n placement={options.tooltipPlacement?.(spot)}\n onMove={handleMove}\n onOpen={onOpen}\n />\n ))}\n </div>\n </Card>\n )\n}\n","import {EditIcon} from '@sanity/icons/Edit'\nimport {Box, Button, Stack, Text} from '@sanity/ui'\nimport {Tooltip} from '@sanity/ui/tooltip'\nimport {createContext, type ReactNode, useCallback, useMemo, useState} from 'react'\nimport {\n type ArrayOfObjectsFormNode,\n type ArraySchemaType,\n type FormPatch,\n type ImageValue,\n type ObjectInputProps,\n type ObjectSchemaType,\n PatchEvent,\n type RenderInputCallback,\n useFormCallbacks,\n} from 'sanity'\n\nimport {HotspotFrame} from './HotspotFrame'\nimport {useInvalidKeys} from './HotspotPickerInput'\nimport type {HotspotImageValue, HotspotItem, HotspotPickerOptions} from './types'\n\n/** Set by the object input: its `items` field leaves the image to it. `null` outside it. */\nexport const HotspotObjectContext = createContext<{editing: boolean} | null>(null)\n\nconst NO_MEMBERS: ArrayOfObjectsFormNode['members'] = []\n\nexport type HotspotObjectInputProps = ObjectInputProps & {defaults?: HotspotPickerOptions}\n\n/**\n * The plugin's object input. With an image, the spot picker sits where the image field goes; the\n * edit button swaps it for the native image input. Without an image, the native input shows.\n */\nexport function HotspotObjectInput(props: HotspotObjectInputProps): ReactNode {\n const {path, onChange, renderPreview, readOnly, defaults} = props\n const value = props.value as HotspotImageValue | undefined\n const hasImage = Boolean(value?.image?.asset?._ref)\n const [isEditing, setIsEditing] = useState(false)\n const editing = isEditing || !hasImage\n const handleEditToggle = useCallback(() => setIsEditing((current) => !current), [])\n const context = useMemo(() => ({editing}), [editing])\n\n const itemsMember = props.members.find(\n (member) => member.kind === 'field' && member.name === 'items',\n )\n const itemsField =\n itemsMember?.kind === 'field' ? (itemsMember.field as ArrayOfObjectsFormNode) : undefined\n const invalidKeys = useInvalidKeys(itemsField?.members ?? NO_MEMBERS)\n const itemsType = props.schemaType.fields.find((field) => field.name === 'items')?.type as\n ArraySchemaType | undefined\n const itemType = itemsType?.of[0] as ObjectSchemaType | undefined\n const arrayPath = useMemo(() => [...path, 'items'], [path])\n\n const {onPathOpen} = useFormCallbacks()\n const handlePatch = useCallback(\n (patches: FormPatch[]) => onChange(PatchEvent.from(patches).prefixAll('items')),\n [onChange],\n )\n const openItem = useCallback(\n (key: string) => onPathOpen([...arrayPath, {_key: key}]),\n [onPathOpen, arrayPath],\n )\n\n // Outside edit mode the image field's input is the spot picker, in the image's place.\n const parentRenderInput = props.renderInput\n const renderInput: RenderInputCallback = useCallback(\n (inputProps) => {\n const isImage =\n inputProps.path.length === path.length + 1 && inputProps.path[path.length] === 'image'\n if (editing || !isImage || !itemType) return parentRenderInput(inputProps)\n return (\n <HotspotFrame\n image={value?.image as ImageValue | undefined}\n items={value?.items as HotspotItem[] | undefined}\n arrayPath={arrayPath}\n itemType={itemType}\n invalidKeys={invalidKeys}\n readOnly={readOnly}\n options={defaults ?? {}}\n renderPreview={renderPreview}\n onPatch={handlePatch}\n onOpen={openItem}\n />\n )\n },\n [\n editing,\n path,\n itemType,\n parentRenderInput,\n value,\n arrayPath,\n invalidKeys,\n readOnly,\n defaults,\n renderPreview,\n handlePatch,\n openItem,\n ],\n )\n\n return (\n <HotspotObjectContext.Provider value={context}>\n <Stack gap={5}>\n {hasImage && (\n <Box style={{position: 'absolute', top: 0, right: 0}}>\n <Tooltip\n animate\n delay={5}\n placement=\"top\"\n content={\n <Text size={1} weight=\"medium\">\n Edit image\n </Text>\n }\n portal\n >\n <Button\n mode=\"bleed\"\n icon={EditIcon}\n padding={2}\n onClick={handleEditToggle}\n selected={isEditing}\n aria-label=\"Edit image\"\n />\n </Tooltip>\n </Box>\n )}\n {props.renderDefault({...props, renderInput})}\n </Stack>\n </HotspotObjectContext.Provider>\n )\n}\n","import {Card, Flex, Text} from '@sanity/ui'\nimport {type ReactNode, useCallback, useContext, useMemo} from 'react'\nimport {\n type ArrayOfObjectsMember,\n type FormPatch,\n type ImageValue,\n type InputProps,\n type ObjectSchemaType,\n PatchEvent,\n useFormValue,\n} from 'sanity'\n\nimport {DEFAULT_IMAGE_WIDTH, HotspotFrame} from './HotspotFrame'\nimport {HotspotObjectContext} from './HotspotObjectInput'\nimport type {HotspotPickerInputProps, HotspotPickerOptions} from './types'\nimport {resolveImagePath} from './utils'\n\n/** Keys of items with error-level validation (their spots show a warning). */\nexport function useInvalidKeys(members: ArrayOfObjectsMember[]): Set<string> {\n return useMemo(() => {\n const keys = new Set<string>()\n for (const member of members) {\n if (member.kind === 'item' && member.item.validation.some((v) => v.level === 'error')) {\n keys.add(member.key)\n }\n }\n return keys\n }, [members])\n}\n\n/** Resolve the field's options over the plugin's defaults. */\nfunction useHotspotOptions(\n props: HotspotPickerInputProps,\n defaults?: HotspotPickerOptions,\n): Required<Pick<HotspotPickerOptions, 'imagePath' | 'imageWidth'>> & HotspotPickerOptions {\n const fieldOptions = props.schemaType.options?.hotspotPicker\n return {\n ...defaults,\n ...(typeof fieldOptions === 'object' ? fieldOptions : {}),\n imagePath:\n (typeof fieldOptions === 'object' && fieldOptions.imagePath) ||\n defaults?.imagePath ||\n 'image',\n imageWidth:\n (typeof fieldOptions === 'object' && fieldOptions.imageWidth) ||\n defaults?.imageWidth ||\n DEFAULT_IMAGE_WIDTH,\n }\n}\n\n/**\n * Array input that places each item as a draggable spot on an image field. The list below the\n * image is the Studio's own array input, so adding, reordering, removing and editing work as usual.\n * Inside the plugin's object type, the object input shows the image instead (above this field).\n */\nexport function HotspotPickerInput(\n props: HotspotPickerInputProps & {defaults?: HotspotPickerOptions},\n): ReactNode {\n const objectContext = useContext(HotspotObjectContext)\n if (objectContext) return props.renderDefault(props as unknown as InputProps)\n return <StandaloneHotspotPicker {...props} />\n}\n\nfunction StandaloneHotspotPicker(\n props: HotspotPickerInputProps & {defaults?: HotspotPickerOptions},\n): ReactNode {\n const {value, onChange, schemaType, renderPreview, path, onItemOpen, members, readOnly} = props\n const options = useHotspotOptions(props, props.defaults)\n const itemType = schemaType.of[0] as ObjectSchemaType\n const imagePath = useMemo(\n () => resolveImagePath(path, options.imagePath),\n [path, options.imagePath],\n )\n const image = useFormValue(imagePath) as ImageValue | undefined\n const invalidKeys = useInvalidKeys(members)\n\n const handlePatch = useCallback(\n (patches: FormPatch[]) => onChange(PatchEvent.from(patches)),\n [onChange],\n )\n const openItem = useCallback(\n (key: string) => onItemOpen([...path, {_key: key}]),\n [onItemOpen, path],\n )\n\n return (\n <Flex direction=\"column\" gap={2}>\n {image?.asset?._ref ? (\n <HotspotFrame\n image={image}\n items={value}\n arrayPath={path}\n itemType={itemType}\n invalidKeys={invalidKeys}\n readOnly={readOnly}\n options={options}\n renderPreview={renderPreview}\n onPatch={handlePatch}\n onOpen={openItem}\n />\n ) : (\n <Card padding={3} radius={2} tone=\"caution\" border>\n <Text size={1}>Add an image first to place spots on it.</Text>\n </Card>\n )}\n {props.renderDefault(props as unknown as InputProps)}\n </Flex>\n )\n}\n","import React from 'react'\nimport {\n defineArrayMember,\n defineField,\n defineType,\n type FieldDefinition,\n type ObjectFieldProps,\n type ObjectInputProps,\n type PreviewValue,\n} from 'sanity'\n\nimport {HotspotObjectInput} from './HotspotObjectInput'\nimport type {HotspotPickerPluginOptions} from './types'\n\nfunction ImageField(props: ObjectFieldProps): React.ReactElement {\n return React.createElement(React.Fragment, null, props.children)\n}\n\n/** Default name of the object type the plugin registers. */\nexport const DEFAULT_TYPE_NAME = 'hotspotImage'\n\n/**\n * The hidden `x` and `y` fields a spot needs (percentages of the image, set by dragging).\n * Spread them into the array member's `fields`.\n */\nexport function hotspotFields(): FieldDefinition[] {\n const coordinate = (name: 'x' | 'y') =>\n defineField({\n name,\n type: 'number',\n readOnly: true,\n hidden: true,\n initialValue: 50,\n validation: (rule) => rule.required().min(0).max(100),\n })\n return [coordinate('x'), coordinate('y')]\n}\n\n/**\n * The object type: an `image` and the `items` placed on it. Each item has a `reference`, the\n * plugin's extra `fields`, and its `x`/`y` position.\n */\nexport function createHotspotType(\n options: HotspotPickerPluginOptions = {},\n): ReturnType<typeof defineType> {\n const {reference, image, item} = options\n const referenceField = reference\n ? [\n defineField({\n title: 'Reference',\n validation: (rule) => rule.required(),\n ...reference,\n name: 'reference',\n type: 'reference',\n } as FieldDefinition),\n ]\n : []\n\n return defineType({\n name: options.name ?? DEFAULT_TYPE_NAME,\n title: options.title ?? 'Hotspot image',\n type: 'object',\n components: {\n input: (props: ObjectInputProps) =>\n React.createElement(HotspotObjectInput, {...props, defaults: options}),\n },\n fields: [\n defineField({\n options: {hotspot: true},\n ...image,\n // Just the input: the object field's own title stands for it, like the search listing.\n components: {field: ImageField, ...image?.components},\n name: 'image',\n title: image?.title ?? 'Image',\n type: 'image',\n } as FieldDefinition),\n defineField({\n name: 'items',\n title: item?.listTitle ?? 'Items',\n type: 'array',\n options: {hotspotPicker: true},\n of: [\n defineArrayMember({\n name: item?.name ?? 'spot',\n title: item?.title ?? reference?.title ?? 'Spot',\n type: 'object',\n icon: item?.icon,\n fields: [...referenceField, ...(item?.fields ?? []), ...hotspotFields()],\n preview: item?.preview ?? {\n select: {title: 'reference.title'},\n prepare: ({title}: {title?: string}) => ({title: title || 'Untitled'}),\n },\n }),\n ],\n }),\n ],\n preview: {\n select: {media: 'image', items: 'items'},\n prepare: ({media, items}: {media?: PreviewValue['media']; items?: unknown[]}) => {\n const count = items?.length ?? 0\n return {title: count === 1 ? '1 item' : `${count} items`, media}\n },\n },\n })\n}\n","import React from 'react'\nimport {\n type ArrayOfObjectsInputProps,\n definePlugin,\n type InputProps,\n isArrayOfObjectsSchemaType,\n} from 'sanity'\n\nimport {HotspotPickerInput} from './HotspotPickerInput'\nimport {createHotspotType} from './schema'\nimport type {HotspotPickerInputProps, HotspotPickerPluginOptions} from './types'\n\n/**\n * Registers the `hotspotImage` object type: an `image` and an array of `items`, each a draggable\n * spot on the image with a `reference` and an `x`/`y` position. Also turns any array field with\n * `options.hotspotPicker` into a spot picker.\n *\n * @example\n * ```ts\n * // sanity.config.ts\n * plugins: [hotspotPicker({reference: {title: 'Product', to: [{type: 'product'}]}})]\n *\n * // schema\n * defineField({name: 'shoppable', type: 'hotspotImage'})\n * ```\n */\nexport const hotspotPicker = definePlugin<HotspotPickerPluginOptions | void>((options) => {\n const defaults = options ?? undefined\n return {\n name: 'hotspot-picker',\n schema: {types: [createHotspotType(defaults)]},\n form: {\n components: {\n input: (props: InputProps) => {\n if (\n isArrayOfObjectsSchemaType(props.schemaType) &&\n props.schemaType.options?.hotspotPicker\n ) {\n return React.createElement(HotspotPickerInput, {\n ...(props as unknown as HotspotPickerInputProps),\n defaults,\n })\n }\n return props.renderDefault(props)\n },\n },\n },\n }\n})\n\n/**\n * Use the input without the plugin, as a field's `components.input`. Set the field's\n * `options.hotspotPicker` (or `true`) for its options.\n */\nexport function HotspotPicker(props: ArrayOfObjectsInputProps): React.ReactElement {\n return React.createElement(HotspotPickerInput, props as unknown as HotspotPickerInputProps)\n}\n\nexport {HotspotPickerInput}\nexport {DEFAULT_TYPE_NAME, hotspotFields} from './schema'\nexport type {\n HotspotArraySchemaType,\n HotspotImageValue,\n HotspotItem,\n HotspotPickerInputProps,\n HotspotPickerOptions,\n HotspotPickerPluginOptions,\n} from './types'\n"],"names":[],"mappings":";;;;;;;;;;;;AA0BO,SAAS,mBACd,OACA,YACiB;AACjB,QAAM,QAAQ;AAAA,IACZ,MACE,WAAW,OAAO,KAAK,CAAC,MAAM,EAAE,SAAS,eAAe,sBAAsB,EAAE,IAAI,CAAC,KACrF,WAAW,OAAO,KAAK,CAAC,MAAM,sBAAsB,EAAE,IAAI,CAAC;AAAA,IAC7D,CAAC,UAAU;AAAA,EAAA,GAEP,UAAU,OAAO,MACjB,aAAa,QAAS,MAAM,MAA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,OAA8B,EAAC,OAAO,SAAS,WAAA;AAAA,YAAU;AAAA,UACtE,CACD;AAAA,QAAA;AAAA,MACH,CACD;AAAA,IAAA;AAAA,IAEH,SAAS;AAAA,MACP,QAAQ,EAAC,OAAO,SAAS,OAAO,QAAA;AAAA,MAChC,SAAS,CAAC,EAAC,OAAO,YAA+D;AAC/E,cAAM,QAAQ,OAAO,UAAU;AAC/B,eAAO,EAAC,OAAO,UAAU,IAAI,WAAW,GAAG,KAAK,UAAU,MAAA;AAAA,MAC5D;AAAA,IAAA;AAAA,EACF,CACD;AACH;AC9EO,MAAM,gBAAgB,aAAgD,CAAC,YAAY;AACxF,QAAM,WAAW,WAAW;AAC5B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,EAAC,OAAO,CAAC,kBAAkB,QAAQ,CAAC,EAAA;AAAA,IAC5C,MAAM;AAAA,MACJ,YAAY;AAAA,QACV,OAAO,CAAC,UAEJ,2BAA2B,MAAM,UAAU,KAC3C,MAAM,WAAW,SAAS,gBAEnB,MAAM,cAAc,oBAAoB;AAAA,UAC7C,GAAI;AAAA,UACJ;AAAA,QAAA,CACD,IAEI,MAAM,cAAc,KAAK;AAAA,MAAA;AAAA,IAEpC;AAAA,EACF;AAEJ,CAAC;AAMM,SAAS,cAAc,OAAqD;AACjF,SAAO,MAAM,cAAc,oBAAoB,KAA2C;AAC5F;"}
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "sanity-plugin-hotspot-picker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A Sanity Studio array input that places each item as a draggable spot on a sibling image field.",
5
+ "keywords": [
6
+ "sanity",
7
+ "sanity-plugin",
8
+ "hotspot",
9
+ "image-hotspot",
10
+ "shoppable-image"
11
+ ],
12
+ "homepage": "https://github.com/dennisregalado/sanity-plugin-hotspot-picker#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/dennisregalado/sanity-plugin-hotspot-picker/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/dennisregalado/sanity-plugin-hotspot-picker.git"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Dennis Regalado <dennis@baggy.studio>",
22
+ "sideEffects": false,
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./dist/index.js",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "types": "./dist/index.d.ts",
32
+ "browserslist": "extends @sanity/browserslist-config",
33
+ "files": [
34
+ "dist",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "scripts": {
39
+ "build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
40
+ "format": "prettier --write --cache --ignore-unknown .",
41
+ "link-watch": "plugin-kit link-watch",
42
+ "lint": "eslint .",
43
+ "prepublishOnly": "npm run build",
44
+ "typecheck": "tsc --noEmit",
45
+ "watch": "pkg-utils watch --strict"
46
+ },
47
+ "dependencies": {
48
+ "@sanity/asset-utils": "^2.3.0",
49
+ "@sanity/image-url": "^2.1.1"
50
+ },
51
+ "devDependencies": {
52
+ "@sanity/pkg-utils": "^10.7.2",
53
+ "@sanity/plugin-kit": "^6.0.0",
54
+ "@types/react": "^19.2.17",
55
+ "@typescript-eslint/eslint-plugin": "^8.62.0",
56
+ "@typescript-eslint/parser": "^8.62.0",
57
+ "eslint": "^8.57.1",
58
+ "eslint-config-prettier": "^10.1.8",
59
+ "eslint-config-sanity": "^7.1.4",
60
+ "eslint-plugin-prettier": "^5.5.6",
61
+ "eslint-plugin-react": "^7.37.5",
62
+ "eslint-plugin-react-hooks": "^7.1.1",
63
+ "prettier": "^3.9.1",
64
+ "prettier-plugin-packagejson": "^3.0.2",
65
+ "react": "^19.2.7",
66
+ "react-dom": "^19.2.7",
67
+ "sanity": "^6.2.0",
68
+ "styled-components": "^6.4.3",
69
+ "typescript": "^6.0.3"
70
+ },
71
+ "peerDependencies": {
72
+ "@sanity/icons": "^5",
73
+ "@sanity/ui": "^4",
74
+ "react": "^18 || ^19",
75
+ "sanity": "^6"
76
+ },
77
+ "engines": {
78
+ "node": ">=20.19 <22 || >=22.12"
79
+ },
80
+ "sanityPlugin": {
81
+ "verifyPackage": {
82
+ "tsconfig": false
83
+ }
84
+ }
85
+ }