@fluid-topics/ft-popover 1.2.64 → 1.2.66

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.
@@ -0,0 +1,13 @@
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
3
+ import { FtdsPopoverSectionProperties } from "./ftds-popover-section.properties";
4
+ export declare class FtdsPopoverSection extends FtLitElement implements FtdsPopoverSectionProperties {
5
+ static elementDefinitions: ElementDefinitionsMap;
6
+ static styles: import("lit").CSSResult;
7
+ heading: string;
8
+ private popoverSectionLinkTypography;
9
+ private popoverSectionLinkSlot;
10
+ protected render(): import("lit-html").TemplateResult<1>;
11
+ renderHeading(): import("lit-html").TemplateResult<1> | typeof nothing;
12
+ protected updated(props: PropertyValues): void;
13
+ }
@@ -0,0 +1,62 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing } from "lit";
8
+ import { property, query } from "lit/decorators.js";
9
+ import { FtLitElement, unslotText } from "@fluid-topics/ft-wc-utils";
10
+ import { FtTypography } from "@fluid-topics/ft-typography";
11
+ import { sectionStyles } from "./ftds-popover-section.styles";
12
+ class FtdsPopoverSection extends FtLitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.heading = "";
16
+ }
17
+ render() {
18
+ return html `
19
+ <div class="ftds-popover-section--container">
20
+ <slot name="heading">
21
+ ${this.renderHeading()}
22
+ </slot>
23
+ <div class="ftds-popover-section--content" part="content" id="ftds-popover-section-content">
24
+ <ft-typography variant="body-2-medium">
25
+ <slot></slot>
26
+ </ft-typography>
27
+ </div>
28
+ <ft-typography variant="body-2-medium" part="popover-section-link-typography" class="ftds-popover-section--link">
29
+ <slot name="link"
30
+ part="popover-section-link"
31
+ @slotchange=${() => this.requestUpdate()}
32
+ ></slot>
33
+ </ft-typography>
34
+ </div>
35
+ `;
36
+ }
37
+ renderHeading() {
38
+ return this.heading ? html `
39
+ <div class="ftds-popover-section--heading" part="heading" id="ftds-popover-section-heading">
40
+ <ft-typography element="span" variant="body-2-semibold">${this.heading}</ft-typography>
41
+ </div>
42
+ ` : nothing;
43
+ }
44
+ updated(props) {
45
+ super.updated(props);
46
+ this.popoverSectionLinkTypography.hidden = unslotText(this.popoverSectionLinkSlot).trim().length === 0;
47
+ }
48
+ }
49
+ FtdsPopoverSection.elementDefinitions = {
50
+ "ft-typography": FtTypography,
51
+ };
52
+ FtdsPopoverSection.styles = sectionStyles;
53
+ __decorate([
54
+ property()
55
+ ], FtdsPopoverSection.prototype, "heading", void 0);
56
+ __decorate([
57
+ query("[part=popover-section-link-typography]")
58
+ ], FtdsPopoverSection.prototype, "popoverSectionLinkTypography", void 0);
59
+ __decorate([
60
+ query("[part=popover-section-link]")
61
+ ], FtdsPopoverSection.prototype, "popoverSectionLinkSlot", void 0);
62
+ export { FtdsPopoverSection };
@@ -0,0 +1,3 @@
1
+ export interface FtdsPopoverSectionProperties {
2
+ heading?: string;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const sectionStyles: import("lit").CSSResult;
@@ -0,0 +1,22 @@
1
+ import { css } from "lit";
2
+ import { popover } from "@fluid-topics/design-system-variables";
3
+ //language=css
4
+ export const sectionStyles = css `
5
+ .ftds-popover-section--heading ft-typography {
6
+ flex-grow: 1;
7
+ flex-shrink: 1;
8
+ text-overflow: ellipsis;
9
+ overflow: hidden;
10
+ white-space: nowrap;
11
+ }
12
+
13
+ .ftds-popover-section--content {
14
+ color: ${popover.bodyColor};
15
+ }
16
+
17
+ .ftds-popover-section--container {
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: ${popover.contentSectionVerticalGap};
21
+ }
22
+ `;
@@ -20,18 +20,23 @@ export declare class FtdsPopover extends FtLitElement implements FtdsPopoverProp
20
20
  private openingButton;
21
21
  private closingButton;
22
22
  private popoverWrapper;
23
+ private popoverContentDiv;
24
+ private popoverContentSlot;
23
25
  private slottedLinkContent;
24
26
  private popoverLinkTypography;
25
- protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
26
- renderPopover(): typeof nothing | import("lit-html").TemplateResult<1>;
27
+ private popoverSectionsDiv;
28
+ private popoverSectionsSlot;
29
+ protected render(): import("lit-html").TemplateResult<1> | typeof nothing;
30
+ renderPopover(): import("lit-html").TemplateResult<1> | typeof nothing;
27
31
  renderClosingButton(): import("lit-html").TemplateResult<1>;
28
- renderHeading(): typeof nothing | import("lit-html").TemplateResult<1>;
32
+ renderHeading(): import("lit-html").TemplateResult<1> | typeof nothing;
29
33
  updated(properties: PropertyValues<FtdsPopover>): void;
30
34
  close(): void;
31
35
  open(event: PointerEvent): void;
32
- hasTextLinkContent(): boolean;
36
+ hasEmptySlot(slot: HTMLSlotElement): boolean;
33
37
  private watchFocusIn;
34
38
  private watchEscapeKey;
35
39
  private closeAndFocusOpeningButton;
36
40
  private positionWrapper;
41
+ private hideUnusedSlots;
37
42
  }
