@hellotext/hellotext 1.8.4 → 1.8.5

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.
Files changed (49) hide show
  1. package/__tests__/core/configuration/webchat_test.js +163 -0
  2. package/__tests__/hellotext_test.js +97 -101
  3. package/dist/hellotext.js +1 -1
  4. package/docs/webchat.md +101 -0
  5. package/jest.config.js +1 -0
  6. package/jest.setup.js +9 -0
  7. package/lib/api/index.js +6 -0
  8. package/lib/api/web_chat/messages.js +74 -0
  9. package/lib/api/web_chats.js +53 -0
  10. package/lib/api/webchat/messages.js +85 -0
  11. package/lib/api/webchats.js +53 -0
  12. package/lib/builders/logo_builder.js +2 -1
  13. package/lib/channels/application_channel.js +68 -0
  14. package/lib/channels/web_chat_channel.js +97 -0
  15. package/lib/channels/webchat_channel.js +112 -0
  16. package/lib/controllers/mixins/usePopover.js +61 -0
  17. package/lib/controllers/web_chat/pagination_controller.js +81 -0
  18. package/lib/controllers/webchat/emoji_picker_controller.js +134 -0
  19. package/lib/controllers/webchat_controller.js +446 -0
  20. package/lib/core/configuration/web_chat.js +168 -0
  21. package/lib/core/configuration/webchat.js +185 -0
  22. package/lib/core/configuration.js +6 -1
  23. package/lib/core/event.js +1 -1
  24. package/lib/hellotext.js +18 -9
  25. package/lib/index.js +4 -0
  26. package/lib/models/business.js +9 -1
  27. package/lib/models/index.js +7 -0
  28. package/lib/models/web_chat.js +51 -0
  29. package/lib/models/webchat.js +51 -0
  30. package/package.json +8 -7
  31. package/src/api/index.js +5 -0
  32. package/src/api/webchat/messages.js +55 -0
  33. package/src/api/webchats.js +30 -0
  34. package/src/builders/logo_builder.js +8 -4
  35. package/src/channels/application_channel.js +45 -0
  36. package/src/channels/webchat_channel.js +77 -0
  37. package/src/controllers/mixins/usePopover.js +50 -0
  38. package/src/controllers/webchat/emoji_picker_controller.js +82 -0
  39. package/src/controllers/webchat_controller.js +448 -0
  40. package/src/core/configuration/webchat.js +176 -0
  41. package/src/core/configuration.js +5 -0
  42. package/src/core/event.js +10 -1
  43. package/src/hellotext.js +7 -2
  44. package/src/index.js +5 -0
  45. package/src/models/business.js +11 -1
  46. package/src/models/index.js +1 -0
  47. package/src/models/webchat.js +28 -0
  48. package/styles/index.css +4 -0
  49. package/webpack.config.js +1 -1
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _application_channel = _interopRequireDefault(require("./application_channel"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+ 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); } }
11
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ 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); }
14
+ 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); }
15
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
16
+ 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); }
17
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+ 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); }; }
19
+ 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); }
20
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
+ 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; } }
22
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
+ var WebchatChannel = /*#__PURE__*/function (_ApplicationChannel) {
24
+ _inherits(WebchatChannel, _ApplicationChannel);
25
+ var _super = _createSuper(WebchatChannel);
26
+ function WebchatChannel(id, session, conversation) {
27
+ var _this;
28
+ _classCallCheck(this, WebchatChannel);
29
+ _this = _super.call(this);
30
+ _this.id = id;
31
+ _this.session = session;
32
+ _this.conversation = conversation;
33
+ _this.subscribe();
34
+ return _this;
35
+ }
36
+ _createClass(WebchatChannel, [{
37
+ key: "subscribe",
38
+ value: function subscribe() {
39
+ var params = {
40
+ channel: "WebchatChannel",
41
+ id: this.id,
42
+ session: this.session,
43
+ conversation: this.conversation
44
+ };
45
+ this.send({
46
+ command: 'subscribe',
47
+ identifier: params
48
+ });
49
+ }
50
+ }, {
51
+ key: "unsubscribe",
52
+ value: function unsubscribe() {
53
+ var params = {
54
+ channel: "WebchatChannel",
55
+ id: this.id,
56
+ session: this.session,
57
+ conversation: this.conversation
58
+ };
59
+ this.send({
60
+ command: 'unsubscribe',
61
+ identifier: params
62
+ });
63
+ }
64
+ }, {
65
+ key: "onMessage",
66
+ value: function onMessage(callback) {
67
+ _get(_getPrototypeOf(WebchatChannel.prototype), "onMessage", this).call(this, message => {
68
+ if (message.type !== 'message') return;
69
+ callback(message);
70
+ });
71
+ }
72
+ }, {
73
+ key: "onConversationAssignment",
74
+ value: function onConversationAssignment(callback) {
75
+ _get(_getPrototypeOf(WebchatChannel.prototype), "onMessage", this).call(this, message => {
76
+ if (message.type === 'conversation.assigned') {
77
+ callback(message);
78
+ }
79
+ });
80
+ }
81
+ }, {
82
+ key: "onAgentOnline",
83
+ value: function onAgentOnline(callback) {
84
+ _get(_getPrototypeOf(WebchatChannel.prototype), "onMessage", this).call(this, message => {
85
+ if (message.type === 'agent_is_online') {
86
+ callback(message);
87
+ }
88
+ });
89
+ }
90
+ }, {
91
+ key: "onReaction",
92
+ value: function onReaction(callback) {
93
+ _get(_getPrototypeOf(WebchatChannel.prototype), "onMessage", this).call(this, message => {
94
+ if (message.type === 'reaction.create' || message.type === 'reaction.destroy') {
95
+ callback(message);
96
+ }
97
+ });
98
+ }
99
+ }, {
100
+ key: "updateSubscriptionWith",
101
+ value: function updateSubscriptionWith(conversation) {
102
+ this.unsubscribe();
103
+ setTimeout(() => {
104
+ this.conversation = conversation;
105
+ this.subscribe();
106
+ }, 1000);
107
+ }
108
+ }]);
109
+ return WebchatChannel;
110
+ }(_application_channel.default);
111
+ var _default = WebchatChannel;
112
+ exports.default = _default;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePopover = void 0;
7
+ var _dom = require("@floating-ui/dom");
8
+ var _hellotext = _interopRequireDefault(require("../../hellotext"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ var usePopover = controller => {
11
+ Object.assign(controller, {
12
+ show() {
13
+ this.openValue = true;
14
+ },
15
+ hide() {
16
+ this.openValue = false;
17
+ },
18
+ toggle() {
19
+ this.openValue = !this.openValue;
20
+ },
21
+ setupFloatingUI(_ref) {
22
+ var {
23
+ trigger,
24
+ popover
25
+ } = _ref;
26
+ this.floatingUICleanup = (0, _dom.autoUpdate)(trigger, popover, () => {
27
+ (0, _dom.computePosition)(trigger, popover, {
28
+ placement: this.placementValue,
29
+ middleware: this.middlewares
30
+ }).then(_ref2 => {
31
+ var {
32
+ x,
33
+ y
34
+ } = _ref2;
35
+ var newStyle = {
36
+ left: "".concat(x, "px"),
37
+ top: "".concat(y, "px")
38
+ };
39
+ Object.assign(popover.style, newStyle);
40
+ });
41
+ });
42
+ },
43
+ openValueChanged() {
44
+ if (this.disabledValue) return;
45
+ if (this.openValue) {
46
+ this.popoverTarget.showPopover();
47
+ this.popoverTarget.setAttribute("aria-expanded", "true");
48
+ if (this['onPopoverOpened']) {
49
+ this.onPopoverOpened();
50
+ }
51
+ } else {
52
+ this.popoverTarget.hidePopover();
53
+ this.popoverTarget.removeAttribute("aria-expanded");
54
+ if (this['onPopoverClosed']) {
55
+ this.onPopoverClosed();
56
+ }
57
+ }
58
+ }
59
+ });
60
+ };
61
+ exports.usePopover = usePopover;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _stimulus = require("@hotwired/stimulus");
8
+ var _core = require("../../core");
9
+ var _hellotext = _interopRequireDefault(require("../../hellotext"));
10
+ var _messages = _interopRequireDefault(require("../../api/web_chat/messages"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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); } }
13
+ 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); }); }; }
14
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
+ 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); } }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
+ 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); }
19
+ 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); }
20
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
21
+ 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); }
22
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
+ 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); }; }
24
+ 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); }
25
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
+ 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; } }
27
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
+ var _default = /*#__PURE__*/function (_Controller) {
29
+ _inherits(_default, _Controller);
30
+ var _super = _createSuper(_default);
31
+ function _default() {
32
+ _classCallCheck(this, _default);
33
+ return _super.apply(this, arguments);
34
+ }
35
+ _createClass(_default, [{
36
+ key: "initialize",
37
+ value: function initialize() {
38
+ this.messagesAPI = new _messages.default(_core.Configuration.webChat.id);
39
+ this.onScroll = this.onScroll.bind(this);
40
+ _get(_getPrototypeOf(_default.prototype), "initialize", this).call(this);
41
+ }
42
+ }, {
43
+ key: "connect",
44
+ value: function connect() {
45
+ this.scrollableTarget.addEventListener('scroll', this.onScroll);
46
+ _get(_getPrototypeOf(_default.prototype), "connect", this).call(this);
47
+ }
48
+ }, {
49
+ key: "disconnect",
50
+ value: function disconnect() {
51
+ this.scrollableTarget.removeEventListener('scroll', this.onScroll);
52
+ _get(_getPrototypeOf(_default.prototype), "disconnect", this).call(this);
53
+ }
54
+ }, {
55
+ key: "onScroll",
56
+ value: function () {
57
+ var _onScroll = _asyncToGenerator(function* () {
58
+ if (this.scrollableTarget.scrollTop > 300 || !this.nextPageValue) return;
59
+ console.log('fetching....');
60
+ var response = yield this.messagesAPI.index({
61
+ page: this.nextPageValue,
62
+ session: _hellotext.default.session
63
+ });
64
+ console.log(yield response.json());
65
+ });
66
+ function onScroll() {
67
+ return _onScroll.apply(this, arguments);
68
+ }
69
+ return onScroll;
70
+ }()
71
+ }]);
72
+ return _default;
73
+ }(_stimulus.Controller);
74
+ exports.default = _default;
75
+ _default.values = {
76
+ nextPage: {
77
+ type: Number,
78
+ default: undefined
79
+ }
80
+ };
81
+ _default.targets = ['scrollable'];
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _stimulus = require("@hotwired/stimulus");
8
+ var _dom = require("@floating-ui/dom");
9
+ var _emojiMart = require("emoji-mart");
10
+ var _usePopover = require("../mixins/usePopover");
11
+ 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); } }
12
+ 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); }); }; }
13
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
+ 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); } }
15
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
+ 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); }
18
+ 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); }
19
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
20
+ 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); }
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
+ 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); }; }
23
+ 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); }
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+ 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; } }
26
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
27
+ var _default = /*#__PURE__*/function (_Controller) {
28
+ _inherits(_default, _Controller);
29
+ var _super = _createSuper(_default);
30
+ function _default() {
31
+ _classCallCheck(this, _default);
32
+ return _super.apply(this, arguments);
33
+ }
34
+ _createClass(_default, [{
35
+ key: "initialize",
36
+ value: function initialize() {
37
+ this.onEmojiSelect = this.onEmojiSelect.bind(this);
38
+ _get(_getPrototypeOf(_default.prototype), "initialize", this).call(this);
39
+ }
40
+ }, {
41
+ key: "connect",
42
+ value: function connect() {
43
+ (0, _usePopover.usePopover)(this);
44
+ this.setupFloatingUI({
45
+ trigger: this.buttonTarget,
46
+ popover: this.popoverTarget
47
+ });
48
+ this.popoverTarget.appendChild(this.pickerObject);
49
+ _get(_getPrototypeOf(_default.prototype), "connect", this).call(this);
50
+ }
51
+ }, {
52
+ key: "disconnect",
53
+ value: function disconnect() {
54
+ this.floatingUICleanup();
55
+ _get(_getPrototypeOf(_default.prototype), "disconnect", this).call(this);
56
+ }
57
+ }, {
58
+ key: "onEmojiSelect",
59
+ value: function onEmojiSelect(emoji) {
60
+ this.dispatch('selected', {
61
+ detail: emoji.native
62
+ });
63
+ this.hide();
64
+ }
65
+ }, {
66
+ key: "onClickOutside",
67
+ value: function onClickOutside(event) {
68
+ if (this.openValue && event.target.nodeType && this.element.contains(event.target) === false) {
69
+ this.openValue = false;
70
+ }
71
+ }
72
+ }, {
73
+ key: "pickerObject",
74
+ get: function get() {
75
+ return new _emojiMart.Picker({
76
+ onEmojiSelect: this.onEmojiSelect,
77
+ theme: 'light',
78
+ dynamicWidth: true,
79
+ previewPosition: 'none',
80
+ skinTonePosition: 'none',
81
+ emojiSize: this.sizeValue,
82
+ perLine: this.perLineValue,
83
+ data: function () {
84
+ var _data = _asyncToGenerator(function* () {
85
+ var response = yield fetch('https://cdn.jsdelivr.net/npm/@emoji-mart/data');
86
+ return response.json();
87
+ });
88
+ function data() {
89
+ return _data.apply(this, arguments);
90
+ }
91
+ return data;
92
+ }()
93
+ });
94
+ }
95
+ }, {
96
+ key: "middlewares",
97
+ get: function get() {
98
+ return [(0, _dom.offset)(5), (0, _dom.shift)({
99
+ padding: 24
100
+ }), (0, _dom.autoPlacement)({
101
+ allowedPlacements: ['top', 'bottom']
102
+ })];
103
+ }
104
+ }]);
105
+ return _default;
106
+ }(_stimulus.Controller);
107
+ exports.default = _default;
108
+ _default.targets = ['button', 'popover'];
109
+ _default.values = {
110
+ placement: {
111
+ type: String,
112
+ default: "bottom-end"
113
+ },
114
+ open: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ autoPlacement: {
119
+ type: Boolean,
120
+ default: false
121
+ },
122
+ disabled: {
123
+ type: Boolean,
124
+ default: false
125
+ },
126
+ size: {
127
+ type: Number,
128
+ default: 24
129
+ },
130
+ perLine: {
131
+ type: Number,
132
+ default: 9
133
+ }
134
+ };