@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,188 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property, state } 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
|
+
const DEFAULT_LABELS = {
|
|
14
|
+
language: "Language"
|
|
15
|
+
};
|
|
16
|
+
class OkLanguageSelect extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.value = "";
|
|
20
|
+
this.open = false;
|
|
21
|
+
this.labels = {};
|
|
22
|
+
this.currentLabel = "";
|
|
23
|
+
this.toggle = (e) => {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
this.open = !this.open;
|
|
26
|
+
};
|
|
27
|
+
this.onDocClick = (e) => {
|
|
28
|
+
if (this.open && !e.composedPath().includes(this)) this.open = false;
|
|
29
|
+
};
|
|
30
|
+
this.onKeydown = (e) => {
|
|
31
|
+
if (e.key === "Escape" && this.open) this.open = false;
|
|
32
|
+
};
|
|
33
|
+
this.onPanelClick = (e) => {
|
|
34
|
+
if (e.target?.closest("a")) this.open = false;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
static {
|
|
38
|
+
this.styles = css`
|
|
39
|
+
:host {
|
|
40
|
+
display: inline-block;
|
|
41
|
+
position: relative;
|
|
42
|
+
--color: var(--ok-text, var(--ion-text-color, #18181b));
|
|
43
|
+
--muted: var(--ok-muted, rgba(var(--ion-text-color-rgb, 24, 24, 27), 0.6));
|
|
44
|
+
--surface: var(--ok-surface, var(--ion-card-background, var(--ion-background-color, #fff)));
|
|
45
|
+
--border: var(--ok-border, rgba(var(--ion-text-color-rgb, 24, 24, 27), 0.14));
|
|
46
|
+
--primary: var(--ok-primary, var(--ion-color-primary, #1496d6));
|
|
47
|
+
--radius: var(--ok-radius, 12px);
|
|
48
|
+
font-family: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
49
|
+
}
|
|
50
|
+
.trigger {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 0.4rem;
|
|
54
|
+
padding: 0.4rem 0.6rem;
|
|
55
|
+
border: 1px solid var(--border);
|
|
56
|
+
border-radius: 999px;
|
|
57
|
+
background: transparent;
|
|
58
|
+
color: var(--color);
|
|
59
|
+
font: inherit;
|
|
60
|
+
font-size: 0.85rem;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
transition: background-color var(--ok-transition, 150ms ease), border-color var(--ok-transition, 150ms ease);
|
|
63
|
+
}
|
|
64
|
+
@media (hover: hover) {
|
|
65
|
+
.trigger:hover { border-color: color-mix(in oklab, var(--primary) 45%, var(--border)); }
|
|
66
|
+
}
|
|
67
|
+
.globe, .chev { width: 1rem; height: 1rem; flex: none; }
|
|
68
|
+
.cur { font-weight: 600; }
|
|
69
|
+
.chev { transition: transform var(--ok-transition, 180ms ease); color: var(--muted); }
|
|
70
|
+
:host([open]) .chev { transform: rotate(180deg); }
|
|
71
|
+
|
|
72
|
+
.panel {
|
|
73
|
+
position: absolute;
|
|
74
|
+
top: calc(100% + 0.4rem);
|
|
75
|
+
right: 0;
|
|
76
|
+
min-width: 11rem;
|
|
77
|
+
background: var(--surface);
|
|
78
|
+
border: 1px solid var(--border);
|
|
79
|
+
border-radius: var(--radius);
|
|
80
|
+
box-shadow: 0 18px 44px -18px rgba(0, 0, 0, 0.28);
|
|
81
|
+
padding: 0.35rem;
|
|
82
|
+
z-index: 60;
|
|
83
|
+
opacity: 0;
|
|
84
|
+
transform: translateY(-6px);
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
transition: opacity var(--ok-transition, 160ms ease), transform var(--ok-transition, 160ms ease);
|
|
87
|
+
}
|
|
88
|
+
:host([open]) .panel { opacity: 1; transform: none; pointer-events: auto; }
|
|
89
|
+
@media (prefers-reduced-motion: reduce) {
|
|
90
|
+
.panel, .chev { transition: none; }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Los <a> de idioma (light DOM) se estilan como ítems de menú. */
|
|
94
|
+
::slotted(a) {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: 0.5rem;
|
|
98
|
+
padding: 0.55rem 0.7rem;
|
|
99
|
+
border-radius: 8px;
|
|
100
|
+
color: var(--color);
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
font-size: 0.9rem;
|
|
103
|
+
transition: background-color var(--ok-transition, 120ms ease);
|
|
104
|
+
}
|
|
105
|
+
@media (hover: hover) {
|
|
106
|
+
::slotted(a:hover) { background: color-mix(in oklab, var(--primary) 12%, transparent); }
|
|
107
|
+
}
|
|
108
|
+
::slotted(a.ok-lang-current) {
|
|
109
|
+
color: var(--primary);
|
|
110
|
+
font-weight: 600;
|
|
111
|
+
background: color-mix(in oklab, var(--primary) 10%, transparent);
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
115
|
+
get t() {
|
|
116
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
117
|
+
}
|
|
118
|
+
connectedCallback() {
|
|
119
|
+
super.connectedCallback();
|
|
120
|
+
document.addEventListener("click", this.onDocClick);
|
|
121
|
+
document.addEventListener("keydown", this.onKeydown);
|
|
122
|
+
}
|
|
123
|
+
disconnectedCallback() {
|
|
124
|
+
super.disconnectedCallback();
|
|
125
|
+
document.removeEventListener("click", this.onDocClick);
|
|
126
|
+
document.removeEventListener("keydown", this.onKeydown);
|
|
127
|
+
}
|
|
128
|
+
firstUpdated() {
|
|
129
|
+
this.resolveCurrent();
|
|
130
|
+
}
|
|
131
|
+
/** Decide el idioma activo: value → navegador → primero; marca el <a> y guarda su etiqueta. */
|
|
132
|
+
resolveCurrent() {
|
|
133
|
+
const anchors = [...this.querySelectorAll("a[data-lang]")];
|
|
134
|
+
if (!anchors.length) return;
|
|
135
|
+
let code = this.value;
|
|
136
|
+
if (!code) {
|
|
137
|
+
const nav = (navigator.language || "").slice(0, 2).toLowerCase();
|
|
138
|
+
if (anchors.some((a) => a.dataset.lang === nav)) code = nav;
|
|
139
|
+
}
|
|
140
|
+
if (!code) code = anchors[0].dataset.lang ?? "";
|
|
141
|
+
for (const a of anchors) {
|
|
142
|
+
const isCur = a.dataset.lang === code;
|
|
143
|
+
a.classList.toggle("ok-lang-current", isCur);
|
|
144
|
+
if (isCur) this.currentLabel = (a.textContent || code).trim();
|
|
145
|
+
}
|
|
146
|
+
if (!this.currentLabel) this.currentLabel = code.toUpperCase();
|
|
147
|
+
}
|
|
148
|
+
render() {
|
|
149
|
+
return html`
|
|
150
|
+
<button
|
|
151
|
+
class="trigger"
|
|
152
|
+
type="button"
|
|
153
|
+
aria-label=${this.t.language}
|
|
154
|
+
aria-haspopup="listbox"
|
|
155
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
156
|
+
@click=${this.toggle}
|
|
157
|
+
>
|
|
158
|
+
<svg class="globe" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
159
|
+
<circle cx="12" cy="12" r="10" /><path d="M2 12h20" />
|
|
160
|
+
<path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
|
|
161
|
+
</svg>
|
|
162
|
+
<span class="cur">${this.currentLabel || this.value.toUpperCase()}</span>
|
|
163
|
+
<svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
164
|
+
<path d="m6 9 6 6 6-6" />
|
|
165
|
+
</svg>
|
|
166
|
+
</button>
|
|
167
|
+
<div class="panel" role="listbox" @click=${this.onPanelClick}>
|
|
168
|
+
<slot @slotchange=${() => this.resolveCurrent()}></slot>
|
|
169
|
+
</div>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
__decorateClass([
|
|
174
|
+
property()
|
|
175
|
+
], OkLanguageSelect.prototype, "value");
|
|
176
|
+
__decorateClass([
|
|
177
|
+
property({ type: Boolean, reflect: true })
|
|
178
|
+
], OkLanguageSelect.prototype, "open");
|
|
179
|
+
__decorateClass([
|
|
180
|
+
property({ attribute: false })
|
|
181
|
+
], OkLanguageSelect.prototype, "labels");
|
|
182
|
+
__decorateClass([
|
|
183
|
+
state()
|
|
184
|
+
], OkLanguageSelect.prototype, "currentLabel");
|
|
185
|
+
define("ok-language-select", OkLanguageSelect);
|
|
186
|
+
export {
|
|
187
|
+
OkLanguageSelect
|
|
188
|
+
};
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { LitElement, css, render, nothing, html } from "lit";
|
|
2
|
+
import { property, state } 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
|
+
const DEFAULT_LABELS = {
|
|
14
|
+
prev: "Previous",
|
|
15
|
+
next: "Next",
|
|
16
|
+
close: "Close",
|
|
17
|
+
download: "Download",
|
|
18
|
+
fullscreen: "Fullscreen"
|
|
19
|
+
};
|
|
20
|
+
class OkLightbox extends LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.items = [];
|
|
24
|
+
this.index = 0;
|
|
25
|
+
this.open = false;
|
|
26
|
+
this.labels = {};
|
|
27
|
+
this.shown = false;
|
|
28
|
+
this.portalRoot = null;
|
|
29
|
+
this.onKeydown = (e) => {
|
|
30
|
+
if (!this.open) return;
|
|
31
|
+
if (e.key === "Escape") {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
this.requestClose();
|
|
34
|
+
} else if (e.key === "ArrowLeft") {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
this.go(-1);
|
|
37
|
+
} else if (e.key === "ArrowRight") {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
this.go(1);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
static {
|
|
44
|
+
this.styles = css`
|
|
45
|
+
:host {
|
|
46
|
+
display: block;
|
|
47
|
+
width: 100%;
|
|
48
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex/literal. */
|
|
49
|
+
--overlay-bg: var(--ok-media-bg, rgba(0, 0, 0, 0.92));
|
|
50
|
+
--fg-soft: var(--ok-media-fg, rgba(255, 255, 255, 0.7));
|
|
51
|
+
--glass: var(--ok-overlay-glass, rgba(255, 255, 255, 0.1));
|
|
52
|
+
--glass-hover: var(--ok-overlay-glass-2, rgba(255, 255, 255, 0.18));
|
|
53
|
+
--brand: var(--ok-primary, var(--ion-color-primary, #e8552a));
|
|
54
|
+
--media-bg: var(--ok-media-frame, rgba(255, 255, 255, 0.06));
|
|
55
|
+
--radius-lg: var(--ok-radius-lg, 10px);
|
|
56
|
+
--radius-sm: var(--ok-radius-sm, 6px);
|
|
57
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
58
|
+
--font-mono: var(--ok-font-mono, ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Overlay a pantalla completa: columna [cabecera | medio | filmstrip]. */
|
|
62
|
+
.lightbox {
|
|
63
|
+
position: fixed;
|
|
64
|
+
inset: 0;
|
|
65
|
+
z-index: 1000;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
padding: 20px;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
background: var(--overlay-bg);
|
|
71
|
+
color: var(--fg-soft);
|
|
72
|
+
font-family: var(--font);
|
|
73
|
+
opacity: 0;
|
|
74
|
+
transition: opacity var(--ok-transition, 200ms ease);
|
|
75
|
+
}
|
|
76
|
+
.lightbox.shown {
|
|
77
|
+
opacity: 1;
|
|
78
|
+
}
|
|
79
|
+
@media (prefers-reduced-motion: reduce) {
|
|
80
|
+
.lightbox {
|
|
81
|
+
transition: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Cabecera mono: contador + nombre a la izquierda; acciones a la derecha. */
|
|
86
|
+
.head {
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: space-between;
|
|
89
|
+
align-items: center;
|
|
90
|
+
gap: 12px;
|
|
91
|
+
font-family: var(--font-mono);
|
|
92
|
+
font-size: 12px;
|
|
93
|
+
color: var(--fg-soft);
|
|
94
|
+
}
|
|
95
|
+
.head .meta {
|
|
96
|
+
min-width: 0;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
}
|
|
101
|
+
.head .count {
|
|
102
|
+
font-variant-numeric: tabular-nums;
|
|
103
|
+
}
|
|
104
|
+
.head .sep {
|
|
105
|
+
opacity: 0.5;
|
|
106
|
+
margin: 0 6px;
|
|
107
|
+
}
|
|
108
|
+
.head .actions {
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
gap: 4px;
|
|
112
|
+
flex: none;
|
|
113
|
+
}
|
|
114
|
+
.icon-btn {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
width: 36px;
|
|
119
|
+
height: 36px;
|
|
120
|
+
padding: 0;
|
|
121
|
+
border: 0;
|
|
122
|
+
border-radius: 50%;
|
|
123
|
+
background: transparent;
|
|
124
|
+
color: var(--fg-soft);
|
|
125
|
+
cursor: pointer;
|
|
126
|
+
text-decoration: none;
|
|
127
|
+
transition: background var(--ok-transition, 150ms ease), color var(--ok-transition, 150ms ease);
|
|
128
|
+
}
|
|
129
|
+
@media (hover: hover) {
|
|
130
|
+
.icon-btn:hover {
|
|
131
|
+
background: var(--glass);
|
|
132
|
+
color: #fff;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
.icon-btn ion-icon {
|
|
136
|
+
font-size: 1.25rem;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Zona central: medio centrado con flechas de navegación absolutas. */
|
|
140
|
+
.main {
|
|
141
|
+
flex: 1;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
padding: 16px 0;
|
|
146
|
+
position: relative;
|
|
147
|
+
min-height: 0;
|
|
148
|
+
}
|
|
149
|
+
.media {
|
|
150
|
+
max-width: 60%;
|
|
151
|
+
max-height: 100%;
|
|
152
|
+
width: auto;
|
|
153
|
+
object-fit: contain;
|
|
154
|
+
background: var(--media-bg);
|
|
155
|
+
border-radius: var(--radius-lg);
|
|
156
|
+
display: block;
|
|
157
|
+
}
|
|
158
|
+
/* Reserva de proporción 16:10 cuando no hay medio o como marco de fondo. */
|
|
159
|
+
.media-empty {
|
|
160
|
+
width: 60%;
|
|
161
|
+
aspect-ratio: 16 / 10;
|
|
162
|
+
max-height: 100%;
|
|
163
|
+
background: var(--media-bg);
|
|
164
|
+
border-radius: var(--radius-lg);
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
font-family: var(--font-mono);
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
color: var(--fg-soft);
|
|
171
|
+
}
|
|
172
|
+
video.media {
|
|
173
|
+
max-height: 100%;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Navegación circular glass de 44px. */
|
|
177
|
+
.nav {
|
|
178
|
+
position: absolute;
|
|
179
|
+
top: 50%;
|
|
180
|
+
transform: translateY(-50%);
|
|
181
|
+
width: 44px;
|
|
182
|
+
height: 44px;
|
|
183
|
+
border-radius: 50%;
|
|
184
|
+
border: 0;
|
|
185
|
+
background: var(--glass);
|
|
186
|
+
color: #fff;
|
|
187
|
+
display: inline-flex;
|
|
188
|
+
align-items: center;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
backdrop-filter: blur(4px);
|
|
192
|
+
transition: background var(--ok-transition, 150ms ease), opacity var(--ok-transition, 150ms ease);
|
|
193
|
+
}
|
|
194
|
+
@media (hover: hover) {
|
|
195
|
+
.nav:hover {
|
|
196
|
+
background: var(--glass-hover);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
.nav[disabled] {
|
|
200
|
+
opacity: 0.25;
|
|
201
|
+
cursor: default;
|
|
202
|
+
pointer-events: none;
|
|
203
|
+
}
|
|
204
|
+
.nav ion-icon {
|
|
205
|
+
font-size: 1.5rem;
|
|
206
|
+
}
|
|
207
|
+
.nav.prev {
|
|
208
|
+
left: 20px;
|
|
209
|
+
}
|
|
210
|
+
.nav.next {
|
|
211
|
+
right: 20px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* Filmstrip inferior: miniaturas 50×36, la activa a opacidad total con outline de marca. */
|
|
215
|
+
.strip {
|
|
216
|
+
display: flex;
|
|
217
|
+
gap: 6px;
|
|
218
|
+
justify-content: center;
|
|
219
|
+
flex-wrap: wrap;
|
|
220
|
+
padding-top: 12px;
|
|
221
|
+
max-height: 96px;
|
|
222
|
+
overflow-x: auto;
|
|
223
|
+
overflow-y: hidden;
|
|
224
|
+
}
|
|
225
|
+
.thumb {
|
|
226
|
+
flex: none;
|
|
227
|
+
width: 50px;
|
|
228
|
+
height: 36px;
|
|
229
|
+
padding: 0;
|
|
230
|
+
border: 0;
|
|
231
|
+
border-radius: var(--radius-sm);
|
|
232
|
+
background: var(--media-bg);
|
|
233
|
+
background-size: cover;
|
|
234
|
+
background-position: center;
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
opacity: 0.5;
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
transition: opacity var(--ok-transition, 150ms ease);
|
|
239
|
+
}
|
|
240
|
+
@media (hover: hover) {
|
|
241
|
+
.thumb:hover {
|
|
242
|
+
opacity: 0.8;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
.thumb.active {
|
|
246
|
+
opacity: 1;
|
|
247
|
+
outline: 2px solid var(--brand);
|
|
248
|
+
outline-offset: 2px;
|
|
249
|
+
}
|
|
250
|
+
.thumb img {
|
|
251
|
+
width: 100%;
|
|
252
|
+
height: 100%;
|
|
253
|
+
object-fit: cover;
|
|
254
|
+
display: block;
|
|
255
|
+
}
|
|
256
|
+
.thumb .vid {
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
262
|
+
color: var(--fg-soft);
|
|
263
|
+
}
|
|
264
|
+
.thumb .vid ion-icon {
|
|
265
|
+
font-size: 1rem;
|
|
266
|
+
}
|
|
267
|
+
`;
|
|
268
|
+
}
|
|
269
|
+
// Textos efectivos: defaults en inglés + overrides del consumidor.
|
|
270
|
+
get t() {
|
|
271
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
272
|
+
}
|
|
273
|
+
disconnectedCallback() {
|
|
274
|
+
super.disconnectedCallback();
|
|
275
|
+
this.unbind();
|
|
276
|
+
const host = this.portalRoot?.host;
|
|
277
|
+
this.portalRoot = null;
|
|
278
|
+
if (host && host.parentNode) host.parentNode.removeChild(host);
|
|
279
|
+
}
|
|
280
|
+
bind() {
|
|
281
|
+
document.addEventListener("keydown", this.onKeydown);
|
|
282
|
+
}
|
|
283
|
+
unbind() {
|
|
284
|
+
document.removeEventListener("keydown", this.onKeydown);
|
|
285
|
+
}
|
|
286
|
+
// Crea (una vez) el portal: un div en `document.body` con shadow propio que ADOPTA la misma hoja
|
|
287
|
+
// de estilos del componente.
|
|
288
|
+
ensurePortal() {
|
|
289
|
+
if (this.portalRoot) return this.portalRoot;
|
|
290
|
+
const host = document.createElement("div");
|
|
291
|
+
host.setAttribute("data-ok-lightbox-portal", "");
|
|
292
|
+
document.body.appendChild(host);
|
|
293
|
+
const root = host.attachShadow({ mode: "open" });
|
|
294
|
+
const styles = this.constructor.elementStyles ?? [];
|
|
295
|
+
root.adoptedStyleSheets = styles.map((s) => s instanceof CSSStyleSheet ? s : s.styleSheet).filter((s) => !!s);
|
|
296
|
+
this.portalRoot = root;
|
|
297
|
+
return root;
|
|
298
|
+
}
|
|
299
|
+
updated(changed) {
|
|
300
|
+
if (changed.has("open")) {
|
|
301
|
+
if (this.open) {
|
|
302
|
+
this.bind();
|
|
303
|
+
requestAnimationFrame(() => requestAnimationFrame(() => this.shown = true));
|
|
304
|
+
} else {
|
|
305
|
+
this.unbind();
|
|
306
|
+
this.shown = false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (!this.open && !this.portalRoot) return;
|
|
310
|
+
render(this.open ? this.overlayTemplate() : nothing, this.ensurePortal());
|
|
311
|
+
}
|
|
312
|
+
// Índice saneado dentro de los límites.
|
|
313
|
+
get safeIndex() {
|
|
314
|
+
const n = this.items.length;
|
|
315
|
+
if (n === 0) return 0;
|
|
316
|
+
return Math.max(0, Math.min(this.index, n - 1));
|
|
317
|
+
}
|
|
318
|
+
prefersReducedMotion() {
|
|
319
|
+
return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
|
320
|
+
}
|
|
321
|
+
// Navega delta posiciones (clamp, sin wrap). Emite `ok-index` si cambia.
|
|
322
|
+
go(delta) {
|
|
323
|
+
const next = this.safeIndex + delta;
|
|
324
|
+
if (next < 0 || next >= this.items.length || next === this.safeIndex) return;
|
|
325
|
+
this.setIndex(next);
|
|
326
|
+
}
|
|
327
|
+
setIndex(i) {
|
|
328
|
+
if (i === this.safeIndex) return;
|
|
329
|
+
this.index = i;
|
|
330
|
+
this.dispatchEvent(
|
|
331
|
+
new CustomEvent("ok-index", { detail: { index: i }, bubbles: true, composed: true })
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
// Pide cerrar: anima el fade-out y al terminar emite `ok-close` (el consumidor pone `open=false`).
|
|
335
|
+
requestClose() {
|
|
336
|
+
this.unbind();
|
|
337
|
+
this.shown = false;
|
|
338
|
+
const box = this.portalRoot?.querySelector(".lightbox");
|
|
339
|
+
const finish = () => {
|
|
340
|
+
this.dispatchEvent(new CustomEvent("ok-close", { bubbles: true, composed: true }));
|
|
341
|
+
};
|
|
342
|
+
if (box && !this.prefersReducedMotion()) {
|
|
343
|
+
box.addEventListener("transitionend", finish, { once: true });
|
|
344
|
+
} else {
|
|
345
|
+
finish();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// Nombre de fichero mostrado en la cabecera (alt o último segmento de la URL).
|
|
349
|
+
fileName(item) {
|
|
350
|
+
if (!item) return "";
|
|
351
|
+
if (item.alt) return item.alt;
|
|
352
|
+
try {
|
|
353
|
+
const path = item.src.split(/[?#]/)[0];
|
|
354
|
+
return path.substring(path.lastIndexOf("/") + 1) || item.src;
|
|
355
|
+
} catch {
|
|
356
|
+
return item.src;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
render() {
|
|
360
|
+
return nothing;
|
|
361
|
+
}
|
|
362
|
+
// Overlay (cabecera + medio + filmstrip). Se renderiza en el portal de `document.body`.
|
|
363
|
+
overlayTemplate() {
|
|
364
|
+
const items = this.items;
|
|
365
|
+
const i = this.safeIndex;
|
|
366
|
+
const current = items[i];
|
|
367
|
+
const isVideo = current?.type === "video";
|
|
368
|
+
const name = this.fileName(current);
|
|
369
|
+
const total = items.length;
|
|
370
|
+
return html`
|
|
371
|
+
<div
|
|
372
|
+
class="lightbox ${this.shown ? "shown" : ""}"
|
|
373
|
+
role="dialog"
|
|
374
|
+
aria-modal="true"
|
|
375
|
+
aria-label=${name}
|
|
376
|
+
>
|
|
377
|
+
<div class="head">
|
|
378
|
+
<div class="meta">
|
|
379
|
+
<span class="count">${total ? i + 1 : 0} / ${total}</span>
|
|
380
|
+
${name ? html`<span class="sep">·</span><span>${name}</span>` : null}
|
|
381
|
+
</div>
|
|
382
|
+
<div class="actions">
|
|
383
|
+
${current ? html`<a
|
|
384
|
+
class="icon-btn"
|
|
385
|
+
href=${current.src}
|
|
386
|
+
download
|
|
387
|
+
target="_blank"
|
|
388
|
+
rel="noopener"
|
|
389
|
+
aria-label=${this.t.download}
|
|
390
|
+
>
|
|
391
|
+
<ion-icon name="download-outline"></ion-icon>
|
|
392
|
+
</a>` : null}
|
|
393
|
+
<button
|
|
394
|
+
type="button"
|
|
395
|
+
class="icon-btn"
|
|
396
|
+
aria-label=${this.t.fullscreen}
|
|
397
|
+
@click=${() => this.toggleFullscreen()}
|
|
398
|
+
>
|
|
399
|
+
<ion-icon name="expand-outline"></ion-icon>
|
|
400
|
+
</button>
|
|
401
|
+
<button
|
|
402
|
+
type="button"
|
|
403
|
+
class="icon-btn"
|
|
404
|
+
aria-label=${this.t.close}
|
|
405
|
+
@click=${() => this.requestClose()}
|
|
406
|
+
>
|
|
407
|
+
<ion-icon name="close-outline"></ion-icon>
|
|
408
|
+
</button>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
|
|
412
|
+
<div class="main">
|
|
413
|
+
<button
|
|
414
|
+
type="button"
|
|
415
|
+
class="nav prev"
|
|
416
|
+
aria-label=${this.t.prev}
|
|
417
|
+
?disabled=${i <= 0}
|
|
418
|
+
@click=${() => this.go(-1)}
|
|
419
|
+
>
|
|
420
|
+
<ion-icon name="chevron-back-outline"></ion-icon>
|
|
421
|
+
</button>
|
|
422
|
+
|
|
423
|
+
${current ? isVideo ? html`<video
|
|
424
|
+
class="media"
|
|
425
|
+
src=${current.src}
|
|
426
|
+
controls
|
|
427
|
+
playsinline
|
|
428
|
+
aria-label=${name}
|
|
429
|
+
></video>` : html`<img class="media" src=${current.src} alt=${name} />` : html`<div class="media-empty"></div>`}
|
|
430
|
+
|
|
431
|
+
<button
|
|
432
|
+
type="button"
|
|
433
|
+
class="nav next"
|
|
434
|
+
aria-label=${this.t.next}
|
|
435
|
+
?disabled=${i >= total - 1}
|
|
436
|
+
@click=${() => this.go(1)}
|
|
437
|
+
>
|
|
438
|
+
<ion-icon name="chevron-forward-outline"></ion-icon>
|
|
439
|
+
</button>
|
|
440
|
+
</div>
|
|
441
|
+
|
|
442
|
+
${total > 1 ? html`<div class="strip" role="tablist">
|
|
443
|
+
${items.map((it, idx) => this.renderThumb(it, idx, idx === i))}
|
|
444
|
+
</div>` : null}
|
|
445
|
+
</div>
|
|
446
|
+
`;
|
|
447
|
+
}
|
|
448
|
+
renderThumb(item, idx, active) {
|
|
449
|
+
const isVideo = item.type === "video";
|
|
450
|
+
return html`<button
|
|
451
|
+
type="button"
|
|
452
|
+
class="thumb ${active ? "active" : ""}"
|
|
453
|
+
role="tab"
|
|
454
|
+
aria-selected=${active ? "true" : "false"}
|
|
455
|
+
aria-label=${this.fileName(item)}
|
|
456
|
+
@click=${() => this.setIndex(idx)}
|
|
457
|
+
>
|
|
458
|
+
${isVideo ? html`<span class="vid"><ion-icon name="play-outline"></ion-icon></span>` : html`<img src=${item.thumb ?? item.src} alt="" loading="lazy" />`}
|
|
459
|
+
</button>`;
|
|
460
|
+
}
|
|
461
|
+
// Pantalla completa nativa sobre el overlay portado (con fallback silencioso si no se concede).
|
|
462
|
+
toggleFullscreen() {
|
|
463
|
+
const box = this.portalRoot?.querySelector(".lightbox");
|
|
464
|
+
if (!box) return;
|
|
465
|
+
if (document.fullscreenElement) {
|
|
466
|
+
void document.exitFullscreen?.();
|
|
467
|
+
} else {
|
|
468
|
+
void box.requestFullscreen?.().catch(() => void 0);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
__decorateClass([
|
|
473
|
+
property({ attribute: false })
|
|
474
|
+
], OkLightbox.prototype, "items");
|
|
475
|
+
__decorateClass([
|
|
476
|
+
property({ type: Number })
|
|
477
|
+
], OkLightbox.prototype, "index");
|
|
478
|
+
__decorateClass([
|
|
479
|
+
property({ type: Boolean })
|
|
480
|
+
], OkLightbox.prototype, "open");
|
|
481
|
+
__decorateClass([
|
|
482
|
+
property({ attribute: false })
|
|
483
|
+
], OkLightbox.prototype, "labels");
|
|
484
|
+
__decorateClass([
|
|
485
|
+
state()
|
|
486
|
+
], OkLightbox.prototype, "shown");
|
|
487
|
+
define("ok-lightbox", OkLightbox);
|
|
488
|
+
export {
|
|
489
|
+
OkLightbox
|
|
490
|
+
};
|