@erplora/outfitkit 0.1.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/LICENSE +21 -0
- package/README.md +457 -0
- package/dist/base/anchor.d.ts +13 -0
- package/dist/base/define.d.ts +1 -0
- package/dist/base/relay.d.ts +1 -0
- package/dist/cdn.d.ts +96 -0
- package/dist/components/ok-app-launcher/ok-app-launcher.d.ts +57 -0
- package/dist/components/ok-audio/ok-audio.d.ts +45 -0
- package/dist/components/ok-avatar/ok-avatar.d.ts +36 -0
- package/dist/components/ok-avatar-group/ok-avatar-group.d.ts +38 -0
- package/dist/components/ok-bar-list/ok-bar-list.d.ts +36 -0
- package/dist/components/ok-bento/ok-bento.d.ts +17 -0
- package/dist/components/ok-bento-item/ok-bento-item.d.ts +34 -0
- package/dist/components/ok-calculator/ok-calculator.d.ts +46 -0
- package/dist/components/ok-calendar/ok-calendar.d.ts +63 -0
- package/dist/components/ok-carousel/ok-carousel.d.ts +48 -0
- package/dist/components/ok-chart/ok-chart.d.ts +55 -0
- package/dist/components/ok-chat/ok-chat.d.ts +54 -0
- package/dist/components/ok-coachmark/ok-coachmark.d.ts +69 -0
- package/dist/components/ok-code/ok-code.d.ts +28 -0
- package/dist/components/ok-color-picker/ok-color-picker.d.ts +63 -0
- package/dist/components/ok-combo/ok-combo.d.ts +46 -0
- package/dist/components/ok-command-palette/ok-command-palette.d.ts +72 -0
- package/dist/components/ok-contact-form/ok-contact-form.d.ts +54 -0
- package/dist/components/ok-cropper/ok-cropper.d.ts +60 -0
- package/dist/components/ok-cta-band/ok-cta-band.d.ts +18 -0
- package/dist/components/ok-currency/ok-currency.d.ts +31 -0
- package/dist/components/ok-data-table/ok-data-table.d.ts +312 -0
- package/dist/components/ok-date-picker/ok-date-picker.d.ts +81 -0
- package/dist/components/ok-detail-list/ok-detail-list.d.ts +30 -0
- package/dist/components/ok-diff/ok-diff.d.ts +38 -0
- package/dist/components/ok-donut/ok-donut.d.ts +38 -0
- package/dist/components/ok-drawer/ok-drawer.d.ts +56 -0
- package/dist/components/ok-dropzone/ok-dropzone.d.ts +48 -0
- package/dist/components/ok-empty-state/ok-empty-state.d.ts +16 -0
- package/dist/components/ok-error-page/ok-error-page.d.ts +77 -0
- package/dist/components/ok-event-card/ok-event-card.d.ts +56 -0
- package/dist/components/ok-feature-card/ok-feature-card.d.ts +23 -0
- package/dist/components/ok-file-item/ok-file-item.d.ts +31 -0
- package/dist/components/ok-file-manager/ok-file-manager.d.ts +145 -0
- package/dist/components/ok-footer/ok-footer.d.ts +10 -0
- package/dist/components/ok-funnel/ok-funnel.d.ts +31 -0
- package/dist/components/ok-gallery/ok-gallery.d.ts +34 -0
- package/dist/components/ok-gauge/ok-gauge.d.ts +49 -0
- package/dist/components/ok-heatmap/ok-heatmap.d.ts +45 -0
- package/dist/components/ok-hero/ok-hero.d.ts +10 -0
- package/dist/components/ok-hover-card/ok-hover-card.d.ts +76 -0
- package/dist/components/ok-icon-tile/ok-icon-tile.d.ts +24 -0
- package/dist/components/ok-image/ok-image.d.ts +56 -0
- package/dist/components/ok-inline-feedback/ok-inline-feedback.d.ts +33 -0
- package/dist/components/ok-invoice/ok-invoice.d.ts +137 -0
- package/dist/components/ok-json-viewer/ok-json-viewer.d.ts +31 -0
- package/dist/components/ok-kanban/ok-kanban.d.ts +56 -0
- package/dist/components/ok-kbd/ok-kbd.d.ts +21 -0
- package/dist/components/ok-keyboard/ok-keyboard.d.ts +35 -0
- package/dist/components/ok-kpi/ok-kpi.d.ts +24 -0
- package/dist/components/ok-language-select/ok-language-select.d.ts +31 -0
- package/dist/components/ok-lightbox/ok-lightbox.d.ts +59 -0
- package/dist/components/ok-logo-cloud/ok-logo-cloud.d.ts +14 -0
- package/dist/components/ok-loyalty-card/ok-loyalty-card.d.ts +35 -0
- package/dist/components/ok-mail/ok-mail.d.ts +117 -0
- package/dist/components/ok-menu/ok-menu.d.ts +75 -0
- package/dist/components/ok-menubar/ok-menubar.d.ts +75 -0
- package/dist/components/ok-navbar/ok-navbar.d.ts +42 -0
- package/dist/components/ok-notification-center/ok-notification-center.d.ts +79 -0
- package/dist/components/ok-org-chart/ok-org-chart.d.ts +67 -0
- package/dist/components/ok-otp/ok-otp.d.ts +31 -0
- package/dist/components/ok-page-header/ok-page-header.d.ts +23 -0
- package/dist/components/ok-pagination/ok-pagination.d.ts +44 -0
- package/dist/components/ok-pdf/ok-pdf.d.ts +32 -0
- package/dist/components/ok-phone/ok-phone.d.ts +48 -0
- package/dist/components/ok-pinpad/ok-pinpad.d.ts +29 -0
- package/dist/components/ok-pricing-card/ok-pricing-card.d.ts +31 -0
- package/dist/components/ok-product-card/ok-product-card.d.ts +25 -0
- package/dist/components/ok-qr/ok-qr.d.ts +24 -0
- package/dist/components/ok-qty-stepper/ok-qty-stepper.d.ts +35 -0
- package/dist/components/ok-range-dual/ok-range-dual.d.ts +38 -0
- package/dist/components/ok-rating/ok-rating.d.ts +33 -0
- package/dist/components/ok-receipt/ok-receipt.d.ts +103 -0
- package/dist/components/ok-reveal/ok-reveal.d.ts +21 -0
- package/dist/components/ok-rich-text/ok-rich-text.d.ts +46 -0
- package/dist/components/ok-scheduler/ok-scheduler.d.ts +74 -0
- package/dist/components/ok-select-card/ok-select-card.d.ts +37 -0
- package/dist/components/ok-signature/ok-signature.d.ts +55 -0
- package/dist/components/ok-skeleton/ok-skeleton.d.ts +40 -0
- package/dist/components/ok-sparkline/ok-sparkline.d.ts +27 -0
- package/dist/components/ok-split-button/ok-split-button.d.ts +49 -0
- package/dist/components/ok-splitter/ok-splitter.d.ts +36 -0
- package/dist/components/ok-stat/ok-stat.d.ts +16 -0
- package/dist/components/ok-status-dot/ok-status-dot.d.ts +24 -0
- package/dist/components/ok-status-pill/ok-status-pill.d.ts +22 -0
- package/dist/components/ok-stepper/ok-stepper.d.ts +33 -0
- package/dist/components/ok-store/ok-store.d.ts +33 -0
- package/dist/components/ok-tag-input/ok-tag-input.d.ts +39 -0
- package/dist/components/ok-testimonial/ok-testimonial.d.ts +21 -0
- package/dist/components/ok-time-picker/ok-time-picker.d.ts +50 -0
- package/dist/components/ok-timeline/ok-timeline.d.ts +33 -0
- package/dist/components/ok-tree/ok-tree.d.ts +46 -0
- package/dist/components/ok-video/ok-video.d.ts +49 -0
- package/dist/components/ok-widget-board/ok-widget-board.d.ts +71 -0
- package/dist/components/ok-wizard/ok-wizard.d.ts +30 -0
- package/dist/define.js +8 -0
- package/dist/erplora.css +112 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +197 -0
- package/dist/layout.css +338 -0
- package/dist/ok-app-launcher.js +396 -0
- package/dist/ok-audio.js +308 -0
- package/dist/ok-avatar-group.js +158 -0
- package/dist/ok-avatar.js +179 -0
- package/dist/ok-bar-list.js +189 -0
- package/dist/ok-bento-item.js +168 -0
- package/dist/ok-bento.js +63 -0
- package/dist/ok-calculator.js +406 -0
- package/dist/ok-calendar.js +541 -0
- package/dist/ok-carousel.js +352 -0
- package/dist/ok-chart.js +325 -0
- package/dist/ok-chat.js +320 -0
- package/dist/ok-coachmark.js +500 -0
- package/dist/ok-code.js +190 -0
- package/dist/ok-color-picker.js +569 -0
- package/dist/ok-combo.js +294 -0
- package/dist/ok-command-palette.js +448 -0
- package/dist/ok-contact-form.js +288 -0
- package/dist/ok-cropper.js +404 -0
- package/dist/ok-cta-band.js +134 -0
- package/dist/ok-currency.js +172 -0
- package/dist/ok-data-table.js +1281 -0
- package/dist/ok-date-picker.js +736 -0
- package/dist/ok-detail-list.js +156 -0
- package/dist/ok-diff.js +200 -0
- package/dist/ok-donut.js +280 -0
- package/dist/ok-drawer.js +357 -0
- package/dist/ok-dropzone.js +376 -0
- package/dist/ok-empty-state.js +104 -0
- package/dist/ok-error-page.js +547 -0
- package/dist/ok-event-card.js +384 -0
- package/dist/ok-feature-card.js +152 -0
- package/dist/ok-file-item.js +259 -0
- package/dist/ok-file-manager.js +1116 -0
- package/dist/ok-footer.js +67 -0
- package/dist/ok-funnel.js +181 -0
- package/dist/ok-gallery.js +293 -0
- package/dist/ok-gauge.js +385 -0
- package/dist/ok-heatmap.js +268 -0
- package/dist/ok-hero.js +43 -0
- package/dist/ok-hover-card.js +480 -0
- package/dist/ok-icon-tile.js +123 -0
- package/dist/ok-image.js +471 -0
- package/dist/ok-inline-feedback.js +221 -0
- package/dist/ok-invoice.js +229 -0
- package/dist/ok-json-viewer.js +330 -0
- package/dist/ok-kanban.js +427 -0
- package/dist/ok-kbd.js +159 -0
- package/dist/ok-keyboard.js +402 -0
- package/dist/ok-kpi.js +147 -0
- package/dist/ok-language-select.js +188 -0
- package/dist/ok-lightbox.js +490 -0
- package/dist/ok-logo-cloud.js +92 -0
- package/dist/ok-loyalty-card.js +353 -0
- package/dist/ok-mail.js +562 -0
- package/dist/ok-menu.js +529 -0
- package/dist/ok-menubar.js +628 -0
- package/dist/ok-navbar.js +306 -0
- package/dist/ok-notification-center.js +545 -0
- package/dist/ok-org-chart.js +619 -0
- package/dist/ok-otp.js +199 -0
- package/dist/ok-page-header.js +202 -0
- package/dist/ok-pagination.js +366 -0
- package/dist/ok-pdf.js +160 -0
- package/dist/ok-phone.js +225 -0
- package/dist/ok-pinpad.js +171 -0
- package/dist/ok-pricing-card.js +184 -0
- package/dist/ok-product-card.js +178 -0
- package/dist/ok-qr.js +652 -0
- package/dist/ok-qty-stepper.js +212 -0
- package/dist/ok-range-dual.js +280 -0
- package/dist/ok-rating.js +199 -0
- package/dist/ok-receipt.js +183 -0
- package/dist/ok-reveal.js +94 -0
- package/dist/ok-rich-text.js +538 -0
- package/dist/ok-scheduler.js +518 -0
- package/dist/ok-select-card.js +231 -0
- package/dist/ok-signature.js +267 -0
- package/dist/ok-skeleton.js +345 -0
- package/dist/ok-sparkline.js +150 -0
- package/dist/ok-split-button.js +251 -0
- package/dist/ok-splitter.js +289 -0
- package/dist/ok-stat.js +77 -0
- package/dist/ok-status-dot.js +163 -0
- package/dist/ok-status-pill.js +123 -0
- package/dist/ok-stepper.js +299 -0
- package/dist/ok-store.js +83 -0
- package/dist/ok-tag-input.js +358 -0
- package/dist/ok-testimonial.js +136 -0
- package/dist/ok-time-picker.js +472 -0
- package/dist/ok-timeline.js +251 -0
- package/dist/ok-tree.js +266 -0
- package/dist/ok-video.js +362 -0
- package/dist/ok-widget-board.js +265 -0
- package/dist/ok-wizard.js +153 -0
- package/dist/outfitkit.js +96 -0
- package/dist/shared/anchor.js +14 -0
- package/dist/store/controller.d.ts +17 -0
- package/dist/store/idb.d.ts +16 -0
- package/dist/store/store.d.ts +39 -0
- package/dist/store-controller.js +31 -0
- package/dist/store.js +182 -0
- package/dist/theme.example.css +70 -0
- package/package.json +147 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { define } from "./define.js";
|
|
4
|
+
import "./ok-qr.js";
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = void 0;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = decorator(target, key, result) || result;
|
|
11
|
+
if (result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_LABELS = {
|
|
15
|
+
empty: "No receipt data.",
|
|
16
|
+
phone: "Tel.",
|
|
17
|
+
receipt: "Receipt",
|
|
18
|
+
servedBy: "Served by",
|
|
19
|
+
customer: "Customer",
|
|
20
|
+
item: "Item",
|
|
21
|
+
amount: "Amount",
|
|
22
|
+
noLines: "— No lines —",
|
|
23
|
+
subtotal: "Subtotal",
|
|
24
|
+
total: "TOTAL",
|
|
25
|
+
change: "Change"
|
|
26
|
+
};
|
|
27
|
+
class OkReceipt extends LitElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.qrSize = 120;
|
|
31
|
+
this.labels = {};
|
|
32
|
+
}
|
|
33
|
+
static {
|
|
34
|
+
this.styles = css`
|
|
35
|
+
:host {
|
|
36
|
+
/* Ancho de papel térmico estándar (80mm). Overridable vía --receipt-width. */
|
|
37
|
+
--w: var(--receipt-width, 80mm);
|
|
38
|
+
display: block;
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
.paper {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
width: var(--w);
|
|
44
|
+
max-width: 100%;
|
|
45
|
+
margin: 0 auto;
|
|
46
|
+
padding: 4mm 3mm;
|
|
47
|
+
background: #fff;
|
|
48
|
+
color: #000;
|
|
49
|
+
/* Monospace = look de tiquet; tabular para alinear importes. */
|
|
50
|
+
font-family: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
|
|
51
|
+
font-size: 11px;
|
|
52
|
+
line-height: 1.45;
|
|
53
|
+
font-variant-numeric: tabular-nums;
|
|
54
|
+
}
|
|
55
|
+
.center { text-align: center; }
|
|
56
|
+
.biz-logo { max-width: 60%; max-height: 22mm; margin: 0 auto 2mm; display: block; }
|
|
57
|
+
.biz-name { font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
|
|
58
|
+
.biz-meta { font-size: 10px; }
|
|
59
|
+
.sep { border: none; border-top: 1px dashed #000; margin: 2mm 0; }
|
|
60
|
+
.meta {
|
|
61
|
+
display: flex; justify-content: space-between; gap: .5rem;
|
|
62
|
+
font-size: 10px;
|
|
63
|
+
}
|
|
64
|
+
table { width: 100%; border-collapse: collapse; }
|
|
65
|
+
th, td { padding: .3mm 0; vertical-align: top; }
|
|
66
|
+
thead th { font-size: 9px; text-transform: uppercase; text-align: left; border-bottom: 1px solid #000; }
|
|
67
|
+
th.num, td.num { text-align: right; white-space: nowrap; }
|
|
68
|
+
.line-name { word-break: break-word; }
|
|
69
|
+
.line-note { font-size: 9px; padding-left: 2mm; opacity: .8; }
|
|
70
|
+
.qty-price { font-size: 9px; opacity: .85; }
|
|
71
|
+
.totals { width: 100%; }
|
|
72
|
+
.totals td { padding: .2mm 0; }
|
|
73
|
+
.totals td.num { text-align: right; white-space: nowrap; }
|
|
74
|
+
.grand td { font-size: 14px; font-weight: 700; padding-top: 1mm; }
|
|
75
|
+
.pay td { font-size: 10px; }
|
|
76
|
+
.footer { font-size: 10px; white-space: pre-line; }
|
|
77
|
+
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 1mm; margin-top: 2mm; }
|
|
78
|
+
.qr-note { font-size: 8px; text-align: center; word-break: break-word; }
|
|
79
|
+
.empty { padding: 4mm; text-align: center; color: #888; font-style: italic; }
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
get t() {
|
|
83
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
84
|
+
}
|
|
85
|
+
cur() {
|
|
86
|
+
return this.receipt?.currency ?? "€";
|
|
87
|
+
}
|
|
88
|
+
money(n) {
|
|
89
|
+
return `${Number(n ?? 0).toFixed(2)} ${this.cur()}`;
|
|
90
|
+
}
|
|
91
|
+
render() {
|
|
92
|
+
const r = this.receipt;
|
|
93
|
+
if (!r) return html`<div class="paper empty">${this.t.empty}</div>`;
|
|
94
|
+
return html`<div class="paper" part="paper">
|
|
95
|
+
${this.renderHeader(r)}
|
|
96
|
+
<hr class="sep" />
|
|
97
|
+
${this.renderMeta(r)}
|
|
98
|
+
<hr class="sep" />
|
|
99
|
+
${this.renderLines(r)}
|
|
100
|
+
<hr class="sep" />
|
|
101
|
+
${this.renderTotals(r)}
|
|
102
|
+
${r.footer ? html`<hr class="sep" /><div class="center footer">${r.footer}</div>` : nothing}
|
|
103
|
+
${this.renderQr(r)}
|
|
104
|
+
</div>`;
|
|
105
|
+
}
|
|
106
|
+
renderHeader(r) {
|
|
107
|
+
const b = r.business ?? { name: "" };
|
|
108
|
+
return html`<div class="center">
|
|
109
|
+
${b.logo_url ? html`<img class="biz-logo" src=${b.logo_url} alt=${b.name || "logo"} />` : html`<slot name="logo"></slot>`}
|
|
110
|
+
<div class="biz-name">${b.name}</div>
|
|
111
|
+
${b.address ? html`<div class="biz-meta">${b.address}</div>` : nothing}
|
|
112
|
+
${b.tax_id ? html`<div class="biz-meta">${b.tax_id}</div>` : nothing}
|
|
113
|
+
${b.phone ? html`<div class="biz-meta">${this.t.phone} ${b.phone}</div>` : nothing}
|
|
114
|
+
</div>`;
|
|
115
|
+
}
|
|
116
|
+
renderMeta(r) {
|
|
117
|
+
return html`<div class="meta">
|
|
118
|
+
<span>${this.t.receipt}: <strong>${r.number}</strong></span>
|
|
119
|
+
${r.datetime ? html`<span>${r.datetime}</span>` : nothing}
|
|
120
|
+
</div>
|
|
121
|
+
${r.cashier || r.customer ? html`<div class="meta">
|
|
122
|
+
${r.cashier ? html`<span>${this.t.servedBy}: ${r.cashier}</span>` : html`<span></span>`}
|
|
123
|
+
${r.customer ? html`<span>${this.t.customer}: ${r.customer}</span>` : nothing}
|
|
124
|
+
</div>` : nothing}`;
|
|
125
|
+
}
|
|
126
|
+
renderLines(r) {
|
|
127
|
+
const lines = r.lines ?? [];
|
|
128
|
+
if (!lines.length) return html`<div class="center biz-meta">${this.t.noLines}</div>`;
|
|
129
|
+
return html`<table>
|
|
130
|
+
<thead>
|
|
131
|
+
<tr><th>${this.t.item}</th><th class="num">${this.t.amount}</th></tr>
|
|
132
|
+
</thead>
|
|
133
|
+
<tbody>
|
|
134
|
+
${lines.map(
|
|
135
|
+
(l) => html`<tr>
|
|
136
|
+
<td class="line-name">
|
|
137
|
+
<div>${l.name}</div>
|
|
138
|
+
<div class="qty-price">${l.qty} × ${this.money(l.unit_price)}</div>
|
|
139
|
+
${l.note ? html`<div class="line-note">${l.note}</div>` : nothing}
|
|
140
|
+
</td>
|
|
141
|
+
<td class="num">${this.money(l.total)}</td>
|
|
142
|
+
</tr>`
|
|
143
|
+
)}
|
|
144
|
+
</tbody>
|
|
145
|
+
</table>`;
|
|
146
|
+
}
|
|
147
|
+
renderTotals(r) {
|
|
148
|
+
const taxes = r.taxes ?? [];
|
|
149
|
+
return html`<table class="totals">
|
|
150
|
+
${r.subtotal != null ? html`<tr><td>${this.t.subtotal}</td><td class="num">${this.money(r.subtotal)}</td></tr>` : nothing}
|
|
151
|
+
${taxes.map(
|
|
152
|
+
(t) => html`<tr><td>${t.label}</td><td class="num">${this.money(t.amount)}</td></tr>`
|
|
153
|
+
)}
|
|
154
|
+
<tr class="grand"><td>${this.t.total}</td><td class="num">${this.money(r.total)}</td></tr>
|
|
155
|
+
${r.payment ? html`<tr class="pay"><td>${r.payment.method}</td><td class="num">${this.money(
|
|
156
|
+
r.payment.paid ?? r.total
|
|
157
|
+
)}</td></tr>
|
|
158
|
+
${r.payment.change != null ? html`<tr class="pay"><td>${this.t.change}</td><td class="num">${this.money(
|
|
159
|
+
r.payment.change
|
|
160
|
+
)}</td></tr>` : nothing}` : nothing}
|
|
161
|
+
</table>`;
|
|
162
|
+
}
|
|
163
|
+
renderQr(r) {
|
|
164
|
+
if (!r.qr) return nothing;
|
|
165
|
+
return html`<div class="qr-wrap">
|
|
166
|
+
<ok-qr .value=${r.qr} .size=${this.qrSize} ec="M" color="#000" background="#fff"></ok-qr>
|
|
167
|
+
${r.qr_note ? html`<div class="qr-note">${r.qr_note}</div>` : nothing}
|
|
168
|
+
</div>`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
__decorateClass([
|
|
172
|
+
property({ attribute: false })
|
|
173
|
+
], OkReceipt.prototype, "receipt");
|
|
174
|
+
__decorateClass([
|
|
175
|
+
property({ type: Number, attribute: "qr-size" })
|
|
176
|
+
], OkReceipt.prototype, "qrSize");
|
|
177
|
+
__decorateClass([
|
|
178
|
+
property({ attribute: false })
|
|
179
|
+
], OkReceipt.prototype, "labels");
|
|
180
|
+
define("ok-receipt", OkReceipt);
|
|
181
|
+
export {
|
|
182
|
+
OkReceipt
|
|
183
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property } from "lit/decorators.js";
|
|
3
|
+
import { define } from "./define.js";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
6
|
+
var result = void 0;
|
|
7
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
8
|
+
if (decorator = decorators[i])
|
|
9
|
+
result = decorator(target, key, result) || result;
|
|
10
|
+
if (result) __defProp(target, key, result);
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
class OkReveal extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.variant = "up";
|
|
17
|
+
this.delay = 0;
|
|
18
|
+
this.once = true;
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
this.styles = css`
|
|
22
|
+
:host {
|
|
23
|
+
display: block;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
.r {
|
|
27
|
+
height: 100%;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
transform: translateY(18px);
|
|
30
|
+
transition:
|
|
31
|
+
opacity var(--ok-reveal-duration, 0.65s) cubic-bezier(0.22, 0.7, 0.2, 1) var(--ok-reveal-delay, 0ms),
|
|
32
|
+
transform var(--ok-reveal-duration, 0.65s) cubic-bezier(0.22, 0.7, 0.2, 1) var(--ok-reveal-delay, 0ms);
|
|
33
|
+
will-change: opacity, transform;
|
|
34
|
+
}
|
|
35
|
+
:host([variant='fade']) .r { transform: none; }
|
|
36
|
+
:host([variant='scale']) .r { transform: scale(0.95); }
|
|
37
|
+
:host([variant='left']) .r { transform: translateX(-28px); }
|
|
38
|
+
:host([variant='right']) .r { transform: translateX(28px); }
|
|
39
|
+
:host(.ok-in) .r {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
transform: none;
|
|
42
|
+
}
|
|
43
|
+
@media (prefers-reduced-motion: reduce) {
|
|
44
|
+
.r {
|
|
45
|
+
opacity: 1 !important;
|
|
46
|
+
transform: none !important;
|
|
47
|
+
transition: none !important;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
super.connectedCallback();
|
|
54
|
+
this.style.setProperty("--ok-reveal-delay", `${this.delay}ms`);
|
|
55
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
56
|
+
this.classList.add("ok-in");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._io = new IntersectionObserver(
|
|
60
|
+
(entries) => {
|
|
61
|
+
for (const e of entries) {
|
|
62
|
+
if (e.isIntersecting) {
|
|
63
|
+
this.classList.add("ok-in");
|
|
64
|
+
if (this.once) this._io?.disconnect();
|
|
65
|
+
} else if (!this.once) {
|
|
66
|
+
this.classList.remove("ok-in");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{ threshold: 0.12, rootMargin: "0px 0px -8% 0px" }
|
|
71
|
+
);
|
|
72
|
+
this._io.observe(this);
|
|
73
|
+
}
|
|
74
|
+
disconnectedCallback() {
|
|
75
|
+
super.disconnectedCallback();
|
|
76
|
+
this._io?.disconnect();
|
|
77
|
+
}
|
|
78
|
+
render() {
|
|
79
|
+
return html`<div class="r"><slot></slot></div>`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
__decorateClass([
|
|
83
|
+
property({ reflect: true })
|
|
84
|
+
], OkReveal.prototype, "variant");
|
|
85
|
+
__decorateClass([
|
|
86
|
+
property({ type: Number })
|
|
87
|
+
], OkReveal.prototype, "delay");
|
|
88
|
+
__decorateClass([
|
|
89
|
+
property({ type: Boolean })
|
|
90
|
+
], OkReveal.prototype, "once");
|
|
91
|
+
define("ok-reveal", OkReveal);
|
|
92
|
+
export {
|
|
93
|
+
OkReveal
|
|
94
|
+
};
|