@pexip-engage-public/plugin-react 0.0.7 → 1.0.3

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,35 +0,0 @@
1
- // TODO: Use `import React` always! (CRA4 support) Undo these changes when we drop CRA 4 support
2
- import React from "react";
3
-
4
- import { SkedifyPluginContextProps } from "./SkedifyPluginContext";
5
- import { usePluginConfiguration } from "./usePluginOptions";
6
- import { useSkedifyPlugin } from "./useSkedifyPlugin";
7
-
8
- interface SkedifyPluginProps
9
- extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
10
- configuration: SkedifyPluginContextProps;
11
- }
12
-
13
- export function SkedifyPlugin({ configuration, ...props }: SkedifyPluginProps) {
14
- const { Plugin } = useSkedifyPlugin(configuration?.scriptSrc);
15
- const options = usePluginConfiguration(configuration);
16
- const containerRef = React.useRef<HTMLDivElement>(null);
17
-
18
- React.useEffect(() => {
19
- if (Plugin && containerRef.current) {
20
- // plugin initialized
21
- const instance = new Plugin(containerRef.current, options);
22
-
23
- return () => instance.dispose();
24
- }
25
- }, [Plugin, options]);
26
-
27
- const className = React.useMemo(() => {
28
- const preInitClassName = props.className?.replace("skedify-plugin", "").trim();
29
- const postInitClassName = `${preInitClassName ?? ""} skedify-plugin`.trim();
30
-
31
- return Plugin ? postInitClassName : preInitClassName;
32
- }, [Plugin, props.className]);
33
-
34
- return <div {...props} className={className} ref={containerRef} />;
35
- }
@@ -1,16 +0,0 @@
1
- // TODO: Use `import React` always! (CRA4 support) Undo these changes when we drop CRA 4 support
2
- import React from "react";
3
-
4
- import type { SkedifyPluginConfiguration } from "./types";
5
-
6
- export interface SkedifyPluginContextProps extends SkedifyPluginConfiguration {
7
- /**
8
- * The plugin entry point URL.
9
- * eg: `https://plugin.skedify.io/{ENTERPRISE_NAME}/skedify-plugin.js`
10
- */
11
- scriptSrc?: string;
12
- }
13
-
14
- export const SkedifyPluginContext = React.createContext<SkedifyPluginContextProps>({});
15
-
16
- export const SkedifyPluginProvider = SkedifyPluginContext.Provider;
package/src/types.ts DELETED
@@ -1,296 +0,0 @@
1
- export interface SkedifyPluginInstance {
2
- dispose(): void;
3
- addEventListener(pluginEventType: string, callback: () => unknown): void;
4
- readonly intention: unknown;
5
- readonly customer: {
6
- company?: string;
7
- customer_number?: string;
8
- email?: string;
9
- external_id?: string;
10
- first_name?: string;
11
- is_existing?: string;
12
- language?: string;
13
- last_name?: string;
14
- location?: string;
15
- phone_number?: string;
16
- timezone?: string;
17
- };
18
-
19
- readonly appointment: {
20
- readonly id?: string;
21
- readonly location: {
22
- readonly id?: string;
23
- };
24
- readonly meeting_type: unknown;
25
- readonly subject: {
26
- readonly id?: string;
27
- readonly category_id?: string;
28
- };
29
-
30
- readonly meta: {
31
- get(key: string, defaultValue: unknown): unknown;
32
- set(key: string, value: unknown): unknown;
33
- remove(key: string): unknown;
34
- };
35
- };
36
- }
37
-
38
- export interface SkedifyPluginConfiguration {
39
- oauth?: {
40
- /**
41
- * Required
42
- *
43
- * The client-ID of the plugin. This ID is provided to you by your Skedify contact.
44
- */
45
- client?: string;
46
- /**
47
- * The bearer token used by the plugin. This token represents the contact.
48
- */
49
- token?: string;
50
- /**
51
- * A resource_code of an existing appointment. This will allow you to complete or change an appointment. This parameter is mostly used by redirects from external sources (e.g. e-mails) and should usually not be provided manually.
52
- */
53
- resource_code?: string;
54
- };
55
- /**
56
- * This parameter is used for tracking events inside the plugin.
57
- */
58
- session?: {
59
- /**
60
- * Used to enable/disable tracking of events in the plugin for insights about conversion.
61
- *
62
- * Possible values are:
63
- * - default (enabled)
64
- * - disabled
65
- */
66
- status?: "default" | "disabled";
67
- /**
68
- * Pass your own custom session ID.
69
- */
70
- id?: string;
71
- /**
72
- * Pass source tags seperated with a semi-colon.
73
- */
74
- source_tags?: string;
75
- };
76
- /**
77
- * This parameter is used for prefilling the customer
78
- */
79
- customer?: {
80
- /**
81
- * Default timezone to be used for the customer, this overwrites the guess that is being done as to what timezone the customer should be in.
82
- */
83
- timezone?: string;
84
- /**
85
- * This prefills the first name in the contact information of the customer.
86
- */
87
- first_name?: string;
88
- /**
89
- * This prefills the last name in the contact information of the customer.
90
- */
91
- last_name?: string;
92
- /**
93
- * This prefills the email in the contact information of the customer.
94
- */
95
- email?: string;
96
- /**
97
- * This prefills the phone number in the contact information of the customer.
98
- */
99
- phone_number?: string;
100
- /**
101
- * This prefills the customer number in the contact information of the customer.
102
- */
103
- customer_number?: string;
104
- };
105
- appointment?: {
106
- /**
107
- * A (Skedify-internal) subject-ID. This allows a subject to be preselected. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the external_subject_id parameter.
108
- */
109
- subject_id?: string;
110
- /**
111
- * A (Skedify-internal) office-/office-ID. This allows an office to be preselected. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the external_office_id parameter.
112
- */
113
- office_id?: string;
114
- /**
115
- * Only available when your enterprise is using Skedify’s listings functionality. A Listing ID. This allows to filter subjects on a Listing. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the external_listing_id parameter.
116
- */
117
- listing_id?: string;
118
- };
119
- /**
120
- * A subject-ID. This allows a subject to be preselected. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the appointment.subject_id parameter.
121
- */
122
- external_subject_id?: string;
123
- /**
124
- * An office-/office-ID. This allows an office to be preselected. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the appointment.office_id parameter.
125
- */
126
- external_office_id?: string;
127
- /**
128
- * Only available when your enterprise is using Skedify’s listings functionality. A Listing ID. This allows to filter subjects on a Listing. This option is ignored when oauth.resource_code is provided. This parameter can not be used together with the appointment.subject_id parameter.
129
- */
130
- external_listing_id?: string;
131
- /**
132
- * A Lead Segment Code. This allows a subject to be preselected matching the lead segment code.
133
- */
134
- lead_segment_code?: string;
135
-
136
- hints?: {
137
- /**
138
- * The suspected intent of the customer. Possible values are schedule, reschedule, invite, edit, cancel. This parameter is mostly used by redirects from external sources (e.g. e-mails) and should usually not be provided manually.
139
- */
140
- intent?: "schedule" | "reschedule" | "invite" | "edit" | "cancel";
141
- /**
142
- * A space-separated list of (Skedify-internal) contact-IDs. This makes the plugin favor choice options that are associated with at least one of the provided contacts.
143
- */
144
- contacts?: string;
145
- /**
146
- * A space-separated list of (external) employee-IDs. This makes the plugin favor choice options that are associated with at least one of the provided external IDs.
147
- */
148
- external_employee_ids?: string;
149
- };
150
- /**
151
- * An RFC 5646-compatible language tag. This will cause the plugin to be displayed in the specified language, unless the language is unavailable. In that case, a best-effort fallback will be performed with increasingly more generic variants of the specified language or finally 'en' if no variants of the specified language are available.
152
- */
153
- language?: string;
154
- /**
155
- * Possible values are office, phone, video, on_location.
156
- */
157
- meeting_types?: string;
158
-
159
- application?: {
160
- /**
161
- * Used to change the scrolling behaviour inside the plugin. Currently only possible to disable the initial scrolling when the plugin loads. Possible values: disable_initial_scroll_on_schedule, default.
162
- */
163
- scroll?: "disable_initial_scroll_on_schedule" | "default";
164
-
165
- /**
166
- * Used to enable timezone selection when the meeting type is video or phone. Possible values: enable_timezone_selection, disable_timezone_selection. The default is disable_timezone_selection.
167
- */
168
- timezone_selection?: "enable_timezone_selection" | "disable_timezone_selection";
169
- };
170
-
171
- /**
172
- * This parameter is used for prefilling the location search step, so that offices are already scoped to this location. When location is passed, both geolocation & formatted_address are required.
173
- */
174
- location?: {
175
- /**
176
- * The textual representation of the location.
177
- */
178
- formatted_address: string;
179
- /**
180
- * Latitude & longitude in the following format lat;lng
181
- */
182
- geolocation: string;
183
- /**
184
- * Textual representation of the city.
185
- */
186
- city?: string;
187
- /**
188
- * Textual representation of the country code (for example: BE).
189
- */
190
- country?: string;
191
- /**
192
- * Textual representation of the postal code.
193
- */
194
- postal_code?: string;
195
- /**
196
- * Textual representation of the state.
197
- */
198
- state?: string;
199
- /**
200
- * Textual representation of the street name & number.
201
- */
202
- street_1?: string;
203
- };
204
-
205
- search?: {
206
- /**
207
- * The country that should be used for searching locations. Should be a two letter ISO 3166-1 country code. You can provide a maximum of 5 comma-separated countries.
208
- */
209
- country?: string;
210
- };
211
- /**
212
- * A sequence of characters that indicates the order of steps to be shown. The following characters are supported:
213
- * - `S`: Subject. The step that allows the customer to pick a subject.
214
- * - `O`: Office. The step that allows the customer to pick an office.
215
- * - `E`: Employee. The step that allows the customer to pick an employee.
216
- * - `T`: Timetable. The step that allows the customer to suggest one or more time slots for their appointment.
217
- * - `Q`: Questions. The step that allows the customer to answer any addition questions specific to the chosen subject.
218
- * - `C`: Customer. The step that allows the customer to provide his/her contact information.
219
- * - `'`: [start]. Indicate the first step that should be shown is the first one following this character.
220
- * - `#`: [locked]. Indicate that the step is locked and can not be edited. This means that a value must be provided.
221
- *
222
- * Currently, the following constraints must always be met:
223
- * - The following characters must always be present: `T`, `Q`, `C`.
224
- * - No other characters than those listed above may be used.
225
- * - When `S` is not present, it is mandatory that an external mechanism will provide the `appointment.subject_id` or `external_subject_id` configuration option instead.
226
- * - When `O` is not present, it is mandatory that an external mechanism will provide the `appointment.office_id` or `external_office_id` configuration option instead.
227
- * - If `S` or `O` are present, they can never occur at a position after `T`.
228
- * - If `S` is present, it can never occur at a position after `Q`.
229
- * - If the start character ( `'`) is present, it can never occur at a position after `T`. If the start character is ommitted, it will be assumed that the first character also specifies the first step to be shown.
230
- *
231
- * By default the value `'SOTQC` will be assumed. This will be the case if no value was provided or if the provided value fails these constraints.
232
- */
233
- flow?: string;
234
- intent?: string;
235
- google?: {
236
- maps?: {
237
- api?: {
238
- key?: string;
239
- };
240
- };
241
- };
242
- }
243
-
244
- export interface SkedifyPluginContructor {
245
- new (element: HTMLElement, options?: SkedifyPluginConfiguration): SkedifyPluginInstance;
246
- version: {
247
- value: string;
248
- };
249
- build: {
250
- value: string;
251
- };
252
- getInstance(num: number): SkedifyPluginInstance | undefined;
253
- count: number;
254
-
255
- addLocale: {
256
- value: (name: string, locale: {}) => void;
257
- };
258
-
259
- EVENT_APPOINTMENT_CANCELLED: string;
260
- EVENT_APPOINTMENT_COMPLETED: string;
261
- EVENT_APPOINTMENT_CREATED: string;
262
- EVENT_APPOINTMENT_EDITED: string;
263
- EVENT_CREATION: string;
264
- EVENT_ERROR: string;
265
- EVENT_INIT: string;
266
- EVENT_LOADED: string;
267
- EVENT_MISCONFIGURED: string;
268
- MISCONFIGURED_CLIENT_ID: string;
269
- MISCONFIGURED_CONTACT_HINTS: string;
270
- MISCONFIGURED_GEOLOCATION: string;
271
- MISCONFIGURED_INTENT_WITHOUT_RESOURCE_CODE: string;
272
- MISCONFIGURED_LISTING_ID: string;
273
- MISCONFIGURED_OFFICE_ID: string;
274
- MISCONFIGURED_RESOURCE_CODE: string;
275
- MISCONFIGURED_SUBJECT_ID: string;
276
- MISCONFIGURED_TIMEZONE: string;
277
- ERROR_API_DOWN: string;
278
- ERROR_RECAPTCHA_SCRIPT_LOAD: string;
279
- ERROR_SUB_DATE_INTERPOLATION: string;
280
- ERROR_TRANSLATION: string;
281
- INTENT_CANCEL: string;
282
- INTENT_EDIT: string;
283
- INTENT_INVITE: string;
284
- INTENT_RESCHEDULE: string;
285
- INTENT_SCHEDULE: string;
286
- }
287
-
288
- export interface SkedifyWindow {
289
- Plugin?: SkedifyPluginContructor;
290
- }
291
-
292
- declare global {
293
- interface Window {
294
- Skedify?: SkedifyWindow;
295
- }
296
- }
@@ -1,66 +0,0 @@
1
- // TODO: Use `import React` always! (CRA4 support) Undo these changes when we drop CRA 4 support
2
- import React from "react";
3
-
4
- import { SkedifyPluginContext } from "./SkedifyPluginContext";
5
- import type { SkedifyPluginContructor } from "./types";
6
-
7
- export function useSkedifyPlugin(scriptSrc?: string, scriptId?: string) {
8
- const ctx = React.useContext(SkedifyPluginContext);
9
- const [pluginInstance, setPlugin] = React.useState<{ Plugin: SkedifyPluginContructor | null }>({
10
- Plugin: null,
11
- });
12
-
13
- const src = scriptSrc ?? ctx.scriptSrc;
14
-
15
- React.useEffect(() => {
16
- if (!src) {
17
- console.warn(
18
- "No scriptSrc was provided to SkedifyPluginProvider, or as prop to <SkedifyPlugin />, skipping plugin initialization..."
19
- );
20
-
21
- return;
22
- }
23
-
24
- if (window && document) {
25
- const id = scriptId ?? src;
26
- // only load entry code once
27
- if (!document.getElementById(id)) {
28
- const script = document.createElement("script");
29
- script.src = src;
30
- script.async = true;
31
- script.defer = true;
32
- script.id = id;
33
- window.document.body.appendChild(script);
34
- }
35
-
36
- if (window.Skedify && window.Skedify.Plugin) {
37
- // If Skedify.Plugin is already available, use that instance.
38
- setPlugin({ Plugin: window.Skedify.Plugin });
39
- } else {
40
- // TODO: temp polling code until we restore EVENT_INIT support
41
- const intervalId = window.setInterval(() => {
42
- if (window.Skedify && window.Skedify.Plugin) {
43
- window.clearInterval(intervalId);
44
- setPlugin({ Plugin: window.Skedify.Plugin });
45
- }
46
- }, 200);
47
-
48
- // document.addEventListener("SkedifyPluginEvent", function (event) {
49
- // console.log(event);
50
- // // every event will have a `event.detail.type` attribute, so different events can be distinguished.
51
- // if (
52
- // event.detail.type === window.Skedify.Plugin.EVENT_INIT ||
53
- // event.detail.type === window.Skedify.Plugin.EVENT_CREATION
54
- // ) {
55
- // console.log("Skedify.Plugin available");
56
- // cb(window.Skedify.Plugin);
57
- // }
58
- // });
59
-
60
- return () => window.clearInterval(intervalId);
61
- }
62
- }
63
- }, [src, scriptId]);
64
-
65
- return pluginInstance;
66
- }
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- import { SkedifyPluginContextProps } from "./SkedifyPluginContext";
3
- interface SkedifyPluginProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
4
- configuration: SkedifyPluginContextProps;
5
- }
6
- export declare function SkedifyPlugin({ configuration, ...props }: SkedifyPluginProps): JSX.Element;
7
- export {};
8
- //# sourceMappingURL=SkedifyPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SkedifyPlugin.d.ts","sourceRoot":"","sources":["../src/SkedifyPlugin.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAInE,UAAU,kBACR,SAAQ,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACrF,aAAa,EAAE,yBAAyB,CAAC;CAC1C;AAED,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,eAsB5E"}
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import type { SkedifyPluginConfiguration } from "./types";
3
- export interface SkedifyPluginContextProps extends SkedifyPluginConfiguration {
4
- /**
5
- * The plugin entry point URL.
6
- * eg: `https://plugin.skedify.io/{ENTERPRISE_NAME}/skedify-plugin.js`
7
- */
8
- scriptSrc?: string;
9
- }
10
- export declare const SkedifyPluginContext: React.Context<SkedifyPluginContextProps>;
11
- export declare const SkedifyPluginProvider: React.Provider<SkedifyPluginContextProps>;
12
- //# sourceMappingURL=SkedifyPluginContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SkedifyPluginContext.d.ts","sourceRoot":"","sources":["../src/SkedifyPluginContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,yBAA0B,SAAQ,0BAA0B;IAC3E;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,oBAAoB,0CAAqD,CAAC;AAEvF,eAAO,MAAM,qBAAqB,2CAAgC,CAAC"}