@molecule/app-annotation-pin-angular 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 +635 -2
- package/dist/annotation-layer.component.d.ts +120 -0
- package/dist/annotation-layer.component.d.ts.map +1 -0
- package/dist/annotation-layer.component.js +222 -0
- package/dist/annotation-layer.component.js.map +1 -0
- package/dist/annotation-pin.component.d.ts +183 -0
- package/dist/annotation-pin.component.d.ts.map +1 -0
- package/dist/annotation-pin.component.js +422 -0
- package/dist/annotation-pin.component.js.map +1 -0
- package/dist/css.d.ts +31 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +90 -0
- package/dist/css.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/slot-dom.d.ts +51 -0
- package/dist/slot-dom.d.ts.map +1 -0
- package/dist/slot-dom.js +89 -0
- package/dist/slot-dom.js.map +1 -0
- package/dist/types.d.ts +105 -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 +72 -4
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnnotationPin component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { NgStyle, NgTemplateOutlet } from '@angular/common';
|
|
7
|
+
import { Component, inject, RendererFactory2, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { styleObject, styleString } from './css.js';
|
|
11
|
+
import { ElementToggle, hasNodes } from './slot-dom.js';
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
const _c0 = ["popupEl"];
|
|
14
|
+
const _c1 = ["labelSlot"];
|
|
15
|
+
const _c2 = ["noteSlot"];
|
|
16
|
+
const _c3 = ["emptyNoteEl"];
|
|
17
|
+
const _c4 = [[["", "slot", "label"]], [["", "slot", "note"]]];
|
|
18
|
+
const _c5 = ["[slot=label]", "[slot=note]"];
|
|
19
|
+
function AnnotationPin_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
20
|
+
i0.ɵɵelementContainer(0, 6);
|
|
21
|
+
} if (rf & 2) {
|
|
22
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx);
|
|
23
|
+
} }
|
|
24
|
+
function AnnotationPin_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
25
|
+
i0.ɵɵtext(0);
|
|
26
|
+
} if (rf & 2) {
|
|
27
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
28
|
+
i0.ɵɵtextInterpolate(ctx_r0.labelText());
|
|
29
|
+
} }
|
|
30
|
+
function AnnotationPin_Conditional_10_Template(rf, ctx) { if (rf & 1) {
|
|
31
|
+
i0.ɵɵelementContainer(0, 6);
|
|
32
|
+
} if (rf & 2) {
|
|
33
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx);
|
|
34
|
+
} }
|
|
35
|
+
function AnnotationPin_Conditional_11_Template(rf, ctx) { if (rf & 1) {
|
|
36
|
+
i0.ɵɵtext(0);
|
|
37
|
+
} if (rf & 2) {
|
|
38
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
39
|
+
i0.ɵɵtextInterpolate(ctx_r0.noteText());
|
|
40
|
+
} }
|
|
41
|
+
/**
|
|
42
|
+
* Whether a node-valued prop is an Angular template (a rendered node) rather
|
|
43
|
+
* than plain text. Checked structurally — `TemplateRef` is a type-only import
|
|
44
|
+
* in the emitted metadata, so `instanceof` is not dependable across bundles.
|
|
45
|
+
*
|
|
46
|
+
* @param value - The prop value.
|
|
47
|
+
* @returns True when it can be rendered with `ngTemplateOutlet`.
|
|
48
|
+
*/
|
|
49
|
+
const isTemplate = (value) => typeof value === 'object' &&
|
|
50
|
+
value !== null &&
|
|
51
|
+
typeof value.createEmbeddedView === 'function';
|
|
52
|
+
/**
|
|
53
|
+
* Renders a text value the way React renders a node string.
|
|
54
|
+
*
|
|
55
|
+
* @param value - The prop value.
|
|
56
|
+
* @returns The text to render, or `null` when there is none.
|
|
57
|
+
*/
|
|
58
|
+
const textOf = (value) => typeof value === 'string' || typeof value === 'number' ? String(value) : null;
|
|
59
|
+
/**
|
|
60
|
+
* A single pin marker (small circle with optional `label`) rendered at an
|
|
61
|
+
* absolute position on its parent. Clicking the marker toggles its popup
|
|
62
|
+
* (which shows the `note` body) via the `onClick` handler.
|
|
63
|
+
*
|
|
64
|
+
* The host IS the outer `<div>` (`div[mol-annotation-pin]`), matching React's
|
|
65
|
+
* root exactly. Node props are an input (a string or a `TemplateRef`) or
|
|
66
|
+
* projected content (`[slot=label]`, `[slot=note]`).
|
|
67
|
+
*
|
|
68
|
+
* This is the Angular counterpart of `@molecule/app-annotation-pin-react`.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Angular projection needs the `<ng-content>` capture points mounted, and an
|
|
72
|
+
* `ng-content` created later never receives the projection, so the popup and
|
|
73
|
+
* the two capture points live in the template unconditionally and
|
|
74
|
+
* {@link AnnotationPin.ngDoCheck} detaches the ones React would not render.
|
|
75
|
+
*/
|
|
76
|
+
export class AnnotationPin {
|
|
77
|
+
/** Position in the parent surface's coordinate space (typically normalised 0..1). */
|
|
78
|
+
position;
|
|
79
|
+
/** Short label inside the marker — text, a template, or `[slot=label]` content. */
|
|
80
|
+
label;
|
|
81
|
+
/** Popup body when selected — text, a template, or `[slot=note]` content. */
|
|
82
|
+
note;
|
|
83
|
+
/** Whether the popup is rendered (React's `selected`). */
|
|
84
|
+
selected;
|
|
85
|
+
/** Click handler — fires when the pin marker is clicked. */
|
|
86
|
+
onClick;
|
|
87
|
+
/** Side the popup renders on (defaults to `'right'` at read time). */
|
|
88
|
+
popupSide;
|
|
89
|
+
/** Extra classes merged onto the root wrapper. */
|
|
90
|
+
className;
|
|
91
|
+
/** Whether positions are normalised (defaults to `true` at read time). */
|
|
92
|
+
normalised;
|
|
93
|
+
/** The popup element, in the template unconditionally (see the class remarks). */
|
|
94
|
+
popupEl;
|
|
95
|
+
/** The `[slot=label]` capture point. */
|
|
96
|
+
labelSlot;
|
|
97
|
+
/** The `[slot=note]` capture point. */
|
|
98
|
+
noteSlot;
|
|
99
|
+
/** The empty-state line, rendered in the template and detached when a note is present. */
|
|
100
|
+
emptyNoteEl;
|
|
101
|
+
/** The DOM renderer, for the attach/detach reconciliation. */
|
|
102
|
+
renderer = inject(RendererFactory2).createRenderer(null, null);
|
|
103
|
+
/** Reconciles the popup against React's DOM. */
|
|
104
|
+
popupToggle = new ElementToggle(this.renderer);
|
|
105
|
+
/** Reconciles the label capture point. */
|
|
106
|
+
labelToggle = new ElementToggle(this.renderer);
|
|
107
|
+
/** Reconciles the note capture point. */
|
|
108
|
+
noteToggle = new ElementToggle(this.renderer);
|
|
109
|
+
/** Reconciles the empty-state line. */
|
|
110
|
+
emptyToggle = new ElementToggle(this.renderer);
|
|
111
|
+
/** Whether a `[slot=note]` projection landed. */
|
|
112
|
+
noteProjected = false;
|
|
113
|
+
/**
|
|
114
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
115
|
+
* locale, so the view re-renders the text on a locale switch.
|
|
116
|
+
*/
|
|
117
|
+
i18n = useTranslation();
|
|
118
|
+
/**
|
|
119
|
+
* The current class map.
|
|
120
|
+
* @returns The UIClassMap.
|
|
121
|
+
*/
|
|
122
|
+
cm() {
|
|
123
|
+
return getClassMap();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The wrapper's class list (React's `cm.cn(className)`).
|
|
127
|
+
* @returns The class string.
|
|
128
|
+
*/
|
|
129
|
+
classes() {
|
|
130
|
+
return this.cm().cn(this.className);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The marker button's class list (React's `cm.cn(cm.roundedFull, cm.cursorPointer)`).
|
|
134
|
+
* @returns The class string.
|
|
135
|
+
*/
|
|
136
|
+
markerClasses() {
|
|
137
|
+
return this.cm().cn(this.cm().roundedFull, this.cm().cursorPointer);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The marker label's class list (React's `cm.cn(cm.textSize('xs'), cm.fontWeight('bold'))`).
|
|
141
|
+
* @returns The class string.
|
|
142
|
+
*/
|
|
143
|
+
labelClasses() {
|
|
144
|
+
return this.cm().cn(this.cm().textSize('xs'), this.cm().fontWeight('bold'));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The popup's class list (React's `cm.cn(cm.surface, cm.borderAll, cm.textSize('sm'))`).
|
|
148
|
+
* @returns The class string.
|
|
149
|
+
*/
|
|
150
|
+
popupClasses() {
|
|
151
|
+
return this.cm().cn(this.cm().surface, this.cm().borderAll, this.cm().textSize('sm'));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The wrapper's inline style (React's `wrapperStyle`).
|
|
155
|
+
* @returns The serialised style attribute.
|
|
156
|
+
*/
|
|
157
|
+
wrapperStyle() {
|
|
158
|
+
const normalised = this.normalised ?? true;
|
|
159
|
+
return styleString({
|
|
160
|
+
position: 'absolute',
|
|
161
|
+
left: normalised ? `${this.position.x * 100}%` : `${this.position.x}px`,
|
|
162
|
+
top: normalised ? `${this.position.y * 100}%` : `${this.position.y}px`,
|
|
163
|
+
transform: 'translate(-50%, -50%)',
|
|
164
|
+
zIndex: this.selected ? 2 : 1,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The marker button's inline style (React's `markerStyle`), as a style map
|
|
169
|
+
* so the CSSOM normalises it exactly as React's own inline styles do.
|
|
170
|
+
* @returns The style map.
|
|
171
|
+
*/
|
|
172
|
+
markerStyles() {
|
|
173
|
+
return styleObject({
|
|
174
|
+
width: 24,
|
|
175
|
+
height: 24,
|
|
176
|
+
border: 'none',
|
|
177
|
+
padding: 0,
|
|
178
|
+
cursor: 'pointer',
|
|
179
|
+
display: 'inline-flex',
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
justifyContent: 'center',
|
|
182
|
+
boxShadow: '0 1px 3px rgba(0,0,0,0.25)',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The marker label's inline style (React's `{ lineHeight: 1, pointerEvents: 'none' }`).
|
|
187
|
+
* @returns The serialised style attribute.
|
|
188
|
+
*/
|
|
189
|
+
labelStyle() {
|
|
190
|
+
return styleString({ lineHeight: 1, pointerEvents: 'none' });
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The popup's inline style (React's `popupStyle`, side-specific).
|
|
194
|
+
* @returns The serialised style attribute.
|
|
195
|
+
*/
|
|
196
|
+
popupStyle() {
|
|
197
|
+
const base = {
|
|
198
|
+
position: 'absolute',
|
|
199
|
+
minWidth: 160,
|
|
200
|
+
maxWidth: 240,
|
|
201
|
+
padding: 8,
|
|
202
|
+
borderRadius: 4,
|
|
203
|
+
boxShadow: '0 4px 12px rgba(0,0,0,0.18)',
|
|
204
|
+
zIndex: 3,
|
|
205
|
+
};
|
|
206
|
+
switch (this.popupSide ?? 'right') {
|
|
207
|
+
case 'top':
|
|
208
|
+
base.bottom = '100%';
|
|
209
|
+
base.left = '50%';
|
|
210
|
+
base.transform = 'translate(-50%, -8px)';
|
|
211
|
+
break;
|
|
212
|
+
case 'bottom':
|
|
213
|
+
base.top = '100%';
|
|
214
|
+
base.left = '50%';
|
|
215
|
+
base.transform = 'translate(-50%, 8px)';
|
|
216
|
+
break;
|
|
217
|
+
case 'left':
|
|
218
|
+
base.right = '100%';
|
|
219
|
+
base.top = '50%';
|
|
220
|
+
base.transform = 'translate(-8px, -50%)';
|
|
221
|
+
break;
|
|
222
|
+
case 'right':
|
|
223
|
+
default:
|
|
224
|
+
base.left = '100%';
|
|
225
|
+
base.top = '50%';
|
|
226
|
+
base.transform = 'translate(8px, -50%)';
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
return styleString(base);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* The label as a template, when the caller passed a node.
|
|
233
|
+
* @returns The template, or null.
|
|
234
|
+
*/
|
|
235
|
+
labelTemplate() {
|
|
236
|
+
return isTemplate(this.label) ? this.label : null;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The label as text, when the caller passed one.
|
|
240
|
+
* @returns The text, or null.
|
|
241
|
+
*/
|
|
242
|
+
labelText() {
|
|
243
|
+
return textOf(this.label);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The note as a template, when the caller passed a node.
|
|
247
|
+
* @returns The template, or null.
|
|
248
|
+
*/
|
|
249
|
+
noteTemplate() {
|
|
250
|
+
return isTemplate(this.note) ? this.note : null;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The note as text, when the caller passed one.
|
|
254
|
+
* @returns The text, or null.
|
|
255
|
+
*/
|
|
256
|
+
noteText() {
|
|
257
|
+
return textOf(this.note);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Whether a label prop was given (any value React would render, `''`
|
|
261
|
+
* included).
|
|
262
|
+
* @returns True when the label prop is present.
|
|
263
|
+
*/
|
|
264
|
+
hasLabelProp() {
|
|
265
|
+
return this.label !== undefined && this.label !== null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Whether a note prop was given (any value React would render, `''` included).
|
|
269
|
+
* @returns True when the note prop is present.
|
|
270
|
+
*/
|
|
271
|
+
hasNoteProp() {
|
|
272
|
+
return this.note !== undefined && this.note !== null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Whether the popup body holds the caller's note (React's `note ?? …`):
|
|
276
|
+
* a note prop of any value, or `[slot=note]` content.
|
|
277
|
+
* @returns True when the note renders instead of the empty state.
|
|
278
|
+
*/
|
|
279
|
+
hasNote() {
|
|
280
|
+
return this.hasNoteProp() || this.noteProjected;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The marker button's accessible label (React's `annotationPin.aria.marker`).
|
|
284
|
+
* @returns The label text.
|
|
285
|
+
*/
|
|
286
|
+
markerLabel() {
|
|
287
|
+
return this.i18n.t('annotationPin.aria.marker', {}, { defaultValue: 'Annotation pin' });
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The popup's accessible label (React's `annotationPin.aria.popup`).
|
|
291
|
+
* @returns The label text.
|
|
292
|
+
*/
|
|
293
|
+
popupLabel() {
|
|
294
|
+
return this.i18n.t('annotationPin.aria.popup', {}, { defaultValue: 'Annotation details' });
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The popup's empty-state text (React's `annotationPin.empty`).
|
|
298
|
+
* @returns The text.
|
|
299
|
+
*/
|
|
300
|
+
emptyNote() {
|
|
301
|
+
return this.i18n.t('annotationPin.empty', {}, { defaultValue: 'No notes for this pin.' });
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Stops the marker click from bubbling to arbitrary ancestor click handlers
|
|
305
|
+
* and forwards it to `onClick`.
|
|
306
|
+
*
|
|
307
|
+
* @param event - The originating mouse event.
|
|
308
|
+
*/
|
|
309
|
+
handleMarkerClick(event) {
|
|
310
|
+
event.stopPropagation();
|
|
311
|
+
this.onClick?.();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Reads the projected capture points and reconciles the popup and the two
|
|
315
|
+
* capture wrappers against what React renders.
|
|
316
|
+
*/
|
|
317
|
+
reconcile() {
|
|
318
|
+
const note = this.noteSlot?.nativeElement;
|
|
319
|
+
if (note)
|
|
320
|
+
this.noteProjected = hasNodes(note);
|
|
321
|
+
this.popupToggle.toggle(this.popupEl?.nativeElement, this.selected === true);
|
|
322
|
+
this.labelToggle.toggle(this.labelSlot?.nativeElement, !this.hasLabelProp());
|
|
323
|
+
this.noteToggle.toggle(note, !this.hasNoteProp());
|
|
324
|
+
this.emptyToggle.toggle(this.emptyNoteEl?.nativeElement, !this.hasNote());
|
|
325
|
+
}
|
|
326
|
+
/** Reconciles once the view (and its projections) exist. */
|
|
327
|
+
ngAfterViewInit() {
|
|
328
|
+
this.reconcile();
|
|
329
|
+
}
|
|
330
|
+
/** Reconciles after input writes, as React re-renders on a prop change. */
|
|
331
|
+
ngDoCheck() {
|
|
332
|
+
this.reconcile();
|
|
333
|
+
}
|
|
334
|
+
static ɵfac = function AnnotationPin_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AnnotationPin)(); };
|
|
335
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AnnotationPin, selectors: [["div", "mol-annotation-pin", ""]], viewQuery: function AnnotationPin_Query(rf, ctx) { if (rf & 1) {
|
|
336
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5)(_c3, 5);
|
|
337
|
+
} if (rf & 2) {
|
|
338
|
+
let _t;
|
|
339
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.popupEl = _t.first);
|
|
340
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.labelSlot = _t.first);
|
|
341
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.noteSlot = _t.first);
|
|
342
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.emptyNoteEl = _t.first);
|
|
343
|
+
} }, hostAttrs: ["data-mol-id", "annotation-pin"], hostVars: 4, hostBindings: function AnnotationPin_HostBindings(rf, ctx) { if (rf & 2) {
|
|
344
|
+
i0.ɵɵattribute("data-pin-selected", ctx.selected ? "true" : "false")("style", ctx.wrapperStyle(), i0.ɵɵsanitizeStyle);
|
|
345
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
346
|
+
} }, inputs: { position: "position", label: "label", note: "note", selected: "selected", onClick: "onClick", popupSide: "popupSide", className: "className", normalised: "normalised" }, ngContentSelectors: _c5, decls: 18, vars: 16, consts: [["labelSlot", ""], ["popupEl", ""], ["noteSlot", ""], ["emptyNoteEl", ""], ["type", "button", "data-mol-id", "annotation-pin-marker", 3, "click", "ngStyle"], ["data-mol-id", "annotation-pin-label"], [3, "ngTemplateOutlet"], ["data-parity-unwrap", ""], ["role", "dialog", "data-mol-id", "annotation-pin-popup"], ["data-mol-id", "annotation-pin-popup-body"], ["data-mol-id", "annotation-pin-popup-empty"]], template: function AnnotationPin_Template(rf, ctx) { if (rf & 1) {
|
|
347
|
+
i0.ɵɵprojectionDef(_c4);
|
|
348
|
+
i0.ɵɵelementStart(0, "button", 4);
|
|
349
|
+
i0.ɵɵlistener("click", function AnnotationPin_Template_button_click_0_listener($event) { return ctx.handleMarkerClick($event); });
|
|
350
|
+
i0.ɵɵelementStart(1, "span", 5);
|
|
351
|
+
i0.ɵɵconditionalCreate(2, AnnotationPin_Conditional_2_Template, 1, 1, "ng-container", 6)(3, AnnotationPin_Conditional_3_Template, 1, 1);
|
|
352
|
+
i0.ɵɵelementStart(4, "span", 7, 0);
|
|
353
|
+
i0.ɵɵprojection(6);
|
|
354
|
+
i0.ɵɵelementEnd()()();
|
|
355
|
+
i0.ɵɵelementStart(7, "div", 8, 1)(9, "div", 9);
|
|
356
|
+
i0.ɵɵconditionalCreate(10, AnnotationPin_Conditional_10_Template, 1, 1, "ng-container", 6)(11, AnnotationPin_Conditional_11_Template, 1, 1);
|
|
357
|
+
i0.ɵɵelementStart(12, "span", 7, 2);
|
|
358
|
+
i0.ɵɵprojection(14, 1);
|
|
359
|
+
i0.ɵɵelementEnd();
|
|
360
|
+
i0.ɵɵelementStart(15, "span", 10, 3);
|
|
361
|
+
i0.ɵɵtext(17);
|
|
362
|
+
i0.ɵɵelementEnd()()();
|
|
363
|
+
} if (rf & 2) {
|
|
364
|
+
let tmp_10_0;
|
|
365
|
+
let tmp_15_0;
|
|
366
|
+
i0.ɵɵclassMap(ctx.markerClasses());
|
|
367
|
+
i0.ɵɵproperty("ngStyle", ctx.markerStyles());
|
|
368
|
+
i0.ɵɵattribute("aria-label", ctx.markerLabel())("aria-expanded", ctx.selected ? "true" : "false");
|
|
369
|
+
i0.ɵɵadvance();
|
|
370
|
+
i0.ɵɵclassMap(ctx.labelClasses());
|
|
371
|
+
i0.ɵɵattribute("style", ctx.labelStyle(), i0.ɵɵsanitizeStyle);
|
|
372
|
+
i0.ɵɵadvance();
|
|
373
|
+
i0.ɵɵconditional((tmp_10_0 = ctx.labelTemplate()) ? 2 : ctx.labelText() !== null ? 3 : -1, tmp_10_0);
|
|
374
|
+
i0.ɵɵadvance(5);
|
|
375
|
+
i0.ɵɵclassMap(ctx.popupClasses());
|
|
376
|
+
i0.ɵɵattribute("aria-label", ctx.popupLabel())("data-popup-side", ctx.popupSide ?? "right")("style", ctx.popupStyle(), i0.ɵɵsanitizeStyle);
|
|
377
|
+
i0.ɵɵadvance(3);
|
|
378
|
+
i0.ɵɵconditional((tmp_15_0 = ctx.noteTemplate()) ? 10 : ctx.noteText() !== null ? 11 : -1, tmp_15_0);
|
|
379
|
+
i0.ɵɵadvance(7);
|
|
380
|
+
i0.ɵɵtextInterpolate(ctx.emptyNote());
|
|
381
|
+
} }, dependencies: [NgStyle, NgTemplateOutlet], encapsulation: 2 });
|
|
382
|
+
}
|
|
383
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AnnotationPin, [{
|
|
384
|
+
type: Component,
|
|
385
|
+
args: [{
|
|
386
|
+
selector: 'div[mol-annotation-pin]',
|
|
387
|
+
standalone: true,
|
|
388
|
+
imports: [NgStyle, NgTemplateOutlet],
|
|
389
|
+
inputs: [
|
|
390
|
+
'position',
|
|
391
|
+
'label',
|
|
392
|
+
'note',
|
|
393
|
+
'selected',
|
|
394
|
+
'onClick',
|
|
395
|
+
'popupSide',
|
|
396
|
+
'className',
|
|
397
|
+
'normalised',
|
|
398
|
+
],
|
|
399
|
+
host: {
|
|
400
|
+
'[class]': 'classes()',
|
|
401
|
+
'data-mol-id': 'annotation-pin',
|
|
402
|
+
'[attr.data-pin-selected]': 'selected ? "true" : "false"',
|
|
403
|
+
'[attr.style]': 'wrapperStyle()',
|
|
404
|
+
},
|
|
405
|
+
// prettier-ignore
|
|
406
|
+
template: `<button type="button" (click)="handleMarkerClick($event)" [attr.aria-label]="markerLabel()" [attr.aria-expanded]="selected ? 'true' : 'false'" data-mol-id="annotation-pin-marker" [class]="markerClasses()" [ngStyle]="markerStyles()"><span [class]="labelClasses()" data-mol-id="annotation-pin-label" [attr.style]="labelStyle()">@if (labelTemplate(); as tpl) {<ng-container [ngTemplateOutlet]="tpl" />} @else if (labelText() !== null) {{{ labelText() }}}<span #labelSlot data-parity-unwrap><ng-content select="[slot=label]"></ng-content></span></span></button><div #popupEl role="dialog" [attr.aria-label]="popupLabel()" data-mol-id="annotation-pin-popup" [attr.data-popup-side]="popupSide ?? 'right'" [class]="popupClasses()" [attr.style]="popupStyle()"><div data-mol-id="annotation-pin-popup-body">@if (noteTemplate(); as tpl) {<ng-container [ngTemplateOutlet]="tpl" />} @else if (noteText() !== null) {{{ noteText() }}}<span #noteSlot data-parity-unwrap><ng-content select="[slot=note]"></ng-content></span><span #emptyNoteEl data-mol-id="annotation-pin-popup-empty">{{ emptyNote() }}</span></div></div>`,
|
|
407
|
+
}]
|
|
408
|
+
}], null, { popupEl: [{
|
|
409
|
+
type: ViewChild,
|
|
410
|
+
args: ['popupEl']
|
|
411
|
+
}], labelSlot: [{
|
|
412
|
+
type: ViewChild,
|
|
413
|
+
args: ['labelSlot']
|
|
414
|
+
}], noteSlot: [{
|
|
415
|
+
type: ViewChild,
|
|
416
|
+
args: ['noteSlot']
|
|
417
|
+
}], emptyNoteEl: [{
|
|
418
|
+
type: ViewChild,
|
|
419
|
+
args: ['emptyNoteEl']
|
|
420
|
+
}] }); })();
|
|
421
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AnnotationPin, { className: "AnnotationPin", filePath: "annotation-pin.component.ts", lineNumber: 89 }); })();
|
|
422
|
+
//# sourceMappingURL=annotation-pin.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-pin.component.js","sourceRoot":"","sources":["../src/annotation-pin.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAEL,SAAS,EAGT,MAAM,EAEN,gBAAgB,EAEhB,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;;;;;;;;;IA8D2T,2BAAyC;;IAA3B,sCAAwB;;;IAAsC,YAAiB;;;IAAjB,wCAAiB;;;IAAyX,2BAAyC;;IAA3B,sCAAwB;;;IAAqC,YAAgB;;;IAAhB,uCAAgB;;AA5Dn6B;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAAiC,EAAE,CACnE,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,OAAQ,KAA8B,CAAC,kBAAkB,KAAK,UAAU,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAC/C,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAE/E;;;;;;;;;;;;;;;;GAgBG;AAwBH,MAAM,OAAO,aAAa;IACxB,qFAAqF;IACrF,QAAQ,CAA2B;IACnC,mFAAmF;IACnF,KAAK,CAAgD;IACrD,6EAA6E;IAC7E,IAA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EAAS;YAAmM,AAAnM,iCAAmM,aAA6C;YAAyE,AAAzE,0FAA8B,iDAA2E;YAAiB,mCAAmC;YAAA,sBAA8C;YAAA,iBAAO;YAAA,oCAA4D;YAAA,aAAiB;YAAa,AAAN,AAAP,iBAAO,EAAM,EAAM;;;;YAA55B,kCAAyB;YAAC,4CAA0B;;YAAO,cAAwB;YAAxB,iCAAwB;;YAAgE,cAA6H;YAA7H,oGAA6H;YAAwP,eAAwB;YAAxB,iCAAwB;;YAA0E,eAA0H;YAA1H,oGAA0H;YAAoJ,eAAiB;YAAjB,qCAAiB;4BAlB7jC,OAAO,EAAE,gBAAgB;;iFAoBxB,aAAa;cAvBzB,SAAS;eAAC;gBACT,QAAQ,EAAE,yBAAyB;gBACnC,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC;gBACpC,MAAM,EAAE;oBACN,UAAU;oBACV,OAAO;oBACP,MAAM;oBACN,UAAU;oBACV,SAAS;oBACT,WAAW;oBACX,WAAW;oBACX,YAAY;iBACb;gBACD,IAAI,EAAE;oBACJ,SAAS,EAAE,WAAW;oBACtB,aAAa,EAAE,gBAAgB;oBAC/B,0BAA0B,EAAE,6BAA6B;oBACzD,cAAc,EAAE,gBAAgB;iBACjC;gBACD,kBAAkB;gBAClB,QAAQ,EAAE,ilCAAilC;aAC5lC;;kBAoBE,SAAS;mBAAC,SAAS;;kBAEnB,SAAS;mBAAC,WAAW;;kBAErB,SAAS;mBAAC,UAAU;;kBAEpB,SAAS;mBAAC,aAAa;;kFAzBb,aAAa"}
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline-style serialisation for the annotation-pin components.
|
|
3
|
+
*
|
|
4
|
+
* React turns a style object into the element's `style` attribute, adding
|
|
5
|
+
* `px` to numeric values except the properties CSS keeps unitless. The other
|
|
6
|
+
* frameworks differ here (Solid passes values straight to the CSSOM), so the
|
|
7
|
+
* components serialise the style themselves: every framework then renders the
|
|
8
|
+
* same declarations and therefore the same pixels.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Serialises a style object into the `style` attribute React would render.
|
|
14
|
+
*
|
|
15
|
+
* @param style - The style declarations.
|
|
16
|
+
* @returns The attribute value.
|
|
17
|
+
*/
|
|
18
|
+
export declare const styleString: (style: Record<string, string | number>) => string;
|
|
19
|
+
/**
|
|
20
|
+
* The same declarations as a style map for Angular's `NgStyle`.
|
|
21
|
+
*
|
|
22
|
+
* `NgStyle` applies each declaration through the CSSOM, which is what React
|
|
23
|
+
* does — an attribute written with `border: none` would keep that spelling
|
|
24
|
+
* while React's normalised attribute says `border: medium`. Keys stay in
|
|
25
|
+
* their camelCase form, which the CSSOM accepts in either spelling.
|
|
26
|
+
*
|
|
27
|
+
* @param style - The style declarations.
|
|
28
|
+
* @returns The style map.
|
|
29
|
+
*/
|
|
30
|
+
export declare const styleObject: (style: Record<string, string | number>) => Record<string, string>;
|
|
31
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoDH;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAStD,CAAA;AAEf;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CASvF,CAAA"}
|
package/dist/css.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline-style serialisation for the annotation-pin components.
|
|
3
|
+
*
|
|
4
|
+
* React turns a style object into the element's `style` attribute, adding
|
|
5
|
+
* `px` to numeric values except the properties CSS keeps unitless. The other
|
|
6
|
+
* frameworks differ here (Solid passes values straight to the CSSOM), so the
|
|
7
|
+
* components serialise the style themselves: every framework then renders the
|
|
8
|
+
* same declarations and therefore the same pixels.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** Properties React keeps unitless — a numeric value gets no `px`. */
|
|
13
|
+
const UNITLESS = new Set([
|
|
14
|
+
'animation-iteration-count',
|
|
15
|
+
'aspect-ratio',
|
|
16
|
+
'border-image-outset',
|
|
17
|
+
'border-image-slice',
|
|
18
|
+
'border-image-width',
|
|
19
|
+
'column-count',
|
|
20
|
+
'columns',
|
|
21
|
+
'fill-opacity',
|
|
22
|
+
'flex',
|
|
23
|
+
'flex-grow',
|
|
24
|
+
'flex-shrink',
|
|
25
|
+
'flood-opacity',
|
|
26
|
+
'font-weight',
|
|
27
|
+
'grid-area',
|
|
28
|
+
'grid-column',
|
|
29
|
+
'grid-column-end',
|
|
30
|
+
'grid-column-start',
|
|
31
|
+
'grid-row',
|
|
32
|
+
'grid-row-end',
|
|
33
|
+
'grid-row-start',
|
|
34
|
+
'line-clamp',
|
|
35
|
+
'line-height',
|
|
36
|
+
'opacity',
|
|
37
|
+
'order',
|
|
38
|
+
'orphans',
|
|
39
|
+
'scale',
|
|
40
|
+
'stop-opacity',
|
|
41
|
+
'stroke-dasharray',
|
|
42
|
+
'stroke-dashoffset',
|
|
43
|
+
'stroke-miterlimit',
|
|
44
|
+
'stroke-opacity',
|
|
45
|
+
'stroke-width',
|
|
46
|
+
'tab-size',
|
|
47
|
+
'widows',
|
|
48
|
+
'z-index',
|
|
49
|
+
'zoom',
|
|
50
|
+
]);
|
|
51
|
+
/**
|
|
52
|
+
* Hyphenates a camelCase CSS property name; an already-hyphenated name and a
|
|
53
|
+
* `--custom-property` are returned as they are.
|
|
54
|
+
*
|
|
55
|
+
* @param name - The property name.
|
|
56
|
+
* @returns The CSS property name.
|
|
57
|
+
*/
|
|
58
|
+
const hyphenate = (name) => name.startsWith('--') ? name : name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
59
|
+
/**
|
|
60
|
+
* Serialises a style object into the `style` attribute React would render.
|
|
61
|
+
*
|
|
62
|
+
* @param style - The style declarations.
|
|
63
|
+
* @returns The attribute value.
|
|
64
|
+
*/
|
|
65
|
+
export const styleString = (style) => Object.entries(style)
|
|
66
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
67
|
+
.map(([name, value]) => {
|
|
68
|
+
const property = hyphenate(name);
|
|
69
|
+
const rendered = typeof value === 'number' && !UNITLESS.has(property) ? `${value}px` : String(value);
|
|
70
|
+
return `${property}: ${rendered}`;
|
|
71
|
+
})
|
|
72
|
+
.join('; ');
|
|
73
|
+
/**
|
|
74
|
+
* The same declarations as a style map for Angular's `NgStyle`.
|
|
75
|
+
*
|
|
76
|
+
* `NgStyle` applies each declaration through the CSSOM, which is what React
|
|
77
|
+
* does — an attribute written with `border: none` would keep that spelling
|
|
78
|
+
* while React's normalised attribute says `border: medium`. Keys stay in
|
|
79
|
+
* their camelCase form, which the CSSOM accepts in either spelling.
|
|
80
|
+
*
|
|
81
|
+
* @param style - The style declarations.
|
|
82
|
+
* @returns The style map.
|
|
83
|
+
*/
|
|
84
|
+
export const styleObject = (style) => Object.fromEntries(Object.entries(style)
|
|
85
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
86
|
+
.map(([name, value]) => {
|
|
87
|
+
const rendered = typeof value === 'number' && !UNITLESS.has(hyphenate(name)) ? `${value}px` : String(value);
|
|
88
|
+
return [name, rendered];
|
|
89
|
+
}));
|
|
90
|
+
//# sourceMappingURL=css.js.map
|
package/dist/css.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sEAAsE;AACtE,MAAM,QAAQ,GAAG,I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,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACrF,OAAO,GAAG,QAAQ,KAAK,QAAQ,EAAE,CAAA;AACnC,CAAC,CAAC;KACD,IAAI,CAAC,IAAI,CAAC,CAAA;AAEf;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAsC,EAA0B,EAAE,CAC5F,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;KAClB,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;KAC5E,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;IACrB,MAAM,QAAQ,GACZ,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5F,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AACzB,CAAC,CAAC,CACL,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular annotation pin / hotspot overlay primitives — the Angular
|
|
3
|
+
* counterpart of `@molecule/app-annotation-pin-react`: same props (React
|
|
4
|
+
* names) and the same DOM for the same input, so an app switches framework by
|
|
5
|
+
* changing only the package name in its imports.
|
|
6
|
+
*
|
|
7
|
+
* Exports `<AnnotationPin>` (single click-to-toggle marker) and
|
|
8
|
+
* `<AnnotationLayer>` (parent wrapper that manages many pins on a surface).
|
|
9
|
+
* Reusable for 3d-model viewers, image annotations, map pins, and hotspot
|
|
10
|
+
* tours.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Component, signal } from '@angular/core'
|
|
15
|
+
* import { AnnotationLayer, type Pin } from '@molecule/app-annotation-pin-angular'
|
|
16
|
+
*
|
|
17
|
+
* @Component({
|
|
18
|
+
* selector: 'app-image-annotator',
|
|
19
|
+
* standalone: true,
|
|
20
|
+
* imports: [AnnotationLayer],
|
|
21
|
+
* template: `
|
|
22
|
+
* <div mol-annotation-layer
|
|
23
|
+
* [pins]="pins()"
|
|
24
|
+
* [activePinId]="activeId()"
|
|
25
|
+
* (onPinClick)="select($event)"
|
|
26
|
+
* (onSurfaceClick)="addPin($event)">
|
|
27
|
+
* <img src="/floorplan.png" alt="" style="width: 100%; display: block" />
|
|
28
|
+
* </div>
|
|
29
|
+
* `,
|
|
30
|
+
* })
|
|
31
|
+
* export class ImageAnnotator {
|
|
32
|
+
* readonly pins = signal<Pin[]>([])
|
|
33
|
+
* readonly activeId = signal<string | null>(null)
|
|
34
|
+
*
|
|
35
|
+
* select(id: string): void {
|
|
36
|
+
* this.activeId.set(id === this.activeId() ? null : id)
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* addPin({ x, y }: { x: number; y: number }): void {
|
|
40
|
+
* const id = crypto.randomUUID()
|
|
41
|
+
* this.pins.update((pins) => [...pins, { id, position: { x, y }, label: pins.length + 1 }])
|
|
42
|
+
* this.activeId.set(id)
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Selection is fully controlled — the layer never stores the active pin;
|
|
49
|
+
* manage `activePinId` yourself and toggle it in `onPinClick`. `position` is
|
|
50
|
+
* normalised 0..1 by default (fractions of the layer box, so pins re-anchor on
|
|
51
|
+
* resize); pass `[normalised]="false"` for raw pixel offsets — on BOTH
|
|
52
|
+
* `<AnnotationLayer>` and any directly-rendered `<AnnotationPin>`, or clicks
|
|
53
|
+
* and markers will disagree. Node props are projected content in Angular
|
|
54
|
+
* (`[slot=label]`, `[slot=note]`, and the layer's default content for the
|
|
55
|
+
* surface) or an input carrying text / a `TemplateRef`. A bare
|
|
56
|
+
* `<AnnotationPin>` needs its own positioned ancestor. Translations come from
|
|
57
|
+
* the companion `@molecule/app-locales-annotation-pin` locale bond.
|
|
58
|
+
*
|
|
59
|
+
* @module
|
|
60
|
+
*/
|
|
61
|
+
export * from './annotation-layer.component.js';
|
|
62
|
+
export * from './annotation-pin.component.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,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
|