@deepfuture/dui-components 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_deprecated/center/center.js +2 -2
- package/_deprecated/hstack/hstack.js +79 -33
- package/_deprecated/page-inset/page-inset.js +104 -56
- package/_deprecated/vstack/vstack.js +61 -19
- package/accordion/accordion-item.js +217 -147
- package/accordion/accordion.js +214 -149
- package/alert-dialog/alert-dialog-close.js +2 -2
- package/alert-dialog/alert-dialog-popup.js +230 -166
- package/alert-dialog/alert-dialog-trigger.js +2 -2
- package/alert-dialog/alert-dialog.js +128 -73
- package/avatar/avatar.js +175 -115
- package/badge/badge.js +2 -2
- package/breadcrumb/breadcrumb-ellipsis.js +2 -2
- package/breadcrumb/breadcrumb-item.js +2 -2
- package/breadcrumb/breadcrumb-link.js +2 -2
- package/breadcrumb/breadcrumb-page.js +2 -2
- package/breadcrumb/breadcrumb-separator.js +2 -2
- package/breadcrumb/breadcrumb.js +2 -2
- package/button/button.js +109 -65
- package/calendar/calendar.js +368 -290
- package/checkbox/checkbox-group.js +146 -87
- package/checkbox/checkbox.js +232 -167
- package/collapsible/collapsible.js +210 -132
- package/combobox/combobox.js +318 -252
- package/command/command-empty.js +67 -25
- package/command/command-group.js +87 -47
- package/command/command-input.js +84 -44
- package/command/command-item.js +168 -124
- package/command/command-list.js +60 -18
- package/command/command-separator.js +2 -2
- package/command/command-shortcut.js +2 -2
- package/command/command.js +297 -232
- package/data-table/data-table.js +225 -153
- package/dialog/dialog-close.js +2 -2
- package/dialog/dialog-popup.js +247 -181
- package/dialog/dialog-trigger.js +2 -2
- package/dialog/dialog.js +128 -73
- package/dropzone/dropzone.js +310 -249
- package/icon/icon.js +2 -2
- package/input/input.js +204 -143
- package/link/link.js +62 -24
- package/menu/menu-item.js +66 -24
- package/menu/menu.js +189 -136
- package/menubar/menubar.js +142 -91
- package/number-field/number-field.js +277 -204
- package/package.json +2 -3
- package/popover/popover-close.js +2 -2
- package/popover/popover-popup.js +126 -76
- package/popover/popover-trigger.js +2 -2
- package/popover/popover.js +181 -120
- package/portal/portal.js +128 -86
- package/preview-card/preview-card-popup.js +114 -66
- package/preview-card/preview-card-trigger.js +2 -2
- package/preview-card/preview-card.js +211 -142
- package/progress/progress.js +91 -45
- package/radio/radio-group.js +153 -90
- package/radio/radio.js +137 -94
- package/scroll-area/scroll-area.js +382 -283
- package/select/select.js +260 -203
- package/separator/separator.js +60 -18
- package/sidebar/sidebar-content.js +2 -2
- package/sidebar/sidebar-footer.js +2 -2
- package/sidebar/sidebar-group-label.js +2 -2
- package/sidebar/sidebar-group.js +2 -2
- package/sidebar/sidebar-header.js +2 -2
- package/sidebar/sidebar-inset.js +2 -2
- package/sidebar/sidebar-menu-button.js +118 -74
- package/sidebar/sidebar-menu-item.js +2 -2
- package/sidebar/sidebar-menu.js +2 -2
- package/sidebar/sidebar-provider.js +202 -129
- package/sidebar/sidebar-separator.js +2 -2
- package/sidebar/sidebar-trigger.js +2 -2
- package/sidebar/sidebar.js +150 -85
- package/slider/slider.js +217 -159
- package/spinner/spinner.js +70 -28
- package/switch/switch.js +174 -111
- package/tabs/tab.js +89 -47
- package/tabs/tabs-indicator.js +2 -2
- package/tabs/tabs-list.js +92 -54
- package/tabs/tabs-panel.js +90 -44
- package/tabs/tabs.js +130 -71
- package/textarea/textarea.js +153 -95
- package/toggle/toggle-group.js +184 -125
- package/toggle/toggle.js +131 -76
- package/toolbar/toolbar.js +79 -33
- package/tooltip/tooltip-popup.js +108 -60
- package/tooltip/tooltip-trigger.js +93 -55
- package/tooltip/tooltip.js +225 -154
- package/trunc/trunc.js +78 -34
package/portal/portal.js
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/portal */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
7
35
|
};
|
|
8
36
|
import { css, html, LitElement } from "lit";
|
|
9
37
|
import { property } from "lit/decorators.js";
|
|
@@ -25,91 +53,105 @@ const styles = css `
|
|
|
25
53
|
* @attr {string} target - CSS selector for the destination container (default: "body").
|
|
26
54
|
* @attr {"shadow" | "document"} target-root - Where to resolve the target selector.
|
|
27
55
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
return root?.querySelector(this.target) ?? undefined;
|
|
51
|
-
}
|
|
52
|
-
connectedCallback() {
|
|
53
|
-
super.connectedCallback();
|
|
54
|
-
this.#container = this.targetElement ?? this.#queryTarget();
|
|
55
|
-
if (this.#container && this.childNodes.length > 0) {
|
|
56
|
-
this.#moveChildrenToTarget();
|
|
56
|
+
let DuiPortal = (() => {
|
|
57
|
+
let _classSuper = LitElement;
|
|
58
|
+
let _target_decorators;
|
|
59
|
+
let _target_initializers = [];
|
|
60
|
+
let _target_extraInitializers = [];
|
|
61
|
+
let _targetRoot_decorators;
|
|
62
|
+
let _targetRoot_initializers = [];
|
|
63
|
+
let _targetRoot_extraInitializers = [];
|
|
64
|
+
let _targetElement_decorators;
|
|
65
|
+
let _targetElement_initializers = [];
|
|
66
|
+
let _targetElement_extraInitializers = [];
|
|
67
|
+
return class DuiPortal extends _classSuper {
|
|
68
|
+
static {
|
|
69
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
70
|
+
_target_decorators = [property({ type: String })];
|
|
71
|
+
_targetRoot_decorators = [property({ type: String, attribute: "target-root", reflect: true })];
|
|
72
|
+
_targetElement_decorators = [property({ attribute: false })];
|
|
73
|
+
__esDecorate(this, null, _target_decorators, { kind: "accessor", name: "target", static: false, private: false, access: { has: obj => "target" in obj, get: obj => obj.target, set: (obj, value) => { obj.target = value; } }, metadata: _metadata }, _target_initializers, _target_extraInitializers);
|
|
74
|
+
__esDecorate(this, null, _targetRoot_decorators, { kind: "accessor", name: "targetRoot", static: false, private: false, access: { has: obj => "targetRoot" in obj, get: obj => obj.targetRoot, set: (obj, value) => { obj.targetRoot = value; } }, metadata: _metadata }, _targetRoot_initializers, _targetRoot_extraInitializers);
|
|
75
|
+
__esDecorate(this, null, _targetElement_decorators, { kind: "accessor", name: "targetElement", static: false, private: false, access: { has: obj => "targetElement" in obj, get: obj => obj.targetElement, set: (obj, value) => { obj.targetElement = value; } }, metadata: _metadata }, _targetElement_initializers, _targetElement_extraInitializers);
|
|
76
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
57
77
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
static tagName = "dui-portal";
|
|
79
|
+
static styles = [styles];
|
|
80
|
+
#target_accessor_storage = __runInitializers(this, _target_initializers, "body");
|
|
81
|
+
/** CSS selector for the destination container. */
|
|
82
|
+
get target() { return this.#target_accessor_storage; }
|
|
83
|
+
set target(value) { this.#target_accessor_storage = value; }
|
|
84
|
+
#targetRoot_accessor_storage = (__runInitializers(this, _target_extraInitializers), __runInitializers(this, _targetRoot_initializers, "document"));
|
|
85
|
+
/** Where to resolve the target selector: "document" (default) or "shadow". */
|
|
86
|
+
get targetRoot() { return this.#targetRoot_accessor_storage; }
|
|
87
|
+
set targetRoot(value) { this.#targetRoot_accessor_storage = value; }
|
|
88
|
+
#targetElement_accessor_storage = (__runInitializers(this, _targetRoot_extraInitializers), __runInitializers(this, _targetElement_initializers, void 0));
|
|
89
|
+
/** Direct element reference for cross-shadow-root targets. Takes precedence over `target` selector. */
|
|
90
|
+
get targetElement() { return this.#targetElement_accessor_storage; }
|
|
91
|
+
set targetElement(value) { this.#targetElement_accessor_storage = value; }
|
|
92
|
+
#container = (__runInitializers(this, _targetElement_extraInitializers), undefined);
|
|
93
|
+
#movedNodes = new Set();
|
|
94
|
+
#isMoving = false;
|
|
95
|
+
#queryTarget() {
|
|
96
|
+
const root = getRootDocument(this, {
|
|
97
|
+
composed: this.targetRoot === "document",
|
|
98
|
+
});
|
|
99
|
+
return root?.querySelector(this.target) ?? undefined;
|
|
100
|
+
}
|
|
101
|
+
connectedCallback() {
|
|
102
|
+
super.connectedCallback();
|
|
103
|
+
this.#container = this.targetElement ?? this.#queryTarget();
|
|
104
|
+
if (this.#container && this.childNodes.length > 0) {
|
|
105
|
+
this.#moveChildrenToTarget();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
disconnectedCallback() {
|
|
109
|
+
super.disconnectedCallback();
|
|
67
110
|
this.#detach();
|
|
68
|
-
this.#attach();
|
|
69
111
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
this.#isMoving = true;
|
|
79
|
-
for (const node of this.#movedNodes) {
|
|
80
|
-
this.append(node);
|
|
112
|
+
updated(changed) {
|
|
113
|
+
if (changed.has("target") ||
|
|
114
|
+
changed.has("targetRoot") ||
|
|
115
|
+
changed.has("targetElement")) {
|
|
116
|
+
this.#detach();
|
|
117
|
+
this.#attach();
|
|
118
|
+
}
|
|
81
119
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
#moveChildrenToTarget() {
|
|
87
|
-
if (!this.#container) {
|
|
88
|
-
throw new Error(`Portal target does not exist: ${this.target}`);
|
|
120
|
+
#attach() {
|
|
121
|
+
this.#container = this.targetElement ?? this.#queryTarget();
|
|
122
|
+
this.#moveChildrenToTarget();
|
|
89
123
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.#
|
|
94
|
-
this.#movedNodes
|
|
124
|
+
#detach() {
|
|
125
|
+
if (this.#movedNodes.size === 0)
|
|
126
|
+
return;
|
|
127
|
+
this.#isMoving = true;
|
|
128
|
+
for (const node of this.#movedNodes) {
|
|
129
|
+
this.append(node);
|
|
130
|
+
}
|
|
131
|
+
this.#movedNodes.clear();
|
|
132
|
+
this.#isMoving = false;
|
|
133
|
+
this.#container = undefined;
|
|
134
|
+
}
|
|
135
|
+
#moveChildrenToTarget() {
|
|
136
|
+
if (!this.#container) {
|
|
137
|
+
throw new Error(`Portal target does not exist: ${this.target}`);
|
|
138
|
+
}
|
|
139
|
+
this.#isMoving = true;
|
|
140
|
+
const nodes = Array.from(this.childNodes);
|
|
141
|
+
for (const node of nodes) {
|
|
142
|
+
this.#container.appendChild(node);
|
|
143
|
+
this.#movedNodes.add(node);
|
|
144
|
+
}
|
|
145
|
+
this.#isMoving = false;
|
|
146
|
+
}
|
|
147
|
+
#handleSlotChange = () => {
|
|
148
|
+
if (this.#isMoving || !this.#container)
|
|
149
|
+
return;
|
|
150
|
+
this.#moveChildrenToTarget();
|
|
151
|
+
};
|
|
152
|
+
render() {
|
|
153
|
+
return html `<slot @slotchange=${this.#handleSlotChange}></slot>`;
|
|
95
154
|
}
|
|
96
|
-
this.#isMoving = false;
|
|
97
|
-
}
|
|
98
|
-
#handleSlotChange = () => {
|
|
99
|
-
if (this.#isMoving || !this.#container)
|
|
100
|
-
return;
|
|
101
|
-
this.#moveChildrenToTarget();
|
|
102
155
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
__decorate([
|
|
108
|
-
property({ type: String })
|
|
109
|
-
], DuiPortal.prototype, "target", null);
|
|
110
|
-
__decorate([
|
|
111
|
-
property({ type: String, attribute: "target-root", reflect: true })
|
|
112
|
-
], DuiPortal.prototype, "targetRoot", null);
|
|
113
|
-
__decorate([
|
|
114
|
-
property({ attribute: false })
|
|
115
|
-
], DuiPortal.prototype, "targetElement", null);
|
|
156
|
+
})();
|
|
157
|
+
export { DuiPortal };
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/preview-card */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
import { css, html, LitElement } from "lit";
|
|
9
|
-
import { property } from "lit/decorators.js";
|
|
41
|
+
import { property, state } from "lit/decorators.js";
|
|
10
42
|
import { ContextConsumer } from "@lit/context";
|
|
11
43
|
import { base } from "@deepfuture/dui-core/base";
|
|
12
44
|
import { previewCardContext } from "./preview-card-context.js";
|
|
@@ -67,37 +99,54 @@ const portalPopupStyles = [
|
|
|
67
99
|
*
|
|
68
100
|
* @slot - Preview card content.
|
|
69
101
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
let DuiPreviewCardPopup = (() => {
|
|
103
|
+
let _classSuper = LitElement;
|
|
104
|
+
let _showArrow_decorators;
|
|
105
|
+
let _showArrow_initializers = [];
|
|
106
|
+
let _showArrow_extraInitializers = [];
|
|
107
|
+
let _private_side_decorators;
|
|
108
|
+
let _private_side_initializers = [];
|
|
109
|
+
let _private_side_extraInitializers = [];
|
|
110
|
+
let _private_side_descriptor;
|
|
111
|
+
return class DuiPreviewCardPopup extends _classSuper {
|
|
112
|
+
static {
|
|
113
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
114
|
+
_showArrow_decorators = [property({ type: Boolean, attribute: "show-arrow" })];
|
|
115
|
+
_private_side_decorators = [state()];
|
|
116
|
+
__esDecorate(this, null, _showArrow_decorators, { kind: "accessor", name: "showArrow", static: false, private: false, access: { has: obj => "showArrow" in obj, get: obj => obj.showArrow, set: (obj, value) => { obj.showArrow = value; } }, metadata: _metadata }, _showArrow_initializers, _showArrow_extraInitializers);
|
|
117
|
+
__esDecorate(this, _private_side_descriptor = { get: __setFunctionName(function () { return this.#side_accessor_storage; }, "#side", "get"), set: __setFunctionName(function (value) { this.#side_accessor_storage = value; }, "#side", "set") }, _private_side_decorators, { kind: "accessor", name: "#side", static: false, private: true, access: { has: obj => #side in obj, get: obj => obj.#side, set: (obj, value) => { obj.#side = value; } }, metadata: _metadata }, _private_side_initializers, _private_side_extraInitializers);
|
|
118
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
119
|
+
}
|
|
120
|
+
static tagName = "dui-preview-card-popup";
|
|
121
|
+
static styles = [base, hostStyles];
|
|
122
|
+
#showArrow_accessor_storage = __runInitializers(this, _showArrow_initializers, true);
|
|
123
|
+
/** Whether to show an arrow pointing to the trigger. */
|
|
124
|
+
get showArrow() { return this.#showArrow_accessor_storage; }
|
|
125
|
+
set showArrow(value) { this.#showArrow_accessor_storage = value; }
|
|
126
|
+
#side_accessor_storage = (__runInitializers(this, _showArrow_extraInitializers), __runInitializers(this, _private_side_initializers, "top"));
|
|
127
|
+
get #side() { return _private_side_descriptor.get.call(this); }
|
|
128
|
+
set #side(value) { return _private_side_descriptor.set.call(this, value); }
|
|
129
|
+
#ctx = (__runInitializers(this, _private_side_extraInitializers), new ContextConsumer(this, {
|
|
130
|
+
context: previewCardContext,
|
|
131
|
+
subscribe: true,
|
|
132
|
+
}));
|
|
133
|
+
#wasOpen = false;
|
|
134
|
+
#portal = new FloatingPortalController(this, {
|
|
135
|
+
getAnchor: () => this.#ctx.value?.triggerEl,
|
|
136
|
+
matchWidth: false,
|
|
137
|
+
placement: "top",
|
|
138
|
+
offset: 8,
|
|
139
|
+
styles: portalPopupStyles,
|
|
140
|
+
contentContainer: ".PreviewCardContent",
|
|
141
|
+
onPosition: ({ placement }) => {
|
|
142
|
+
const actualSide = placement.split("-")[0];
|
|
143
|
+
if (actualSide !== this.#side) {
|
|
144
|
+
this.#side = actualSide;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
renderPopup: (portal) => {
|
|
148
|
+
const popupId = this.#ctx.value?.popupId ?? "";
|
|
149
|
+
return html `
|
|
101
150
|
<div
|
|
102
151
|
class="Popup"
|
|
103
152
|
id="${popupId}"
|
|
@@ -112,34 +161,33 @@ export class DuiPreviewCardPopup extends LitElement {
|
|
|
112
161
|
${this.showArrow ? renderArrow(this.#side) : ""}
|
|
113
162
|
</div>
|
|
114
163
|
`;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
#handleMouseEnter = () => {
|
|
167
|
+
this.#ctx.value?.openPreviewCard();
|
|
168
|
+
};
|
|
169
|
+
#handleMouseLeave = () => {
|
|
170
|
+
this.#ctx.value?.closePreviewCard();
|
|
171
|
+
};
|
|
172
|
+
updated() {
|
|
173
|
+
const isOpen = this.#ctx.value?.open ?? false;
|
|
174
|
+
if (isOpen && !this.#wasOpen) {
|
|
175
|
+
this.#updatePlacement();
|
|
176
|
+
this.#portal.open();
|
|
177
|
+
}
|
|
178
|
+
else if (!isOpen && this.#wasOpen) {
|
|
179
|
+
this.#portal.close();
|
|
180
|
+
}
|
|
181
|
+
this.#wasOpen = isOpen;
|
|
128
182
|
}
|
|
129
|
-
|
|
130
|
-
this.#
|
|
183
|
+
#updatePlacement() {
|
|
184
|
+
const side = this.#ctx.value?.side ?? "top";
|
|
185
|
+
this.#portal.placement = side;
|
|
186
|
+
this.#portal.offset = this.#ctx.value?.sideOffset ?? 8;
|
|
131
187
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
render() {
|
|
140
|
-
return html `<slot></slot>`;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
__decorate([
|
|
144
|
-
property({ type: Boolean, attribute: "show-arrow" })
|
|
145
|
-
], DuiPreviewCardPopup.prototype, "showArrow", null);
|
|
188
|
+
render() {
|
|
189
|
+
return html `<slot></slot>`;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
})();
|
|
193
|
+
export { DuiPreviewCardPopup };
|
|
@@ -19,8 +19,8 @@ const componentStyles = css `
|
|
|
19
19
|
* @slot - Content that triggers the preview card.
|
|
20
20
|
*/
|
|
21
21
|
export class DuiPreviewCardTrigger extends LitElement {
|
|
22
|
-
static
|
|
23
|
-
static
|
|
22
|
+
static tagName = "dui-preview-card-trigger";
|
|
23
|
+
static styles = [base, hostStyles, componentStyles];
|
|
24
24
|
#ctx = new ContextConsumer(this, {
|
|
25
25
|
context: previewCardContext,
|
|
26
26
|
subscribe: true,
|