@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/dist/index.js 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.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Types of `@molecule/app-annotation-pin-vue` — the Vue counterpart of
3
+ * `@molecule/app-annotation-pin-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ import type { VNodeChild } from 'vue';
8
+ /**
9
+ * A single pin to display on a parent surface. `position` is in the
10
+ * parent's coordinate space — for image / 2D-canvas overlays this is
11
+ * normalised 0..1 (so the pin re-anchors as the surface resizes); for
12
+ * pixel-positioned overlays callers can pass raw px values and provide
13
+ * their own `style` overrides via `className`.
14
+ *
15
+ * The label/note are pure data — components handle render only. Surfaces
16
+ * supply pin objects via `<AnnotationLayer :pins="...">` (or render a
17
+ * single pin directly if there is only one).
18
+ */
19
+ export interface Pin {
20
+ /** Stable identifier (used as the Vue key). */
21
+ id: string;
22
+ /** Position in the parent surface's coordinate space (typically normalised 0..1). */
23
+ position: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ /** Short label (e.g. an index or single-word tag) shown inside the pin marker. */
28
+ label?: VNodeChild;
29
+ /** Longer note / description body, shown inside the popup when the pin is selected. */
30
+ note?: VNodeChild;
31
+ }
32
+ /**
33
+ * `<AnnotationPin>` props.
34
+ */
35
+ export interface AnnotationPinProps {
36
+ /** Position in the parent surface's coordinate space (typically normalised 0..1). */
37
+ position: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ /**
42
+ * Short label (e.g. an index or single-word tag) shown inside the marker.
43
+ * Passed as a prop or as the same-named slot — both work.
44
+ */
45
+ label?: VNodeChild;
46
+ /**
47
+ * Longer note shown inside the popup when the pin is selected. Passed as a
48
+ * prop or as the same-named slot — both work.
49
+ */
50
+ note?: VNodeChild;
51
+ /**
52
+ * Whether the pin is currently selected. When `true` the popup is
53
+ * rendered. Selection is controlled — callers manage state in
54
+ * `<AnnotationLayer>` (or themselves) and update via `onClick`.
55
+ */
56
+ selected?: boolean;
57
+ /** Click handler — fires when the pin marker is clicked. */
58
+ onClick?: () => void;
59
+ /**
60
+ * Side the popup renders on, relative to the marker. Defaults to `'right'`.
61
+ */
62
+ popupSide?: 'top' | 'bottom' | 'left' | 'right';
63
+ /** Extra classes merged onto the root wrapper. */
64
+ className?: string;
65
+ /**
66
+ * Whether `position` is normalised (0..1) — when `true` the wrapper
67
+ * positions itself with `%` units so pins re-anchor on resize. When
68
+ * `false` the wrapper uses raw `px` values. Defaults to `true`.
69
+ */
70
+ normalised?: boolean;
71
+ }
72
+ /**
73
+ * `<AnnotationLayer>` props.
74
+ */
75
+ export interface AnnotationLayerProps {
76
+ /** Pins to render on the layer. */
77
+ pins: Pin[];
78
+ /**
79
+ * Optional layer content (the surface to annotate — image, canvas, map
80
+ * tile, etc.). The DEFAULT slot.
81
+ */
82
+ children?: VNodeChild;
83
+ /**
84
+ * The currently active (popup-open) pin id, or `null` for none. The
85
+ * layer is fully controlled — callers manage selection state.
86
+ */
87
+ activePinId?: string | null;
88
+ /** Called with the clicked pin id when a pin marker is clicked. */
89
+ onPinClick?: (pinId: string) => void;
90
+ /**
91
+ * Called when the user clicks an empty area of the layer (i.e. not on
92
+ * a pin marker or a popup). Coordinates are in the same space as
93
+ * `Pin.position` — normalised 0..1 by default. Keyboard users get the
94
+ * same action: activating the layer's "add pin" button (Tab to it,
95
+ * then Enter / Space) places a pin at the surface centre.
96
+ */
97
+ onSurfaceClick?: (position: {
98
+ x: number;
99
+ y: number;
100
+ }) => void;
101
+ /**
102
+ * Whether positions are normalised (0..1) — when `true` the layer
103
+ * computes click coordinates as fractions of its bounding box; when
104
+ * `false` it returns raw pixel offsets. Defaults to `true`.
105
+ */
106
+ normalised?: boolean;
107
+ /**
108
+ * Side the popup renders on, relative to its marker. Defaults to `'right'`.
109
+ */
110
+ popupSide?: 'top' | 'bottom' | 'left' | 'right';
111
+ /** Extra classes merged onto the layer root. */
112
+ className?: string;
113
+ /** Inline style for the layer root, merged over the layer's own. */
114
+ style?: Record<string, string | number>;
115
+ }
116
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,GAAG;IAClB,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,qFAAqF;IACrF,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAClC,kFAAkF;IAClF,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,uFAAuF;IACvF,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;IAC/C,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,IAAI,EAAE,GAAG,EAAE,CAAA;IACX;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,mEAAmE;IACnE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAC7D;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;IAC/C,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;CACxC"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types of `@molecule/app-annotation-pin-vue` — the Vue counterpart of
3
+ * `@molecule/app-annotation-pin-react`, same props and DOM.
4
+ *
5
+ * @module
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@molecule/app-annotation-pin-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Pin/annotation marker overlay with click-to-place pins and label/note popups for 3d-model-viewer, image annotations, map pins, hotspot tours",
5
+ "homepage": "https://www.molecule.dev/packages/app-annotation-pin-vue",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "vue-tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "annotation",
28
+ "pin",
29
+ "marker",
30
+ "hotspot",
31
+ "vue"
32
+ ],
33
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
34
+ "license": "Apache-2.0",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/molecule-dev/molecule.git",
38
+ "directory": "packages/app/features/annotation-pin-vue"
39
+ },
40
+ "engines": {
41
+ "node": ">=20"
42
+ },
43
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "peerDependencies": {
48
+ "@molecule/app-ui": "^1.0.1",
49
+ "@molecule/app-ui-vue": "^1.1.0",
50
+ "@molecule/app-vue": "^3.5.0",
51
+ "vue": "^3.4.0"
52
+ },
53
+ "devDependencies": {
54
+ "@molecule/app-framework-conformance": "0.0.0",
55
+ "@molecule/app-i18n": "1.2.2",
56
+ "@molecule/app-icons": "1.0.4",
57
+ "@molecule/app-ui": "1.4.0",
58
+ "@molecule/app-ui-vue": "1.1.5",
59
+ "@molecule/app-vue": "3.7.2",
60
+ "@types/node": "26.6.5",
61
+ "jsdom": "30.1.3",
62
+ "typescript": "6.0.3",
63
+ "vite": "8.3.5",
64
+ "vitest": "4.1.12",
65
+ "vue": "3.5.44",
66
+ "vue-tsc": "3.3.13"
67
+ }
68
+ }