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, boolattribute } from '@mantou/gem/lib/decorators';
|
9 | import { GemElement, html } from '@mantou/gem/lib/element';
|
10 | import { createCSSSheet, css, classMap } from '@mantou/gem/lib/utils';
|
11 | import { icons } from '../lib/icons';
|
12 | import { theme } from '../lib/theme';
|
13 | import { commonHandle } from '../lib/hotkeys';
|
14 | import './use';
|
15 | import './tooltip';
|
16 | import './action-text';
|
17 | const style = createCSSSheet(css `
|
18 | :host(:where(:not([hidden]))) {
|
19 | display: flex;
|
20 | align-items: center;
|
21 | gap: 0.3em;
|
22 | color: ${theme.describeColor};
|
23 | }
|
24 | :host([compact]) {
|
25 | font-size: 0.875em;
|
26 | }
|
27 | .item-title {
|
28 | text-transform: capitalize;
|
29 | }
|
30 | .item-icon {
|
31 | width: 1.5em;
|
32 | }
|
33 | .item-title,
|
34 | .item-icon,
|
35 | .separator {
|
36 | flex-shrink: 0;
|
37 | }
|
38 | .separator {
|
39 | width: 1em;
|
40 | margin-bottom: -0.2em;
|
41 | }
|
42 | .item-icon:hover,
|
43 | .current {
|
44 | color: ${theme.primaryColor};
|
45 | font-weight: bold;
|
46 | }
|
47 | `);
|
48 |
|
49 |
|
50 |
|
51 | let DuoyunBreadcrumbsElement = class DuoyunBreadcrumbsElement extends GemElement {
|
52 | constructor() {
|
53 | super();
|
54 | this.render = () => {
|
55 | var _a;
|
56 | return html `
|
57 | ${(_a = this.list) === null || _a === void 0 ? void 0 : _a.map(({ title, tooltip, handle, icon }, index, arr, isLast = arr.length - 1 === index) => html `
|
58 | <dy-tooltip .content=${tooltip}>
|
59 | ${icon
|
60 | ? html `<dy-use class="item-icon" .element=${icon}></dy-use>`
|
61 | : html `
|
62 | <dy-action-text
|
63 | role="link"
|
64 | @click=${handle}
|
65 | @keydown=${commonHandle}
|
66 | class=${classMap({ 'item-title': true, current: isLast })}
|
67 | >
|
68 | ${title}
|
69 | </dy-action-text>
|
70 | `}
|
71 | </dy-tooltip>
|
72 | ${!isLast ? html `<dy-use class="separator" role="separator" .element=${icons.right}></dy-use>` : ''}
|
73 | `)}
|
74 | `;
|
75 | };
|
76 | this.internals.ariaLabel = 'breadcrumbs';
|
77 | }
|
78 | };
|
79 | __decorate([
|
80 | boolattribute
|
81 | ], DuoyunBreadcrumbsElement.prototype, "compact", void 0);
|
82 | __decorate([
|
83 | property
|
84 | ], DuoyunBreadcrumbsElement.prototype, "list", void 0);
|
85 | DuoyunBreadcrumbsElement = __decorate([
|
86 | customElement('dy-breadcrumbs'),
|
87 | adoptedStyle(style)
|
88 | ], DuoyunBreadcrumbsElement);
|
89 | export { DuoyunBreadcrumbsElement };
|
90 |
|
\ | No newline at end of file |