@deepfuture/dui-components 0.0.11 → 0.0.13
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/README.md +191 -0
- package/_deprecated/center/center.js +2 -2
- package/_deprecated/center/index.d.ts +3 -1
- package/_deprecated/center/index.js +3 -1
- package/_deprecated/hstack/hstack.js +79 -33
- package/_deprecated/hstack/index.d.ts +3 -1
- package/_deprecated/hstack/index.js +3 -1
- package/_deprecated/page-inset/index.d.ts +3 -1
- package/_deprecated/page-inset/index.js +3 -1
- package/_deprecated/page-inset/page-inset.js +104 -56
- package/_deprecated/vstack/index.d.ts +3 -1
- package/_deprecated/vstack/index.js +3 -1
- package/_deprecated/vstack/vstack.js +61 -19
- package/accordion/accordion-item.js +217 -147
- package/accordion/accordion.js +214 -149
- package/accordion/index.d.ts +5 -2
- package/accordion/index.js +5 -2
- 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/alert-dialog/index.d.ts +9 -4
- package/alert-dialog/index.js +9 -4
- package/avatar/avatar.js +175 -115
- package/avatar/index.d.ts +3 -1
- package/avatar/index.js +3 -1
- package/badge/badge.js +2 -2
- package/badge/index.d.ts +3 -1
- package/badge/index.js +3 -1
- 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/breadcrumb/index.d.ts +13 -6
- package/breadcrumb/index.js +13 -6
- package/button/button.js +109 -65
- package/button/index.d.ts +3 -1
- package/button/index.js +3 -1
- package/calendar/calendar.js +368 -290
- package/calendar/index.d.ts +3 -1
- package/calendar/index.js +3 -1
- package/checkbox/checkbox-group.js +146 -87
- package/checkbox/checkbox.js +232 -167
- package/checkbox/index.d.ts +5 -2
- package/checkbox/index.js +5 -2
- package/collapsible/collapsible.js +210 -132
- package/collapsible/index.d.ts +3 -1
- package/collapsible/index.js +3 -1
- package/combobox/combobox.js +318 -252
- package/combobox/index.d.ts +3 -1
- package/combobox/index.js +3 -1
- 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/command/index.d.ts +17 -8
- package/command/index.js +17 -8
- package/data-table/data-table.js +225 -153
- package/data-table/index.d.ts +3 -1
- package/data-table/index.js +3 -1
- 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/dialog/index.d.ts +9 -4
- package/dialog/index.js +9 -4
- package/dropzone/dropzone.js +310 -249
- package/dropzone/index.d.ts +3 -1
- package/dropzone/index.js +3 -1
- package/icon/icon.js +2 -2
- package/icon/index.d.ts +3 -1
- package/icon/index.js +3 -1
- package/input/index.d.ts +3 -1
- package/input/index.js +3 -1
- package/input/input.js +204 -143
- package/link/index.d.ts +3 -1
- package/link/index.js +3 -1
- package/link/link.js +62 -24
- package/menu/index.d.ts +5 -2
- package/menu/index.js +5 -2
- package/menu/menu-item.js +66 -24
- package/menu/menu.js +189 -136
- package/menubar/index.d.ts +3 -1
- package/menubar/index.js +3 -1
- package/menubar/menubar.js +142 -91
- package/number-field/index.d.ts +3 -1
- package/number-field/index.js +3 -1
- package/number-field/number-field.js +277 -204
- package/package.json +5 -4
- package/popover/index.d.ts +9 -4
- package/popover/index.js +9 -4
- 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/index.d.ts +3 -1
- package/portal/index.js +3 -1
- package/portal/portal.js +128 -86
- package/preview-card/index.d.ts +7 -3
- package/preview-card/index.js +7 -3
- 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/index.d.ts +3 -1
- package/progress/index.js +3 -1
- package/progress/progress.js +91 -45
- package/radio/index.d.ts +5 -2
- package/radio/index.js +5 -2
- package/radio/radio-group.js +153 -90
- package/radio/radio.js +137 -94
- package/scroll-area/index.d.ts +3 -1
- package/scroll-area/index.js +3 -1
- package/scroll-area/scroll-area.js +382 -276
- package/select/index.d.ts +3 -1
- package/select/index.js +3 -1
- package/select/select.js +260 -203
- package/separator/index.d.ts +3 -1
- package/separator/index.js +3 -1
- package/separator/separator.js +60 -18
- package/sidebar/index.d.ts +27 -13
- package/sidebar/index.js +32 -13
- 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/index.d.ts +3 -1
- package/slider/index.js +3 -1
- package/slider/slider.js +217 -159
- package/spinner/index.d.ts +3 -1
- package/spinner/index.js +3 -1
- package/spinner/spinner.js +70 -28
- package/switch/index.d.ts +3 -1
- package/switch/index.js +3 -1
- package/switch/switch.js +174 -111
- package/tabs/index.d.ts +11 -5
- package/tabs/index.js +11 -5
- 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/index.d.ts +3 -1
- package/textarea/index.js +3 -1
- package/textarea/textarea.js +153 -95
- package/toggle/index.d.ts +5 -2
- package/toggle/index.js +5 -2
- package/toggle/toggle-group.js +184 -125
- package/toggle/toggle.js +131 -76
- package/toolbar/index.d.ts +3 -1
- package/toolbar/index.js +3 -1
- package/toolbar/toolbar.js +79 -33
- package/tooltip/index.d.ts +7 -3
- package/tooltip/index.js +7 -3
- package/tooltip/tooltip-popup.js +108 -60
- package/tooltip/tooltip-trigger.js +93 -55
- package/tooltip/tooltip.js +225 -154
- package/trunc/index.d.ts +3 -1
- package/trunc/index.js +3 -1
- package/trunc/trunc.js +78 -34
- package/accordion/register.d.ts +0 -1
- package/accordion/register.js +0 -8
- package/alert-dialog/register.d.ts +0 -1
- package/alert-dialog/register.js +0 -16
- package/avatar/register.d.ts +0 -1
- package/avatar/register.js +0 -4
- package/badge/register.d.ts +0 -1
- package/badge/register.js +0 -4
- package/breadcrumb/register.d.ts +0 -1
- package/breadcrumb/register.js +0 -14
- package/button/register.d.ts +0 -1
- package/button/register.js +0 -4
- package/calendar/register.d.ts +0 -1
- package/calendar/register.js +0 -4
- package/checkbox/register.d.ts +0 -1
- package/checkbox/register.js +0 -8
- package/collapsible/register.d.ts +0 -1
- package/collapsible/register.js +0 -4
- package/combobox/register.d.ts +0 -1
- package/combobox/register.js +0 -4
- package/command/register.d.ts +0 -1
- package/command/register.js +0 -22
- package/data-table/register.d.ts +0 -1
- package/data-table/register.js +0 -4
- package/dialog/register.d.ts +0 -1
- package/dialog/register.js +0 -16
- package/dropzone/register.d.ts +0 -1
- package/dropzone/register.js +0 -4
- package/icon/register.d.ts +0 -1
- package/icon/register.js +0 -4
- package/input/register.d.ts +0 -1
- package/input/register.js +0 -4
- package/link/register.d.ts +0 -1
- package/link/register.js +0 -4
- package/menu/register.d.ts +0 -1
- package/menu/register.js +0 -8
- package/menubar/register.d.ts +0 -1
- package/menubar/register.js +0 -4
- package/number-field/register.d.ts +0 -1
- package/number-field/register.js +0 -4
- package/popover/register.d.ts +0 -1
- package/popover/register.js +0 -16
- package/portal/register.d.ts +0 -1
- package/portal/register.js +0 -4
- package/preview-card/register.d.ts +0 -1
- package/preview-card/register.js +0 -12
- package/progress/register.d.ts +0 -1
- package/progress/register.js +0 -4
- package/radio/register.d.ts +0 -1
- package/radio/register.js +0 -8
- package/scroll-area/register.d.ts +0 -1
- package/scroll-area/register.js +0 -4
- package/select/register.d.ts +0 -1
- package/select/register.js +0 -4
- package/separator/register.d.ts +0 -1
- package/separator/register.js +0 -4
- package/sidebar/register.d.ts +0 -1
- package/sidebar/register.js +0 -52
- package/slider/register.d.ts +0 -1
- package/slider/register.js +0 -4
- package/spinner/register.d.ts +0 -1
- package/spinner/register.js +0 -4
- package/switch/register.d.ts +0 -1
- package/switch/register.js +0 -4
- package/tabs/register.d.ts +0 -1
- package/tabs/register.js +0 -10
- package/textarea/register.d.ts +0 -1
- package/textarea/register.js +0 -4
- package/toggle/register.d.ts +0 -1
- package/toggle/register.js +0 -8
- package/toolbar/register.d.ts +0 -1
- package/toolbar/register.js +0 -4
- package/tooltip/register.d.ts +0 -1
- package/tooltip/register.js +0 -12
- package/trunc/register.d.ts +0 -1
- package/trunc/register.js +0 -4
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/scroll-area */
|
|
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
|
-
var _a;
|
|
9
40
|
import { css, html, LitElement, nothing, } from "lit";
|
|
10
|
-
import { property } from "lit/decorators.js";
|
|
41
|
+
import { property, state } from "lit/decorators.js";
|
|
11
42
|
import { base } from "@deepfuture/dui-core/base";
|
|
12
43
|
const styles = css `
|
|
13
44
|
:host {
|
|
@@ -118,264 +149,347 @@ const styles = css `
|
|
|
118
149
|
* @cssprop [--scroll-area-thumb-color] - Scrollbar thumb color.
|
|
119
150
|
* @cssprop [--scroll-fade-color] - Fade overlay color.
|
|
120
151
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
let DuiScrollArea = (() => {
|
|
153
|
+
var _a;
|
|
154
|
+
let _classSuper = LitElement;
|
|
155
|
+
let _orientation_decorators;
|
|
156
|
+
let _orientation_initializers = [];
|
|
157
|
+
let _orientation_extraInitializers = [];
|
|
158
|
+
let _fade_decorators;
|
|
159
|
+
let _fade_initializers = [];
|
|
160
|
+
let _fade_extraInitializers = [];
|
|
161
|
+
let _maxHeight_decorators;
|
|
162
|
+
let _maxHeight_initializers = [];
|
|
163
|
+
let _maxHeight_extraInitializers = [];
|
|
164
|
+
let _private_hasOverflowX_decorators;
|
|
165
|
+
let _private_hasOverflowX_initializers = [];
|
|
166
|
+
let _private_hasOverflowX_extraInitializers = [];
|
|
167
|
+
let _private_hasOverflowX_descriptor;
|
|
168
|
+
let _private_hasOverflowY_decorators;
|
|
169
|
+
let _private_hasOverflowY_initializers = [];
|
|
170
|
+
let _private_hasOverflowY_extraInitializers = [];
|
|
171
|
+
let _private_hasOverflowY_descriptor;
|
|
172
|
+
let _private_hovering_decorators;
|
|
173
|
+
let _private_hovering_initializers = [];
|
|
174
|
+
let _private_hovering_extraInitializers = [];
|
|
175
|
+
let _private_hovering_descriptor;
|
|
176
|
+
let _private_scrolling_decorators;
|
|
177
|
+
let _private_scrolling_initializers = [];
|
|
178
|
+
let _private_scrolling_extraInitializers = [];
|
|
179
|
+
let _private_scrolling_descriptor;
|
|
180
|
+
let _private_thumbHeightPercent_decorators;
|
|
181
|
+
let _private_thumbHeightPercent_initializers = [];
|
|
182
|
+
let _private_thumbHeightPercent_extraInitializers = [];
|
|
183
|
+
let _private_thumbHeightPercent_descriptor;
|
|
184
|
+
let _private_thumbWidthPercent_decorators;
|
|
185
|
+
let _private_thumbWidthPercent_initializers = [];
|
|
186
|
+
let _private_thumbWidthPercent_extraInitializers = [];
|
|
187
|
+
let _private_thumbWidthPercent_descriptor;
|
|
188
|
+
let _private_thumbTopPercent_decorators;
|
|
189
|
+
let _private_thumbTopPercent_initializers = [];
|
|
190
|
+
let _private_thumbTopPercent_extraInitializers = [];
|
|
191
|
+
let _private_thumbTopPercent_descriptor;
|
|
192
|
+
let _private_thumbLeftPercent_decorators;
|
|
193
|
+
let _private_thumbLeftPercent_initializers = [];
|
|
194
|
+
let _private_thumbLeftPercent_extraInitializers = [];
|
|
195
|
+
let _private_thumbLeftPercent_descriptor;
|
|
196
|
+
let _private_isAtTop_decorators;
|
|
197
|
+
let _private_isAtTop_initializers = [];
|
|
198
|
+
let _private_isAtTop_extraInitializers = [];
|
|
199
|
+
let _private_isAtTop_descriptor;
|
|
200
|
+
return class DuiScrollArea extends _classSuper {
|
|
201
|
+
static {
|
|
202
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
203
|
+
_orientation_decorators = [property({ reflect: true })];
|
|
204
|
+
_fade_decorators = [property({ type: Boolean, reflect: true })];
|
|
205
|
+
_maxHeight_decorators = [property({ attribute: "max-height" })];
|
|
206
|
+
_private_hasOverflowX_decorators = [state()];
|
|
207
|
+
_private_hasOverflowY_decorators = [state()];
|
|
208
|
+
_private_hovering_decorators = [state()];
|
|
209
|
+
_private_scrolling_decorators = [state()];
|
|
210
|
+
_private_thumbHeightPercent_decorators = [state()];
|
|
211
|
+
_private_thumbWidthPercent_decorators = [state()];
|
|
212
|
+
_private_thumbTopPercent_decorators = [state()];
|
|
213
|
+
_private_thumbLeftPercent_decorators = [state()];
|
|
214
|
+
_private_isAtTop_decorators = [state()];
|
|
215
|
+
__esDecorate(this, null, _orientation_decorators, { kind: "accessor", name: "orientation", static: false, private: false, access: { has: obj => "orientation" in obj, get: obj => obj.orientation, set: (obj, value) => { obj.orientation = value; } }, metadata: _metadata }, _orientation_initializers, _orientation_extraInitializers);
|
|
216
|
+
__esDecorate(this, null, _fade_decorators, { kind: "accessor", name: "fade", static: false, private: false, access: { has: obj => "fade" in obj, get: obj => obj.fade, set: (obj, value) => { obj.fade = value; } }, metadata: _metadata }, _fade_initializers, _fade_extraInitializers);
|
|
217
|
+
__esDecorate(this, null, _maxHeight_decorators, { kind: "accessor", name: "maxHeight", static: false, private: false, access: { has: obj => "maxHeight" in obj, get: obj => obj.maxHeight, set: (obj, value) => { obj.maxHeight = value; } }, metadata: _metadata }, _maxHeight_initializers, _maxHeight_extraInitializers);
|
|
218
|
+
__esDecorate(this, _private_hasOverflowX_descriptor = { get: __setFunctionName(function () { return this.#hasOverflowX_accessor_storage; }, "#hasOverflowX", "get"), set: __setFunctionName(function (value) { this.#hasOverflowX_accessor_storage = value; }, "#hasOverflowX", "set") }, _private_hasOverflowX_decorators, { kind: "accessor", name: "#hasOverflowX", static: false, private: true, access: { has: obj => #hasOverflowX in obj, get: obj => obj.#hasOverflowX, set: (obj, value) => { obj.#hasOverflowX = value; } }, metadata: _metadata }, _private_hasOverflowX_initializers, _private_hasOverflowX_extraInitializers);
|
|
219
|
+
__esDecorate(this, _private_hasOverflowY_descriptor = { get: __setFunctionName(function () { return this.#hasOverflowY_accessor_storage; }, "#hasOverflowY", "get"), set: __setFunctionName(function (value) { this.#hasOverflowY_accessor_storage = value; }, "#hasOverflowY", "set") }, _private_hasOverflowY_decorators, { kind: "accessor", name: "#hasOverflowY", static: false, private: true, access: { has: obj => #hasOverflowY in obj, get: obj => obj.#hasOverflowY, set: (obj, value) => { obj.#hasOverflowY = value; } }, metadata: _metadata }, _private_hasOverflowY_initializers, _private_hasOverflowY_extraInitializers);
|
|
220
|
+
__esDecorate(this, _private_hovering_descriptor = { get: __setFunctionName(function () { return this.#hovering_accessor_storage; }, "#hovering", "get"), set: __setFunctionName(function (value) { this.#hovering_accessor_storage = value; }, "#hovering", "set") }, _private_hovering_decorators, { kind: "accessor", name: "#hovering", static: false, private: true, access: { has: obj => #hovering in obj, get: obj => obj.#hovering, set: (obj, value) => { obj.#hovering = value; } }, metadata: _metadata }, _private_hovering_initializers, _private_hovering_extraInitializers);
|
|
221
|
+
__esDecorate(this, _private_scrolling_descriptor = { get: __setFunctionName(function () { return this.#scrolling_accessor_storage; }, "#scrolling", "get"), set: __setFunctionName(function (value) { this.#scrolling_accessor_storage = value; }, "#scrolling", "set") }, _private_scrolling_decorators, { kind: "accessor", name: "#scrolling", static: false, private: true, access: { has: obj => #scrolling in obj, get: obj => obj.#scrolling, set: (obj, value) => { obj.#scrolling = value; } }, metadata: _metadata }, _private_scrolling_initializers, _private_scrolling_extraInitializers);
|
|
222
|
+
__esDecorate(this, _private_thumbHeightPercent_descriptor = { get: __setFunctionName(function () { return this.#thumbHeightPercent_accessor_storage; }, "#thumbHeightPercent", "get"), set: __setFunctionName(function (value) { this.#thumbHeightPercent_accessor_storage = value; }, "#thumbHeightPercent", "set") }, _private_thumbHeightPercent_decorators, { kind: "accessor", name: "#thumbHeightPercent", static: false, private: true, access: { has: obj => #thumbHeightPercent in obj, get: obj => obj.#thumbHeightPercent, set: (obj, value) => { obj.#thumbHeightPercent = value; } }, metadata: _metadata }, _private_thumbHeightPercent_initializers, _private_thumbHeightPercent_extraInitializers);
|
|
223
|
+
__esDecorate(this, _private_thumbWidthPercent_descriptor = { get: __setFunctionName(function () { return this.#thumbWidthPercent_accessor_storage; }, "#thumbWidthPercent", "get"), set: __setFunctionName(function (value) { this.#thumbWidthPercent_accessor_storage = value; }, "#thumbWidthPercent", "set") }, _private_thumbWidthPercent_decorators, { kind: "accessor", name: "#thumbWidthPercent", static: false, private: true, access: { has: obj => #thumbWidthPercent in obj, get: obj => obj.#thumbWidthPercent, set: (obj, value) => { obj.#thumbWidthPercent = value; } }, metadata: _metadata }, _private_thumbWidthPercent_initializers, _private_thumbWidthPercent_extraInitializers);
|
|
224
|
+
__esDecorate(this, _private_thumbTopPercent_descriptor = { get: __setFunctionName(function () { return this.#thumbTopPercent_accessor_storage; }, "#thumbTopPercent", "get"), set: __setFunctionName(function (value) { this.#thumbTopPercent_accessor_storage = value; }, "#thumbTopPercent", "set") }, _private_thumbTopPercent_decorators, { kind: "accessor", name: "#thumbTopPercent", static: false, private: true, access: { has: obj => #thumbTopPercent in obj, get: obj => obj.#thumbTopPercent, set: (obj, value) => { obj.#thumbTopPercent = value; } }, metadata: _metadata }, _private_thumbTopPercent_initializers, _private_thumbTopPercent_extraInitializers);
|
|
225
|
+
__esDecorate(this, _private_thumbLeftPercent_descriptor = { get: __setFunctionName(function () { return this.#thumbLeftPercent_accessor_storage; }, "#thumbLeftPercent", "get"), set: __setFunctionName(function (value) { this.#thumbLeftPercent_accessor_storage = value; }, "#thumbLeftPercent", "set") }, _private_thumbLeftPercent_decorators, { kind: "accessor", name: "#thumbLeftPercent", static: false, private: true, access: { has: obj => #thumbLeftPercent in obj, get: obj => obj.#thumbLeftPercent, set: (obj, value) => { obj.#thumbLeftPercent = value; } }, metadata: _metadata }, _private_thumbLeftPercent_initializers, _private_thumbLeftPercent_extraInitializers);
|
|
226
|
+
__esDecorate(this, _private_isAtTop_descriptor = { get: __setFunctionName(function () { return this.#isAtTop_accessor_storage; }, "#isAtTop", "get"), set: __setFunctionName(function (value) { this.#isAtTop_accessor_storage = value; }, "#isAtTop", "set") }, _private_isAtTop_decorators, { kind: "accessor", name: "#isAtTop", static: false, private: true, access: { has: obj => #isAtTop in obj, get: obj => obj.#isAtTop, set: (obj, value) => { obj.#isAtTop = value; } }, metadata: _metadata }, _private_isAtTop_initializers, _private_isAtTop_extraInitializers);
|
|
227
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
142
228
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
get #thumbTopPercent() { return this.#thumbTopPercent_accessor_storage; }
|
|
165
|
-
set #thumbTopPercent(value) { this.#thumbTopPercent_accessor_storage = value; }
|
|
166
|
-
#thumbLeftPercent_accessor_storage = 0;
|
|
167
|
-
get #thumbLeftPercent() { return this.#thumbLeftPercent_accessor_storage; }
|
|
168
|
-
set #thumbLeftPercent(value) { this.#thumbLeftPercent_accessor_storage = value; }
|
|
169
|
-
#isAtTop_accessor_storage = true;
|
|
170
|
-
get #isAtTop() { return this.#isAtTop_accessor_storage; }
|
|
171
|
-
set #isAtTop(value) { this.#isAtTop_accessor_storage = value; }
|
|
172
|
-
static #SCROLL_BOTTOM_TOLERANCE = 1;
|
|
173
|
-
#isAtBottom = true;
|
|
174
|
-
#prevScrollTop = 0;
|
|
175
|
-
#scrollEndTimer;
|
|
176
|
-
#resizeObserver;
|
|
177
|
-
#dragging;
|
|
178
|
-
#dragStartPointer = 0;
|
|
179
|
-
#dragStartScroll = 0;
|
|
180
|
-
// --- Lifecycle ---
|
|
181
|
-
connectedCallback() {
|
|
182
|
-
super.connectedCallback();
|
|
183
|
-
this.addEventListener("pointerenter", this.#onPointerEnter);
|
|
184
|
-
this.addEventListener("pointerleave", this.#onPointerLeave);
|
|
185
|
-
}
|
|
186
|
-
disconnectedCallback() {
|
|
187
|
-
super.disconnectedCallback();
|
|
188
|
-
this.removeEventListener("pointerenter", this.#onPointerEnter);
|
|
189
|
-
this.removeEventListener("pointerleave", this.#onPointerLeave);
|
|
190
|
-
this.#resizeObserver?.disconnect();
|
|
191
|
-
clearTimeout(this.#scrollEndTimer);
|
|
192
|
-
}
|
|
193
|
-
firstUpdated() {
|
|
194
|
-
const viewport = this.#viewport;
|
|
195
|
-
if (!viewport)
|
|
196
|
-
return;
|
|
197
|
-
this.#resizeObserver = new ResizeObserver(() => this.#measure());
|
|
198
|
-
this.#resizeObserver.observe(viewport);
|
|
199
|
-
const slot = viewport.querySelector("slot");
|
|
200
|
-
if (slot) {
|
|
201
|
-
slot.addEventListener("slotchange", () => {
|
|
202
|
-
requestAnimationFrame(() => this.#measure());
|
|
203
|
-
});
|
|
229
|
+
static tagName = "dui-scroll-area";
|
|
230
|
+
static styles = [base, styles];
|
|
231
|
+
#orientation_accessor_storage = __runInitializers(this, _orientation_initializers, "vertical");
|
|
232
|
+
/** Scroll direction(s). */
|
|
233
|
+
get orientation() { return this.#orientation_accessor_storage; }
|
|
234
|
+
set orientation(value) { this.#orientation_accessor_storage = value; }
|
|
235
|
+
#fade_accessor_storage = (__runInitializers(this, _orientation_extraInitializers), __runInitializers(this, _fade_initializers, false));
|
|
236
|
+
/** Show a fade overlay at the top when scrolled. */
|
|
237
|
+
get fade() { return this.#fade_accessor_storage; }
|
|
238
|
+
set fade(value) { this.#fade_accessor_storage = value; }
|
|
239
|
+
#maxHeight_accessor_storage = (__runInitializers(this, _fade_extraInitializers), __runInitializers(this, _maxHeight_initializers, undefined));
|
|
240
|
+
/** Optional max-height constraint (CSS value). */
|
|
241
|
+
get maxHeight() { return this.#maxHeight_accessor_storage; }
|
|
242
|
+
set maxHeight(value) { this.#maxHeight_accessor_storage = value; }
|
|
243
|
+
willUpdate(changed) {
|
|
244
|
+
if (changed.has("maxHeight")) {
|
|
245
|
+
if (this.maxHeight)
|
|
246
|
+
this.style.setProperty("--scroll-area-max-height", this.maxHeight);
|
|
247
|
+
else
|
|
248
|
+
this.style.removeProperty("--scroll-area-max-height");
|
|
249
|
+
}
|
|
204
250
|
}
|
|
205
|
-
this
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
251
|
+
#hasOverflowX_accessor_storage = (__runInitializers(this, _maxHeight_extraInitializers), __runInitializers(this, _private_hasOverflowX_initializers, false));
|
|
252
|
+
// --- Internal state ---
|
|
253
|
+
get #hasOverflowX() { return _private_hasOverflowX_descriptor.get.call(this); }
|
|
254
|
+
set #hasOverflowX(value) { return _private_hasOverflowX_descriptor.set.call(this, value); }
|
|
255
|
+
#hasOverflowY_accessor_storage = (__runInitializers(this, _private_hasOverflowX_extraInitializers), __runInitializers(this, _private_hasOverflowY_initializers, false));
|
|
256
|
+
get #hasOverflowY() { return _private_hasOverflowY_descriptor.get.call(this); }
|
|
257
|
+
set #hasOverflowY(value) { return _private_hasOverflowY_descriptor.set.call(this, value); }
|
|
258
|
+
#hovering_accessor_storage = (__runInitializers(this, _private_hasOverflowY_extraInitializers), __runInitializers(this, _private_hovering_initializers, false));
|
|
259
|
+
get #hovering() { return _private_hovering_descriptor.get.call(this); }
|
|
260
|
+
set #hovering(value) { return _private_hovering_descriptor.set.call(this, value); }
|
|
261
|
+
#scrolling_accessor_storage = (__runInitializers(this, _private_hovering_extraInitializers), __runInitializers(this, _private_scrolling_initializers, false));
|
|
262
|
+
get #scrolling() { return _private_scrolling_descriptor.get.call(this); }
|
|
263
|
+
set #scrolling(value) { return _private_scrolling_descriptor.set.call(this, value); }
|
|
264
|
+
#thumbHeightPercent_accessor_storage = (__runInitializers(this, _private_scrolling_extraInitializers), __runInitializers(this, _private_thumbHeightPercent_initializers, 0));
|
|
265
|
+
get #thumbHeightPercent() { return _private_thumbHeightPercent_descriptor.get.call(this); }
|
|
266
|
+
set #thumbHeightPercent(value) { return _private_thumbHeightPercent_descriptor.set.call(this, value); }
|
|
267
|
+
#thumbWidthPercent_accessor_storage = (__runInitializers(this, _private_thumbHeightPercent_extraInitializers), __runInitializers(this, _private_thumbWidthPercent_initializers, 0));
|
|
268
|
+
get #thumbWidthPercent() { return _private_thumbWidthPercent_descriptor.get.call(this); }
|
|
269
|
+
set #thumbWidthPercent(value) { return _private_thumbWidthPercent_descriptor.set.call(this, value); }
|
|
270
|
+
#thumbTopPercent_accessor_storage = (__runInitializers(this, _private_thumbWidthPercent_extraInitializers), __runInitializers(this, _private_thumbTopPercent_initializers, 0));
|
|
271
|
+
get #thumbTopPercent() { return _private_thumbTopPercent_descriptor.get.call(this); }
|
|
272
|
+
set #thumbTopPercent(value) { return _private_thumbTopPercent_descriptor.set.call(this, value); }
|
|
273
|
+
#thumbLeftPercent_accessor_storage = (__runInitializers(this, _private_thumbTopPercent_extraInitializers), __runInitializers(this, _private_thumbLeftPercent_initializers, 0));
|
|
274
|
+
get #thumbLeftPercent() { return _private_thumbLeftPercent_descriptor.get.call(this); }
|
|
275
|
+
set #thumbLeftPercent(value) { return _private_thumbLeftPercent_descriptor.set.call(this, value); }
|
|
276
|
+
#isAtTop_accessor_storage = (__runInitializers(this, _private_thumbLeftPercent_extraInitializers), __runInitializers(this, _private_isAtTop_initializers, true));
|
|
277
|
+
get #isAtTop() { return _private_isAtTop_descriptor.get.call(this); }
|
|
278
|
+
set #isAtTop(value) { return _private_isAtTop_descriptor.set.call(this, value); }
|
|
279
|
+
static #SCROLL_BOTTOM_TOLERANCE = 1;
|
|
280
|
+
#isAtBottom = (__runInitializers(this, _private_isAtTop_extraInitializers), true);
|
|
281
|
+
#prevScrollTop = 0;
|
|
282
|
+
#scrollEndTimer;
|
|
283
|
+
#resizeObserver;
|
|
284
|
+
#dragging;
|
|
285
|
+
#dragStartPointer = 0;
|
|
286
|
+
#dragStartScroll = 0;
|
|
287
|
+
// --- Lifecycle ---
|
|
288
|
+
connectedCallback() {
|
|
289
|
+
super.connectedCallback();
|
|
290
|
+
this.addEventListener("pointerenter", this.#onPointerEnter);
|
|
291
|
+
this.addEventListener("pointerleave", this.#onPointerLeave);
|
|
216
292
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
get isAtBottom() {
|
|
224
|
-
return this.#isAtBottom;
|
|
225
|
-
}
|
|
226
|
-
// --- Getters ---
|
|
227
|
-
get #viewport() {
|
|
228
|
-
return this.shadowRoot?.querySelector(".Viewport") ?? null;
|
|
229
|
-
}
|
|
230
|
-
get #showVertical() {
|
|
231
|
-
return this.orientation === "vertical" || this.orientation === "both";
|
|
232
|
-
}
|
|
233
|
-
get #showHorizontal() {
|
|
234
|
-
return this.orientation === "horizontal" || this.orientation === "both";
|
|
235
|
-
}
|
|
236
|
-
// --- Measurement ---
|
|
237
|
-
#measure = () => {
|
|
238
|
-
const vp = this.#viewport;
|
|
239
|
-
if (!vp)
|
|
240
|
-
return;
|
|
241
|
-
const hasOverflowY = vp.scrollHeight > vp.clientHeight;
|
|
242
|
-
const hasOverflowX = vp.scrollWidth > vp.clientWidth;
|
|
243
|
-
this.#hasOverflowY = hasOverflowY;
|
|
244
|
-
this.#hasOverflowX = hasOverflowX;
|
|
245
|
-
if (hasOverflowY) {
|
|
246
|
-
this.#thumbHeightPercent = (vp.clientHeight / vp.scrollHeight) * 100;
|
|
293
|
+
disconnectedCallback() {
|
|
294
|
+
super.disconnectedCallback();
|
|
295
|
+
this.removeEventListener("pointerenter", this.#onPointerEnter);
|
|
296
|
+
this.removeEventListener("pointerleave", this.#onPointerLeave);
|
|
297
|
+
this.#resizeObserver?.disconnect();
|
|
298
|
+
clearTimeout(this.#scrollEndTimer);
|
|
247
299
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
300
|
+
firstUpdated() {
|
|
301
|
+
const viewport = this.#viewport;
|
|
302
|
+
if (!viewport)
|
|
303
|
+
return;
|
|
304
|
+
this.#resizeObserver = new ResizeObserver(() => this.#measure());
|
|
305
|
+
this.#resizeObserver.observe(viewport);
|
|
306
|
+
const slot = viewport.querySelector("slot");
|
|
307
|
+
if (slot) {
|
|
308
|
+
const observe = () => {
|
|
309
|
+
for (const node of slot.assignedElements()) {
|
|
310
|
+
this.#resizeObserver.observe(node);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
slot.addEventListener("slotchange", () => {
|
|
314
|
+
observe();
|
|
315
|
+
requestAnimationFrame(() => this.#measure());
|
|
316
|
+
});
|
|
317
|
+
observe();
|
|
318
|
+
}
|
|
319
|
+
this.#measure();
|
|
267
320
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.#isAtTop = vp.scrollTop <= 0;
|
|
279
|
-
this.#isAtBottom =
|
|
280
|
-
vp.scrollTop + vp.clientHeight >=
|
|
281
|
-
vp.scrollHeight - _a.#SCROLL_BOTTOM_TOLERANCE;
|
|
282
|
-
if (scrolledUp && wasAtBottom && !this.#isAtBottom) {
|
|
283
|
-
this.dispatchEvent(new Event("scrolled-from-bottom", { bubbles: true, composed: true }));
|
|
321
|
+
// --- Public methods ---
|
|
322
|
+
/** Scroll the viewport to the bottom. */
|
|
323
|
+
async scrollToBottom() {
|
|
324
|
+
await this.updateComplete;
|
|
325
|
+
const viewport = this.#viewport;
|
|
326
|
+
if (viewport) {
|
|
327
|
+
viewport.scrollTop = viewport.scrollHeight;
|
|
328
|
+
this.#isAtBottom = true;
|
|
329
|
+
this.#prevScrollTop = viewport.scrollTop;
|
|
330
|
+
}
|
|
284
331
|
}
|
|
285
|
-
|
|
286
|
-
|
|
332
|
+
/** Whether the viewport is scrolled to the top. */
|
|
333
|
+
get isAtTop() {
|
|
334
|
+
return this.#isAtTop;
|
|
287
335
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.#scrolling = false;
|
|
292
|
-
}, 1000);
|
|
293
|
-
};
|
|
294
|
-
#onPointerEnter = () => {
|
|
295
|
-
this.#hovering = true;
|
|
296
|
-
this.#measure();
|
|
297
|
-
};
|
|
298
|
-
#onPointerLeave = () => {
|
|
299
|
-
this.#hovering = false;
|
|
300
|
-
};
|
|
301
|
-
// --- Track click (jump to position) ---
|
|
302
|
-
#onTrackPointerDown = (orientation, event) => {
|
|
303
|
-
event.preventDefault();
|
|
304
|
-
event.stopPropagation();
|
|
305
|
-
const vp = this.#viewport;
|
|
306
|
-
if (!vp)
|
|
307
|
-
return;
|
|
308
|
-
if (orientation === "vertical") {
|
|
309
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
310
|
-
if (!track)
|
|
311
|
-
return;
|
|
312
|
-
const rect = track.getBoundingClientRect();
|
|
313
|
-
const fraction = (event.clientY - rect.top) / rect.height;
|
|
314
|
-
vp.scrollTop = fraction * (vp.scrollHeight - vp.clientHeight);
|
|
336
|
+
/** Whether the viewport is scrolled to the bottom. */
|
|
337
|
+
get isAtBottom() {
|
|
338
|
+
return this.#isAtBottom;
|
|
315
339
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return;
|
|
320
|
-
const rect = track.getBoundingClientRect();
|
|
321
|
-
const fraction = (event.clientX - rect.left) / rect.width;
|
|
322
|
-
vp.scrollLeft = fraction * (vp.scrollWidth - vp.clientWidth);
|
|
340
|
+
// --- Getters ---
|
|
341
|
+
get #viewport() {
|
|
342
|
+
return this.shadowRoot?.querySelector(".Viewport") ?? null;
|
|
323
343
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
#onThumbPointerDown = (orientation, event) => {
|
|
327
|
-
event.preventDefault();
|
|
328
|
-
event.stopPropagation();
|
|
329
|
-
const vp = this.#viewport;
|
|
330
|
-
if (!vp)
|
|
331
|
-
return;
|
|
332
|
-
this.#dragging = orientation;
|
|
333
|
-
if (orientation === "vertical") {
|
|
334
|
-
this.#dragStartPointer = event.clientY;
|
|
335
|
-
this.#dragStartScroll = vp.scrollTop;
|
|
344
|
+
get #showVertical() {
|
|
345
|
+
return this.orientation === "vertical" || this.orientation === "both";
|
|
336
346
|
}
|
|
337
|
-
|
|
338
|
-
this
|
|
339
|
-
this.#dragStartScroll = vp.scrollLeft;
|
|
347
|
+
get #showHorizontal() {
|
|
348
|
+
return this.orientation === "horizontal" || this.orientation === "both";
|
|
340
349
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const vp = this.#viewport;
|
|
346
|
-
if (!vp || !this.#dragging)
|
|
347
|
-
return;
|
|
348
|
-
if (this.#dragging === "vertical") {
|
|
349
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
350
|
-
if (!track)
|
|
350
|
+
// --- Measurement ---
|
|
351
|
+
#measure = () => {
|
|
352
|
+
const vp = this.#viewport;
|
|
353
|
+
if (!vp)
|
|
351
354
|
return;
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
355
|
+
const hasOverflowY = vp.scrollHeight > vp.clientHeight;
|
|
356
|
+
const hasOverflowX = vp.scrollWidth > vp.clientWidth;
|
|
357
|
+
this.#hasOverflowY = hasOverflowY;
|
|
358
|
+
this.#hasOverflowX = hasOverflowX;
|
|
359
|
+
if (hasOverflowY) {
|
|
360
|
+
this.#thumbHeightPercent = (vp.clientHeight / vp.scrollHeight) * 100;
|
|
361
|
+
}
|
|
362
|
+
if (hasOverflowX) {
|
|
363
|
+
this.#thumbWidthPercent = (vp.clientWidth / vp.scrollWidth) * 100;
|
|
364
|
+
}
|
|
365
|
+
this.#updateThumbPosition(vp);
|
|
366
|
+
};
|
|
367
|
+
#updateThumbPosition = (vp) => {
|
|
368
|
+
if (this.#hasOverflowY) {
|
|
369
|
+
const maxScrollTop = vp.scrollHeight - vp.clientHeight;
|
|
370
|
+
this.#thumbTopPercent =
|
|
371
|
+
maxScrollTop > 0
|
|
372
|
+
? (vp.scrollTop / maxScrollTop) * (100 - this.#thumbHeightPercent)
|
|
373
|
+
: 0;
|
|
374
|
+
}
|
|
375
|
+
if (this.#hasOverflowX) {
|
|
376
|
+
const maxScrollLeft = vp.scrollWidth - vp.clientWidth;
|
|
377
|
+
this.#thumbLeftPercent =
|
|
378
|
+
maxScrollLeft > 0
|
|
379
|
+
? (vp.scrollLeft / maxScrollLeft) * (100 - this.#thumbWidthPercent)
|
|
380
|
+
: 0;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
// --- Event handlers ---
|
|
384
|
+
#onScroll = () => {
|
|
385
|
+
const vp = this.#viewport;
|
|
386
|
+
if (!vp)
|
|
361
387
|
return;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
vp.
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
388
|
+
this.#scrolling = true;
|
|
389
|
+
this.#updateThumbPosition(vp);
|
|
390
|
+
const wasAtBottom = this.#isAtBottom;
|
|
391
|
+
const scrolledUp = vp.scrollTop < this.#prevScrollTop;
|
|
392
|
+
this.#isAtTop = vp.scrollTop <= 0;
|
|
393
|
+
this.#isAtBottom =
|
|
394
|
+
vp.scrollTop + vp.clientHeight >=
|
|
395
|
+
vp.scrollHeight - DuiScrollArea.#SCROLL_BOTTOM_TOLERANCE;
|
|
396
|
+
if (scrolledUp && wasAtBottom && !this.#isAtBottom) {
|
|
397
|
+
this.dispatchEvent(new Event("scrolled-from-bottom", { bubbles: true, composed: true }));
|
|
398
|
+
}
|
|
399
|
+
else if (!wasAtBottom && this.#isAtBottom) {
|
|
400
|
+
this.dispatchEvent(new Event("scrolled-to-bottom", { bubbles: true, composed: true }));
|
|
401
|
+
}
|
|
402
|
+
this.#prevScrollTop = vp.scrollTop;
|
|
403
|
+
clearTimeout(this.#scrollEndTimer);
|
|
404
|
+
this.#scrollEndTimer = setTimeout(() => {
|
|
405
|
+
this.#scrolling = false;
|
|
406
|
+
}, 1000);
|
|
407
|
+
};
|
|
408
|
+
#onPointerEnter = () => {
|
|
409
|
+
this.#hovering = true;
|
|
410
|
+
this.#measure();
|
|
411
|
+
};
|
|
412
|
+
#onPointerLeave = () => {
|
|
413
|
+
this.#hovering = false;
|
|
414
|
+
};
|
|
415
|
+
// --- Track click (jump to position) ---
|
|
416
|
+
#onTrackPointerDown = (orientation, event) => {
|
|
417
|
+
event.preventDefault();
|
|
418
|
+
event.stopPropagation();
|
|
419
|
+
const vp = this.#viewport;
|
|
420
|
+
if (!vp)
|
|
421
|
+
return;
|
|
422
|
+
if (orientation === "vertical") {
|
|
423
|
+
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
424
|
+
if (!track)
|
|
425
|
+
return;
|
|
426
|
+
const rect = track.getBoundingClientRect();
|
|
427
|
+
const fraction = (event.clientY - rect.top) / rect.height;
|
|
428
|
+
vp.scrollTop = fraction * (vp.scrollHeight - vp.clientHeight);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
|
|
432
|
+
if (!track)
|
|
433
|
+
return;
|
|
434
|
+
const rect = track.getBoundingClientRect();
|
|
435
|
+
const fraction = (event.clientX - rect.left) / rect.width;
|
|
436
|
+
vp.scrollLeft = fraction * (vp.scrollWidth - vp.clientWidth);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
// --- Thumb drag ---
|
|
440
|
+
#onThumbPointerDown = (orientation, event) => {
|
|
441
|
+
event.preventDefault();
|
|
442
|
+
event.stopPropagation();
|
|
443
|
+
const vp = this.#viewport;
|
|
444
|
+
if (!vp)
|
|
445
|
+
return;
|
|
446
|
+
this.#dragging = orientation;
|
|
447
|
+
if (orientation === "vertical") {
|
|
448
|
+
this.#dragStartPointer = event.clientY;
|
|
449
|
+
this.#dragStartScroll = vp.scrollTop;
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
this.#dragStartPointer = event.clientX;
|
|
453
|
+
this.#dragStartScroll = vp.scrollLeft;
|
|
454
|
+
}
|
|
455
|
+
document.addEventListener("pointermove", this.#onDragMove);
|
|
456
|
+
document.addEventListener("pointerup", this.#onDragEnd);
|
|
457
|
+
};
|
|
458
|
+
#onDragMove = (event) => {
|
|
459
|
+
const vp = this.#viewport;
|
|
460
|
+
if (!vp || !this.#dragging)
|
|
461
|
+
return;
|
|
462
|
+
if (this.#dragging === "vertical") {
|
|
463
|
+
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
464
|
+
if (!track)
|
|
465
|
+
return;
|
|
466
|
+
const delta = event.clientY - this.#dragStartPointer;
|
|
467
|
+
const trackHeight = track.clientHeight;
|
|
468
|
+
const scrollRange = vp.scrollHeight - vp.clientHeight;
|
|
469
|
+
vp.scrollTop =
|
|
470
|
+
this.#dragStartScroll + (delta / trackHeight) * scrollRange;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
|
|
474
|
+
if (!track)
|
|
475
|
+
return;
|
|
476
|
+
const delta = event.clientX - this.#dragStartPointer;
|
|
477
|
+
const trackWidth = track.clientWidth;
|
|
478
|
+
const scrollRange = vp.scrollWidth - vp.clientWidth;
|
|
479
|
+
vp.scrollLeft =
|
|
480
|
+
this.#dragStartScroll + (delta / trackWidth) * scrollRange;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
#onDragEnd = () => {
|
|
484
|
+
this.#dragging = undefined;
|
|
485
|
+
document.removeEventListener("pointermove", this.#onDragMove);
|
|
486
|
+
document.removeEventListener("pointerup", this.#onDragEnd);
|
|
487
|
+
};
|
|
488
|
+
// --- Render ---
|
|
489
|
+
#renderVerticalScrollbar() {
|
|
490
|
+
if (!this.#showVertical || !this.#hasOverflowY)
|
|
491
|
+
return nothing;
|
|
492
|
+
return html `
|
|
379
493
|
<div
|
|
380
494
|
class="Scrollbar"
|
|
381
495
|
part="scrollbar-vertical"
|
|
@@ -389,16 +503,16 @@ export class DuiScrollArea extends LitElement {
|
|
|
389
503
|
part="thumb-vertical"
|
|
390
504
|
data-orientation="vertical"
|
|
391
505
|
style="height: ${this.#thumbHeightPercent}%; top: ${this
|
|
392
|
-
|
|
506
|
+
.#thumbTopPercent}%; position: absolute;"
|
|
393
507
|
@pointerdown="${(e) => this.#onThumbPointerDown("vertical", e)}"
|
|
394
508
|
></div>
|
|
395
509
|
</div>
|
|
396
510
|
`;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
511
|
+
}
|
|
512
|
+
#renderHorizontalScrollbar() {
|
|
513
|
+
if (!this.#showHorizontal || !this.#hasOverflowX)
|
|
514
|
+
return nothing;
|
|
515
|
+
return html `
|
|
402
516
|
<div
|
|
403
517
|
class="Scrollbar"
|
|
404
518
|
part="scrollbar-horizontal"
|
|
@@ -412,14 +526,14 @@ export class DuiScrollArea extends LitElement {
|
|
|
412
526
|
part="thumb-horizontal"
|
|
413
527
|
data-orientation="horizontal"
|
|
414
528
|
style="width: ${this.#thumbWidthPercent}%; left: ${this
|
|
415
|
-
|
|
529
|
+
.#thumbLeftPercent}%; position: absolute;"
|
|
416
530
|
@pointerdown="${(e) => this.#onThumbPointerDown("horizontal", e)}"
|
|
417
531
|
></div>
|
|
418
532
|
</div>
|
|
419
533
|
`;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
534
|
+
}
|
|
535
|
+
render() {
|
|
536
|
+
return html `
|
|
423
537
|
<div
|
|
424
538
|
class="ScrollArea"
|
|
425
539
|
part="root"
|
|
@@ -428,26 +542,18 @@ export class DuiScrollArea extends LitElement {
|
|
|
428
542
|
?data-scrolling="${this.#scrolling}"
|
|
429
543
|
>
|
|
430
544
|
${this.fade
|
|
431
|
-
|
|
545
|
+
? html `<div
|
|
432
546
|
class="ScrollFade"
|
|
433
547
|
?data-scrolled="${!this.#isAtTop}"
|
|
434
548
|
></div>`
|
|
435
|
-
|
|
549
|
+
: nothing}
|
|
436
550
|
<div class="Viewport" part="viewport" @scroll="${this.#onScroll}">
|
|
437
551
|
<slot></slot>
|
|
438
552
|
</div>
|
|
439
553
|
${this.#renderVerticalScrollbar()} ${this.#renderHorizontalScrollbar()}
|
|
440
554
|
</div>
|
|
441
555
|
`;
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
property({ reflect: true })
|
|
447
|
-
], DuiScrollArea.prototype, "orientation", null);
|
|
448
|
-
__decorate([
|
|
449
|
-
property({ type: Boolean, reflect: true })
|
|
450
|
-
], DuiScrollArea.prototype, "fade", null);
|
|
451
|
-
__decorate([
|
|
452
|
-
property({ attribute: "max-height" })
|
|
453
|
-
], DuiScrollArea.prototype, "maxHeight", null);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
})();
|
|
559
|
+
export { DuiScrollArea };
|