UNPKG

2.49 kBJavaScriptView Raw
1var __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};
7import { GemElement, html } from '@mantou/gem/lib/element';
8import { adoptedStyle, customElement, attribute, state } from '@mantou/gem/lib/decorators';
9import { createCSSSheet, css } from '@mantou/gem/lib/utils';
10import { theme, getSemanticColor } from '../lib/theme';
11import { commonHandle } from '../lib/hotkeys';
12import { focusStyle } from '../lib/styles';
13import './tooltip';
14const 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 * @customElement dy-action-text
34 */
35let 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);
64DuoyunActionTextElement = __decorate([
65 customElement('dy-action-text'),
66 adoptedStyle(style),
67 adoptedStyle(focusStyle)
68], DuoyunActionTextElement);
69export { DuoyunActionTextElement };
70//# sourceMappingURL=action-text.js.map
\No newline at end of file