@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.
Files changed (52) hide show
  1. package/dist/components/absolute-container/absolute-container.js +113 -91
  2. package/dist/components/absolute-container/absolute-container.stories.js +36 -0
  3. package/dist/components/absolute-container/index.js +1 -1
  4. package/dist/components/bottom-sheet/bottom-sheet.js +415 -308
  5. package/dist/components/bottom-sheet/bottom-sheet.stories.js +43 -0
  6. package/dist/components/bottom-sheet/bottom-sheet.test.js +15 -0
  7. package/dist/components/bottom-sheet/index.js +1 -1
  8. package/dist/components/canvas/canvas-base.d.ts +2 -1
  9. package/dist/components/canvas/canvas-base.d.ts.map +1 -1
  10. package/dist/components/canvas/canvas-base.js +56 -44
  11. package/dist/components/canvas/canvas-gradient.js +61 -45
  12. package/dist/components/canvas/canvas-image.js +158 -111
  13. package/dist/components/canvas/index.js +2 -2
  14. package/dist/components/carousel-scroller/carousel-scroller.js +133 -121
  15. package/dist/components/carousel-scroller/carousel-scroller.stories.js +40 -0
  16. package/dist/components/carousel-scroller/index.js +1 -1
  17. package/dist/components/color-palette/color-palette-utils.js +105 -41
  18. package/dist/components/color-palette/color-palette.js +429 -337
  19. package/dist/components/color-palette/component/color-palette-component.js +184 -142
  20. package/dist/components/color-palette/component/color-palette-component.stories.js +74 -0
  21. package/dist/components/color-palette/component/index.js +1 -0
  22. package/dist/components/color-palette/editor/color-palette-editor.js +702 -591
  23. package/dist/components/color-palette/editor/color-palette-editor.stories.js +39 -0
  24. package/dist/components/color-palette/editor/index.js +1 -0
  25. package/dist/components/color-palette/index.js +5 -7
  26. package/dist/components/color-palette/item/color-palette-item-edit.js +114 -87
  27. package/dist/components/color-palette/item/color-palette-item.js +155 -140
  28. package/dist/components/color-palette/item/index.js +2 -0
  29. package/dist/components/color-palette/menu/color-palette-menu.js +241 -217
  30. package/dist/components/color-palette/menu/color-palette-reorder.js +117 -103
  31. package/dist/components/color-palette/menu/index.js +2 -0
  32. package/dist/components/color-palette/storybook/color-palette-invalid.stories.js +90 -0
  33. package/dist/components/color-palette/storybook/color-palette-valid.stories.js +295 -0
  34. package/dist/components/color-palette/storybook/color-palette.stories.js +76 -0
  35. package/dist/components/tool-tip/Tooltip2.js +103 -0
  36. package/dist/components/tool-tip/index.js +1 -1
  37. package/dist/components/tool-tip/tool-tip.d.ts +1 -0
  38. package/dist/components/tool-tip/tool-tip.d.ts.map +1 -1
  39. package/dist/components/tool-tip/tool-tip.js +125 -102
  40. package/dist/components/tool-tip/tool-tip.stories.js +30 -0
  41. package/dist/index.js +6 -14
  42. package/dist/utils/EventEmitter.js +23 -23
  43. package/dist/utils/basicUtils.js +149 -32
  44. package/dist/utils/dragDropUtils.js +121 -0
  45. package/dist/utils/generateUtils.js +73 -39
  46. package/dist/utils/types.d.ts +1 -1
  47. package/dist/utils/types.d.ts.map +1 -1
  48. package/dist/utils/types.js +1 -0
  49. package/package.json +1 -1
  50. package/dist/_virtual/_commonjsHelpers.js +0 -8
  51. package/dist/_virtual/x11.js +0 -4
  52. package/dist/node_modules/colorsea/colors/x11.js +0 -14
