@justeattakeaway/pie-tooltip 0.5.2 → 0.7.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
@@ -48,7 +48,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
48
48
  |---|---|---|---|
49
49
  | `trigger` | Any string | The `id` of the element the panel is anchored to. The trigger lives elsewhere in the DOM and is never slotted into the tooltip. | `undefined` |
50
50
  | `isOpen` | `true`, `false` | When true, the panel is visible. The component never writes to this property. | `false` |
51
- | `position` | `top`, `top-start`, `top-end`, `bottom`, `bottom-start`, `bottom-end`, `left`, `left-start`, `left-end`, `right`, `right-start`, `right-end` | The preferred side of the trigger the panel sits on, and its alignment along the cross axis. The panel repositions itself when this would collide with the viewport or a clipping scroll container. | `top` |
51
+ | `position` | `top-centre`, `top-start`, `top-end`, `bottom-centre`, `bottom-start`, `bottom-end`, `left-centre`, `left-start`, `left-end`, `right-centre`, `right-start`, `right-end` | The side of the trigger the panel sits on, and its alignment along the cross axis. | `top-centre` |
52
52
  | `size` | `default`, `fit-to-content`, `fill-container` | How the panel sizes itself. `default` is a fixed 280px and wraps, `fit-to-content` is as wide as its content, and `fill-container` matches the inline size of the trigger's parent element. Not applied when `type` is `icon`. | `default` |
53
53
  | `variant` | `default`, `inverse` | The colour treatment of the panel. `default` is the dark panel, `inverse` the light one. | `default` |
54
54
  | `type` | `default`, `icon` | The presentation of the panel. `icon` is the compact treatment intended for icon triggers: it has no arrow and is always as wide as its content, so `size` and `--tooltip-width` have no effect on it. | `default` |
@@ -98,24 +98,13 @@ Place the tooltip next to its trigger element in the DOM for the best accessibil
98
98
  `position` names a side and, optionally, an alignment along the opposite axis:
99
99
 
100
100
  ```
101
- top top-start top-end
102
- bottom bottom-start bottom-end
103
- left left-start left-end
104
- right right-start right-end
101
+ top-centre top-start top-end
102
+ bottom-centre bottom-start bottom-end
103
+ left-centre left-start left-end
104
+ right-centre right-start right-end
105
105
  ```
106
106
 
107
- In right-to-left languages, everything on the inline axis mirrors. The alignments follow the reading direction, so `top-start` aligns against the right-hand edge, and `left` and `right` swap: a panel asked for on the left appears on the right. The `-start` and `-end` alignments of `left` and `right` are on the block axis, which has no direction to mirror, so only the side moves.
108
-
109
- ### Collision detection
110
-
111
- `position` is a preference, not a guarantee. Before the panel is shown, and on every scroll, resize or direction change while it is open, the component measures the panel against the space available and repositions it if the preferred position would collide.
112
-
113
- - It flips to the opposite side first: `top` to `bottom`, and so on.
114
- - It then tries the remaining sides.
115
- - Within a side, it shifts the alignment (for example `top-start` to `top-end`) so the panel stays fully in view.
116
- - If no position fits entirely, it uses whichever position shows the most of the panel.
117
-
118
- The available space is the viewport, narrowed by any ancestor that clips the panel. Collision detection is always on and cannot be disabled.
107
+ In right-to-left languages, everything on the inline axis mirrors. The alignments follow the reading direction, so `top-start` aligns against the right-hand edge, and the `left` and `right` sides swap: a panel asked for on the left appears on the right. The `-start` and `-end` alignments of the `left` and `right` sides are on the block axis, which has no direction to mirror, so only the side moves.
119
108
 
120
109
  ## Sizing
121
110
 
@@ -16,9 +16,9 @@
16
16
  "kind": "variable",
17
17
  "name": "positions",
18
18
  "type": {
19
- "text": "[\n 'top',\n 'top-start',\n 'top-end',\n 'bottom',\n 'bottom-start',\n 'bottom-end',\n 'left',\n 'left-start',\n 'left-end',\n 'right',\n 'right-start',\n 'right-end',\n]"
19
+ "text": "[\n 'top-centre',\n 'top-start',\n 'top-end',\n 'bottom-centre',\n 'bottom-start',\n 'bottom-end',\n 'left-centre',\n 'left-start',\n 'left-end',\n 'right-centre',\n 'right-start',\n 'right-end',\n]"
20
20
  },
21
- "default": "[ 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end', ]"
21
+ "default": "[ 'top-centre', 'top-start', 'top-end', 'bottom-centre', 'bottom-start', 'bottom-end', 'left-centre', 'left-start', 'left-end', 'right-centre', 'right-start', 'right-end', ]"
22
22
  },
23
23
  {
24
24
  "kind": "variable",
@@ -101,7 +101,7 @@
101
101
  "type": {
102
102
  "text": "DefaultProps"
103
103
  },
104
- "default": "{ isOpen: false, position: 'top', size: 'default', variant: 'default', type: 'default', isDismissible: false, headingLevel: 'h2', }"
104
+ "default": "{ isOpen: false, position: 'top-centre', size: 'default', variant: 'default', type: 'default', isDismissible: false, headingLevel: 'h2', }"
105
105
  }
106
106
  ],
107
107
  "exports": [
@@ -343,14 +343,6 @@
343
343
  "privacy": "private",
344
344
  "default": "true"
345
345
  },
