@deepfuture/dui-components 0.0.21 → 1.0.1
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 +56 -65
- package/_install.js +11 -0
- package/accordion/accordion-item.d.ts +3 -20
- package/accordion/accordion-item.js +92 -292
- package/accordion/accordion.d.ts +3 -18
- package/accordion/accordion.js +9 -247
- package/accordion/index.d.ts +6 -6
- package/accordion/index.js +5 -5
- package/alert-dialog/alert-dialog-close.d.ts +3 -14
- package/alert-dialog/alert-dialog-close.js +4 -34
- package/alert-dialog/alert-dialog-popup.d.ts +3 -32
- package/alert-dialog/alert-dialog-popup.js +68 -317
- package/alert-dialog/alert-dialog-trigger.d.ts +3 -14
- package/alert-dialog/alert-dialog-trigger.js +4 -51
- package/alert-dialog/alert-dialog.d.ts +3 -30
- package/alert-dialog/alert-dialog.js +8 -158
- package/alert-dialog/index.d.ts +11 -11
- package/alert-dialog/index.js +9 -9
- package/all.d.ts +159 -123
- package/all.js +134 -231
- package/avatar/avatar.d.ts +3 -39
- package/avatar/avatar.js +18 -238
- package/avatar/index.d.ts +4 -4
- package/avatar/index.js +3 -3
- package/badge/badge.d.ts +3 -10
- package/badge/badge.js +87 -22
- package/badge/index.d.ts +2 -3
- package/badge/index.js +2 -3
- package/breadcrumb/breadcrumb-ellipsis.d.ts +3 -12
- package/breadcrumb/breadcrumb-ellipsis.js +8 -34
- package/breadcrumb/breadcrumb-item.d.ts +3 -11
- package/breadcrumb/breadcrumb-item.js +7 -26
- package/breadcrumb/breadcrumb-link.d.ts +3 -12
- package/breadcrumb/breadcrumb-link.js +16 -26
- package/breadcrumb/breadcrumb-page.d.ts +3 -11
- package/breadcrumb/breadcrumb-page.js +8 -31
- package/breadcrumb/breadcrumb-separator.d.ts +3 -12
- package/breadcrumb/breadcrumb-separator.js +8 -31
- package/breadcrumb/breadcrumb.d.ts +3 -12
- package/breadcrumb/breadcrumb.js +10 -33
- package/breadcrumb/index.d.ts +12 -13
- package/breadcrumb/index.js +12 -13
- package/button/button.d.ts +3 -32
- package/button/button.js +220 -165
- package/button/index.d.ts +3 -3
- package/button/index.js +3 -3
- package/calendar/calendar.d.ts +3 -31
- package/calendar/calendar.js +71 -481
- package/calendar/index.d.ts +3 -3
- package/calendar/index.js +3 -3
- package/card/card.d.ts +3 -27
- package/card/card.js +80 -163
- package/card/index.d.ts +2 -3
- package/card/index.js +2 -3
- package/card-grid/card-grid.d.ts +3 -15
- package/card-grid/card-grid.js +8 -106
- package/card-grid/index.d.ts +2 -3
- package/card-grid/index.js +2 -3
- package/checkbox/checkbox-group.d.ts +3 -34
- package/checkbox/checkbox-group.js +11 -188
- package/checkbox/checkbox.d.ts +3 -47
- package/checkbox/checkbox.js +43 -341
- package/checkbox/index.d.ts +6 -6
- package/checkbox/index.js +5 -5
- package/collapsible/collapsible.d.ts +3 -20
- package/collapsible/collapsible.js +82 -277
- package/collapsible/index.d.ts +3 -3
- package/collapsible/index.js +3 -3
- package/combobox/combobox.d.ts +3 -47
- package/combobox/combobox.js +136 -538
- package/combobox/index.d.ts +4 -4
- package/combobox/index.js +3 -3
- package/command/command-empty.d.ts +3 -8
- package/command/command-empty.js +10 -88
- package/command/command-group.d.ts +3 -13
- package/command/command-group.js +14 -114
- package/command/command-input.d.ts +3 -11
- package/command/command-input.js +20 -136
- package/command/command-item.d.ts +3 -18
- package/command/command-item.js +23 -212
- package/command/command-list.d.ts +3 -7
- package/command/command-list.js +11 -79
- package/command/command-separator.d.ts +3 -5
- package/command/command-separator.js +10 -11
- package/command/command-shortcut.d.ts +3 -5
- package/command/command-shortcut.js +9 -12
- package/command/command.d.ts +3 -23
- package/command/command.js +10 -339
- package/command/index.d.ts +17 -19
- package/command/index.js +16 -18
- package/data-table/data-table.d.ts +3 -57
- package/data-table/data-table.js +85 -449
- package/data-table/index.d.ts +3 -4
- package/data-table/index.js +2 -3
- package/dialog/dialog-close.d.ts +3 -14
- package/dialog/dialog-close.js +4 -34
- package/dialog/dialog-popup.d.ts +3 -34
- package/dialog/dialog-popup.js +70 -336
- package/dialog/dialog-trigger.d.ts +3 -14
- package/dialog/dialog-trigger.js +4 -51
- package/dialog/dialog.d.ts +3 -30
- package/dialog/dialog.js +8 -158
- package/dialog/index.d.ts +11 -11
- package/dialog/index.js +9 -9
- package/dropzone/dropzone.d.ts +3 -72
- package/dropzone/dropzone.js +29 -407
- package/dropzone/index.d.ts +4 -4
- package/dropzone/index.js +3 -3
- package/field/field.d.ts +3 -30
- package/field/field.js +34 -353
- package/field/index.d.ts +1 -0
- package/field/index.js +1 -0
- package/fieldset/fieldset.d.ts +3 -18
- package/fieldset/fieldset.js +21 -110
- package/fieldset/index.d.ts +1 -0
- package/fieldset/index.js +1 -0
- package/icon/icon.d.ts +3 -15
- package/icon/icon.js +4 -33
- package/icon/index.d.ts +2 -3
- package/icon/index.js +2 -3
- package/input/index.d.ts +3 -3
- package/input/index.js +3 -3
- package/input/input.d.ts +3 -49
- package/input/input.js +57 -238
- package/menu/index.d.ts +4 -5
- package/menu/index.js +4 -5
- package/menu/menu-item.d.ts +3 -13
- package/menu/menu-item.js +40 -91
- package/menu/menu.d.ts +3 -15
- package/menu/menu.js +27 -277
- package/menubar/index.d.ts +3 -4
- package/menubar/index.js +2 -3
- package/menubar/menubar.d.ts +3 -19
- package/menubar/menubar.js +12 -183
- package/number-field/index.d.ts +3 -3
- package/number-field/index.js +3 -3
- package/number-field/number-field.d.ts +3 -55
- package/number-field/number-field.js +205 -698
- package/package.json +125 -113
- package/popover/index.d.ts +11 -11
- package/popover/index.js +9 -9
- package/popover/popover-close.d.ts +3 -12
- package/popover/popover-close.js +4 -32
- package/popover/popover-popup.d.ts +3 -18
- package/popover/popover-popup.js +28 -205
- package/popover/popover-trigger.d.ts +3 -13
- package/popover/popover-trigger.js +4 -73
- package/popover/popover.d.ts +3 -29
- package/popover/popover.js +8 -207
- package/portal/index.d.ts +3 -4
- package/portal/index.js +2 -3
- package/portal/portal.d.ts +3 -27
- package/portal/portal.js +8 -157
- package/preview-card/index.d.ts +9 -9
- package/preview-card/index.js +7 -7
- package/preview-card/preview-card-popup.d.ts +3 -14
- package/preview-card/preview-card-popup.js +29 -194
- package/preview-card/preview-card-trigger.d.ts +3 -12
- package/preview-card/preview-card-trigger.js +4 -74
- package/preview-card/preview-card.d.ts +3 -33
- package/preview-card/preview-card.js +8 -239
- package/progress/index.d.ts +2 -3
- package/progress/index.js +2 -3
- package/progress/progress.d.ts +3 -17
- package/progress/progress.js +28 -130
- package/radio/index.d.ts +6 -6
- package/radio/index.js +5 -5
- package/radio/radio-group.d.ts +3 -37
- package/radio/radio-group.js +8 -200
- package/radio/radio.d.ts +3 -28
- package/radio/radio.js +38 -213
- package/scroll-area/index.d.ts +2 -3
- package/scroll-area/index.js +2 -3
- package/scroll-area/scroll-area.d.ts +3 -36
- package/scroll-area/scroll-area.js +25 -535
- package/select/index.d.ts +3 -4
- package/select/index.js +2 -3
- package/select/select.d.ts +3 -39
- package/select/select.js +115 -425
- package/separator/index.d.ts +2 -3
- package/separator/index.js +2 -3
- package/separator/separator.d.ts +3 -10
- package/separator/separator.js +23 -85
- package/sidebar/index.d.ts +29 -29
- package/sidebar/index.js +27 -32
- package/sidebar/sidebar-content.d.ts +3 -12
- package/sidebar/sidebar-content.js +7 -29
- package/sidebar/sidebar-footer.d.ts +3 -10
- package/sidebar/sidebar-footer.js +7 -20
- package/sidebar/sidebar-group-label.d.ts +3 -15
- package/sidebar/sidebar-group-label.js +16 -41
- package/sidebar/sidebar-group.d.ts +3 -13
- package/sidebar/sidebar-group.js +7 -24
- package/sidebar/sidebar-header.d.ts +3 -10
- package/sidebar/sidebar-header.js +7 -16
- package/sidebar/sidebar-inset.d.ts +3 -13
- package/sidebar/sidebar-inset.js +7 -28
- package/sidebar/sidebar-menu-button.d.ts +3 -26
- package/sidebar/sidebar-menu-button.js +59 -217
- package/sidebar/sidebar-menu-item.d.ts +3 -10
- package/sidebar/sidebar-menu-item.js +7 -19
- package/sidebar/sidebar-menu.d.ts +3 -12
- package/sidebar/sidebar-menu.js +7 -25
- package/sidebar/sidebar-provider.d.ts +3 -34
- package/sidebar/sidebar-provider.js +22 -232
- package/sidebar/sidebar-separator.d.ts +3 -10
- package/sidebar/sidebar-separator.js +9 -19
- package/sidebar/sidebar-trigger.d.ts +3 -14
- package/sidebar/sidebar-trigger.js +10 -46
- package/sidebar/sidebar.d.ts +3 -19
- package/sidebar/sidebar.js +65 -262
- package/slider/index.d.ts +3 -3
- package/slider/index.js +3 -3
- package/slider/slider.d.ts +3 -45
- package/slider/slider.js +97 -382
- package/spinner/index.d.ts +2 -3
- package/spinner/index.js +2 -3
- package/spinner/spinner.d.ts +3 -11
- package/spinner/spinner.js +20 -163
- package/split-button/index.d.ts +3 -1
- package/split-button/index.js +3 -1
- package/split-button/split-button.d.ts +3 -33
- package/split-button/split-button.js +306 -394
- package/stepper/index.d.ts +3 -3
- package/stepper/index.js +3 -3
- package/stepper/stepper.d.ts +3 -41
- package/stepper/stepper.js +57 -381
- package/switch/index.d.ts +3 -3
- package/switch/index.js +3 -3
- package/switch/switch.d.ts +3 -30
- package/switch/switch.js +63 -228
- package/tabs/index.d.ts +12 -12
- package/tabs/index.js +11 -11
- package/tabs/tab.d.ts +3 -14
- package/tabs/tab.js +32 -131
- package/tabs/tabs-indicator.d.ts +3 -9
- package/tabs/tabs-indicator.js +17 -22
- package/tabs/tabs-list.d.ts +3 -15
- package/tabs/tabs-list.js +14 -113
- package/tabs/tabs-panel.d.ts +3 -16
- package/tabs/tabs-panel.js +32 -114
- package/tabs/tabs.d.ts +3 -22
- package/tabs/tabs.js +8 -170
- package/textarea/index.d.ts +4 -4
- package/textarea/index.js +3 -3
- package/textarea/textarea.d.ts +3 -36
- package/textarea/textarea.js +63 -220
- package/toggle/index.d.ts +6 -6
- package/toggle/index.js +5 -5
- package/toggle/toggle-group.d.ts +3 -27
- package/toggle/toggle-group.js +9 -224
- package/toggle/toggle.d.ts +3 -26
- package/toggle/toggle.js +93 -178
- package/tokens/properties.css +361 -0
- package/tokens/prose.css +250 -0
- package/tokens/prose.d.ts +2 -0
- package/tokens/prose.js +4 -0
- package/tokens/tokens-raw.d.ts +2 -0
- package/tokens/tokens-raw.js +2 -0
- package/tokens/tokens.css +409 -0
- package/tokens/tokens.d.ts +2 -0
- package/tokens/tokens.js +5 -0
- package/toolbar/index.d.ts +2 -3
- package/toolbar/index.js +2 -3
- package/toolbar/toolbar.d.ts +3 -11
- package/toolbar/toolbar.js +25 -116
- package/tooltip/index.d.ts +9 -9
- package/tooltip/index.js +7 -7
- package/tooltip/tooltip-popup.d.ts +3 -14
- package/tooltip/tooltip-popup.js +31 -185
- package/tooltip/tooltip-trigger.d.ts +3 -14
- package/tooltip/tooltip-trigger.js +5 -148
- package/tooltip/tooltip.d.ts +3 -35
- package/tooltip/tooltip.js +8 -253
- package/trunc/index.d.ts +2 -3
- package/trunc/index.js +2 -3
- package/trunc/trunc.d.ts +3 -17
- package/trunc/trunc.js +10 -108
- package/_deprecated/center/center.d.ts +0 -14
- package/_deprecated/center/center.js +0 -37
- package/_deprecated/center/index.d.ts +0 -3
- package/_deprecated/center/index.js +0 -3
- package/_deprecated/center/register.js +0 -4
- package/_deprecated/hstack/hstack.d.ts +0 -25
- package/_deprecated/hstack/hstack.js +0 -187
- package/_deprecated/hstack/index.d.ts +0 -4
- package/_deprecated/hstack/index.js +0 -3
- package/_deprecated/hstack/register.d.ts +0 -1
- package/_deprecated/hstack/register.js +0 -4
- package/_deprecated/page-inset/index.d.ts +0 -3
- package/_deprecated/page-inset/index.js +0 -3
- package/_deprecated/page-inset/page-inset.d.ts +0 -28
- package/_deprecated/page-inset/page-inset.js +0 -151
- package/_deprecated/page-inset/register.d.ts +0 -1
- package/_deprecated/page-inset/register.js +0 -4
- package/_deprecated/vstack/index.d.ts +0 -3
- package/_deprecated/vstack/index.js +0 -3
- package/_deprecated/vstack/register.d.ts +0 -1
- package/_deprecated/vstack/register.js +0 -4
- package/_deprecated/vstack/vstack.d.ts +0 -17
- package/_deprecated/vstack/vstack.js +0 -125
- package/accordion/accordion-context.d.ts +0 -15
- package/accordion/accordion-context.js +0 -3
- package/alert-dialog/alert-dialog-context.d.ts +0 -13
- package/alert-dialog/alert-dialog-context.js +0 -3
- package/checkbox/checkbox-group-context.d.ts +0 -11
- package/checkbox/checkbox-group-context.js +0 -3
- package/command/command-context.d.ts +0 -30
- package/command/command-context.js +0 -3
- package/command/command-score.d.ts +0 -6
- package/command/command-score.js +0 -31
- package/dialog/dialog-context.d.ts +0 -13
- package/dialog/dialog-context.js +0 -3
- package/global.d.ts +0 -179
- package/menubar/menubar-context.d.ts +0 -9
- package/menubar/menubar-context.js +0 -2
- package/popover/popover-context.d.ts +0 -17
- package/popover/popover-context.js +0 -3
- package/preview-card/preview-card-context.d.ts +0 -16
- package/preview-card/preview-card-context.js +0 -3
- package/radio/radio-group-context.d.ts +0 -11
- package/radio/radio-group-context.js +0 -2
- package/sidebar/sidebar-context.d.ts +0 -15
- package/sidebar/sidebar-context.js +0 -3
- package/split-button/register.d.ts +0 -1
- package/split-button/register.js +0 -4
- package/tabs/tabs-context.d.ts +0 -8
- package/tabs/tabs-context.js +0 -2
- package/toggle/toggle-group-context.d.ts +0 -9
- package/toggle/toggle-group-context.js +0 -2
- package/tooltip/tooltip-context.d.ts +0 -17
- package/tooltip/tooltip-context.js +0 -3
- /package/{_deprecated/center/register.d.ts → _install.d.ts} +0 -0
|
@@ -1,548 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 });
|
|
39
|
-
};
|
|
40
|
-
import { css, html, LitElement, nothing, } from "lit";
|
|
41
|
-
import { property, state } from "lit/decorators.js";
|
|
42
|
-
import { base } from "@deepfuture/dui-core/base";
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { DuiScrollAreaPrimitive } from "@deepfuture/dui-primitives/scroll-area";
|
|
3
|
+
import "../_install.js";
|
|
43
4
|
const styles = css `
|
|
44
|
-
:host {
|
|
45
|
-
display: block;
|
|
46
|
-
position: relative;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
height: 100%;
|
|
49
|
-
max-height: var(--scroll-area-max-height, none);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.ScrollArea {
|
|
53
|
-
position: relative;
|
|
54
|
-
width: 100%;
|
|
55
|
-
height: 100%;
|
|
56
|
-
max-height: inherit;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.Viewport {
|
|
60
|
-
width: 100%;
|
|
61
|
-
height: 100%;
|
|
62
|
-
max-height: inherit;
|
|
63
|
-
overflow: auto;
|
|
64
|
-
overscroll-behavior: auto;
|
|
65
|
-
scrollbar-width: none;
|
|
66
|
-
|
|
67
|
-
&::-webkit-scrollbar {
|
|
68
|
-
display: none;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
:host([fade]) .Viewport[data-scrolled] {
|
|
73
|
-
-webkit-mask-image: linear-gradient(to bottom, transparent, black var(--scroll-fade-size, 1.5rem));
|
|
74
|
-
mask-image: linear-gradient(to bottom, transparent, black var(--scroll-fade-size, 1.5rem));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
5
|
.Scrollbar {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
justify-content: center;
|
|
81
|
-
opacity: 0;
|
|
82
|
-
pointer-events: none;
|
|
83
|
-
|
|
84
|
-
&[data-hovering],
|
|
85
|
-
&[data-scrolling] {
|
|
86
|
-
opacity: 1;
|
|
87
|
-
pointer-events: auto;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&[data-scrolling] {
|
|
91
|
-
transition-duration: 0ms;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.Scrollbar::before {
|
|
96
|
-
content: "";
|
|
97
|
-
position: absolute;
|
|
6
|
+
border-radius: var(--radius-sm);
|
|
7
|
+
transition: opacity var(--duration-fast);
|
|
98
8
|
}
|
|
99
9
|
|
|
100
10
|
.Scrollbar[data-orientation="vertical"] {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
bottom: 0;
|
|
104
|
-
|
|
105
|
-
&::before {
|
|
106
|
-
width: 1.25rem;
|
|
107
|
-
height: 100%;
|
|
108
|
-
left: 50%;
|
|
109
|
-
transform: translateX(-50%);
|
|
110
|
-
}
|
|
11
|
+
width: var(--space-1);
|
|
12
|
+
margin: var(--space-px);
|
|
111
13
|
}
|
|
112
14
|
|
|
113
15
|
.Scrollbar[data-orientation="horizontal"] {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
bottom: 0;
|
|
117
|
-
|
|
118
|
-
&::before {
|
|
119
|
-
width: 100%;
|
|
120
|
-
height: 1.25rem;
|
|
121
|
-
bottom: -0.25rem;
|
|
122
|
-
}
|
|
16
|
+
height: var(--space-1);
|
|
17
|
+
margin: var(--space-px);
|
|
123
18
|
}
|
|
124
19
|
|
|
125
|
-
.Thumb
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
20
|
+
.Thumb {
|
|
21
|
+
border-radius: inherit;
|
|
22
|
+
background: var(--scroll-area-thumb-color, var(--text-2));
|
|
23
|
+
opacity: 0.4;
|
|
24
|
+
transition: opacity var(--duration-fast);
|
|
129
25
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
26
|
+
&:hover {
|
|
27
|
+
opacity: 0.7;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:active {
|
|
31
|
+
opacity: 0.8;
|
|
32
|
+
}
|
|
133
33
|
}
|
|
134
34
|
`;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* auto-hide behavior. Supports vertical, horizontal, or both orientations.
|
|
140
|
-
*
|
|
141
|
-
* @slot - Default slot for scrollable content.
|
|
142
|
-
*
|
|
143
|
-
* @cssprop [--scroll-area-max-height] - Max-height constraint.
|
|
144
|
-
* @cssprop [--scroll-area-thumb-color] - Scrollbar thumb color.
|
|
145
|
-
* @cssprop [--scroll-fade-size] - Distance over which the top fade goes from transparent to opaque (default: 1.5rem).
|
|
146
|
-
*/
|
|
147
|
-
let DuiScrollArea = (() => {
|
|
148
|
-
var _a;
|
|
149
|
-
let _classSuper = LitElement;
|
|
150
|
-
let _orientation_decorators;
|
|
151
|
-
let _orientation_initializers = [];
|
|
152
|
-
let _orientation_extraInitializers = [];
|
|
153
|
-
let _fade_decorators;
|
|
154
|
-
let _fade_initializers = [];
|
|
155
|
-
let _fade_extraInitializers = [];
|
|
156
|
-
let _maxHeight_decorators;
|
|
157
|
-
let _maxHeight_initializers = [];
|
|
158
|
-
let _maxHeight_extraInitializers = [];
|
|
159
|
-
let _private_hasOverflowX_decorators;
|
|
160
|
-
let _private_hasOverflowX_initializers = [];
|
|
161
|
-
let _private_hasOverflowX_extraInitializers = [];
|
|
162
|
-
let _private_hasOverflowX_descriptor;
|
|
163
|
-
let _private_hasOverflowY_decorators;
|
|
164
|
-
let _private_hasOverflowY_initializers = [];
|
|
165
|
-
let _private_hasOverflowY_extraInitializers = [];
|
|
166
|
-
let _private_hasOverflowY_descriptor;
|
|
167
|
-
let _private_hovering_decorators;
|
|
168
|
-
let _private_hovering_initializers = [];
|
|
169
|
-
let _private_hovering_extraInitializers = [];
|
|
170
|
-
let _private_hovering_descriptor;
|
|
171
|
-
let _private_scrolling_decorators;
|
|
172
|
-
let _private_scrolling_initializers = [];
|
|
173
|
-
let _private_scrolling_extraInitializers = [];
|
|
174
|
-
let _private_scrolling_descriptor;
|
|
175
|
-
let _private_thumbHeightPercent_decorators;
|
|
176
|
-
let _private_thumbHeightPercent_initializers = [];
|
|
177
|
-
let _private_thumbHeightPercent_extraInitializers = [];
|
|
178
|
-
let _private_thumbHeightPercent_descriptor;
|
|
179
|
-
let _private_thumbWidthPercent_decorators;
|
|
180
|
-
let _private_thumbWidthPercent_initializers = [];
|
|
181
|
-
let _private_thumbWidthPercent_extraInitializers = [];
|
|
182
|
-
let _private_thumbWidthPercent_descriptor;
|
|
183
|
-
let _private_thumbTopPercent_decorators;
|
|
184
|
-
let _private_thumbTopPercent_initializers = [];
|
|
185
|
-
let _private_thumbTopPercent_extraInitializers = [];
|
|
186
|
-
let _private_thumbTopPercent_descriptor;
|
|
187
|
-
let _private_thumbLeftPercent_decorators;
|
|
188
|
-
let _private_thumbLeftPercent_initializers = [];
|
|
189
|
-
let _private_thumbLeftPercent_extraInitializers = [];
|
|
190
|
-
let _private_thumbLeftPercent_descriptor;
|
|
191
|
-
let _private_isAtTop_decorators;
|
|
192
|
-
let _private_isAtTop_initializers = [];
|
|
193
|
-
let _private_isAtTop_extraInitializers = [];
|
|
194
|
-
let _private_isAtTop_descriptor;
|
|
195
|
-
return class DuiScrollArea extends _classSuper {
|
|
196
|
-
static {
|
|
197
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
198
|
-
_orientation_decorators = [property({ reflect: true })];
|
|
199
|
-
_fade_decorators = [property({ type: Boolean, reflect: true })];
|
|
200
|
-
_maxHeight_decorators = [property({ attribute: "max-height" })];
|
|
201
|
-
_private_hasOverflowX_decorators = [state()];
|
|
202
|
-
_private_hasOverflowY_decorators = [state()];
|
|
203
|
-
_private_hovering_decorators = [state()];
|
|
204
|
-
_private_scrolling_decorators = [state()];
|
|
205
|
-
_private_thumbHeightPercent_decorators = [state()];
|
|
206
|
-
_private_thumbWidthPercent_decorators = [state()];
|
|
207
|
-
_private_thumbTopPercent_decorators = [state()];
|
|
208
|
-
_private_thumbLeftPercent_decorators = [state()];
|
|
209
|
-
_private_isAtTop_decorators = [state()];
|
|
210
|
-
__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);
|
|
211
|
-
__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);
|
|
212
|
-
__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);
|
|
213
|
-
__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);
|
|
214
|
-
__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);
|
|
215
|
-
__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);
|
|
216
|
-
__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);
|
|
217
|
-
__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);
|
|
218
|
-
__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);
|
|
219
|
-
__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);
|
|
220
|
-
__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);
|
|
221
|
-
__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);
|
|
222
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
223
|
-
}
|
|
224
|
-
static tagName = "dui-scroll-area";
|
|
225
|
-
static styles = [base, styles];
|
|
226
|
-
#orientation_accessor_storage = __runInitializers(this, _orientation_initializers, "vertical");
|
|
227
|
-
/** Scroll direction(s). */
|
|
228
|
-
get orientation() { return this.#orientation_accessor_storage; }
|
|
229
|
-
set orientation(value) { this.#orientation_accessor_storage = value; }
|
|
230
|
-
#fade_accessor_storage = (__runInitializers(this, _orientation_extraInitializers), __runInitializers(this, _fade_initializers, false));
|
|
231
|
-
/** Show a fade overlay at the top when scrolled. */
|
|
232
|
-
get fade() { return this.#fade_accessor_storage; }
|
|
233
|
-
set fade(value) { this.#fade_accessor_storage = value; }
|
|
234
|
-
#maxHeight_accessor_storage = (__runInitializers(this, _fade_extraInitializers), __runInitializers(this, _maxHeight_initializers, undefined));
|
|
235
|
-
/** Optional max-height constraint (CSS value). */
|
|
236
|
-
get maxHeight() { return this.#maxHeight_accessor_storage; }
|
|
237
|
-
set maxHeight(value) { this.#maxHeight_accessor_storage = value; }
|
|
238
|
-
willUpdate(changed) {
|
|
239
|
-
if (changed.has("maxHeight")) {
|
|
240
|
-
if (this.maxHeight)
|
|
241
|
-
this.style.setProperty("--scroll-area-max-height", this.maxHeight);
|
|
242
|
-
else
|
|
243
|
-
this.style.removeProperty("--scroll-area-max-height");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
#hasOverflowX_accessor_storage = (__runInitializers(this, _maxHeight_extraInitializers), __runInitializers(this, _private_hasOverflowX_initializers, false));
|
|
247
|
-
// --- Internal state ---
|
|
248
|
-
get #hasOverflowX() { return _private_hasOverflowX_descriptor.get.call(this); }
|
|
249
|
-
set #hasOverflowX(value) { return _private_hasOverflowX_descriptor.set.call(this, value); }
|
|
250
|
-
#hasOverflowY_accessor_storage = (__runInitializers(this, _private_hasOverflowX_extraInitializers), __runInitializers(this, _private_hasOverflowY_initializers, false));
|
|
251
|
-
get #hasOverflowY() { return _private_hasOverflowY_descriptor.get.call(this); }
|
|
252
|
-
set #hasOverflowY(value) { return _private_hasOverflowY_descriptor.set.call(this, value); }
|
|
253
|
-
#hovering_accessor_storage = (__runInitializers(this, _private_hasOverflowY_extraInitializers), __runInitializers(this, _private_hovering_initializers, false));
|
|
254
|
-
get #hovering() { return _private_hovering_descriptor.get.call(this); }
|
|
255
|
-
set #hovering(value) { return _private_hovering_descriptor.set.call(this, value); }
|
|
256
|
-
#scrolling_accessor_storage = (__runInitializers(this, _private_hovering_extraInitializers), __runInitializers(this, _private_scrolling_initializers, false));
|
|
257
|
-
get #scrolling() { return _private_scrolling_descriptor.get.call(this); }
|
|
258
|
-
set #scrolling(value) { return _private_scrolling_descriptor.set.call(this, value); }
|
|
259
|
-
#thumbHeightPercent_accessor_storage = (__runInitializers(this, _private_scrolling_extraInitializers), __runInitializers(this, _private_thumbHeightPercent_initializers, 0));
|
|
260
|
-
get #thumbHeightPercent() { return _private_thumbHeightPercent_descriptor.get.call(this); }
|
|
261
|
-
set #thumbHeightPercent(value) { return _private_thumbHeightPercent_descriptor.set.call(this, value); }
|
|
262
|
-
#thumbWidthPercent_accessor_storage = (__runInitializers(this, _private_thumbHeightPercent_extraInitializers), __runInitializers(this, _private_thumbWidthPercent_initializers, 0));
|
|
263
|
-
get #thumbWidthPercent() { return _private_thumbWidthPercent_descriptor.get.call(this); }
|
|
264
|
-
set #thumbWidthPercent(value) { return _private_thumbWidthPercent_descriptor.set.call(this, value); }
|
|
265
|
-
#thumbTopPercent_accessor_storage = (__runInitializers(this, _private_thumbWidthPercent_extraInitializers), __runInitializers(this, _private_thumbTopPercent_initializers, 0));
|
|
266
|
-
get #thumbTopPercent() { return _private_thumbTopPercent_descriptor.get.call(this); }
|
|
267
|
-
set #thumbTopPercent(value) { return _private_thumbTopPercent_descriptor.set.call(this, value); }
|
|
268
|
-
#thumbLeftPercent_accessor_storage = (__runInitializers(this, _private_thumbTopPercent_extraInitializers), __runInitializers(this, _private_thumbLeftPercent_initializers, 0));
|
|
269
|
-
get #thumbLeftPercent() { return _private_thumbLeftPercent_descriptor.get.call(this); }
|
|
270
|
-
set #thumbLeftPercent(value) { return _private_thumbLeftPercent_descriptor.set.call(this, value); }
|
|
271
|
-
#isAtTop_accessor_storage = (__runInitializers(this, _private_thumbLeftPercent_extraInitializers), __runInitializers(this, _private_isAtTop_initializers, true));
|
|
272
|
-
get #isAtTop() { return _private_isAtTop_descriptor.get.call(this); }
|
|
273
|
-
set #isAtTop(value) { return _private_isAtTop_descriptor.set.call(this, value); }
|
|
274
|
-
static #SCROLL_BOTTOM_TOLERANCE = 1;
|
|
275
|
-
#isAtBottom = (__runInitializers(this, _private_isAtTop_extraInitializers), true);
|
|
276
|
-
#prevScrollTop = 0;
|
|
277
|
-
#scrollEndTimer;
|
|
278
|
-
#resizeObserver;
|
|
279
|
-
#dragging;
|
|
280
|
-
#dragStartPointer = 0;
|
|
281
|
-
#dragStartScroll = 0;
|
|
282
|
-
// --- Lifecycle ---
|
|
283
|
-
connectedCallback() {
|
|
284
|
-
super.connectedCallback();
|
|
285
|
-
this.addEventListener("pointerenter", this.#onPointerEnter);
|
|
286
|
-
this.addEventListener("pointerleave", this.#onPointerLeave);
|
|
287
|
-
}
|
|
288
|
-
disconnectedCallback() {
|
|
289
|
-
super.disconnectedCallback();
|
|
290
|
-
this.removeEventListener("pointerenter", this.#onPointerEnter);
|
|
291
|
-
this.removeEventListener("pointerleave", this.#onPointerLeave);
|
|
292
|
-
this.#resizeObserver?.disconnect();
|
|
293
|
-
clearTimeout(this.#scrollEndTimer);
|
|
294
|
-
}
|
|
295
|
-
firstUpdated() {
|
|
296
|
-
const viewport = this.#viewport;
|
|
297
|
-
if (!viewport)
|
|
298
|
-
return;
|
|
299
|
-
this.#resizeObserver = new ResizeObserver(() => this.#measure());
|
|
300
|
-
this.#resizeObserver.observe(viewport);
|
|
301
|
-
const slot = viewport.querySelector("slot");
|
|
302
|
-
if (slot) {
|
|
303
|
-
const observe = () => {
|
|
304
|
-
for (const node of slot.assignedElements()) {
|
|
305
|
-
this.#resizeObserver.observe(node);
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
slot.addEventListener("slotchange", () => {
|
|
309
|
-
observe();
|
|
310
|
-
requestAnimationFrame(() => this.#measure());
|
|
311
|
-
});
|
|
312
|
-
observe();
|
|
313
|
-
}
|
|
314
|
-
this.#measure();
|
|
315
|
-
}
|
|
316
|
-
// --- Public methods ---
|
|
317
|
-
/** Scroll the viewport to the bottom. */
|
|
318
|
-
async scrollToBottom() {
|
|
319
|
-
await this.updateComplete;
|
|
320
|
-
const viewport = this.#viewport;
|
|
321
|
-
if (viewport) {
|
|
322
|
-
viewport.scrollTop = viewport.scrollHeight;
|
|
323
|
-
this.#isAtBottom = true;
|
|
324
|
-
this.#prevScrollTop = viewport.scrollTop;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
/** Whether the viewport is scrolled to the top. */
|
|
328
|
-
get isAtTop() {
|
|
329
|
-
return this.#isAtTop;
|
|
330
|
-
}
|
|
331
|
-
/** Whether the viewport is scrolled to the bottom. */
|
|
332
|
-
get isAtBottom() {
|
|
333
|
-
return this.#isAtBottom;
|
|
334
|
-
}
|
|
335
|
-
// --- Getters ---
|
|
336
|
-
get #viewport() {
|
|
337
|
-
return this.shadowRoot?.querySelector(".Viewport") ?? null;
|
|
338
|
-
}
|
|
339
|
-
get #showVertical() {
|
|
340
|
-
return this.orientation === "vertical" || this.orientation === "both";
|
|
341
|
-
}
|
|
342
|
-
get #showHorizontal() {
|
|
343
|
-
return this.orientation === "horizontal" || this.orientation === "both";
|
|
344
|
-
}
|
|
345
|
-
// --- Measurement ---
|
|
346
|
-
#measure = () => {
|
|
347
|
-
const vp = this.#viewport;
|
|
348
|
-
if (!vp)
|
|
349
|
-
return;
|
|
350
|
-
const hasOverflowY = vp.scrollHeight > vp.clientHeight;
|
|
351
|
-
const hasOverflowX = vp.scrollWidth > vp.clientWidth;
|
|
352
|
-
this.#hasOverflowY = hasOverflowY;
|
|
353
|
-
this.#hasOverflowX = hasOverflowX;
|
|
354
|
-
if (hasOverflowY) {
|
|
355
|
-
this.#thumbHeightPercent = (vp.clientHeight / vp.scrollHeight) * 100;
|
|
356
|
-
}
|
|
357
|
-
if (hasOverflowX) {
|
|
358
|
-
this.#thumbWidthPercent = (vp.clientWidth / vp.scrollWidth) * 100;
|
|
359
|
-
}
|
|
360
|
-
this.#updateThumbPosition(vp);
|
|
361
|
-
};
|
|
362
|
-
#updateThumbPosition = (vp) => {
|
|
363
|
-
if (this.#hasOverflowY) {
|
|
364
|
-
const maxScrollTop = vp.scrollHeight - vp.clientHeight;
|
|
365
|
-
this.#thumbTopPercent =
|
|
366
|
-
maxScrollTop > 0
|
|
367
|
-
? (vp.scrollTop / maxScrollTop) * (100 - this.#thumbHeightPercent)
|
|
368
|
-
: 0;
|
|
369
|
-
}
|
|
370
|
-
if (this.#hasOverflowX) {
|
|
371
|
-
const maxScrollLeft = vp.scrollWidth - vp.clientWidth;
|
|
372
|
-
this.#thumbLeftPercent =
|
|
373
|
-
maxScrollLeft > 0
|
|
374
|
-
? (vp.scrollLeft / maxScrollLeft) * (100 - this.#thumbWidthPercent)
|
|
375
|
-
: 0;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
// --- Event handlers ---
|
|
379
|
-
#onScroll = () => {
|
|
380
|
-
const vp = this.#viewport;
|
|
381
|
-
if (!vp)
|
|
382
|
-
return;
|
|
383
|
-
this.#scrolling = true;
|
|
384
|
-
this.#updateThumbPosition(vp);
|
|
385
|
-
const wasAtBottom = this.#isAtBottom;
|
|
386
|
-
const scrolledUp = vp.scrollTop < this.#prevScrollTop;
|
|
387
|
-
this.#isAtTop = vp.scrollTop <= 0;
|
|
388
|
-
this.#isAtBottom =
|
|
389
|
-
vp.scrollTop + vp.clientHeight >=
|
|
390
|
-
vp.scrollHeight - DuiScrollArea.#SCROLL_BOTTOM_TOLERANCE;
|
|
391
|
-
if (scrolledUp && wasAtBottom && !this.#isAtBottom) {
|
|
392
|
-
this.dispatchEvent(new Event("scrolled-from-bottom", { bubbles: true, composed: true }));
|
|
393
|
-
}
|
|
394
|
-
else if (!wasAtBottom && this.#isAtBottom) {
|
|
395
|
-
this.dispatchEvent(new Event("scrolled-to-bottom", { bubbles: true, composed: true }));
|
|
396
|
-
}
|
|
397
|
-
this.#prevScrollTop = vp.scrollTop;
|
|
398
|
-
clearTimeout(this.#scrollEndTimer);
|
|
399
|
-
this.#scrollEndTimer = setTimeout(() => {
|
|
400
|
-
this.#scrolling = false;
|
|
401
|
-
}, 1000);
|
|
402
|
-
};
|
|
403
|
-
#onPointerEnter = () => {
|
|
404
|
-
this.#hovering = true;
|
|
405
|
-
this.#measure();
|
|
406
|
-
};
|
|
407
|
-
#onPointerLeave = () => {
|
|
408
|
-
this.#hovering = false;
|
|
409
|
-
};
|
|
410
|
-
// --- Track click (jump to position) ---
|
|
411
|
-
#onTrackPointerDown = (orientation, event) => {
|
|
412
|
-
event.preventDefault();
|
|
413
|
-
event.stopPropagation();
|
|
414
|
-
const vp = this.#viewport;
|
|
415
|
-
if (!vp)
|
|
416
|
-
return;
|
|
417
|
-
if (orientation === "vertical") {
|
|
418
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
419
|
-
if (!track)
|
|
420
|
-
return;
|
|
421
|
-
const rect = track.getBoundingClientRect();
|
|
422
|
-
const fraction = (event.clientY - rect.top) / rect.height;
|
|
423
|
-
vp.scrollTop = fraction * (vp.scrollHeight - vp.clientHeight);
|
|
424
|
-
}
|
|
425
|
-
else {
|
|
426
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
|
|
427
|
-
if (!track)
|
|
428
|
-
return;
|
|
429
|
-
const rect = track.getBoundingClientRect();
|
|
430
|
-
const fraction = (event.clientX - rect.left) / rect.width;
|
|
431
|
-
vp.scrollLeft = fraction * (vp.scrollWidth - vp.clientWidth);
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
// --- Thumb drag ---
|
|
435
|
-
#onThumbPointerDown = (orientation, event) => {
|
|
436
|
-
event.preventDefault();
|
|
437
|
-
event.stopPropagation();
|
|
438
|
-
const vp = this.#viewport;
|
|
439
|
-
if (!vp)
|
|
440
|
-
return;
|
|
441
|
-
this.#dragging = orientation;
|
|
442
|
-
if (orientation === "vertical") {
|
|
443
|
-
this.#dragStartPointer = event.clientY;
|
|
444
|
-
this.#dragStartScroll = vp.scrollTop;
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
this.#dragStartPointer = event.clientX;
|
|
448
|
-
this.#dragStartScroll = vp.scrollLeft;
|
|
449
|
-
}
|
|
450
|
-
document.addEventListener("pointermove", this.#onDragMove);
|
|
451
|
-
document.addEventListener("pointerup", this.#onDragEnd);
|
|
452
|
-
};
|
|
453
|
-
#onDragMove = (event) => {
|
|
454
|
-
const vp = this.#viewport;
|
|
455
|
-
if (!vp || !this.#dragging)
|
|
456
|
-
return;
|
|
457
|
-
if (this.#dragging === "vertical") {
|
|
458
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="vertical"]');
|
|
459
|
-
if (!track)
|
|
460
|
-
return;
|
|
461
|
-
const delta = event.clientY - this.#dragStartPointer;
|
|
462
|
-
const trackHeight = track.clientHeight;
|
|
463
|
-
const scrollRange = vp.scrollHeight - vp.clientHeight;
|
|
464
|
-
vp.scrollTop =
|
|
465
|
-
this.#dragStartScroll + (delta / trackHeight) * scrollRange;
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
const track = this.shadowRoot?.querySelector('.Scrollbar[data-orientation="horizontal"]');
|
|
469
|
-
if (!track)
|
|
470
|
-
return;
|
|
471
|
-
const delta = event.clientX - this.#dragStartPointer;
|
|
472
|
-
const trackWidth = track.clientWidth;
|
|
473
|
-
const scrollRange = vp.scrollWidth - vp.clientWidth;
|
|
474
|
-
vp.scrollLeft =
|
|
475
|
-
this.#dragStartScroll + (delta / trackWidth) * scrollRange;
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
#onDragEnd = () => {
|
|
479
|
-
this.#dragging = undefined;
|
|
480
|
-
document.removeEventListener("pointermove", this.#onDragMove);
|
|
481
|
-
document.removeEventListener("pointerup", this.#onDragEnd);
|
|
482
|
-
};
|
|
483
|
-
// --- Render ---
|
|
484
|
-
#renderVerticalScrollbar() {
|
|
485
|
-
if (!this.#showVertical || !this.#hasOverflowY)
|
|
486
|
-
return nothing;
|
|
487
|
-
return html `
|
|
488
|
-
<div
|
|
489
|
-
class="Scrollbar"
|
|
490
|
-
part="scrollbar-vertical"
|
|
491
|
-
data-orientation="vertical"
|
|
492
|
-
?data-hovering="${this.#hovering}"
|
|
493
|
-
?data-scrolling="${this.#scrolling}"
|
|
494
|
-
@pointerdown="${(e) => this.#onTrackPointerDown("vertical", e)}"
|
|
495
|
-
>
|
|
496
|
-
<div
|
|
497
|
-
class="Thumb"
|
|
498
|
-
part="thumb-vertical"
|
|
499
|
-
data-orientation="vertical"
|
|
500
|
-
style="height: ${this.#thumbHeightPercent}%; top: ${this
|
|
501
|
-
.#thumbTopPercent}%; position: absolute;"
|
|
502
|
-
@pointerdown="${(e) => this.#onThumbPointerDown("vertical", e)}"
|
|
503
|
-
></div>
|
|
504
|
-
</div>
|
|
505
|
-
`;
|
|
506
|
-
}
|
|
507
|
-
#renderHorizontalScrollbar() {
|
|
508
|
-
if (!this.#showHorizontal || !this.#hasOverflowX)
|
|
509
|
-
return nothing;
|
|
510
|
-
return html `
|
|
511
|
-
<div
|
|
512
|
-
class="Scrollbar"
|
|
513
|
-
part="scrollbar-horizontal"
|
|
514
|
-
data-orientation="horizontal"
|
|
515
|
-
?data-hovering="${this.#hovering}"
|
|
516
|
-
?data-scrolling="${this.#scrolling}"
|
|
517
|
-
@pointerdown="${(e) => this.#onTrackPointerDown("horizontal", e)}"
|
|
518
|
-
>
|
|
519
|
-
<div
|
|
520
|
-
class="Thumb"
|
|
521
|
-
part="thumb-horizontal"
|
|
522
|
-
data-orientation="horizontal"
|
|
523
|
-
style="width: ${this.#thumbWidthPercent}%; left: ${this
|
|
524
|
-
.#thumbLeftPercent}%; position: absolute;"
|
|
525
|
-
@pointerdown="${(e) => this.#onThumbPointerDown("horizontal", e)}"
|
|
526
|
-
></div>
|
|
527
|
-
</div>
|
|
528
|
-
`;
|
|
529
|
-
}
|
|
530
|
-
render() {
|
|
531
|
-
return html `
|
|
532
|
-
<div
|
|
533
|
-
class="ScrollArea"
|
|
534
|
-
part="root"
|
|
535
|
-
?data-has-overflow-x="${this.#hasOverflowX}"
|
|
536
|
-
?data-has-overflow-y="${this.#hasOverflowY}"
|
|
537
|
-
?data-scrolling="${this.#scrolling}"
|
|
538
|
-
>
|
|
539
|
-
<div class="Viewport" part="viewport" ?data-scrolled="${!this.#isAtTop}" @scroll="${this.#onScroll}">
|
|
540
|
-
<slot></slot>
|
|
541
|
-
</div>
|
|
542
|
-
${this.#renderVerticalScrollbar()} ${this.#renderHorizontalScrollbar()}
|
|
543
|
-
</div>
|
|
544
|
-
`;
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
})();
|
|
548
|
-
export { DuiScrollArea };
|
|
35
|
+
export class DuiScrollArea extends DuiScrollAreaPrimitive {
|
|
36
|
+
static styles = [...DuiScrollAreaPrimitive.styles, styles];
|
|
37
|
+
}
|
|
38
|
+
customElements.define(DuiScrollArea.tagName, DuiScrollArea);
|
package/select/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiSelect };
|
|
3
|
-
export type { SelectOption } from "
|
|
4
|
-
export declare const selectFamily: (typeof DuiSelect)[];
|
|
1
|
+
import "./select.js";
|
|
2
|
+
export { DuiSelect } from "./select.js";
|
|
3
|
+
export type { SelectOption } from "@deepfuture/dui-primitives/select";
|
package/select/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { DuiSelect };
|
|
3
|
-
export const selectFamily = [DuiSelect];
|
|
1
|
+
import "./select.js";
|
|
2
|
+
export { DuiSelect } from "./select.js";
|
package/select/select.d.ts
CHANGED
|
@@ -1,41 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type SelectValueChangeDetail = {
|
|
9
|
-
value: string;
|
|
10
|
-
option: SelectOption;
|
|
11
|
-
};
|
|
12
|
-
export declare const valueChangeEvent: (detail: SelectValueChangeDetail) => CustomEvent<SelectValueChangeDetail>;
|
|
13
|
-
/**
|
|
14
|
-
* `<dui-select>` — A dropdown select for choosing from a list of options.
|
|
15
|
-
*
|
|
16
|
-
* @csspart trigger - The trigger button.
|
|
17
|
-
* @csspart value - The displayed value text.
|
|
18
|
-
* @fires value-change - Fired when the selected value changes.
|
|
19
|
-
* Detail: { value: string, option: SelectOption }
|
|
20
|
-
*/
|
|
21
|
-
export declare class DuiSelect extends LitElement {
|
|
22
|
-
#private;
|
|
23
|
-
static tagName: "dui-select";
|
|
24
|
-
static formAssociated: boolean;
|
|
1
|
+
import { DuiSelectPrimitive } from "@deepfuture/dui-primitives/select";
|
|
2
|
+
import "../_install.js";
|
|
3
|
+
export declare class DuiSelect extends DuiSelectPrimitive {
|
|
25
4
|
static styles: import("lit").CSSResult[];
|
|
26
|
-
constructor();
|
|
27
|
-
/** The available options. */
|
|
28
|
-
accessor options: SelectOption[];
|
|
29
|
-
/** Currently selected value. */
|
|
30
|
-
accessor value: string;
|
|
31
|
-
/** Placeholder text shown when no value is selected. */
|
|
32
|
-
accessor placeholder: string;
|
|
33
|
-
/** Whether the select is disabled. */
|
|
34
|
-
accessor disabled: boolean;
|
|
35
|
-
/** Position the popup so the selected item overlays the trigger (macOS-style). */
|
|
36
|
-
accessor alignItemToTrigger: boolean;
|
|
37
|
-
/** Name for form submission. */
|
|
38
|
-
accessor name: string;
|
|
39
|
-
willUpdate(): void;
|
|
40
|
-
render(): TemplateResult;
|
|
41
5
|
}
|