@bigbinary/neeto-molecules 1.7.10 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmojiPicker.js +134 -0
- package/dist/EmojiPicker.js.map +1 -0
- package/dist/EmojiReactions.js +123 -0
- package/dist/EmojiReactions.js.map +1 -0
- package/dist/ProductEmbed.js +57 -17
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/Sidebar.js +21 -7
- package/dist/Sidebar.js.map +1 -1
- package/dist/cjs/EmojiPicker.js +142 -0
- package/dist/cjs/EmojiPicker.js.map +1 -0
- package/dist/cjs/EmojiReactions.js +130 -0
- package/dist/cjs/EmojiReactions.js.map +1 -0
- package/dist/cjs/ProductEmbed.js +56 -16
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/dist/cjs/Sidebar.js +20 -6
- package/dist/cjs/Sidebar.js.map +1 -1
- package/package.json +8 -1
- package/src/translations/en.json +5 -1
- package/types/EmojiPicker.d.ts +33 -0
- package/types/EmojiReactions.d.ts +60 -0
- package/types/ProductEmbed.d.ts +1 -0
- package/types/Sidebar.d.ts +1 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import data from '@emoji-mart/data/sets/14/apple.json';
|
|
3
|
+
import Picker from '@emoji-mart/react';
|
|
4
|
+
import { SmileFaceGrey } from '@bigbinary/neeto-icons';
|
|
5
|
+
import { Dropdown } from '@bigbinary/neetoui';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
function _extends() {
|
|
9
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
10
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
11
|
+
var source = arguments[i];
|
|
12
|
+
for (var key in source) {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
|
+
target[key] = source[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
return _extends.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _arrayWithHoles(arr) {
|
|
24
|
+
if (Array.isArray(arr)) return arr;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _iterableToArrayLimit(r, l) {
|
|
28
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
29
|
+
if (null != t) {
|
|
30
|
+
var e,
|
|
31
|
+
n,
|
|
32
|
+
i,
|
|
33
|
+
u,
|
|
34
|
+
a = [],
|
|
35
|
+
f = !0,
|
|
36
|
+
o = !1;
|
|
37
|
+
try {
|
|
38
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
39
|
+
if (Object(t) !== t) return;
|
|
40
|
+
f = !1;
|
|
41
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
42
|
+
} catch (r) {
|
|
43
|
+
o = !0, n = r;
|
|
44
|
+
} finally {
|
|
45
|
+
try {
|
|
46
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
47
|
+
} finally {
|
|
48
|
+
if (o) throw n;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return a;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _arrayLikeToArray(arr, len) {
|
|
56
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
57
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
58
|
+
return arr2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
62
|
+
if (!o) return;
|
|
63
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
64
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
65
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
66
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
67
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _nonIterableRest() {
|
|
71
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _slicedToArray(arr, i) {
|
|
75
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var EmojiPicker = function EmojiPicker(_ref) {
|
|
79
|
+
var onSelect = _ref.onSelect,
|
|
80
|
+
dropdownProps = _ref.dropdownProps,
|
|
81
|
+
_ref$open = _ref.open,
|
|
82
|
+
open = _ref$open === void 0 ? false : _ref$open;
|
|
83
|
+
var _useTranslation = useTranslation(),
|
|
84
|
+
t = _useTranslation.t;
|
|
85
|
+
var _useState = useState(open),
|
|
86
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
+
isOpen = _useState2[0],
|
|
88
|
+
setIsOpen = _useState2[1];
|
|
89
|
+
var onEmojiClick = function onEmojiClick(emoji) {
|
|
90
|
+
setIsOpen(false);
|
|
91
|
+
onSelect(emoji);
|
|
92
|
+
};
|
|
93
|
+
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
94
|
+
isOpen: isOpen,
|
|
95
|
+
closeOnEsc: true,
|
|
96
|
+
appendTo: function appendTo() {
|
|
97
|
+
return document.body;
|
|
98
|
+
},
|
|
99
|
+
closeOnSelect: false,
|
|
100
|
+
dropdownProps: {
|
|
101
|
+
className: "neeto-ui-shadow-s z-10"
|
|
102
|
+
},
|
|
103
|
+
position: "bottom-start",
|
|
104
|
+
buttonProps: {
|
|
105
|
+
icon: SmileFaceGrey,
|
|
106
|
+
tooltipProps: {
|
|
107
|
+
content: t("neetoMolecules.common.emojiPicker"),
|
|
108
|
+
position: "top"
|
|
109
|
+
},
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
return setIsOpen(true);
|
|
112
|
+
},
|
|
113
|
+
style: "text"
|
|
114
|
+
},
|
|
115
|
+
onClickOutside: function onClickOutside() {
|
|
116
|
+
return setIsOpen(false);
|
|
117
|
+
},
|
|
118
|
+
onClose: function onClose() {
|
|
119
|
+
return setIsOpen(false);
|
|
120
|
+
}
|
|
121
|
+
}, dropdownProps), /*#__PURE__*/React.createElement(Picker, {
|
|
122
|
+
data: data,
|
|
123
|
+
autoFocus: true,
|
|
124
|
+
"native": true,
|
|
125
|
+
previewPosition: "none",
|
|
126
|
+
set: "apple",
|
|
127
|
+
skinTonePosition: "none",
|
|
128
|
+
theme: "light",
|
|
129
|
+
onEmojiSelect: onEmojiClick
|
|
130
|
+
}));
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { EmojiPicker as default };
|
|
134
|
+
//# sourceMappingURL=EmojiPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmojiPicker.js","sources":["../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js","../node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../src/components/EmojiPicker.jsx"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = !0,\n o = !1;\n try {\n if (i = (t = t.call(r)).next, 0 === l) {\n if (Object(t) !== t) return;\n f = !1;\n } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = !0, n = r;\n } finally {\n try {\n if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","import React, { useState } from \"react\";\n\nimport data from \"@emoji-mart/data/sets/14/apple.json\";\nimport Picker from \"@emoji-mart/react\";\nimport { SmileFaceGrey } from \"neetoicons\";\nimport { Dropdown } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { useTranslation } from \"react-i18next\";\n\nconst EmojiPicker = ({ onSelect, dropdownProps, open = false }) => {\n const { t } = useTranslation();\n const [isOpen, setIsOpen] = useState(open);\n\n const onEmojiClick = emoji => {\n setIsOpen(false);\n onSelect(emoji);\n };\n\n return (\n <Dropdown\n {...{ isOpen }}\n closeOnEsc\n appendTo={() => document.body}\n closeOnSelect={false}\n dropdownProps={{ className: \"neeto-ui-shadow-s z-10\" }}\n position=\"bottom-start\"\n buttonProps={{\n icon: SmileFaceGrey,\n tooltipProps: {\n content: t(\"neetoMolecules.common.emojiPicker\"),\n position: \"top\",\n },\n onClick: () => setIsOpen(true),\n style: \"text\",\n }}\n onClickOutside={() => setIsOpen(false)}\n onClose={() => setIsOpen(false)}\n {...dropdownProps}\n >\n <Picker\n {...{ data }}\n autoFocus\n native\n previewPosition=\"none\"\n set=\"apple\"\n skinTonePosition=\"none\"\n theme=\"light\"\n onEmojiSelect={onEmojiClick}\n />\n </Dropdown>\n );\n};\n\nEmojiPicker.propTypes = {\n /**\n * Function to be called when an emoji is selected\n */\n onSelect: PropTypes.func,\n /**\n * Props to be passed to the dropdown component.\n */\n dropdownProps: PropTypes.shape({\n strategy: PropTypes.oneOf(Object.values([\"absolute\", \"fixed\"])),\n }),\n /**\n * Whether to open the emoji picker by default or not.\n */\n open: PropTypes.bool,\n};\n\nexport default EmojiPicker;\n"],"names":["arrayLikeToArray","arrayWithHoles","iterableToArrayLimit","unsupportedIterableToArray","nonIterableRest","EmojiPicker","_ref","onSelect","dropdownProps","_ref$open","open","_useTranslation","useTranslation","t","_useState","useState","_useState2","_slicedToArray","isOpen","setIsOpen","onEmojiClick","emoji","React","createElement","Dropdown","_extends","closeOnEsc","appendTo","document","body","closeOnSelect","className","position","buttonProps","icon","SmileFaceGrey","tooltipProps","content","onClick","style","onClickO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mCAAmC,CAAC;AAC/CmB,QAAAA,QAAQ,EAAE,KAAA;OACX;MACDM,OAAO,EAAE,SAAAA,OAAA,GAAA;QAAA,OAAMnB,SAAS,CAAC,IAAI,CAAC,CAAA;AAAA,OAAA;AAC9BoB,MAAAA,KAAK,EAAE,MAAA;KACP;IACFC,cAAc,EAAE,SAAAA,cAAA,GAAA;MAAA,OAAMrB,SAAS,CAAC,KAAK,CAAC,CAAA;KAAC;IACvCsB,OAAO,EAAE,SAAAA,OAAA,GAAA;MAAA,OAAMtB,SAAS,CAAC,KAAK,CAAC,CAAA;AAAA,KAAA;AAAC,GAAA,EAC5BX,aAAa,CAEjBc,eAAAA,KAAA,CAAAC,aAAA,CAACmB,MAAM,EAAA;AACCC,IAAAA,IAAI,EAAJA,IAAI;IACVC,SAAS,EAAA,IAAA;IACT,QAAM,EAAA,IAAA;AACNC,IAAAA,eAAe,EAAC,MAAM;AACtBC,IAAAA,GAAG,EAAC,OAAO;AACXC,IAAAA,gBAAgB,EAAC,MAAM;AACvBC,IAAAA,KAAK,EAAC,OAAO;AACbC,IAAAA,aAAa,EAAE7B,YAAAA;AAAa,GAC7B,CACO,CAAC,CAAA;AAEf;;;;"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { noop } from '@bigbinary/neeto-cist';
|
|
4
|
+
import { Tooltip, Typography } from '@bigbinary/neetoui';
|
|
5
|
+
import { pluck } from 'ramda';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
|
|
8
|
+
function _arrayWithHoles(arr) {
|
|
9
|
+
if (Array.isArray(arr)) return arr;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _iterableToArrayLimit(r, l) {
|
|
13
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
14
|
+
if (null != t) {
|
|
15
|
+
var e,
|
|
16
|
+
n,
|
|
17
|
+
i,
|
|
18
|
+
u,
|
|
19
|
+
a = [],
|
|
20
|
+
f = !0,
|
|
21
|
+
o = !1;
|
|
22
|
+
try {
|
|
23
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
24
|
+
if (Object(t) !== t) return;
|
|
25
|
+
f = !1;
|
|
26
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
27
|
+
} catch (r) {
|
|
28
|
+
o = !0, n = r;
|
|
29
|
+
} finally {
|
|
30
|
+
try {
|
|
31
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
32
|
+
} finally {
|
|
33
|
+
if (o) throw n;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return a;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _arrayLikeToArray(arr, len) {
|
|
41
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
42
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
43
|
+
return arr2;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
47
|
+
if (!o) return;
|
|
48
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
49
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
51
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
52
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _nonIterableRest() {
|
|
56
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function _slicedToArray(arr, i) {
|
|
60
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var groupBy = function groupBy(objectArray, groupKey) {
|
|
64
|
+
return objectArray.reduce(function (data, obj) {
|
|
65
|
+
(data[obj[groupKey]] = data[obj[groupKey]] || []).push(obj);
|
|
66
|
+
return data;
|
|
67
|
+
}, {});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var EmojiReactions = function EmojiReactions(_ref) {
|
|
71
|
+
var isUpdating = _ref.isUpdating,
|
|
72
|
+
reactions = _ref.reactions,
|
|
73
|
+
_ref$onReactionClick = _ref.onReactionClick,
|
|
74
|
+
onReactionClick = _ref$onReactionClick === void 0 ? noop : _ref$onReactionClick,
|
|
75
|
+
_ref$emojiSize = _ref.emojiSize,
|
|
76
|
+
emojiSize = _ref$emojiSize === void 0 ? "text-sm" : _ref$emojiSize,
|
|
77
|
+
_ref$emojiBoxStyle = _ref.emojiBoxStyle,
|
|
78
|
+
emojiBoxStyle = _ref$emojiBoxStyle === void 0 ? "neeto-ui-bg-white py-1 px-2" : _ref$emojiBoxStyle;
|
|
79
|
+
var _useTranslation = useTranslation(),
|
|
80
|
+
t = _useTranslation.t;
|
|
81
|
+
var groupedReactions = useMemo(function () {
|
|
82
|
+
return groupBy(reactions || [], "unified");
|
|
83
|
+
}, [reactions]);
|
|
84
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, Object.entries(groupedReactions).map(function (_ref2) {
|
|
85
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
86
|
+
unified = _ref3[0],
|
|
87
|
+
grouped = _ref3[1];
|
|
88
|
+
var groupedNames = pluck("userName", reactions).join(", ");
|
|
89
|
+
var reaction = grouped[0];
|
|
90
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
91
|
+
key: unified,
|
|
92
|
+
position: "top",
|
|
93
|
+
content: /*#__PURE__*/React.createElement("div", {
|
|
94
|
+
className: "flex flex-col items-center justify-center"
|
|
95
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
96
|
+
className: "neeto-ui-bg-white neeto-ui-rounded mb-1 flex h-10 w-10 items-center justify-center"
|
|
97
|
+
}, reaction["native"]), /*#__PURE__*/React.createElement("p", {
|
|
98
|
+
className: "text-center text-xs"
|
|
99
|
+
}, t("neetoMolecules.reactions.content", {
|
|
100
|
+
groupedNames: groupedNames
|
|
101
|
+
})))
|
|
102
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
"data-cy": "emoji-reactions-".concat(reaction.unified),
|
|
104
|
+
className: classNames(["neeto-ui-rounded-full hover:neeto-ui-bg-gray-100 neeto-ui-bg-gray-100 flex cursor-pointer items-center justify-center px-2 py-1", emojiBoxStyle], {
|
|
105
|
+
"opacity-80": isUpdating
|
|
106
|
+
}),
|
|
107
|
+
onClick: function onClick() {
|
|
108
|
+
return !isUpdating && onReactionClick({
|
|
109
|
+
"native": reaction["native"],
|
|
110
|
+
unified: reaction.unified
|
|
111
|
+
}, grouped);
|
|
112
|
+
}
|
|
113
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
114
|
+
className: "space-x-2 text-sm",
|
|
115
|
+
style: "body2"
|
|
116
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
117
|
+
className: emojiSize
|
|
118
|
+
}, reaction["native"]), /*#__PURE__*/React.createElement("span", null, grouped.length))));
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { EmojiReactions as default };
|
|
123
|
+
//# sourceMappingURL=EmojiReactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmojiReactions.js","sources":["../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js","../node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../src/components/EmojiReactions/utils.js","../src/components/EmojiReactions/index.jsx"],"sourcesContent":["export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = !0,\n o = !1;\n try {\n if (i = (t = t.call(r)).next, 0 === l) {\n if (Object(t) !== t) return;\n f = !1;\n } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = !0, n = r;\n } finally {\n try {\n if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export const groupBy = (objectArray, groupKey) =>\n objectArray.reduce((data, obj) => {\n (data[obj[groupKey]] = data[obj[groupKey]] || []).push(obj);\n\n return data;\n }, {});\n","import React, { useMemo } from \"react\";\n\nimport classNames from \"classnames\";\nimport { noop } from \"neetocist\";\nimport { Tooltip, Typography } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { pluck } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { groupBy } from \"./utils\";\n\nconst EmojiReactions = ({\n isUpdating,\n reactions,\n onReactionClick = noop,\n emojiSize = \"text-sm\",\n emojiBoxStyle = \"neeto-ui-bg-white py-1 px-2\",\n}) => {\n const { t } = useTranslation();\n const groupedReactions = useMemo(\n () => groupBy(reactions || [], \"unified\"),\n [reactions]\n );\n\n return (\n <>\n {Object.entries(groupedReactions).map(([unified, grouped]) => {\n const groupedNames = pluck(\"userName\", reactions).join(\", \");\n const reaction = grouped[0];\n\n return (\n <Tooltip\n key={unified}\n position=\"top\"\n content={\n <div className=\"flex flex-col items-center justify-center\">\n <div className=\"neeto-ui-bg-white neeto-ui-rounded mb-1 flex h-10 w-10 items-center justify-center\">\n {reaction.native}\n </div>\n <p className=\"text-center text-xs\">\n {t(\"neetoMolecules.reactions.content\", { groupedNames })}\n </p>\n </div>\n }\n >\n <div\n data-cy={`emoji-reactions-${reaction.unified}`}\n className={classNames(\n [\n \"neeto-ui-rounded-full hover:neeto-ui-bg-gray-100 neeto-ui-bg-gray-100 flex cursor-pointer items-center justify-center px-2 py-1\",\n emojiBoxStyle,\n ],\n { \"opacity-80\": isUpdating }\n )}\n onClick={() =>\n !isUpdating &&\n onReactionClick(\n {\n native: reaction.native,\n unified: reaction.unified,\n },\n grouped\n )\n }\n >\n <Typography className=\"space-x-2 text-sm\" style=\"body2\">\n <span className={emojiSize}>{reaction.native}</span>\n <span>{grouped.length}</span>\n </Typography>\n </div>\n </Tooltip>\n );\n })}\n </>\n );\n};\n\nEmojiReactions.propTypes = {\n /**\n * Array of reactions to be displayed\n */\n reactions: PropTypes.arrayOf(\n PropTypes.shape({\n native: PropTypes.string,\n unified: PropTypes.string,\n userName: PropTypes.string,\n })\n ),\n /**\n * Callback function to be called when user click on an existing reaction\n */\n onReactionClick: PropTypes.func,\n /**\n * Size of the emoji\n */\n emojiSize: PropTypes.string,\n /**\n * Emoji picker box style\n */\n emojiBoxStyle: PropTypes.string,\n /**\n * Use this flag to block click action while backend is updating.\n */\n isUpdating: PropTypes.bool,\n};\n\nexport default EmojiReactions;\n"],"names":["arrayLikeToArray","arrayWithHoles","iterableToArrayLimit","unsupportedIterableToArray","nonIterableRest","groupBy","objectArray","groupKey","reduce","data","obj","push","EmojiReactions","_ref","isUpdating","reactions","_ref$onReactionClick","onReactionClick","noop","_ref$emojiSize","emojiSize","_ref$emojiBoxStyle","emojiBoxStyle","_useTranslation","useTranslation","t","groupedReactions","useMemo","React","createElement","Fragment","Object","entries","map","_ref2","_ref3","_slicedToArray","unified","grouped","groupedNames","pluck","join","reaction","Tooltip","key","position","content","className","concat","classNames","onClick","Typography","style","length"],"mappings":";;;;;;;AAAe,SAAS,eAAe,CAAC,GAAG,EAAE;AAC7C,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC;AACrC;;ACFe,SAAS,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE;AACpD,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,GAAG,WAAW,IAAI,OAAO,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;AACnG,EAAE,IAAI,IAAI,IAAI,CAAC,EAAE;AACjB,IAAI,IAAI,CAAC;AACT,MAAM,CAAC;AACP,MAAM,CAAC;AACP,MAAM,CAAC;AACP,MAAM,CAAC,GAAG,EAA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OAAO,EAAE,SAAAA,OAAA,GAAA;AAAA,QAAA,OACP,CAACpC,UAAU,IACXG,eAAe,CACb;AACE,UAAA,QAAA,EAAQyB,QAAQ,CAAO,QAAA,CAAA;UACvBL,OAAO,EAAEK,QAAQ,CAACL,OAAAA;SACnB,EACDC,OACF,CAAC,CAAA;AAAA,OAAA;AACF,KAAA,eAEDV,KAAA,CAAAC,aAAA,CAACsB,UAAU,EAAA;AAACJ,MAAAA,SAAS,EAAC,mBAAmB;AAACK,MAAAA,KAAK,EAAC,OAAA;KAC9CxB,eAAAA,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMkB,MAAAA,SAAS,EAAE3B,SAAAA;AAAU,KAAA,EAAEsB,QAAQ,CAAA,QAAA,CAAc,CAAC,eACpDd,KAAA,CAAAC,aAAA,CAAOS,MAAAA,EAAAA,IAAAA,EAAAA,OAAO,CAACe,MAAa,CAClB,CACT,CACE,CAAC,CAAA;AAEd,GAAC,CACD,CAAC,CAAA;AAEP;;;;"}
|
package/dist/ProductEmbed.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { Code as Code$1, Eye, Info, LeftArrow } from '@bigbinary/neeto-icons';
|
|
4
4
|
import { Typography, Callout, Input, Checkbox, Select, Label, ColorPicker, Tab, Radio, Button, Spinner } from '@bigbinary/neetoui';
|
|
5
|
-
import { mergeDeepLeft, mergeLeft } from 'ramda';
|
|
5
|
+
import { mergeDeepLeft, toPairs, mergeLeft } from 'ramda';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import Codeblock from '@bigbinary/neeto-molecules/Codeblock';
|
|
8
8
|
import { t as t$1 } from 'i18next';
|
|
@@ -554,39 +554,76 @@ var embedBaseScript = function embedBaseScript(embedScriptLink) {
|
|
|
554
554
|
var embedEnv = function embedEnv() {
|
|
555
555
|
return globalProps.railsEnv !== "production" ? "\n\t env: \"".concat(globalProps.railsEnv, "\",") : "";
|
|
556
556
|
};
|
|
557
|
-
var
|
|
557
|
+
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
558
|
+
return toPairs(extraArgs).map(function (_ref) {
|
|
559
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
560
|
+
key = _ref2[0],
|
|
561
|
+
value = _ref2[1];
|
|
562
|
+
return "\n\t ".concat(key, ": \"").concat(value, "\"");
|
|
563
|
+
});
|
|
564
|
+
};
|
|
565
|
+
var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
566
|
+
var customization = _ref3.customization,
|
|
567
|
+
id = _ref3.id,
|
|
568
|
+
embedScriptLink = _ref3.embedScriptLink,
|
|
569
|
+
extraArgs = _ref3.extraArgs;
|
|
558
570
|
var elementSelector = customization.elementSelector,
|
|
559
571
|
_customization$width = customization.width,
|
|
560
572
|
width = _customization$width === void 0 ? 100 : _customization$width,
|
|
561
573
|
_customization$height = customization.height,
|
|
562
574
|
height = _customization$height === void 0 ? 100 : _customization$height;
|
|
563
|
-
return "\n <!-- ".concat(globalProps.appName, " inline embed code begins -->\n <div style=\"min-width: 90vw; height: 90vh;\" id=\"").concat(elementSelector, "\">\n <!-- ").concat(globalProps.appName, " widget will be added here -->\n </div>\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: { height: \"").concat(height, "%\", width: \"").concat(width, "%\"},").concat(embedEnv(), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
|
|
575
|
+
return "\n <!-- ".concat(globalProps.appName, " inline embed code begins -->\n <div style=\"min-width: 90vw; height: 90vh;\" id=\"").concat(elementSelector, "\">\n <!-- ").concat(globalProps.appName, " widget will be added here -->\n </div>\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: { height: \"").concat(height, "%\", width: \"").concat(width, "%\"},").concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
|
|
564
576
|
};
|
|
565
|
-
var floatingPopupEmbedCode = function floatingPopupEmbedCode(
|
|
577
|
+
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
578
|
+
var customization = _ref4.customization,
|
|
579
|
+
id = _ref4.id,
|
|
580
|
+
embedScriptLink = _ref4.embedScriptLink,
|
|
581
|
+
extraArgs = _ref4.extraArgs;
|
|
566
582
|
var btnTextColor = customization.btnTextColor,
|
|
567
583
|
showIcon = customization.showIcon,
|
|
568
584
|
btnText = customization.btnText,
|
|
569
585
|
btnPosition = customization.btnPosition,
|
|
570
586
|
btnColor = customization.btnColor,
|
|
571
587
|
icon = customization.icon;
|
|
572
|
-
return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\", ").concat(icon ? "\n\t\tshowIcon: ".concat(showIcon, ",") : "", "\n },").concat(embedEnv(), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
|
|
588
|
+
return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\", ").concat(icon ? "\n\t\tshowIcon: ".concat(showIcon, ",") : "", "\n },").concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
|
|
573
589
|
};
|
|
574
|
-
var elementPopupEmbedCode = function elementPopupEmbedCode(
|
|
590
|
+
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
591
|
+
var customization = _ref5.customization,
|
|
592
|
+
id = _ref5.id,
|
|
593
|
+
embedScriptLink = _ref5.embedScriptLink,
|
|
594
|
+
extraArgs = _ref5.extraArgs;
|
|
575
595
|
var elementSelector = customization.elementSelector;
|
|
576
|
-
return "\n <!-- ".concat(globalProps.appName, " element-click embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedEnv(), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
|
|
596
|
+
return "\n <!-- ".concat(globalProps.appName, " element-click embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(globalProps.appName, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
|
|
577
597
|
};
|
|
578
|
-
var embedCode = function embedCode(
|
|
579
|
-
var type =
|
|
580
|
-
customization =
|
|
581
|
-
id =
|
|
582
|
-
embedScriptLink =
|
|
598
|
+
var embedCode = function embedCode(_ref6) {
|
|
599
|
+
var type = _ref6.type,
|
|
600
|
+
customization = _ref6.customization,
|
|
601
|
+
id = _ref6.id,
|
|
602
|
+
embedScriptLink = _ref6.embedScriptLink,
|
|
603
|
+
_ref6$extraArgs = _ref6.extraArgs,
|
|
604
|
+
extraArgs = _ref6$extraArgs === void 0 ? {} : _ref6$extraArgs;
|
|
583
605
|
switch (type) {
|
|
584
606
|
case "inline":
|
|
585
|
-
return inlineEmbedCode(
|
|
607
|
+
return inlineEmbedCode({
|
|
608
|
+
customization: customization,
|
|
609
|
+
id: id,
|
|
610
|
+
embedScriptLink: embedScriptLink,
|
|
611
|
+
extraArgs: extraArgs
|
|
612
|
+
});
|
|
586
613
|
case "floatingPopup":
|
|
587
|
-
return floatingPopupEmbedCode(
|
|
614
|
+
return floatingPopupEmbedCode({
|
|
615
|
+
customization: customization,
|
|
616
|
+
id: id,
|
|
617
|
+
embedScriptLink: embedScriptLink,
|
|
618
|
+
extraArgs: extraArgs
|
|
619
|
+
});
|
|
588
620
|
case "elementPopup":
|
|
589
|
-
return elementPopupEmbedCode(
|
|
621
|
+
return elementPopupEmbedCode({
|
|
622
|
+
customization: customization,
|
|
623
|
+
id: id,
|
|
624
|
+
embedScriptLink: embedScriptLink,
|
|
625
|
+
extraArgs: extraArgs
|
|
626
|
+
});
|
|
590
627
|
default:
|
|
591
628
|
return "";
|
|
592
629
|
}
|
|
@@ -608,7 +645,9 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
608
645
|
goBackLink = _ref$goBackLink === void 0 ? "" : _ref$goBackLink,
|
|
609
646
|
id = _ref.id,
|
|
610
647
|
_ref$options = _ref.options,
|
|
611
|
-
options = _ref$options === void 0 ? {} : _ref$options
|
|
648
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
649
|
+
_ref$extraArgs = _ref.extraArgs,
|
|
650
|
+
extraArgs = _ref$extraArgs === void 0 ? {} : _ref$extraArgs;
|
|
612
651
|
var _useState = useState(true),
|
|
613
652
|
_useState2 = _slicedToArray(_useState, 2),
|
|
614
653
|
isScriptLoading = _useState2[0],
|
|
@@ -634,7 +673,8 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
634
673
|
id: id,
|
|
635
674
|
type: selectedOption,
|
|
636
675
|
customization: customizations[selectedOption],
|
|
637
|
-
embedScriptLink: embedScriptLink
|
|
676
|
+
embedScriptLink: embedScriptLink,
|
|
677
|
+
extraArgs: extraArgs
|
|
638
678
|
});
|
|
639
679
|
var loadScript = function loadScript() {
|
|
640
680
|
var script = document.createElement("script");
|