@molecule/app-annotation-pin-vue 0.0.0-stage → 1.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 +202 -0
- package/README.md +381 -2
- package/dist/AnnotationLayer.d.ts +115 -0
- package/dist/AnnotationLayer.d.ts.map +1 -0
- package/dist/AnnotationLayer.js +142 -0
- package/dist/AnnotationLayer.js.map +1 -0
- package/dist/AnnotationPin.d.ts +90 -0
- package/dist/AnnotationPin.d.ts.map +1 -0
- package/dist/AnnotationPin.js +204 -0
- package/dist/AnnotationPin.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +66 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue annotation layer — a surface with many pin markers overlaid on it.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-annotation-pin-react`'s
|
|
5
|
+
* `AnnotationLayer` — the same props (React names), the same ClassMap tokens,
|
|
6
|
+
* the same i18n keys, and the same DOM for the same input.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type PropType, type VNodeChild } from 'vue';
|
|
11
|
+
import type { Pin } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper that manages multiple pins on a parent surface. Renders its
|
|
14
|
+
* default slot (the surface — typically an `<img>`, `<canvas>`, or
|
|
15
|
+
* map-tile element) and overlays each `pins[]` entry as a clickable
|
|
16
|
+
* `<AnnotationPin>` marker.
|
|
17
|
+
*
|
|
18
|
+
* Click behaviour:
|
|
19
|
+
* - clicking a pin marker fires `onPinClick(pinId)`
|
|
20
|
+
* - clicking empty space on the layer fires `onSurfaceClick({ x, y })`,
|
|
21
|
+
* which callers typically use to add a new pin. That action lives on
|
|
22
|
+
* an invisible "add annotation pin" button covering the surface (the
|
|
23
|
+
* layer region itself is not interactive — it contains the pin
|
|
24
|
+
* buttons and popups): pointer clicks place a pin at the click
|
|
25
|
+
* position; activating the button with a keyboard (Tab to it, then
|
|
26
|
+
* Enter / Space) or assistive tech places a pin at the surface centre.
|
|
27
|
+
*
|
|
28
|
+
* The layer itself sets `position: relative` so absolute pin
|
|
29
|
+
* positioning works without the caller having to provide a wrapper.
|
|
30
|
+
*
|
|
31
|
+
* All styling routes through `getClassMap()`; all user-visible text
|
|
32
|
+
* routes through `t()` so the layer translates via the companion
|
|
33
|
+
* `@molecule/app-locales-annotation-pin` locale bond.
|
|
34
|
+
*
|
|
35
|
+
* @param props - Component props (see {@link AnnotationLayerProps}).
|
|
36
|
+
* @returns The annotation-layer component.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AnnotationLayer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
39
|
+
pins: {
|
|
40
|
+
type: PropType<Pin[]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
activePinId: {
|
|
44
|
+
type: PropType<string | null | undefined>;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
onPinClick: {
|
|
48
|
+
type: PropType<(pinId: string) => void>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
onSurfaceClick: {
|
|
52
|
+
type: PropType<(position: {
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
}) => void>;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
normalised: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
|
+
popupSide: {
|
|
63
|
+
type: PropType<"top" | "bottom" | "left" | "right">;
|
|
64
|
+
default: string;
|
|
65
|
+
};
|
|
66
|
+
className: StringConstructor;
|
|
67
|
+
style: {
|
|
68
|
+
type: PropType<Record<string, string | number>>;
|
|
69
|
+
default: undefined;
|
|
70
|
+
};
|
|
71
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
72
|
+
pins: {
|
|
73
|
+
type: PropType<Pin[]>;
|
|
74
|
+
required: true;
|
|
75
|
+
};
|
|
76
|
+
activePinId: {
|
|
77
|
+
type: PropType<string | null | undefined>;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
onPinClick: {
|
|
81
|
+
type: PropType<(pinId: string) => void>;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
onSurfaceClick: {
|
|
85
|
+
type: PropType<(position: {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
}) => void>;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
91
|
+
normalised: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
popupSide: {
|
|
96
|
+
type: PropType<"top" | "bottom" | "left" | "right">;
|
|
97
|
+
default: string;
|
|
98
|
+
};
|
|
99
|
+
className: StringConstructor;
|
|
100
|
+
style: {
|
|
101
|
+
type: PropType<Record<string, string | number>>;
|
|
102
|
+
default: undefined;
|
|
103
|
+
};
|
|
104
|
+
}>> & Readonly<{}>, {
|
|
105
|
+
popupSide: "top" | "bottom" | "left" | "right";
|
|
106
|
+
normalised: boolean;
|
|
107
|
+
style: Record<string, string | number>;
|
|
108
|
+
activePinId: string | null | undefined;
|
|
109
|
+
onPinClick: (pinId: string) => void;
|
|
110
|
+
onSurfaceClick: (position: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
}) => void;
|
|
114
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
115
|
+
//# sourceMappingURL=AnnotationLayer.d.ts.map
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AC,CAAC;;;;;;;;wBAjBtB,MAAM,KAAK,IAAI;+BAIZ;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;4EAmG3E,CAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue annotation layer — a surface with many pin markers overlaid on it.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-annotation-pin-react`'s
|
|
5
|
+
* `AnnotationLayer` — the same props (React names), the same ClassMap tokens,
|
|
6
|
+
* the same i18n keys, and the same DOM for the same input.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h } from 'vue';
|
|
11
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
12
|
+
import { useTranslation } from '@molecule/app-vue';
|
|
13
|
+
import { AnnotationPin } from './AnnotationPin.js';
|
|
14
|
+
/**
|
|
15
|
+
* Wrapper that manages multiple pins on a parent surface. Renders its
|
|
16
|
+
* default slot (the surface — typically an `<img>`, `<canvas>`, or
|
|
17
|
+
* map-tile element) and overlays each `pins[]` entry as a clickable
|
|
18
|
+
* `<AnnotationPin>` marker.
|
|
19
|
+
*
|
|
20
|
+
* Click behaviour:
|
|
21
|
+
* - clicking a pin marker fires `onPinClick(pinId)`
|
|
22
|
+
* - clicking empty space on the layer fires `onSurfaceClick({ x, y })`,
|
|
23
|
+
* which callers typically use to add a new pin. That action lives on
|
|
24
|
+
* an invisible "add annotation pin" button covering the surface (the
|
|
25
|
+
* layer region itself is not interactive — it contains the pin
|
|
26
|
+
* buttons and popups): pointer clicks place a pin at the click
|
|
27
|
+
* position; activating the button with a keyboard (Tab to it, then
|
|
28
|
+
* Enter / Space) or assistive tech places a pin at the surface centre.
|
|
29
|
+
*
|
|
30
|
+
* The layer itself sets `position: relative` so absolute pin
|
|
31
|
+
* positioning works without the caller having to provide a wrapper.
|
|
32
|
+
*
|
|
33
|
+
* All styling routes through `getClassMap()`; all user-visible text
|
|
34
|
+
* routes through `t()` so the layer translates via the companion
|
|
35
|
+
* `@molecule/app-locales-annotation-pin` locale bond.
|
|
36
|
+
*
|
|
37
|
+
* @param props - Component props (see {@link AnnotationLayerProps}).
|
|
38
|
+
* @returns The annotation-layer component.
|
|
39
|
+
*/
|
|
40
|
+
export const AnnotationLayer = defineComponent({
|
|
41
|
+
name: 'AnnotationLayer',
|
|
42
|
+
props: {
|
|
43
|
+
pins: {
|
|
44
|
+
type: Array,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
activePinId: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: undefined,
|
|
50
|
+
},
|
|
51
|
+
onPinClick: {
|
|
52
|
+
type: Function,
|
|
53
|
+
default: undefined,
|
|
54
|
+
},
|
|
55
|
+
onSurfaceClick: {
|
|
56
|
+
type: Function,
|
|
57
|
+
default: undefined,
|
|
58
|
+
},
|
|
59
|
+
normalised: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: true,
|
|
62
|
+
},
|
|
63
|
+
popupSide: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: 'right',
|
|
66
|
+
},
|
|
67
|
+
className: String,
|
|
68
|
+
style: {
|
|
69
|
+
type: Object,
|
|
70
|
+
default: undefined,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
setup(props, { slots }) {
|
|
74
|
+
const cm = getClassMap();
|
|
75
|
+
const { t } = useTranslation();
|
|
76
|
+
/**
|
|
77
|
+
* Computes the clicked position relative to the add-pin button's box
|
|
78
|
+
* (which covers the layer) and forwards to `onSurfaceClick`. If
|
|
79
|
+
* `normalised` is `true`, the returned coordinates are 0..1
|
|
80
|
+
* fractions; otherwise they are raw pixel offsets.
|
|
81
|
+
*
|
|
82
|
+
* Clicks produced by keyboard activation (Enter / Space on the
|
|
83
|
+
* focused button) or assistive tech carry `detail === 0` and no
|
|
84
|
+
* pointer position — such clicks place the pin at the surface centre.
|
|
85
|
+
* Pin markers and popups never reach this handler: they stack above
|
|
86
|
+
* the button and are its siblings, so their clicks do not hit it.
|
|
87
|
+
*
|
|
88
|
+
* @param event - The originating mouse event.
|
|
89
|
+
*/
|
|
90
|
+
const handleSurfaceClick = (event) => {
|
|
91
|
+
if (!props.onSurfaceClick)
|
|
92
|
+
return;
|
|
93
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
94
|
+
const keyboardActivated = event.detail === 0;
|
|
95
|
+
const px = keyboardActivated ? rect.width / 2 : event.clientX - rect.left;
|
|
96
|
+
const py = keyboardActivated ? rect.height / 2 : event.clientY - rect.top;
|
|
97
|
+
const safeRectWidth = rect.width || 1;
|
|
98
|
+
const safeRectHeight = rect.height || 1;
|
|
99
|
+
const x = props.normalised ? px / safeRectWidth : px;
|
|
100
|
+
const y = props.normalised ? py / safeRectHeight : py;
|
|
101
|
+
props.onSurfaceClick({ x, y });
|
|
102
|
+
};
|
|
103
|
+
return () => {
|
|
104
|
+
const content = slots.default ? slots.default() : [];
|
|
105
|
+
if (props.onSurfaceClick)
|
|
106
|
+
content.push(h('button', {
|
|
107
|
+
type: 'button',
|
|
108
|
+
'aria-label': t('annotationPin.aria.addPin', {}, { defaultValue: 'Add annotation pin' }),
|
|
109
|
+
'data-mol-id': 'annotation-layer-add-pin',
|
|
110
|
+
onClick: handleSurfaceClick,
|
|
111
|
+
class: cm.cn(cm.position('absolute'), cm.inset0, cm.cursorPointer),
|
|
112
|
+
// Reset the browser's default button chrome — the add-pin button
|
|
113
|
+
// is an invisible full-surface target, not a visible control.
|
|
114
|
+
style: { border: 'none', padding: '0px', background: 'transparent' },
|
|
115
|
+
}));
|
|
116
|
+
for (const pin of props.pins)
|
|
117
|
+
content.push(h(AnnotationPin, {
|
|
118
|
+
key: pin.id,
|
|
119
|
+
position: pin.position,
|
|
120
|
+
label: pin.label,
|
|
121
|
+
note: pin.note,
|
|
122
|
+
selected: props.activePinId === pin.id,
|
|
123
|
+
popupSide: props.popupSide,
|
|
124
|
+
normalised: props.normalised,
|
|
125
|
+
onClick: () => props.onPinClick?.(pin.id),
|
|
126
|
+
}));
|
|
127
|
+
return h('div', {
|
|
128
|
+
role: 'region',
|
|
129
|
+
'aria-label': t('annotationPin.aria.layer', {}, { defaultValue: 'Annotation layer' }),
|
|
130
|
+
'data-mol-id': 'annotation-layer',
|
|
131
|
+
class: cm.cn(props.className),
|
|
132
|
+
style: {
|
|
133
|
+
position: 'relative',
|
|
134
|
+
width: '100%',
|
|
135
|
+
height: '100%',
|
|
136
|
+
...(props.style ?? {}),
|
|
137
|
+
},
|
|
138
|
+
}, content);
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=AnnotationLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationLayer.js","sourceRoot":"","sources":["../src/AnnotationLayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAkC,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;IAC7C,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE;QACL,IAAI,EAAE;YACJ,IAAI,EAAE,KAAwB;YAC9B,QAAQ,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,MAA6C;YACnD,OAAO,EAAE,SAAS;SACnB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAA6C;YACnD,OAAO,EAAE,SAAS;SACnB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,QAAkE;YACxE,OAAO,EAAE,SAAS;SACnB;QACD,UA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E,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;iBAC1C,CAAC,CACH,CAAA;YAEH,OAAO,CAAC,CACN,KAAK,EACL;gBACE,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,CAAC,CAAC,0BAA0B,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;gBACrF,aAAa,EAAE,kBAAkB;gBACjC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;gBAC7B,KAAK,EAAE;oBACL,QAAQ,EAAE,UAAU;oBACpB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,MAAM;oBACd,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;iBACvB;aACF,EACD,OAAO,CACR,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue annotation pin marker — a click-to-toggle marker with a label and a
|
|
3
|
+
* note popup.
|
|
4
|
+
*
|
|
5
|
+
* Vue counterpart of `@molecule/app-annotation-pin-react`'s `AnnotationPin` —
|
|
6
|
+
* the same props (React names), the same ClassMap tokens, the same i18n keys,
|
|
7
|
+
* and the same DOM for the same input.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { type PropType, type VNodeChild } from 'vue';
|
|
12
|
+
/**
|
|
13
|
+
* A single pin marker (small circle with optional `label`) rendered at
|
|
14
|
+
* an absolute position on its parent. Clicking the marker toggles its
|
|
15
|
+
* popup (which shows the `note` body) via the `onClick` handler.
|
|
16
|
+
*
|
|
17
|
+
* Positioning is absolute relative to the nearest positioned ancestor —
|
|
18
|
+
* callers must wrap the surface (image, canvas, map) in a
|
|
19
|
+
* `position: relative` element. `AnnotationLayer` provides this
|
|
20
|
+
* wrapper automatically.
|
|
21
|
+
*
|
|
22
|
+
* All styling routes through `getClassMap()`; all user-visible text
|
|
23
|
+
* (aria-labels, fallback note text) routes through `t()` so the marker
|
|
24
|
+
* translates via the companion `@molecule/app-locales-annotation-pin`
|
|
25
|
+
* locale bond.
|
|
26
|
+
*
|
|
27
|
+
* @param props - Component props (see {@link AnnotationPinProps}).
|
|
28
|
+
* @returns The pin component.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AnnotationPin: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
31
|
+
position: {
|
|
32
|
+
type: PropType<{
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
label: null;
|
|
39
|
+
note: null;
|
|
40
|
+
selected: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
onClick: {
|
|
45
|
+
type: PropType<() => void>;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
popupSide: {
|
|
49
|
+
type: PropType<"top" | "bottom" | "left" | "right">;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
className: StringConstructor;
|
|
53
|
+
normalised: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
58
|
+
position: {
|
|
59
|
+
type: PropType<{
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
}>;
|
|
63
|
+
required: true;
|
|
64
|
+
};
|
|
65
|
+
label: null;
|
|
66
|
+
note: null;
|
|
67
|
+
selected: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
71
|
+
onClick: {
|
|
72
|
+
type: PropType<() => void>;
|
|
73
|
+
default: undefined;
|
|
74
|
+
};
|
|
75
|
+
popupSide: {
|
|
76
|
+
type: PropType<"top" | "bottom" | "left" | "right">;
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
79
|
+
className: StringConstructor;
|
|
80
|
+
normalised: {
|
|
81
|
+
type: BooleanConstructor;
|
|
82
|
+
default: boolean;
|
|
83
|
+
};
|
|
84
|
+
}>> & Readonly<{}>, {
|
|
85
|
+
selected: boolean;
|
|
86
|
+
onClick: () => void;
|
|
87
|
+
popupSide: "top" | "bottom" | "left" | "right";
|
|
88
|
+
normalised: boolean;
|
|
89
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
90
|
+
//# sourceMappingURL=AnnotationPin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationPin.d.ts","sourceRoot":"","sources":["../src/AnnotationPin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAqBxE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;;cAIJ,QAAQ,CAAC;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;;;;;;;;cAYhC,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;cAItB,QAAQ,CAAC,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;;;;;;;;UAsFpD,UAAU;;cAtGH,QAAQ,CAAC;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;;;;;;;;cAYhC,QAAQ,CAAC,MAAM,IAAI,CAAC;;;;cAItB,QAAQ,CAAC,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;;;;;;;;;;mBAJ5B,IAAI;;;4EAoKzC,CAAA"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue annotation pin marker — a click-to-toggle marker with a label and a
|
|
3
|
+
* note popup.
|
|
4
|
+
*
|
|
5
|
+
* Vue counterpart of `@molecule/app-annotation-pin-react`'s `AnnotationPin` —
|
|
6
|
+
* the same props (React names), the same ClassMap tokens, the same i18n keys,
|
|
7
|
+
* and the same DOM for the same input.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { defineComponent, h } from 'vue';
|
|
12
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
13
|
+
import { useTranslation } from '@molecule/app-vue';
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a node-valued prop that may also arrive as a same-named slot: a
|
|
16
|
+
* prop that was given wins (React's single source of truth — a later `null`
|
|
17
|
+
* removes the node, as React does), and the slot is used only while the prop
|
|
18
|
+
* is absent. An absent pair contributes nothing.
|
|
19
|
+
*
|
|
20
|
+
* @param prop - The prop value, when the caller passed the prop.
|
|
21
|
+
* @param slot - The slot render function, when the caller passed the slot.
|
|
22
|
+
* @returns The children to render.
|
|
23
|
+
*/
|
|
24
|
+
const nodeValue = (prop, slot) => {
|
|
25
|
+
if (prop !== undefined)
|
|
26
|
+
return prop === null ? [] : [prop];
|
|
27
|
+
if (slot)
|
|
28
|
+
return slot();
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A single pin marker (small circle with optional `label`) rendered at
|
|
33
|
+
* an absolute position on its parent. Clicking the marker toggles its
|
|
34
|
+
* popup (which shows the `note` body) via the `onClick` handler.
|
|
35
|
+
*
|
|
36
|
+
* Positioning is absolute relative to the nearest positioned ancestor —
|
|
37
|
+
* callers must wrap the surface (image, canvas, map) in a
|
|
38
|
+
* `position: relative` element. `AnnotationLayer` provides this
|
|
39
|
+
* wrapper automatically.
|
|
40
|
+
*
|
|
41
|
+
* All styling routes through `getClassMap()`; all user-visible text
|
|
42
|
+
* (aria-labels, fallback note text) routes through `t()` so the marker
|
|
43
|
+
* translates via the companion `@molecule/app-locales-annotation-pin`
|
|
44
|
+
* locale bond.
|
|
45
|
+
*
|
|
46
|
+
* @param props - Component props (see {@link AnnotationPinProps}).
|
|
47
|
+
* @returns The pin component.
|
|
48
|
+
*/
|
|
49
|
+
export const AnnotationPin = defineComponent({
|
|
50
|
+
name: 'AnnotationPin',
|
|
51
|
+
props: {
|
|
52
|
+
position: {
|
|
53
|
+
type: Object,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
// Node-valued props: declared with `null` (any runtime type, no
|
|
57
|
+
// validation — a VNode, a string, a number, or `null` to hide).
|
|
58
|
+
label: null,
|
|
59
|
+
note: null,
|
|
60
|
+
selected: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
onClick: {
|
|
65
|
+
type: Function,
|
|
66
|
+
default: undefined,
|
|
67
|
+
},
|
|
68
|
+
popupSide: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: 'right',
|
|
71
|
+
},
|
|
72
|
+
className: String,
|
|
73
|
+
normalised: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
setup(props, { slots }) {
|
|
79
|
+
const cm = getClassMap();
|
|
80
|
+
const { t } = useTranslation();
|
|
81
|
+
/**
|
|
82
|
+
* The popup body: the note when it was given (a null note renders an
|
|
83
|
+
* empty body, as React's `note ?? …` does), otherwise the translated
|
|
84
|
+
* empty-state line.
|
|
85
|
+
*
|
|
86
|
+
* @returns The popup body's children.
|
|
87
|
+
*/
|
|
88
|
+
const noteContent = () => {
|
|
89
|
+
if (props.note !== undefined && props.note !== null)
|
|
90
|
+
return [props.note];
|
|
91
|
+
// A note passed as the same-named slot wins over the empty state.
|
|
92
|
+
if (props.note === undefined && slots.note)
|
|
93
|
+
return slots.note();
|
|
94
|
+
return [
|
|
95
|
+
h('span', { 'data-mol-id': 'annotation-pin-popup-empty' }, t('annotationPin.empty', {}, { defaultValue: 'No notes for this pin.' })),
|
|
96
|
+
];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The popup's side-specific inline style (React's `popupStyle`).
|
|
100
|
+
*
|
|
101
|
+
* @param side - The popup side.
|
|
102
|
+
* @returns The inline style.
|
|
103
|
+
*/
|
|
104
|
+
const popupStyle = (side) => {
|
|
105
|
+
const base = {
|
|
106
|
+
position: 'absolute',
|
|
107
|
+
minWidth: '160px',
|
|
108
|
+
maxWidth: '240px',
|
|
109
|
+
padding: '8px',
|
|
110
|
+
borderRadius: '4px',
|
|
111
|
+
boxShadow: '0 4px 12px rgba(0,0,0,0.18)',
|
|
112
|
+
zIndex: 3,
|
|
113
|
+
};
|
|
114
|
+
switch (side) {
|
|
115
|
+
case 'top':
|
|
116
|
+
base.bottom = '100%';
|
|
117
|
+
base.left = '50%';
|
|
118
|
+
base.transform = 'translate(-50%, -8px)';
|
|
119
|
+
break;
|
|
120
|
+
case 'bottom':
|
|
121
|
+
base.top = '100%';
|
|
122
|
+
base.left = '50%';
|
|
123
|
+
base.transform = 'translate(-50%, 8px)';
|
|
124
|
+
break;
|
|
125
|
+
case 'left':
|
|
126
|
+
base.right = '100%';
|
|
127
|
+
base.top = '50%';
|
|
128
|
+
base.transform = 'translate(-8px, -50%)';
|
|
129
|
+
break;
|
|
130
|
+
case 'right':
|
|
131
|
+
default:
|
|
132
|
+
base.left = '100%';
|
|
133
|
+
base.top = '50%';
|
|
134
|
+
base.transform = 'translate(8px, -50%)';
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return base;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Stops the marker click from bubbling to arbitrary ancestor click
|
|
141
|
+
* handlers and forwards it to `onClick`.
|
|
142
|
+
*
|
|
143
|
+
* @param event - The originating mouse event.
|
|
144
|
+
*/
|
|
145
|
+
const handleMarkerClick = (event) => {
|
|
146
|
+
event.stopPropagation();
|
|
147
|
+
if (props.onClick)
|
|
148
|
+
props.onClick();
|
|
149
|
+
};
|
|
150
|
+
return () => {
|
|
151
|
+
const x = props.normalised ? `${props.position.x * 100}%` : `${props.position.x}px`;
|
|
152
|
+
const y = props.normalised ? `${props.position.y * 100}%` : `${props.position.y}px`;
|
|
153
|
+
return h('div', {
|
|
154
|
+
class: cm.cn(props.className),
|
|
155
|
+
'data-mol-id': 'annotation-pin',
|
|
156
|
+
'data-pin-selected': props.selected ? 'true' : 'false',
|
|
157
|
+
style: {
|
|
158
|
+
position: 'absolute',
|
|
159
|
+
left: x,
|
|
160
|
+
top: y,
|
|
161
|
+
transform: 'translate(-50%, -50%)',
|
|
162
|
+
zIndex: props.selected ? 2 : 1,
|
|
163
|
+
},
|
|
164
|
+
}, [
|
|
165
|
+
h('button', {
|
|
166
|
+
type: 'button',
|
|
167
|
+
onClick: handleMarkerClick,
|
|
168
|
+
'aria-label': t('annotationPin.aria.marker', {}, { defaultValue: 'Annotation pin' }),
|
|
169
|
+
'aria-expanded': props.selected ? 'true' : 'false',
|
|
170
|
+
'data-mol-id': 'annotation-pin-marker',
|
|
171
|
+
class: cm.cn(cm.roundedFull, cm.cursorPointer),
|
|
172
|
+
style: {
|
|
173
|
+
width: '24px',
|
|
174
|
+
height: '24px',
|
|
175
|
+
border: 'none',
|
|
176
|
+
padding: '0px',
|
|
177
|
+
cursor: 'pointer',
|
|
178
|
+
display: 'inline-flex',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
justifyContent: 'center',
|
|
181
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.25)',
|
|
182
|
+
},
|
|
183
|
+
}, [
|
|
184
|
+
h('span', {
|
|
185
|
+
class: cm.cn(cm.textSize('xs'), cm.fontWeight('bold')),
|
|
186
|
+
'data-mol-id': 'annotation-pin-label',
|
|
187
|
+
style: { lineHeight: 1, pointerEvents: 'none' },
|
|
188
|
+
}, nodeValue(props.label, slots.label)),
|
|
189
|
+
]),
|
|
190
|
+
props.selected
|
|
191
|
+
? h('div', {
|
|
192
|
+
role: 'dialog',
|
|
193
|
+
'aria-label': t('annotationPin.aria.popup', {}, { defaultValue: 'Annotation details' }),
|
|
194
|
+
'data-mol-id': 'annotation-pin-popup',
|
|
195
|
+
'data-popup-side': props.popupSide,
|
|
196
|
+
class: cm.cn(cm.surface, cm.borderAll, cm.textSize('sm')),
|
|
197
|
+
style: popupStyle(props.popupSide),
|
|
198
|
+
}, [h('div', { 'data-mol-id': 'annotation-pin-popup-body' }, noteContent())])
|
|
199
|
+
: null,
|
|
200
|
+
]);
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
//# sourceMappingURL=AnnotationPin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationPin.js","sourceRoot":"","sources":["../src/AnnotationPin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAkC,MAAM,KAAK,CAAA;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;;;;GASG;AACH,MAAM,SAAS,GAAG,CAAC,IAAgB,EAAE,IAAsC,EAAgB,EAAE;IAC3F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAC1D,IAAI,IAAI;QAAE,OAAO,IAAI,EAAE,CAAA;IACvB,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;IAC3C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,MAA4C;YAClD,QAAQ,EAAE,IAAI;SACf;QACD,gE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qBACxC;iBACF,EACD;oBACE,CAAC,CACC,MAAM,EACN;wBACE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBACtD,aAAa,EAAE,sBAAsB;wBACrC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE;qBAChD,EACD,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CACpC;iBACF,CACF;gBACD,KAAK,CAAC,QAAQ;oBACZ,CAAC,CAAC,CAAC,CACC,KAAK,EACL;wBACE,IAAI,EAAE,QAAQ;wBACd,YAAY,EAAE,CAAC,CACb,0BAA0B,EAC1B,EAAE,EACF,EAAE,YAAY,EAAE,oBAAoB,EAAE,CACvC;wBACD,aAAa,EAAE,sBAAsB;wBACrC,iBAAiB,EAAE,KAAK,CAAC,SAAS;wBAClC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;wBACzD,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;qBACnC,EACD,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,2BAA2B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAC1E;oBACH,CAAC,CAAC,IAAI;aACT,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue annotation pin / hotspot overlay primitives.
|
|
3
|
+
*
|
|
4
|
+
* Exports `<AnnotationPin>` (single click-to-toggle marker) and
|
|
5
|
+
* `<AnnotationLayer>` (parent wrapper that manages many pins on a
|
|
6
|
+
* surface). Reusable for 3d-model viewers, image annotations, map
|
|
7
|
+
* pins, and hotspot tours. It is the Vue counterpart of
|
|
8
|
+
* `@molecule/app-annotation-pin-react`: same props (React names) and the
|
|
9
|
+
* same DOM for the same input, so an app switches framework by changing
|
|
10
|
+
* only the package name in its imports.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { defineComponent, h, ref } from 'vue'
|
|
15
|
+
* import { AnnotationLayer, type Pin } from '@molecule/app-annotation-pin-vue'
|
|
16
|
+
*
|
|
17
|
+
* const ImageAnnotator = defineComponent({
|
|
18
|
+
* props: { src: { type: String, required: true } },
|
|
19
|
+
* setup(props) {
|
|
20
|
+
* const pins = ref<Pin[]>([])
|
|
21
|
+
* const activeId = ref<string | null>(null)
|
|
22
|
+
*
|
|
23
|
+
* const addPin = ({ x, y }: { x: number; y: number }): void => {
|
|
24
|
+
* const id = crypto.randomUUID()
|
|
25
|
+
* pins.value = [...pins.value, { id, position: { x, y }, label: pins.value.length + 1 }]
|
|
26
|
+
* activeId.value = id
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* return () =>
|
|
30
|
+
* h(
|
|
31
|
+
* AnnotationLayer,
|
|
32
|
+
* {
|
|
33
|
+
* pins: pins.value,
|
|
34
|
+
* activePinId: activeId.value,
|
|
35
|
+
* onPinClick: (id: string) => {
|
|
36
|
+
* activeId.value = id === activeId.value ? null : id
|
|
37
|
+
* },
|
|
38
|
+
* onSurfaceClick: addPin,
|
|
39
|
+
* },
|
|
40
|
+
* { default: () => [h('img', { src: props.src, alt: '', style: { width: '100%', display: 'block' } })] },
|
|
41
|
+
* )
|
|
42
|
+
* },
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Selection is fully controlled — the layer never stores the active pin;
|
|
48
|
+
* manage `activePinId` yourself and toggle it in `onPinClick`. `position`
|
|
49
|
+
* is normalised 0..1 by default (fractions of the layer box, so pins
|
|
50
|
+
* re-anchor on resize); pass `normalised={false}` for raw pixel offsets —
|
|
51
|
+
* on BOTH `<AnnotationLayer>` and any directly-rendered `<AnnotationPin>`,
|
|
52
|
+
* or clicks and markers will disagree. The layer wraps the default slot in
|
|
53
|
+
* a `position: relative` box; a bare `<AnnotationPin>` needs its own
|
|
54
|
+
* positioned ancestor. Node-valued props (`label`, `note`, the layer's
|
|
55
|
+
* content) arrive as a prop AND a same-named slot; components accept
|
|
56
|
+
* either. Translations come from the companion
|
|
57
|
+
* `@molecule/app-locales-annotation-pin` locale bond.
|
|
58
|
+
*
|
|
59
|
+
* @module
|
|
60
|
+
*/
|
|
61
|
+
export * from './AnnotationLayer.js';
|
|
62
|
+
export * from './AnnotationPin.js';
|
|
63
|
+
export * from './types.js';
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
|