@cupra/ui-kit 1.0.0-canary.13 → 1.0.0-canary.15

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.
Files changed (45) hide show
  1. package/dist/components/ds-rating/ds-rating.d.ts +14 -0
  2. package/dist/components/ds-rating/ds-rating.js +73 -0
  3. package/dist/components/ds-rating/ds-rating.test.d.ts +8 -0
  4. package/dist/components/ds-rating/ds-rating.types.d.ts +6 -0
  5. package/dist/components/ds-rating/styles/common.styles.d.ts +1 -0
  6. package/dist/components/ds-rating/styles/common.styles.js +14 -0
  7. package/dist/components/ds-theme-provider/ds-theme-provider.js +1 -1
  8. package/dist/components/ds-tooltip/ds-tooltip.d.ts +37 -23
  9. package/dist/components/ds-tooltip/ds-tooltip.js +179 -157
  10. package/dist/components/ds-tooltip/ds-tooltip.test.d.ts +8 -0
  11. package/dist/components/ds-tooltip/ds-tooltip.types.d.ts +5 -10
  12. package/dist/components/ds-tooltip/styles/common.styles.d.ts +0 -2
  13. package/dist/components/ds-tooltip/styles/common.styles.js +69 -102
  14. package/dist/components/index.d.ts +2 -1
  15. package/dist/index.js +4 -3
  16. package/dist/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +430 -0
  17. package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +313 -0
  18. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +132 -0
  19. package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +128 -0
  20. package/dist/utils/StylesRegistry/StylesRegistry.js +1 -1
  21. package/dist/utils/cssWithTokens.js +1 -1
  22. package/dist/utils/htmlWithTokens.js +1 -1
  23. package/dist-react/components/ds-rating/ds-rating.d.ts +14 -0
  24. package/dist-react/components/ds-rating/ds-rating.js +73 -0
  25. package/dist-react/components/ds-rating/ds-rating.test.d.ts +8 -0
  26. package/dist-react/components/ds-rating/ds-rating.types.d.ts +6 -0
  27. package/dist-react/components/ds-rating/styles/common.styles.d.ts +1 -0
  28. package/dist-react/components/ds-rating/styles/common.styles.js +14 -0
  29. package/dist-react/components/ds-theme-provider/ds-theme-provider.js +1 -1
  30. package/dist-react/components/ds-tooltip/ds-tooltip.d.ts +37 -23
  31. package/dist-react/components/ds-tooltip/ds-tooltip.js +179 -157
  32. package/dist-react/components/ds-tooltip/ds-tooltip.test.d.ts +8 -0
  33. package/dist-react/components/ds-tooltip/ds-tooltip.types.d.ts +5 -10
  34. package/dist-react/components/ds-tooltip/styles/common.styles.d.ts +0 -2
  35. package/dist-react/components/ds-tooltip/styles/common.styles.js +69 -102
  36. package/dist-react/components/index.d.ts +2 -1
  37. package/dist-react/index.js +4 -3
  38. package/dist-react/node_modules/.pnpm/@floating-ui_core@1.7.3/node_modules/@floating-ui/core/dist/floating-ui.core.js +430 -0
  39. package/dist-react/node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +313 -0
  40. package/dist-react/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +132 -0
  41. package/dist-react/node_modules/.pnpm/@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +128 -0
  42. package/dist-react/utils/StylesRegistry/StylesRegistry.js +1 -1
  43. package/dist-react/utils/cssWithTokens.js +1 -1
  44. package/dist-react/utils/htmlWithTokens.js +1 -1
  45. package/package.json +2 -1
