@uibit/hotspot 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # Hotspot
2
2
 
3
+ [![NPM Version](https://img.shields.io/npm/v/@uibit/hotspot.svg?style=flat-square&color=black)](https://www.npmjs.com/package/@uibit/hotspot)
4
+
5
+
3
6
  [Interactive Demonstration](https://rawlings.github.io/uibit/components/hotspot)
4
7
 
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @uibit/hotspot
12
+ ```
13
+
14
+
5
15
  Hotspot enables interactive image exploration by overlaying contextual annotations on top of specific regions of an image. It transforms static diagrams, product mockups, and photographs into interactive guides that reveal rich details on demand, reducing clutter.
6
16
 
7
17
  ## Value Delivery
@@ -8,7 +8,7 @@
8
8
  "declarations": [
9
9
  {
10
10
  "kind": "class",
11
- "description": "Interactive hotspot annotations for images. Display contextual tooltip\ncards on click or hover with custom content overlays and animations.",
11
+ "description": "Interactive hotspot annotations for images. Display contextual tooltip",
12
12
  "name": "Hotspot",
13
13
  "cssProperties": [
14
14
  {
@@ -245,6 +245,211 @@
245
245
  }
246
246
  }
247
247
  ]
248
+ },
249
+ {
250
+ "kind": "field",
251
+ "name": "locale",
252
+ "type": {
253
+ "text": "string"
254
+ },
255
+ "default": "''",
256
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
257
+ "attribute": "locale",
258
+ "inheritedFrom": {
259
+ "name": "UIBitElement",
260
+ "module": "../../platform/core/src/element.ts"
261
+ }
262
+ },
263
+ {
264
+ "kind": "field",
265
+ "name": "resolvedLocale",
266
+ "type": {
267
+ "text": "string | undefined"
268
+ },
269
+ "description": "Resolves the active locale for formatting and localization.\nChecks the `locale` property first, then traverses up the DOM to find\nthe nearest ancestor with a `lang` attribute, and finally falls back\nto undefined (which defaults to browser locale).",
270
+ "readonly": true,
271
+ "inheritedFrom": {
272
+ "name": "UIBitElement",
273
+ "module": "../../platform/core/src/element.ts"
274
+ }
275
+ },
276
+ {
277
+ "kind": "field",
278
+ "name": "_disposables",
279
+ "type": {
280
+ "text": "Set<() => void>"
281
+ },
282
+ "privacy": "private",
283
+ "default": "new Set()",
284
+ "inheritedFrom": {
285
+ "name": "UIBitElement",
286
+ "module": "../../platform/core/src/element.ts"
287
+ }
288
+ },
289
+ {
290
+ "kind": "method",
291
+ "name": "createProperty",
292
+ "static": true,
293
+ "parameters": [
294
+ {
295
+ "name": "name",
296
+ "type": {
297
+ "text": "PropertyKey"
298
+ }
299
+ },
300
+ {
301
+ "name": "options",
302
+ "optional": true,
303
+ "type": {
304
+ "text": "PropertyDeclaration"
305
+ }
306
+ }
307
+ ],
308
+ "description": "Overrides createProperty to automatically map camelCase property names\nto kebab-case attribute names by default.",
309
+ "inheritedFrom": {
310
+ "name": "UIBitElement",
311
+ "module": "../../platform/core/src/element.ts"
312
+ }
313
+ },
314
+ {
315
+ "kind": "method",
316
+ "name": "finalizeStyles",
317
+ "static": true,
318
+ "return": {
319
+ "type": {
320
+ "text": "Array<any>"
321
+ }
322
+ },
323
+ "parameters": [
324
+ {
325
+ "name": "styles",
326
+ "optional": true,
327
+ "type": {
328
+ "text": "CSSResultGroup"
329
+ }
330
+ }
331
+ ],
332
+ "description": "Automatically prepends basic layout resets (border-box) to the\ncomponent's final styles.",
333
+ "inheritedFrom": {
334
+ "name": "UIBitElement",
335
+ "module": "../../platform/core/src/element.ts"
336
+ }
337
+ },
338
+ {
339
+ "kind": "method",
340
+ "name": "dispatchCustomEvent",
341
+ "return": {
342
+ "type": {
343
+ "text": "boolean"
344
+ }
345
+ },
346
+ "parameters": [
347
+ {
348
+ "name": "name",
349
+ "type": {
350
+ "text": "string"
351
+ }
352
+ },
353
+ {
354
+ "name": "detail",
355
+ "optional": true,
356
+ "type": {
357
+ "text": "T"
358
+ }
359
+ },
360
+ {
361
+ "name": "options",
362
+ "optional": true,
363
+ "type": {
364
+ "text": "Omit<CustomEventInit<T>, 'detail'>"
365
+ }
366
+ }
367
+ ],
368
+ "description": "Helper to dispatch a custom event with standard bubbles and composed options.",
369
+ "inheritedFrom": {
370
+ "name": "UIBitElement",
371
+ "module": "../../platform/core/src/element.ts"
372
+ }
373
+ },
374
+ {
375
+ "kind": "method",
376
+ "name": "getCssPropertyValue",
377
+ "return": {
378
+ "type": {
379
+ "text": "string"
380
+ }
381
+ },
382
+ "parameters": [
383
+ {
384
+ "name": "propertyName",
385
+ "type": {
386
+ "text": "string"
387
+ }
388
+ }
389
+ ],
390
+ "description": "Helper to retrieve a computed CSS custom property value from the element.",
391
+ "inheritedFrom": {
392
+ "name": "UIBitElement",
393
+ "module": "../../platform/core/src/element.ts"
394
+ }
395
+ },
396
+ {
397
+ "kind": "method",
398
+ "name": "registerDisposable",
399
+ "parameters": [
400
+ {
401
+ "name": "cleanup",
402
+ "type": {
403
+ "text": "() => void"
404
+ }
405
+ }
406
+ ],
407
+ "description": "Register a cleanup function to be executed when the element is disconnected from the DOM.",
408
+ "inheritedFrom": {
409
+ "name": "UIBitElement",
410
+ "module": "../../platform/core/src/element.ts"
411
+ }
412
+ },
413
+ {
414
+ "kind": "method",
415
+ "name": "listen",
416
+ "return": {
417
+ "type": {
418
+ "text": "() => void"
419
+ }
420
+ },
421
+ "parameters": [
422
+ {
423
+ "name": "target",
424
+ "type": {
425
+ "text": "EventTarget"
426
+ }
427
+ },
428
+ {
429
+ "name": "type",
430
+ "type": {
431
+ "text": "K"
432
+ }
433
+ },
434
+ {
435
+ "name": "listener",
436
+ "type": {
437
+ "text": "(this: EventTarget, ev: HTMLElementEventMap[K]) => any"
438
+ }
439
+ },
440
+ {
441
+ "name": "options",
442
+ "optional": true,
443
+ "type": {
444
+ "text": "boolean | AddEventListenerOptions"
445
+ }
446
+ }
447
+ ],
448
+ "description": "Utility to add an event listener that is automatically cleaned up when the element is disconnected.",
449
+ "inheritedFrom": {
450
+ "name": "UIBitElement",
451
+ "module": "../../platform/core/src/element.ts"
452
+ }
248
453
  }
249
454
  ],
250
455
  "events": [
@@ -283,12 +488,32 @@
283
488
  "default": "'click'",
284
489
  "description": "Interaction mode for showing the popover.",
285
490
  "fieldName": "trigger"
491
+ },
492
+ {
493
+ "name": "locale",
494
+ "type": {
495
+ "text": "string"
496
+ },
497
+ "default": "''",
498
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
499
+ "fieldName": "locale",
500
+ "inheritedFrom": {
501
+ "name": "UIBitElement",
502
+ "module": "../../platform/core/src/element.ts"
503
+ }
504
+ }
505
+ ],
506
+ "cssStates": [
507
+ {
508
+ "name": "active",
509
+ "description": "Active when the hotspot popover is expanded."
286
510
  }
287
511
  ],
288
512
  "superclass": {
289
513
  "name": "UIBitElement",
290
514
  "package": "@uibit/core"
291
515
  },
516
+ "summary": "An interactive image hotspot component with animated markers and popovers.\ncards on click or hover with custom content overlays and animations.",
292
517
  "tagName": "uibit-hotspot",
293
518
  "customElement": true
294
519
  }
@@ -385,6 +610,250 @@
385
610
  "path": "src/types.ts",
386
611
  "declarations": [],
387
612
  "exports": []
613
+ },
614
+ {
615
+ "kind": "javascript-module",
616
+ "path": "../../platform/core/src/element.ts",
617
+ "declarations": [
618
+ {
619
+ "kind": "class",
620
+ "description": "A foundational base class for all UIBit web components.\nProvides custom event helpers, default kebab-case attribute mapping,\nautomatic cleanup/disposable tracking, and auto-injected reset styles.",
621
+ "name": "UIBitElement",
622
+ "members": [
623
+ {
624
+ "kind": "field",
625
+ "name": "locale",
626
+ "type": {
627
+ "text": "string"
628
+ },
629
+ "default": "''",
630
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
631
+ "attribute": "locale"
632
+ },
633
+ {
634
+ "kind": "field",
635
+ "name": "resolvedLocale",
636
+ "type": {
637
+ "text": "string | undefined"
638
+ },
639
+ "description": "Resolves the active locale for formatting and localization.\nChecks the `locale` property first, then traverses up the DOM to find\nthe nearest ancestor with a `lang` attribute, and finally falls back\nto undefined (which defaults to browser locale).",
640
+ "readonly": true
641
+ },
642
+ {
643
+ "kind": "field",
644
+ "name": "_disposables",
645
+ "type": {
646
+ "text": "Set<() => void>"
647
+ },
648
+ "privacy": "private",
649
+ "default": "new Set()"
650
+ },
651
+ {
652
+ "kind": "method",
653
+ "name": "createProperty",
654
+ "static": true,
655
+ "parameters": [
656
+ {
657
+ "name": "name",
658
+ "type": {
659
+ "text": "PropertyKey"
660
+ }
661
+ },
662
+ {
663
+ "name": "options",
664
+ "optional": true,
665
+ "type": {
666
+ "text": "PropertyDeclaration"
667
+ }
668
+ }
669
+ ],
670
+ "description": "Overrides createProperty to automatically map camelCase property names\nto kebab-case attribute names by default."
671
+ },
672
+ {
673
+ "kind": "method",
674
+ "name": "finalizeStyles",
675
+ "static": true,
676
+ "return": {
677
+ "type": {
678
+ "text": "Array<any>"
679
+ }
680
+ },
681
+ "parameters": [
682
+ {
683
+ "name": "styles",
684
+ "optional": true,
685
+ "type": {
686
+ "text": "CSSResultGroup"
687
+ }
688
+ }
689
+ ],
690
+ "description": "Automatically prepends basic layout resets (border-box) to the\ncomponent's final styles."
691
+ },
692
+ {
693
+ "kind": "method",
694
+ "name": "dispatchCustomEvent",
695
+ "return": {
696
+ "type": {
697
+ "text": "boolean"
698
+ }
699
+ },
700
+ "parameters": [
701
+ {
702
+ "name": "name",
703
+ "type": {
704
+ "text": "string"
705
+ }
706
+ },
707
+ {
708
+ "name": "detail",
709
+ "optional": true,
710
+ "type": {
711
+ "text": "T"
712
+ }
713
+ },
714
+ {
715
+ "name": "options",
716
+ "optional": true,
717
+ "type": {
718
+ "text": "Omit<CustomEventInit<T>, 'detail'>"
719
+ }
720
+ }
721
+ ],
722
+ "description": "Helper to dispatch a custom event with standard bubbles and composed options."
723
+ },
724
+ {
725
+ "kind": "method",
726
+ "name": "getCssPropertyValue",
727
+ "return": {
728
+ "type": {
729
+ "text": "string"
730
+ }
731
+ },
732
+ "parameters": [
733
+ {
734
+ "name": "propertyName",
735
+ "type": {
736
+ "text": "string"
737
+ }
738
+ }
739
+ ],
740
+ "description": "Helper to retrieve a computed CSS custom property value from the element."
741
+ },
742
+ {
743
+ "kind": "method",
744
+ "name": "registerDisposable",
745
+ "parameters": [
746
+ {
747
+ "name": "cleanup",
748
+ "type": {
749
+ "text": "() => void"
750
+ }
751
+ }
752
+ ],
753
+ "description": "Register a cleanup function to be executed when the element is disconnected from the DOM."
754
+ },
755
+ {
756
+ "kind": "method",
757
+ "name": "listen",
758
+ "return": {
759
+ "type": {
760
+ "text": "() => void"
761
+ }
762
+ },
763
+ "parameters": [
764
+ {
765
+ "name": "target",
766
+ "type": {
767
+ "text": "EventTarget"
768
+ }
769
+ },
770
+ {
771
+ "name": "type",
772
+ "type": {
773
+ "text": "K"
774
+ }
775
+ },
776
+ {
777
+ "name": "listener",
778
+ "type": {
779
+ "text": "(this: EventTarget, ev: HTMLElementEventMap[K]) => any"
780
+ }
781
+ },
782
+ {
783
+ "name": "options",
784
+ "optional": true,
785
+ "type": {
786
+ "text": "boolean | AddEventListenerOptions"
787
+ }
788
+ }
789
+ ],
790
+ "description": "Utility to add an event listener that is automatically cleaned up when the element is disconnected."
791
+ },
792
+ {
793
+ "kind": "method",
794
+ "name": "listen",
795
+ "return": {
796
+ "type": {
797
+ "text": "() => void"
798
+ }
799
+ },
800
+ "parameters": [
801
+ {
802
+ "name": "target",
803
+ "type": {
804
+ "text": "EventTarget"
805
+ }
806
+ },
807
+ {
808
+ "name": "type",
809
+ "type": {
810
+ "text": "string"
811
+ }
812
+ },
813
+ {
814
+ "name": "listener",
815
+ "type": {
816
+ "text": "EventListenerOrEventListenerObject"
817
+ }
818
+ },
819
+ {
820
+ "name": "options",
821
+ "optional": true,
822
+ "type": {
823
+ "text": "boolean | AddEventListenerOptions"
824
+ }
825
+ }
826
+ ]
827
+ }
828
+ ],
829
+ "attributes": [
830
+ {
831
+ "name": "locale",
832
+ "type": {
833
+ "text": "string"
834
+ },
835
+ "default": "''",
836
+ "description": "BCP 47 locale string for formatting and localization. Defaults to inherited document language.",
837
+ "fieldName": "locale"
838
+ }
839
+ ],
840
+ "superclass": {
841
+ "name": "LitElement",
842
+ "package": "lit"
843
+ },
844
+ "customElement": true
845
+ }
846
+ ],
847
+ "exports": [
848
+ {
849
+ "kind": "js",
850
+ "name": "UIBitElement",
851
+ "declaration": {
852
+ "name": "UIBitElement",
853
+ "module": "../../platform/core/src/element.ts"
854
+ }
855
+ }
856
+ ]
388
857
  }
389
858
  ]
390
859
  }
@@ -2,38 +2,43 @@ import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output,
2
2
  import '@uibit/hotspot';
3
3
  import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
4
4
  import type { HotspotItem } from '@uibit/hotspot';
5
-
6
5
  @Component({
7
- selector: 'uibit-hotspot',
8
- template: '<ng-content></ng-content>',
9
- changeDetection: ChangeDetectionStrategy.OnPush,
10
- standalone: true,
11
- host: {
12
- '(hotspot-click)': 'hotspotClick.emit($event)'
13
- }
6
+ selector: 'uibit-hotspot',
7
+ template: '<ng-content></ng-content>',
8
+ changeDetection: ChangeDetectionStrategy.OnPush,
9
+ standalone: true,
10
+ host: {
11
+ '(hotspot-click)': 'hotspotClick.emit($event)'
12
+ }
14
13
  })
15
14
  export class NgxHotspot {
16
- constructor(private el: ElementRef<HTMLElementClass>) {
17
- effect(() => {
18
- if (this.el.nativeElement) {
19
- this.el.nativeElement.hotspots = this.hotspots();
20
- }
15
+ constructor(private el: ElementRef<HTMLElementClass>){
16
+ effect(()=>{
17
+ if (this.el.nativeElement) {
18
+ this.el.nativeElement.hotspots = this.hotspots();
19
+ }
20
+ });
21
+ effect(()=>{
22
+ if (this.el.nativeElement) {
23
+ this.el.nativeElement.interactive = this.interactive();
24
+ }
25
+ });
26
+ effect(()=>{
27
+ if (this.el.nativeElement) {
28
+ this.el.nativeElement.trigger = this.trigger();
29
+ }
30
+ });
31
+ effect(()=>{
32
+ if (this.el.nativeElement) {
33
+ this.el.nativeElement.locale = this.locale();
34
+ }
35
+ });
36
+ }
37
+ readonly hotspots = input<HotspotItem[]>([]);
38
+ readonly interactive = input<boolean, any>(true, {
39
+ transform: booleanAttribute
21
40
  });
22
- effect(() => {
23
- if (this.el.nativeElement) {
24
- this.el.nativeElement.interactive = this.interactive();
25
- }
26
- });
27
- effect(() => {
28
- if (this.el.nativeElement) {
29
- this.el.nativeElement.trigger = this.trigger();
30
- }
31
- });
32
- }
33
-
34
- readonly hotspots = input<HotspotItem[], any>([]);
35
- readonly interactive = input<boolean, any>(true, { transform: booleanAttribute });
36
- readonly trigger = input<'click' | 'hover', any>('click');
37
-
38
- readonly hotspotClick = output<CustomEvent<HotspotItem>>();
41
+ readonly trigger = input<'click' | 'hover'>('click');
42
+ readonly locale = input<string>('');
43
+ readonly hotspotClick = output<CustomEvent<HotspotItem>>();
39
44
  }
@@ -1,10 +1,17 @@
1
1
  import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
2
2
  import '@uibit/hotspot';
3
+ import type { HotspotItem } from '@uibit/hotspot';
3
4
 
4
5
  declare global {
5
6
  namespace astroHTML.JSX {
6
7
  interface IntrinsicElements {
7
- 'uibit-hotspot': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
8
+ 'uibit-hotspot': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
9
+ hotspots?: HotspotItem[];
10
+ interactive?: boolean;
11
+ trigger?: 'click' | 'hover';
12
+ locale?: string;
13
+ "on:hotspot-click"?: (event: CustomEvent<HotspotItem>) => void;
14
+ };
8
15
  }
9
16
  }
10
17
  }
@@ -10,6 +10,9 @@ declare module 'preact' {
10
10
  hotspots?: HotspotItem[];
11
11
  interactive?: boolean;
12
12
  trigger?: 'click' | 'hover';
13
+ locale?: string;
14
+ onHotspotClick?: (event: CustomEvent<HotspotItem>) => void;
15
+ "on:hotspot-click"?: (event: CustomEvent<HotspotItem>) => void;
13
16
  };
14
17
  }
15
18
  }
@@ -0,0 +1,100 @@
1
+ import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
2
+ import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
3
+ import '@uibit/hotspot';
4
+ import type { HotspotItem } from '@uibit/hotspot';
5
+ const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
6
+ export interface HotspotProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'hotspots' | 'interactive' | 'trigger' | 'locale' | 'onHotspotClick'> {
7
+ children?: React.ReactNode;
8
+ hotspots?: HotspotItem[] | string;
9
+ interactive?: boolean;
10
+ trigger?: 'click' | 'hover';
11
+ locale?: string;
12
+ onHotspotClick?: (event: CustomEvent<HotspotItem>) => void;
13
+ }
14
+ export const Hotspot = ({ ref, children, ...props }: HotspotProps & {
15
+ ref?: React.Ref<HTMLElementClass>;
16
+ })=>{
17
+ const innerRef = useRef<HTMLElementClass>(null);
18
+ const propsRef = useRef(props);
19
+ propsRef.current = props;
20
+ useImperativeHandle(ref, ()=>innerRef.current!);
21
+ useTypeOfLayoutEffect(()=>{
22
+ const element = innerRef.current;
23
+ if (element && props.hotspots !== undefined) {
24
+ (element as any).hotspots = props.hotspots;
25
+ }
26
+ }, [
27
+ props.hotspots
28
+ ]);
29
+ useTypeOfLayoutEffect(()=>{
30
+ const element = innerRef.current;
31
+ if (element && props.interactive !== undefined) {
32
+ (element as any).interactive = props.interactive;
33
+ }
34
+ }, [
35
+ props.interactive
36
+ ]);
37
+ useTypeOfLayoutEffect(()=>{
38
+ const element = innerRef.current;
39
+ if (element && props.trigger !== undefined) {
40
+ (element as any).trigger = props.trigger;
41
+ }
42
+ }, [
43
+ props.trigger
44
+ ]);
45
+ useTypeOfLayoutEffect(()=>{
46
+ const element = innerRef.current;
47
+ if (element && props.locale !== undefined) {
48
+ (element as any).locale = props.locale;
49
+ }
50
+ }, [
51
+ props.locale
52
+ ]);
53
+ useTypeOfLayoutEffect(()=>{
54
+ const element = innerRef.current;
55
+ if (!element) return;
56
+ const handleEvent = (event: Event)=>{
57
+ if (propsRef.current.onHotspotClick) {
58
+ propsRef.current.onHotspotClick(event as any);
59
+ }
60
+ };
61
+ element.addEventListener('hotspot-click', handleEvent);
62
+ return ()=>{
63
+ element.removeEventListener('hotspot-click', handleEvent);
64
+ };
65
+ }, []);
66
+ const domProps = {
67
+ ...props
68
+ };
69
+ const customPropNames = [
70
+ 'hotspots',
71
+ 'interactive',
72
+ 'trigger',
73
+ 'locale',
74
+ 'onHotspotClick'
75
+ ];
76
+ for (const key of customPropNames){
77
+ delete (domProps as any)[key];
78
+ }
79
+ return React.createElement('uibit-hotspot', {
80
+ ref: innerRef,
81
+ ...domProps
82
+ }, children);
83
+ };
84
+ declare global {
85
+ namespace React {
86
+ namespace JSX {
87
+ interface IntrinsicElements {
88
+ 'uibit-hotspot': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
89
+ children?: React.ReactNode;
90
+ class?: string;
91
+ hotspots?: HotspotItem[] | string;
92
+ interactive?: boolean;
93
+ trigger?: 'click' | 'hover';
94
+ locale?: string;
95
+ onHotspotClick?: (event: CustomEvent<HotspotItem>) => void;
96
+ };
97
+ }
98
+ }
99
+ }
100
+ }
@@ -10,7 +10,8 @@ declare module 'solid-js' {
10
10
  hotspots?: HotspotItem[];
11
11
  interactive?: boolean;
12
12
  trigger?: 'click' | 'hover';
13
- "on:hotspot-click"?: (event: CustomEvent) => void;
13
+ locale?: string;
14
+ "on:hotspot-click"?: (event: CustomEvent<HotspotItem>) => void;
14
15
  };
15
16
  }
16
17
  }
@@ -9,6 +9,9 @@ declare module '@stencil/core' {
9
9
  hotspots?: HotspotItem[];
10
10
  interactive?: boolean;
11
11
  trigger?: 'click' | 'hover';
12
+ locale?: string;
13
+ onHotspotClick?: (event: CustomEvent<HotspotItem>) => void;
14
+ "on:hotspot-click"?: (event: CustomEvent<HotspotItem>) => void;
12
15
  };
13
16
  }
14
17
  }
@@ -2,38 +2,75 @@
2
2
  import '@uibit/hotspot';
3
3
  import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
4
4
  import type { HotspotItem } from '@uibit/hotspot';
5
-
6
- let {
7
- hotspots = undefined,
8
- interactive = undefined,
9
- trigger = undefined,
10
- popover-{id} = undefined,
11
- children
5
+
6
+ let {
7
+ hotspots = $bindable(),
8
+ interactive = $bindable(),
9
+ trigger = $bindable(),
10
+ locale = $bindable(),
11
+ popover-{id} = undefined,
12
+ children,
13
+ ...restProps
12
14
  } = $props<{
13
- children?: any;
15
+ children?: import('svelte').Snippet;
14
16
  hotspots?: HotspotItem[];
15
17
  interactive?: boolean;
16
18
  trigger?: 'click' | 'hover';
19
+ locale?: string;
17
20
  popover-{id}?: import('svelte').Snippet;
21
+ [key: string]: any;
18
22
  }>();
19
-
20
- let elementRef: HTMLElementClass | null = $state(null);
21
-
22
- $effect(() => {
23
- if (elementRef && hotspots !== undefined) {
23
+
24
+ let elementRef: HTMLElementClass | null = $state(null);
25
+
26
+ $effect(() => {
27
+ if (elementRef && hotspots !== undefined && elementRef.hotspots !== hotspots) {
24
28
  elementRef.hotspots = hotspots;
25
29
  }
26
- if (elementRef && interactive !== undefined) {
30
+ if (elementRef && interactive !== undefined && elementRef.interactive !== interactive) {
27
31
  elementRef.interactive = interactive;
28
32
  }
29
- if (elementRef && trigger !== undefined) {
33
+ if (elementRef && trigger !== undefined && elementRef.trigger !== trigger) {
30
34
  elementRef.trigger = trigger;
31
35
  }
36
+ if (elementRef && locale !== undefined && elementRef.locale !== locale) {
37
+ elementRef.locale = locale;
38
+ }
39
+ });
40
+
41
+ $effect(() => {
42
+ const element = elementRef;
43
+ if (!element) return;
44
+
45
+ const handleEvent = () => {
46
+ if (hotspots !== element.hotspots) {
47
+ hotspots = element.hotspots as any;
48
+ }
49
+ if (interactive !== element.interactive) {
50
+ interactive = element.interactive as any;
51
+ }
52
+ if (trigger !== element.trigger) {
53
+ trigger = element.trigger as any;
54
+ }
55
+ if (locale !== element.locale) {
56
+ locale = element.locale as any;
57
+ }
58
+ };
59
+
60
+ const events = ['change', 'input', 'hotspot-click'];
61
+ for (const event of events) {
62
+ element.addEventListener(event, handleEvent);
63
+ }
64
+ return () => {
65
+ for (const event of events) {
66
+ element.removeEventListener(event, handleEvent);
67
+ }
68
+ };
32
69
  });
33
-
70
+
34
71
  </script>
35
72
 
36
- <uibit-hotspot bind:this={elementRef} {...$$restProps}>
73
+ <uibit-hotspot bind:this={elementRef} {...restProps}>
37
74
  {#if popover-{id}}
38
75
  <div slot="popover-{id}">
39
76
  {@render popover-{id}()}
@@ -1,27 +1,98 @@
1
- import { defineComponent, h } from 'vue';
1
+ import { defineComponent, h, ref, watch } from 'vue';
2
2
  import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
3
3
  import '@uibit/hotspot';
4
4
  import type { HotspotItem } from '@uibit/hotspot';
5
-
6
5
  export const Hotspot = defineComponent({
7
- name: 'Hotspot',
8
- props: {
9
- hotspots: { type: [String, Number, Boolean, Array, Object] as any },
10
- interactive: { type: [String, Number, Boolean, Array, Object] as any },
11
- trigger: { type: [String, Number, Boolean, Array, Object] as any }
12
- },
13
- emits: ['hotspot-click'],
14
- setup(props, { slots, emit }) {
15
- return () => {
16
- const eventListeners: Record<string, any> = {};
17
- eventListeners['onHotspot-click'] = (event: Event) => {
18
- emit('hotspot-click', event);
19
- };
20
-
21
- return h('uibit-hotspot', {
22
- ...props,
23
- ...eventListeners
24
- }, slots.default?.());
25
- };
26
- }
6
+ name: 'Hotspot',
7
+ props: {
8
+ hotspots: {
9
+ type: [
10
+ String,
11
+ Number,
12
+ Boolean,
13
+ Array,
14
+ Object
15
+ ] as any
16
+ },
17
+ interactive: {
18
+ type: [
19
+ String,
20
+ Number,
21
+ Boolean,
22
+ Array,
23
+ Object
24
+ ] as any
25
+ },
26
+ trigger: {
27
+ type: [
28
+ String,
29
+ Number,
30
+ Boolean,
31
+ Array,
32
+ Object
33
+ ] as any
34
+ },
35
+ locale: {
36
+ type: [
37
+ String,
38
+ Number,
39
+ Boolean,
40
+ Array,
41
+ Object
42
+ ] as any
43
+ }
44
+ },
45
+ emits: [
46
+ 'hotspot-click'
47
+ ],
48
+ setup (props, { slots, emit }) {
49
+ const elementRef = ref<HTMLElementClass | null>(null);
50
+ if (false) {
51
+ watch(()=>props.modelValue, (newVal)=>{
52
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
53
+ elementRef.value.value = newVal;
54
+ }
55
+ });
56
+ watch(()=>props.value, (newVal)=>{
57
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
58
+ elementRef.value.value = newVal;
59
+ }
60
+ });
61
+ }
62
+ watch(()=>props.hotspots, (newVal)=>{
63
+ if (elementRef.value && newVal !== undefined) {
64
+ (elementRef.value as any).hotspots = newVal;
65
+ }
66
+ });
67
+ watch(()=>props.interactive, (newVal)=>{
68
+ if (elementRef.value && newVal !== undefined) {
69
+ (elementRef.value as any).interactive = newVal;
70
+ }
71
+ });
72
+ watch(()=>props.trigger, (newVal)=>{
73
+ if (elementRef.value && newVal !== undefined) {
74
+ (elementRef.value as any).trigger = newVal;
75
+ }
76
+ });
77
+ watch(()=>props.locale, (newVal)=>{
78
+ if (elementRef.value && newVal !== undefined) {
79
+ (elementRef.value as any).locale = newVal;
80
+ }
81
+ });
82
+ return ()=>{
83
+ const eventListeners: Record<string, any> = {};
84
+ eventListeners['onHotspot-click'] = (event: Event)=>{
85
+ emit('hotspot-click', event);
86
+ };
87
+ const mergedProps = {
88
+ ...props,
89
+ ...eventListeners,
90
+ ref: elementRef
91
+ };
92
+ if (false && props.modelValue !== undefined) {
93
+ (mergedProps as any).value = props.modelValue;
94
+ }
95
+ return h('uibit-hotspot', mergedProps, slots.default?.());
96
+ };
97
+ }
27
98
  });
package/dist/hotspot.d.ts CHANGED
@@ -2,6 +2,8 @@ import { UIBitElement } from '@uibit/core';
2
2
  import type { HotspotItem } from './types';
3
3
  /**
4
4
  * Interactive hotspot annotations for images. Display contextual tooltip
5
+
6
+ * @summary An interactive image hotspot component with animated markers and popovers.
5
7
  * cards on click or hover with custom content overlays and animations.
6
8
  *
7
9
  * @fires {HotspotItem} hotspot-click - Fired when a hotspot trigger is activated
@@ -28,7 +30,8 @@ import type { HotspotItem } from './types';
28
30
  * @csspart popover - The popover card
29
31
  * @csspart popover-content - The content area inside the popover
30
32
  * @csspart popover-close - The close button inside the popover
31
- */
33
+
34
+ * @cssstate active - Active when the hotspot popover is expanded.*/
32
35
  export declare class Hotspot extends UIBitElement {
33
36
  static styles: import("lit").CSSResult;
34
37
  /** Array of hotspot items. Each item requires `id`, `x` (%), `y` (%), `label`, and optionally `title` and `content`. */
@@ -1 +1 @@
1
- {"version":3,"file":"hotspot.d.ts","sourceRoot":"","sources":["../src/hotspot.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,YAAY,EAAE,MAAM,aAAa,CAAC;AAGpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBACa,OAAQ,SAAQ,YAAY;IACvC,MAAM,CAAC,MAAM,0BAAU;IAEvB,wHAAwH;IAC7F,QAAQ,EAAE,WAAW,EAAE,CAAM;IACxD,0EAA0E;IAC7C,WAAW,UAAQ;IAChD,gDAAgD;IACpB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAW;IAExD,OAAO,CAAC,eAAe,CAAuB;IAEvD,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B,iBAAiB,SAIhB;IAED,oBAAoB,SAKnB;IAED,OAAO,CAAC,qBAAqB,CAI3B;IAEF,OAAO,CAAC,mBAAmB,CAMzB;IAEF,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAItB,MAAM,oCA+DL;CACF;eAEc,OAAO"}
1
+ {"version":3,"file":"hotspot.d.ts","sourceRoot":"","sources":["../src/hotspot.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,YAAY,EAAE,MAAM,aAAa,CAAC;AAGpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEA+BoE;AACpE,qBACa,OAAQ,SAAQ,YAAY;IACvC,MAAM,CAAC,MAAM,0BAAU;IAEvB,wHAAwH;IAexH,QAAQ,EAAE,WAAW,EAAE,CAAM;IAC7B,0EAA0E;IAC7C,WAAW,UAAQ;IAChD,gDAAgD;IACpB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAW;IAExD,OAAO,CAAC,eAAe,CAAuB;IAEvD,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B,iBAAiB,SAIhB;IAED,oBAAoB,SAKnB;IAED,OAAO,CAAC,qBAAqB,CAI3B;IAEF,OAAO,CAAC,mBAAmB,CAMzB;IAEF,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,uBAAuB;IAM/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAItB,MAAM,oCA+DL;CACF;eAEc,OAAO"}
package/dist/hotspot.js CHANGED
@@ -11,6 +11,8 @@ import { property, state } from 'lit/decorators.js';
11
11
  import { styles } from './styles';
12
12
  /**
13
13
  * Interactive hotspot annotations for images. Display contextual tooltip
14
+
15
+ * @summary An interactive image hotspot component with animated markers and popovers.
14
16
  * cards on click or hover with custom content overlays and animations.
15
17
  *
16
18
  * @fires {HotspotItem} hotspot-click - Fired when a hotspot trigger is activated
@@ -37,7 +39,8 @@ import { styles } from './styles';
37
39
  * @csspart popover - The popover card
38
40
  * @csspart popover-content - The content area inside the popover
39
41
  * @csspart popover-close - The close button inside the popover
40
- */
42
+
43
+ * @cssstate active - Active when the hotspot popover is expanded.*/
41
44
  let Hotspot = class Hotspot extends UIBitElement {
42
45
  constructor() {
43
46
  super(...arguments);
@@ -131,7 +134,7 @@ let Hotspot = class Hotspot extends UIBitElement {
131
134
  return html `
132
135
  <div part="container" class="hotspot-container">
133
136
  <slot></slot>
134
- ${this.hotspots.map((spot, index) => {
137
+ ${(this.hotspots || []).map((spot, index) => {
135
138
  const spotId = spot.id || String(index);
136
139
  const isOpened = this.activeHotspotId === spotId;
137
140
  const yVal = typeof spot.y === 'number' ? spot.y : parseFloat(String(spot.y || '0'));
@@ -190,7 +193,22 @@ let Hotspot = class Hotspot extends UIBitElement {
190
193
  }
191
194
  };
192
195
  __decorate([
193
- property({ type: Array })
196
+ property({
197
+ type: Array,
198
+ converter: {
199
+ fromAttribute: (value) => {
200
+ if (!value)
201
+ return [];
202
+ try {
203
+ return JSON.parse(value);
204
+ }
205
+ catch {
206
+ return [];
207
+ }
208
+ },
209
+ toAttribute: (value) => JSON.stringify(value),
210
+ },
211
+ })
194
212
  ], Hotspot.prototype, "hotspots", void 0);
195
213
  __decorate([
196
214
  property({ type: Boolean })
@@ -1 +1 @@
1
- {"version":3,"file":"hotspot.js","sourceRoot":"","sources":["../src/hotspot.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;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,KAAK,EAAE;gDAA+C;AAxB5C,OAAO;IADnB,aAAa,CAAC,eAAe,CAAC;GAClB,OAAO,CAiLnB;;AAED,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibit/hotspot",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Interactive hotspot annotations for images. Display contextual tooltip cards on click or hover with custom content overlays and animations.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "import": "./dist/index.js"
12
12
  },
13
13
  "./custom-elements.json": "./custom-elements.json",
14
- "./react": "./dist/frameworks/react/index.d.ts",
14
+ "./react": "./dist/frameworks/react/index.ts",
15
15
  "./vue": "./dist/frameworks/vue/index.ts",
16
16
  "./svelte": "./dist/frameworks/svelte/index.svelte",
17
17
  "./angular": "./dist/frameworks/angular/index.ts",
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "lucide": "^1.24.0",
48
- "@uibit/core": "0.1.0"
48
+ "@uibit/core": "0.2.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^20.19.43",
52
52
  "lit": "^3.3.3",
53
53
  "typescript": "7.0.2",
54
- "@uibit/codegen": "0.1.0"
54
+ "@uibit/codegen": "0.2.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "lit": "^3.0.0",
@@ -82,9 +82,9 @@
82
82
  "tagName": "uibit-hotspot"
83
83
  },
84
84
  "scripts": {
85
- "build": "cem analyze --globs 'src/**/*.ts' --litelement && uibit-codegen --package . && tsc",
86
- "dev": "concurrently \"cem analyze --globs 'src/**/*.ts' --litelement --watch\" \"tsc --watch\"",
87
- "analyze": "cem analyze --globs 'src/**/*.ts' --litelement",
85
+ "build": "cem analyze --config ../custom-elements-manifest.config.js && uibit-codegen --package . && tsc",
86
+ "dev": "concurrently \"cem analyze --config ../custom-elements-manifest.config.js --watch\" \"tsc --watch\"",
87
+ "analyze": "cem analyze --config ../custom-elements-manifest.config.js",
88
88
  "typecheck": "tsc --noEmit"
89
89
  }
90
90
  }
@@ -1,21 +0,0 @@
1
- import type { HTMLAttributes, ClassAttributes } from 'react';
2
- import type { Hotspot as HTMLElementClass } from '@uibit/hotspot';
3
- import '@uibit/hotspot';
4
- import type { HotspotItem } from '@uibit/hotspot';
5
-
6
- declare global {
7
- namespace React {
8
- namespace JSX {
9
- interface IntrinsicElements {
10
- 'uibit-hotspot': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
11
- children?: React.ReactNode;
12
- class?: string;
13
- hotspots?: HotspotItem[];
14
- interactive?: boolean;
15
- trigger?: 'click' | 'hover';
16
- onHotspotClick?: (event: any) => void;
17
- };
18
- }
19
- }
20
- }
21
- }