@revvue/embed 0.0.0-beta.1
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.
- package/README.md +1 -0
- package/dist/browser/css/dialog.css +1 -0
- package/dist/browser/css/drawer.css +1 -0
- package/dist/browser/css/popover.css +1 -0
- package/dist/browser/css/widget.css +1 -0
- package/dist/browser/embed.js +2 -0
- package/dist/package/css/dialog.css +1 -0
- package/dist/package/css/drawer.css +1 -0
- package/dist/package/css/popover.css +1 -0
- package/dist/package/css/widget.css +1 -0
- package/dist/package/package.cjs +383 -0
- package/dist/package/package.mjs +376 -0
- package/dist/package/types/config/contants.d.ts +2 -0
- package/dist/package/types/config/contants.d.ts.map +1 -0
- package/dist/package/types/config/env.d.ts +8 -0
- package/dist/package/types/config/env.d.ts.map +1 -0
- package/dist/package/types/core/app-options.d.ts +18 -0
- package/dist/package/types/core/app-options.d.ts.map +1 -0
- package/dist/package/types/core/appearance-options.d.ts +5 -0
- package/dist/package/types/core/appearance-options.d.ts.map +1 -0
- package/dist/package/types/core/button-options.d.ts +38 -0
- package/dist/package/types/core/button-options.d.ts.map +1 -0
- package/dist/package/types/core/common.d.ts +8 -0
- package/dist/package/types/core/common.d.ts.map +1 -0
- package/dist/package/types/core/create-iframe.d.ts +10 -0
- package/dist/package/types/core/create-iframe.d.ts.map +1 -0
- package/dist/package/types/core/create-iframe.spec.d.ts +2 -0
- package/dist/package/types/core/create-iframe.spec.d.ts.map +1 -0
- package/dist/package/types/core/embed-apps.d.ts +2 -0
- package/dist/package/types/core/embed-apps.d.ts.map +1 -0
- package/dist/package/types/core/embed-types.d.ts +12 -0
- package/dist/package/types/core/embed-types.d.ts.map +1 -0
- package/dist/package/types/embed/fetch-embed.d.ts +4 -0
- package/dist/package/types/embed/fetch-embed.d.ts.map +1 -0
- package/dist/package/types/embed/mount-embeds.d.ts +2 -0
- package/dist/package/types/embed/mount-embeds.d.ts.map +1 -0
- package/dist/package/types/factories/create-dialog/create-dialog.d.ts +5 -0
- package/dist/package/types/factories/create-dialog/create-dialog.d.ts.map +1 -0
- package/dist/package/types/factories/create-dialog/create-dialog.spec.d.ts +2 -0
- package/dist/package/types/factories/create-dialog/create-dialog.spec.d.ts.map +1 -0
- package/dist/package/types/factories/create-dialog/index.d.ts +2 -0
- package/dist/package/types/factories/create-dialog/index.d.ts.map +1 -0
- package/dist/package/types/factories/create-drawer/create-drawer.d.ts +6 -0
- package/dist/package/types/factories/create-drawer/create-drawer.d.ts.map +1 -0
- package/dist/package/types/factories/create-drawer/create-drawer.spec.d.ts +2 -0
- package/dist/package/types/factories/create-drawer/create-drawer.spec.d.ts.map +1 -0
- package/dist/package/types/factories/create-drawer/index.d.ts +2 -0
- package/dist/package/types/factories/create-drawer/index.d.ts.map +1 -0
- package/dist/package/types/factories/create-popover/create-popover.d.ts +6 -0
- package/dist/package/types/factories/create-popover/create-popover.d.ts.map +1 -0
- package/dist/package/types/factories/create-popover/create-popover.spec.d.ts +2 -0
- package/dist/package/types/factories/create-popover/create-popover.spec.d.ts.map +1 -0
- package/dist/package/types/factories/create-popover/index.d.ts +2 -0
- package/dist/package/types/factories/create-popover/index.d.ts.map +1 -0
- package/dist/package/types/factories/create-widget/create-widget.d.ts +5 -0
- package/dist/package/types/factories/create-widget/create-widget.d.ts.map +1 -0
- package/dist/package/types/factories/create-widget/create-widget.spec.d.ts +2 -0
- package/dist/package/types/factories/create-widget/create-widget.spec.d.ts.map +1 -0
- package/dist/package/types/factories/create-widget/index.d.ts +2 -0
- package/dist/package/types/factories/create-widget/index.d.ts.map +1 -0
- package/dist/package/types/factories/index.d.ts +5 -0
- package/dist/package/types/factories/index.d.ts.map +1 -0
- package/dist/package/types/package.d.ts +8 -0
- package/dist/package/types/package.d.ts.map +1 -0
- package/dist/package/types/test/fixtures.d.ts +16 -0
- package/dist/package/types/test/fixtures.d.ts.map +1 -0
- package/dist/package/types/test/setup.d.ts +1 -0
- package/dist/package/types/test/setup.d.ts.map +1 -0
- package/dist/package/types/utils/brand-types.d.ts +4 -0
- package/dist/package/types/utils/brand-types.d.ts.map +1 -0
- package/dist/package/types/utils/built-button/built-button.d.ts +8 -0
- package/dist/package/types/utils/built-button/built-button.d.ts.map +1 -0
- package/dist/package/types/utils/built-button/index.d.ts +2 -0
- package/dist/package/types/utils/built-button/index.d.ts.map +1 -0
- package/dist/package/types/utils/create-env.d.ts +12 -0
- package/dist/package/types/utils/create-env.d.ts.map +1 -0
- package/dist/package/types/utils/is.d.ts +10 -0
- package/dist/package/types/utils/is.d.ts.map +1 -0
- package/dist/package/types/utils/keyboard-events.d.ts +3 -0
- package/dist/package/types/utils/keyboard-events.d.ts.map +1 -0
- package/dist/package/types/utils/load-css.d.ts +3 -0
- package/dist/package/types/utils/load-css.d.ts.map +1 -0
- package/dist/package/types/utils/merge-options.d.ts +2 -0
- package/dist/package/types/utils/merge-options.d.ts.map +1 -0
- package/dist/package/types/utils/refresh-iframe.d.ts +2 -0
- package/dist/package/types/utils/refresh-iframe.d.ts.map +1 -0
- package/dist/package/types/utils/set-element-size.d.ts +8 -0
- package/dist/package/types/utils/set-element-size.d.ts.map +1 -0
- package/dist/types/config/env.d.ts +6 -0
- package/dist/types/config/env.d.ts.map +1 -0
- package/dist/types/core/app-options.d.ts +17 -0
- package/dist/types/core/app-options.d.ts.map +1 -0
- package/dist/types/core/common.d.ts +8 -0
- package/dist/types/core/common.d.ts.map +1 -0
- package/dist/types/core/embed-apps.d.ts +2 -0
- package/dist/types/core/embed-apps.d.ts.map +1 -0
- package/dist/types/core/embed-types.d.ts +2 -0
- package/dist/types/core/embed-types.d.ts.map +1 -0
- package/dist/types/dynamic-app/fetch-dynamic-app.d.ts +4 -0
- package/dist/types/dynamic-app/fetch-dynamic-app.d.ts.map +1 -0
- package/dist/types/factories/create-dialog/create-dialog.d.ts +3 -0
- package/dist/types/factories/create-dialog/create-dialog.d.ts.map +1 -0
- package/dist/types/factories/create-dialog/index.d.ts +2 -0
- package/dist/types/factories/create-dialog/index.d.ts.map +1 -0
- package/dist/types/factories/create-drawer/create-drawer.d.ts +3 -0
- package/dist/types/factories/create-drawer/create-drawer.d.ts.map +1 -0
- package/dist/types/factories/create-drawer/index.d.ts +2 -0
- package/dist/types/factories/create-drawer/index.d.ts.map +1 -0
- package/dist/types/factories/create-popup/create-popup.d.ts +3 -0
- package/dist/types/factories/create-popup/create-popup.d.ts.map +1 -0
- package/dist/types/factories/create-popup/index.d.ts +2 -0
- package/dist/types/factories/create-popup/index.d.ts.map +1 -0
- package/dist/types/factories/create-widget/create-widget.d.ts +3 -0
- package/dist/types/factories/create-widget/create-widget.d.ts.map +1 -0
- package/dist/types/factories/create-widget/index.d.ts +2 -0
- package/dist/types/factories/create-widget/index.d.ts.map +1 -0
- package/dist/types/factories/index.d.ts +5 -0
- package/dist/types/factories/index.d.ts.map +1 -0
- package/dist/types/package.d.ts +2 -0
- package/dist/types/package.d.ts.map +1 -0
- package/dist/types/utils/brand-types.d.ts +4 -0
- package/dist/types/utils/brand-types.d.ts.map +1 -0
- package/dist/types/utils/create-env.d.ts +12 -0
- package/dist/types/utils/create-env.d.ts.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
//#region src/core/common.ts
|
|
2
|
+
var tenantId = (id) => id;
|
|
3
|
+
var formId = (id) => id;
|
|
4
|
+
var embedId = (id) => id;
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/utils/refresh-iframe.ts
|
|
7
|
+
function refreshIframe(iframe) {
|
|
8
|
+
if (iframe) {
|
|
9
|
+
const source = iframe.src;
|
|
10
|
+
if (source.includes("&refresh")) iframe.src = source.split("&refresh#").join("#");
|
|
11
|
+
else {
|
|
12
|
+
const splitURL = source.split("#");
|
|
13
|
+
splitURL[0] = `${splitURL[0]}&refresh`;
|
|
14
|
+
iframe.src = splitURL.join("#");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/core/create-iframe.ts
|
|
20
|
+
function getIframeSrc() {
|
|
21
|
+
return "http://localhost:5173/";
|
|
22
|
+
}
|
|
23
|
+
function createIframe(_options) {
|
|
24
|
+
const src = getIframeSrc();
|
|
25
|
+
const embedId = crypto.randomUUID();
|
|
26
|
+
const iframe = document.createElement("iframe");
|
|
27
|
+
iframe.src = src;
|
|
28
|
+
iframe.dataset.testid = "iframe";
|
|
29
|
+
iframe.style.border = "0px";
|
|
30
|
+
iframe.allow = "microphone; camera";
|
|
31
|
+
iframe.id = embedId;
|
|
32
|
+
const refresh = () => refreshIframe(iframe);
|
|
33
|
+
const focus = () => {
|
|
34
|
+
iframe.contentWindow?.postMessage("rvv-embed-focus", "*");
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
iframe,
|
|
38
|
+
focus,
|
|
39
|
+
refresh,
|
|
40
|
+
embedId
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/utils/is.ts
|
|
45
|
+
var isOpen = (element) => {
|
|
46
|
+
return isInPage(element) && isVisible(element);
|
|
47
|
+
};
|
|
48
|
+
var isInPage = (element) => !!element.parentNode;
|
|
49
|
+
var isVisible = (element) => element.style.display !== "none";
|
|
50
|
+
var isBrowser = () => {
|
|
51
|
+
return typeof document !== "undefined" && typeof window !== "undefined";
|
|
52
|
+
};
|
|
53
|
+
var is = {
|
|
54
|
+
open: isOpen,
|
|
55
|
+
inPage: isInPage,
|
|
56
|
+
visible: isVisible,
|
|
57
|
+
browser: isBrowser
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/utils/keyboard-events.ts
|
|
61
|
+
function addCustomKeydownListener(callback) {
|
|
62
|
+
const abortController = new AbortController();
|
|
63
|
+
window.addEventListener("keydown", callback, { signal: abortController.signal });
|
|
64
|
+
return abortController;
|
|
65
|
+
}
|
|
66
|
+
function onEscape(callback) {
|
|
67
|
+
const abortController = addCustomKeydownListener((e) => {
|
|
68
|
+
if (e.key === "Escape") {
|
|
69
|
+
callback();
|
|
70
|
+
abortController.abort();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/utils/set-element-size.ts
|
|
76
|
+
var getValueWithUnits = (value) => {
|
|
77
|
+
if (typeof value === "string" && !value.match(/^[0-9]+$/)) return value;
|
|
78
|
+
else return `${value}px`;
|
|
79
|
+
};
|
|
80
|
+
var setElementSize = (element, { width, height }) => {
|
|
81
|
+
if (width) element.style.width = getValueWithUnits(width);
|
|
82
|
+
if (height) element.style.height = getValueWithUnits(height);
|
|
83
|
+
return element;
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/factories/create-dialog/create-dialog.ts
|
|
87
|
+
function createDialogElement() {
|
|
88
|
+
const container = document.createElement("dialog");
|
|
89
|
+
container.classList.add("rvv-dialog");
|
|
90
|
+
return container;
|
|
91
|
+
}
|
|
92
|
+
function createDialogWrapper() {
|
|
93
|
+
const wrapper = document.createElement("div");
|
|
94
|
+
wrapper.classList.add("rvv-dialog-wrapper");
|
|
95
|
+
return wrapper;
|
|
96
|
+
}
|
|
97
|
+
function unmountElement$2(element) {
|
|
98
|
+
element.remove();
|
|
99
|
+
}
|
|
100
|
+
function createDialog(options, element) {
|
|
101
|
+
if (!is.browser()) return {
|
|
102
|
+
toggle: () => {},
|
|
103
|
+
open: () => {},
|
|
104
|
+
close: () => {},
|
|
105
|
+
unmount: () => {},
|
|
106
|
+
refresh: () => {},
|
|
107
|
+
focus: () => {}
|
|
108
|
+
};
|
|
109
|
+
const { iframe, refresh, focus } = createIframe(options);
|
|
110
|
+
const container = element ?? document.body;
|
|
111
|
+
const dialog = createDialogElement();
|
|
112
|
+
const wrapper = createDialogWrapper();
|
|
113
|
+
setElementSize(wrapper, {
|
|
114
|
+
width: options.width,
|
|
115
|
+
height: options.height
|
|
116
|
+
});
|
|
117
|
+
container.append(dialog);
|
|
118
|
+
wrapper.append(iframe);
|
|
119
|
+
iframe.onload = (event) => {
|
|
120
|
+
if (event?.isTrusted) {
|
|
121
|
+
dialog.showModal();
|
|
122
|
+
onEscape(close);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function open() {
|
|
126
|
+
if (is.open(wrapper)) return;
|
|
127
|
+
dialog.append(wrapper);
|
|
128
|
+
dialog.showModal();
|
|
129
|
+
}
|
|
130
|
+
function close() {
|
|
131
|
+
if (!is.open(wrapper)) return;
|
|
132
|
+
dialog.close();
|
|
133
|
+
unmountElement$2(wrapper);
|
|
134
|
+
}
|
|
135
|
+
function toggle() {
|
|
136
|
+
is.open(wrapper) ? close() : open();
|
|
137
|
+
}
|
|
138
|
+
function unmount() {
|
|
139
|
+
unmountElement$2(dialog);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
toggle,
|
|
143
|
+
open,
|
|
144
|
+
close,
|
|
145
|
+
unmount,
|
|
146
|
+
refresh,
|
|
147
|
+
focus
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/utils/built-button/built-button.ts
|
|
152
|
+
var defaultIcon = `
|
|
153
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-message-square-icon lucide-message-square"><path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z"/></svg>`;
|
|
154
|
+
var closeIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`;
|
|
155
|
+
function buildDefaultIcons() {
|
|
156
|
+
const openEl = document.createElement("span");
|
|
157
|
+
openEl.classList.add("rvv-button-icon--open");
|
|
158
|
+
openEl.innerHTML = defaultIcon;
|
|
159
|
+
const closeEl = document.createElement("span");
|
|
160
|
+
closeEl.classList.add("rvv-button-icon--close");
|
|
161
|
+
closeEl.innerHTML = closeIcon;
|
|
162
|
+
return {
|
|
163
|
+
openEl,
|
|
164
|
+
closeEl
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function buildButtonElement(options) {
|
|
168
|
+
const button = document.createElement("button");
|
|
169
|
+
button.classList.add("rvv-button", "rvv-button--trigger");
|
|
170
|
+
button.setAttribute("type", "button");
|
|
171
|
+
button.dataset.position = options.position ?? "right";
|
|
172
|
+
button.dataset.open = "false";
|
|
173
|
+
if (options.color) button.style.setProperty("--rvv-button-color", options.color);
|
|
174
|
+
if (options.textColor) button.style.setProperty("--rvv-button-text-color", options.textColor);
|
|
175
|
+
const iconWrapper = document.createElement("span");
|
|
176
|
+
iconWrapper.classList.add("rvv-button-icon");
|
|
177
|
+
iconWrapper.setAttribute("aria-hidden", "true");
|
|
178
|
+
if (options.label) {
|
|
179
|
+
const labelEl = document.createElement("span");
|
|
180
|
+
labelEl.classList.add("rvv-button-label");
|
|
181
|
+
labelEl.textContent = options.label;
|
|
182
|
+
button.append(labelEl);
|
|
183
|
+
}
|
|
184
|
+
if (options.icon) iconWrapper.innerHTML = options.icon;
|
|
185
|
+
else if (!options.label) {
|
|
186
|
+
const { openEl, closeEl } = buildDefaultIcons();
|
|
187
|
+
iconWrapper.append(openEl, closeEl);
|
|
188
|
+
}
|
|
189
|
+
if (iconWrapper.childNodes.length > 0) button.append(iconWrapper);
|
|
190
|
+
function setOpen(isOpen) {
|
|
191
|
+
button.dataset.open = String(isOpen);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
el: button,
|
|
195
|
+
setOpen
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/factories/create-drawer/create-drawer.ts
|
|
200
|
+
function createDrawerElement() {
|
|
201
|
+
const container = document.createElement("div");
|
|
202
|
+
container.classList.add("rvv-drawer");
|
|
203
|
+
return container;
|
|
204
|
+
}
|
|
205
|
+
function createDrawerWrapper() {
|
|
206
|
+
const wrapper = document.createElement("div");
|
|
207
|
+
wrapper.classList.add("rvv-drawer-wrapper");
|
|
208
|
+
return wrapper;
|
|
209
|
+
}
|
|
210
|
+
function unmountElement$1(element) {
|
|
211
|
+
element.remove();
|
|
212
|
+
}
|
|
213
|
+
function createDrawer(options, element) {
|
|
214
|
+
if (!is.browser()) return {
|
|
215
|
+
toggle: () => {},
|
|
216
|
+
open: () => {},
|
|
217
|
+
close: () => {},
|
|
218
|
+
unmount: () => {},
|
|
219
|
+
refresh: () => {},
|
|
220
|
+
focus: () => {}
|
|
221
|
+
};
|
|
222
|
+
const { iframe, refresh, focus } = createIframe(options);
|
|
223
|
+
const container = element ?? document.body;
|
|
224
|
+
const drawer = createDrawerElement();
|
|
225
|
+
const wrapper = createDrawerWrapper();
|
|
226
|
+
setElementSize(wrapper, {
|
|
227
|
+
width: options.width,
|
|
228
|
+
height: options.height
|
|
229
|
+
});
|
|
230
|
+
container.append(drawer);
|
|
231
|
+
wrapper.append(iframe);
|
|
232
|
+
const { autoOpen = false, autoOpenDelay = 0 } = options;
|
|
233
|
+
let setButtonOpen = () => {};
|
|
234
|
+
const { el: buttonEl, setOpen } = buildButtonElement(options);
|
|
235
|
+
setButtonOpen = setOpen;
|
|
236
|
+
buttonEl.addEventListener("click", () => toggle());
|
|
237
|
+
document.body.append(buttonEl);
|
|
238
|
+
iframe.onload = (event) => {
|
|
239
|
+
if (event?.isTrusted) {
|
|
240
|
+
drawer.classList.add("open");
|
|
241
|
+
onEscape(close);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
function open() {
|
|
245
|
+
if (is.open(wrapper)) return;
|
|
246
|
+
drawer.append(wrapper);
|
|
247
|
+
setButtonOpen(true);
|
|
248
|
+
}
|
|
249
|
+
function close() {
|
|
250
|
+
if (!is.open(wrapper)) return;
|
|
251
|
+
unmountElement$1(wrapper);
|
|
252
|
+
drawer.classList.remove("open");
|
|
253
|
+
setButtonOpen(false);
|
|
254
|
+
}
|
|
255
|
+
function toggle() {
|
|
256
|
+
is.open(wrapper) ? close() : open();
|
|
257
|
+
}
|
|
258
|
+
function unmount() {
|
|
259
|
+
buttonEl?.remove();
|
|
260
|
+
unmountElement$1(drawer);
|
|
261
|
+
}
|
|
262
|
+
if (autoOpen) if (autoOpenDelay > 0) setTimeout(() => open(), autoOpenDelay);
|
|
263
|
+
else open();
|
|
264
|
+
return {
|
|
265
|
+
toggle,
|
|
266
|
+
open,
|
|
267
|
+
close,
|
|
268
|
+
unmount,
|
|
269
|
+
refresh,
|
|
270
|
+
focus
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/factories/create-popover/create-popover.ts
|
|
275
|
+
function createPopoverElement() {
|
|
276
|
+
const container = document.createElement("div");
|
|
277
|
+
container.classList.add("rvv-popover");
|
|
278
|
+
return container;
|
|
279
|
+
}
|
|
280
|
+
function createPopoverWrapper() {
|
|
281
|
+
const wrapper = document.createElement("div");
|
|
282
|
+
wrapper.classList.add("rvv-popover-wrapper");
|
|
283
|
+
return wrapper;
|
|
284
|
+
}
|
|
285
|
+
function unmountElement(element) {
|
|
286
|
+
element.remove();
|
|
287
|
+
}
|
|
288
|
+
function createPopover(options, element) {
|
|
289
|
+
if (!is.browser()) return {
|
|
290
|
+
toggle: () => {},
|
|
291
|
+
close: () => {},
|
|
292
|
+
open: () => {},
|
|
293
|
+
unmount: () => {},
|
|
294
|
+
refresh: () => {},
|
|
295
|
+
focus: () => {}
|
|
296
|
+
};
|
|
297
|
+
const { iframe, refresh, focus } = createIframe(options);
|
|
298
|
+
const container = element ?? document.body;
|
|
299
|
+
const popover = createPopoverElement();
|
|
300
|
+
const wrapper = createPopoverWrapper();
|
|
301
|
+
setElementSize(wrapper, {
|
|
302
|
+
width: options.width,
|
|
303
|
+
height: options.height
|
|
304
|
+
});
|
|
305
|
+
container.append(popover);
|
|
306
|
+
wrapper.append(iframe);
|
|
307
|
+
const { autoOpen = false, autoOpenDelay = 0 } = options;
|
|
308
|
+
let setButtonOpen = () => {};
|
|
309
|
+
const { el: buttonEl, setOpen } = buildButtonElement(options);
|
|
310
|
+
setButtonOpen = setOpen;
|
|
311
|
+
buttonEl.addEventListener("click", () => toggle());
|
|
312
|
+
document.body.append(buttonEl);
|
|
313
|
+
function toggle() {
|
|
314
|
+
is.open(wrapper) ? close() : open();
|
|
315
|
+
}
|
|
316
|
+
iframe.onload = (event) => {
|
|
317
|
+
if (event?.isTrusted) {
|
|
318
|
+
popover.classList.add("open");
|
|
319
|
+
onEscape(close);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
function open() {
|
|
323
|
+
if (is.open(wrapper)) return;
|
|
324
|
+
popover.append(wrapper);
|
|
325
|
+
setButtonOpen(true);
|
|
326
|
+
}
|
|
327
|
+
function close() {
|
|
328
|
+
if (!is.open(wrapper)) return;
|
|
329
|
+
popover.classList.remove("open");
|
|
330
|
+
setButtonOpen(false);
|
|
331
|
+
popover.addEventListener("transitionend", () => unmountElement(wrapper), { once: true });
|
|
332
|
+
}
|
|
333
|
+
function unmount() {
|
|
334
|
+
buttonEl?.remove();
|
|
335
|
+
unmountElement(popover);
|
|
336
|
+
}
|
|
337
|
+
if (autoOpen) if (autoOpenDelay > 0) setTimeout(() => open(), autoOpenDelay);
|
|
338
|
+
else open();
|
|
339
|
+
return {
|
|
340
|
+
toggle,
|
|
341
|
+
close,
|
|
342
|
+
open,
|
|
343
|
+
unmount,
|
|
344
|
+
refresh,
|
|
345
|
+
focus
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/factories/create-widget/create-widget.ts
|
|
350
|
+
function createWidget(options, element) {
|
|
351
|
+
if (!is.browser()) return {
|
|
352
|
+
unmount: () => {},
|
|
353
|
+
refresh: () => {},
|
|
354
|
+
focus: () => {}
|
|
355
|
+
};
|
|
356
|
+
const { iframe, refresh, focus } = createIframe(options);
|
|
357
|
+
const container = element ?? document.body;
|
|
358
|
+
const widget = document.createElement("div");
|
|
359
|
+
widget.classList.add("rvv-widget");
|
|
360
|
+
container.append(widget);
|
|
361
|
+
setElementSize(widget, {
|
|
362
|
+
width: options.width,
|
|
363
|
+
height: options.height
|
|
364
|
+
});
|
|
365
|
+
widget.append(iframe);
|
|
366
|
+
function unmount() {
|
|
367
|
+
iframe.remove();
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
unmount,
|
|
371
|
+
refresh,
|
|
372
|
+
focus
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
export { createDialog, createDrawer, createPopover, createWidget, embedId, formId, tenantId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contants.d.ts","sourceRoot":"","sources":["../../../../src/config/contants.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/config/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;;;;;CA8Bf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AppearanceOptions } from './appearance-options';
|
|
2
|
+
import { TenantId } from './common';
|
|
3
|
+
import { AppKind } from './embed-apps';
|
|
4
|
+
import { EmbedType } from './embed-types';
|
|
5
|
+
export interface BaseEmbedOptions {
|
|
6
|
+
tenant: TenantId;
|
|
7
|
+
type: EmbedType;
|
|
8
|
+
app: AppKind;
|
|
9
|
+
}
|
|
10
|
+
export interface ChatOptions extends BaseEmbedOptions, AppearanceOptions {
|
|
11
|
+
app: "chat";
|
|
12
|
+
}
|
|
13
|
+
export interface FormOptions extends BaseEmbedOptions, AppearanceOptions {
|
|
14
|
+
app: "form";
|
|
15
|
+
formId: string;
|
|
16
|
+
}
|
|
17
|
+
export type EmbedOptions = ChatOptions | FormOptions;
|
|
18
|
+
//# sourceMappingURL=app-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-options.d.ts","sourceRoot":"","sources":["../../../../src/core/app-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,WAAY,SAAQ,gBAAgB,EAAE,iBAAiB;IACtE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,gBAAgB,EAAE,iBAAiB;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appearance-options.d.ts","sourceRoot":"","sources":["../../../../src/core/appearance-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface ButtonOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Text label displayed inside the button.
|
|
4
|
+
* @default "Open"
|
|
5
|
+
*/
|
|
6
|
+
label?: string;
|
|
7
|
+
/**
|
|
8
|
+
* An icon displayed before the label. Accepts an emoji string or an SVG string.
|
|
9
|
+
* When provided without a `label`, the button renders as a compact icon-only button.
|
|
10
|
+
*/
|
|
11
|
+
icon?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Which horizontal edge the button is anchored to.
|
|
14
|
+
* @default "right"
|
|
15
|
+
*/
|
|
16
|
+
position?: "left" | "right";
|
|
17
|
+
/**
|
|
18
|
+
* Background color of the button (any CSS color value).
|
|
19
|
+
* @example "#6366f1"
|
|
20
|
+
*/
|
|
21
|
+
color?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Text and icon color of the button (any CSS color value).
|
|
24
|
+
* @default "#ffffff"
|
|
25
|
+
*/
|
|
26
|
+
textColor?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Automatically open the embed when the button mounts.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
autoOpen?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Milliseconds to wait before auto-opening (requires `autoOpen: true`).
|
|
34
|
+
* @default 0
|
|
35
|
+
*/
|
|
36
|
+
autoOpenDelay?: number;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=button-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-options.d.ts","sourceRoot":"","sources":["../../../../src/core/button-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAE5B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Brand } from '../utils/brand-types';
|
|
2
|
+
export type TenantId = Brand<string, "TenantId">;
|
|
3
|
+
export type FormId = Brand<string, "FormId">;
|
|
4
|
+
export type EmbedId = Brand<string, "EmbedId">;
|
|
5
|
+
export declare const tenantId: (id: string) => TenantId;
|
|
6
|
+
export declare const formId: (id: string) => FormId;
|
|
7
|
+
export declare const embedId: (id: string) => EmbedId;
|
|
8
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/core/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACjD,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC7C,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,KAAG,QAA0B,CAAC;AACjE,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,KAAG,MAAsB,CAAC;AAC3D,eAAO,MAAM,OAAO,GAAI,IAAI,MAAM,KAAG,OAAwB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EmbedOptions } from './app-options';
|
|
2
|
+
type CreateIframeOptions = {} & EmbedOptions;
|
|
3
|
+
export declare function createIframe(_options: CreateIframeOptions): {
|
|
4
|
+
iframe: HTMLIFrameElement;
|
|
5
|
+
focus: () => void;
|
|
6
|
+
refresh: () => void;
|
|
7
|
+
embedId: `${string}-${string}-${string}-${string}-${string}`;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=create-iframe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-iframe.d.ts","sourceRoot":"","sources":["../../../../src/core/create-iframe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,KAAK,mBAAmB,GAAG,EAAE,GAAG,YAAY,CAAC;AAM7C,wBAAgB,YAAY,CAAC,QAAQ,EAAE,mBAAmB;;;;;EAoBzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-iframe.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/create-iframe.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-apps.d.ts","sourceRoot":"","sources":["../../../../src/core/embed-apps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type EmbedType = "widget" | "popover" | "drawer" | "dialog";
|
|
2
|
+
export type EmbedWidget = {
|
|
3
|
+
unmount: () => void;
|
|
4
|
+
refresh: () => void;
|
|
5
|
+
focus: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type EmbedFloating = EmbedWidget & {
|
|
8
|
+
open: () => void;
|
|
9
|
+
close: () => void;
|
|
10
|
+
toggle: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=embed-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-types.d.ts","sourceRoot":"","sources":["../../../../src/core/embed-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-embed.d.ts","sourceRoot":"","sources":["../../../../src/embed/fetch-embed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,wBAAsB,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAQnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-embeds.d.ts","sourceRoot":"","sources":["../../../../src/embed/mount-embeds.ts"],"names":[],"mappings":"AAsCA,wBAAsB,WAAW,CAAC,SAAS,GAAE,WAAW,GAAG,QAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7F"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EmbedOptions } from '../../core/app-options';
|
|
2
|
+
import { EmbedFloating } from '../../core/embed-types';
|
|
3
|
+
export type Dialog = EmbedFloating;
|
|
4
|
+
export declare function createDialog(options: EmbedOptions, element?: HTMLElement): Dialog;
|
|
5
|
+
//# sourceMappingURL=create-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-dialog.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-dialog/create-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK5D,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC;AAkBnC,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAwDjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-dialog.spec.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-dialog/create-dialog.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-dialog/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EmbedOptions } from '../../core/app-options';
|
|
2
|
+
import { ButtonOptions } from '../../core/button-options';
|
|
3
|
+
import { EmbedFloating } from '../../core/embed-types';
|
|
4
|
+
export type Drawer = EmbedFloating;
|
|
5
|
+
export declare function createDrawer(options: EmbedOptions & ButtonOptions, element?: HTMLElement): Drawer;
|
|
6
|
+
//# sourceMappingURL=create-drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-drawer.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-drawer/create-drawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAM5D,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC;AAkBnC,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CA2EjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-drawer.spec.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-drawer/create-drawer.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-drawer/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EmbedOptions } from '../../core/app-options';
|
|
2
|
+
import { ButtonOptions } from '../../core/button-options';
|
|
3
|
+
import { EmbedFloating } from '../../core/embed-types';
|
|
4
|
+
export type Popover = EmbedFloating;
|
|
5
|
+
export declare function createPopover(options: EmbedOptions & ButtonOptions, element?: HTMLElement): Popover;
|
|
6
|
+
//# sourceMappingURL=create-popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-popover.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-popover/create-popover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAM5D,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC;AAkBpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CA6EnG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-popover.spec.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-popover/create-popover.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-popover/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EmbedOptions } from '../../core/app-options';
|
|
2
|
+
import { EmbedWidget } from '../../core/embed-types';
|
|
3
|
+
export type Widget = EmbedWidget;
|
|
4
|
+
export declare function createWidget(options: EmbedOptions, element?: HTMLElement): Widget;
|
|
5
|
+
//# sourceMappingURL=create-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-widget.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-widget/create-widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC;AAEjC,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CA2BjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-widget.spec.d.ts","sourceRoot":"","sources":["../../../../../src/factories/create-widget/create-widget.spec.ts"],"names":[],"mappings":""}
|