@@ -1,312 +1,419 @@
1
- import { css as p, LitElement as g, html as d } from "lit";
2
- import { query as c, property as a, customElement as u } from "lit/decorators.js";
3
- import { EventEmitter as m } from "../../utils/EventEmitter.js";
4
- var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, r = (t, e, o, s) => {
5
- for (var n = s > 1 ? void 0 : s ? v(e, o) : e, h = t.length - 1, l; h >= 0; h--)
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
- let i = class extends g {
10
- constructor() {
11
- super(...arguments), this.open = !1, this.nonmodal = !1, this.dragging = !1, this.scrolling = !1, this.snapPoints = [], this.defaultSnap = NaN, this.emitter = new m(), this.startY = 0, this.startHeight = 0, this.previousTouch = null, this.lastScrollTop = 0;
12
- }
13
- /**
14
- * Sets the height of the sheet
15
- * Infinity can be used to fit content automatically
16
- * @param height percentage or infinity
17
- */
18
- set height(t) {
19
- var o;
20
- const e = Math.min(Math.max(t, 0), 100);
21
- this.emitter.emit("snapped", this.isSnapped(e), (o = this.shadowRoot) == null ? void 0 : o.activeElement), isFinite(t) ? this.style.setProperty("--height", `${Math.round(e)}dvh`) : this.style.setProperty("--height", "fit-content");
22
- }
23
- get height() {
24
- return parseInt(this.style.getPropertyValue("--height"));
25
- }
26
- connectedCallback() {
27
- super.connectedCallback();
28
- const t = this.snapPoints.length === 2 ? 0 : 1;
29
- this.defaultSnap = this.snapPoints.length > 0 ? isNaN(this.defaultSnap) ? this.snapPoints[Math.round(this.snapPoints.length / 2) - t] : this.defaultSnap : NaN, this.emitter.on("snapped", this.onSnapped.bind(this)), requestAnimationFrame(() => {
30
- this.showSheet(this.open);
31
- });
32
- }
33
- disconnectedCallback() {
34
- super.disconnectedCallback(), this.emitter.clear();
35
- }
36
- render() {
37
- return requestAnimationFrame(() => {
38
- this.setDialog(this.open);
39
- }), d`
40
- <dialog
41
- @click=${(t) => {
42
- t.stopPropagation(), this.toggleSheet();
43
- }}
44
- >
45
- <button
46
- id="handle"
47
- part="handle"
48
- @pointerdown=${this.pointerDown}
49
- @pointermove=${this.pointerMove}
50
- @pointerup=${this.pointerUp}
51
- @click=${(t) => {
52
- t.stopPropagation();
53
- }}
54
- >
55
-
56
- </button>
57
-
58
- <div
59
- id='content'
60
- part="content"
61
- tabindex='0'
62
- @touchstart=${this.touchDown}
63
- @touchend=${this.touchUp}
64
- @touchmove=${this.touchMove}
65
- @scroll=${this.contentScroll}
66
- @touchcancel=${(t) => {
67
- console.warn("User Agent touchcancelled the event.", t.target);
68
- }}
69
- @dragstart=${(t) => {
70
- t.preventDefault();
71
- }}
72
- @click=${(t) => {
73
- t.stopPropagation();
74
- }}
75
- >
76
- <slot></slot>
77
- </div>
78
- </dialog>
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
- * Find closest point index to target in array
83
- */
84
- closestSnapPointIndex(t, e) {
85
- return t.reduce((o, s, n) => Math.abs(s - e) < Math.abs(t[o] - e) ? n : o, 0);
86
- }
87
- /**
88
- * Sets sheet height to the closest snap
89
- * @param height percentage
90
- */
91
- setSnap(t) {
92
- if (this.snapPoints.length === 0) return;
93
- const e = this.snapPoints[this.closestSnapPointIndex(this.snapPoints, t)];
94
- e === this.snapPoints[0] && this.showSheet(!1), this.height = e;
95
- }
96
- /**
97
- * @returns Whether sheet is snapped to a snap point
98
- */
99
- isSnapped(t) {
100
- return this.snapPoints.some((e) => e === Math.round(t));
101
- }
102
- /**
103
- * Sets the display state of the sheet
104
- */
105
- showSheet(t) {
106
- this.open = t, this.height = isNaN(this.defaultSnap) ? 1 / 0 : this.defaultSnap, this.setOverscroll(t), this.setDialog(t);
107
- }
108
- /**
109
- * Toggles the display state of the sheet
110
- */
111
- toggleSheet() {
112
- this.showSheet(!this.open);
113
- }
114
- /**
115
- * Remove overscroll to prevent mobile browsers from refreshing during drag
116
- */
117
- setOverscroll(t) {
118
- const e = document.querySelector("html"), o = document.querySelector("body"), s = t ? "none" : "unset";
119
- e && e.style.setProperty("overscroll-behavior-block", s), o && o.style.setProperty("overscroll-behavior-block", s);
120
- }
121
- setDialog(t) {
122
- t && !this.dialog.open ? this.nonmodal ? this.dialog.show() : this.dialog.showModal() : t && this.dialog.open ? this.nonmodal && this.modalDialog ? (this.dialog.close(), this.dialog.show()) : !this.nonmodal && this.nonModalDialog && (this.dialog.close(), this.dialog.showModal()) : this.dialog.close();
123
- }
124
- touchDown(t) {
125
- t.target instanceof HTMLElement && (this.startY = t.touches[0].pageY, this.startHeight = this.height);
126
- }
127
- touchMove(t) {
128
- if (!(t.target instanceof HTMLElement)) return;
129
- const e = t.touches[0];
130
- let o = NaN;
131
- this.previousTouch && (o = e.pageY - this.previousTouch.pageY), this.previousTouch = e;
132
- let s = this.startY - t.touches[0].pageY;
133
- const n = this.startHeight + s / window.innerHeight * 100;
134
- !this.scrolling && this.dragging ? this.height = n : this.scrolling && this.dragging || this.scrolling && !this.dragging ? t.target.focus({ preventScroll: !0 }) : !this.scrolling && !this.dragging && (o >= 0 ? this.height = Math.min(n, this.defaultSnap || this.snapPoints[this.snapPoints.length - 1]) : t.target.focus({ preventScroll: !0 }));
135
- }
136
- touchUp(t) {
137
- t.target instanceof HTMLElement && (this.previousTouch = null, this.setSnap(this.height));
138
- }
139
- pointerDown(t) {
140
- t.target instanceof HTMLElement && (t.target.setPointerCapture(t.pointerId), this.startY = t.pageY, this.startHeight = this.height);
141
- }
142
- pointerMove(t) {
143
- if (!(t.target instanceof HTMLElement && t.target.hasPointerCapture(t.pointerId)) || !t.isPrimary) return;
144
- t.preventDefault();
145
- let e = this.startY - t.pageY;
146
- const o = this.startHeight + e / window.innerHeight * 100;
147
- t.target.id === "handle" && (this.height = o);
148
- }
149
- pointerUp(t) {
150
- t.target instanceof HTMLElement && (t.target.releasePointerCapture(t.pointerId), this.setSnap(this.height));
151
- }
152
- onSnapped(t, e) {
153
- this.dragging = !t;
154
- }
155
- contentScroll(t) {
156
- if (!(t.target instanceof HTMLElement && t.target.id === "content")) return;
157
- const e = t.target.scrollTop;
158
- this.scrolling = e !== this.lastScrollTop, this.lastScrollTop = e, e === 0 && (this.scrolling = !1);
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
- i.styles = [
162
- p`
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
- r([
278
- c("dialog")
279
- ], i.prototype, "dialog", 2);
280
- r([
281
- c("dialog:not(:modal)")
282
- ], i.prototype, "nonModalDialog", 2);
283
- r([
284
- c("dialog:modal")
285
- ], i.prototype, "modalDialog", 2);
286
- r([
287
- a({ type: Boolean, reflect: !0 })
288
- ], i.prototype, "open", 2);
289
- r([
290
- a({ type: Boolean, reflect: !0 })
291
- ], i.prototype, "nonmodal", 2);
292
- r([
293
- a({ type: Boolean, reflect: !0 })
294
- ], i.prototype, "dragging", 2);
295
- r([
296
- a({ type: Boolean, reflect: !0 })
297
- ], i.prototype, "scrolling", 2);
298
- r([
299
- a({ type: Array })
300
- ], i.prototype, "snapPoints", 2);
301
- r([
302
- a({ type: Number })
303
- ], i.prototype, "defaultSnap", 2);
304
- r([
305
- a({ type: Number, reflect: !0 })
306
- ], i.prototype, "height", 1);
307
- i = r([
308
- u("bottom-sheet")
309
- ], i);
310
- export {
311
- i as BottomSheet
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 };