346
- {
347
- "kind": "field",
348
- "name": "_resolvedPosition",
349
- "type": {
350
- "text": "TooltipProps['position'] | undefined"
351
- },
352
- "privacy": "private"
353
- },
354
346
  {
355
347
  "kind": "field",
356
348
  "name": "_clippedTriggerElement",
@@ -369,24 +361,6 @@
369
361
  "privacy": "private",
370
362
  "default": "[]"
371
363
  },
372
- {
373
- "kind": "field",
374
- "name": "_overlayClippers",
375
- "type": {
376
- "text": "Array<Element>"
377
- },
378
- "privacy": "private",
379
- "default": "[]"
380
- },
381
- {
382
- "kind": "field",
383
- "name": "_collisionSignature",
384
- "type": {
385
- "text": "string | null"
386
- },
387
- "privacy": "private",
388
- "default": "null"
389
- },
390
364
  {
391
365
  "kind": "field",
392
366
  "name": "_overlayModeDirty",
@@ -538,76 +512,6 @@
538
512
  }
539
513
  }
540
514
  },
541
- {
542
- "kind": "method",
543
- "name": "resolveCollision",
544
- "privacy": "private",
545
- "return": {
546
- "type": {
547
- "text": "void"
548
- }
549
- },
550
- "parameters": [
551
- {
552
- "name": "anchorRect",
553
- "type": {
554
- "text": "DOMRect"
555
- }
556
- }
557
- ]
558
- },
559
- {
560
- "kind": "method",
561
- "name": "_setResolvedPosition",
562
- "privacy": "private",
563
- "return": {
564
- "type": {
565
- "text": "void"
566
- }
567
- },
568
- "parameters": [
569
- {
570
- "name": "position",
571
- "type": {
572
- "text": "TooltipProps['position']"
573
- }
574
- }
575
- ]
576
- },
577
- {
578
- "kind": "method",
579
- "name": "_getCollisionBoundary",
580
- "privacy": "private",
581
- "return": {
582
- "type": {
583
- "text": "DOMRect | null"
584
- }
585
- }
586
- },
587
- {
588
- "kind": "method",
589
- "name": "_getCandidatePositions",
590
- "privacy": "private",
591
- "return": {
592
- "type": {
593
- "text": "Array<{ side: TooltipSide; alignment: TooltipAlignment }>"
594
- }
595
- },
596
- "parameters": [
597
- {
598
- "name": "preferredSide",
599
- "type": {
600
- "text": "TooltipSide"
601
- }
602
- },
603
- {
604
- "name": "preferredAlignment",
605
- "type": {
606
- "text": "TooltipAlignment"
607
- }
608
- }
609
- ]
610
- },
611
515
  {
612
516
  "kind": "method",
613
517
  "name": "_refreshTriggerClippers",
package/dist/index.d.ts CHANGED
@@ -38,7 +38,7 @@ export declare const ON_TOOLTIP_OPEN_EVENT = "pie-tooltip-open";
38
38
  export declare class PieTooltip extends PieElement implements TooltipProps {
39
39
  trigger: TooltipProps['trigger'];
40
40
  isOpen: boolean;
41
- position: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
41
+ position: "top-centre" | "top-start" | "top-end" | "bottom-centre" | "bottom-start" | "bottom-end" | "left-centre" | "left-start" | "left-end" | "right-centre" | "right-start" | "right-end";
42
42
  size: "default" | "fit-to-content" | "fill-container";
43
43
  variant: "default" | "inverse";
44
44
  type: "default" | "icon";
@@ -52,11 +52,8 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
52
52
  private _hasActionContent;
53
53
  private _isPositioned;
54
54
  private _isAnchorVisible;
55
- private _resolvedPosition;
56
55
  private _clippedTriggerElement;
57
56
  private _triggerClippers;
58
- private _overlayClippers;
59
- private _collisionSignature;
60
57
  private _overlayModeDirty;
61
58
  private _triggerTrackingController;
62
59
  private _interactionController;
@@ -78,10 +75,6 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
78
75
  private resolveMode;
79
76
  private resolveOverlayMode;
80
77
  private projectOverTrigger;
81
- private resolveCollision;
82
- private _setResolvedPosition;
83
- private _getCollisionBoundary;
84
- private _getCandidatePositions;
85
78
  private _refreshTriggerClippers;
86
79
  private handleCloseButtonClick;
87
80
  private _getTriggerElement;
@@ -96,7 +89,7 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
96
89
  render(): TemplateResult;
97
90
  }
98
91
 
99
- export declare const positions: readonly ["top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "right", "right-start", "right-end"];
92
+ export declare const positions: readonly ["top-centre", "top-start", "top-end", "bottom-centre", "bottom-start", "bottom-end", "left-centre", "left-start", "left-end", "right-centre", "right-start", "right-end"];
100
93
 
101
94
  export declare const sizes: readonly ["default", "fit-to-content", "fill-container"];
102
95
 
@@ -107,7 +100,7 @@ export declare interface TooltipProps {
107
100
  trigger?: string;
108
101
  /** When true, the panel is visible. The component never writes to this property. */
109
102
  isOpen?: boolean;
110
- /** The preferred side and alignment; the panel repositions itself to avoid collisions. */
103
+ /** The side of the trigger the panel sits on, and its alignment along the cross axis. */
111
104
  position?: typeof positions[number];
112
105
  /** How the panel sizes itself. Not applied when `type` is `icon`. */
113
106
  size?: typeof sizes[number];