@hellotext/hellotext 2.5.6 → 2.5.8
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 +5 -26
- package/dist/hellotext.js +1 -1
- package/dist/hellotext.js.LICENSE.txt +1 -1
- package/index.d.ts +15 -6
- package/lib/api/acks.cjs +17 -31
- package/lib/api/acks.js +17 -42
- package/lib/api/businesses.cjs +14 -28
- package/lib/api/businesses.js +13 -36
- package/lib/api/events.cjs +26 -40
- package/lib/api/events.js +28 -52
- package/lib/api/forms.cjs +24 -40
- package/lib/api/forms.js +24 -57
- package/lib/api/identifications.cjs +15 -29
- package/lib/api/identifications.js +15 -40
- package/lib/api/index.cjs +26 -46
- package/lib/api/index.js +28 -49
- package/lib/api/push/identities.cjs +43 -0
- package/lib/api/push/identities.js +35 -0
- package/lib/api/response.cjs +30 -52
- package/lib/api/response.js +31 -60
- package/lib/api/submissions.cjs +18 -34
- package/lib/api/submissions.js +18 -48
- package/lib/api/webchat/messages.cjs +44 -64
- package/lib/api/webchat/messages.js +44 -80
- package/lib/api/webchats.cjs +37 -56
- package/lib/api/webchats.js +37 -65
- package/lib/api/whatsapp_widgets.cjs +49 -72
- package/lib/api/whatsapp_widgets.js +48 -91
- package/lib/builders/input_builder.cjs +36 -48
- package/lib/builders/input_builder.js +36 -48
- package/lib/builders/logo_builder.cjs +10 -29
- package/lib/builders/logo_builder.js +20 -28
- package/lib/channels/application_channel.cjs +136 -178
- package/lib/channels/application_channel.js +137 -180
- package/lib/channels/webchat_channel.cjs +125 -170
- package/lib/channels/webchat_channel.js +125 -170
- package/lib/controllers/form_controller.cjs +82 -121
- package/lib/controllers/form_controller.js +82 -130
- package/lib/controllers/message_controller.cjs +211 -282
- package/lib/controllers/message_controller.js +209 -284
- package/lib/controllers/mixins/usePopover.cjs +3 -6
- package/lib/controllers/mixins/usePopover.js +17 -22
- package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
- package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
- package/lib/controllers/webchat/useBehaviour.js +5 -5
- package/lib/controllers/webchat/useOpeningSequence.js +6 -6
- package/lib/controllers/webchat/useTeaser.js +9 -9
- package/lib/controllers/webchat_controller.cjs +916 -1088
- package/lib/controllers/webchat_controller.js +926 -1152
- package/lib/core/configuration/forms.cjs +21 -35
- package/lib/core/configuration/forms.js +20 -35
- package/lib/core/configuration/locale.cjs +36 -71
- package/lib/core/configuration/locale.js +36 -70
- package/lib/core/configuration/push.cjs +16 -0
- package/lib/core/configuration/push.js +10 -0
- package/lib/core/configuration/webchat.cjs +142 -182
- package/lib/core/configuration/webchat.js +145 -189
- package/lib/core/configuration/whatsapp.cjs +76 -102
- package/lib/core/configuration/whatsapp.js +76 -105
- package/lib/core/configuration.cjs +62 -75
- package/lib/core/configuration.js +61 -75
- package/lib/core/event.cjs +36 -59
- package/lib/core/event.js +35 -61
- package/lib/core/sanitize_html.js +4 -4
- package/lib/errors/invalid_event.cjs +5 -26
- package/lib/errors/invalid_event.js +5 -26
- package/lib/errors/not_initialized_error.cjs +5 -26
- package/lib/errors/not_initialized_error.js +5 -26
- package/lib/hellotext.cjs +186 -211
- package/lib/hellotext.js +189 -236
- package/lib/index.js +1 -1
- package/lib/models/business.cjs +115 -152
- package/lib/models/business.js +118 -162
- package/lib/models/cookies.cjs +34 -51
- package/lib/models/cookies.js +34 -51
- package/lib/models/fingerprint.cjs +8 -23
- package/lib/models/fingerprint.js +25 -58
- package/lib/models/form.cjs +106 -142
- package/lib/models/form.js +105 -153
- package/lib/models/form_collection.cjs +63 -101
- package/lib/models/form_collection.js +61 -107
- package/lib/models/index.cjs +7 -0
- package/lib/models/index.js +1 -0
- package/lib/models/page.cjs +106 -129
- package/lib/models/page.js +106 -131
- package/lib/models/push.cjs +345 -0
- package/lib/models/push.js +339 -0
- package/lib/models/query.cjs +21 -41
- package/lib/models/query.js +21 -41
- package/lib/models/session.cjs +33 -65
- package/lib/models/session.js +30 -63
- package/lib/models/user.cjs +29 -51
- package/lib/models/user.js +29 -51
- package/lib/models/utm.cjs +15 -27
- package/lib/models/utm.js +17 -32
- package/lib/models/webchat.cjs +52 -76
- package/lib/models/webchat.js +52 -90
- package/lib/models/whatsapp_widget.cjs +41 -59
- package/lib/models/whatsapp_widget.js +41 -73
- package/lib/vanilla.cjs +4 -7
- package/lib/vanilla.js +2 -1
- package/package.json +2 -10
- package/src/api/index.js +5 -0
- package/src/api/push/identities.js +42 -0
- package/src/core/configuration/push.js +12 -0
- package/src/core/configuration.js +5 -0
- package/src/hellotext.js +15 -1
- package/src/index.bundle.js +0 -1
- package/src/models/business.js +1 -0
- package/src/models/index.js +1 -0
- package/src/models/push.js +397 -0
- package/src/vanilla.js +2 -1
- package/styles/index.css +0 -30
|
@@ -9,157 +9,113 @@ var _stimulus = require("@hotwired/stimulus");
|
|
|
9
9
|
var _usePopover = require("../mixins/usePopover");
|
|
10
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.pickerLoadPromise = null;
|
|
39
|
-
this.connected = false;
|
|
40
|
-
_get(_getPrototypeOf(_default.prototype), "initialize", this).call(this);
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "connect",
|
|
44
|
-
value: function connect() {
|
|
45
|
-
this.connected = true;
|
|
46
|
-
(0, _usePopover.usePopover)(this);
|
|
47
|
-
this.setupFloatingUI({
|
|
48
|
-
trigger: this.buttonTarget,
|
|
49
|
-
popover: this.popoverTarget,
|
|
50
|
-
strategy: 'absolute'
|
|
51
|
-
});
|
|
52
|
-
_get(_getPrototypeOf(_default.prototype), "connect", this).call(this);
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "disconnect",
|
|
56
|
-
value: function disconnect() {
|
|
57
|
-
this.connected = false;
|
|
58
|
-
this.pickerLoadPromise = null;
|
|
59
|
-
this.floatingUICleanup();
|
|
60
|
-
_get(_getPrototypeOf(_default.prototype), "disconnect", this).call(this);
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "onEmojiSelect",
|
|
64
|
-
value: function onEmojiSelect(emoji) {
|
|
65
|
-
this.dispatch('selected', {
|
|
66
|
-
detail: emoji.native
|
|
67
|
-
});
|
|
68
|
-
this.hide();
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "onClickOutside",
|
|
72
|
-
value: function onClickOutside(event) {
|
|
73
|
-
if (this.openValue && event.target.nodeType && this.element.contains(event.target) === false) {
|
|
74
|
-
this.openValue = false;
|
|
75
|
-
}
|
|
12
|
+
class _default extends _stimulus.Controller {
|
|
13
|
+
static targets = ['button', 'popover'];
|
|
14
|
+
static values = {
|
|
15
|
+
placement: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'bottom-end'
|
|
18
|
+
},
|
|
19
|
+
open: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
autoPlacement: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
disabled: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 24
|
|
34
|
+
},
|
|
35
|
+
perLine: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 9
|
|
76
38
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "webchat-emoji-en" */'@emoji-mart/data/i18n/en.json')));
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "buildPicker",
|
|
114
|
-
value: function buildPicker(Picker, i18n) {
|
|
115
|
-
return new Picker({
|
|
116
|
-
onEmojiSelect: this.onEmojiSelect,
|
|
117
|
-
theme: 'light',
|
|
118
|
-
dynamicWidth: true,
|
|
119
|
-
previewPosition: 'none',
|
|
120
|
-
skinTonePosition: 'none',
|
|
121
|
-
emojiSize: this.sizeValue,
|
|
122
|
-
perLine: this.perLineValue,
|
|
123
|
-
i18n
|
|
124
|
-
});
|
|
39
|
+
};
|
|
40
|
+
initialize() {
|
|
41
|
+
this.onEmojiSelect = this.onEmojiSelect.bind(this);
|
|
42
|
+
this.pickerLoaded = false;
|
|
43
|
+
this.pickerLoadPromise = null;
|
|
44
|
+
this.connected = false;
|
|
45
|
+
super.initialize();
|
|
46
|
+
}
|
|
47
|
+
connect() {
|
|
48
|
+
this.connected = true;
|
|
49
|
+
(0, _usePopover.usePopover)(this);
|
|
50
|
+
this.setupFloatingUI({
|
|
51
|
+
trigger: this.buttonTarget,
|
|
52
|
+
popover: this.popoverTarget,
|
|
53
|
+
strategy: 'absolute'
|
|
54
|
+
});
|
|
55
|
+
super.connect();
|
|
56
|
+
}
|
|
57
|
+
disconnect() {
|
|
58
|
+
this.connected = false;
|
|
59
|
+
this.pickerLoadPromise = null;
|
|
60
|
+
this.floatingUICleanup();
|
|
61
|
+
super.disconnect();
|
|
62
|
+
}
|
|
63
|
+
onEmojiSelect(emoji) {
|
|
64
|
+
this.dispatch('selected', {
|
|
65
|
+
detail: emoji.native
|
|
66
|
+
});
|
|
67
|
+
this.hide();
|
|
68
|
+
}
|
|
69
|
+
onClickOutside(event) {
|
|
70
|
+
if (this.openValue && event.target.nodeType && this.element.contains(event.target) === false) {
|
|
71
|
+
this.openValue = false;
|
|
125
72
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
73
|
+
}
|
|
74
|
+
async onPopoverOpened() {
|
|
75
|
+
await this.loadPicker();
|
|
76
|
+
}
|
|
77
|
+
async loadPicker() {
|
|
78
|
+
if (this.pickerLoaded) return;
|
|
79
|
+
this.pickerLoadPromise ||= this.loadPickerDependencies();
|
|
80
|
+
const {
|
|
81
|
+
Picker,
|
|
82
|
+
i18n
|
|
83
|
+
} = await this.pickerLoadPromise;
|
|
84
|
+
if (!this.connected || this.pickerLoaded) return;
|
|
85
|
+
this.popoverTarget.appendChild(this.buildPicker(Picker, i18n));
|
|
86
|
+
this.pickerLoaded = true;
|
|
87
|
+
}
|
|
88
|
+
async loadPickerDependencies() {
|
|
89
|
+
const [pickerModule, i18nModule] = await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "webchat-emoji" */'emoji-mart'))), this.loadI18n()]);
|
|
90
|
+
return {
|
|
91
|
+
Picker: pickerModule.Picker,
|
|
92
|
+
i18n: i18nModule.default || i18nModule
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
loadI18n() {
|
|
96
|
+
if (Hellotext.business.locale === 'es') {
|
|
97
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "webchat-emoji-es" */'@emoji-mart/data/i18n/es.json')));
|
|
134
98
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
default: false
|
|
156
|
-
},
|
|
157
|
-
size: {
|
|
158
|
-
type: Number,
|
|
159
|
-
default: 24
|
|
160
|
-
},
|
|
161
|
-
perLine: {
|
|
162
|
-
type: Number,
|
|
163
|
-
default: 9
|
|
99
|
+
return Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "webchat-emoji-en" */'@emoji-mart/data/i18n/en.json')));
|
|
100
|
+
}
|
|
101
|
+
buildPicker(Picker, i18n) {
|
|
102
|
+
return new Picker({
|
|
103
|
+
onEmojiSelect: this.onEmojiSelect,
|
|
104
|
+
theme: 'light',
|
|
105
|
+
dynamicWidth: true,
|
|
106
|
+
previewPosition: 'none',
|
|
107
|
+
skinTonePosition: 'none',
|
|
108
|
+
emojiSize: this.sizeValue,
|
|
109
|
+
perLine: this.perLineValue,
|
|
110
|
+
i18n
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
get middlewares() {
|
|
114
|
+
return [(0, _dom.offset)(5), (0, _dom.shift)({
|
|
115
|
+
padding: 24
|
|
116
|
+
}), (0, _dom.autoPlacement)({
|
|
117
|
+
allowedPlacements: ['top', 'bottom']
|
|
118
|
+
})];
|
|
164
119
|
}
|
|
165
|
-
}
|
|
120
|
+
}
|
|
121
|
+
exports.default = _default;
|
|
@@ -1,177 +1,112 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
2
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
7
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
-
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
9
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
10
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
14
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
1
|
import { autoPlacement, offset, shift } from '@floating-ui/dom';
|
|
18
2
|
import { Controller } from '@hotwired/stimulus';
|
|
19
3
|
import { usePopover } from '../mixins/usePopover';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_get(_getPrototypeOf(_default.prototype), "connect", this).call(this);
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "disconnect",
|
|
50
|
-
value: function disconnect() {
|
|
51
|
-
this.connected = false;
|
|
52
|
-
this.pickerLoadPromise = null;
|
|
53
|
-
this.floatingUICleanup();
|
|
54
|
-
_get(_getPrototypeOf(_default.prototype), "disconnect", this).call(this);
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "onEmojiSelect",
|
|
58
|
-
value: function onEmojiSelect(emoji) {
|
|
59
|
-
this.dispatch('selected', {
|
|
60
|
-
detail: emoji.native
|
|
61
|
-
});
|
|
62
|
-
this.hide();
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = ['button', 'popover'];
|
|
6
|
+
static values = {
|
|
7
|
+
placement: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: 'bottom-end'
|
|
10
|
+
},
|
|
11
|
+
open: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
autoPlacement: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
disabled: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 24
|
|
26
|
+
},
|
|
27
|
+
perLine: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 9
|
|
63
30
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return _loadPicker.apply(this, arguments);
|
|
98
|
-
}
|
|
99
|
-
return loadPicker;
|
|
100
|
-
}()
|
|
101
|
-
}, {
|
|
102
|
-
key: "loadPickerDependencies",
|
|
103
|
-
value: function () {
|
|
104
|
-
var _loadPickerDependencies = _asyncToGenerator(function* () {
|
|
105
|
-
var [pickerModule, i18nModule] = yield Promise.all([import( /* webpackChunkName: "webchat-emoji" */'emoji-mart'), this.loadI18n()]);
|
|
106
|
-
return {
|
|
107
|
-
Picker: pickerModule.Picker,
|
|
108
|
-
i18n: i18nModule.default || i18nModule
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
function loadPickerDependencies() {
|
|
112
|
-
return _loadPickerDependencies.apply(this, arguments);
|
|
113
|
-
}
|
|
114
|
-
return loadPickerDependencies;
|
|
115
|
-
}()
|
|
116
|
-
}, {
|
|
117
|
-
key: "loadI18n",
|
|
118
|
-
value: function loadI18n() {
|
|
119
|
-
if (Hellotext.business.locale === 'es') {
|
|
120
|
-
return import( /* webpackChunkName: "webchat-emoji-es" */'@emoji-mart/data/i18n/es.json');
|
|
121
|
-
}
|
|
122
|
-
return import( /* webpackChunkName: "webchat-emoji-en" */'@emoji-mart/data/i18n/en.json');
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "buildPicker",
|
|
126
|
-
value: function buildPicker(Picker, i18n) {
|
|
127
|
-
return new Picker({
|
|
128
|
-
onEmojiSelect: this.onEmojiSelect,
|
|
129
|
-
theme: 'light',
|
|
130
|
-
dynamicWidth: true,
|
|
131
|
-
previewPosition: 'none',
|
|
132
|
-
skinTonePosition: 'none',
|
|
133
|
-
emojiSize: this.sizeValue,
|
|
134
|
-
perLine: this.perLineValue,
|
|
135
|
-
i18n
|
|
136
|
-
});
|
|
31
|
+
};
|
|
32
|
+
initialize() {
|
|
33
|
+
this.onEmojiSelect = this.onEmojiSelect.bind(this);
|
|
34
|
+
this.pickerLoaded = false;
|
|
35
|
+
this.pickerLoadPromise = null;
|
|
36
|
+
this.connected = false;
|
|
37
|
+
super.initialize();
|
|
38
|
+
}
|
|
39
|
+
connect() {
|
|
40
|
+
this.connected = true;
|
|
41
|
+
usePopover(this);
|
|
42
|
+
this.setupFloatingUI({
|
|
43
|
+
trigger: this.buttonTarget,
|
|
44
|
+
popover: this.popoverTarget,
|
|
45
|
+
strategy: 'absolute'
|
|
46
|
+
});
|
|
47
|
+
super.connect();
|
|
48
|
+
}
|
|
49
|
+
disconnect() {
|
|
50
|
+
this.connected = false;
|
|
51
|
+
this.pickerLoadPromise = null;
|
|
52
|
+
this.floatingUICleanup();
|
|
53
|
+
super.disconnect();
|
|
54
|
+
}
|
|
55
|
+
onEmojiSelect(emoji) {
|
|
56
|
+
this.dispatch('selected', {
|
|
57
|
+
detail: emoji.native
|
|
58
|
+
});
|
|
59
|
+
this.hide();
|
|
60
|
+
}
|
|
61
|
+
onClickOutside(event) {
|
|
62
|
+
if (this.openValue && event.target.nodeType && this.element.contains(event.target) === false) {
|
|
63
|
+
this.openValue = false;
|
|
137
64
|
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
65
|
+
}
|
|
66
|
+
async onPopoverOpened() {
|
|
67
|
+
await this.loadPicker();
|
|
68
|
+
}
|
|
69
|
+
async loadPicker() {
|
|
70
|
+
if (this.pickerLoaded) return;
|
|
71
|
+
this.pickerLoadPromise ||= this.loadPickerDependencies();
|
|
72
|
+
const {
|
|
73
|
+
Picker,
|
|
74
|
+
i18n
|
|
75
|
+
} = await this.pickerLoadPromise;
|
|
76
|
+
if (!this.connected || this.pickerLoaded) return;
|
|
77
|
+
this.popoverTarget.appendChild(this.buildPicker(Picker, i18n));
|
|
78
|
+
this.pickerLoaded = true;
|
|
79
|
+
}
|
|
80
|
+
async loadPickerDependencies() {
|
|
81
|
+
const [pickerModule, i18nModule] = await Promise.all([import( /* webpackChunkName: "webchat-emoji" */'emoji-mart'), this.loadI18n()]);
|
|
82
|
+
return {
|
|
83
|
+
Picker: pickerModule.Picker,
|
|
84
|
+
i18n: i18nModule.default || i18nModule
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
loadI18n() {
|
|
88
|
+
if (Hellotext.business.locale === 'es') {
|
|
89
|
+
return import( /* webpackChunkName: "webchat-emoji-es" */'@emoji-mart/data/i18n/es.json');
|
|
146
90
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
size: {
|
|
169
|
-
type: Number,
|
|
170
|
-
default: 24
|
|
171
|
-
},
|
|
172
|
-
perLine: {
|
|
173
|
-
type: Number,
|
|
174
|
-
default: 9
|
|
91
|
+
return import( /* webpackChunkName: "webchat-emoji-en" */'@emoji-mart/data/i18n/en.json');
|
|
92
|
+
}
|
|
93
|
+
buildPicker(Picker, i18n) {
|
|
94
|
+
return new Picker({
|
|
95
|
+
onEmojiSelect: this.onEmojiSelect,
|
|
96
|
+
theme: 'light',
|
|
97
|
+
dynamicWidth: true,
|
|
98
|
+
previewPosition: 'none',
|
|
99
|
+
skinTonePosition: 'none',
|
|
100
|
+
emojiSize: this.sizeValue,
|
|
101
|
+
perLine: this.perLineValue,
|
|
102
|
+
i18n
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
get middlewares() {
|
|
106
|
+
return [offset(5), shift({
|
|
107
|
+
padding: 24
|
|
108
|
+
}), autoPlacement({
|
|
109
|
+
allowedPlacements: ['top', 'bottom']
|
|
110
|
+
})];
|
|
175
111
|
}
|
|
176
|
-
}
|
|
177
|
-
export { _default as default };
|
|
112
|
+
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Stimulus lifecycle and `usePopover` still owns the mechanics of opening and
|
|
3
3
|
// closing the popover. Keeping this policy here gives the configured behaviour
|
|
4
4
|
// value one place to translate into timers, storage gates, and cleanup.
|
|
5
|
-
export
|
|
5
|
+
export const useBehaviour = controller => {
|
|
6
6
|
Object.assign(controller, {
|
|
7
7
|
// Called from `connect` after the controller has wired channels, targets,
|
|
8
8
|
// and popover state. Even a zero-second delay goes through a timeout so the
|
|
9
9
|
// automatic open happens after the mount pass rather than during setup.
|
|
10
10
|
scheduleBehaviourOpen() {
|
|
11
11
|
if (!this.shouldAutoOpenFromBehaviour()) return;
|
|
12
|
-
|
|
12
|
+
const delay = Number(this.behaviourValue.delay_seconds || 0) * 1000;
|
|
13
13
|
this.behaviourOpenTimeout = window.setTimeout(() => {
|
|
14
14
|
this.behaviourOpenTimeout = null;
|
|
15
15
|
if (this.openValue) return;
|
|
@@ -30,7 +30,7 @@ export var useBehaviour = controller => {
|
|
|
30
30
|
// that it would be allowed. That keeps blocked, cancelled, and manually
|
|
31
31
|
// opened visits from being counted as behaviour-driven opens.
|
|
32
32
|
shouldAutoOpenFromBehaviour() {
|
|
33
|
-
|
|
33
|
+
const behaviour = this.behaviourValue;
|
|
34
34
|
if (!behaviour || behaviour.trigger !== 'on_load') return false;
|
|
35
35
|
if (behaviour.first_visit_only && localStorage.getItem(this.firstVisitKey())) {
|
|
36
36
|
return false;
|
|
@@ -55,13 +55,13 @@ export var useBehaviour = controller => {
|
|
|
55
55
|
// Records that this widget has already used its long-lived first-visit
|
|
56
56
|
// automatic open. This is the durable gate behind `first_visit_only`.
|
|
57
57
|
firstVisitKey() {
|
|
58
|
-
return
|
|
58
|
+
return `hellotext--webchat--${this.idValue}--auto-opened`;
|
|
59
59
|
},
|
|
60
60
|
// Records that this widget has already used its automatic open during the
|
|
61
61
|
// current browser session. This is the shorter-lived gate behind
|
|
62
62
|
// `once_per_session`.
|
|
63
63
|
sessionKey() {
|
|
64
|
-
return
|
|
64
|
+
return `hellotext--webchat--${this.idValue}--auto-opened-session`;
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// manages when those staged messages become visible and which ids should travel
|
|
3
3
|
// with the first customer message. It never creates a conversation or posts the
|
|
4
4
|
// staged messages by itself.
|
|
5
|
-
export
|
|
5
|
+
export const useOpeningSequence = controller => {
|
|
6
6
|
Object.assign(controller, {
|
|
7
7
|
// Called from `connect` to prepare lifecycle state before the webchat opens.
|
|
8
8
|
// The sequence may not exist on every widget, so the rest of the runtime can
|
|
@@ -37,9 +37,9 @@ export var useOpeningSequence = controller => {
|
|
|
37
37
|
// still uses a timeout so reveal work stays outside the popover-open call
|
|
38
38
|
// stack and cancellation has one consistent path.
|
|
39
39
|
playOpeningSequenceMessageAt(index) {
|
|
40
|
-
|
|
40
|
+
const message = this.openingSequenceMessages[index];
|
|
41
41
|
if (!message) return;
|
|
42
|
-
|
|
42
|
+
const delay = this.openingSequenceMessageDelay(message) * 1000;
|
|
43
43
|
this.openingSequenceTimeout = window.setTimeout(() => {
|
|
44
44
|
this.openingSequenceTimeout = null;
|
|
45
45
|
if (this.openingSequenceCancelled) return;
|
|
@@ -57,12 +57,12 @@ export var useOpeningSequence = controller => {
|
|
|
57
57
|
this.scrollOpeningSequenceToBottom();
|
|
58
58
|
},
|
|
59
59
|
recordOpeningSequenceMessage(message) {
|
|
60
|
-
|
|
60
|
+
const id = message.dataset.openingSequenceMessageId;
|
|
61
61
|
if (!id || this.revealedOpeningSequenceMessageIds.includes(id)) return;
|
|
62
62
|
this.revealedOpeningSequenceMessageIds.push(id);
|
|
63
63
|
},
|
|
64
64
|
openingSequenceMessageDelay(message) {
|
|
65
|
-
|
|
65
|
+
const delay = Number(message.dataset.delaySeconds || 0);
|
|
66
66
|
return Number.isFinite(delay) ? delay : 0;
|
|
67
67
|
},
|
|
68
68
|
scrollOpeningSequenceToBottom() {
|
|
@@ -82,7 +82,7 @@ export var useOpeningSequence = controller => {
|
|
|
82
82
|
// interrupts pending reveals so the payload cannot include later messages.
|
|
83
83
|
appendOpeningSequenceMessageIds(formData) {
|
|
84
84
|
this.cancelOpeningSequence();
|
|
85
|
-
|
|
85
|
+
const ids = this.revealedOpeningSequenceMessageIds || [];
|
|
86
86
|
ids.forEach(id => {
|
|
87
87
|
formData.append('message[opening_sequence_message_ids][]', id);
|
|
88
88
|
});
|