@deepfuture/dui-components 0.0.12 → 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.
Files changed (89) hide show
  1. package/_deprecated/center/center.js +2 -2
  2. package/_deprecated/hstack/hstack.js +79 -33
  3. package/_deprecated/page-inset/page-inset.js +104 -56
  4. package/_deprecated/vstack/vstack.js +61 -19
  5. package/accordion/accordion-item.js +217 -147
  6. package/accordion/accordion.js +214 -149
  7. package/alert-dialog/alert-dialog-close.js +2 -2
  8. package/alert-dialog/alert-dialog-popup.js +230 -166
  9. package/alert-dialog/alert-dialog-trigger.js +2 -2
  10. package/alert-dialog/alert-dialog.js +128 -73
  11. package/avatar/avatar.js +175 -115
  12. package/badge/badge.js +2 -2
  13. package/breadcrumb/breadcrumb-ellipsis.js +2 -2
  14. package/breadcrumb/breadcrumb-item.js +2 -2
  15. package/breadcrumb/breadcrumb-link.js +2 -2
  16. package/breadcrumb/breadcrumb-page.js +2 -2
  17. package/breadcrumb/breadcrumb-separator.js +2 -2
  18. package/breadcrumb/breadcrumb.js +2 -2
  19. package/button/button.js +109 -65
  20. package/calendar/calendar.js +368 -290
  21. package/checkbox/checkbox-group.js +146 -87
  22. package/checkbox/checkbox.js +232 -167
  23. package/collapsible/collapsible.js +210 -132
  24. package/combobox/combobox.js +318 -252
  25. package/command/command-empty.js +67 -25
  26. package/command/command-group.js +87 -47
  27. package/command/command-input.js +84 -44
  28. package/command/command-item.js +168 -124
  29. package/command/command-list.js +60 -18
  30. package/command/command-separator.js +2 -2
  31. package/command/command-shortcut.js +2 -2
  32. package/command/command.js +297 -232
  33. package/data-table/data-table.js +225 -153
  34. package/dialog/dialog-close.js +2 -2
  35. package/dialog/dialog-popup.js +247 -181
  36. package/dialog/dialog-trigger.js +2 -2
  37. package/dialog/dialog.js +128 -73
  38. package/dropzone/dropzone.js +310 -249
  39. package/icon/icon.js +2 -2
  40. package/input/input.js +204 -143
  41. package/link/link.js +62 -24
  42. package/menu/menu-item.js +66 -24
  43. package/menu/menu.js +189 -136
  44. package/menubar/menubar.js +142 -91
  45. package/number-field/number-field.js +277 -204
  46. package/package.json +2 -2
  47. package/popover/popover-close.js +2 -2
  48. package/popover/popover-popup.js +126 -76
  49. package/popover/popover-trigger.js +2 -2
  50. package/popover/popover.js +181 -120
  51. package/portal/portal.js +128 -86
  52. package/preview-card/preview-card-popup.js +114 -66
  53. package/preview-card/preview-card-trigger.js +2 -2
  54. package/preview-card/preview-card.js +211 -142
  55. package/progress/progress.js +91 -45
  56. package/radio/radio-group.js +153 -90
  57. package/radio/radio.js +137 -94
  58. package/scroll-area/scroll-area.js +382 -283
  59. package/select/select.js +260 -203
  60. package/separator/separator.js +60 -18
  61. package/sidebar/sidebar-content.js +2 -2
  62. package/sidebar/sidebar-footer.js +2 -2
  63. package/sidebar/sidebar-group-label.js +2 -2
  64. package/sidebar/sidebar-group.js +2 -2
  65. package/sidebar/sidebar-header.js +2 -2
  66. package/sidebar/sidebar-inset.js +2 -2
  67. package/sidebar/sidebar-menu-button.js +118 -74
  68. package/sidebar/sidebar-menu-item.js +2 -2
  69. package/sidebar/sidebar-menu.js +2 -2
  70. package/sidebar/sidebar-provider.js +202 -129
  71. package/sidebar/sidebar-separator.js +2 -2
  72. package/sidebar/sidebar-trigger.js +2 -2
  73. package/sidebar/sidebar.js +150 -85
  74. package/slider/slider.js +217 -159
  75. package/spinner/spinner.js +70 -28
  76. package/switch/switch.js +174 -111
  77. package/tabs/tab.js +89 -47
  78. package/tabs/tabs-indicator.js +2 -2
  79. package/tabs/tabs-list.js +92 -54
  80. package/tabs/tabs-panel.js +90 -44
  81. package/tabs/tabs.js +130 -71
  82. package/textarea/textarea.js +153 -95
  83. package/toggle/toggle-group.js +184 -125
  84. package/toggle/toggle.js +131 -76
  85. package/toolbar/toolbar.js +79 -33
  86. package/tooltip/tooltip-popup.js +108 -60
  87. package/tooltip/tooltip-trigger.js +93 -55
  88. package/tooltip/tooltip.js +225 -154
  89. package/trunc/trunc.js +78 -34
