@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
package/dist/ok-otp.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { property, query } 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
|
+
digitLabel: (index, length) => `Digit ${index} of ${length}`
|
|
15
|
+
};
|
|
16
|
+
class OkOtp extends LitElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.length = 6;
|
|
20
|
+
this.value = "";
|
|
21
|
+
this.labels = {};
|
|
22
|
+
}
|
|
23
|
+
static {
|
|
24
|
+
this.styles = css`
|
|
25
|
+
:host {
|
|
26
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
27
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
28
|
+
--background: var(--ok-surface, var(--ion-background-color, #ffffff));
|
|
29
|
+
--border-color: var(--ok-border, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.25));
|
|
30
|
+
--border-color-focus: var(--ok-primary, var(--ion-color-primary, #3880ff));
|
|
31
|
+
--border-radius: var(--ok-radius, 8px);
|
|
32
|
+
--gap: var(--ok-otp-gap, 0.5rem);
|
|
33
|
+
--size: var(--ok-otp-size, 3rem);
|
|
34
|
+
--font: var(--ok-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
|
35
|
+
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: var(--gap);
|
|
40
|
+
}
|
|
41
|
+
input {
|
|
42
|
+
width: var(--size);
|
|
43
|
+
height: var(--size);
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
text-align: center;
|
|
46
|
+
font-family: var(--font);
|
|
47
|
+
font-size: calc(var(--size) * 0.45);
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
color: var(--color);
|
|
50
|
+
background: var(--background);
|
|
51
|
+
border: 1px solid var(--border-color);
|
|
52
|
+
border-radius: var(--border-radius);
|
|
53
|
+
outline: none;
|
|
54
|
+
transition: border-color 0.15s ease, box-shadow 0.15s ease;
|
|
55
|
+
-moz-appearance: textfield;
|
|
56
|
+
}
|
|
57
|
+
input::-webkit-outer-spin-button,
|
|
58
|
+
input::-webkit-inner-spin-button {
|
|
59
|
+
-webkit-appearance: none;
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
input:focus {
|
|
63
|
+
border-color: var(--border-color-focus);
|
|
64
|
+
box-shadow: 0 0 0 2px rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.2);
|
|
65
|
+
}
|
|
66
|
+
input:disabled {
|
|
67
|
+
opacity: 0.5;
|
|
68
|
+
cursor: not-allowed;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
// Textos efectivos: defaults en inglés + overrides del consumidor.
|
|
73
|
+
get t() {
|
|
74
|
+
return { ...DEFAULT_LABELS, ...this.labels };
|
|
75
|
+
}
|
|
76
|
+
// Devuelve los inputs del shadow en orden.
|
|
77
|
+
get inputs() {
|
|
78
|
+
return Array.from(this.renderRoot.querySelectorAll("input"));
|
|
79
|
+
}
|
|
80
|
+
// Pone el foco en una casilla por índice (si existe) y selecciona su contenido.
|
|
81
|
+
focusAt(index) {
|
|
82
|
+
const el = this.inputs[index];
|
|
83
|
+
if (el) {
|
|
84
|
+
el.focus();
|
|
85
|
+
el.select();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Reconstruye `value` desde el contenido de las casillas y emite eventos.
|
|
89
|
+
syncFromInputs() {
|
|
90
|
+
const digits = this.inputs.map((el) => el.value).join("");
|
|
91
|
+
this.value = digits;
|
|
92
|
+
this.dispatchEvent(
|
|
93
|
+
new CustomEvent("ok-change", {
|
|
94
|
+
detail: { value: digits },
|
|
95
|
+
bubbles: true,
|
|
96
|
+
composed: true
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
if (digits.length === this.length && /^\d+$/.test(digits)) {
|
|
100
|
+
this.dispatchEvent(
|
|
101
|
+
new CustomEvent("ok-complete", {
|
|
102
|
+
detail: { value: digits },
|
|
103
|
+
bubbles: true,
|
|
104
|
+
composed: true
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Teclear en una casilla: solo dígitos, fuerza un único carácter y auto-avanza.
|
|
110
|
+
onInput(e, index) {
|
|
111
|
+
const el = e.target;
|
|
112
|
+
const cleaned = el.value.replace(/\D/g, "");
|
|
113
|
+
if (cleaned.length > 1) {
|
|
114
|
+
this.distribute(cleaned, index);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
el.value = cleaned;
|
|
118
|
+
if (cleaned) this.focusAt(index + 1);
|
|
119
|
+
this.syncFromInputs();
|
|
120
|
+
}
|
|
121
|
+
// Backspace en casilla vacía → retrocede y borra la anterior.
|
|
122
|
+
onKeydown(e, index) {
|
|
123
|
+
const el = e.target;
|
|
124
|
+
if (e.key === "Backspace" && !el.value && index > 0) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
const prev = this.inputs[index - 1];
|
|
127
|
+
if (prev) {
|
|
128
|
+
prev.value = "";
|
|
129
|
+
this.focusAt(index - 1);
|
|
130
|
+
this.syncFromInputs();
|
|
131
|
+
}
|
|
132
|
+
} else if (e.key === "ArrowLeft") {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
this.focusAt(index - 1);
|
|
135
|
+
} else if (e.key === "ArrowRight") {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
this.focusAt(index + 1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Pegar: reparte los dígitos del portapapeles desde la casilla `start`.
|
|
141
|
+
onPaste(e, start) {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const text = (e.clipboardData?.getData("text") ?? "").replace(/\D/g, "");
|
|
144
|
+
if (text) this.distribute(text, start);
|
|
145
|
+
}
|
|
146
|
+
// Reparte una cadena de dígitos por las casillas a partir de `start`.
|
|
147
|
+
distribute(digits, start) {
|
|
148
|
+
const inputs = this.inputs;
|
|
149
|
+
let i = start;
|
|
150
|
+
for (const ch of digits) {
|
|
151
|
+
if (i >= inputs.length) break;
|
|
152
|
+
inputs[i].value = ch;
|
|
153
|
+
i++;
|
|
154
|
+
}
|
|
155
|
+
this.focusAt(Math.min(i, inputs.length - 1));
|
|
156
|
+
this.syncFromInputs();
|
|
157
|
+
}
|
|
158
|
+
// Sincroniza las casillas con `value` cuando cambia desde fuera.
|
|
159
|
+
digitAt(index) {
|
|
160
|
+
return this.value[index] ?? "";
|
|
161
|
+
}
|
|
162
|
+
// Tras renderizar, asegura que el foco inicial sea cómodo si está vacío (no fuerza foco).
|
|
163
|
+
firstUpdated() {
|
|
164
|
+
void this.firstInput;
|
|
165
|
+
}
|
|
166
|
+
render() {
|
|
167
|
+
const slots = Array.from({ length: Math.max(0, this.length) }, (_, i) => i);
|
|
168
|
+
return html`${slots.map(
|
|
169
|
+
(i) => html`<input
|
|
170
|
+
type="text"
|
|
171
|
+
inputmode="numeric"
|
|
172
|
+
autocomplete="one-time-code"
|
|
173
|
+
maxlength="1"
|
|
174
|
+
aria-label=${this.t.digitLabel(i + 1, this.length)}
|
|
175
|
+
.value=${this.digitAt(i)}
|
|
176
|
+
@input=${(e) => this.onInput(e, i)}
|
|
177
|
+
@keydown=${(e) => this.onKeydown(e, i)}
|
|
178
|
+
@paste=${(e) => this.onPaste(e, i)}
|
|
179
|
+
@focus=${(e) => e.target.select()}
|
|
180
|
+
/>`
|
|
181
|
+
)}`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
__decorateClass([
|
|
185
|
+
property({ type: Number })
|
|
186
|
+
], OkOtp.prototype, "length");
|
|
187
|
+
__decorateClass([
|
|
188
|
+
property({ type: String })
|
|
189
|
+
], OkOtp.prototype, "value");
|
|
190
|
+
__decorateClass([
|
|
191
|
+
property({ attribute: false })
|
|
192
|
+
], OkOtp.prototype, "labels");
|
|
193
|
+
__decorateClass([
|
|
194
|
+
query("input")
|
|
195
|
+
], OkOtp.prototype, "firstInput");
|
|
196
|
+
define("ok-otp", OkOtp);
|
|
197
|
+
export {
|
|
198
|
+
OkOtp
|
|
199
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
class OkPageHeader extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.heading = "";
|
|
17
|
+
this.level = 1;
|
|
18
|
+
this.compact = false;
|
|
19
|
+
this.hasBreadcrumbs = false;
|
|
20
|
+
this.hasMeta = false;
|
|
21
|
+
this.hasActions = false;
|
|
22
|
+
this.hasExtra = false;
|
|
23
|
+
}
|
|
24
|
+
static {
|
|
25
|
+
this.styles = css`
|
|
26
|
+
:host {
|
|
27
|
+
/* Vars overridable (estilo Ionic), default = cadena --ok-* → --ion-* → hex */
|
|
28
|
+
--color: var(--ok-text, var(--ion-text-color, #1c1b17));
|
|
29
|
+
--color-muted: var(--ok-text-muted, rgba(var(--ion-text-color-rgb, 28, 27, 23), 0.6));
|
|
30
|
+
--spacing: var(--ok-spacing, 1rem);
|
|
31
|
+
|
|
32
|
+
/* Bloque a ancho completo del contenedor, sin fondo propio. */
|
|
33
|
+
display: block;
|
|
34
|
+
width: 100%;
|
|
35
|
+
color: var(--color);
|
|
36
|
+
padding-block: var(--spacing);
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
}
|
|
39
|
+
:host([compact]) {
|
|
40
|
+
padding-block: calc(var(--spacing) * 0.5);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Breadcrumbs encima del título (hueco para ion-breadcrumbs). */
|
|
44
|
+
.crumbs {
|
|
45
|
+
margin-bottom: calc(var(--spacing) * 0.5);
|
|
46
|
+
}
|
|
47
|
+
.crumbs.empty {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Fila principal: texto a la izquierda, acciones a la derecha. */
|
|
52
|
+
.row {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: flex-start;
|
|
55
|
+
justify-content: space-between;
|
|
56
|
+
gap: var(--spacing);
|
|
57
|
+
flex-wrap: wrap;
|
|
58
|
+
}
|
|
59
|
+
.text {
|
|
60
|
+
flex: 1 1 24rem;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.heading {
|
|
65
|
+
margin: 0;
|
|
66
|
+
font-size: 1.65rem;
|
|
67
|
+
font-weight: 700;
|
|
68
|
+
line-height: 1.2;
|
|
69
|
+
letter-spacing: -0.015em;
|
|
70
|
+
overflow-wrap: break-word;
|
|
71
|
+
}
|
|
72
|
+
/* Sub-página (level=2) y variante compacta: título algo menor. */
|
|
73
|
+
.heading.h2,
|
|
74
|
+
:host([compact]) .heading {
|
|
75
|
+
font-size: 1.3rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.description {
|
|
79
|
+
margin: 0.35rem 0 0;
|
|
80
|
+
font-size: 0.95rem;
|
|
81
|
+
color: var(--color-muted);
|
|
82
|
+
max-width: 70ch;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Línea de metadatos (fechas, ids…) bajo el título/descipción. */
|
|
86
|
+
.meta {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
flex-wrap: wrap;
|
|
90
|
+
gap: 0.35rem 1rem;
|
|
91
|
+
margin-top: 0.45rem;
|
|
92
|
+
font-size: 0.85rem;
|
|
93
|
+
color: var(--color-muted);
|
|
94
|
+
}
|
|
95
|
+
.meta.empty {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Acciones a la derecha (ion-button); en móvil bajan debajo del título. */
|
|
100
|
+
.actions {
|
|
101
|
+
flex: 0 0 auto;
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
flex-wrap: wrap;
|
|
105
|
+
gap: 0.5rem;
|
|
106
|
+
}
|
|
107
|
+
.actions.empty {
|
|
108
|
+
display: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Contenido extra bajo la descripción (chips de filtros, pills…). */
|
|
112
|
+
.extra {
|
|
113
|
+
margin-top: calc(var(--spacing) * 0.75);
|
|
114
|
+
}
|
|
115
|
+
.extra.empty {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* < 640px: stack vertical (acciones bajo el título, ancho completo). */
|
|
120
|
+
@media (max-width: 640px) {
|
|
121
|
+
.row {
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
align-items: stretch;
|
|
124
|
+
}
|
|
125
|
+
.actions {
|
|
126
|
+
justify-content: flex-start;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
// slotchange genérico → actualiza el flag del slot correspondiente.
|
|
132
|
+
onSlotChange(e) {
|
|
133
|
+
const slot = e.target;
|
|
134
|
+
const has = slot.assignedNodes({ flatten: true }).some(
|
|
135
|
+
(n) => n.nodeType === Node.ELEMENT_NODE || (n.textContent ?? "").trim().length > 0
|
|
136
|
+
);
|
|
137
|
+
switch (slot.name) {
|
|
138
|
+
case "breadcrumbs":
|
|
139
|
+
this.hasBreadcrumbs = has;
|
|
140
|
+
break;
|
|
141
|
+
case "meta":
|
|
142
|
+
this.hasMeta = has;
|
|
143
|
+
break;
|
|
144
|
+
case "actions":
|
|
145
|
+
this.hasActions = has;
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
this.hasExtra = has;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
render() {
|
|
152
|
+
const onSlot = (e) => this.onSlotChange(e);
|
|
153
|
+
return html`
|
|
154
|
+
<div class=${this.hasBreadcrumbs ? "crumbs" : "crumbs empty"}>
|
|
155
|
+
<slot name="breadcrumbs" @slotchange=${onSlot}></slot>
|
|
156
|
+
</div>
|
|
157
|
+
<div class="row">
|
|
158
|
+
<div class="text">
|
|
159
|
+
${this.level === 2 ? html`<h2 class="heading h2">${this.heading}</h2>` : html`<h1 class="heading">${this.heading}</h1>`}
|
|
160
|
+
${this.description ? html`<p class="description">${this.description}</p>` : ""}
|
|
161
|
+
<div class=${this.hasMeta ? "meta" : "meta empty"}>
|
|
162
|
+
<slot name="meta" @slotchange=${onSlot}></slot>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class=${this.hasActions ? "actions" : "actions empty"}>
|
|
166
|
+
<slot name="actions" @slotchange=${onSlot}></slot>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
<div class=${this.hasExtra ? "extra" : "extra empty"}>
|
|
170
|
+
<slot @slotchange=${onSlot}></slot>
|
|
171
|
+
</div>
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
__decorateClass([
|
|
176
|
+
property()
|
|
177
|
+
], OkPageHeader.prototype, "heading");
|
|
178
|
+
__decorateClass([
|
|
179
|
+
property({ type: Number })
|
|
180
|
+
], OkPageHeader.prototype, "level");
|
|
181
|
+
__decorateClass([
|
|
182
|
+
property()
|
|
183
|
+
], OkPageHeader.prototype, "description");
|
|
184
|
+
__decorateClass([
|
|
185
|
+
property({ type: Boolean, reflect: true })
|
|
186
|
+
], OkPageHeader.prototype, "compact");
|
|
187
|
+
__decorateClass([
|
|
188
|
+
state()
|
|
189
|
+
], OkPageHeader.prototype, "hasBreadcrumbs");
|
|
190
|
+
__decorateClass([
|
|
191
|
+
state()
|
|
192
|
+
], OkPageHeader.prototype, "hasMeta");
|
|
193
|
+
__decorateClass([
|
|
194
|
+
state()
|
|
195
|
+
], OkPageHeader.prototype, "hasActions");
|
|
196
|
+
__decorateClass([
|
|
197
|
+
state()
|
|
198
|
+
], OkPageHeader.prototype, "hasExtra");
|
|
199
|
+
define("ok-page-header", OkPageHeader);
|
|
200
|
+
export {
|
|
201
|
+
OkPageHeader
|
|
202
|
+
};
|