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 _DuoyunMoreElement_onClick;
|
13 | import { adoptedStyle, customElement, attribute, emitter, boolattribute } from '@mantou/gem/lib/decorators';
|
14 | import { GemElement, html } from '@mantou/gem/lib/element';
|
15 | import { classMap, createCSSSheet, css, styleMap } from '@mantou/gem/lib/utils';
|
16 | import { locale } from '../lib/locale';
|
17 | import { commonHandle } from '../lib/hotkeys';
|
18 | import { DuoyunScrollBaseElement } from './base/scroll';
|
19 | import './action-text';
|
20 | const style = createCSSSheet(css `
|
21 | :host(:where(:not([hidden]))) {
|
22 | display: flex;
|
23 | flex-direction: column;
|
24 | align-items: flex-start;
|
25 | }
|
26 | .slot {
|
27 | text-align: left;
|
28 | overflow: hidden;
|
29 | }
|
30 | .overflow {
|
31 | margin-block-end: 0.5em;
|
32 | }
|
33 | .action {
|
34 | cursor: pointer;
|
35 | }
|
36 | `);
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | let DuoyunMoreElement = class DuoyunMoreElement extends GemElement {
|
43 | constructor() {
|
44 | super();
|
45 | this.state = {
|
46 | bottomOverflow: false,
|
47 | expanded: false,
|
48 | };
|
49 | _DuoyunMoreElement_onClick.set(this, () => {
|
50 | this.setState({ expanded: !this.state.expanded });
|
51 | });
|
52 | this.render = () => {
|
53 | const { expanded, bottomOverflow } = this.state;
|
54 | return html `
|
55 | <dy-more-slot
|
56 | class=${classMap({ slot: true, overflow: bottomOverflow })}
|
57 | style=${styleMap({
|
58 | maxHeight: expanded ? 'none' : this.maxheight || '3.8lh',
|
59 | })}
|
60 | @change=${({ detail }) => this.setState({ bottomOverflow: detail })}
|
61 | >
|
62 | <slot></slot>
|
63 | </dy-more-slot>
|
64 | ${!this.expandless && (bottomOverflow || expanded)
|
65 | ? html `
|
66 | <dy-action-text class="action" @keydown=${commonHandle} @click=${__classPrivateFieldGet(this, _DuoyunMoreElement_onClick, "f")}>
|
67 | ${expanded ? this.less || locale.less : this.more || locale.more}
|
68 | </dy-action-text>
|
69 | `
|
70 | : ''}
|
71 | `;
|
72 | };
|
73 | this.internals.role = 'combobox';
|
74 | this.effect(() => {
|
75 | this.internals.ariaExpanded = String(this.state.expanded);
|
76 | });
|
77 | }
|
78 | };
|
79 | _DuoyunMoreElement_onClick = new WeakMap();
|
80 | __decorate([
|
81 | attribute
|
82 | ], DuoyunMoreElement.prototype, "maxheight", void 0);
|
83 | __decorate([
|
84 | attribute
|
85 | ], DuoyunMoreElement.prototype, "more", void 0);
|
86 | __decorate([
|
87 | attribute
|
88 | ], DuoyunMoreElement.prototype, "less", void 0);
|
89 | __decorate([
|
90 | boolattribute
|
91 | ], DuoyunMoreElement.prototype, "expandless", void 0);
|
92 | DuoyunMoreElement = __decorate([
|
93 | customElement('dy-more'),
|
94 | adoptedStyle(style)
|
95 | ], DuoyunMoreElement);
|
96 | export { DuoyunMoreElement };
|
97 |
|
98 |
|
99 |
|
100 | let DuoyunMoreSlotElement = class DuoyunMoreSlotElement extends DuoyunScrollBaseElement {
|
101 | constructor() {
|
102 | super();
|
103 | this.mounted = () => {
|
104 | this.effect(() => {
|
105 | this.change(this.bottomOverflow);
|
106 | });
|
107 | };
|
108 | this.render = () => {
|
109 | return html `<slot></slot>`;
|
110 | };
|
111 | this.internals.role = 'paragraph';
|
112 | }
|
113 | };
|
114 | __decorate([
|
115 | emitter
|
116 | ], DuoyunMoreSlotElement.prototype, "change", void 0);
|
117 | DuoyunMoreSlotElement = __decorate([
|
118 | customElement('dy-more-slot')
|
119 | ], DuoyunMoreSlotElement);
|
120 | export { DuoyunMoreSlotElement };
|
121 |
|
\ | No newline at end of file |