sanity-plugin-hotspot-array 0.0.7 → 0.1.0-v3-studio.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/LICENSE +1 -1
- package/README.md +136 -38
- package/lib/cjs/index.js +403 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/index.js +395 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/types/index.d.ts +36 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +61 -47
- package/sanity.json +6 -5
- package/src/Feedback.tsx +2 -2
- package/src/ImageHotspotArray.tsx +188 -0
- package/src/Spot.tsx +32 -19
- package/src/index.tsx +42 -0
- package/v2-incompatible.js +11 -0
- package/.babelrc +0 -3
- package/lib/Feedback.js +0 -23
- package/lib/Feedback.js.map +0 -1
- package/lib/HotspotArray.js +0 -189
- package/lib/HotspotArray.js.map +0 -1
- package/lib/Spot.js +0 -180
- package/lib/Spot.js.map +0 -1
- package/lib/useUnsetInputComponent.js +0 -32
- package/lib/useUnsetInputComponent.js.map +0 -1
- package/src/HotspotArray.tsx +0 -177
- package/src/useUnsetInputComponent.ts +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;ACEA;;;;;;;;;ACFA;;;AAGe,kDAAkB,YAAC,QAAQ,CAAA,EAAwB,EAAE;IAClE,qBACE,gCAAC,CAAA,GAAA,oBAAI,CAAA;QAAC,OAAO,EAAE,CAAC;QAAE,MAAM,EAAE,CAAC;QAAE,MAAM,EAAE,CAAC;QAAE,IAAI,EAAC,SAAS;kBACpD,cAAA,gCAAC,CAAA,GAAA,oBAAI,CAAA;sBAAE,QAAQ;UAAQ;MAClB,CACR;CACF;;;ACRD;;;;;AAOA,MAAM,+BAAS,GAAkB;IAC/B,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,YAAY;IACvB,G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x","src/Spot.tsx"],"sourcesContent":["import {ImageHotspotArray, type HotspotItem} from './ImageHotspotArray'\nimport React, {ComponentType} from 'react'\nimport {ArrayOfObjectsInputProps, createPlugin} from 'sanity'\nimport {type HotspotTooltipProps} from './Spot'\n\nexport interface ImageHotspotOptions<HotspotFields = {[key: string]: unknown}> {\n pathRoot?: 'document' | 'parent'\n imagePath: string\n descriptionPath?: string\n tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>\n}\n\ndeclare module '@sanity/types' {\n export interface ArrayOptions {\n imageHotspot?: ImageHotspotOptions\n }\n}\n\nexport {ImageHotspotArray}\nexport type {HotspotTooltipProps, HotspotItem}\n\nexport const imageHotspotArrayPlugin = createPlugin({\n name: 'image-hotspot-array',\n form: {\n components: {\n input: (props) => {\n if (props.schemaType.jsonType === 'array' && props.schemaType.options?.imageHotspot) {\n const imageHotspotOptions = props.schemaType.options?.imageHotspot\n if (imageHotspotOptions) {\n return (\n <ImageHotspotArray\n {...(props as unknown as ArrayOfObjectsInputProps<HotspotItem>)}\n imageHotspotOptions={imageHotspotOptions}\n />\n )\n }\n }\n return props.renderDefault(props)\n },\n },\n },\n})\n","/* eslint-disable react/display-name */\n\nimport {getImageDimensions} from '@sanity/asset-utils'\nimport {\n ArrayOfObjectsInputProps,\n ImageValue,\n insert,\n ObjectSchemaType,\n PatchEvent,\n set,\n setIfMissing,\n useClient,\n useFormValue,\n} from 'sanity'\nimport imageUrlBuilder from '@sanity/image-url'\nimport {Card, Flex, Stack} from '@sanity/ui'\nimport {randomKey} from '@sanity/util/content'\nimport get from 'lodash/get'\nimport React, {useCallback, useMemo, useRef, useState} from 'react'\n\nimport {IUseResizeObserverCallback, useDebouncedCallback, useResizeObserver} from '@react-hookz/web'\nimport Feedback from './Feedback'\nimport Spot from './Spot'\nimport {ImageHotspotOptions} from './index'\n\nconst imageStyle = {width: `100%`, height: `auto`}\n\nconst VALID_ROOT_PATHS = ['document', 'parent']\n\nexport type FnHotspotMove = (key: string, x: number, y: number) => void\n\nexport type HotspotItem<HotspotFields = {[key: string]: unknown}> = {\n _key: string\n _type: string\n x: number\n y: number\n} & HotspotFields\n\nexport function ImageHotspotArray(\n props: ArrayOfObjectsInputProps<HotspotItem> & {imageHotspotOptions: ImageHotspotOptions}\n) {\n const {value, onChange, imageHotspotOptions, schemaType, renderPreview} = props\n\n const sanityClient = useClient({apiVersion: '2022-01-01'})\n\n const imageHotspotPathRoot = useMemo(() => {\n const pathRoot = VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot ?? '')\n ? imageHotspotOptions.pathRoot\n : 'document'\n return pathRoot === 'document' ? [] : props.path.slice(0, -1)\n }, [imageHotspotOptions.pathRoot, props.path])\n\n const rootObject = useFormValue(imageHotspotPathRoot)\n\n /**\n * Finding the image from the imageHotspotPathRoot (defaults to document),\n * using the path from the hotspot's `options` field\n *\n * when changes in imageHotspotPathRoot (e.g. document) occur,\n * check if there are any changes to the hotspotImage and update the reference\n */\n const hotspotImage = useMemo(() => {\n return get(rootObject, imageHotspotOptions.imagePath) as ImageValue | undefined\n }, [rootObject, imageHotspotOptions.imagePath])\n\n const displayImage = useMemo(() => {\n const builder = imageUrlBuilder(sanityClient).dataset(sanityClient.config().dataset ?? '')\n const urlFor = (source: ImageValue) => builder.image(source)\n\n if (hotspotImage?.asset?._ref) {\n const {aspectRatio} = getImageDimensions(hotspotImage.asset._ref)\n const width = 1200\n const height = Math.round(width / aspectRatio)\n const url = urlFor(hotspotImage).width(width).url()\n\n return {width, height, url}\n }\n\n return null\n }, [hotspotImage, sanityClient])\n\n const handleHotspotImageClick = useCallback(\n (event: any) => {\n const {nativeEvent} = event\n\n // Calculate the x/y percentage of the click position\n const x = Number(((nativeEvent.offsetX * 100) / nativeEvent.srcElement.width).toFixed(2))\n const y = Number(((nativeEvent.offsetY * 100) / nativeEvent.srcElement.height).toFixed(2))\n const description = `New Hotspot at ${x}% x ${y}%`\n\n const newRow: HotspotItem = {\n _key: randomKey(12),\n _type: schemaType.of[0].name,\n x,\n y,\n }\n\n if (imageHotspotOptions?.descriptionPath) {\n newRow[imageHotspotOptions.descriptionPath] = description\n }\n\n onChange(PatchEvent.from([setIfMissing([]), insert([newRow], 'after', [-1])]))\n },\n [imageHotspotOptions, onChange, schemaType]\n )\n\n const handleHotspotMove: FnHotspotMove = useCallback(\n (key, x, y) => {\n onChange(\n PatchEvent.from([\n // Set the `x` value of this array key item\n set(x, [{_key: key}, 'x']),\n // Set the `y` value of this array key item\n set(y, [{_key: key}, 'y']),\n ])\n )\n },\n [onChange]\n )\n\n const hotspotImageRef = useRef<HTMLImageElement | null>(null)\n\n const [imageRect, setImageRect] = useState<DOMRectReadOnly>()\n const updateImageRectCallback = useDebouncedCallback(\n ((e) => setImageRect(e.contentRect)) as IUseResizeObserverCallback,\n [setImageRect],\n 200\n )\n useResizeObserver(hotspotImageRef, updateImageRectCallback)\n\n return (\n <Stack space={[2, 2, 3]}>\n {displayImage?.url ? (\n <div style={{position: `relative`}}>\n {imageRect &&\n (value?.length ?? 0) > 0 &&\n value?.map((spot, index) => (\n <Spot\n index={index}\n key={spot._key}\n value={spot}\n bounds={imageRect}\n update={handleHotspotMove}\n hotspotDescriptionPath={imageHotspotOptions?.descriptionPath}\n tooltip={imageHotspotOptions?.tooltip}\n renderPreview={renderPreview}\n schemaType={schemaType.of[0] as ObjectSchemaType}\n />\n ))}\n\n <Card __unstable_checkered shadow={1}>\n <Flex align=\"center\" justify=\"center\">\n <img\n ref={hotspotImageRef}\n src={displayImage.url}\n width={displayImage.width}\n height={displayImage.height}\n alt=\"\"\n style={imageStyle}\n onClick={handleHotspotImageClick}\n />\n </Flex>\n </Card>\n </div>\n ) : (\n <Feedback>\n {imageHotspotOptions.imagePath ? (\n <>\n No Hotspot image found at path <code>{imageHotspotOptions.imagePath}</code>\n </>\n ) : (\n <>\n Define a path in this field using to the image field in this document at{' '}\n <code>options.hotspotImagePath</code>\n </>\n )}\n </Feedback>\n )}\n {imageHotspotOptions.pathRoot && !VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot) && (\n <Feedback>\n The supplied imageHotspotPathRoot \"{imageHotspotOptions.pathRoot}\" is not valid, falling\n back to \"document\". Available values are \"{VALID_ROOT_PATHS.join(', ')}\".\n </Feedback>\n )}\n {props.renderDefault(props as unknown as ArrayOfObjectsInputProps)}\n </Stack>\n )\n}\n","import React, {ReactNode} from 'react'\nimport {Card, Text} from '@sanity/ui'\n\nexport default function Feedback({children}: {children: ReactNode}) {\n return (\n <Card padding={4} radius={2} shadow={1} tone=\"caution\">\n <Text>{children}</Text>\n </Card>\n )\n}\n","/* eslint-disable */\nimport {Box, Text, Tooltip} from '@sanity/ui'\nimport {motion, useMotionValue} from 'framer-motion'\nimport get from 'lodash/get'\nimport React, {ComponentType, CSSProperties, ReactElement, useEffect} from 'react'\nimport {FnHotspotMove, HotspotItem} from './ImageHotspotArray'\nimport {ObjectSchemaType, RenderPreviewCallback} from 'sanity'\n\nconst dragStyle: CSSProperties = {\n width: '1.4rem',\n height: '1.4rem',\n position: 'absolute',\n boxSizing: 'border-box',\n top: 0,\n left: 0,\n margin: '-0.7rem 0 0 -0.7rem',\n cursor: 'pointer',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: '50%',\n background: '#000',\n color: 'white',\n}\n\nconst dragStyleWhileDrag: CSSProperties = {\n background: 'rgba(0, 0, 0, 0.1)',\n border: '1px solid #fff',\n cursor: 'none',\n}\n\nconst dragStyleWhileHover: CSSProperties = {\n background: 'rgba(0, 0, 0, 0.1)',\n border: '1px solid #fff',\n}\n\nconst dotStyle: CSSProperties = {\n position: 'absolute',\n left: '50%',\n top: '50%',\n height: '0.2rem',\n width: '0.2rem',\n margin: '-0.1rem 0 0 -0.1rem',\n background: '#fff',\n visibility: 'hidden',\n borderRadius: '50%',\n // make sure pointer events only run on the parent\n pointerEvents: 'none',\n}\n\nconst dotStyleWhileActive: CSSProperties = {\n visibility: 'visible',\n}\n\nconst labelStyle: CSSProperties = {\n color: 'white',\n fontSize: '0.7rem',\n fontWeight: 600,\n lineHeight: '1',\n}\n\nconst labelStyleWhileActive: CSSProperties = {\n visibility: 'hidden',\n}\n\nconst round = (num: number) => Math.round(num * 100) / 100\n\nexport interface HotspotTooltipProps<HotspotFields = {[key: string]: unknown}> {\n value: HotspotItem<HotspotFields>\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n}\n\ninterface HotspotProps<HotspotFields = {[key: string]: unknown}> {\n value: HotspotItem\n bounds: DOMRectReadOnly\n update: FnHotspotMove\n hotspotDescriptionPath?: string\n tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>\n index: number\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n}\n\nexport default function Spot({\n value,\n bounds,\n update,\n hotspotDescriptionPath,\n tooltip,\n index,\n schemaType,\n renderPreview,\n}: HotspotProps) {\n const [isDragging, setIsDragging] = React.useState(false)\n const [isHovering, setIsHovering] = React.useState(false)\n\n // x/y are stored as % but need to be converted to px\n const x = useMotionValue(round(bounds.width * (value.x / 100)))\n const y = useMotionValue(round(bounds.height * (value.y / 100)))\n\n /**\n * update x/y if the bounds change when resizing the window\n */\n useEffect(() => {\n x.set(round(bounds.width * (value.x / 100)))\n y.set(round(bounds.height * (value.y / 100)))\n }, [x, y, value, bounds])\n\n const handleDragEnd = React.useCallback(() => {\n setIsDragging(false)\n\n // get current values for x/y in px\n const currentX = x.get()\n const currentY = y.get()\n\n // Which we need to convert back to `%` to patch the document\n const newX = round((currentX * 100) / bounds.width)\n const newY = round((currentY * 100) / bounds.height)\n\n // Don't go below 0 or above 100\n const safeX = Math.max(0, Math.min(100, newX))\n const safeY = Math.max(0, Math.min(100, newY))\n\n update(value._key, safeX, safeY)\n }, [x, y, value, update, bounds])\n const handleDragStart = React.useCallback(() => setIsDragging(true), [])\n\n const handleHoverStart = React.useCallback(() => setIsHovering(true), [])\n const handleHoverEnd = React.useCallback(() => setIsHovering(false), [])\n\n if (!x || !y) {\n return null\n }\n\n return (\n <Tooltip\n key={value._key}\n disabled={isDragging}\n portal\n content={\n tooltip && typeof tooltip === 'function' ? (\n React.createElement(tooltip, {value, renderPreview, schemaType})\n ) : (\n <Box padding={2} style={{maxWidth: 200, pointerEvents: `none`}}>\n <Text textOverflow=\"ellipsis\">\n {hotspotDescriptionPath\n ? (get(value, hotspotDescriptionPath) as string)\n : `${value.x}% x ${value.y}%`}\n </Text>\n </Box>\n )\n }\n >\n <motion.div\n drag\n dragConstraints={bounds}\n dragElastic={0}\n dragMomentum={false}\n onDragEnd={handleDragEnd}\n onDragStart={handleDragStart}\n onHoverStart={handleHoverStart}\n onHoverEnd={handleHoverEnd}\n style={{\n ...dragStyle,\n x,\n y,\n ...(isDragging && {...dragStyleWhileDrag}),\n ...(isHovering && {...dragStyleWhileHover}),\n }}\n >\n {/* Dot */}\n <Box\n style={{\n ...dotStyle,\n ...((isDragging || isHovering) && {...dotStyleWhileActive}),\n }}\n />\n {/* Label */}\n <div\n style={{\n ...labelStyle,\n ...((isDragging || isHovering) && {...labelStyleWhileActive}),\n }}\n >\n {index + 1}\n </div>\n </motion.div>\n </Tooltip>\n )\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import {jsx as $7XdDa$jsx, jsxs as $7XdDa$jsxs, Fragment as $7XdDa$Fragment} from "react/jsx-runtime";
|
|
2
|
+
import $7XdDa$react, {useMemo as $7XdDa$useMemo, useCallback as $7XdDa$useCallback, useRef as $7XdDa$useRef, useState as $7XdDa$useState, useEffect as $7XdDa$useEffect} from "react";
|
|
3
|
+
import {createPlugin as $7XdDa$createPlugin, useClient as $7XdDa$useClient, useFormValue as $7XdDa$useFormValue, PatchEvent as $7XdDa$PatchEvent, setIfMissing as $7XdDa$setIfMissing, insert as $7XdDa$insert, set as $7XdDa$set} from "sanity";
|
|
4
|
+
import {getImageDimensions as $7XdDa$getImageDimensions} from "@sanity/asset-utils";
|
|
5
|
+
import $7XdDa$sanityimageurl from "@sanity/image-url";
|
|
6
|
+
import {Stack as $7XdDa$Stack, Card as $7XdDa$Card, Flex as $7XdDa$Flex, Text as $7XdDa$Text, Tooltip as $7XdDa$Tooltip, Box as $7XdDa$Box} from "@sanity/ui";
|
|
7
|
+
import {randomKey as $7XdDa$randomKey} from "@sanity/util/content";
|
|
8
|
+
import $7XdDa$lodashget from "lodash/get";
|
|
9
|
+
import {useDebouncedCallback as $7XdDa$useDebouncedCallback, useResizeObserver as $7XdDa$useResizeObserver} from "@react-hookz/web";
|
|
10
|
+
import {useMotionValue as $7XdDa$useMotionValue, motion as $7XdDa$motion} from "framer-motion";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function $60d135b0057fb272$export$2e2bcd8739ae039({ children: children }) {
|
|
26
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Card), {
|
|
27
|
+
padding: 4,
|
|
28
|
+
radius: 2,
|
|
29
|
+
shadow: 1,
|
|
30
|
+
tone: "caution",
|
|
31
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Text), {
|
|
32
|
+
children: children
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const $ad617f9fb52013ae$var$dragStyle = {
|
|
44
|
+
width: "1.4rem",
|
|
45
|
+
height: "1.4rem",
|
|
46
|
+
position: "absolute",
|
|
47
|
+
boxSizing: "border-box",
|
|
48
|
+
top: 0,
|
|
49
|
+
left: 0,
|
|
50
|
+
margin: "-0.7rem 0 0 -0.7rem",
|
|
51
|
+
cursor: "pointer",
|
|
52
|
+
display: "flex",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
borderRadius: "50%",
|
|
56
|
+
background: "#000",
|
|
57
|
+
color: "white"
|
|
58
|
+
};
|
|
59
|
+
const $ad617f9fb52013ae$var$dragStyleWhileDrag = {
|
|
60
|
+
background: "rgba(0, 0, 0, 0.1)",
|
|
61
|
+
border: "1px solid #fff",
|
|
62
|
+
cursor: "none"
|
|
63
|
+
};
|
|
64
|
+
const $ad617f9fb52013ae$var$dragStyleWhileHover = {
|
|
65
|
+
background: "rgba(0, 0, 0, 0.1)",
|
|
66
|
+
border: "1px solid #fff"
|
|
67
|
+
};
|
|
68
|
+
const $ad617f9fb52013ae$var$dotStyle = {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
left: "50%",
|
|
71
|
+
top: "50%",
|
|
72
|
+
height: "0.2rem",
|
|
73
|
+
width: "0.2rem",
|
|
74
|
+
margin: "-0.1rem 0 0 -0.1rem",
|
|
75
|
+
background: "#fff",
|
|
76
|
+
visibility: "hidden",
|
|
77
|
+
borderRadius: "50%",
|
|
78
|
+
// make sure pointer events only run on the parent
|
|
79
|
+
pointerEvents: "none"
|
|
80
|
+
};
|
|
81
|
+
const $ad617f9fb52013ae$var$dotStyleWhileActive = {
|
|
82
|
+
visibility: "visible"
|
|
83
|
+
};
|
|
84
|
+
const $ad617f9fb52013ae$var$labelStyle = {
|
|
85
|
+
color: "white",
|
|
86
|
+
fontSize: "0.7rem",
|
|
87
|
+
fontWeight: 600,
|
|
88
|
+
lineHeight: "1"
|
|
89
|
+
};
|
|
90
|
+
const $ad617f9fb52013ae$var$labelStyleWhileActive = {
|
|
91
|
+
visibility: "hidden"
|
|
92
|
+
};
|
|
93
|
+
const $ad617f9fb52013ae$var$round = (num)=>Math.round(num * 100) / 100;
|
|
94
|
+
function $ad617f9fb52013ae$export$2e2bcd8739ae039({ value: value , bounds: bounds , update: update , hotspotDescriptionPath: hotspotDescriptionPath , tooltip: tooltip , index: index , schemaType: schemaType , renderPreview: renderPreview }) {
|
|
95
|
+
const [isDragging, setIsDragging] = (0, $7XdDa$react).useState(false);
|
|
96
|
+
const [isHovering, setIsHovering] = (0, $7XdDa$react).useState(false);
|
|
97
|
+
// x/y are stored as % but need to be converted to px
|
|
98
|
+
const x = (0, $7XdDa$useMotionValue)($ad617f9fb52013ae$var$round(bounds.width * (value.x / 100)));
|
|
99
|
+
const y = (0, $7XdDa$useMotionValue)($ad617f9fb52013ae$var$round(bounds.height * (value.y / 100)));
|
|
100
|
+
/**
|
|
101
|
+
* update x/y if the bounds change when resizing the window
|
|
102
|
+
*/ (0, $7XdDa$useEffect)(()=>{
|
|
103
|
+
x.set($ad617f9fb52013ae$var$round(bounds.width * (value.x / 100)));
|
|
104
|
+
y.set($ad617f9fb52013ae$var$round(bounds.height * (value.y / 100)));
|
|
105
|
+
}, [
|
|
106
|
+
x,
|
|
107
|
+
y,
|
|
108
|
+
value,
|
|
109
|
+
bounds
|
|
110
|
+
]);
|
|
111
|
+
const handleDragEnd = (0, $7XdDa$react).useCallback(()=>{
|
|
112
|
+
setIsDragging(false);
|
|
113
|
+
// get current values for x/y in px
|
|
114
|
+
const currentX = x.get();
|
|
115
|
+
const currentY = y.get();
|
|
116
|
+
// Which we need to convert back to `%` to patch the document
|
|
117
|
+
const newX = $ad617f9fb52013ae$var$round(currentX * 100 / bounds.width);
|
|
118
|
+
const newY = $ad617f9fb52013ae$var$round(currentY * 100 / bounds.height);
|
|
119
|
+
// Don't go below 0 or above 100
|
|
120
|
+
const safeX = Math.max(0, Math.min(100, newX));
|
|
121
|
+
const safeY = Math.max(0, Math.min(100, newY));
|
|
122
|
+
update(value._key, safeX, safeY);
|
|
123
|
+
}, [
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
value,
|
|
127
|
+
update,
|
|
128
|
+
bounds
|
|
129
|
+
]);
|
|
130
|
+
const handleDragStart = (0, $7XdDa$react).useCallback(()=>setIsDragging(true), []);
|
|
131
|
+
const handleHoverStart = (0, $7XdDa$react).useCallback(()=>setIsHovering(true), []);
|
|
132
|
+
const handleHoverEnd = (0, $7XdDa$react).useCallback(()=>setIsHovering(false), []);
|
|
133
|
+
if (!x || !y) return null;
|
|
134
|
+
return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Tooltip), {
|
|
135
|
+
disabled: isDragging,
|
|
136
|
+
portal: true,
|
|
137
|
+
content: tooltip && typeof tooltip === "function" ? /*#__PURE__*/ (0, $7XdDa$react).createElement(tooltip, {
|
|
138
|
+
value: value,
|
|
139
|
+
renderPreview: renderPreview,
|
|
140
|
+
schemaType: schemaType
|
|
141
|
+
}) : /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Box), {
|
|
142
|
+
padding: 2,
|
|
143
|
+
style: {
|
|
144
|
+
maxWidth: 200,
|
|
145
|
+
pointerEvents: `none`
|
|
146
|
+
},
|
|
147
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Text), {
|
|
148
|
+
textOverflow: "ellipsis",
|
|
149
|
+
children: hotspotDescriptionPath ? (0, $7XdDa$lodashget)(value, hotspotDescriptionPath) : `${value.x}% x ${value.y}%`
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$motion).div, {
|
|
153
|
+
drag: true,
|
|
154
|
+
dragConstraints: bounds,
|
|
155
|
+
dragElastic: 0,
|
|
156
|
+
dragMomentum: false,
|
|
157
|
+
onDragEnd: handleDragEnd,
|
|
158
|
+
onDragStart: handleDragStart,
|
|
159
|
+
onHoverStart: handleHoverStart,
|
|
160
|
+
onHoverEnd: handleHoverEnd,
|
|
161
|
+
style: {
|
|
162
|
+
...$ad617f9fb52013ae$var$dragStyle,
|
|
163
|
+
x: x,
|
|
164
|
+
y: y,
|
|
165
|
+
...isDragging && {
|
|
166
|
+
...$ad617f9fb52013ae$var$dragStyleWhileDrag
|
|
167
|
+
},
|
|
168
|
+
...isHovering && {
|
|
169
|
+
...$ad617f9fb52013ae$var$dragStyleWhileHover
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Box), {
|
|
174
|
+
style: {
|
|
175
|
+
...$ad617f9fb52013ae$var$dotStyle,
|
|
176
|
+
...(isDragging || isHovering) && {
|
|
177
|
+
...$ad617f9fb52013ae$var$dotStyleWhileActive
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("div", {
|
|
182
|
+
style: {
|
|
183
|
+
...$ad617f9fb52013ae$var$labelStyle,
|
|
184
|
+
...(isDragging || isHovering) && {
|
|
185
|
+
...$ad617f9fb52013ae$var$labelStyleWhileActive
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
children: index + 1
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
}, value._key);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
const $3fa33a99b88eeab6$var$imageStyle = {
|
|
197
|
+
width: `100%`,
|
|
198
|
+
height: `auto`
|
|
199
|
+
};
|
|
200
|
+
const $3fa33a99b88eeab6$var$VALID_ROOT_PATHS = [
|
|
201
|
+
"document",
|
|
202
|
+
"parent"
|
|
203
|
+
];
|
|
204
|
+
function $3fa33a99b88eeab6$export$aa9dd3c5642820fe(props) {
|
|
205
|
+
const { value: value , onChange: onChange , imageHotspotOptions: imageHotspotOptions , schemaType: schemaType , renderPreview: renderPreview } = props;
|
|
206
|
+
const sanityClient = (0, $7XdDa$useClient)({
|
|
207
|
+
apiVersion: "2022-01-01"
|
|
208
|
+
});
|
|
209
|
+
const imageHotspotPathRoot = (0, $7XdDa$useMemo)(()=>{
|
|
210
|
+
const pathRoot = $3fa33a99b88eeab6$var$VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot ?? "") ? imageHotspotOptions.pathRoot : "document";
|
|
211
|
+
return pathRoot === "document" ? [] : props.path.slice(0, -1);
|
|
212
|
+
}, [
|
|
213
|
+
imageHotspotOptions.pathRoot,
|
|
214
|
+
props.path
|
|
215
|
+
]);
|
|
216
|
+
const rootObject = (0, $7XdDa$useFormValue)(imageHotspotPathRoot);
|
|
217
|
+
/**
|
|
218
|
+
* Finding the image from the imageHotspotPathRoot (defaults to document),
|
|
219
|
+
* using the path from the hotspot's `options` field
|
|
220
|
+
*
|
|
221
|
+
* when changes in imageHotspotPathRoot (e.g. document) occur,
|
|
222
|
+
* check if there are any changes to the hotspotImage and update the reference
|
|
223
|
+
*/ const hotspotImage = (0, $7XdDa$useMemo)(()=>{
|
|
224
|
+
return (0, $7XdDa$lodashget)(rootObject, imageHotspotOptions.imagePath);
|
|
225
|
+
}, [
|
|
226
|
+
rootObject,
|
|
227
|
+
imageHotspotOptions.imagePath
|
|
228
|
+
]);
|
|
229
|
+
const displayImage = (0, $7XdDa$useMemo)(()=>{
|
|
230
|
+
const builder = (0, $7XdDa$sanityimageurl)(sanityClient).dataset(sanityClient.config().dataset ?? "");
|
|
231
|
+
const urlFor = (source)=>builder.image(source);
|
|
232
|
+
if (hotspotImage?.asset?._ref) {
|
|
233
|
+
const { aspectRatio: aspectRatio } = (0, $7XdDa$getImageDimensions)(hotspotImage.asset._ref);
|
|
234
|
+
const width = 1200;
|
|
235
|
+
const height = Math.round(width / aspectRatio);
|
|
236
|
+
const url = urlFor(hotspotImage).width(width).url();
|
|
237
|
+
return {
|
|
238
|
+
width: width,
|
|
239
|
+
height: height,
|
|
240
|
+
url: url
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}, [
|
|
245
|
+
hotspotImage,
|
|
246
|
+
sanityClient
|
|
247
|
+
]);
|
|
248
|
+
const handleHotspotImageClick = (0, $7XdDa$useCallback)((event)=>{
|
|
249
|
+
const { nativeEvent: nativeEvent } = event;
|
|
250
|
+
// Calculate the x/y percentage of the click position
|
|
251
|
+
const x = Number((nativeEvent.offsetX * 100 / nativeEvent.srcElement.width).toFixed(2));
|
|
252
|
+
const y = Number((nativeEvent.offsetY * 100 / nativeEvent.srcElement.height).toFixed(2));
|
|
253
|
+
const description = `New Hotspot at ${x}% x ${y}%`;
|
|
254
|
+
const newRow = {
|
|
255
|
+
_key: (0, $7XdDa$randomKey)(12),
|
|
256
|
+
_type: schemaType.of[0].name,
|
|
257
|
+
x: x,
|
|
258
|
+
y: y
|
|
259
|
+
};
|
|
260
|
+
if (imageHotspotOptions?.descriptionPath) newRow[imageHotspotOptions.descriptionPath] = description;
|
|
261
|
+
onChange((0, $7XdDa$PatchEvent).from([
|
|
262
|
+
(0, $7XdDa$setIfMissing)([]),
|
|
263
|
+
(0, $7XdDa$insert)([
|
|
264
|
+
newRow
|
|
265
|
+
], "after", [
|
|
266
|
+
-1
|
|
267
|
+
])
|
|
268
|
+
]));
|
|
269
|
+
}, [
|
|
270
|
+
imageHotspotOptions,
|
|
271
|
+
onChange,
|
|
272
|
+
schemaType
|
|
273
|
+
]);
|
|
274
|
+
const handleHotspotMove = (0, $7XdDa$useCallback)((key, x, y)=>{
|
|
275
|
+
onChange((0, $7XdDa$PatchEvent).from([
|
|
276
|
+
// Set the `x` value of this array key item
|
|
277
|
+
(0, $7XdDa$set)(x, [
|
|
278
|
+
{
|
|
279
|
+
_key: key
|
|
280
|
+
},
|
|
281
|
+
"x"
|
|
282
|
+
]),
|
|
283
|
+
// Set the `y` value of this array key item
|
|
284
|
+
(0, $7XdDa$set)(y, [
|
|
285
|
+
{
|
|
286
|
+
_key: key
|
|
287
|
+
},
|
|
288
|
+
"y"
|
|
289
|
+
]),
|
|
290
|
+
]));
|
|
291
|
+
}, [
|
|
292
|
+
onChange
|
|
293
|
+
]);
|
|
294
|
+
const hotspotImageRef = (0, $7XdDa$useRef)(null);
|
|
295
|
+
const [imageRect, setImageRect] = (0, $7XdDa$useState)();
|
|
296
|
+
const updateImageRectCallback = (0, $7XdDa$useDebouncedCallback)((e)=>setImageRect(e.contentRect), [
|
|
297
|
+
setImageRect
|
|
298
|
+
], 200);
|
|
299
|
+
(0, $7XdDa$useResizeObserver)(hotspotImageRef, updateImageRectCallback);
|
|
300
|
+
return /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Stack), {
|
|
301
|
+
space: [
|
|
302
|
+
2,
|
|
303
|
+
2,
|
|
304
|
+
3
|
|
305
|
+
],
|
|
306
|
+
children: [
|
|
307
|
+
displayImage?.url ? /*#__PURE__*/ (0, $7XdDa$jsxs)("div", {
|
|
308
|
+
style: {
|
|
309
|
+
position: `relative`
|
|
310
|
+
},
|
|
311
|
+
children: [
|
|
312
|
+
imageRect && (value?.length ?? 0) > 0 && value?.map((spot, index)=>/*#__PURE__*/ (0, $7XdDa$jsx)((0, $ad617f9fb52013ae$export$2e2bcd8739ae039), {
|
|
313
|
+
index: index,
|
|
314
|
+
value: spot,
|
|
315
|
+
bounds: imageRect,
|
|
316
|
+
update: handleHotspotMove,
|
|
317
|
+
hotspotDescriptionPath: imageHotspotOptions?.descriptionPath,
|
|
318
|
+
tooltip: imageHotspotOptions?.tooltip,
|
|
319
|
+
renderPreview: renderPreview,
|
|
320
|
+
schemaType: schemaType.of[0]
|
|
321
|
+
}, spot._key)),
|
|
322
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Card), {
|
|
323
|
+
__unstable_checkered: true,
|
|
324
|
+
shadow: 1,
|
|
325
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Flex), {
|
|
326
|
+
align: "center",
|
|
327
|
+
justify: "center",
|
|
328
|
+
children: /*#__PURE__*/ (0, $7XdDa$jsx)("img", {
|
|
329
|
+
ref: hotspotImageRef,
|
|
330
|
+
src: displayImage.url,
|
|
331
|
+
width: displayImage.width,
|
|
332
|
+
height: displayImage.height,
|
|
333
|
+
alt: "",
|
|
334
|
+
style: $3fa33a99b88eeab6$var$imageStyle,
|
|
335
|
+
onClick: handleHotspotImageClick
|
|
336
|
+
})
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
]
|
|
340
|
+
}) : /*#__PURE__*/ (0, $7XdDa$jsx)((0, $60d135b0057fb272$export$2e2bcd8739ae039), {
|
|
341
|
+
children: imageHotspotOptions.imagePath ? /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
342
|
+
children: [
|
|
343
|
+
"No Hotspot image found at path ",
|
|
344
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("code", {
|
|
345
|
+
children: imageHotspotOptions.imagePath
|
|
346
|
+
})
|
|
347
|
+
]
|
|
348
|
+
}) : /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $7XdDa$Fragment), {
|
|
349
|
+
children: [
|
|
350
|
+
"Define a path in this field using to the image field in this document at",
|
|
351
|
+
" ",
|
|
352
|
+
/*#__PURE__*/ (0, $7XdDa$jsx)("code", {
|
|
353
|
+
children: "options.hotspotImagePath"
|
|
354
|
+
})
|
|
355
|
+
]
|
|
356
|
+
})
|
|
357
|
+
}),
|
|
358
|
+
imageHotspotOptions.pathRoot && !$3fa33a99b88eeab6$var$VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot) && /*#__PURE__*/ (0, $7XdDa$jsxs)((0, $60d135b0057fb272$export$2e2bcd8739ae039), {
|
|
359
|
+
children: [
|
|
360
|
+
'The supplied imageHotspotPathRoot "',
|
|
361
|
+
imageHotspotOptions.pathRoot,
|
|
362
|
+
'" is not valid, falling back to "document". Available values are "',
|
|
363
|
+
$3fa33a99b88eeab6$var$VALID_ROOT_PATHS.join(", "),
|
|
364
|
+
'".'
|
|
365
|
+
]
|
|
366
|
+
}),
|
|
367
|
+
props.renderDefault(props)
|
|
368
|
+
]
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
const $357f50a17451fe9f$export$2e97a933fd61fb01 = (0, $7XdDa$createPlugin)({
|
|
376
|
+
name: "image-hotspot-array",
|
|
377
|
+
form: {
|
|
378
|
+
components: {
|
|
379
|
+
input: (props)=>{
|
|
380
|
+
if (props.schemaType.jsonType === "array" && props.schemaType.options?.imageHotspot) {
|
|
381
|
+
const imageHotspotOptions = props.schemaType.options?.imageHotspot;
|
|
382
|
+
if (imageHotspotOptions) return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $3fa33a99b88eeab6$export$aa9dd3c5642820fe), {
|
|
383
|
+
...props,
|
|
384
|
+
imageHotspotOptions: imageHotspotOptions
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return props.renderDefault(props);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
export {$357f50a17451fe9f$export$2e97a933fd61fb01 as imageHotspotArrayPlugin, $3fa33a99b88eeab6$export$aa9dd3c5642820fe as ImageHotspotArray};
|
|
395
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;ACEA;;;;;;;;;ACFA;;;AAGe,kDAAkB,YAAC,QAAQ,CAAA,EAAwB,EAAE;IAClE,qBACE,gBAAC,CAAA,GAAA,WAAI,CAAA;QAAC,OAAO,EAAE,CAAC;QAAE,MAAM,EAAE,CAAC;QAAE,MAAM,EAAE,CAAC;QAAE,IAAI,EAAC,SAAS;kBACpD,cAAA,gBAAC,CAAA,GAAA,WAAI,CAAA;sBAAE,QAAQ;UAAQ;MAClB,CACR;CACF;;;ACRD;;;;;AAOA,MAAM,+BAAS,GAAkB;IAC/B,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,YAAY;IACvB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,qBAAqB;IAC7B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AAS,iBAC5B;;wBAAE,iCAC+B;sCAAA,gBAAC,MAAI;sCAAE,mBAAmB,CAAC,SAAS;0BAAQ;;kBAC1E,iBAEH;;wBAAE,0EACwE;wBAAC,GAAG;sCAC5E,gBAAC,MAAI;sCAAC,0BAAwB;0BAAO;;kBACpC,AACJ;cACQ,AACZ;YACA,mBAAmB,CAAC,QAAQ,IAAI,CAAC,sCAAgB,CAAC,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,CAAC,kBACvF,iBAAC,CAAA,GAAA,wCAAQ,CAAA;;oBAAC,qCAC2B;oBAAC,mBAAmB,CAAC,QAAQ;oBAAC,oEACvB;oBAAC,sCAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;oBAAC,IACzE;;cAAW,AACZ;YACA,KAAK,CAAC,aAAa,CAAC,KAAK,CAAwC;;MAC5D,CACT;CACF;;;;;ADtKM,MAAM,yCAAuB,GAAG,CAAA,GAAA,mBAAY,CAAA,CAAC;IAClD,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,KAAK,GAAK;gBAChB,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE;oBACnF,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY;oBAClE,IAAI,mBAAmB,EACrB,qBACE,gBAAC,CAAA,GAAA,yCAAiB,CAAA;wBACf,GAAI,KAAK;wBACV,mBAAmB,EAAE,mBAAmB;sBACxC,CACH;iBAEJ;gBACD,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;aAClC;SACF;KACF;CACF,CAAC","sources":["src/index.tsx","src/ImageHotspotArray.tsx","src/Feedback.tsx","src/Spot.tsx"],"sourcesContent":["import {ImageHotspotArray, type HotspotItem} from './ImageHotspotArray'\nimport React, {ComponentType} from 'react'\nimport {ArrayOfObjectsInputProps, createPlugin} from 'sanity'\nimport {type HotspotTooltipProps} from './Spot'\n\nexport interface ImageHotspotOptions<HotspotFields = {[key: string]: unknown}> {\n pathRoot?: 'document' | 'parent'\n imagePath: string\n descriptionPath?: string\n tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>\n}\n\ndeclare module '@sanity/types' {\n export interface ArrayOptions {\n imageHotspot?: ImageHotspotOptions\n }\n}\n\nexport {ImageHotspotArray}\nexport type {HotspotTooltipProps, HotspotItem}\n\nexport const imageHotspotArrayPlugin = createPlugin({\n name: 'image-hotspot-array',\n form: {\n components: {\n input: (props) => {\n if (props.schemaType.jsonType === 'array' && props.schemaType.options?.imageHotspot) {\n const imageHotspotOptions = props.schemaType.options?.imageHotspot\n if (imageHotspotOptions) {\n return (\n <ImageHotspotArray\n {...(props as unknown as ArrayOfObjectsInputProps<HotspotItem>)}\n imageHotspotOptions={imageHotspotOptions}\n />\n )\n }\n }\n return props.renderDefault(props)\n },\n },\n },\n})\n","/* eslint-disable react/display-name */\n\nimport {getImageDimensions} from '@sanity/asset-utils'\nimport {\n ArrayOfObjectsInputProps,\n ImageValue,\n insert,\n ObjectSchemaType,\n PatchEvent,\n set,\n setIfMissing,\n useClient,\n useFormValue,\n} from 'sanity'\nimport imageUrlBuilder from '@sanity/image-url'\nimport {Card, Flex, Stack} from '@sanity/ui'\nimport {randomKey} from '@sanity/util/content'\nimport get from 'lodash/get'\nimport React, {useCallback, useMemo, useRef, useState} from 'react'\n\nimport {IUseResizeObserverCallback, useDebouncedCallback, useResizeObserver} from '@react-hookz/web'\nimport Feedback from './Feedback'\nimport Spot from './Spot'\nimport {ImageHotspotOptions} from './index'\n\nconst imageStyle = {width: `100%`, height: `auto`}\n\nconst VALID_ROOT_PATHS = ['document', 'parent']\n\nexport type FnHotspotMove = (key: string, x: number, y: number) => void\n\nexport type HotspotItem<HotspotFields = {[key: string]: unknown}> = {\n _key: string\n _type: string\n x: number\n y: number\n} & HotspotFields\n\nexport function ImageHotspotArray(\n props: ArrayOfObjectsInputProps<HotspotItem> & {imageHotspotOptions: ImageHotspotOptions}\n) {\n const {value, onChange, imageHotspotOptions, schemaType, renderPreview} = props\n\n const sanityClient = useClient({apiVersion: '2022-01-01'})\n\n const imageHotspotPathRoot = useMemo(() => {\n const pathRoot = VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot ?? '')\n ? imageHotspotOptions.pathRoot\n : 'document'\n return pathRoot === 'document' ? [] : props.path.slice(0, -1)\n }, [imageHotspotOptions.pathRoot, props.path])\n\n const rootObject = useFormValue(imageHotspotPathRoot)\n\n /**\n * Finding the image from the imageHotspotPathRoot (defaults to document),\n * using the path from the hotspot's `options` field\n *\n * when changes in imageHotspotPathRoot (e.g. document) occur,\n * check if there are any changes to the hotspotImage and update the reference\n */\n const hotspotImage = useMemo(() => {\n return get(rootObject, imageHotspotOptions.imagePath) as ImageValue | undefined\n }, [rootObject, imageHotspotOptions.imagePath])\n\n const displayImage = useMemo(() => {\n const builder = imageUrlBuilder(sanityClient).dataset(sanityClient.config().dataset ?? '')\n const urlFor = (source: ImageValue) => builder.image(source)\n\n if (hotspotImage?.asset?._ref) {\n const {aspectRatio} = getImageDimensions(hotspotImage.asset._ref)\n const width = 1200\n const height = Math.round(width / aspectRatio)\n const url = urlFor(hotspotImage).width(width).url()\n\n return {width, height, url}\n }\n\n return null\n }, [hotspotImage, sanityClient])\n\n const handleHotspotImageClick = useCallback(\n (event: any) => {\n const {nativeEvent} = event\n\n // Calculate the x/y percentage of the click position\n const x = Number(((nativeEvent.offsetX * 100) / nativeEvent.srcElement.width).toFixed(2))\n const y = Number(((nativeEvent.offsetY * 100) / nativeEvent.srcElement.height).toFixed(2))\n const description = `New Hotspot at ${x}% x ${y}%`\n\n const newRow: HotspotItem = {\n _key: randomKey(12),\n _type: schemaType.of[0].name,\n x,\n y,\n }\n\n if (imageHotspotOptions?.descriptionPath) {\n newRow[imageHotspotOptions.descriptionPath] = description\n }\n\n onChange(PatchEvent.from([setIfMissing([]), insert([newRow], 'after', [-1])]))\n },\n [imageHotspotOptions, onChange, schemaType]\n )\n\n const handleHotspotMove: FnHotspotMove = useCallback(\n (key, x, y) => {\n onChange(\n PatchEvent.from([\n // Set the `x` value of this array key item\n set(x, [{_key: key}, 'x']),\n // Set the `y` value of this array key item\n set(y, [{_key: key}, 'y']),\n ])\n )\n },\n [onChange]\n )\n\n const hotspotImageRef = useRef<HTMLImageElement | null>(null)\n\n const [imageRect, setImageRect] = useState<DOMRectReadOnly>()\n const updateImageRectCallback = useDebouncedCallback(\n ((e) => setImageRect(e.contentRect)) as IUseResizeObserverCallback,\n [setImageRect],\n 200\n )\n useResizeObserver(hotspotImageRef, updateImageRectCallback)\n\n return (\n <Stack space={[2, 2, 3]}>\n {displayImage?.url ? (\n <div style={{position: `relative`}}>\n {imageRect &&\n (value?.length ?? 0) > 0 &&\n value?.map((spot, index) => (\n <Spot\n index={index}\n key={spot._key}\n value={spot}\n bounds={imageRect}\n update={handleHotspotMove}\n hotspotDescriptionPath={imageHotspotOptions?.descriptionPath}\n tooltip={imageHotspotOptions?.tooltip}\n renderPreview={renderPreview}\n schemaType={schemaType.of[0] as ObjectSchemaType}\n />\n ))}\n\n <Card __unstable_checkered shadow={1}>\n <Flex align=\"center\" justify=\"center\">\n <img\n ref={hotspotImageRef}\n src={displayImage.url}\n width={displayImage.width}\n height={displayImage.height}\n alt=\"\"\n style={imageStyle}\n onClick={handleHotspotImageClick}\n />\n </Flex>\n </Card>\n </div>\n ) : (\n <Feedback>\n {imageHotspotOptions.imagePath ? (\n <>\n No Hotspot image found at path <code>{imageHotspotOptions.imagePath}</code>\n </>\n ) : (\n <>\n Define a path in this field using to the image field in this document at{' '}\n <code>options.hotspotImagePath</code>\n </>\n )}\n </Feedback>\n )}\n {imageHotspotOptions.pathRoot && !VALID_ROOT_PATHS.includes(imageHotspotOptions.pathRoot) && (\n <Feedback>\n The supplied imageHotspotPathRoot \"{imageHotspotOptions.pathRoot}\" is not valid, falling\n back to \"document\". Available values are \"{VALID_ROOT_PATHS.join(', ')}\".\n </Feedback>\n )}\n {props.renderDefault(props as unknown as ArrayOfObjectsInputProps)}\n </Stack>\n )\n}\n","import React, {ReactNode} from 'react'\nimport {Card, Text} from '@sanity/ui'\n\nexport default function Feedback({children}: {children: ReactNode}) {\n return (\n <Card padding={4} radius={2} shadow={1} tone=\"caution\">\n <Text>{children}</Text>\n </Card>\n )\n}\n","/* eslint-disable */\nimport {Box, Text, Tooltip} from '@sanity/ui'\nimport {motion, useMotionValue} from 'framer-motion'\nimport get from 'lodash/get'\nimport React, {ComponentType, CSSProperties, ReactElement, useEffect} from 'react'\nimport {FnHotspotMove, HotspotItem} from './ImageHotspotArray'\nimport {ObjectSchemaType, RenderPreviewCallback} from 'sanity'\n\nconst dragStyle: CSSProperties = {\n width: '1.4rem',\n height: '1.4rem',\n position: 'absolute',\n boxSizing: 'border-box',\n top: 0,\n left: 0,\n margin: '-0.7rem 0 0 -0.7rem',\n cursor: 'pointer',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n borderRadius: '50%',\n background: '#000',\n color: 'white',\n}\n\nconst dragStyleWhileDrag: CSSProperties = {\n background: 'rgba(0, 0, 0, 0.1)',\n border: '1px solid #fff',\n cursor: 'none',\n}\n\nconst dragStyleWhileHover: CSSProperties = {\n background: 'rgba(0, 0, 0, 0.1)',\n border: '1px solid #fff',\n}\n\nconst dotStyle: CSSProperties = {\n position: 'absolute',\n left: '50%',\n top: '50%',\n height: '0.2rem',\n width: '0.2rem',\n margin: '-0.1rem 0 0 -0.1rem',\n background: '#fff',\n visibility: 'hidden',\n borderRadius: '50%',\n // make sure pointer events only run on the parent\n pointerEvents: 'none',\n}\n\nconst dotStyleWhileActive: CSSProperties = {\n visibility: 'visible',\n}\n\nconst labelStyle: CSSProperties = {\n color: 'white',\n fontSize: '0.7rem',\n fontWeight: 600,\n lineHeight: '1',\n}\n\nconst labelStyleWhileActive: CSSProperties = {\n visibility: 'hidden',\n}\n\nconst round = (num: number) => Math.round(num * 100) / 100\n\nexport interface HotspotTooltipProps<HotspotFields = {[key: string]: unknown}> {\n value: HotspotItem<HotspotFields>\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n}\n\ninterface HotspotProps<HotspotFields = {[key: string]: unknown}> {\n value: HotspotItem\n bounds: DOMRectReadOnly\n update: FnHotspotMove\n hotspotDescriptionPath?: string\n tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>\n index: number\n schemaType: ObjectSchemaType\n renderPreview: RenderPreviewCallback\n}\n\nexport default function Spot({\n value,\n bounds,\n update,\n hotspotDescriptionPath,\n tooltip,\n index,\n schemaType,\n renderPreview,\n}: HotspotProps) {\n const [isDragging, setIsDragging] = React.useState(false)\n const [isHovering, setIsHovering] = React.useState(false)\n\n // x/y are stored as % but need to be converted to px\n const x = useMotionValue(round(bounds.width * (value.x / 100)))\n const y = useMotionValue(round(bounds.height * (value.y / 100)))\n\n /**\n * update x/y if the bounds change when resizing the window\n */\n useEffect(() => {\n x.set(round(bounds.width * (value.x / 100)))\n y.set(round(bounds.height * (value.y / 100)))\n }, [x, y, value, bounds])\n\n const handleDragEnd = React.useCallback(() => {\n setIsDragging(false)\n\n // get current values for x/y in px\n const currentX = x.get()\n const currentY = y.get()\n\n // Which we need to convert back to `%` to patch the document\n const newX = round((currentX * 100) / bounds.width)\n const newY = round((currentY * 100) / bounds.height)\n\n // Don't go below 0 or above 100\n const safeX = Math.max(0, Math.min(100, newX))\n const safeY = Math.max(0, Math.min(100, newY))\n\n update(value._key, safeX, safeY)\n }, [x, y, value, update, bounds])\n const handleDragStart = React.useCallback(() => setIsDragging(true), [])\n\n const handleHoverStart = React.useCallback(() => setIsHovering(true), [])\n const handleHoverEnd = React.useCallback(() => setIsHovering(false), [])\n\n if (!x || !y) {\n return null\n }\n\n return (\n <Tooltip\n key={value._key}\n disabled={isDragging}\n portal\n content={\n tooltip && typeof tooltip === 'function' ? (\n React.createElement(tooltip, {value, renderPreview, schemaType})\n ) : (\n <Box padding={2} style={{maxWidth: 200, pointerEvents: `none`}}>\n <Text textOverflow=\"ellipsis\">\n {hotspotDescriptionPath\n ? (get(value, hotspotDescriptionPath) as string)\n : `${value.x}% x ${value.y}%`}\n </Text>\n </Box>\n )\n }\n >\n <motion.div\n drag\n dragConstraints={bounds}\n dragElastic={0}\n dragMomentum={false}\n onDragEnd={handleDragEnd}\n onDragStart={handleDragStart}\n onHoverStart={handleHoverStart}\n onHoverEnd={handleHoverEnd}\n style={{\n ...dragStyle,\n x,\n y,\n ...(isDragging && {...dragStyleWhileDrag}),\n ...(isHovering && {...dragStyleWhileHover}),\n }}\n >\n {/* Dot */}\n <Box\n style={{\n ...dotStyle,\n ...((isDragging || isHovering) && {...dotStyleWhileActive}),\n }}\n />\n {/* Label */}\n <div\n style={{\n ...labelStyle,\n ...((isDragging || isHovering) && {...labelStyleWhileActive}),\n }}\n >\n {index + 1}\n </div>\n </motion.div>\n </Tooltip>\n )\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ObjectSchemaType, RenderPreviewCallback, ArrayOfObjectsInputProps } from "sanity";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
export interface HotspotTooltipProps<HotspotFields = {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
}> {
|
|
6
|
+
value: HotspotItem<HotspotFields>;
|
|
7
|
+
schemaType: ObjectSchemaType;
|
|
8
|
+
renderPreview: RenderPreviewCallback;
|
|
9
|
+
}
|
|
10
|
+
export type HotspotItem<HotspotFields = {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}> = {
|
|
13
|
+
_key: string;
|
|
14
|
+
_type: string;
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
} & HotspotFields;
|
|
18
|
+
export function ImageHotspotArray(props: ArrayOfObjectsInputProps<HotspotItem> & {
|
|
19
|
+
imageHotspotOptions: ImageHotspotOptions;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
export interface ImageHotspotOptions<HotspotFields = {
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}> {
|
|
24
|
+
pathRoot?: 'document' | 'parent';
|
|
25
|
+
imagePath: string;
|
|
26
|
+
descriptionPath?: string;
|
|
27
|
+
tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>;
|
|
28
|
+
}
|
|
29
|
+
declare module '@sanity/types' {
|
|
30
|
+
interface ArrayOptions {
|
|
31
|
+
imageHotspot?: ImageHotspotOptions;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const imageHotspotArrayPlugin: import("sanity").Plugin<void>;
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;ACmEA,qCAAqC,aAAa,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC;IAC3E,KAAK,EAAE,YAAY,aAAa,CAAC,CAAA;IACjC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,aAAa,EAAE,qBAAqB,CAAA;CACrC;ACxCD,wBAAwB,aAAa,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,IAAI;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,GAAG,aAAa,CAAA;AAEjB,kCACE,KAAK,EAAE,yBAAyB,WAAW,CAAC,GAAG;IAAC,mBAAmB,EAAE,mBAAmB,CAAA;CAAC,eAoJ1F;ACtLD,qCAAqC,aAAa,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC;IAC3E,QAAQ,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,cAAc,oBAAoB,aAAa,CAAC,CAAC,CAAA;CAC5D;AAED,eAAe,eAAe,CAAC;IAC7B,UAAiB,YAAY;QAC3B,YAAY,CAAC,EAAE,mBAAmB,CAAA;KACnC;CACF;AAKD,OAAO,MAAM,sDAoBX,CAAA","sources":["src/src/Feedback.tsx","src/src/Spot.tsx","src/src/ImageHotspotArray.tsx","src/src/index.tsx","src/index.tsx"],"sourcesContent":[null,null,null,null,"import {ImageHotspotArray, type HotspotItem} from './ImageHotspotArray'\nimport React, {ComponentType} from 'react'\nimport {ArrayOfObjectsInputProps, createPlugin} from 'sanity'\nimport {type HotspotTooltipProps} from './Spot'\n\nexport interface ImageHotspotOptions<HotspotFields = {[key: string]: unknown}> {\n pathRoot?: 'document' | 'parent'\n imagePath: string\n descriptionPath?: string\n tooltip?: ComponentType<HotspotTooltipProps<HotspotFields>>\n}\n\ndeclare module '@sanity/types' {\n export interface ArrayOptions {\n imageHotspot?: ImageHotspotOptions\n }\n}\n\nexport {ImageHotspotArray}\nexport type {HotspotTooltipProps, HotspotItem}\n\nexport const imageHotspotArrayPlugin = createPlugin({\n name: 'image-hotspot-array',\n form: {\n components: {\n input: (props) => {\n if (props.schemaType.jsonType === 'array' && props.schemaType.options?.imageHotspot) {\n const imageHotspotOptions = props.schemaType.options?.imageHotspot\n if (imageHotspotOptions) {\n return (\n <ImageHotspotArray\n {...(props as unknown as ArrayOfObjectsInputProps<HotspotItem>)}\n imageHotspotOptions={imageHotspotOptions}\n />\n )\n }\n }\n return props.renderDefault(props)\n },\n },\n },\n})\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../"}
|