@@ -1,13 +1,44 @@
1
1
  /** Ported from original DUI: deep-future-app/app/client/components/dui/scroll-area */
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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,271 +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
- export class DuiScrollArea extends LitElement {
122
- static { this.tagName = "dui-scroll-area"; }
123
- static { this.styles = [base, styles]; }
124
- #orientation_accessor_storage = "vertical";
125
- /** Scroll direction(s). */
126
- get orientation() { return this.#orientation_accessor_storage; }
127
- set orientation(value) { this.#orientation_accessor_storage = value; }
128
- #fade_accessor_storage = false;
129
- /** Show a fade overlay at the top when scrolled. */
130
- get fade() { return this.#fade_accessor_storage; }
131
- set fade(value) { this.#fade_accessor_storage = value; }
132
- #maxHeight_accessor_storage = undefined;
133
- /** Optional max-height constraint (CSS value). */
134
- get maxHeight() { return this.#maxHeight_accessor_storage; }
135
- set maxHeight(value) { this.#maxHeight_accessor_storage = value; }
136
- willUpdate(changed) {
137
- if (changed.has("maxHeight")) {
138
- if (this.maxHeight)
139
- this.style.setProperty("--scroll-area-max-height", this.maxHeight);
140
- else
141
- this.style.removeProperty("--scroll-area-max-height");
142
- }
143
- }
144
- #hasOverflowX_accessor_storage = false;
145
- // --- Internal state ---
146
- get #hasOverflowX() { return this.#hasOverflowX_accessor_storage; }
147
- set #hasOverflowX(value) { this.#hasOverflowX_accessor_storage = value; }
148
- #hasOverflowY_accessor_storage = false;
149
- get #hasOverflowY() { return this.#hasOverflowY_accessor_storage; }
150
- set #hasOverflowY(value) { this.#hasOverflowY_accessor_storage = value; }
151
- #hovering_accessor_storage = false;
152
- get #hovering() { return this.#hovering_accessor_storage; }
153
- set #hovering(value) { this.#hovering_accessor_storage = value; }
154
- #scrolling_accessor_storage = false;
155
- get #scrolling() { return this.#scrolling_accessor_storage; }
156
- set #scrolling(value) { this.#scrolling_accessor_storage = value; }
157
- #thumbHeightPercent_accessor_storage = 0;
158
- get #thumbHeightPercent() { return this.#thumbHeightPercent_accessor_storage; }
159
- set #thumbHeightPercent(value) { this.#thumbHeightPercent_accessor_storage = value; }
160
- #thumbWidthPercent_accessor_storage = 0;
161
- get #thumbWidthPercent() { return this.#thumbWidthPercent_accessor_storage; }
162
- set #thumbWidthPercent(value) { this.#thumbWidthPercent_accessor_storage = value; }
163
- #thumbTopPercent_accessor_storage = 0;
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
- const observe = () => {
202
- for (const node of slot.assignedElements()) {
203
- this.#resizeObserver.observe(node);
204
- }
205
- };
206
- slot.addEventListener("slotchange", () => {
207
- observe();
208
- requestAnimationFrame(() => this.#measure());
209
- });
210
- observe();
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 });
211
228
  }
212
- this.#measure();
213
- }
214
- // --- Public methods ---
215
- /** Scroll the viewport to the bottom. */
216
- async scrollToBottom() {
217
- await this.updateComplete;
218
- const viewport = this.#viewport;
219
- if (viewport) {
220
- viewport.scrollTop = viewport.scrollHeight;
221
- this.#isAtBottom = true;
222
- this.#prevScrollTop = viewport.scrollTop;
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
+ }
223
250
  }
224
- }
225
- /** Whether the viewport is scrolled to the top. */
226
- get isAtTop() {
227
- return this.#isAtTop;
228
- }
229
- /** Whether the viewport is scrolled to the bottom. */
230
- get isAtBottom() {
231
- return this.#isAtBottom;
232
- }
233
- // --- Getters ---
234
- get #viewport() {
235
- return this.shadowRoot?.querySelector(".Viewport") ?? null;
236
- }
237
- get #showVertical() {
238
- return this.orientation === "vertical" || this.orientation === "both";
239
- }
240
- get #showHorizontal() {
241
- return this.orientation === "horizontal" || this.orientation === "both";
242
- }
243
- // --- Measurement ---
244
- #measure = () => {
245
- const vp = this.#viewport;
246
- if (!vp)
247
- return;
248
- const hasOverflowY = vp.scrollHeight > vp.clientHeight;
249
- const hasOverflowX = vp.scrollWidth > vp.clientWidth;
250
- this.#hasOverflowY = hasOverflowY;
251
- this.#hasOverflowX = hasOverflowX;
252
- if (hasOverflowY) {
253
- this.#thumbHeightPercent = (vp.clientHeight / vp.scrollHeight) * 100;
254
- }
255
- if (hasOverflowX) {
256
- this.#thumbWidthPercent = (vp.clientWidth / vp.scrollWidth) * 100;
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);
257
292
  }
