@mhmo91/schmancy 0.2.26 → 0.2.28

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.
@@ -1,193 +0,0 @@
1
- import { Subject as x, switchMap as j, forkJoin as S, fromEvent as d, takeUntil as b, timer as C, map as p, defaultIfEmpty as F, of as O, tap as l, delay as u, filter as D, take as U, mergeMap as B, merge as I } from "rxjs";
2
- import "lit/directives/class-map.js";
3
- import "lit/directives/style-map.js";
4
- import { T as $ } from "./tailwind.mixin-DtR4DQvn.js";
5
- import { css as T, html as f } from "lit";
6
- import { property as h, customElement as w, query as L, queryAssignedElements as q } from "lit/decorators.js";
7
- import { $ as z } from "./litElement.mixin-CjxO_zfv.js";
8
- var N = Object.defineProperty, M = Object.getOwnPropertyDescriptor, k = (t, e, s, o) => {
9
- for (var n, i = o > 1 ? void 0 : o ? M(e, s) : e, a = t.length - 1; a >= 0; a--) (n = t[a]) && (i = (o ? n(e, s, i) : n(i)) || i);
10
- return o && i && N(e, s, i), i;
11
- };
12
- let m = class extends $(T`
13
- :host {
14
- inset: 0;
15
- display: block;
16
- padding-bottom: 16px;
17
- }
18
- `) {
19
- render() {
20
- const t = { absolute: this.title.length === 0, relative: this.title.length > 0 };
21
- return f`
22
- <schmancy-grid class="${this.classMap(t)}" align="center" justify="stretch" cols="auto 1fr auto">
23
- <slot name="back">
24
- <schmancy-button
25
- @click=${() => {
26
- this.dispatchEvent(new CustomEvent("dismiss", { bubbles: !0, composed: !0 }));
27
- }}
28
- >
29
- <span class="text-[24px]">&#8592; </span>
30
- </schmancy-button>
31
- </slot>
32
- <schmancy-typography transform="capitalize" type="headline" token="lg"> ${this.title} </schmancy-typography>
33
- <slot name="actions">
34
- <schmancy-button
35
- @click=${() => {
36
- this.dispatchEvent(new CustomEvent("dismiss", { bubbles: !0, composed: !0 }));
37
- }}
38
- >
39
- <span class="text-[24px]">✕</span>
40
- </schmancy-button>
41
- </slot>
42
- </schmancy-grid>
43
- `;
44
- }
45
- };
46
- function R(t, e) {
47
- return (s, o) => {
48
- const { willUpdate: n } = s;
49
- e = Object.assign({ waitUntilFirstUpdate: !1 }, e), s.willUpdate = function(i) {
50
- if (n.call(this, i), i.has(t)) {
51
- const a = i.get(t), E = this[t];
52
- a !== E && (e != null && e.waitUntilFirstUpdate && !this.hasUpdated || this[o].call(this, a, E));
53
- }
54
- };
55
- };
56
- }
57
- k([h()], m.prototype, "title", 2), m = k([w("schmancy-sheet-header")], m);
58
- var J = Object.defineProperty, Y = Object.getOwnPropertyDescriptor;
59
- let A = class extends $() {
60
- render() {
61
- return f`
62
- <div tabindex="0">
63
- <slot></slot>
64
- </div>
65
- `;
66
- }
67
- };
68
- A = ((t, e, s, o) => {
69
- for (var n, i = o > 1 ? void 0 : o ? Y(e, s) : e, a = t.length - 1; a >= 0; a--) (n = t[a]) && (i = (o ? n(e, s, i) : n(i)) || i);
70
- return o && i && J(e, s, i), i;
71
- })([w("schmancy-sheet-content")], A);
72
- var P = ((t) => (t.Side = "side", t.Bottom = "bottom", t.BottomCenter = "bottom-center", t.TopRight = "top-right", t.BottomRight = "bottom-right", t))(P || {});
73
- const v = "are-you-there-sheet", g = "yes-here", y = new class {
74
- constructor() {
75
- this.bottomSheet = new x(), this.$dismiss = new x(), this.bottomSheet.pipe(j((t) => S([d(window, g).pipe(b(C(0)), p((e) => e.detail.sheet), F(void 0)), O(t).pipe(l(() => {
76
- window.dispatchEvent(new CustomEvent(v, { detail: { uid: t.uid ?? t.component.tagName } }));
77
- }))])), p(([t, e]) => (t || (t = document.createElement("schmancy-sheet"), document.body.appendChild(t)), t.setAttribute("uid", e.uid ?? e.component.tagName), t.setAttribute("position", e.position ?? "bottom"), t.setAttribute("allowOverlyDismiss", e.allowOverlyDismiss === !1 ? "false" : "true"), e.title && t.setAttribute("title", e.title), e.persist && t.setAttribute("persist", e.persist ?? !1), e.header && t.setAttribute("header", e.header), document.body.style.overflow = "hidden", { target: e, sheet: t })), u(20), D(({ target: t, sheet: e }) => {
78
- var s, o;
79
- return !t.persist || !((o = (s = e == null ? void 0 : e.shadowRoot) == null ? void 0 : s.querySelector("slot")) != null && o.assignedElements().find((n) => n.tagName === t.component.tagName)) || (e == null || e.setAttribute("open", "true"), !1);
80
- }), l(({ target: t, sheet: e }) => {
81
- e == null || e.appendChild(t.component);
82
- }), u(1), l(({ sheet: t }) => {
83
- t == null || t.setAttribute("open", "true");
84
- }), l(({ sheet: t }) => {
85
- d(t, "close").pipe(U(1)).pipe(u(300)).subscribe((e) => {
86
- const s = e.target;
87
- s != null && s.persist || (s == null || s.remove()), document.body.style.overflow = "auto";
88
- });
89
- })).subscribe(), this.$dismiss.pipe(B((t) => S([d(window, g).pipe(b(C(100)), p((e) => e.detail.sheet), F(void 0)), O(t).pipe(l(() => {
90
- window.dispatchEvent(new CustomEvent(v, { detail: { uid: t } }));
91
- }))])), l(([t]) => {
92
- t == null || t.closeSheet();
93
- })).subscribe();
94
- }
95
- dismiss(t) {
96
- this.$dismiss.next(t);
97
- }
98
- open(t) {
99
- this.bottomSheet.next(t);
100
- }
101
- }();
102
- var G = Object.defineProperty, H = Object.getOwnPropertyDescriptor, c = (t, e, s, o) => {
103
- for (var n, i = o > 1 ? void 0 : o ? H(e, s) : e, a = t.length - 1; a >= 0; a--) (n = t[a]) && (i = (o ? n(e, s, i) : n(i)) || i);
104
- return o && i && G(e, s, i), i;
105
- };
106
- let r = class extends z(":host{--overlay-color: var(--schmancy-sys-color-surface-dim);--transition-duration: .2s;--sheet-radius: 0;--max-height: 100vh}.sheet{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1000;display:flex;visibility:visible;transition:visibility var(--transition-duration) ease-in-out}.sheet[aria-hidden=true]{visibility:hidden;pointer-events:none}.sheet[aria-hidden=true] .content{transform:translateY(100%)}.sheet[aria-hidden=true] .content[data-position=side]{transform:translate(100%)}.sheet[aria-hidden=true] .overlay{opacity:0}.overlay{position:absolute;top:0;right:0;bottom:0;left:0;background:var(--overlay-color);opacity:.4;transition:opacity var(--transition-duration) ease-in-out}.content{z-index:1;transition:transform var(--transition-duration) ease-in-out}.content[data-position=side]{height:100%;margin-left:auto;min-width:320px;max-width:90vw;width:fit-content}.content[data-position=bottom]{width:100%;margin-top:auto;border-radius:16px 16px 0 0;max-height:90vh}") {
107
- constructor() {
108
- super(...arguments), this.open = !1, this.header = "visible", this.position = P.Side, this.persist = !1, this.allowOverlayDismiss = !0, this.title = "", this.focusAttribute = "autofocus", this.lastFocusedElement = null, this.handleFocusIn = (t) => {
109
- var e;
110
- (e = this.sheet) != null && e.contains(t.target) || this.focus();
111
- };
112
- }
113
- onOpenChange(t, e) {
114
- var s;
115
- this.setIsSheetShown(e), e ? (this.lastFocusedElement = document.activeElement, this.addFocusTrap(), this.focus()) : (this.removeFocusTrap(), (s = this.lastFocusedElement) == null || s.focus(), this.lastFocusedElement = null);
116
- }
117
- connectedCallback() {
118
- super.connectedCallback(), this.setupEventListeners();
119
- }
120
- disconnectedCallback() {
121
- super.disconnectedCallback(), this.disconnecting.next(!0);
122
- }
123
- setupEventListeners() {
124
- const t = d(window, "popstate").pipe(l((o) => {
125
- o.preventDefault(), this.closeSheet();
126
- })), e = d(window, "keyup").pipe(l((o) => {
127
- o.key !== "Escape" || this.sheetContainsFocus() || y.dismiss(this.uid);
128
- })), s = d(window, v).pipe(l((o) => {
129
- o.detail.uid === this.uid && this.announcePresence();
130
- }));
131
- I(t, e, s).pipe(b(this.disconnecting)).subscribe();
132
- }
133
- sheetContainsFocus() {
134
- var t;
135
- return ((t = this.sheet) == null ? void 0 : t.contains(document.activeElement)) ?? !1;
136
- }
137
- announcePresence() {
138
- this.dispatchEvent(new CustomEvent(g, { detail: { sheet: this }, bubbles: !0, composed: !0 }));
139
- }
140
- addFocusTrap() {
141
- document.addEventListener("focusin", this.handleFocusIn);
142
- }
143
- removeFocusTrap() {
144
- document.removeEventListener("focusin", this.handleFocusIn);
145
- }
146
- setIsSheetShown(t) {
147
- var e, s;
148
- (e = this.sheet) == null || e.setAttribute("aria-hidden", String(!t)), (s = this.sheet) == null || s.setAttribute("aria-modal", String(t));
149
- }
150
- closeSheet() {
151
- this.open = !1, this.dispatchEvent(new CustomEvent("close"));
152
- }
153
- getFocusElement() {
154
- const t = `[${this.focusAttribute}]`;
155
- return this.assignedElements.find((e) => e.matches(t) || e.querySelector(t)) ?? null;
156
- }
157
- focus() {
158
- var t;
159
- (t = this.getFocusElement()) == null || t.focus();
160
- }
161
- render() {
162
- return f`
163
- <div class="sheet" role="dialog" aria-labelledby="sheet-title" aria-hidden="true" aria-modal="false">
164
- <div
165
- class="overlay"
166
- @click=${(t) => {
167
- t.stopPropagation(), this.allowOverlayDismiss && y.dismiss(this.uid);
168
- }}
169
- ></div>
170
- <schmancy-sheet-content class="content" data-position=${this.position}>
171
- <schmancy-sheet-header
172
- @dismiss=${(t) => {
173
- t.stopPropagation(), y.dismiss(this.uid);
174
- }}
175
- id="sheet-title"
176
- .hidden=${this.header === "hidden"}
177
- title=${this.title}
178
- ></schmancy-sheet-header>
179
- <slot></slot>
180
- </schmancy-sheet-content>
181
- </div>
182
- `;
183
- }
184
- };
185
- c([h({ type: String, reflect: !0 })], r.prototype, "uid", 2), c([h({ type: Boolean, reflect: !0 })], r.prototype, "open", 2), c([h({ type: String, reflect: !0 })], r.prototype, "header", 2), c([h({ type: String, reflect: !0 })], r.prototype, "position", 2), c([h({ type: Boolean, reflect: !0 })], r.prototype, "persist", 2), c([h({ type: Boolean, reflect: !0 })], r.prototype, "allowOverlayDismiss", 2), c([h({ type: String, reflect: !0 })], r.prototype, "title", 2), c([L(".sheet")], r.prototype, "sheet", 2), c([q({ flatten: !0 })], r.prototype, "assignedElements", 2), c([h()], r.prototype, "focusAttribute", 2), c([R("open")], r.prototype, "onOpenChange", 1), r = c([w("schmancy-sheet")], r);
186
- export {
187
- P as S,
188
- v as a,
189
- g as b,
190
- R as h,
191
- y as s
192
- };
193
- //# sourceMappingURL=sheet-Dt3siMhI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sheet-Dt3siMhI.js","sources":["../src/sheet/header.ts","../src/sheet/hook.ts","../src/sheet/sheet-content.ts","../src/sheet/sheet.service.ts","../src/sheet/sheet.ts"],"sourcesContent":["import { TailwindElement } from '@mixins/index'\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\n@customElement('schmancy-sheet-header')\nexport default class SchmancySheetHeader extends TailwindElement(css`\n\t:host {\n\t\tinset: 0;\n\t\tdisplay: block;\n\t\tpadding-bottom: 16px;\n\t}\n`) {\n\t@property() title: string\n\trender() {\n\t\tconst classes = {\n\t\t\tabsolute: this.title.length === 0,\n\t\t\trelative: this.title.length > 0,\n\t\t}\n\t\treturn html`\n\t\t\t<schmancy-grid class=\"${this.classMap(classes)}\" align=\"center\" justify=\"stretch\" cols=\"auto 1fr auto\">\n\t\t\t\t<slot name=\"back\">\n\t\t\t\t\t<schmancy-button\n\t\t\t\t\t\t@click=${() => {\n\t\t\t\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\t\t\t\tnew CustomEvent('dismiss', {\n\t\t\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"text-[24px]\">&#8592; </span>\n\t\t\t\t\t</schmancy-button>\n\t\t\t\t</slot>\n\t\t\t\t<schmancy-typography transform=\"capitalize\" type=\"headline\" token=\"lg\"> ${this.title} </schmancy-typography>\n\t\t\t\t<slot name=\"actions\">\n\t\t\t\t\t<schmancy-button\n\t\t\t\t\t\t@click=${() => {\n\t\t\t\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\t\t\t\tnew CustomEvent('dismiss', {\n\t\t\t\t\t\t\t\t\tbubbles: true,\n\t\t\t\t\t\t\t\t\tcomposed: true,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"text-[24px]\">✕</span>\n\t\t\t\t\t</schmancy-button>\n\t\t\t\t</slot>\n\t\t\t</schmancy-grid>\n\t\t`\n\t}\n}\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-sheet-header': SchmancySheetHeader\n\t}\n}\n","// @watch decorator\n//\n// Runs when an observed property changes, e.g. @property or @state, but before the component updates.\n//\n// To wait for an update to complete after a change occurs, use `await this.updateComplete` in the handler. To start\n// watching after the initial update/render, use `{ waitUntilFirstUpdate: true }` or `this.hasUpdated` in the handler.\n//\n// Usage:\n//\n// @watch('propName')\n// handlePropChange(oldValue, newValue) {\n// ...\n// }\n//\ninterface WatchOptions {\n waitUntilFirstUpdate?: boolean\n}\n\nexport function hook(propName: string, options?: WatchOptions) {\n return (protoOrDescriptor: any, name: string): any => {\n const { willUpdate } = protoOrDescriptor\n\n options = Object.assign({ waitUntilFirstUpdate: false }, options) as WatchOptions\n\n protoOrDescriptor.willUpdate = function (changedProps: Map<string, any>) {\n willUpdate.call(this, changedProps)\n\n if (changedProps.has(propName)) {\n const oldValue = changedProps.get(propName)\n const newValue = this[propName]\n\n if (oldValue !== newValue) {\n if (!options?.waitUntilFirstUpdate || this.hasUpdated) {\n this[name].call(this, oldValue, newValue)\n }\n }\n }\n }\n }\n}\n","import { TailwindElement } from '@mixins/index'\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\n@customElement('schmancy-sheet-content')\nexport default class SchmancySheetContent extends TailwindElement() {\n\trender() {\n\t\treturn html`\n\t\t\t<div tabindex=\"0\">\n\t\t\t\t<slot></slot>\n\t\t\t</div>\n\t\t`\n\t}\n}\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-sheet-content': SchmancySheetContent\n\t}\n}\n","import {\n\tdefaultIfEmpty,\n\tdelay,\n\tfilter,\n\tforkJoin,\n\tfromEvent,\n\tmap,\n\tmergeMap,\n\tof,\n\tSubject,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n\ttap,\n\ttimer,\n} from 'rxjs'\nimport SchmancySheet from './sheet'\n\nexport enum SchmancySheetPosition {\n\tSide = 'side',\n\tBottom = 'bottom',\n\t/**\n\t * @deprecated use bottom instead\n\t */\n\tBottomCenter = 'bottom-center',\n\t/**\n\t * @deprecated use side instead\n\t */\n\tTopRight = 'top-right',\n\t/**\n\t * @deprecated use side instead\n\t */\n\tBottomRight = 'bottom-right',\n}\n\ntype BottomSheeetTarget = {\n\tcomponent: HTMLElement\n\tuid?: string\n\tposition?: SchmancySheetPosition\n\tpersist?: boolean\n\tclose?: () => void\n\tallowOverlyDismiss?: boolean\n\ttitle?: string\n\theader?: 'hidden' | 'visible'\n}\n\n// Events for communication between bottom-sheet component and bottom-sheet.service\nexport type SheetWhereAreYouRickyEvent = CustomEvent<{\n\tuid: string\n}>\nexport const SheetWhereAreYouRicky = 'are-you-there-sheet'\n\nexport type SheetHereMortyEvent = CustomEvent<{\n\tsheet: SchmancySheet\n}>\nexport const SheetHereMorty = 'yes-here'\nclass BottomSheetService {\n\tbottomSheet = new Subject<BottomSheeetTarget>()\n\t$dismiss = new Subject<string>()\n\tconstructor() {\n\t\tthis.bottomSheet\n\t\t\t.pipe(\n\t\t\t\tswitchMap(target =>\n\t\t\t\t\tforkJoin([\n\t\t\t\t\t\tfromEvent<SheetHereMortyEvent>(window, SheetHereMorty).pipe(\n\t\t\t\t\t\t\ttakeUntil(timer(0)),\n\t\t\t\t\t\t\tmap(e => e.detail.sheet),\n\t\t\t\t\t\t\tdefaultIfEmpty(undefined),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tof(target).pipe(\n\t\t\t\t\t\t\ttap(() => {\n\t\t\t\t\t\t\t\twindow.dispatchEvent(\n\t\t\t\t\t\t\t\t\tnew CustomEvent(SheetWhereAreYouRicky, {\n\t\t\t\t\t\t\t\t\t\tdetail: { uid: target.uid ?? target.component.tagName },\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\tmap(([sheet, target]) => {\n\t\t\t\t\tconsole.log(sheet, target)\n\t\t\t\t\tif (!sheet) {\n\t\t\t\t\t\t// if sheet is not found, create it\n\t\t\t\t\t\tsheet = document.createElement('schmancy-sheet')\n\t\t\t\t\t\tdocument.body.appendChild(sheet)\n\t\t\t\t\t}\n\t\t\t\t\tsheet.setAttribute('uid', target.uid ?? target.component.tagName)\n\t\t\t\t\tsheet.setAttribute('position', target.position ?? SchmancySheetPosition.Bottom)\n\t\t\t\t\tsheet.setAttribute('allowOverlyDismiss', target.allowOverlyDismiss === false ? 'false' : 'true')\n\t\t\t\t\ttarget.title && sheet.setAttribute('title', target.title)\n\t\t\t\t\ttarget.persist && sheet.setAttribute('persist', target.persist ?? false)\n\t\t\t\t\ttarget.header && sheet.setAttribute('header', target.header)\n\t\t\t\t\tdocument.body.style.overflow = 'hidden' // lock the scroll of the host\n\t\t\t\t\treturn { target, sheet }\n\t\t\t\t}),\n\t\t\t\tdelay(20),\n\t\t\t\tfilter(({ target, sheet }) => {\n\t\t\t\t\t// if the sheet has already the component, just show it\n\t\t\t\t\tif (\n\t\t\t\t\t\ttarget.persist &&\n\t\t\t\t\t\tsheet?.shadowRoot\n\t\t\t\t\t\t\t?.querySelector('slot')\n\t\t\t\t\t\t\t?.assignedElements()\n\t\t\t\t\t\t\t.find(e => e.tagName === target.component.tagName)\n\t\t\t\t\t) {\n\t\t\t\t\t\tsheet?.setAttribute('open', 'true')\n\t\t\t\t\t\treturn false\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn true // if the sheet does not have the component, continue to the next step\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t\ttap(({ target, sheet }) => {\n\t\t\t\t\tsheet?.appendChild(target.component)\n\t\t\t\t}),\n\t\t\t\tdelay(1),\n\t\t\t\ttap(({ sheet }) => {\n\t\t\t\t\tsheet?.setAttribute('open', 'true')\n\t\t\t\t}),\n\t\t\t\ttap(({ sheet }) => {\n\t\t\t\t\tfromEvent<CustomEvent>(sheet, 'close')\n\t\t\t\t\t\t.pipe(take(1))\n\t\t\t\t\t\t.pipe(delay(300))\n\t\t\t\t\t\t.subscribe(e => {\n\t\t\t\t\t\t\tconst target = e.target as SchmancySheet\n\t\t\t\t\t\t\tconsole.log(target)\n\n\t\t\t\t\t\t\tif (!target?.persist) target?.remove()\n\t\t\t\t\t\t\tdocument.body.style.overflow = 'auto' // unlock the scroll of the host\n\t\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.subscribe()\n\n\t\tthis.$dismiss\n\t\t\t.pipe(\n\t\t\t\tmergeMap(uid =>\n\t\t\t\t\tforkJoin([\n\t\t\t\t\t\tfromEvent<SheetHereMortyEvent>(window, SheetHereMorty).pipe(\n\t\t\t\t\t\t\ttakeUntil(timer(100)), // Some people say why 10? I say why not?\n\t\t\t\t\t\t\tmap(e => e.detail.sheet),\n\t\t\t\t\t\t\tdefaultIfEmpty(undefined),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tof(uid).pipe(\n\t\t\t\t\t\t\ttap(() => {\n\t\t\t\t\t\t\t\twindow.dispatchEvent(new CustomEvent(SheetWhereAreYouRicky, { detail: { uid } }))\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\ttap(([sheet]) => {\n\t\t\t\t\tsheet?.closeSheet()\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.subscribe()\n\t}\n\n\tdismiss(uid: string) {\n\t\tthis.$dismiss.next(uid)\n\t}\n\n\topen(target: BottomSheeetTarget) {\n\t\tthis.bottomSheet.next(target)\n\t}\n}\nexport const sheet = new BottomSheetService()\n","import { $LitElement } from '@mixins/index'\nimport { html } from 'lit'\nimport { customElement, property, query, queryAssignedElements } from 'lit/decorators.js'\nimport { fromEvent, merge, takeUntil, tap } from 'rxjs'\nimport { hook } from './hook'\nimport style from './sheet.scss?inline'\nimport {\n\tSchmancySheetPosition,\n\tSheetHereMorty,\n\tSheetWhereAreYouRicky,\n\tSheetWhereAreYouRickyEvent,\n\tsheet,\n} from './sheet.service'\n\n@customElement('schmancy-sheet')\nexport default class SchmancySheet extends $LitElement(style) {\n\t@property({ type: String, reflect: true }) uid!: string\n\t@property({ type: Boolean, reflect: true }) open = false\n\t@property({ type: String, reflect: true }) header: 'hidden' | 'visible' = 'visible'\n\t@property({ type: String, reflect: true }) position: SchmancySheetPosition = SchmancySheetPosition.Side\n\t@property({ type: Boolean, reflect: true }) persist = false\n\t@property({ type: Boolean, reflect: true }) allowOverlayDismiss = true\n\t@property({ type: String, reflect: true }) title = ''\n\n\t@query('.sheet') private sheet!: HTMLElement\n\t@queryAssignedElements({ flatten: true }) private assignedElements!: HTMLElement[]\n\n\t@property() focusAttribute = 'autofocus'\n\tprivate lastFocusedElement: HTMLElement | null = null\n\n\t@hook('open')\n\tonOpenChange(_oldValue: boolean, newValue: boolean) {\n\t\tthis.setIsSheetShown(newValue)\n\n\t\tif (newValue) {\n\t\t\tthis.lastFocusedElement = document.activeElement as HTMLElement\n\t\t\tthis.addFocusTrap()\n\t\t\tthis.focus()\n\t\t} else {\n\t\t\tthis.removeFocusTrap()\n\t\t\tthis.lastFocusedElement?.focus()\n\t\t\tthis.lastFocusedElement = null\n\t\t}\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback()\n\t\tthis.setupEventListeners()\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback()\n\t\tthis.disconnecting.next(true)\n\t}\n\n\tprivate setupEventListeners() {\n\t\t// Handle browser back button\n\t\tconst popState$ = fromEvent<PopStateEvent>(window, 'popstate').pipe(\n\t\t\ttap(e => {\n\t\t\t\te.preventDefault()\n\t\t\t\tthis.closeSheet()\n\t\t\t}),\n\t\t)\n\n\t\t// Handle ESC key\n\t\tconst keyUp$ = fromEvent<KeyboardEvent>(window, 'keyup').pipe(\n\t\t\ttap(event => {\n\t\t\t\tif (event.key === 'Escape' && !this.sheetContainsFocus()) {\n\t\t\t\t\tsheet.dismiss(this.uid)\n\t\t\t\t}\n\t\t\t}),\n\t\t)\n\n\t\t// Handle inter-component communication\n\t\tconst rickyComm$ = fromEvent<SheetWhereAreYouRickyEvent>(window, SheetWhereAreYouRicky).pipe(\n\t\t\ttap(e => {\n\t\t\t\tif (e.detail.uid === this.uid) this.announcePresence()\n\t\t\t}),\n\t\t)\n\n\t\tmerge(popState$, keyUp$, rickyComm$).pipe(takeUntil(this.disconnecting)).subscribe()\n\t}\n\n\tprivate sheetContainsFocus(): boolean {\n\t\treturn this.sheet?.contains(document.activeElement) ?? false\n\t}\n\n\tprivate announcePresence() {\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent(SheetHereMorty, {\n\t\t\t\tdetail: { sheet: this },\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t)\n\t}\n\n\tprivate addFocusTrap() {\n\t\tdocument.addEventListener('focusin', this.handleFocusIn)\n\t}\n\n\tprivate removeFocusTrap() {\n\t\tdocument.removeEventListener('focusin', this.handleFocusIn)\n\t}\n\n\tprivate handleFocusIn = (e: Event) => {\n\t\tif (!this.sheet?.contains(e.target as Node)) {\n\t\t\tthis.focus()\n\t\t}\n\t}\n\n\tsetIsSheetShown(isShown: boolean) {\n\t\tthis.sheet?.setAttribute('aria-hidden', String(!isShown))\n\t\tthis.sheet?.setAttribute('aria-modal', String(isShown))\n\t}\n\n\tcloseSheet() {\n\t\tthis.open = false\n\t\tthis.dispatchEvent(new CustomEvent('close'))\n\t}\n\n\tprivate getFocusElement(): HTMLElement | null {\n\t\tconst selector = `[${this.focusAttribute}]`\n\t\treturn (this.assignedElements.find(el => el.matches(selector) || el.querySelector(selector)) as HTMLElement) ?? null\n\t}\n\n\toverride focus() {\n\t\tthis.getFocusElement()?.focus()\n\t}\n\n\trender() {\n\t\treturn html`\n\t\t\t<div class=\"sheet\" role=\"dialog\" aria-labelledby=\"sheet-title\" aria-hidden=\"true\" aria-modal=\"false\">\n\t\t\t\t<div\n\t\t\t\t\tclass=\"overlay\"\n\t\t\t\t\t@click=${(e: Event) => {\n\t\t\t\t\t\te.stopPropagation()\n\t\t\t\t\t\tif (this.allowOverlayDismiss) sheet.dismiss(this.uid)\n\t\t\t\t\t}}\n\t\t\t\t></div>\n\t\t\t\t<schmancy-sheet-content class=\"content\" data-position=${this.position}>\n\t\t\t\t\t<schmancy-sheet-header\n\t\t\t\t\t\t@dismiss=${(e: CustomEvent) => {\n\t\t\t\t\t\t\te.stopPropagation()\n\t\t\t\t\t\t\tsheet.dismiss(this.uid)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tid=\"sheet-title\"\n\t\t\t\t\t\t.hidden=${this.header === 'hidden'}\n\t\t\t\t\t\ttitle=${this.title}\n\t\t\t\t\t></schmancy-sheet-header>\n\t\t\t\t\t<slot></slot>\n\t\t\t\t</schmancy-sheet-content>\n\t\t\t</div>\n\t\t`\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'schmancy-sheet': SchmancySheet\n\t}\n}\n"],"names":["SchmancySheetHeader","TailwindElement","css","classes","absolute","this","title","length","relative","html","classMap","dispatchEvent","CustomEvent","bubbles","composed","hook","propName","options","protoOrDescriptor","name","willUpdate","Object","assign","waitUntilFirstUpdate","changedProps","call","has","oldValue","get","newValue","hasUpdated","__decorateClass","property","prototype","customElement","SchmancySheetContent","render","SchmancySheetPosition","SheetWhereAreYouRicky","SheetHereMorty","sheet","bottomSheet","Subject","$dismiss","pipe","switchMap","forkJoin","fromEvent","window","takeUntil","timer","map","e","detail","defaultIfEmpty","of","target","tap","uid","component","tagName","document","createElement","body","appendChild","setAttribute","position","allowOverlyDismiss","persist","header","style","overflow","delay","filter","shadowRoot","querySelector","assignedElements","find","take","subscribe","remove","mergeMap","closeSheet","next","SchmancySheet","$LitElement","constructor","super","arguments","open","Side","allowOverlayDismiss","focusAttribute","lastFocusedElement","handleFocusIn","contains","focus","_oldValue","setIsSheetShown","activeElement","addFocusTrap","removeFocusTrap","connectedCallback","setupEventListeners","disconnectedCallback","disconnecting","popState$","preventDefault","keyUp$","event","key","sheetContainsFocus","dismiss","rickyComm$","announcePresence","merge","addEventListener","removeEventListener","isShown","String","selector","el","matches","getFocusElement","stopPropagation","type","reflect","Boolean","query","queryAssignedElements","flatten"],"mappings":";;;;;;;;;;;AAKA,IAAqBA,IAArB,cAAiDC,EAAgBC;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,CAQhE,EAAA;AAAA,EAAA,SACC;AAAA,UAAMC,IAAU,EACfC,UAAUC,KAAKC,MAAMC,WAAW,GAChCC,UAAUH,KAAKC,MAAMC,SAAS,EAAA;AAExB,WAAAE;AAAAA,2BACkBJ,KAAKK,SAASP,CAAAA,CAAAA;AAAAA;AAAAA;AAAAA,eAG1B,MACHE;AAAAA,WAAAM,cACJ,IAAIC,YAAY,WAAW,EAC1BC,SAAAA,IACAC,UAAAA,GAEF,CAAA,CAAA;AAAA,IAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8EAMuET,KAAKC,KAAAA;AAAAA;AAAAA;AAAAA,eAGpE,MACHD;AAAAA,WAAAM,cACJ,IAAIC,YAAY,WAAW,EAC1BC,SAAAA,IACAC,UAAAA,GAEF,CAAA,CAAA;AAAA,IAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EACA;AAAA;AC1BS,SAAAC,EAAKC,GAAkBC,GAC9B;AAAA,SAAA,CAACC,GAAwBC,MAAAA;AACxB,UAAAC,EAAAA,YAAEA,MAAeF;AAEvBD,QAAUI,OAAOC,OAAO,EAAEC,yBAA+BN,GAAAA,CAAAA,GAEvCC,EAAAE,aAAa,SAAUI,GAGnC;AAAA,UAFOJ,EAAAK,KAAKpB,MAAMmB,IAElBA,EAAaE,IAAIV,CAAW,GAAA;AAC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