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 |
|
8 | import { adoptedStyle, customElement, property } from '@mantou/gem/lib/decorators';
|
9 | import { GemElement, html } from '@mantou/gem/lib/element';
|
10 | import { createCSSSheet, css } from '@mantou/gem/lib/utils';
|
11 | import { theme } from '../lib/theme';
|
12 | import './avatar';
|
13 | import './divider';
|
14 | const style = createCSSSheet(css `
|
15 | :host(:where(:not([hidden]))) {
|
16 | display: flex;
|
17 | flex-direction: column;
|
18 | gap: 0.5em;
|
19 | font-size: 0.875em;
|
20 | }
|
21 | `);
|
22 |
|
23 |
|
24 |
|
25 | let DuoyunListElement = class DuoyunListElement extends GemElement {
|
26 | constructor() {
|
27 | super();
|
28 | this.render = () => {
|
29 | var _a;
|
30 | return html `${(_a = this.data) === null || _a === void 0 ? void 0 : _a.map((item) => html `
|
31 | <dy-list-item .data=${item} .renderItem=${this.renderItem}></dy-list-item>
|
32 | <dy-divider></dy-divider>
|
33 | `)}`;
|
34 | };
|
35 | this.internals.role = 'list';
|
36 | }
|
37 | };
|
38 | __decorate([
|
39 | property
|
40 | ], DuoyunListElement.prototype, "data", void 0);
|
41 | __decorate([
|
42 | property
|
43 | ], DuoyunListElement.prototype, "renderItem", void 0);
|
44 | DuoyunListElement = __decorate([
|
45 | customElement('dy-list'),
|
46 | adoptedStyle(style)
|
47 | ], DuoyunListElement);
|
48 | export { DuoyunListElement };
|
49 | const itemStyle = createCSSSheet(css `
|
50 | :host(:where(:not([hidden]))) {
|
51 | display: flex;
|
52 | align-items: center;
|
53 | gap: 1em;
|
54 | }
|
55 | .content {
|
56 | display: flex;
|
57 | flex-direction: column;
|
58 | gap: 0.2em;
|
59 | min-width: 0;
|
60 | }
|
61 | .title,
|
62 | .description {
|
63 | overflow: hidden;
|
64 | text-overflow: ellipsis;
|
65 | white-space: nowrap;
|
66 | }
|
67 | .title {
|
68 | font-weight: 500;
|
69 | }
|
70 | .description {
|
71 | color: ${theme.describeColor};
|
72 | }
|
73 | `);
|
74 |
|
75 |
|
76 |
|
77 | let DuoyunListItemElement = class DuoyunListItemElement extends GemElement {
|
78 | constructor() {
|
79 | super({ isAsync: true });
|
80 | this.render = () => {
|
81 | if (!this.data)
|
82 | return html ``;
|
83 | const { title, avatar, description, status } = this.data;
|
84 | return this.renderItem
|
85 | ? this.renderItem(this.data)
|
86 | : html `
|
87 | ${!avatar
|
88 | ? ''
|
89 | : html `
|
90 | <div class="avatar">
|
91 | ${typeof avatar === 'string'
|
92 | ? html `<dy-avatar src=${avatar} alt="Avatar" .status=${status}></dy-avatar>`
|
93 | : avatar}
|
94 | </div>
|
95 | `}
|
96 | <div class="content">
|
97 | <div class="title">${title}</div>
|
98 | <div class="description">${description}</div>
|
99 | </div>
|
100 | `;
|
101 | };
|
102 | this.internals.role = 'listitem';
|
103 | }
|
104 | };
|
105 | __decorate([
|
106 | property
|
107 | ], DuoyunListItemElement.prototype, "data", void 0);
|
108 | __decorate([
|
109 | property
|
110 | ], DuoyunListItemElement.prototype, "renderItem", void 0);
|
111 | DuoyunListItemElement = __decorate([
|
112 | customElement('dy-list-item'),
|
113 | adoptedStyle(itemStyle)
|
114 | ], DuoyunListItemElement);
|
115 | export { DuoyunListItemElement };
|
116 |
|
\ | No newline at end of file |