258
- this.#updateThumbPosition(vp);
259
- };
260
- #updateThumbPosition = (vp) => {
261
- if (this.#hasOverflowY) {
262
- const maxScrollTop = vp.scrollHeight - vp.clientHeight;
263
- this.#thumbTopPercent =
264
- maxScrollTop > 0
265
- ? (vp.scrollTop / maxScrollTop) * (100 - this.#thumbHeightPercent)
266
- : 0;
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);
267
299
  }
268
- if (this.#hasOverflowX) {
269
- const maxScrollLeft = vp.scrollWidth - vp.clientWidth;
270
- this.#thumbLeftPercent =
271
- maxScrollLeft > 0
272
- ? (vp.scrollLeft / maxScrollLeft) * (100 - this.#thumbWidthPercent)
273
- : 0;
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();
274
320
  }
275
- };
276
- // --- Event handlers ---
277
- #onScroll = () => {
278
- const vp = this.#viewport;
279
- if (!vp)
280
- return;
281
- this.#scrolling = true;
282
- this.#updateThumbPosition(vp);
283
- const wasAtBottom = this.#isAtBottom;
284
- const scrolledUp = vp.scrollTop < this.#prevScrollTop;
285
- this.#isAtTop = vp.scrollTop <= 0;
286
- this.#isAtBottom =
287
- vp.scrollTop + vp.clientHeight >=
288
- vp.scrollHeight - _a.#SCROLL_BOTTOM_TOLERANCE;
289
- if (scrolledUp && wasAtBottom && !this.#isAtBottom) {
290
- 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
+ }
291
331
  }
292
- else if (!wasAtBottom && this.#isAtBottom) {
293
- this.dispatchEvent(new Event("scrolled-to-bottom", { bubbles: true, composed: true }));
332
+ /** Whether the viewport is scrolled to the top. */
333
+ get isAtTop() {
334
+ return this.#isAtTop;
294
335
  }
295
- this.#prevScrollTop = vp.scrollTop;
296
- clearTimeout(this.#scrollEndTimer);
297
- this.#scrollEndTimer = setTimeout(() => {
298
- this.#scrolling = false;
299
- }, 1000);
300
- };
301
- #onPointerEnter = () => {
302
- this.#hovering = true;
303
- this.#measure();
304
- };
305
- #onPointerLeave = () => {
306
- this.#hovering = false;
307
- };
308
- // --- Track click (jump to position) ---
309
- #onTrackPointerDown = (orientation, event) => {
310
- event.preventDefault();
311
- event.stopPropagation();
312
- const vp = this.#viewport;
313
- if (!vp)
314
- return;
315
- if (orientation === "vertical") {
316
- const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
317
- if (!track)
318
- return;
319
- const rect = track.getBoundingClientRect();
320
- const fraction = (event.clientY - rect.top) / rect.height;
321
- vp.scrollTop = fraction * (vp.scrollHeight - vp.clientHeight);
336
+ /** Whether the viewport is scrolled to the bottom. */
337
+ get isAtBottom() {
338
+ return this.#isAtBottom;
322
339
  }
323
- else {
324
- const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
325
- if (!track)
326
- return;
327
- const rect = track.getBoundingClientRect();
328
- const fraction = (event.clientX - rect.left) / rect.width;
329
- vp.scrollLeft = fraction * (vp.scrollWidth - vp.clientWidth);
340
+ // --- Getters ---
341
+ get #viewport() {
342
+ return this.shadowRoot?.querySelector(".Viewport") ?? null;
330
343
  }
331
- };
332
- // --- Thumb drag ---
333
- #onThumbPointerDown = (orientation, event) => {
334
- event.preventDefault();
335
- event.stopPropagation();
336
- const vp = this.#viewport;
337
- if (!vp)
338
- return;
339
- this.#dragging = orientation;
340
- if (orientation === "vertical") {
341
- this.#dragStartPointer = event.clientY;
342
- this.#dragStartScroll = vp.scrollTop;
344
+ get #showVertical() {
345
+ return this.orientation === "vertical" || this.orientation === "both";
343
346
  }
344
- else {
345
- this.#dragStartPointer = event.clientX;
346
- this.#dragStartScroll = vp.scrollLeft;
347
+ get #showHorizontal() {
348
+ return this.orientation === "horizontal" || this.orientation === "both";
347
349
  }
