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 | import { GemElement, html } from '@mantou/gem/lib/element';
|
8 | import { adoptedStyle, customElement, attribute, state } from '@mantou/gem/lib/decorators';
|
9 | import { createCSSSheet, css } from '@mantou/gem/lib/utils';
|
10 | import { theme, getSemanticColor } from '../lib/theme';
|
11 | import { commonHandle } from '../lib/hotkeys';
|
12 | import { focusStyle } from '../lib/styles';
|
13 | import './tooltip';
|
14 | const style = createCSSSheet(css `
|
15 | :host {
|
16 | overflow: hidden;
|
17 | text-overflow: ellipsis;
|
18 | cursor: default;
|
19 | line-height: 1.5;
|
20 | --color: initial;
|
21 | color: var(--color, inherit);
|
22 | border-radius: ${theme.normalRound};
|
23 | }
|
24 | :host(:where(:hover, [data-active], :state(active))) {
|
25 | color: var(--color, ${theme.primaryColor});
|
26 | text-decoration: underline;
|
27 | }
|
28 | :host(:where(:lang(zh), :lang(ja), :lang(kr))) {
|
29 | text-underline-offset: 0.125em;
|
30 | }
|
31 | `);
|
32 |
|
33 |
|
34 |
|
35 | let DuoyunActionTextElement = class DuoyunActionTextElement extends GemElement {
|
36 | constructor() {
|
37 | super();
|
38 | this.render = () => {
|
39 | return html `
|
40 | <style>
|
41 | :host([color]) {
|
42 | --color: ${getSemanticColor(this.color) || this.color};
|
43 | }
|
44 | </style>
|
45 | <dy-tooltip .content=${this.tooltip}>
|
46 | <slot></slot>
|
47 | </dy-tooltip>
|
48 | `;
|
49 | };
|
50 | this.tabIndex = 0;
|
51 | this.internals.role = 'button';
|
52 | this.addEventListener('keydown', commonHandle);
|
53 | }
|
54 | };
|
55 | __decorate([
|
56 | attribute
|
57 | ], DuoyunActionTextElement.prototype, "tooltip", void 0);
|
58 | __decorate([
|
59 | attribute
|
60 | ], DuoyunActionTextElement.prototype, "color", void 0);
|
61 | __decorate([
|
62 | state
|
63 | ], DuoyunActionTextElement.prototype, "active", void 0);
|
64 | DuoyunActionTextElement = __decorate([
|
65 | customElement('dy-action-text'),
|
66 | adoptedStyle(style),
|
67 | adoptedStyle(focusStyle)
|
68 | ], DuoyunActionTextElement);
|
69 | export { DuoyunActionTextElement };
|
70 |
|
\ | No newline at end of file |