@fluid-topics/ft-reader-feedback 1.0.50 → 1.0.52

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.
@@ -3,16 +3,23 @@ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
4
  import { FtTopicRatingSummary } from "@fluid-topics/ft-reader-context/build/store/model";
5
5
  import type { FtPublicationRatingSummary, FtUserProfile } from "@fluid-topics/public-api";
6
+ import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
6
7
  import { FtTextArea } from "@fluid-topics/ft-text-area";
7
8
  import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
8
- import { FtLitElementWithI18n, I18nProperty } from "@fluid-topics/ft-i18n";
9
+ import { I18nProperty } from "@fluid-topics/ft-i18n";
10
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
9
11
  export interface FeedbackI18nProperties {
10
12
  feedbackMainTitle: I18nProperty;
11
13
  ratingSectionTitle: I18nProperty;
12
14
  feedbackSectionTitle: I18nProperty;
13
15
  dichotomousRatingSectionTitle: I18nProperty;
14
16
  }
15
- export declare class FtReaderFeedback extends FtLitElementWithI18n implements FtReaderFeedbackProperties {
17
+ export interface FtFeedbackEventDetail {
18
+ message: string;
19
+ from?: string;
20
+ }
21
+ declare const FtReaderFeedback_base: typeof FtReaderComponent & (new (...args: any[]) => import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface);
22
+ export declare class FtReaderFeedback extends FtReaderFeedback_base implements FtReaderFeedbackProperties {
16
23
  static elementDefinitions: ElementDefinitionsMap;
17
24
  static styles: import("lit").CSSResult;
18
25
  editorMode: boolean;
@@ -22,6 +29,7 @@ export declare class FtReaderFeedback extends FtLitElementWithI18n implements Ft
22
29
  ratingSummary?: FtPublicationRatingSummary | FtTopicRatingSummary;
23
30
  user?: FtUserProfile;
24
31
  feedbackInput: FtTextArea;
32
+ from: string;
25
33
  feedbackMessage: string;
26
34
  iconVariant?: FtIconVariants;
27
35
  emptyStarIcon?: string;
@@ -30,6 +38,7 @@ export declare class FtReaderFeedback extends FtLitElementWithI18n implements Ft
30
38
  filledLikeIcon?: string;
31
39
  emptyDislikeIcon?: string;
32
40
  filledDislikeIcon?: string;
41
+ configuration?: FtReaderFeedbackConfiguration;
33
42
  feedbackMailLinkBuilder: (feedbackMessage: string) => string | undefined;
34
43
  constructor();
35
44
  get canAccessFeedback(): boolean | undefined;
@@ -45,8 +54,10 @@ export declare class FtReaderFeedback extends FtLitElementWithI18n implements Ft
45
54
  private renderRating;
46
55
  private rate;
47
56
  private renderFeedbackSection;
57
+ private validFromEmail;
48
58
  private sendFeedback;
49
59
  private placeholderInEditor;
50
60
  private onMailerFeedbackSent;
51
61
  clearFeedbackInput(): void;
52
62
  }
63
+ export {};
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { html, nothing } from "lit";
8
8
  import { property, query, state } from "lit/decorators.js";
9
- import { parseDate, } from "@fluid-topics/ft-wc-utils";
9
+ import { parseDate, redux, } from "@fluid-topics/ft-wc-utils";
10
10
  import { styles } from "./ft-reader-feedback.css";
11
11
  import { FtTypography } from "@fluid-topics/ft-typography";
12
12
  import { FtIcon } from "@fluid-topics/ft-icon";
@@ -16,14 +16,17 @@ import { FtTextArea } from "@fluid-topics/ft-text-area";
16
16
  import { repeat } from "lit/directives/repeat.js";
17
17
  import { FtButton } from "@fluid-topics/ft-button";
18
18
  import { defaultMessages, feedback } from "./utils/IntegratedFeedbackComponentMessages";
19
- import { FtLitElementWithI18n } from "@fluid-topics/ft-i18n";
19
+ import { withI18n } from "@fluid-topics/ft-i18n";
20
20
  import { defaultDesignerMessages, designer } from "./utils/InDesignerFeedbackComponentMessages";
21
- class FtReaderFeedback extends FtLitElementWithI18n {
21
+ import { FtTextField } from "@fluid-topics/ft-text-field";
22
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
23
+ class FtReaderFeedback extends withI18n(FtReaderComponent) {
22
24
  constructor() {
23
25
  super();
24
26
  this.editorMode = false;
25
27
  this.hideTitle = false;
26
28
  this.ratingAllowed = false;
29
+ this.from = "";
27
30
  this.feedbackMessage = "";
28
31
  this.emptyStarIcon = "STAR";
29
32
  this.filledStarIcon = "STAR_PLAIN";
@@ -181,12 +184,13 @@ class FtReaderFeedback extends FtLitElementWithI18n {
181
184
  }
182
185
  }
183
186
  renderFeedbackSection() {
187
+ var _a, _b;
184
188
  if (this.canAccessFeedback) {
185
189
  const mailLink = this.feedbackMailLinkBuilder(this.feedbackMessage);
186
190
  let button = html `
187
191
  <ft-button primary
188
192
  class="ft-reader-feedback--send-feedback"
189
- ?disabled=${!this.feedbackMessage}
193
+ ?disabled=${!this.feedbackMessage || !this.validFromEmail()}
190
194
  @click=${() => mailLink ? this.onMailerFeedbackSent() : this.sendFeedback()}
191
195
  part="send-feedback">
192
196
  ${feedback.messages.okButton()}
@@ -204,6 +208,15 @@ class FtReaderFeedback extends FtLitElementWithI18n {
204
208
  <ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
205
209
  ${this.i18n(this.i18nProperties.feedbackSectionTitle)}
206
210
  </ft-typography>
211
+ ${((_a = this.user) === null || _a === void 0 ? void 0 : _a.userId) == null && ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers) ? html `
212
+ <ft-text-field
213
+ class="ft-reader-feedback--from-input"
214
+ label=${feedback.messages.feedbackfromEmail()}
215
+ @live-change=${(e) => this.from = e.detail.trim()}
216
+ ?error=${this.from && !this.validFromEmail()}
217
+ helper=${this.from && !this.validFromEmail() ? feedback.messages.feedbackfromEmailInvalid() : ""}
218
+ />
219
+ ` : nothing}
207
220
  <ft-text-area outlined
208
221
  class="ft-reader-feedback--feedback-input" part="feedback-input"
209
222
  label="${feedback.messages.feedbackInputLabel()}"
@@ -215,8 +228,20 @@ class FtReaderFeedback extends FtLitElementWithI18n {
215
228
  }
216
229
  return this.placeholderInEditor(designer.messages.missingFeedbackRole());
217
230
  }
231
+ validFromEmail() {
232
+ var _a, _b;
233
+ const expression = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
234
+ return !(((_a = this.user) === null || _a === void 0 ? void 0 : _a.userId) == null && ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers))
235
+ || expression.test(this.from);
236
+ }
218
237
  sendFeedback() {
219
- this.dispatchEvent(new CustomEvent("send-feedback", { detail: this.feedbackInput.value }));
238
+ var _a;
239
+ this.dispatchEvent(new CustomEvent("send-feedback", {
240
+ detail: {
241
+ message: this.feedbackInput.value,
242
+ ...(((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.mailsSentByFluidTopicsForUnauthenticatedUsers) && { from: this.from }),
243
+ }
244
+ }));
220
245
  }
221
246
  placeholderInEditor(message) {
222
247
  return this.editorMode ? html `
@@ -244,6 +269,7 @@ FtReaderFeedback.elementDefinitions = {
244
269
  "ft-switch": FtSwitch,
245
270
  "ft-switch-option": FtSwitchOption,
246
271
  "ft-text-area": FtTextArea,
272
+ "ft-text-field": FtTextField,
247
273
  };
248
274
  FtReaderFeedback.styles = styles;
249
275
  __decorate([
@@ -267,6 +293,9 @@ __decorate([
267
293
  __decorate([
268
294
  query(".ft-reader-feedback--feedback-input")
269
295
  ], FtReaderFeedback.prototype, "feedbackInput", void 0);
296
+ __decorate([
297
+ state()
298
+ ], FtReaderFeedback.prototype, "from", void 0);
270
299
  __decorate([
271
300
  state()
272
301
  ], FtReaderFeedback.prototype, "feedbackMessage", void 0);
@@ -291,6 +320,12 @@ __decorate([
291
320
  __decorate([
292
321
  property()
293
322
  ], FtReaderFeedback.prototype, "filledDislikeIcon", void 0);
323
+ __decorate([
324
+ redux({
325
+ store: "reader",
326
+ selector: (state) => { var _a; return (_a = state.configuration) === null || _a === void 0 ? void 0 : _a.feedback; }
327
+ })
328
+ ], FtReaderFeedback.prototype, "configuration", void 0);
294
329
  __decorate([
295
330
  property()
296
331
  ], FtReaderFeedback.prototype, "feedbackMailLinkBuilder", void 0);