348
- document.addEventListener("pointermove", this.#onDragMove);
349
- document.addEventListener("pointerup", this.#onDragEnd);
350
- };
351
- #onDragMove = (event) => {
352
- const vp = this.#viewport;
353
- if (!vp || !this.#dragging)
354
- return;
355
- if (this.#dragging === "vertical") {
356
- const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
357
- if (!track)
350
+ // --- Measurement ---
351
+ #measure = () => {
352
+ const vp = this.#viewport;
353
+ if (!vp)
358
354
  return;
359
- const delta = event.clientY - this.#dragStartPointer;
360
- const trackHeight = track.clientHeight;
361
- const scrollRange = vp.scrollHeight - vp.clientHeight;
362
- vp.scrollTop =
363
- this.#dragStartScroll + (delta / trackHeight) * scrollRange;
364
- }
365
- else {
366
- const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
367
- if (!track)
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)
368
387
  return;
369
- const delta = event.clientX - this.#dragStartPointer;
370
- const trackWidth = track.clientWidth;
371
- const scrollRange = vp.scrollWidth - vp.clientWidth;
372
- vp.scrollLeft =
373
- this.#dragStartScroll + (delta / trackWidth) * scrollRange;
374
- }
375
- };
376
- #onDragEnd = () => {
377
- this.#dragging = undefined;
378
- document.removeEventListener("pointermove", this.#onDragMove);
379
- document.removeEventListener("pointerup", this.#onDragEnd);
380
- };
381
- // --- Render ---
382
- #renderVerticalScrollbar() {
383
- if (!this.#showVertical || !this.#hasOverflowY)
384
- return nothing;
385
- return html `
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 `
386
493
  <div
387
494
  class="Scrollbar"
388
495
  part="scrollbar-vertical"
@@ -396,16 +503,16 @@ export class DuiScrollArea extends LitElement {
396
503
  part="thumb-vertical"
397
504
  data-orientation="vertical"
398
505
  style="height: ${this.#thumbHeightPercent}%; top: ${this
399
- .#thumbTopPercent}%; position: absolute;"
506
+ .#thumbTopPercent}%; position: absolute;"
400
507
  @pointerdown="${(e) => this.#onThumbPointerDown("vertical", e)}"
401
508
  ></div>
402
509
  </div>
403
510
  `;
404
- }
405
- #renderHorizontalScrollbar() {
406
- if (!this.#showHorizontal || !this.#hasOverflowX)
407
- return nothing;
408
- return html `
511
+ }
512
+ #renderHorizontalScrollbar() {
513
+ if (!this.#showHorizontal || !this.#hasOverflowX)
514
+ return nothing;
515
+ return html `
409
516
  <div
410
517
  class="Scrollbar"
411
518
  part="scrollbar-horizontal"
@@ -419,14 +526,14 @@ export class DuiScrollArea extends LitElement {
419
526
  part="thumb-horizontal"
420
527
  data-orientation="horizontal"
421
528
  style="width: ${this.#thumbWidthPercent}%; left: ${this
422
- .#thumbLeftPercent}%; position: absolute;"
529
+ .#thumbLeftPercent}%; position: absolute;"
423
530
  @pointerdown="${(e) => this.#onThumbPointerDown("horizontal", e)}"
424
531
  ></div>
425
532
  </div>
426
533
  `;
427
- }
428
- render() {
429
- return html `
534
+ }
535
+ render() {
536
+ return html `
430
537
  <div
431
538
  class="ScrollArea"
432
539
  part="root"
@@ -435,26 +542,18 @@ export class DuiScrollArea extends LitElement {
435
542
  ?data-scrolling="${this.#scrolling}"
436
543
  >
437
544
  ${this.fade
438
- ? html `<div
545
+ ? html `<div
439
546
  class="ScrollFade"
440
547
  ?data-scrolled="${!this.#isAtTop}"
441
548
  ></div>`
442
- : nothing}
549
+ : nothing}
443
550
  <div class="Viewport" part="viewport" @scroll="${this.#onScroll}">
444
551
  <slot></slot>
445
552
  </div>
446
553
  ${this.#renderVerticalScrollbar()} ${this.#renderHorizontalScrollbar()}
447
554
  </div>
448
555
  `;
449
- }
450
- }
451
- _a = DuiScrollArea;
452
- __decorate([
453
- property({ reflect: true })
454
- ], DuiScrollArea.prototype, "orientation", null);
455
- __decorate([
456
- property({ type: Boolean, reflect: true })
457
- ], DuiScrollArea.prototype, "fade", null);
458
- __decorate([
459
- property({ attribute: "max-height" })
460
- ], DuiScrollArea.prototype, "maxHeight", null);
556
+ }
557
+ };
558
+ })();
559
+ export { DuiScrollArea };