@fluid-topics/ft-reader-feedback 0.3.55

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,14 @@
1
+ import { FtUserProfile } from "@fluid-topics/public-api";
2
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
3
+ export interface FtReaderFeedbackProperties {
4
+ editorMode?: boolean;
5
+ user?: FtUserProfile;
6
+ iconVariant: FtIconVariants;
7
+ emptyStarIcon?: string;
8
+ filledStarIcon?: string;
9
+ emptyLikeIcon?: string;
10
+ filledLikeIcon?: string;
11
+ emptyDislikeIcon?: string;
12
+ filledDislikeIcon?: string;
13
+ }
14
+ //# sourceMappingURL=ft-reader-feedback.properties.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ft-reader-feedback.properties.js.map
@@ -0,0 +1,32 @@
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
5
+ import { FtReaderFeedback } from "./ft-reader-feedback";
6
+ import { FtMap, FtPublicationRatingSummary, FtReaderFeedbackConfiguration, FtUserProfile } from "@fluid-topics/public-api";
7
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
8
+ import { FeedbackMailLinkBuilder } from "./utils/mail";
9
+ export declare class FtReaderMapFeedback extends FtReaderComponent implements FtReaderFeedbackProperties {
10
+ static elementDefinitions: ElementDefinitionsMap;
11
+ map?: FtMap;
12
+ editorMode: boolean;
13
+ configuration?: FtReaderFeedbackConfiguration;
14
+ ratingSummary?: FtPublicationRatingSummary;
15
+ user?: FtUserProfile;
16
+ iconVariant: FtIconVariants;
17
+ emptyStarIcon?: string;
18
+ filledStarIcon?: string;
19
+ emptyLikeIcon?: string;
20
+ filledLikeIcon?: string;
21
+ emptyDislikeIcon?: string;
22
+ filledDislikeIcon?: string;
23
+ readerFeedback: FtReaderFeedback;
24
+ feedbackLinkBuilder: FeedbackMailLinkBuilder;
25
+ protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
26
+ protected updated(props: PropertyValues): void;
27
+ connectedCallback(): void;
28
+ private updateData;
29
+ private rate;
30
+ private sendFeedback;
31
+ }
32
+ //# sourceMappingURL=ft-reader-map-feedback.d.ts.map
@@ -0,0 +1,163 @@
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 { FtNotificationEvent, redux } from "@fluid-topics/ft-wc-utils";
10
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
11
+ import { FtReaderFeedback } from "./ft-reader-feedback";
12
+ import { state } from "lit/decorators";
13
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
14
+ import { mapLabelResolver } from "./utils/labels";
15
+ import { FeedbackMailLinkBuilder } from "./utils/mail";
16
+ export class FtReaderMapFeedback extends FtReaderComponent {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.editorMode = false;
20
+ this.iconVariant = FtIconVariants.fluid_topics;
21
+ this.emptyStarIcon = "STAR";
22
+ this.filledStarIcon = "STAR_PLAIN";
23
+ this.emptyLikeIcon = "THUMBS_UP";
24
+ this.filledLikeIcon = "THUMBS_UP_PLAIN";
25
+ this.emptyDislikeIcon = "THUMBS_DOWN";
26
+ this.filledDislikeIcon = "THUMBS_DOWN_PLAIN";
27
+ this.feedbackLinkBuilder = new FeedbackMailLinkBuilder(mapLabelResolver.resolve("mailDisclaimer"));
28
+ }
29
+ render() {
30
+ if (this.map == null) {
31
+ return nothing;
32
+ }
33
+ return html `
34
+ <ft-reader-feedback
35
+ ratingAllowed
36
+ .editorMode=${true}
37
+ .labelResolver=${mapLabelResolver}
38
+ .ratingSummary=${this.ratingSummary}
39
+ .user=${this.user}
40
+ .iconVariant=${this.iconVariant}
41
+ .emptyStarIcon=${this.emptyStarIcon}
42
+ .filledStarIcon=${this.filledStarIcon}
43
+ .emptyLikeIcon=${this.emptyLikeIcon}
44
+ .filledLikeIcon=${this.filledLikeIcon}
45
+ .emptyDislikeIcon=${this.emptyDislikeIcon}
46
+ .filledDislikeIcon=${this.filledDislikeIcon}
47
+ .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
48
+ @rate=${this.rate}
49
+ @send-feedback=${this.sendFeedback}
50
+ ></ft-reader-feedback>
51
+ `;
52
+ }
53
+ updated(props) {
54
+ var _a, _b, _c;
55
+ super.updated(props);
56
+ if (props.has("map")) {
57
+ this.updateData();
58
+ }
59
+ if (["map", "configuration", "user"].some(p => props.has(p)) && this.map && this.configuration) {
60
+ this.feedbackLinkBuilder.update(mapLabelResolver.resolve("mailSubject", this.map.title), (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getLink()) !== null && _b !== void 0 ? _b : "", this.map.metadata, this.configuration, ((_c = this.user) === null || _c === void 0 ? void 0 : _c.userId) != null);
61
+ }
62
+ }
63
+ connectedCallback() {
64
+ super.connectedCallback();
65
+ this.updateData();
66
+ }
67
+ async updateData() {
68
+ var _a, _b;
69
+ this.user = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getSession().then(s => s.profile));
70
+ if (this.map) {
71
+ this.ratingSummary = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getMapRating());
72
+ }
73
+ }
74
+ async rate(ratingEvent) {
75
+ var _a, _b, _c;
76
+ if (this.ratingSummary) {
77
+ try {
78
+ if (ratingEvent.detail == null) {
79
+ this.ratingSummary = { ...this.ratingSummary, rating: undefined };
80
+ await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.unrateMap());
81
+ }
82
+ else {
83
+ this.ratingSummary = {
84
+ ...this.ratingSummary,
85
+ rating: {
86
+ type: this.ratingSummary.type,
87
+ value: ratingEvent.detail,
88
+ date: new Date()
89
+ }
90
+ };
91
+ await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateMap((_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, ratingEvent.detail));
92
+ }
93
+ }
94
+ catch {
95
+ this.dispatchEvent(new FtNotificationEvent({
96
+ type: "error",
97
+ message: mapLabelResolver.resolve("ratingFailure")
98
+ }));
99
+ }
100
+ }
101
+ this.updateData();
102
+ }
103
+ async sendFeedback(ratingEvent) {
104
+ var _a;
105
+ try {
106
+ await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.sendMapFeedback(ratingEvent.detail));
107
+ this.dispatchEvent(new FtNotificationEvent({
108
+ type: "info",
109
+ message: mapLabelResolver.resolve("feedbackSuccess")
110
+ }));
111
+ this.readerFeedback.clearFeedbackInput();
112
+ }
113
+ catch {
114
+ this.dispatchEvent(new FtNotificationEvent({
115
+ type: "error",
116
+ message: mapLabelResolver.resolve("feedbackFailure")
117
+ }));
118
+ }
119
+ }
120
+ }
121
+ FtReaderMapFeedback.elementDefinitions = {
122
+ "ft-reader-feedback": FtReaderFeedback
123
+ };
124
+ __decorate([
125
+ redux()
126
+ ], FtReaderMapFeedback.prototype, "map", void 0);
127
+ __decorate([
128
+ property({ attribute: false })
129
+ ], FtReaderMapFeedback.prototype, "editorMode", void 0);
130
+ __decorate([
131
+ redux((state) => { var _a; return (_a = state.configuration) === null || _a === void 0 ? void 0 : _a.feedback; })
132
+ ], FtReaderMapFeedback.prototype, "configuration", void 0);
133
+ __decorate([
134
+ state()
135
+ ], FtReaderMapFeedback.prototype, "ratingSummary", void 0);
136
+ __decorate([
137
+ state()
138
+ ], FtReaderMapFeedback.prototype, "user", void 0);
139
+ __decorate([
140
+ property({ type: String })
141
+ ], FtReaderMapFeedback.prototype, "iconVariant", void 0);
142
+ __decorate([
143
+ property({ type: String })
144
+ ], FtReaderMapFeedback.prototype, "emptyStarIcon", void 0);
145
+ __decorate([
146
+ property({ type: String })
147
+ ], FtReaderMapFeedback.prototype, "filledStarIcon", void 0);
148
+ __decorate([
149
+ property({ type: String })
150
+ ], FtReaderMapFeedback.prototype, "emptyLikeIcon", void 0);
151
+ __decorate([
152
+ property({ type: String })
153
+ ], FtReaderMapFeedback.prototype, "filledLikeIcon", void 0);
154
+ __decorate([
155
+ property({ type: String })
156
+ ], FtReaderMapFeedback.prototype, "emptyDislikeIcon", void 0);
157
+ __decorate([
158
+ property({ type: String })
159
+ ], FtReaderMapFeedback.prototype, "filledDislikeIcon", void 0);
160
+ __decorate([
161
+ query("ft-reader-feedback")
162
+ ], FtReaderMapFeedback.prototype, "readerFeedback", void 0);
163
+ //# sourceMappingURL=ft-reader-map-feedback.js.map
@@ -0,0 +1,34 @@
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
+ import { FtReaderFeedback } from "./ft-reader-feedback";
5
+ import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
6
+ import type { FtMap, FtUserProfile } from "@fluid-topics/public-api";
7
+ import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
8
+ import { FtTopicRatingSummary } from "@fluid-topics/ft-reader-context/build/store/model";
9
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
10
+ import { FeedbackMailLinkBuilder } from "./utils/mail";
11
+ export declare class FtReaderTopicFeedback extends FtReaderTopicComponent implements FtReaderFeedbackProperties {
12
+ static elementDefinitions: ElementDefinitionsMap;
13
+ map?: FtMap;
14
+ editorMode: boolean;
15
+ configuration?: FtReaderFeedbackConfiguration;
16
+ ratingSummary?: FtTopicRatingSummary;
17
+ user?: FtUserProfile;
18
+ iconVariant: FtIconVariants;
19
+ emptyStarIcon?: string;
20
+ filledStarIcon?: string;
21
+ emptyLikeIcon?: string;
22
+ filledLikeIcon?: string;
23
+ emptyDislikeIcon?: string;
24
+ filledDislikeIcon?: string;
25
+ readerFeedback: FtReaderFeedback;
26
+ feedbackLinkBuilder: FeedbackMailLinkBuilder;
27
+ protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
28
+ protected updated(props: PropertyValues): void;
29
+ connectedCallback(): void;
30
+ private updateData;
31
+ private rate;
32
+ private sendFeedback;
33
+ }
34
+ //# sourceMappingURL=ft-reader-topic-feedback.d.ts.map
@@ -0,0 +1,165 @@
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, state } from "lit/decorators.js";
9
+ import { FtNotificationEvent, redux } from "@fluid-topics/ft-wc-utils";
10
+ import { FtReaderFeedback } from "./ft-reader-feedback";
11
+ import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
12
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
13
+ import { topicLabelResolver } from "./utils/labels";
14
+ import { FeedbackMailLinkBuilder } from "./utils/mail";
15
+ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.editorMode = false;
19
+ this.iconVariant = FtIconVariants.fluid_topics;
20
+ this.emptyStarIcon = "STAR";
21
+ this.filledStarIcon = "STAR_PLAIN";
22
+ this.emptyLikeIcon = "THUMBS_UP";
23
+ this.filledLikeIcon = "THUMBS_UP_PLAIN";
24
+ this.emptyDislikeIcon = "THUMBS_DOWN";
25
+ this.filledDislikeIcon = "THUMBS_DOWN_PLAIN";
26
+ this.feedbackLinkBuilder = new FeedbackMailLinkBuilder(topicLabelResolver.resolve("mailDisclaimer"));
27
+ }
28
+ render() {
29
+ if (this.map == null || this.tocNode == null) {
30
+ return nothing;
31
+ }
32
+ return html `
33
+ <ft-reader-feedback
34
+ ?ratingAllowed=${this.tocNode.hasRating}
35
+ .editorMode=${this.editorMode}
36
+ .labelResolver=${topicLabelResolver}
37
+ .ratingSummary=${this.ratingSummary}
38
+ .user=${this.user}
39
+ .iconVariant=${this.iconVariant}
40
+ .emptyStarIcon=${this.emptyStarIcon}
41
+ .filledStarIcon=${this.filledStarIcon}
42
+ .emptyLikeIcon=${this.emptyLikeIcon}
43
+ .filledLikeIcon=${this.filledLikeIcon}
44
+ .emptyDislikeIcon=${this.emptyDislikeIcon}
45
+ .filledDislikeIcon=${this.filledDislikeIcon}
46
+ .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
47
+ @rate=${this.rate}
48
+ @send-feedback=${this.sendFeedback}
49
+ ></ft-reader-feedback>
50
+ `;
51
+ }
52
+ updated(props) {
53
+ var _a, _b, _c;
54
+ super.updated(props);
55
+ if (props.has("tocNode") && this.tocNode) {
56
+ this.updateData();
57
+ }
58
+ if (["map", "tocNode", "configuration", "user"].some(p => props.has(p)) && this.map && this.tocNode && this.configuration) {
59
+ this.feedbackLinkBuilder.update(topicLabelResolver.resolve("mailSubject", this.tocNode.title, this.map.title), (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getLink(this.tocNode.tocId)) !== null && _b !== void 0 ? _b : "", this.map.metadata, this.configuration, ((_c = this.user) === null || _c === void 0 ? void 0 : _c.userId) != null);
60
+ }
61
+ }
62
+ connectedCallback() {
63
+ super.connectedCallback();
64
+ this.updateData();
65
+ }
66
+ async updateData() {
67
+ var _a, _b;
68
+ this.user = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getSession().then(s => s.profile));
69
+ if (this.tocNode) {
70
+ this.ratingSummary = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getTopicRating(this.tocNode.tocId));
71
+ }
72
+ }
73
+ async rate(ratingEvent) {
74
+ var _a, _b, _c;
75
+ if (this.ratingSummary && this.tocNode) {
76
+ try {
77
+ if (ratingEvent.detail == null) {
78
+ this.ratingSummary = { ...this.ratingSummary, rating: undefined };
79
+ await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.unrateTopic(this.tocNode.tocId));
80
+ }
81
+ else {
82
+ this.ratingSummary = {
83
+ ...this.ratingSummary,
84
+ rating: {
85
+ tocId: this.tocNode.tocId,
86
+ type: this.ratingSummary.type,
87
+ value: ratingEvent.detail,
88
+ date: new Date()
89
+ }
90
+ };
91
+ await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateTopic(this.tocNode.tocId, (_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, ratingEvent.detail));
92
+ }
93
+ }
94
+ catch {
95
+ this.dispatchEvent(new FtNotificationEvent({
96
+ type: "error",
97
+ message: topicLabelResolver.resolve("ratingFailure")
98
+ }));
99
+ }
100
+ }
101
+ this.updateData();
102
+ }
103
+ async sendFeedback(ratingEvent) {
104
+ var _a;
105
+ try {
106
+ if (this.tocNode) {
107
+ await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.sendTopicFeedback(this.tocNode.tocId, ratingEvent.detail));
108
+ this.dispatchEvent(new FtNotificationEvent({
109
+ type: "info",
110
+ message: topicLabelResolver.resolve("feedbackSuccess")
111
+ }));
112
+ this.readerFeedback.clearFeedbackInput();
113
+ }
114
+ }
115
+ catch {
116
+ this.dispatchEvent(new FtNotificationEvent({
117
+ type: "error",
118
+ message: topicLabelResolver.resolve("feedbackFailure")
119
+ }));
120
+ }
121
+ }
122
+ }
123
+ FtReaderTopicFeedback.elementDefinitions = {
124
+ "ft-reader-feedback": FtReaderFeedback
125
+ };
126
+ __decorate([
127
+ redux()
128
+ ], FtReaderTopicFeedback.prototype, "map", void 0);
129
+ __decorate([
130
+ property({ attribute: false })
131
+ ], FtReaderTopicFeedback.prototype, "editorMode", void 0);
132
+ __decorate([
133
+ redux((state) => { var _a; return (_a = state.configuration) === null || _a === void 0 ? void 0 : _a.feedback; })
134
+ ], FtReaderTopicFeedback.prototype, "configuration", void 0);
135
+ __decorate([
136
+ state()
137
+ ], FtReaderTopicFeedback.prototype, "ratingSummary", void 0);
138
+ __decorate([
139
+ state()
140
+ ], FtReaderTopicFeedback.prototype, "user", void 0);
141
+ __decorate([
142
+ property()
143
+ ], FtReaderTopicFeedback.prototype, "iconVariant", void 0);
144
+ __decorate([
145
+ property()
146
+ ], FtReaderTopicFeedback.prototype, "emptyStarIcon", void 0);
147
+ __decorate([
148
+ property()
149
+ ], FtReaderTopicFeedback.prototype, "filledStarIcon", void 0);
150
+ __decorate([
151
+ property()
152
+ ], FtReaderTopicFeedback.prototype, "emptyLikeIcon", void 0);
153
+ __decorate([
154
+ property()
155
+ ], FtReaderTopicFeedback.prototype, "filledLikeIcon", void 0);
156
+ __decorate([
157
+ property()
158
+ ], FtReaderTopicFeedback.prototype, "emptyDislikeIcon", void 0);
159
+ __decorate([
160
+ property()
161
+ ], FtReaderTopicFeedback.prototype, "filledDislikeIcon", void 0);
162
+ __decorate([
163
+ query("ft-reader-feedback")
164
+ ], FtReaderTopicFeedback.prototype, "readerFeedback", void 0);
165
+ //# sourceMappingURL=ft-reader-topic-feedback.js.map
@@ -0,0 +1,5 @@
1
+ export * from "./ft-reader-feedback.css";
2
+ export * from "./ft-reader-feedback.properties";
3
+ export * from "./ft-reader-map-feedback";
4
+ export * from "./ft-reader-topic-feedback";
5
+ //# sourceMappingURL=index.d.ts.map
package/build/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { customElement } from "@fluid-topics/ft-wc-utils";
2
+ import { FtReaderMapFeedback } from "./ft-reader-map-feedback";
3
+ import { FtReaderTopicFeedback } from "./ft-reader-topic-feedback";
4
+ export * from "./ft-reader-feedback.css";
5
+ export * from "./ft-reader-feedback.properties";
6
+ export * from "./ft-reader-map-feedback";
7
+ export * from "./ft-reader-topic-feedback";
8
+ customElement("ft-reader-map-feedback")(FtReaderMapFeedback);
9
+ customElement("ft-reader-topic-feedback")(FtReaderTopicFeedback);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,29 @@
1
+ import { ParametrizedLabelResolver, ParametrizedLabels } from "@fluid-topics/ft-wc-utils";
2
+ export interface FtReaderFeedbackLabels extends ParametrizedLabels {
3
+ feedbackMainTitle?: string;
4
+ ratingSectionTitle?: string;
5
+ feedbackSectionTitle?: string;
6
+ starsRating?: string;
7
+ "starsRating[\\=1]"?: string;
8
+ like?: string;
9
+ dislike?: string;
10
+ dichotomousRatingSectionTitle?: string;
11
+ dichotomousYes?: string;
12
+ dichotomousNo?: string;
13
+ notRated?: string;
14
+ ratedNow?: string;
15
+ ratedToday?: string;
16
+ ratedOn?: string;
17
+ feedbackInputLabel?: string;
18
+ okButton?: string;
19
+ cancelButton?: string;
20
+ mailSubject?: string;
21
+ mailDisclaimer?: string;
22
+ feedbackSuccess?: string;
23
+ feedbackFailure?: string;
24
+ ratingSuccess?: string;
25
+ ratingFailure?: string;
26
+ }
27
+ export declare const topicLabelResolver: ParametrizedLabelResolver<FtReaderFeedbackLabels>;
28
+ export declare const mapLabelResolver: ParametrizedLabelResolver<FtReaderFeedbackLabels>;
29
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { ParametrizedLabelResolver } from "@fluid-topics/ft-wc-utils";
2
+ const DEFAULT_LABELS = {
3
+ starsRating: "{0} stars",
4
+ "starsRating[\\=1]": "1 star",
5
+ like: "Like",
6
+ dislike: "Dislike",
7
+ dichotomousYes: "Yes",
8
+ dichotomousNo: "No",
9
+ notRated: "Not rated",
10
+ ratedNow: "Rated now",
11
+ ratedToday: "Rated today",
12
+ ratedOn: "Rated on {0, date}",
13
+ feedbackInputLabel: "How can we improve it?",
14
+ okButton: "Send feedback",
15
+ cancelButton: "Cancel",
16
+ feedbackSuccess: "Feedback successfully sent. Thank you!",
17
+ feedbackFailure: "Failed to send feedback. Please try again later.",
18
+ ratingSuccess: "Rating successfully sent. Thank you!",
19
+ ratingFailure: "Failed to send rating. Please try again later.",
20
+ };
21
+ const DEFAULT_MAP_LABELS = {
22
+ ...DEFAULT_LABELS,
23
+ feedbackMainTitle: "Send feedback",
24
+ ratingSectionTitle: "Rate this document",
25
+ dichotomousRatingSectionTitle: "Did it solve your problem?",
26
+ feedbackSectionTitle: "Write your review",
27
+ mailSubject: "Feedback about “{0}”",
28
+ };
29
+ const DEFAULT_TOPIC_LABELS = {
30
+ ...DEFAULT_LABELS,
31
+ feedbackMainTitle: "Send feedback",
32
+ ratingSectionTitle: "Rate this content",
33
+ dichotomousRatingSectionTitle: "Did this content solve your problem?",
34
+ feedbackSectionTitle: "Write your review",
35
+ mailSubject: "Feedback about “{0}” in “{1}”",
36
+ };
37
+ export const topicLabelResolver = new ParametrizedLabelResolver(DEFAULT_TOPIC_LABELS, {});
38
+ export const mapLabelResolver = new ParametrizedLabelResolver(DEFAULT_MAP_LABELS, {});
39
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1,14 @@
1
+ import { FtMetadata, FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
2
+ export declare class FeedbackMailLinkBuilder {
3
+ private disclaimer;
4
+ private subject;
5
+ private url;
6
+ private allMetadata;
7
+ private subjectMetadata;
8
+ private configuration?;
9
+ private isAuthenticated;
10
+ constructor(disclaimer: string);
11
+ update(subject: string, url: string, metadata: Array<FtMetadata>, configuration: FtReaderFeedbackConfiguration, isAuthenticated: boolean): void;
12
+ build(feedbackMessage: string): string | undefined;
13
+ }
14
+ //# sourceMappingURL=mail.d.ts.map
@@ -0,0 +1,42 @@
1
+ export class FeedbackMailLinkBuilder {
2
+ constructor(disclaimer) {
3
+ this.disclaimer = disclaimer;
4
+ this.subject = "";
5
+ this.url = "";
6
+ this.allMetadata = "";
7
+ this.subjectMetadata = "";
8
+ this.isAuthenticated = false;
9
+ }
10
+ update(subject, url, metadata, configuration, isAuthenticated) {
11
+ this.subject = subject;
12
+ this.url = url;
13
+ this.configuration = configuration;
14
+ this.isAuthenticated = isAuthenticated;
15
+ this.subjectMetadata = configuration.subjectMetadataIds
16
+ .map(key => metadata.find(m => m.key === key))
17
+ .filter(m => m != null)
18
+ .map(m => "[" + m.values.join(", ") + "]")
19
+ .join("");
20
+ this.allMetadata = metadata.filter(m => !m.key.startsWith("ft:"))
21
+ .map(m => "[" + m.values.join(", ") + "]")
22
+ .join(" ");
23
+ }
24
+ build(feedbackMessage) {
25
+ var _a, _b;
26
+ if (feedbackMessage.length === 0 || this.isAuthenticated && (this.configuration == null || ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.mailsSentByFluidTopics))) {
27
+ return undefined;
28
+ }
29
+ const subject = encodeURIComponent(this.subject + " " + this.subjectMetadata);
30
+ const body = encodeURIComponent(`
31
+ ${this.allMetadata}
32
+ ${this.url}
33
+ _________________________________________________________________
34
+
35
+ ${feedbackMessage}
36
+
37
+ _________________________________________________________________
38
+ ${this.disclaimer}`);
39
+ return `mailto:${(_b = this.configuration) === null || _b === void 0 ? void 0 : _b.recipients.join(",")}?subject=${subject}&body=${body}`;
40
+ }
41
+ }
42
+ //# sourceMappingURL=mail.js.map
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@fluid-topics/ft-reader-feedback",
3
+ "version": "0.3.55",
4
+ "description": "Feedback forms for a map and its topics in an integrated reader",
5
+ "keywords": [
6
+ "Lit"
7
+ ],
8
+ "author": "Fluid Topics <devtopics@antidot.net>",
9
+ "license": "ISC",
10
+ "main": "build/index.js",
11
+ "web": "build/ft-reader-feedback.min.js",
12
+ "typings": "build/index",
13
+ "files": [
14
+ "build/**/*.js",
15
+ "build/**/*.ts"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
+ },
21
+ "dependencies": {
22
+ "@fluid-topics/ft-wc-utils": "0.3.55",
23
+ "lit": "2.2.8"
24
+ },
25
+ "gitHead": "4106f01e238edeb1c85fba22d6d50a18757e0b3e"
26
+ }