@@ -72,7 +72,7 @@ class FtdsPopover extends FtLitElement {
72
72
  </slot>
73
73
  <div class="ftds-popover--content" part="content" id="ftds-popover-content">
74
74
  <ft-typography variant="body-2-medium">
75
- <slot></slot>
75
+ <slot part="popover-content-slot"></slot>
76
76
  </ft-typography>
77
77
  </div>
78
78
  <ft-typography variant="body-2-medium" part="popover-link-typography">
@@ -82,6 +82,9 @@ class FtdsPopover extends FtLitElement {
82
82
  @slotchange=${() => this.requestUpdate()}
83
83
  ></slot>
84
84
  </ft-typography>
85
+ <div part="popover-sections" class="ftds-popover-sections">
86
+ <slot name="sections" part="popover-sections-slot" class="ftds-popover--sections"></slot>
87
+ </div>
85
88
  </div>
86
89
  </div>
87
90
  ` : nothing;
@@ -126,8 +129,8 @@ class FtdsPopover extends FtLitElement {
126
129
  this.opened = true;
127
130
  this.dispatchEvent(new CustomEvent("opened-changed", { detail: { opened: true } }));
128
131
  }
129
- hasTextLinkContent() {
130
- return unslotText(this.slottedLinkContent).trim().length > 0;
132
+ hasEmptySlot(slot) {
133
+ return unslotText(slot).trim().length === 0;
131
134
  }
132
135
  async positionWrapper() {
133
136
  this.popoverWrapper.classList.remove("ftds-popover--wrapper-positioned");
@@ -139,9 +142,14 @@ class FtdsPopover extends FtLitElement {
139
142
  this.popoverWrapper.style.left = `${x}px`;
140
143
  this.popoverWrapper.style.top = `${y}px`;
141
144
  this.popoverWrapper.classList.add("ftds-popover--wrapper-positioned");
142
- this.popoverLinkTypography.hidden = !this.hasTextLinkContent();
145
+ this.hideUnusedSlots();
143
146
  this.popoverOpenTriggeredWithKeyboard ? this.closingButton.focus() : this.closingButton.focusWithoutTooltip();
144
147
  }
148
+ hideUnusedSlots() {
149
+ this.hasEmptySlot(this.slottedLinkContent) ? this.popoverLinkTypography.classList.add("hidden") : this.popoverLinkTypography.classList.remove("hidden");
150
+ this.hasEmptySlot(this.popoverContentSlot) ? this.popoverContentDiv.classList.add("hidden") : this.popoverContentDiv.classList.remove("hidden");
151
+ this.hasEmptySlot(this.popoverSectionsSlot) ? this.popoverSectionsDiv.classList.add("hidden") : this.popoverSectionsDiv.classList.remove("hidden");
152
+ }
145
153
  }
146
154
  FtdsPopover.elementDefinitions = {
147
155
  "ft-typography": FtTypography,
@@ -184,10 +192,22 @@ __decorate([
184
192
  __decorate([
185
193
  query("[part=wrapper]")
186
194
  ], FtdsPopover.prototype, "popoverWrapper", void 0);
195
+ __decorate([
196
+ query("[part=content]")
197
+ ], FtdsPopover.prototype, "popoverContentDiv", void 0);
198
+ __decorate([
199
+ query("[part=popover-content-slot]")
200
+ ], FtdsPopover.prototype, "popoverContentSlot", void 0);
187
201
  __decorate([
188
202
  query("[part=popover-link]")
189
203
  ], FtdsPopover.prototype, "slottedLinkContent", void 0);
190
204
  __decorate([
191
205
  query("[part=popover-link-typography]")
192
206
  ], FtdsPopover.prototype, "popoverLinkTypography", void 0);
207
+ __decorate([
208
+ query("[part=popover-sections]")
209
+ ], FtdsPopover.prototype, "popoverSectionsDiv", void 0);
210
+ __decorate([
211
+ query("[part=popover-sections-slot]")
212
+ ], FtdsPopover.prototype, "popoverSectionsSlot", void 0);
193
213
  export { FtdsPopover };
@@ -80,4 +80,14 @@ export const styles = css `
80
80
  .ftds-popover--wrapper-positioned {
81
81
  visibility: visible;
82
82
  }
83
+
84
+ .ftds-popover-sections {
85
+ display: flex;
86
+ flex-direction: column;
87
+ gap: ${popover.multiSectionVerticalGap};
88
+ }
89
+
90
+ .hidden {
91
+ display: none;
92
+ }
83
93
  `;
package/build/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from "./ftds-popover";
2
2
  export * from "./ftds-popover.styles";
3
3
  export * from "./ftds-popover.properties";
4
+ export * from "./ftds-popover-section";
5
+ export * from "./ftds-popover-section.styles";
6
+ export * from "./ftds-popover-section.properties";
package/build/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import { customElement } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtdsPopover } from "./ftds-popover";
3
+ import { FtdsPopoverSection } from "./ftds-popover-section";
3
4
  export * from "./ftds-popover";
4
5
  export * from "./ftds-popover.styles";
5
6
  export * from "./ftds-popover.properties";
7
+ export * from "./ftds-popover-section";
8
+ export * from "./ftds-popover-section.styles";
9
+ export * from "./ftds-popover-section.properties";
6
10
  customElement("ftds-popover")(FtdsPopover);
11
+ customElement("ftds-popover-section")(FtdsPopoverSection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-popover",
3
- "version": "1.2.64",
3
+ "version": "1.2.66",
4
4
  "description": "A simple popover component",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,13 +19,13 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/design-system-variables": "0.1.92",
23
- "@fluid-topics/ft-button": "1.2.64",
24
- "@fluid-topics/ft-icon": "1.2.64",
25
- "@fluid-topics/ft-link": "1.2.64",
26
- "@fluid-topics/ft-typography": "1.2.64",
27
- "@fluid-topics/ft-wc-utils": "1.2.64",
22
+ "@fluid-topics/design-system-variables": "0.1.98",
23
+ "@fluid-topics/ft-button": "1.2.66",
24
+ "@fluid-topics/ft-icon": "1.2.66",
25
+ "@fluid-topics/ft-link": "1.2.66",
26
+ "@fluid-topics/ft-typography": "1.2.66",
27
+ "@fluid-topics/ft-wc-utils": "1.2.66",
28
28
  "lit": "3.1.0"
29
29
  },
30
- "gitHead": "0d9d231aec58aaf8b8e6d94fbabb0cd6122aaed8"
30
+ "gitHead": "9a20b33e06cb203d5decfef5737a1f245777dddc"
31
31
  }