1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 | var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11 | };
|
12 | var _DuoyunIconsElement_onCopy;
|
13 | import { adoptedStyle, customElement } from '@mantou/gem/lib/decorators';
|
14 | import { GemElement, html } from '@mantou/gem/lib/element';
|
15 | import { createCSSSheet, css } from '@mantou/gem/lib/utils';
|
16 | import { icons } from '../lib/icons';
|
17 | import { theme } from '../lib/theme';
|
18 | import { locale } from '../lib/locale';
|
19 | import { Toast } from './toast';
|
20 | import './use';
|
21 | const style = createCSSSheet(css `
|
22 | :host(:where(:not([hidden]))) {
|
23 | display: grid;
|
24 | grid-template-columns: repeat(auto-fill, minmax(6em, 1fr));
|
25 | gap: ${theme.gridGutter};
|
26 | }
|
27 | .item {
|
28 | display: flex;
|
29 | flex-direction: column;
|
30 | align-items: center;
|
31 | gap: 1em;
|
32 | border-radius: ${theme.normalRound};
|
33 | padding: 1em;
|
34 | cursor: default;
|
35 | background-color: ${theme.lightBackgroundColor};
|
36 | }
|
37 | .item:hover {
|
38 | background-color: ${theme.hoverBackgroundColor};
|
39 | }
|
40 | .icon {
|
41 | width: 2em;
|
42 | }
|
43 | `);
|
44 |
|
45 |
|
46 |
|
47 | let DuoyunIconsElement = class DuoyunIconsElement extends GemElement {
|
48 | constructor() {
|
49 | super(...arguments);
|
50 | _DuoyunIconsElement_onCopy.set(this, async (name) => {
|
51 | await navigator.clipboard.writeText(`<dy-use .element=\${icons.${name}}></dy-use>`);
|
52 | Toast.open('success', locale.copySuccess, {
|
53 | duration: 1000,
|
54 | });
|
55 | });
|
56 | this.render = () => {
|
57 | const entries = Object.entries(icons);
|
58 | return html `
|
59 | ${entries.map(([name, value]) => {
|
60 | return html `
|
61 | <div class="item" @click=${() => __classPrivateFieldGet(this, _DuoyunIconsElement_onCopy, "f").call(this, name)}>
|
62 | <dy-use class="icon" .element=${value}></dy-use>${name}
|
63 | </div>
|
64 | `;
|
65 | })}
|
66 | `;
|
67 | };
|
68 | }
|
69 | };
|
70 | _DuoyunIconsElement_onCopy = new WeakMap();
|
71 | DuoyunIconsElement = __decorate([
|
72 | customElement('dy-icons'),
|
73 | adoptedStyle(style)
|
74 | ], DuoyunIconsElement);
|
75 | export { DuoyunIconsElement };
|
76 |
|
\ | No newline at end of file |