@alegendstale/holly-components 0.2.9 → 0.2.10
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/dist/components/absolute-container/absolute-container.js +113 -91
- package/dist/components/absolute-container/absolute-container.stories.js +36 -0
- package/dist/components/absolute-container/index.js +1 -1
- package/dist/components/bottom-sheet/bottom-sheet.js +415 -308
- package/dist/components/bottom-sheet/bottom-sheet.stories.js +43 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.js +15 -0
- package/dist/components/bottom-sheet/index.js +1 -1
- package/dist/components/canvas/canvas-base.d.ts +2 -1
- package/dist/components/canvas/canvas-base.d.ts.map +1 -1
- package/dist/components/canvas/canvas-base.js +56 -44
- package/dist/components/canvas/canvas-gradient.js +61 -45
- package/dist/components/canvas/canvas-image.js +158 -111
- package/dist/components/canvas/index.js +2 -2
- package/dist/components/carousel-scroller/carousel-scroller.js +133 -121
- package/dist/components/carousel-scroller/carousel-scroller.stories.js +40 -0
- package/dist/components/carousel-scroller/index.js +1 -1
- package/dist/components/color-palette/color-palette-utils.js +105 -41
- package/dist/components/color-palette/color-palette.js +429 -337
- package/dist/components/color-palette/component/color-palette-component.js +184 -142
- package/dist/components/color-palette/component/color-palette-component.stories.js +74 -0
- package/dist/components/color-palette/component/index.js +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.js +702 -591
- package/dist/components/color-palette/editor/color-palette-editor.stories.js +39 -0
- package/dist/components/color-palette/editor/index.js +1 -0
- package/dist/components/color-palette/index.js +5 -7
- package/dist/components/color-palette/item/color-palette-item-edit.js +114 -87
- package/dist/components/color-palette/item/color-palette-item.js +155 -140
- package/dist/components/color-palette/item/index.js +2 -0
- package/dist/components/color-palette/menu/color-palette-menu.js +241 -217
- package/dist/components/color-palette/menu/color-palette-reorder.js +117 -103
- package/dist/components/color-palette/menu/index.js +2 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +90 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.js +295 -0
- package/dist/components/color-palette/storybook/color-palette.stories.js +76 -0
- package/dist/components/tool-tip/Tooltip2.js +103 -0
- package/dist/components/tool-tip/index.js +1 -1
- package/dist/components/tool-tip/tool-tip.d.ts +1 -0
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
- package/dist/components/tool-tip/tool-tip.js +125 -102
- package/dist/components/tool-tip/tool-tip.stories.js +30 -0
- package/dist/index.js +6 -14
- package/dist/utils/EventEmitter.js +23 -23
- package/dist/utils/basicUtils.js +149 -32
- package/dist/utils/dragDropUtils.js +121 -0
- package/dist/utils/generateUtils.js +73 -39
- package/dist/utils/types.d.ts +1 -1
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js +1 -0
- package/package.json +1 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -8
- package/dist/_virtual/x11.js +0 -4
- package/dist/node_modules/colorsea/colors/x11.js +0 -14
|
@@ -1,312 +1,419 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
(l = t[h]) && (n = (s ? l(e, o, n) : l(n)) || n);
|
|
7
|
-
return s && n && f(e, o, n), n;
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
6
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
@
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
>
|
|
76
|
-
|
|
77
|
-
</
|
|
78
|
-
|
|
7
|
+
import { LitElement, html, css } from 'lit';
|
|
8
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
9
|
+
import { EventEmitter } from '../../utils/EventEmitter';
|
|
10
|
+
let BottomSheet = class BottomSheet extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.open = false;
|
|
14
|
+
this.nonmodal = false;
|
|
15
|
+
this.dragging = false;
|
|
16
|
+
this.scrolling = false;
|
|
17
|
+
this.snapPoints = [];
|
|
18
|
+
this.defaultSnap = NaN;
|
|
19
|
+
this.emitter = new EventEmitter();
|
|
20
|
+
this.startY = 0;
|
|
21
|
+
this.startHeight = 0;
|
|
22
|
+
this.previousTouch = null;
|
|
23
|
+
this.lastScrollTop = 0;
|
|
24
|
+
}
|
|
25
|
+
set height(val) {
|
|
26
|
+
const newHeight = Math.min(Math.max(val, 0), 100);
|
|
27
|
+
this.emitter.emit('snapped', this.isSnapped(newHeight), this.shadowRoot?.activeElement);
|
|
28
|
+
// Automatically fit content if height is infinity
|
|
29
|
+
if (!isFinite(val))
|
|
30
|
+
this.style.setProperty('--height', `fit-content`);
|
|
31
|
+
else
|
|
32
|
+
this.style.setProperty('--height', `${Math.round(newHeight)}dvh`);
|
|
33
|
+
}
|
|
34
|
+
get height() {
|
|
35
|
+
return parseInt(this.style.getPropertyValue('--height'));
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
// Make sure sheet snap doesn't break on index 2.
|
|
40
|
+
const lengthWhen2 = this.snapPoints.length === 2 ? 0 : 1;
|
|
41
|
+
this.defaultSnap = this.snapPoints.length > 0 ? isNaN(this.defaultSnap) ? this.snapPoints[Math.round(this.snapPoints.length / 2) - lengthWhen2] : this.defaultSnap : NaN;
|
|
42
|
+
this.emitter.on('snapped', this.onSnapped.bind(this));
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
this.showSheet(this.open);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
this.emitter.clear();
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
requestAnimationFrame(() => {
|
|
53
|
+
this.setDialog(this.open);
|
|
54
|
+
});
|
|
55
|
+
return html `
|
|
56
|
+
<dialog
|
|
57
|
+
@click=${(e) => {
|
|
58
|
+
// Prevents clicks from reaching elements underneath sheet
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
this.toggleSheet();
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<button
|
|
64
|
+
id="handle"
|
|
65
|
+
part="handle"
|
|
66
|
+
@pointerdown=${this.pointerDown}
|
|
67
|
+
@pointermove=${this.pointerMove}
|
|
68
|
+
@pointerup=${this.pointerUp}
|
|
69
|
+
@click=${(e) => {
|
|
70
|
+
// Prevents clicks from reaching elements underneath sheet
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
⸻
|
|
75
|
+
</button>
|
|
76
|
+
|
|
77
|
+
<div
|
|
78
|
+
id='content'
|
|
79
|
+
part="content"
|
|
80
|
+
tabindex='0'
|
|
81
|
+
@touchstart=${this.touchDown}
|
|
82
|
+
@touchend=${this.touchUp}
|
|
83
|
+
@touchmove=${this.touchMove}
|
|
84
|
+
@scroll=${this.contentScroll}
|
|
85
|
+
@touchcancel=${(e) => {
|
|
86
|
+
console.warn('User Agent touchcancelled the event.', e.target);
|
|
87
|
+
}}
|
|
88
|
+
@dragstart=${(e) => {
|
|
89
|
+
// Prevent slot children from being dragged
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
}}
|
|
92
|
+
@click=${(e) => {
|
|
93
|
+
// Prevents clicks from reaching elements underneath sheet
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<slot></slot>
|
|
98
|
+
</div>
|
|
99
|
+
</dialog>
|
|
79
100
|
`;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Find closest point index to target in array
|
|
104
|
+
*/
|
|
105
|
+
closestSnapPointIndex(snapPoints, target) {
|
|
106
|
+
return snapPoints.reduce((closestIndex, value, index) => (Math.abs(value - target) < Math.abs(snapPoints[closestIndex] - target) ? index : closestIndex), 0);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sets sheet height to the closest snap
|
|
110
|
+
* @param height percentage
|
|
111
|
+
*/
|
|
112
|
+
setSnap(height) {
|
|
113
|
+
if (this.snapPoints.length === 0)
|
|
114
|
+
return;
|
|
115
|
+
const currentSnap = this.snapPoints[this.closestSnapPointIndex(this.snapPoints, height)];
|
|
116
|
+
// Hide sheet if current snap is the smallest
|
|
117
|
+
if (currentSnap === this.snapPoints[0])
|
|
118
|
+
this.showSheet(false);
|
|
119
|
+
this.height = currentSnap;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @returns Whether sheet is snapped to a snap point
|
|
123
|
+
*/
|
|
124
|
+
isSnapped(height) {
|
|
125
|
+
return this.snapPoints.some((val) => val === Math.round(height));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sets the display state of the sheet
|
|
129
|
+
*/
|
|
130
|
+
showSheet(open) {
|
|
131
|
+
this.open = open;
|
|
132
|
+
this.height = isNaN(this.defaultSnap) ? Infinity : this.defaultSnap;
|
|
133
|
+
this.setOverscroll(open);
|
|
134
|
+
this.setDialog(open);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Toggles the display state of the sheet
|
|
138
|
+
*/
|
|
139
|
+
toggleSheet() {
|
|
140
|
+
this.showSheet(!this.open);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Remove overscroll to prevent mobile browsers from refreshing during drag
|
|
144
|
+
*/
|
|
145
|
+
setOverscroll(open) {
|
|
146
|
+
const htmlEl = document.querySelector('html');
|
|
147
|
+
const bodyEl = document.querySelector('body');
|
|
148
|
+
const behavior = open ? 'none' : 'unset';
|
|
149
|
+
htmlEl && htmlEl.style.setProperty('overscroll-behavior-block', behavior);
|
|
150
|
+
bodyEl && bodyEl.style.setProperty('overscroll-behavior-block', behavior);
|
|
151
|
+
}
|
|
152
|
+
setDialog(open) {
|
|
153
|
+
if (open && !this.dialog.open) {
|
|
154
|
+
if (this.nonmodal)
|
|
155
|
+
this.dialog.show();
|
|
156
|
+
else
|
|
157
|
+
this.dialog.showModal();
|
|
158
|
+
}
|
|
159
|
+
else if (open && this.dialog.open) {
|
|
160
|
+
// If a modal dialog is open, close and open a nonmodal dialog
|
|
161
|
+
if (this.nonmodal && this.modalDialog) {
|
|
162
|
+
this.dialog.close();
|
|
163
|
+
this.dialog.show();
|
|
164
|
+
}
|
|
165
|
+
// If a nonmodal dialog is open, close and open a modal dialog
|
|
166
|
+
else if (!this.nonmodal && this.nonModalDialog) {
|
|
167
|
+
this.dialog.close();
|
|
168
|
+
this.dialog.showModal();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.dialog.close();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
touchDown(e) {
|
|
176
|
+
if (!(e.target instanceof HTMLElement))
|
|
177
|
+
return;
|
|
178
|
+
this.startY = e.touches[0].pageY;
|
|
179
|
+
this.startHeight = this.height;
|
|
180
|
+
}
|
|
181
|
+
touchMove(e) {
|
|
182
|
+
// Ensure target has pointer capture
|
|
183
|
+
if (!(e.target instanceof HTMLElement))
|
|
184
|
+
return;
|
|
185
|
+
const touch = e.touches[0];
|
|
186
|
+
let movementY = NaN;
|
|
187
|
+
if (this.previousTouch) {
|
|
188
|
+
movementY = touch.pageY - this.previousTouch.pageY;
|
|
189
|
+
}
|
|
190
|
+
this.previousTouch = touch;
|
|
191
|
+
let deltaY = this.startY - e.touches[0].pageY;
|
|
192
|
+
const newHeight = this.startHeight + (deltaY / window.innerHeight) * 100;
|
|
193
|
+
// Allow user to drag
|
|
194
|
+
if (!this.scrolling && this.dragging) {
|
|
195
|
+
this.height = newHeight;
|
|
196
|
+
}
|
|
197
|
+
// Allow user to scroll
|
|
198
|
+
else if (this.scrolling && this.dragging || this.scrolling && !this.dragging) {
|
|
199
|
+
e.target.focus({ preventScroll: true });
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Allow user to scroll OR drag
|
|
203
|
+
* Determined by first direction of movement
|
|
204
|
+
*/
|
|
205
|
+
else if (!this.scrolling && !this.dragging) {
|
|
206
|
+
// Scroll Down
|
|
207
|
+
if (movementY >= 0) {
|
|
208
|
+
// Ensure the height of the container never goes above the middle snap point when scrolling down
|
|
209
|
+
this.height = Math.min(newHeight, this.defaultSnap || this.snapPoints[this.snapPoints.length - 1]);
|
|
210
|
+
}
|
|
211
|
+
// Scroll Up
|
|
212
|
+
else {
|
|
213
|
+
// Allow user to scroll
|
|
214
|
+
e.target.focus({ preventScroll: true });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
touchUp(e) {
|
|
219
|
+
if (!(e.target instanceof HTMLElement))
|
|
220
|
+
return;
|
|
221
|
+
this.previousTouch = null;
|
|
222
|
+
this.setSnap(this.height);
|
|
223
|
+
}
|
|
224
|
+
pointerDown(e) {
|
|
225
|
+
if (!(e.target instanceof HTMLElement))
|
|
226
|
+
return;
|
|
227
|
+
e.target.setPointerCapture(e.pointerId);
|
|
228
|
+
this.startY = e.pageY;
|
|
229
|
+
this.startHeight = this.height;
|
|
230
|
+
}
|
|
231
|
+
pointerMove(e) {
|
|
232
|
+
// Ensure target has pointer capture
|
|
233
|
+
if (!(e.target instanceof HTMLElement && e.target.hasPointerCapture(e.pointerId)))
|
|
234
|
+
return;
|
|
235
|
+
// Ensure only one pointer is being tracked
|
|
236
|
+
if (!e.isPrimary)
|
|
237
|
+
return;
|
|
238
|
+
// Prevents sheet drag from being interrupted
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
let deltaY = this.startY - e.pageY;
|
|
241
|
+
const newHeight = this.startHeight + (deltaY / window.innerHeight) * 100;
|
|
242
|
+
if (e.target.id === 'handle') {
|
|
243
|
+
this.height = newHeight;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
pointerUp(e) {
|
|
247
|
+
if (!(e.target instanceof HTMLElement))
|
|
248
|
+
return;
|
|
249
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
250
|
+
this.setSnap(this.height);
|
|
251
|
+
}
|
|
252
|
+
onSnapped(snapped, activeElement) {
|
|
253
|
+
this.dragging = !snapped;
|
|
254
|
+
}
|
|
255
|
+
contentScroll(e) {
|
|
256
|
+
if (!(e.target instanceof HTMLElement && e.target.id === 'content'))
|
|
257
|
+
return;
|
|
258
|
+
const currentScrollTop = e.target.scrollTop;
|
|
259
|
+
this.scrolling = currentScrollTop !== this.lastScrollTop;
|
|
260
|
+
this.lastScrollTop = currentScrollTop;
|
|
261
|
+
if (currentScrollTop === 0)
|
|
262
|
+
this.scrolling = false;
|
|
263
|
+
}
|
|
160
264
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
:host {
|
|
164
|
-
contain: content;
|
|
165
|
-
overscroll-behavior-block: none;
|
|
166
|
-
--height: fit-content;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
:host([dragging]) dialog {
|
|
170
|
-
#content {
|
|
171
|
-
cursor: grabbing;
|
|
172
|
-
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
173
|
-
touch-action: none;
|
|
174
|
-
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
175
|
-
overflow-y: hidden;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
:host(:not([dragging])) dialog {
|
|
180
|
-
/* Only animate if not dragging */
|
|
181
|
-
transition-property: overlay opacity display;
|
|
182
|
-
transition-duration: 0.25s;
|
|
183
|
-
transition-behavior: allow-discrete;
|
|
184
|
-
|
|
185
|
-
&::backdrop {
|
|
186
|
-
transition-property: overlay opacity display;
|
|
187
|
-
transition-duration: 0.25s;
|
|
188
|
-
transition-behavior: allow-discrete;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
#content {
|
|
192
|
-
/* Allow scroll */
|
|
193
|
-
touch-action: pan-y;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
dialog {
|
|
198
|
-
display: none;
|
|
199
|
-
opacity: 0;
|
|
200
|
-
translate: 0 var(--height);
|
|
201
|
-
|
|
202
|
-
height: var(--height);
|
|
203
|
-
min-height: 0;
|
|
204
|
-
max-height: 100%;
|
|
205
|
-
min-width: 100%;
|
|
206
|
-
max-width: 100%;
|
|
207
|
-
flex-direction: column;
|
|
208
|
-
box-sizing: border-box;
|
|
209
|
-
padding: 0;
|
|
210
|
-
border: 0;
|
|
211
|
-
background-color: light-dark(#d9d9d9, #1c1c1c);
|
|
212
|
-
/* Important! Removes default browser styling, allowing bottom to work */
|
|
213
|
-
inset: unset;
|
|
214
|
-
bottom: 0;
|
|
215
|
-
left: 0;
|
|
216
|
-
overflow-y: hidden;
|
|
217
|
-
|
|
218
|
-
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
219
|
-
touch-action: none;
|
|
220
|
-
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
221
|
-
overflow-y: hidden;
|
|
222
|
-
|
|
223
|
-
&[open] {
|
|
224
|
-
display: flex;
|
|
225
|
-
opacity: 1;
|
|
226
|
-
translate: 0 0;
|
|
227
|
-
|
|
228
|
-
&::backdrop {
|
|
229
|
-
opacity: 0.8;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
&::backdrop {
|
|
234
|
-
background: black;
|
|
235
|
-
opacity: 0;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@starting-style {
|
|
240
|
-
dialog[open] {
|
|
241
|
-
opacity: 0;
|
|
242
|
-
translate: 0 var(--height);
|
|
243
|
-
|
|
244
|
-
&::backdrop {
|
|
245
|
-
opacity: 0;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
#handle {
|
|
251
|
-
display: block;
|
|
252
|
-
position: sticky;
|
|
253
|
-
top: 0;
|
|
254
|
-
background: transparent;
|
|
255
|
-
border: 0;
|
|
256
|
-
cursor: grabbing;
|
|
257
|
-
min-height: 35px;
|
|
258
|
-
user-select: none;
|
|
259
|
-
touch-action: none;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
div {
|
|
263
|
-
/* display: contents; */
|
|
264
|
-
overflow-y: auto;
|
|
265
|
-
scrollbar-width: none;
|
|
266
|
-
box-sizing: border-box;
|
|
267
|
-
min-height: 100%;
|
|
268
|
-
min-width: 100%;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
::slotted(*) {
|
|
272
|
-
/* Prevent slotted items from taking pointer events */
|
|
273
|
-
/* pointer-events: none; */
|
|
274
|
-
}
|
|
275
|
-
|
|
265
|
+
BottomSheet.styles = [
|
|
266
|
+
css `
|
|
267
|
+
:host {
|
|
268
|
+
contain: content;
|
|
269
|
+
overscroll-behavior-block: none;
|
|
270
|
+
--height: fit-content;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
:host([dragging]) dialog {
|
|
274
|
+
#content {
|
|
275
|
+
cursor: grabbing;
|
|
276
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
277
|
+
touch-action: none;
|
|
278
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
279
|
+
overflow-y: hidden;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
:host(:not([dragging])) dialog {
|
|
284
|
+
/* Only animate if not dragging */
|
|
285
|
+
transition-property: overlay opacity display;
|
|
286
|
+
transition-duration: 0.25s;
|
|
287
|
+
transition-behavior: allow-discrete;
|
|
288
|
+
|
|
289
|
+
&::backdrop {
|
|
290
|
+
transition-property: overlay opacity display;
|
|
291
|
+
transition-duration: 0.25s;
|
|
292
|
+
transition-behavior: allow-discrete;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#content {
|
|
296
|
+
/* Allow scroll */
|
|
297
|
+
touch-action: pan-y;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
dialog {
|
|
302
|
+
display: none;
|
|
303
|
+
opacity: 0;
|
|
304
|
+
translate: 0 var(--height);
|
|
305
|
+
|
|
306
|
+
height: var(--height);
|
|
307
|
+
min-height: 0;
|
|
308
|
+
max-height: 100%;
|
|
309
|
+
min-width: 100%;
|
|
310
|
+
max-width: 100%;
|
|
311
|
+
flex-direction: column;
|
|
312
|
+
box-sizing: border-box;
|
|
313
|
+
padding: 0;
|
|
314
|
+
border: 0;
|
|
315
|
+
background-color: light-dark(#d9d9d9, #1c1c1c);
|
|
316
|
+
/* Important! Removes default browser styling, allowing bottom to work */
|
|
317
|
+
inset: unset;
|
|
318
|
+
bottom: 0;
|
|
319
|
+
left: 0;
|
|
320
|
+
overflow-y: hidden;
|
|
321
|
+
|
|
322
|
+
/* Important! Prevents mobile browsers from reclaiming PointerMove event on touch devices */
|
|
323
|
+
touch-action: none;
|
|
324
|
+
/* Prevent weird scrollbar movement on mobile when dragging */
|
|
325
|
+
overflow-y: hidden;
|
|
326
|
+
|
|
327
|
+
&[open] {
|
|
328
|
+
display: flex;
|
|
329
|
+
opacity: 1;
|
|
330
|
+
translate: 0 0;
|
|
331
|
+
|
|
332
|
+
&::backdrop {
|
|
333
|
+
opacity: 0.8;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
&::backdrop {
|
|
338
|
+
background: black;
|
|
339
|
+
opacity: 0;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@starting-style {
|
|
344
|
+
dialog[open] {
|
|
345
|
+
opacity: 0;
|
|
346
|
+
translate: 0 var(--height);
|
|
347
|
+
|
|
348
|
+
&::backdrop {
|
|
349
|
+
opacity: 0;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
#handle {
|
|
355
|
+
display: block;
|
|
356
|
+
position: sticky;
|
|
357
|
+
top: 0;
|
|
358
|
+
background: transparent;
|
|
359
|
+
border: 0;
|
|
360
|
+
cursor: grabbing;
|
|
361
|
+
min-height: 35px;
|
|
362
|
+
user-select: none;
|
|
363
|
+
touch-action: none;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
div {
|
|
367
|
+
/* display: contents; */
|
|
368
|
+
overflow-y: auto;
|
|
369
|
+
scrollbar-width: none;
|
|
370
|
+
box-sizing: border-box;
|
|
371
|
+
min-height: 100%;
|
|
372
|
+
min-width: 100%;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
::slotted(*) {
|
|
376
|
+
/* Prevent slotted items from taking pointer events */
|
|
377
|
+
/* pointer-events: none; */
|
|
378
|
+
}
|
|
379
|
+
`,
|
|
276
380
|
];
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
],
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
],
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
],
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
],
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
],
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
],
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
],
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
],
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
],
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
381
|
+
__decorate([
|
|
382
|
+
query('dialog')
|
|
383
|
+
], BottomSheet.prototype, "dialog", void 0);
|
|
384
|
+
__decorate([
|
|
385
|
+
query('dialog:not(:modal)')
|
|
386
|
+
], BottomSheet.prototype, "nonModalDialog", void 0);
|
|
387
|
+
__decorate([
|
|
388
|
+
query('dialog:modal')
|
|
389
|
+
], BottomSheet.prototype, "modalDialog", void 0);
|
|
390
|
+
__decorate([
|
|
391
|
+
property({ type: Boolean, reflect: true })
|
|
392
|
+
], BottomSheet.prototype, "open", void 0);
|
|
393
|
+
__decorate([
|
|
394
|
+
property({ type: Boolean, reflect: true })
|
|
395
|
+
], BottomSheet.prototype, "nonmodal", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
property({ type: Boolean, reflect: true })
|
|
398
|
+
], BottomSheet.prototype, "dragging", void 0);
|
|
399
|
+
__decorate([
|
|
400
|
+
property({ type: Boolean, reflect: true })
|
|
401
|
+
], BottomSheet.prototype, "scrolling", void 0);
|
|
402
|
+
__decorate([
|
|
403
|
+
property({ type: Array })
|
|
404
|
+
], BottomSheet.prototype, "snapPoints", void 0);
|
|
405
|
+
__decorate([
|
|
406
|
+
property({ type: Number })
|
|
407
|
+
], BottomSheet.prototype, "defaultSnap", void 0);
|
|
408
|
+
__decorate([
|
|
409
|
+
property({ type: Number, reflect: true })
|
|
410
|
+
/**
|
|
411
|
+
* Sets the height of the sheet
|
|
412
|
+
* Infinity can be used to fit content automatically
|
|
413
|
+
* @param height percentage or infinity
|
|
414
|
+
*/
|
|
415
|
+
], BottomSheet.prototype, "height", null);
|
|
416
|
+
BottomSheet = __decorate([
|
|
417
|
+
customElement('bottom-sheet')
|
|
418
|
+
], BottomSheet);
|
|
419
|
+
export { BottomSheet };
|