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 _DuoyunDividerElement_instances, _DuoyunDividerElement_orientation_get, _DuoyunDividerElement_size_get, _DuoyunDividerElement_height_get, _DuoyunDividerElement_width_get, _DuoyunDividerElement_bgColor_get;
|
13 |
|
14 | import { adoptedStyle, customElement, attribute } from '@mantou/gem/lib/decorators';
|
15 | import { GemElement, html } from '@mantou/gem/lib/element';
|
16 | import { createCSSSheet, css } from '@mantou/gem/lib/utils';
|
17 | import { theme, getSemanticColor } from '../lib/theme';
|
18 | const style = createCSSSheet(css `
|
19 | :host(:where(:not([hidden]))) {
|
20 | display: block;
|
21 | border-radius: 10px;
|
22 | align-self: stretch;
|
23 | background: currentColor;
|
24 | }
|
25 | `);
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | let DuoyunDividerElement = class DuoyunDividerElement extends GemElement {
|
32 | constructor() {
|
33 | super();
|
34 | _DuoyunDividerElement_instances.add(this);
|
35 | this.render = () => {
|
36 | return html `
|
37 | <style>
|
38 | :host {
|
39 | width: ${__classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_width_get)};
|
40 | height: ${__classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_height_get)};
|
41 | color: ${__classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_bgColor_get)};
|
42 | }
|
43 | </style>
|
44 | `;
|
45 | };
|
46 | this.internals.role = 'separator';
|
47 | this.effect(() => {
|
48 | this.internals.ariaOrientation = __classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_orientation_get);
|
49 | });
|
50 | }
|
51 | };
|
52 | _DuoyunDividerElement_instances = new WeakSet(), _DuoyunDividerElement_orientation_get = function _DuoyunDividerElement_orientation_get() {
|
53 | return this.orientation || 'horizontal';
|
54 | }, _DuoyunDividerElement_size_get = function _DuoyunDividerElement_size_get() {
|
55 | switch (this.size) {
|
56 | case 'large':
|
57 | return '4px';
|
58 | case 'medium':
|
59 | return '2px';
|
60 | default:
|
61 | return '1px';
|
62 | }
|
63 | }, _DuoyunDividerElement_height_get = function _DuoyunDividerElement_height_get() {
|
64 | if (__classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_orientation_get) === 'vertical') {
|
65 | return 'auto';
|
66 | }
|
67 | return __classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_size_get);
|
68 | }, _DuoyunDividerElement_width_get = function _DuoyunDividerElement_width_get() {
|
69 | if (__classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_orientation_get) === 'vertical') {
|
70 | return __classPrivateFieldGet(this, _DuoyunDividerElement_instances, "a", _DuoyunDividerElement_size_get);
|
71 | }
|
72 | return 'auto';
|
73 | }, _DuoyunDividerElement_bgColor_get = function _DuoyunDividerElement_bgColor_get() {
|
74 | if (this.color)
|
75 | return getSemanticColor(this.color) || this.color;
|
76 | switch (this.size) {
|
77 | case 'large':
|
78 | return theme.textColor;
|
79 | default:
|
80 | return theme.borderColor;
|
81 | }
|
82 | };
|
83 | __decorate([
|
84 | attribute
|
85 | ], DuoyunDividerElement.prototype, "size", void 0);
|
86 | __decorate([
|
87 | attribute
|
88 | ], DuoyunDividerElement.prototype, "color", void 0);
|
89 | __decorate([
|
90 | attribute
|
91 | ], DuoyunDividerElement.prototype, "orientation", void 0);
|
92 | DuoyunDividerElement = __decorate([
|
93 | customElement('dy-divider'),
|
94 | adoptedStyle(style)
|
95 | ], DuoyunDividerElement);
|
96 | export { DuoyunDividerElement };
|
97 |
|
\ | No newline at end of file |