@@ -0,0 +1,14 @@
1
+ import { UiKitElement } from '../base/UiKitElement.ts';
2
+ import '../ds-icon/ds-icon.ts';
3
+ import type { DsRatingAttrs } from './ds-rating.types';
4
+ export declare class DsRating extends UiKitElement {
5
+ static styles: import("lit").CSSResult[];
6
+ value: DsRatingAttrs['value'];
7
+ disabled: DsRatingAttrs['disabled'];
8
+ hideRatingText: DsRatingAttrs['hide-rating-text'];
9
+ private get displayValue();
10
+ private get classes();
11
+ private getStarIconName;
12
+ protected get starsTemplate(): any[];
13
+ render(): import("lit").TemplateResult<1>;
14
+ }
@@ -0,0 +1,73 @@
1
+ import { UiKitElement as c } from "../base/UiKitElement.js";
2
+ import { customUiKitElement as h } from "../../decorators/customUiKitElement.js";
3
+ import { booleanConverter as u } from "../../utils/booleanConverter.js";
4
+ import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
5
+ import { html as p } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
6
+ import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
7
+ import { property as m } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
8
+ import { classMap as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
9
+ import "../ds-icon/ds-icon.js";
10
+ import { commonStyles as f } from "./styles/common.styles.js";
11
+ var v = Object.defineProperty, g = Object.getOwnPropertyDescriptor, o = (e, t, r, a) => {
12
+ for (var s = a > 1 ? void 0 : a ? g(t, r) : t, l = e.length - 1, n; l >= 0; l--)
13
+ (n = e[l]) && (s = (a ? n(t, r, s) : n(s)) || s);
14
+ return a && s && v(t, r, s), s;
15
+ };
16
+ let i = class extends c {
17
+ constructor() {
18
+ super(...arguments), this.disabled = !1, this.hideRatingText = !1;
19
+ }
20
+ get displayValue() {
21
+ if (this.value === void 0 || this.value === null || this.value < 0) return 0;
22
+ const e = Math.max(0, Math.min(5, this.value)), t = Math.floor(e), r = Number((e - t).toFixed(2));
23
+ return t + Math.round(r / 0.5) * 0.5;
24
+ }
25
+ get classes() {
26
+ return {
27
+ container: !0,
28
+ disabled: this.disabled
29
+ };
30
+ }
31
+ getStarIconName(e, t) {
32
+ return t >= e ? "star-filled" : t >= e - 0.5 ? "half-star-filled" : "star";
33
+ }
34
+ get starsTemplate() {
35
+ const e = this.displayValue, t = [];
36
+ for (let r = 1; r <= 5; r++) {
37
+ const a = this.getStarIconName(r, e);
38
+ a && t.push(
39
+ this.componentFactory.createIcon({
40
+ class: "star-icon",
41
+ "icon-name": a,
42
+ size: 16
43
+ })
44
+ );
45
+ }
46
+ return t;
47
+ }
48
+ render() {
49
+ const e = this.value !== void 0 && this.value >= 0 ? this.value : 0, r = Math.max(0, Math.min(5, e)).toString();
50
+ return p`
51
+ <div class=${d(this.classes)} aria-label=${`Rating: ${r} out of 5`} role="img">
52
+ <div class="stars-wrapper">${this.starsTemplate}</div>
53
+ ${this.hideRatingText ? "" : p`<span class="rating-text">${r}</span>`}
54
+ </div>
55
+ `;
56
+ }
57
+ };
58
+ i.styles = [f];
59
+ o([
60
+ m({ type: Number })
61
+ ], i.prototype, "value", 2);
62
+ o([
63
+ m({ type: Boolean, converter: u, reflect: !0 })
64
+ ], i.prototype, "disabled", 2);
65
+ o([
66
+ m({ type: Boolean, converter: u, attribute: "hide-rating-text" })
67
+ ], i.prototype, "hideRatingText", 2);
68
+ i = o([
69
+ h("ds-rating")
70
+ ], i);
71
+ export {
72
+ i as DsRating
73
+ };
@@ -0,0 +1,8 @@
1
+ import type { DsRating } from './ds-rating';
2
+ import './ds-rating';
3
+ import '../ds-theme-provider/ds-theme-provider.ts';
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'ds-rating': DsRating;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { CommonAttrs } from '../../types/types.ts';
2
+ export type DsRatingAttrs = {
3
+ value?: number;
4
+ disabled?: boolean;
5
+ 'hide-rating-text'?: boolean;
6
+ } & CommonAttrs;
@@ -0,0 +1 @@
1
+ export declare const commonStyles: import("lit").CSSResult;
@@ -0,0 +1,14 @@
1
+ import "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
2
+ import "../../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
3
+ import "../../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
4
+ import { css as r } from "../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";
5
+ const e = r`
6
+ .container,
7
+ .stars-wrapper {
8
+ display: flex;
9
+ align-items: center;
10
+ }
11
+ `;
12
+ export {
13
+ e as commonStyles
14
+ };
@@ -53,7 +53,7 @@ let m = class extends $ {
53
53
  }
54
54
  loadThemeStyles() {
55
55
  return this.loadStyles ? new Promise((t, o) => {
56
- const s = "/1.0.0-canary.13", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
56
+ const s = "/1.0.0-canary.15", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
57
57
  if (document.head.querySelector(`link[href="${r}"]`)) t();
58
58
  else {
59
59
  const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
@@ -1,45 +1,59 @@
1
1
  import { UiKitElement } from '../base/UiKitElement.ts';
2
+ import { type Placement } from '@floating-ui/dom';
2
3
  import { nothing } from 'lit';
3
4
  import type { DsTooltipAttrs } from './ds-tooltip.types';
4
5
  declare const DsTooltip_base: (new (...args: any[]) => import("../../mixins/ViewportMixin").ViewportInterface) & typeof UiKitElement;
5
6
  export declare class DsTooltip extends DsTooltip_base {
6
7
  static styles: import("lit").CSSResult[];
7
8
  mode: DsTooltipAttrs['mode'];
8
- titleText: DsTooltipAttrs['title-text'];
9
- bodyText: DsTooltipAttrs['body-text'];
10
- position: DsTooltipAttrs['position'];
11
- align: DsTooltipAttrs['align'];
12
- cancelButtonText: DsTooltipAttrs['cancel-button-text'];
13
- confirmButtonText: DsTooltipAttrs['confirm-button-text'];
14
9
  show: DsTooltipAttrs['show'];
15
- zIndex: DsTooltipAttrs['z-index'];
16
- bodyWidth: DsTooltipAttrs['body-width'];
17
- protected tooltip: HTMLInputElement;
10
+ disableHoverListener: DsTooltipAttrs['disable-hover-listener'];
11
+ disableFocusListener: DsTooltipAttrs['disable-focus-listener'];
12
+ disablePressListener: DsTooltipAttrs['disable-press-listener'];
13
+ protected tooltopPlacement: Placement;
14
+ protected container: HTMLInputElement;
15
+ protected anchorContainer: HTMLInputElement;
18
16
  protected arrow: HTMLInputElement;
19
- connectedCallback(): void;
17
+ private anchorElements;
18
+ private headerElements;
19
+ private closeButtonElements;
20
+ private contentElements;
21
+ protected usingKeyboard: boolean;
20
22
  disconnectedCallback(): void;
21
- protected willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
23
+ protected updated(changedProperties: Map<string | number | symbol, unknown>): void;
24
+ protected updatePosition(): void;
25
+ protected handleKeyDown: () => void;
26
+ protected handlePointerDown: () => void;
22
27
  protected handleResize: (params?: any) => void | Function;
23
28
  protected get arrowClasses(): {
24
29
  [x: string]: boolean;
25
30
  arrow: boolean;
26
31
  'not-positionable': boolean;
27
32
  };
28
- protected get tooltipClasses(): {
29
- [x: string]: string | boolean;
30
- tooltip: boolean;
31
- complex: string;
33
+ protected get containerClasses(): {
34
+ [x: string]: boolean;
35
+ container: boolean;
36
+ };
37
+ protected get headerClasses(): {
38
+ 'header-container': boolean;
39
+ hidden: boolean;
40
+ };
41
+ protected get contentClasses(): {
42
+ 'content-container': boolean;
43
+ 'ds-scroll': boolean;
44
+ 'ds-scroll--size-s': boolean;
45
+ hidden: boolean;
32
46
  };
33
- protected get buttonsTemplate(): typeof nothing | import("lit").TemplateResult<1>;
47
+ protected handleClose: () => void;
48
+ protected get arrowTemplate(): import("lit").TemplateResult<1>;
34
49
  protected get tooltipTemplate(): typeof nothing | import("lit").TemplateResult<1>;
35
- private getTooltipWidth;
36
50
  protected get styleTokens(): import("lit").HTMLTemplateResult;
51
+ protected handleAnchorPointerDown: (event: PointerEvent) => void;
52
+ protected handleAnchorMouseOver: () => void;
53
+ protected handleAnchorMouseOut: () => void;
54
+ protected handleAnchorFocusIn: () => void;
55
+ protected handleAnchorFocusOut: () => void;
56
+ protected handlePressOutside: (event: MouseEvent) => void;
37
57
  render(): import("lit").TemplateResult<1>;
38
- protected handleClickSlot(): void;
39
- protected handleMouseOver(): void;
40
- protected handleMouseOut(): void;
41
- protected handleClickCancelButton(): void;
42
- protected handleClickConfirmButton(): void;
43
- protected handleClickOutside: (event: MouseEvent | TouchEvent) => void;
44
58
  }
45
59
  export {};
@@ -1,95 +1,143 @@
1
- import { UiKitElement as m } from "../base/UiKitElement.js";
2
- import { customUiKitElement as f } from "../../decorators/customUiKitElement.js";
3
- import { ViewportMixin as y } from "../../mixins/ViewportMixin.js";
4
- import { booleanConverter as b } from "../../utils/booleanConverter.js";
5
- import { debounce as v } from "../../utils/debounce.js";
1
+ import { UiKitElement as w } from "../base/UiKitElement.js";
2
+ import { customUiKitElement as v } from "../../decorators/customUiKitElement.js";
3
+ import { computePosition as y, flip as b, shift as g, offset as P, arrow as E, size as L } from "../../node_modules/.pnpm/@floating-ui_dom@1.7.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";
4
+ import { ViewportMixin as $ } from "../../mixins/ViewportMixin.js";
5
+ import { booleanConverter as c } from "../../utils/booleanConverter.js";
6
+ import { debounce as C } from "../../utils/debounce.js";
6
7
  import { htmlWithTokens as x } from "../../utils/htmlWithTokens.js";
7
8
  import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
8
- import { nothing as a, html as c } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
9
+ import { html as p, nothing as O } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
9
10
  import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
10
- import { property as h } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
11
- import { query as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
12
- import { classMap as u } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
13
- import { commonStyles as g, tooltipStyles as w, arrowStyles as T } from "./styles/common.styles.js";
14
- var C = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, s = (t, n, r, i) => {
15
- for (var o = i > 1 ? void 0 : i ? $(n, r) : n, l = t.length - 1, d; l >= 0; l--)
16
- (d = t[l]) && (o = (i ? d(n, r, o) : d(o)) || o);
17
- return i && o && C(n, r, o), o;
11
+ import { property as l } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
12
+ import { state as A } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
13
+ import { query as m } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
14
+ import { queryAssignedElements as u } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js";
15
+ import { classMap as d } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
16
+ import { commonStyles as D } from "./styles/common.styles.js";
17
+ var F = Object.defineProperty, M = Object.getOwnPropertyDescriptor, r = (e, t, o, i) => {
18
+ for (var n = i > 1 ? void 0 : i ? M(t, o) : t, h = e.length - 1, a; h >= 0; h--)
19
+ (a = e[h]) && (n = (i ? a(t, o, n) : a(n)) || n);
20
+ return i && n && F(t, o, n), n;
18
21
  };
19
- let e = class extends y(m) {
22
+ let s = class extends $(w) {
20
23
  constructor() {
21
- super(...arguments), this.mode = "light", this.titleText = "", this.bodyText = "", this.position = "bottom", this.align = "center", this.show = !1, this.zIndex = 2e3, this.bodyWidth = "unset", this.handleResize = v({ func: () => this.requestUpdate() }), this.handleClickOutside = (t) => {
22
- var r;
23
- const n = t.target;
24
- n !== this && !this.contains(n) && !((r = this.shadowRoot) != null && r.contains(n)) && (this.show = !1);
24
+ super(...arguments), this.mode = "light", this.show = !1, this.disableHoverListener = !1, this.disableFocusListener = !1, this.disablePressListener = !1, this.usingKeyboard = !1, this.handleKeyDown = () => {
25
+ this.usingKeyboard = !0;
26
+ }, this.handlePointerDown = () => {
27
+ this.usingKeyboard = !1;
28
+ }, this.handleResize = C({ func: () => this.requestUpdate() }), this.handleClose = () => {
29
+ this.show = !1;
30
+ }, this.handleAnchorPointerDown = (e) => {
31
+ this.disablePressListener || e.button === 0 && (this.show = !this.show);
32
+ }, this.handleAnchorMouseOver = () => {
33
+ this.disableHoverListener || (this.show = !0);
34
+ }, this.handleAnchorMouseOut = () => {
35
+ this.disableHoverListener || setTimeout(() => {
36
+ var e, t, o, i, n;
37
+ !((t = (e = this.container) == null ? void 0 : e.matches) != null && t.call(e, ":hover")) && !((i = (o = this.arrow) == null ? void 0 : o.matches) != null && i.call(o, ":hover")) && !((n = this == null ? void 0 : this.matches) != null && n.call(this, ":hover")) && (this.show = !1);
38
+ }, 150);
39
+ }, this.handleAnchorFocusIn = () => {
40
+ this.usingKeyboard && (this.disableFocusListener || (this.show = !0));
41
+ }, this.handleAnchorFocusOut = () => {
42
+ this.usingKeyboard && (this.disableFocusListener || (this.show = !1));
43
+ }, this.handlePressOutside = (e) => {
44
+ var o;
45
+ if (this.disablePressListener || e.button !== 0) return;
46
+ const t = e.target;
47
+ t === this || this.contains(t) || (o = this.shadowRoot) != null && o.contains(t) || this.anchorElements[0] === t || this.anchorElements[0].contains(t) || (this.show = !1);
25
48
  };
26
49
  }
27
- connectedCallback() {
28
- super.connectedCallback(), window.addEventListener("resize", this.handleResize);
29
- }
30
50
  disconnectedCallback() {
31
- super.disconnectedCallback(), window.removeEventListener("resize", this.handleResize);
32
- }
33
- willUpdate(t) {
34
- t.has("show") && (this.show ? document.addEventListener("click", this.handleClickOutside) : document.removeEventListener("click", this.handleClickOutside));
51
+ super.disconnectedCallback(), window.removeEventListener("resize", this.handleResize), document.removeEventListener("pointerdown", this.handlePressOutside), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("pointerdown", this.handlePointerDown);
52
+ }
53
+ updated(e) {
54
+ document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("pointerdown", this.handlePointerDown), this.updatePosition(), e.has("show") && (this.show ? (window.addEventListener("resize", this.handleResize), document.addEventListener("pointerdown", this.handlePressOutside)) : (window.removeEventListener("resize", this.handleResize), document.removeEventListener("pointerdown", this.handlePressOutside)));
55
+ }
56
+ updatePosition() {
57
+ requestAnimationFrame(() => {
58
+ var e;
59
+ !this.anchorContainer || !this.container || !this.show || !((e = this.anchorElements) != null && e[0]) || !(this.anchorContainer instanceof Element) || !(this.container instanceof Element) || !(this.arrow instanceof Element) || (y(this.anchorContainer, this.container, {
60
+ placement: "bottom-start",
61
+ middleware: [
62
+ b(),
63
+ g(),
64
+ P(8),
65
+ E({ element: this.arrow }),
66
+ L({
67
+ apply({ availableWidth: t, availableHeight: o, elements: i }) {
68
+ Object.assign(i.floating.style, {
69
+ maxWidth: `${Math.min(240, t - 8)}px`,
70
+ maxHeight: `${Math.max(0, o - 8)}px`
71
+ });
72
+ }
73
+ })
74
+ ]
75
+ }).then((t) => {
76
+ const { x: o, y: i, middlewareData: n, placement: h } = t;
77
+ if (this.tooltopPlacement = h, Object.assign(this.container.style, {
78
+ left: `${o ?? 0}px`,
79
+ top: `${i ?? 0}px`
80
+ }), n.arrow) {
81
+ const { x: a, y: f } = n.arrow;
82
+ Object.assign(this.arrow.style, {
83
+ left: a != null ? `${a}px` : "",
84
+ top: f != null ? `${f}px` : ""
85
+ });
86
+ }
87
+ }), this.requestUpdate());
88
+ });
35
89
  }
36
90
  get arrowClasses() {
37
- var t;
91
+ var e;
38
92
  return {
39
93
  arrow: !0,
40
- [this.position]: !0,
41
- [this.align]: !0,
42
94
  [this.mode]: !0,
43
- "not-positionable": (this == null ? void 0 : this.offsetWidth) > ((t = this.tooltip) == null ? void 0 : t.offsetWidth)
95
+ "not-positionable": (this == null ? void 0 : this.offsetWidth) > ((e = this.container) == null ? void 0 : e.offsetWidth)
44
96
  };
45
97
  }
46
- get tooltipClasses() {
98
+ get containerClasses() {
47
99
  return {
48
- tooltip: !0,
49
- [this.position]: !0,
50
- [this.align]: !0,
51
- [this.mode]: !0,
52
- complex: this.cancelButtonText || this.confirmButtonText
100
+ container: !0,
101
+ [this.tooltopPlacement]: !!this.tooltopPlacement,
102
+ [this.mode]: !0
53
103
  };
54
104
  }
55
- get buttonsTemplate() {
56
- if (!this.cancelButtonText && !this.confirmButtonText) return a;
57
- const t = this.mode === "light" ? "dark" : "light";
58
- return c`
59
- <div class="buttons-container">
60
- ${this.cancelButtonText ? this.componentFactory.createButton({
61
- class: "cancel-button",
62
- "@click": this.handleClickCancelButton,
63
- size: "small",
64
- variant: "secondary",
65
- mode: t,
66
- children: this.cancelButtonText
67
- }) : a}
68
- ${this.confirmButtonText ? this.componentFactory.createButton({
69
- class: "confirm-button",
70
- "@click": this.handleClickConfirmButton,
71
- size: "small",
72
- variant: "primary",
73
- mode: t,
74
- children: this.confirmButtonText
75
- }) : a}
76
- </div>
77
- `;
105
+ get headerClasses() {
106
+ var e, t;
107
+ return {
108
+ "header-container": !0,
109
+ hidden: ((e = this.headerElements) == null ? void 0 : e.length) === 0 && ((t = this.closeButtonElements) == null ? void 0 : t.length) === 0
110
+ };
78
111
  }
79
- get tooltipTemplate() {
80
- return this.show ? c`
81
- <div class=${u(this.arrowClasses)} @mouseout="${this.handleMouseOut}"></div>
82
- <div class=${u(this.tooltipClasses)} @mouseout=${this.handleMouseOut}>
83
- ${this.titleText ? c`<div class="title">${this.titleText}</div>` : a}
84
- ${this.bodyText ? c`<div class="body">${this.bodyText}</div>` : a}
85
- ${this.buttonsTemplate}
86
- </div>
87
- ` : a;
112
+ get contentClasses() {
113
+ var e;
114
+ return {
115
+ "content-container": !0,
116
+ "ds-scroll": !0,
117
+ "ds-scroll--size-s": !0,
118
+ hidden: ((e = this.contentElements) == null ? void 0 : e.length) === 0
119
+ };
88
120
  }
89
- getTooltipWidth() {
90
- const i = this.offsetLeft + this.scrollLeft + this.clientLeft, o = document.body.clientWidth - i - this.clientWidth;
91
- let l;
92
- return this.position === "left" ? l = i - 13 : this.position === "right" ? l = o - 13 : this.align === "center" ? l = (i < o ? i : o) * 2 + this.clientWidth : this.align === "start" ? l = document.body.clientWidth - i : this.align === "end" && (l = i + this.clientWidth), `${l - 16 - 32}px`;
121
+ get arrowTemplate() {
122
+ return p`
123
+ <svg id="arrow" xmlns="http://www.w3.org/2000/svg" width="17" height="9" viewBox="0 0 17 9" fill="none" class=${d(this.arrowClasses)} @mouseout="${this.handleAnchorMouseOut}">
124
+ <path d="M5.77946 4.38048L0.5 9L16 9L11.1427 4.46656C9.88663 3.29419 9.25858 2.708 8.48883 2.69565C7.71909 2.68329 7.07255 3.24902 5.77946 4.38048Z" fill="#26262C" class="ds-tooltip-arrow-background"/>
125
+ <path d="M0.5 8.5L5.89467 4.11683C7.1398 3.10516 7.76236 2.59933 8.49029 2.6109C9.21822 2.62246 9.8244 3.14782 11.0368 4.19853L16 8.5" stroke="#FAFAFA" stroke-opacity="0.3" stroke-linecap="round" class="ds-tooltip-arrow-border"/>
126
+ </svg>`;
127
+ }
128
+ get tooltipTemplate() {
129
+ return this.show && this.anchorElements.length > 0 ? p`
130
+ <div id="tooltip" part="container" class=${d(this.containerClasses)} @mouseout=${this.handleAnchorMouseOut}>
131
+ <header part="header" class=${d(this.headerClasses)}>
132
+ <slot @slotchange=${this.updatePosition} name="header"></slot>
133
+ <slot @slotchange=${this.updatePosition} name="close-button" @click=${this.handleClose}></slot>
134
+ </header>
135
+ <div part="content" class=${d(this.contentClasses)}>
136
+ <slot @slotchange=${this.updatePosition} name="content"></slot>
137
+ </div>
138
+ <slot part="image" @slotchange=${this.updatePosition} name="image"></slot>
139
+ ${this.arrowTemplate}
140
+ </div>` : O;
93
141
  }
94
142
  get styleTokens() {
95
143
  return x`
@@ -101,98 +149,72 @@ let e = class extends y(m) {
101
149
  `;
102
150
  }
103
151
  render() {
104
- return c`
152
+ return p`
105
153
  <style>
106
- .tooltip {
107
- max-width: ${this.getTooltipWidth()};
108
- }
109
- .tooltip,
110
- .arrow {
111
- z-index: ${this.zIndex};
112
- }
113
- .body {
114
- max-width: ${this.bodyWidth};
154
+ .anchor {
155
+ cursor: ${this.disablePressListener ? "default" : "pointer"};
115
156
  }
116
157
  </style>
117
158
  ${this.styleTokens}
118
- <slot
119
- @mouseover="${this.handleMouseOver}"
120
- @mouseout="${this.handleMouseOut}"
121
- @click=${this.handleClickSlot}
122
- ></slot>
123
-
159
+ <div
160
+ id="button"
161
+ class="anchor"
162
+ tabindex="0"
163
+ @mouseover="${this.handleAnchorMouseOver}"
164
+ @mouseout="${this.handleAnchorMouseOut}"
165
+ @pointerdown="${this.handleAnchorPointerDown}"
166
+ @focusin=${this.handleAnchorFocusIn}
167
+ @focusout=${this.handleAnchorFocusOut}
168
+ >
169
+ <slot></slot>
170
+ </div>
124
171
  ${this.tooltipTemplate}
125
172
  `;
126
173
  }
127
- handleClickSlot() {
128
- ["xs", "s", "m"].includes(this.viewport) && (this.show = !this.show);
129
- }
130
- handleMouseOver() {
131
- ["xs", "s", "m"].includes(this.viewport) || (this.show = !0);
132
- }
133
- handleMouseOut() {
134
- ["xs", "s", "m"].includes(this.viewport) || setTimeout(() => {
135
- var t, n, r, i, o;
136
- !((n = (t = this.tooltip) == null ? void 0 : t.matches) != null && n.call(t, ":hover")) && !((i = (r = this.arrow) == null ? void 0 : r.matches) != null && i.call(r, ":hover")) && !((o = this == null ? void 0 : this.matches) != null && o.call(this, ":hover")) && (this.show = !1);
137
- }, 150);
138
- }
139
- handleClickCancelButton() {
140
- this.dispatchEvent(
141
- new CustomEvent("click-cancel-button", {
142
- bubbles: !0,
143
- composed: !0
144
- })
145
- ), this.show = !1;
146
- }
147
- handleClickConfirmButton() {
148
- this.dispatchEvent(
149
- new CustomEvent("click-confirm-button", {
150
- bubbles: !0,
151
- composed: !0
152
- })
153
- );
154
- }
155
174
  };
156
- e.styles = [g, w, T];
157
- s([
158
- h({ type: String, reflect: !0 })
159
- ], e.prototype, "mode", 2);
160
- s([
161
- h({ type: String, attribute: "title-text" })
162
- ], e.prototype, "titleText", 2);
163
- s([
164
- h({ type: String, attribute: "body-text" })
165
- ], e.prototype, "bodyText", 2);
166
- s([
167
- h({ type: String })
168
- ], e.prototype, "position", 2);
169
- s([
170
- h({ type: String })
171
- ], e.prototype, "align", 2);
172
- s([
173
- h({ type: String, attribute: "cancel-button-text" })
174
- ], e.prototype, "cancelButtonText", 2);
175
- s([
176
- h({ type: String, attribute: "confirm-button-text" })
177
- ], e.prototype, "confirmButtonText", 2);
178
- s([
179
- h({ type: Boolean, reflect: !0, converter: b })
180
- ], e.prototype, "show", 2);
181
- s([
182
- h({ type: Number, attribute: "z-index" })
183
- ], e.prototype, "zIndex", 2);
184
- s([
185
- h({ type: String, attribute: "body-width" })
186
- ], e.prototype, "bodyWidth", 2);
187
- s([
188
- p(".tooltip")
189
- ], e.prototype, "tooltip", 2);
190
- s([
191
- p(".arrow")
192
- ], e.prototype, "arrow", 2);
193
- e = s([
194
- f("ds-tooltip")
195
- ], e);
175
+ s.styles = [D];
176
+ r([
177
+ l({ type: String, reflect: !0 })
178
+ ], s.prototype, "mode", 2);
179
+ r([
180
+ l({ type: Boolean, reflect: !0, converter: c })
181
+ ], s.prototype, "show", 2);
182
+ r([
183
+ l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-hover-listener" })
184
+ ], s.prototype, "disableHoverListener", 2);
185
+ r([
186
+ l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-focus-listener" })
187
+ ], s.prototype, "disableFocusListener", 2);
188
+ r([
189
+ l({ type: Boolean, reflect: !0, converter: c, attribute: "disable-press-listener" })
190
+ ], s.prototype, "disablePressListener", 2);
191
+ r([
192
+ A()
193
+ ], s.prototype, "tooltopPlacement", 2);
194
+ r([
195
+ m(".container")
196
+ ], s.prototype, "container", 2);
197
+ r([
198
+ m("#button")
199
+ ], s.prototype, "anchorContainer", 2);
200
+ r([
201
+ m("#arrow")
202
+ ], s.prototype, "arrow", 2);
203
+ r([
204
+ u({ slot: "" })
205
+ ], s.prototype, "anchorElements", 2);
206
+ r([
207
+ u({ slot: "header" })
208
+ ], s.prototype, "headerElements", 2);
209
+ r([
210
+ u({ slot: "close-button" })
211
+ ], s.prototype, "closeButtonElements", 2);
212
+ r([
213
+ u({ slot: "content" })
214
+ ], s.prototype, "contentElements", 2);
215
+ s = r([
216
+ v("ds-tooltip")
217
+ ], s);
196
218
  export {
197
- e as DsTooltip
219
+ s as DsTooltip
198
220
  };
@@ -0,0 +1,8 @@
1
+ import '../ds-theme-provider/ds-theme-provider.ts';
2
+ import './ds-tooltip.ts';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'ds-tooltip': import('./ds-tooltip').DsTooltip;
6
+ 'ds-theme-provider': HTMLElement;
7
+ }
8
+ }
@@ -1,13 +1,8 @@
1
1
  import type { CommonAttrs } from '../../types/types';
2
- export interface DsTooltipAttrs extends CommonAttrs {
2
+ export type DsTooltipAttrs = CommonAttrs & {
3
3
  mode?: 'dark' | 'light';
4
- 'title-text'?: string;
5
- 'body-text'?: string;
6
- position?: 'top' | 'right' | 'bottom' | 'left';
7
- align?: 'start' | 'center' | 'end';
8
4
  show?: boolean;
9
- 'body-width'?: string;
10
- 'cancel-button-text'?: string;
11
- 'confirm-button-text'?: string;
12
- 'z-index'?: number;
13
- }
5
+ 'disable-hover-listener'?: boolean;
6
+ 'disable-focus-listener'?: boolean;
7
+ 'disable-press-listener'?: boolean;
8
+ };
@@ -1,3 +1 @@
1
1
  export declare const commonStyles: import("lit").CSSResult;
2
- export declare const tooltipStyles: import("lit").CSSResult;
3
- export declare const arrowStyles: import("lit").CSSResult;