@foundrykit/payload-fields 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +208 -2
- package/dist/exports/client.d.ts +8 -0
- package/dist/exports/client.js +10 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/fields/address/AddressInput.d.ts +7 -0
- package/dist/fields/address/AddressInput.js +203 -0
- package/dist/fields/address/AddressInput.js.map +1 -0
- package/dist/fields/address/index.d.ts +8 -0
- package/dist/fields/address/index.js +77 -0
- package/dist/fields/address/index.js.map +1 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.d.ts +3 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.js +206 -0
- package/dist/fields/bestTimeToVisit/MonthRatingField.js.map +1 -0
- package/dist/fields/bestTimeToVisit/index.d.ts +6 -0
- package/dist/fields/bestTimeToVisit/index.js +82 -0
- package/dist/fields/bestTimeToVisit/index.js.map +1 -0
- package/dist/fields/budget/PriceInput.d.ts +3 -0
- package/dist/fields/budget/PriceInput.js +65 -0
- package/dist/fields/budget/PriceInput.js.map +1 -0
- package/dist/fields/budget/RowLabel.d.ts +3 -0
- package/dist/fields/budget/RowLabel.js +22 -0
- package/dist/fields/budget/RowLabel.js.map +1 -0
- package/dist/fields/budget/index.d.ts +8 -0
- package/dist/fields/budget/index.js +111 -0
- package/dist/fields/budget/index.js.map +1 -0
- package/dist/fields/changedBy/index.d.ts +11 -0
- package/dist/fields/changedBy/index.js +30 -0
- package/dist/fields/changedBy/index.js.map +1 -0
- package/dist/fields/changedBy/populateChangedBy.d.ts +3 -0
- package/dist/fields/changedBy/populateChangedBy.js +12 -0
- package/dist/fields/changedBy/populateChangedBy.js.map +1 -0
- package/dist/fields/countryCode/index.d.ts +11 -0
- package/dist/fields/countryCode/index.js +880 -0
- package/dist/fields/countryCode/index.js.map +1 -0
- package/dist/fields/dateRange/DateRangeComponent.d.ts +3 -0
- package/dist/fields/dateRange/DateRangeComponent.js +77 -0
- package/dist/fields/dateRange/DateRangeComponent.js.map +1 -0
- package/dist/fields/dateRange/index.d.ts +11 -0
- package/dist/fields/dateRange/index.js +26 -0
- package/dist/fields/dateRange/index.js.map +1 -0
- package/dist/fields/gallery/index.d.ts +10 -0
- package/dist/fields/gallery/index.js +23 -0
- package/dist/fields/gallery/index.js.map +1 -0
- package/dist/fields/icon/index.d.ts +8 -0
- package/dist/fields/icon/index.js +30 -0
- package/dist/fields/icon/index.js.map +1 -0
- package/dist/fields/imageMap/ImageMapField.d.ts +13 -0
- package/dist/fields/imageMap/ImageMapField.js +67 -0
- package/dist/fields/imageMap/ImageMapField.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.d.ts +13 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.js +225 -0
- package/dist/fields/imageMap/MapEditor/MapEditor.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.d.ts +12 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.js +61 -0
- package/dist/fields/imageMap/MapEditor/PinContextMenu.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.d.ts +14 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.js +103 -0
- package/dist/fields/imageMap/MapEditor/WaypointPopover.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.d.ts +9 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.js +190 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.js.map +1 -0
- package/dist/fields/imageMap/MapEditor/WaypointSheet.scss +128 -0
- package/dist/fields/imageMap/MapEditor/map-editor.scss +556 -0
- package/dist/fields/imageMap/MapEditor/types.d.ts +20 -0
- package/dist/fields/imageMap/MapEditor/types.js +3 -0
- package/dist/fields/imageMap/MapEditor/types.js.map +1 -0
- package/dist/fields/imageMap/index.d.ts +16 -0
- package/dist/fields/imageMap/index.js +35 -0
- package/dist/fields/imageMap/index.js.map +1 -0
- package/dist/fields/link/index.d.ts +21 -0
- package/dist/fields/link/index.js +134 -0
- package/dist/fields/link/index.js.map +1 -0
- package/dist/fields/link/resolveLink.d.ts +28 -0
- package/dist/fields/link/resolveLink.js +26 -0
- package/dist/fields/link/resolveLink.js.map +1 -0
- package/dist/fields/openingTimes/RowLabel.d.ts +2 -0
- package/dist/fields/openingTimes/RowLabel.js +12 -0
- package/dist/fields/openingTimes/RowLabel.js.map +1 -0
- package/dist/fields/openingTimes/index.d.ts +8 -0
- package/dist/fields/openingTimes/index.js +22 -0
- package/dist/fields/openingTimes/index.js.map +1 -0
- package/dist/fields/openingTimes/opening-time.d.ts +6 -0
- package/dist/fields/openingTimes/opening-time.js +37 -0
- package/dist/fields/openingTimes/opening-time.js.map +1 -0
- package/dist/fields/socials/index.d.ts +7 -0
- package/dist/fields/socials/index.js +70 -0
- package/dist/fields/socials/index.js.map +1 -0
- package/dist/fields/tags/RowLabel.d.ts +2 -0
- package/dist/fields/tags/RowLabel.js +12 -0
- package/dist/fields/tags/RowLabel.js.map +1 -0
- package/dist/fields/tags/index.d.ts +10 -0
- package/dist/fields/tags/index.js +22 -0
- package/dist/fields/tags/index.js.map +1 -0
- package/dist/fields/tags/tag.d.ts +6 -0
- package/dist/fields/tags/tag.js +18 -0
- package/dist/fields/tags/tag.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/utilities/deepMerge.d.ts +4 -0
- package/dist/utilities/deepMerge.js +30 -0
- package/dist/utilities/deepMerge.js.map +1 -0
- package/package.json +118 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/imageMap/MapEditor/MapEditor.tsx"],"sourcesContent":["'use client';\nimport * as Tooltip from '@radix-ui/react-tooltip';\nimport { MapPin } from 'lucide-react';\nimport { useEffect, useRef, useState } from 'react';\nimport './map-editor.scss';\nimport './WaypointSheet.scss';\nimport { PinContextMenu } from './PinContextMenu.js';\nimport type { ImageMapValue, MapImage, Waypoint } from './types.js';\nimport { WaypointPopover } from './WaypointPopover.js';\nimport { WaypointSheet } from './WaypointSheet.js';\n\ntype PopoverState = { mode: 'add'; x: number; y: number } | null;\n\n/**\n * The interactive editor. Purely controlled: it renders `value.waypoints` over\n * `image` and calls `onChange` with the next value on every add/edit/delete.\n * Persistence is the parent field's concern (Payload saves the field).\n */\nexport default function MapEditor({\n value = {},\n image,\n onChange,\n}: {\n value?: ImageMapValue;\n image: MapImage;\n onChange: (next: ImageMapValue) => void;\n}) {\n const mapRef = useRef<HTMLImageElement>(null);\n const cursor = useMousePositionWithinDiv({ divRef: mapRef });\n const [waypoints, setWaypoints] = useState<Waypoint[]>(value.waypoints || []);\n const [popoverState, setPopoverState] = useState<PopoverState>(null);\n const [newWaypointName, setNewWaypointName] = useState('');\n const [editDialogOpen, setEditDialogOpen] = useState(false);\n const [editingWaypoint, setEditingWaypoint] = useState<Waypoint | null>(null);\n\n useEffect(() => {\n setWaypoints(value.waypoints || []);\n }, [value.waypoints]);\n\n const commit = (next: Waypoint[]) => {\n setWaypoints(next);\n onChange({ ...value, waypoints: next });\n };\n\n const handleClick = () => {\n if (cursor.x >= 0 && cursor.y >= 0 && mapRef.current) {\n const rect = mapRef.current.getBoundingClientRect();\n setPopoverState({\n mode: 'add',\n x: (cursor.x / rect.width) * 100,\n y: (cursor.y / rect.height) * 100,\n });\n setNewWaypointName('');\n }\n };\n\n const handleNameSubmit = (name: string) => {\n if (name.trim() && popoverState) {\n const newWaypoint: Waypoint = {\n id: `${popoverState.x.toFixed(2)}-${popoverState.y.toFixed(2)}-${waypoints.length}`,\n x: popoverState.x,\n y: popoverState.y,\n name,\n };\n commit([...waypoints, newWaypoint]);\n setPopoverState(null);\n setNewWaypointName('');\n }\n };\n\n const handleEditWaypoint = (wp: Waypoint) =>\n commit(waypoints.map(w => (w.id === wp.id ? wp : w)));\n const handleRemoveWaypoint = (id: string) =>\n commit(waypoints.filter(w => w.id !== id));\n\n const cursorPercent = (axis: 'x' | 'y') => {\n if (!mapRef.current) return 0;\n const rect = mapRef.current.getBoundingClientRect();\n const size = axis === 'x' ? rect.width : rect.height;\n return cursor[axis] >= 0 ? Math.round((cursor[axis] / size) * 100) : 0;\n };\n\n return (\n <Tooltip.Provider>\n <div className='map-editor'>\n <div className='map-editor__header'>\n <div className='map-editor__header-title'>\n <h2>Map Editor</h2>\n </div>\n <div className='map-editor__header-actions'>\n <div className='map-editor__waypoints'>\n {waypoints.map(waypoint => (\n <div key={waypoint.id} className='map-editor__waypoint'>\n <span>\n {waypoint.name}: [{Math.round(waypoint.x)}%,{' '}\n {Math.round(waypoint.y)}%]\n </span>\n <button\n type='button'\n className='map-editor__remove'\n onClick={() => handleRemoveWaypoint(waypoint.id)}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n </div>\n </div>\n\n <div className='map-editor__image-container'>\n {/* eslint-disable-next-line @next/next/no-img-element */}\n <img\n src={image.url || ''}\n alt={image.alt || ''}\n width={image.width || undefined}\n height={image.height || undefined}\n ref={mapRef}\n onClick={handleClick}\n />\n {waypoints.map(waypoint => (\n <PinContextMenu\n key={waypoint.id}\n waypoint={waypoint}\n onEdit={() => {\n setEditingWaypoint(waypoint);\n setEditDialogOpen(true);\n }}\n onDelete={() => handleRemoveWaypoint(waypoint.id)}\n >\n <button\n type='button'\n className='map-editor__waypoint-dot'\n style={{ left: `${waypoint.x}%`, top: `${waypoint.y}%` }}\n aria-label={`Pin: ${waypoint.name}`}\n >\n <MapPin />\n </button>\n </PinContextMenu>\n ))}\n {popoverState?.mode === 'add' && (\n <WaypointPopover\n open={popoverState?.mode === 'add'}\n mode='add'\n onOpenChange={open => {\n if (!open) setPopoverState(null);\n }}\n nameValue={newWaypointName}\n setNameValue={setNewWaypointName}\n onSaveName={handleNameSubmit}\n onCancel={() => setPopoverState(null)}\n trigger={\n <div\n style={{\n position: 'absolute',\n left: `${popoverState.x}%`,\n top: `${popoverState.y}%`,\n width: 1,\n height: 1,\n pointerEvents: 'none',\n }}\n />\n }\n />\n )}\n {editingWaypoint && (\n <WaypointSheet\n open={editDialogOpen}\n onOpenChange={setEditDialogOpen}\n waypoint={editingWaypoint}\n onSave={(wp: Waypoint) => {\n handleEditWaypoint(wp);\n setEditDialogOpen(false);\n }}\n onCancel={() => setEditDialogOpen(false)}\n />\n )}\n <p className='map-editor__coordinates'>\n [x: {cursorPercent('x')}%, y: {cursorPercent('y')}%]\n </p>\n </div>\n </div>\n </Tooltip.Provider>\n );\n}\n\nfunction useMousePositionWithinDiv({\n divRef,\n}: {\n divRef: React.RefObject<HTMLImageElement | null>;\n}) {\n const [mousePosition, setMousePosition] = useState<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n useEffect(() => {\n const updateMousePosition = (ev: MouseEvent) => {\n if (divRef.current) {\n const rect = divRef.current.getBoundingClientRect();\n const x = ev.clientX - rect.left;\n const y = ev.clientY - rect.top;\n if (x >= 0 && y >= 0) setMousePosition({ x, y });\n }\n };\n const div = divRef.current;\n if (div) {\n div.addEventListener('mousemove', updateMousePosition);\n div.addEventListener('click', updateMousePosition);\n }\n return () => {\n if (div) {\n div.removeEventListener('mousemove', updateMousePosition);\n div.removeEventListener('click', updateMousePosition);\n }\n };\n }, [divRef]);\n return mousePosition;\n}\n"],"names":["Tooltip","MapPin","useEffect","useRef","useState","PinContextMenu","WaypointPopover","WaypointSheet","MapEditor","value","image","onChange","mapRef","cursor","useMousePositionWithinDiv","divRef","waypoints","setWaypoints","popoverState","setPopoverState","newWaypointName","setNewWaypointName","editDialogOpen","setEditDialogOpen","editingWaypoint","setEditingWaypoint","commit","next","handleClick","x","y","current","rect","getBoundingClientRect","mode","width","height","handleNameSubmit","name","trim","newWaypoint","id","toFixed","length","handleEditWaypoint","wp","map","w","handleRemoveWaypoint","filter","cursorPercent","axis","size","Math","round","Provider","div","className","h2","waypoint","span","button","type","onClick","img","src","url","alt","undefined","ref","onEdit","onDelete","style","left","top","aria-label","open","onOpenChange","nameValue","setNameValue","onSaveName","onCancel","trigger","position","pointerEvents","onSave","p","mousePosition","setMousePosition","updateMousePosition","ev","clientX","clientY","addEventListener","removeEventListener"],"mappings":"AAAA;;AACA,YAAYA,aAAa,0BAA0B;AACnD,SAASC,MAAM,QAAQ,eAAe;AACtC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACpD,OAAO,oBAAoB;AAC3B,OAAO,uBAAuB;AAC9B,SAASC,cAAc,QAAQ,sBAAsB;AAErD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,aAAa,QAAQ,qBAAqB;AAInD;;;;CAIC,GACD,eAAe,SAASC,UAAU,EAChCC,QAAQ,CAAC,CAAC,EACVC,KAAK,EACLC,QAAQ,EAKT;IACC,MAAMC,SAAST,OAAyB;IACxC,MAAMU,SAASC,0BAA0B;QAAEC,QAAQH;IAAO;IAC1D,MAAM,CAACI,WAAWC,aAAa,GAAGb,SAAqBK,MAAMO,SAAS,IAAI,EAAE;IAC5E,MAAM,CAACE,cAAcC,gBAAgB,GAAGf,SAAuB;IAC/D,MAAM,CAACgB,iBAAiBC,mBAAmB,GAAGjB,SAAS;IACvD,MAAM,CAACkB,gBAAgBC,kBAAkB,GAAGnB,SAAS;IACrD,MAAM,CAACoB,iBAAiBC,mBAAmB,GAAGrB,SAA0B;IAExEF,UAAU;QACRe,aAAaR,MAAMO,SAAS,IAAI,EAAE;IACpC,GAAG;QAACP,MAAMO,SAAS;KAAC;IAEpB,MAAMU,SAAS,CAACC;QACdV,aAAaU;QACbhB,SAAS;YAAE,GAAGF,KAAK;YAAEO,WAAWW;QAAK;IACvC;IAEA,MAAMC,cAAc;QAClB,IAAIf,OAAOgB,CAAC,IAAI,KAAKhB,OAAOiB,CAAC,IAAI,KAAKlB,OAAOmB,OAAO,EAAE;YACpD,MAAMC,OAAOpB,OAAOmB,OAAO,CAACE,qBAA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L,IAAIjC,KAAK;gBACPA,IAAIsC,mBAAmB,CAAC,aAAaL;gBACrCjC,IAAIsC,mBAAmB,CAAC,SAASL;YACnC;QACF;IACF,GAAG;QAAC1E;KAAO;IACX,OAAOwE;AACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export declare function PinContextMenu({ waypoint, onEdit, onDelete, children, }: {
|
|
3
|
+
waypoint: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
onEdit: () => void;
|
|
10
|
+
onDelete: () => void;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as ContextMenu from '@radix-ui/react-context-menu';
|
|
3
|
+
import * as Tooltip from '@radix-ui/react-tooltip';
|
|
4
|
+
export function PinContextMenu({ waypoint, onEdit, onDelete, children }) {
|
|
5
|
+
return /*#__PURE__*/ _jsxs(Tooltip.Root, {
|
|
6
|
+
delayDuration: 200,
|
|
7
|
+
children: [
|
|
8
|
+
/*#__PURE__*/ _jsxs(ContextMenu.Root, {
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsx(ContextMenu.Trigger, {
|
|
11
|
+
asChild: true,
|
|
12
|
+
children: /*#__PURE__*/ _jsx(Tooltip.Trigger, {
|
|
13
|
+
asChild: true,
|
|
14
|
+
children: children
|
|
15
|
+
})
|
|
16
|
+
}),
|
|
17
|
+
/*#__PURE__*/ _jsxs(ContextMenu.Content, {
|
|
18
|
+
className: "map-editor__context-menu",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ _jsx(ContextMenu.Item, {
|
|
21
|
+
className: "map-editor__context-menu-item",
|
|
22
|
+
onSelect: onEdit,
|
|
23
|
+
children: "Edit"
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ _jsx(ContextMenu.Item, {
|
|
26
|
+
className: "map-editor__context-menu-item map-editor__context-menu-item--delete",
|
|
27
|
+
onSelect: onDelete,
|
|
28
|
+
children: "Delete"
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _jsxs(Tooltip.Content, {
|
|
35
|
+
className: "map-editor__tooltip",
|
|
36
|
+
side: "top",
|
|
37
|
+
align: "center",
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx("div", {
|
|
40
|
+
style: {
|
|
41
|
+
fontWeight: 600
|
|
42
|
+
},
|
|
43
|
+
children: waypoint.name
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ _jsx("div", {
|
|
46
|
+
style: {
|
|
47
|
+
fontSize: '0.85em',
|
|
48
|
+
opacity: 0.8
|
|
49
|
+
},
|
|
50
|
+
children: "Right click for options"
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx(Tooltip.Arrow, {
|
|
53
|
+
className: "map-editor__tooltip-arrow"
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=PinContextMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/imageMap/MapEditor/PinContextMenu.tsx"],"sourcesContent":["import * as ContextMenu from '@radix-ui/react-context-menu';\nimport * as Tooltip from '@radix-ui/react-tooltip';\nimport type React from 'react';\n\nexport function PinContextMenu({\n waypoint,\n onEdit,\n onDelete,\n children,\n}: {\n waypoint: { id: string; name: string; x: number; y: number };\n onEdit: () => void;\n onDelete: () => void;\n children: React.ReactNode;\n}) {\n return (\n <Tooltip.Root delayDuration={200}>\n <ContextMenu.Root>\n <ContextMenu.Trigger asChild>\n <Tooltip.Trigger asChild>{children}</Tooltip.Trigger>\n </ContextMenu.Trigger>\n <ContextMenu.Content className='map-editor__context-menu'>\n <ContextMenu.Item\n className='map-editor__context-menu-item'\n onSelect={onEdit}\n >\n Edit\n </ContextMenu.Item>\n <ContextMenu.Item\n className='map-editor__context-menu-item map-editor__context-menu-item--delete'\n onSelect={onDelete}\n >\n Delete\n </ContextMenu.Item>\n </ContextMenu.Content>\n </ContextMenu.Root>\n <Tooltip.Content\n className='map-editor__tooltip'\n side='top'\n align='center'\n >\n <div style={{ fontWeight: 600 }}>{waypoint.name}</div>\n <div style={{ fontSize: '0.85em', opacity: 0.8 }}>\n Right click for options\n </div>\n <Tooltip.Arrow className='map-editor__tooltip-arrow' />\n </Tooltip.Content>\n </Tooltip.Root>\n );\n}\n"],"names":["ContextMenu","Tooltip","PinContextMenu","waypoint","onEdit","onDelete","children","Root","delayDuration","Trigger","asChild","Content","className","Item","onSelect","side","align","div","style","fontWeight","name","fontSize","opacity","Arrow"],"mappings":";AAAA,YAAYA,iBAAiB,+BAA+B;AAC5D,YAAYC,aAAa,0BAA0B;AAGnD,OAAO,SAASC,eAAe,EAC7BC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EAMT;IACC,qBACE,MAACL,QAAQM,IAAI;QAACC,eAAe;;0BAC3B,MAACR,YAAYO,IAAI;;kCACf,KAACP,YAAYS,OAAO;wBAACC,OAAO;kCAC1B,cAAA,KAACT,QAAQQ,OAAO;4BAACC,OAAO;sCAAEJ;;;kCAE5B,MAACN,YAAYW,OAAO;wBAACC,WAAU;;0CAC7B,KAACZ,YAAYa,IAAI;gCACfD,WAAU;gCACVE,UAAUV;0CACX;;0CAGD,KAACJ,YAAYa,IAAI;gCACfD,WAAU;gCACVE,UAAUT;0CACX;;;;;;0BAKL,MAACJ,QAAQU,OAAO;gBACdC,WAAU;gBACVG,MAAK;gBACLC,OAAM;;kCAEN,KAACC;wBAAIC,OAAO;4BAAEC,YAAY;wBAAI;kCAAIhB,SAASiB,IAAI;;kCAC/C,KAACH;wBAAIC,OAAO;4BAAEG,UAAU;4BAAUC,SAAS;wBAAI;kCAAG;;kCAGlD,KAACrB,QAAQsB,KAAK;wBAACX,WAAU;;;;;;AAIjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
interface WaypointPopoverProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
mode: 'add' | 'delete';
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
onSaveName?: (name: string) => void;
|
|
7
|
+
onDelete?: () => void;
|
|
8
|
+
onCancel?: () => void;
|
|
9
|
+
nameValue?: string;
|
|
10
|
+
setNameValue?: (val: string) => void;
|
|
11
|
+
trigger?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function WaypointPopover({ open, mode, onOpenChange, onSaveName, onDelete, onCancel, nameValue, setNameValue, trigger, }: WaypointPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as Popover from '@radix-ui/react-popover';
|
|
3
|
+
export function WaypointPopover({ open, mode, onOpenChange, onSaveName, onDelete, onCancel, nameValue = '', setNameValue, trigger }) {
|
|
4
|
+
return /*#__PURE__*/ _jsxs(Popover.Root, {
|
|
5
|
+
open: open,
|
|
6
|
+
onOpenChange: onOpenChange,
|
|
7
|
+
children: [
|
|
8
|
+
trigger && /*#__PURE__*/ _jsx(Popover.Trigger, {
|
|
9
|
+
asChild: true,
|
|
10
|
+
children: trigger
|
|
11
|
+
}),
|
|
12
|
+
/*#__PURE__*/ _jsxs(Popover.Content, {
|
|
13
|
+
className: "map-editor__popover-content",
|
|
14
|
+
side: "top",
|
|
15
|
+
sideOffset: -10,
|
|
16
|
+
alignOffset: 0,
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ _jsx("div", {
|
|
19
|
+
className: "map-editor__popover-content-inner",
|
|
20
|
+
children: mode === 'add' ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ _jsx("p", {
|
|
23
|
+
className: "map-editor__popover-content-title",
|
|
24
|
+
children: "Add a new waypoint"
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ _jsx("input", {
|
|
27
|
+
type: "text",
|
|
28
|
+
className: "map-editor__popover-input",
|
|
29
|
+
value: nameValue,
|
|
30
|
+
onChange: (e)=>setNameValue?.(e.target.value),
|
|
31
|
+
placeholder: "Enter waypoint name",
|
|
32
|
+
onKeyDown: (e)=>{
|
|
33
|
+
if (e.key === 'Enter' && onSaveName) onSaveName(nameValue);
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
37
|
+
style: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
gap: 10,
|
|
40
|
+
marginTop: 10
|
|
41
|
+
},
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ _jsx("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
className: "map-editor__popover-button btn btn--size-medium btn--icon-style-without-border",
|
|
46
|
+
onClick: ()=>onSaveName?.(nameValue),
|
|
47
|
+
children: "Save Waypoint"
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ _jsx(Popover.Close, {
|
|
50
|
+
asChild: true,
|
|
51
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
className: "map-editor__popover-button btn btn--size-medium btn--icon-style-without-border",
|
|
54
|
+
onClick: onCancel,
|
|
55
|
+
children: "Cancel"
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ _jsx("p", {
|
|
64
|
+
className: "map-editor__popover-content-title",
|
|
65
|
+
children: "Delete waypoint"
|
|
66
|
+
}),
|
|
67
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
68
|
+
style: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
gap: 10,
|
|
71
|
+
marginTop: 10
|
|
72
|
+
},
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsx("button", {
|
|
75
|
+
type: "button",
|
|
76
|
+
className: "map-editor__popover-button btn",
|
|
77
|
+
onClick: onDelete,
|
|
78
|
+
children: "Delete Waypoint"
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ _jsx(Popover.Close, {
|
|
81
|
+
asChild: true,
|
|
82
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
83
|
+
type: "button",
|
|
84
|
+
className: "map-editor__popover-button btn",
|
|
85
|
+
onClick: onCancel,
|
|
86
|
+
children: "Cancel"
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(Popover.Arrow, {
|
|
95
|
+
className: "map-editor__popover-arrow"
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=WaypointPopover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/imageMap/MapEditor/WaypointPopover.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport type React from 'react';\n\ninterface WaypointPopoverProps {\n open: boolean;\n mode: 'add' | 'delete';\n onOpenChange: (open: boolean) => void;\n onSaveName?: (name: string) => void;\n onDelete?: () => void;\n onCancel?: () => void;\n nameValue?: string;\n setNameValue?: (val: string) => void;\n trigger?: React.ReactNode;\n}\n\nexport function WaypointPopover({\n open,\n mode,\n onOpenChange,\n onSaveName,\n onDelete,\n onCancel,\n nameValue = '',\n setNameValue,\n trigger,\n}: WaypointPopoverProps) {\n return (\n <Popover.Root open={open} onOpenChange={onOpenChange}>\n {trigger && <Popover.Trigger asChild>{trigger}</Popover.Trigger>}\n <Popover.Content\n className='map-editor__popover-content'\n side='top'\n sideOffset={-10}\n alignOffset={0}\n >\n <div className='map-editor__popover-content-inner'>\n {mode === 'add' ? (\n <>\n <p className='map-editor__popover-content-title'>\n Add a new waypoint\n </p>\n <input\n type='text'\n className='map-editor__popover-input'\n value={nameValue}\n onChange={e => setNameValue?.(e.target.value)}\n placeholder='Enter waypoint name'\n onKeyDown={e => {\n if (e.key === 'Enter' && onSaveName) onSaveName(nameValue);\n }}\n />\n <div style={{ display: 'flex', gap: 10, marginTop: 10 }}>\n <button\n type='button'\n className='map-editor__popover-button btn btn--size-medium btn--icon-style-without-border'\n onClick={() => onSaveName?.(nameValue)}\n >\n Save Waypoint\n </button>\n <Popover.Close asChild>\n <button\n type='button'\n className='map-editor__popover-button btn btn--size-medium btn--icon-style-without-border'\n onClick={onCancel}\n >\n Cancel\n </button>\n </Popover.Close>\n </div>\n </>\n ) : (\n <>\n <p className='map-editor__popover-content-title'>\n Delete waypoint\n </p>\n <div style={{ display: 'flex', gap: 10, marginTop: 10 }}>\n <button\n type='button'\n className='map-editor__popover-button btn'\n onClick={onDelete}\n >\n Delete Waypoint\n </button>\n <Popover.Close asChild>\n <button\n type='button'\n className='map-editor__popover-button btn'\n onClick={onCancel}\n >\n Cancel\n </button>\n </Popover.Close>\n </div>\n </>\n )}\n </div>\n <Popover.Arrow className='map-editor__popover-arrow' />\n </Popover.Content>\n </Popover.Root>\n );\n}\n"],"names":["Popover","WaypointPopover","open","mode","onOpenChange","onSaveName","onDelete","onCancel","nameValue","setNameValue","trigger","Root","Trigger","asChild","Content","className","side","sideOffset","alignOffset","div","p","input","type","value","onChange","e","target","placeholder","onKeyDown","key","style","display","gap","marginTop","button","onClick","Close","Arrow"],"mappings":";AAAA,YAAYA,aAAa,0BAA0B;AAenD,OAAO,SAASC,gBAAgB,EAC9BC,IAAI,EACJC,IAAI,EACJC,YAAY,EACZC,UAAU,EACVC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EAAE,EACdC,YAAY,EACZC,OAAO,EACc;IACrB,qBACE,MAACV,QAAQW,IAAI;QAACT,MAAMA;QAAME,cAAcA;;YACrCM,yBAAW,KAACV,QAAQY,OAAO;gBAACC,OAAO;0BAAEH;;0BACtC,MAACV,QAAQc,OAAO;gBACdC,WAAU;gBACVC,MAAK;gBACLC,YAAY,CAAC;gBACbC,aAAa;;kCAEb,KAACC;wBAAIJ,WAAU;kCACZZ,SAAS,sBACR;;8CACE,KAACiB;oCAAEL,WAAU;8CAAoC;;8CAGjD,KAACM;oCACCC,MAAK;oCACLP,WAAU;oCACVQ,OAAOf;oCACPgB,UAAUC,CAAAA,IAAKhB,eAAegB,EAAEC,MAAM,CAACH,KAAK;oCAC5CI,aAAY;oCACZC,WAAWH,CAAAA;wCACT,IAAIA,EAAEI,GAAG,KAAK,WAAWxB,YAAYA,WAAWG;oCAClD;;8CAEF,MAACW;oCAAIW,OAAO;wCAAEC,SAAS;wCAAQC,KAAK;wCAAIC,WAAW;oCAAG;;sDACpD,KAACC;4CACCZ,MAAK;4CACLP,WAAU;4CACVoB,SAAS,IAAM9B,aAAaG;sDAC7B;;sDAGD,KAACR,QAAQoC,KAAK;4CAACvB,OAAO;sDACpB,cAAA,KAACqB;gDACCZ,MAAK;gDACLP,WAAU;gDACVoB,SAAS5B;0DACV;;;;;;2CAOP;;8CACE,KAACa;oCAAEL,WAAU;8CAAoC;;8CAGjD,MAACI;oCAAIW,OAAO;wCAAEC,SAAS;wCAAQC,KAAK;wCAAIC,WAAW;oCAAG;;sDACpD,KAACC;4CACCZ,MAAK;4CACLP,WAAU;4CACVoB,SAAS7B;sDACV;;sDAGD,KAACN,QAAQoC,KAAK;4CAACvB,OAAO;sDACpB,cAAA,KAACqB;gDACCZ,MAAK;gDACLP,WAAU;gDACVoB,SAAS5B;0DACV;;;;;;;;kCAQX,KAACP,QAAQqC,KAAK;wBAACtB,WAAU;;;;;;AAIjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './WaypointSheet.scss';
|
|
2
|
+
import type { Waypoint } from './types.js';
|
|
3
|
+
export declare function WaypointSheet({ open, onOpenChange, waypoint, onSave, onCancel, }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
waypoint: Waypoint;
|
|
7
|
+
onSave: (wp: Waypoint) => void;
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import './WaypointSheet.scss';
|
|
5
|
+
export function WaypointSheet({ open, onOpenChange, waypoint, onSave, onCancel }) {
|
|
6
|
+
const [formState, setFormState] = React.useState(waypoint);
|
|
7
|
+
React.useEffect(()=>{
|
|
8
|
+
setFormState(waypoint);
|
|
9
|
+
}, [
|
|
10
|
+
waypoint
|
|
11
|
+
]);
|
|
12
|
+
if (!formState) return null;
|
|
13
|
+
return /*#__PURE__*/ _jsx(DialogPrimitive.Root, {
|
|
14
|
+
open: open,
|
|
15
|
+
onOpenChange: onOpenChange,
|
|
16
|
+
children: /*#__PURE__*/ _jsxs(DialogPrimitive.Portal, {
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ _jsx(DialogPrimitive.Overlay, {
|
|
19
|
+
className: "waypoint-sheet__overlay"
|
|
20
|
+
}),
|
|
21
|
+
/*#__PURE__*/ _jsxs(DialogPrimitive.Content, {
|
|
22
|
+
className: "waypoint-sheet__dialog",
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ _jsxs(DialogPrimitive.DialogTitle, {
|
|
25
|
+
className: "waypoint-sheet__header",
|
|
26
|
+
children: [
|
|
27
|
+
"Edit Waypoint",
|
|
28
|
+
/*#__PURE__*/ _jsx(DialogPrimitive.Close, {
|
|
29
|
+
asChild: true,
|
|
30
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
"aria-label": "Close",
|
|
33
|
+
className: "waypoint-sheet__close",
|
|
34
|
+
children: "×"
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsxs("form", {
|
|
40
|
+
onSubmit: (e)=>{
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
onSave(formState);
|
|
43
|
+
},
|
|
44
|
+
className: "waypoint-sheet__form",
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
47
|
+
children: [
|
|
48
|
+
"Name",
|
|
49
|
+
/*#__PURE__*/ _jsx("input", {
|
|
50
|
+
type: "text",
|
|
51
|
+
value: formState.name,
|
|
52
|
+
onChange: (e)=>setFormState({
|
|
53
|
+
...formState,
|
|
54
|
+
name: e.target.value
|
|
55
|
+
}),
|
|
56
|
+
required: true
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ _jsx("p", {
|
|
59
|
+
className: "help-text",
|
|
60
|
+
role: "region",
|
|
61
|
+
"aria-live": "polite",
|
|
62
|
+
children: "The name of the waypoint."
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
67
|
+
children: [
|
|
68
|
+
"Content",
|
|
69
|
+
/*#__PURE__*/ _jsx("textarea", {
|
|
70
|
+
value: formState.content ?? '',
|
|
71
|
+
onChange: (e)=>setFormState({
|
|
72
|
+
...formState,
|
|
73
|
+
content: e.target.value
|
|
74
|
+
})
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ _jsx("p", {
|
|
77
|
+
className: "help-text",
|
|
78
|
+
role: "region",
|
|
79
|
+
"aria-live": "polite",
|
|
80
|
+
children: "Text shown on the waypoint."
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
85
|
+
children: [
|
|
86
|
+
"Type",
|
|
87
|
+
/*#__PURE__*/ _jsx("input", {
|
|
88
|
+
type: "text",
|
|
89
|
+
value: formState.type ?? '',
|
|
90
|
+
onChange: (e)=>setFormState({
|
|
91
|
+
...formState,
|
|
92
|
+
type: e.target.value
|
|
93
|
+
}),
|
|
94
|
+
placeholder: "Optional category / icon key"
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx("p", {
|
|
97
|
+
className: "help-text",
|
|
98
|
+
role: "region",
|
|
99
|
+
"aria-live": "polite",
|
|
100
|
+
children: "Optional free-text category you can map to an icon on the frontend."
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}),
|
|
104
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
105
|
+
children: [
|
|
106
|
+
"Link",
|
|
107
|
+
/*#__PURE__*/ _jsx("input", {
|
|
108
|
+
type: "url",
|
|
109
|
+
value: formState.link ?? '',
|
|
110
|
+
onChange: (e)=>setFormState({
|
|
111
|
+
...formState,
|
|
112
|
+
link: e.target.value
|
|
113
|
+
})
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ _jsx("p", {
|
|
116
|
+
className: "help-text",
|
|
117
|
+
role: "region",
|
|
118
|
+
"aria-live": "polite",
|
|
119
|
+
children: "Include the full URL (http:// or https://)."
|
|
120
|
+
})
|
|
121
|
+
]
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
124
|
+
children: [
|
|
125
|
+
"Link Text",
|
|
126
|
+
/*#__PURE__*/ _jsx("input", {
|
|
127
|
+
type: "text",
|
|
128
|
+
value: formState.linkText ?? '',
|
|
129
|
+
onChange: (e)=>setFormState({
|
|
130
|
+
...formState,
|
|
131
|
+
linkText: e.target.value
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ _jsx("p", {
|
|
135
|
+
className: "help-text",
|
|
136
|
+
role: "region",
|
|
137
|
+
"aria-live": "polite",
|
|
138
|
+
children: "Text for the link. Defaults to “View More” if blank."
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
143
|
+
children: [
|
|
144
|
+
"Image",
|
|
145
|
+
/*#__PURE__*/ _jsx("input", {
|
|
146
|
+
type: "text",
|
|
147
|
+
value: formState.image ?? '',
|
|
148
|
+
onChange: (e)=>setFormState({
|
|
149
|
+
...formState,
|
|
150
|
+
image: e.target.value
|
|
151
|
+
}),
|
|
152
|
+
placeholder: "Enter a URL or relative path"
|
|
153
|
+
}),
|
|
154
|
+
/*#__PURE__*/ _jsx("p", {
|
|
155
|
+
className: "help-text",
|
|
156
|
+
role: "region",
|
|
157
|
+
"aria-live": "polite",
|
|
158
|
+
children: "Full URL or relative path (e.g. https://… or /media/image.jpg)."
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
163
|
+
className: "waypoint-sheet__actions",
|
|
164
|
+
children: [
|
|
165
|
+
/*#__PURE__*/ _jsx("button", {
|
|
166
|
+
type: "submit",
|
|
167
|
+
className: "btn btn--primary",
|
|
168
|
+
children: "Save"
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ _jsx(DialogPrimitive.Close, {
|
|
171
|
+
asChild: true,
|
|
172
|
+
children: /*#__PURE__*/ _jsx("button", {
|
|
173
|
+
type: "button",
|
|
174
|
+
className: "btn btn--secondary",
|
|
175
|
+
onClick: onCancel,
|
|
176
|
+
children: "Cancel"
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=WaypointSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/imageMap/MapEditor/WaypointSheet.tsx"],"sourcesContent":["import * as DialogPrimitive from '@radix-ui/react-dialog';\nimport React from 'react';\nimport './WaypointSheet.scss';\nimport type { Waypoint } from './types.js';\n\nexport function WaypointSheet({\n open,\n onOpenChange,\n waypoint,\n onSave,\n onCancel,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n waypoint: Waypoint;\n onSave: (wp: Waypoint) => void;\n onCancel: () => void;\n}) {\n const [formState, setFormState] = React.useState(waypoint);\n\n React.useEffect(() => {\n setFormState(waypoint);\n }, [waypoint]);\n\n if (!formState) return null;\n\n return (\n <DialogPrimitive.Root open={open} onOpenChange={onOpenChange}>\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className='waypoint-sheet__overlay' />\n <DialogPrimitive.Content className='waypoint-sheet__dialog'>\n <DialogPrimitive.DialogTitle className='waypoint-sheet__header'>\n Edit Waypoint\n <DialogPrimitive.Close asChild>\n <button\n type='button'\n aria-label='Close'\n className='waypoint-sheet__close'\n >\n ×\n </button>\n </DialogPrimitive.Close>\n </DialogPrimitive.DialogTitle>\n <form\n onSubmit={e => {\n e.preventDefault();\n onSave(formState);\n }}\n className='waypoint-sheet__form'\n >\n <label>\n Name\n <input\n type='text'\n value={formState.name}\n onChange={e =>\n setFormState({ ...formState, name: e.target.value })\n }\n required\n />\n <p className='help-text' role='region' aria-live='polite'>\n The name of the waypoint.\n </p>\n </label>\n\n <label>\n Content\n <textarea\n value={formState.content ?? ''}\n onChange={e =>\n setFormState({ ...formState, content: e.target.value })\n }\n />\n <p className='help-text' role='region' aria-live='polite'>\n Text shown on the waypoint.\n </p>\n </label>\n\n <label>\n Type\n <input\n type='text'\n value={formState.type ?? ''}\n onChange={e =>\n setFormState({ ...formState, type: e.target.value })\n }\n placeholder='Optional category / icon key'\n />\n <p className='help-text' role='region' aria-live='polite'>\n Optional free-text category you can map to an icon on the\n frontend.\n </p>\n </label>\n\n <label>\n Link\n <input\n type='url'\n value={formState.link ?? ''}\n onChange={e =>\n setFormState({ ...formState, link: e.target.value })\n }\n />\n <p className='help-text' role='region' aria-live='polite'>\n Include the full URL (http:// or https://).\n </p>\n </label>\n\n <label>\n Link Text\n <input\n type='text'\n value={formState.linkText ?? ''}\n onChange={e =>\n setFormState({ ...formState, linkText: e.target.value })\n }\n />\n <p className='help-text' role='region' aria-live='polite'>\n Text for the link. Defaults to “View More” if blank.\n </p>\n </label>\n\n <label>\n Image\n <input\n type='text'\n value={formState.image ?? ''}\n onChange={e =>\n setFormState({ ...formState, image: e.target.value })\n }\n placeholder='Enter a URL or relative path'\n />\n <p className='help-text' role='region' aria-live='polite'>\n Full URL or relative path (e.g. https://… or /media/image.jpg).\n </p>\n </label>\n\n <div className='waypoint-sheet__actions'>\n <button type='submit' className='btn btn--primary'>\n Save\n </button>\n <DialogPrimitive.Close asChild>\n <button\n type='button'\n className='btn btn--secondary'\n onClick={onCancel}\n >\n Cancel\n </button>\n </DialogPrimitive.Close>\n </div>\n </form>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n}\n"],"names":["DialogPrimitive","React","WaypointSheet","open","onOpenChange","waypoint","onSave","onCancel","formState","setFormState","useState","useEffect","Root","Portal","Overlay","className","Content","DialogTitle","Close","asChild","button","type","aria-label","form","onSubmit","e","preventDefault","label","input","value","name","onChange","target","required","p","role","aria-live","textarea","content","placeholder","link","linkText","image","div","onClick"],"mappings":";AAAA,YAAYA,qBAAqB,yBAAyB;AAC1D,OAAOC,WAAW,QAAQ;AAC1B,OAAO,uBAAuB;AAG9B,OAA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AU;gDACV6B,SAASrC;0DACV;;;;;;;;;;;;AAUjB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
.waypoint-sheet__overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
background: rgba(0, 0, 0, 0.4);
|
|
5
|
+
z-index: 1000;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.waypoint-sheet__dialog {
|
|
9
|
+
position: fixed;
|
|
10
|
+
top: 0;
|
|
11
|
+
right: 0;
|
|
12
|
+
height: 100vh;
|
|
13
|
+
width: 400px;
|
|
14
|
+
max-width: 100vw;
|
|
15
|
+
background: #fff;
|
|
16
|
+
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
|
|
17
|
+
z-index: 1001;
|
|
18
|
+
padding: 32px;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: 24px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.waypoint-sheet__header {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-bottom: 16px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.waypoint-sheet__close {
|
|
32
|
+
background: none;
|
|
33
|
+
border: none;
|
|
34
|
+
font-size: 24px;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
line-height: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.waypoint-sheet__form {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 16px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.waypoint-sheet__form label {
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
margin-bottom: 4px;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: 4px;
|
|
51
|
+
|
|
52
|
+
.help-text {
|
|
53
|
+
margin-top: 4px;
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
line-height: 1.2;
|
|
56
|
+
color: #666;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input:focus:invalid {
|
|
60
|
+
outline: 2px solid red;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
input:focus:valid {
|
|
64
|
+
outline: 2px solid green;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
input + span {
|
|
68
|
+
padding: 0 0.3rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
input:invalid + span::after {
|
|
72
|
+
content: "✖" / "Content is not valid";
|
|
73
|
+
color: red;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
input:valid + span::after {
|
|
77
|
+
content: "✓" / "Content is valid";
|
|
78
|
+
color: green;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.waypoint-sheet__form input,
|
|
83
|
+
.waypoint-sheet__form textarea,
|
|
84
|
+
.waypoint-sheet__form select {
|
|
85
|
+
width: 100%;
|
|
86
|
+
padding: 8px;
|
|
87
|
+
border: 1px solid #c8c8c8;
|
|
88
|
+
border-radius: 4px;
|
|
89
|
+
font-size: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.waypoint-sheet__actions {
|
|
93
|
+
display: flex;
|
|
94
|
+
gap: 12px;
|
|
95
|
+
margin-top: 16px;
|
|
96
|
+
|
|
97
|
+
.btn {
|
|
98
|
+
margin-block: 0px;
|
|
99
|
+
border-radius: 4px;
|
|
100
|
+
transition: all 0.3s ease;
|
|
101
|
+
padding: 0.25rem 2rem;
|
|
102
|
+
font-size: 1.125rem;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
|
|
105
|
+
&--primary {
|
|
106
|
+
background-color: #fe7a05;
|
|
107
|
+
color: #fff;
|
|
108
|
+
border: 1px solid #fe7a05;
|
|
109
|
+
|
|
110
|
+
&:hover {
|
|
111
|
+
background-color: #fff;
|
|
112
|
+
color: #fe7a05;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&--secondary {
|
|
117
|
+
background-color: #fff;
|
|
118
|
+
color: #000;
|
|
119
|
+
border: 1px solid #000;
|
|
120
|
+
|
|
121
|
+
&:hover {
|
|
122
|
+
background-color: #fe7a05;
|
|
123
|
+
color: #fff;
|
|
124
|
+
border: 1px solid #fe7a05;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|