@engagently/types 3.1.3 → 4.0.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.
@@ -1,9 +1,13 @@
1
1
  import type { defaultResources } from '../../i18n/i18n';
2
2
  import type { AvailableThemes, ColorSchemesConfig } from '../../ui/themes/_types';
3
- import type { PaletteConfig, ThemeSettings } from '../../ui/themes/config';
3
+ import type { ThemeSettings } from '../../ui/themes/config';
4
4
  import type { CombinedError, Operation } from '@urql/preact';
5
5
  import type { EgyEntities, MessageEvents } from './WidgetDefinitions';
6
- import type { DsmFeatureName, PlmFeatureName } from '../lib/api/enums';
6
+ import type { DsmFeatureName } from '../lib/api/enums';
7
+ export declare enum ExperienceCallBackNames {
8
+ POLL_BAR = "POLL_BAR",
9
+ POLL_SLIDER = "POLL_SLIDER"
10
+ }
7
11
  export type CallbackFn = (data: {
8
12
  from: EgyEntities;
9
13
  type?: string;
@@ -21,14 +25,13 @@ export interface EngageConfig {
21
25
  communityId: string;
22
26
  token?: string | null;
23
27
  strategy?: string;
24
- palette?: PaletteConfig;
25
28
  theme?: `${AvailableThemes}`;
26
29
  themeSettings?: Partial<ThemeSettings>;
27
30
  defaultLanguage?: string;
28
31
  translations?: Translations;
29
32
  dev?: boolean;
30
33
  colorScheme?: `${ColorSchemesConfig}`;
31
- cta?: Partial<Record<DsmFeatureName | PlmFeatureName, CallbackFn>>;
34
+ cta?: Partial<Record<DsmFeatureName | ExperienceCallBackNames, CallbackFn>>;
32
35
  error?: ErrorCallbackFn;
33
36
  events?: Partial<Record<EventHooks, CallbackFn>>;
34
37
  }
@@ -1,4 +1,7 @@
1
1
  import type { VNode } from 'preact';
2
+ import type { ExperienceParticipationFragment } from '../../widgets/src/poll/data/ExperienceFragments.generated';
3
+ import type { PollBarData } from '../../ui/core/PollBar/PollBar';
4
+ import type { ChartData } from '../../ui/core/Charts/Chart';
2
5
  /**
3
6
  * Type Definitions for all available entities
4
7
  *
@@ -11,9 +14,14 @@ import type { VNode } from 'preact';
11
14
  export declare enum EgyEntities {
12
15
  EGY_TS = "engagently.ts",
13
16
  EGY_DISCUSSION = "egy-discussion",
14
- EGY_POLL = "egy-poll"
17
+ EGY_POLL = "egy-poll",
18
+ EGY_POLL_BAR = "egy-poll-bar",
19
+ EGY_POLL_SLIDER = "egy-poll-slider"
15
20
  }
16
21
  export type EgyEntitiesValues = `${EgyEntities}`;
22
+ export declare enum SharedSlots {
23
+ CTA_HEADER = "ctaHeader"
24
+ }
17
25
  /**
18
26
  * MAKE SURE TO UPDATE THE TYPES IN THE FOLLOWING PLACES WHEN CHANGING ATTRS:
19
27
  * - DiscussionAttributesHTMLElement
@@ -46,10 +54,20 @@ export type DiscussionAttributesComponent = {
46
54
  isLive?: boolean;
47
55
  imageUrl?: string;
48
56
  };
49
- export declare enum DiscussionSlots {
57
+ export declare enum DiscussionMessagesSlots {
58
+ DISCUSSION_CLOSED = "messages_discussionClosed",
59
+ DISCUSSION_GLOBAL_CLOSED = "messages_discussionGlobalClosed",
60
+ DISCUSSION_LIVE_CLOSED = "messages_discussionLiveClosed",
61
+ DISCUSSION_PREAMBLE = "messages_discussionPreamble",
62
+ LOG_IN_TO_COMMENT = "messages_logInToComment",
63
+ USER_SANCTION_BLOCK = "messages_userSanctionBlock",
64
+ USER_SANCTION_BLOCK_UNTIL = "messages_userSanctionBlockUntil",
65
+ USER_SANCTION_WARN = "messages_userSanctionWarn",
66
+ USERNAME_CHANGE = "messages_usernameChange"
67
+ }
68
+ export declare enum DiscussionIconSlots {
50
69
  BOOKMARK_ICON = "bookmarkIcon",
51
70
  BOOKMARK_ICON_ACTIVE = "bookmarkIconActive",
52
- CUSTOM_CALL_TO_ACTION = "customCallToAction",
53
71
  DELETE_ICON = "deleteIcon",
54
72
  EDIT_ICON = "editIcon",
55
73
  LIVE_MODE_ICON = "liveModeIcon",
@@ -65,11 +83,17 @@ export declare enum DiscussionSlots {
65
83
  REPORT_ICON_ACTIVE = "reportIconActive",
66
84
  SETTINGS_ICON = "settingsIcon",
67
85
  SHARE_ICON = "shareIcon",
68
- USER_ICON = "userIcon"
86
+ USER_ICON = "userIcon",
87
+ REPLIES_TOGGLE_ICON_open = "repliesToggleIcon_open",
88
+ REPLIES_TOGGLE_ICON_closed = "repliesToggleIcon_closed"
69
89
  }
90
+ export declare enum DiscussionSlots {
91
+ CUSTOM_CALL_TO_ACTION = "customCallToAction"
92
+ }
93
+ export type DiscussionSlotValues = `${SharedSlots}` | `${DiscussionSlots}` | `${DiscussionIconSlots}` | `${DiscussionMessagesSlots}`;
70
94
  export interface DiscussionWidget {
71
95
  name: EgyEntities.EGY_DISCUSSION;
72
- slots: Array<`${DiscussionSlots}`>;
96
+ slots: Array<DiscussionSlotValues>;
73
97
  attributes: Array<`${DiscussionAttributes}`>;
74
98
  }
75
99
  export declare enum DiscussionCommentaryActions {
@@ -107,13 +131,144 @@ export type PollAttributesComponent = {
107
131
  pollId: string;
108
132
  type?: string;
109
133
  };
110
- export declare enum PollSlots {
111
- ICON = "icon"
134
+ export declare enum PollEvents {
135
+ INIT = "egy-poll:init",
136
+ VOTE = "egy-poll:vote"
137
+ }
138
+ export interface PollWidgetEvents {
139
+ [PollEvents.INIT]: CustomEvent<{
140
+ entity: EgyEntities;
141
+ }>;
142
+ [PollEvents.VOTE]: CustomEvent<{
143
+ optionId?: string;
144
+ value?: number;
145
+ entity: EgyEntities;
146
+ }>;
112
147
  }
148
+ export type PollSlotValues = `${SharedSlots}`;
113
149
  export interface PollWidget {
114
150
  name: EgyEntities.EGY_POLL;
115
151
  attributes: Array<`${PollAttributes}`>;
116
- slots: Array<`${PollSlots}`>;
152
+ slots: Array<PollSlotValues>;
153
+ }
154
+ /**
155
+ * MAKE SURE TO UPDATE THE TYPES IN THE FOLLOWING PLACES WHEN CHANGING ATTRS:
156
+ * - PollBarAttributesHTMLElement
157
+ * - PollBarAttributesComponent
158
+ *
159
+ * also make sure to update the assignment in the PollBarPortal component, and
160
+ * extend the PollBar Widget!
161
+ */
162
+ export declare enum PollBarAttributes {
163
+ POLL_DATA = "poll-data",
164
+ CURRENT_USER_PARTICIPATION = "current-user-participation",
165
+ SHOW_SKELETON = "show-skeleton",
166
+ IS_LOADING = "is-loading",
167
+ IS_DISABLED = "is-disabled",
168
+ VOTE_ACTION_ENABLED = "vote-action-enabled",
169
+ VOTE_DISPLAY = "vote-display",
170
+ VOTE_CTA_ENABLED = "vote-cta-enabled",
171
+ VOTE_CTA_MESSAGE = "vote-cta-message",
172
+ RESULT_ACTION_ENABLED = "result-action-enabled",
173
+ RESULT_DISPLAY = "result-display",
174
+ RESULT_CTA_ENABLED = "result-cta-enabled",
175
+ RESULT_CTA_MESSAGE = "result-cta-message",
176
+ DISPLAY_STATS = "display-stats"
177
+ }
178
+ export interface PollBarAttributesHTMLElement {
179
+ ['poll-data']?: PollBarData | null;
180
+ ['current-user-participation']?: ExperienceParticipationFragment | null;
181
+ ['show-skeleton']?: boolean | string;
182
+ ['is-loading']?: boolean | string;
183
+ ['is-disabled']?: boolean | string;
184
+ ['vote-action-enabled']?: boolean | string;
185
+ ['vote-display']?: boolean | string;
186
+ ['vote-cta-enabled']?: boolean | string;
187
+ ['vote-cta-message']?: string | null;
188
+ ['result-action-enabled']?: boolean | string;
189
+ ['result-display']?: boolean | string;
190
+ ['result-cta-enabled']?: boolean | string;
191
+ ['result-cta-message']?: string | null;
192
+ ['display-stats']?: boolean | string;
193
+ }
194
+ export interface PollBarAttributesComponent {
195
+ pollData?: PollBarData | null;
196
+ currentUserParticipation?: ExperienceParticipationFragment | null;
197
+ showSkeleton?: boolean;
198
+ isLoading?: boolean;
199
+ isDisabled?: boolean;
200
+ voteActionEnabled?: boolean;
201
+ voteDisplay?: boolean;
202
+ voteCtaEnabled?: boolean;
203
+ voteCtaMessage?: string | null;
204
+ resultActionEnabled?: boolean;
205
+ resultDisplay?: boolean;
206
+ resultCtaEnabled?: boolean;
207
+ resultCtaMessage?: string | null;
208
+ displayStats?: boolean;
209
+ }
210
+ export interface PollBarWidget {
211
+ name: EgyEntities.EGY_POLL_BAR;
212
+ slots: Array<PollSlotValues>;
213
+ attributes: Array<`${PollBarAttributes}`>;
214
+ }
215
+ /**
216
+ * MAKE SURE TO UPDATE THE TYPES IN THE FOLLOWING PLACES WHEN CHANGING ATTRS:
217
+ * - PollSliderAttributesHTMLElement
218
+ * - PollSliderAttributesComponent
219
+ *
220
+ * also make sure to update the assignment in the PollSliderPortal component,
221
+ * and extend the PollSlider Widget!
222
+ */
223
+ export declare enum PollSliderAttributes {
224
+ POLL_DATA = "poll-data",
225
+ CURRENT_USER_PARTICIPATION = "current-user-participation",
226
+ IS_LOADING = "is-loading",
227
+ IS_DISABLED = "is-disabled",
228
+ VOTE_ACTION_ENABLED = "vote-action-enabled",
229
+ VOTE_DISPLAY = "vote-display",
230
+ VOTE_CTA_ENABLED = "vote-cta-enabled",
231
+ VOTE_CTA_MESSAGE = "vote-cta-message",
232
+ RESULT_ACTION_ENABLED = "result-action-enabled",
233
+ USER_NAME = "user-name",
234
+ USER_THUMBNAIL_URL = "user-thumbnail-url",
235
+ REFRESH_KEY = "refresh-key",
236
+ DISPLAY_STATS = "display-stats"
237
+ }
238
+ export interface PollSliderAttributesHTMLElement {
239
+ ['poll-data']?: ChartData | null;
240
+ ['current-user-participation']?: ExperienceParticipationFragment | null;
241
+ ['is-loading']?: boolean | string;
242
+ ['is-disabled']?: boolean | string;
243
+ ['vote-action-enabled']?: boolean | string;
244
+ ['vote-display']?: boolean | string;
245
+ ['vote-cta-enabled']?: boolean | string;
246
+ ['vote-cta-message']?: string | null;
247
+ ['result-action-enabled']?: boolean | string;
248
+ ['user-name']?: string | null;
249
+ ['user-thumbnail-url']?: string | null;
250
+ ['refresh-key']?: string;
251
+ ['display-stats']?: boolean | string;
252
+ }
253
+ export interface PollSliderAttributesComponent {
254
+ pollData?: ChartData | null;
255
+ currentUserParticipation?: ExperienceParticipationFragment | null;
256
+ isLoading?: boolean;
257
+ isDisabled?: boolean;
258
+ voteActionEnabled?: boolean;
259
+ voteDisplay?: boolean;
260
+ voteCtaEnabled?: boolean;
261
+ voteCtaMessage?: string | null;
262
+ resultActionEnabled?: boolean;
263
+ userName?: string | null;
264
+ userThumbnailUrl?: string | null;
265
+ refreshKey?: string;
266
+ displayStats?: boolean;
267
+ }
268
+ export interface PollSliderWidget {
269
+ name: EgyEntities.EGY_POLL_SLIDER;
270
+ slots: Array<PollSlotValues>;
271
+ attributes: Array<`${PollSliderAttributes}`>;
117
272
  }
118
273
  /**
119
274
  * Events that can be used by the pub/sub implementation for window.postMessage
@@ -42,9 +42,25 @@ export declare enum DsmViewName {
42
42
  Share = "SHARE",
43
43
  Thread = "THREAD"
44
44
  }
45
- export declare enum PlmFeatureName {
46
- SimpleResult = "SIMPLE_RESULT",
47
- SimpleVote = "SIMPLE_VOTE"
45
+ export declare enum ExmExperienceParticipation {
46
+ Anonymous = "ANONYMOUS",
47
+ Any = "ANY",
48
+ Authenticated = "AUTHENTICATED",
49
+ Paid = "PAID"
50
+ }
51
+ export declare enum ExmExperienceTypeName {
52
+ Poll = "POLL",
53
+ Quiz = "QUIZ",
54
+ Survey = "SURVEY"
55
+ }
56
+ export declare enum ExmQuestionChoiceType {
57
+ Bucket = "BUCKET",
58
+ Choice = "CHOICE",
59
+ Input = "INPUT"
60
+ }
61
+ export declare enum ExmQuestionType {
62
+ Bar = "BAR",
63
+ Slider = "SLIDER"
48
64
  }
49
65
  export declare enum PageStatus {
50
66
  Empty = "EMPTY",
@@ -124,10 +124,6 @@ export declare const defaultResources: {
124
124
  labels: {
125
125
  "sort-comments": string;
126
126
  };
127
- "live-controls": {
128
- pause: string;
129
- resume: string;
130
- };
131
127
  "new-commentary": string;
132
128
  "new-commentary_other": string;
133
129
  "no-more-comments": string;
@@ -225,12 +221,6 @@ export declare const defaultResources: {
225
221
  SHARE: {
226
222
  "call-to-action": string;
227
223
  };
228
- SIMPLE_RESULT: {
229
- "call-to-action": string;
230
- };
231
- SIMPLE_VOTE: {
232
- "call-to-action": string;
233
- };
234
224
  };
235
225
  interpolation: {
236
226
  comment: string;
@@ -257,15 +247,17 @@ export declare const defaultResources: {
257
247
  messages: {
258
248
  "discussion-closed": string;
259
249
  "discussion-global-closed": string;
250
+ "discussion-live-closed": string;
260
251
  "discussion-preamble": string;
261
252
  "log-in-to-comment": string;
262
- "user-sanction-block": string;
263
253
  "user-sanction-block-until": string;
254
+ "user-sanction-block": string;
264
255
  "user-sanction-warn": string;
265
256
  "username-change": string;
266
257
  };
267
258
  poll: {
268
259
  "thank-you-for-vote": string;
260
+ "call-to-action": string;
269
261
  };
270
262
  };
271
263
  en: {
@@ -391,10 +383,6 @@ export declare const defaultResources: {
391
383
  labels: {
392
384
  "sort-comments": string;
393
385
  };
394
- "live-controls": {
395
- pause: string;
396
- resume: string;
397
- };
398
386
  "new-commentary": string;
399
387
  "new-commentary_other": string;
400
388
  "no-more-comments": string;
@@ -491,12 +479,6 @@ export declare const defaultResources: {
491
479
  SHARE: {
492
480
  "call-to-action": string;
493
481
  };
494
- SIMPLE_RESULT: {
495
- "call-to-action": string;
496
- };
497
- SIMPLE_VOTE: {
498
- "call-to-action": string;
499
- };
500
482
  };
501
483
  interpolation: {
502
484
  comment: string;
@@ -523,15 +505,17 @@ export declare const defaultResources: {
523
505
  messages: {
524
506
  "discussion-closed": string;
525
507
  "discussion-global-closed": string;
508
+ "discussion-live-closed": string;
526
509
  "discussion-preamble": string;
527
510
  "log-in-to-comment": string;
528
- "user-sanction-block": string;
529
511
  "user-sanction-block-until": string;
512
+ "user-sanction-block": string;
530
513
  "user-sanction-warn": string;
531
514
  "username-change": string;
532
515
  };
533
516
  poll: {
534
517
  "thank-you-for-vote": string;
518
+ "call-to-action": string;
535
519
  };
536
520
  };
537
521
  };
@@ -4,6 +4,8 @@ import type { Exchange } from '@urql/preact';
4
4
  type SignInOptions = Partial<{
5
5
  token: string | null;
6
6
  }>;
7
+ export declare const reinit: (partialConfig?: Partial<EngageConfig>) => Promise<void>;
8
+ export declare const signOut: ({ anonymousSession }?: SignOutOptions) => Promise<void>;
7
9
  export type Engagently = {
8
10
  config?: EngageConfig;
9
11
  communityConfig?: DeepPartial<CommunityConfig>;
@@ -2,10 +2,14 @@ import type { HTMLAttributes } from 'vue';
2
2
 
3
3
  import type { Engagently } from '../main/lib/engagently';
4
4
  import type {
5
+ PollEvents,
6
+ PollWidgetEvents,
5
7
  DiscussionAttributesHTMLElement,
6
8
  PollAttributesHTMLElement,
7
9
  DiscussionAttributesComponent,
8
10
  PollAttributesComponent,
11
+ PollBarAttributesHTMLElement,
12
+ PollSliderAttributesHTMLElement,
9
13
  } from '../common/_types/WidgetDefinitions';
10
14
 
11
15
  ////// exposed types package exports
@@ -13,6 +17,16 @@ import type {
13
17
  declare const webkit: Webkit;
14
18
  export { EngageConfig } from '../common/_types/ConfigDefinition';
15
19
 
20
+ export { PollEvents, PollWidgetEvents };
21
+ export {
22
+ DiscussionAttributesHTMLElement,
23
+ PollAttributesHTMLElement,
24
+ DiscussionAttributesComponent,
25
+ PollAttributesComponent,
26
+ PollBarAttributesHTMLElement,
27
+ PollSliderAttributesHTMLElement,
28
+ };
29
+
16
30
  //////
17
31
  declare module 'vue' {
18
32
  export interface GlobalComponents {
@@ -38,9 +52,21 @@ declare global {
38
52
  React.HTMLAttributes<HTMLElement> & PollAttributesHTMLElement,
39
53
  HTMLElement
40
54
  >;
55
+ 'egy-poll-bar': React.DetailedHTMLProps<
56
+ React.HTMLAttributes<HTMLElement> & PollBarAttributesHTMLElement,
57
+ HTMLElement
58
+ >;
59
+ 'egy-poll-slider': React.DetailedHTMLProps<
60
+ React.HTMLAttributes<HTMLElement> & PollSliderAttributesHTMLElement,
61
+ HTMLElement
62
+ >;
41
63
  }
42
64
  }
43
65
 
66
+ declare global {
67
+ interface HTMLElementEventMap extends PollWidgetEvents {}
68
+ }
69
+
44
70
  interface Window {
45
71
  engagently?: Engagently;
46
72
  initEngagently?: () => void;
@@ -49,10 +49,6 @@ export type ThemePalette = {
49
49
  white: string;
50
50
  mode: 'light' | 'dark';
51
51
  };
52
- export type PaletteConfig = {
53
- dark: DeepPartial<Omit<ThemePalette, 'mode'>>;
54
- light: DeepPartial<Omit<ThemePalette, 'mode'>>;
55
- };
56
52
  declare const generateDefaultPalette: () => Omit<ThemePalette, 'background' | 'text' | 'mode' | 'elements' | 'default'>;
57
53
  declare const generatePaletteLight: () => ThemePalette;
58
54
  declare const generatePaletteDark: () => ThemePalette;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engagently/types",
3
- "version": "3.1.3",
3
+ "version": "4.0.0",
4
4
  "main": "./index.ts",
5
5
  "types": "dist/types/engagently.d.ts",
6
6
  "files": [