UNPKG

@lobehub/fluent-emoji

Version:

Fluent Emoji are a collection of familiar, friendly, and modern emoji from Microsoft

108 lines 4.51 kB
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import emojilib from '@lobehub/emojilib'; import { FluentEmoji, getFluentEmojiCDN } from "./.."; import { SearchBar } from '@lobehub/ui'; import { Segmented } from 'antd'; import { useTheme } from 'antd-style'; import { memo, useMemo, useState } from 'react'; import { Flexbox } from 'react-layout-kit'; import EmojiItem from "./EmojiItem"; import VirtuosoGridList from "./VirtuosoGridList"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; var Dashboard = /*#__PURE__*/memo(function () { var theme = useTheme(); var _useState = useState('3d'), _useState2 = _slicedToArray(_useState, 2), type = _useState2[0], setType = _useState2[1]; var _useState3 = useState(), _useState4 = _slicedToArray(_useState3, 2), keyword = _useState4[0], setKeyword = _useState4[1]; var list = useMemo(function () { if (!keyword) return Object.entries(emojilib); return Object.entries(emojilib).filter(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), emoji = _ref2[0], name = _ref2[1]; return emoji.includes(keyword) || name.toLowerCase().includes(keyword.toLowerCase()); }); }, [keyword]); return /*#__PURE__*/_jsxs(Flexbox, { gap: 16, style: { maxWidth: 960 }, width: '100%', children: [/*#__PURE__*/_jsxs(Flexbox, { align: 'center', gap: 12, horizontal: true, children: [/*#__PURE__*/_jsx(SearchBar, { defaultValue: keyword, onSearch: function onSearch(v) { return setKeyword(v); }, placeholder: 'Search by emoji keywords...', style: { width: '100%' }, type: 'block' }), /*#__PURE__*/_jsx(Segmented, { defaultValue: type, onChange: function onChange(v) { return setType(v); }, options: [{ label: 'Mono', value: 'mono' }, { label: 'Flat', value: 'flat' }, { label: 'Modern', value: 'modern' }, { label: '3D', value: '3d' }, { label: 'Anim', value: 'anim' }], style: { border: "1px solid ".concat(theme.colorBorder) } })] }), /*#__PURE__*/_jsx(VirtuosoGridList, { data: list, initialItemCount: 24, itemContent: function itemContent(_, _ref3) { var _ref4 = _slicedToArray(_ref3, 2), emoji = _ref4[0], name = _ref4[1]; return /*#__PURE__*/_jsx(EmojiItem, { emoji: emoji, title: name, url: getFluentEmojiCDN(emoji, { type: type }), children: /*#__PURE__*/_jsx(FluentEmoji, { emoji: emoji, size: 56, type: type }, name) }, name); }, style: { minHeight: '1050px' } })] }); }); export default Dashboard;