@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
41 lines (38 loc) • 1.78 kB
JavaScript
import { __awaiter, __generator } from 'tslib';
import { EmoticonItem } from '../../EmoticonItem/EmoticonItem.js';
import { SearchIndex } from 'emoji-mart';
import lodash_first from '../../../node_modules/.pnpm/lodash.first@3.0.0/node_modules/lodash.first/index.js';
var useEmojiTrigger = function () {
return {
component: EmoticonItem,
dataProvider: function (query, _, onReady) { return __awaiter(void 0, void 0, void 0, function () {
var emojis, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (query.length === 0 || query.charAt(0).match(/[^a-zA-Z0-9+-]/)) {
return [2 /*return*/, []];
}
return [4 /*yield*/, (SearchIndex === null || SearchIndex === void 0 ? void 0 : SearchIndex.search(query))];
case 1:
emojis = (_a.sent()) || [];
console.log('emojis: ', emojis, query);
result = emojis.filter(Boolean).slice(0, /* TODO themeVersion === '2' ? 7 : */ 10);
if (onReady)
onReady(result, query);
return [2 /*return*/, result];
}
});
}); },
output: function (entity) {
var _a, _b;
return ({
caretPosition: 'next',
key: entity.id,
text: (_b = (_a = lodash_first(entity.skins)) === null || _a === void 0 ? void 0 : _a.native) !== null && _b !== void 0 ? _b : entity.name,
});
},
};
};
export { useEmojiTrigger };
//# sourceMappingURL=useEmojiTrigger.js.map