@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
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,382 @@
|
|
|
1
|
-
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-16T18:56:25.479Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-annotation-pin-vue
|
|
10
|
+
|
|
11
|
+
Vue annotation pin / hotspot overlay primitives.
|
|
12
|
+
|
|
13
|
+
Exports `<AnnotationPin>` (single click-to-toggle marker) and
|
|
14
|
+
`<AnnotationLayer>` (parent wrapper that manages many pins on a
|
|
15
|
+
surface). Reusable for 3d-model viewers, image annotations, map
|
|
16
|
+
pins, and hotspot tours. It is the Vue counterpart of
|
|
17
|
+
`@molecule/app-annotation-pin-react`: same props (React names) and the
|
|
18
|
+
same DOM for the same input, so an app switches framework by changing
|
|
19
|
+
only the package name in its imports.
|
|
20
|
+
|
|
21
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
22
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
23
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { defineComponent, h, ref } from 'vue'
|
|
29
|
+
import { AnnotationLayer, type Pin } from '@molecule/app-annotation-pin-vue'
|
|
30
|
+
|
|
31
|
+
const ImageAnnotator = defineComponent({
|
|
32
|
+
props: { src: { type: String, required: true } },
|
|
33
|
+
setup(props) {
|
|
34
|
+
const pins = ref<Pin[]>([])
|
|
35
|
+
const activeId = ref<string | null>(null)
|
|
36
|
+
|
|
37
|
+
const addPin = ({ x, y }: { x: number; y: number }): void => {
|
|
38
|
+
const id = crypto.randomUUID()
|
|
39
|
+
pins.value = [...pins.value, { id, position: { x, y }, label: pins.value.length + 1 }]
|
|
40
|
+
activeId.value = id
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return () =>
|
|
44
|
+
h(
|
|
45
|
+
AnnotationLayer,
|
|
46
|
+
{
|
|
47
|
+
pins: pins.value,
|
|
48
|
+
activePinId: activeId.value,
|
|
49
|
+
onPinClick: (id: string) => {
|
|
50
|
+
activeId.value = id === activeId.value ? null : id
|
|
51
|
+
},
|
|
52
|
+
onSurfaceClick: addPin,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
default: () => [
|
|
56
|
+
h('img', { src: props.src, alt: '', style: { width: '100%', display: 'block' } }),
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Type
|
|
65
|
+
|
|
66
|
+
`feature`
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm install @molecule/app-annotation-pin-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
### Interfaces
|
|
77
|
+
|
|
78
|
+
#### `Pin`
|
|
79
|
+
|
|
80
|
+
A single pin to display on a parent surface. `position` is in the
|
|
81
|
+
parent's coordinate space — for image / 2D-canvas overlays this is
|
|
82
|
+
normalised 0..1 (so the pin re-anchors as the surface resizes); for
|
|
83
|
+
pixel-positioned overlays callers can pass raw px values and provide
|
|
84
|
+
their own `style` overrides via `className`.
|
|
85
|
+
|
|
86
|
+
The label/note are pure data — components handle render only. Surfaces
|
|
87
|
+
supply pin objects via `<AnnotationLayer :pins="...">` (or render a
|
|
88
|
+
single pin directly if there is only one).
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
interface Pin {
|
|
92
|
+
/** Stable identifier (used as the Vue key). */
|
|
93
|
+
id: string
|
|
94
|
+
/** Position in the parent surface's coordinate space (typically normalised 0..1). */
|
|
95
|
+
position: { x: number; y: number }
|
|
96
|
+
/** Short label (e.g. an index or single-word tag) shown inside the pin marker. */
|
|
97
|
+
label?: VNodeChild
|
|
98
|
+
/** Longer note / description body, shown inside the popup when the pin is selected. */
|
|
99
|
+
note?: VNodeChild
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### `AnnotationPinProps`
|
|
104
|
+
|
|
105
|
+
`<AnnotationPin>` props.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
interface AnnotationPinProps {
|
|
109
|
+
/** Position in the parent surface's coordinate space (typically normalised 0..1). */
|
|
110
|
+
position: { x: number; y: number }
|
|
111
|
+
/**
|
|
112
|
+
* Short label (e.g. an index or single-word tag) shown inside the marker.
|
|
113
|
+
* Passed as a prop or as the same-named slot — both work.
|
|
114
|
+
*/
|
|
115
|
+
label?: VNodeChild
|
|
116
|
+
/**
|
|
117
|
+
* Longer note shown inside the popup when the pin is selected. Passed as a
|
|
118
|
+
* prop or as the same-named slot — both work.
|
|
119
|
+
*/
|
|
120
|
+
note?: VNodeChild
|
|
121
|
+
/**
|
|
122
|
+
* Whether the pin is currently selected. When `true` the popup is
|
|
123
|
+
* rendered. Selection is controlled — callers manage state in
|
|
124
|
+
* `<AnnotationLayer>` (or themselves) and update via `onClick`.
|
|
125
|
+
*/
|
|
126
|
+
selected?: boolean
|
|
127
|
+
/** Click handler — fires when the pin marker is clicked. */
|
|
128
|
+
onClick?: () => void
|
|
129
|
+
/**
|
|
130
|
+
* Side the popup renders on, relative to the marker. Defaults to `'right'`.
|
|
131
|
+
*/
|
|
132
|
+
popupSide?: 'top' | 'bottom' | 'left' | 'right'
|
|
133
|
+
/** Extra classes merged onto the root wrapper. */
|
|
134
|
+
className?: string
|
|
135
|
+
/**
|
|
136
|
+
* Whether `position` is normalised (0..1) — when `true` the wrapper
|
|
137
|
+
* positions itself with `%` units so pins re-anchor on resize. When
|
|
138
|
+
* `false` the wrapper uses raw `px` values. Defaults to `true`.
|
|
139
|
+
*/
|
|
140
|
+
normalised?: boolean
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### `AnnotationLayerProps`
|
|
145
|
+
|
|
146
|
+
`<AnnotationLayer>` props.
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
interface AnnotationLayerProps {
|
|
150
|
+
/** Pins to render on the layer. */
|
|
151
|
+
pins: Pin[]
|
|
152
|
+
/**
|
|
153
|
+
* Optional layer content (the surface to annotate — image, canvas, map
|
|
154
|
+
* tile, etc.). The DEFAULT slot.
|
|
155
|
+
*/
|
|
156
|
+
children?: VNodeChild
|
|
157
|
+
/**
|
|
158
|
+
* The currently active (popup-open) pin id, or `null` for none. The
|
|
159
|
+
* layer is fully controlled — callers manage selection state.
|
|
160
|
+
*/
|
|
161
|
+
activePinId?: string | null
|
|
162
|
+
/** Called with the clicked pin id when a pin marker is clicked. */
|
|
163
|
+
onPinClick?: (pinId: string) => void
|
|
164
|
+
/**
|
|
165
|
+
* Called when the user clicks an empty area of the layer (i.e. not on
|
|
166
|
+
* a pin marker or a popup). Coordinates are in the same space as
|
|
167
|
+
* `Pin.position` — normalised 0..1 by default. Keyboard users get the
|
|
168
|
+
* same action: activating the layer's "add pin" button (Tab to it,
|
|
169
|
+
* then Enter / Space) places a pin at the surface centre.
|
|
170
|
+
*/
|
|
171
|
+
onSurfaceClick?: (position: { x: number; y: number }) => void
|
|
172
|
+
/**
|
|
173
|
+
* Whether positions are normalised (0..1) — when `true` the layer
|
|
174
|
+
* computes click coordinates as fractions of its bounding box; when
|
|
175
|
+
* `false` it returns raw pixel offsets. Defaults to `true`.
|
|
176
|
+
*/
|
|
177
|
+
normalised?: boolean
|
|
178
|
+
/**
|
|
179
|
+
* Side the popup renders on, relative to its marker. Defaults to `'right'`.
|
|
180
|
+
*/
|
|
181
|
+
popupSide?: 'top' | 'bottom' | 'left' | 'right'
|
|
182
|
+
/** Extra classes merged onto the layer root. */
|
|
183
|
+
className?: string
|
|
184
|
+
/** Inline style for the layer root, merged over the layer's own. */
|
|
185
|
+
style?: Record<string, string | number>
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Constants
|
|
190
|
+
|
|
191
|
+
#### `AnnotationLayer`
|
|
192
|
+
|
|
193
|
+
Wrapper that manages multiple pins on a parent surface. Renders its
|
|
194
|
+
default slot (the surface — typically an `<img>`, `<canvas>`, or
|
|
195
|
+
map-tile element) and overlays each `pins[]` entry as a clickable
|
|
196
|
+
`<AnnotationPin>` marker.
|
|
197
|
+
|
|
198
|
+
Click behaviour:
|
|
199
|
+
|
|
200
|
+
- clicking a pin marker fires `onPinClick(pinId)`
|
|
201
|
+
- clicking empty space on the layer fires `onSurfaceClick({ x, y })`,
|
|
202
|
+
which callers typically use to add a new pin. That action lives on
|
|
203
|
+
an invisible "add annotation pin" button covering the surface (the
|
|
204
|
+
layer region itself is not interactive — it contains the pin
|
|
205
|
+
buttons and popups): pointer clicks place a pin at the click
|
|
206
|
+
position; activating the button with a keyboard (Tab to it, then
|
|
207
|
+
Enter / Space) or assistive tech places a pin at the surface centre.
|
|
208
|
+
|
|
209
|
+
The layer itself sets `position: relative` so absolute pin
|
|
210
|
+
positioning works without the caller having to provide a wrapper.
|
|
211
|
+
|
|
212
|
+
All styling routes through `getClassMap()`; all user-visible text
|
|
213
|
+
routes through `t()` so the layer translates via the companion
|
|
214
|
+
`@molecule/app-locales-annotation-pin` locale bond.
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
const AnnotationLayer: DefineComponent<
|
|
218
|
+
ExtractPropTypes<{
|
|
219
|
+
pins: { type: PropType<Pin[]>; required: true }
|
|
220
|
+
activePinId: { type: PropType<string | null | undefined>; default: undefined }
|
|
221
|
+
onPinClick: { type: PropType<(pinId: string) => void>; default: undefined }
|
|
222
|
+
onSurfaceClick: {
|
|
223
|
+
type: PropType<(position: { x: number; y: number }) => void>
|
|
224
|
+
default: undefined
|
|
225
|
+
}
|
|
226
|
+
normalised: { type: BooleanConstructor; default: boolean }
|
|
227
|
+
popupSide: { type: PropType<'top' | 'bottom' | 'left' | 'right'>; default: string }
|
|
228
|
+
className: StringConstructor
|
|
229
|
+
style: { type: PropType<Record<string, string | number>>; default: undefined }
|
|
230
|
+
}>,
|
|
231
|
+
() => VNodeChild,
|
|
232
|
+
{},
|
|
233
|
+
{},
|
|
234
|
+
{},
|
|
235
|
+
ComponentOptionsMixin,
|
|
236
|
+
ComponentOptionsMixin,
|
|
237
|
+
{},
|
|
238
|
+
string,
|
|
239
|
+
PublicProps,
|
|
240
|
+
Readonly<
|
|
241
|
+
ExtractPropTypes<{
|
|
242
|
+
pins: { type: PropType<Pin[]>; required: true }
|
|
243
|
+
activePinId: { type: PropType<string | null | undefined>; default: undefined }
|
|
244
|
+
onPinClick: { type: PropType<(pinId: string) => void>; default: undefined }
|
|
245
|
+
onSurfaceClick: {
|
|
246
|
+
type: PropType<(position: { x: number; y: number }) => void>
|
|
247
|
+
default: undefined
|
|
248
|
+
}
|
|
249
|
+
normalised: { type: BooleanConstructor; default: boolean }
|
|
250
|
+
popupSide: { type: PropType<'top' | 'bottom' | 'left' | 'right'>; default: string }
|
|
251
|
+
className: StringConstructor
|
|
252
|
+
style: { type: PropType<Record<string, string | number>>; default: undefined }
|
|
253
|
+
}>
|
|
254
|
+
> &
|
|
255
|
+
Readonly<{}>,
|
|
256
|
+
{
|
|
257
|
+
activePinId: string | null | undefined
|
|
258
|
+
onPinClick: (pinId: string) => void
|
|
259
|
+
onSurfaceClick: (position: { x: number; y: number }) => void
|
|
260
|
+
normalised: boolean
|
|
261
|
+
popupSide: 'top' | 'bottom' | 'left' | 'right'
|
|
262
|
+
style: Record<string, string | number>
|
|
263
|
+
},
|
|
264
|
+
{},
|
|
265
|
+
{},
|
|
266
|
+
{},
|
|
267
|
+
string,
|
|
268
|
+
ComponentProvideOptions,
|
|
269
|
+
true,
|
|
270
|
+
{},
|
|
271
|
+
any
|
|
272
|
+
>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- `props` — Component props (see {@link AnnotationLayerProps}).
|
|
276
|
+
|
|
277
|
+
**Returns:** The annotation-layer component.
|
|
278
|
+
|
|
279
|
+
#### `AnnotationPin`
|
|
280
|
+
|
|
281
|
+
A single pin marker (small circle with optional `label`) rendered at
|
|
282
|
+
an absolute position on its parent. Clicking the marker toggles its
|
|
283
|
+
popup (which shows the `note` body) via the `onClick` handler.
|
|
284
|
+
|
|
285
|
+
Positioning is absolute relative to the nearest positioned ancestor —
|
|
286
|
+
callers must wrap the surface (image, canvas, map) in a
|
|
287
|
+
`position: relative` element. `AnnotationLayer` provides this
|
|
288
|
+
wrapper automatically.
|
|
289
|
+
|
|
290
|
+
All styling routes through `getClassMap()`; all user-visible text
|
|
291
|
+
(aria-labels, fallback note text) routes through `t()` so the marker
|
|
292
|
+
translates via the companion `@molecule/app-locales-annotation-pin`
|
|
293
|
+
locale bond.
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
const AnnotationPin: DefineComponent<
|
|
297
|
+
ExtractPropTypes<{
|
|
298
|
+
position: { type: PropType<{ x: number; y: number }>; required: true }
|
|
299
|
+
label: null
|
|
300
|
+
note: null
|
|
301
|
+
selected: { type: BooleanConstructor; default: boolean }
|
|
302
|
+
onClick: { type: PropType<() => void>; default: undefined }
|
|
303
|
+
popupSide: { type: PropType<'top' | 'bottom' | 'left' | 'right'>; default: string }
|
|
304
|
+
className: StringConstructor
|
|
305
|
+
normalised: { type: BooleanConstructor; default: boolean }
|
|
306
|
+
}>,
|
|
307
|
+
() => VNodeChild,
|
|
308
|
+
{},
|
|
309
|
+
{},
|
|
310
|
+
{},
|
|
311
|
+
ComponentOptionsMixin,
|
|
312
|
+
ComponentOptionsMixin,
|
|
313
|
+
{},
|
|
314
|
+
string,
|
|
315
|
+
PublicProps,
|
|
316
|
+
Readonly<
|
|
317
|
+
ExtractPropTypes<{
|
|
318
|
+
position: { type: PropType<{ x: number; y: number }>; required: true }
|
|
319
|
+
label: null
|
|
320
|
+
note: null
|
|
321
|
+
selected: { type: BooleanConstructor; default: boolean }
|
|
322
|
+
onClick: { type: PropType<() => void>; default: undefined }
|
|
323
|
+
popupSide: { type: PropType<'top' | 'bottom' | 'left' | 'right'>; default: string }
|
|
324
|
+
className: StringConstructor
|
|
325
|
+
normalised: { type: BooleanConstructor; default: boolean }
|
|
326
|
+
}>
|
|
327
|
+
> &
|
|
328
|
+
Readonly<{}>,
|
|
329
|
+
{
|
|
330
|
+
normalised: boolean
|
|
331
|
+
popupSide: 'top' | 'bottom' | 'left' | 'right'
|
|
332
|
+
selected: boolean
|
|
333
|
+
onClick: () => void
|
|
334
|
+
},
|
|
335
|
+
{},
|
|
336
|
+
{},
|
|
337
|
+
{},
|
|
338
|
+
string,
|
|
339
|
+
ComponentProvideOptions,
|
|
340
|
+
true,
|
|
341
|
+
{},
|
|
342
|
+
any
|
|
343
|
+
>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
- `props` — Component props (see {@link AnnotationPinProps}).
|
|
347
|
+
|
|
348
|
+
**Returns:** The pin component.
|
|
349
|
+
|
|
350
|
+
## Injection Notes
|
|
351
|
+
|
|
352
|
+
### Requirements
|
|
353
|
+
|
|
354
|
+
Peer dependencies:
|
|
355
|
+
|
|
356
|
+
- `@molecule/app-ui` ^1.0.1
|
|
357
|
+
- `@molecule/app-ui-vue` ^1.1.0
|
|
358
|
+
- `@molecule/app-vue` ^3.5.0
|
|
359
|
+
- `vue` ^3.4.0
|
|
360
|
+
|
|
361
|
+
### Runtime Dependencies
|
|
362
|
+
|
|
363
|
+
- `@molecule/app-ui`
|
|
364
|
+
- `@molecule/app-ui-vue`
|
|
365
|
+
- `@molecule/app-vue`
|
|
366
|
+
- `vue`
|
|
367
|
+
|
|
368
|
+
Selection is fully controlled — the layer never stores the active pin;
|
|
369
|
+
manage `activePinId` yourself and toggle it in `onPinClick`. `position`
|
|
370
|
+
is normalised 0..1 by default (fractions of the layer box, so pins
|
|
371
|
+
re-anchor on resize); pass `normalised={false}` for raw pixel offsets —
|
|
372
|
+
on BOTH `<AnnotationLayer>` and any directly-rendered `<AnnotationPin>`,
|
|
373
|
+
or clicks and markers will disagree. The layer wraps the default slot in
|
|
374
|
+
a `position: relative` box; a bare `<AnnotationPin>` needs its own
|
|
375
|
+
positioned ancestor. Node-valued props (`label`, `note`, the layer's
|
|
376
|
+
content) arrive as a prop AND a same-named slot; components accept
|
|
377
|
+
either. Translations come from the companion
|
|
378
|
+
`@molecule/app-locales-annotation-pin` locale bond.
|
|
379
|
+
|
|
380
|
+
## Translations
|
|
381
|
+
|
|
382
|
+
Translation strings are provided by `@molecule/app-locales-annotation-pin`.
|